-
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 implementation
- Loading branch information
Showing
7 changed files
with
135 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,15 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.7; | ||
|
||
import { ChildPool } from "../ChildPool.sol"; | ||
|
||
contract ChildPoolMock is ChildPool { | ||
uint256 public value; | ||
|
||
event ValueSet(uint256 value); | ||
|
||
function setValue(uint256 value_) external { | ||
value = value_; | ||
emit ValueSet(value_); | ||
} | ||
} |
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,15 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.7; | ||
|
||
import { MaticX } from "../MaticX.sol"; | ||
|
||
contract MaticXMock is MaticX { | ||
uint256 public value; | ||
|
||
event ValueSet(uint256 value); | ||
|
||
function setValue(uint256 value_) external { | ||
value = value_; | ||
emit ValueSet(value_); | ||
} | ||
} |
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,15 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.7; | ||
|
||
import { ValidatorRegistry } from "../ValidatorRegistry.sol"; | ||
|
||
contract ValidatorRegistryMock is ValidatorRegistry { | ||
uint256 public value; | ||
|
||
event ValueSet(uint256 value); | ||
|
||
function setValue(uint256 value_) external { | ||
value = value_; | ||
emit ValueSet(value_); | ||
} | ||
} |
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,49 @@ | ||
import { task, types } from "hardhat/config"; | ||
import { TASK_CLEAN, TASK_COMPILE } from "hardhat/builtin-tasks/task-names"; | ||
import { getSigner } from "../utils/account"; | ||
import { isLocalNetwork, Network } from "../utils/network"; | ||
|
||
interface TaskParams { | ||
name: string; | ||
} | ||
|
||
task("deploy-implementation") | ||
.setDescription("Deploy a contract implementation") | ||
.addParam<string>("name", "Contract name", undefined, types.string) | ||
.setAction( | ||
async ( | ||
{ name: contractName }: TaskParams, | ||
{ ethers, upgrades, network, run } | ||
) => { | ||
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 adjustedContractName = isLocalNetwork(networkName) | ||
? `${contractName}Mock` | ||
: contractName; | ||
const ContractFactory = await ethers.getContractFactory( | ||
adjustedContractName, | ||
signer | ||
); | ||
|
||
const implementationAddress = await upgrades.deployImplementation( | ||
ContractFactory, | ||
{ | ||
kind: "transparent", | ||
verifySourceCode: true, | ||
} | ||
); | ||
console.log( | ||
`${contractName} Implementation deployed at ${implementationAddress}` | ||
); | ||
} | ||
); |
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