@wowok/wowok 3.1.0 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/esm/{Transaction-CrzrFqPW.mjs → Transaction-MUfKhsCF.mjs} +1 -1
  2. package/dist/esm/{arb-DfwGgOuj.mjs → arb-DznGhYNq.mjs} +1 -1
  3. package/dist/esm/bcs/index.d.mts +1 -1
  4. package/dist/esm/{call-Bi3kQ2dz.mjs → call-BU2Fl-xY.mjs} +1 -1
  5. package/dist/esm/client/index.d.mts +1 -1
  6. package/dist/esm/client/index.mjs +1 -1
  7. package/dist/esm/client-BTNiaang.mjs +1 -0
  8. package/dist/esm/{common-DC9BAaSg.mjs → common-Xdn-Z6c9.mjs} +1 -1
  9. package/dist/esm/{constants-BGKNJZYa.mjs → constants-DR8H5zhY.mjs} +1 -1
  10. package/dist/esm/cryptography/index.d.mts +1 -1
  11. package/dist/esm/{evm-account-DiQ0dl_e.d.mts → evm-account-C6LC6C4v.d.mts} +2 -2
  12. package/dist/esm/exception-CUK4T4UJ.mjs +1 -0
  13. package/dist/esm/{fund-approval-D9vwQz49.mjs → fund-approval-BeJzE3D_.mjs} +1 -1
  14. package/dist/esm/graphql/index.d.mts +1 -1
  15. package/dist/esm/graphql/index.mjs +1 -1
  16. package/dist/esm/{graphql-6uRIEz97.mjs → graphql-DuKbqfWz.mjs} +1 -1
  17. package/dist/esm/grpc/index.d.mts +1 -1
  18. package/dist/esm/grpc/index.mjs +1 -1
  19. package/dist/esm/{grpc-CuD3bO9t.mjs → grpc-zOhtAWkI.mjs} +1 -1
  20. package/dist/esm/{index-Bs4A3nTL.d.mts → index-DGfn17Bq.d.mts} +12 -1
  21. package/dist/esm/{index-DKne9Aij.d.mts → index-DZz_hx8l.d.mts} +32 -6
  22. package/dist/esm/{index-B-cxGU73.d.mts → index-o_aMVwsK.d.mts} +6 -6
  23. package/dist/esm/index.d.mts +7 -7
  24. package/dist/esm/index.mjs +1 -1
  25. package/dist/esm/jsonRpc/index.d.mts +1 -1
  26. package/dist/esm/jsonRpc/index.mjs +1 -1
  27. package/dist/esm/keypairs/ed25519/index.d.mts +1 -1
  28. package/dist/esm/keypairs/falcon512/index.d.mts +1 -1
  29. package/dist/esm/keypairs/passkey/index.d.mts +1 -1
  30. package/dist/esm/keypairs/secp256k1/index.d.mts +1 -1
  31. package/dist/esm/keypairs/secp256r1/index.d.mts +1 -1
  32. package/dist/esm/{messenger-api-DpkUVzX3.mjs → messenger-api-3u9c6Lit.mjs} +1 -1
  33. package/dist/esm/{messenger-CTktoUW7.mjs → messenger-bXs3igIA.mjs} +1 -1
  34. package/dist/esm/multisig/index.d.mts +1 -1
  35. package/dist/esm/{proof-A-gI-Jbd.mjs → proof-DFDO3YXO.mjs} +1 -1
  36. package/dist/esm/{received-k4hM6HMS.mjs → received-DqdGkEis.mjs} +1 -1
  37. package/dist/esm/{secure-storage-WrSCAIOu.d.mts → secure-storage-CnXXBqBE.d.mts} +1 -1
  38. package/dist/esm/{service-D-99KdWk.mjs → service-DS1cO2w0.mjs} +1 -1
  39. package/dist/esm/storage-0-olOTTC.mjs +1 -0
  40. package/dist/esm/{storage-C_8llI0r.d.mts → storage-CEDkwpbs.d.mts} +14 -1
  41. package/dist/esm/transactions/index.d.mts +1 -1
  42. package/dist/esm/transactions/index.mjs +1 -1
  43. package/dist/esm/{transactions-HEsbZ5tl.mjs → transactions-CklK5guM.mjs} +1 -1
  44. package/dist/esm/util-DMprYkJf.mjs +1 -0
  45. package/dist/esm/util-H--aa378.mjs +1 -0
  46. package/dist/esm/utils/index.d.mts +2 -2
  47. package/dist/esm/utils/index.mjs +1 -1
  48. package/dist/esm/{utils-CFfdvJ-L.mjs → utils-C91AIzNd.mjs} +1 -1
  49. package/dist/esm/verify/index.d.mts +1 -1
  50. package/dist/esm/w/call/allocation.d.mts +1 -1
  51. package/dist/esm/w/call/allocation.mjs +1 -1
  52. package/dist/esm/w/call/arbitration.d.mts +1 -1
  53. package/dist/esm/w/call/arbitration.mjs +1 -1
  54. package/dist/esm/w/call/base.d.mts +1 -1
  55. package/dist/esm/w/call/base.mjs +1 -1
  56. package/dist/esm/w/call/demand.d.mts +1 -1
  57. package/dist/esm/w/call/demand.mjs +1 -1
  58. package/dist/esm/w/call/guard.d.mts +1 -1
  59. package/dist/esm/w/call/guard.mjs +1 -1
  60. package/dist/esm/w/call/index.d.mts +1 -1
  61. package/dist/esm/w/call/index.mjs +1 -1
  62. package/dist/esm/w/call/machine.d.mts +1 -1
  63. package/dist/esm/w/call/machine.mjs +1 -1
  64. package/dist/esm/w/call/passport.d.mts +1 -1
  65. package/dist/esm/w/call/passport.mjs +1 -1
  66. package/dist/esm/w/call/payment.d.mts +1 -1
  67. package/dist/esm/w/call/payment.mjs +1 -1
  68. package/dist/esm/w/call/permission.d.mts +1 -1
  69. package/dist/esm/w/call/permission.mjs +1 -1
  70. package/dist/esm/w/call/progress.d.mts +1 -1
  71. package/dist/esm/w/call/progress.mjs +1 -1
  72. package/dist/esm/w/call/repository.d.mts +1 -1
  73. package/dist/esm/w/call/repository.mjs +1 -1
  74. package/dist/esm/w/call/reward.d.mts +1 -1
  75. package/dist/esm/w/call/reward.mjs +1 -1
  76. package/dist/esm/w/call/service.d.mts +1 -1
  77. package/dist/esm/w/call/service.mjs +1 -1
  78. package/dist/esm/w/call/treasury.d.mts +1 -1
  79. package/dist/esm/w/call/treasury.mjs +1 -1
  80. package/dist/esm/w/common.d.mts +1 -1
  81. package/dist/esm/w/common.mjs +1 -1
  82. package/dist/esm/w/index.d.mts +5 -5
  83. package/dist/esm/w/index.mjs +1 -1
  84. package/dist/esm/w/local/account.d.mts +2 -2
  85. package/dist/esm/w/local/account.mjs +1 -1
  86. package/dist/esm/w/local/cache.mjs +1 -1
  87. package/dist/esm/w/local/config.mjs +1 -1
  88. package/dist/esm/w/local/evm/networks.mjs +1 -1
  89. package/dist/esm/w/local/evm-account.d.mts +1 -1
  90. package/dist/esm/w/local/evm-account.mjs +1 -1
  91. package/dist/esm/w/local/fund-approval.mjs +1 -1
  92. package/dist/esm/w/local/index.d.mts +4 -4
  93. package/dist/esm/w/local/index.mjs +1 -1
  94. package/dist/esm/w/local/local.mjs +1 -1
  95. package/dist/esm/w/local/secure-storage.d.mts +1 -1
  96. package/dist/esm/w/local/secure-storage.mjs +1 -1
  97. package/dist/esm/w/local/storage.d.mts +2 -2
  98. package/dist/esm/w/local/storage.mjs +1 -1
  99. package/dist/esm/w/local/token.d.mts +1 -1
  100. package/dist/esm/w/local/token.mjs +1 -1
  101. package/dist/esm/w/local/wip.mjs +1 -1
  102. package/dist/esm/w/messenger/attachment.d.mts +1 -1
  103. package/dist/esm/w/messenger/index.d.mts +1 -1
  104. package/dist/esm/w/messenger/index.mjs +1 -1
  105. package/dist/esm/w/messenger/messenger-api.d.mts +1 -1
  106. package/dist/esm/w/messenger/messenger-api.mjs +1 -1
  107. package/dist/esm/w/messenger/messenger.d.mts +1 -1
  108. package/dist/esm/w/messenger/messenger.mjs +1 -1
  109. package/dist/esm/w/messenger/reply.d.mts +1 -1
  110. package/dist/esm/w/messenger/storage.d.mts +1 -1
  111. package/dist/esm/w/messenger/types.d.mts +1 -1
  112. package/dist/esm/w/messenger/utils.d.mts +1 -1
  113. package/dist/esm/w/query/index.d.mts +2 -2
  114. package/dist/esm/w/query/index.mjs +1 -1
  115. package/dist/esm/w/query/object.d.mts +1 -1
  116. package/dist/esm/w/query/object.mjs +1 -1
  117. package/dist/esm/{w-DBP-lq8H.mjs → w-DZU7c6qK.mjs} +1 -1
  118. package/package.json +1 -1
  119. package/dist/esm/client-BMMGbUOY.mjs +0 -1
  120. package/dist/esm/exception-D2n4LV8F.mjs +0 -1
  121. package/dist/esm/storage-D1bEi2b7.mjs +0 -1
  122. package/dist/esm/util-BKGG0lou.mjs +0 -1
  123. package/dist/esm/util-CCMJ8QaZ.mjs +0 -1
