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

Include tBTC reference in the Acre contract deployment scripts #58

Merged
merged 11 commits into from
Dec 7, 2023
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ pnpm-debug.log*
!.vscode/extensions.json
.idea
.DS_Store

# Temporary directory
tmp/
1 change: 1 addition & 0 deletions core/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ cache/
deployments/
export.json
export/
external/
typechain/
9 changes: 8 additions & 1 deletion core/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
"rules": {
"import/no-extraneous-dependencies": [
"error",
{ "devDependencies": ["hardhat.config.ts", "test/**"] }
{
"devDependencies": [
"hardhat.config.ts",
"deploy/**",
"helpers/**",
"test/**"
]
}
]
}
}
1 change: 1 addition & 0 deletions core/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ cache/
deployments/
export.json
export/
external/
typechain/
30 changes: 30 additions & 0 deletions core/deploy/00_resolve_tbtc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
import { isNonZeroAddress } from "../helpers/address"

const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { getNamedAccounts, deployments } = hre
const { log } = deployments
const { deployer } = await getNamedAccounts()

const tbtc = await deployments.getOrNull("TBTC")

if (tbtc && isNonZeroAddress(tbtc.address)) {
log(`using TBTC contract at ${tbtc.address}`)
} else if (!hre.network.tags.allowStubs) {
throw new Error("deployed TBTC contract not found")
} else {
log("deploying TBTC contract stub")

await deployments.deploy("TBTC", {
contract: "TestERC20",
from: deployer,
log: true,
waitConfirmations: 1,
})
}
}

export default func

func.tags = ["TBTC"]
19 changes: 15 additions & 4 deletions core/deploy/01_deploy_acre.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments } = hre
const { log } = deployments
const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { getNamedAccounts, deployments } = hre
const { deployer } = await getNamedAccounts()

log("Deploying Acre contract")
const tbtc = await deployments.get("TBTC")

await deployments.deploy("Acre", {
from: deployer,
args: [tbtc.address],
log: true,
waitConfirmations: 1,
})

// TODO: Add Etherscan verification
// TODO: Add Tenderly verification
}

export default func

func.tags = ["Acre"]
func.dependencies = ["TBTC"]
23 changes: 23 additions & 0 deletions core/deploy/21_transfer_ownership_acre.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"

const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { getNamedAccounts, deployments } = hre
const { deployer, governance } = await getNamedAccounts()
const { log } = deployments

log(`transferring ownership of Acre contract to ${governance}`)

await deployments.execute(
"Acre",
{ from: deployer, log: true, waitConfirmations: 1 },
"transferOwnership",
governance,
)
}

export default func

func.tags = ["TransferOwnershipAcre"]
// TODO: Enable once Acre extends Ownable
func.skip = async () => true
Loading