@@ -162,7 +162,8 @@ export class SuiPricePusher implements IPricePusher {
162
162
endpoint : string ,
163
163
keypair : Ed25519Keypair ,
164
164
gasBudget : number ,
165
- numGasObjects : number
165
+ numGasObjects : number ,
166
+ ignoreGasObjects : string [ ]
166
167
) : Promise < SuiPricePusher > {
167
168
if ( numGasObjects > MAX_NUM_OBJECTS_IN_ARGUMENT ) {
168
169
throw new Error (
@@ -183,7 +184,8 @@ export class SuiPricePusher implements IPricePusher {
183
184
const gasPool = await SuiPricePusher . initializeGasPool (
184
185
keypair ,
185
186
provider ,
186
- numGasObjects
187
+ numGasObjects ,
188
+ ignoreGasObjects
187
189
) ;
188
190
189
191
const pythClient = new SuiPythClient (
@@ -318,17 +320,26 @@ export class SuiPricePusher implements IPricePusher {
318
320
319
321
// This function will smash all coins owned by the signer into one, and then
320
322
// split them equally into numGasObjects.
323
+ // ignoreGasObjects is a list of gas objects that will be ignored during the
324
+ // merging -- use this to store any locked objects on initialization.
321
325
private static async initializeGasPool (
322
326
signer : Ed25519Keypair ,
323
327
provider : SuiClient ,
324
- numGasObjects : number
328
+ numGasObjects : number ,
329
+ ignoreGasObjects : string [ ]
325
330
) : Promise < SuiObjectRef [ ] > {
326
331
const signerAddress = await signer . toSuiAddress ( ) ;
327
332
333
+ if ( ignoreGasObjects . length > 0 ) {
334
+ console . log ( "Ignoring some gas objects for coin merging:" ) ;
335
+ console . log ( ignoreGasObjects ) ;
336
+ }
337
+
328
338
const consolidatedCoin = await SuiPricePusher . mergeGasCoinsIntoOne (
329
339
signer ,
330
340
provider ,
331
- signerAddress
341
+ signerAddress ,
342
+ ignoreGasObjects
332
343
) ;
333
344
const coinResult = await provider . getObject ( {
334
345
id : consolidatedCoin . objectId ,
@@ -458,7 +469,8 @@ export class SuiPricePusher implements IPricePusher {
458
469
private static async mergeGasCoinsIntoOne (
459
470
signer : Ed25519Keypair ,
460
471
provider : SuiClient ,
461
- owner : SuiAddress
472
+ owner : SuiAddress ,
473
+ initialLockedAddresses : string [ ]
462
474
) : Promise < SuiObjectRef > {
463
475
const gasCoins = await SuiPricePusher . getAllGasCoins ( provider , owner ) ;
464
476
// skip merging if there is only one coin
@@ -472,6 +484,7 @@ export class SuiPricePusher implements IPricePusher {
472
484
) ;
473
485
let finalCoin ;
474
486
const lockedAddresses : Set < string > = new Set ( ) ;
487
+ initialLockedAddresses . forEach ( ( value ) => lockedAddresses . add ( value ) ) ;
475
488
for ( let i = 0 ; i < gasCoinsChunks . length ; i ++ ) {
476
489
const mergeTx = new TransactionBlock ( ) ;
477
490
let coins = gasCoinsChunks [ i ] ;
@@ -497,15 +510,13 @@ export class SuiPricePusher implements IPricePusher {
497
510
"quorum of validators because of locked objects. Retried a conflicting transaction"
498
511
)
499
512
) {
500
- /*
501
513
Object . values ( ( e as any ) . data ) . forEach ( ( lockedObjects : any ) => {
502
514
lockedObjects . forEach ( ( lockedObject : [ string , number , string ] ) => {
503
515
lockedAddresses . add ( lockedObject [ 0 ] ) ;
504
516
} ) ;
505
517
} ) ;
506
518
// retry merging without the locked coins
507
519
i -- ;
508
- */
509
520
continue ;
510
521
}
511
522
throw e ;
0 commit comments