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

Mark implementation contract initialized on deploy #21

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/contracts/contracts/TokenLock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ contract TokenLock is OwnableUpgradeable, IERC20 {
/// ERC-20 function is not supported
error NotSupported();

/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address _owner,
address _token,
uint256 _depositDeadline,
uint256 _lockDuration,
string memory _name,
string memory _symbol
) {
initialize(_owner, _token, _depositDeadline, _lockDuration, _name, _symbol);
}

function initialize(
address _owner,
address _token,
Expand Down
10 changes: 10 additions & 0 deletions packages/contracts/src/tasks/constructorArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type Args = [string, string, string, string, string, string]
const DEAD_ADDRESS = "0x000000000000000000000000000000000000dead"
export const constructorArgs: Args = [
DEAD_ADDRESS,
DEAD_ADDRESS,
"0",
"0",
"",
"",
]
21 changes: 13 additions & 8 deletions packages/contracts/src/tasks/initialDeploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "hardhat-deploy"
import "@nomiclabs/hardhat-ethers"
import { task, types } from "hardhat/config"
import { constructorArgs } from "./constructorArgs"

task("initialDeploy", "Deploys a fresh TokenLock contract")
.addParam("owner", "Address of the owner", undefined, types.string)
Expand Down Expand Up @@ -33,14 +34,18 @@ task("initialDeploy", "Deploys a fresh TokenLock contract")
const [caller] = await hre.ethers.getSigners()
console.log("Using the account:", caller.address)
const TokenLock = await hre.ethers.getContractFactory("TokenLock")
const tokenLock = await hre.upgrades.deployProxy(TokenLock, [
taskArgs.owner,
taskArgs.token,
taskArgs.depositDeadline,
taskArgs.lockDuration,
taskArgs.name,
taskArgs.symbol,
])
const tokenLock = await hre.upgrades.deployProxy(
TokenLock,
[
taskArgs.owner,
taskArgs.token,
taskArgs.depositDeadline,
taskArgs.lockDuration,
taskArgs.name,
taskArgs.symbol,
],
{ constructorArgs }
)

console.log("TokenLock proxy deployed to:", tokenLock.address)
console.log("Waiting for deploy transaction to be mined...")
Expand Down
7 changes: 6 additions & 1 deletion packages/contracts/src/tasks/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "hardhat-deploy"
import "@nomiclabs/hardhat-ethers"

import { task, types } from "hardhat/config"
import { constructorArgs } from "./constructorArgs"

task("upgrade", "Upgrades the logic of an existing TokenLock contract")
.addParam(
Expand All @@ -14,7 +15,11 @@ task("upgrade", "Upgrades the logic of an existing TokenLock contract")
const [caller] = await hre.ethers.getSigners()
console.log("Using the account:", caller.address)
const TokenLock = await hre.ethers.getContractFactory("TokenLock")
const tokenLock = await hre.upgrades.upgradeProxy(taskArgs.proxy, TokenLock)
const tokenLock = await hre.upgrades.upgradeProxy(
taskArgs.proxy,
TokenLock,
{ constructorArgs }
)

console.log(
`Latest version of the implementation deployed to: ${tokenLock.address}`
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/src/tasks/verify.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { task, types } from "hardhat/config"
import { constructorArgs } from "./constructorArgs"

task("verifyEtherscan", "Verifies the contract on etherscan")
.addParam(
Expand All @@ -10,6 +11,6 @@ task("verifyEtherscan", "Verifies the contract on etherscan")
.setAction(async (taskArgs, hardhatRuntime) => {
await hardhatRuntime.run("verify", {
address: taskArgs.implementation,
constructorArgsParams: [],
constructorArgsParams: constructorArgs,
})
})
Loading