@@ -1 +1 @@
1
- import{l as a52a}from'./wow-types-DctQuD2J.mjs';import{o as a52b}from'./bcs-Cjvfeyqf.mjs';import{a as a52c,g as a52d,i as a52e,n as a52f,s as a52g,t as a52h}from'./Transaction-CrzrFqPW.mjs';import{promiseWithResolvers}from'@mysten/utils';var AsyncCache=class{async['getObject'](a){const [b,c]=await Promise['all']([this['get']('OwnedObject',a),this['get']('SharedOrImmutableObject',a)]);return b??c??null;}async['getObjects'](a){return Promise['all'](a['map'](b=>this['getObject'](b)));}async['addObject'](a){if(a['owner'])await this['set']('OwnedObject',a['objectId'],a);else await this['set']('SharedOrImmutableObject',a['objectId'],a);return a;}async['addObjects'](a){await Promise['all'](a['map'](async b=>this['addObject'](b)));}async['deleteObject'](a){await Promise['all']([this['delete']('OwnedObject',a),this['delete']('SharedOrImmutableObject',a)]);}async['deleteObjects'](a){await Promise['all'](a['map'](b=>this['deleteObject'](b)));}async['getMoveFunctionDefinition'](a){const b=a52a(a['package'])+'::'+a['module']+'::'+a['function'];return this['get']('MoveFunction',b);}async['addMoveFunctionDefinition'](a){const b=a52a(a['package']),c=b+'::'+a['module']+'::'+a['function'],d={...a,'package':b};return await this['set']('MoveFunction',c,d),d;}async['deleteMoveFunctionDefinition'](a){const b=a52a(a['package'])+'::'+a['module']+'::'+a['function'];await this['delete']('MoveFunction',b);}async['getCustom'](a){return this['get']('Custom',a);}async['setCustom'](a,b){return this['set']('Custom',a,b);}async['deleteCustom'](a){return this['delete']('Custom',a);}},InMemoryCache=class extends AsyncCache{#caches={'OwnedObject':new Map(),'SharedOrImmutableObject':new Map(),'MoveFunction':new Map(),'Custom':new Map()};async['get'](a,b){return this.#caches[a]['get'](b)??null;}async['set'](a,b,c){this.#caches[a]['set'](b,c);}async['delete'](a,b){this.#caches[a]['delete'](b);}async['clear'](a){if(a)this.#caches[a]['clear']();else{for(const b of Object['values'](this.#caches))b['clear']();}}},ObjectCache=class{#cache;#onEffects;constructor({cache:cache=new InMemoryCache(),onEffects:a}){this.#cache=cache,this.#onEffects=a;}['asPlugin'](){return async(a,b,c)=>{const d=a['inputs']['filter'](g=>g['UnresolvedObject'])['map'](g=>g['UnresolvedObject']['objectId']),e=(await this.#cache['getObjects'](d))['filter'](g=>g!==null),f=new Map(e['map'](g=>[g['objectId'],g]));for(const g of a['inputs']){if(!g['UnresolvedObject'])continue;const h=f['get'](g['UnresolvedObject']['objectId']);if(!h)continue;if(h['initialSharedVersion']&&!g['UnresolvedObject']['initialSharedVersion'])g['UnresolvedObject']['initialSharedVersion']=h['initialSharedVersion'];else{if(h['version']&&!g['UnresolvedObject']['version'])g['UnresolvedObject']['version']=h['version'];if(h['digest']&&!g['UnresolvedObject']['digest'])g['UnresolvedObject']['digest']=h['digest'];}}await Promise['all'](a['commands']['map'](async i=>{if(i['MoveCall']){const j=await this['getMoveFunctionDefinition']({'package':i['MoveCall']['package'],'module':i['MoveCall']['module'],'function':i['MoveCall']['function']});if(j)i['MoveCall']['_argumentTypes']=j['parameters'];}})),await c(),await Promise['all'](a['commands']['map'](async i=>{if(i['MoveCall']?.['_argumentTypes'])await this.#cache['addMoveFunctionDefinition']({'package':i['MoveCall']['package'],'module':i['MoveCall']['module'],'function':i['MoveCall']['function'],'parameters':i['MoveCall']['_argumentTypes']});}));};}async['clear'](){await this.#cache['clear']();}async['getMoveFunctionDefinition'](a){return this.#cache['getMoveFunctionDefinition'](a);}async['getObjects'](a){return this.#cache['getObjects'](a);}async['deleteObjects'](a){return this.#cache['deleteObjects'](a);}async['clearOwnedObjects'](){await this.#cache['clear']('OwnedObject');}async['clearCustom'](){await this.#cache['clear']('Custom');}async['getCustom'](a){return this.#cache['getCustom'](a);}async['setCustom'](a,b){return this.#cache['setCustom'](a,b);}async['deleteCustom'](a){return this.#cache['deleteCustom'](a);}async['applyEffects'](a){if(!a['V2'])throw new Error('Unsupported\x20transaction\x20effects\x20version\x20'+a['$kind']);const {lamportVersion:b,changedObjects:c}=a['V2'],d=[],e=[];c['forEach'](([f,g])=>{if(g['outputState']['NotExist'])d['push'](f);else{if(g['outputState']['ObjectWrite']){const [h,i]=g['outputState']['ObjectWrite'];e['push']({'objectId':f,'digest':h,'version':b,'owner':i['AddressOwner']??i['ObjectOwner']??null,'initialSharedVersion':i['Shared']?.['initialSharedVersion']??null});}}}),await Promise['all']([this.#cache['addObjects'](e),this.#cache['deleteObjects'](d),this.#onEffects?.(a)]);}},CachingTransactionExecutor=class{#client;#lastDigest=null;constructor({client:a,...b}){this.#client=a,this['cache']=new ObjectCache(b);}async['reset'](){await Promise['all']([this['cache']['clearOwnedObjects'](),this['cache']['clearCustom'](),this['waitForLastTransaction']()]);}async['buildTransaction']({transaction:a,...b}){return a['addBuildPlugin'](this['cache']['asPlugin']()),a['addBuildPlugin'](a52g),a['build']({'client':this.#client,...b});}async['executeTransaction']({transaction:a,signatures:b,include:c}){const d=a52f(a)?await this['buildTransaction']({'transaction':a}):a,e=await this.#client['core']['executeTransaction']({'transaction':d,'signatures':b,'include':{...c,'effects':!![]}}),f=e['$kind']==='Transaction'?e['Transaction']:e['FailedTransaction'];if(f['effects']?.['bcs']){const g=a52b['TransactionEffects']['parse'](f['effects']['bcs']);await this['applyEffects'](g);}return e;}async['signAndExecuteTransaction']({include:a,transaction:b,signer:c}){b['setSenderIfNotSet'](c['toWowAddress']());const d=await this['buildTransaction']({'transaction':b}),{signature:e}=await c['signTransaction'](d);return this['executeTransaction']({'transaction':d,'signatures':[e],'include':a});}async['applyEffects'](a){this.#lastDigest=a['V2']?.['transactionDigest']??null,await this['cache']['applyEffects'](a);}async['waitForLastTransaction'](){this.#lastDigest&&(await this.#client['core']['waitForTransaction']({'digest':this.#lastDigest}),this.#lastDigest=null);}},SerialQueue=class{#queue=[];async['runTask'](a){return new Promise((b,c)=>{this.#queue['push'](()=>{a()['finally'](()=>{this.#queue['shift']();if(this.#queue['length']>0x0)this.#queue[0x0]();})['then'](b,c);});if(this.#queue['length']===0x1)this.#queue[0x0]();});}},ParallelQueue=class{#queue;constructor(a){this.#queue=[],this['activeTasks']=0x0,this['maxTasks']=a;}['runTask'](a){return new Promise((b,c)=>{if(this['activeTasks']<this['maxTasks'])this['activeTasks']++,a()['finally'](()=>{if(this.#queue['length']>0x0)this.#queue['shift']()();else this['activeTasks']--;})['then'](b,c);else this.#queue['push'](()=>{a()['finally'](()=>{if(this.#queue['length']>0x0)this.#queue['shift']()();else this['activeTasks']--;})['then'](b,c);});});}};const EPOCH_BOUNDARY_WINDOW$1=0xea60;var SerialTransactionExecutor=class{#queue=new SerialQueue();#signer;#client;#cache;#defaultGasBudget;#gasMode;#epochInfo=null;#epochInfoPromise=null;constructor(a){const {signer:b,defaultGasBudget:defaultGasBudget=0x2faf080n,client:c,cache:d}=a;this.#signer=b,this.#client=c,this.#defaultGasBudget=defaultGasBudget,this.#gasMode=a['gasMode']??'coins',this.#cache=new CachingTransactionExecutor({'client':c,'cache':d,'onEffects':e=>this.#cacheGasCoin(e)});}async['applyEffects'](a){return this.#cache['applyEffects'](a);}#cacheGasCoin=async a=>{if(this.#gasMode==='addressBalance'||!a['V2'])return;const b=getGasCoinFromEffects(a)['ref'];if(b)this.#cache['cache']['setCustom']('gasCoin',b);else this.#cache['cache']['deleteCustom']('gasCoin');};async['buildTransaction'](a){return this.#queue['runTask'](()=>this.#buildTransaction(a));}#buildTransaction=async a=>{await a['prepareForSerialization']({'client':this.#client,'supportedIntents':['CoinWithBalance']});const b=a52h['from'](a);if(this.#gasMode==='addressBalance')b['setGasPayment']([]),b['setExpiration'](await this.#getValidDuringExpiration());else{const c=await this.#cache['cache']['getCustom']('gasCoin');if(c)b['setGasPayment']([c]);}return b['setGasBudgetIfNotSet'](this.#defaultGasBudget),b['setSenderIfNotSet'](this.#signer['toWowAddress']()),this.#cache['buildTransaction']({'transaction':b});};async #getValidDuringExpiration(){await this.#ensureEpochInfo();const a=BigInt(this.#epochInfo['epoch']);return{'ValidDuring':{'minEpoch':String(a),'maxEpoch':String(a+0x1n),'minTimestamp':null,'maxTimestamp':null,'chain':this.#epochInfo['chainIdentifier'],'nonce':Math['random']()*0x100000000>>>0x0}};}async #ensureEpochInfo(){if(this.#epochInfo&&this.#epochInfo['expiration']-EPOCH_BOUNDARY_WINDOW$1-Date['now']()>0x0)return;if(this.#epochInfoPromise){await this.#epochInfoPromise;return;}this.#epochInfoPromise=this.#fetchEpochInfo();try{await this.#epochInfoPromise;}finally{this.#epochInfoPromise=null;}}async #fetchEpochInfo(){const [{systemState:a},{chainIdentifier:b}]=await Promise['all']([this.#client['core']['getCurrentSystemState'](),this.#client['core']['getChainIdentifier']()]);this.#epochInfo={'epoch':a['epoch'],'expiration':Number(a['epochStartTimestampMs'])+Number(a['parameters']['epochDurationMs']),'chainIdentifier':b};}['resetCache'](){return this.#cache['reset']();}['waitForLastTransaction'](){return this.#cache['waitForLastTransaction']();}['executeTransaction'](a,b,c=[]){return this.#queue['runTask'](async()=>{const d=a52f(a)?await this.#buildTransaction(a):a,{signature:e}=await this.#signer['signTransaction'](d);return this.#cache['executeTransaction']({'signatures':[e,...c],'transaction':d,'include':b})['catch'](async f=>{await this['resetCache']();throw f;});});}};function getGasCoinFromEffects(a){if(!a['V2'])throw new Error('Unexpected\x20effects\x20version');const b=a['V2']['changedObjects'][a['V2']['gasObjectIndex']];if(!b)throw new Error('Gas\x20object\x20not\x20found\x20in\x20effects');const [c,{outputState:d}]=b;if(!d['ObjectWrite'])throw new Error('Unexpected\x20gas\x20object\x20state');const [e,f]=d['ObjectWrite'];return{'ref':{'objectId':c,'digest':e,'version':a['V2']['lamportVersion']},'owner':f['AddressOwner']||f['ObjectOwner']};}const PARALLEL_EXECUTOR_DEFAULTS={'coinBatchSize':0x14,'initialCoinBalance':0xbebc200n,'minimumCoinBalance':0x2faf080n,'maxPoolSize':0x32},EPOCH_BOUNDARY_WINDOW=0xea60;var ParallelTransactionExecutor=class{#signer;#client;#gasMode;#coinBatchSize;#initialCoinBalance;#minimumCoinBalance;#defaultGasBudget;#maxPoolSize;#sourceCoins;#coinPool=[];#cache;#objectIdQueues=new Map();#buildQueue=new SerialQueue();#executeQueue;#lastDigest=null;#cacheLock=null;#pendingTransactions=0x0;#epochInfo=null;#epochInfoPromise=null;constructor(a){this.#signer=a['signer'],this.#client=a['client'],this.#gasMode=a['gasMode']??'coins';if(this.#gasMode==='coins'){const b=a;this.#coinBatchSize=b['coinBatchSize']??PARALLEL_EXECUTOR_DEFAULTS['coinBatchSize'],this.#initialCoinBalance=b['initialCoinBalance']??PARALLEL_EXECUTOR_DEFAULTS['initialCoinBalance'],this.#minimumCoinBalance=b['minimumCoinBalance']??PARALLEL_EXECUTOR_DEFAULTS['minimumCoinBalance'],this.#sourceCoins=b['sourceCoins']?new Map(b['sourceCoins']['map'](c=>[c,null])):null;}else this.#coinBatchSize=0x0,this.#initialCoinBalance=0x0n,this.#minimumCoinBalance=PARALLEL_EXECUTOR_DEFAULTS['minimumCoinBalance'],this.#sourceCoins=null;this.#defaultGasBudget=a['defaultGasBudget']??this.#minimumCoinBalance,this.#maxPoolSize=a['maxPoolSize']??PARALLEL_EXECUTOR_DEFAULTS['maxPoolSize'],this.#cache=new CachingTransactionExecutor({'client':a['client'],'cache':a['cache']}),this.#executeQueue=new ParallelQueue(this.#maxPoolSize);}['resetCache'](){return this.#epochInfo=null,this.#updateCache(()=>this.#cache['reset']());}async['waitForLastTransaction'](){await this.#updateCache(()=>this.#waitForLastDigest());}async['executeTransaction'](a,b,c=[]){const {promise:d,resolve:e,reject:f}=promiseWithResolvers(),g=await this.#getUsedObjects(a),h=()=>{this.#executeQueue['runTask'](()=>{return this.#execute(a,g,b,c)['then'](e,f);});},i=new Set();g['forEach'](j=>{if(this.#objectIdQueues['get'](j))i['add'](j),this.#objectIdQueues['get'](j)['push'](()=>{i['delete'](j);if(i['size']===0x0)h();});else this.#objectIdQueues['set'](j,[]);});if(i['size']===0x0)h();return d;}async #getUsedObjects(a){const b=new Set();let c=![];return a['addSerializationPlugin'](async(d,e,f)=>{await f();if(c)return;c=!![],d['inputs']['forEach'](g=>{if(g['Object']?.['ImmOrOwnedObject']?.['objectId'])b['add'](g['Object']['ImmOrOwnedObject']['objectId']);else{if(g['Object']?.['Receiving']?.['objectId'])b['add'](g['Object']['Receiving']['objectId']);else{if(g['UnresolvedObject']?.['objectId']&&!g['UnresolvedObject']['initialSharedVersion'])b['add'](g['UnresolvedObject']['objectId']);}}});}),await a['prepareForSerialization']({'client':this.#client}),b;}async #execute(a,b,c,d=[]){let e=null;try{a['setSenderIfNotSet'](this.#signer['toWowAddress']()),await this.#buildQueue['runTask'](async()=>{if(!a['getData']()['gasData']['price'])a['setGasPrice'](await this.#getGasPrice());a['setGasBudgetIfNotSet'](this.#defaultGasBudget),await this.#updateCache(),this.#pendingTransactions++,this.#gasMode==='addressBalance'?(a['setGasPayment']([]),a['setExpiration'](await this.#getValidDuringExpiration())):(e=await this.#getGasCoin(),a['setGasPayment']([{'objectId':e['id'],'version':e['version'],'digest':e['digest']}])),await this.#cache['buildTransaction']({'transaction':a,'onlyTransactionKind':!![]});});const f=await a['build']({'client':this.#client}),{signature:g}=await this.#signer['signTransaction'](f),h=await this.#cache['executeTransaction']({'transaction':f,'signatures':[g,...d],'include':c}),i=h['$kind']==='Transaction'?h['Transaction']:h['FailedTransaction'],j=i['effects'],k=j['gasObject'],l=j['gasUsed'];if(e&&l&&k){const m=e;if((k['outputOwner']?.['AddressOwner']??k['outputOwner']?.['ObjectOwner'])===this.#signer['toWowAddress']()){const n=BigInt(l['computationCost'])+BigInt(l['storageCost'])-BigInt(l['storageRebate']),o=m['balance']-n;let p=![];new a52d(a['getData']())['mapArguments'](r=>{if(r['$kind']==='GasCoin')p=!![];return r;});const q={'objectId':k['objectId'],'version':k['outputVersion'],'digest':k['outputDigest']};if(!p&&o>=this.#minimumCoinBalance)this.#coinPool['push']({'id':q['objectId'],'version':q['version'],'digest':q['digest'],'balance':o});else{if(!this.#sourceCoins)this.#sourceCoins=new Map();this.#sourceCoins['set'](q['objectId'],q);}}}return this.#lastDigest=i['digest'],h;}catch(r){if(e){if(!this.#sourceCoins)this.#sourceCoins=new Map();this.#sourceCoins['set'](e['id'],null);}await this.#updateCache(async()=>{await Promise['all']([this.#cache['cache']['deleteObjects']([...b]),this.#waitForLastDigest()]);});throw r;}finally{b['forEach'](s=>{const t=this.#objectIdQueues['get'](s);if(t&&t['length']>0x0)t['shift']()();else{if(t)this.#objectIdQueues['delete'](s);}}),this.#pendingTransactions--;}}async #updateCache(a){if(this.#cacheLock)await this.#cacheLock;this.#cacheLock=a?.()['then'](()=>{this.#cacheLock=null;},()=>{})??null;}async #waitForLastDigest(){const a=this.#lastDigest;a&&(this.#lastDigest=null,await this.#client['core']['waitForTransaction']({'digest':a}));}async #getGasCoin(){if(this.#coinPool['length']===0x0&&this.#pendingTransactions<=this.#maxPoolSize)await this.#refillCoinPool();if(this.#coinPool['length']===0x0)throw new Error('No\x20coins\x20available');return this.#coinPool['shift']();}async #getGasPrice(){return await this.#ensureEpochInfo(),this.#epochInfo['price'];}async #getValidDuringExpiration(){await this.#ensureEpochInfo();const a=BigInt(this.#epochInfo['epoch']);return{'ValidDuring':{'minEpoch':String(a),'maxEpoch':String(a+0x1n),'minTimestamp':null,'maxTimestamp':null,'chain':this.#epochInfo['chainIdentifier'],'nonce':Math['random']()*0x100000000>>>0x0}};}async #ensureEpochInfo(){if(this.#epochInfo&&this.#epochInfo['expiration']-EPOCH_BOUNDARY_WINDOW-Date['now']()>0x0)return;if(this.#epochInfoPromise){await this.#epochInfoPromise;return;}this.#epochInfoPromise=this.#fetchEpochInfo();try{await this.#epochInfoPromise;}finally{this.#epochInfoPromise=null;}}async #fetchEpochInfo(){const [{systemState:a},{chainIdentifier:b}]=await Promise['all']([this.#client['core']['getCurrentSystemState'](),this.#client['core']['getChainIdentifier']()]);this.#epochInfo={'epoch':a['epoch'],'price':BigInt(a['referenceGasPrice']),'expiration':Number(a['epochStartTimestampMs'])+Number(a['parameters']['epochDurationMs']),'chainIdentifier':b};}async #refillCoinPool(){const a=Math['min'](this.#coinBatchSize,this.#maxPoolSize-(this.#coinPool['length']+this.#pendingTransactions)+0x1);if(a===0x0)return;const b=new a52h(),c=this.#signer['toWowAddress']();b['setSender'](c);if(this.#sourceCoins){const n=[],o=[];for(const [p,q]of this.#sourceCoins)if(q)n['push'](q);else o['push'](p);if(o['length']>0x0){const {objects:r}=await this.#client['core']['getObjects']({'objectIds':o});n['push'](...r['filter'](s=>!(s instanceof Error))['map'](s=>({'objectId':s['objectId'],'version':s['version'],'digest':s['digest']})));}b['setGasPayment'](n),this.#sourceCoins=new Map();}const d=new Array(a)['fill'](this.#initialCoinBalance),e=b['splitCoins'](b['gas'],d),f=[];for(let s=0x0;s<d['length'];s++)f['push'](e[s]);b['transferObjects'](f,c),await this['waitForLastTransaction'](),b['addBuildPlugin'](a52g);const g=await b['build']({'client':this.#client}),{signature:h}=await this.#signer['signTransaction'](g),j=await this.#client['core']['executeTransaction']({'transaction':g,'signatures':[h],'include':{'effects':!![]}}),k=j['$kind']==='Transaction'?j['Transaction']:j['FailedTransaction'],l=k['effects'];l['changedObjects']['forEach'](t=>{if(t['objectId']===l['gasObject']?.['objectId']||t['outputState']!=='ObjectWrite')return;this.#coinPool['push']({'id':t['objectId'],'version':t['outputVersion'],'digest':t['outputDigest'],'balance':BigInt(this.#initialCoinBalance)});});if(!this.#sourceCoins)this.#sourceCoins=new Map();const m=l['gasObject'];this.#sourceCoins['set'](m['objectId'],{'objectId':m['objectId'],'version':m['outputVersion'],'digest':m['outputDigest']}),await this.#client['core']['waitForTransaction']({'digest':k['digest']});}};const Arguments={'pure':a52e(a=>b=>b['pure'](a)),'object':a52c(a=>b=>b['object'](a)),'sharedObjectRef':(...a)=>b=>b['sharedObjectRef'](...a),'objectRef':(...a)=>b=>b['objectRef'](...a),'receivingRef':(...a)=>b=>b['receivingRef'](...a)};export{ObjectCache as a,AsyncCache as i,ParallelTransactionExecutor as n,SerialTransactionExecutor as r,Arguments as t};
1
+ import{l as a52a}from'./wow-types-DctQuD2J.mjs';import{o as a52b}from'./bcs-Cjvfeyqf.mjs';import{a as a52c,g as a52d,i as a52e,n as a52f,s as a52g,t as a52h}from'./Transaction-MUfKhsCF.mjs';import{promiseWithResolvers}from'@mysten/utils';var AsyncCache=class{async['getObject'](a){const [b,c]=await Promise['all']([this['get']('OwnedObject',a),this['get']('SharedOrImmutableObject',a)]);return b??c??null;}async['getObjects'](a){return Promise['all'](a['map'](b=>this['getObject'](b)));}async['addObject'](a){if(a['owner'])await this['set']('OwnedObject',a['objectId'],a);else await this['set']('SharedOrImmutableObject',a['objectId'],a);return a;}async['addObjects'](a){await Promise['all'](a['map'](async b=>this['addObject'](b)));}async['deleteObject'](a){await Promise['all']([this['delete']('OwnedObject',a),this['delete']('SharedOrImmutableObject',a)]);}async['deleteObjects'](a){await Promise['all'](a['map'](b=>this['deleteObject'](b)));}async['getMoveFunctionDefinition'](a){const b=a52a(a['package'])+'::'+a['module']+'::'+a['function'];return this['get']('MoveFunction',b);}async['addMoveFunctionDefinition'](a){const b=a52a(a['package']),c=b+'::'+a['module']+'::'+a['function'],d={...a,'package':b};return await this['set']('MoveFunction',c,d),d;}async['deleteMoveFunctionDefinition'](a){const b=a52a(a['package'])+'::'+a['module']+'::'+a['function'];await this['delete']('MoveFunction',b);}async['getCustom'](a){return this['get']('Custom',a);}async['setCustom'](a,b){return this['set']('Custom',a,b);}async['deleteCustom'](a){return this['delete']('Custom',a);}},InMemoryCache=class extends AsyncCache{#caches={'OwnedObject':new Map(),'SharedOrImmutableObject':new Map(),'MoveFunction':new Map(),'Custom':new Map()};async['get'](a,b){return this.#caches[a]['get'](b)??null;}async['set'](a,b,c){this.#caches[a]['set'](b,c);}async['delete'](a,b){this.#caches[a]['delete'](b);}async['clear'](a){if(a)this.#caches[a]['clear']();else{for(const b of Object['values'](this.#caches))b['clear']();}}},ObjectCache=class{#cache;#onEffects;constructor({cache:cache=new InMemoryCache(),onEffects:a}){this.#cache=cache,this.#onEffects=a;}['asPlugin'](){return async(a,b,c)=>{const d=a['inputs']['filter'](g=>g['UnresolvedObject'])['map'](g=>g['UnresolvedObject']['objectId']),e=(await this.#cache['getObjects'](d))['filter'](g=>g!==null),f=new Map(e['map'](g=>[g['objectId'],g]));for(const g of a['inputs']){if(!g['UnresolvedObject'])continue;const h=f['get'](g['UnresolvedObject']['objectId']);if(!h)continue;if(h['initialSharedVersion']&&!g['UnresolvedObject']['initialSharedVersion'])g['UnresolvedObject']['initialSharedVersion']=h['initialSharedVersion'];else{if(h['version']&&!g['UnresolvedObject']['version'])g['UnresolvedObject']['version']=h['version'];if(h['digest']&&!g['UnresolvedObject']['digest'])g['UnresolvedObject']['digest']=h['digest'];}}await Promise['all'](a['commands']['map'](async i=>{if(i['MoveCall']){const j=await this['getMoveFunctionDefinition']({'package':i['MoveCall']['package'],'module':i['MoveCall']['module'],'function':i['MoveCall']['function']});if(j)i['MoveCall']['_argumentTypes']=j['parameters'];}})),await c(),await Promise['all'](a['commands']['map'](async i=>{if(i['MoveCall']?.['_argumentTypes'])await this.#cache['addMoveFunctionDefinition']({'package':i['MoveCall']['package'],'module':i['MoveCall']['module'],'function':i['MoveCall']['function'],'parameters':i['MoveCall']['_argumentTypes']});}));};}async['clear'](){await this.#cache['clear']();}async['getMoveFunctionDefinition'](a){return this.#cache['getMoveFunctionDefinition'](a);}async['getObjects'](a){return this.#cache['getObjects'](a);}async['deleteObjects'](a){return this.#cache['deleteObjects'](a);}async['clearOwnedObjects'](){await this.#cache['clear']('OwnedObject');}async['clearCustom'](){await this.#cache['clear']('Custom');}async['getCustom'](a){return this.#cache['getCustom'](a);}async['setCustom'](a,b){return this.#cache['setCustom'](a,b);}async['deleteCustom'](a){return this.#cache['deleteCustom'](a);}async['applyEffects'](a){if(!a['V2'])throw new Error('Unsupported\x20transaction\x20effects\x20version\x20'+a['$kind']);const {lamportVersion:b,changedObjects:c}=a['V2'],d=[],e=[];c['forEach'](([f,g])=>{if(g['outputState']['NotExist'])d['push'](f);else{if(g['outputState']['ObjectWrite']){const [h,i]=g['outputState']['ObjectWrite'];e['push']({'objectId':f,'digest':h,'version':b,'owner':i['AddressOwner']??i['ObjectOwner']??null,'initialSharedVersion':i['Shared']?.['initialSharedVersion']??null});}}}),await Promise['all']([this.#cache['addObjects'](e),this.#cache['deleteObjects'](d),this.#onEffects?.(a)]);}},CachingTransactionExecutor=class{#client;#lastDigest=null;constructor({client:a,...b}){this.#client=a,this['cache']=new ObjectCache(b);}async['reset'](){await Promise['all']([this['cache']['clearOwnedObjects'](),this['cache']['clearCustom'](),this['waitForLastTransaction']()]);}async['buildTransaction']({transaction:a,...b}){return a['addBuildPlugin'](this['cache']['asPlugin']()),a['addBuildPlugin'](a52g),a['build']({'client':this.#client,...b});}async['executeTransaction']({transaction:a,signatures:b,include:c}){const d=a52f(a)?await this['buildTransaction']({'transaction':a}):a,e=await this.#client['core']['executeTransaction']({'transaction':d,'signatures':b,'include':{...c,'effects':!![]}}),f=e['$kind']==='Transaction'?e['Transaction']:e['FailedTransaction'];if(f['effects']?.['bcs']){const g=a52b['TransactionEffects']['parse'](f['effects']['bcs']);await this['applyEffects'](g);}return e;}async['signAndExecuteTransaction']({include:a,transaction:b,signer:c}){b['setSenderIfNotSet'](c['toWowAddress']());const d=await this['buildTransaction']({'transaction':b}),{signature:e}=await c['signTransaction'](d);return this['executeTransaction']({'transaction':d,'signatures':[e],'include':a});}async['applyEffects'](a){this.#lastDigest=a['V2']?.['transactionDigest']??null,await this['cache']['applyEffects'](a);}async['waitForLastTransaction'](){this.#lastDigest&&(await this.#client['core']['waitForTransaction']({'digest':this.#lastDigest}),this.#lastDigest=null);}},SerialQueue=class{#queue=[];async['runTask'](a){return new Promise((b,c)=>{this.#queue['push'](()=>{a()['finally'](()=>{this.#queue['shift']();if(this.#queue['length']>0x0)this.#queue[0x0]();})['then'](b,c);});if(this.#queue['length']===0x1)this.#queue[0x0]();});}},ParallelQueue=class{#queue;constructor(a){this.#queue=[],this['activeTasks']=0x0,this['maxTasks']=a;}['runTask'](a){return new Promise((b,c)=>{if(this['activeTasks']<this['maxTasks'])this['activeTasks']++,a()['finally'](()=>{if(this.#queue['length']>0x0)this.#queue['shift']()();else this['activeTasks']--;})['then'](b,c);else this.#queue['push'](()=>{a()['finally'](()=>{if(this.#queue['length']>0x0)this.#queue['shift']()();else this['activeTasks']--;})['then'](b,c);});});}};const EPOCH_BOUNDARY_WINDOW$1=0xea60;var SerialTransactionExecutor=class{#queue=new SerialQueue();#signer;#client;#cache;#defaultGasBudget;#gasMode;#epochInfo=null;#epochInfoPromise=null;constructor(a){const {signer:b,defaultGasBudget:defaultGasBudget=0x2faf080n,client:c,cache:d}=a;this.#signer=b,this.#client=c,this.#defaultGasBudget=defaultGasBudget,this.#gasMode=a['gasMode']??'coins',this.#cache=new CachingTransactionExecutor({'client':c,'cache':d,'onEffects':e=>this.#cacheGasCoin(e)});}async['applyEffects'](a){return this.#cache['applyEffects'](a);}#cacheGasCoin=async a=>{if(this.#gasMode==='addressBalance'||!a['V2'])return;const b=getGasCoinFromEffects(a)['ref'];if(b)this.#cache['cache']['setCustom']('gasCoin',b);else this.#cache['cache']['deleteCustom']('gasCoin');};async['buildTransaction'](a){return this.#queue['runTask'](()=>this.#buildTransaction(a));}#buildTransaction=async a=>{await a['prepareForSerialization']({'client':this.#client,'supportedIntents':['CoinWithBalance']});const b=a52h['from'](a);if(this.#gasMode==='addressBalance')b['setGasPayment']([]),b['setExpiration'](await this.#getValidDuringExpiration());else{const c=await this.#cache['cache']['getCustom']('gasCoin');if(c)b['setGasPayment']([c]);}return b['setGasBudgetIfNotSet'](this.#defaultGasBudget),b['setSenderIfNotSet'](this.#signer['toWowAddress']()),this.#cache['buildTransaction']({'transaction':b});};async #getValidDuringExpiration(){await this.#ensureEpochInfo();const a=BigInt(this.#epochInfo['epoch']);return{'ValidDuring':{'minEpoch':String(a),'maxEpoch':String(a+0x1n),'minTimestamp':null,'maxTimestamp':null,'chain':this.#epochInfo['chainIdentifier'],'nonce':Math['random']()*0x100000000>>>0x0}};}async #ensureEpochInfo(){if(this.#epochInfo&&this.#epochInfo['expiration']-EPOCH_BOUNDARY_WINDOW$1-Date['now']()>0x0)return;if(this.#epochInfoPromise){await this.#epochInfoPromise;return;}this.#epochInfoPromise=this.#fetchEpochInfo();try{await this.#epochInfoPromise;}finally{this.#epochInfoPromise=null;}}async #fetchEpochInfo(){const [{systemState:a},{chainIdentifier:b}]=await Promise['all']([this.#client['core']['getCurrentSystemState'](),this.#client['core']['getChainIdentifier']()]);this.#epochInfo={'epoch':a['epoch'],'expiration':Number(a['epochStartTimestampMs'])+Number(a['parameters']['epochDurationMs']),'chainIdentifier':b};}['resetCache'](){return this.#cache['reset']();}['waitForLastTransaction'](){return this.#cache['waitForLastTransaction']();}['executeTransaction'](a,b,c=[]){return this.#queue['runTask'](async()=>{const d=a52f(a)?await this.#buildTransaction(a):a,{signature:e}=await this.#signer['signTransaction'](d);return this.#cache['executeTransaction']({'signatures':[e,...c],'transaction':d,'include':b})['catch'](async f=>{await this['resetCache']();throw f;});});}};function getGasCoinFromEffects(a){if(!a['V2'])throw new Error('Unexpected\x20effects\x20version');const b=a['V2']['changedObjects'][a['V2']['gasObjectIndex']];if(!b)throw new Error('Gas\x20object\x20not\x20found\x20in\x20effects');const [c,{outputState:d}]=b;if(!d['ObjectWrite'])throw new Error('Unexpected\x20gas\x20object\x20state');const [e,f]=d['ObjectWrite'];return{'ref':{'objectId':c,'digest':e,'version':a['V2']['lamportVersion']},'owner':f['AddressOwner']||f['ObjectOwner']};}const PARALLEL_EXECUTOR_DEFAULTS={'coinBatchSize':0x14,'initialCoinBalance':0xbebc200n,'minimumCoinBalance':0x2faf080n,'maxPoolSize':0x32},EPOCH_BOUNDARY_WINDOW=0xea60;var ParallelTransactionExecutor=class{#signer;#client;#gasMode;#coinBatchSize;#initialCoinBalance;#minimumCoinBalance;#defaultGasBudget;#maxPoolSize;#sourceCoins;#coinPool=[];#cache;#objectIdQueues=new Map();#buildQueue=new SerialQueue();#executeQueue;#lastDigest=null;#cacheLock=null;#pendingTransactions=0x0;#epochInfo=null;#epochInfoPromise=null;constructor(a){this.#signer=a['signer'],this.#client=a['client'],this.#gasMode=a['gasMode']??'coins';if(this.#gasMode==='coins'){const b=a;this.#coinBatchSize=b['coinBatchSize']??PARALLEL_EXECUTOR_DEFAULTS['coinBatchSize'],this.#initialCoinBalance=b['initialCoinBalance']??PARALLEL_EXECUTOR_DEFAULTS['initialCoinBalance'],this.#minimumCoinBalance=b['minimumCoinBalance']??PARALLEL_EXECUTOR_DEFAULTS['minimumCoinBalance'],this.#sourceCoins=b['sourceCoins']?new Map(b['sourceCoins']['map'](c=>[c,null])):null;}else this.#coinBatchSize=0x0,this.#initialCoinBalance=0x0n,this.#minimumCoinBalance=PARALLEL_EXECUTOR_DEFAULTS['minimumCoinBalance'],this.#sourceCoins=null;this.#defaultGasBudget=a['defaultGasBudget']??this.#minimumCoinBalance,this.#maxPoolSize=a['maxPoolSize']??PARALLEL_EXECUTOR_DEFAULTS['maxPoolSize'],this.#cache=new CachingTransactionExecutor({'client':a['client'],'cache':a['cache']}),this.#executeQueue=new ParallelQueue(this.#maxPoolSize);}['resetCache'](){return this.#epochInfo=null,this.#updateCache(()=>this.#cache['reset']());}async['waitForLastTransaction'](){await this.#updateCache(()=>this.#waitForLastDigest());}async['executeTransaction'](a,b,c=[]){const {promise:d,resolve:e,reject:f}=promiseWithResolvers(),g=await this.#getUsedObjects(a),h=()=>{this.#executeQueue['runTask'](()=>{return this.#execute(a,g,b,c)['then'](e,f);});},i=new Set();g['forEach'](j=>{if(this.#objectIdQueues['get'](j))i['add'](j),this.#objectIdQueues['get'](j)['push'](()=>{i['delete'](j);if(i['size']===0x0)h();});else this.#objectIdQueues['set'](j,[]);});if(i['size']===0x0)h();return d;}async #getUsedObjects(a){const b=new Set();let c=![];return a['addSerializationPlugin'](async(d,e,f)=>{await f();if(c)return;c=!![],d['inputs']['forEach'](g=>{if(g['Object']?.['ImmOrOwnedObject']?.['objectId'])b['add'](g['Object']['ImmOrOwnedObject']['objectId']);else{if(g['Object']?.['Receiving']?.['objectId'])b['add'](g['Object']['Receiving']['objectId']);else{if(g['UnresolvedObject']?.['objectId']&&!g['UnresolvedObject']['initialSharedVersion'])b['add'](g['UnresolvedObject']['objectId']);}}});}),await a['prepareForSerialization']({'client':this.#client}),b;}async #execute(a,b,c,d=[]){let e=null;try{a['setSenderIfNotSet'](this.#signer['toWowAddress']()),await this.#buildQueue['runTask'](async()=>{if(!a['getData']()['gasData']['price'])a['setGasPrice'](await this.#getGasPrice());a['setGasBudgetIfNotSet'](this.#defaultGasBudget),await this.#updateCache(),this.#pendingTransactions++,this.#gasMode==='addressBalance'?(a['setGasPayment']([]),a['setExpiration'](await this.#getValidDuringExpiration())):(e=await this.#getGasCoin(),a['setGasPayment']([{'objectId':e['id'],'version':e['version'],'digest':e['digest']}])),await this.#cache['buildTransaction']({'transaction':a,'onlyTransactionKind':!![]});});const f=await a['build']({'client':this.#client}),{signature:g}=await this.#signer['signTransaction'](f),h=await this.#cache['executeTransaction']({'transaction':f,'signatures':[g,...d],'include':c}),i=h['$kind']==='Transaction'?h['Transaction']:h['FailedTransaction'],j=i['effects'],k=j['gasObject'],l=j['gasUsed'];if(e&&l&&k){const m=e;if((k['outputOwner']?.['AddressOwner']??k['outputOwner']?.['ObjectOwner'])===this.#signer['toWowAddress']()){const n=BigInt(l['computationCost'])+BigInt(l['storageCost'])-BigInt(l['storageRebate']),o=m['balance']-n;let p=![];new a52d(a['getData']())['mapArguments'](r=>{if(r['$kind']==='GasCoin')p=!![];return r;});const q={'objectId':k['objectId'],'version':k['outputVersion'],'digest':k['outputDigest']};if(!p&&o>=this.#minimumCoinBalance)this.#coinPool['push']({'id':q['objectId'],'version':q['version'],'digest':q['digest'],'balance':o});else{if(!this.#sourceCoins)this.#sourceCoins=new Map();this.#sourceCoins['set'](q['objectId'],q);}}}return this.#lastDigest=i['digest'],h;}catch(r){if(e){if(!this.#sourceCoins)this.#sourceCoins=new Map();this.#sourceCoins['set'](e['id'],null);}await this.#updateCache(async()=>{await Promise['all']([this.#cache['cache']['deleteObjects']([...b]),this.#waitForLastDigest()]);});throw r;}finally{b['forEach'](s=>{const t=this.#objectIdQueues['get'](s);if(t&&t['length']>0x0)t['shift']()();else{if(t)this.#objectIdQueues['delete'](s);}}),this.#pendingTransactions--;}}async #updateCache(a){if(this.#cacheLock)await this.#cacheLock;this.#cacheLock=a?.()['then'](()=>{this.#cacheLock=null;},()=>{})??null;}async #waitForLastDigest(){const a=this.#lastDigest;a&&(this.#lastDigest=null,await this.#client['core']['waitForTransaction']({'digest':a}));}async #getGasCoin(){if(this.#coinPool['length']===0x0&&this.#pendingTransactions<=this.#maxPoolSize)await this.#refillCoinPool();if(this.#coinPool['length']===0x0)throw new Error('No\x20coins\x20available');return this.#coinPool['shift']();}async #getGasPrice(){return await this.#ensureEpochInfo(),this.#epochInfo['price'];}async #getValidDuringExpiration(){await this.#ensureEpochInfo();const a=BigInt(this.#epochInfo['epoch']);return{'ValidDuring':{'minEpoch':String(a),'maxEpoch':String(a+0x1n),'minTimestamp':null,'maxTimestamp':null,'chain':this.#epochInfo['chainIdentifier'],'nonce':Math['random']()*0x100000000>>>0x0}};}async #ensureEpochInfo(){if(this.#epochInfo&&this.#epochInfo['expiration']-EPOCH_BOUNDARY_WINDOW-Date['now']()>0x0)return;if(this.#epochInfoPromise){await this.#epochInfoPromise;return;}this.#epochInfoPromise=this.#fetchEpochInfo();try{await this.#epochInfoPromise;}finally{this.#epochInfoPromise=null;}}async #fetchEpochInfo(){const [{systemState:a},{chainIdentifier:b}]=await Promise['all']([this.#client['core']['getCurrentSystemState'](),this.#client['core']['getChainIdentifier']()]);this.#epochInfo={'epoch':a['epoch'],'price':BigInt(a['referenceGasPrice']),'expiration':Number(a['epochStartTimestampMs'])+Number(a['parameters']['epochDurationMs']),'chainIdentifier':b};}async #refillCoinPool(){const a=Math['min'](this.#coinBatchSize,this.#maxPoolSize-(this.#coinPool['length']+this.#pendingTransactions)+0x1);if(a===0x0)return;const b=new a52h(),c=this.#signer['toWowAddress']();b['setSender'](c);if(this.#sourceCoins){const n=[],o=[];for(const [p,q]of this.#sourceCoins)if(q)n['push'](q);else o['push'](p);if(o['length']>0x0){const {objects:r}=await this.#client['core']['getObjects']({'objectIds':o});n['push'](...r['filter'](s=>!(s instanceof Error))['map'](s=>({'objectId':s['objectId'],'version':s['version'],'digest':s['digest']})));}b['setGasPayment'](n),this.#sourceCoins=new Map();}const d=new Array(a)['fill'](this.#initialCoinBalance),e=b['splitCoins'](b['gas'],d),f=[];for(let s=0x0;s<d['length'];s++)f['push'](e[s]);b['transferObjects'](f,c),await this['waitForLastTransaction'](),b['addBuildPlugin'](a52g);const g=await b['build']({'client':this.#client}),{signature:h}=await this.#signer['signTransaction'](g),j=await this.#client['core']['executeTransaction']({'transaction':g,'signatures':[h],'include':{'effects':!![]}}),k=j['$kind']==='Transaction'?j['Transaction']:j['FailedTransaction'],l=k['effects'];l['changedObjects']['forEach'](t=>{if(t['objectId']===l['gasObject']?.['objectId']||t['outputState']!=='ObjectWrite')return;this.#coinPool['push']({'id':t['objectId'],'version':t['outputVersion'],'digest':t['outputDigest'],'balance':BigInt(this.#initialCoinBalance)});});if(!this.#sourceCoins)this.#sourceCoins=new Map();const m=l['gasObject'];this.#sourceCoins['set'](m['objectId'],{'objectId':m['objectId'],'version':m['outputVersion'],'digest':m['outputDigest']}),await this.#client['core']['waitForTransaction']({'digest':k['digest']});}};const Arguments={'pure':a52e(a=>b=>b['pure'](a)),'object':a52c(a=>b=>b['object'](a)),'sharedObjectRef':(...a)=>b=>b['sharedObjectRef'](...a),'objectRef':(...a)=>b=>b['objectRef'](...a),'receivingRef':(...a)=>b=>b['receivingRef'](...a)};export{ObjectCache as a,AsyncCache as i,ParallelTransactionExecutor as n,SerialTransactionExecutor as r,Arguments as t};