Skip to content

Commit b03be15

Browse files
authored
Merge pull request #21 from bobanetwork/owner
separate contract deployer and owner
2 parents bec5853 + 1ff91df commit b03be15

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

.env.example.deploy

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
L2_NODE_WEB3_URL=<rpc>
2-
ADMIN_PRIVATE_KEY=<private key of admin account>
2+
DEPLOYER_PRIVATE_KEY=<private key of deployer's account>
3+
ADMIN_ADDRESS=<admin account address>
34
THRESHOLD=3
45
NUMBER_OF_MEMBERS=5
56
DEGREE=18

contracts/zkdvrf_pre.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ contract zkdvrf_pre is Ownable {
7878
mapping(uint256 => IPseudoRand.PseudoRandom) public roundToRandom;
7979

8080

81-
constructor(uint32 thresholdValue, uint32 numberValue, address halo2VerifierAddress, address halo2VerifyingKeyAddress, address globalPublicParamsAddress, address pseudoRandAddress, uint256 minDeposit) Ownable(msg.sender) {
81+
constructor(uint32 thresholdValue, uint32 numberValue, address owner, address halo2VerifierAddress, address halo2VerifyingKeyAddress, address globalPublicParamsAddress, address pseudoRandAddress, uint256 minDeposit) Ownable(owner) {
8282
require(halo2VerifierAddress != address(0) && globalPublicParamsAddress != address(0) && pseudoRandAddress != address(0), "Cannot be zero addresses");
8383
memberCount = numberValue;
8484
threshold = thresholdValue;

scripts/deploy.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {Contract, ContractFactory, providers, utils, Wallet} from "ethers";
33

44
async function main() {
55
const netprovider = new providers.JsonRpcProvider(process.env.L2_NODE_WEB3_URL)
6-
const accPrivateKey = process.env.ADMIN_PRIVATE_KEY ?? ''
6+
const accPrivateKey = process.env.DEPLOYER_PRIVATE_KEY ?? ''
7+
const adminAddress = process.env.ADMIN_ADDRESS ?? ''
78
const deployerWallet = new Wallet(accPrivateKey, netprovider)
89
const threshold = process.env.THRESHOLD
910
const numberOfMembers = process.env.NUMBER_OF_MEMBERS
@@ -53,7 +54,7 @@ async function main() {
5354
}
5455

5556
const Zkdvrf = await ethers.getContractFactory('zkdvrf_pre')
56-
const zkdvrf = await Zkdvrf.connect(deployerWallet).deploy(threshold, numberOfMembers, halo2VerifierAddress, halo2VerifyingKeyAddress, globalPublicParamsAddress, pseudoRandAddress, minDeposit)
57+
const zkdvrf = await Zkdvrf.connect(deployerWallet).deploy(threshold, numberOfMembers, adminAddress, halo2VerifierAddress, halo2VerifyingKeyAddress, globalPublicParamsAddress, pseudoRandAddress, minDeposit)
5758
await zkdvrf.deployed()
5859

5960
console.log("zkdvrf_pre deployed at", zkdvrf.address)

test/zkdvrf_pre.spec.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ describe('ZKDVRF (with precomputation of hash) on-chain tests', async () => {
155155
Halo2VerifyingKey = await (await ethers.getContractFactory('contracts/Halo2VerifyingKey-3-5-18-g2.sol:Halo2VerifyingKey')).deploy()
156156
GlobalPublicParams = await (await ethers.getContractFactory('GlobalPublicParams')).deploy()
157157
PseudoRand = await (await ethers.getContractFactory('PseudoRand')).deploy()
158-
Zkdvrf = await (
159-
await ethers.getContractFactory('zkdvrf_pre')
160-
).deploy(3, 5, Halo2Verifier.address, Halo2VerifyingKey.address, GlobalPublicParams.address, PseudoRand.address, minDeposit)
161158

162159
account1 = (await ethers.getSigners())[0]
163160
account2 = (await ethers.getSigners())[1]
@@ -170,6 +167,11 @@ describe('ZKDVRF (with precomputation of hash) on-chain tests', async () => {
170167
account4Address = await account4.getAddress()
171168
account5Address = await account5.getAddress()
172169

170+
Zkdvrf = await (
171+
await ethers.getContractFactory('zkdvrf_pre')
172+
).deploy(3, 5, account1Address, Halo2Verifier.address, Halo2VerifyingKey.address, GlobalPublicParams.address, PseudoRand.address, minDeposit)
173+
174+
173175
lotteryAdmin = (await ethers.getSigners())[5]
174176
player1 = (await ethers.getSigners())[6]
175177
player2 = (await ethers.getSigners())[7]

0 commit comments

Comments
 (0)