1
1
import fs from 'fs'
2
2
import { ethers } from 'hardhat'
3
- import { BigNumber } from 'ethers'
3
+ import { BigNumber , Wallet } from 'ethers'
4
4
import { PrivKey , Keypair } from 'maci-domainobjs'
5
5
6
6
import { createMessage } from '../utils/maci'
7
7
8
8
async function main ( ) {
9
- const [ , , , , , , , , , , , , contributor1 , contributor2 ] =
10
- await ethers . getSigners ( )
9
+ // const [, , , , , , , , , , , , contributor1, contributor2, contributor3] =
10
+ // await ethers.getSigners()
11
+
12
+ const contributor1 = new Wallet (
13
+ process . env . CONTRIBUTOR_PK_1 ! ,
14
+ ethers . provider
15
+ )
16
+ const contributor2 = new Wallet (
17
+ process . env . CONTRIBUTOR_PK_2 ! ,
18
+ ethers . provider
19
+ )
20
+ const contributor3 = new Wallet (
21
+ process . env . CONTRIBUTOR_PK_3 ! ,
22
+ ethers . provider
23
+ )
24
+
11
25
const state = JSON . parse ( fs . readFileSync ( 'state.json' ) . toString ( ) )
12
26
const coordinatorKeyPair = new Keypair (
13
27
PrivKey . unserialize ( state . coordinatorPrivKey )
14
28
)
15
29
16
- for ( const contributor of [ contributor1 , contributor2 ] ) {
30
+ for ( const contributor of [ contributor1 , contributor2 , contributor3 ] ) {
17
31
const contributorAddress = await contributor . getAddress ( )
18
32
const contributorData = state . contributors [ contributorAddress ]
19
33
const contributorKeyPair = new Keypair (
@@ -37,8 +51,11 @@ async function main() {
37
51
encPubKeys . push ( encPubKey . asContractParam ( ) )
38
52
nonce += 1
39
53
// Vote
40
- for ( const recipientIndex of [ 1 , 2 ] ) {
41
- const votes = BigNumber . from ( contributorData . voiceCredits ) . div ( 4 )
54
+ const recipients = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ]
55
+ for ( const recipientIndex of recipients ) {
56
+ const votes = BigNumber . from ( contributorData . voiceCredits ) . div (
57
+ recipients . length
58
+ )
42
59
const [ message , encPubKey ] = createMessage (
43
60
contributorData . stateIndex ,
44
61
newContributorKeypair ,
@@ -58,10 +75,21 @@ async function main() {
58
75
state . fundingRound ,
59
76
contributor
60
77
)
61
- await fundingRoundAsContributor . submitMessageBatch (
78
+
79
+ const tx = await fundingRoundAsContributor . submitMessageBatch (
62
80
messages . reverse ( ) ,
63
- encPubKeys . reverse ( )
81
+ encPubKeys . reverse ( ) ,
82
+ {
83
+ gasLimit : 20000000 ,
84
+ }
64
85
)
86
+ try {
87
+ await tx . wait ( )
88
+ } catch ( err ) {
89
+ console . log ( 'error!' , err )
90
+ return
91
+ }
92
+
65
93
console . log ( `Contributor ${ contributorAddress } voted.` )
66
94
}
67
95
}
0 commit comments