File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @pythnetwork/price-pusher" ,
3
- "version" : " 5.4.5 " ,
3
+ "version" : " 5.4.6 " ,
4
4
"description" : " Pyth Price Pusher" ,
5
5
"homepage" : " https://pyth.network" ,
6
6
"main" : " lib/index.js" ,
Original file line number Diff line number Diff line change @@ -329,7 +329,11 @@ export class SuiPricePusher implements IPricePusher {
329
329
`The balance of gas object ${ gasObject . objectId } is too low. Removing from pool.`
330
330
) ;
331
331
} else {
332
- nextGasObject = gasObject ;
332
+ // Refresh the coin object here in case the error is caused by an object version mismatch.
333
+ nextGasObject = await SuiPricePusher . tryRefreshObjectReference (
334
+ this . signer . provider ,
335
+ gasObject
336
+ ) ;
333
337
}
334
338
console . error ( e ) ;
335
339
@@ -373,6 +377,29 @@ export class SuiPricePusher implements IPricePusher {
373
377
return gasPool ;
374
378
}
375
379
380
+ // Attempt to refresh the version of the provided object reference to point to the current version
381
+ // of the object. Return the provided object reference if an error occurs or the object could not
382
+ // be retrieved.
383
+ private static async tryRefreshObjectReference (
384
+ provider : JsonRpcProvider ,
385
+ ref : SuiObjectRef
386
+ ) : Promise < SuiObjectRef > {
387
+ try {
388
+ const objectResponse = await provider . getObject ( { id : ref . objectId } ) ;
389
+ if ( objectResponse . data !== undefined ) {
390
+ return {
391
+ digest : objectResponse . data . digest ,
392
+ objectId : objectResponse . data . objectId ,
393
+ version : objectResponse . data . version ,
394
+ } ;
395
+ } else {
396
+ return ref ;
397
+ }
398
+ } catch ( error ) {
399
+ return ref ;
400
+ }
401
+ }
402
+
376
403
private static async getAllGasCoins (
377
404
provider : JsonRpcProvider ,
378
405
owner : SuiAddress
You can’t perform that action at this time.
0 commit comments