Skip to content

Commit

Permalink
update with ethers v6 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Jan 18, 2024
1 parent e4b7382 commit 2af42d0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 172 deletions.
18 changes: 11 additions & 7 deletions contracts/cli/newClrFund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
* Create a new instance of the ClrFund contract.
*
* If the coordinator ETH address is not provided, use the signer address
* If the COORDINATOR_MACISK env. varibale not set, create a new random MACI key
* If the COORDINATOR_MACISK environment varibale not set in the .env file,
* this script will create a new random MACI key
*
* Display help:
* yarn ts-node cli/newClrFund.ts -h
*
* Sample usage:
*
* HARDHAT_NETWORK=localhost yarn ts-node cli/newClrFund.ts \
* --deployer <clrfund deployer contract address> \
* --token <native token address> \
* [--coordinator <coordinator ETH address> ] \
* [--user-registry-type <user registry type> ] \
* [--recipient-registry-type <recipient registry type> ]
* --coordinator <coordinator ETH address> \
* --user-registry-type <user registry type> \
* --recipient-registry-type <recipient registry type>
*
*
* If user registry address and recipient registry address are not provided,
Expand Down Expand Up @@ -111,7 +115,7 @@ async function main(args: any) {
'ClrFundDeployer',
deployer
)
console.log('ClrFundDeployer:', clrfundDeployer.address)
console.log('ClrFundDeployer:', clrfundDeployer.target)

const tx = await clrfundDeployer.deployClrFund()
const receipt = await tx.wait()
Expand Down Expand Up @@ -167,7 +171,7 @@ async function main(args: any) {
brightidVerifier: args.brightidVerifier,
brightidSponsor: args.brightidSponsor,
})
userRegistryAddress = userRegistryContract.address
userRegistryAddress = await userRegistryContract.getAddress()
}
const setUserRegistryTx =
await clrfundContract.setUserRegistry(userRegistryAddress)
Expand All @@ -188,7 +192,7 @@ async function main(args: any) {
deposit,
controller: clrfund,
})
recipientRegistryAddress = recipientRegistryContract.address
recipientRegistryAddress = await recipientRegistryContract.getAddress()
}

const setRecipientRegistryTx = await clrfundContract.setRecipientRegistry(
Expand Down
144 changes: 0 additions & 144 deletions contracts/tasks/newClrFund.ts

This file was deleted.

42 changes: 22 additions & 20 deletions contracts/utils/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ export async function deployUserRegistry({
brightidVerifier?: string
brightidSponsor?: string
}): Promise<Contract> {
let userRegistry: Contract
let contractArgs: any[] = []
const registryType = (userRegistryType || '').toLowerCase()

if (registryType === 'brightid') {
if (!brightidContext) {
throw new Error('Missing BrightId context')
Expand All @@ -145,27 +146,24 @@ export async function deployUserRegistry({
throw new Error('Missing BrightId sponsor contract address')
}

const BrightIdUserRegistry = await ethers.getContractFactory(
'BrightIdUserRegistry',
signer
)

userRegistry = await BrightIdUserRegistry.deploy(
contractArgs = [
encodeBytes32String(brightidContext),
brightidVerifier,
brightidSponsor
)
} else {
const userRegistryName = userRegistryNames[registryType]
if (!userRegistryName) {
throw new Error('unsupported user registry type: ' + registryType)
}
brightidSponsor,
]
}

userRegistry = await ethers.deployContract(userRegistryName, signer)
const userRegistryName = userRegistryNames[registryType]
if (!userRegistryName) {
throw new Error('unsupported user registry type: ' + registryType)
}

await userRegistry.waitForDeployment()
return userRegistry
return deployContract({
name: userRegistryName,
contractArgs,
ethers,
signer,
})
}

/**
Expand Down Expand Up @@ -213,10 +211,14 @@ export async function deployRecipientRegistry({
? [controller]
: [deposit, challengePeriod, controller]

const factory = await ethers.getContractFactory(registryName, signer)
const recipientRegistry = await factory.deploy(...args)
const recipientRegistry = await ethers.deployContract(
registryName,
args,
signer
)

return await recipientRegistry.deployed()
await recipientRegistry.waitForDeployment()
return recipientRegistry
}

/**
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3044,7 +3044,7 @@
resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-toolbox/-/hardhat-toolbox-4.0.0.tgz#eb1f619218dd1414fa161dfec92d3e5e53a2f407"
integrity sha512-jhcWHp0aHaL0aDYj8IJl80v4SZXWMS1A2XxXa1CA6pBiFfJKuZinCkO6wb+POAt0LIfXB3gA3AgdcOccrcwBwA==

"@nomicfoundation/hardhat-verify@^2.0.0":
"@nomicfoundation/hardhat-verify@^2.0.3":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-verify/-/hardhat-verify-2.0.3.tgz#173557f8cfa53c8c9da23a326f54d24fe459ae68"
integrity sha512-ESbRu9by53wu6VvgwtMtm108RSmuNsVqXtzg061D+/4R7jaWh/Wl/8ve+p6SdDX7vA1Z3L02hDO1Q3BY4luLXQ==
Expand Down

0 comments on commit 2af42d0

Please sign in to comment.