Skip to content

Commit

Permalink
Merge pull request #21 from bobanetwork/owner
Browse files Browse the repository at this point in the history
separate contract deployer and owner
  • Loading branch information
kitounliu committed Jul 23, 2024
2 parents bec5853 + 1ff91df commit b03be15
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .env.example.deploy
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
L2_NODE_WEB3_URL=<rpc>
ADMIN_PRIVATE_KEY=<private key of admin account>
DEPLOYER_PRIVATE_KEY=<private key of deployer's account>
ADMIN_ADDRESS=<admin account address>
THRESHOLD=3
NUMBER_OF_MEMBERS=5
DEGREE=18
Expand Down
2 changes: 1 addition & 1 deletion contracts/zkdvrf_pre.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ contract zkdvrf_pre is Ownable {
mapping(uint256 => IPseudoRand.PseudoRandom) public roundToRandom;


constructor(uint32 thresholdValue, uint32 numberValue, address halo2VerifierAddress, address halo2VerifyingKeyAddress, address globalPublicParamsAddress, address pseudoRandAddress, uint256 minDeposit) Ownable(msg.sender) {
constructor(uint32 thresholdValue, uint32 numberValue, address owner, address halo2VerifierAddress, address halo2VerifyingKeyAddress, address globalPublicParamsAddress, address pseudoRandAddress, uint256 minDeposit) Ownable(owner) {
require(halo2VerifierAddress != address(0) && globalPublicParamsAddress != address(0) && pseudoRandAddress != address(0), "Cannot be zero addresses");
memberCount = numberValue;
threshold = thresholdValue;
Expand Down
5 changes: 3 additions & 2 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {Contract, ContractFactory, providers, utils, Wallet} from "ethers";

async function main() {
const netprovider = new providers.JsonRpcProvider(process.env.L2_NODE_WEB3_URL)
const accPrivateKey = process.env.ADMIN_PRIVATE_KEY ?? ''
const accPrivateKey = process.env.DEPLOYER_PRIVATE_KEY ?? ''
const adminAddress = process.env.ADMIN_ADDRESS ?? ''
const deployerWallet = new Wallet(accPrivateKey, netprovider)
const threshold = process.env.THRESHOLD
const numberOfMembers = process.env.NUMBER_OF_MEMBERS
Expand Down Expand Up @@ -53,7 +54,7 @@ async function main() {
}

const Zkdvrf = await ethers.getContractFactory('zkdvrf_pre')
const zkdvrf = await Zkdvrf.connect(deployerWallet).deploy(threshold, numberOfMembers, halo2VerifierAddress, halo2VerifyingKeyAddress, globalPublicParamsAddress, pseudoRandAddress, minDeposit)
const zkdvrf = await Zkdvrf.connect(deployerWallet).deploy(threshold, numberOfMembers, adminAddress, halo2VerifierAddress, halo2VerifyingKeyAddress, globalPublicParamsAddress, pseudoRandAddress, minDeposit)
await zkdvrf.deployed()

console.log("zkdvrf_pre deployed at", zkdvrf.address)
Expand Down
8 changes: 5 additions & 3 deletions test/zkdvrf_pre.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ describe('ZKDVRF (with precomputation of hash) on-chain tests', async () => {
Halo2VerifyingKey = await (await ethers.getContractFactory('contracts/Halo2VerifyingKey-3-5-18-g2.sol:Halo2VerifyingKey')).deploy()
GlobalPublicParams = await (await ethers.getContractFactory('GlobalPublicParams')).deploy()
PseudoRand = await (await ethers.getContractFactory('PseudoRand')).deploy()
Zkdvrf = await (
await ethers.getContractFactory('zkdvrf_pre')
).deploy(3, 5, Halo2Verifier.address, Halo2VerifyingKey.address, GlobalPublicParams.address, PseudoRand.address, minDeposit)

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

Zkdvrf = await (
await ethers.getContractFactory('zkdvrf_pre')
).deploy(3, 5, account1Address, Halo2Verifier.address, Halo2VerifyingKey.address, GlobalPublicParams.address, PseudoRand.address, minDeposit)


lotteryAdmin = (await ethers.getSigners())[5]
player1 = (await ethers.getSigners())[6]
player2 = (await ethers.getSigners())[7]
Expand Down

0 comments on commit b03be15

Please sign in to comment.