@@ -162,7 +162,8 @@ export class SuiPricePusher implements IPricePusher {
162162 endpoint : string ,
163163 keypair : Ed25519Keypair ,
164164 gasBudget : number ,
165- numGasObjects : number
165+ numGasObjects : number ,
166+ ignoreGasObjects : string [ ]
166167 ) : Promise < SuiPricePusher > {
167168 if ( numGasObjects > MAX_NUM_OBJECTS_IN_ARGUMENT ) {
168169 throw new Error (
@@ -183,7 +184,8 @@ export class SuiPricePusher implements IPricePusher {
183184 const gasPool = await SuiPricePusher . initializeGasPool (
184185 keypair ,
185186 provider ,
186- numGasObjects
187+ numGasObjects ,
188+ ignoreGasObjects
187189 ) ;
188190
189191 const pythClient = new SuiPythClient (
@@ -318,17 +320,26 @@ export class SuiPricePusher implements IPricePusher {
318320
319321 // This function will smash all coins owned by the signer into one, and then
320322 // 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.
321325 private static async initializeGasPool (
322326 signer : Ed25519Keypair ,
323327 provider : SuiClient ,
324- numGasObjects : number
328+ numGasObjects : number ,
329+ ignoreGasObjects : string [ ]
325330 ) : Promise < SuiObjectRef [ ] > {
326331 const signerAddress = await signer . toSuiAddress ( ) ;
327332
333+ if ( ignoreGasObjects . length > 0 ) {
334+ console . log ( "Ignoring some gas objects for coin merging:" ) ;
335+ console . log ( ignoreGasObjects ) ;
336+ }
337+
328338 const consolidatedCoin = await SuiPricePusher . mergeGasCoinsIntoOne (
329339 signer ,
330340 provider ,
331- signerAddress
341+ signerAddress ,
342+ ignoreGasObjects
332343 ) ;
333344 const coinResult = await provider . getObject ( {
334345 id : consolidatedCoin . objectId ,
@@ -458,7 +469,8 @@ export class SuiPricePusher implements IPricePusher {
458469 private static async mergeGasCoinsIntoOne (
459470 signer : Ed25519Keypair ,
460471 provider : SuiClient ,
461- owner : SuiAddress
472+ owner : SuiAddress ,
473+ initialLockedAddresses : string [ ]
462474 ) : Promise < SuiObjectRef > {
463475 const gasCoins = await SuiPricePusher . getAllGasCoins ( provider , owner ) ;
464476 // skip merging if there is only one coin
@@ -472,6 +484,7 @@ export class SuiPricePusher implements IPricePusher {
472484 ) ;
473485 let finalCoin ;
474486 const lockedAddresses : Set < string > = new Set ( ) ;
487+ initialLockedAddresses . forEach ( ( value ) => lockedAddresses . add ( value ) ) ;
475488 for ( let i = 0 ; i < gasCoinsChunks . length ; i ++ ) {
476489 const mergeTx = new TransactionBlock ( ) ;
477490 let coins = gasCoinsChunks [ i ] ;
@@ -497,15 +510,13 @@ export class SuiPricePusher implements IPricePusher {
497510 "quorum of validators because of locked objects. Retried a conflicting transaction"
498511 )
499512 ) {
500- /*
501513 Object . values ( ( e as any ) . data ) . forEach ( ( lockedObjects : any ) => {
502514 lockedObjects . forEach ( ( lockedObject : [ string , number , string ] ) => {
503515 lockedAddresses . add ( lockedObject [ 0 ] ) ;
504516 } ) ;
505517 } ) ;
506518 // retry merging without the locked coins
507519 i -- ;
508- */
509520 continue ;
510521 }
511522 throw e ;
0 commit comments