-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Here we add deployment scripts for both `L*BitcoinDepositor` contracts. We use Base as the reference chain.
- Loading branch information
1 parent
7f81fbe
commit 533e889
Showing
7 changed files
with
195 additions
and
3 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
cross-chain/base/deploy_l1/00_deploy_base_l1_bitcoin_depositor.ts
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,53 @@ | ||
import type { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction } from "hardhat-deploy/types" | ||
import { getWormholeChains } from "../deploy_helpers/wormhole_chains" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { ethers, getNamedAccounts, helpers, deployments } = hre | ||
const { deployer } = await getNamedAccounts() | ||
const l2Deployments = hre.companionNetworks.l2.deployments | ||
|
||
const wormholeChains = getWormholeChains(hre.network.name) | ||
|
||
const tbtcBridge = await deployments.get("Bridge") | ||
const tbtcVault = await deployments.get("TBTCVault") | ||
const wormhole = await deployments.get("Wormhole") | ||
const wormholeRelayer = await deployments.get("WormholeRelayer") | ||
const wormholeTokenBridge = await deployments.get("TokenBridge") | ||
const baseWormholeGateway = await l2Deployments.get("BaseWormholeGateway") | ||
|
||
const [, proxyDeployment] = await helpers.upgrades.deployProxy( | ||
"BaseL1BitcoinDepositor", | ||
{ | ||
contractName: | ||
"@keep-network/tbtc-v2/contracts/l2/L1BitcoinDepositor.sol:L1BitcoinDepositor", | ||
initializerArgs: [ | ||
tbtcBridge.address, | ||
tbtcVault.address, | ||
wormhole.address, | ||
wormholeRelayer.address, | ||
wormholeTokenBridge.address, | ||
baseWormholeGateway.address, | ||
wormholeChains.l2ChainId, | ||
], | ||
factoryOpts: { signer: await ethers.getSigner(deployer) }, | ||
proxyOpts: { | ||
kind: "transparent", | ||
}, | ||
} | ||
) | ||
|
||
if (hre.network.tags.etherscan) { | ||
// We use `verify` instead of `verify:verify` as the `verify` task is defined | ||
// in "@openzeppelin/hardhat-upgrades" to perform Etherscan verification | ||
// of Proxy and Implementation contracts. | ||
await hre.run("verify", { | ||
address: proxyDeployment.address, | ||
constructorArgsParams: proxyDeployment.args, | ||
}) | ||
} | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["BaseL1BitcoinDepositor"] |
25 changes: 25 additions & 0 deletions
25
cross-chain/base/deploy_l1/01_attach_base_l2_bitcoin_depositor.ts
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,25 @@ | ||
import type { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction } from "hardhat-deploy/types" | ||
|
||
const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { | ||
const { deployments, getNamedAccounts } = hre | ||
const { deployer } = await getNamedAccounts() | ||
const { execute } = deployments | ||
const l2Deployments = hre.companionNetworks.l2.deployments | ||
|
||
const baseL2BitcoinDepositor = await l2Deployments.get( | ||
"BaseL2BitcoinDepositor" | ||
) | ||
|
||
await execute( | ||
"BaseL1BitcoinDepositor", | ||
{ from: deployer, log: true, waitConfirmations: 1 }, | ||
"attachL2BitcoinDepositor", | ||
baseL2BitcoinDepositor.address | ||
) | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["AttachBaseL2BitcoinDepositor"] | ||
func.dependencies = ["BaseL1BitcoinDepositor"] |
19 changes: 19 additions & 0 deletions
19
cross-chain/base/deploy_l1/03_transfer_base_l1_bitcoin_depositor_ownership.ts
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,19 @@ | ||
import type { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction } from "hardhat-deploy/types" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { getNamedAccounts, helpers } = hre | ||
const { deployer, governance } = await getNamedAccounts() | ||
|
||
await helpers.ownable.transferOwnership( | ||
"BaseL1BitcoinDepositor", | ||
governance, | ||
deployer | ||
) | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["TransferBaseL1BitcoinDepositorOwnership"] | ||
func.dependencies = ["BaseL1BitcoinDepositor"] | ||
func.runAtTheEnd = true |
48 changes: 48 additions & 0 deletions
48
cross-chain/base/deploy_l2/25_deploy_base_l2_bitcoin_depositor.ts
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,48 @@ | ||
import type { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction } from "hardhat-deploy/types" | ||
import { getWormholeChains } from "../deploy_helpers/wormhole_chains" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { ethers, getNamedAccounts, helpers, deployments } = hre | ||
const { deployer } = await getNamedAccounts() | ||
|
||
const wormholeChains = getWormholeChains(hre.network.name) | ||
|
||
const baseWormholeRelayer = await deployments.get("BaseWormholeRelayer") | ||
const baseWormholeGateway = await deployments.get("BaseWormholeGateway") | ||
|
||
const [, proxyDeployment] = await helpers.upgrades.deployProxy( | ||
"BaseL2BitcoinDepositor", | ||
{ | ||
contractName: | ||
"@keep-network/tbtc-v2/contracts/l2/L2BitcoinDepositor.sol:L2BitcoinDepositor", | ||
initializerArgs: [ | ||
baseWormholeRelayer.address, | ||
baseWormholeGateway.address, | ||
wormholeChains.l1ChainId, | ||
], | ||
factoryOpts: { signer: await ethers.getSigner(deployer) }, | ||
proxyOpts: { | ||
kind: "transparent", | ||
}, | ||
} | ||
) | ||
|
||
// Contracts can be verified on L2 Base Etherscan in a similar way as we | ||
// do it on L1 Etherscan | ||
if (hre.network.tags.basescan) { | ||
// We use `verify` instead of `verify:verify` as the `verify` task is defined | ||
// in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation | ||
// contract, the proxy itself and any proxy-related contracts, as well as | ||
// link the proxy to the implementation contract’s ABI on (Ether)scan. | ||
await hre.run("verify", { | ||
address: proxyDeployment.address, | ||
constructorArgsParams: [], | ||
}) | ||
} | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["BaseL2BitcoinDepositor"] | ||
func.dependencies = ["BaseWormholeGateway"] |
25 changes: 25 additions & 0 deletions
25
cross-chain/base/deploy_l2/26_attach_base_l1_bitcoin_depositor.ts
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,25 @@ | ||
import type { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction } from "hardhat-deploy/types" | ||
|
||
const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { | ||
const { deployments, getNamedAccounts } = hre | ||
const { deployer } = await getNamedAccounts() | ||
const { execute } = deployments | ||
const l1Deployments = hre.companionNetworks.l1.deployments | ||
|
||
const baseL1BitcoinDepositor = await l1Deployments.get( | ||
"BaseL1BitcoinDepositor" | ||
) | ||
|
||
await execute( | ||
"BaseL2BitcoinDepositor", | ||
{ from: deployer, log: true, waitConfirmations: 1 }, | ||
"attachL1BitcoinDepositor", | ||
baseL1BitcoinDepositor.address | ||
) | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["AttachBaseL1BitcoinDepositor"] | ||
func.dependencies = ["BaseL2BitcoinDepositor"] |
19 changes: 19 additions & 0 deletions
19
cross-chain/base/deploy_l2/27_transfer_base_l2_bitcoin_depositor_ownership.ts
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,19 @@ | ||
import type { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction } from "hardhat-deploy/types" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { getNamedAccounts, helpers } = hre | ||
const { deployer, governance } = await getNamedAccounts() | ||
|
||
await helpers.ownable.transferOwnership( | ||
"BaseL2BitcoinDepositor", | ||
governance, | ||
deployer | ||
) | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["TransferBaseL2BitcoinDepositorOwnership"] | ||
func.dependencies = ["BaseL2BitcoinDepositor"] | ||
func.runAtTheEnd = true |
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