Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sepolia support for Polygon cross-chain #751

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cross-chain/polygon/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
!/deployments/mainnet/
!/deployments/polygon/
!/deployments/mumbai/
!/deployments/amoy/

# OZ
/.openzeppelin/unknown-*.json
5 changes: 3 additions & 2 deletions cross-chain/polygon/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,7 +42,8 @@ yarn deploy --network <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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/polygon/deploy_sidechain/02_verify_polygon_tbtc_token.ts

View workflow job for this annotation

GitHub Actions / contracts-format

Unexpected unnamed async function
const { deployments } = hre

const proxyDeployment = await deployments.get("PolygonTBTC")
Expand All @@ -12,7 +12,7 @@
// 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/polygon/deploy_sidechain/04_verify_polygon_wormhole_gateway.ts

View workflow job for this annotation

GitHub Actions / contracts-format

Unexpected unnamed async function
const { deployments } = hre

const proxyDeployment = await deployments.get("PolygonWormholeGateway")
Expand All @@ -12,7 +12,7 @@
// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions cross-chain/polygon/external/amoy/SolanaWormholeGateway.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b"
}
3 changes: 3 additions & 0 deletions cross-chain/polygon/external/sepolia/TokenBridge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0xDB5492265f6038831E89f495670FF909aDe94bd9"
}
49 changes: 49 additions & 0 deletions cross-chain/polygon/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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",
},
Expand Down
1 change: 1 addition & 0 deletions cross-chain/polygon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading