@wormhole-foundation/wormhole-connect 1.2.0-beta.0-development → 1.3.0-beta.0-development

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 (127) hide show
  1. package/dist/assets/aptos-DZ2rfUfg.js +3 -0
  2. package/dist/assets/{aptos-fvUGRJ4h.js → aptos-g3DaQf0b.js} +61 -61
  3. package/dist/assets/{ccip-DLVsVRZh.js → ccip-CTWg50DB.js} +1 -1
  4. package/dist/assets/{chunk-U2PRGW4O-BklU2g_V.js → chunk-U2PRGW4O-_uqZ791P.js} +1 -1
  5. package/dist/assets/evm-CUAh52pb.js +2 -0
  6. package/dist/assets/{evm-D7r3Ne49.js → evm-Dpe6bb4m.js} +4 -4
  7. package/dist/assets/index-B169l5cS.js +1 -0
  8. package/dist/assets/{index-BINzPDaS.js → index-B2zKde8M.js} +1 -1
  9. package/dist/assets/{index-BmcqXpQd.js → index-B85n1wgg.js} +1 -1
  10. package/dist/assets/{index-BOsp0gGs.js → index-BGPIDyz6.js} +1 -1
  11. package/dist/assets/index-BT5QH3hv.js +1 -0
  12. package/dist/assets/{index-5UpuI6jk.js → index-BbXYZkyr.js} +1 -1
  13. package/dist/assets/{index-C_VIzW7c.js → index-Bwgv1Ind.js} +1 -1
  14. package/dist/assets/{index-P4tasYP-.js → index-CFWDbus8.js} +1 -1
  15. package/dist/assets/{index-BKYhAEpg.js → index-CJV78alS.js} +1 -1
  16. package/dist/assets/{index-DAS-UCcB.js → index-Ck17eoCG.js} +1 -1
  17. package/dist/assets/{index-C0ho2skw.js → index-CpdwiPRU.js} +2 -2
  18. package/dist/assets/{index-C02sy3fv.js → index-DVtwRIfn.js} +1 -1
  19. package/dist/assets/{index-D3TIHxII.js → index-jE0RsYBN.js} +1 -1
  20. package/dist/assets/{index.es-wOiA40sy.js → index.es-CEXOl433.js} +2 -2
  21. package/dist/assets/{signer-BzqNQC8X.js → signer-D8BxqoWW.js} +1 -1
  22. package/dist/assets/{solana--aMZfCgL.js → solana-Cu2aa7vE.js} +1 -1
  23. package/dist/assets/solana-Ddk7It-E.js +2 -0
  24. package/dist/assets/{sui-C76oYlao.js → sui-BXAKH3nv.js} +3 -3
  25. package/dist/assets/unsignedTransaction-DsxtoHjl.js +1 -0
  26. package/dist/main.js +28 -28
  27. package/dist/src/config/mainnet/tokens.d.ts.map +1 -1
  28. package/dist/src/config/testnet/tokens.d.ts.map +1 -1
  29. package/dist/src/hooks/useWalletCompatibility.d.ts +14 -0
  30. package/dist/src/hooks/useWalletCompatibility.d.ts.map +1 -0
  31. package/dist/src/utils/index.d.ts +1 -1
  32. package/dist/src/utils/index.d.ts.map +1 -1
  33. package/dist/src/utils/wallet/aptos.d.ts.map +1 -1
  34. package/dist/src/views/v2/Bridge/index.d.ts.map +1 -1
  35. package/lib/{aptos-BZuWMk3D.mjs → aptos-BADK10fB.mjs} +871 -870
  36. package/lib/{aptos-2J8A-FZO.mjs → aptos-CNLtQdwF.mjs} +59 -57
  37. package/lib/{aptos-DL1Hgg15.js → aptos-DeODB5kZ.js} +4 -4
  38. package/lib/aptos-DhXgHrnl.js +2 -0
  39. package/lib/{base64-Bit1A1if.js → base64-CEPDNsRw.js} +1 -1
  40. package/lib/{base64-BdSgqiJl.mjs → base64-w49IrkvT.mjs} +1 -1
  41. package/lib/{ccip-CMkUITDS.js → ccip-PRIyWWAN.js} +1 -1
  42. package/lib/{ccip-Cw8-T0j-.mjs → ccip-VK5volw3.mjs} +1 -1
  43. package/lib/{chunk-U2PRGW4O-CMIP41vB.mjs → chunk-U2PRGW4O-Ch5UM-YX.mjs} +6 -3
  44. package/lib/{chunk-U2PRGW4O-CuEEOygo.js → chunk-U2PRGW4O-D9odrfIU.js} +5 -5
  45. package/lib/{events-Bs7CEKn9.js → events-Bu0pqh5u.js} +1 -1
  46. package/lib/{events-CpDIhB3C.mjs → events-jOp8E97m.mjs} +1 -1
  47. package/lib/{evm-CK7UNFtq.js → evm-3jPN9QHX.js} +1 -1
  48. package/lib/{evm-DfX7cWQI.mjs → evm-B13HZSOG.mjs} +6 -6
  49. package/lib/{evm-1S_EvV1A.mjs → evm-CZgBqG6_.mjs} +7 -7
  50. package/lib/{evm-D5NO24dh.js → evm-Y4sMK_A1.js} +4 -4
  51. package/lib/index-1qQOAFE2.mjs +102 -0
  52. package/lib/{index-C6iaLaJq.mjs → index-BAhBSTHO.mjs} +18418 -18338
  53. package/lib/{index-wW7H3ciQ.mjs → index-BDForJp0.mjs} +2 -2
  54. package/lib/{index-CqSLXgKG.js → index-BFbkaHZM.js} +1 -1
  55. package/lib/{index-CqfWDHV0.mjs → index-BHdCskLu.mjs} +2 -2
  56. package/lib/{index-DKZeU-Xf.js → index-BRf1dmcD.js} +1 -1
  57. package/lib/{index-BPtbGGHy.mjs → index-BVuV_rfV.mjs} +3 -3
  58. package/lib/{index-CXWWVJUC.js → index-BX2v7vz2.js} +1 -1
  59. package/lib/{index-Q-iWWETw.mjs → index-BZknHaxy.mjs} +70 -70
  60. package/lib/{index-CwNerYWM.js → index-Brzu_xNS.js} +1 -1
  61. package/lib/{index-D_BTWvYp.mjs → index-BuWkXqNE.mjs} +2 -2
  62. package/lib/{index-BXPqhxjc.js → index-C2Rk8dJm.js} +1 -1
  63. package/lib/{index-C8__BuqK.mjs → index-CKnJa2J4.mjs} +1 -1
  64. package/lib/{index-DhxGcoTC.mjs → index-CdUjuPf9.mjs} +5 -5
  65. package/lib/{index-D5xkWCZ3.mjs → index-CkQ2SX_N.mjs} +48 -57
  66. package/lib/{index-o0AEhklr.mjs → index-CpOpT2eM.mjs} +2 -2
  67. package/lib/{index-hk3iRhUd.mjs → index-CtVdS94F.mjs} +4 -4
  68. package/lib/{index-8nlb2LGX.js → index-CzRLTmkg.js} +1 -1
  69. package/lib/{index-DbiW1-3L.mjs → index-D4DQMA-o.mjs} +1 -1
  70. package/lib/{index-hIJ0h_GZ.js → index-D5ta6SAe.js} +91 -91
  71. package/lib/{index-v3UQ6KEC.js → index-D9KxVP2I.js} +1 -1
  72. package/lib/index-DBmgmviv.js +1 -0
  73. package/lib/{index-S1YybQMR.js → index-DFS9XfYE.js} +1 -1
  74. package/lib/{index-7_XTrYay.js → index-DL5itoYd.js} +1 -1
  75. package/lib/index-DOqilxLu.js +1 -0
  76. package/lib/{index-C42d1PS9.js → index-DT5QhFiG.js} +1 -1
  77. package/lib/{index-CbJWXG7l.mjs → index-DcL6du1P.mjs} +2 -2
  78. package/lib/{index-7Jgokx3S.js → index-DfRhe8kL.js} +1 -1
  79. package/lib/{index-B96enquk.js → index-DjDJigyM.js} +1 -1
  80. package/lib/{index-BNn38QYa.mjs → index-DkNDirHr.mjs} +2 -2
  81. package/lib/{index-BfBNSTY8.js → index-Dr6Wkn1g.js} +1 -1
  82. package/lib/{index-D2Bw_LRJ.js → index-Dw4_1FXq.js} +1 -1
  83. package/lib/{index-Cqiy61ub.mjs → index-DzeE34W2.mjs} +1 -1
  84. package/lib/{index-TVlE0v9D.js → index-EVkJCI6W.js} +1 -1
  85. package/lib/{index-vWXFBAHR.js → index-OdUgDqqR.js} +1 -1
  86. package/lib/{index-B-ZKCWaX.js → index-dYeh9TN5.js} +1 -1
  87. package/lib/{index-BDbrAqgW.mjs → index-hnhyQbEN.mjs} +5 -5
  88. package/lib/{index-Bm1zXhFz.mjs → index-ieIOqnbv.mjs} +1 -1
  89. package/lib/{index-B-UHVwW1.mjs → index-v8vynoP2.mjs} +2 -2
  90. package/lib/{index-BzHjroj_.mjs → index-yIiSwVLU.mjs} +2 -2
  91. package/lib/{index.es-DN28d137.js → index.es-D9Co2OZW.js} +2 -2
  92. package/lib/{index.es-BnuWmVuS.mjs → index.es-jvUS3_-Z.mjs} +5 -5
  93. package/lib/index.js +1 -1
  94. package/lib/index.mjs +1 -1
  95. package/lib/{signer-YETmMcF8.js → signer-BvZ7J3Rl.js} +1 -1
  96. package/lib/{signer-D5i4Nnyi.mjs → signer-CsfCFMWy.mjs} +1 -1
  97. package/lib/solana-BD_xWaS3.js +1 -0
  98. package/lib/{solana-C7qBFXj3.js → solana-BfiZpxkP.js} +1 -1
  99. package/lib/solana-ChpC_WNg.mjs +16 -0
  100. package/lib/{solana-DtBRFbad.mjs → solana-Dh_0HpA8.mjs} +4 -4
  101. package/lib/{solanaEmbed.esm-BER_HE9G.js → solanaEmbed.esm-B3b-A7RS.js} +1 -1
  102. package/lib/{solanaEmbed.esm-Bb5iLp3o.mjs → solanaEmbed.esm-BCE4UL9u.mjs} +2 -2
  103. package/lib/src/config/mainnet/tokens.d.ts.map +1 -1
  104. package/lib/src/config/testnet/tokens.d.ts.map +1 -1
  105. package/lib/src/hooks/useWalletCompatibility.d.ts +14 -0
  106. package/lib/src/hooks/useWalletCompatibility.d.ts.map +1 -0
  107. package/lib/src/utils/index.d.ts +1 -1
  108. package/lib/src/utils/index.d.ts.map +1 -1
  109. package/lib/src/utils/wallet/aptos.d.ts.map +1 -1
  110. package/lib/src/views/v2/Bridge/index.d.ts.map +1 -1
  111. package/lib/{sui-De3Fl_fo.js → sui-BhOuuPtT.js} +1 -1
  112. package/lib/{sui-1QFb30Ta.mjs → sui-Cc0SlN9d.mjs} +1 -1
  113. package/lib/{sui-DAyysPh2.mjs → sui-DmasAl1E.mjs} +5 -5
  114. package/lib/{sui-c1d9xieM.js → sui-RIp5yjOC.js} +2 -2
  115. package/lib/unsignedTransaction-BDOQhqcZ.mjs +16 -0
  116. package/lib/unsignedTransaction-C1YeEl4G.js +1 -0
  117. package/lib/{utf8-BxTDE5Vo.mjs → utf8-V9eCtEDc.mjs} +1 -1
  118. package/lib/{utf8-B-nUZvyF.js → utf8-lSE3VJ2A.js} +1 -1
  119. package/package.json +17 -17
  120. package/dist/assets/aptos-De-iCK2S.js +0 -3
  121. package/dist/assets/evm-BBq1KqPa.js +0 -2
  122. package/dist/assets/index-LPMvkG3A.js +0 -1
  123. package/dist/assets/solana-DTptRMWs.js +0 -2
  124. package/lib/aptos-DcCwQMe7.js +0 -2
  125. package/lib/index-Bq2G38s-.js +0 -1
  126. package/lib/solana-B9GQ_Umb.js +0 -1
  127. package/lib/solana-tevnHUxv.mjs +0 -16
