Skip to content

Commit

Permalink
Redeploy all
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetson committed Dec 4, 2023
1 parent 1689f5f commit b6f7872
Show file tree
Hide file tree
Showing 14 changed files with 4,436 additions and 1,713 deletions.
3 changes: 3 additions & 0 deletions packages/hardhat/contracts/LinkedFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ contract LinkedFactory is Ownable, CCIPReceiver {
// selector => Network Param
mapping(uint64 => Network) public destNetworks;

mapping(address => address) public linkedAddrs; // no need to pre-compute everytime

uint64 private tempChainId;

event X_Setup(uint64 selector, address nftAddress, bytes32 messageId);
Expand Down Expand Up @@ -97,6 +99,7 @@ contract LinkedFactory is Ownable, CCIPReceiver {
// so let's keep the order in all blockchains.
linkedNft.setup(selectors, linkedNftAddrs);
linkedNft.setupOne(networkSelector, address(linkedNft));
linkedAddrs[nftAddr] = address(linkedNft);

emit Linked(nftAddr, address(linkedNft));
} catch Error(string memory reason) {
Expand Down
8 changes: 4 additions & 4 deletions packages/hardhat/contracts/Registrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract Registrar is Ownable {
mapping(uint64 => Network) public destNetworks;
// original nft => owner|creator
mapping(address => address) public nftAdmin;
mapping(address => address) public wrappers; // no need to pre-compute everytime
mapping(address => address) public linkedAddrs; // no need to pre-compute everytime

uint64 private tempChainId;

Expand Down Expand Up @@ -105,7 +105,7 @@ contract Registrar is Ownable {
created.setupOne(networkSelector);

nftAdmin[nftAddr] = msg.sender;
wrappers[nftAddr] = address(created);
linkedAddrs[nftAddr] = address(created);
}

/** Setup a linked NFT for `nftAddr` on another blockchain defined by `destSelector`.
Expand All @@ -122,7 +122,7 @@ contract Registrar is Ownable {
require(factory != address(0), "no factory");

// add to the wrappedNft the selectors.
WrappedNft wrappedNft = WrappedNft(wrappers[nftAddr]);
WrappedNft wrappedNft = WrappedNft(linkedAddrs[nftAddr]);
require(wrappedNft.linkedNfts(destSelector) == address(0), "already linked");

uint256 remaining = createLinkedNft(nftAddr, destSelector);
Expand All @@ -144,7 +144,7 @@ contract Registrar is Ownable {
/// @param nftAddr the original NFT address
/// @return the native token that user can retrieve back
function createLinkedNft(address nftAddr, uint64 destSelector) internal returns (uint256) {
WrappedNft wrappedNft = WrappedNft(wrappers[nftAddr]);
WrappedNft wrappedNft = WrappedNft(linkedAddrs[nftAddr]);
// The created nft will be linked to all previous nfts that we have.
(uint64[] memory selectors, address[] memory linkedNftAddrs) = wrappedNft.allNfts();

Expand Down
11 changes: 0 additions & 11 deletions packages/hardhat/contracts/WrappedNft.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,12 @@ import { IRouterClient } from "./chainlink/ccip/interfaces/IRouterClient.sol";
import { Client } from "./chainlink/ccip/libraries/Client.sol";
import { CCIPReceiver } from "./chainlink/ccip/applications/CCIPReceiver.sol";

/**
* @notice WrappedNft is an NFT on the Source Blockchain, which locks the original NFT, and disables transferring it.
* When an NFT is wrapped, the Listening oracles would mint the copy on target Blockchain.
*
* todo Unwrapping Wrapped NFTs is not possible in this version.
*/
contract WrappedNft is ERC721URIStorage, IERC721Receiver, CCIPReceiver {
ERC721 public originalNft;

address public registrar;
address public router;

// track routers and selectors of dest blockchains.

// The linked nft addresses across blockchains.
// For this blockchain it creates a wrapped NFT.
//
// chain id => linked nft|wrapped nft.
uint64[] public nftSupportedChains;
mapping(uint64 => address) public linkedNfts;
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/deploy/01_deploy_registrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const registrarContract: DeployFunction = async function (hre: HardhatRuntimeEnv

const chainId = await hre.getChainId();

const deployments = Deployments[chainId][0];
const deployments = Deployments[chainId as keyof typeof Deployments][0];
const sourceLib: string = deployments.contracts["SourceNftLib"].address;

const networkParams = one(chainId);
Expand Down
86 changes: 17 additions & 69 deletions packages/hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ const config: HardhatUserConfig = {
},
},
networks: {
// View the networks that are pre-configured.
// If the network you are looking for is not here you can add new network settings
hardhat: {
forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${providerApiKey}`,
enabled: process.env.MAINNET_FORKING_ENABLED === "true",
},
},
mainnet: {
url: `https://eth-mainnet.alchemyapi.io/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
Expand All @@ -52,26 +44,6 @@ const config: HardhatUserConfig = {
url: `https://ethereum-sepolia.publicnode.com`,
accounts: [deployerPrivateKey],
},
goerli: {
url: `https://eth-goerli.alchemyapi.io/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
arbitrum: {
url: `https://arb-mainnet.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
arbitrumGoerli: {
url: `https://arb-goerli.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
optimism: {
url: `https://opt-mainnet.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
optimismGoerli: {
url: `https://opt-goerli.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
polygon: {
url: `https://polygon-mainnet.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
Expand All @@ -88,48 +60,12 @@ const config: HardhatUserConfig = {
url: `https://polygonzkevm-testnet.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
zkSyncTestnet: {
url: "https://testnet.era.zksync.dev",
zksync: true,
accounts: [deployerPrivateKey],
verifyURL: "https://zksync2-testnet-explorer.zksync.dev/contract_verification",
},
zkSync: {
url: "https://mainnet.era.zksync.io",
zksync: true,
accounts: [deployerPrivateKey],
verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification",
},
gnosis: {
url: "https://rpc.gnosischain.com",
accounts: [deployerPrivateKey],
},
chiado: {
url: "https://rpc.chiadochain.net",
accounts: [deployerPrivateKey],
},
base: {
url: "https://mainnet.base.org",
accounts: [deployerPrivateKey],
},
baseGoerli: {
url: "https://goerli.base.org",
fuji: {
url: `https://avalanche-fuji-c-chain.publicnode.com`,
accounts: [deployerPrivateKey],
},
scrollSepolia: {
url: "https://sepolia-rpc.scroll.io",
accounts: [deployerPrivateKey],
},
scroll: {
url: "https://rpc.scroll.io",
accounts: [deployerPrivateKey],
},
pgn: {
url: "https://rpc.publicgoods.network",
accounts: [deployerPrivateKey],
},
pgnTestnet: {
url: "https://sepolia.publicgoods.network",
bscTestnet: {
url: `https://bsc-testnet.publicnode.com`,
accounts: [deployerPrivateKey],
},
},
Expand All @@ -142,7 +78,19 @@ const config: HardhatUserConfig = {
apiKey: {
sepolia: etherscanApiKey,
polygonMumbai: process.env.POLYGONSCAN_API_KEY as string,
},
fuji: "fuji",
bscTestnet: process.env.BSCSCAN_API_KEY as string,
},
customChains: [
{
network: "fuji",
chainId: 43113,
urls: {
apiURL: "https://api.routescan.io/v2/network/testnet/evm/43113/etherscan",
browserURL: "https://avalanche.testnet.routescan.io",
},
},
],
},
};

Expand Down
10 changes: 10 additions & 0 deletions packages/hardhat/scripts/constructor/bsctestnet_linkedfactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default [
"0xB8159170038F96FB",
"0x9527e2d01a3064ef6b50c1da1c0cc523803bcff2",
["0xCCF0A31A221F3C9B", "0xADECC60412CE25A5", "0xDE41BA4FC9D91AD9"],
[
"0x554472a2720e5e7d5d3c817529aba05eed5f82d8",
"0x70499c328e1e2a3c41108bd3730f6670a44595d1",
"0xd0daae2231e9cb96b94c8512223533293c3693bf",
],
];
10 changes: 10 additions & 0 deletions packages/hardhat/scripts/constructor/bsctestnet_registrar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default [
"0xB8159170038F96FB",
"0x9527e2d01a3064ef6b50c1da1c0cc523803bcff2",
["0xCCF0A31A221F3C9B", "0xADECC60412CE25A5", "0xDE41BA4FC9D91AD9"],
[
"0x554472a2720e5e7d5d3c817529aba05eed5f82d8",
"0x70499c328e1e2a3c41108bd3730f6670a44595d1",
"0xd0daae2231e9cb96b94c8512223533293c3693bf",
],
];
10 changes: 10 additions & 0 deletions packages/hardhat/scripts/constructor/fuji_registrar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default [
"0xCCF0A31A221F3C9B",
"0x554472a2720e5e7d5d3c817529aba05eed5f82d8",
["0xB8159170038F96FB", "0xADECC60412CE25A5", "0xDE41BA4FC9D91AD9"],
[
"0x9527e2d01a3064ef6b50c1da1c0cc523803bcff2",
"0x70499c328e1e2a3c41108bd3730f6670a44595d1",
"0xd0daae2231e9cb96b94c8512223533293c3693bf",
],
];
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
export default [
"0xADECC60412CE25A5",
"0x70499c328e1e2a3c41108bd3730f6670a44595d1",
["0xB8159170038F96FB", "0xCCF0A31A221F3C9B", "0xADECC60412CE25A5", "0xDE41BA4FC9D91AD9"],
["0xB8159170038F96FB", "0xCCF0A31A221F3C9B", "0xDE41BA4FC9D91AD9"],
[
"0x9527e2d01a3064ef6b50c1da1c0cc523803bcff2",
"0x554472a2720e5e7d5d3c817529aba05eed5f82d8",
"0x70499c328e1e2a3c41108bd3730f6670a44595d1",
"0xd0daae2231e9cb96b94c8512223533293c3693bf",
],
];
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
export default [
"0xDE41BA4FC9D91AD9",
"0xd0daae2231e9cb96b94c8512223533293c3693bf",
["0xB8159170038F96FB", "0xCCF0A31A221F3C9B", "0xADECC60412CE25A5", "0xDE41BA4FC9D91AD9"],
["0xB8159170038F96FB", "0xCCF0A31A221F3C9B", "0xADECC60412CE25A5"],
[
"0x9527e2d01a3064ef6b50c1da1c0cc523803bcff2",
"0x554472a2720e5e7d5d3c817529aba05eed5f82d8",
"0x70499c328e1e2a3c41108bd3730f6670a44595d1",
"0xd0daae2231e9cb96b94c8512223533293c3693bf",
],
];
Loading

0 comments on commit b6f7872

Please sign in to comment.