From bfcdacd346bab030f2ee378411a7ee4a6a6df4c2 Mon Sep 17 00:00:00 2001 From: Medet Ahmetson Date: Mon, 11 Dec 2023 09:58:25 +0700 Subject: [PATCH] Disable security for the demo --- packages/hardhat/contracts/LinkedFactory.sol | 14 ++++++++++---- packages/hardhat/contracts/LinkedNft.sol | 16 ++++++++-------- packages/hardhat/contracts/Registrar.sol | 2 +- packages/hardhat/contracts/WrappedNft.sol | 12 ++++++------ 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/packages/hardhat/contracts/LinkedFactory.sol b/packages/hardhat/contracts/LinkedFactory.sol index 3145244..d21aa38 100644 --- a/packages/hardhat/contracts/LinkedFactory.sol +++ b/packages/hardhat/contracts/LinkedFactory.sol @@ -73,14 +73,20 @@ contract LinkedFactory is Ownable, CCIPReceiver { destNetworks[_selector].registrar = _registrar; } + function ccipReceive2( + Client.Any2EVMMessage calldata message + ) external { + _ccipReceive(message); + } + function _ccipReceive( Client.Any2EVMMessage memory message ) internal override { - address sourceRegistrar = abi.decode(message.sender, (address)); - require(destNetworks[message.sourceChainSelector].registrar == sourceRegistrar, "not the registrar"); - +// address sourceRegistrar = abi.decode(message.sender, (address)); +// require(destNetworks[message.sourceChainSelector].registrar == sourceRegistrar, "not the registrar"); (bool success, ) = address(this).call(message.data); - require(success); +// require(success); + emit Received(message.sender, message.messageId, message.sourceChainSelector); } function xSetup( diff --git a/packages/hardhat/contracts/LinkedNft.sol b/packages/hardhat/contracts/LinkedNft.sol index d444cbc..5287f23 100644 --- a/packages/hardhat/contracts/LinkedNft.sol +++ b/packages/hardhat/contracts/LinkedNft.sol @@ -30,18 +30,18 @@ contract LinkedNft is ERC721URIStorage, CCIPReceiver { event X_Bridge(uint64 destSelector, uint256 nftId, address owner, bytes32 messageId); modifier nftOwner(uint256 nftId) { - require(ownerOf(nftId) == msg.sender, "not owner"); + //require(_ownerOf(nftId) == msg.sender, "not owner"); _; } modifier onlyFactory() { - require(msg.sender == address(factory)); + //require(msg.sender == address(factory)); _; } modifier onlyFactoryOrSource() { - if (msg.sender != address(factory)) { + /*if (msg.sender != address(factory)) { require(sender != address(0), "not from ccip"); bool found = false; for (uint256 i = 0; i < nftSupportedChains.length; i++) { @@ -51,24 +51,24 @@ contract LinkedNft is ERC721URIStorage, CCIPReceiver { } } require(found, "not source"); - } + }*/ _; } modifier onlySource() { - bool found = false; + /*bool found = false; for (uint256 i = 0; i < nftSupportedChains.length; i++) { if (linkedNfts[nftSupportedChains[i]] == sender) { found = true; break; } } - require(found, "not source"); + require(found, "not source");*/ _; } modifier validDestination(uint64 _selector) { - require(selector != _selector, "to itself"); + /*require(selector != _selector, "to itself"); bool found = false; for (uint256 i = 0; i < nftSupportedChains.length; i++) { if (nftSupportedChains[i] == _selector) { @@ -76,7 +76,7 @@ contract LinkedNft is ERC721URIStorage, CCIPReceiver { break; } } - require(found, "unsupported network"); + require(found, "unsupported network");*/ _; } diff --git a/packages/hardhat/contracts/Registrar.sol b/packages/hardhat/contracts/Registrar.sol index 366fad1..25d824f 100644 --- a/packages/hardhat/contracts/Registrar.sol +++ b/packages/hardhat/contracts/Registrar.sol @@ -47,7 +47,7 @@ contract Registrar is Ownable { event Linked(address originalAddr, address nftAddress); modifier onlyNftAdmin(address nftAddr) { - require(msg.sender == nftAdmin[nftAddr], "not admin"); + //require(msg.sender == nftAdmin[nftAddr], "not admin"); _; } diff --git a/packages/hardhat/contracts/WrappedNft.sol b/packages/hardhat/contracts/WrappedNft.sol index fe7d390..b986f58 100644 --- a/packages/hardhat/contracts/WrappedNft.sol +++ b/packages/hardhat/contracts/WrappedNft.sol @@ -27,13 +27,13 @@ contract WrappedNft is ERC721URIStorage, IERC721Receiver, CCIPReceiver { event X_SetupOne(uint64 selector, address nftAddress, bytes32 messageId); modifier nftOwner(uint256 nftId) { - require(originalNft.ownerOf(nftId) == msg.sender, "not owner"); - require(originalNft.isApprovedForAll(msg.sender, address(this)), "wrapping has no permission"); + /*require(originalNft.ownerOf(nftId) == msg.sender, "not owner"); + require(originalNft.isApprovedForAll(msg.sender, address(this)), "wrapping has no permission");*/ _; } modifier onlySource { - require(sender != address(0), "not from ccip"); + /*require(sender != address(0), "not from ccip"); bool found = false; for (uint256 i = 0; i < nftSupportedChains.length; i++) { if (linkedNfts[nftSupportedChains[i]] == sender) { @@ -41,18 +41,18 @@ contract WrappedNft is ERC721URIStorage, IERC721Receiver, CCIPReceiver { break; } } - require(found, "not source"); + require(found, "not source");*/ _; } modifier onlyFactory() { - require(msg.sender == registrar); +// require(msg.sender == registrar); _; } modifier validDestination(uint64 _selector) { - require(linkedNfts[_selector] != address(0), "not linked"); +// require(linkedNfts[_selector] != address(0), "not linked"); _; }