@@ -1,5 +1,5 @@
1
- "use strict";var on=Object.defineProperty;var cn=(t,e,r)=>e in t?on(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pe=(t,e,r)=>cn(t,typeof e!="symbol"?e+"":e,r);const d=require("./index-hIJ0h_GZ.js"),kt=require("./index-B-ZKCWaX.js");function H(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const st=8192;function $(t){if(t.length<st)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=st){const n=t.slice(r,r+st);e+=String.fromCharCode(...n)}return btoa(e)}function Ue(t){var s;const e=t.startsWith("0x")?t.slice(2):t,n=((s=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];return Uint8Array.from(n)}function ge(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function xt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function un(t){let e=0,r=0,n=0;for(;;){let s=t[n];if(n+=1,e|=(s&127)<<r,!(s&128))break;r+=7}return{value:e,length:n}}class fr{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:s}=un(r);return this.shift(s),n}readVec(e){let r=this.readULEB(),n=[];for(let s=0;s<r;s++)n.push(e(this,s,r));return n}}function dn(t,e){switch(e){case"base58":return d.toB58(t);case"base64":return $(t);case"hex":return ge(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function ln(t,e){switch(e){case"base58":return d.fromB58(t);case"base64":return H(t);case"hex":return Ue(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function gr(t,e=["<",">"]){const[r,n]=e,s=[];let i="",a=0;for(let o=0;o<t.length;o++){const u=t[o];if(u===r&&a++,u===n&&a--,a===0&&u===","){s.push(i.trim()),i="";continue}i+=u}return s.push(i.trim()),s}class pr{constructor({size:e=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=r||e,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const r=this.bytePosition+e;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const s=new ArrayBuffer(this.size);new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(s)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return it(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return it(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return it(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return xt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,s)=>r(this,n,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return dn(this.toBytes(),e)}}function it(t,e){let r=new Uint8Array(e),n=0;for(;t>0;)r[n]=Number(t%BigInt(256)),t=t/BigInt(256),n+=1;return r}var yr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},W=(t,e,r)=>(yr(t,e,"read from private field"),r?r.call(t):e.get(t)),Ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Je=(t,e,r,n)=>(yr(t,e,"write to private field"),e.set(t,r),r),ye,ke,We,ae;const mr=class{constructor(t){Ze(this,ye,void 0),Ze(this,ke,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),Je(this,ye,t.write),Je(this,ke,t.serialize??((e,r)=>{const n=new pr({size:this.serializedSize(e)??void 0,...r});return W(this,ye).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),W(this,ye).call(this,t,e)}serialize(t,e){return this.validate(t),new hn(this,W(this,ke).call(this,t,e))}parse(t){const e=new fr(t);return this.read(e)}transform({name:t,input:e,output:r}){return new mr({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>W(this,ye).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>W(this,ke).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let K=mr;ye=new WeakMap;ke=new WeakMap;const wr=Symbol.for("@mysten/serialized-bcs");function _t(t){return!!t&&typeof t=="object"&&t[wr]===!0}class hn{constructor(e,r){Ze(this,We,void 0),Ze(this,ae,void 0),Je(this,We,e),Je(this,ae,r)}get[wr](){return!0}toBytes(){return W(this,ae)}toHex(){return ge(W(this,ae))}toBase64(){return $(W(this,ae))}toBase58(){return d.toB58(W(this,ae))}parse(){return W(this,We).parse(W(this,ae))}}We=new WeakMap;ae=new WeakMap;function Xe({size:t,...e}){return new K({...e,serializedSize:()=>t})}function at({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](n),validate:n=>{var s;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,n)}})}function ot({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](BigInt(n)),validate:n=>{var i;const s=BigInt(n);if(s<0||s>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${s}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,s)}})}function fn({serialize:t,...e}){const r=new K({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function gn({toBytes:t,fromBytes:e,...r}){return new K({...r,read:n=>{const s=n.readULEB(),i=n.readBytes(s);return e(i)},write:(n,s)=>{const i=t(n);s.writeULEB(i.length);for(let a=0;a<i.length;a++)s.write8(i[a])},serialize:n=>{const s=t(n),i=xt(s.length),a=new Uint8Array(i.length+s.length);return a.set(i,0),a.set(s,i.length),a},validate:n=>{var s;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(s=r.validate)==null||s.call(r,n)}})}function pn(t){let e=null;function r(){return e||(e=t()),e}return new K({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,s)=>r().write(n,s),serialize:(n,s)=>r().serialize(n,s).toBytes()})}const c={u8(t){return at({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return at({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return at({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return ot({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return ot({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return ot({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Xe({name:"bool",size:1,read:e=>e.read8()===1,write:(e,r)=>r.write8(e?1:0),...t,validate:e=>{var r;if((r=t==null?void 0:t.validate)==null||r.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return fn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(xt(e)),...t})},bytes(t,e){return Xe({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let s=0;s<t;s++)n.write8(r[s]??0)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t)throw new TypeError(`Expected array of length ${t}, found ${r.length}`)}})},string(t){return gn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new K({name:`${e.name}[${t}]`,read:n=>{const s=new Array(t);for(let i=0;i<t;i++)s[i]=e.read(n);return s},write:(n,s)=>{for(const i of n)e.write(i,s)},...r,validate:n=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,n),!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==t)throw new TypeError(`Expected array of length ${t}, found ${n.length}`)}})},option(t){return c.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>"Some"in e?e.Some:null})},vector(t,e){return new K({name:`vector<${t.name}>`,read:r=>{const n=r.readULEB(),s=new Array(n);for(let i=0;i<n;i++)s[i]=t.read(r);return s},write:(r,n)=>{n.writeULEB(r.length);for(const s of r)t.write(s,n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`)}})},tuple(t,e){return new K({name:`(${t.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let s=0;s<t.length;s++){const i=t[s].serializedSize(r[s]);if(i==null)return null;n+=i}return n},read:r=>{const n=[];for(const s of t)n.push(s.read(r));return n},write:(r,n)=>{for(let s=0;s<t.length;s++)t[s].write(r[s],n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!Array.isArray(r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t.length)throw new TypeError(`Expected array of length ${t.length}, found ${r.length}`)}})},struct(t,e,r){const n=Object.entries(e);return new K({name:t,serializedSize:s=>{let i=0;for(const[a,o]of n){const u=o.serializedSize(s[a]);if(u==null)return null;i+=u}return i},read:s=>{const i={};for(const[a,o]of n)i[a]=o.read(s);return i},write:(s,i)=>{for(const[a,o]of n)o.write(s[a],i)},...r,validate:s=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`)}})},enum(t,e,r){const n=Object.entries(e);return new K({name:t,read:s=>{const i=s.readULEB(),[a,o]=n[i];return{[a]:(o==null?void 0:o.read(s))??!0}},write:(s,i)=>{const[a,o]=Object.entries(s)[0];for(let u=0;u<n.length;u++){const[l,f]=n[u];if(l===a){i.writeULEB(u),f==null||f.write(o,i);return}}},...r,validate:s=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`);const i=Object.keys(s);if(i.length!==1)throw new TypeError(`Expected object with one key, found ${i.length}`);const[a]=i;if(!Object.hasOwn(e,a))throw new TypeError(`Invalid enum variant ${a}`)}})},map(t,e){return c.vector(c.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[s,i]of r)n.set(s,i);return n}})},generic(t,e){return(...r)=>e(...r).transform({name:`${e.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(t){return pn(t)}},yn=32,xe=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof xe){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(xe.ADDRESS,t.addressLength,t.addressEncoding),this.registerVectorType(t.vectorType),t.types&&t.types.structs)for(let e of Object.keys(t.types.structs))this.registerStructType(e,t.types.structs[e]);if(t.types&&t.types.enums)for(let e of Object.keys(t.types.enums))this.registerEnumType(e,t.types.enums[e]);if(t.types&&t.types.aliases)for(let e of Object.keys(t.types.aliases))this.registerAlias(e,t.types.aliases[e]);t.withPrimitives!==!1&&mn(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,s)}if(typeof t=="object"){const n=this.tempKey();return new xe(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
1
+ "use strict";var on=Object.defineProperty;var cn=(t,e,r)=>e in t?on(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pe=(t,e,r)=>cn(t,typeof e!="symbol"?e+"":e,r);const d=require("./index-D5ta6SAe.js"),kt=require("./index-dYeh9TN5.js");function H(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const st=8192;function $(t){if(t.length<st)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=st){const n=t.slice(r,r+st);e+=String.fromCharCode(...n)}return btoa(e)}function Ue(t){var s;const e=t.startsWith("0x")?t.slice(2):t,n=((s=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];return Uint8Array.from(n)}function ge(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function xt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function un(t){let e=0,r=0,n=0;for(;;){let s=t[n];if(n+=1,e|=(s&127)<<r,!(s&128))break;r+=7}return{value:e,length:n}}class fr{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:s}=un(r);return this.shift(s),n}readVec(e){let r=this.readULEB(),n=[];for(let s=0;s<r;s++)n.push(e(this,s,r));return n}}function dn(t,e){switch(e){case"base58":return d.toB58(t);case"base64":return $(t);case"hex":return ge(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function ln(t,e){switch(e){case"base58":return d.fromB58(t);case"base64":return H(t);case"hex":return Ue(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function gr(t,e=["<",">"]){const[r,n]=e,s=[];let i="",a=0;for(let o=0;o<t.length;o++){const u=t[o];if(u===r&&a++,u===n&&a--,a===0&&u===","){s.push(i.trim()),i="";continue}i+=u}return s.push(i.trim()),s}class pr{constructor({size:e=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=r||e,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const r=this.bytePosition+e;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const s=new ArrayBuffer(this.size);new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(s)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return it(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return it(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return it(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return xt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,s)=>r(this,n,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return dn(this.toBytes(),e)}}function it(t,e){let r=new Uint8Array(e),n=0;for(;t>0;)r[n]=Number(t%BigInt(256)),t=t/BigInt(256),n+=1;return r}var yr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},W=(t,e,r)=>(yr(t,e,"read from private field"),r?r.call(t):e.get(t)),Ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Je=(t,e,r,n)=>(yr(t,e,"write to private field"),e.set(t,r),r),ye,ke,We,ae;const mr=class{constructor(t){Ze(this,ye,void 0),Ze(this,ke,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),Je(this,ye,t.write),Je(this,ke,t.serialize??((e,r)=>{const n=new pr({size:this.serializedSize(e)??void 0,...r});return W(this,ye).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),W(this,ye).call(this,t,e)}serialize(t,e){return this.validate(t),new hn(this,W(this,ke).call(this,t,e))}parse(t){const e=new fr(t);return this.read(e)}transform({name:t,input:e,output:r}){return new mr({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>W(this,ye).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>W(this,ke).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let K=mr;ye=new WeakMap;ke=new WeakMap;const wr=Symbol.for("@mysten/serialized-bcs");function _t(t){return!!t&&typeof t=="object"&&t[wr]===!0}class hn{constructor(e,r){Ze(this,We,void 0),Ze(this,ae,void 0),Je(this,We,e),Je(this,ae,r)}get[wr](){return!0}toBytes(){return W(this,ae)}toHex(){return ge(W(this,ae))}toBase64(){return $(W(this,ae))}toBase58(){return d.toB58(W(this,ae))}parse(){return W(this,We).parse(W(this,ae))}}We=new WeakMap;ae=new WeakMap;function Xe({size:t,...e}){return new K({...e,serializedSize:()=>t})}function at({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](n),validate:n=>{var s;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,n)}})}function ot({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](BigInt(n)),validate:n=>{var i;const s=BigInt(n);if(s<0||s>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${s}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,s)}})}function fn({serialize:t,...e}){const r=new K({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function gn({toBytes:t,fromBytes:e,...r}){return new K({...r,read:n=>{const s=n.readULEB(),i=n.readBytes(s);return e(i)},write:(n,s)=>{const i=t(n);s.writeULEB(i.length);for(let a=0;a<i.length;a++)s.write8(i[a])},serialize:n=>{const s=t(n),i=xt(s.length),a=new Uint8Array(i.length+s.length);return a.set(i,0),a.set(s,i.length),a},validate:n=>{var s;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(s=r.validate)==null||s.call(r,n)}})}function pn(t){let e=null;function r(){return e||(e=t()),e}return new K({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,s)=>r().write(n,s),serialize:(n,s)=>r().serialize(n,s).toBytes()})}const c={u8(t){return at({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return at({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return at({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return ot({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return ot({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return ot({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Xe({name:"bool",size:1,read:e=>e.read8()===1,write:(e,r)=>r.write8(e?1:0),...t,validate:e=>{var r;if((r=t==null?void 0:t.validate)==null||r.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return fn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(xt(e)),...t})},bytes(t,e){return Xe({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let s=0;s<t;s++)n.write8(r[s]??0)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t)throw new TypeError(`Expected array of length ${t}, found ${r.length}`)}})},string(t){return gn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new K({name:`${e.name}[${t}]`,read:n=>{const s=new Array(t);for(let i=0;i<t;i++)s[i]=e.read(n);return s},write:(n,s)=>{for(const i of n)e.write(i,s)},...r,validate:n=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,n),!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==t)throw new TypeError(`Expected array of length ${t}, found ${n.length}`)}})},option(t){return c.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>"Some"in e?e.Some:null})},vector(t,e){return new K({name:`vector<${t.name}>`,read:r=>{const n=r.readULEB(),s=new Array(n);for(let i=0;i<n;i++)s[i]=t.read(r);return s},write:(r,n)=>{n.writeULEB(r.length);for(const s of r)t.write(s,n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`)}})},tuple(t,e){return new K({name:`(${t.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let s=0;s<t.length;s++){const i=t[s].serializedSize(r[s]);if(i==null)return null;n+=i}return n},read:r=>{const n=[];for(const s of t)n.push(s.read(r));return n},write:(r,n)=>{for(let s=0;s<t.length;s++)t[s].write(r[s],n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!Array.isArray(r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t.length)throw new TypeError(`Expected array of length ${t.length}, found ${r.length}`)}})},struct(t,e,r){const n=Object.entries(e);return new K({name:t,serializedSize:s=>{let i=0;for(const[a,o]of n){const u=o.serializedSize(s[a]);if(u==null)return null;i+=u}return i},read:s=>{const i={};for(const[a,o]of n)i[a]=o.read(s);return i},write:(s,i)=>{for(const[a,o]of n)o.write(s[a],i)},...r,validate:s=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`)}})},enum(t,e,r){const n=Object.entries(e);return new K({name:t,read:s=>{const i=s.readULEB(),[a,o]=n[i];return{[a]:(o==null?void 0:o.read(s))??!0}},write:(s,i)=>{const[a,o]=Object.entries(s)[0];for(let u=0;u<n.length;u++){const[l,f]=n[u];if(l===a){i.writeULEB(u),f==null||f.write(o,i);return}}},...r,validate:s=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`);const i=Object.keys(s);if(i.length!==1)throw new TypeError(`Expected object with one key, found ${i.length}`);const[a]=i;if(!Object.hasOwn(e,a))throw new TypeError(`Invalid enum variant ${a}`)}})},map(t,e){return c.vector(c.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[s,i]of r)n.set(s,i);return n}})},generic(t,e){return(...r)=>e(...r).transform({name:`${e.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(t){return pn(t)}},yn=32,xe=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof xe){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(xe.ADDRESS,t.addressLength,t.addressEncoding),this.registerVectorType(t.vectorType),t.types&&t.types.structs)for(let e of Object.keys(t.types.structs))this.registerStructType(e,t.types.structs[e]);if(t.types&&t.types.enums)for(let e of Object.keys(t.types.enums))this.registerEnumType(e,t.types.enums[e]);if(t.types&&t.types.aliases)for(let e of Object.keys(t.types.aliases))this.registerAlias(e,t.types.aliases[e]);t.withPrimitives!==!1&&mn(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,s)}if(typeof t=="object"){const n=this.tempKey();return new xe(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
2
2
  ${JSON.stringify(t)}`)}de(t,e,r){if(typeof e=="string")if(r)e=ln(e,r);else throw new Error("To pass a string to `bcs.de`, specify encoding");if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).decode(this,e,s)}if(typeof t=="object"){const n=new xe(this),s=this.tempKey();return n.registerStructType(s,t).de(s,e,r)}throw new Error(`Incorrect type passed into the '.de()' function.
3
3
  ${JSON.stringify(t)}`)}hasType(t){return this.types.has(t)}registerAlias(t,e){return this.types.set(t,e),this}registerType(t,e,r,n=()=>!0){const{name:s,params:i}=this.parseTypeName(t);return this.types.set(s,{encode(a,o,u,l){const f=i.reduce((p,y,m)=>Object.assign(p,{[y]:l[m]}),{});return this._encodeRaw.call(a,new pr(u),o,l,f)},decode(a,o,u){const l=i.reduce((f,p,y)=>Object.assign(f,{[p]:u[y]}),{});return this._decodeRaw.call(a,new fr(o),u,l)},_encodeRaw(a,o,u,l){if(n(o))return e.call(this,a,o,u,l);throw new Error(`Validation failed for type ${s}, data: ${o}`)},_decodeRaw(a,o,u){return r.call(this,a,o,u)}}),this}registerBcsType(t,e){return this.registerType(t,(r,n,s)=>{const i=s.map(a=>new K({name:String(a),write:(o,u)=>{const{name:l,params:f}=this.parseTypeName(a),p=this.getTypeInterface(l),y=f.reduce((m,x,T)=>Object.assign(m,{[x]:s[T]}),{});return p._encodeRaw.call(this,u,o,f,y)},read:()=>{throw new Error("Not implemented")}}));return e(...i).write(n,r),r},(r,n)=>{const s=n.map(i=>new K({name:String(i),write:(a,o)=>{throw new Error("Not implemented")},read:a=>{const{name:o,params:u}=this.parseTypeName(i),l=this.getTypeInterface(o),f=u.reduce((p,y,m)=>Object.assign(p,{[y]:n[m]}),{});return l._decodeRaw.call(this,a,u,f)}}));return e(...s).read(r)}),this}registerAddressType(t,e,r="hex"){switch(r){case"base64":return this.registerType(t,function(s,i){return H(i).reduce((a,o)=>a.write8(o),s)},function(s){return $(s.readBytes(e))});case"hex":return this.registerType(t,function(s,i){return Ue(i).reduce((a,o)=>a.write8(o),s)},function(s){return ge(s.readBytes(e))});default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(t){let{name:e,params:r}=this.parseTypeName(t);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+e);return this.registerType(t,function(s,i,a,o){return s.writeVec(i,(u,l)=>{let f=a[0];if(!f)throw new Error(`Incorrect number of type parameters passed a to vector '${t}'`);let{name:p,params:y}=this.parseTypeName(f);if(this.hasType(p))return this.getTypeInterface(p)._encodeRaw.call(this,u,l,y,o);if(!(p in o))throw new Error(`Unable to find a matching type definition for ${p} in vector; make sure you passed a generic`);let{name:m,params:x}=this.parseTypeName(o[p]);return this.getTypeInterface(m)._encodeRaw.call(this,u,l,x,o)})},function(s,i,a){return s.readVec(o=>{let u=i[0];if(!u)throw new Error(`Incorrect number of type parameters passed to a vector '${t}'`);let{name:l,params:f}=this.parseTypeName(u);if(this.hasType(l))return this.getTypeInterface(l)._decodeRaw.call(this,o,f,a);if(!(l in a))throw new Error(`Unable to find a matching type definition for ${l} in vector; make sure you passed a generic`);let{name:p,params:y}=this.parseTypeName(a[l]);return this.getTypeInterface(p)._decodeRaw.call(this,o,y,a)})})}registerStructType(t,e){for(let a in e){let o=this.tempKey(),u=e[a];!Array.isArray(u)&&typeof u!="string"&&(e[a]=o,this.registerStructType(o,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,u,l,f){if(!u||u.constructor!==Object)throw new Error(`Expected ${s} to be an Object, got: ${u}`);if(l.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${l.length}`);for(let p of n){if(!(p in u))throw new Error(`Struct ${s} requires field ${p}:${r[p]}`);const{name:y,params:m}=this.parseTypeName(r[p]);if(!i.includes(y))this.getTypeInterface(y)._encodeRaw.call(this,o,u[p],m,f);else{const x=i.indexOf(y);let{name:T,params:C}=this.parseTypeName(l[x]);if(this.hasType(T)){this.getTypeInterface(T)._encodeRaw.call(this,o,u[p],C,f);continue}if(!(T in f))throw new Error(`Unable to find a matching type definition for ${T} in ${s}; make sure you passed a generic`);let{name:M,params:se}=this.parseTypeName(f[T]);this.getTypeInterface(M)._encodeRaw.call(this,o,u[p],se,f)}}return o},function(o,u,l){if(u.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${u.length}`);let f={};for(let p of n){const{name:y,params:m}=this.parseTypeName(r[p]);if(!i.includes(y))f[p]=this.getTypeInterface(y)._decodeRaw.call(this,o,m,l);else{const x=i.indexOf(y);let{name:T,params:C}=this.parseTypeName(u[x]);if(this.hasType(T)){f[p]=this.getTypeInterface(T)._decodeRaw.call(this,o,C,l);continue}if(!(T in l))throw new Error(`Unable to find a matching type definition for ${T} in ${s}; make sure you passed a generic`);let{name:M,params:se}=this.parseTypeName(l[T]);f[p]=this.getTypeInterface(M)._decodeRaw.call(this,o,se,l)}}return f})}registerEnumType(t,e){for(let a in e){let o=this.tempKey(),u=e[a];u!==null&&!Array.isArray(u)&&typeof u!="string"&&(e[a]=o,this.registerStructType(o,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,u,l,f){if(!u)throw new Error(`Unable to write enum "${s}", missing data.
4
4
  Received: "${u}"`);if(typeof u!="object")throw new Error(`Incorrect data passed into enum "${s}", expected object with properties: "${n.join(" | ")}".
5
- Received: "${JSON.stringify(u)}"`);let p=Object.keys(u)[0];if(p===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let y=n.indexOf(p);if(y===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${p}"`);let m=n[y],x=r[m];if(o.write8(y),x===null)return o;let T=i.indexOf(x),C=T===-1?x:l[T];{let{name:M,params:se}=this.parseTypeName(C);return this.getTypeInterface(M)._encodeRaw.call(this,o,u[p],se,f)}},function(o,u,l){let f=o.readULEB(),p=n[f],y=r[p];if(f===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${f}"`);if(y===null)return{[p]:!0};let m=i.indexOf(y),x=m===-1?y:u[m];{let{name:T,params:C}=this.parseTypeName(x);return{[p]:this.getTypeInterface(T)._decodeRaw.call(this,o,C,l)}}})}getTypeInterface(t){let e=this.types.get(t);if(typeof e=="string"){let r=[];for(;typeof e=="string";){if(r.includes(e))throw new Error(`Recursive definition found: ${r.join(" -> ")} -> ${e}`);r.push(e),e=this.types.get(e)}}if(e===void 0)throw new Error(`Type ${t} is not registered`);return e}parseTypeName(t){if(Array.isArray(t)){let[o,...u]=t;return{name:o,params:u}}if(typeof t!="string")throw new Error(`Illegal type passed as a name of the type: ${t}`);let[e,r]=this.schema.genericSeparators||["<",">"],n=t.indexOf(e),s=Array.from(t).reverse().indexOf(r);if(n===-1&&s===-1)return{name:t,params:[]};if(n===-1||s===-1)throw new Error(`Unclosed generic in name '${t}'`);let i=t.slice(0,n),a=gr(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let _=xe;_.U8="u8";_.U16="u16";_.U32="u32";_.U64="u64";_.U128="u128";_.U256="u256";_.BOOL="bool";_.VECTOR="vector";_.ADDRESS="address";_.STRING="string";_.HEX="hex-string";_.BASE58="base58-string";_.BASE64="base64-string";function mn(t){t.registerType(_.U8,function(e,r){return e.write8(r)},function(e){return e.read8()},e=>e<256),t.registerType(_.U16,function(e,r){return e.write16(r)},function(e){return e.read16()},e=>e<65536),t.registerType(_.U32,function(e,r){return e.write32(r)},function(e){return e.read32()},e=>e<=4294967296n),t.registerType(_.U64,function(e,r){return e.write64(r)},function(e){return e.read64()}),t.registerType(_.U128,function(e,r){return e.write128(r)},function(e){return e.read128()}),t.registerType(_.U256,function(e,r){return e.write256(r)},function(e){return e.read256()}),t.registerType(_.BOOL,function(e,r){return e.write8(r)},function(e){return e.read8().toString(10)==="1"}),t.registerType(_.STRING,function(e,r){return e.writeVec(Array.from(r),(n,s)=>n.write8(s.charCodeAt(0)))},function(e){return e.readVec(r=>r.read8()).map(r=>String.fromCharCode(Number(r))).join("")},e=>!0),t.registerType(_.HEX,function(e,r){return e.writeVec(Array.from(Ue(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return ge(new Uint8Array(r))}),t.registerType(_.BASE58,function(e,r){return e.writeVec(Array.from(d.fromB58(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return d.toB58(new Uint8Array(r))}),t.registerType(_.BASE64,function(e,r){return e.writeVec(Array.from(H(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return $(new Uint8Array(r))})}function wn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:yn,addressEncoding:"hex"}}class bn extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:o}=e,u=o.length===0?s:`At path: ${o.join(".")} -- ${s}`;super(i??u),i!=null&&(this.cause=u),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Sn(t){return V(t)&&typeof t[Symbol.iterator]=="function"}function V(t){return typeof t=="object"&&t!=null}function L(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function Tn(t){const{done:e,value:r}=t.next();return e?void 0:r}function En(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:s,branch:i}=e,{type:a}=r,{refinement:o,message:u=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${L(n)}\``}=t;return{value:n,type:a,refinement:o,key:s[s.length-1],path:s,branch:i,...t,message:u}}function*sr(t,e,r,n){Sn(t)||(t=[t]);for(const s of t){const i=En(s,e,r,n);i&&(yield i)}}function*At(t,e,r={}){const{path:n=[],branch:s=[t],coerce:i=!1,mask:a=!1}=r,o={path:n,branch:s};if(i&&(t=e.coercer(t,o),a&&e.type!=="type"&&V(e.schema)&&V(t)&&!Array.isArray(t)))for(const l in t)e.schema[l]===void 0&&delete t[l];let u="valid";for(const l of e.validator(t,o))l.explanation=r.message,u="not_valid",yield[l,void 0];for(let[l,f,p]of e.entries(t,o)){const y=At(f,p,{path:l===void 0?n:[...n,l],branch:l===void 0?s:[...s,f],coerce:i,mask:a,message:r.message});for(const m of y)m[0]?(u=m[0].refinement!=null?"not_refined":"not_valid",yield[m[0],void 0]):i&&(f=m[1],l===void 0?t=f:t instanceof Map?t.set(l,f):t instanceof Set?t.add(f):V(t)&&(f!==void 0||l in t)&&(t[l]=f))}if(u!=="not_valid")for(const l of e.refiner(t,o))l.explanation=r.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,t])}class X{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=u=>u,entries:o=function*(){}}=e;this.type=r,this.schema=n,this.entries=o,this.coercer=a,s?this.validator=(u,l)=>{const f=s(u,l);return sr(f,l,this,u)}:this.validator=()=>[],i?this.refiner=(u,l)=>{const f=i(u,l);return sr(f,l,this,u)}:this.refiner=()=>[]}assert(e,r){return lt(e,this,r)}create(e,r){return br(e,this,r)}is(e){return U(e,this)}mask(e,r){return Sr(e,this,r)}validate(e,r={}){return De(e,this,r)}}function lt(t,e,r){const n=De(t,e,{message:r});if(n[0])throw n[0]}function br(t,e,r){const n=De(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Sr(t,e,r){const n=De(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function U(t,e){return!De(t,e)[0]}function De(t,e,r={}){const n=At(t,e,r),s=Tn(n);return s[0]?[new bn(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Ce(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?kn(n):g(n)}function D(t,e){return new X({type:t,schema:null,validator:e})}function ht(){return D("any",()=>!0)}function E(t){return new X({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${L(e)}`}})}function vn(){return D("bigint",t=>typeof t=="bigint")}function P(){return D("boolean",t=>typeof t=="boolean")}function J(){return D("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${L(t)}`)}function b(t){const e=L(t),r=typeof t;return new X({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${L(n)}`}})}function Tr(){return D("never",()=>!1)}function O(t){return new X({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function he(){return D("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${L(t)}`)}function g(t){const e=t?Object.keys(t):[],r=Tr();return new X({type:"object",schema:t||null,*entries(n){if(t&&V(n)){const s=new Set(Object.keys(n));for(const i of e)s.delete(i),yield[i,n[i],t[i]];for(const i of s)yield[i,n[i],r]}},validator(n){return V(n)||`Expected an object, but received: ${L(n)}`},coercer(n){return V(n)?{...n}:n}})}function w(t){return new X({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Z(t,e){return new X({type:"record",schema:null,*entries(r){if(V(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`}})}function h(){return D("string",t=>typeof t=="string"||`Expected a string, but received: ${L(t)}`)}function Er(t){const e=Tr();return new X({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let s=0;s<n;s++)yield[s,r[s],t[s]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${L(r)}`}})}function kn(t){const e=Object.keys(t);return new X({type:"type",schema:t,*entries(r){if(V(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`},coercer(r){return V(r)?{...r}:r}})}function j(t){const e=t.map(r=>r.type).join(" | ");return new X({type:"union",schema:null,coercer(r){for(const n of t){const[s,i]=n.validate(r,{coerce:!0});if(!s)return i}return r},validator(r,n){const s=[];for(const i of t){const[...a]=At(r,i,n),[o]=a;if(o[0])for(const[u]of a)u&&s.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${L(r)}`,...s]}})}function vr(){return D("unknown",()=>!0)}const xn="0.50.1",_n="1.19.0",An={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class kr extends Error{}class xr extends kr{constructor(e,r){super(e),this.code=r,this.type=An[r]??"ServerError"}}class In extends kr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var It=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},A=(t,e,r)=>(It(t,e,"read from private field"),r?r.call(t):e.get(t)),ie=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},we=(t,e,r,n)=>(It(t,e,"write to private field"),e.set(t,r),r),On=(t,e,r,n)=>({set _(s){we(t,e,s)},get _(){return A(t,e,n)}}),_r=(t,e,r)=>(It(t,e,"access private method"),r),de,Oe,ee,le,Be,be,ft,Ar,Ot,Ir;function jn(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const Cn={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class Bn{constructor(e,r={}){if(ie(this,ft),ie(this,Ot),ie(this,de,0),ie(this,Oe,0),ie(this,ee,null),ie(this,le,null),ie(this,Be,new Set),ie(this,be,new Map),this.endpoint=e,this.options={...Cn,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=jn(this.endpoint))}async makeRequest(e,r){const n=await _r(this,ft,Ar).call(this);return new Promise((s,i)=>{we(this,de,A(this,de)+1),A(this,be).set(A(this,de),{resolve:s,reject:i,timeout:setTimeout(()=>{A(this,be).delete(A(this,de)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:A(this,de),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new xr(s.message,s.code);return i})}async subscribe(e){const r=new Mn(e);return A(this,Be).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}de=new WeakMap;Oe=new WeakMap;ee=new WeakMap;le=new WeakMap;Be=new WeakMap;be=new WeakMap;ft=new WeakSet;Ar=function(){return A(this,le)?A(this,le):(we(this,le,new Promise(t=>{var e;(e=A(this,ee))==null||e.close(),we(this,ee,new this.options.WebSocketConstructor(this.endpoint)),A(this,ee).addEventListener("open",()=>{we(this,Oe,0),t(A(this,ee))}),A(this,ee).addEventListener("close",()=>{On(this,Oe)._++,A(this,Oe)<=this.options.maxReconnects&&setTimeout(()=>{_r(this,Ot,Ir).call(this)},this.options.reconnectTimeout)}),A(this,ee).addEventListener("message",({data:r})=>{let n;try{n=JSON.parse(r)}catch(s){console.error(new Error(`Failed to parse RPC message: ${r}`,{cause:s}));return}if("id"in n&&n.id!=null&&A(this,be).has(n.id)){const{resolve:s,timeout:i}=A(this,be).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;A(this,Be).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),A(this,le))};Ot=new WeakSet;Ir=async function(){var t;return(t=A(this,ee))==null||t.close(),we(this,le,null),Promise.allSettled([...A(this,Be)].map(e=>e.subscribe(this)))};class Mn{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:r}=this;return this.subscribed=!1,r==null?!1:(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[r]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const r=await e.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=r)}}var jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},z=(t,e,r)=>(jt(t,e,"read from private field"),r?r.call(t):e.get(t)),ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},gt=(t,e,r,n)=>(jt(t,e,"write to private field"),e.set(t,r),r),Pn=(t,e,r)=>(jt(t,e,"access private method"),r),_e,F,je,pt,Or;class Rn{constructor(e){ze(this,pt),ze(this,_e,0),ze(this,F,void 0),ze(this,je,void 0),gt(this,F,e)}fetch(e,r){const n=z(this,F).fetch??globalThis.fetch;if(!this.fetch)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return n(e,r)}async request(e){var s,i;gt(this,_e,z(this,_e)+1);const r=await this.fetch(((s=z(this,F).rpc)==null?void 0:s.url)??z(this,F).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":xn,"Client-Target-Api-Version":_n,...(i=z(this,F).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:z(this,_e),method:e.method,params:e.params})});if(!r.ok)throw new In(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new xr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await Pn(this,pt,Or).call(this).subscribe(e);return async()=>!!await r()}}_e=new WeakMap;F=new WeakMap;je=new WeakMap;pt=new WeakSet;Or=function(){var t;if(!z(this,je)){const e=z(this,F).WebSocketConstructor??globalThis.WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");gt(this,je,new Bn(((t=z(this,F).websocket)==null?void 0:t.url)??z(this,F).url,{WebSocketConstructor:e,...z(this,F).websocket}))}return z(this,je)};const Nn=/^vector<(.+)>$/,$n=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class te{static parseFromStr(e,r=!1){if(e==="address")return{address:null};if(e==="bool")return{bool:null};if(e==="u8")return{u8:null};if(e==="u16")return{u16:null};if(e==="u32")return{u32:null};if(e==="u64")return{u64:null};if(e==="u128")return{u128:null};if(e==="u256")return{u256:null};if(e==="signer")return{signer:null};const n=e.match(Nn);if(n)return{vector:te.parseFromStr(n[1],r)};const s=e.match($n);if(s)return{struct:{address:r?d.normalizeSuiAddress(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:te.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return gr(e).map(n=>te.parseFromStr(n,r))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${te.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(te.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const k=new _({...wn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function jr(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function Un(t){return c.enum("Option",{None:null,Some:t})}function Ct(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const G=c.bytes(d.SUI_ADDRESS_LENGTH).transform({input:t=>typeof t=="string"?Ue(d.normalizeSuiAddress(t)):t,output:t=>d.normalizeSuiAddress(ge(t))}),Bt=c.vector(c.u8()).transform({name:"ObjectDigest",input:t=>d.fromB58(t),output:t=>d.toB58(new Uint8Array(t))}),Me=c.struct("SuiObjectRef",{objectId:G,version:c.u64(),digest:Bt}),Mt=c.struct("SharedObjectRef",{objectId:G,initialSharedVersion:c.u64(),mutable:c.bool()}),Ye=c.enum("ObjectArg",{ImmOrOwned:Me,Shared:Mt,Receiving:Me}),Pt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:Ye,ObjVec:c.vector(Ye)}),ve=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>ve),struct:c.lazy(()=>zt),u16:null,u32:null,u256:null}),q=Ct(c.enum("Argument",{GasCoin:null,Input:c.struct("Input",{index:c.u16()}),Result:c.struct("Result",{index:c.u16()}),NestedResult:c.struct("NestedResult",{index:c.u16(),resultIndex:c.u16()})})),Rt=c.struct("ProgrammableMoveCall",{package:G,module:c.string(),function:c.string(),type_arguments:c.vector(ve),arguments:c.vector(q)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>te.parseFromStr(i,!0));return{package:d.normalizeSuiAddress(e),module:r,function:n,type_arguments:s,arguments:t.arguments}},output:t=>({target:[t.package,t.module,t.function].join("::"),arguments:t.arguments,typeArguments:t.type_arguments.map(te.tagToString)})}),Nt=Ct(c.enum("Transaction",{MoveCall:Rt,TransferObjects:c.struct("TransferObjects",{objects:c.vector(q),address:q}),SplitCoins:c.struct("SplitCoins",{coin:q,amounts:c.vector(q)}),MergeCoins:c.struct("MergeCoins",{destination:q,sources:c.vector(q)}),Publish:c.struct("Publish",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G)}),MakeMoveVec:c.struct("MakeMoveVec",{type:Un(ve),objects:c.vector(q)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G),packageId:G,ticket:q})})),$t=c.struct("ProgrammableTransaction",{inputs:c.vector(Pt),transactions:c.vector(Nt)}),Ut=c.enum("TransactionKind",{ProgrammableTransaction:$t,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Dt=c.enum("TransactionExpiration",{None:null,Epoch:jr()}),zt=c.struct("StructTag",{address:G,module:c.string(),name:c.string(),typeParams:c.vector(ve)}),Vt=c.struct("GasData",{payment:c.vector(Me),owner:G,price:c.u64(),budget:c.u64()}),Lt=c.struct("TransactionDataV1",{kind:Ut,sender:G,gasData:Vt,expiration:Dt}),qt=c.enum("TransactionData",{V1:Lt}),Dn=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),zn=c.enum("IntentVersion",{V0:null}),Vn=c.enum("AppId",{Sui:null}),Ln=c.struct("Intent",{scope:Dn,version:zn,appId:Vn}),qn=c.generic(["T"],t=>c.struct("IntentMessage<T>",{intent:Ln,value:t})),Wt=c.enum("CompressedSignature",{ED25519:c.fixedArray(64,c.u8()),Secp256k1:c.fixedArray(64,c.u8()),Secp256r1:c.fixedArray(64,c.u8()),ZkLogin:c.vector(c.u8())}),Ft=c.enum("PublicKey",{ED25519:c.fixedArray(32,c.u8()),Secp256k1:c.fixedArray(33,c.u8()),Secp256r1:c.fixedArray(33,c.u8()),ZkLogin:c.vector(c.u8())}),Kt=c.struct("MultiSigPkMap",{pubKey:Ft,weight:c.u8()}),Gt=c.struct("MultiSigPublicKey",{pk_map:c.vector(Kt),threshold:c.u16()}),Cr=c.struct("MultiSig",{sigs:c.vector(Wt),bitmap:c.u16(),multisig_pk:Gt}),Wn=c.vector(c.u8()).transform({input:t=>typeof t=="string"?H(t):t,output:t=>$(new Uint8Array(t))}),Br=c.struct("SenderSignedTransaction",{intentMessage:qn(qt),txSignatures:c.vector(Wn)}),Mr=c.vector(Br,{name:"SenderSignedData"}),I={...c,U8:c.u8(),U16:c.u16(),U32:c.u32(),U64:c.u64(),U128:c.u128(),U256:c.u256(),ULEB128:c.uleb128(),Bool:c.bool(),String:c.string(),Address:G,Argument:q,CallArg:Pt,CompressedSignature:Wt,GasData:Vt,MultiSig:Cr,MultiSigPkMap:Kt,MultiSigPublicKey:Gt,ObjectArg:Ye,ObjectDigest:Bt,ProgrammableMoveCall:Rt,ProgrammableTransaction:$t,PublicKey:Ft,SenderSignedData:Mr,SenderSignedTransaction:Br,SharedObjectRef:Mt,StructTag:zt,SuiObjectRef:Me,Transaction:Nt,TransactionData:qt,TransactionDataV1:Lt,TransactionExpiration:Dt,TransactionKind:Ut,TypeTag:ve,ser:k.ser.bind(k),de:k.de.bind(k),getTypeInterface:k.getTypeInterface.bind(k),hasType:k.hasType.bind(k),parseTypeName:k.parseTypeName.bind(k),registerAddressType:k.registerAddressType.bind(k),registerAlias:k.registerAlias.bind(k),registerBcsType:k.registerBcsType.bind(k),registerEnumType:k.registerEnumType.bind(k),registerStructType:k.registerStructType.bind(k),registerType:k.registerType.bind(k),types:k.types};k.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));k.registerBcsType("unsafe_u64",()=>jr());k.registerBcsType("enumKind",t=>Ct(t));[G,q,Pt,Wt,Vt,Cr,Kt,Gt,Ye,Bt,Rt,$t,Ft,Mr,Mt,zt,Me,Nt,qt,Lt,Dt,Ut,ve].forEach(t=>{k.registerBcsType(t.name,()=>t)});const Ht=j([g({AddressOwner:h()}),g({ObjectOwner:h()}),g({Shared:g({initial_shared_version:O(h())})}),b("Immutable")]);D("SuiJsonValue",()=>!0);const Fn=j([g({u32:h()}),g({u64:h()}),g({f64:h()})]);g({attributes:Z(h(),O(Fn)),featureFlags:Z(h(),P()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});j([h(),b("package")]);const oe=g({digest:h(),objectId:h(),version:j([he(),h(),vn()])});g({owner:Ht,reference:oe});g({objectId:h(),sequenceNumber:h()});g({payment:E(oe),owner:h(),price:h(),budget:h()});const Kn=Ce(oe,g({type:h(),owner:Ht,previousTransaction:h()})),Gn=Z(h(),ht()),Hn=Z(h(),vr()),Zn=g({type:h(),fields:Gn,hasPublicTransfer:P()}),Jn=g({disassembled:Hn}),Xn=j([Ce(Zn,g({dataType:b("moveObject")})),Ce(Jn,g({dataType:b("package")}))]),Yn=g({type:h(),hasPublicTransfer:P(),version:h(),bcsBytes:h()}),Qn=g({id:h(),moduleMap:Z(h(),h())}),es=j([Ce(Yn,g({dataType:b("moveObject")})),Ce(Qn,g({dataType:b("package")}))]);BigInt(1e9);const Pr=g({code:h(),error:w(h()),object_id:w(h()),parent_object_id:w(h()),version:w(h()),digest:w(h())}),ts=g({data:O(w(Z(h(),h()))),error:O(w(Pr))}),rs=j([ts,w(Z(h(),h()))]),Rr=g({objectId:h(),version:h(),digest:h(),type:O(w(h())),content:O(w(Xn)),bcs:O(w(es)),owner:O(w(Ht)),previousTransaction:O(w(h())),storageRebate:O(w(h())),display:O(w(rs))});g({showType:O(w(P())),showContent:O(w(P())),showBcs:O(w(P())),showOwner:O(w(P())),showPreviousTransaction:O(w(P())),showStorageRebate:O(w(P())),showDisplay:O(w(P()))});j([b("Exists"),b("notExists"),b("Deleted")]);E(Kn);const ns=g({data:O(w(Rr)),error:O(w(Pr))});function ss(t){return t.data}function is(t){if(t.error&&"object_id"in t.error&&"version"in t.error&&"digest"in t.error){const e=t.error;return{objectId:e.object_id,version:e.version,digest:e.digest}}}function ir(t){if("reference"in t)return t.reference;const e=ss(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:is(t)}g({objectId:h(),atCheckpoint:w(he())});g({data:E(ns),nextCursor:w(O(h())),hasNextPage:P()});j([g({details:Rr,status:b("VersionFound")}),g({details:h(),status:b("ObjectNotExists")}),g({details:oe,status:b("ObjectDeleted")}),g({details:Er([h(),he()]),status:b("VersionNotFound")}),g({details:g({asked_version:he(),latest_version:he(),object_id:h()}),status:b("VersionTooHigh")})]);const as=j([h(),g({Object:h()})]);E(as);const os=g({address:h(),name:h()}),cs=j([b("Private"),b("Public"),b("Friend")]),Zt=g({abilities:E(h())}),us=g({constraints:Zt,isPhantom:P()}),ds=g({TypeParameter:he()}),ct=Er([g({module:h(),package:h(),function:h()}),h()]);g({rank3Days:E(ct),rank7Days:E(ct),rank30Days:E(ct)});function Nr(t){if(!t)return!1;if(typeof t=="string"||U(t,ds)||$r(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(U(e.Reference,Se)||U(e.MutableReference,Se)||U(e.Vector,Se))}const Se=D("SuiMoveNormalizedType",Nr);function $r(t){if(!t||typeof t!="object")return!1;const e=t;if(!e.Struct||typeof e.Struct!="object")return!1;const r=e.Struct;return!(typeof r.address!="string"||typeof r.module!="string"||typeof r.name!="string"||!Array.isArray(r.typeArguments)||!r.typeArguments.every(n=>Nr(n)))}D("SuiMoveNormalizedStructType",$r);const ls=g({visibility:cs,isEntry:P(),typeParameters:E(Zt),parameters:E(Se),return:E(Se)}),hs=g({name:h(),type:Se}),fs=g({abilities:Zt,typeParameters:E(us),fields:E(hs)}),gs=g({fileFormatVersion:he(),address:h(),name:h(),friends:E(os),structs:Z(h(),fs),exposedFunctions:Z(h(),ls)});Z(h(),gs);function yt(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function Ur(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function Jt(t){if(typeof t=="object"&&"Struct"in t)return t;const e=Ur(t),r=yt(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const ps=j([g({ImmOrOwned:oe}),g({Shared:g({objectId:h(),initialSharedVersion:j([J(),h()]),mutable:P()})}),g({Receiving:oe})]),Qe=g({Pure:E(J())}),mt=g({Object:ps}),et=j([Qe,mt]);function ys(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:_t(t)?t.toBytes():I.ser(e,t,{maxSize:1/0}).toBytes())}}const N={Pure:ys,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:d.normalizeSuiAddress(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}}};function ar(t){return typeof t=="string"?d.normalizeSuiAddress(t):"ImmOrOwned"in t.Object?d.normalizeSuiAddress(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?d.normalizeSuiAddress(t.Object.Receiving.objectId):d.normalizeSuiAddress(t.Object.Shared.objectId)}function ms(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function ws(t){var e;return((e=ms(t))==null?void 0:e.mutable)??!1}function bs(t){function e(r,n){return t(r,n)}return e.u8=r=>t(I.U8.serialize(r)),e.u16=r=>t(I.U16.serialize(r)),e.u32=r=>t(I.U32.serialize(r)),e.u64=r=>t(I.U64.serialize(r)),e.u128=r=>t(I.U128.serialize(r)),e.u256=r=>t(I.U256.serialize(r)),e.bool=r=>t(I.Bool.serialize(r)),e.string=r=>t(I.String.serialize(r)),e.address=r=>t(I.Address.serialize(r)),e.id=e.address,e}const Ss="object",Ts="ID",Es="ascii",vs="String",ks="string",xs="String",_s="option",As="Option",Is={address:d.SUI_FRAMEWORK_ADDRESS,module:Ss,name:Ts},Os={address:d.MOVE_STDLIB_ADDRESS,module:Es,name:vs},js={address:d.MOVE_STDLIB_ADDRESS,module:ks,name:xs},Cs={address:d.MOVE_STDLIB_ADDRESS,module:_s,name:As},Ve=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function Bs(t){var r;const e=(r=Jt(t))==null?void 0:r.Struct;return(e==null?void 0:e.address)==="0x2"&&(e==null?void 0:e.module)==="tx_context"&&(e==null?void 0:e.name)==="TxContext"}function ut(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const Ms=["Address","Bool","U8","U16","U32","U64","U128","U256"];function wt(t,e){if(typeof t=="string"&&Ms.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])ut("number",e);else if(t==="Bool")ut("boolean",e);else if(t==="Address"&&(ut("string",e),e&&!d.isValidSuiAddress(e)))throw new Error("Invalid Sui Address");return t.toLowerCase()}else if(typeof t=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(t,null,2)}`);if("Vector"in t){if((e===void 0||typeof e=="string")&&t.Vector==="U8")return"string";if(e!==void 0&&!Array.isArray(e))throw new Error(`Expect ${e} to be a array, received ${typeof e}`);const r=wt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(Ve(t.Struct,Os))return"string";if(Ve(t.Struct,js))return"utf8string";if(Ve(t.Struct,Is))return"address";if(Ve(t.Struct,Cs)){const r={Vector:t.Struct.typeArguments[0]};return wt(r,e)}}}function Ps(t,e){const r=Array.from(`${t}::`).map(s=>s.charCodeAt(0)),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),d.blake2b(n,{dkLen:32})}function R(t,e){return br(t,e)}const Rs=t=>j([g({None:j([b(!0),b(null)])}),g({Some:t})]),Pe=j([g({kind:b("Input"),index:J(),value:w(ht()),type:w(b("object"))}),g({kind:b("Input"),index:J(),value:w(ht()),type:b("pure")})]),Ns=[Pe,g({kind:b("GasCoin")}),g({kind:b("Result"),index:J()}),g({kind:b("NestedResult"),index:J(),resultIndex:J()})],ne=j([...Ns]),Dr=g({kind:b("MoveCall"),target:D("target",h().validator),typeArguments:E(h()),arguments:E(ne)}),zr=g({kind:b("TransferObjects"),objects:E(ne),address:ne}),Vr=g({kind:b("SplitCoins"),coin:ne,amounts:E(ne)}),Lr=g({kind:b("MergeCoins"),destination:ne,sources:E(ne)}),qr=g({kind:b("MakeMoveVec"),type:w(Rs(Z(h(),vr()))),objects:E(ne)}),Wr=g({kind:b("Publish"),modules:E(E(J())),dependencies:E(h())}),Fr=g({kind:b("Upgrade"),modules:E(E(J())),dependencies:E(h()),packageId:h(),ticket:ne}),$s=[Dr,zr,Vr,Lr,Wr,Fr,qr],Us=j([...$s]),ue={MoveCall(t){return R({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},Dr)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=N.Pure(I.Address.serialize(e.value))),R({kind:"TransferObjects",objects:t,address:e},zr)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=N.Pure(I.U64.serialize(r.value)))}),R({kind:"SplitCoins",coin:t,amounts:e},Vr)},MergeCoins(t,e){return R({kind:"MergeCoins",destination:t,sources:e},Lr)},Publish({modules:t,dependencies:e}){return R({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(H(r)):r),dependencies:e.map(r=>d.normalizeSuiObjectId(r))},Wr)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return R({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(H(s)):s),dependencies:e.map(s=>d.normalizeSuiObjectId(s)),packageId:r,ticket:n},Fr)},MakeMoveVec({type:t,objects:e}){return R({kind:"MakeMoveVec",type:t?{Some:te.parseFromStr(t)}:{None:null},objects:e},qr)}},Ds=w(O(j([g({Epoch:J()}),g({None:j([b(!0),b(null)])})]))),or=D("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),zs=g({budget:w(or),price:w(or),payment:w(E(oe)),owner:w(h())}),Le=g({version:b(1),sender:w(h()),expiration:Ds,gasConfig:zs,inputs:E(Pe),transactions:E(Us)});function cr(t){return d.normalizeSuiAddress(t).replace("0x","")}class re{constructor(e){this.version=1,this.sender=e==null?void 0:e.sender,this.expiration=e==null?void 0:e.expiration,this.gasConfig=(e==null?void 0:e.gasConfig)??{},this.inputs=(e==null?void 0:e.inputs)??[],this.transactions=(e==null?void 0:e.transactions)??[]}static fromKindBytes(e){const r=I.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=R({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>R({kind:"Input",value:i,index:a,type:U(i,Qe)?"pure":"object"},Pe)),transactions:n.transactions},Le);return re.restore(s)}static fromBytes(e){var a;const r=I.TransactionData.parse(e),n=r==null?void 0:r.V1,s="ProgrammableTransaction"in n.kind?(a=n==null?void 0:n.kind)==null?void 0:a.ProgrammableTransaction:null;if(!n||!s)throw new Error("Unable to deserialize from bytes.");const i=R({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((o,u)=>R({kind:"Input",value:o,index:u,type:U(o,Qe)?"pure":"object"},Pe)),transactions:s.transactions},Le);return re.restore(i)}static restore(e){lt(e,Le);const r=new re;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=Ps("TransactionData",e);return d.toB58(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(f=>(lt(f.value,et),f.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return I.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,o=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const l={sender:cr(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:cr(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return I.TransactionData.serialize({V1:l},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return re.getDigestFromBytes(e)}snapshot(){return R(this,Le)}}var Xt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},v=(t,e,r)=>(Xt(t,e,"read from private field"),r?r.call(t):e.get(t)),Y=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},qe=(t,e,r,n)=>(Xt(t,e,"write to private field"),e.set(t,r),r),B=(t,e,r)=>(Xt(t,e,"access private method"),r),S,Ae,Fe,Ie,Ke,ce,fe,Yt,Kr,Qt,Gr,er,Hr,tr,Zr,Ge,bt;const Vs={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function Ls(t){const e={kind:"Result",index:t},r=[],n=s=>r[s]??(r[s]={kind:"NestedResult",index:t,resultIndex:s});return new Proxy(e,{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(s,i){if(i in s)return Reflect.get(s,i);if(i===Symbol.iterator)return function*(){let o=0;for(;;)yield n(o),o++};if(typeof i=="symbol")return;const a=parseInt(i,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function qs(t){const e=Jt(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Re(t){if(!t.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return t.client}const Jr=Symbol.for("@mysten/transaction"),dt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},Ws=1000n,Fs=50,Ks=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function Gs(t){return!!t&&typeof t=="object"&&t[Jr]===!0}const St=class{constructor(t){Y(this,Ae),Y(this,Ie),Y(this,ce),Y(this,Yt),Y(this,Qt),Y(this,er),Y(this,tr),Y(this,Ge),Y(this,S,void 0),qe(this,S,new re(t?t.blockData:void 0))}static fromKind(t){const e=new St;return qe(e,S,re.fromKindBytes(typeof t=="string"?H(t):t)),e}static from(t){const e=new St;return typeof t!="string"||!t.startsWith("{")?qe(e,S,re.fromBytes(typeof t=="string"?H(t):t)):qe(e,S,re.restore(JSON.parse(t))),e}setSender(t){v(this,S).sender=t}setSenderIfNotSet(t){v(this,S).sender||(v(this,S).sender=t)}setExpiration(t){v(this,S).expiration=t}setGasPrice(t){v(this,S).gasConfig.price=String(t)}setGasBudget(t){v(this,S).gasConfig.budget=String(t)}setGasOwner(t){v(this,S).gasConfig.owner=t}setGasPayment(t){v(this,S).gasConfig.payment=t.map(e=>Sr(e,oe))}get blockData(){return v(this,S).snapshot()}get[Jr](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:bs((t,e)=>_t(t)?B(this,Ae,Fe).call(this,"pure",{Pure:Array.from(t.toBytes())}):B(this,Ae,Fe).call(this,"pure",t instanceof Uint8Array?N.Pure(t):e?N.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=ar(t),r=v(this,S).inputs.find(n=>n.type==="object"&&e===ar(n.value));return r&&U(r.value,mt)&&"Shared"in r.value.Object&&U(t,mt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??B(this,Ae,Fe).call(this,"object",typeof t=="string"?d.normalizeSuiAddress(t):t)}objectRef(...t){return this.object(N.ObjectRef(...t))}receivingRef(...t){return this.object(N.ReceivingRef(...t))}sharedObjectRef(...t){return this.object(N.SharedObjectRef(...t))}add(t){const e=v(this,S).transactions.push(t);return Ls(e-1)}splitCoins(t,e){return this.add(ue.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):B(this,Ie,Ke).call(this,r))))}mergeCoins(t,e){return this.add(ue.MergeCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="string"?this.object(r):r)))}publish({modules:t,dependencies:e}){return this.add(ue.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(ue.Upgrade({modules:t,dependencies:e,packageId:r,ticket:typeof n=="string"?this.object(n):n}))}moveCall({arguments:t,typeArguments:e,target:r}){return this.add(ue.MoveCall({arguments:t==null?void 0:t.map(n=>B(this,Ie,Ke).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(ue.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):B(this,Ie,Ke).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(ue.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(v(this,S).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).build({maxSizeBytes:B(this,ce,fe).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).getDigest()}};let Hs=St;S=new WeakMap;Ae=new WeakSet;Fe=function(t,e){const r=v(this,S).inputs.length,n=R({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Pe);return v(this,S).inputs.push(n),n};Ie=new WeakSet;Ke=function(t){return _t(t)?this.pure(t):t};ce=new WeakSet;fe=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return Vs[t];const n=e==null?void 0:e.attributes[dt[t]];if(!n)throw new Error(`Missing expected protocol config: "${dt[t]}"`);const s="u64"in n?n.u64:"u32"in n?n.u32:n.f64;if(!s)throw new Error(`Unexpected protocol config value found for: "${dt[t]}"`);return Number(s)};Yt=new WeakSet;Kr=function(t){const e=B(this,ce,fe).call(this,"maxPureArgumentSize",t);v(this,S).inputs.forEach((r,n)=>{if(U(r.value,Qe)&&r.value.Pure.length>e)throw new Error(`Input at index ${n} is too large, max pure input size is ${e} bytes, got ${r.value.Pure.length} bytes`)})};Qt=new WeakSet;Gr=async function(t){if(v(this,S).gasConfig.payment){const s=B(this,ce,fe).call(this,"maxGasObjects",t);if(v(this,S).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||v(this,S).gasConfig.payment)return;const e=v(this,S).gasConfig.owner??v(this,S).sender,n=(await Re(t).getCoins({owner:e,coinType:d.SUI_TYPE_ARG})).data.filter(s=>!v(this,S).inputs.find(a=>U(a.value,et)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,B(this,ce,fe).call(this,"maxGasObjects",t)-1).map(s=>({objectId:s.coinObjectId,digest:s.digest,version:s.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");this.setGasPayment(n)};er=new WeakSet;Hr=async function(t){t.onlyTransactionKind||v(this,S).gasConfig.price||this.setGasPrice(await Re(t).getReferenceGasPrice())};tr=new WeakSet;Zr=async function(t){const{inputs:e,transactions:r}=v(this,S),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:d.normalizeSuiAddress(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!U(e[o.index].value,et))&&n.push(i),i.kind==="SplitCoins"&&i.amounts.forEach(a=>{if(a.kind==="Input"){const o=e[a.index];typeof o.value!="object"&&(o.value=N.Pure(I.U64.serialize(o.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=N.Pure(I.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,u]=i.target.split("::"),l=await Re(t).getNormalizedMoveFunction({package:d.normalizeSuiObjectId(a),module:o,function:u}),p=l.parameters.length>0&&Bs(l.parameters.at(-1))?l.parameters.slice(0,l.parameters.length-1):l.parameters;if(p.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");p.forEach((y,m)=>{const x=i.arguments[m];if(x.kind!=="Input")return;const T=e[x.index];if(U(T.value,et))return;const C=T.value,M=wt(y,C);if(M){T.value=N.Pure(C,M);return}if(Jt(y)!=null||typeof y=="object"&&"TypeParameter"in y){if(typeof C!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(C,null,2)}`);s.push({id:C,input:T,normalizedType:y});return}throw new Error(`Unknown call arg type ${JSON.stringify(y,null,2)} for value ${JSON.stringify(C,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:f})=>f))],a=Ks(i,Fs),o=(await Promise.all(a.map(f=>Re(t).multiGetObjects({ids:f,options:{showOwner:!0}})))).flat();let u=new Map(i.map((f,p)=>[f,o[p]]));const l=Array.from(u).filter(([f,p])=>p.error).map(([f,p])=>f);if(l.length)throw new Error(`The following input objects are invalid: ${l.join(", ")}`);s.forEach(({id:f,input:p,normalizedType:y})=>{var C;const m=u.get(f),x=(C=m.data)==null?void 0:C.owner,T=x&&typeof x=="object"&&"Shared"in x?x.Shared.initial_shared_version:void 0;if(T){const M=y!=null&&yt(y)==null&&Ur(y)==null,se=ws(p.value)||M||y!=null&&yt(y)!=null;p.value=N.SharedObjectRef({objectId:f,initialSharedVersion:T,mutable:se})}else y&&qs(y)?p.value=N.ReceivingRef(ir(m)):p.value=N.ObjectRef(ir(m))})}};Ge=new WeakSet;bt=async function(t){if(!t.onlyTransactionKind&&!v(this,S).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([B(this,er,Hr).call(this,t),B(this,tr,Zr).call(this,t)]),!t.onlyTransactionKind&&(await B(this,Qt,Gr).call(this,t),!v(this,S).gasConfig.budget)){const e=await Re(t).dryRunTransactionBlock({transactionBlock:v(this,S).build({maxSizeBytes:B(this,ce,fe).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(B(this,ce,fe).call(this,"maxTxGas",t)),payment:[]}}})});if(e.effects.status.status!=="success")throw new Error(`Dry run failed, could not automatically determine a budget: ${e.effects.status.error}`,{cause:e});const r=Ws*BigInt(this.blockData.gasConfig.price||1n),n=BigInt(e.effects.gasUsed.computationCost)+r,s=n+BigInt(e.effects.gasUsed.storageCost)-BigInt(e.effects.gasUsed.storageRebate);this.setGasBudget(s>n?s:n)}B(this,Yt,Kr).call(this,t)};const Zs=Symbol.for("@mysten/SuiClient");class Js{get[Zs](){return!0}constructor(e){this.transport=e.transport??new Rn({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,r){return await this.transport.request({method:e,params:r})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach(n=>{if(!n||!d.isValidSuiObjectId(d.normalizeSuiObjectId(n)))throw new Error(`Invalid Sui Object id ${n}`)}),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,(e.order||"descending")==="descending"]})}async getTransactionBlock(e){if(!d.isValidTransactionDigest(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach(n=>{if(!d.isValidTransactionDigest(n))throw new Error(`Invalid Transaction digest ${n}`)}),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock(e){return await this.transport.request({method:"sui_executeTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock),Array.isArray(e.signature)?e.signature:[e.signature],e.options,e.requestType]})}async signAndExecuteTransactionBlock({transactionBlock:e,signer:r,...n}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(r.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:a}=await r.signTransactionBlock(s);return this.executeTransactionBlock({transactionBlock:a,signature:i,...n})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach(r=>{if(!r||!d.isValidSuiObjectId(d.normalizeSuiObjectId(r)))throw new Error(`Invalid Sui Stake id ${r}`)}),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,(e.order||"descending")==="descending"]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){var n;let r;if(Gs(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=$(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=$(e.transactionBlock);else throw new Error("Unknown transaction block format.");return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,r,(n=e.gasPrice)==null?void 0:n.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e==null?void 0:e.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e==null?void 0:e.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e==null?void 0:e.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"}),r=d.fromB58(e.digest);return ge(r.slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames(e){return await this.transport.request({method:"suix_resolveNameServiceNames",params:[e.address,e.cursor,e.limit]})}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e==null?void 0:e.version]})}async waitForTransactionBlock({signal:e,timeout:r=60*1e3,pollInterval:n=2*1e3,...s}){const i=AbortSignal.timeout(r),a=new Promise((o,u)=>{i.addEventListener("abort",()=>u(i.reason))});for(a.catch(()=>{});!i.aborted;){e==null||e.throwIfAborted();try{return await this.getTransactionBlock(s)}catch{await Promise.race([new Promise(u=>setTimeout(u,n)),a])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}class Xr extends d.ChainContext{}const Tt="Sui",rr=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},Xs=(t,e)=>{try{return d.normalizeSuiType(t)===d.normalizeSuiType(e)}catch{return!1}},Ys=t=>(t==null?void 0:t.type)==="created",Qs=t=>(t==null?void 0:t.type)==="published";function ei(t){return Array.isArray(t)}function rt(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function Yr(t){return typeof t=="object"&&!ei(t)&&!rt(t)}function ti(t){return typeof t=="object"&&"id"in t}const ri=16*1024,ni=t=>I.ser("vector<u8>",t,{maxSize:ri}).toBytes(),si=async(t,e)=>{const{data:r,error:n}=await t.getObject({id:e,options:{showContent:!0}});if(n)throw new Error("Error getting object: "+n);if(!r||!rt(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return d.getPackageIdFromType(r.content.type)},Qr=async(t,e)=>{if(!d.isValidSuiAddress(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return rr(r)},ii=async(t,e)=>{let r,n;do{const a=await t.getDynamicFields({parentId:e,cursor:n});r=a.data.find(o=>o.name.type.endsWith("CurrentPackage")),n=a.hasNextPage?a.nextCursor:null}while(n&&!r);if(!r)throw new Error("CurrentPackage not found");const s=await t.getObject({id:r.objectId,options:{showContent:!0}}),i=rr(s);if(!i||!Yr(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!rt(i.value))throw new Error("Unable to get package id");return i.value.fields.package},ai=async(t,e,r)=>{let n=null,s=null,i=null,a;do{if(i=await t.getOwnedObjects({owner:r,filter:{StructType:`${e}::emitter::EmitterCap`},options:{showContent:!0},cursor:a}),!i||!i.data)throw Error("Failed to get owned objects");for(const o of i.data){if(!o.data)continue;const{version:u,objectId:l}=o.data;(n===null||u<n)&&(n=u,s=l)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},oi=async(t,e)=>{const r=new Hs,[n]=r.publish({modules:t.modules.map(s=>Array.from(d.b64.decode(s))),dependencies:t.dependencies.map(s=>d.normalizeSuiObjectId(s))});return r.transferObjects([n],r.pure(e)),r},Q=class Q extends d.PlatformContext{constructor(e,r){super(e,r??d.networkPlatformConfigs(e,Q._platform))}getRpc(e){if(e in this.config)return new Js({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new Xr(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!Q.isSupportedChain(r))throw new Error(`invalid chain for ${Tt}: ${r}`);return d.Wormhole.tokenId(r,d.SUI_COIN)}static isNativeTokenId(e,r,n){return!Q.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return d.chainToPlatform(e)===Q._platform}static async getDecimals(e,r,n){if(d.isNative(n))return d.nativeDecimals(Q._platform);const s=new d.SuiAddress(n);try{const a=await Qr(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.toString()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getCoins(e,r,n){let s=[],i=null;const a=new d.SuiAddress(r).toString();do{const o=await e.getCoins({owner:a,coinType:n,cursor:i});s=[...s,...o.data],i=o.hasNextPage?o.nextCursor:null}while(i);return s}static async getBalance(e,r,n,s){if(d.isNative(s)){const{totalBalance:a}=await r.getBalance({owner:n});return BigInt(a)}const{totalBalance:i}=await r.getBalance({owner:n,coinType:s.toString()});return BigInt(i)}static async getBalances(e,r,n,s){return(await Promise.all(s.map(async a=>{const o=await this.getBalance(e,r,n,a);return{[d.isNative(a)?"native":new d.SuiAddress(a).toString()]:o}}))).reduce((a,o)=>Object.assign(a,o),{})}static async sendWait(e,r,n){const s=[];for(const i of n){const a=await r.executeTransactionBlock(i);await r.waitForTransactionBlock({digest:a.digest}),s.push(a.digest)}return s}static async getLatestBlock(e){return Number(await e.getLatestCheckpointSequenceNumber())}static async getLatestFinalizedBlock(e){return this.getLatestBlock(e)}static chainFromChainId(e){const r=d.platformNativeChainIdToNetworkChain(Q._platform,e);if(r===void 0)throw new Error(`Unknown native chain id ${e}`);const[n,s]=r;return[n,s]}static async chainFromRpc(e){const r=await e.call("sui_getChainIdentifier",[]);return this.chainFromChainId(r)}};pe(Q,"_platform",Tt);let Ee=Q;var Ne={};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.bech32m=Et=Ne.bech32=void 0;const tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",en={};for(let t=0;t<tt.length;t++){const e=tt.charAt(t);en[e]=t}function Te(t){const e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function ur(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=Te(e)^n>>5}e=Te(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=Te(e)^n&31}return e}function nr(t,e,r,n){let s=0,i=0;const a=(1<<r)-1,o=[];for(let u=0;u<t.length;++u)for(s=s<<e|t[u],i+=e;i>=r;)i-=r,o.push(s>>i&a);if(n)i>0&&o.push(s<<r-i&a);else{if(i>=e)return"Excess padding";if(s<<r-i&a)return"Non-zero padding"}return o}function ci(t){return nr(t,8,5,!0)}function ui(t){const e=nr(t,5,8,!1);if(Array.isArray(e))return e}function di(t){const e=nr(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function tn(t){let e;t==="bech32"?e=1:e=734539939;function r(a,o,u){if(u=u||90,a.length+7+o.length>u)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let l=ur(a);if(typeof l=="string")throw new Error(l);let f=a+"1";for(let p=0;p<o.length;++p){const y=o[p];if(y>>5)throw new Error("Non 5-bit word");l=Te(l)^y,f+=tt.charAt(y)}for(let p=0;p<6;++p)l=Te(l);l^=e;for(let p=0;p<6;++p){const y=l>>(5-p)*5&31;f+=tt.charAt(y)}return f}function n(a,o){if(o=o||90,a.length<8)return a+" too short";if(a.length>o)return"Exceeds length limit";const u=a.toLowerCase(),l=a.toUpperCase();if(a!==u&&a!==l)return"Mixed-case string "+a;a=u;const f=a.lastIndexOf("1");if(f===-1)return"No separator character for "+a;if(f===0)return"Missing prefix for "+a;const p=a.slice(0,f),y=a.slice(f+1);if(y.length<6)return"Data too short";let m=ur(p);if(typeof m=="string")return m;const x=[];for(let T=0;T<y.length;++T){const C=y.charAt(T),M=en[C];if(M===void 0)return"Unknown character "+C;m=Te(m)^M,!(T+6>=y.length)&&x.push(M)}return m!==e?"Invalid checksum for "+a:{prefix:p,words:x}}function s(a,o){const u=n(a,o);if(typeof u=="object")return u}function i(a,o){const u=n(a,o);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:s,decode:i,encode:r,toWords:ci,fromWordsUnsafe:ui,fromWords:di}}var Et=Ne.bech32=tn("bech32");Ne.bech32m=tn("bech32m");var $e=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))($e||{});function li(t){return[t,0,0]}function rn(t,e){const r=li(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const nt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},hi={ED25519:32,Secp256k1:33,Secp256r1:33},fi={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function gi(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function pi(t,e){const r=t.toString(16);return d.hexToBytes(r.padStart(e*2,"0").slice(-e*2))}function yi(t,e){const r=pi(t,e),n=gi(r);return n===-1?new Uint8Array([0]):r.slice(n)}function mi(t,e){const r=yi(t,32);e==="accounts.google.com"&&(e="https://accounts.google.com");const n=new TextEncoder().encode(e),s=new Uint8Array(2+r.length+n.length);return s.set([nt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),d.normalizeSuiAddress(d.bytesToHex(d.blake2b(s,{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}function wi(t){if(t.length!==1)throw new Error("Invalid base64Url character: "+t);const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(t);if(r===-1)throw new Error("Invalid base64Url character: "+t);const n=r.toString(2).padStart(6,"0");return Array.from(n).map(Number)}function bi(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=wi(n);e=e.concat(s)}return e}function Si(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=bi(t);const n=e%4;if(n!==0)if(n===1)r=r.slice(2);else if(n===2)r=r.slice(4);else throw new Error(`Input (s = ${t}) is not tightly packed because i%4 = 3 (i = ${e}))`);const s=(e+t.length-1)%4;if(s!==3)if(s===2)r=r.slice(0,r.length-2);else if(s===1)r=r.slice(0,r.length-4);else throw new Error(`Input (s = ${t}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${e}))`);if(r.length%8!==0)throw new Error("We should never reach here...");const i=new Uint8Array(Math.floor(r.length/8));let a=0;for(let o=0;o<r.length;o+=8){const u=r.slice(o,o+8),l=parseInt(u.join(""),2);i[a++]=l}return new TextDecoder().decode(i)}function Ti(t){if(!(t.slice(-1)==="}"||t.slice(-1)===","))throw new Error("Invalid claim");const e=JSON.parse("{"+t.slice(0,-1)+"}");if(Object.keys(e).length!==1)throw new Error("Invalid claim");const r=Object.keys(e)[0];return[r,e[r]]}function Ei(t,e){const r=Si(t.value,t.indexMod4),[n,s]=Ti(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const vi=c.struct("ZkLoginSignature",{inputs:c.struct("ZkLoginSignatureInputs",{proofPoints:c.struct("ZkLoginSignatureInputsProofPoints",{a:c.vector(c.string()),b:c.vector(c.vector(c.string())),c:c.vector(c.string())}),issBase64Details:c.struct("ZkLoginSignatureInputsClaim",{value:c.string(),indexMod4:c.u8()}),headerBase64:c.string(),addressSeed:c.string()}),maxEpoch:c.u64(),userSignature:c.vector(c.u8())});function ki(t){return vi.parse(typeof t=="string"?H(t):t)}function xi({signature:t,signatureScheme:e,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const n=r.toRawBytes(),s=new Uint8Array(1+t.length+n.length);return s.set([nt[e]]),s.set(t,1),s.set(n,1+t.length),$(s)}function _i(t){const e=H(t),r=fi[e[0]];switch(r){case"MultiSig":const n=I.MultiSig.parse(e.slice(1));return{serializedSignature:t,signatureScheme:r,multisig:n,bytes:e};case"ZkLogin":const s=e.slice(1),{inputs:i,maxEpoch:a,userSignature:o}=ki(s),{issBase64Details:u,addressSeed:l}=i,f=Ei(u,"iss"),p=mi(BigInt(l),f);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:f,address:p,addressSeed:BigInt(l)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const y=hi[r],m=e.slice(1,e.length-y),x=e.slice(1+m.length);return{serializedSignature:t,signatureScheme:r,signature:m,publicKey:x,bytes:e};default:throw new Error("Unsupported signature scheme")}}const He=32,Ai="suiprivkey";class Ii{async signWithIntent(e,r){const n=rn(r,e),s=d.blake2b(n,{dkLen:32});return{signature:xi({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:$(e)}}async signTransactionBlock(e){return this.signWithIntent(e,$e.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(c.vector(c.u8()).serialize(e).toBytes(),$e.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class Oi extends Ii{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function ji(t,e){if(t.length!==He)throw new Error("Invalid bytes length");const r=nt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),Et.encode(Ai,Et.toWords(n))}function dr(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function Ci(t){return kt.mnemonicToSeedSync(t,"")}function Bi(t){return ge(Ci(t))}const Mi="ed25519 seed",Pi=2147483648,Ri=new RegExp("^m(\\/[0-9]+')+$"),nn=t=>t.replace("'",""),Ni=t=>{const r=kt.hmac.create(d.sha512,Mi).update(Ue(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},$i=({key:t,chainCode:e},r)=>{const n=new ArrayBuffer(4);new DataView(n).setUint32(0,r);const i=new Uint8Array(1+t.length+n.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(t,1),i.set(new Uint8Array(n,0,n.byteLength),t.length+1);const a=kt.hmac.create(d.sha512,e).update(i).digest(),o=a.slice(0,32),u=a.slice(32);return{key:o,chainCode:u}},Ui=t=>Ri.test(t)?!t.split("/").slice(1).map(nn).some(isNaN):!1,lr=(t,e,r=Pi)=>{if(!Ui(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=Ni(e);return t.split("/").slice(1).map(nn).map(a=>parseInt(a,10)).reduce((a,o)=>$i(a,o+r),{key:n,chainCode:s})};function sn(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}class Di{equals(e){return sn(this.toRawBytes(),e.toRawBytes())}toBase64(){return $(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return $(e)}verifyWithIntent(e,r,n){const s=rn(n,e),i=d.blake2b(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(I.vector(I.u8()).serialize(e).toBytes(),r,$e.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,$e.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return d.normalizeSuiAddress(d.bytesToHex(d.blake2b(this.toSuiBytes(),{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}}const vt=32;class an extends Di{constructor(e){if(super(),typeof e=="string"?this.data=H(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==vt)throw new Error(`Invalid public key input. Expected ${vt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return nt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=_i(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!sn(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return d.nacl.sign.detached.verify(e,n,this.toRawBytes())}}an.SIZE=vt;const hr="m/44'/784'/0'/0'/0'";class me extends Oi{constructor(e){super(),e?this.keypair=e:this.keypair=d.nacl.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new me(d.nacl.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==He)throw new Error(`Wrong secretKey size. Expected ${He} bytes, got ${n}.`);const s=d.nacl.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=d.nacl.sign.detached(a,s.secretKey);if(!d.nacl.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new me(s)}getPublicKey(){return new an(this.keypair.publicKey)}getSecretKey(){return ji(this.keypair.secretKey.slice(0,He),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return d.nacl.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=hr),!dr(r))throw new Error("Invalid derivation path");const{key:n}=lr(r,Bi(e));return me.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=hr),!dr(r))throw new Error("Invalid derivation path");const{key:n}=lr(r,e);return me.fromSecretKey(n)}}async function zi(t,e){const[,r]=await Ee.chainFromRpc(t);return new Vi(r,t,me.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class Vi{constructor(e,r,n,s){pe(this,"_chain");pe(this,"_client");pe(this,"_signer");pe(this,"_debug");this._chain=e,this._client=r,this._signer=n,this._debug=s}chain(){return this._chain}address(){return this._signer.toSuiAddress()}async signAndSend(e){const r=[];for(const n of e){const{description:s,transaction:i}=n;this._debug&&console.log(`Signing ${s} for ${this.address()}`);try{const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}catch(a){throw a}}return r}}const Li={Address:d.SuiAddress,Platform:Ee,getSigner:zi,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-D2Bw_LRJ.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-BfBNSTY8.js")),CircleBridge:()=>Promise.resolve().then(()=>require("./index-CXWWVJUC.js"))},getChain:(t,e,r)=>new Xr(e,new Ee(t,d.applyChainsConfigConfigOverrides(t,Tt,{[e]:r})))},qi=Object.freeze(Object.defineProperty({__proto__:null,default:Li},Symbol.toStringTag,{value:"Module"}));exports.SuiPlatform=Ee;exports.getFieldsFromObjectResponse=rr;exports.getObjectFields=Qr;exports.getOldestEmitterCapObjectId=ai;exports.getOriginalPackageId=si;exports.getPackageId=ii;exports.isMoveStructId=ti;exports.isMoveStructObject=Yr;exports.isMoveStructStruct=rt;exports.isSameType=Xs;exports.isSuiCreateEvent=Ys;exports.isSuiPublishEvent=Qs;exports.publishPackage=oi;exports.sui=qi;exports.uint8ArrayToBCS=ni;
5
+ Received: "${JSON.stringify(u)}"`);let p=Object.keys(u)[0];if(p===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let y=n.indexOf(p);if(y===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${p}"`);let m=n[y],x=r[m];if(o.write8(y),x===null)return o;let T=i.indexOf(x),C=T===-1?x:l[T];{let{name:M,params:se}=this.parseTypeName(C);return this.getTypeInterface(M)._encodeRaw.call(this,o,u[p],se,f)}},function(o,u,l){let f=o.readULEB(),p=n[f],y=r[p];if(f===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${f}"`);if(y===null)return{[p]:!0};let m=i.indexOf(y),x=m===-1?y:u[m];{let{name:T,params:C}=this.parseTypeName(x);return{[p]:this.getTypeInterface(T)._decodeRaw.call(this,o,C,l)}}})}getTypeInterface(t){let e=this.types.get(t);if(typeof e=="string"){let r=[];for(;typeof e=="string";){if(r.includes(e))throw new Error(`Recursive definition found: ${r.join(" -> ")} -> ${e}`);r.push(e),e=this.types.get(e)}}if(e===void 0)throw new Error(`Type ${t} is not registered`);return e}parseTypeName(t){if(Array.isArray(t)){let[o,...u]=t;return{name:o,params:u}}if(typeof t!="string")throw new Error(`Illegal type passed as a name of the type: ${t}`);let[e,r]=this.schema.genericSeparators||["<",">"],n=t.indexOf(e),s=Array.from(t).reverse().indexOf(r);if(n===-1&&s===-1)return{name:t,params:[]};if(n===-1||s===-1)throw new Error(`Unclosed generic in name '${t}'`);let i=t.slice(0,n),a=gr(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let _=xe;_.U8="u8";_.U16="u16";_.U32="u32";_.U64="u64";_.U128="u128";_.U256="u256";_.BOOL="bool";_.VECTOR="vector";_.ADDRESS="address";_.STRING="string";_.HEX="hex-string";_.BASE58="base58-string";_.BASE64="base64-string";function mn(t){t.registerType(_.U8,function(e,r){return e.write8(r)},function(e){return e.read8()},e=>e<256),t.registerType(_.U16,function(e,r){return e.write16(r)},function(e){return e.read16()},e=>e<65536),t.registerType(_.U32,function(e,r){return e.write32(r)},function(e){return e.read32()},e=>e<=4294967296n),t.registerType(_.U64,function(e,r){return e.write64(r)},function(e){return e.read64()}),t.registerType(_.U128,function(e,r){return e.write128(r)},function(e){return e.read128()}),t.registerType(_.U256,function(e,r){return e.write256(r)},function(e){return e.read256()}),t.registerType(_.BOOL,function(e,r){return e.write8(r)},function(e){return e.read8().toString(10)==="1"}),t.registerType(_.STRING,function(e,r){return e.writeVec(Array.from(r),(n,s)=>n.write8(s.charCodeAt(0)))},function(e){return e.readVec(r=>r.read8()).map(r=>String.fromCharCode(Number(r))).join("")},e=>!0),t.registerType(_.HEX,function(e,r){return e.writeVec(Array.from(Ue(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return ge(new Uint8Array(r))}),t.registerType(_.BASE58,function(e,r){return e.writeVec(Array.from(d.fromB58(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return d.toB58(new Uint8Array(r))}),t.registerType(_.BASE64,function(e,r){return e.writeVec(Array.from(H(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return $(new Uint8Array(r))})}function wn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:yn,addressEncoding:"hex"}}class bn extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:o}=e,u=o.length===0?s:`At path: ${o.join(".")} -- ${s}`;super(i??u),i!=null&&(this.cause=u),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Sn(t){return V(t)&&typeof t[Symbol.iterator]=="function"}function V(t){return typeof t=="object"&&t!=null}function L(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function Tn(t){const{done:e,value:r}=t.next();return e?void 0:r}function En(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:s,branch:i}=e,{type:a}=r,{refinement:o,message:u=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${L(n)}\``}=t;return{value:n,type:a,refinement:o,key:s[s.length-1],path:s,branch:i,...t,message:u}}function*sr(t,e,r,n){Sn(t)||(t=[t]);for(const s of t){const i=En(s,e,r,n);i&&(yield i)}}function*At(t,e,r={}){const{path:n=[],branch:s=[t],coerce:i=!1,mask:a=!1}=r,o={path:n,branch:s};if(i&&(t=e.coercer(t,o),a&&e.type!=="type"&&V(e.schema)&&V(t)&&!Array.isArray(t)))for(const l in t)e.schema[l]===void 0&&delete t[l];let u="valid";for(const l of e.validator(t,o))l.explanation=r.message,u="not_valid",yield[l,void 0];for(let[l,f,p]of e.entries(t,o)){const y=At(f,p,{path:l===void 0?n:[...n,l],branch:l===void 0?s:[...s,f],coerce:i,mask:a,message:r.message});for(const m of y)m[0]?(u=m[0].refinement!=null?"not_refined":"not_valid",yield[m[0],void 0]):i&&(f=m[1],l===void 0?t=f:t instanceof Map?t.set(l,f):t instanceof Set?t.add(f):V(t)&&(f!==void 0||l in t)&&(t[l]=f))}if(u!=="not_valid")for(const l of e.refiner(t,o))l.explanation=r.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,t])}class X{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=u=>u,entries:o=function*(){}}=e;this.type=r,this.schema=n,this.entries=o,this.coercer=a,s?this.validator=(u,l)=>{const f=s(u,l);return sr(f,l,this,u)}:this.validator=()=>[],i?this.refiner=(u,l)=>{const f=i(u,l);return sr(f,l,this,u)}:this.refiner=()=>[]}assert(e,r){return lt(e,this,r)}create(e,r){return br(e,this,r)}is(e){return U(e,this)}mask(e,r){return Sr(e,this,r)}validate(e,r={}){return De(e,this,r)}}function lt(t,e,r){const n=De(t,e,{message:r});if(n[0])throw n[0]}function br(t,e,r){const n=De(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Sr(t,e,r){const n=De(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function U(t,e){return!De(t,e)[0]}function De(t,e,r={}){const n=At(t,e,r),s=Tn(n);return s[0]?[new bn(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Ce(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?kn(n):g(n)}function D(t,e){return new X({type:t,schema:null,validator:e})}function ht(){return D("any",()=>!0)}function E(t){return new X({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${L(e)}`}})}function vn(){return D("bigint",t=>typeof t=="bigint")}function P(){return D("boolean",t=>typeof t=="boolean")}function J(){return D("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${L(t)}`)}function b(t){const e=L(t),r=typeof t;return new X({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${L(n)}`}})}function Tr(){return D("never",()=>!1)}function O(t){return new X({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function he(){return D("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${L(t)}`)}function g(t){const e=t?Object.keys(t):[],r=Tr();return new X({type:"object",schema:t||null,*entries(n){if(t&&V(n)){const s=new Set(Object.keys(n));for(const i of e)s.delete(i),yield[i,n[i],t[i]];for(const i of s)yield[i,n[i],r]}},validator(n){return V(n)||`Expected an object, but received: ${L(n)}`},coercer(n){return V(n)?{...n}:n}})}function w(t){return new X({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Z(t,e){return new X({type:"record",schema:null,*entries(r){if(V(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`}})}function h(){return D("string",t=>typeof t=="string"||`Expected a string, but received: ${L(t)}`)}function Er(t){const e=Tr();return new X({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let s=0;s<n;s++)yield[s,r[s],t[s]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${L(r)}`}})}function kn(t){const e=Object.keys(t);return new X({type:"type",schema:t,*entries(r){if(V(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`},coercer(r){return V(r)?{...r}:r}})}function j(t){const e=t.map(r=>r.type).join(" | ");return new X({type:"union",schema:null,coercer(r){for(const n of t){const[s,i]=n.validate(r,{coerce:!0});if(!s)return i}return r},validator(r,n){const s=[];for(const i of t){const[...a]=At(r,i,n),[o]=a;if(o[0])for(const[u]of a)u&&s.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${L(r)}`,...s]}})}function vr(){return D("unknown",()=>!0)}const xn="0.50.1",_n="1.19.0",An={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class kr extends Error{}class xr extends kr{constructor(e,r){super(e),this.code=r,this.type=An[r]??"ServerError"}}class In extends kr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var It=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},A=(t,e,r)=>(It(t,e,"read from private field"),r?r.call(t):e.get(t)),ie=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},we=(t,e,r,n)=>(It(t,e,"write to private field"),e.set(t,r),r),On=(t,e,r,n)=>({set _(s){we(t,e,s)},get _(){return A(t,e,n)}}),_r=(t,e,r)=>(It(t,e,"access private method"),r),de,Oe,ee,le,Be,be,ft,Ar,Ot,Ir;function jn(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const Cn={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class Bn{constructor(e,r={}){if(ie(this,ft),ie(this,Ot),ie(this,de,0),ie(this,Oe,0),ie(this,ee,null),ie(this,le,null),ie(this,Be,new Set),ie(this,be,new Map),this.endpoint=e,this.options={...Cn,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=jn(this.endpoint))}async makeRequest(e,r){const n=await _r(this,ft,Ar).call(this);return new Promise((s,i)=>{we(this,de,A(this,de)+1),A(this,be).set(A(this,de),{resolve:s,reject:i,timeout:setTimeout(()=>{A(this,be).delete(A(this,de)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:A(this,de),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new xr(s.message,s.code);return i})}async subscribe(e){const r=new Mn(e);return A(this,Be).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}de=new WeakMap;Oe=new WeakMap;ee=new WeakMap;le=new WeakMap;Be=new WeakMap;be=new WeakMap;ft=new WeakSet;Ar=function(){return A(this,le)?A(this,le):(we(this,le,new Promise(t=>{var e;(e=A(this,ee))==null||e.close(),we(this,ee,new this.options.WebSocketConstructor(this.endpoint)),A(this,ee).addEventListener("open",()=>{we(this,Oe,0),t(A(this,ee))}),A(this,ee).addEventListener("close",()=>{On(this,Oe)._++,A(this,Oe)<=this.options.maxReconnects&&setTimeout(()=>{_r(this,Ot,Ir).call(this)},this.options.reconnectTimeout)}),A(this,ee).addEventListener("message",({data:r})=>{let n;try{n=JSON.parse(r)}catch(s){console.error(new Error(`Failed to parse RPC message: ${r}`,{cause:s}));return}if("id"in n&&n.id!=null&&A(this,be).has(n.id)){const{resolve:s,timeout:i}=A(this,be).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;A(this,Be).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),A(this,le))};Ot=new WeakSet;Ir=async function(){var t;return(t=A(this,ee))==null||t.close(),we(this,le,null),Promise.allSettled([...A(this,Be)].map(e=>e.subscribe(this)))};class Mn{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:r}=this;return this.subscribed=!1,r==null?!1:(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[r]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const r=await e.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=r)}}var jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},z=(t,e,r)=>(jt(t,e,"read from private field"),r?r.call(t):e.get(t)),ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},gt=(t,e,r,n)=>(jt(t,e,"write to private field"),e.set(t,r),r),Pn=(t,e,r)=>(jt(t,e,"access private method"),r),_e,F,je,pt,Or;class Rn{constructor(e){ze(this,pt),ze(this,_e,0),ze(this,F,void 0),ze(this,je,void 0),gt(this,F,e)}fetch(e,r){const n=z(this,F).fetch??globalThis.fetch;if(!this.fetch)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return n(e,r)}async request(e){var s,i;gt(this,_e,z(this,_e)+1);const r=await this.fetch(((s=z(this,F).rpc)==null?void 0:s.url)??z(this,F).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":xn,"Client-Target-Api-Version":_n,...(i=z(this,F).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:z(this,_e),method:e.method,params:e.params})});if(!r.ok)throw new In(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new xr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await Pn(this,pt,Or).call(this).subscribe(e);return async()=>!!await r()}}_e=new WeakMap;F=new WeakMap;je=new WeakMap;pt=new WeakSet;Or=function(){var t;if(!z(this,je)){const e=z(this,F).WebSocketConstructor??globalThis.WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");gt(this,je,new Bn(((t=z(this,F).websocket)==null?void 0:t.url)??z(this,F).url,{WebSocketConstructor:e,...z(this,F).websocket}))}return z(this,je)};const Nn=/^vector<(.+)>$/,$n=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class te{static parseFromStr(e,r=!1){if(e==="address")return{address:null};if(e==="bool")return{bool:null};if(e==="u8")return{u8:null};if(e==="u16")return{u16:null};if(e==="u32")return{u32:null};if(e==="u64")return{u64:null};if(e==="u128")return{u128:null};if(e==="u256")return{u256:null};if(e==="signer")return{signer:null};const n=e.match(Nn);if(n)return{vector:te.parseFromStr(n[1],r)};const s=e.match($n);if(s)return{struct:{address:r?d.normalizeSuiAddress(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:te.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return gr(e).map(n=>te.parseFromStr(n,r))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${te.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(te.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const k=new _({...wn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function jr(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function Un(t){return c.enum("Option",{None:null,Some:t})}function Ct(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const G=c.bytes(d.SUI_ADDRESS_LENGTH).transform({input:t=>typeof t=="string"?Ue(d.normalizeSuiAddress(t)):t,output:t=>d.normalizeSuiAddress(ge(t))}),Bt=c.vector(c.u8()).transform({name:"ObjectDigest",input:t=>d.fromB58(t),output:t=>d.toB58(new Uint8Array(t))}),Me=c.struct("SuiObjectRef",{objectId:G,version:c.u64(),digest:Bt}),Mt=c.struct("SharedObjectRef",{objectId:G,initialSharedVersion:c.u64(),mutable:c.bool()}),Ye=c.enum("ObjectArg",{ImmOrOwned:Me,Shared:Mt,Receiving:Me}),Pt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:Ye,ObjVec:c.vector(Ye)}),ve=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>ve),struct:c.lazy(()=>zt),u16:null,u32:null,u256:null}),q=Ct(c.enum("Argument",{GasCoin:null,Input:c.struct("Input",{index:c.u16()}),Result:c.struct("Result",{index:c.u16()}),NestedResult:c.struct("NestedResult",{index:c.u16(),resultIndex:c.u16()})})),Rt=c.struct("ProgrammableMoveCall",{package:G,module:c.string(),function:c.string(),type_arguments:c.vector(ve),arguments:c.vector(q)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>te.parseFromStr(i,!0));return{package:d.normalizeSuiAddress(e),module:r,function:n,type_arguments:s,arguments:t.arguments}},output:t=>({target:[t.package,t.module,t.function].join("::"),arguments:t.arguments,typeArguments:t.type_arguments.map(te.tagToString)})}),Nt=Ct(c.enum("Transaction",{MoveCall:Rt,TransferObjects:c.struct("TransferObjects",{objects:c.vector(q),address:q}),SplitCoins:c.struct("SplitCoins",{coin:q,amounts:c.vector(q)}),MergeCoins:c.struct("MergeCoins",{destination:q,sources:c.vector(q)}),Publish:c.struct("Publish",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G)}),MakeMoveVec:c.struct("MakeMoveVec",{type:Un(ve),objects:c.vector(q)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G),packageId:G,ticket:q})})),$t=c.struct("ProgrammableTransaction",{inputs:c.vector(Pt),transactions:c.vector(Nt)}),Ut=c.enum("TransactionKind",{ProgrammableTransaction:$t,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Dt=c.enum("TransactionExpiration",{None:null,Epoch:jr()}),zt=c.struct("StructTag",{address:G,module:c.string(),name:c.string(),typeParams:c.vector(ve)}),Vt=c.struct("GasData",{payment:c.vector(Me),owner:G,price:c.u64(),budget:c.u64()}),Lt=c.struct("TransactionDataV1",{kind:Ut,sender:G,gasData:Vt,expiration:Dt}),qt=c.enum("TransactionData",{V1:Lt}),Dn=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),zn=c.enum("IntentVersion",{V0:null}),Vn=c.enum("AppId",{Sui:null}),Ln=c.struct("Intent",{scope:Dn,version:zn,appId:Vn}),qn=c.generic(["T"],t=>c.struct("IntentMessage<T>",{intent:Ln,value:t})),Wt=c.enum("CompressedSignature",{ED25519:c.fixedArray(64,c.u8()),Secp256k1:c.fixedArray(64,c.u8()),Secp256r1:c.fixedArray(64,c.u8()),ZkLogin:c.vector(c.u8())}),Ft=c.enum("PublicKey",{ED25519:c.fixedArray(32,c.u8()),Secp256k1:c.fixedArray(33,c.u8()),Secp256r1:c.fixedArray(33,c.u8()),ZkLogin:c.vector(c.u8())}),Kt=c.struct("MultiSigPkMap",{pubKey:Ft,weight:c.u8()}),Gt=c.struct("MultiSigPublicKey",{pk_map:c.vector(Kt),threshold:c.u16()}),Cr=c.struct("MultiSig",{sigs:c.vector(Wt),bitmap:c.u16(),multisig_pk:Gt}),Wn=c.vector(c.u8()).transform({input:t=>typeof t=="string"?H(t):t,output:t=>$(new Uint8Array(t))}),Br=c.struct("SenderSignedTransaction",{intentMessage:qn(qt),txSignatures:c.vector(Wn)}),Mr=c.vector(Br,{name:"SenderSignedData"}),I={...c,U8:c.u8(),U16:c.u16(),U32:c.u32(),U64:c.u64(),U128:c.u128(),U256:c.u256(),ULEB128:c.uleb128(),Bool:c.bool(),String:c.string(),Address:G,Argument:q,CallArg:Pt,CompressedSignature:Wt,GasData:Vt,MultiSig:Cr,MultiSigPkMap:Kt,MultiSigPublicKey:Gt,ObjectArg:Ye,ObjectDigest:Bt,ProgrammableMoveCall:Rt,ProgrammableTransaction:$t,PublicKey:Ft,SenderSignedData:Mr,SenderSignedTransaction:Br,SharedObjectRef:Mt,StructTag:zt,SuiObjectRef:Me,Transaction:Nt,TransactionData:qt,TransactionDataV1:Lt,TransactionExpiration:Dt,TransactionKind:Ut,TypeTag:ve,ser:k.ser.bind(k),de:k.de.bind(k),getTypeInterface:k.getTypeInterface.bind(k),hasType:k.hasType.bind(k),parseTypeName:k.parseTypeName.bind(k),registerAddressType:k.registerAddressType.bind(k),registerAlias:k.registerAlias.bind(k),registerBcsType:k.registerBcsType.bind(k),registerEnumType:k.registerEnumType.bind(k),registerStructType:k.registerStructType.bind(k),registerType:k.registerType.bind(k),types:k.types};k.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));k.registerBcsType("unsafe_u64",()=>jr());k.registerBcsType("enumKind",t=>Ct(t));[G,q,Pt,Wt,Vt,Cr,Kt,Gt,Ye,Bt,Rt,$t,Ft,Mr,Mt,zt,Me,Nt,qt,Lt,Dt,Ut,ve].forEach(t=>{k.registerBcsType(t.name,()=>t)});const Ht=j([g({AddressOwner:h()}),g({ObjectOwner:h()}),g({Shared:g({initial_shared_version:O(h())})}),b("Immutable")]);D("SuiJsonValue",()=>!0);const Fn=j([g({u32:h()}),g({u64:h()}),g({f64:h()})]);g({attributes:Z(h(),O(Fn)),featureFlags:Z(h(),P()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});j([h(),b("package")]);const oe=g({digest:h(),objectId:h(),version:j([he(),h(),vn()])});g({owner:Ht,reference:oe});g({objectId:h(),sequenceNumber:h()});g({payment:E(oe),owner:h(),price:h(),budget:h()});const Kn=Ce(oe,g({type:h(),owner:Ht,previousTransaction:h()})),Gn=Z(h(),ht()),Hn=Z(h(),vr()),Zn=g({type:h(),fields:Gn,hasPublicTransfer:P()}),Jn=g({disassembled:Hn}),Xn=j([Ce(Zn,g({dataType:b("moveObject")})),Ce(Jn,g({dataType:b("package")}))]),Yn=g({type:h(),hasPublicTransfer:P(),version:h(),bcsBytes:h()}),Qn=g({id:h(),moduleMap:Z(h(),h())}),es=j([Ce(Yn,g({dataType:b("moveObject")})),Ce(Qn,g({dataType:b("package")}))]);BigInt(1e9);const Pr=g({code:h(),error:w(h()),object_id:w(h()),parent_object_id:w(h()),version:w(h()),digest:w(h())}),ts=g({data:O(w(Z(h(),h()))),error:O(w(Pr))}),rs=j([ts,w(Z(h(),h()))]),Rr=g({objectId:h(),version:h(),digest:h(),type:O(w(h())),content:O(w(Xn)),bcs:O(w(es)),owner:O(w(Ht)),previousTransaction:O(w(h())),storageRebate:O(w(h())),display:O(w(rs))});g({showType:O(w(P())),showContent:O(w(P())),showBcs:O(w(P())),showOwner:O(w(P())),showPreviousTransaction:O(w(P())),showStorageRebate:O(w(P())),showDisplay:O(w(P()))});j([b("Exists"),b("notExists"),b("Deleted")]);E(Kn);const ns=g({data:O(w(Rr)),error:O(w(Pr))});function ss(t){return t.data}function is(t){if(t.error&&"object_id"in t.error&&"version"in t.error&&"digest"in t.error){const e=t.error;return{objectId:e.object_id,version:e.version,digest:e.digest}}}function ir(t){if("reference"in t)return t.reference;const e=ss(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:is(t)}g({objectId:h(),atCheckpoint:w(he())});g({data:E(ns),nextCursor:w(O(h())),hasNextPage:P()});j([g({details:Rr,status:b("VersionFound")}),g({details:h(),status:b("ObjectNotExists")}),g({details:oe,status:b("ObjectDeleted")}),g({details:Er([h(),he()]),status:b("VersionNotFound")}),g({details:g({asked_version:he(),latest_version:he(),object_id:h()}),status:b("VersionTooHigh")})]);const as=j([h(),g({Object:h()})]);E(as);const os=g({address:h(),name:h()}),cs=j([b("Private"),b("Public"),b("Friend")]),Zt=g({abilities:E(h())}),us=g({constraints:Zt,isPhantom:P()}),ds=g({TypeParameter:he()}),ct=Er([g({module:h(),package:h(),function:h()}),h()]);g({rank3Days:E(ct),rank7Days:E(ct),rank30Days:E(ct)});function Nr(t){if(!t)return!1;if(typeof t=="string"||U(t,ds)||$r(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(U(e.Reference,Se)||U(e.MutableReference,Se)||U(e.Vector,Se))}const Se=D("SuiMoveNormalizedType",Nr);function $r(t){if(!t||typeof t!="object")return!1;const e=t;if(!e.Struct||typeof e.Struct!="object")return!1;const r=e.Struct;return!(typeof r.address!="string"||typeof r.module!="string"||typeof r.name!="string"||!Array.isArray(r.typeArguments)||!r.typeArguments.every(n=>Nr(n)))}D("SuiMoveNormalizedStructType",$r);const ls=g({visibility:cs,isEntry:P(),typeParameters:E(Zt),parameters:E(Se),return:E(Se)}),hs=g({name:h(),type:Se}),fs=g({abilities:Zt,typeParameters:E(us),fields:E(hs)}),gs=g({fileFormatVersion:he(),address:h(),name:h(),friends:E(os),structs:Z(h(),fs),exposedFunctions:Z(h(),ls)});Z(h(),gs);function yt(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function Ur(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function Jt(t){if(typeof t=="object"&&"Struct"in t)return t;const e=Ur(t),r=yt(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const ps=j([g({ImmOrOwned:oe}),g({Shared:g({objectId:h(),initialSharedVersion:j([J(),h()]),mutable:P()})}),g({Receiving:oe})]),Qe=g({Pure:E(J())}),mt=g({Object:ps}),et=j([Qe,mt]);function ys(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:_t(t)?t.toBytes():I.ser(e,t,{maxSize:1/0}).toBytes())}}const N={Pure:ys,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:d.normalizeSuiAddress(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}}};function ar(t){return typeof t=="string"?d.normalizeSuiAddress(t):"ImmOrOwned"in t.Object?d.normalizeSuiAddress(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?d.normalizeSuiAddress(t.Object.Receiving.objectId):d.normalizeSuiAddress(t.Object.Shared.objectId)}function ms(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function ws(t){var e;return((e=ms(t))==null?void 0:e.mutable)??!1}function bs(t){function e(r,n){return t(r,n)}return e.u8=r=>t(I.U8.serialize(r)),e.u16=r=>t(I.U16.serialize(r)),e.u32=r=>t(I.U32.serialize(r)),e.u64=r=>t(I.U64.serialize(r)),e.u128=r=>t(I.U128.serialize(r)),e.u256=r=>t(I.U256.serialize(r)),e.bool=r=>t(I.Bool.serialize(r)),e.string=r=>t(I.String.serialize(r)),e.address=r=>t(I.Address.serialize(r)),e.id=e.address,e}const Ss="object",Ts="ID",Es="ascii",vs="String",ks="string",xs="String",_s="option",As="Option",Is={address:d.SUI_FRAMEWORK_ADDRESS,module:Ss,name:Ts},Os={address:d.MOVE_STDLIB_ADDRESS,module:Es,name:vs},js={address:d.MOVE_STDLIB_ADDRESS,module:ks,name:xs},Cs={address:d.MOVE_STDLIB_ADDRESS,module:_s,name:As},Ve=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function Bs(t){var r;const e=(r=Jt(t))==null?void 0:r.Struct;return(e==null?void 0:e.address)==="0x2"&&(e==null?void 0:e.module)==="tx_context"&&(e==null?void 0:e.name)==="TxContext"}function ut(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const Ms=["Address","Bool","U8","U16","U32","U64","U128","U256"];function wt(t,e){if(typeof t=="string"&&Ms.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])ut("number",e);else if(t==="Bool")ut("boolean",e);else if(t==="Address"&&(ut("string",e),e&&!d.isValidSuiAddress(e)))throw new Error("Invalid Sui Address");return t.toLowerCase()}else if(typeof t=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(t,null,2)}`);if("Vector"in t){if((e===void 0||typeof e=="string")&&t.Vector==="U8")return"string";if(e!==void 0&&!Array.isArray(e))throw new Error(`Expect ${e} to be a array, received ${typeof e}`);const r=wt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(Ve(t.Struct,Os))return"string";if(Ve(t.Struct,js))return"utf8string";if(Ve(t.Struct,Is))return"address";if(Ve(t.Struct,Cs)){const r={Vector:t.Struct.typeArguments[0]};return wt(r,e)}}}function Ps(t,e){const r=Array.from(`${t}::`).map(s=>s.charCodeAt(0)),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),d.blake2b(n,{dkLen:32})}function R(t,e){return br(t,e)}const Rs=t=>j([g({None:j([b(!0),b(null)])}),g({Some:t})]),Pe=j([g({kind:b("Input"),index:J(),value:w(ht()),type:w(b("object"))}),g({kind:b("Input"),index:J(),value:w(ht()),type:b("pure")})]),Ns=[Pe,g({kind:b("GasCoin")}),g({kind:b("Result"),index:J()}),g({kind:b("NestedResult"),index:J(),resultIndex:J()})],ne=j([...Ns]),Dr=g({kind:b("MoveCall"),target:D("target",h().validator),typeArguments:E(h()),arguments:E(ne)}),zr=g({kind:b("TransferObjects"),objects:E(ne),address:ne}),Vr=g({kind:b("SplitCoins"),coin:ne,amounts:E(ne)}),Lr=g({kind:b("MergeCoins"),destination:ne,sources:E(ne)}),qr=g({kind:b("MakeMoveVec"),type:w(Rs(Z(h(),vr()))),objects:E(ne)}),Wr=g({kind:b("Publish"),modules:E(E(J())),dependencies:E(h())}),Fr=g({kind:b("Upgrade"),modules:E(E(J())),dependencies:E(h()),packageId:h(),ticket:ne}),$s=[Dr,zr,Vr,Lr,Wr,Fr,qr],Us=j([...$s]),ue={MoveCall(t){return R({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},Dr)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=N.Pure(I.Address.serialize(e.value))),R({kind:"TransferObjects",objects:t,address:e},zr)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=N.Pure(I.U64.serialize(r.value)))}),R({kind:"SplitCoins",coin:t,amounts:e},Vr)},MergeCoins(t,e){return R({kind:"MergeCoins",destination:t,sources:e},Lr)},Publish({modules:t,dependencies:e}){return R({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(H(r)):r),dependencies:e.map(r=>d.normalizeSuiObjectId(r))},Wr)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return R({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(H(s)):s),dependencies:e.map(s=>d.normalizeSuiObjectId(s)),packageId:r,ticket:n},Fr)},MakeMoveVec({type:t,objects:e}){return R({kind:"MakeMoveVec",type:t?{Some:te.parseFromStr(t)}:{None:null},objects:e},qr)}},Ds=w(O(j([g({Epoch:J()}),g({None:j([b(!0),b(null)])})]))),or=D("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),zs=g({budget:w(or),price:w(or),payment:w(E(oe)),owner:w(h())}),Le=g({version:b(1),sender:w(h()),expiration:Ds,gasConfig:zs,inputs:E(Pe),transactions:E(Us)});function cr(t){return d.normalizeSuiAddress(t).replace("0x","")}class re{constructor(e){this.version=1,this.sender=e==null?void 0:e.sender,this.expiration=e==null?void 0:e.expiration,this.gasConfig=(e==null?void 0:e.gasConfig)??{},this.inputs=(e==null?void 0:e.inputs)??[],this.transactions=(e==null?void 0:e.transactions)??[]}static fromKindBytes(e){const r=I.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=R({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>R({kind:"Input",value:i,index:a,type:U(i,Qe)?"pure":"object"},Pe)),transactions:n.transactions},Le);return re.restore(s)}static fromBytes(e){var a;const r=I.TransactionData.parse(e),n=r==null?void 0:r.V1,s="ProgrammableTransaction"in n.kind?(a=n==null?void 0:n.kind)==null?void 0:a.ProgrammableTransaction:null;if(!n||!s)throw new Error("Unable to deserialize from bytes.");const i=R({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((o,u)=>R({kind:"Input",value:o,index:u,type:U(o,Qe)?"pure":"object"},Pe)),transactions:s.transactions},Le);return re.restore(i)}static restore(e){lt(e,Le);const r=new re;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=Ps("TransactionData",e);return d.toB58(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(f=>(lt(f.value,et),f.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return I.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,o=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const l={sender:cr(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:cr(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return I.TransactionData.serialize({V1:l},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return re.getDigestFromBytes(e)}snapshot(){return R(this,Le)}}var Xt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},v=(t,e,r)=>(Xt(t,e,"read from private field"),r?r.call(t):e.get(t)),Y=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},qe=(t,e,r,n)=>(Xt(t,e,"write to private field"),e.set(t,r),r),B=(t,e,r)=>(Xt(t,e,"access private method"),r),S,Ae,Fe,Ie,Ke,ce,fe,Yt,Kr,Qt,Gr,er,Hr,tr,Zr,Ge,bt;const Vs={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function Ls(t){const e={kind:"Result",index:t},r=[],n=s=>r[s]??(r[s]={kind:"NestedResult",index:t,resultIndex:s});return new Proxy(e,{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(s,i){if(i in s)return Reflect.get(s,i);if(i===Symbol.iterator)return function*(){let o=0;for(;;)yield n(o),o++};if(typeof i=="symbol")return;const a=parseInt(i,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function qs(t){const e=Jt(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Re(t){if(!t.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return t.client}const Jr=Symbol.for("@mysten/transaction"),dt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},Ws=1000n,Fs=50,Ks=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function Gs(t){return!!t&&typeof t=="object"&&t[Jr]===!0}const St=class{constructor(t){Y(this,Ae),Y(this,Ie),Y(this,ce),Y(this,Yt),Y(this,Qt),Y(this,er),Y(this,tr),Y(this,Ge),Y(this,S,void 0),qe(this,S,new re(t?t.blockData:void 0))}static fromKind(t){const e=new St;return qe(e,S,re.fromKindBytes(typeof t=="string"?H(t):t)),e}static from(t){const e=new St;return typeof t!="string"||!t.startsWith("{")?qe(e,S,re.fromBytes(typeof t=="string"?H(t):t)):qe(e,S,re.restore(JSON.parse(t))),e}setSender(t){v(this,S).sender=t}setSenderIfNotSet(t){v(this,S).sender||(v(this,S).sender=t)}setExpiration(t){v(this,S).expiration=t}setGasPrice(t){v(this,S).gasConfig.price=String(t)}setGasBudget(t){v(this,S).gasConfig.budget=String(t)}setGasOwner(t){v(this,S).gasConfig.owner=t}setGasPayment(t){v(this,S).gasConfig.payment=t.map(e=>Sr(e,oe))}get blockData(){return v(this,S).snapshot()}get[Jr](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:bs((t,e)=>_t(t)?B(this,Ae,Fe).call(this,"pure",{Pure:Array.from(t.toBytes())}):B(this,Ae,Fe).call(this,"pure",t instanceof Uint8Array?N.Pure(t):e?N.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=ar(t),r=v(this,S).inputs.find(n=>n.type==="object"&&e===ar(n.value));return r&&U(r.value,mt)&&"Shared"in r.value.Object&&U(t,mt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??B(this,Ae,Fe).call(this,"object",typeof t=="string"?d.normalizeSuiAddress(t):t)}objectRef(...t){return this.object(N.ObjectRef(...t))}receivingRef(...t){return this.object(N.ReceivingRef(...t))}sharedObjectRef(...t){return this.object(N.SharedObjectRef(...t))}add(t){const e=v(this,S).transactions.push(t);return Ls(e-1)}splitCoins(t,e){return this.add(ue.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):B(this,Ie,Ke).call(this,r))))}mergeCoins(t,e){return this.add(ue.MergeCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="string"?this.object(r):r)))}publish({modules:t,dependencies:e}){return this.add(ue.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(ue.Upgrade({modules:t,dependencies:e,packageId:r,ticket:typeof n=="string"?this.object(n):n}))}moveCall({arguments:t,typeArguments:e,target:r}){return this.add(ue.MoveCall({arguments:t==null?void 0:t.map(n=>B(this,Ie,Ke).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(ue.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):B(this,Ie,Ke).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(ue.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(v(this,S).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).build({maxSizeBytes:B(this,ce,fe).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).getDigest()}};let Hs=St;S=new WeakMap;Ae=new WeakSet;Fe=function(t,e){const r=v(this,S).inputs.length,n=R({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Pe);return v(this,S).inputs.push(n),n};Ie=new WeakSet;Ke=function(t){return _t(t)?this.pure(t):t};ce=new WeakSet;fe=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return Vs[t];const n=e==null?void 0:e.attributes[dt[t]];if(!n)throw new Error(`Missing expected protocol config: "${dt[t]}"`);const s="u64"in n?n.u64:"u32"in n?n.u32:n.f64;if(!s)throw new Error(`Unexpected protocol config value found for: "${dt[t]}"`);return Number(s)};Yt=new WeakSet;Kr=function(t){const e=B(this,ce,fe).call(this,"maxPureArgumentSize",t);v(this,S).inputs.forEach((r,n)=>{if(U(r.value,Qe)&&r.value.Pure.length>e)throw new Error(`Input at index ${n} is too large, max pure input size is ${e} bytes, got ${r.value.Pure.length} bytes`)})};Qt=new WeakSet;Gr=async function(t){if(v(this,S).gasConfig.payment){const s=B(this,ce,fe).call(this,"maxGasObjects",t);if(v(this,S).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||v(this,S).gasConfig.payment)return;const e=v(this,S).gasConfig.owner??v(this,S).sender,n=(await Re(t).getCoins({owner:e,coinType:d.SUI_TYPE_ARG})).data.filter(s=>!v(this,S).inputs.find(a=>U(a.value,et)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,B(this,ce,fe).call(this,"maxGasObjects",t)-1).map(s=>({objectId:s.coinObjectId,digest:s.digest,version:s.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");this.setGasPayment(n)};er=new WeakSet;Hr=async function(t){t.onlyTransactionKind||v(this,S).gasConfig.price||this.setGasPrice(await Re(t).getReferenceGasPrice())};tr=new WeakSet;Zr=async function(t){const{inputs:e,transactions:r}=v(this,S),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:d.normalizeSuiAddress(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!U(e[o.index].value,et))&&n.push(i),i.kind==="SplitCoins"&&i.amounts.forEach(a=>{if(a.kind==="Input"){const o=e[a.index];typeof o.value!="object"&&(o.value=N.Pure(I.U64.serialize(o.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=N.Pure(I.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,u]=i.target.split("::"),l=await Re(t).getNormalizedMoveFunction({package:d.normalizeSuiObjectId(a),module:o,function:u}),p=l.parameters.length>0&&Bs(l.parameters.at(-1))?l.parameters.slice(0,l.parameters.length-1):l.parameters;if(p.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");p.forEach((y,m)=>{const x=i.arguments[m];if(x.kind!=="Input")return;const T=e[x.index];if(U(T.value,et))return;const C=T.value,M=wt(y,C);if(M){T.value=N.Pure(C,M);return}if(Jt(y)!=null||typeof y=="object"&&"TypeParameter"in y){if(typeof C!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(C,null,2)}`);s.push({id:C,input:T,normalizedType:y});return}throw new Error(`Unknown call arg type ${JSON.stringify(y,null,2)} for value ${JSON.stringify(C,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:f})=>f))],a=Ks(i,Fs),o=(await Promise.all(a.map(f=>Re(t).multiGetObjects({ids:f,options:{showOwner:!0}})))).flat();let u=new Map(i.map((f,p)=>[f,o[p]]));const l=Array.from(u).filter(([f,p])=>p.error).map(([f,p])=>f);if(l.length)throw new Error(`The following input objects are invalid: ${l.join(", ")}`);s.forEach(({id:f,input:p,normalizedType:y})=>{var C;const m=u.get(f),x=(C=m.data)==null?void 0:C.owner,T=x&&typeof x=="object"&&"Shared"in x?x.Shared.initial_shared_version:void 0;if(T){const M=y!=null&&yt(y)==null&&Ur(y)==null,se=ws(p.value)||M||y!=null&&yt(y)!=null;p.value=N.SharedObjectRef({objectId:f,initialSharedVersion:T,mutable:se})}else y&&qs(y)?p.value=N.ReceivingRef(ir(m)):p.value=N.ObjectRef(ir(m))})}};Ge=new WeakSet;bt=async function(t){if(!t.onlyTransactionKind&&!v(this,S).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([B(this,er,Hr).call(this,t),B(this,tr,Zr).call(this,t)]),!t.onlyTransactionKind&&(await B(this,Qt,Gr).call(this,t),!v(this,S).gasConfig.budget)){const e=await Re(t).dryRunTransactionBlock({transactionBlock:v(this,S).build({maxSizeBytes:B(this,ce,fe).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(B(this,ce,fe).call(this,"maxTxGas",t)),payment:[]}}})});if(e.effects.status.status!=="success")throw new Error(`Dry run failed, could not automatically determine a budget: ${e.effects.status.error}`,{cause:e});const r=Ws*BigInt(this.blockData.gasConfig.price||1n),n=BigInt(e.effects.gasUsed.computationCost)+r,s=n+BigInt(e.effects.gasUsed.storageCost)-BigInt(e.effects.gasUsed.storageRebate);this.setGasBudget(s>n?s:n)}B(this,Yt,Kr).call(this,t)};const Zs=Symbol.for("@mysten/SuiClient");class Js{get[Zs](){return!0}constructor(e){this.transport=e.transport??new Rn({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,r){return await this.transport.request({method:e,params:r})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach(n=>{if(!n||!d.isValidSuiObjectId(d.normalizeSuiObjectId(n)))throw new Error(`Invalid Sui Object id ${n}`)}),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,(e.order||"descending")==="descending"]})}async getTransactionBlock(e){if(!d.isValidTransactionDigest(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach(n=>{if(!d.isValidTransactionDigest(n))throw new Error(`Invalid Transaction digest ${n}`)}),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock(e){return await this.transport.request({method:"sui_executeTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock),Array.isArray(e.signature)?e.signature:[e.signature],e.options,e.requestType]})}async signAndExecuteTransactionBlock({transactionBlock:e,signer:r,...n}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(r.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:a}=await r.signTransactionBlock(s);return this.executeTransactionBlock({transactionBlock:a,signature:i,...n})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach(r=>{if(!r||!d.isValidSuiObjectId(d.normalizeSuiObjectId(r)))throw new Error(`Invalid Sui Stake id ${r}`)}),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,(e.order||"descending")==="descending"]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){var n;let r;if(Gs(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=$(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=$(e.transactionBlock);else throw new Error("Unknown transaction block format.");return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,r,(n=e.gasPrice)==null?void 0:n.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e==null?void 0:e.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e==null?void 0:e.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e==null?void 0:e.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"}),r=d.fromB58(e.digest);return ge(r.slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames(e){return await this.transport.request({method:"suix_resolveNameServiceNames",params:[e.address,e.cursor,e.limit]})}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e==null?void 0:e.version]})}async waitForTransactionBlock({signal:e,timeout:r=60*1e3,pollInterval:n=2*1e3,...s}){const i=AbortSignal.timeout(r),a=new Promise((o,u)=>{i.addEventListener("abort",()=>u(i.reason))});for(a.catch(()=>{});!i.aborted;){e==null||e.throwIfAborted();try{return await this.getTransactionBlock(s)}catch{await Promise.race([new Promise(u=>setTimeout(u,n)),a])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}class Xr extends d.ChainContext{}const Tt="Sui",rr=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},Xs=(t,e)=>{try{return d.normalizeSuiType(t)===d.normalizeSuiType(e)}catch{return!1}},Ys=t=>(t==null?void 0:t.type)==="created",Qs=t=>(t==null?void 0:t.type)==="published";function ei(t){return Array.isArray(t)}function rt(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function Yr(t){return typeof t=="object"&&!ei(t)&&!rt(t)}function ti(t){return typeof t=="object"&&"id"in t}const ri=16*1024,ni=t=>I.ser("vector<u8>",t,{maxSize:ri}).toBytes(),si=async(t,e)=>{const{data:r,error:n}=await t.getObject({id:e,options:{showContent:!0}});if(n)throw new Error("Error getting object: "+n);if(!r||!rt(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return d.getPackageIdFromType(r.content.type)},Qr=async(t,e)=>{if(!d.isValidSuiAddress(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return rr(r)},ii=async(t,e)=>{let r,n;do{const a=await t.getDynamicFields({parentId:e,cursor:n});r=a.data.find(o=>o.name.type.endsWith("CurrentPackage")),n=a.hasNextPage?a.nextCursor:null}while(n&&!r);if(!r)throw new Error("CurrentPackage not found");const s=await t.getObject({id:r.objectId,options:{showContent:!0}}),i=rr(s);if(!i||!Yr(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!rt(i.value))throw new Error("Unable to get package id");return i.value.fields.package},ai=async(t,e,r)=>{let n=null,s=null,i=null,a;do{if(i=await t.getOwnedObjects({owner:r,filter:{StructType:`${e}::emitter::EmitterCap`},options:{showContent:!0},cursor:a}),!i||!i.data)throw Error("Failed to get owned objects");for(const o of i.data){if(!o.data)continue;const{version:u,objectId:l}=o.data;(n===null||u<n)&&(n=u,s=l)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},oi=async(t,e)=>{const r=new Hs,[n]=r.publish({modules:t.modules.map(s=>Array.from(d.b64.decode(s))),dependencies:t.dependencies.map(s=>d.normalizeSuiObjectId(s))});return r.transferObjects([n],r.pure(e)),r},Q=class Q extends d.PlatformContext{constructor(e,r){super(e,r??d.networkPlatformConfigs(e,Q._platform))}getRpc(e){if(e in this.config)return new Js({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new Xr(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!Q.isSupportedChain(r))throw new Error(`invalid chain for ${Tt}: ${r}`);return d.Wormhole.tokenId(r,d.SUI_COIN)}static isNativeTokenId(e,r,n){return!Q.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return d.chainToPlatform(e)===Q._platform}static async getDecimals(e,r,n){if(d.isNative(n))return d.nativeDecimals(Q._platform);const s=new d.SuiAddress(n);try{const a=await Qr(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.toString()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getCoins(e,r,n){let s=[],i=null;const a=new d.SuiAddress(r).toString();do{const o=await e.getCoins({owner:a,coinType:n,cursor:i});s=[...s,...o.data],i=o.hasNextPage?o.nextCursor:null}while(i);return s}static async getBalance(e,r,n,s){if(d.isNative(s)){const{totalBalance:a}=await r.getBalance({owner:n});return BigInt(a)}const{totalBalance:i}=await r.getBalance({owner:n,coinType:s.toString()});return BigInt(i)}static async getBalances(e,r,n,s){return(await Promise.all(s.map(async a=>{const o=await this.getBalance(e,r,n,a);return{[d.isNative(a)?"native":new d.SuiAddress(a).toString()]:o}}))).reduce((a,o)=>Object.assign(a,o),{})}static async sendWait(e,r,n){const s=[];for(const i of n){const a=await r.executeTransactionBlock(i);await r.waitForTransactionBlock({digest:a.digest}),s.push(a.digest)}return s}static async getLatestBlock(e){return Number(await e.getLatestCheckpointSequenceNumber())}static async getLatestFinalizedBlock(e){return this.getLatestBlock(e)}static chainFromChainId(e){const r=d.platformNativeChainIdToNetworkChain(Q._platform,e);if(r===void 0)throw new Error(`Unknown native chain id ${e}`);const[n,s]=r;return[n,s]}static async chainFromRpc(e){const r=await e.call("sui_getChainIdentifier",[]);return this.chainFromChainId(r)}};pe(Q,"_platform",Tt);let Ee=Q;var Ne={};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.bech32m=Et=Ne.bech32=void 0;const tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",en={};for(let t=0;t<tt.length;t++){const e=tt.charAt(t);en[e]=t}function Te(t){const e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function ur(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=Te(e)^n>>5}e=Te(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=Te(e)^n&31}return e}function nr(t,e,r,n){let s=0,i=0;const a=(1<<r)-1,o=[];for(let u=0;u<t.length;++u)for(s=s<<e|t[u],i+=e;i>=r;)i-=r,o.push(s>>i&a);if(n)i>0&&o.push(s<<r-i&a);else{if(i>=e)return"Excess padding";if(s<<r-i&a)return"Non-zero padding"}return o}function ci(t){return nr(t,8,5,!0)}function ui(t){const e=nr(t,5,8,!1);if(Array.isArray(e))return e}function di(t){const e=nr(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function tn(t){let e;t==="bech32"?e=1:e=734539939;function r(a,o,u){if(u=u||90,a.length+7+o.length>u)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let l=ur(a);if(typeof l=="string")throw new Error(l);let f=a+"1";for(let p=0;p<o.length;++p){const y=o[p];if(y>>5)throw new Error("Non 5-bit word");l=Te(l)^y,f+=tt.charAt(y)}for(let p=0;p<6;++p)l=Te(l);l^=e;for(let p=0;p<6;++p){const y=l>>(5-p)*5&31;f+=tt.charAt(y)}return f}function n(a,o){if(o=o||90,a.length<8)return a+" too short";if(a.length>o)return"Exceeds length limit";const u=a.toLowerCase(),l=a.toUpperCase();if(a!==u&&a!==l)return"Mixed-case string "+a;a=u;const f=a.lastIndexOf("1");if(f===-1)return"No separator character for "+a;if(f===0)return"Missing prefix for "+a;const p=a.slice(0,f),y=a.slice(f+1);if(y.length<6)return"Data too short";let m=ur(p);if(typeof m=="string")return m;const x=[];for(let T=0;T<y.length;++T){const C=y.charAt(T),M=en[C];if(M===void 0)return"Unknown character "+C;m=Te(m)^M,!(T+6>=y.length)&&x.push(M)}return m!==e?"Invalid checksum for "+a:{prefix:p,words:x}}function s(a,o){const u=n(a,o);if(typeof u=="object")return u}function i(a,o){const u=n(a,o);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:s,decode:i,encode:r,toWords:ci,fromWordsUnsafe:ui,fromWords:di}}var Et=Ne.bech32=tn("bech32");Ne.bech32m=tn("bech32m");var $e=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))($e||{});function li(t){return[t,0,0]}function rn(t,e){const r=li(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const nt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},hi={ED25519:32,Secp256k1:33,Secp256r1:33},fi={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function gi(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function pi(t,e){const r=t.toString(16);return d.hexToBytes(r.padStart(e*2,"0").slice(-e*2))}function yi(t,e){const r=pi(t,e),n=gi(r);return n===-1?new Uint8Array([0]):r.slice(n)}function mi(t,e){const r=yi(t,32);e==="accounts.google.com"&&(e="https://accounts.google.com");const n=new TextEncoder().encode(e),s=new Uint8Array(2+r.length+n.length);return s.set([nt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),d.normalizeSuiAddress(d.bytesToHex(d.blake2b(s,{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}function wi(t){if(t.length!==1)throw new Error("Invalid base64Url character: "+t);const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(t);if(r===-1)throw new Error("Invalid base64Url character: "+t);const n=r.toString(2).padStart(6,"0");return Array.from(n).map(Number)}function bi(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=wi(n);e=e.concat(s)}return e}function Si(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=bi(t);const n=e%4;if(n!==0)if(n===1)r=r.slice(2);else if(n===2)r=r.slice(4);else throw new Error(`Input (s = ${t}) is not tightly packed because i%4 = 3 (i = ${e}))`);const s=(e+t.length-1)%4;if(s!==3)if(s===2)r=r.slice(0,r.length-2);else if(s===1)r=r.slice(0,r.length-4);else throw new Error(`Input (s = ${t}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${e}))`);if(r.length%8!==0)throw new Error("We should never reach here...");const i=new Uint8Array(Math.floor(r.length/8));let a=0;for(let o=0;o<r.length;o+=8){const u=r.slice(o,o+8),l=parseInt(u.join(""),2);i[a++]=l}return new TextDecoder().decode(i)}function Ti(t){if(!(t.slice(-1)==="}"||t.slice(-1)===","))throw new Error("Invalid claim");const e=JSON.parse("{"+t.slice(0,-1)+"}");if(Object.keys(e).length!==1)throw new Error("Invalid claim");const r=Object.keys(e)[0];return[r,e[r]]}function Ei(t,e){const r=Si(t.value,t.indexMod4),[n,s]=Ti(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const vi=c.struct("ZkLoginSignature",{inputs:c.struct("ZkLoginSignatureInputs",{proofPoints:c.struct("ZkLoginSignatureInputsProofPoints",{a:c.vector(c.string()),b:c.vector(c.vector(c.string())),c:c.vector(c.string())}),issBase64Details:c.struct("ZkLoginSignatureInputsClaim",{value:c.string(),indexMod4:c.u8()}),headerBase64:c.string(),addressSeed:c.string()}),maxEpoch:c.u64(),userSignature:c.vector(c.u8())});function ki(t){return vi.parse(typeof t=="string"?H(t):t)}function xi({signature:t,signatureScheme:e,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const n=r.toRawBytes(),s=new Uint8Array(1+t.length+n.length);return s.set([nt[e]]),s.set(t,1),s.set(n,1+t.length),$(s)}function _i(t){const e=H(t),r=fi[e[0]];switch(r){case"MultiSig":const n=I.MultiSig.parse(e.slice(1));return{serializedSignature:t,signatureScheme:r,multisig:n,bytes:e};case"ZkLogin":const s=e.slice(1),{inputs:i,maxEpoch:a,userSignature:o}=ki(s),{issBase64Details:u,addressSeed:l}=i,f=Ei(u,"iss"),p=mi(BigInt(l),f);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:f,address:p,addressSeed:BigInt(l)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const y=hi[r],m=e.slice(1,e.length-y),x=e.slice(1+m.length);return{serializedSignature:t,signatureScheme:r,signature:m,publicKey:x,bytes:e};default:throw new Error("Unsupported signature scheme")}}const He=32,Ai="suiprivkey";class Ii{async signWithIntent(e,r){const n=rn(r,e),s=d.blake2b(n,{dkLen:32});return{signature:xi({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:$(e)}}async signTransactionBlock(e){return this.signWithIntent(e,$e.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(c.vector(c.u8()).serialize(e).toBytes(),$e.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class Oi extends Ii{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function ji(t,e){if(t.length!==He)throw new Error("Invalid bytes length");const r=nt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),Et.encode(Ai,Et.toWords(n))}function dr(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function Ci(t){return kt.mnemonicToSeedSync(t,"")}function Bi(t){return ge(Ci(t))}const Mi="ed25519 seed",Pi=2147483648,Ri=new RegExp("^m(\\/[0-9]+')+$"),nn=t=>t.replace("'",""),Ni=t=>{const r=kt.hmac.create(d.sha512,Mi).update(Ue(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},$i=({key:t,chainCode:e},r)=>{const n=new ArrayBuffer(4);new DataView(n).setUint32(0,r);const i=new Uint8Array(1+t.length+n.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(t,1),i.set(new Uint8Array(n,0,n.byteLength),t.length+1);const a=kt.hmac.create(d.sha512,e).update(i).digest(),o=a.slice(0,32),u=a.slice(32);return{key:o,chainCode:u}},Ui=t=>Ri.test(t)?!t.split("/").slice(1).map(nn).some(isNaN):!1,lr=(t,e,r=Pi)=>{if(!Ui(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=Ni(e);return t.split("/").slice(1).map(nn).map(a=>parseInt(a,10)).reduce((a,o)=>$i(a,o+r),{key:n,chainCode:s})};function sn(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}class Di{equals(e){return sn(this.toRawBytes(),e.toRawBytes())}toBase64(){return $(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return $(e)}verifyWithIntent(e,r,n){const s=rn(n,e),i=d.blake2b(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(I.vector(I.u8()).serialize(e).toBytes(),r,$e.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,$e.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return d.normalizeSuiAddress(d.bytesToHex(d.blake2b(this.toSuiBytes(),{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}}const vt=32;class an extends Di{constructor(e){if(super(),typeof e=="string"?this.data=H(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==vt)throw new Error(`Invalid public key input. Expected ${vt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return nt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=_i(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!sn(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return d.nacl.sign.detached.verify(e,n,this.toRawBytes())}}an.SIZE=vt;const hr="m/44'/784'/0'/0'/0'";class me extends Oi{constructor(e){super(),e?this.keypair=e:this.keypair=d.nacl.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new me(d.nacl.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==He)throw new Error(`Wrong secretKey size. Expected ${He} bytes, got ${n}.`);const s=d.nacl.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=d.nacl.sign.detached(a,s.secretKey);if(!d.nacl.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new me(s)}getPublicKey(){return new an(this.keypair.publicKey)}getSecretKey(){return ji(this.keypair.secretKey.slice(0,He),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return d.nacl.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=hr),!dr(r))throw new Error("Invalid derivation path");const{key:n}=lr(r,Bi(e));return me.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=hr),!dr(r))throw new Error("Invalid derivation path");const{key:n}=lr(r,e);return me.fromSecretKey(n)}}async function zi(t,e){const[,r]=await Ee.chainFromRpc(t);return new Vi(r,t,me.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class Vi{constructor(e,r,n,s){pe(this,"_chain");pe(this,"_client");pe(this,"_signer");pe(this,"_debug");this._chain=e,this._client=r,this._signer=n,this._debug=s}chain(){return this._chain}address(){return this._signer.toSuiAddress()}async signAndSend(e){const r=[];for(const n of e){const{description:s,transaction:i}=n;this._debug&&console.log(`Signing ${s} for ${this.address()}`);try{const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}catch(a){throw a}}return r}}const Li={Address:d.SuiAddress,Platform:Ee,getSigner:zi,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-Dw4_1FXq.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-Dr6Wkn1g.js")),CircleBridge:()=>Promise.resolve().then(()=>require("./index-BX2v7vz2.js"))},getChain:(t,e,r)=>new Xr(e,new Ee(t,d.applyChainsConfigConfigOverrides(t,Tt,{[e]:r})))},qi=Object.freeze(Object.defineProperty({__proto__:null,default:Li},Symbol.toStringTag,{value:"Module"}));exports.SuiPlatform=Ee;exports.getFieldsFromObjectResponse=rr;exports.getObjectFields=Qr;exports.getOldestEmitterCapObjectId=ai;exports.getOriginalPackageId=si;exports.getPackageId=ii;exports.isMoveStructId=ti;exports.isMoveStructObject=Yr;exports.isMoveStructStruct=rt;exports.isSameType=Xs;exports.isSuiCreateEvent=Ys;exports.isSuiPublishEvent=Qs;exports.publishPackage=oi;exports.sui=qi;exports.uint8ArrayToBCS=ni;
@@ -0,0 +1,16 @@
1
+ var o = Object.defineProperty;
2
+ var c = (a, t, i) => t in a ? o(a, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : a[t] = i;
3
+ var s = (a, t, i) => c(a, typeof t != "symbol" ? t + "" : t, i);
4
+ class h {
5
+ constructor(t, i, n, r, e = !1) {
6
+ s(this, "transaction");
7
+ s(this, "network");
8
+ s(this, "chain");
9
+ s(this, "description");
10
+ s(this, "parallelizable");
11
+ this.transaction = t, this.network = i, this.chain = n, this.description = r, this.parallelizable = e;
12
+ }
13
+ }
14
+ export {
15
+ h as A
16
+ };
@@ -0,0 +1 @@
1
+ "use strict";var e=Object.defineProperty;var o=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i;var n=(t,s,i)=>o(t,typeof s!="symbol"?s+"":s,i);class l{constructor(s,i,a,r,c=!1){n(this,"transaction");n(this,"network");n(this,"chain");n(this,"description");n(this,"parallelizable");this.transaction=s,this.network=i,this.chain=a,this.description=r,this.parallelizable=c}}exports.AptosUnsignedTransaction=l;
@@ -1,4 +1,4 @@
1
- import { c1 as Y, cF as rr } from "./index-C6iaLaJq.mjs";
1
+ import { c1 as Y, cG as rr } from "./index-BAhBSTHO.mjs";
2
2
  const tr = "logger/5.7.0";
3
3
  let G = !1, L = !1;
4
4
  const O = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 };
@@ -1 +1 @@
1
- "use strict";const j=require("./index-hIJ0h_GZ.js"),er="logger/5.7.0";let G=!1,L=!1;const O={debug:1,default:2,info:2,warning:3,error:4,off:5};let B=O.default,C=null;function nr(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(t=>{try{if("test".normalize(t)!=="test")throw new Error("bad normalize")}catch{r.push(t)}}),r.length)throw new Error("missing "+r.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(r){return r.message}return null}const X=nr();var M;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(M||(M={}));var p;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(p||(p={}));const $="0123456789abcdef";class o{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const n=t.toLowerCase();O[n]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!(B>O[n])&&console.log.apply(console,e)}debug(...t){this._log(o.levels.DEBUG,t)}info(...t){this._log(o.levels.INFO,t)}warn(...t){this._log(o.levels.WARNING,t)}makeError(t,e,n){if(L)return this.makeError("censored error",e,{});e||(e=o.errors.UNKNOWN_ERROR),n||(n={});const i=[];Object.keys(n).forEach(l=>{const R=n[l];try{if(R instanceof Uint8Array){let I="";for(let _=0;_<R.length;_++)I+=$[R[_]>>4],I+=$[R[_]&15];i.push(l+"=Uint8Array(0x"+I+")")}else i.push(l+"="+JSON.stringify(R))}catch{i.push(l+"="+JSON.stringify(n[l].toString()))}}),i.push(`code=${e}`),i.push(`version=${this.version}`);const f=t;let u="";switch(e){case p.NUMERIC_FAULT:{u="NUMERIC_FAULT";const l=t;switch(l){case"overflow":case"underflow":case"division-by-zero":u+="-"+l;break;case"negative-power":case"negative-width":u+="-unsupported";break;case"unbound-bitwise-result":u+="-unbound-result";break}break}case p.CALL_EXCEPTION:case p.INSUFFICIENT_FUNDS:case p.MISSING_NEW:case p.NONCE_EXPIRED:case p.REPLACEMENT_UNDERPRICED:case p.TRANSACTION_REPLACED:case p.UNPREDICTABLE_GAS_LIMIT:u=e;break}u&&(t+=" [ See: https://links.ethers.org/v5-errors-"+u+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const h=new Error(t);return h.reason=f,h.code=e,Object.keys(n).forEach(function(l){h[l]=n[l]}),h}throwError(t,e,n){throw this.makeError(t,e,n)}throwArgumentError(t,e,n){return this.throwError(t,o.errors.INVALID_ARGUMENT,{argument:e,value:n})}assert(t,e,n,i){t||this.throwError(e,n,i)}assertArgument(t,e,n,i){t||this.throwArgumentError(e,n,i)}checkNormalize(t){X&&this.throwError("platform missing String.prototype.normalize",o.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:X})}checkSafeUint53(t,e){typeof t=="number"&&(e==null&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,o.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,o.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,n){n?n=": "+n:n="",t<e&&this.throwError("missing argument"+n,o.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+n,o.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){(t===Object||t==null)&&this.throwError("missing new",o.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",o.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",o.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return C||(C=new o(er)),C}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",o.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),G){if(!t)return;this.globalLogger().throwError("error censorship permanent",o.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}L=!!t,G=!!e}static setLogLevel(t){const e=O[t.toLowerCase()];if(e==null){o.globalLogger().warn("invalid log level - "+t);return}B=e}static from(t){return new o(t)}}o.errors=p;o.levels=M;const ir="bytes/5.7.0",c=new o(ir);function J(r){return!!r.toHexString}function y(r){return r.slice||(r.slice=function(){const t=Array.prototype.slice.call(arguments);return y(new Uint8Array(Array.prototype.slice.apply(r,t)))}),r}function sr(r){return x(r)&&!(r.length%2)||d(r)}function z(r){return typeof r=="number"&&r==r&&r%1===0}function d(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!z(r.length)||r.length<0)return!1;for(let t=0;t<r.length;t++){const e=r[t];if(!z(e)||e<0||e>=256)return!1}return!0}function w(r,t){if(t||(t={}),typeof r=="number"){c.checkSafeUint53(r,"invalid arrayify value");const e=[];for(;r;)e.unshift(r&255),r=parseInt(String(r/256));return e.length===0&&e.push(0),y(new Uint8Array(e))}if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),J(r)&&(r=r.toHexString()),x(r)){let e=r.substring(2);e.length%2&&(t.hexPad==="left"?e="0"+e:t.hexPad==="right"?e+="0":c.throwArgumentError("hex data is odd-length","value",r));const n=[];for(let i=0;i<e.length;i+=2)n.push(parseInt(e.substring(i,i+2),16));return y(new Uint8Array(n))}return d(r)?y(new Uint8Array(r)):c.throwArgumentError("invalid arrayify value","value",r)}function or(r){const t=r.map(i=>w(i)),e=t.reduce((i,f)=>i+f.length,0),n=new Uint8Array(e);return t.reduce((i,f)=>(n.set(f,i),i+f.length),0),y(n)}function fr(r,t){r=w(r),r.length>t&&c.throwArgumentError("value out of range","value",arguments[0]);const e=new Uint8Array(t);return e.set(r,t-r.length),y(e)}function x(r,t){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||t&&r.length!==2+2*t)}const D="0123456789abcdef";function E(r,t){if(t||(t={}),typeof r=="number"){c.checkSafeUint53(r,"invalid hexlify value");let e="";for(;r;)e=D[r&15]+e,r=Math.floor(r/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),J(r))return r.toHexString();if(x(r))return r.length%2&&(t.hexPad==="left"?r="0x0"+r.substring(2):t.hexPad==="right"?r+="0":c.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(d(r)){let e="0x";for(let n=0;n<r.length;n++){let i=r[n];e+=D[(i&240)>>4]+D[i&15]}return e}return c.throwArgumentError("invalid hexlify value","value",r)}function ur(r){if(typeof r!="string")r=E(r);else if(!x(r)||r.length%2)return null;return(r.length-2)/2}function cr(r,t,e){return typeof r!="string"?r=E(r):(!x(r)||r.length%2)&&c.throwArgumentError("invalid hexData","value",r),t=2+2*t,e!=null?"0x"+r.substring(t,2+2*e):"0x"+r.substring(t)}function hr(r){let t="0x";return r.forEach(e=>{t+=E(e).substring(2)}),t}function T(r,t){for(typeof r!="string"?r=E(r):x(r)||c.throwArgumentError("invalid hex string","value",r),r.length>2*t+2&&c.throwArgumentError("value out of range","value",arguments[1]);r.length<2*t+2;)r="0x0"+r.substring(2);return r}function lr(r){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(sr(r)){let e=w(r);e.length===64?(t.v=27+(e[32]>>7),e[32]&=127,t.r=E(e.slice(0,32)),t.s=E(e.slice(32,64))):e.length===65?(t.r=E(e.slice(0,32)),t.s=E(e.slice(32,64)),t.v=e[64]):c.throwArgumentError("invalid signature string","signature",r),t.v<27&&(t.v===0||t.v===1?t.v+=27:c.throwArgumentError("signature invalid v byte","signature",r)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(e[32]|=128),t._vs=E(e.slice(32,64))}else{if(t.r=r.r,t.s=r.s,t.v=r.v,t.recoveryParam=r.recoveryParam,t._vs=r._vs,t._vs!=null){const i=fr(w(t._vs),32);t._vs=E(i);const f=i[0]>=128?1:0;t.recoveryParam==null?t.recoveryParam=f:t.recoveryParam!==f&&c.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),i[0]&=127;const u=E(i);t.s==null?t.s=u:t.s!==u&&c.throwArgumentError("signature v mismatch _vs","signature",r)}if(t.recoveryParam==null)t.v==null?c.throwArgumentError("signature missing v and recoveryParam","signature",r):t.v===0||t.v===1?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(t.v==null)t.v=27+t.recoveryParam;else{const i=t.v===0||t.v===1?t.v:1-t.v%2;t.recoveryParam!==i&&c.throwArgumentError("signature recoveryParam mismatch v","signature",r)}t.r==null||!x(t.r)?c.throwArgumentError("signature missing or invalid r","signature",r):t.r=T(t.r,32),t.s==null||!x(t.s)?c.throwArgumentError("signature missing or invalid s","signature",r):t.s=T(t.s,32);const e=w(t.s);e[0]>=128&&c.throwArgumentError("signature s out of range","signature",r),t.recoveryParam&&(e[0]|=128);const n=E(e);t._vs&&(x(t._vs)||c.throwArgumentError("signature invalid _vs","signature",r),t._vs=T(t._vs,32)),t._vs==null?t._vs=n:t._vs!==n&&c.throwArgumentError("signature _vs mismatch v and s","signature",r)}return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}const gr="bignumber/5.7.0";var b=j.BN.BN;const A=new o(gr),F={},H=9007199254740991;let V=!1;class a{constructor(t,e){t!==F&&A.throwError("cannot call constructor directly; use BigNumber.from",o.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return g(s(this).fromTwos(t))}toTwos(t){return g(s(this).toTwos(t))}abs(){return this._hex[0]==="-"?a.from(this._hex.substring(1)):this}add(t){return g(s(this).add(s(t)))}sub(t){return g(s(this).sub(s(t)))}div(t){return a.from(t).isZero()&&m("division-by-zero","div"),g(s(this).div(s(t)))}mul(t){return g(s(this).mul(s(t)))}mod(t){const e=s(t);return e.isNeg()&&m("division-by-zero","mod"),g(s(this).umod(e))}pow(t){const e=s(t);return e.isNeg()&&m("negative-power","pow"),g(s(this).pow(e))}and(t){const e=s(t);return(this.isNegative()||e.isNeg())&&m("unbound-bitwise-result","and"),g(s(this).and(e))}or(t){const e=s(t);return(this.isNegative()||e.isNeg())&&m("unbound-bitwise-result","or"),g(s(this).or(e))}xor(t){const e=s(t);return(this.isNegative()||e.isNeg())&&m("unbound-bitwise-result","xor"),g(s(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&m("negative-width","mask"),g(s(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&m("negative-width","shl"),g(s(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&m("negative-width","shr"),g(s(this).shrn(t))}eq(t){return s(this).eq(s(t))}lt(t){return s(this).lt(s(t))}lte(t){return s(this).lte(s(t))}gt(t){return s(this).gt(s(t))}gte(t){return s(this).gte(s(t))}isNegative(){return this._hex[0]==="-"}isZero(){return s(this).isZero()}toNumber(){try{return s(this).toNumber()}catch{m("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return A.throwError("this platform does not support BigInt",o.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?V||(V=!0,A.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?A.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",o.errors.UNEXPECTED_ARGUMENT,{}):A.throwError("BigNumber.toString does not accept parameters",o.errors.UNEXPECTED_ARGUMENT,{})),s(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof a)return t;if(typeof t=="string")return t.match(/^-?0x[0-9a-f]+$/i)?new a(F,U(t)):t.match(/^-?[0-9]+$/)?new a(F,U(new b(t))):A.throwArgumentError("invalid BigNumber string","value",t);if(typeof t=="number")return t%1&&m("underflow","BigNumber.from",t),(t>=H||t<=-H)&&m("overflow","BigNumber.from",t),a.from(String(t));const e=t;if(typeof e=="bigint")return a.from(e.toString());if(d(e))return a.from(E(e));if(e)if(e.toHexString){const n=e.toHexString();if(typeof n=="string")return a.from(n)}else{let n=e._hex;if(n==null&&e.type==="BigNumber"&&(n=e.hex),typeof n=="string"&&(x(n)||n[0]==="-"&&x(n.substring(1))))return a.from(n)}return A.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!!(t&&t._isBigNumber)}}function U(r){if(typeof r!="string")return U(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&A.throwArgumentError("invalid hex","value",r),r=U(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return"0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function g(r){return a.from(U(r))}function s(r){const t=a.from(r).toHexString();return t[0]==="-"?new b("-"+t.substring(3),16):new b(t.substring(2),16)}function m(r,t,e){const n={fault:r,operation:t};return e!=null&&(n.value=e),A.throwError(r,o.errors.NUMERIC_FAULT,n)}function ar(r){return new b(r,36).toString(16)}const Er="properties/5.7.0",Z=new o(Er);function q(r,t,e){Object.defineProperty(r,t,{enumerable:!0,value:e,writable:!1})}function Nr(r,t){for(let e=0;e<32;e++){if(r[t])return r[t];if(!r.prototype||typeof r.prototype!="object")break;r=Object.getPrototypeOf(r.prototype).constructor}return null}const xr={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function Q(r){if(r==null||xr[typeof r])return!0;if(Array.isArray(r)||typeof r=="object"){if(!Object.isFrozen(r))return!1;const t=Object.keys(r);for(let e=0;e<t.length;e++){let n=null;try{n=r[t[e]]}catch{continue}if(!Q(n))return!1}return!0}return Z.throwArgumentError(`Cannot deepCopy ${typeof r}`,"object",r)}function mr(r){if(Q(r))return r;if(Array.isArray(r))return Object.freeze(r.map(t=>v(t)));if(typeof r=="object"){const t={};for(const e in r){const n=r[e];n!==void 0&&q(t,e,v(n))}return t}return Z.throwArgumentError(`Cannot deepCopy ${typeof r}`,"object",r)}function v(r){return mr(r)}class pr{constructor(t){for(const e in t)this[e]=v(t[e])}}function Y(r){return"0x"+j.sha3.keccak_256(w(r))}const wr="address/5.7.0",S=new o(wr);function W(r){x(r,20)||S.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const t=r.substring(2).split(""),e=new Uint8Array(40);for(let i=0;i<40;i++)e[i]=t[i].charCodeAt(0);const n=w(Y(e));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(n[i>>1]&15)>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}const Ar=9007199254740991;function Rr(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const k={};for(let r=0;r<10;r++)k[String(r)]=String(r);for(let r=0;r<26;r++)k[String.fromCharCode(65+r)]=String(10+r);const K=Math.floor(Rr(Ar));function yr(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let t=r.split("").map(n=>k[n]).join("");for(;t.length>=K;){let n=t.substring(0,K);t=parseInt(n,10)%97+t.substring(n.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}function Sr(r){let t=null;if(typeof r!="string"&&S.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),t=W(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==r&&S.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==yr(r)&&S.throwArgumentError("bad icap checksum","address",r),t=ar(r.substring(4));t.length<40;)t="0"+t;t=W("0x"+t)}else S.throwArgumentError("invalid address","address",r);return t}const Ur="strings/5.7.0",rr=new o(Ur);var P;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(P||(P={}));var N;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(N||(N={}));function Ir(r,t,e,n,i){return rr.throwArgumentError(`invalid codepoint at offset ${t}; ${r}`,"bytes",e)}function tr(r,t,e,n,i){if(r===N.BAD_PREFIX||r===N.UNEXPECTED_CONTINUE){let f=0;for(let u=t+1;u<e.length&&e[u]>>6===2;u++)f++;return f}return r===N.OVERRUN?e.length-t-1:0}function _r(r,t,e,n,i){return r===N.OVERLONG?(n.push(i),0):(n.push(65533),tr(r,t,e))}const Or=Object.freeze({error:Ir,ignore:tr,replace:_r});function Tr(r,t){t==null&&(t=Or.error),r=w(r);const e=[];let n=0;for(;n<r.length;){const i=r[n++];if(!(i>>7)){e.push(i);continue}let f=null,u=null;if((i&224)===192)f=1,u=127;else if((i&240)===224)f=2,u=2047;else if((i&248)===240)f=3,u=65535;else{(i&192)===128?n+=t(N.UNEXPECTED_CONTINUE,n-1,r,e):n+=t(N.BAD_PREFIX,n-1,r,e);continue}if(n-1+f>=r.length){n+=t(N.OVERRUN,n-1,r,e);continue}let h=i&(1<<8-f-1)-1;for(let l=0;l<f;l++){let R=r[n];if((R&192)!=128){n+=t(N.MISSING_CONTINUE,n,r,e),h=null;break}h=h<<6|R&63,n++}if(h!==null){if(h>1114111){n+=t(N.OUT_OF_RANGE,n-1-f,r,e,h);continue}if(h>=55296&&h<=57343){n+=t(N.UTF16_SURROGATE,n-1-f,r,e,h);continue}if(h<=u){n+=t(N.OVERLONG,n-1-f,r,e,h);continue}e.push(h)}}return e}function br(r,t=P.current){t!=P.current&&(rr.checkNormalize(),r=r.normalize(t));let e=[];for(let n=0;n<r.length;n++){const i=r.charCodeAt(n);if(i<128)e.push(i);else if(i<2048)e.push(i>>6|192),e.push(i&63|128);else if((i&64512)==55296){n++;const f=r.charCodeAt(n);if(n>=r.length||(f&64512)!==56320)throw new Error("invalid utf-8 string");const u=65536+((i&1023)<<10)+(f&1023);e.push(u>>18|240),e.push(u>>12&63|128),e.push(u>>6&63|128),e.push(u&63|128)}else e.push(i>>12|224),e.push(i>>6&63|128),e.push(i&63|128)}return w(e)}function Pr(r){return r.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function dr(r,t){return Pr(Tr(r,t))}exports.BigNumber=a;exports.Description=pr;exports.Logger=o;exports.arrayify=w;exports.concat=or;exports.defineReadOnly=q;exports.getAddress=Sr;exports.getStatic=Nr;exports.hexConcat=hr;exports.hexDataLength=ur;exports.hexDataSlice=cr;exports.hexZeroPad=T;exports.hexlify=E;exports.isHexString=x;exports.keccak256=Y;exports.splitSignature=lr;exports.toUtf8Bytes=br;exports.toUtf8String=dr;
1
+ "use strict";const j=require("./index-D5ta6SAe.js"),er="logger/5.7.0";let G=!1,L=!1;const O={debug:1,default:2,info:2,warning:3,error:4,off:5};let B=O.default,C=null;function nr(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(t=>{try{if("test".normalize(t)!=="test")throw new Error("bad normalize")}catch{r.push(t)}}),r.length)throw new Error("missing "+r.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(r){return r.message}return null}const X=nr();var M;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(M||(M={}));var p;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(p||(p={}));const $="0123456789abcdef";class o{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const n=t.toLowerCase();O[n]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!(B>O[n])&&console.log.apply(console,e)}debug(...t){this._log(o.levels.DEBUG,t)}info(...t){this._log(o.levels.INFO,t)}warn(...t){this._log(o.levels.WARNING,t)}makeError(t,e,n){if(L)return this.makeError("censored error",e,{});e||(e=o.errors.UNKNOWN_ERROR),n||(n={});const i=[];Object.keys(n).forEach(l=>{const R=n[l];try{if(R instanceof Uint8Array){let I="";for(let _=0;_<R.length;_++)I+=$[R[_]>>4],I+=$[R[_]&15];i.push(l+"=Uint8Array(0x"+I+")")}else i.push(l+"="+JSON.stringify(R))}catch{i.push(l+"="+JSON.stringify(n[l].toString()))}}),i.push(`code=${e}`),i.push(`version=${this.version}`);const f=t;let u="";switch(e){case p.NUMERIC_FAULT:{u="NUMERIC_FAULT";const l=t;switch(l){case"overflow":case"underflow":case"division-by-zero":u+="-"+l;break;case"negative-power":case"negative-width":u+="-unsupported";break;case"unbound-bitwise-result":u+="-unbound-result";break}break}case p.CALL_EXCEPTION:case p.INSUFFICIENT_FUNDS:case p.MISSING_NEW:case p.NONCE_EXPIRED:case p.REPLACEMENT_UNDERPRICED:case p.TRANSACTION_REPLACED:case p.UNPREDICTABLE_GAS_LIMIT:u=e;break}u&&(t+=" [ See: https://links.ethers.org/v5-errors-"+u+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const h=new Error(t);return h.reason=f,h.code=e,Object.keys(n).forEach(function(l){h[l]=n[l]}),h}throwError(t,e,n){throw this.makeError(t,e,n)}throwArgumentError(t,e,n){return this.throwError(t,o.errors.INVALID_ARGUMENT,{argument:e,value:n})}assert(t,e,n,i){t||this.throwError(e,n,i)}assertArgument(t,e,n,i){t||this.throwArgumentError(e,n,i)}checkNormalize(t){X&&this.throwError("platform missing String.prototype.normalize",o.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:X})}checkSafeUint53(t,e){typeof t=="number"&&(e==null&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,o.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,o.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,n){n?n=": "+n:n="",t<e&&this.throwError("missing argument"+n,o.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+n,o.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){(t===Object||t==null)&&this.throwError("missing new",o.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",o.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",o.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return C||(C=new o(er)),C}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",o.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),G){if(!t)return;this.globalLogger().throwError("error censorship permanent",o.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}L=!!t,G=!!e}static setLogLevel(t){const e=O[t.toLowerCase()];if(e==null){o.globalLogger().warn("invalid log level - "+t);return}B=e}static from(t){return new o(t)}}o.errors=p;o.levels=M;const ir="bytes/5.7.0",c=new o(ir);function J(r){return!!r.toHexString}function y(r){return r.slice||(r.slice=function(){const t=Array.prototype.slice.call(arguments);return y(new Uint8Array(Array.prototype.slice.apply(r,t)))}),r}function sr(r){return x(r)&&!(r.length%2)||d(r)}function z(r){return typeof r=="number"&&r==r&&r%1===0}function d(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!z(r.length)||r.length<0)return!1;for(let t=0;t<r.length;t++){const e=r[t];if(!z(e)||e<0||e>=256)return!1}return!0}function w(r,t){if(t||(t={}),typeof r=="number"){c.checkSafeUint53(r,"invalid arrayify value");const e=[];for(;r;)e.unshift(r&255),r=parseInt(String(r/256));return e.length===0&&e.push(0),y(new Uint8Array(e))}if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),J(r)&&(r=r.toHexString()),x(r)){let e=r.substring(2);e.length%2&&(t.hexPad==="left"?e="0"+e:t.hexPad==="right"?e+="0":c.throwArgumentError("hex data is odd-length","value",r));const n=[];for(let i=0;i<e.length;i+=2)n.push(parseInt(e.substring(i,i+2),16));return y(new Uint8Array(n))}return d(r)?y(new Uint8Array(r)):c.throwArgumentError("invalid arrayify value","value",r)}function or(r){const t=r.map(i=>w(i)),e=t.reduce((i,f)=>i+f.length,0),n=new Uint8Array(e);return t.reduce((i,f)=>(n.set(f,i),i+f.length),0),y(n)}function fr(r,t){r=w(r),r.length>t&&c.throwArgumentError("value out of range","value",arguments[0]);const e=new Uint8Array(t);return e.set(r,t-r.length),y(e)}function x(r,t){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||t&&r.length!==2+2*t)}const D="0123456789abcdef";function E(r,t){if(t||(t={}),typeof r=="number"){c.checkSafeUint53(r,"invalid hexlify value");let e="";for(;r;)e=D[r&15]+e,r=Math.floor(r/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),J(r))return r.toHexString();if(x(r))return r.length%2&&(t.hexPad==="left"?r="0x0"+r.substring(2):t.hexPad==="right"?r+="0":c.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(d(r)){let e="0x";for(let n=0;n<r.length;n++){let i=r[n];e+=D[(i&240)>>4]+D[i&15]}return e}return c.throwArgumentError("invalid hexlify value","value",r)}function ur(r){if(typeof r!="string")r=E(r);else if(!x(r)||r.length%2)return null;return(r.length-2)/2}function cr(r,t,e){return typeof r!="string"?r=E(r):(!x(r)||r.length%2)&&c.throwArgumentError("invalid hexData","value",r),t=2+2*t,e!=null?"0x"+r.substring(t,2+2*e):"0x"+r.substring(t)}function hr(r){let t="0x";return r.forEach(e=>{t+=E(e).substring(2)}),t}function T(r,t){for(typeof r!="string"?r=E(r):x(r)||c.throwArgumentError("invalid hex string","value",r),r.length>2*t+2&&c.throwArgumentError("value out of range","value",arguments[1]);r.length<2*t+2;)r="0x0"+r.substring(2);return r}function lr(r){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(sr(r)){let e=w(r);e.length===64?(t.v=27+(e[32]>>7),e[32]&=127,t.r=E(e.slice(0,32)),t.s=E(e.slice(32,64))):e.length===65?(t.r=E(e.slice(0,32)),t.s=E(e.slice(32,64)),t.v=e[64]):c.throwArgumentError("invalid signature string","signature",r),t.v<27&&(t.v===0||t.v===1?t.v+=27:c.throwArgumentError("signature invalid v byte","signature",r)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(e[32]|=128),t._vs=E(e.slice(32,64))}else{if(t.r=r.r,t.s=r.s,t.v=r.v,t.recoveryParam=r.recoveryParam,t._vs=r._vs,t._vs!=null){const i=fr(w(t._vs),32);t._vs=E(i);const f=i[0]>=128?1:0;t.recoveryParam==null?t.recoveryParam=f:t.recoveryParam!==f&&c.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),i[0]&=127;const u=E(i);t.s==null?t.s=u:t.s!==u&&c.throwArgumentError("signature v mismatch _vs","signature",r)}if(t.recoveryParam==null)t.v==null?c.throwArgumentError("signature missing v and recoveryParam","signature",r):t.v===0||t.v===1?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(t.v==null)t.v=27+t.recoveryParam;else{const i=t.v===0||t.v===1?t.v:1-t.v%2;t.recoveryParam!==i&&c.throwArgumentError("signature recoveryParam mismatch v","signature",r)}t.r==null||!x(t.r)?c.throwArgumentError("signature missing or invalid r","signature",r):t.r=T(t.r,32),t.s==null||!x(t.s)?c.throwArgumentError("signature missing or invalid s","signature",r):t.s=T(t.s,32);const e=w(t.s);e[0]>=128&&c.throwArgumentError("signature s out of range","signature",r),t.recoveryParam&&(e[0]|=128);const n=E(e);t._vs&&(x(t._vs)||c.throwArgumentError("signature invalid _vs","signature",r),t._vs=T(t._vs,32)),t._vs==null?t._vs=n:t._vs!==n&&c.throwArgumentError("signature _vs mismatch v and s","signature",r)}return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}const gr="bignumber/5.7.0";var b=j.BN.BN;const A=new o(gr),F={},H=9007199254740991;let V=!1;class a{constructor(t,e){t!==F&&A.throwError("cannot call constructor directly; use BigNumber.from",o.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return g(s(this).fromTwos(t))}toTwos(t){return g(s(this).toTwos(t))}abs(){return this._hex[0]==="-"?a.from(this._hex.substring(1)):this}add(t){return g(s(this).add(s(t)))}sub(t){return g(s(this).sub(s(t)))}div(t){return a.from(t).isZero()&&m("division-by-zero","div"),g(s(this).div(s(t)))}mul(t){return g(s(this).mul(s(t)))}mod(t){const e=s(t);return e.isNeg()&&m("division-by-zero","mod"),g(s(this).umod(e))}pow(t){const e=s(t);return e.isNeg()&&m("negative-power","pow"),g(s(this).pow(e))}and(t){const e=s(t);return(this.isNegative()||e.isNeg())&&m("unbound-bitwise-result","and"),g(s(this).and(e))}or(t){const e=s(t);return(this.isNegative()||e.isNeg())&&m("unbound-bitwise-result","or"),g(s(this).or(e))}xor(t){const e=s(t);return(this.isNegative()||e.isNeg())&&m("unbound-bitwise-result","xor"),g(s(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&m("negative-width","mask"),g(s(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&m("negative-width","shl"),g(s(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&m("negative-width","shr"),g(s(this).shrn(t))}eq(t){return s(this).eq(s(t))}lt(t){return s(this).lt(s(t))}lte(t){return s(this).lte(s(t))}gt(t){return s(this).gt(s(t))}gte(t){return s(this).gte(s(t))}isNegative(){return this._hex[0]==="-"}isZero(){return s(this).isZero()}toNumber(){try{return s(this).toNumber()}catch{m("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return A.throwError("this platform does not support BigInt",o.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?V||(V=!0,A.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?A.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",o.errors.UNEXPECTED_ARGUMENT,{}):A.throwError("BigNumber.toString does not accept parameters",o.errors.UNEXPECTED_ARGUMENT,{})),s(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof a)return t;if(typeof t=="string")return t.match(/^-?0x[0-9a-f]+$/i)?new a(F,U(t)):t.match(/^-?[0-9]+$/)?new a(F,U(new b(t))):A.throwArgumentError("invalid BigNumber string","value",t);if(typeof t=="number")return t%1&&m("underflow","BigNumber.from",t),(t>=H||t<=-H)&&m("overflow","BigNumber.from",t),a.from(String(t));const e=t;if(typeof e=="bigint")return a.from(e.toString());if(d(e))return a.from(E(e));if(e)if(e.toHexString){const n=e.toHexString();if(typeof n=="string")return a.from(n)}else{let n=e._hex;if(n==null&&e.type==="BigNumber"&&(n=e.hex),typeof n=="string"&&(x(n)||n[0]==="-"&&x(n.substring(1))))return a.from(n)}return A.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!!(t&&t._isBigNumber)}}function U(r){if(typeof r!="string")return U(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&A.throwArgumentError("invalid hex","value",r),r=U(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return"0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function g(r){return a.from(U(r))}function s(r){const t=a.from(r).toHexString();return t[0]==="-"?new b("-"+t.substring(3),16):new b(t.substring(2),16)}function m(r,t,e){const n={fault:r,operation:t};return e!=null&&(n.value=e),A.throwError(r,o.errors.NUMERIC_FAULT,n)}function ar(r){return new b(r,36).toString(16)}const Er="properties/5.7.0",Z=new o(Er);function q(r,t,e){Object.defineProperty(r,t,{enumerable:!0,value:e,writable:!1})}function Nr(r,t){for(let e=0;e<32;e++){if(r[t])return r[t];if(!r.prototype||typeof r.prototype!="object")break;r=Object.getPrototypeOf(r.prototype).constructor}return null}const xr={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function Q(r){if(r==null||xr[typeof r])return!0;if(Array.isArray(r)||typeof r=="object"){if(!Object.isFrozen(r))return!1;const t=Object.keys(r);for(let e=0;e<t.length;e++){let n=null;try{n=r[t[e]]}catch{continue}if(!Q(n))return!1}return!0}return Z.throwArgumentError(`Cannot deepCopy ${typeof r}`,"object",r)}function mr(r){if(Q(r))return r;if(Array.isArray(r))return Object.freeze(r.map(t=>v(t)));if(typeof r=="object"){const t={};for(const e in r){const n=r[e];n!==void 0&&q(t,e,v(n))}return t}return Z.throwArgumentError(`Cannot deepCopy ${typeof r}`,"object",r)}function v(r){return mr(r)}class pr{constructor(t){for(const e in t)this[e]=v(t[e])}}function Y(r){return"0x"+j.sha3.keccak_256(w(r))}const wr="address/5.7.0",S=new o(wr);function W(r){x(r,20)||S.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const t=r.substring(2).split(""),e=new Uint8Array(40);for(let i=0;i<40;i++)e[i]=t[i].charCodeAt(0);const n=w(Y(e));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(n[i>>1]&15)>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}const Ar=9007199254740991;function Rr(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const k={};for(let r=0;r<10;r++)k[String(r)]=String(r);for(let r=0;r<26;r++)k[String.fromCharCode(65+r)]=String(10+r);const K=Math.floor(Rr(Ar));function yr(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let t=r.split("").map(n=>k[n]).join("");for(;t.length>=K;){let n=t.substring(0,K);t=parseInt(n,10)%97+t.substring(n.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}function Sr(r){let t=null;if(typeof r!="string"&&S.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),t=W(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==r&&S.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==yr(r)&&S.throwArgumentError("bad icap checksum","address",r),t=ar(r.substring(4));t.length<40;)t="0"+t;t=W("0x"+t)}else S.throwArgumentError("invalid address","address",r);return t}const Ur="strings/5.7.0",rr=new o(Ur);var P;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(P||(P={}));var N;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(N||(N={}));function Ir(r,t,e,n,i){return rr.throwArgumentError(`invalid codepoint at offset ${t}; ${r}`,"bytes",e)}function tr(r,t,e,n,i){if(r===N.BAD_PREFIX||r===N.UNEXPECTED_CONTINUE){let f=0;for(let u=t+1;u<e.length&&e[u]>>6===2;u++)f++;return f}return r===N.OVERRUN?e.length-t-1:0}function _r(r,t,e,n,i){return r===N.OVERLONG?(n.push(i),0):(n.push(65533),tr(r,t,e))}const Or=Object.freeze({error:Ir,ignore:tr,replace:_r});function Tr(r,t){t==null&&(t=Or.error),r=w(r);const e=[];let n=0;for(;n<r.length;){const i=r[n++];if(!(i>>7)){e.push(i);continue}let f=null,u=null;if((i&224)===192)f=1,u=127;else if((i&240)===224)f=2,u=2047;else if((i&248)===240)f=3,u=65535;else{(i&192)===128?n+=t(N.UNEXPECTED_CONTINUE,n-1,r,e):n+=t(N.BAD_PREFIX,n-1,r,e);continue}if(n-1+f>=r.length){n+=t(N.OVERRUN,n-1,r,e);continue}let h=i&(1<<8-f-1)-1;for(let l=0;l<f;l++){let R=r[n];if((R&192)!=128){n+=t(N.MISSING_CONTINUE,n,r,e),h=null;break}h=h<<6|R&63,n++}if(h!==null){if(h>1114111){n+=t(N.OUT_OF_RANGE,n-1-f,r,e,h);continue}if(h>=55296&&h<=57343){n+=t(N.UTF16_SURROGATE,n-1-f,r,e,h);continue}if(h<=u){n+=t(N.OVERLONG,n-1-f,r,e,h);continue}e.push(h)}}return e}function br(r,t=P.current){t!=P.current&&(rr.checkNormalize(),r=r.normalize(t));let e=[];for(let n=0;n<r.length;n++){const i=r.charCodeAt(n);if(i<128)e.push(i);else if(i<2048)e.push(i>>6|192),e.push(i&63|128);else if((i&64512)==55296){n++;const f=r.charCodeAt(n);if(n>=r.length||(f&64512)!==56320)throw new Error("invalid utf-8 string");const u=65536+((i&1023)<<10)+(f&1023);e.push(u>>18|240),e.push(u>>12&63|128),e.push(u>>6&63|128),e.push(u&63|128)}else e.push(i>>12|224),e.push(i>>6&63|128),e.push(i&63|128)}return w(e)}function Pr(r){return r.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function dr(r,t){return Pr(Tr(r,t))}exports.BigNumber=a;exports.Description=pr;exports.Logger=o;exports.arrayify=w;exports.concat=or;exports.defineReadOnly=q;exports.getAddress=Sr;exports.getStatic=Nr;exports.hexConcat=hr;exports.hexDataLength=ur;exports.hexDataSlice=cr;exports.hexZeroPad=T;exports.hexlify=E;exports.isHexString=x;exports.keccak256=Y;exports.splitSignature=lr;exports.toUtf8Bytes=br;exports.toUtf8String=dr;