diff --git a/cross-chain/polygon/.gitignore b/cross-chain/polygon/.gitignore index ae6c3fbe7..a49706017 100644 --- a/cross-chain/polygon/.gitignore +++ b/cross-chain/polygon/.gitignore @@ -10,6 +10,7 @@ !/deployments/mainnet/ !/deployments/polygon/ !/deployments/mumbai/ +!/deployments/amoy/ # OZ /.openzeppelin/unknown-*.json diff --git a/cross-chain/polygon/README.adoc b/cross-chain/polygon/README.adoc index 8cd49aeb4..ddd2290d1 100644 --- a/cross-chain/polygon/README.adoc +++ b/cross-chain/polygon/README.adoc @@ -27,7 +27,7 @@ Wormhole-specific tBTC representation into the canonical `PolygonTBTC` token. The deployment scripts are responsible for managing updates of the tBTC gateway addresses across various chains. These addresses are stored in the `external/` -directory for a specific network, such as `mumbai/ArbitrumWormholeGateway.json.` +directory for a specific network, such as `amoy/ArbitrumWormholeGateway.json.` It is important to note that these addresses should remain constant for the mainnet network. However, there may be instances where a new version of a cross-chain module is deployed to the testing network, which would require a @@ -42,7 +42,8 @@ yarn deploy --network Supported networks: - `hardhat` - for local development -- `mumbai` - testing network +- `mumbai` - testing network (will become deprecated with the end of 2023) +- `amoy` - testing network - `polygon` - mainnet Currently, this module does not deploy any contracts on L1. All the existing diff --git a/cross-chain/polygon/deploy_sidechain/02_verify_polygon_tbtc_token.ts b/cross-chain/polygon/deploy_sidechain/02_verify_polygon_tbtc_token.ts index d60d94379..93c3b789b 100644 --- a/cross-chain/polygon/deploy_sidechain/02_verify_polygon_tbtc_token.ts +++ b/cross-chain/polygon/deploy_sidechain/02_verify_polygon_tbtc_token.ts @@ -12,7 +12,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // Contracts can be verified on Polygonscan in a similar way as we // do it on L1 Etherscan if (hre.network.tags.polygonscan) { - if (hre.network.name === "mumbai") { + if (hre.network.name === "mumbai" || hre.network.name === "amoy") { // Polygonscan might not include the recently added proxy transaction right // after deployment. We need to wait some time so that transaction is // visible on Polygonscan. diff --git a/cross-chain/polygon/deploy_sidechain/04_verify_polygon_wormhole_gateway.ts b/cross-chain/polygon/deploy_sidechain/04_verify_polygon_wormhole_gateway.ts index 46831f6f6..75e1ee6ce 100644 --- a/cross-chain/polygon/deploy_sidechain/04_verify_polygon_wormhole_gateway.ts +++ b/cross-chain/polygon/deploy_sidechain/04_verify_polygon_wormhole_gateway.ts @@ -12,7 +12,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // Contracts can be verified on Polygonscan in a similar way as we // do it on L1 Etherscan if (hre.network.tags.polygonscan) { - if (hre.network.name === "mumbai") { + if (hre.network.name === "mumbai" || hre.network.name === "amoy") { // Polygonscan might not include the recently added proxy transaction right // after deployment. We need to wait some time so that transaction is // visible on Polygonscan. diff --git a/cross-chain/polygon/deploy_sidechain/12_update_self_in_wormhole_gateway_mapping.ts b/cross-chain/polygon/deploy_sidechain/12_update_self_in_wormhole_gateway_mapping.ts index 4c64dd339..7d6437d00 100644 --- a/cross-chain/polygon/deploy_sidechain/12_update_self_in_wormhole_gateway_mapping.ts +++ b/cross-chain/polygon/deploy_sidechain/12_update_self_in_wormhole_gateway_mapping.ts @@ -8,6 +8,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // See https://book.wormhole.com/reference/contracts.html // This ID is valid for both Polygon Testnet (Mumbai) and Mainnet + // TODO: check ID for the Amoy testnet once it's supported by Wormhole. const wormholeChainID = 5 const polygonWormholeGateway = await deployments.get("PolygonWormholeGateway") diff --git a/cross-chain/polygon/deploy_sidechain/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts b/cross-chain/polygon/deploy_sidechain/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts index 1faf0eb26..6d294dab7 100644 --- a/cross-chain/polygon/deploy_sidechain/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts +++ b/cross-chain/polygon/deploy_sidechain/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts @@ -12,6 +12,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // See https://book.wormhole.com/reference/contracts.html // This ID is valid for both Arbitrum Goerli and Mainnet + // TODO: check if id is correct for Arbitrum Sepolia as well (once Wormhole + // supports that testnet) const arbitrumWormholeChainID = 23 const arbitrumWormholeGateway = await deployments.getOrNull( diff --git a/cross-chain/polygon/deploy_sidechain/14_update_with_optimism_in_wormhole_gateway_mapping.ts b/cross-chain/polygon/deploy_sidechain/14_update_with_optimism_in_wormhole_gateway_mapping.ts index 2bbc986e1..05cfc24bb 100644 --- a/cross-chain/polygon/deploy_sidechain/14_update_with_optimism_in_wormhole_gateway_mapping.ts +++ b/cross-chain/polygon/deploy_sidechain/14_update_with_optimism_in_wormhole_gateway_mapping.ts @@ -12,6 +12,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // See https://book.wormhole.com/reference/contracts.html // This ID is valid for both Optimism Goerli and Mainnet + // TODO: check if id is correct for Optimism Sepolia as well (once Wormhole + // supports that testnet) const optimismWormholeChainID = 24 const optimismWormholeGateway = await deployments.getOrNull( diff --git a/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts b/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts index c0db4cbff..8544ede9e 100644 --- a/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts +++ b/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts @@ -11,6 +11,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base // This ID is valid for both Base Goerli and Mainnet + // TODO: check if id is correct for Base Sepolia as well (once Wormhole + // supports that testnet) const baseWormholeChainID = 30 const baseWormholeGateway = await deployments.getOrNull("BaseWormholeGateway") diff --git a/cross-chain/polygon/deploy_sidechain/32_manual_upgrade_polygon_wormhole_gateway.ts b/cross-chain/polygon/deploy_sidechain/32_manual_upgrade_polygon_wormhole_gateway.ts index d5b381edb..bcd863513 100644 --- a/cross-chain/polygon/deploy_sidechain/32_manual_upgrade_polygon_wormhole_gateway.ts +++ b/cross-chain/polygon/deploy_sidechain/32_manual_upgrade_polygon_wormhole_gateway.ts @@ -57,7 +57,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // Contracts can be verified on L2 Polygonscan in a similar way as we do it on // L1 Etherscan if (hre.network.tags.polygonscan) { - if (hre.network.name === "mumbai") { + if (hre.network.name === "mumbai" || hre.network.name === "amoy") { // Polygonscan might not include the recently added proxy transaction right // after deployment. We need to wait some time so that transaction is // visible on Polygonscan. diff --git a/cross-chain/polygon/external/amoy/SolanaWormholeGateway.json b/cross-chain/polygon/external/amoy/SolanaWormholeGateway.json new file mode 100644 index 000000000..dee25fa3e --- /dev/null +++ b/cross-chain/polygon/external/amoy/SolanaWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" +} diff --git a/cross-chain/polygon/external/sepolia/TokenBridge.json b/cross-chain/polygon/external/sepolia/TokenBridge.json new file mode 100644 index 000000000..c09d6e7c2 --- /dev/null +++ b/cross-chain/polygon/external/sepolia/TokenBridge.json @@ -0,0 +1,3 @@ +{ + "address": "0xDB5492265f6038831E89f495670FF909aDe94bd9" +} diff --git a/cross-chain/polygon/hardhat.config.ts b/cross-chain/polygon/hardhat.config.ts index 77b469ecf..c3789ef45 100644 --- a/cross-chain/polygon/hardhat.config.ts +++ b/cross-chain/polygon/hardhat.config.ts @@ -44,6 +44,15 @@ const config: HardhatUserConfig = { : undefined, tags: ["etherscan"], }, + sepolia: { + url: process.env.PARENTCHAIN_API_URL || "", + chainId: 11155111, + deploy: ["deploy_parentchain"], + accounts: process.env.PARENTCHAIN_ACCOUNTS_PRIVATE_KEYS + ? process.env.PARENTCHAIN_ACCOUNTS_PRIVATE_KEYS.split(",") + : undefined, + tags: ["etherscan"], + }, mainnet: { url: process.env.PARENTCHAIN_API_URL || "", chainId: 1, @@ -65,6 +74,19 @@ const config: HardhatUserConfig = { // parentchain: "goerli", // }, }, + amoy: { + url: process.env.SIDECHAIN_API_URL || "", + chainId: 80002, + deploy: ["deploy_sidechain"], + accounts: process.env.SIDECHAIN_ACCOUNTS_PRIVATE_KEYS + ? process.env.SIDECHAIN_ACCOUNTS_PRIVATE_KEYS.split(",") + : undefined, + // Uncomment once Polygonscan supports Amoy testnet. + // tags: ["polygonscan"], + // companionNetworks: { + // parentchain: "goerli", + // }, + }, polygon: { url: process.env.SIDECHAIN_API_URL || "", chainId: 137, @@ -82,40 +104,67 @@ const config: HardhatUserConfig = { external: { deployments: { goerli: ["./external/goerli"], + sepolia: ["./external/sepolia"], mainnet: ["./external/mainnet"], mumbai: ["./external/mumbai"], + amoy: ["./external/amoy"], polygon: ["./external/polygon"], }, }, deploymentArtifactsExport: { goerli: "artifacts/parentchain", + sepolia: "artifacts/parentchain", mainnet: "artifacts/parentchain", mumbai: "artifacts/sidechain", + amoy: "artifacts/sidechain", polygon: "artifacts/sidechain", }, etherscan: { apiKey: { goerli: process.env.ETHERSCAN_API_KEY, + sepolia: process.env.ETHERSCAN_API_KEY, mainnet: process.env.ETHERSCAN_API_KEY, polygonMumbai: process.env.POLYGONSCAN_API_KEY, + // TODO: uncomment once Amoy testnet is live and supported by Polygonscan. + // polygonAmoy: process.env.POLYGONSCAN_API_KEY, polygon: process.env.POLYGONSCAN_API_KEY, }, + // TODO: Uncomment once Amoy testnet is live and supported by Polygonscan. + // The custom config will not be needed if `polygonAmoy` will be added to + // https://github.com/NomicFoundation/hardhat/blame/main/packages/hardhat-verify/src/internal/chain-config.ts. + // In that case we'll need to update `hardhat-verify` dependency. + // customChains: [ + // { + // networkName: "polygonAmoy", + // chainId: 80002, + // urls: { + // // Check below values in https://docs.polygonscan.com/getting-started/endpoint-urls + // // once Polygonscan supports Amoy testnet. + // apiURL: "https://api-testnet.polygonscan.com/api", + // browserURL: "https://amoy.polygonscan.com/", + // } + // } + // ] }, namedAccounts: { deployer: { default: 1, goerli: 0, + sepolia: 0, mumbai: 0, + amoy: 0, mainnet: "0x123694886DBf5Ac94DDA07135349534536D14cAf", polygon: "0x123694886DBf5Ac94DDA07135349534536D14cAf", }, governance: { default: 2, goerli: 0, + sepolia: 0, mumbai: 0, + amoy: 0, mainnet: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f", polygon: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f", }, diff --git a/cross-chain/polygon/package.json b/cross-chain/polygon/package.json index e815eda85..107ae1259 100644 --- a/cross-chain/polygon/package.json +++ b/cross-chain/polygon/package.json @@ -31,6 +31,7 @@ "lint:config:fix": "prettier --write '**/*.@(json|yaml)'", "prepack": "tsc -p tsconfig.export.json && hardhat export-artifacts export/artifacts", "export-artifacts:goerli": "yarn hardhat export-deployment-artifacts --network mumbai", + "export-artifacts:sepolia": "yarn hardhat export-deployment-artifacts --network amoy", "export-artifacts:mainnet": "yarn hardhat export-deployment-artifacts --network polygon", "prepublishOnly": "npm run export-artifacts:$npm_config_network", "test": "hardhat test"