@wormhole-foundation/wormhole-connect 1.1.4-beta.1-development → 1.1.4-beta.2-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 (118) hide show
  1. package/dist/assets/{algorand-CL9E7qV4.js → algorand-CyJRjYjt.js} +2 -2
  2. package/dist/assets/{aptos-CYfJ6QKV.js → aptos-k14Q8oIC.js} +2 -2
  3. package/dist/assets/{ccip-Cfs6IR2H.js → ccip-BNTHR_fq.js} +1 -1
  4. package/dist/assets/{cosmwasm-B8f9g9-e.js → cosmwasm-Bb55TeV-.js} +3 -3
  5. package/dist/assets/{evm-BeHPA-N8.js → evm-BxXdWj24.js} +5 -5
  6. package/dist/assets/{evm-DsaBFKKm.js → evm-C-buBtRY.js} +2 -2
  7. package/dist/assets/{index-DzWKLl_i.js → index-BAmVCbB-.js} +1 -1
  8. package/dist/assets/{index-C0jKBHol.js → index-BEc0YFBn.js} +1 -1
  9. package/dist/assets/{index-DW2PHjzW.js → index-BLMTT3rM.js} +1 -1
  10. package/dist/assets/{index-CVz7Lfsa.js → index-BY0kgWx8.js} +1 -1
  11. package/dist/assets/{index-BtIDaBGl.js → index-BfDApobA.js} +1 -1
  12. package/dist/assets/{index-Cka3pqB6.js → index-BwBQHmYt.js} +1 -1
  13. package/dist/assets/{index-B1Zd6Tbj.js → index-C0psfra-.js} +1 -1
  14. package/dist/assets/{index-Dmt4H-sz.js → index-C2FPBPlV.js} +1 -1
  15. package/dist/assets/{index-DyOk_vKo.js → index-C3Sky6pw.js} +1 -1
  16. package/dist/assets/{index-DEXJQ6UW.js → index-C87qdc5P.js} +1 -1
  17. package/dist/assets/{index-QCp2fK6U.js → index-D2LZykJf.js} +2 -2
  18. package/dist/assets/{index-DSNr6Aeg.js → index-DoWu6bTw.js} +1 -1
  19. package/dist/assets/{index-DkQt9fOR.js → index-Dqm3REGN.js} +1 -1
  20. package/dist/assets/{index-BQIi8F3e.js → index-FQGd6qGV.js} +1 -1
  21. package/dist/assets/{index-QJ2zlRk3.js → index-IlqLhD3I.js} +1 -1
  22. package/dist/assets/{index-q0W2SHor.js → index-YIP9QK2L.js} +1 -1
  23. package/dist/assets/{index-TrUYBc0F.js → index-nosdUF9i.js} +1 -1
  24. package/dist/assets/{index-CFYbGyvs.js → index-xo-ROtuF.js} +1 -1
  25. package/dist/assets/{index-CZCNUCD6.js → index-yAX3aWkW.js} +1 -1
  26. package/dist/assets/{index.es-xWGpyzms.js → index.es--WISYjTj.js} +3 -3
  27. package/dist/assets/{keccak-Dh1-j093.js → keccak-DYzglTc3.js} +1 -1
  28. package/dist/assets/{solana-FuO6ds45.js → solana-BmGIyTEt.js} +2 -2
  29. package/dist/assets/{solana-HXT1gH4s.js → solana-D5RkygmT.js} +2 -2
  30. package/dist/assets/{solanaEmbed.esm-CmWxi_NO.js → solanaEmbed.esm-CFdxIRQj.js} +1 -1
  31. package/dist/assets/{sui-CQYR74Ws.js → sui-CW05lm4n.js} +2 -2
  32. package/dist/assets/{unsignedTransaction-YIv7ff3U.js → unsignedTransaction-DAYPmfUj.js} +1 -1
  33. package/dist/main.js +69 -69
  34. package/lib/{algorand-DMWnCGDD.js → algorand-B9Pcx34H.js} +1 -1
  35. package/lib/{algorand-CKeviXZg.mjs → algorand-BfdC8LMm.mjs} +3 -3
  36. package/lib/{aptos-LGyhejg2.mjs → aptos-CuQYjxz4.mjs} +1 -1
  37. package/lib/{aptos-DBFfVz6j.js → aptos-D8msRZYc.js} +1 -1
  38. package/lib/{aptos-DNei2Fw9.mjs → aptos-DISEuAM4.mjs} +3 -3
  39. package/lib/{aptos-CAJat9Bn.js → aptos-DlboPucS.js} +2 -2
  40. package/lib/{ccip-E64BZKbj.js → ccip-BqkngZ6V.js} +1 -1
  41. package/lib/{ccip-gtLK9yzS.mjs → ccip-DV1T5CQz.mjs} +1 -1
  42. package/lib/{cosmwasm-CnK43h4P.mjs → cosmwasm-BFPK6deV.mjs} +111 -7
  43. package/lib/{cosmwasm-CmkeZSLD.js → cosmwasm-D3ZKcsjq.js} +2 -2
  44. package/lib/{events-dBi7i6gd.mjs → events-CaIL5tL1.mjs} +1 -1
  45. package/lib/{events-D5Nem7a2.js → events-Cxw8aBUy.js} +1 -1
  46. package/lib/{evm-DyPy8X4q.mjs → evm-7idwo4la.mjs} +5 -5
  47. package/lib/{evm-Bsq-lyhx.mjs → evm-D11YbeC_.mjs} +7 -7
  48. package/lib/{evm-BEkpevR1.js → evm-D12EHZXD.js} +4 -4
  49. package/lib/{evm-JR5REYuq.js → evm-UrRoO3lT.js} +1 -1
  50. package/lib/{index-DWFG3ux-.js → index-B-m7_r9W.js} +1 -1
  51. package/lib/{index-BZTaoymt.mjs → index-BEfsEC8g.mjs} +3 -3
  52. package/lib/{index-Cc_mraT5.mjs → index-BKeG3u48.mjs} +2 -2
  53. package/lib/{index-FW1hHPsY.js → index-BMLK3kVY.js} +1 -1
  54. package/lib/{index-CrVV6hQ2.js → index-BMsGsrRe.js} +1 -1
  55. package/lib/{index-xr-_5YwS.mjs → index-BPD6tZ5I.mjs} +7575 -5146
  56. package/lib/{index-CL3ekJSh.js → index-BQI2oZiv.js} +1 -1
  57. package/lib/{index-CeksQZJ0.mjs → index-BUGIe9Q0.mjs} +4 -4
  58. package/lib/{index-CvX8wxOG.mjs → index-BkUc_QzZ.mjs} +2 -2
  59. package/lib/{index-DE7BjSqw.js → index-Br_1eyUd.js} +1 -1
  60. package/lib/{index-C8MkGmi-.mjs → index-C1KUJpQh.mjs} +1 -1
  61. package/lib/{index-B_wAMidq.js → index-C6ww0FoG.js} +1 -1
  62. package/lib/{index-YigUyjDr.mjs → index-CBnSdTOm.mjs} +1 -1
  63. package/lib/{index-DD4g5WJB.mjs → index-CDGkVXf1.mjs} +2 -2
  64. package/lib/{index-D5un17aL.mjs → index-CG2dc9k1.mjs} +13 -13
  65. package/lib/{index-CsYGJh8i.js → index-CGqBKzB5.js} +1 -1
  66. package/lib/{index-TidzojcT.js → index-CHGr1Xo0.js} +1 -1
  67. package/lib/{index-BHnHO_u8.js → index-CJ8hOjdz.js} +1 -1
  68. package/lib/{index-BlRWSvuT.js → index-COW9BRyV.js} +1 -1
  69. package/lib/{index-jnHYrj-0.mjs → index-CeK6G0Jr.mjs} +2 -2
  70. package/lib/{index-u9NHndtJ.mjs → index-Cfupv0rQ.mjs} +4 -4
  71. package/lib/{index-C-MpEmke.mjs → index-Cg19mcso.mjs} +1 -1
  72. package/lib/{index-DhJzyV8c.js → index-Cg6LDJti.js} +1 -1
  73. package/lib/{index-Cwf7_SpM.js → index-CkHXWtPG.js} +1 -1
  74. package/lib/{index-B9YINx-j.mjs → index-ClI_55nW.mjs} +7 -7
  75. package/lib/{index-BSXkcZeB.mjs → index-ClbyJuae.mjs} +2 -2
  76. package/lib/{index-DRTJX6NI.mjs → index-Cs8OaRdq.mjs} +2 -2
  77. package/lib/{index-B6Yxe_gd.mjs → index-D4FfgE9k.mjs} +2 -2
  78. package/lib/{index-PebPsVgf.js → index-D9Ezmk4f.js} +1 -1
  79. package/lib/{index-BIhEJqD8.js → index-DgKyQSTc.js} +1 -1
  80. package/lib/{index-BxaWYSOO.js → index-Dh6mkRtz.js} +74 -74
  81. package/lib/{index-w88sWpdI.js → index-DjZ438HP.js} +1 -1
  82. package/lib/{index-DSJ41rGf.mjs → index-DlXF_HRr.mjs} +2 -2
  83. package/lib/{index-DRDlsqLC.js → index-DsMw6BFg.js} +1 -1
  84. package/lib/{index-CtuM0Nhj.mjs → index-GKdJmpc9.mjs} +2 -2
  85. package/lib/{index-CAOx_2w0.mjs → index-IwSEAKjs.mjs} +3 -3
  86. package/lib/{index-CvLvO-ub.mjs → index-VO5jvtPN.mjs} +1 -1
  87. package/lib/{index-fpX08H1Q.js → index-Vouac_sN.js} +1 -1
  88. package/lib/{index-snvFYwLU.mjs → index-f6MztC_k.mjs} +2 -2
  89. package/lib/{index-BrZMeh8Y.js → index-hb33T1qT.js} +1 -1
  90. package/lib/{index-D9LNItFN.js → index-s_6sncui.js} +1 -1
  91. package/lib/{index-CN4S3GOd.mjs → index-vmVyLCAM.mjs} +3 -3
  92. package/lib/{index-CLImffCI.js → index-xTifobUX.js} +1 -1
  93. package/lib/{index-Brws-ttZ.js → index-yYbCizsj.js} +1 -1
  94. package/lib/{index.es-BgIY-CJP.mjs → index.es-Bld6bvmZ.mjs} +5 -5
  95. package/lib/{index.es-DA6xjT-p.js → index.es-DWCjm6mS.js} +2 -2
  96. package/lib/index.js +1 -1
  97. package/lib/index.mjs +1 -1
  98. package/lib/{keccak-D3kXYcOs.mjs → keccak-BwFcIiaM.mjs} +1 -1
  99. package/lib/{keccak-xKB7Kino.js → keccak-C8mX3bFz.js} +1 -1
  100. package/lib/{pbkdf2-DCnqfxZR.js → pbkdf2-Bk-3RPXm.js} +1 -1
  101. package/lib/{pbkdf2-Dg0HWbq4.mjs → pbkdf2-CeHVjwwG.mjs} +1 -1
  102. package/lib/{signer-DIzVzPl8.mjs → signer-DXNU3KLz.mjs} +1 -1
  103. package/lib/{signer-CbcYYMJ7.js → signer-LadskxdY.js} +1 -1
  104. package/lib/solana-B15fGx9S.js +1 -0
  105. package/lib/{solana-BVgObkcE.mjs → solana-BasjNE9K.mjs} +4 -4
  106. package/lib/{solana-DmCHygOA.js → solana-C9iEiCkx.js} +1 -1
  107. package/lib/{solana-HKO9jNRD.mjs → solana-CfCGAR-_.mjs} +5 -5
  108. package/lib/{solanaEmbed.esm-DqNfqaxI.js → solanaEmbed.esm-CJdWWBYT.js} +1 -1
  109. package/lib/{solanaEmbed.esm-DEAHXGVn.mjs → solanaEmbed.esm-pwzJ8Zc0.mjs} +3 -3
  110. package/lib/{sui-DN8E0m68.mjs → sui-B9B-EQyp.mjs} +4 -4
  111. package/lib/{sui-BDoIBdRb.js → sui-BJBxQjSI.js} +2 -2
  112. package/lib/{sui-Bp2zLhA_.mjs → sui-HC466JTC.mjs} +1 -1
  113. package/lib/{sui-W_WW-YXK.js → sui-iJeaGeqF.js} +1 -1
  114. package/lib/{unsignedTransaction-Dkfjd5_o.js → unsignedTransaction-CmgkSLIX.js} +1 -1
  115. package/lib/unsignedTransaction-Di5zQIK0.mjs +35 -0
  116. package/package.json +3 -3
  117. package/lib/solana-BYXqKgjy.js +0 -1
  118. package/lib/unsignedTransaction-C32EJDkZ.mjs +0 -35
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-q0W2SHor.js","main.js","main.css","assets/pbkdf2-CTUZRYZs.js","assets/index-CFYbGyvs.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-YIP9QK2L.js","main.js","main.css","assets/pbkdf2-CTUZRYZs.js","assets/index-xo-ROtuF.js"])))=>i.map(i=>d[i]);
2
2
  var En=Object.defineProperty;var vn=(t,e,r)=>e in t?En(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var we=(t,e,r)=>vn(t,typeof e!="symbol"?e+"":e,r);import{aq as ut,ar as Le,as as Bt,at as O,au as Mt,av as oe,aw as kn,ax as Pt,ay as Me,az as ce,aA as _n,aB as Fe,aC as gr,ae as xn,aD as pr,aE as In,aF as An,af as On,ah as Cn,ai as jn,aG as Bn,ak as Mn,al as lt,am as Pn,aH as Je,ap as Rn,aI as $n,aJ as xr,aK as Ir,R as fe,_ as yr,a3 as Nn}from"../main.js";import{p as Un}from"./pbkdf2-CTUZRYZs.js";function H(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const ft=8192;function N(t){if(t.length<ft)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=ft){const n=t.slice(r,r+ft);e+=String.fromCharCode(...n)}return btoa(e)}function qe(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 me(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function Rt(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 Dn(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 Ar{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}=Dn(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 zn(t,e){switch(e){case"base58":return Le(t);case"base64":return N(t);case"hex":return me(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Vn(t,e){switch(e){case"base58":return ut(t);case"base64":return H(t);case"hex":return qe(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Or(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 Cr{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 ht(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return ht(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return ht(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return Rt(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 zn(this.toBytes(),e)}}function ht(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 jr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},W=(t,e,r)=>(jr(t,e,"read from private field"),r?r.call(t):e.get(t)),rt=(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)},nt=(t,e,r,n)=>(jr(t,e,"write to private field"),e.set(t,r),r),be,xe,Xe,ae;const Br=class{constructor(t){rt(this,be,void 0),rt(this,xe,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),nt(this,be,t.write),nt(this,xe,t.serialize??((e,r)=>{const n=new Cr({size:this.serializedSize(e)??void 0,...r});return W(this,be).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),W(this,be).call(this,t,e)}serialize(t,e){return this.validate(t),new Ln(this,W(this,xe).call(this,t,e))}parse(t){const e=new Ar(t);return this.read(e)}transform({name:t,input:e,output:r}){return new Br({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>W(this,be).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>W(this,xe).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let K=Br;be=new WeakMap;xe=new WeakMap;const Mr=Symbol.for("@mysten/serialized-bcs");function $t(t){return!!t&&typeof t=="object"&&t[Mr]===!0}class Ln{constructor(e,r){rt(this,Xe,void 0),rt(this,ae,void 0),nt(this,Xe,e),nt(this,ae,r)}get[Mr](){return!0}toBytes(){return W(this,ae)}toHex(){return me(W(this,ae))}toBase64(){return N(W(this,ae))}toBase58(){return Le(W(this,ae))}parse(){return W(this,Xe).parse(W(this,ae))}}Xe=new WeakMap;ae=new WeakMap;function st({size:t,...e}){return new K({...e,serializedSize:()=>t})}function gt({readMethod:t,writeMethod:e,...r}){return st({...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 pt({readMethod:t,writeMethod:e,...r}){return st({...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 qn({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 Wn({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=Rt(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 Fn(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 gt({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return gt({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return gt({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return pt({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return pt({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return pt({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return st({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 qn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Rt(e)),...t})},bytes(t,e){return st({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 Wn({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[d,f]=n[u];if(d===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 Fn(t)}},Kn=32,Ie=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof Ie){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(Ie.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&&Gn(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 Ie(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
3
3
  ${JSON.stringify(t)}`)}de(t,e,r){if(typeof e=="string")if(r)e=Vn(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 Ie(this),s=this.tempKey();return n.registerStructType(s,t).de(s,e,r)}throw new Error(`Incorrect type passed into the '.de()' function.
4
4
  ${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,d){const f=i.reduce((g,p,y)=>Object.assign(g,{[p]:d[y]}),{});return this._encodeRaw.call(a,new Cr(u),o,d,f)},decode(a,o,u){const d=i.reduce((f,g,p)=>Object.assign(f,{[g]:u[p]}),{});return this._decodeRaw.call(a,new Ar(o),u,d)},_encodeRaw(a,o,u,d){if(n(o))return e.call(this,a,o,u,d);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:d,params:f}=this.parseTypeName(a),g=this.getTypeInterface(d),p=f.reduce((y,k,S)=>Object.assign(y,{[k]:s[S]}),{});return g._encodeRaw.call(this,u,o,f,p)},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),d=this.getTypeInterface(o),f=u.reduce((g,p,y)=>Object.assign(g,{[p]:n[y]}),{});return d._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 N(s.readBytes(e))});case"hex":return this.registerType(t,function(s,i){return qe(i).reduce((a,o)=>a.write8(o),s)},function(s){return me(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,d)=>{let f=a[0];if(!f)throw new Error(`Incorrect number of type parameters passed a to vector '${t}'`);let{name:g,params:p}=this.parseTypeName(f);if(this.hasType(g))return this.getTypeInterface(g)._encodeRaw.call(this,u,d,p,o);if(!(g in o))throw new Error(`Unable to find a matching type definition for ${g} in vector; make sure you passed a generic`);let{name:y,params:k}=this.parseTypeName(o[g]);return this.getTypeInterface(y)._encodeRaw.call(this,u,d,k,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:d,params:f}=this.parseTypeName(u);if(this.hasType(d))return this.getTypeInterface(d)._decodeRaw.call(this,o,f,a);if(!(d in a))throw new Error(`Unable to find a matching type definition for ${d} in vector; make sure you passed a generic`);let{name:g,params:p}=this.parseTypeName(a[d]);return this.getTypeInterface(g)._decodeRaw.call(this,o,p,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,d,f){if(!u||u.constructor!==Object)throw new Error(`Expected ${s} to be an Object, got: ${u}`);if(d.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${d.length}`);for(let g of n){if(!(g in u))throw new Error(`Struct ${s} requires field ${g}:${r[g]}`);const{name:p,params:y}=this.parseTypeName(r[g]);if(!i.includes(p))this.getTypeInterface(p)._encodeRaw.call(this,o,u[g],y,f);else{const k=i.indexOf(p);let{name:S,params:j}=this.parseTypeName(d[k]);if(this.hasType(S)){this.getTypeInterface(S)._encodeRaw.call(this,o,u[g],j,f);continue}if(!(S in f))throw new Error(`Unable to find a matching type definition for ${S} in ${s}; make sure you passed a generic`);let{name:M,params:se}=this.parseTypeName(f[S]);this.getTypeInterface(M)._encodeRaw.call(this,o,u[g],se,f)}}return o},function(o,u,d){if(u.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${u.length}`);let f={};for(let g of n){const{name:p,params:y}=this.parseTypeName(r[g]);if(!i.includes(p))f[g]=this.getTypeInterface(p)._decodeRaw.call(this,o,y,d);else{const k=i.indexOf(p);let{name:S,params:j}=this.parseTypeName(u[k]);if(this.hasType(S)){f[g]=this.getTypeInterface(S)._decodeRaw.call(this,o,j,d);continue}if(!(S in d))throw new Error(`Unable to find a matching type definition for ${S} in ${s}; make sure you passed a generic`);let{name:M,params:se}=this.parseTypeName(d[S]);f[g]=this.getTypeInterface(M)._decodeRaw.call(this,o,se,d)}}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,d,f){if(!u)throw new Error(`Unable to write enum "${s}", missing data.
5
5
  Received: "${u}"`);if(typeof u!="object")throw new Error(`Incorrect data passed into enum "${s}", expected object with properties: "${n.join(" | ")}".
6
- Received: "${JSON.stringify(u)}"`);let g=Object.keys(u)[0];if(g===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let p=n.indexOf(g);if(p===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${g}"`);let y=n[p],k=r[y];if(o.write8(p),k===null)return o;let S=i.indexOf(k),j=S===-1?k:d[S];{let{name:M,params:se}=this.parseTypeName(j);return this.getTypeInterface(M)._encodeRaw.call(this,o,u[g],se,f)}},function(o,u,d){let f=o.readULEB(),g=n[f],p=r[g];if(f===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${f}"`);if(p===null)return{[g]:!0};let y=i.indexOf(p),k=y===-1?p:u[y];{let{name:S,params:j}=this.parseTypeName(k);return{[g]:this.getTypeInterface(S)._decodeRaw.call(this,o,j,d)}}})}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=Or(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let _=Ie;_.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 Gn(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(qe(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return me(new Uint8Array(r))}),t.registerType(_.BASE58,function(e,r){return e.writeVec(Array.from(ut(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return Le(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 N(new Uint8Array(r))})}function Hn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Kn,addressEncoding:"hex"}}class Zn 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 Jn(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 Xn(t){const{done:e,value:r}=t.next();return e?void 0:r}function Yn(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*mr(t,e,r,n){Jn(t)||(t=[t]);for(const s of t){const i=Yn(s,e,r,n);i&&(yield i)}}function*Nt(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 d in t)e.schema[d]===void 0&&delete t[d];let u="valid";for(const d of e.validator(t,o))d.explanation=r.message,u="not_valid",yield[d,void 0];for(let[d,f,g]of e.entries(t,o)){const p=Nt(f,g,{path:d===void 0?n:[...n,d],branch:d===void 0?s:[...s,f],coerce:i,mask:a,message:r.message});for(const y of p)y[0]?(u=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):i&&(f=y[1],d===void 0?t=f:t instanceof Map?t.set(d,f):t instanceof Set?t.add(f):V(t)&&(f!==void 0||d in t)&&(t[d]=f))}if(u!=="not_valid")for(const d of e.refiner(t,o))d.explanation=r.message,u="not_refined",yield[d,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,d)=>{const f=s(u,d);return mr(f,d,this,u)}:this.validator=()=>[],i?this.refiner=(u,d)=>{const f=i(u,d);return mr(f,d,this,u)}:this.refiner=()=>[]}assert(e,r){return bt(e,this,r)}create(e,r){return Pr(e,this,r)}is(e){return U(e,this)}mask(e,r){return Rr(e,this,r)}validate(e,r={}){return We(e,this,r)}}function bt(t,e,r){const n=We(t,e,{message:r});if(n[0])throw n[0]}function Pr(t,e,r){const n=We(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Rr(t,e,r){const n=We(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function U(t,e){return!We(t,e)[0]}function We(t,e,r={}){const n=Nt(t,e,r),s=Xn(n);return s[0]?[new Zn(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Pe(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?es(n):h(n)}function D(t,e){return new X({type:t,schema:null,validator:e})}function St(){return D("any",()=>!0)}function T(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 Qn(){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 w(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 $r(){return D("never",()=>!1)}function A(t){return new X({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function pe(){return D("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${L(t)}`)}function h(t){const e=t?Object.keys(t):[],r=$r();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 m(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 l(){return D("string",t=>typeof t=="string"||`Expected a string, but received: ${L(t)}`)}function Nr(t){const e=$r();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 es(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 C(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]=Nt(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 Ur(){return D("unknown",()=>!0)}/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */function Dr(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function ts(t){const e=Dr(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}const rs=t=>Dr(`mnemonic${t}`);function ns(t,e=""){return Un(Bt,ts(t).nfkd,rs(e),{c:2048,dkLen:64})}const ss="0.50.1",is="1.19.0",as={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class zr extends Error{}class Vr extends zr{constructor(e,r){super(e),this.code=r,this.type=as[r]??"ServerError"}}class os extends zr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var Ut=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},x=(t,e,r)=>(Ut(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)},Te=(t,e,r,n)=>(Ut(t,e,"write to private field"),e.set(t,r),r),cs=(t,e,r,n)=>({set _(s){Te(t,e,s)},get _(){return x(t,e,n)}}),Lr=(t,e,r)=>(Ut(t,e,"access private method"),r),he,je,ee,ge,Re,Ee,Tt,qr,Dt,Wr;function us(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const ds={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class ls{constructor(e,r={}){if(ie(this,Tt),ie(this,Dt),ie(this,he,0),ie(this,je,0),ie(this,ee,null),ie(this,ge,null),ie(this,Re,new Set),ie(this,Ee,new Map),this.endpoint=e,this.options={...ds,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=us(this.endpoint))}async makeRequest(e,r){const n=await Lr(this,Tt,qr).call(this);return new Promise((s,i)=>{Te(this,he,x(this,he)+1),x(this,Ee).set(x(this,he),{resolve:s,reject:i,timeout:setTimeout(()=>{x(this,Ee).delete(x(this,he)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:x(this,he),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new Vr(s.message,s.code);return i})}async subscribe(e){const r=new fs(e);return x(this,Re).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}he=new WeakMap;je=new WeakMap;ee=new WeakMap;ge=new WeakMap;Re=new WeakMap;Ee=new WeakMap;Tt=new WeakSet;qr=function(){return x(this,ge)?x(this,ge):(Te(this,ge,new Promise(t=>{var e;(e=x(this,ee))==null||e.close(),Te(this,ee,new this.options.WebSocketConstructor(this.endpoint)),x(this,ee).addEventListener("open",()=>{Te(this,je,0),t(x(this,ee))}),x(this,ee).addEventListener("close",()=>{cs(this,je)._++,x(this,je)<=this.options.maxReconnects&&setTimeout(()=>{Lr(this,Dt,Wr).call(this)},this.options.reconnectTimeout)}),x(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&&x(this,Ee).has(n.id)){const{resolve:s,timeout:i}=x(this,Ee).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;x(this,Re).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),x(this,ge))};Dt=new WeakSet;Wr=async function(){var t;return(t=x(this,ee))==null||t.close(),Te(this,ge,null),Promise.allSettled([...x(this,Re)].map(e=>e.subscribe(this)))};class fs{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 zt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},z=(t,e,r)=>(zt(t,e,"read from private field"),r?r.call(t):e.get(t)),Ke=(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)},Et=(t,e,r,n)=>(zt(t,e,"write to private field"),e.set(t,r),r),hs=(t,e,r)=>(zt(t,e,"access private method"),r),Ae,F,Be,vt,Fr;class gs{constructor(e){Ke(this,vt),Ke(this,Ae,0),Ke(this,F,void 0),Ke(this,Be,void 0),Et(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;Et(this,Ae,z(this,Ae)+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":ss,"Client-Target-Api-Version":is,...(i=z(this,F).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:z(this,Ae),method:e.method,params:e.params})});if(!r.ok)throw new os(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new Vr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await hs(this,vt,Fr).call(this).subscribe(e);return async()=>!!await r()}}Ae=new WeakMap;F=new WeakMap;Be=new WeakMap;vt=new WeakSet;Fr=function(){var t;if(!z(this,Be)){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.");Et(this,Be,new ls(((t=z(this,F).websocket)==null?void 0:t.url)??z(this,F).url,{WebSocketConstructor:e,...z(this,F).websocket}))}return z(this,Be)};const ps=/^vector<(.+)>$/,ys=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;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(ps);if(n)return{vector:te.parseFromStr(n[1],r)};const s=e.match(ys);if(s)return{struct:{address:r?O(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 Or(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 v=new _({...Hn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function Kr(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function ms(t){return c.enum("Option",{None:null,Some:t})}function Vt(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(Mt).transform({input:t=>typeof t=="string"?qe(O(t)):t,output:t=>O(me(t))}),Lt=c.vector(c.u8()).transform({name:"ObjectDigest",input:t=>ut(t),output:t=>Le(new Uint8Array(t))}),$e=c.struct("SuiObjectRef",{objectId:G,version:c.u64(),digest:Lt}),qt=c.struct("SharedObjectRef",{objectId:G,initialSharedVersion:c.u64(),mutable:c.bool()}),it=c.enum("ObjectArg",{ImmOrOwned:$e,Shared:qt,Receiving:$e}),Wt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:it,ObjVec:c.vector(it)}),_e=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>_e),struct:c.lazy(()=>Jt),u16:null,u32:null,u256:null}),q=Vt(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()})})),Ft=c.struct("ProgrammableMoveCall",{package:G,module:c.string(),function:c.string(),type_arguments:c.vector(_e),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:O(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)})}),Kt=Vt(c.enum("Transaction",{MoveCall:Ft,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:ms(_e),objects:c.vector(q)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G),packageId:G,ticket:q})})),Gt=c.struct("ProgrammableTransaction",{inputs:c.vector(Wt),transactions:c.vector(Kt)}),Ht=c.enum("TransactionKind",{ProgrammableTransaction:Gt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Zt=c.enum("TransactionExpiration",{None:null,Epoch:Kr()}),Jt=c.struct("StructTag",{address:G,module:c.string(),name:c.string(),typeParams:c.vector(_e)}),Xt=c.struct("GasData",{payment:c.vector($e),owner:G,price:c.u64(),budget:c.u64()}),Yt=c.struct("TransactionDataV1",{kind:Ht,sender:G,gasData:Xt,expiration:Zt}),Qt=c.enum("TransactionData",{V1:Yt}),ws=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),bs=c.enum("IntentVersion",{V0:null}),Ss=c.enum("AppId",{Sui:null}),Ts=c.struct("Intent",{scope:ws,version:bs,appId:Ss}),Es=c.generic(["T"],t=>c.struct("IntentMessage<T>",{intent:Ts,value:t})),er=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())}),tr=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())}),rr=c.struct("MultiSigPkMap",{pubKey:tr,weight:c.u8()}),nr=c.struct("MultiSigPublicKey",{pk_map:c.vector(rr),threshold:c.u16()}),Gr=c.struct("MultiSig",{sigs:c.vector(er),bitmap:c.u16(),multisig_pk:nr}),vs=c.vector(c.u8()).transform({input:t=>typeof t=="string"?H(t):t,output:t=>N(new Uint8Array(t))}),Hr=c.struct("SenderSignedTransaction",{intentMessage:Es(Qt),txSignatures:c.vector(vs)}),Zr=c.vector(Hr,{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:Wt,CompressedSignature:er,GasData:Xt,MultiSig:Gr,MultiSigPkMap:rr,MultiSigPublicKey:nr,ObjectArg:it,ObjectDigest:Lt,ProgrammableMoveCall:Ft,ProgrammableTransaction:Gt,PublicKey:tr,SenderSignedData:Zr,SenderSignedTransaction:Hr,SharedObjectRef:qt,StructTag:Jt,SuiObjectRef:$e,Transaction:Kt,TransactionData:Qt,TransactionDataV1:Yt,TransactionExpiration:Zt,TransactionKind:Ht,TypeTag:_e,ser:v.ser.bind(v),de:v.de.bind(v),getTypeInterface:v.getTypeInterface.bind(v),hasType:v.hasType.bind(v),parseTypeName:v.parseTypeName.bind(v),registerAddressType:v.registerAddressType.bind(v),registerAlias:v.registerAlias.bind(v),registerBcsType:v.registerBcsType.bind(v),registerEnumType:v.registerEnumType.bind(v),registerStructType:v.registerStructType.bind(v),registerType:v.registerType.bind(v),types:v.types};v.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));v.registerBcsType("unsafe_u64",()=>Kr());v.registerBcsType("enumKind",t=>Vt(t));[G,q,Wt,er,Xt,Gr,rr,nr,it,Lt,Ft,Gt,tr,Zr,qt,Jt,$e,Kt,Qt,Yt,Zt,Ht,_e].forEach(t=>{v.registerBcsType(t.name,()=>t)});const sr=C([h({AddressOwner:l()}),h({ObjectOwner:l()}),h({Shared:h({initial_shared_version:A(l())})}),w("Immutable")]);D("SuiJsonValue",()=>!0);const ks=C([h({u32:l()}),h({u64:l()}),h({f64:l()})]);h({attributes:Z(l(),A(ks)),featureFlags:Z(l(),P()),maxSupportedProtocolVersion:l(),minSupportedProtocolVersion:l(),protocolVersion:l()});C([l(),w("package")]);const ue=h({digest:l(),objectId:l(),version:C([pe(),l(),Qn()])});h({owner:sr,reference:ue});h({objectId:l(),sequenceNumber:l()});h({payment:T(ue),owner:l(),price:l(),budget:l()});const _s=Pe(ue,h({type:l(),owner:sr,previousTransaction:l()})),xs=Z(l(),St()),Is=Z(l(),Ur()),As=h({type:l(),fields:xs,hasPublicTransfer:P()}),Os=h({disassembled:Is}),Cs=C([Pe(As,h({dataType:w("moveObject")})),Pe(Os,h({dataType:w("package")}))]),js=h({type:l(),hasPublicTransfer:P(),version:l(),bcsBytes:l()}),Bs=h({id:l(),moduleMap:Z(l(),l())}),Ms=C([Pe(js,h({dataType:w("moveObject")})),Pe(Bs,h({dataType:w("package")}))]);BigInt(1e9);const Jr=h({code:l(),error:m(l()),object_id:m(l()),parent_object_id:m(l()),version:m(l()),digest:m(l())}),Ps=h({data:A(m(Z(l(),l()))),error:A(m(Jr))}),Rs=C([Ps,m(Z(l(),l()))]),Xr=h({objectId:l(),version:l(),digest:l(),type:A(m(l())),content:A(m(Cs)),bcs:A(m(Ms)),owner:A(m(sr)),previousTransaction:A(m(l())),storageRebate:A(m(l())),display:A(m(Rs))});h({showType:A(m(P())),showContent:A(m(P())),showBcs:A(m(P())),showOwner:A(m(P())),showPreviousTransaction:A(m(P())),showStorageRebate:A(m(P())),showDisplay:A(m(P()))});C([w("Exists"),w("notExists"),w("Deleted")]);T(_s);const $s=h({data:A(m(Xr)),error:A(m(Jr))});function Ns(t){return t.data}function Us(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 wr(t){if("reference"in t)return t.reference;const e=Ns(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:Us(t)}h({objectId:l(),atCheckpoint:m(pe())});h({data:T($s),nextCursor:m(A(l())),hasNextPage:P()});C([h({details:Xr,status:w("VersionFound")}),h({details:l(),status:w("ObjectNotExists")}),h({details:ue,status:w("ObjectDeleted")}),h({details:Nr([l(),pe()]),status:w("VersionNotFound")}),h({details:h({asked_version:pe(),latest_version:pe(),object_id:l()}),status:w("VersionTooHigh")})]);const Ds=C([l(),h({Object:l()})]);T(Ds);const zs=h({address:l(),name:l()}),Vs=C([w("Private"),w("Public"),w("Friend")]),ir=h({abilities:T(l())}),Ls=h({constraints:ir,isPhantom:P()}),qs=h({TypeParameter:pe()}),yt=Nr([h({module:l(),package:l(),function:l()}),l()]);h({rank3Days:T(yt),rank7Days:T(yt),rank30Days:T(yt)});function Yr(t){if(!t)return!1;if(typeof t=="string"||U(t,qs)||Qr(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(U(e.Reference,ve)||U(e.MutableReference,ve)||U(e.Vector,ve))}const ve=D("SuiMoveNormalizedType",Yr);function Qr(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=>Yr(n)))}D("SuiMoveNormalizedStructType",Qr);const Ws=h({visibility:Vs,isEntry:P(),typeParameters:T(ir),parameters:T(ve),return:T(ve)}),Fs=h({name:l(),type:ve}),Ks=h({abilities:ir,typeParameters:T(Ls),fields:T(Fs)}),Gs=h({fileFormatVersion:pe(),address:l(),name:l(),friends:T(zs),structs:Z(l(),Ks),exposedFunctions:Z(l(),Ws)});Z(l(),Gs);function kt(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function en(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function ar(t){if(typeof t=="object"&&"Struct"in t)return t;const e=en(t),r=kt(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const Hs=C([h({ImmOrOwned:ue}),h({Shared:h({objectId:l(),initialSharedVersion:C([J(),l()]),mutable:P()})}),h({Receiving:ue})]),at=h({Pure:T(J())}),_t=h({Object:Hs}),ot=C([at,_t]);function Zs(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:$t(t)?t.toBytes():I.ser(e,t,{maxSize:1/0}).toBytes())}}const $={Pure:Zs,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:O(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:O(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:O(t)}}}}};function br(t){return typeof t=="string"?O(t):"ImmOrOwned"in t.Object?O(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?O(t.Object.Receiving.objectId):O(t.Object.Shared.objectId)}function Js(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function Xs(t){var e;return((e=Js(t))==null?void 0:e.mutable)??!1}function Ys(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 Qs="object",ei="ID",ti="ascii",ri="String",ni="string",si="String",ii="option",ai="Option",oi={address:kn,module:Qs,name:ei},ci={address:Pt,module:ti,name:ri},ui={address:Pt,module:ni,name:si},di={address:Pt,module:ii,name:ai},Ge=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function li(t){var r;const e=(r=ar(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 mt(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const fi=["Address","Bool","U8","U16","U32","U64","U128","U256"];function xt(t,e){if(typeof t=="string"&&fi.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])mt("number",e);else if(t==="Bool")mt("boolean",e);else if(t==="Address"&&(mt("string",e),e&&!oe(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=xt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(Ge(t.Struct,ci))return"string";if(Ge(t.Struct,ui))return"utf8string";if(Ge(t.Struct,oi))return"address";if(Ge(t.Struct,di)){const r={Vector:t.Struct.typeArguments[0]};return xt(r,e)}}}function hi(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),Me(n,{dkLen:32})}function R(t,e){return Pr(t,e)}const gi=t=>C([h({None:C([w(!0),w(null)])}),h({Some:t})]),Ne=C([h({kind:w("Input"),index:J(),value:m(St()),type:m(w("object"))}),h({kind:w("Input"),index:J(),value:m(St()),type:w("pure")})]),pi=[Ne,h({kind:w("GasCoin")}),h({kind:w("Result"),index:J()}),h({kind:w("NestedResult"),index:J(),resultIndex:J()})],ne=C([...pi]),tn=h({kind:w("MoveCall"),target:D("target",l().validator),typeArguments:T(l()),arguments:T(ne)}),rn=h({kind:w("TransferObjects"),objects:T(ne),address:ne}),nn=h({kind:w("SplitCoins"),coin:ne,amounts:T(ne)}),sn=h({kind:w("MergeCoins"),destination:ne,sources:T(ne)}),an=h({kind:w("MakeMoveVec"),type:m(gi(Z(l(),Ur()))),objects:T(ne)}),on=h({kind:w("Publish"),modules:T(T(J())),dependencies:T(l())}),cn=h({kind:w("Upgrade"),modules:T(T(J())),dependencies:T(l()),packageId:l(),ticket:ne}),yi=[tn,rn,nn,sn,on,cn,an],mi=C([...yi]),le={MoveCall(t){return R({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},tn)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=$.Pure(I.Address.serialize(e.value))),R({kind:"TransferObjects",objects:t,address:e},rn)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=$.Pure(I.U64.serialize(r.value)))}),R({kind:"SplitCoins",coin:t,amounts:e},nn)},MergeCoins(t,e){return R({kind:"MergeCoins",destination:t,sources:e},sn)},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=>ce(r))},on)},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=>ce(s)),packageId:r,ticket:n},cn)},MakeMoveVec({type:t,objects:e}){return R({kind:"MakeMoveVec",type:t?{Some:te.parseFromStr(t)}:{None:null},objects:e},an)}},wi=m(A(C([h({Epoch:J()}),h({None:C([w(!0),w(null)])})]))),Sr=D("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),bi=h({budget:m(Sr),price:m(Sr),payment:m(T(ue)),owner:m(l())}),He=h({version:w(1),sender:m(l()),expiration:wi,gasConfig:bi,inputs:T(Ne),transactions:T(mi)});function Tr(t){return O(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,at)?"pure":"object"},Ne)),transactions:n.transactions},He);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,at)?"pure":"object"},Ne)),transactions:s.transactions},He);return re.restore(i)}static restore(e){bt(e,He);const r=new re;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=hi("TransactionData",e);return Le(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(f=>(bt(f.value,ot),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 d={sender:Tr(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:Tr(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return I.TransactionData.serialize({V1:d},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return re.getDigestFromBytes(e)}snapshot(){return R(this,He)}}var or=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},E=(t,e,r)=>(or(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)},Ze=(t,e,r,n)=>(or(t,e,"write to private field"),e.set(t,r),r),B=(t,e,r)=>(or(t,e,"access private method"),r),b,Oe,Ye,Ce,Qe,de,ye,cr,un,ur,dn,dr,ln,lr,fn,et,It;const Si={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function Ti(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 Ei(t){const e=ar(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Ue(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 hn=Symbol.for("@mysten/transaction"),wt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},vi=1000n,ki=50,_i=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function xi(t){return!!t&&typeof t=="object"&&t[hn]===!0}const At=class{constructor(t){Y(this,Oe),Y(this,Ce),Y(this,de),Y(this,cr),Y(this,ur),Y(this,dr),Y(this,lr),Y(this,et),Y(this,b,void 0),Ze(this,b,new re(t?t.blockData:void 0))}static fromKind(t){const e=new At;return Ze(e,b,re.fromKindBytes(typeof t=="string"?H(t):t)),e}static from(t){const e=new At;return typeof t!="string"||!t.startsWith("{")?Ze(e,b,re.fromBytes(typeof t=="string"?H(t):t)):Ze(e,b,re.restore(JSON.parse(t))),e}setSender(t){E(this,b).sender=t}setSenderIfNotSet(t){E(this,b).sender||(E(this,b).sender=t)}setExpiration(t){E(this,b).expiration=t}setGasPrice(t){E(this,b).gasConfig.price=String(t)}setGasBudget(t){E(this,b).gasConfig.budget=String(t)}setGasOwner(t){E(this,b).gasConfig.owner=t}setGasPayment(t){E(this,b).gasConfig.payment=t.map(e=>Rr(e,ue))}get blockData(){return E(this,b).snapshot()}get[hn](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:Ys((t,e)=>$t(t)?B(this,Oe,Ye).call(this,"pure",{Pure:Array.from(t.toBytes())}):B(this,Oe,Ye).call(this,"pure",t instanceof Uint8Array?$.Pure(t):e?$.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=br(t),r=E(this,b).inputs.find(n=>n.type==="object"&&e===br(n.value));return r&&U(r.value,_t)&&"Shared"in r.value.Object&&U(t,_t)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??B(this,Oe,Ye).call(this,"object",typeof t=="string"?O(t):t)}objectRef(...t){return this.object($.ObjectRef(...t))}receivingRef(...t){return this.object($.ReceivingRef(...t))}sharedObjectRef(...t){return this.object($.SharedObjectRef(...t))}add(t){const e=E(this,b).transactions.push(t);return Ti(e-1)}splitCoins(t,e){return this.add(le.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,Ce,Qe).call(this,r))))}mergeCoins(t,e){return this.add(le.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(le.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(le.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(le.MoveCall({arguments:t==null?void 0:t.map(n=>B(this,Ce,Qe).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(le.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):B(this,Ce,Qe).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(le.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(E(this,b).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,et,It).call(this,t),E(this,b).build({maxSizeBytes:B(this,de,ye).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await B(this,et,It).call(this,t),E(this,b).getDigest()}};let Ii=At;b=new WeakMap;Oe=new WeakSet;Ye=function(t,e){const r=E(this,b).inputs.length,n=R({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Ne);return E(this,b).inputs.push(n),n};Ce=new WeakSet;Qe=function(t){return $t(t)?this.pure(t):t};de=new WeakSet;ye=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return Si[t];const n=e==null?void 0:e.attributes[wt[t]];if(!n)throw new Error(`Missing expected protocol config: "${wt[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: "${wt[t]}"`);return Number(s)};cr=new WeakSet;un=function(t){const e=B(this,de,ye).call(this,"maxPureArgumentSize",t);E(this,b).inputs.forEach((r,n)=>{if(U(r.value,at)&&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`)})};ur=new WeakSet;dn=async function(t){if(E(this,b).gasConfig.payment){const s=B(this,de,ye).call(this,"maxGasObjects",t);if(E(this,b).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||E(this,b).gasConfig.payment)return;const e=E(this,b).gasConfig.owner??E(this,b).sender,n=(await Ue(t).getCoins({owner:e,coinType:_n})).data.filter(s=>!E(this,b).inputs.find(a=>U(a.value,ot)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,B(this,de,ye).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)};dr=new WeakSet;ln=async function(t){t.onlyTransactionKind||E(this,b).gasConfig.price||this.setGasPrice(await Ue(t).getReferenceGasPrice())};lr=new WeakSet;fn=async function(t){const{inputs:e,transactions:r}=E(this,b),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:O(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!U(e[o.index].value,ot))&&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=$.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=$.Pure(I.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,u]=i.target.split("::"),d=await Ue(t).getNormalizedMoveFunction({package:ce(a),module:o,function:u}),g=d.parameters.length>0&&li(d.parameters.at(-1))?d.parameters.slice(0,d.parameters.length-1):d.parameters;if(g.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");g.forEach((p,y)=>{const k=i.arguments[y];if(k.kind!=="Input")return;const S=e[k.index];if(U(S.value,ot))return;const j=S.value,M=xt(p,j);if(M){S.value=$.Pure(j,M);return}if(ar(p)!=null||typeof p=="object"&&"TypeParameter"in p){if(typeof j!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(j,null,2)}`);s.push({id:j,input:S,normalizedType:p});return}throw new Error(`Unknown call arg type ${JSON.stringify(p,null,2)} for value ${JSON.stringify(j,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:f})=>f))],a=_i(i,ki),o=(await Promise.all(a.map(f=>Ue(t).multiGetObjects({ids:f,options:{showOwner:!0}})))).flat();let u=new Map(i.map((f,g)=>[f,o[g]]));const d=Array.from(u).filter(([f,g])=>g.error).map(([f,g])=>f);if(d.length)throw new Error(`The following input objects are invalid: ${d.join(", ")}`);s.forEach(({id:f,input:g,normalizedType:p})=>{var j;const y=u.get(f),k=(j=y.data)==null?void 0:j.owner,S=k&&typeof k=="object"&&"Shared"in k?k.Shared.initial_shared_version:void 0;if(S){const M=p!=null&&kt(p)==null&&en(p)==null,se=Xs(g.value)||M||p!=null&&kt(p)!=null;g.value=$.SharedObjectRef({objectId:f,initialSharedVersion:S,mutable:se})}else p&&Ei(p)?g.value=$.ReceivingRef(wr(y)):g.value=$.ObjectRef(wr(y))})}};et=new WeakSet;It=async function(t){if(!t.onlyTransactionKind&&!E(this,b).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,dr,ln).call(this,t),B(this,lr,fn).call(this,t)]),!t.onlyTransactionKind&&(await B(this,ur,dn).call(this,t),!E(this,b).gasConfig.budget)){const e=await Ue(t).dryRunTransactionBlock({transactionBlock:E(this,b).build({maxSizeBytes:B(this,de,ye).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(B(this,de,ye).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=vi*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,cr,un).call(this,t)};const Ai=Symbol.for("@mysten/SuiClient");class Oi{get[Ai](){return!0}constructor(e){this.transport=e.transport??new gs({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!oe(O(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||!oe(O(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||!oe(O(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||!oe(O(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||!oe(O(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||!Fe(ce(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||!Fe(ce(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(!gr(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(!gr(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:N(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||!oe(O(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||!Fe(ce(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(xi(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=N(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=N(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:N(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!Fe(ce(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=ut(e.digest);return me(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 gn extends xn{}const Ot="Sui",pn=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},wa=(t,e)=>{try{return pr(t)===pr(e)}catch{return!1}},ba=t=>(t==null?void 0:t.type)==="created",Sa=t=>(t==null?void 0:t.type)==="published";function Ci(t){return Array.isArray(t)}function fr(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function ji(t){return typeof t=="object"&&!Ci(t)&&!fr(t)}function Ta(t){return typeof t=="object"&&"id"in t}const Bi=16*1024,Ea=t=>I.ser("vector<u8>",t,{maxSize:Bi}).toBytes(),va=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||!fr(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return In(r.content.type)},Mi=async(t,e)=>{if(!oe(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return pn(r)},ka=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=pn(s);if(!i||!ji(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!fr(i.value))throw new Error("Unable to get package id");return i.value.fields.package},_a=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:d}=o.data;(n===null||u<n)&&(n=u,s=d)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},xa=async(t,e)=>{const r=new Ii,[n]=r.publish({modules:t.modules.map(s=>Array.from(An.decode(s))),dependencies:t.dependencies.map(s=>ce(s))});return r.transferObjects([n],r.pure(e)),r},Q=class Q extends On{constructor(e,r){super(e,r??Cn(e,Q._platform))}getRpc(e){if(e in this.config)return new Oi({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new gn(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 ${Ot}: ${r}`);return jn.tokenId(r,Bn)}static isNativeTokenId(e,r,n){return!Q.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return Mn(e)===Q._platform}static async getDecimals(e,r,n){if(lt(n))return Pn(Q._platform);const s=new Je(n);try{const a=await Mi(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 Je(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(lt(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{[lt(a)?"native":new Je(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=Rn(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)}};we(Q,"_platform",Ot);let De=Q;var ze={};Object.defineProperty(ze,"__esModule",{value:!0});ze.bech32m=Ct=ze.bech32=void 0;const ct="qpzry9x8gf2tvdw0s3jn54khce6mua7l",yn={};for(let t=0;t<ct.length;t++){const e=ct.charAt(t);yn[e]=t}function ke(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 Er(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=ke(e)^n>>5}e=ke(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=ke(e)^n&31}return e}function hr(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 Pi(t){return hr(t,8,5,!0)}function Ri(t){const e=hr(t,5,8,!1);if(Array.isArray(e))return e}function $i(t){const e=hr(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function mn(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 d=Er(a);if(typeof d=="string")throw new Error(d);let f=a+"1";for(let g=0;g<o.length;++g){const p=o[g];if(p>>5)throw new Error("Non 5-bit word");d=ke(d)^p,f+=ct.charAt(p)}for(let g=0;g<6;++g)d=ke(d);d^=e;for(let g=0;g<6;++g){const p=d>>(5-g)*5&31;f+=ct.charAt(p)}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(),d=a.toUpperCase();if(a!==u&&a!==d)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 g=a.slice(0,f),p=a.slice(f+1);if(p.length<6)return"Data too short";let y=Er(g);if(typeof y=="string")return y;const k=[];for(let S=0;S<p.length;++S){const j=p.charAt(S),M=yn[j];if(M===void 0)return"Unknown character "+j;y=ke(y)^M,!(S+6>=p.length)&&k.push(M)}return y!==e?"Invalid checksum for "+a:{prefix:g,words:k}}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:Pi,fromWordsUnsafe:Ri,fromWords:$i}}var Ct=ze.bech32=mn("bech32");ze.bech32m=mn("bech32m");var Ve=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))(Ve||{});function Ni(t){return[t,0,0]}function wn(t,e){const r=Ni(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const dt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},Ui={ED25519:32,Secp256k1:33,Secp256r1:33},Di={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function zi(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function Vi(t,e){const r=t.toString(16);return $n(r.padStart(e*2,"0").slice(-e*2))}function Li(t,e){const r=Vi(t,e),n=zi(r);return n===-1?new Uint8Array([0]):r.slice(n)}function qi(t,e){const r=Li(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([dt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),O(xr(Me(s,{dkLen:32})).slice(0,Mt*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 Fi(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 Ki(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=Fi(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),d=parseInt(u.join(""),2);i[a++]=d}return new TextDecoder().decode(i)}function Gi(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 Hi(t,e){const r=Ki(t.value,t.indexMod4),[n,s]=Gi(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const Zi=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 Ji(t){return Zi.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([dt[e]]),s.set(t,1),s.set(n,1+t.length),N(s)}function Yi(t){const e=H(t),r=Di[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}=Ji(s),{issBase64Details:u,addressSeed:d}=i,f=Hi(u,"iss"),g=qi(BigInt(d),f);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:f,address:g,addressSeed:BigInt(d)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const p=Ui[r],y=e.slice(1,e.length-p),k=e.slice(1+y.length);return{serializedSignature:t,signatureScheme:r,signature:y,publicKey:k,bytes:e};default:throw new Error("Unsupported signature scheme")}}const tt=32,Qi="suiprivkey";class ea{async signWithIntent(e,r){const n=wn(r,e),s=Me(n,{dkLen:32});return{signature:Xi({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:N(e)}}async signTransactionBlock(e){return this.signWithIntent(e,Ve.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(c.vector(c.u8()).serialize(e).toBytes(),Ve.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class ta extends ea{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function ra(t,e){if(t.length!==tt)throw new Error("Invalid bytes length");const r=dt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),Ct.encode(Qi,Ct.toWords(n))}function vr(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function na(t){return ns(t,"")}function sa(t){return me(na(t))}const ia="ed25519 seed",aa=2147483648,oa=new RegExp("^m(\\/[0-9]+')+$"),bn=t=>t.replace("'",""),ca=t=>{const r=Ir.create(Bt,ia).update(qe(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},ua=({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=Ir.create(Bt,e).update(i).digest(),o=a.slice(0,32),u=a.slice(32);return{key:o,chainCode:u}},da=t=>oa.test(t)?!t.split("/").slice(1).map(bn).some(isNaN):!1,kr=(t,e,r=aa)=>{if(!da(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=ca(e);return t.split("/").slice(1).map(bn).map(a=>parseInt(a,10)).reduce((a,o)=>ua(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 la{equals(e){return Sn(this.toRawBytes(),e.toRawBytes())}toBase64(){return N(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return N(e)}verifyWithIntent(e,r,n){const s=wn(n,e),i=Me(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(I.vector(I.u8()).serialize(e).toBytes(),r,Ve.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,Ve.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return O(xr(Me(this.toSuiBytes(),{dkLen:32})).slice(0,Mt*2))}}const jt=32;class Tn extends la{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!==jt)throw new Error(`Invalid public key input. Expected ${jt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return dt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=Yi(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 fe.sign.detached.verify(e,n,this.toRawBytes())}}Tn.SIZE=jt;const _r="m/44'/784'/0'/0'/0'";class Se extends ta{constructor(e){super(),e?this.keypair=e:this.keypair=fe.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Se(fe.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==tt)throw new Error(`Wrong secretKey size. Expected ${tt} bytes, got ${n}.`);const s=fe.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=fe.sign.detached(a,s.secretKey);if(!fe.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new Se(s)}getPublicKey(){return new Tn(this.keypair.publicKey)}getSecretKey(){return ra(this.keypair.secretKey.slice(0,tt),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return fe.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=_r),!vr(r))throw new Error("Invalid derivation path");const{key:n}=kr(r,sa(e));return Se.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=_r),!vr(r))throw new Error("Invalid derivation path");const{key:n}=kr(r,e);return Se.fromSecretKey(n)}}async function fa(t,e){const[,r]=await De.chainFromRpc(t);return new ha(r,t,Se.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class ha{constructor(e,r,n,s){we(this,"_chain");we(this,"_client");we(this,"_signer");we(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 ga={Address:Je,Platform:De,getSigner:fa,protocols:{WormholeCore:()=>yr(()=>import("./index-q0W2SHor.js"),__vite__mapDeps([0,1,2,3])),TokenBridge:()=>yr(()=>import("./index-CFYbGyvs.js"),__vite__mapDeps([4,1,2,0,3]))},getChain:(t,e,r)=>new gn(e,new De(t,Nn(t,Ot,{[e]:r})))},Ia=Object.freeze(Object.defineProperty({__proto__:null,default:ga},Symbol.toStringTag,{value:"Module"}));export{De as S,pn as a,fr as b,Sa as c,ba as d,wa as e,_a as f,Mi as g,ka as h,ji as i,va as j,Ta as k,xa as p,Ia as s,Ea as u};
6
+ Received: "${JSON.stringify(u)}"`);let g=Object.keys(u)[0];if(g===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let p=n.indexOf(g);if(p===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${g}"`);let y=n[p],k=r[y];if(o.write8(p),k===null)return o;let S=i.indexOf(k),j=S===-1?k:d[S];{let{name:M,params:se}=this.parseTypeName(j);return this.getTypeInterface(M)._encodeRaw.call(this,o,u[g],se,f)}},function(o,u,d){let f=o.readULEB(),g=n[f],p=r[g];if(f===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${f}"`);if(p===null)return{[g]:!0};let y=i.indexOf(p),k=y===-1?p:u[y];{let{name:S,params:j}=this.parseTypeName(k);return{[g]:this.getTypeInterface(S)._decodeRaw.call(this,o,j,d)}}})}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=Or(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let _=Ie;_.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 Gn(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(qe(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return me(new Uint8Array(r))}),t.registerType(_.BASE58,function(e,r){return e.writeVec(Array.from(ut(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return Le(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 N(new Uint8Array(r))})}function Hn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Kn,addressEncoding:"hex"}}class Zn 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 Jn(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 Xn(t){const{done:e,value:r}=t.next();return e?void 0:r}function Yn(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*mr(t,e,r,n){Jn(t)||(t=[t]);for(const s of t){const i=Yn(s,e,r,n);i&&(yield i)}}function*Nt(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 d in t)e.schema[d]===void 0&&delete t[d];let u="valid";for(const d of e.validator(t,o))d.explanation=r.message,u="not_valid",yield[d,void 0];for(let[d,f,g]of e.entries(t,o)){const p=Nt(f,g,{path:d===void 0?n:[...n,d],branch:d===void 0?s:[...s,f],coerce:i,mask:a,message:r.message});for(const y of p)y[0]?(u=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):i&&(f=y[1],d===void 0?t=f:t instanceof Map?t.set(d,f):t instanceof Set?t.add(f):V(t)&&(f!==void 0||d in t)&&(t[d]=f))}if(u!=="not_valid")for(const d of e.refiner(t,o))d.explanation=r.message,u="not_refined",yield[d,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,d)=>{const f=s(u,d);return mr(f,d,this,u)}:this.validator=()=>[],i?this.refiner=(u,d)=>{const f=i(u,d);return mr(f,d,this,u)}:this.refiner=()=>[]}assert(e,r){return bt(e,this,r)}create(e,r){return Pr(e,this,r)}is(e){return U(e,this)}mask(e,r){return Rr(e,this,r)}validate(e,r={}){return We(e,this,r)}}function bt(t,e,r){const n=We(t,e,{message:r});if(n[0])throw n[0]}function Pr(t,e,r){const n=We(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Rr(t,e,r){const n=We(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function U(t,e){return!We(t,e)[0]}function We(t,e,r={}){const n=Nt(t,e,r),s=Xn(n);return s[0]?[new Zn(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Pe(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?es(n):h(n)}function D(t,e){return new X({type:t,schema:null,validator:e})}function St(){return D("any",()=>!0)}function T(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 Qn(){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 w(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 $r(){return D("never",()=>!1)}function A(t){return new X({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function pe(){return D("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${L(t)}`)}function h(t){const e=t?Object.keys(t):[],r=$r();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 m(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 l(){return D("string",t=>typeof t=="string"||`Expected a string, but received: ${L(t)}`)}function Nr(t){const e=$r();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 es(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 C(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]=Nt(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 Ur(){return D("unknown",()=>!0)}/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */function Dr(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function ts(t){const e=Dr(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}const rs=t=>Dr(`mnemonic${t}`);function ns(t,e=""){return Un(Bt,ts(t).nfkd,rs(e),{c:2048,dkLen:64})}const ss="0.50.1",is="1.19.0",as={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class zr extends Error{}class Vr extends zr{constructor(e,r){super(e),this.code=r,this.type=as[r]??"ServerError"}}class os extends zr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var Ut=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},x=(t,e,r)=>(Ut(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)},Te=(t,e,r,n)=>(Ut(t,e,"write to private field"),e.set(t,r),r),cs=(t,e,r,n)=>({set _(s){Te(t,e,s)},get _(){return x(t,e,n)}}),Lr=(t,e,r)=>(Ut(t,e,"access private method"),r),he,je,ee,ge,Re,Ee,Tt,qr,Dt,Wr;function us(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const ds={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class ls{constructor(e,r={}){if(ie(this,Tt),ie(this,Dt),ie(this,he,0),ie(this,je,0),ie(this,ee,null),ie(this,ge,null),ie(this,Re,new Set),ie(this,Ee,new Map),this.endpoint=e,this.options={...ds,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=us(this.endpoint))}async makeRequest(e,r){const n=await Lr(this,Tt,qr).call(this);return new Promise((s,i)=>{Te(this,he,x(this,he)+1),x(this,Ee).set(x(this,he),{resolve:s,reject:i,timeout:setTimeout(()=>{x(this,Ee).delete(x(this,he)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:x(this,he),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new Vr(s.message,s.code);return i})}async subscribe(e){const r=new fs(e);return x(this,Re).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}he=new WeakMap;je=new WeakMap;ee=new WeakMap;ge=new WeakMap;Re=new WeakMap;Ee=new WeakMap;Tt=new WeakSet;qr=function(){return x(this,ge)?x(this,ge):(Te(this,ge,new Promise(t=>{var e;(e=x(this,ee))==null||e.close(),Te(this,ee,new this.options.WebSocketConstructor(this.endpoint)),x(this,ee).addEventListener("open",()=>{Te(this,je,0),t(x(this,ee))}),x(this,ee).addEventListener("close",()=>{cs(this,je)._++,x(this,je)<=this.options.maxReconnects&&setTimeout(()=>{Lr(this,Dt,Wr).call(this)},this.options.reconnectTimeout)}),x(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&&x(this,Ee).has(n.id)){const{resolve:s,timeout:i}=x(this,Ee).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;x(this,Re).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),x(this,ge))};Dt=new WeakSet;Wr=async function(){var t;return(t=x(this,ee))==null||t.close(),Te(this,ge,null),Promise.allSettled([...x(this,Re)].map(e=>e.subscribe(this)))};class fs{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 zt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},z=(t,e,r)=>(zt(t,e,"read from private field"),r?r.call(t):e.get(t)),Ke=(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)},Et=(t,e,r,n)=>(zt(t,e,"write to private field"),e.set(t,r),r),hs=(t,e,r)=>(zt(t,e,"access private method"),r),Ae,F,Be,vt,Fr;class gs{constructor(e){Ke(this,vt),Ke(this,Ae,0),Ke(this,F,void 0),Ke(this,Be,void 0),Et(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;Et(this,Ae,z(this,Ae)+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":ss,"Client-Target-Api-Version":is,...(i=z(this,F).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:z(this,Ae),method:e.method,params:e.params})});if(!r.ok)throw new os(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new Vr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await hs(this,vt,Fr).call(this).subscribe(e);return async()=>!!await r()}}Ae=new WeakMap;F=new WeakMap;Be=new WeakMap;vt=new WeakSet;Fr=function(){var t;if(!z(this,Be)){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.");Et(this,Be,new ls(((t=z(this,F).websocket)==null?void 0:t.url)??z(this,F).url,{WebSocketConstructor:e,...z(this,F).websocket}))}return z(this,Be)};const ps=/^vector<(.+)>$/,ys=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;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(ps);if(n)return{vector:te.parseFromStr(n[1],r)};const s=e.match(ys);if(s)return{struct:{address:r?O(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 Or(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 v=new _({...Hn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function Kr(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function ms(t){return c.enum("Option",{None:null,Some:t})}function Vt(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(Mt).transform({input:t=>typeof t=="string"?qe(O(t)):t,output:t=>O(me(t))}),Lt=c.vector(c.u8()).transform({name:"ObjectDigest",input:t=>ut(t),output:t=>Le(new Uint8Array(t))}),$e=c.struct("SuiObjectRef",{objectId:G,version:c.u64(),digest:Lt}),qt=c.struct("SharedObjectRef",{objectId:G,initialSharedVersion:c.u64(),mutable:c.bool()}),it=c.enum("ObjectArg",{ImmOrOwned:$e,Shared:qt,Receiving:$e}),Wt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:it,ObjVec:c.vector(it)}),_e=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>_e),struct:c.lazy(()=>Jt),u16:null,u32:null,u256:null}),q=Vt(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()})})),Ft=c.struct("ProgrammableMoveCall",{package:G,module:c.string(),function:c.string(),type_arguments:c.vector(_e),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:O(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)})}),Kt=Vt(c.enum("Transaction",{MoveCall:Ft,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:ms(_e),objects:c.vector(q)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G),packageId:G,ticket:q})})),Gt=c.struct("ProgrammableTransaction",{inputs:c.vector(Wt),transactions:c.vector(Kt)}),Ht=c.enum("TransactionKind",{ProgrammableTransaction:Gt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Zt=c.enum("TransactionExpiration",{None:null,Epoch:Kr()}),Jt=c.struct("StructTag",{address:G,module:c.string(),name:c.string(),typeParams:c.vector(_e)}),Xt=c.struct("GasData",{payment:c.vector($e),owner:G,price:c.u64(),budget:c.u64()}),Yt=c.struct("TransactionDataV1",{kind:Ht,sender:G,gasData:Xt,expiration:Zt}),Qt=c.enum("TransactionData",{V1:Yt}),ws=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),bs=c.enum("IntentVersion",{V0:null}),Ss=c.enum("AppId",{Sui:null}),Ts=c.struct("Intent",{scope:ws,version:bs,appId:Ss}),Es=c.generic(["T"],t=>c.struct("IntentMessage<T>",{intent:Ts,value:t})),er=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())}),tr=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())}),rr=c.struct("MultiSigPkMap",{pubKey:tr,weight:c.u8()}),nr=c.struct("MultiSigPublicKey",{pk_map:c.vector(rr),threshold:c.u16()}),Gr=c.struct("MultiSig",{sigs:c.vector(er),bitmap:c.u16(),multisig_pk:nr}),vs=c.vector(c.u8()).transform({input:t=>typeof t=="string"?H(t):t,output:t=>N(new Uint8Array(t))}),Hr=c.struct("SenderSignedTransaction",{intentMessage:Es(Qt),txSignatures:c.vector(vs)}),Zr=c.vector(Hr,{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:Wt,CompressedSignature:er,GasData:Xt,MultiSig:Gr,MultiSigPkMap:rr,MultiSigPublicKey:nr,ObjectArg:it,ObjectDigest:Lt,ProgrammableMoveCall:Ft,ProgrammableTransaction:Gt,PublicKey:tr,SenderSignedData:Zr,SenderSignedTransaction:Hr,SharedObjectRef:qt,StructTag:Jt,SuiObjectRef:$e,Transaction:Kt,TransactionData:Qt,TransactionDataV1:Yt,TransactionExpiration:Zt,TransactionKind:Ht,TypeTag:_e,ser:v.ser.bind(v),de:v.de.bind(v),getTypeInterface:v.getTypeInterface.bind(v),hasType:v.hasType.bind(v),parseTypeName:v.parseTypeName.bind(v),registerAddressType:v.registerAddressType.bind(v),registerAlias:v.registerAlias.bind(v),registerBcsType:v.registerBcsType.bind(v),registerEnumType:v.registerEnumType.bind(v),registerStructType:v.registerStructType.bind(v),registerType:v.registerType.bind(v),types:v.types};v.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));v.registerBcsType("unsafe_u64",()=>Kr());v.registerBcsType("enumKind",t=>Vt(t));[G,q,Wt,er,Xt,Gr,rr,nr,it,Lt,Ft,Gt,tr,Zr,qt,Jt,$e,Kt,Qt,Yt,Zt,Ht,_e].forEach(t=>{v.registerBcsType(t.name,()=>t)});const sr=C([h({AddressOwner:l()}),h({ObjectOwner:l()}),h({Shared:h({initial_shared_version:A(l())})}),w("Immutable")]);D("SuiJsonValue",()=>!0);const ks=C([h({u32:l()}),h({u64:l()}),h({f64:l()})]);h({attributes:Z(l(),A(ks)),featureFlags:Z(l(),P()),maxSupportedProtocolVersion:l(),minSupportedProtocolVersion:l(),protocolVersion:l()});C([l(),w("package")]);const ue=h({digest:l(),objectId:l(),version:C([pe(),l(),Qn()])});h({owner:sr,reference:ue});h({objectId:l(),sequenceNumber:l()});h({payment:T(ue),owner:l(),price:l(),budget:l()});const _s=Pe(ue,h({type:l(),owner:sr,previousTransaction:l()})),xs=Z(l(),St()),Is=Z(l(),Ur()),As=h({type:l(),fields:xs,hasPublicTransfer:P()}),Os=h({disassembled:Is}),Cs=C([Pe(As,h({dataType:w("moveObject")})),Pe(Os,h({dataType:w("package")}))]),js=h({type:l(),hasPublicTransfer:P(),version:l(),bcsBytes:l()}),Bs=h({id:l(),moduleMap:Z(l(),l())}),Ms=C([Pe(js,h({dataType:w("moveObject")})),Pe(Bs,h({dataType:w("package")}))]);BigInt(1e9);const Jr=h({code:l(),error:m(l()),object_id:m(l()),parent_object_id:m(l()),version:m(l()),digest:m(l())}),Ps=h({data:A(m(Z(l(),l()))),error:A(m(Jr))}),Rs=C([Ps,m(Z(l(),l()))]),Xr=h({objectId:l(),version:l(),digest:l(),type:A(m(l())),content:A(m(Cs)),bcs:A(m(Ms)),owner:A(m(sr)),previousTransaction:A(m(l())),storageRebate:A(m(l())),display:A(m(Rs))});h({showType:A(m(P())),showContent:A(m(P())),showBcs:A(m(P())),showOwner:A(m(P())),showPreviousTransaction:A(m(P())),showStorageRebate:A(m(P())),showDisplay:A(m(P()))});C([w("Exists"),w("notExists"),w("Deleted")]);T(_s);const $s=h({data:A(m(Xr)),error:A(m(Jr))});function Ns(t){return t.data}function Us(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 wr(t){if("reference"in t)return t.reference;const e=Ns(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:Us(t)}h({objectId:l(),atCheckpoint:m(pe())});h({data:T($s),nextCursor:m(A(l())),hasNextPage:P()});C([h({details:Xr,status:w("VersionFound")}),h({details:l(),status:w("ObjectNotExists")}),h({details:ue,status:w("ObjectDeleted")}),h({details:Nr([l(),pe()]),status:w("VersionNotFound")}),h({details:h({asked_version:pe(),latest_version:pe(),object_id:l()}),status:w("VersionTooHigh")})]);const Ds=C([l(),h({Object:l()})]);T(Ds);const zs=h({address:l(),name:l()}),Vs=C([w("Private"),w("Public"),w("Friend")]),ir=h({abilities:T(l())}),Ls=h({constraints:ir,isPhantom:P()}),qs=h({TypeParameter:pe()}),yt=Nr([h({module:l(),package:l(),function:l()}),l()]);h({rank3Days:T(yt),rank7Days:T(yt),rank30Days:T(yt)});function Yr(t){if(!t)return!1;if(typeof t=="string"||U(t,qs)||Qr(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(U(e.Reference,ve)||U(e.MutableReference,ve)||U(e.Vector,ve))}const ve=D("SuiMoveNormalizedType",Yr);function Qr(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=>Yr(n)))}D("SuiMoveNormalizedStructType",Qr);const Ws=h({visibility:Vs,isEntry:P(),typeParameters:T(ir),parameters:T(ve),return:T(ve)}),Fs=h({name:l(),type:ve}),Ks=h({abilities:ir,typeParameters:T(Ls),fields:T(Fs)}),Gs=h({fileFormatVersion:pe(),address:l(),name:l(),friends:T(zs),structs:Z(l(),Ks),exposedFunctions:Z(l(),Ws)});Z(l(),Gs);function kt(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function en(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function ar(t){if(typeof t=="object"&&"Struct"in t)return t;const e=en(t),r=kt(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const Hs=C([h({ImmOrOwned:ue}),h({Shared:h({objectId:l(),initialSharedVersion:C([J(),l()]),mutable:P()})}),h({Receiving:ue})]),at=h({Pure:T(J())}),_t=h({Object:Hs}),ot=C([at,_t]);function Zs(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:$t(t)?t.toBytes():I.ser(e,t,{maxSize:1/0}).toBytes())}}const $={Pure:Zs,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:O(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:O(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:O(t)}}}}};function br(t){return typeof t=="string"?O(t):"ImmOrOwned"in t.Object?O(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?O(t.Object.Receiving.objectId):O(t.Object.Shared.objectId)}function Js(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function Xs(t){var e;return((e=Js(t))==null?void 0:e.mutable)??!1}function Ys(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 Qs="object",ei="ID",ti="ascii",ri="String",ni="string",si="String",ii="option",ai="Option",oi={address:kn,module:Qs,name:ei},ci={address:Pt,module:ti,name:ri},ui={address:Pt,module:ni,name:si},di={address:Pt,module:ii,name:ai},Ge=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function li(t){var r;const e=(r=ar(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 mt(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const fi=["Address","Bool","U8","U16","U32","U64","U128","U256"];function xt(t,e){if(typeof t=="string"&&fi.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])mt("number",e);else if(t==="Bool")mt("boolean",e);else if(t==="Address"&&(mt("string",e),e&&!oe(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=xt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(Ge(t.Struct,ci))return"string";if(Ge(t.Struct,ui))return"utf8string";if(Ge(t.Struct,oi))return"address";if(Ge(t.Struct,di)){const r={Vector:t.Struct.typeArguments[0]};return xt(r,e)}}}function hi(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),Me(n,{dkLen:32})}function R(t,e){return Pr(t,e)}const gi=t=>C([h({None:C([w(!0),w(null)])}),h({Some:t})]),Ne=C([h({kind:w("Input"),index:J(),value:m(St()),type:m(w("object"))}),h({kind:w("Input"),index:J(),value:m(St()),type:w("pure")})]),pi=[Ne,h({kind:w("GasCoin")}),h({kind:w("Result"),index:J()}),h({kind:w("NestedResult"),index:J(),resultIndex:J()})],ne=C([...pi]),tn=h({kind:w("MoveCall"),target:D("target",l().validator),typeArguments:T(l()),arguments:T(ne)}),rn=h({kind:w("TransferObjects"),objects:T(ne),address:ne}),nn=h({kind:w("SplitCoins"),coin:ne,amounts:T(ne)}),sn=h({kind:w("MergeCoins"),destination:ne,sources:T(ne)}),an=h({kind:w("MakeMoveVec"),type:m(gi(Z(l(),Ur()))),objects:T(ne)}),on=h({kind:w("Publish"),modules:T(T(J())),dependencies:T(l())}),cn=h({kind:w("Upgrade"),modules:T(T(J())),dependencies:T(l()),packageId:l(),ticket:ne}),yi=[tn,rn,nn,sn,on,cn,an],mi=C([...yi]),le={MoveCall(t){return R({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},tn)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=$.Pure(I.Address.serialize(e.value))),R({kind:"TransferObjects",objects:t,address:e},rn)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=$.Pure(I.U64.serialize(r.value)))}),R({kind:"SplitCoins",coin:t,amounts:e},nn)},MergeCoins(t,e){return R({kind:"MergeCoins",destination:t,sources:e},sn)},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=>ce(r))},on)},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=>ce(s)),packageId:r,ticket:n},cn)},MakeMoveVec({type:t,objects:e}){return R({kind:"MakeMoveVec",type:t?{Some:te.parseFromStr(t)}:{None:null},objects:e},an)}},wi=m(A(C([h({Epoch:J()}),h({None:C([w(!0),w(null)])})]))),Sr=D("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),bi=h({budget:m(Sr),price:m(Sr),payment:m(T(ue)),owner:m(l())}),He=h({version:w(1),sender:m(l()),expiration:wi,gasConfig:bi,inputs:T(Ne),transactions:T(mi)});function Tr(t){return O(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,at)?"pure":"object"},Ne)),transactions:n.transactions},He);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,at)?"pure":"object"},Ne)),transactions:s.transactions},He);return re.restore(i)}static restore(e){bt(e,He);const r=new re;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=hi("TransactionData",e);return Le(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(f=>(bt(f.value,ot),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 d={sender:Tr(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:Tr(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return I.TransactionData.serialize({V1:d},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return re.getDigestFromBytes(e)}snapshot(){return R(this,He)}}var or=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},E=(t,e,r)=>(or(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)},Ze=(t,e,r,n)=>(or(t,e,"write to private field"),e.set(t,r),r),B=(t,e,r)=>(or(t,e,"access private method"),r),b,Oe,Ye,Ce,Qe,de,ye,cr,un,ur,dn,dr,ln,lr,fn,et,It;const Si={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function Ti(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 Ei(t){const e=ar(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Ue(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 hn=Symbol.for("@mysten/transaction"),wt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},vi=1000n,ki=50,_i=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function xi(t){return!!t&&typeof t=="object"&&t[hn]===!0}const At=class{constructor(t){Y(this,Oe),Y(this,Ce),Y(this,de),Y(this,cr),Y(this,ur),Y(this,dr),Y(this,lr),Y(this,et),Y(this,b,void 0),Ze(this,b,new re(t?t.blockData:void 0))}static fromKind(t){const e=new At;return Ze(e,b,re.fromKindBytes(typeof t=="string"?H(t):t)),e}static from(t){const e=new At;return typeof t!="string"||!t.startsWith("{")?Ze(e,b,re.fromBytes(typeof t=="string"?H(t):t)):Ze(e,b,re.restore(JSON.parse(t))),e}setSender(t){E(this,b).sender=t}setSenderIfNotSet(t){E(this,b).sender||(E(this,b).sender=t)}setExpiration(t){E(this,b).expiration=t}setGasPrice(t){E(this,b).gasConfig.price=String(t)}setGasBudget(t){E(this,b).gasConfig.budget=String(t)}setGasOwner(t){E(this,b).gasConfig.owner=t}setGasPayment(t){E(this,b).gasConfig.payment=t.map(e=>Rr(e,ue))}get blockData(){return E(this,b).snapshot()}get[hn](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:Ys((t,e)=>$t(t)?B(this,Oe,Ye).call(this,"pure",{Pure:Array.from(t.toBytes())}):B(this,Oe,Ye).call(this,"pure",t instanceof Uint8Array?$.Pure(t):e?$.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=br(t),r=E(this,b).inputs.find(n=>n.type==="object"&&e===br(n.value));return r&&U(r.value,_t)&&"Shared"in r.value.Object&&U(t,_t)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??B(this,Oe,Ye).call(this,"object",typeof t=="string"?O(t):t)}objectRef(...t){return this.object($.ObjectRef(...t))}receivingRef(...t){return this.object($.ReceivingRef(...t))}sharedObjectRef(...t){return this.object($.SharedObjectRef(...t))}add(t){const e=E(this,b).transactions.push(t);return Ti(e-1)}splitCoins(t,e){return this.add(le.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,Ce,Qe).call(this,r))))}mergeCoins(t,e){return this.add(le.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(le.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(le.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(le.MoveCall({arguments:t==null?void 0:t.map(n=>B(this,Ce,Qe).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(le.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):B(this,Ce,Qe).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(le.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(E(this,b).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,et,It).call(this,t),E(this,b).build({maxSizeBytes:B(this,de,ye).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await B(this,et,It).call(this,t),E(this,b).getDigest()}};let Ii=At;b=new WeakMap;Oe=new WeakSet;Ye=function(t,e){const r=E(this,b).inputs.length,n=R({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Ne);return E(this,b).inputs.push(n),n};Ce=new WeakSet;Qe=function(t){return $t(t)?this.pure(t):t};de=new WeakSet;ye=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return Si[t];const n=e==null?void 0:e.attributes[wt[t]];if(!n)throw new Error(`Missing expected protocol config: "${wt[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: "${wt[t]}"`);return Number(s)};cr=new WeakSet;un=function(t){const e=B(this,de,ye).call(this,"maxPureArgumentSize",t);E(this,b).inputs.forEach((r,n)=>{if(U(r.value,at)&&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`)})};ur=new WeakSet;dn=async function(t){if(E(this,b).gasConfig.payment){const s=B(this,de,ye).call(this,"maxGasObjects",t);if(E(this,b).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||E(this,b).gasConfig.payment)return;const e=E(this,b).gasConfig.owner??E(this,b).sender,n=(await Ue(t).getCoins({owner:e,coinType:_n})).data.filter(s=>!E(this,b).inputs.find(a=>U(a.value,ot)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,B(this,de,ye).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)};dr=new WeakSet;ln=async function(t){t.onlyTransactionKind||E(this,b).gasConfig.price||this.setGasPrice(await Ue(t).getReferenceGasPrice())};lr=new WeakSet;fn=async function(t){const{inputs:e,transactions:r}=E(this,b),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:O(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!U(e[o.index].value,ot))&&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=$.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=$.Pure(I.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,u]=i.target.split("::"),d=await Ue(t).getNormalizedMoveFunction({package:ce(a),module:o,function:u}),g=d.parameters.length>0&&li(d.parameters.at(-1))?d.parameters.slice(0,d.parameters.length-1):d.parameters;if(g.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");g.forEach((p,y)=>{const k=i.arguments[y];if(k.kind!=="Input")return;const S=e[k.index];if(U(S.value,ot))return;const j=S.value,M=xt(p,j);if(M){S.value=$.Pure(j,M);return}if(ar(p)!=null||typeof p=="object"&&"TypeParameter"in p){if(typeof j!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(j,null,2)}`);s.push({id:j,input:S,normalizedType:p});return}throw new Error(`Unknown call arg type ${JSON.stringify(p,null,2)} for value ${JSON.stringify(j,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:f})=>f))],a=_i(i,ki),o=(await Promise.all(a.map(f=>Ue(t).multiGetObjects({ids:f,options:{showOwner:!0}})))).flat();let u=new Map(i.map((f,g)=>[f,o[g]]));const d=Array.from(u).filter(([f,g])=>g.error).map(([f,g])=>f);if(d.length)throw new Error(`The following input objects are invalid: ${d.join(", ")}`);s.forEach(({id:f,input:g,normalizedType:p})=>{var j;const y=u.get(f),k=(j=y.data)==null?void 0:j.owner,S=k&&typeof k=="object"&&"Shared"in k?k.Shared.initial_shared_version:void 0;if(S){const M=p!=null&&kt(p)==null&&en(p)==null,se=Xs(g.value)||M||p!=null&&kt(p)!=null;g.value=$.SharedObjectRef({objectId:f,initialSharedVersion:S,mutable:se})}else p&&Ei(p)?g.value=$.ReceivingRef(wr(y)):g.value=$.ObjectRef(wr(y))})}};et=new WeakSet;It=async function(t){if(!t.onlyTransactionKind&&!E(this,b).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,dr,ln).call(this,t),B(this,lr,fn).call(this,t)]),!t.onlyTransactionKind&&(await B(this,ur,dn).call(this,t),!E(this,b).gasConfig.budget)){const e=await Ue(t).dryRunTransactionBlock({transactionBlock:E(this,b).build({maxSizeBytes:B(this,de,ye).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(B(this,de,ye).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=vi*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,cr,un).call(this,t)};const Ai=Symbol.for("@mysten/SuiClient");class Oi{get[Ai](){return!0}constructor(e){this.transport=e.transport??new gs({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!oe(O(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||!oe(O(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||!oe(O(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||!oe(O(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||!oe(O(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||!Fe(ce(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||!Fe(ce(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(!gr(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(!gr(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:N(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||!oe(O(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||!Fe(ce(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(xi(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=N(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=N(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:N(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!Fe(ce(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=ut(e.digest);return me(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 gn extends xn{}const Ot="Sui",pn=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},wa=(t,e)=>{try{return pr(t)===pr(e)}catch{return!1}},ba=t=>(t==null?void 0:t.type)==="created",Sa=t=>(t==null?void 0:t.type)==="published";function Ci(t){return Array.isArray(t)}function fr(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function ji(t){return typeof t=="object"&&!Ci(t)&&!fr(t)}function Ta(t){return typeof t=="object"&&"id"in t}const Bi=16*1024,Ea=t=>I.ser("vector<u8>",t,{maxSize:Bi}).toBytes(),va=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||!fr(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return In(r.content.type)},Mi=async(t,e)=>{if(!oe(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return pn(r)},ka=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=pn(s);if(!i||!ji(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!fr(i.value))throw new Error("Unable to get package id");return i.value.fields.package},_a=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:d}=o.data;(n===null||u<n)&&(n=u,s=d)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},xa=async(t,e)=>{const r=new Ii,[n]=r.publish({modules:t.modules.map(s=>Array.from(An.decode(s))),dependencies:t.dependencies.map(s=>ce(s))});return r.transferObjects([n],r.pure(e)),r},Q=class Q extends On{constructor(e,r){super(e,r??Cn(e,Q._platform))}getRpc(e){if(e in this.config)return new Oi({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new gn(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 ${Ot}: ${r}`);return jn.tokenId(r,Bn)}static isNativeTokenId(e,r,n){return!Q.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return Mn(e)===Q._platform}static async getDecimals(e,r,n){if(lt(n))return Pn(Q._platform);const s=new Je(n);try{const a=await Mi(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 Je(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(lt(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{[lt(a)?"native":new Je(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=Rn(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)}};we(Q,"_platform",Ot);let De=Q;var ze={};Object.defineProperty(ze,"__esModule",{value:!0});ze.bech32m=Ct=ze.bech32=void 0;const ct="qpzry9x8gf2tvdw0s3jn54khce6mua7l",yn={};for(let t=0;t<ct.length;t++){const e=ct.charAt(t);yn[e]=t}function ke(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 Er(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=ke(e)^n>>5}e=ke(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=ke(e)^n&31}return e}function hr(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 Pi(t){return hr(t,8,5,!0)}function Ri(t){const e=hr(t,5,8,!1);if(Array.isArray(e))return e}function $i(t){const e=hr(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function mn(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 d=Er(a);if(typeof d=="string")throw new Error(d);let f=a+"1";for(let g=0;g<o.length;++g){const p=o[g];if(p>>5)throw new Error("Non 5-bit word");d=ke(d)^p,f+=ct.charAt(p)}for(let g=0;g<6;++g)d=ke(d);d^=e;for(let g=0;g<6;++g){const p=d>>(5-g)*5&31;f+=ct.charAt(p)}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(),d=a.toUpperCase();if(a!==u&&a!==d)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 g=a.slice(0,f),p=a.slice(f+1);if(p.length<6)return"Data too short";let y=Er(g);if(typeof y=="string")return y;const k=[];for(let S=0;S<p.length;++S){const j=p.charAt(S),M=yn[j];if(M===void 0)return"Unknown character "+j;y=ke(y)^M,!(S+6>=p.length)&&k.push(M)}return y!==e?"Invalid checksum for "+a:{prefix:g,words:k}}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:Pi,fromWordsUnsafe:Ri,fromWords:$i}}var Ct=ze.bech32=mn("bech32");ze.bech32m=mn("bech32m");var Ve=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))(Ve||{});function Ni(t){return[t,0,0]}function wn(t,e){const r=Ni(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const dt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},Ui={ED25519:32,Secp256k1:33,Secp256r1:33},Di={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function zi(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function Vi(t,e){const r=t.toString(16);return $n(r.padStart(e*2,"0").slice(-e*2))}function Li(t,e){const r=Vi(t,e),n=zi(r);return n===-1?new Uint8Array([0]):r.slice(n)}function qi(t,e){const r=Li(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([dt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),O(xr(Me(s,{dkLen:32})).slice(0,Mt*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 Fi(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 Ki(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=Fi(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),d=parseInt(u.join(""),2);i[a++]=d}return new TextDecoder().decode(i)}function Gi(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 Hi(t,e){const r=Ki(t.value,t.indexMod4),[n,s]=Gi(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const Zi=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 Ji(t){return Zi.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([dt[e]]),s.set(t,1),s.set(n,1+t.length),N(s)}function Yi(t){const e=H(t),r=Di[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}=Ji(s),{issBase64Details:u,addressSeed:d}=i,f=Hi(u,"iss"),g=qi(BigInt(d),f);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:f,address:g,addressSeed:BigInt(d)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const p=Ui[r],y=e.slice(1,e.length-p),k=e.slice(1+y.length);return{serializedSignature:t,signatureScheme:r,signature:y,publicKey:k,bytes:e};default:throw new Error("Unsupported signature scheme")}}const tt=32,Qi="suiprivkey";class ea{async signWithIntent(e,r){const n=wn(r,e),s=Me(n,{dkLen:32});return{signature:Xi({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:N(e)}}async signTransactionBlock(e){return this.signWithIntent(e,Ve.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(c.vector(c.u8()).serialize(e).toBytes(),Ve.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class ta extends ea{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function ra(t,e){if(t.length!==tt)throw new Error("Invalid bytes length");const r=dt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),Ct.encode(Qi,Ct.toWords(n))}function vr(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function na(t){return ns(t,"")}function sa(t){return me(na(t))}const ia="ed25519 seed",aa=2147483648,oa=new RegExp("^m(\\/[0-9]+')+$"),bn=t=>t.replace("'",""),ca=t=>{const r=Ir.create(Bt,ia).update(qe(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},ua=({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=Ir.create(Bt,e).update(i).digest(),o=a.slice(0,32),u=a.slice(32);return{key:o,chainCode:u}},da=t=>oa.test(t)?!t.split("/").slice(1).map(bn).some(isNaN):!1,kr=(t,e,r=aa)=>{if(!da(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=ca(e);return t.split("/").slice(1).map(bn).map(a=>parseInt(a,10)).reduce((a,o)=>ua(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 la{equals(e){return Sn(this.toRawBytes(),e.toRawBytes())}toBase64(){return N(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return N(e)}verifyWithIntent(e,r,n){const s=wn(n,e),i=Me(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(I.vector(I.u8()).serialize(e).toBytes(),r,Ve.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,Ve.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return O(xr(Me(this.toSuiBytes(),{dkLen:32})).slice(0,Mt*2))}}const jt=32;class Tn extends la{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!==jt)throw new Error(`Invalid public key input. Expected ${jt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return dt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=Yi(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 fe.sign.detached.verify(e,n,this.toRawBytes())}}Tn.SIZE=jt;const _r="m/44'/784'/0'/0'/0'";class Se extends ta{constructor(e){super(),e?this.keypair=e:this.keypair=fe.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Se(fe.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==tt)throw new Error(`Wrong secretKey size. Expected ${tt} bytes, got ${n}.`);const s=fe.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=fe.sign.detached(a,s.secretKey);if(!fe.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new Se(s)}getPublicKey(){return new Tn(this.keypair.publicKey)}getSecretKey(){return ra(this.keypair.secretKey.slice(0,tt),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return fe.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=_r),!vr(r))throw new Error("Invalid derivation path");const{key:n}=kr(r,sa(e));return Se.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=_r),!vr(r))throw new Error("Invalid derivation path");const{key:n}=kr(r,e);return Se.fromSecretKey(n)}}async function fa(t,e){const[,r]=await De.chainFromRpc(t);return new ha(r,t,Se.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class ha{constructor(e,r,n,s){we(this,"_chain");we(this,"_client");we(this,"_signer");we(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 ga={Address:Je,Platform:De,getSigner:fa,protocols:{WormholeCore:()=>yr(()=>import("./index-YIP9QK2L.js"),__vite__mapDeps([0,1,2,3])),TokenBridge:()=>yr(()=>import("./index-xo-ROtuF.js"),__vite__mapDeps([4,1,2,0,3]))},getChain:(t,e,r)=>new gn(e,new De(t,Nn(t,Ot,{[e]:r})))},Ia=Object.freeze(Object.defineProperty({__proto__:null,default:ga},Symbol.toStringTag,{value:"Module"}));export{De as S,pn as a,fr as b,Sa as c,ba as d,wa as e,_a as f,Mi as g,ka as h,ji as i,va as j,Ta as k,xa as p,Ia as s,Ea as u};
@@ -1 +1 @@
1
- var o=Object.defineProperty;var c=(t,a,e)=>a in t?o(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e;var s=(t,a,e)=>c(t,typeof a!="symbol"?a+"":a,e);import{a1 as l,C as m,a2 as u}from"./cosmwasm-B8f9g9-e.js";import{de as d,df as f,dg as g,a_ as p}from"../main.js";function h(t,a){let e=d.get(t,a);return e||(e="0.1"),l.calculateFee(f*1.5,`${e}${m.getNativeDenom(t,a)}`)}function T(t,a,e,r){return{typeUrl:g,value:u.MsgExecuteContract.fromPartial({sender:t,contract:a,msg:p.encode(JSON.stringify(e)),funds:r})}}class _{constructor(a,e,r,i,n=!1){s(this,"transaction");s(this,"network");s(this,"chain");s(this,"description");s(this,"parallelizable");this.transaction=a,this.network=e,this.chain=r,this.description=i,this.parallelizable=n}}export{_ as C,T as b,h as c};
1
+ var o=Object.defineProperty;var c=(t,a,e)=>a in t?o(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e;var s=(t,a,e)=>c(t,typeof a!="symbol"?a+"":a,e);import{a1 as l,C as m,a2 as u}from"./cosmwasm-Bb55TeV-.js";import{de as d,df as f,dg as g,a$ as p}from"../main.js";function h(t,a){let e=d.get(t,a);return e||(e="0.1"),l.calculateFee(f*1.5,`${e}${m.getNativeDenom(t,a)}`)}function T(t,a,e,r){return{typeUrl:g,value:u.MsgExecuteContract.fromPartial({sender:t,contract:a,msg:p.encode(JSON.stringify(e)),funds:r})}}class F{constructor(a,e,r,i,n=!1){s(this,"transaction");s(this,"network");s(this,"chain");s(this,"description");s(this,"parallelizable");this.transaction=a,this.network=e,this.chain=r,this.description=i,this.parallelizable=n}}export{F as C,T as b,h as c};