@@ -20,38 +20,43 @@ console.log(`Current nonce: ${nonce}`);
20
20
const account = wallet . address ;
21
21
const shouldSimulate = true ;
22
22
// Assert the list is unique
23
- if ( new Set ( renewList ) . size !== renewList . length ) {
24
- console . error ( "List is not unique" ) ;
25
- process . exit ( 1 ) ;
26
- }
23
+ // if (new Set(renewList).size !== renewList.length) {
24
+ // console.error("List is not unique");
25
+ // process.exit(1);
26
+ // }
27
+ const contract = new ethers . Contract ( ronRegistrarControllerAddr , abi , provider ) ;
28
+ const chunkSize = 20 ;
27
29
28
30
async function bulkRenew ( ) {
29
- const contract = new ethers . Contract ( ronRegistrarControllerAddr , abi , provider ) ;
31
+ for ( let i = 0 ; i < renewList . length ; i += chunkSize ) {
32
+ const chunk = renewList . slice ( i , i + chunkSize ) ;
33
+ console . log ( `Processing chunk ${ i / chunkSize + 1 } - ${ chunk . length } labels` ) ;
30
34
31
- const promises = renewList . map ( async ( label ) => {
32
- if ( shouldSimulate ) {
33
- console . log ( `nonce: ${ nonce ++ } ` ) ;
34
- try {
35
- await contract . renew . staticCall ( label , defaultRenewDuration , {
36
- from : account ,
37
- } ) ;
38
- } catch ( error ) {
39
- console . error ( `Failed to simulate renew for ${ label } - ${ defaultRenewDuration } ` , error ) ;
40
- }
41
- } else {
42
- console . log ( `nonce: ${ nonce } ` ) ;
43
- try {
44
- await contract . connect ( wallet ) . renew ( label , defaultRenewDuration , {
45
- nonce : nonce ++ ,
46
- } ) ;
47
- console . log ( `Renew for label ${ label } - duration: ${ defaultRenewDuration } success` ) ;
48
- } catch ( error ) {
49
- console . error ( `Failed to renew label ${ label } - duration ${ defaultRenewDuration } :` , error ) ;
35
+ const promises = chunk . map ( async ( label ) => {
36
+ if ( shouldSimulate ) {
37
+ console . log ( `nonce: ${ nonce ++ } ` ) ;
38
+ try {
39
+ await contract . renew . staticCall ( label , defaultRenewDuration , {
40
+ from : account ,
41
+ } ) ;
42
+ } catch ( error ) {
43
+ console . error ( `Failed to simulate renew for ${ label } - ${ defaultRenewDuration } ` , error ) ;
44
+ }
45
+ } else {
46
+ console . log ( `nonce: ${ nonce } ` ) ;
47
+ try {
48
+ await contract . connect ( wallet ) . renew ( label , defaultRenewDuration , {
49
+ nonce : nonce ++ ,
50
+ } ) ;
51
+ console . log ( `Renew for label ${ label } - duration: ${ defaultRenewDuration } success` ) ;
52
+ } catch ( error ) {
53
+ console . error ( `Failed to renew label ${ label } - duration ${ defaultRenewDuration } :` , error ) ;
54
+ }
50
55
}
51
- }
52
- } ) ;
56
+ } ) ;
53
57
54
- await Promise . all ( promises ) ;
58
+ await Promise . all ( promises ) ;
59
+ }
55
60
}
56
61
57
62
bulkRenew ( ) ;
0 commit comments