-
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.
Implement task to deploy FxStateRootTunnel contract
- Loading branch information
Showing
3 changed files
with
123 additions
and
16 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
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,78 @@ | ||
import { TASK_CLEAN, TASK_COMPILE } from "hardhat/builtin-tasks/task-names"; | ||
import { task, types } from "hardhat/config"; | ||
import { getSigner } from "../utils/account"; | ||
import { isLocalNetwork, Network } from "../utils/network"; | ||
|
||
interface TaskParams { | ||
checkpointManager: string; | ||
fxRoot: string; | ||
fxStateRootTunnel: string; | ||
} | ||
|
||
task("deploy:fx-state-root-tunnel") | ||
.setDescription("Deploy the FxStateRootTunnel contract") | ||
.addParam<string>( | ||
"checkpointManager", | ||
"Address of the CheckpointManager contract", | ||
undefined, | ||
types.string | ||
) | ||
.addParam<string>( | ||
"fxRoot", | ||
"Address of the FxRoot contract", | ||
undefined, | ||
types.string | ||
) | ||
.addParam<string>( | ||
"maticX", | ||
"Address of the MaticX contract", | ||
undefined, | ||
types.string | ||
) | ||
.setAction( | ||
async ( | ||
{ | ||
checkpointManager: checkpointManagerAddress, | ||
fxRoot: fxRootAddress, | ||
maticX: maticXAddress, | ||
}: TaskParams, | ||
{ ethers, network, run } | ||
) => { | ||
if (!ethers.utils.isAddress(checkpointManagerAddress)) { | ||
throw new Error("Invalid CheckpointManager address"); | ||
} | ||
if (!ethers.utils.isAddress(fxRootAddress)) { | ||
throw new Error("Invalid FxRootAddress address"); | ||
} | ||
if (!ethers.utils.isAddress(maticXAddress)) { | ||
throw new Error("Invalid MaticX address"); | ||
} | ||
|
||
const networkName = network.name as Network; | ||
console.log(`Network name: ${networkName}`); | ||
if (!isLocalNetwork(networkName)) { | ||
await run(TASK_CLEAN); | ||
} | ||
await run(TASK_COMPILE); | ||
|
||
const signer = await getSigner( | ||
ethers, | ||
network.provider, | ||
network.config.from | ||
); | ||
const FxStateRootTunnel = await ethers.getContractFactory( | ||
"FxStateRootTunnel", | ||
signer | ||
); | ||
|
||
const fxStateRootTunnel = await FxStateRootTunnel.deploy( | ||
checkpointManagerAddress, | ||
fxRootAddress, | ||
maticXAddress | ||
); | ||
await fxStateRootTunnel.deployed(); | ||
console.log( | ||
`FxStateRootTunnel deployed at ${fxStateRootTunnel.address}` | ||
); | ||
} | ||
); |
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