@@ -5,95 +5,105 @@ const BondedECDSAKeepJson = require("@keep-network/keep-ecdsa/artifacts/BondedEC
55const contractHelper = require ( "./lib/contract-helper" )
66
77module . exports = async function ( ) {
8- try {
9- const BondedECDSAKeepFactory = truffleContract ( BondedECDSAKeepFactoryJson )
10- const BondedECDSAKeep = truffleContract ( BondedECDSAKeepJson )
11- BondedECDSAKeepFactory . setProvider ( web3 . currentProvider )
12- BondedECDSAKeep . setProvider ( web3 . currentProvider )
13-
14- const factoryDeploymentBlock = await contractHelper . getDeploymentBlockNumber (
15- BondedECDSAKeepFactoryJson , web3
8+ try {
9+ const BondedECDSAKeepFactory = truffleContract ( BondedECDSAKeepFactoryJson )
10+ const BondedECDSAKeep = truffleContract ( BondedECDSAKeepJson )
11+ BondedECDSAKeepFactory . setProvider ( web3 . currentProvider )
12+ BondedECDSAKeep . setProvider ( web3 . currentProvider )
13+
14+ const factoryDeploymentBlock = await contractHelper . getDeploymentBlockNumber (
15+ BondedECDSAKeepFactoryJson ,
16+ web3 ,
17+ )
18+
19+ const factory = await BondedECDSAKeepFactory . deployed ( )
20+
21+ const keepCount = await factory . getKeepCount ( )
22+ console . log ( `created keeps count: ${ keepCount } ` )
23+
24+ const allOperators = new Set ( )
25+ const goodOperators = new Set ( )
26+
27+ for ( i = 0 ; i < keepCount ; i ++ ) {
28+ const keepAddress = await callWithRetry ( ( ) => factory . getKeepAtIndex ( i ) )
29+ const keep = await BondedECDSAKeep . at ( keepAddress )
30+ const keepPublicKey = await callWithRetry ( ( ) => keep . publicKey ( ) )
31+ const members = await callWithRetry ( ( ) => keep . getMembers ( ) )
32+ const isActive = await callWithRetry ( ( ) => keep . isActive ( ) )
33+ const bond = await callWithRetry ( ( ) => keep . checkBondAmount ( ) )
34+
35+ const signatureRequestedEvents = await keep . getPastEvents (
36+ "SignatureRequested" ,
37+ {
38+ fromBlock : factoryDeploymentBlock ,
39+ toBlock : "latest" ,
40+ } ,
41+ )
42+
43+ console . log ( `keep address: ${ keepAddress } ` )
44+ console . log ( `keep index: ${ i } ` )
45+ console . log ( `pubkey: ${ keepPublicKey } ` )
46+ console . log ( `members: ${ members } ` )
47+ console . log ( `isActive: ${ isActive } ` )
48+ console . log ( `bond [wei]: ${ bond } ` )
49+ console . log ( `bond [eth]: ${ web3 . utils . fromWei ( bond ) } ` )
50+ console . log ( `bond [eth]: ${ web3 . utils . fromWei ( bond ) } ` )
51+
52+ if ( signatureRequestedEvents . length == 0 ) {
53+ console . log ( `signature requested: no` )
54+ } else {
55+ console . log (
56+ `signature requested: yes, [${ signatureRequestedEvents . length } ] times` ,
1657 )
1758
18- const factory = await BondedECDSAKeepFactory . deployed ( )
19-
20- const keepCount = await factory . getKeepCount ( )
21- console . log ( `created keeps count: ${ keepCount } ` )
22-
23- const allOperators = new Set ( )
24- const goodOperators = new Set ( )
25-
26- for ( i = 0 ; i < keepCount ; i ++ ) {
27- const keepAddress = await callWithRetry ( ( ) => factory . getKeepAtIndex ( i ) )
28- const keep = await BondedECDSAKeep . at ( keepAddress )
29- const keepPublicKey = await callWithRetry ( ( ) => keep . publicKey ( ) )
30- const members = await callWithRetry ( ( ) => keep . getMembers ( ) )
31- const isActive = await callWithRetry ( ( ) => keep . isActive ( ) )
32- const bond = await callWithRetry ( ( ) => keep . checkBondAmount ( ) )
33-
34- const signatureRequestedEvents = await keep . getPastEvents (
35- "SignatureRequested" ,
36- {
37- fromBlock : factoryDeploymentBlock ,
38- toBlock : "latest" ,
39- }
40- )
41-
42- console . log ( `keep address: ${ keepAddress } ` )
43- console . log ( `keep index: ${ i } ` )
44- console . log ( `pubkey: ${ keepPublicKey } ` )
45- console . log ( `members: ${ members } ` )
46- console . log ( `isActive: ${ isActive } ` )
47- console . log ( `bond [wei]: ${ bond } ` )
48- console . log ( `bond [eth]: ${ web3 . utils . fromWei ( bond ) } ` )
49- console . log ( `bond [eth]: ${ web3 . utils . fromWei ( bond ) } ` )
50- if ( signatureRequestedEvents . length == 0 ) {
51- console . log ( `signature requested: no` )
52- } else {
53- console . log ( `signature requested: yes, [${ signatureRequestedEvents . length } ] times` )
54-
55- const signatureSubmittedEvents = await keep . getPastEvents (
56- "SignatureSubmitted" ,
57- {
58- fromBlock : factoryDeploymentBlock ,
59- toBlock : "latest" ,
60- }
61- )
62- if ( signatureRequestedEvents . length == 0 ) {
63- console . log ( `signature submitted: no` )
64- } else {
65- console . log ( `signature submitted: yes, [${ signatureSubmittedEvents . length } ] times` )
66- }
67- }
68-
69- members . forEach ( ( member ) => allOperators . add ( member ) )
70- if ( keepPublicKey ) {
71- members . forEach ( ( member ) => goodOperators . add ( member ) )
72- }
73-
74- console . log ( `` )
59+ const signatureSubmittedEvents = await keep . getPastEvents (
60+ "SignatureSubmitted" ,
61+ {
62+ fromBlock : factoryDeploymentBlock ,
63+ toBlock : "latest" ,
64+ } ,
65+ )
66+ if ( signatureRequestedEvents . length == 0 ) {
67+ console . log ( `signature submitted: no` )
68+ } else {
69+ console . log (
70+ `signature submitted: yes, [${ signatureSubmittedEvents . length } ] times` ,
71+ )
7572 }
73+ }
7674
77- // if the operator is a member of at least one keep and that operator
78- // is NOT a member of at least one keep which successfully generated
79- // a public key, this operator is here
80- let potentiallyBadOperators = new Set ( allOperators )
81- for ( let goodOperator of goodOperators ) {
82- potentiallyBadOperators . delete ( goodOperator )
83- }
84- console . log ( `potentially bad operators = ${ new Array ( ...potentiallyBadOperators ) . join ( ', ' ) } ` )
75+ members . forEach ( ( member ) => allOperators . add ( member ) )
76+ if ( keepPublicKey ) {
77+ members . forEach ( ( member ) => goodOperators . add ( member ) )
78+ }
79+
80+ console . log ( `` )
81+ }
8582
86- process . exit ( )
87- } catch ( error ) {
88- console . log ( error )
83+ // if the operator is a member of at least one keep and that operator
84+ // is NOT a member of at least one keep which successfully generated
85+ // a public key, this operator is here
86+ let potentiallyBadOperators = new Set ( allOperators )
87+ for ( let goodOperator of goodOperators ) {
88+ potentiallyBadOperators . delete ( goodOperator )
8989 }
90+ console . log (
91+ `potentially bad operators = ${ new Array ( ...potentiallyBadOperators ) . join (
92+ ", " ,
93+ ) } `,
94+ )
95+
96+ process . exit ( )
97+ } catch ( error ) {
98+ console . log ( error )
99+ }
90100}
91101
92102async function callWithRetry ( fn ) {
93- try {
94- return await fn ( )
95- } catch ( error ) {
96- console . log ( `Error ${ error } occurred; retrying...` )
97- return await fn ( )
98- }
99- }
103+ try {
104+ return await fn ( )
105+ } catch ( error ) {
106+ console . log ( `Error ${ error } occurred; retrying...` )
107+ return await fn ( )
108+ }
109+ }
0 commit comments