-
Notifications
You must be signed in to change notification settings - Fork 3
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
d514a14
commit cdeea53
Showing
1 changed file
with
216 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,216 @@ | ||
const { | ||
txTask, | ||
loadSignerSync, | ||
etherscanVerify, | ||
} = require('../../helpers/tasks'); | ||
const { getEthersProvider } = require('../../helpers/utils'); | ||
const { | ||
getDeployedContractInstance, | ||
readDeploymentData, | ||
writeDeploymentData, | ||
writeBulkDeploymentData, | ||
getCompiledContractFactory, | ||
} = require('../../helpers/contracts'); | ||
|
||
const { | ||
deployArbitrumBaseChainGatewayContracts, | ||
deployArbitrumSatelliteChainGatewayContracts, | ||
} = require('../../helpers/deploy'); | ||
|
||
txTask( | ||
'deploy:arbitrum_base_chain', | ||
'Deploys the chain gateway on the base chain', | ||
).setAction(async (args, hre) => { | ||
const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit }; | ||
if (txParams.gasPrice == 0) { | ||
txParams.gasPrice = await hre.ethers.provider.getGasPrice(); | ||
} | ||
const deployer = loadSignerSync(args, hre.ethers.provider); | ||
const deployerAddress = await deployer.getAddress(); | ||
const chainAddresses = await readDeploymentData(hre.network.name); | ||
|
||
console.log('------------------------------------------------------------'); | ||
console.log('Deploying contracts on base-chain'); | ||
console.log('Deployer:', deployerAddress); | ||
console.log(txParams); | ||
|
||
const ampl = await getDeployedContractInstance( | ||
hre.network.name, | ||
'ampl', | ||
hre.ethers.provider, | ||
); | ||
|
||
const policy = await getDeployedContractInstance( | ||
hre.network.name, | ||
'policy', | ||
hre.ethers.provider, | ||
); | ||
|
||
const tokenVault = await getDeployedContractInstance( | ||
hre.network.name, | ||
'arbitrum/tokenVault', | ||
hre.ethers.provider, | ||
); | ||
|
||
const { gateway } = await deployArbitrumBaseChainGatewayContracts( | ||
{ | ||
ampl, | ||
policy, | ||
tokenVault, | ||
}, | ||
hre.ethers, | ||
deployer, | ||
txParams, | ||
5, | ||
); | ||
|
||
console.log('------------------------------------------------------------'); | ||
console.log('Writing data to file'); | ||
await writeDeploymentData( | ||
hre.network.name, | ||
'arbitrum/transferGateway', | ||
gateway, | ||
); | ||
await writeDeploymentData( | ||
hre.network.name, | ||
'arbitrum/rebaseGateway', | ||
gateway, | ||
); | ||
|
||
console.log('------------------------------------------------------------'); | ||
console.log('Verify on etherscan'); | ||
await etherscanVerify(hre, gateway.address, [ | ||
ampl.address, | ||
policy.address, | ||
tokenVault.address, | ||
]); | ||
}); | ||
|
||
txTask( | ||
'deploy:arbitrum_satellite_chain', | ||
'Deploys the chain gateway contract and connects it with arbitrum bridge and the cross-chain ample token', | ||
).setAction(async (args, hre) => { | ||
// NOTE: gas estimation is off on arbitrum | ||
// const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit }; | ||
// if (txParams.gasPrice == 0) { | ||
// txParams.gasPrice = await hre.ethers.provider.getGasPrice(); | ||
// } | ||
const txParams = {}; | ||
const deployer = loadSignerSync(args, hre.ethers.provider); | ||
const deployerAddress = await deployer.getAddress(); | ||
const chainAddresses = await readDeploymentData(hre.network.name); | ||
|
||
console.log('------------------------------------------------------------'); | ||
console.log('Deploying contracts on satellite-chain'); | ||
console.log('Deployer:', deployerAddress); | ||
console.log(txParams); | ||
|
||
const xcAmple = await getDeployedContractInstance( | ||
hre.network.name, | ||
'xcAmple', | ||
hre.ethers.provider, | ||
); | ||
|
||
const xcAmpleController = await getDeployedContractInstance( | ||
hre.network.name, | ||
'xcAmpleController', | ||
hre.ethers.provider, | ||
); | ||
|
||
const { gateway } = await deployArbitrumSatelliteChainGatewayContracts( | ||
{ xcAmple, xcAmpleController }, | ||
hre.ethers, | ||
deployer, | ||
txParams, | ||
5, | ||
); | ||
|
||
console.log('------------------------------------------------------------'); | ||
console.log('Writing data to file'); | ||
await writeDeploymentData( | ||
hre.network.name, | ||
'arbitrum/transferGateway', | ||
gateway, | ||
); | ||
await writeDeploymentData( | ||
hre.network.name, | ||
'arbitrum/rebaseGateway', | ||
gateway, | ||
); | ||
|
||
console.log('------------------------------------------------------------'); | ||
console.log('Verify on etherscan'); | ||
await etherscanVerify(hre, gateway.address, [ | ||
xcAmple.address, | ||
xcAmpleController.address, | ||
]); | ||
}); | ||
|
||
txTask('deploy:arbitrum_connection', 'Connects the two gateway contracts') | ||
.addParam('baseChainNetwork', 'The network name of the base chain network') | ||
.addParam( | ||
'satChainNetwork', | ||
'The network name of the satellite chain network', | ||
) | ||
.addParam('baseInbox', 'The address of the arbitrum inbox on the base chain') | ||
.addParam( | ||
'baseRouter', | ||
'The address of the arbitrum router contract on the base chain', | ||
) | ||
.addParam( | ||
'satRouter', | ||
'The address of the arbitrum router contract on the satellite chain', | ||
) | ||
.setAction(async (args, hre) => { | ||
const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit }; | ||
if (txParams.gasPrice == 0) { | ||
txParams.gasPrice = await hre.ethers.provider.getGasPrice(); | ||
} | ||
|
||
const baseChainProvider = getEthersProvider(args.baseChainNetwork); | ||
const satChainProvider = getEthersProvider(args.satChainNetwork); | ||
|
||
const baseChainSigner = loadSignerSync(args, baseChainProvider); | ||
const satChainSigner = loadSignerSync(args, satChainProvider); | ||
|
||
const baseGateway = await getDeployedContractInstance( | ||
args.baseChainNetwork, | ||
'arbitrum/rebaseGateway', | ||
baseChainProvider, | ||
); | ||
const ampl = await getDeployedContractInstance( | ||
args.baseChainNetwork, | ||
'ampl', | ||
baseChainProvider, | ||
); | ||
|
||
const satGateway = await getDeployedContractInstance( | ||
args.satChainNetwork, | ||
'arbitrum/rebaseGateway', | ||
satChainProvider, | ||
); | ||
const xcAmple = await getDeployedContractInstance( | ||
args.satChainNetwork, | ||
'xcAmple', | ||
satChainProvider, | ||
); | ||
|
||
await ( | ||
await baseGateway | ||
.connect(baseChainSigner) | ||
.initialize( | ||
args.baseInbox, | ||
args.baseRouter, | ||
xcAmple.address, | ||
satGateway.address, | ||
txParams, | ||
) | ||
).wait(2); | ||
|
||
// NOTE: gas estimation is off on arbitrum | ||
await ( | ||
await satGateway | ||
.connect(satChainSigner) | ||
.initialize(args.satRouter, ampl.address, baseGateway.address, {}) | ||
).wait(2); | ||
}); |