Skip to content

Commit

Permalink
Disable security for the demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetson committed Dec 11, 2023
1 parent b7a9a0a commit bfcdacd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
14 changes: 10 additions & 4 deletions packages/hardhat/contracts/LinkedFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 8 additions & 8 deletions packages/hardhat/contracts/LinkedNft.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -51,32 +51,32 @@ 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) {
found = true;
break;
}
}
require(found, "unsupported network");
require(found, "unsupported network");*/
_;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/contracts/Registrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
_;
}

Expand Down
12 changes: 6 additions & 6 deletions packages/hardhat/contracts/WrappedNft.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,32 @@ 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) {
found = true;
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");
_;
}

Expand Down

0 comments on commit bfcdacd

Please sign in to comment.