forked from gnosischain/tokenbridge-contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
797c5ae
commit 29d807c
Showing
6 changed files
with
447 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
DEPLOYER_PRIV_KEY= | ||
|
||
SEPOLIA_RPC_URL= | ||
CHIADO_RPC_URL="https://rpc.chiadochain.net" | ||
MAINNET_RPC_URL= | ||
GNOSIS_RPC_URL="https://rpc.gnosischain.com" | ||
|
||
ETHERSCAN_API_KEY="" | ||
BLOCKSCOUT_API_KEY="" | ||
GNOSISSCAN_API_KEY="" | ||
|
||
FOREIGN_CHAIN_ID=1 | ||
HOME_CHAIN_ID=100 | ||
|
||
FOREIGN_AMB=0x4C36d2919e407f0Cc2Ee3c993ccF8ac26d9CE64e | ||
FOREIGN_HASHI_MANAGER_AMB= | ||
FOREIGN_HASHI_MANAGER_XDAI= | ||
|
||
FOREIGN_YAHO=0xbAE4Ebbf42815BB9Bc3720267Ea4496277d60DB8 | ||
FOREIGN_YARU=0x30f64a297cc66a873FB603d1e89D5891962C25ba | ||
FOREIGN_XDAI=0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016 | ||
|
||
HOME_YAHO=0xbAE4Ebbf42815BB9Bc3720267Ea4496277d60DB8 | ||
HOME_YARU=0x153801d0B85D2FCAc6EA07446b6A709ce6720AC5 | ||
HOME_HASHI_MANAGER_AMB= | ||
HOME_HASHI_MANAGER_XDAI= | ||
HOME_XDAI=0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6 | ||
HOME_AMB=0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
require('@nomicfoundation/hardhat-toolbox') | ||
Check failure on line 1 in hardhat.config.js
|
||
require('@openzeppelin/hardhat-upgrades') | ||
Check failure on line 2 in hardhat.config.js
|
||
|
||
require('dotenv').config() | ||
Check failure on line 4 in hardhat.config.js
|
||
require('./tasks/deployAMB') | ||
require('./tasks/deloyXDAI') | ||
|
||
module.exports = { | ||
networks: { | ||
fgnosis: { | ||
url: 'http://127.0.0.1:8544', | ||
}, | ||
fmainnet: { | ||
url: 'http://127.0.0.1:8545', | ||
}, | ||
sepolia: { | ||
url: process.env.SEPOLIA_RPC_URL, | ||
accounts: [process.env.DEPLOYER_PRIV_KEY], | ||
}, | ||
chiado: { | ||
url: 'https://rpc.chiadochain.net', | ||
accounts: [process.env.DEPLOYER_PRIV_KEY], | ||
}, | ||
mainnet: { | ||
url: process.env.MAINNET_RPC_URL, | ||
accounts: [process.env.DEPLOYER_PRIV_KEY], | ||
}, | ||
gnosis: { | ||
url: 'https://rpc.gnosischain.com', | ||
accounts: [process.env.DEPLOYER_PRIV_KEY], | ||
}, | ||
xdai: { | ||
// use --network xdai to verify on blockscout | ||
url: 'https://rpc.gnosischain.com', | ||
accounts: [process.env.DEPLOYER_PRIV_KEY], | ||
}, | ||
}, | ||
|
||
etherscan: { | ||
apiKey: { | ||
sepolia: process.env.ETHERSCAN_API_KEY, | ||
chiado: process.env.BLOCKSCOUT_API_KEY, | ||
gnosis: process.env.GNOSISSCAN_API_KEY, | ||
xdai: process.env.BLOCKSCOUT_API_KEY, // use --network xdai to verify on blockscout | ||
mainnet: process.env.ETHERSCAN_API_KEY, | ||
}, | ||
customChains: [ | ||
{ | ||
network: 'xdai', | ||
chainId: 100, | ||
urls: { | ||
apiURL: 'https://gnosis.blockscout.com//api', | ||
browserURL: 'https://gnosis.blockscout.com/', | ||
}, | ||
}, | ||
{ | ||
network: 'chiado', | ||
chainId: 10200, | ||
urls: { | ||
apiURL: 'https://gnosis-chiado.blockscout.com/api', | ||
browserURL: 'https://gnosis-chiado.blockscout.com/', | ||
}, | ||
}, | ||
], | ||
}, | ||
path: { | ||
source: 'contracts', | ||
scripts: 'hardhat-deploy', | ||
}, | ||
solidity: { | ||
compilers: [ | ||
{ | ||
version: '0.4.24', | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 100, // NOTE: change to 100 when using HomeBridgeErcToNative | ||
}, | ||
evmVersion: 'byzantium', | ||
}, | ||
}, | ||
{ | ||
version: '0.8.20', | ||
settings: { | ||
viaIR: true, | ||
optimizer: { | ||
enabled: true, | ||
runs: 10000, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
const { task } = require('hardhat/config') | ||
const verify = require('./verify') | ||
require('dotenv').config() | ||
|
||
task('deploy:ForeignxDAIBridge') | ||
.addFlag('verify') | ||
.setAction(async (_taskArgs, hre) => { | ||
const [owner] = await hre.ethers.getSigners() | ||
let ProxyFactory = await hre.ethers.getContractFactory('EternalStorageProxy') | ||
let ForeignxDAIBridgeFactory = await hre.ethers.getContractFactory('XDaiForeignBridge') | ||
let HashiManagerFactory = await hre.ethers.getContractFactory('HashiManager') | ||
|
||
console.log('Deploying Foreign xDAI bridge implementation...') | ||
let ForeignxDAIBridge = await ForeignxDAIBridgeFactory.deploy() | ||
await ForeignxDAIBridge.deploymentTransaction().wait() | ||
const ForeignxDAIBridgeAddress = await ForeignxDAIBridge.getAddress() | ||
console.log('Foreign xDAI bridge deployed to ', ForeignxDAIBridgeAddress) | ||
|
||
let ForeignHashiManagerProxy | ||
let ForeignHashiManager | ||
|
||
if (!process.env.FOREIGN_HASHI_MANAGER_XDAI) { | ||
console.log('Deploying Hashi Manager....') | ||
ForeignHashiManagerProxy = await ProxyFactory.deploy() | ||
await ForeignHashiManagerProxy.deploymentTransaction().wait() | ||
ForeignHashiManager = await HashiManagerFactory.deploy() | ||
|
||
await ForeignHashiManager.deploymentTransaction().wait() | ||
console.log('Hashi Manager deployed to', await ForeignHashiManagerProxy.getAddress()) | ||
|
||
console.log('Upgrading Foreign Hashi Manager Proxy...') | ||
let hashiManagerUpgradeTx = await ForeignHashiManagerProxy.connect(owner).upgradeTo( | ||
'1', | ||
await ForeignHashiManager.getAddress() | ||
) | ||
await hashiManagerUpgradeTx.wait() | ||
console.log(`Foreign Hashi Manager upgrade Tx ${hashiManagerUpgradeTx.hash}`) | ||
ForeignHashiManager = ForeignHashiManager.attach(await ForeignHashiManagerProxy.getAddress()) | ||
|
||
console.log('Configuring Hashi Manager...') | ||
let setHashiOwner = await ForeignHashiManager.initialize(owner.address) | ||
await setHashiOwner.wait() | ||
console.log(`Hashi Owner set: ${setHashiOwner.hash}`) | ||
|
||
let setHashiTargetChainIDTx = await ForeignHashiManager.connect(owner).setTargetChainId(process.env.HOME_CHAIN_ID) | ||
await setHashiTargetChainIDTx.wait() | ||
console.log(`Target ChainID set to ${process.env.HOME_CHAIN_ID}: ${setHashiTargetChainIDTx.hash}`) | ||
|
||
let setTargetAddress = await ForeignHashiManager.connect(owner).setTargetAddress(process.env.HOME_XDAI) | ||
await setTargetAddress.wait() | ||
console.log(`Target Address set: ${setTargetAddress.hash}`) | ||
|
||
let setYahoTx = await ForeignHashiManager.connect(owner).setYaho(process.env.FOREIGN_YAHO) | ||
await setYahoTx.wait() | ||
console.log(`Yaho set: ${setYahoTx.hash}`) | ||
|
||
let setYaruTx = await ForeignHashiManager.connect(owner).setYaru(process.env.FOREIGN_YARU) | ||
await setYaruTx.wait() | ||
console.log(`Yaru set: ${setYaruTx.hash}`) | ||
} | ||
|
||
if (_taskArgs.verify) { | ||
console.log('Verifying contracts....') | ||
|
||
await verify(hre, ForeignxDAIBridgeAddress, []) | ||
if (!process.env.FOREIGN_HASHI_MANAGER_XDAI) { | ||
await verify(hre, await ForeignHashiManagerProxy.getAddress(), []) | ||
await verify(hre, await ForeignHashiManager.getAddress(), []) | ||
} | ||
} | ||
console.log('Foreign xDAI bridge deployment done') | ||
}) | ||
|
||
task('deploy:HomexDAIBridge') | ||
.addFlag('verify') | ||
.setAction(async (_taskArgs, hre) => { | ||
const [owner] = await hre.ethers.getSigners() | ||
let ProxyFactory = await hre.ethers.getContractFactory('EternalStorageProxy') | ||
|
||
let HomexDAIFactory = await hre.ethers.getContractFactory('HomeBridgeErcToNative') | ||
let HashiManagerFactory = await hre.ethers.getContractFactory('HashiManager') | ||
let HomeHashiManagerProxy | ||
let HomeHashiManager | ||
|
||
console.log('Deploying Home xDAI bridge implementation...') | ||
let HomexDAI = await HomexDAIFactory.deploy() | ||
await HomexDAI.deploymentTransaction().wait() | ||
const HomexDAIAddress = await HomexDAI.getAddress() | ||
|
||
console.log('Home xDAI bridge deployed to ', HomexDAIAddress) | ||
|
||
if (!process.env.HOME_HASHI_MANAGER_XDAI) { | ||
console.log('Deploying Hashi Manager....') | ||
HomeHashiManagerProxy = await ProxyFactory.deploy() | ||
await HomeHashiManagerProxy.deploymentTransaction().wait() | ||
|
||
HomeHashiManager = await HashiManagerFactory.deploy() | ||
await HomeHashiManager.deploymentTransaction().wait() | ||
|
||
console.log(`Home Hashi Manager deployed to ${await HomeHashiManagerProxy.getAddress()}`) | ||
|
||
console.log('Upgrading Home Hashi Manager Proxy...') | ||
let hashiManagerUpgradeTx = await HomeHashiManagerProxy.connect(owner).upgradeTo( | ||
'1', | ||
await HomeHashiManager.getAddress() | ||
) | ||
await hashiManagerUpgradeTx.wait() | ||
console.log(`Hashi Manager upgrade Tx ${hashiManagerUpgradeTx.hash}`) | ||
HomeHashiManager = HomeHashiManager.attach(await HomeHashiManagerProxy.getAddress()) | ||
|
||
if (_taskArgs.verify) { | ||
console.log('Verifying contracts...') | ||
|
||
await verify(hre, HomexDAIAddress, []) | ||
if (!process.env.HOME_HASHI_MANAGER_XDAI) { | ||
await verify(hre, await HomeHashiManagerProxy.getAddress(), []) | ||
await verify(hre, await HomeHashiManager.getAddress(), []) | ||
} | ||
} | ||
|
||
let setHashiOwner = await HomeHashiManager.initialize(owner.address) | ||
await setHashiOwner.wait() | ||
console.log(`Hashi Manager Owner set: ${setHashiOwner.hash}`) | ||
|
||
let setHashiTargetChainIDTx = await HomeHashiManager.connect(owner).setTargetChainId(process.env.FOREIGN_CHAIN_ID) | ||
await setHashiTargetChainIDTx.wait() | ||
console.log(`Target ChainID set to ${process.env.FOREIGN_CHAIN_ID}: ${setHashiTargetChainIDTx.hash}`) | ||
|
||
let setYahoTx = await HomeHashiManager.connect(owner).setYaho(process.env.HOME_YAHO) | ||
await setYahoTx.wait() | ||
console.log(`Yaho set: ${setYahoTx.hash}`) | ||
|
||
let setYaruTx = await HomeHashiManager.connect(owner).setYaru(process.env.HOME_YARU) | ||
await setYaruTx.wait() | ||
console.log(`Yaru set: ${setYaruTx.hash}`) | ||
|
||
let setTargetAddress = await HomeHashiManager.connect(owner).setTargetAddress(process.env.FOREIGN_XDAI) | ||
await setTargetAddress.wait() | ||
console.log(`Target Address set: ${setTargetAddress.hash}`) | ||
} | ||
console.log('Home xDAI bridge deployment done') | ||
}) |
Oops, something went wrong.