Skip to content

Commit

Permalink
Pass the name and symbol to the Linked NFT
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetson committed Nov 30, 2023
1 parent 01913f1 commit 60cad7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/hardhat/contracts/LinkedNft.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract LinkedNft is ERC721URIStorage {
address public registrar;
address public source;

constructor(address _source, string memory _name, string memory _symbol) ERC721(_name, _symbol) {
constructor(address _source, string memory _name, string memory _symbol) ERC721(string.concat("Linked ", _name), string.concat("l", _symbol)) {
registrar = msg.sender;
source = _source;
}
Expand Down
17 changes: 10 additions & 7 deletions packages/hardhat/contracts/Registrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ contract Registrar is Ownable, CCIPReceiver {
require(deployTx == 0, "todo: Fetch from chainlink function the creator");
}

address wrappedNft = calculateAddress(block.chainid, nftAddr);
address wrappedNft = address(new WrappedNft{salt: generateSalt(address(this), nftAddr)}(nftAddr));

// First let's deploy the wrappedNft
// Deploy the wrapped nft.
Expand All @@ -125,7 +125,8 @@ contract Registrar is Ownable, CCIPReceiver {

// args = block.chainid, nftAddr, wrappedNft, nftSupportedChains
// todo make sure to re-calculate the wrapped nft in the destination.
bytes memory data = abi.encodeWithSignature("xSetup(address,address,uint256[])", nftAddr, wrappedNft, nftSupportedChains[nftAddr]);
bytes memory data = abi.encodeWithSignature("xSetup(address,address,uint256[],string memory,string memory)",
nftAddr, wrappedNft, nftSupportedChains[nftAddr], WrappedNft(wrappedNft).originalName(), WrappedNft(wrappedNft).originalSymbol());
uint256 totalFee = 0;
uint256[] memory fees = new uint256[](chainIds.length);
Client.EVM2AnyMessage[] memory messages = new Client.EVM2AnyMessage[](chainIds.length);
Expand Down Expand Up @@ -158,9 +159,6 @@ contract Registrar is Ownable, CCIPReceiver {

emit X_Setup(chainIds[i], nftAddr, messageId);
}

address deployedWrappedNft = address(new WrappedNft{salt: generateSalt(address(this), nftAddr)}(nftAddr));
require(deployedWrappedNft == wrappedNft, "mismatch");
}

// If your NFT wants to support new chains, call this.
Expand Down Expand Up @@ -213,7 +211,12 @@ contract Registrar is Ownable, CCIPReceiver {
require(success);
}

function xSetup(address nftAddr, address wrappedNft, uint256[] calldata chainIds) private {
function xSetup(
address nftAddr,
address wrappedNft, uint256[] calldata chainIds,
string memory name,
string memory symbol
) private {
wrappedNft = calculateAddress(tempChainId, nftAddr);

// First let's deploy the wrappedNft
Expand All @@ -230,7 +233,7 @@ contract Registrar is Ownable, CCIPReceiver {
nftSupportedChains[nftAddr].push(chainIds[i]);

if (chainIds[i] == block.chainid) {
deployedAddr = address(new LinkedNft{salt: generateSalt(address(this), nftAddr)}(nftAddr, "", ""));
deployedAddr = address(new LinkedNft{salt: generateSalt(address(this), nftAddr)}(nftAddr, name, symbol));
require(deployedAddr == linkedNfts[chainIds[i]][nftAddr], "mismatch");
}
}
Expand Down

0 comments on commit 60cad7e

Please sign in to comment.