@wormhole-foundation/wormhole-connect 2.2.0-beta.0-development → 2.2.0-beta.1-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 (79) hide show
  1. package/dist/main.js +3 -3
  2. package/dist/src/hooks/useFetchSupportedRoutes.d.ts.map +1 -1
  3. package/lib/{aptos-S7qfk4eF.js → aptos-31PA2rFX.js} +2 -2
  4. package/lib/{aptos-DCqU4gTT.js → aptos-B8jsnVoS.js} +1 -1
  5. package/lib/{aptos-C2ziOmGF.mjs → aptos-CCgGvZjs.mjs} +5 -5
  6. package/lib/{aptos-CWV_-hYv.mjs → aptos-DVYbmFJJ.mjs} +2 -2
  7. package/lib/{base64-0sjqFKVy.js → base64-5kcPH2Ry.js} +1 -1
  8. package/lib/{base64-BQzK72Or.mjs → base64-CL9tkFGP.mjs} +1 -1
  9. package/lib/{ccip-izvu-uQb.js → ccip--zj9SMHN.js} +1 -1
  10. package/lib/{ccip-CinZc0eB.mjs → ccip-javMNNCd.mjs} +1 -1
  11. package/lib/{chunk-IMTC3J2M-B9Gs0lA6.js → chunk-IMTC3J2M-BcLXY1O4.js} +1 -1
  12. package/lib/{chunk-IMTC3J2M-DLSLeYCs.mjs → chunk-IMTC3J2M-DeAwWSAu.mjs} +3 -3
  13. package/lib/{events-CHPwOTnS.mjs → events-BIr0rmUF.mjs} +1 -1
  14. package/lib/{events-1FQ3eltE.js → events-ZTJJzzwL.js} +1 -1
  15. package/lib/{evm-ChjeT84k.mjs → evm-BdJvPk3J.mjs} +5 -5
  16. package/lib/{evm-Ct70o4qq.js → evm-BmG93aNU.js} +3 -3
  17. package/lib/{evm-DM3ptAm5.mjs → evm-CYdShX9n.mjs} +5 -5
  18. package/lib/{evm-CufYMX4l.js → evm-DWNU26Tx.js} +1 -1
  19. package/lib/{index-kq3hfwzK.mjs → index-B39ftYxK.mjs} +4 -4
  20. package/lib/{index-DycMfdxo.mjs → index-BUHmIbm1.mjs} +2 -2
  21. package/lib/{index-qLtfrTA8.js → index-BbiyKg6p.js} +1 -1
  22. package/lib/{index-VyhZwUqP.mjs → index-BhqFkgz5.mjs} +2 -2
  23. package/lib/{index-DIb3pG-F.mjs → index-Bn7RXnWl.mjs} +2 -2
  24. package/lib/{index-B8ce-3i8.js → index-C0yUUgWL.js} +1 -1
  25. package/lib/{index-BjNWK8dQ.js → index-C89319ht.js} +1 -1
  26. package/lib/{index-DZUvAczP.js → index-CGCa-j7o.js} +1 -1
  27. package/lib/{index-B01sYhft.js → index-CGW6Ztd2.js} +1 -1
  28. package/lib/{index-DI-HM1Ot.mjs → index-CLGrfUbL.mjs} +2 -2
  29. package/lib/{index-BmJv4bHO.js → index-CMzehyQ8.js} +1 -1
  30. package/lib/{index-BbOEOMF9.mjs → index-CNRoD0cV.mjs} +90 -68
  31. package/lib/{index-eb1ZkXTw.mjs → index-Ck1M3TS1.mjs} +2 -2
  32. package/lib/{index-CoJbWKE6.mjs → index-Co3Xxu9O.mjs} +2 -2
  33. package/lib/{index-BrmHiqtc.mjs → index-CtfLRYM0.mjs} +2 -2
  34. package/lib/{index-tNClJ60p.js → index-CvDrTlD5.js} +1 -1
  35. package/lib/{index-CkX5tNYL.js → index-D0onBS9d.js} +1 -1
  36. package/lib/{index-BwQVNtKZ.mjs → index-DCC8GaVH.mjs} +2 -2
  37. package/lib/{index-wAvhmkLB.mjs → index-DGB2Fxry.mjs} +2 -2
  38. package/lib/{index-CFgXIz60.js → index-DOGZjt2S.js} +8 -8
  39. package/lib/{index-DfB5v4ik.mjs → index-DUaJiMqI.mjs} +3 -3
  40. package/lib/{index-DVSVBn4-.js → index-DWtG2bDp.js} +1 -1
  41. package/lib/{index-CAPrmxTu.mjs → index-DYiI6lkY.mjs} +1 -1
  42. package/lib/{index-f7DJpJiE.js → index-D_2bb1Pv.js} +1 -1
  43. package/lib/{index-C7CP__nZ.mjs → index-D_elFvDQ.mjs} +1 -1
  44. package/lib/{index-BmyyJYRn.mjs → index-DdvuhkPU.mjs} +1 -1
  45. package/lib/{index-xSmtZZwu.js → index-Dg_F5gMq.js} +1 -1
  46. package/lib/{index-j3KJk58s.mjs → index-Dsfz-oia.mjs} +3 -3
  47. package/lib/{index-C21geUZs.js → index-DvkkJ_AY.js} +1 -1
  48. package/lib/{index-BmwpYJH0.mjs → index-SEUn7gSU.mjs} +1 -1
  49. package/lib/{index-R4BZ1VCa.js → index-Upxa6-Ok.js} +1 -1
  50. package/lib/{index-Bl_-2Jvy.mjs → index-YTBFGtnw.mjs} +1 -1
  51. package/lib/{index-BCqJU6-4.js → index-ZSnwMbPW.js} +1 -1
  52. package/lib/{index-zLAF1Ksq.js → index-ZjwERA88.js} +1 -1
  53. package/lib/{index-Bm760kIP.mjs → index-cugw_66S.mjs} +1 -1
  54. package/lib/{index-C6_DBqBu.js → index-gdamBcoQ.js} +1 -1
  55. package/lib/{index-BEDagXR8.js → index-i9soDbgm.js} +1 -1
  56. package/lib/{index-GCg7snms.mjs → index-kwKTcApr.mjs} +5 -5
  57. package/lib/{index-COebbG0T.js → index-rzStwWOM.js} +1 -1
  58. package/lib/{index-48ExAZK2.mjs → index-x4yUWfDi.mjs} +1 -1
  59. package/lib/{index-BvZJV-Fm.js → index-xI8bbCGj.js} +1 -1
  60. package/lib/{index-Cnr4jKbe.js → index-yQD0Xsib.js} +1 -1
  61. package/lib/{index.es-Cvjdc21H.mjs → index.es-Cw1Vg7NX.mjs} +6 -6
  62. package/lib/{index.es-BURMeB7M.js → index.es-D1p0ce-Y.js} +2 -2
  63. package/lib/index.js +1 -1
  64. package/lib/index.mjs +1 -1
  65. package/lib/{signer-BclsiSRH.js → signer-C1_tDQTi.js} +1 -1
  66. package/lib/{signer-Bpst1zw_.mjs → signer-C4Jm9zsl.mjs} +1 -1
  67. package/lib/{solana-C4YIunl-.mjs → solana--vtCR0-G.mjs} +4 -4
  68. package/lib/{solana-CD0Aufq1.js → solana-BtM4z8cN.js} +1 -1
  69. package/lib/solana-LXeQ1tV1.js +1 -0
  70. package/lib/{solana-CoaPC8s6.mjs → solana-Q8lVR5YD.mjs} +5 -5
  71. package/lib/{solanaEmbed.esm-DjUFqFpM.mjs → solanaEmbed.esm-BvXjTkVM.mjs} +2 -2
  72. package/lib/{solanaEmbed.esm-BjNnWnx-.js → solanaEmbed.esm-DsV8Nqbb.js} +1 -1
  73. package/lib/src/hooks/useFetchSupportedRoutes.d.ts.map +1 -1
  74. package/lib/{sui-3oNSJVtq.mjs → sui-B6LQdf1S.mjs} +1 -1
  75. package/lib/{sui-B0C-5XvG.mjs → sui-C9At-twC.mjs} +5 -5
  76. package/lib/{sui-CT8fFOQ8.js → sui-CdyyFA7x.js} +2 -2
  77. package/lib/{sui-CHLH8_Fu.js → sui-CsDZcGdt.js} +1 -1
  78. package/package.json +1 -1
  79. package/lib/solana-DK8zh1ic.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchSupportedRoutes.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFetchSupportedRoutes.ts"],"names":[],"mappings":"AAUA,KAAK,UAAU,GAAG;IAChB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,uBAAuB,QAAO,UAoGnC,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"useFetchSupportedRoutes.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFetchSupportedRoutes.ts"],"names":[],"mappings":"AAUA,KAAK,UAAU,GAAG;IAChB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,uBAAuB,QAAO,UAuGnC,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { g as sM } from "./wallets-B2tqS5lZ.mjs";
2
2
  import { R as SM } from "./util--bw7gFPs.mjs";
3
- import { Z as CM, a1 as q, ax as EM, ay as _, $ as zM, a8 as O } from "./index-BbOEOMF9.mjs";
3
+ import { Z as CM, a1 as q, ax as EM, ay as _, $ as zM, a8 as O } from "./index-CNRoD0cV.mjs";
4
4
  class wM extends TypeError {
5
5
  constructor(A, i) {
6
6
  let t;
@@ -1,8 +1,8 @@
1
1
  var Sn = Object.defineProperty;
2
2
  var Tn = (t, e, r) => e in t ? Sn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var we = (t, e, r) => Tn(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { s as ut, t as Le, u as O, v as Bt, w as oe, M as Mt, x as En, y as Me, z as ce, B as vn, D as Fe, F as fr, C as kn, G as gr, H as xn, I as _n, h as In, n as An, j as On, J as Cn, l as jn, m as lt, o as Bn, K as Je, q as Mn, L as Pn, N as kr, O as xr, Q as _r, R as he, c as Rn } from "./index-BbOEOMF9.mjs";
5
- import { m as $n } from "./index-CAPrmxTu.mjs";
4
+ import { s as ut, t as Le, u as O, v as Bt, w as oe, M as Mt, x as En, y as Me, z as ce, B as vn, D as Fe, F as fr, C as kn, G as gr, H as xn, I as _n, h as In, n as An, j as On, J as Cn, l as jn, m as lt, o as Bn, K as Je, q as Mn, L as Pn, N as kr, O as xr, Q as _r, R as he, c as Rn } from "./index-CNRoD0cV.mjs";
5
+ import { m as $n } from "./index-DYiI6lkY.mjs";
6
6
  function H(t) {
7
7
  return Uint8Array.from(atob(t), (e) => e.charCodeAt(0));
8
8
  }
@@ -5129,9 +5129,9 @@ const ua = {
5129
5129
  Platform: De,
5130
5130
  getSigner: oa,
5131
5131
  protocols: {
5132
- WormholeCore: () => import("./index-DI-HM1Ot.mjs"),
5133
- TokenBridge: () => import("./index-DfB5v4ik.mjs"),
5134
- CircleBridge: () => import("./index-VyhZwUqP.mjs")
5132
+ WormholeCore: () => import("./index-CLGrfUbL.mjs"),
5133
+ TokenBridge: () => import("./index-DUaJiMqI.mjs"),
5134
+ CircleBridge: () => import("./index-BhqFkgz5.mjs")
5135
5135
  },
5136
5136
  getChain: (t, e, r) => new hn(e, new De(t, Rn(t, Ot, { [e]: r })))
5137
5137
  }, Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -1,5 +1,5 @@
1
- "use strict";var an=Object.defineProperty;var on=(t,e,r)=>e in t?an(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pe=(t,e,r)=>on(t,typeof e!="symbol"?e+"":e,r);const d=require("./index-CFgXIz60.js"),cn=require("./index-BEDagXR8.js");function H(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const st=8192;function $(t){if(t.length<st)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=st){const n=t.slice(r,r+st);e+=String.fromCharCode(...n)}return btoa(e)}function Ue(t){var s;const e=t.startsWith("0x")?t.slice(2):t,n=((s=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];return Uint8Array.from(n)}function ge(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function kt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function un(t){let e=0,r=0,n=0;for(;;){let s=t[n];if(n+=1,e|=(s&127)<<r,!(s&128))break;r+=7}return{value:e,length:n}}class hr{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:s}=un(r);return this.shift(s),n}readVec(e){let r=this.readULEB(),n=[];for(let s=0;s<r;s++)n.push(e(this,s,r));return n}}function dn(t,e){switch(e){case"base58":return d.toB58(t);case"base64":return $(t);case"hex":return ge(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function ln(t,e){switch(e){case"base58":return d.fromB58(t);case"base64":return H(t);case"hex":return Ue(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function fr(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 gr{constructor({size:e=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=r||e,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const r=this.bytePosition+e;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const s=new ArrayBuffer(this.size);new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(s)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return it(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return it(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return it(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return kt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,s)=>r(this,n,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return dn(this.toBytes(),e)}}function it(t,e){let r=new Uint8Array(e),n=0;for(;t>0;)r[n]=Number(t%BigInt(256)),t=t/BigInt(256),n+=1;return r}var pr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},W=(t,e,r)=>(pr(t,e,"read from private field"),r?r.call(t):e.get(t)),Ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Je=(t,e,r,n)=>(pr(t,e,"write to private field"),e.set(t,r),r),ye,ke,We,ae;const yr=class{constructor(t){Ze(this,ye,void 0),Ze(this,ke,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),Je(this,ye,t.write),Je(this,ke,t.serialize??((e,r)=>{const n=new gr({size:this.serializedSize(e)??void 0,...r});return W(this,ye).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),W(this,ye).call(this,t,e)}serialize(t,e){return this.validate(t),new hn(this,W(this,ke).call(this,t,e))}parse(t){const e=new hr(t);return this.read(e)}transform({name:t,input:e,output:r}){return new yr({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>W(this,ye).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>W(this,ke).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let K=yr;ye=new WeakMap;ke=new WeakMap;const mr=Symbol.for("@mysten/serialized-bcs");function xt(t){return!!t&&typeof t=="object"&&t[mr]===!0}class hn{constructor(e,r){Ze(this,We,void 0),Ze(this,ae,void 0),Je(this,We,e),Je(this,ae,r)}get[mr](){return!0}toBytes(){return W(this,ae)}toHex(){return ge(W(this,ae))}toBase64(){return $(W(this,ae))}toBase58(){return d.toB58(W(this,ae))}parse(){return W(this,We).parse(W(this,ae))}}We=new WeakMap;ae=new WeakMap;function Xe({size:t,...e}){return new K({...e,serializedSize:()=>t})}function at({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](n),validate:n=>{var s;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,n)}})}function ot({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](BigInt(n)),validate:n=>{var i;const s=BigInt(n);if(s<0||s>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${s}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,s)}})}function fn({serialize:t,...e}){const r=new K({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function gn({toBytes:t,fromBytes:e,...r}){return new K({...r,read:n=>{const s=n.readULEB(),i=n.readBytes(s);return e(i)},write:(n,s)=>{const i=t(n);s.writeULEB(i.length);for(let a=0;a<i.length;a++)s.write8(i[a])},serialize:n=>{const s=t(n),i=kt(s.length),a=new Uint8Array(i.length+s.length);return a.set(i,0),a.set(s,i.length),a},validate:n=>{var s;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(s=r.validate)==null||s.call(r,n)}})}function pn(t){let e=null;function r(){return e||(e=t()),e}return new K({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,s)=>r().write(n,s),serialize:(n,s)=>r().serialize(n,s).toBytes()})}const c={u8(t){return at({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return at({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return at({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return ot({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return ot({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return ot({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Xe({name:"bool",size:1,read:e=>e.read8()===1,write:(e,r)=>r.write8(e?1:0),...t,validate:e=>{var r;if((r=t==null?void 0:t.validate)==null||r.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return fn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(kt(e)),...t})},bytes(t,e){return Xe({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let s=0;s<t;s++)n.write8(r[s]??0)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t)throw new TypeError(`Expected array of length ${t}, found ${r.length}`)}})},string(t){return gn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new K({name:`${e.name}[${t}]`,read:n=>{const s=new Array(t);for(let i=0;i<t;i++)s[i]=e.read(n);return s},write:(n,s)=>{for(const i of n)e.write(i,s)},...r,validate:n=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,n),!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==t)throw new TypeError(`Expected array of length ${t}, found ${n.length}`)}})},option(t){return c.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>"Some"in e?e.Some:null})},vector(t,e){return new K({name:`vector<${t.name}>`,read:r=>{const n=r.readULEB(),s=new Array(n);for(let i=0;i<n;i++)s[i]=t.read(r);return s},write:(r,n)=>{n.writeULEB(r.length);for(const s of r)t.write(s,n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`)}})},tuple(t,e){return new K({name:`(${t.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let s=0;s<t.length;s++){const i=t[s].serializedSize(r[s]);if(i==null)return null;n+=i}return n},read:r=>{const n=[];for(const s of t)n.push(s.read(r));return n},write:(r,n)=>{for(let s=0;s<t.length;s++)t[s].write(r[s],n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!Array.isArray(r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t.length)throw new TypeError(`Expected array of length ${t.length}, found ${r.length}`)}})},struct(t,e,r){const n=Object.entries(e);return new K({name:t,serializedSize:s=>{let i=0;for(const[a,o]of n){const u=o.serializedSize(s[a]);if(u==null)return null;i+=u}return i},read:s=>{const i={};for(const[a,o]of n)i[a]=o.read(s);return i},write:(s,i)=>{for(const[a,o]of n)o.write(s[a],i)},...r,validate:s=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`)}})},enum(t,e,r){const n=Object.entries(e);return new K({name:t,read:s=>{const i=s.readULEB(),[a,o]=n[i];return{[a]:(o==null?void 0:o.read(s))??!0}},write:(s,i)=>{const[a,o]=Object.entries(s)[0];for(let u=0;u<n.length;u++){const[l,f]=n[u];if(l===a){i.writeULEB(u),f==null||f.write(o,i);return}}},...r,validate:s=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`);const i=Object.keys(s);if(i.length!==1)throw new TypeError(`Expected object with one key, found ${i.length}`);const[a]=i;if(!Object.hasOwn(e,a))throw new TypeError(`Invalid enum variant ${a}`)}})},map(t,e){return c.vector(c.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[s,i]of r)n.set(s,i);return n}})},generic(t,e){return(...r)=>e(...r).transform({name:`${e.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(t){return pn(t)}},yn=32,xe=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof xe){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(xe.ADDRESS,t.addressLength,t.addressEncoding),this.registerVectorType(t.vectorType),t.types&&t.types.structs)for(let e of Object.keys(t.types.structs))this.registerStructType(e,t.types.structs[e]);if(t.types&&t.types.enums)for(let e of Object.keys(t.types.enums))this.registerEnumType(e,t.types.enums[e]);if(t.types&&t.types.aliases)for(let e of Object.keys(t.types.aliases))this.registerAlias(e,t.types.aliases[e]);t.withPrimitives!==!1&&mn(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,s)}if(typeof t=="object"){const n=this.tempKey();return new xe(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
1
+ "use strict";var an=Object.defineProperty;var on=(t,e,r)=>e in t?an(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pe=(t,e,r)=>on(t,typeof e!="symbol"?e+"":e,r);const d=require("./index-DOGZjt2S.js"),cn=require("./index-i9soDbgm.js");function H(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const st=8192;function $(t){if(t.length<st)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=st){const n=t.slice(r,r+st);e+=String.fromCharCode(...n)}return btoa(e)}function Ue(t){var s;const e=t.startsWith("0x")?t.slice(2):t,n=((s=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];return Uint8Array.from(n)}function ge(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function kt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function un(t){let e=0,r=0,n=0;for(;;){let s=t[n];if(n+=1,e|=(s&127)<<r,!(s&128))break;r+=7}return{value:e,length:n}}class hr{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:s}=un(r);return this.shift(s),n}readVec(e){let r=this.readULEB(),n=[];for(let s=0;s<r;s++)n.push(e(this,s,r));return n}}function dn(t,e){switch(e){case"base58":return d.toB58(t);case"base64":return $(t);case"hex":return ge(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function ln(t,e){switch(e){case"base58":return d.fromB58(t);case"base64":return H(t);case"hex":return Ue(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function fr(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 gr{constructor({size:e=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=r||e,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const r=this.bytePosition+e;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const s=new ArrayBuffer(this.size);new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(s)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return it(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return it(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return it(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return kt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,s)=>r(this,n,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return dn(this.toBytes(),e)}}function it(t,e){let r=new Uint8Array(e),n=0;for(;t>0;)r[n]=Number(t%BigInt(256)),t=t/BigInt(256),n+=1;return r}var pr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},W=(t,e,r)=>(pr(t,e,"read from private field"),r?r.call(t):e.get(t)),Ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Je=(t,e,r,n)=>(pr(t,e,"write to private field"),e.set(t,r),r),ye,ke,We,ae;const yr=class{constructor(t){Ze(this,ye,void 0),Ze(this,ke,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),Je(this,ye,t.write),Je(this,ke,t.serialize??((e,r)=>{const n=new gr({size:this.serializedSize(e)??void 0,...r});return W(this,ye).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),W(this,ye).call(this,t,e)}serialize(t,e){return this.validate(t),new hn(this,W(this,ke).call(this,t,e))}parse(t){const e=new hr(t);return this.read(e)}transform({name:t,input:e,output:r}){return new yr({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>W(this,ye).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>W(this,ke).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let K=yr;ye=new WeakMap;ke=new WeakMap;const mr=Symbol.for("@mysten/serialized-bcs");function xt(t){return!!t&&typeof t=="object"&&t[mr]===!0}class hn{constructor(e,r){Ze(this,We,void 0),Ze(this,ae,void 0),Je(this,We,e),Je(this,ae,r)}get[mr](){return!0}toBytes(){return W(this,ae)}toHex(){return ge(W(this,ae))}toBase64(){return $(W(this,ae))}toBase58(){return d.toB58(W(this,ae))}parse(){return W(this,We).parse(W(this,ae))}}We=new WeakMap;ae=new WeakMap;function Xe({size:t,...e}){return new K({...e,serializedSize:()=>t})}function at({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](n),validate:n=>{var s;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,n)}})}function ot({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](BigInt(n)),validate:n=>{var i;const s=BigInt(n);if(s<0||s>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${s}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,s)}})}function fn({serialize:t,...e}){const r=new K({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function gn({toBytes:t,fromBytes:e,...r}){return new K({...r,read:n=>{const s=n.readULEB(),i=n.readBytes(s);return e(i)},write:(n,s)=>{const i=t(n);s.writeULEB(i.length);for(let a=0;a<i.length;a++)s.write8(i[a])},serialize:n=>{const s=t(n),i=kt(s.length),a=new Uint8Array(i.length+s.length);return a.set(i,0),a.set(s,i.length),a},validate:n=>{var s;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(s=r.validate)==null||s.call(r,n)}})}function pn(t){let e=null;function r(){return e||(e=t()),e}return new K({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,s)=>r().write(n,s),serialize:(n,s)=>r().serialize(n,s).toBytes()})}const c={u8(t){return at({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return at({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return at({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return ot({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return ot({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return ot({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Xe({name:"bool",size:1,read:e=>e.read8()===1,write:(e,r)=>r.write8(e?1:0),...t,validate:e=>{var r;if((r=t==null?void 0:t.validate)==null||r.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return fn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(kt(e)),...t})},bytes(t,e){return Xe({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let s=0;s<t;s++)n.write8(r[s]??0)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t)throw new TypeError(`Expected array of length ${t}, found ${r.length}`)}})},string(t){return gn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new K({name:`${e.name}[${t}]`,read:n=>{const s=new Array(t);for(let i=0;i<t;i++)s[i]=e.read(n);return s},write:(n,s)=>{for(const i of n)e.write(i,s)},...r,validate:n=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,n),!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==t)throw new TypeError(`Expected array of length ${t}, found ${n.length}`)}})},option(t){return c.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>"Some"in e?e.Some:null})},vector(t,e){return new K({name:`vector<${t.name}>`,read:r=>{const n=r.readULEB(),s=new Array(n);for(let i=0;i<n;i++)s[i]=t.read(r);return s},write:(r,n)=>{n.writeULEB(r.length);for(const s of r)t.write(s,n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`)}})},tuple(t,e){return new K({name:`(${t.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let s=0;s<t.length;s++){const i=t[s].serializedSize(r[s]);if(i==null)return null;n+=i}return n},read:r=>{const n=[];for(const s of t)n.push(s.read(r));return n},write:(r,n)=>{for(let s=0;s<t.length;s++)t[s].write(r[s],n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!Array.isArray(r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t.length)throw new TypeError(`Expected array of length ${t.length}, found ${r.length}`)}})},struct(t,e,r){const n=Object.entries(e);return new K({name:t,serializedSize:s=>{let i=0;for(const[a,o]of n){const u=o.serializedSize(s[a]);if(u==null)return null;i+=u}return i},read:s=>{const i={};for(const[a,o]of n)i[a]=o.read(s);return i},write:(s,i)=>{for(const[a,o]of n)o.write(s[a],i)},...r,validate:s=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`)}})},enum(t,e,r){const n=Object.entries(e);return new K({name:t,read:s=>{const i=s.readULEB(),[a,o]=n[i];return{[a]:(o==null?void 0:o.read(s))??!0}},write:(s,i)=>{const[a,o]=Object.entries(s)[0];for(let u=0;u<n.length;u++){const[l,f]=n[u];if(l===a){i.writeULEB(u),f==null||f.write(o,i);return}}},...r,validate:s=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`);const i=Object.keys(s);if(i.length!==1)throw new TypeError(`Expected object with one key, found ${i.length}`);const[a]=i;if(!Object.hasOwn(e,a))throw new TypeError(`Invalid enum variant ${a}`)}})},map(t,e){return c.vector(c.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[s,i]of r)n.set(s,i);return n}})},generic(t,e){return(...r)=>e(...r).transform({name:`${e.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(t){return pn(t)}},yn=32,xe=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof xe){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(xe.ADDRESS,t.addressLength,t.addressEncoding),this.registerVectorType(t.vectorType),t.types&&t.types.structs)for(let e of Object.keys(t.types.structs))this.registerStructType(e,t.types.structs[e]);if(t.types&&t.types.enums)for(let e of Object.keys(t.types.enums))this.registerEnumType(e,t.types.enums[e]);if(t.types&&t.types.aliases)for(let e of Object.keys(t.types.aliases))this.registerAlias(e,t.types.aliases[e]);t.withPrimitives!==!1&&mn(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,s)}if(typeof t=="object"){const n=this.tempKey();return new xe(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
2
2
  ${JSON.stringify(t)}`)}de(t,e,r){if(typeof e=="string")if(r)e=ln(e,r);else throw new Error("To pass a string to `bcs.de`, specify encoding");if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).decode(this,e,s)}if(typeof t=="object"){const n=new xe(this),s=this.tempKey();return n.registerStructType(s,t).de(s,e,r)}throw new Error(`Incorrect type passed into the '.de()' function.
3
3
  ${JSON.stringify(t)}`)}hasType(t){return this.types.has(t)}registerAlias(t,e){return this.types.set(t,e),this}registerType(t,e,r,n=()=>!0){const{name:s,params:i}=this.parseTypeName(t);return this.types.set(s,{encode(a,o,u,l){const f=i.reduce((p,y,m)=>Object.assign(p,{[y]:l[m]}),{});return this._encodeRaw.call(a,new gr(u),o,l,f)},decode(a,o,u){const l=i.reduce((f,p,y)=>Object.assign(f,{[p]:u[y]}),{});return this._decodeRaw.call(a,new hr(o),u,l)},_encodeRaw(a,o,u,l){if(n(o))return e.call(this,a,o,u,l);throw new Error(`Validation failed for type ${s}, data: ${o}`)},_decodeRaw(a,o,u){return r.call(this,a,o,u)}}),this}registerBcsType(t,e){return this.registerType(t,(r,n,s)=>{const i=s.map(a=>new K({name:String(a),write:(o,u)=>{const{name:l,params:f}=this.parseTypeName(a),p=this.getTypeInterface(l),y=f.reduce((m,x,T)=>Object.assign(m,{[x]:s[T]}),{});return p._encodeRaw.call(this,u,o,f,y)},read:()=>{throw new Error("Not implemented")}}));return e(...i).write(n,r),r},(r,n)=>{const s=n.map(i=>new K({name:String(i),write:(a,o)=>{throw new Error("Not implemented")},read:a=>{const{name:o,params:u}=this.parseTypeName(i),l=this.getTypeInterface(o),f=u.reduce((p,y,m)=>Object.assign(p,{[y]:n[m]}),{});return l._decodeRaw.call(this,a,u,f)}}));return e(...s).read(r)}),this}registerAddressType(t,e,r="hex"){switch(r){case"base64":return this.registerType(t,function(s,i){return H(i).reduce((a,o)=>a.write8(o),s)},function(s){return $(s.readBytes(e))});case"hex":return this.registerType(t,function(s,i){return Ue(i).reduce((a,o)=>a.write8(o),s)},function(s){return ge(s.readBytes(e))});default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(t){let{name:e,params:r}=this.parseTypeName(t);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+e);return this.registerType(t,function(s,i,a,o){return s.writeVec(i,(u,l)=>{let f=a[0];if(!f)throw new Error(`Incorrect number of type parameters passed a to vector '${t}'`);let{name:p,params:y}=this.parseTypeName(f);if(this.hasType(p))return this.getTypeInterface(p)._encodeRaw.call(this,u,l,y,o);if(!(p in o))throw new Error(`Unable to find a matching type definition for ${p} in vector; make sure you passed a generic`);let{name:m,params:x}=this.parseTypeName(o[p]);return this.getTypeInterface(m)._encodeRaw.call(this,u,l,x,o)})},function(s,i,a){return s.readVec(o=>{let u=i[0];if(!u)throw new Error(`Incorrect number of type parameters passed to a vector '${t}'`);let{name:l,params:f}=this.parseTypeName(u);if(this.hasType(l))return this.getTypeInterface(l)._decodeRaw.call(this,o,f,a);if(!(l in a))throw new Error(`Unable to find a matching type definition for ${l} in vector; make sure you passed a generic`);let{name:p,params:y}=this.parseTypeName(a[l]);return this.getTypeInterface(p)._decodeRaw.call(this,o,y,a)})})}registerStructType(t,e){for(let a in e){let o=this.tempKey(),u=e[a];!Array.isArray(u)&&typeof u!="string"&&(e[a]=o,this.registerStructType(o,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,u,l,f){if(!u||u.constructor!==Object)throw new Error(`Expected ${s} to be an Object, got: ${u}`);if(l.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${l.length}`);for(let p of n){if(!(p in u))throw new Error(`Struct ${s} requires field ${p}:${r[p]}`);const{name:y,params:m}=this.parseTypeName(r[p]);if(!i.includes(y))this.getTypeInterface(y)._encodeRaw.call(this,o,u[p],m,f);else{const x=i.indexOf(y);let{name:T,params:C}=this.parseTypeName(l[x]);if(this.hasType(T)){this.getTypeInterface(T)._encodeRaw.call(this,o,u[p],C,f);continue}if(!(T in f))throw new Error(`Unable to find a matching type definition for ${T} in ${s}; make sure you passed a generic`);let{name:M,params:se}=this.parseTypeName(f[T]);this.getTypeInterface(M)._encodeRaw.call(this,o,u[p],se,f)}}return o},function(o,u,l){if(u.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${u.length}`);let f={};for(let p of n){const{name:y,params:m}=this.parseTypeName(r[p]);if(!i.includes(y))f[p]=this.getTypeInterface(y)._decodeRaw.call(this,o,m,l);else{const x=i.indexOf(y);let{name:T,params:C}=this.parseTypeName(u[x]);if(this.hasType(T)){f[p]=this.getTypeInterface(T)._decodeRaw.call(this,o,C,l);continue}if(!(T in l))throw new Error(`Unable to find a matching type definition for ${T} in ${s}; make sure you passed a generic`);let{name:M,params:se}=this.parseTypeName(l[T]);f[p]=this.getTypeInterface(M)._decodeRaw.call(this,o,se,l)}}return f})}registerEnumType(t,e){for(let a in e){let o=this.tempKey(),u=e[a];u!==null&&!Array.isArray(u)&&typeof u!="string"&&(e[a]=o,this.registerStructType(o,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,u,l,f){if(!u)throw new Error(`Unable to write enum "${s}", missing data.
4
4
  Received: "${u}"`);if(typeof u!="object")throw new Error(`Incorrect data passed into enum "${s}", expected object with properties: "${n.join(" | ")}".
5
- Received: "${JSON.stringify(u)}"`);let p=Object.keys(u)[0];if(p===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let y=n.indexOf(p);if(y===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${p}"`);let m=n[y],x=r[m];if(o.write8(y),x===null)return o;let T=i.indexOf(x),C=T===-1?x:l[T];{let{name:M,params:se}=this.parseTypeName(C);return this.getTypeInterface(M)._encodeRaw.call(this,o,u[p],se,f)}},function(o,u,l){let f=o.readULEB(),p=n[f],y=r[p];if(f===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${f}"`);if(y===null)return{[p]:!0};let m=i.indexOf(y),x=m===-1?y:u[m];{let{name:T,params:C}=this.parseTypeName(x);return{[p]:this.getTypeInterface(T)._decodeRaw.call(this,o,C,l)}}})}getTypeInterface(t){let e=this.types.get(t);if(typeof e=="string"){let r=[];for(;typeof e=="string";){if(r.includes(e))throw new Error(`Recursive definition found: ${r.join(" -> ")} -> ${e}`);r.push(e),e=this.types.get(e)}}if(e===void 0)throw new Error(`Type ${t} is not registered`);return e}parseTypeName(t){if(Array.isArray(t)){let[o,...u]=t;return{name:o,params:u}}if(typeof t!="string")throw new Error(`Illegal type passed as a name of the type: ${t}`);let[e,r]=this.schema.genericSeparators||["<",">"],n=t.indexOf(e),s=Array.from(t).reverse().indexOf(r);if(n===-1&&s===-1)return{name:t,params:[]};if(n===-1||s===-1)throw new Error(`Unclosed generic in name '${t}'`);let i=t.slice(0,n),a=fr(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let _=xe;_.U8="u8";_.U16="u16";_.U32="u32";_.U64="u64";_.U128="u128";_.U256="u256";_.BOOL="bool";_.VECTOR="vector";_.ADDRESS="address";_.STRING="string";_.HEX="hex-string";_.BASE58="base58-string";_.BASE64="base64-string";function mn(t){t.registerType(_.U8,function(e,r){return e.write8(r)},function(e){return e.read8()},e=>e<256),t.registerType(_.U16,function(e,r){return e.write16(r)},function(e){return e.read16()},e=>e<65536),t.registerType(_.U32,function(e,r){return e.write32(r)},function(e){return e.read32()},e=>e<=4294967296n),t.registerType(_.U64,function(e,r){return e.write64(r)},function(e){return e.read64()}),t.registerType(_.U128,function(e,r){return e.write128(r)},function(e){return e.read128()}),t.registerType(_.U256,function(e,r){return e.write256(r)},function(e){return e.read256()}),t.registerType(_.BOOL,function(e,r){return e.write8(r)},function(e){return e.read8().toString(10)==="1"}),t.registerType(_.STRING,function(e,r){return e.writeVec(Array.from(r),(n,s)=>n.write8(s.charCodeAt(0)))},function(e){return e.readVec(r=>r.read8()).map(r=>String.fromCharCode(Number(r))).join("")},e=>!0),t.registerType(_.HEX,function(e,r){return e.writeVec(Array.from(Ue(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return ge(new Uint8Array(r))}),t.registerType(_.BASE58,function(e,r){return e.writeVec(Array.from(d.fromB58(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return d.toB58(new Uint8Array(r))}),t.registerType(_.BASE64,function(e,r){return e.writeVec(Array.from(H(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return $(new Uint8Array(r))})}function wn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:yn,addressEncoding:"hex"}}class bn extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:o}=e,u=o.length===0?s:`At path: ${o.join(".")} -- ${s}`;super(i??u),i!=null&&(this.cause=u),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Sn(t){return V(t)&&typeof t[Symbol.iterator]=="function"}function V(t){return typeof t=="object"&&t!=null}function L(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function Tn(t){const{done:e,value:r}=t.next();return e?void 0:r}function En(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:s,branch:i}=e,{type:a}=r,{refinement:o,message:u=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${L(n)}\``}=t;return{value:n,type:a,refinement:o,key:s[s.length-1],path:s,branch:i,...t,message:u}}function*nr(t,e,r,n){Sn(t)||(t=[t]);for(const s of t){const i=En(s,e,r,n);i&&(yield i)}}function*_t(t,e,r={}){const{path:n=[],branch:s=[t],coerce:i=!1,mask:a=!1}=r,o={path:n,branch:s};if(i&&(t=e.coercer(t,o),a&&e.type!=="type"&&V(e.schema)&&V(t)&&!Array.isArray(t)))for(const l in t)e.schema[l]===void 0&&delete t[l];let u="valid";for(const l of e.validator(t,o))l.explanation=r.message,u="not_valid",yield[l,void 0];for(let[l,f,p]of e.entries(t,o)){const y=_t(f,p,{path:l===void 0?n:[...n,l],branch:l===void 0?s:[...s,f],coerce:i,mask:a,message:r.message});for(const m of y)m[0]?(u=m[0].refinement!=null?"not_refined":"not_valid",yield[m[0],void 0]):i&&(f=m[1],l===void 0?t=f:t instanceof Map?t.set(l,f):t instanceof Set?t.add(f):V(t)&&(f!==void 0||l in t)&&(t[l]=f))}if(u!=="not_valid")for(const l of e.refiner(t,o))l.explanation=r.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,t])}class X{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=u=>u,entries:o=function*(){}}=e;this.type=r,this.schema=n,this.entries=o,this.coercer=a,s?this.validator=(u,l)=>{const f=s(u,l);return nr(f,l,this,u)}:this.validator=()=>[],i?this.refiner=(u,l)=>{const f=i(u,l);return nr(f,l,this,u)}:this.refiner=()=>[]}assert(e,r){return lt(e,this,r)}create(e,r){return wr(e,this,r)}is(e){return U(e,this)}mask(e,r){return br(e,this,r)}validate(e,r={}){return De(e,this,r)}}function lt(t,e,r){const n=De(t,e,{message:r});if(n[0])throw n[0]}function wr(t,e,r){const n=De(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function br(t,e,r){const n=De(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function U(t,e){return!De(t,e)[0]}function De(t,e,r={}){const n=_t(t,e,r),s=Tn(n);return s[0]?[new bn(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Ce(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?kn(n):g(n)}function D(t,e){return new X({type:t,schema:null,validator:e})}function ht(){return D("any",()=>!0)}function E(t){return new X({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${L(e)}`}})}function vn(){return D("bigint",t=>typeof t=="bigint")}function P(){return D("boolean",t=>typeof t=="boolean")}function J(){return D("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${L(t)}`)}function b(t){const e=L(t),r=typeof t;return new X({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${L(n)}`}})}function Sr(){return D("never",()=>!1)}function O(t){return new X({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function he(){return D("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${L(t)}`)}function g(t){const e=t?Object.keys(t):[],r=Sr();return new X({type:"object",schema:t||null,*entries(n){if(t&&V(n)){const s=new Set(Object.keys(n));for(const i of e)s.delete(i),yield[i,n[i],t[i]];for(const i of s)yield[i,n[i],r]}},validator(n){return V(n)||`Expected an object, but received: ${L(n)}`},coercer(n){return V(n)?{...n}:n}})}function w(t){return new X({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Z(t,e){return new X({type:"record",schema:null,*entries(r){if(V(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`}})}function h(){return D("string",t=>typeof t=="string"||`Expected a string, but received: ${L(t)}`)}function Tr(t){const e=Sr();return new X({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let s=0;s<n;s++)yield[s,r[s],t[s]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${L(r)}`}})}function kn(t){const e=Object.keys(t);return new X({type:"type",schema:t,*entries(r){if(V(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`},coercer(r){return V(r)?{...r}:r}})}function j(t){const e=t.map(r=>r.type).join(" | ");return new X({type:"union",schema:null,coercer(r){for(const n of t){const[s,i]=n.validate(r,{coerce:!0});if(!s)return i}return r},validator(r,n){const s=[];for(const i of t){const[...a]=_t(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 Er(){return D("unknown",()=>!0)}const xn="0.50.1",_n="1.19.0",An={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class vr extends Error{}class kr extends vr{constructor(e,r){super(e),this.code=r,this.type=An[r]??"ServerError"}}class In extends vr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var At=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},A=(t,e,r)=>(At(t,e,"read from private field"),r?r.call(t):e.get(t)),ie=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},we=(t,e,r,n)=>(At(t,e,"write to private field"),e.set(t,r),r),On=(t,e,r,n)=>({set _(s){we(t,e,s)},get _(){return A(t,e,n)}}),xr=(t,e,r)=>(At(t,e,"access private method"),r),de,Oe,ee,le,Be,be,ft,_r,It,Ar;function jn(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const Cn={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class Bn{constructor(e,r={}){if(ie(this,ft),ie(this,It),ie(this,de,0),ie(this,Oe,0),ie(this,ee,null),ie(this,le,null),ie(this,Be,new Set),ie(this,be,new Map),this.endpoint=e,this.options={...Cn,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=jn(this.endpoint))}async makeRequest(e,r){const n=await xr(this,ft,_r).call(this);return new Promise((s,i)=>{we(this,de,A(this,de)+1),A(this,be).set(A(this,de),{resolve:s,reject:i,timeout:setTimeout(()=>{A(this,be).delete(A(this,de)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:A(this,de),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new kr(s.message,s.code);return i})}async subscribe(e){const r=new Mn(e);return A(this,Be).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}de=new WeakMap;Oe=new WeakMap;ee=new WeakMap;le=new WeakMap;Be=new WeakMap;be=new WeakMap;ft=new WeakSet;_r=function(){return A(this,le)?A(this,le):(we(this,le,new Promise(t=>{var e;(e=A(this,ee))==null||e.close(),we(this,ee,new this.options.WebSocketConstructor(this.endpoint)),A(this,ee).addEventListener("open",()=>{we(this,Oe,0),t(A(this,ee))}),A(this,ee).addEventListener("close",()=>{On(this,Oe)._++,A(this,Oe)<=this.options.maxReconnects&&setTimeout(()=>{xr(this,It,Ar).call(this)},this.options.reconnectTimeout)}),A(this,ee).addEventListener("message",({data:r})=>{let n;try{n=JSON.parse(r)}catch(s){console.error(new Error(`Failed to parse RPC message: ${r}`,{cause:s}));return}if("id"in n&&n.id!=null&&A(this,be).has(n.id)){const{resolve:s,timeout:i}=A(this,be).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;A(this,Be).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),A(this,le))};It=new WeakSet;Ar=async function(){var t;return(t=A(this,ee))==null||t.close(),we(this,le,null),Promise.allSettled([...A(this,Be)].map(e=>e.subscribe(this)))};class Mn{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:r}=this;return this.subscribed=!1,r==null?!1:(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[r]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const r=await e.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=r)}}var Ot=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},z=(t,e,r)=>(Ot(t,e,"read from private field"),r?r.call(t):e.get(t)),ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},gt=(t,e,r,n)=>(Ot(t,e,"write to private field"),e.set(t,r),r),Pn=(t,e,r)=>(Ot(t,e,"access private method"),r),_e,F,je,pt,Ir;class Rn{constructor(e){ze(this,pt),ze(this,_e,0),ze(this,F,void 0),ze(this,je,void 0),gt(this,F,e)}fetch(e,r){const n=z(this,F).fetch??globalThis.fetch;if(!this.fetch)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return n(e,r)}async request(e){var s,i;gt(this,_e,z(this,_e)+1);const r=await this.fetch(((s=z(this,F).rpc)==null?void 0:s.url)??z(this,F).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":xn,"Client-Target-Api-Version":_n,...(i=z(this,F).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:z(this,_e),method:e.method,params:e.params})});if(!r.ok)throw new In(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new kr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await Pn(this,pt,Ir).call(this).subscribe(e);return async()=>!!await r()}}_e=new WeakMap;F=new WeakMap;je=new WeakMap;pt=new WeakSet;Ir=function(){var t;if(!z(this,je)){const e=z(this,F).WebSocketConstructor??globalThis.WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");gt(this,je,new Bn(((t=z(this,F).websocket)==null?void 0:t.url)??z(this,F).url,{WebSocketConstructor:e,...z(this,F).websocket}))}return z(this,je)};const Nn=/^vector<(.+)>$/,$n=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class te{static parseFromStr(e,r=!1){if(e==="address")return{address:null};if(e==="bool")return{bool:null};if(e==="u8")return{u8:null};if(e==="u16")return{u16:null};if(e==="u32")return{u32:null};if(e==="u64")return{u64:null};if(e==="u128")return{u128:null};if(e==="u256")return{u256:null};if(e==="signer")return{signer:null};const n=e.match(Nn);if(n)return{vector:te.parseFromStr(n[1],r)};const s=e.match($n);if(s)return{struct:{address:r?d.normalizeSuiAddress(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:te.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return fr(e).map(n=>te.parseFromStr(n,r))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${te.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(te.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const k=new _({...wn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function Or(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function Un(t){return c.enum("Option",{None:null,Some:t})}function jt(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const G=c.bytes(d.SUI_ADDRESS_LENGTH).transform({input:t=>typeof t=="string"?Ue(d.normalizeSuiAddress(t)):t,output:t=>d.normalizeSuiAddress(ge(t))}),Ct=c.vector(c.u8()).transform({name:"ObjectDigest",input:t=>d.fromB58(t),output:t=>d.toB58(new Uint8Array(t))}),Me=c.struct("SuiObjectRef",{objectId:G,version:c.u64(),digest:Ct}),Bt=c.struct("SharedObjectRef",{objectId:G,initialSharedVersion:c.u64(),mutable:c.bool()}),Ye=c.enum("ObjectArg",{ImmOrOwned:Me,Shared:Bt,Receiving:Me}),Mt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:Ye,ObjVec:c.vector(Ye)}),ve=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>ve),struct:c.lazy(()=>Dt),u16:null,u32:null,u256:null}),q=jt(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()})})),Pt=c.struct("ProgrammableMoveCall",{package:G,module:c.string(),function:c.string(),type_arguments:c.vector(ve),arguments:c.vector(q)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>te.parseFromStr(i,!0));return{package:d.normalizeSuiAddress(e),module:r,function:n,type_arguments:s,arguments:t.arguments}},output:t=>({target:[t.package,t.module,t.function].join("::"),arguments:t.arguments,typeArguments:t.type_arguments.map(te.tagToString)})}),Rt=jt(c.enum("Transaction",{MoveCall:Pt,TransferObjects:c.struct("TransferObjects",{objects:c.vector(q),address:q}),SplitCoins:c.struct("SplitCoins",{coin:q,amounts:c.vector(q)}),MergeCoins:c.struct("MergeCoins",{destination:q,sources:c.vector(q)}),Publish:c.struct("Publish",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G)}),MakeMoveVec:c.struct("MakeMoveVec",{type:Un(ve),objects:c.vector(q)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G),packageId:G,ticket:q})})),Nt=c.struct("ProgrammableTransaction",{inputs:c.vector(Mt),transactions:c.vector(Rt)}),$t=c.enum("TransactionKind",{ProgrammableTransaction:Nt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Ut=c.enum("TransactionExpiration",{None:null,Epoch:Or()}),Dt=c.struct("StructTag",{address:G,module:c.string(),name:c.string(),typeParams:c.vector(ve)}),zt=c.struct("GasData",{payment:c.vector(Me),owner:G,price:c.u64(),budget:c.u64()}),Vt=c.struct("TransactionDataV1",{kind:$t,sender:G,gasData:zt,expiration:Ut}),Lt=c.enum("TransactionData",{V1:Vt}),Dn=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),zn=c.enum("IntentVersion",{V0:null}),Vn=c.enum("AppId",{Sui:null}),Ln=c.struct("Intent",{scope:Dn,version:zn,appId:Vn}),qn=c.generic(["T"],t=>c.struct("IntentMessage<T>",{intent:Ln,value:t})),qt=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())}),Wt=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())}),Ft=c.struct("MultiSigPkMap",{pubKey:Wt,weight:c.u8()}),Kt=c.struct("MultiSigPublicKey",{pk_map:c.vector(Ft),threshold:c.u16()}),jr=c.struct("MultiSig",{sigs:c.vector(qt),bitmap:c.u16(),multisig_pk:Kt}),Wn=c.vector(c.u8()).transform({input:t=>typeof t=="string"?H(t):t,output:t=>$(new Uint8Array(t))}),Cr=c.struct("SenderSignedTransaction",{intentMessage:qn(Lt),txSignatures:c.vector(Wn)}),Br=c.vector(Cr,{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:Mt,CompressedSignature:qt,GasData:zt,MultiSig:jr,MultiSigPkMap:Ft,MultiSigPublicKey:Kt,ObjectArg:Ye,ObjectDigest:Ct,ProgrammableMoveCall:Pt,ProgrammableTransaction:Nt,PublicKey:Wt,SenderSignedData:Br,SenderSignedTransaction:Cr,SharedObjectRef:Bt,StructTag:Dt,SuiObjectRef:Me,Transaction:Rt,TransactionData:Lt,TransactionDataV1:Vt,TransactionExpiration:Ut,TransactionKind:$t,TypeTag:ve,ser:k.ser.bind(k),de:k.de.bind(k),getTypeInterface:k.getTypeInterface.bind(k),hasType:k.hasType.bind(k),parseTypeName:k.parseTypeName.bind(k),registerAddressType:k.registerAddressType.bind(k),registerAlias:k.registerAlias.bind(k),registerBcsType:k.registerBcsType.bind(k),registerEnumType:k.registerEnumType.bind(k),registerStructType:k.registerStructType.bind(k),registerType:k.registerType.bind(k),types:k.types};k.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));k.registerBcsType("unsafe_u64",()=>Or());k.registerBcsType("enumKind",t=>jt(t));[G,q,Mt,qt,zt,jr,Ft,Kt,Ye,Ct,Pt,Nt,Wt,Br,Bt,Dt,Me,Rt,Lt,Vt,Ut,$t,ve].forEach(t=>{k.registerBcsType(t.name,()=>t)});const Gt=j([g({AddressOwner:h()}),g({ObjectOwner:h()}),g({Shared:g({initial_shared_version:O(h())})}),b("Immutable")]);D("SuiJsonValue",()=>!0);const Fn=j([g({u32:h()}),g({u64:h()}),g({f64:h()})]);g({attributes:Z(h(),O(Fn)),featureFlags:Z(h(),P()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});j([h(),b("package")]);const oe=g({digest:h(),objectId:h(),version:j([he(),h(),vn()])});g({owner:Gt,reference:oe});g({objectId:h(),sequenceNumber:h()});g({payment:E(oe),owner:h(),price:h(),budget:h()});const Kn=Ce(oe,g({type:h(),owner:Gt,previousTransaction:h()})),Gn=Z(h(),ht()),Hn=Z(h(),Er()),Zn=g({type:h(),fields:Gn,hasPublicTransfer:P()}),Jn=g({disassembled:Hn}),Xn=j([Ce(Zn,g({dataType:b("moveObject")})),Ce(Jn,g({dataType:b("package")}))]),Yn=g({type:h(),hasPublicTransfer:P(),version:h(),bcsBytes:h()}),Qn=g({id:h(),moduleMap:Z(h(),h())}),es=j([Ce(Yn,g({dataType:b("moveObject")})),Ce(Qn,g({dataType:b("package")}))]);BigInt(1e9);const Mr=g({code:h(),error:w(h()),object_id:w(h()),parent_object_id:w(h()),version:w(h()),digest:w(h())}),ts=g({data:O(w(Z(h(),h()))),error:O(w(Mr))}),rs=j([ts,w(Z(h(),h()))]),Pr=g({objectId:h(),version:h(),digest:h(),type:O(w(h())),content:O(w(Xn)),bcs:O(w(es)),owner:O(w(Gt)),previousTransaction:O(w(h())),storageRebate:O(w(h())),display:O(w(rs))});g({showType:O(w(P())),showContent:O(w(P())),showBcs:O(w(P())),showOwner:O(w(P())),showPreviousTransaction:O(w(P())),showStorageRebate:O(w(P())),showDisplay:O(w(P()))});j([b("Exists"),b("notExists"),b("Deleted")]);E(Kn);const ns=g({data:O(w(Pr)),error:O(w(Mr))});function ss(t){return t.data}function is(t){if(t.error&&"object_id"in t.error&&"version"in t.error&&"digest"in t.error){const e=t.error;return{objectId:e.object_id,version:e.version,digest:e.digest}}}function sr(t){if("reference"in t)return t.reference;const e=ss(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:is(t)}g({objectId:h(),atCheckpoint:w(he())});g({data:E(ns),nextCursor:w(O(h())),hasNextPage:P()});j([g({details:Pr,status:b("VersionFound")}),g({details:h(),status:b("ObjectNotExists")}),g({details:oe,status:b("ObjectDeleted")}),g({details:Tr([h(),he()]),status:b("VersionNotFound")}),g({details:g({asked_version:he(),latest_version:he(),object_id:h()}),status:b("VersionTooHigh")})]);const as=j([h(),g({Object:h()})]);E(as);const os=g({address:h(),name:h()}),cs=j([b("Private"),b("Public"),b("Friend")]),Ht=g({abilities:E(h())}),us=g({constraints:Ht,isPhantom:P()}),ds=g({TypeParameter:he()}),ct=Tr([g({module:h(),package:h(),function:h()}),h()]);g({rank3Days:E(ct),rank7Days:E(ct),rank30Days:E(ct)});function Rr(t){if(!t)return!1;if(typeof t=="string"||U(t,ds)||Nr(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(U(e.Reference,Se)||U(e.MutableReference,Se)||U(e.Vector,Se))}const Se=D("SuiMoveNormalizedType",Rr);function Nr(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=>Rr(n)))}D("SuiMoveNormalizedStructType",Nr);const ls=g({visibility:cs,isEntry:P(),typeParameters:E(Ht),parameters:E(Se),return:E(Se)}),hs=g({name:h(),type:Se}),fs=g({abilities:Ht,typeParameters:E(us),fields:E(hs)}),gs=g({fileFormatVersion:he(),address:h(),name:h(),friends:E(os),structs:Z(h(),fs),exposedFunctions:Z(h(),ls)});Z(h(),gs);function yt(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function $r(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function Zt(t){if(typeof t=="object"&&"Struct"in t)return t;const e=$r(t),r=yt(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const ps=j([g({ImmOrOwned:oe}),g({Shared:g({objectId:h(),initialSharedVersion:j([J(),h()]),mutable:P()})}),g({Receiving:oe})]),Qe=g({Pure:E(J())}),mt=g({Object:ps}),et=j([Qe,mt]);function ys(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:xt(t)?t.toBytes():I.ser(e,t,{maxSize:1/0}).toBytes())}}const N={Pure:ys,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:d.normalizeSuiAddress(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}}};function ir(t){return typeof t=="string"?d.normalizeSuiAddress(t):"ImmOrOwned"in t.Object?d.normalizeSuiAddress(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?d.normalizeSuiAddress(t.Object.Receiving.objectId):d.normalizeSuiAddress(t.Object.Shared.objectId)}function ms(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function ws(t){var e;return((e=ms(t))==null?void 0:e.mutable)??!1}function bs(t){function e(r,n){return t(r,n)}return e.u8=r=>t(I.U8.serialize(r)),e.u16=r=>t(I.U16.serialize(r)),e.u32=r=>t(I.U32.serialize(r)),e.u64=r=>t(I.U64.serialize(r)),e.u128=r=>t(I.U128.serialize(r)),e.u256=r=>t(I.U256.serialize(r)),e.bool=r=>t(I.Bool.serialize(r)),e.string=r=>t(I.String.serialize(r)),e.address=r=>t(I.Address.serialize(r)),e.id=e.address,e}const Ss="object",Ts="ID",Es="ascii",vs="String",ks="string",xs="String",_s="option",As="Option",Is={address:d.SUI_FRAMEWORK_ADDRESS,module:Ss,name:Ts},Os={address:d.MOVE_STDLIB_ADDRESS,module:Es,name:vs},js={address:d.MOVE_STDLIB_ADDRESS,module:ks,name:xs},Cs={address:d.MOVE_STDLIB_ADDRESS,module:_s,name:As},Ve=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function Bs(t){var r;const e=(r=Zt(t))==null?void 0:r.Struct;return(e==null?void 0:e.address)==="0x2"&&(e==null?void 0:e.module)==="tx_context"&&(e==null?void 0:e.name)==="TxContext"}function ut(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const Ms=["Address","Bool","U8","U16","U32","U64","U128","U256"];function wt(t,e){if(typeof t=="string"&&Ms.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])ut("number",e);else if(t==="Bool")ut("boolean",e);else if(t==="Address"&&(ut("string",e),e&&!d.isValidSuiAddress(e)))throw new Error("Invalid Sui Address");return t.toLowerCase()}else if(typeof t=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(t,null,2)}`);if("Vector"in t){if((e===void 0||typeof e=="string")&&t.Vector==="U8")return"string";if(e!==void 0&&!Array.isArray(e))throw new Error(`Expect ${e} to be a array, received ${typeof e}`);const r=wt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(Ve(t.Struct,Os))return"string";if(Ve(t.Struct,js))return"utf8string";if(Ve(t.Struct,Is))return"address";if(Ve(t.Struct,Cs)){const r={Vector:t.Struct.typeArguments[0]};return wt(r,e)}}}function Ps(t,e){const r=Array.from(`${t}::`).map(s=>s.charCodeAt(0)),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),d.blake2b(n,{dkLen:32})}function R(t,e){return wr(t,e)}const Rs=t=>j([g({None:j([b(!0),b(null)])}),g({Some:t})]),Pe=j([g({kind:b("Input"),index:J(),value:w(ht()),type:w(b("object"))}),g({kind:b("Input"),index:J(),value:w(ht()),type:b("pure")})]),Ns=[Pe,g({kind:b("GasCoin")}),g({kind:b("Result"),index:J()}),g({kind:b("NestedResult"),index:J(),resultIndex:J()})],ne=j([...Ns]),Ur=g({kind:b("MoveCall"),target:D("target",h().validator),typeArguments:E(h()),arguments:E(ne)}),Dr=g({kind:b("TransferObjects"),objects:E(ne),address:ne}),zr=g({kind:b("SplitCoins"),coin:ne,amounts:E(ne)}),Vr=g({kind:b("MergeCoins"),destination:ne,sources:E(ne)}),Lr=g({kind:b("MakeMoveVec"),type:w(Rs(Z(h(),Er()))),objects:E(ne)}),qr=g({kind:b("Publish"),modules:E(E(J())),dependencies:E(h())}),Wr=g({kind:b("Upgrade"),modules:E(E(J())),dependencies:E(h()),packageId:h(),ticket:ne}),$s=[Ur,Dr,zr,Vr,qr,Wr,Lr],Us=j([...$s]),ue={MoveCall(t){return R({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},Ur)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=N.Pure(I.Address.serialize(e.value))),R({kind:"TransferObjects",objects:t,address:e},Dr)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=N.Pure(I.U64.serialize(r.value)))}),R({kind:"SplitCoins",coin:t,amounts:e},zr)},MergeCoins(t,e){return R({kind:"MergeCoins",destination:t,sources:e},Vr)},Publish({modules:t,dependencies:e}){return R({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(H(r)):r),dependencies:e.map(r=>d.normalizeSuiObjectId(r))},qr)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return R({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(H(s)):s),dependencies:e.map(s=>d.normalizeSuiObjectId(s)),packageId:r,ticket:n},Wr)},MakeMoveVec({type:t,objects:e}){return R({kind:"MakeMoveVec",type:t?{Some:te.parseFromStr(t)}:{None:null},objects:e},Lr)}},Ds=w(O(j([g({Epoch:J()}),g({None:j([b(!0),b(null)])})]))),ar=D("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),zs=g({budget:w(ar),price:w(ar),payment:w(E(oe)),owner:w(h())}),Le=g({version:b(1),sender:w(h()),expiration:Ds,gasConfig:zs,inputs:E(Pe),transactions:E(Us)});function or(t){return d.normalizeSuiAddress(t).replace("0x","")}class re{constructor(e){this.version=1,this.sender=e==null?void 0:e.sender,this.expiration=e==null?void 0:e.expiration,this.gasConfig=(e==null?void 0:e.gasConfig)??{},this.inputs=(e==null?void 0:e.inputs)??[],this.transactions=(e==null?void 0:e.transactions)??[]}static fromKindBytes(e){const r=I.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=R({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>R({kind:"Input",value:i,index:a,type:U(i,Qe)?"pure":"object"},Pe)),transactions:n.transactions},Le);return re.restore(s)}static fromBytes(e){var a;const r=I.TransactionData.parse(e),n=r==null?void 0:r.V1,s="ProgrammableTransaction"in n.kind?(a=n==null?void 0:n.kind)==null?void 0:a.ProgrammableTransaction:null;if(!n||!s)throw new Error("Unable to deserialize from bytes.");const i=R({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((o,u)=>R({kind:"Input",value:o,index:u,type:U(o,Qe)?"pure":"object"},Pe)),transactions:s.transactions},Le);return re.restore(i)}static restore(e){lt(e,Le);const r=new re;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=Ps("TransactionData",e);return d.toB58(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(f=>(lt(f.value,et),f.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return I.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,o=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const l={sender:or(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:or(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return I.TransactionData.serialize({V1:l},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return re.getDigestFromBytes(e)}snapshot(){return R(this,Le)}}var Jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},v=(t,e,r)=>(Jt(t,e,"read from private field"),r?r.call(t):e.get(t)),Y=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},qe=(t,e,r,n)=>(Jt(t,e,"write to private field"),e.set(t,r),r),B=(t,e,r)=>(Jt(t,e,"access private method"),r),S,Ae,Fe,Ie,Ke,ce,fe,Xt,Fr,Yt,Kr,Qt,Gr,er,Hr,Ge,bt;const Vs={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function Ls(t){const e={kind:"Result",index:t},r=[],n=s=>r[s]??(r[s]={kind:"NestedResult",index:t,resultIndex:s});return new Proxy(e,{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(s,i){if(i in s)return Reflect.get(s,i);if(i===Symbol.iterator)return function*(){let o=0;for(;;)yield n(o),o++};if(typeof i=="symbol")return;const a=parseInt(i,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function qs(t){const e=Zt(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Re(t){if(!t.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return t.client}const Zr=Symbol.for("@mysten/transaction"),dt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},Ws=1000n,Fs=50,Ks=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function Gs(t){return!!t&&typeof t=="object"&&t[Zr]===!0}const St=class{constructor(t){Y(this,Ae),Y(this,Ie),Y(this,ce),Y(this,Xt),Y(this,Yt),Y(this,Qt),Y(this,er),Y(this,Ge),Y(this,S,void 0),qe(this,S,new re(t?t.blockData:void 0))}static fromKind(t){const e=new St;return qe(e,S,re.fromKindBytes(typeof t=="string"?H(t):t)),e}static from(t){const e=new St;return typeof t!="string"||!t.startsWith("{")?qe(e,S,re.fromBytes(typeof t=="string"?H(t):t)):qe(e,S,re.restore(JSON.parse(t))),e}setSender(t){v(this,S).sender=t}setSenderIfNotSet(t){v(this,S).sender||(v(this,S).sender=t)}setExpiration(t){v(this,S).expiration=t}setGasPrice(t){v(this,S).gasConfig.price=String(t)}setGasBudget(t){v(this,S).gasConfig.budget=String(t)}setGasOwner(t){v(this,S).gasConfig.owner=t}setGasPayment(t){v(this,S).gasConfig.payment=t.map(e=>br(e,oe))}get blockData(){return v(this,S).snapshot()}get[Zr](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:bs((t,e)=>xt(t)?B(this,Ae,Fe).call(this,"pure",{Pure:Array.from(t.toBytes())}):B(this,Ae,Fe).call(this,"pure",t instanceof Uint8Array?N.Pure(t):e?N.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=ir(t),r=v(this,S).inputs.find(n=>n.type==="object"&&e===ir(n.value));return r&&U(r.value,mt)&&"Shared"in r.value.Object&&U(t,mt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??B(this,Ae,Fe).call(this,"object",typeof t=="string"?d.normalizeSuiAddress(t):t)}objectRef(...t){return this.object(N.ObjectRef(...t))}receivingRef(...t){return this.object(N.ReceivingRef(...t))}sharedObjectRef(...t){return this.object(N.SharedObjectRef(...t))}add(t){const e=v(this,S).transactions.push(t);return Ls(e-1)}splitCoins(t,e){return this.add(ue.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):B(this,Ie,Ke).call(this,r))))}mergeCoins(t,e){return this.add(ue.MergeCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="string"?this.object(r):r)))}publish({modules:t,dependencies:e}){return this.add(ue.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(ue.Upgrade({modules:t,dependencies:e,packageId:r,ticket:typeof n=="string"?this.object(n):n}))}moveCall({arguments:t,typeArguments:e,target:r}){return this.add(ue.MoveCall({arguments:t==null?void 0:t.map(n=>B(this,Ie,Ke).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(ue.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):B(this,Ie,Ke).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(ue.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(v(this,S).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).build({maxSizeBytes:B(this,ce,fe).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).getDigest()}};let Hs=St;S=new WeakMap;Ae=new WeakSet;Fe=function(t,e){const r=v(this,S).inputs.length,n=R({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Pe);return v(this,S).inputs.push(n),n};Ie=new WeakSet;Ke=function(t){return xt(t)?this.pure(t):t};ce=new WeakSet;fe=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return Vs[t];const n=e==null?void 0:e.attributes[dt[t]];if(!n)throw new Error(`Missing expected protocol config: "${dt[t]}"`);const s="u64"in n?n.u64:"u32"in n?n.u32:n.f64;if(!s)throw new Error(`Unexpected protocol config value found for: "${dt[t]}"`);return Number(s)};Xt=new WeakSet;Fr=function(t){const e=B(this,ce,fe).call(this,"maxPureArgumentSize",t);v(this,S).inputs.forEach((r,n)=>{if(U(r.value,Qe)&&r.value.Pure.length>e)throw new Error(`Input at index ${n} is too large, max pure input size is ${e} bytes, got ${r.value.Pure.length} bytes`)})};Yt=new WeakSet;Kr=async function(t){if(v(this,S).gasConfig.payment){const s=B(this,ce,fe).call(this,"maxGasObjects",t);if(v(this,S).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||v(this,S).gasConfig.payment)return;const e=v(this,S).gasConfig.owner??v(this,S).sender,n=(await Re(t).getCoins({owner:e,coinType:d.SUI_TYPE_ARG})).data.filter(s=>!v(this,S).inputs.find(a=>U(a.value,et)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,B(this,ce,fe).call(this,"maxGasObjects",t)-1).map(s=>({objectId:s.coinObjectId,digest:s.digest,version:s.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");this.setGasPayment(n)};Qt=new WeakSet;Gr=async function(t){t.onlyTransactionKind||v(this,S).gasConfig.price||this.setGasPrice(await Re(t).getReferenceGasPrice())};er=new WeakSet;Hr=async function(t){const{inputs:e,transactions:r}=v(this,S),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:d.normalizeSuiAddress(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!U(e[o.index].value,et))&&n.push(i),i.kind==="SplitCoins"&&i.amounts.forEach(a=>{if(a.kind==="Input"){const o=e[a.index];typeof o.value!="object"&&(o.value=N.Pure(I.U64.serialize(o.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=N.Pure(I.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,u]=i.target.split("::"),l=await Re(t).getNormalizedMoveFunction({package:d.normalizeSuiObjectId(a),module:o,function:u}),p=l.parameters.length>0&&Bs(l.parameters.at(-1))?l.parameters.slice(0,l.parameters.length-1):l.parameters;if(p.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");p.forEach((y,m)=>{const x=i.arguments[m];if(x.kind!=="Input")return;const T=e[x.index];if(U(T.value,et))return;const C=T.value,M=wt(y,C);if(M){T.value=N.Pure(C,M);return}if(Zt(y)!=null||typeof y=="object"&&"TypeParameter"in y){if(typeof C!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(C,null,2)}`);s.push({id:C,input:T,normalizedType:y});return}throw new Error(`Unknown call arg type ${JSON.stringify(y,null,2)} for value ${JSON.stringify(C,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:f})=>f))],a=Ks(i,Fs),o=(await Promise.all(a.map(f=>Re(t).multiGetObjects({ids:f,options:{showOwner:!0}})))).flat();let u=new Map(i.map((f,p)=>[f,o[p]]));const l=Array.from(u).filter(([f,p])=>p.error).map(([f,p])=>f);if(l.length)throw new Error(`The following input objects are invalid: ${l.join(", ")}`);s.forEach(({id:f,input:p,normalizedType:y})=>{var C;const m=u.get(f),x=(C=m.data)==null?void 0:C.owner,T=x&&typeof x=="object"&&"Shared"in x?x.Shared.initial_shared_version:void 0;if(T){const M=y!=null&&yt(y)==null&&$r(y)==null,se=ws(p.value)||M||y!=null&&yt(y)!=null;p.value=N.SharedObjectRef({objectId:f,initialSharedVersion:T,mutable:se})}else y&&qs(y)?p.value=N.ReceivingRef(sr(m)):p.value=N.ObjectRef(sr(m))})}};Ge=new WeakSet;bt=async function(t){if(!t.onlyTransactionKind&&!v(this,S).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([B(this,Qt,Gr).call(this,t),B(this,er,Hr).call(this,t)]),!t.onlyTransactionKind&&(await B(this,Yt,Kr).call(this,t),!v(this,S).gasConfig.budget)){const e=await Re(t).dryRunTransactionBlock({transactionBlock:v(this,S).build({maxSizeBytes:B(this,ce,fe).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(B(this,ce,fe).call(this,"maxTxGas",t)),payment:[]}}})});if(e.effects.status.status!=="success")throw new Error(`Dry run failed, could not automatically determine a budget: ${e.effects.status.error}`,{cause:e});const r=Ws*BigInt(this.blockData.gasConfig.price||1n),n=BigInt(e.effects.gasUsed.computationCost)+r,s=n+BigInt(e.effects.gasUsed.storageCost)-BigInt(e.effects.gasUsed.storageRebate);this.setGasBudget(s>n?s:n)}B(this,Xt,Fr).call(this,t)};const Zs=Symbol.for("@mysten/SuiClient");class Js{get[Zs](){return!0}constructor(e){this.transport=e.transport??new Rn({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,r){return await this.transport.request({method:e,params:r})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach(n=>{if(!n||!d.isValidSuiObjectId(d.normalizeSuiObjectId(n)))throw new Error(`Invalid Sui Object id ${n}`)}),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,(e.order||"descending")==="descending"]})}async getTransactionBlock(e){if(!d.isValidTransactionDigest(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach(n=>{if(!d.isValidTransactionDigest(n))throw new Error(`Invalid Transaction digest ${n}`)}),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock(e){return await this.transport.request({method:"sui_executeTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock),Array.isArray(e.signature)?e.signature:[e.signature],e.options,e.requestType]})}async signAndExecuteTransactionBlock({transactionBlock:e,signer:r,...n}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(r.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:a}=await r.signTransactionBlock(s);return this.executeTransactionBlock({transactionBlock:a,signature:i,...n})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach(r=>{if(!r||!d.isValidSuiObjectId(d.normalizeSuiObjectId(r)))throw new Error(`Invalid Sui Stake id ${r}`)}),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,(e.order||"descending")==="descending"]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){var n;let r;if(Gs(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=$(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=$(e.transactionBlock);else throw new Error("Unknown transaction block format.");return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,r,(n=e.gasPrice)==null?void 0:n.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e==null?void 0:e.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e==null?void 0:e.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e==null?void 0:e.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"}),r=d.fromB58(e.digest);return ge(r.slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames(e){return await this.transport.request({method:"suix_resolveNameServiceNames",params:[e.address,e.cursor,e.limit]})}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e==null?void 0:e.version]})}async waitForTransactionBlock({signal:e,timeout:r=60*1e3,pollInterval:n=2*1e3,...s}){const i=AbortSignal.timeout(r),a=new Promise((o,u)=>{i.addEventListener("abort",()=>u(i.reason))});for(a.catch(()=>{});!i.aborted;){e==null||e.throwIfAborted();try{return await this.getTransactionBlock(s)}catch{await Promise.race([new Promise(u=>setTimeout(u,n)),a])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}class Jr extends d.ChainContext{}const Tt="Sui",tr=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},Xs=(t,e)=>{try{return d.normalizeSuiType(t)===d.normalizeSuiType(e)}catch{return!1}},Ys=t=>(t==null?void 0:t.type)==="created",Qs=t=>(t==null?void 0:t.type)==="published";function ei(t){return Array.isArray(t)}function rt(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function Xr(t){return typeof t=="object"&&!ei(t)&&!rt(t)}function ti(t){return typeof t=="object"&&"id"in t}const ri=16*1024,ni=t=>I.ser("vector<u8>",t,{maxSize:ri}).toBytes(),si=async(t,e)=>{const{data:r,error:n}=await t.getObject({id:e,options:{showContent:!0}});if(n)throw new Error("Error getting object: "+n);if(!r||!rt(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return d.getPackageIdFromType(r.content.type)},Yr=async(t,e)=>{if(!d.isValidSuiAddress(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return tr(r)},ii=async(t,e)=>{let r,n;do{const a=await t.getDynamicFields({parentId:e,cursor:n});r=a.data.find(o=>o.name.type.endsWith("CurrentPackage")),n=a.hasNextPage?a.nextCursor:null}while(n&&!r);if(!r)throw new Error("CurrentPackage not found");const s=await t.getObject({id:r.objectId,options:{showContent:!0}}),i=tr(s);if(!i||!Xr(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!rt(i.value))throw new Error("Unable to get package id");return i.value.fields.package},ai=async(t,e,r)=>{let n=null,s=null,i=null,a;do{if(i=await t.getOwnedObjects({owner:r,filter:{StructType:`${e}::emitter::EmitterCap`},options:{showContent:!0},cursor:a}),!i||!i.data)throw Error("Failed to get owned objects");for(const o of i.data){if(!o.data)continue;const{version:u,objectId:l}=o.data;(n===null||u<n)&&(n=u,s=l)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},oi=async(t,e)=>{const r=new Hs,[n]=r.publish({modules:t.modules.map(s=>Array.from(d.b64.decode(s))),dependencies:t.dependencies.map(s=>d.normalizeSuiObjectId(s))});return r.transferObjects([n],r.pure(e)),r},Q=class Q extends d.PlatformContext{constructor(e,r){super(e,r??d.networkPlatformConfigs(e,Q._platform))}getRpc(e){if(e in this.config)return new Js({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new Jr(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!Q.isSupportedChain(r))throw new Error(`invalid chain for ${Tt}: ${r}`);return d.Wormhole.tokenId(r,d.SUI_COIN)}static isNativeTokenId(e,r,n){return!Q.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return d.chainToPlatform(e)===Q._platform}static async getDecimals(e,r,n){if(d.isNative(n))return d.nativeDecimals(Q._platform);const s=new d.SuiAddress(n);try{const a=await Yr(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.toString()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getCoins(e,r,n){let s=[],i=null;const a=new d.SuiAddress(r).toString();do{const o=await e.getCoins({owner:a,coinType:n,cursor:i});s=[...s,...o.data],i=o.hasNextPage?o.nextCursor:null}while(i);return s}static async getBalance(e,r,n,s){if(d.isNative(s)){const{totalBalance:a}=await r.getBalance({owner:n});return BigInt(a)}const{totalBalance:i}=await r.getBalance({owner:n,coinType:s.toString()});return BigInt(i)}static async getBalances(e,r,n,s){return(await Promise.all(s.map(async a=>{const o=await this.getBalance(e,r,n,a);return{[d.isNative(a)?"native":new d.SuiAddress(a).toString()]:o}}))).reduce((a,o)=>Object.assign(a,o),{})}static async sendWait(e,r,n){const s=[];for(const i of n){const a=await r.executeTransactionBlock(i);await r.waitForTransactionBlock({digest:a.digest}),s.push(a.digest)}return s}static async getLatestBlock(e){return Number(await e.getLatestCheckpointSequenceNumber())}static async getLatestFinalizedBlock(e){return this.getLatestBlock(e)}static chainFromChainId(e){const r=d.platformNativeChainIdToNetworkChain(Q._platform,e);if(r===void 0)throw new Error(`Unknown native chain id ${e}`);const[n,s]=r;return[n,s]}static async chainFromRpc(e){const r=await e.call("sui_getChainIdentifier",[]);return this.chainFromChainId(r)}};pe(Q,"_platform",Tt);let Ee=Q;var Ne={};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.bech32m=Et=Ne.bech32=void 0;const tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Qr={};for(let t=0;t<tt.length;t++){const e=tt.charAt(t);Qr[e]=t}function Te(t){const e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function cr(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=Te(e)^n>>5}e=Te(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=Te(e)^n&31}return e}function rr(t,e,r,n){let s=0,i=0;const a=(1<<r)-1,o=[];for(let u=0;u<t.length;++u)for(s=s<<e|t[u],i+=e;i>=r;)i-=r,o.push(s>>i&a);if(n)i>0&&o.push(s<<r-i&a);else{if(i>=e)return"Excess padding";if(s<<r-i&a)return"Non-zero padding"}return o}function ci(t){return rr(t,8,5,!0)}function ui(t){const e=rr(t,5,8,!1);if(Array.isArray(e))return e}function di(t){const e=rr(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function en(t){let e;t==="bech32"?e=1:e=734539939;function r(a,o,u){if(u=u||90,a.length+7+o.length>u)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let l=cr(a);if(typeof l=="string")throw new Error(l);let f=a+"1";for(let p=0;p<o.length;++p){const y=o[p];if(y>>5)throw new Error("Non 5-bit word");l=Te(l)^y,f+=tt.charAt(y)}for(let p=0;p<6;++p)l=Te(l);l^=e;for(let p=0;p<6;++p){const y=l>>(5-p)*5&31;f+=tt.charAt(y)}return f}function n(a,o){if(o=o||90,a.length<8)return a+" too short";if(a.length>o)return"Exceeds length limit";const u=a.toLowerCase(),l=a.toUpperCase();if(a!==u&&a!==l)return"Mixed-case string "+a;a=u;const f=a.lastIndexOf("1");if(f===-1)return"No separator character for "+a;if(f===0)return"Missing prefix for "+a;const p=a.slice(0,f),y=a.slice(f+1);if(y.length<6)return"Data too short";let m=cr(p);if(typeof m=="string")return m;const x=[];for(let T=0;T<y.length;++T){const C=y.charAt(T),M=Qr[C];if(M===void 0)return"Unknown character "+C;m=Te(m)^M,!(T+6>=y.length)&&x.push(M)}return m!==e?"Invalid checksum for "+a:{prefix:p,words:x}}function s(a,o){const u=n(a,o);if(typeof u=="object")return u}function i(a,o){const u=n(a,o);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:s,decode:i,encode:r,toWords:ci,fromWordsUnsafe:ui,fromWords:di}}var Et=Ne.bech32=en("bech32");Ne.bech32m=en("bech32m");var $e=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))($e||{});function li(t){return[t,0,0]}function tn(t,e){const r=li(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const nt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},hi={ED25519:32,Secp256k1:33,Secp256r1:33},fi={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function gi(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function pi(t,e){const r=t.toString(16);return d.hexToBytes(r.padStart(e*2,"0").slice(-32*2))}function yi(t,e){const r=pi(t,e),n=gi(r);return n===-1?new Uint8Array([0]):r.slice(n)}function mi(t,e){const r=yi(t,32);e==="accounts.google.com"&&(e="https://accounts.google.com");const n=new TextEncoder().encode(e),s=new Uint8Array(2+r.length+n.length);return s.set([nt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),d.normalizeSuiAddress(d.bytesToHex(d.blake2b(s,{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}function wi(t){if(t.length!==1)throw new Error("Invalid base64Url character: "+t);const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(t);if(r===-1)throw new Error("Invalid base64Url character: "+t);const n=r.toString(2).padStart(6,"0");return Array.from(n).map(Number)}function bi(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=wi(n);e=e.concat(s)}return e}function Si(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=bi(t);const n=e%4;if(n!==0)if(n===1)r=r.slice(2);else if(n===2)r=r.slice(4);else throw new Error(`Input (s = ${t}) is not tightly packed because i%4 = 3 (i = ${e}))`);const s=(e+t.length-1)%4;if(s!==3)if(s===2)r=r.slice(0,r.length-2);else if(s===1)r=r.slice(0,r.length-4);else throw new Error(`Input (s = ${t}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${e}))`);if(r.length%8!==0)throw new Error("We should never reach here...");const i=new Uint8Array(Math.floor(r.length/8));let a=0;for(let o=0;o<r.length;o+=8){const u=r.slice(o,o+8),l=parseInt(u.join(""),2);i[a++]=l}return new TextDecoder().decode(i)}function Ti(t){if(!(t.slice(-1)==="}"||t.slice(-1)===","))throw new Error("Invalid claim");const e=JSON.parse("{"+t.slice(0,-1)+"}");if(Object.keys(e).length!==1)throw new Error("Invalid claim");const r=Object.keys(e)[0];return[r,e[r]]}function Ei(t,e){const r=Si(t.value,t.indexMod4),[n,s]=Ti(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const vi=c.struct("ZkLoginSignature",{inputs:c.struct("ZkLoginSignatureInputs",{proofPoints:c.struct("ZkLoginSignatureInputsProofPoints",{a:c.vector(c.string()),b:c.vector(c.vector(c.string())),c:c.vector(c.string())}),issBase64Details:c.struct("ZkLoginSignatureInputsClaim",{value:c.string(),indexMod4:c.u8()}),headerBase64:c.string(),addressSeed:c.string()}),maxEpoch:c.u64(),userSignature:c.vector(c.u8())});function ki(t){return vi.parse(typeof t=="string"?H(t):t)}function xi({signature:t,signatureScheme:e,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const n=r.toRawBytes(),s=new Uint8Array(1+t.length+n.length);return s.set([nt[e]]),s.set(t,1),s.set(n,1+t.length),$(s)}function _i(t){const e=H(t),r=fi[e[0]];switch(r){case"MultiSig":const n=I.MultiSig.parse(e.slice(1));return{serializedSignature:t,signatureScheme:r,multisig:n,bytes:e};case"ZkLogin":const s=e.slice(1),{inputs:i,maxEpoch:a,userSignature:o}=ki(s),{issBase64Details:u,addressSeed:l}=i,f=Ei(u,"iss"),p=mi(BigInt(l),f);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:f,address:p,addressSeed:BigInt(l)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const y=hi[r],m=e.slice(1,e.length-y),x=e.slice(1+m.length);return{serializedSignature:t,signatureScheme:r,signature:m,publicKey:x,bytes:e};default:throw new Error("Unsupported signature scheme")}}const He=32,Ai="suiprivkey";class Ii{async signWithIntent(e,r){const n=tn(r,e),s=d.blake2b(n,{dkLen:32});return{signature:xi({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:$(e)}}async signTransactionBlock(e){return this.signWithIntent(e,$e.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(c.vector(c.u8()).serialize(e).toBytes(),$e.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class Oi extends Ii{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function ji(t,e){if(t.length!==He)throw new Error("Invalid bytes length");const r=nt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),Et.encode(Ai,Et.toWords(n))}function ur(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function Ci(t){return cn.mnemonicToSeedSync(t,"")}function Bi(t){return ge(Ci(t))}const Mi="ed25519 seed",Pi=2147483648,Ri=new RegExp("^m(\\/[0-9]+')+$"),rn=t=>t.replace("'",""),Ni=t=>{const r=d.hmac.create(d.sha512,Mi).update(Ue(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},$i=({key:t,chainCode:e},r)=>{const n=new ArrayBuffer(4);new DataView(n).setUint32(0,r);const i=new Uint8Array(1+t.length+n.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(t,1),i.set(new Uint8Array(n,0,n.byteLength),t.length+1);const a=d.hmac.create(d.sha512,e).update(i).digest(),o=a.slice(0,32),u=a.slice(32);return{key:o,chainCode:u}},Ui=t=>Ri.test(t)?!t.split("/").slice(1).map(rn).some(isNaN):!1,dr=(t,e,r=Pi)=>{if(!Ui(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=Ni(e);return t.split("/").slice(1).map(rn).map(a=>parseInt(a,10)).reduce((a,o)=>$i(a,o+r),{key:n,chainCode:s})};function nn(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}class Di{equals(e){return nn(this.toRawBytes(),e.toRawBytes())}toBase64(){return $(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return $(e)}verifyWithIntent(e,r,n){const s=tn(n,e),i=d.blake2b(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(I.vector(I.u8()).serialize(e).toBytes(),r,$e.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,$e.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return d.normalizeSuiAddress(d.bytesToHex(d.blake2b(this.toSuiBytes(),{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}}const vt=32;class sn extends Di{constructor(e){if(super(),typeof e=="string"?this.data=H(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==vt)throw new Error(`Invalid public key input. Expected ${vt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return nt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=_i(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!nn(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return d.nacl.sign.detached.verify(e,n,this.toRawBytes())}}sn.SIZE=vt;const lr="m/44'/784'/0'/0'/0'";class me extends Oi{constructor(e){super(),e?this.keypair=e:this.keypair=d.nacl.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new me(d.nacl.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==He)throw new Error(`Wrong secretKey size. Expected ${He} bytes, got ${n}.`);const s=d.nacl.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=d.nacl.sign.detached(a,s.secretKey);if(!d.nacl.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new me(s)}getPublicKey(){return new sn(this.keypair.publicKey)}getSecretKey(){return ji(this.keypair.secretKey.slice(0,He),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return d.nacl.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=lr),!ur(r))throw new Error("Invalid derivation path");const{key:n}=dr(r,Bi(e));return me.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=lr),!ur(r))throw new Error("Invalid derivation path");const{key:n}=dr(r,e);return me.fromSecretKey(n)}}async function zi(t,e){const[,r]=await Ee.chainFromRpc(t);return new Vi(r,t,me.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class Vi{constructor(e,r,n,s){pe(this,"_chain");pe(this,"_client");pe(this,"_signer");pe(this,"_debug");this._chain=e,this._client=r,this._signer=n,this._debug=s}chain(){return this._chain}address(){return this._signer.toSuiAddress()}async signAndSend(e){const r=[];for(const n of e){const{description:s,transaction:i}=n;this._debug&&console.log(`Signing ${s} for ${this.address()}`);try{const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}catch(a){throw a}}return r}}const Li={Address:d.SuiAddress,Platform:Ee,getSigner:zi,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-tNClJ60p.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-Cnr4jKbe.js")),CircleBridge:()=>Promise.resolve().then(()=>require("./index-BCqJU6-4.js"))},getChain:(t,e,r)=>new Jr(e,new Ee(t,d.applyChainsConfigConfigOverrides(t,Tt,{[e]:r})))},qi=Object.freeze(Object.defineProperty({__proto__:null,default:Li},Symbol.toStringTag,{value:"Module"}));exports.SuiPlatform=Ee;exports.getFieldsFromObjectResponse=tr;exports.getObjectFields=Yr;exports.getOldestEmitterCapObjectId=ai;exports.getOriginalPackageId=si;exports.getPackageId=ii;exports.isMoveStructId=ti;exports.isMoveStructObject=Xr;exports.isMoveStructStruct=rt;exports.isSameType=Xs;exports.isSuiCreateEvent=Ys;exports.isSuiPublishEvent=Qs;exports.publishPackage=oi;exports.sui=qi;exports.uint8ArrayToBCS=ni;
5
+ Received: "${JSON.stringify(u)}"`);let p=Object.keys(u)[0];if(p===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let y=n.indexOf(p);if(y===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${p}"`);let m=n[y],x=r[m];if(o.write8(y),x===null)return o;let T=i.indexOf(x),C=T===-1?x:l[T];{let{name:M,params:se}=this.parseTypeName(C);return this.getTypeInterface(M)._encodeRaw.call(this,o,u[p],se,f)}},function(o,u,l){let f=o.readULEB(),p=n[f],y=r[p];if(f===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${f}"`);if(y===null)return{[p]:!0};let m=i.indexOf(y),x=m===-1?y:u[m];{let{name:T,params:C}=this.parseTypeName(x);return{[p]:this.getTypeInterface(T)._decodeRaw.call(this,o,C,l)}}})}getTypeInterface(t){let e=this.types.get(t);if(typeof e=="string"){let r=[];for(;typeof e=="string";){if(r.includes(e))throw new Error(`Recursive definition found: ${r.join(" -> ")} -> ${e}`);r.push(e),e=this.types.get(e)}}if(e===void 0)throw new Error(`Type ${t} is not registered`);return e}parseTypeName(t){if(Array.isArray(t)){let[o,...u]=t;return{name:o,params:u}}if(typeof t!="string")throw new Error(`Illegal type passed as a name of the type: ${t}`);let[e,r]=this.schema.genericSeparators||["<",">"],n=t.indexOf(e),s=Array.from(t).reverse().indexOf(r);if(n===-1&&s===-1)return{name:t,params:[]};if(n===-1||s===-1)throw new Error(`Unclosed generic in name '${t}'`);let i=t.slice(0,n),a=fr(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let _=xe;_.U8="u8";_.U16="u16";_.U32="u32";_.U64="u64";_.U128="u128";_.U256="u256";_.BOOL="bool";_.VECTOR="vector";_.ADDRESS="address";_.STRING="string";_.HEX="hex-string";_.BASE58="base58-string";_.BASE64="base64-string";function mn(t){t.registerType(_.U8,function(e,r){return e.write8(r)},function(e){return e.read8()},e=>e<256),t.registerType(_.U16,function(e,r){return e.write16(r)},function(e){return e.read16()},e=>e<65536),t.registerType(_.U32,function(e,r){return e.write32(r)},function(e){return e.read32()},e=>e<=4294967296n),t.registerType(_.U64,function(e,r){return e.write64(r)},function(e){return e.read64()}),t.registerType(_.U128,function(e,r){return e.write128(r)},function(e){return e.read128()}),t.registerType(_.U256,function(e,r){return e.write256(r)},function(e){return e.read256()}),t.registerType(_.BOOL,function(e,r){return e.write8(r)},function(e){return e.read8().toString(10)==="1"}),t.registerType(_.STRING,function(e,r){return e.writeVec(Array.from(r),(n,s)=>n.write8(s.charCodeAt(0)))},function(e){return e.readVec(r=>r.read8()).map(r=>String.fromCharCode(Number(r))).join("")},e=>!0),t.registerType(_.HEX,function(e,r){return e.writeVec(Array.from(Ue(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return ge(new Uint8Array(r))}),t.registerType(_.BASE58,function(e,r){return e.writeVec(Array.from(d.fromB58(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return d.toB58(new Uint8Array(r))}),t.registerType(_.BASE64,function(e,r){return e.writeVec(Array.from(H(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return $(new Uint8Array(r))})}function wn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:yn,addressEncoding:"hex"}}class bn extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:o}=e,u=o.length===0?s:`At path: ${o.join(".")} -- ${s}`;super(i??u),i!=null&&(this.cause=u),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Sn(t){return V(t)&&typeof t[Symbol.iterator]=="function"}function V(t){return typeof t=="object"&&t!=null}function L(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function Tn(t){const{done:e,value:r}=t.next();return e?void 0:r}function En(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:s,branch:i}=e,{type:a}=r,{refinement:o,message:u=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${L(n)}\``}=t;return{value:n,type:a,refinement:o,key:s[s.length-1],path:s,branch:i,...t,message:u}}function*nr(t,e,r,n){Sn(t)||(t=[t]);for(const s of t){const i=En(s,e,r,n);i&&(yield i)}}function*_t(t,e,r={}){const{path:n=[],branch:s=[t],coerce:i=!1,mask:a=!1}=r,o={path:n,branch:s};if(i&&(t=e.coercer(t,o),a&&e.type!=="type"&&V(e.schema)&&V(t)&&!Array.isArray(t)))for(const l in t)e.schema[l]===void 0&&delete t[l];let u="valid";for(const l of e.validator(t,o))l.explanation=r.message,u="not_valid",yield[l,void 0];for(let[l,f,p]of e.entries(t,o)){const y=_t(f,p,{path:l===void 0?n:[...n,l],branch:l===void 0?s:[...s,f],coerce:i,mask:a,message:r.message});for(const m of y)m[0]?(u=m[0].refinement!=null?"not_refined":"not_valid",yield[m[0],void 0]):i&&(f=m[1],l===void 0?t=f:t instanceof Map?t.set(l,f):t instanceof Set?t.add(f):V(t)&&(f!==void 0||l in t)&&(t[l]=f))}if(u!=="not_valid")for(const l of e.refiner(t,o))l.explanation=r.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,t])}class X{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=u=>u,entries:o=function*(){}}=e;this.type=r,this.schema=n,this.entries=o,this.coercer=a,s?this.validator=(u,l)=>{const f=s(u,l);return nr(f,l,this,u)}:this.validator=()=>[],i?this.refiner=(u,l)=>{const f=i(u,l);return nr(f,l,this,u)}:this.refiner=()=>[]}assert(e,r){return lt(e,this,r)}create(e,r){return wr(e,this,r)}is(e){return U(e,this)}mask(e,r){return br(e,this,r)}validate(e,r={}){return De(e,this,r)}}function lt(t,e,r){const n=De(t,e,{message:r});if(n[0])throw n[0]}function wr(t,e,r){const n=De(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function br(t,e,r){const n=De(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function U(t,e){return!De(t,e)[0]}function De(t,e,r={}){const n=_t(t,e,r),s=Tn(n);return s[0]?[new bn(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Ce(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?kn(n):g(n)}function D(t,e){return new X({type:t,schema:null,validator:e})}function ht(){return D("any",()=>!0)}function E(t){return new X({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${L(e)}`}})}function vn(){return D("bigint",t=>typeof t=="bigint")}function P(){return D("boolean",t=>typeof t=="boolean")}function J(){return D("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${L(t)}`)}function b(t){const e=L(t),r=typeof t;return new X({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${L(n)}`}})}function Sr(){return D("never",()=>!1)}function O(t){return new X({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function he(){return D("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${L(t)}`)}function g(t){const e=t?Object.keys(t):[],r=Sr();return new X({type:"object",schema:t||null,*entries(n){if(t&&V(n)){const s=new Set(Object.keys(n));for(const i of e)s.delete(i),yield[i,n[i],t[i]];for(const i of s)yield[i,n[i],r]}},validator(n){return V(n)||`Expected an object, but received: ${L(n)}`},coercer(n){return V(n)?{...n}:n}})}function w(t){return new X({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Z(t,e){return new X({type:"record",schema:null,*entries(r){if(V(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`}})}function h(){return D("string",t=>typeof t=="string"||`Expected a string, but received: ${L(t)}`)}function Tr(t){const e=Sr();return new X({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let s=0;s<n;s++)yield[s,r[s],t[s]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${L(r)}`}})}function kn(t){const e=Object.keys(t);return new X({type:"type",schema:t,*entries(r){if(V(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`},coercer(r){return V(r)?{...r}:r}})}function j(t){const e=t.map(r=>r.type).join(" | ");return new X({type:"union",schema:null,coercer(r){for(const n of t){const[s,i]=n.validate(r,{coerce:!0});if(!s)return i}return r},validator(r,n){const s=[];for(const i of t){const[...a]=_t(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 Er(){return D("unknown",()=>!0)}const xn="0.50.1",_n="1.19.0",An={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class vr extends Error{}class kr extends vr{constructor(e,r){super(e),this.code=r,this.type=An[r]??"ServerError"}}class In extends vr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var At=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},A=(t,e,r)=>(At(t,e,"read from private field"),r?r.call(t):e.get(t)),ie=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},we=(t,e,r,n)=>(At(t,e,"write to private field"),e.set(t,r),r),On=(t,e,r,n)=>({set _(s){we(t,e,s)},get _(){return A(t,e,n)}}),xr=(t,e,r)=>(At(t,e,"access private method"),r),de,Oe,ee,le,Be,be,ft,_r,It,Ar;function jn(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const Cn={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class Bn{constructor(e,r={}){if(ie(this,ft),ie(this,It),ie(this,de,0),ie(this,Oe,0),ie(this,ee,null),ie(this,le,null),ie(this,Be,new Set),ie(this,be,new Map),this.endpoint=e,this.options={...Cn,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=jn(this.endpoint))}async makeRequest(e,r){const n=await xr(this,ft,_r).call(this);return new Promise((s,i)=>{we(this,de,A(this,de)+1),A(this,be).set(A(this,de),{resolve:s,reject:i,timeout:setTimeout(()=>{A(this,be).delete(A(this,de)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:A(this,de),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new kr(s.message,s.code);return i})}async subscribe(e){const r=new Mn(e);return A(this,Be).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}de=new WeakMap;Oe=new WeakMap;ee=new WeakMap;le=new WeakMap;Be=new WeakMap;be=new WeakMap;ft=new WeakSet;_r=function(){return A(this,le)?A(this,le):(we(this,le,new Promise(t=>{var e;(e=A(this,ee))==null||e.close(),we(this,ee,new this.options.WebSocketConstructor(this.endpoint)),A(this,ee).addEventListener("open",()=>{we(this,Oe,0),t(A(this,ee))}),A(this,ee).addEventListener("close",()=>{On(this,Oe)._++,A(this,Oe)<=this.options.maxReconnects&&setTimeout(()=>{xr(this,It,Ar).call(this)},this.options.reconnectTimeout)}),A(this,ee).addEventListener("message",({data:r})=>{let n;try{n=JSON.parse(r)}catch(s){console.error(new Error(`Failed to parse RPC message: ${r}`,{cause:s}));return}if("id"in n&&n.id!=null&&A(this,be).has(n.id)){const{resolve:s,timeout:i}=A(this,be).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;A(this,Be).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),A(this,le))};It=new WeakSet;Ar=async function(){var t;return(t=A(this,ee))==null||t.close(),we(this,le,null),Promise.allSettled([...A(this,Be)].map(e=>e.subscribe(this)))};class Mn{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:r}=this;return this.subscribed=!1,r==null?!1:(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[r]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const r=await e.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=r)}}var Ot=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},z=(t,e,r)=>(Ot(t,e,"read from private field"),r?r.call(t):e.get(t)),ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},gt=(t,e,r,n)=>(Ot(t,e,"write to private field"),e.set(t,r),r),Pn=(t,e,r)=>(Ot(t,e,"access private method"),r),_e,F,je,pt,Ir;class Rn{constructor(e){ze(this,pt),ze(this,_e,0),ze(this,F,void 0),ze(this,je,void 0),gt(this,F,e)}fetch(e,r){const n=z(this,F).fetch??globalThis.fetch;if(!this.fetch)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return n(e,r)}async request(e){var s,i;gt(this,_e,z(this,_e)+1);const r=await this.fetch(((s=z(this,F).rpc)==null?void 0:s.url)??z(this,F).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":xn,"Client-Target-Api-Version":_n,...(i=z(this,F).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:z(this,_e),method:e.method,params:e.params})});if(!r.ok)throw new In(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new kr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await Pn(this,pt,Ir).call(this).subscribe(e);return async()=>!!await r()}}_e=new WeakMap;F=new WeakMap;je=new WeakMap;pt=new WeakSet;Ir=function(){var t;if(!z(this,je)){const e=z(this,F).WebSocketConstructor??globalThis.WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");gt(this,je,new Bn(((t=z(this,F).websocket)==null?void 0:t.url)??z(this,F).url,{WebSocketConstructor:e,...z(this,F).websocket}))}return z(this,je)};const Nn=/^vector<(.+)>$/,$n=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class te{static parseFromStr(e,r=!1){if(e==="address")return{address:null};if(e==="bool")return{bool:null};if(e==="u8")return{u8:null};if(e==="u16")return{u16:null};if(e==="u32")return{u32:null};if(e==="u64")return{u64:null};if(e==="u128")return{u128:null};if(e==="u256")return{u256:null};if(e==="signer")return{signer:null};const n=e.match(Nn);if(n)return{vector:te.parseFromStr(n[1],r)};const s=e.match($n);if(s)return{struct:{address:r?d.normalizeSuiAddress(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:te.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return fr(e).map(n=>te.parseFromStr(n,r))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${te.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(te.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const k=new _({...wn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function Or(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function Un(t){return c.enum("Option",{None:null,Some:t})}function jt(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const G=c.bytes(d.SUI_ADDRESS_LENGTH).transform({input:t=>typeof t=="string"?Ue(d.normalizeSuiAddress(t)):t,output:t=>d.normalizeSuiAddress(ge(t))}),Ct=c.vector(c.u8()).transform({name:"ObjectDigest",input:t=>d.fromB58(t),output:t=>d.toB58(new Uint8Array(t))}),Me=c.struct("SuiObjectRef",{objectId:G,version:c.u64(),digest:Ct}),Bt=c.struct("SharedObjectRef",{objectId:G,initialSharedVersion:c.u64(),mutable:c.bool()}),Ye=c.enum("ObjectArg",{ImmOrOwned:Me,Shared:Bt,Receiving:Me}),Mt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:Ye,ObjVec:c.vector(Ye)}),ve=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>ve),struct:c.lazy(()=>Dt),u16:null,u32:null,u256:null}),q=jt(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()})})),Pt=c.struct("ProgrammableMoveCall",{package:G,module:c.string(),function:c.string(),type_arguments:c.vector(ve),arguments:c.vector(q)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>te.parseFromStr(i,!0));return{package:d.normalizeSuiAddress(e),module:r,function:n,type_arguments:s,arguments:t.arguments}},output:t=>({target:[t.package,t.module,t.function].join("::"),arguments:t.arguments,typeArguments:t.type_arguments.map(te.tagToString)})}),Rt=jt(c.enum("Transaction",{MoveCall:Pt,TransferObjects:c.struct("TransferObjects",{objects:c.vector(q),address:q}),SplitCoins:c.struct("SplitCoins",{coin:q,amounts:c.vector(q)}),MergeCoins:c.struct("MergeCoins",{destination:q,sources:c.vector(q)}),Publish:c.struct("Publish",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G)}),MakeMoveVec:c.struct("MakeMoveVec",{type:Un(ve),objects:c.vector(q)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G),packageId:G,ticket:q})})),Nt=c.struct("ProgrammableTransaction",{inputs:c.vector(Mt),transactions:c.vector(Rt)}),$t=c.enum("TransactionKind",{ProgrammableTransaction:Nt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Ut=c.enum("TransactionExpiration",{None:null,Epoch:Or()}),Dt=c.struct("StructTag",{address:G,module:c.string(),name:c.string(),typeParams:c.vector(ve)}),zt=c.struct("GasData",{payment:c.vector(Me),owner:G,price:c.u64(),budget:c.u64()}),Vt=c.struct("TransactionDataV1",{kind:$t,sender:G,gasData:zt,expiration:Ut}),Lt=c.enum("TransactionData",{V1:Vt}),Dn=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),zn=c.enum("IntentVersion",{V0:null}),Vn=c.enum("AppId",{Sui:null}),Ln=c.struct("Intent",{scope:Dn,version:zn,appId:Vn}),qn=c.generic(["T"],t=>c.struct("IntentMessage<T>",{intent:Ln,value:t})),qt=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())}),Wt=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())}),Ft=c.struct("MultiSigPkMap",{pubKey:Wt,weight:c.u8()}),Kt=c.struct("MultiSigPublicKey",{pk_map:c.vector(Ft),threshold:c.u16()}),jr=c.struct("MultiSig",{sigs:c.vector(qt),bitmap:c.u16(),multisig_pk:Kt}),Wn=c.vector(c.u8()).transform({input:t=>typeof t=="string"?H(t):t,output:t=>$(new Uint8Array(t))}),Cr=c.struct("SenderSignedTransaction",{intentMessage:qn(Lt),txSignatures:c.vector(Wn)}),Br=c.vector(Cr,{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:Mt,CompressedSignature:qt,GasData:zt,MultiSig:jr,MultiSigPkMap:Ft,MultiSigPublicKey:Kt,ObjectArg:Ye,ObjectDigest:Ct,ProgrammableMoveCall:Pt,ProgrammableTransaction:Nt,PublicKey:Wt,SenderSignedData:Br,SenderSignedTransaction:Cr,SharedObjectRef:Bt,StructTag:Dt,SuiObjectRef:Me,Transaction:Rt,TransactionData:Lt,TransactionDataV1:Vt,TransactionExpiration:Ut,TransactionKind:$t,TypeTag:ve,ser:k.ser.bind(k),de:k.de.bind(k),getTypeInterface:k.getTypeInterface.bind(k),hasType:k.hasType.bind(k),parseTypeName:k.parseTypeName.bind(k),registerAddressType:k.registerAddressType.bind(k),registerAlias:k.registerAlias.bind(k),registerBcsType:k.registerBcsType.bind(k),registerEnumType:k.registerEnumType.bind(k),registerStructType:k.registerStructType.bind(k),registerType:k.registerType.bind(k),types:k.types};k.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));k.registerBcsType("unsafe_u64",()=>Or());k.registerBcsType("enumKind",t=>jt(t));[G,q,Mt,qt,zt,jr,Ft,Kt,Ye,Ct,Pt,Nt,Wt,Br,Bt,Dt,Me,Rt,Lt,Vt,Ut,$t,ve].forEach(t=>{k.registerBcsType(t.name,()=>t)});const Gt=j([g({AddressOwner:h()}),g({ObjectOwner:h()}),g({Shared:g({initial_shared_version:O(h())})}),b("Immutable")]);D("SuiJsonValue",()=>!0);const Fn=j([g({u32:h()}),g({u64:h()}),g({f64:h()})]);g({attributes:Z(h(),O(Fn)),featureFlags:Z(h(),P()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});j([h(),b("package")]);const oe=g({digest:h(),objectId:h(),version:j([he(),h(),vn()])});g({owner:Gt,reference:oe});g({objectId:h(),sequenceNumber:h()});g({payment:E(oe),owner:h(),price:h(),budget:h()});const Kn=Ce(oe,g({type:h(),owner:Gt,previousTransaction:h()})),Gn=Z(h(),ht()),Hn=Z(h(),Er()),Zn=g({type:h(),fields:Gn,hasPublicTransfer:P()}),Jn=g({disassembled:Hn}),Xn=j([Ce(Zn,g({dataType:b("moveObject")})),Ce(Jn,g({dataType:b("package")}))]),Yn=g({type:h(),hasPublicTransfer:P(),version:h(),bcsBytes:h()}),Qn=g({id:h(),moduleMap:Z(h(),h())}),es=j([Ce(Yn,g({dataType:b("moveObject")})),Ce(Qn,g({dataType:b("package")}))]);BigInt(1e9);const Mr=g({code:h(),error:w(h()),object_id:w(h()),parent_object_id:w(h()),version:w(h()),digest:w(h())}),ts=g({data:O(w(Z(h(),h()))),error:O(w(Mr))}),rs=j([ts,w(Z(h(),h()))]),Pr=g({objectId:h(),version:h(),digest:h(),type:O(w(h())),content:O(w(Xn)),bcs:O(w(es)),owner:O(w(Gt)),previousTransaction:O(w(h())),storageRebate:O(w(h())),display:O(w(rs))});g({showType:O(w(P())),showContent:O(w(P())),showBcs:O(w(P())),showOwner:O(w(P())),showPreviousTransaction:O(w(P())),showStorageRebate:O(w(P())),showDisplay:O(w(P()))});j([b("Exists"),b("notExists"),b("Deleted")]);E(Kn);const ns=g({data:O(w(Pr)),error:O(w(Mr))});function ss(t){return t.data}function is(t){if(t.error&&"object_id"in t.error&&"version"in t.error&&"digest"in t.error){const e=t.error;return{objectId:e.object_id,version:e.version,digest:e.digest}}}function sr(t){if("reference"in t)return t.reference;const e=ss(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:is(t)}g({objectId:h(),atCheckpoint:w(he())});g({data:E(ns),nextCursor:w(O(h())),hasNextPage:P()});j([g({details:Pr,status:b("VersionFound")}),g({details:h(),status:b("ObjectNotExists")}),g({details:oe,status:b("ObjectDeleted")}),g({details:Tr([h(),he()]),status:b("VersionNotFound")}),g({details:g({asked_version:he(),latest_version:he(),object_id:h()}),status:b("VersionTooHigh")})]);const as=j([h(),g({Object:h()})]);E(as);const os=g({address:h(),name:h()}),cs=j([b("Private"),b("Public"),b("Friend")]),Ht=g({abilities:E(h())}),us=g({constraints:Ht,isPhantom:P()}),ds=g({TypeParameter:he()}),ct=Tr([g({module:h(),package:h(),function:h()}),h()]);g({rank3Days:E(ct),rank7Days:E(ct),rank30Days:E(ct)});function Rr(t){if(!t)return!1;if(typeof t=="string"||U(t,ds)||Nr(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(U(e.Reference,Se)||U(e.MutableReference,Se)||U(e.Vector,Se))}const Se=D("SuiMoveNormalizedType",Rr);function Nr(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=>Rr(n)))}D("SuiMoveNormalizedStructType",Nr);const ls=g({visibility:cs,isEntry:P(),typeParameters:E(Ht),parameters:E(Se),return:E(Se)}),hs=g({name:h(),type:Se}),fs=g({abilities:Ht,typeParameters:E(us),fields:E(hs)}),gs=g({fileFormatVersion:he(),address:h(),name:h(),friends:E(os),structs:Z(h(),fs),exposedFunctions:Z(h(),ls)});Z(h(),gs);function yt(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function $r(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function Zt(t){if(typeof t=="object"&&"Struct"in t)return t;const e=$r(t),r=yt(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const ps=j([g({ImmOrOwned:oe}),g({Shared:g({objectId:h(),initialSharedVersion:j([J(),h()]),mutable:P()})}),g({Receiving:oe})]),Qe=g({Pure:E(J())}),mt=g({Object:ps}),et=j([Qe,mt]);function ys(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:xt(t)?t.toBytes():I.ser(e,t,{maxSize:1/0}).toBytes())}}const N={Pure:ys,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:d.normalizeSuiAddress(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}}};function ir(t){return typeof t=="string"?d.normalizeSuiAddress(t):"ImmOrOwned"in t.Object?d.normalizeSuiAddress(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?d.normalizeSuiAddress(t.Object.Receiving.objectId):d.normalizeSuiAddress(t.Object.Shared.objectId)}function ms(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function ws(t){var e;return((e=ms(t))==null?void 0:e.mutable)??!1}function bs(t){function e(r,n){return t(r,n)}return e.u8=r=>t(I.U8.serialize(r)),e.u16=r=>t(I.U16.serialize(r)),e.u32=r=>t(I.U32.serialize(r)),e.u64=r=>t(I.U64.serialize(r)),e.u128=r=>t(I.U128.serialize(r)),e.u256=r=>t(I.U256.serialize(r)),e.bool=r=>t(I.Bool.serialize(r)),e.string=r=>t(I.String.serialize(r)),e.address=r=>t(I.Address.serialize(r)),e.id=e.address,e}const Ss="object",Ts="ID",Es="ascii",vs="String",ks="string",xs="String",_s="option",As="Option",Is={address:d.SUI_FRAMEWORK_ADDRESS,module:Ss,name:Ts},Os={address:d.MOVE_STDLIB_ADDRESS,module:Es,name:vs},js={address:d.MOVE_STDLIB_ADDRESS,module:ks,name:xs},Cs={address:d.MOVE_STDLIB_ADDRESS,module:_s,name:As},Ve=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function Bs(t){var r;const e=(r=Zt(t))==null?void 0:r.Struct;return(e==null?void 0:e.address)==="0x2"&&(e==null?void 0:e.module)==="tx_context"&&(e==null?void 0:e.name)==="TxContext"}function ut(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const Ms=["Address","Bool","U8","U16","U32","U64","U128","U256"];function wt(t,e){if(typeof t=="string"&&Ms.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])ut("number",e);else if(t==="Bool")ut("boolean",e);else if(t==="Address"&&(ut("string",e),e&&!d.isValidSuiAddress(e)))throw new Error("Invalid Sui Address");return t.toLowerCase()}else if(typeof t=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(t,null,2)}`);if("Vector"in t){if((e===void 0||typeof e=="string")&&t.Vector==="U8")return"string";if(e!==void 0&&!Array.isArray(e))throw new Error(`Expect ${e} to be a array, received ${typeof e}`);const r=wt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(Ve(t.Struct,Os))return"string";if(Ve(t.Struct,js))return"utf8string";if(Ve(t.Struct,Is))return"address";if(Ve(t.Struct,Cs)){const r={Vector:t.Struct.typeArguments[0]};return wt(r,e)}}}function Ps(t,e){const r=Array.from(`${t}::`).map(s=>s.charCodeAt(0)),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),d.blake2b(n,{dkLen:32})}function R(t,e){return wr(t,e)}const Rs=t=>j([g({None:j([b(!0),b(null)])}),g({Some:t})]),Pe=j([g({kind:b("Input"),index:J(),value:w(ht()),type:w(b("object"))}),g({kind:b("Input"),index:J(),value:w(ht()),type:b("pure")})]),Ns=[Pe,g({kind:b("GasCoin")}),g({kind:b("Result"),index:J()}),g({kind:b("NestedResult"),index:J(),resultIndex:J()})],ne=j([...Ns]),Ur=g({kind:b("MoveCall"),target:D("target",h().validator),typeArguments:E(h()),arguments:E(ne)}),Dr=g({kind:b("TransferObjects"),objects:E(ne),address:ne}),zr=g({kind:b("SplitCoins"),coin:ne,amounts:E(ne)}),Vr=g({kind:b("MergeCoins"),destination:ne,sources:E(ne)}),Lr=g({kind:b("MakeMoveVec"),type:w(Rs(Z(h(),Er()))),objects:E(ne)}),qr=g({kind:b("Publish"),modules:E(E(J())),dependencies:E(h())}),Wr=g({kind:b("Upgrade"),modules:E(E(J())),dependencies:E(h()),packageId:h(),ticket:ne}),$s=[Ur,Dr,zr,Vr,qr,Wr,Lr],Us=j([...$s]),ue={MoveCall(t){return R({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},Ur)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=N.Pure(I.Address.serialize(e.value))),R({kind:"TransferObjects",objects:t,address:e},Dr)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=N.Pure(I.U64.serialize(r.value)))}),R({kind:"SplitCoins",coin:t,amounts:e},zr)},MergeCoins(t,e){return R({kind:"MergeCoins",destination:t,sources:e},Vr)},Publish({modules:t,dependencies:e}){return R({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(H(r)):r),dependencies:e.map(r=>d.normalizeSuiObjectId(r))},qr)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return R({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(H(s)):s),dependencies:e.map(s=>d.normalizeSuiObjectId(s)),packageId:r,ticket:n},Wr)},MakeMoveVec({type:t,objects:e}){return R({kind:"MakeMoveVec",type:t?{Some:te.parseFromStr(t)}:{None:null},objects:e},Lr)}},Ds=w(O(j([g({Epoch:J()}),g({None:j([b(!0),b(null)])})]))),ar=D("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),zs=g({budget:w(ar),price:w(ar),payment:w(E(oe)),owner:w(h())}),Le=g({version:b(1),sender:w(h()),expiration:Ds,gasConfig:zs,inputs:E(Pe),transactions:E(Us)});function or(t){return d.normalizeSuiAddress(t).replace("0x","")}class re{constructor(e){this.version=1,this.sender=e==null?void 0:e.sender,this.expiration=e==null?void 0:e.expiration,this.gasConfig=(e==null?void 0:e.gasConfig)??{},this.inputs=(e==null?void 0:e.inputs)??[],this.transactions=(e==null?void 0:e.transactions)??[]}static fromKindBytes(e){const r=I.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=R({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>R({kind:"Input",value:i,index:a,type:U(i,Qe)?"pure":"object"},Pe)),transactions:n.transactions},Le);return re.restore(s)}static fromBytes(e){var a;const r=I.TransactionData.parse(e),n=r==null?void 0:r.V1,s="ProgrammableTransaction"in n.kind?(a=n==null?void 0:n.kind)==null?void 0:a.ProgrammableTransaction:null;if(!n||!s)throw new Error("Unable to deserialize from bytes.");const i=R({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((o,u)=>R({kind:"Input",value:o,index:u,type:U(o,Qe)?"pure":"object"},Pe)),transactions:s.transactions},Le);return re.restore(i)}static restore(e){lt(e,Le);const r=new re;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=Ps("TransactionData",e);return d.toB58(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(f=>(lt(f.value,et),f.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return I.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,o=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const l={sender:or(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:or(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return I.TransactionData.serialize({V1:l},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return re.getDigestFromBytes(e)}snapshot(){return R(this,Le)}}var Jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},v=(t,e,r)=>(Jt(t,e,"read from private field"),r?r.call(t):e.get(t)),Y=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},qe=(t,e,r,n)=>(Jt(t,e,"write to private field"),e.set(t,r),r),B=(t,e,r)=>(Jt(t,e,"access private method"),r),S,Ae,Fe,Ie,Ke,ce,fe,Xt,Fr,Yt,Kr,Qt,Gr,er,Hr,Ge,bt;const Vs={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function Ls(t){const e={kind:"Result",index:t},r=[],n=s=>r[s]??(r[s]={kind:"NestedResult",index:t,resultIndex:s});return new Proxy(e,{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(s,i){if(i in s)return Reflect.get(s,i);if(i===Symbol.iterator)return function*(){let o=0;for(;;)yield n(o),o++};if(typeof i=="symbol")return;const a=parseInt(i,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function qs(t){const e=Zt(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Re(t){if(!t.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return t.client}const Zr=Symbol.for("@mysten/transaction"),dt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},Ws=1000n,Fs=50,Ks=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function Gs(t){return!!t&&typeof t=="object"&&t[Zr]===!0}const St=class{constructor(t){Y(this,Ae),Y(this,Ie),Y(this,ce),Y(this,Xt),Y(this,Yt),Y(this,Qt),Y(this,er),Y(this,Ge),Y(this,S,void 0),qe(this,S,new re(t?t.blockData:void 0))}static fromKind(t){const e=new St;return qe(e,S,re.fromKindBytes(typeof t=="string"?H(t):t)),e}static from(t){const e=new St;return typeof t!="string"||!t.startsWith("{")?qe(e,S,re.fromBytes(typeof t=="string"?H(t):t)):qe(e,S,re.restore(JSON.parse(t))),e}setSender(t){v(this,S).sender=t}setSenderIfNotSet(t){v(this,S).sender||(v(this,S).sender=t)}setExpiration(t){v(this,S).expiration=t}setGasPrice(t){v(this,S).gasConfig.price=String(t)}setGasBudget(t){v(this,S).gasConfig.budget=String(t)}setGasOwner(t){v(this,S).gasConfig.owner=t}setGasPayment(t){v(this,S).gasConfig.payment=t.map(e=>br(e,oe))}get blockData(){return v(this,S).snapshot()}get[Zr](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:bs((t,e)=>xt(t)?B(this,Ae,Fe).call(this,"pure",{Pure:Array.from(t.toBytes())}):B(this,Ae,Fe).call(this,"pure",t instanceof Uint8Array?N.Pure(t):e?N.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=ir(t),r=v(this,S).inputs.find(n=>n.type==="object"&&e===ir(n.value));return r&&U(r.value,mt)&&"Shared"in r.value.Object&&U(t,mt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??B(this,Ae,Fe).call(this,"object",typeof t=="string"?d.normalizeSuiAddress(t):t)}objectRef(...t){return this.object(N.ObjectRef(...t))}receivingRef(...t){return this.object(N.ReceivingRef(...t))}sharedObjectRef(...t){return this.object(N.SharedObjectRef(...t))}add(t){const e=v(this,S).transactions.push(t);return Ls(e-1)}splitCoins(t,e){return this.add(ue.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):B(this,Ie,Ke).call(this,r))))}mergeCoins(t,e){return this.add(ue.MergeCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="string"?this.object(r):r)))}publish({modules:t,dependencies:e}){return this.add(ue.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(ue.Upgrade({modules:t,dependencies:e,packageId:r,ticket:typeof n=="string"?this.object(n):n}))}moveCall({arguments:t,typeArguments:e,target:r}){return this.add(ue.MoveCall({arguments:t==null?void 0:t.map(n=>B(this,Ie,Ke).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(ue.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):B(this,Ie,Ke).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(ue.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(v(this,S).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).build({maxSizeBytes:B(this,ce,fe).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).getDigest()}};let Hs=St;S=new WeakMap;Ae=new WeakSet;Fe=function(t,e){const r=v(this,S).inputs.length,n=R({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Pe);return v(this,S).inputs.push(n),n};Ie=new WeakSet;Ke=function(t){return xt(t)?this.pure(t):t};ce=new WeakSet;fe=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return Vs[t];const n=e==null?void 0:e.attributes[dt[t]];if(!n)throw new Error(`Missing expected protocol config: "${dt[t]}"`);const s="u64"in n?n.u64:"u32"in n?n.u32:n.f64;if(!s)throw new Error(`Unexpected protocol config value found for: "${dt[t]}"`);return Number(s)};Xt=new WeakSet;Fr=function(t){const e=B(this,ce,fe).call(this,"maxPureArgumentSize",t);v(this,S).inputs.forEach((r,n)=>{if(U(r.value,Qe)&&r.value.Pure.length>e)throw new Error(`Input at index ${n} is too large, max pure input size is ${e} bytes, got ${r.value.Pure.length} bytes`)})};Yt=new WeakSet;Kr=async function(t){if(v(this,S).gasConfig.payment){const s=B(this,ce,fe).call(this,"maxGasObjects",t);if(v(this,S).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||v(this,S).gasConfig.payment)return;const e=v(this,S).gasConfig.owner??v(this,S).sender,n=(await Re(t).getCoins({owner:e,coinType:d.SUI_TYPE_ARG})).data.filter(s=>!v(this,S).inputs.find(a=>U(a.value,et)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,B(this,ce,fe).call(this,"maxGasObjects",t)-1).map(s=>({objectId:s.coinObjectId,digest:s.digest,version:s.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");this.setGasPayment(n)};Qt=new WeakSet;Gr=async function(t){t.onlyTransactionKind||v(this,S).gasConfig.price||this.setGasPrice(await Re(t).getReferenceGasPrice())};er=new WeakSet;Hr=async function(t){const{inputs:e,transactions:r}=v(this,S),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:d.normalizeSuiAddress(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!U(e[o.index].value,et))&&n.push(i),i.kind==="SplitCoins"&&i.amounts.forEach(a=>{if(a.kind==="Input"){const o=e[a.index];typeof o.value!="object"&&(o.value=N.Pure(I.U64.serialize(o.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=N.Pure(I.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,u]=i.target.split("::"),l=await Re(t).getNormalizedMoveFunction({package:d.normalizeSuiObjectId(a),module:o,function:u}),p=l.parameters.length>0&&Bs(l.parameters.at(-1))?l.parameters.slice(0,l.parameters.length-1):l.parameters;if(p.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");p.forEach((y,m)=>{const x=i.arguments[m];if(x.kind!=="Input")return;const T=e[x.index];if(U(T.value,et))return;const C=T.value,M=wt(y,C);if(M){T.value=N.Pure(C,M);return}if(Zt(y)!=null||typeof y=="object"&&"TypeParameter"in y){if(typeof C!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(C,null,2)}`);s.push({id:C,input:T,normalizedType:y});return}throw new Error(`Unknown call arg type ${JSON.stringify(y,null,2)} for value ${JSON.stringify(C,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:f})=>f))],a=Ks(i,Fs),o=(await Promise.all(a.map(f=>Re(t).multiGetObjects({ids:f,options:{showOwner:!0}})))).flat();let u=new Map(i.map((f,p)=>[f,o[p]]));const l=Array.from(u).filter(([f,p])=>p.error).map(([f,p])=>f);if(l.length)throw new Error(`The following input objects are invalid: ${l.join(", ")}`);s.forEach(({id:f,input:p,normalizedType:y})=>{var C;const m=u.get(f),x=(C=m.data)==null?void 0:C.owner,T=x&&typeof x=="object"&&"Shared"in x?x.Shared.initial_shared_version:void 0;if(T){const M=y!=null&&yt(y)==null&&$r(y)==null,se=ws(p.value)||M||y!=null&&yt(y)!=null;p.value=N.SharedObjectRef({objectId:f,initialSharedVersion:T,mutable:se})}else y&&qs(y)?p.value=N.ReceivingRef(sr(m)):p.value=N.ObjectRef(sr(m))})}};Ge=new WeakSet;bt=async function(t){if(!t.onlyTransactionKind&&!v(this,S).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([B(this,Qt,Gr).call(this,t),B(this,er,Hr).call(this,t)]),!t.onlyTransactionKind&&(await B(this,Yt,Kr).call(this,t),!v(this,S).gasConfig.budget)){const e=await Re(t).dryRunTransactionBlock({transactionBlock:v(this,S).build({maxSizeBytes:B(this,ce,fe).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(B(this,ce,fe).call(this,"maxTxGas",t)),payment:[]}}})});if(e.effects.status.status!=="success")throw new Error(`Dry run failed, could not automatically determine a budget: ${e.effects.status.error}`,{cause:e});const r=Ws*BigInt(this.blockData.gasConfig.price||1n),n=BigInt(e.effects.gasUsed.computationCost)+r,s=n+BigInt(e.effects.gasUsed.storageCost)-BigInt(e.effects.gasUsed.storageRebate);this.setGasBudget(s>n?s:n)}B(this,Xt,Fr).call(this,t)};const Zs=Symbol.for("@mysten/SuiClient");class Js{get[Zs](){return!0}constructor(e){this.transport=e.transport??new Rn({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,r){return await this.transport.request({method:e,params:r})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach(n=>{if(!n||!d.isValidSuiObjectId(d.normalizeSuiObjectId(n)))throw new Error(`Invalid Sui Object id ${n}`)}),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,(e.order||"descending")==="descending"]})}async getTransactionBlock(e){if(!d.isValidTransactionDigest(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach(n=>{if(!d.isValidTransactionDigest(n))throw new Error(`Invalid Transaction digest ${n}`)}),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock(e){return await this.transport.request({method:"sui_executeTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock),Array.isArray(e.signature)?e.signature:[e.signature],e.options,e.requestType]})}async signAndExecuteTransactionBlock({transactionBlock:e,signer:r,...n}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(r.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:a}=await r.signTransactionBlock(s);return this.executeTransactionBlock({transactionBlock:a,signature:i,...n})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach(r=>{if(!r||!d.isValidSuiObjectId(d.normalizeSuiObjectId(r)))throw new Error(`Invalid Sui Stake id ${r}`)}),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,(e.order||"descending")==="descending"]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){var n;let r;if(Gs(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=$(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=$(e.transactionBlock);else throw new Error("Unknown transaction block format.");return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,r,(n=e.gasPrice)==null?void 0:n.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e==null?void 0:e.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e==null?void 0:e.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e==null?void 0:e.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"}),r=d.fromB58(e.digest);return ge(r.slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames(e){return await this.transport.request({method:"suix_resolveNameServiceNames",params:[e.address,e.cursor,e.limit]})}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e==null?void 0:e.version]})}async waitForTransactionBlock({signal:e,timeout:r=60*1e3,pollInterval:n=2*1e3,...s}){const i=AbortSignal.timeout(r),a=new Promise((o,u)=>{i.addEventListener("abort",()=>u(i.reason))});for(a.catch(()=>{});!i.aborted;){e==null||e.throwIfAborted();try{return await this.getTransactionBlock(s)}catch{await Promise.race([new Promise(u=>setTimeout(u,n)),a])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}class Jr extends d.ChainContext{}const Tt="Sui",tr=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},Xs=(t,e)=>{try{return d.normalizeSuiType(t)===d.normalizeSuiType(e)}catch{return!1}},Ys=t=>(t==null?void 0:t.type)==="created",Qs=t=>(t==null?void 0:t.type)==="published";function ei(t){return Array.isArray(t)}function rt(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function Xr(t){return typeof t=="object"&&!ei(t)&&!rt(t)}function ti(t){return typeof t=="object"&&"id"in t}const ri=16*1024,ni=t=>I.ser("vector<u8>",t,{maxSize:ri}).toBytes(),si=async(t,e)=>{const{data:r,error:n}=await t.getObject({id:e,options:{showContent:!0}});if(n)throw new Error("Error getting object: "+n);if(!r||!rt(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return d.getPackageIdFromType(r.content.type)},Yr=async(t,e)=>{if(!d.isValidSuiAddress(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return tr(r)},ii=async(t,e)=>{let r,n;do{const a=await t.getDynamicFields({parentId:e,cursor:n});r=a.data.find(o=>o.name.type.endsWith("CurrentPackage")),n=a.hasNextPage?a.nextCursor:null}while(n&&!r);if(!r)throw new Error("CurrentPackage not found");const s=await t.getObject({id:r.objectId,options:{showContent:!0}}),i=tr(s);if(!i||!Xr(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!rt(i.value))throw new Error("Unable to get package id");return i.value.fields.package},ai=async(t,e,r)=>{let n=null,s=null,i=null,a;do{if(i=await t.getOwnedObjects({owner:r,filter:{StructType:`${e}::emitter::EmitterCap`},options:{showContent:!0},cursor:a}),!i||!i.data)throw Error("Failed to get owned objects");for(const o of i.data){if(!o.data)continue;const{version:u,objectId:l}=o.data;(n===null||u<n)&&(n=u,s=l)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},oi=async(t,e)=>{const r=new Hs,[n]=r.publish({modules:t.modules.map(s=>Array.from(d.b64.decode(s))),dependencies:t.dependencies.map(s=>d.normalizeSuiObjectId(s))});return r.transferObjects([n],r.pure(e)),r},Q=class Q extends d.PlatformContext{constructor(e,r){super(e,r??d.networkPlatformConfigs(e,Q._platform))}getRpc(e){if(e in this.config)return new Js({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new Jr(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!Q.isSupportedChain(r))throw new Error(`invalid chain for ${Tt}: ${r}`);return d.Wormhole.tokenId(r,d.SUI_COIN)}static isNativeTokenId(e,r,n){return!Q.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return d.chainToPlatform(e)===Q._platform}static async getDecimals(e,r,n){if(d.isNative(n))return d.nativeDecimals(Q._platform);const s=new d.SuiAddress(n);try{const a=await Yr(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.toString()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getCoins(e,r,n){let s=[],i=null;const a=new d.SuiAddress(r).toString();do{const o=await e.getCoins({owner:a,coinType:n,cursor:i});s=[...s,...o.data],i=o.hasNextPage?o.nextCursor:null}while(i);return s}static async getBalance(e,r,n,s){if(d.isNative(s)){const{totalBalance:a}=await r.getBalance({owner:n});return BigInt(a)}const{totalBalance:i}=await r.getBalance({owner:n,coinType:s.toString()});return BigInt(i)}static async getBalances(e,r,n,s){return(await Promise.all(s.map(async a=>{const o=await this.getBalance(e,r,n,a);return{[d.isNative(a)?"native":new d.SuiAddress(a).toString()]:o}}))).reduce((a,o)=>Object.assign(a,o),{})}static async sendWait(e,r,n){const s=[];for(const i of n){const a=await r.executeTransactionBlock(i);await r.waitForTransactionBlock({digest:a.digest}),s.push(a.digest)}return s}static async getLatestBlock(e){return Number(await e.getLatestCheckpointSequenceNumber())}static async getLatestFinalizedBlock(e){return this.getLatestBlock(e)}static chainFromChainId(e){const r=d.platformNativeChainIdToNetworkChain(Q._platform,e);if(r===void 0)throw new Error(`Unknown native chain id ${e}`);const[n,s]=r;return[n,s]}static async chainFromRpc(e){const r=await e.call("sui_getChainIdentifier",[]);return this.chainFromChainId(r)}};pe(Q,"_platform",Tt);let Ee=Q;var Ne={};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.bech32m=Et=Ne.bech32=void 0;const tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Qr={};for(let t=0;t<tt.length;t++){const e=tt.charAt(t);Qr[e]=t}function Te(t){const e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function cr(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=Te(e)^n>>5}e=Te(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=Te(e)^n&31}return e}function rr(t,e,r,n){let s=0,i=0;const a=(1<<r)-1,o=[];for(let u=0;u<t.length;++u)for(s=s<<e|t[u],i+=e;i>=r;)i-=r,o.push(s>>i&a);if(n)i>0&&o.push(s<<r-i&a);else{if(i>=e)return"Excess padding";if(s<<r-i&a)return"Non-zero padding"}return o}function ci(t){return rr(t,8,5,!0)}function ui(t){const e=rr(t,5,8,!1);if(Array.isArray(e))return e}function di(t){const e=rr(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function en(t){let e;t==="bech32"?e=1:e=734539939;function r(a,o,u){if(u=u||90,a.length+7+o.length>u)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let l=cr(a);if(typeof l=="string")throw new Error(l);let f=a+"1";for(let p=0;p<o.length;++p){const y=o[p];if(y>>5)throw new Error("Non 5-bit word");l=Te(l)^y,f+=tt.charAt(y)}for(let p=0;p<6;++p)l=Te(l);l^=e;for(let p=0;p<6;++p){const y=l>>(5-p)*5&31;f+=tt.charAt(y)}return f}function n(a,o){if(o=o||90,a.length<8)return a+" too short";if(a.length>o)return"Exceeds length limit";const u=a.toLowerCase(),l=a.toUpperCase();if(a!==u&&a!==l)return"Mixed-case string "+a;a=u;const f=a.lastIndexOf("1");if(f===-1)return"No separator character for "+a;if(f===0)return"Missing prefix for "+a;const p=a.slice(0,f),y=a.slice(f+1);if(y.length<6)return"Data too short";let m=cr(p);if(typeof m=="string")return m;const x=[];for(let T=0;T<y.length;++T){const C=y.charAt(T),M=Qr[C];if(M===void 0)return"Unknown character "+C;m=Te(m)^M,!(T+6>=y.length)&&x.push(M)}return m!==e?"Invalid checksum for "+a:{prefix:p,words:x}}function s(a,o){const u=n(a,o);if(typeof u=="object")return u}function i(a,o){const u=n(a,o);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:s,decode:i,encode:r,toWords:ci,fromWordsUnsafe:ui,fromWords:di}}var Et=Ne.bech32=en("bech32");Ne.bech32m=en("bech32m");var $e=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))($e||{});function li(t){return[t,0,0]}function tn(t,e){const r=li(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const nt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},hi={ED25519:32,Secp256k1:33,Secp256r1:33},fi={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function gi(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function pi(t,e){const r=t.toString(16);return d.hexToBytes(r.padStart(e*2,"0").slice(-32*2))}function yi(t,e){const r=pi(t,e),n=gi(r);return n===-1?new Uint8Array([0]):r.slice(n)}function mi(t,e){const r=yi(t,32);e==="accounts.google.com"&&(e="https://accounts.google.com");const n=new TextEncoder().encode(e),s=new Uint8Array(2+r.length+n.length);return s.set([nt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),d.normalizeSuiAddress(d.bytesToHex(d.blake2b(s,{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}function wi(t){if(t.length!==1)throw new Error("Invalid base64Url character: "+t);const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(t);if(r===-1)throw new Error("Invalid base64Url character: "+t);const n=r.toString(2).padStart(6,"0");return Array.from(n).map(Number)}function bi(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=wi(n);e=e.concat(s)}return e}function Si(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=bi(t);const n=e%4;if(n!==0)if(n===1)r=r.slice(2);else if(n===2)r=r.slice(4);else throw new Error(`Input (s = ${t}) is not tightly packed because i%4 = 3 (i = ${e}))`);const s=(e+t.length-1)%4;if(s!==3)if(s===2)r=r.slice(0,r.length-2);else if(s===1)r=r.slice(0,r.length-4);else throw new Error(`Input (s = ${t}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${e}))`);if(r.length%8!==0)throw new Error("We should never reach here...");const i=new Uint8Array(Math.floor(r.length/8));let a=0;for(let o=0;o<r.length;o+=8){const u=r.slice(o,o+8),l=parseInt(u.join(""),2);i[a++]=l}return new TextDecoder().decode(i)}function Ti(t){if(!(t.slice(-1)==="}"||t.slice(-1)===","))throw new Error("Invalid claim");const e=JSON.parse("{"+t.slice(0,-1)+"}");if(Object.keys(e).length!==1)throw new Error("Invalid claim");const r=Object.keys(e)[0];return[r,e[r]]}function Ei(t,e){const r=Si(t.value,t.indexMod4),[n,s]=Ti(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const vi=c.struct("ZkLoginSignature",{inputs:c.struct("ZkLoginSignatureInputs",{proofPoints:c.struct("ZkLoginSignatureInputsProofPoints",{a:c.vector(c.string()),b:c.vector(c.vector(c.string())),c:c.vector(c.string())}),issBase64Details:c.struct("ZkLoginSignatureInputsClaim",{value:c.string(),indexMod4:c.u8()}),headerBase64:c.string(),addressSeed:c.string()}),maxEpoch:c.u64(),userSignature:c.vector(c.u8())});function ki(t){return vi.parse(typeof t=="string"?H(t):t)}function xi({signature:t,signatureScheme:e,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const n=r.toRawBytes(),s=new Uint8Array(1+t.length+n.length);return s.set([nt[e]]),s.set(t,1),s.set(n,1+t.length),$(s)}function _i(t){const e=H(t),r=fi[e[0]];switch(r){case"MultiSig":const n=I.MultiSig.parse(e.slice(1));return{serializedSignature:t,signatureScheme:r,multisig:n,bytes:e};case"ZkLogin":const s=e.slice(1),{inputs:i,maxEpoch:a,userSignature:o}=ki(s),{issBase64Details:u,addressSeed:l}=i,f=Ei(u,"iss"),p=mi(BigInt(l),f);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:f,address:p,addressSeed:BigInt(l)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const y=hi[r],m=e.slice(1,e.length-y),x=e.slice(1+m.length);return{serializedSignature:t,signatureScheme:r,signature:m,publicKey:x,bytes:e};default:throw new Error("Unsupported signature scheme")}}const He=32,Ai="suiprivkey";class Ii{async signWithIntent(e,r){const n=tn(r,e),s=d.blake2b(n,{dkLen:32});return{signature:xi({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:$(e)}}async signTransactionBlock(e){return this.signWithIntent(e,$e.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(c.vector(c.u8()).serialize(e).toBytes(),$e.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class Oi extends Ii{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function ji(t,e){if(t.length!==He)throw new Error("Invalid bytes length");const r=nt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),Et.encode(Ai,Et.toWords(n))}function ur(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function Ci(t){return cn.mnemonicToSeedSync(t,"")}function Bi(t){return ge(Ci(t))}const Mi="ed25519 seed",Pi=2147483648,Ri=new RegExp("^m(\\/[0-9]+')+$"),rn=t=>t.replace("'",""),Ni=t=>{const r=d.hmac.create(d.sha512,Mi).update(Ue(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},$i=({key:t,chainCode:e},r)=>{const n=new ArrayBuffer(4);new DataView(n).setUint32(0,r);const i=new Uint8Array(1+t.length+n.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(t,1),i.set(new Uint8Array(n,0,n.byteLength),t.length+1);const a=d.hmac.create(d.sha512,e).update(i).digest(),o=a.slice(0,32),u=a.slice(32);return{key:o,chainCode:u}},Ui=t=>Ri.test(t)?!t.split("/").slice(1).map(rn).some(isNaN):!1,dr=(t,e,r=Pi)=>{if(!Ui(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=Ni(e);return t.split("/").slice(1).map(rn).map(a=>parseInt(a,10)).reduce((a,o)=>$i(a,o+r),{key:n,chainCode:s})};function nn(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}class Di{equals(e){return nn(this.toRawBytes(),e.toRawBytes())}toBase64(){return $(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return $(e)}verifyWithIntent(e,r,n){const s=tn(n,e),i=d.blake2b(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(I.vector(I.u8()).serialize(e).toBytes(),r,$e.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,$e.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return d.normalizeSuiAddress(d.bytesToHex(d.blake2b(this.toSuiBytes(),{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}}const vt=32;class sn extends Di{constructor(e){if(super(),typeof e=="string"?this.data=H(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==vt)throw new Error(`Invalid public key input. Expected ${vt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return nt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=_i(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!nn(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return d.nacl.sign.detached.verify(e,n,this.toRawBytes())}}sn.SIZE=vt;const lr="m/44'/784'/0'/0'/0'";class me extends Oi{constructor(e){super(),e?this.keypair=e:this.keypair=d.nacl.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new me(d.nacl.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==He)throw new Error(`Wrong secretKey size. Expected ${He} bytes, got ${n}.`);const s=d.nacl.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=d.nacl.sign.detached(a,s.secretKey);if(!d.nacl.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new me(s)}getPublicKey(){return new sn(this.keypair.publicKey)}getSecretKey(){return ji(this.keypair.secretKey.slice(0,He),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return d.nacl.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=lr),!ur(r))throw new Error("Invalid derivation path");const{key:n}=dr(r,Bi(e));return me.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=lr),!ur(r))throw new Error("Invalid derivation path");const{key:n}=dr(r,e);return me.fromSecretKey(n)}}async function zi(t,e){const[,r]=await Ee.chainFromRpc(t);return new Vi(r,t,me.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class Vi{constructor(e,r,n,s){pe(this,"_chain");pe(this,"_client");pe(this,"_signer");pe(this,"_debug");this._chain=e,this._client=r,this._signer=n,this._debug=s}chain(){return this._chain}address(){return this._signer.toSuiAddress()}async signAndSend(e){const r=[];for(const n of e){const{description:s,transaction:i}=n;this._debug&&console.log(`Signing ${s} for ${this.address()}`);try{const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}catch(a){throw a}}return r}}const Li={Address:d.SuiAddress,Platform:Ee,getSigner:zi,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-CvDrTlD5.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-yQD0Xsib.js")),CircleBridge:()=>Promise.resolve().then(()=>require("./index-ZSnwMbPW.js"))},getChain:(t,e,r)=>new Jr(e,new Ee(t,d.applyChainsConfigConfigOverrides(t,Tt,{[e]:r})))},qi=Object.freeze(Object.defineProperty({__proto__:null,default:Li},Symbol.toStringTag,{value:"Module"}));exports.SuiPlatform=Ee;exports.getFieldsFromObjectResponse=tr;exports.getObjectFields=Yr;exports.getOldestEmitterCapObjectId=ai;exports.getOriginalPackageId=si;exports.getPackageId=ii;exports.isMoveStructId=ti;exports.isMoveStructObject=Xr;exports.isMoveStructStruct=rt;exports.isSameType=Xs;exports.isSuiCreateEvent=Ys;exports.isSuiPublishEvent=Qs;exports.publishPackage=oi;exports.sui=qi;exports.uint8ArrayToBCS=ni;