@wormhole-foundation/wormhole-connect 0.3.19-beta.1-development → 0.3.19-beta.4-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.
- package/dist/assets/{ccip-CC5KdnX-.js → ccip-fCzlhBBT.js} +1 -1
- package/dist/assets/cosmos-CZk6ggNU.js +37 -0
- package/dist/assets/{cosmwasm-D6dc3HhR.js → cosmwasm-BRgXJAEm.js} +3 -3
- package/dist/assets/{ens-validation.es6-JeiZhPFM.js → ens-validation.es6-CEldkK56.js} +1 -1
- package/dist/assets/{evm-scnxy1Tm.js → evm-zyz5dAmi.js} +4 -4
- package/dist/assets/{index-CfFB0O_w.js → index-2haya2pd.js} +1 -1
- package/dist/assets/{index-DdlsdoUO.js → index-BSZP2fsz.js} +1 -1
- package/dist/assets/{index-CYsDCGyL.js → index-BUfxN-fw.js} +1 -1
- package/dist/assets/{index-CZGBtcJ2.js → index-Cjisu-Ym.js} +1 -1
- package/dist/assets/index-CoAwWRVw.js +3 -0
- package/dist/assets/{index-DcrZhJuV.js → index-DYCDjsFo.js} +2 -2
- package/dist/assets/{index.es-CkKy_bC0.js → index.es-LrzWWyFt.js} +2 -2
- package/dist/assets/{solana-DJERwdo1.js → solana-ClUmAbQX.js} +2 -2
- package/dist/assets/{solanaEmbed.esm-CYzxDEiX.js → solanaEmbed.esm-BpCHncZo.js} +1 -1
- package/dist/assets/{unsignedTransaction-Bbs3hbtB.js → unsignedTransaction-C5QlrOSq.js} +1 -1
- package/dist/main.js +11 -11
- package/dist/src/components/ManualAddressInput.d.ts.map +1 -1
- package/dist/src/components/TokensModal.d.ts.map +1 -1
- package/dist/src/telemetry/types.d.ts +1 -0
- package/dist/src/telemetry/types.d.ts.map +1 -1
- package/dist/src/views/Bridge/Send.d.ts.map +1 -1
- package/lib/{algorand-Cn2ASQM8.mjs → algorand-BNtk5Zlz.mjs} +4 -4
- package/lib/{algorand-BEj3eMlU.js → algorand-BOA88Yi9.js} +1 -1
- package/lib/{aptos-C5usxwjg.js → aptos-09IlHhtG.js} +1 -1
- package/lib/{aptos-CgcrUUs6.js → aptos-2Xg1Y_0j.js} +2 -2
- package/lib/{aptos-r2dqWkwd.mjs → aptos-DsuCT57P.mjs} +4 -4
- package/lib/{aptos-B4K8HU4y.mjs → aptos-ofb4q2o1.mjs} +1 -1
- package/lib/{browser-CqNEk73A.mjs → browser-5rNYk7ew.mjs} +2 -2
- package/lib/{browser-9qSlzcs1.js → browser-CMlhlM7_.js} +1 -1
- package/lib/{ccip-DiTkor0v.js → ccip-BnSw75yc.js} +1 -1
- package/lib/{ccip-Cg8GiGjJ.mjs → ccip-rZCaMFot.mjs} +1 -1
- package/lib/{chain-CNimQoal.mjs → chain-BZjg2BoT.mjs} +1 -1
- package/lib/{chain-BS9tnRQF.js → chain-NLYiTi92.js} +1 -1
- package/lib/{cosmos-DAYdruCU.js → cosmos-DeEa4QWd.js} +1 -1
- package/lib/{cosmos-kdBLlX5J.mjs → cosmos-IWVkyjMV.mjs} +3 -3
- package/lib/{cosmwasm-t4y0gzD9.js → cosmwasm-BFtZD1Ru.js} +2 -2
- package/lib/{cosmwasm-BdmGrQe2.mjs → cosmwasm-CGR89px_.mjs} +6 -6
- package/lib/{create-BC4-6NQa.js → create-Bpjnlpg_.js} +1 -1
- package/lib/{create-Bh45gqri.mjs → create-PB82rGuQ.mjs} +1 -1
- package/lib/{ens-validation.es6-B5lcZ1z0.js → ens-validation.es6-BY6Eu6az.js} +1 -1
- package/lib/{ens-validation.es6-BBk1nSK3.mjs → ens-validation.es6-D6AE2QT0.mjs} +2 -2
- package/lib/{evm-BdLUkbt8.mjs → evm-DB1-WEEt.mjs} +6 -6
- package/lib/{evm-ByfaloPB.js → evm-DY9ovr2c.js} +2 -2
- package/lib/{evm-CI9jvgpD.mjs → evm-FMLhTUS9.mjs} +6 -6
- package/lib/{evm-Cplwt-Uu.js → evm-aLUoXBeT.js} +4 -4
- package/lib/{index-CeYAnGJU.js → index-6GqC5Hzz.js} +1 -1
- package/lib/{index-ClpF6w41.mjs → index-95lzn8zO.mjs} +5 -5
- package/lib/{index-DkHNYEwj.js → index-9SUIf5nS.js} +1 -1
- package/lib/{index-RHlQCTsY.js → index-B2IuVewp.js} +1 -1
- package/lib/{index-DonnLcua.mjs → index-B2JrUboW.mjs} +6 -6
- package/lib/{index-D10P63La.mjs → index-BAMSsTuN.mjs} +4 -4
- package/lib/{index-_ey36AjY.mjs → index-BEQsB526.mjs} +2 -2
- package/lib/{index-BTJEpkGu.mjs → index-BEjdY6hm.mjs} +5 -5
- package/lib/{index-CiNv_vqX.js → index-BG24T1GX.js} +1 -1
- package/lib/{index-CLqwNevH.mjs → index-BI-a425p.mjs} +1 -1
- package/lib/{index-CZM1nqSC.js → index-BQqBYm1C.js} +1 -1
- package/lib/{index-L-oyxcKw.mjs → index-BSpDXKq1.mjs} +4 -4
- package/lib/{index-BAfpfiMg.mjs → index-BULQb7l7.mjs} +4 -4
- package/lib/{index-DKqdtMJw.mjs → index-Bdzevkwx.mjs} +3 -3
- package/lib/{index-DVzNMQU2.mjs → index-BqGrE5rX.mjs} +4 -4
- package/lib/{index-BskUJ6-F.js → index-BwTYRqte.js} +1 -1
- package/lib/{index-DjJSdBO_.mjs → index-C1JlVOwd.mjs} +77 -63
- package/lib/{index-tFdU3m1V.js → index-C7pm5tV-.js} +1 -1
- package/lib/{index-DJoVr9ew.mjs → index-CFc6ua8j.mjs} +4 -4
- package/lib/{index-D05MUiKM.js → index-COcHH6cV.js} +1 -1
- package/lib/{index-dgxqH4Al.mjs → index-CPg2DDGG.mjs} +4 -4
- package/lib/{index-v5JYqN5T.js → index-CaF25_vp.js} +1 -1
- package/lib/{index-Vqfiz4gq.js → index-CefRPGIJ.js} +1 -1
- package/lib/{index-Cms5l5e9.mjs → index-CfOBXKOA.mjs} +2 -2
- package/lib/{index-D2283Eib.js → index-Clclaa8l.js} +1 -1
- package/lib/{index-6SYLbVVC.mjs → index-Cn3ZByEn.mjs} +5 -5
- package/lib/{index-DHNJ7dTI.mjs → index-CswKQSoP.mjs} +3 -3
- package/lib/{index-DULgLsXD.mjs → index-Cu-QZ2Yi.mjs} +4 -4
- package/lib/{index-DuPl6mJy.mjs → index-CxU-Gb5y.mjs} +4 -4
- package/lib/{index-D4polzlG.mjs → index-D0taDsGK.mjs} +4 -4
- package/lib/{index-DTYdWw1E.js → index-D1vD1x9T.js} +1 -1
- package/lib/{index-B11tXNbe.mjs → index-DHsWcdrI.mjs} +1 -1
- package/lib/{index-W5vGD3Jp.js → index-DIhwpM7p.js} +1 -1
- package/lib/{index-CyoAaX76.js → index-DRhnM5uA.js} +1 -1
- package/lib/{index-CitMOybO.js → index-D_ETBz6p.js} +1 -1
- package/lib/{index-Bjg2w3Jp.mjs → index-Df-PgrLd.mjs} +2 -2
- package/lib/{index-Cpfo_13K.js → index-DfYc88fY.js} +5 -5
- package/lib/{index-DWqHObYQ.js → index-Dph4RybI.js} +1 -1
- package/lib/{index-JCeZURsa.mjs → index-Dvg604_r.mjs} +3 -3
- package/lib/{index-LbkpxbxU.js → index-DzVxkotY.js} +1 -1
- package/lib/{index-DO9Aqf4O.js → index-LMP2SXjR.js} +1 -1
- package/lib/{index-D3leTI6y.js → index-M0F8WpQR.js} +1 -1
- package/lib/{index-BdZfdhLf.js → index-Na_--gcE.js} +1 -1
- package/lib/{index-DC95G-Xg.js → index-aCI_DUM-.js} +1 -1
- package/lib/{index-Cc-SRhQH.mjs → index-afsYF03s.mjs} +4 -4
- package/lib/{index--XOWHvs8.js → index-tMk2zWGF.js} +1 -1
- package/lib/{index.es-CE_sbvG3.mjs → index.es-DqS4HLZw.mjs} +4 -4
- package/lib/{index.es-D641bRIm.js → index.es-uerP6wyE.js} +2 -2
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{libsodium-wrappers-DLsfT6wH.mjs → libsodium-wrappers-B78L643V.mjs} +1 -1
- package/lib/{libsodium-wrappers-Dv4avoYQ.js → libsodium-wrappers-DP3-RcK9.js} +1 -1
- package/lib/{sei-DSmG2Vzd.mjs → sei-CvQ5fq9U.mjs} +2 -2
- package/lib/{sei-BgefK64I.js → sei-D8YL8hcu.js} +1 -1
- package/lib/{solana--NAZIp_H.mjs → solana-DIKpxJ66.mjs} +3 -3
- package/lib/{solana-D-xykBVb.js → solana-PbyA60e9.js} +1 -1
- package/lib/{solana-cDD0Ny2l.js → solana-Q02Qu6Us.js} +2 -2
- package/lib/{solana-DGHdzU4Y.mjs → solana-eqcW3EUS.mjs} +6 -6
- package/lib/{solanaEmbed.esm-CvJOxxKf.mjs → solanaEmbed.esm-B35xqpi9.mjs} +2 -2
- package/lib/{solanaEmbed.esm-SQGeqX2v.js → solanaEmbed.esm-DAJICEjv.js} +1 -1
- package/lib/src/components/ManualAddressInput.d.ts.map +1 -1
- package/lib/src/components/TokensModal.d.ts.map +1 -1
- package/lib/src/telemetry/types.d.ts +1 -0
- package/lib/src/telemetry/types.d.ts.map +1 -1
- package/lib/src/views/Bridge/Send.d.ts.map +1 -1
- package/lib/{sui-CabK_MAW.mjs → sui-CmBrrkS9.mjs} +1 -1
- package/lib/{sui-CitobCk-.js → sui-Cz7TcwK6.js} +1 -1
- package/lib/{sui-CnL17qoE.mjs → sui-DWSLoSDK.mjs} +4 -4
- package/lib/{sui-Bn1nWU88.js → sui-YcpSM6BX.js} +2 -2
- package/lib/{unsignedTransaction-wkSutsdc.js → unsignedTransaction-CuG8xbiM.js} +1 -1
- package/lib/{unsignedTransaction-Bl6mVw94.mjs → unsignedTransaction-Dgrq3Lq3.mjs} +2 -2
- package/package.json +1 -1
- package/dist/assets/cosmos-CKUC0334.js +0 -37
- package/dist/assets/index-DTubKMVE.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var xn=Object.defineProperty;var In=(t,e,r)=>e in t?xn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var te=(t,e,r)=>(In(t,typeof e!="symbol"?e+"":e,r),r);const m=require("./index-Cpfo_13K.js"),_r=require("./chain-BS9tnRQF.js");/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */function Ar(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function _n(t){const e=Ar(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}const An=t=>Ar(`mnemonic${t}`);function On(t,e=""){return m.pbkdf2(m.sha512,_n(t).nfkd,An(e),{c:2048,dkLen:64})}function Cn(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=n}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var w=0,T=0,k=0,j=p.length;k!==j&&p[k]===0;)k++,w++;for(var P=(j-k)*l+1>>>0,L=new Uint8Array(P);k!==j;){for(var ee=p[k],ge=0,K=P-1;(ee!==0||ge<T)&&K!==-1;K--,ge++)ee+=256*L[K]>>>0,L[K]=ee%a>>>0,ee=ee/a>>>0;if(ee!==0)throw new Error("Non-zero carry");T=ge,k++}for(var ie=P-T;ie!==P&&L[ie]===0;)ie++;for(var Qe=c.repeat(w);ie<P;++ie)Qe+=t.charAt(L[ie]);return Qe}function g(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;for(var w=0,T=0,k=0;p[w]===c;)T++,w++;for(var j=(p.length-w)*u+1>>>0,P=new Uint8Array(j);p[w];){var L=e[p.charCodeAt(w)];if(L===255)return;for(var ee=0,ge=j-1;(L!==0||ee<k)&&ge!==-1;ge--,ee++)L+=a*P[ge]>>>0,P[ge]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");k=ee,w++}for(var K=j-k;K!==j&&P[K]===0;)K++;for(var ie=new Uint8Array(T+(j-K)),Qe=T;K!==j;)ie[Qe++]=P[K++];return ie}function y(p){var w=g(p);if(w)return w;throw new Error("Non-base"+a+" character")}return{encode:f,decodeUnsafe:g,decode:y}}var Bn=Cn;const jn=Bn,Mn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var Pn=jn(Mn);const Or=m.getDefaultExportFromCjs(Pn),He=t=>Or.encode(t),Ze=t=>Or.decode(t);function Y(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const wt=8192;function D(t){if(t.length<wt)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=wt){const n=t.slice(r,r+wt);e+=String.fromCharCode(...n)}return btoa(e)}function Je(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 Ie(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function $t(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 Rn(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 Cr{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}=Rn(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 $n(t,e){switch(e){case"base58":return He(t);case"base64":return D(t);case"hex":return Ie(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Un(t,e){switch(e){case"base58":return Ze(t);case"base64":return Y(t);case"hex":return Je(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Br(t,e=["<",">"]){const[r,n]=e,s=[];let i="",a=0;for(let c=0;c<t.length;c++){const u=t[c];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 jr{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 bt(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return bt(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return bt(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return $t(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 $n(this.toBytes(),e)}}function bt(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 Mr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},H=(t,e,r)=>(Mr(t,e,"read from private field"),r?r.call(t):e.get(t)),lt=(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)},dt=(t,e,r,n)=>(Mr(t,e,"write to private field"),e.set(t,r),r),_e,Pe,it,ye;const Pr=class{constructor(t){lt(this,_e,void 0),lt(this,Pe,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),dt(this,_e,t.write),dt(this,Pe,t.serialize??((e,r)=>{const n=new jr({size:this.serializedSize(e)??void 0,...r});return H(this,_e).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),H(this,_e).call(this,t,e)}serialize(t,e){return this.validate(t),new Nn(this,H(this,Pe).call(this,t,e))}parse(t){const e=new Cr(t);return this.read(e)}transform({name:t,input:e,output:r}){return new Pr({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>H(this,_e).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>H(this,Pe).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let J=Pr;_e=new WeakMap;Pe=new WeakMap;const Rr=Symbol.for("@mysten/serialized-bcs");function Ut(t){return!!t&&typeof t=="object"&&t[Rr]===!0}class Nn{constructor(e,r){lt(this,it,void 0),lt(this,ye,void 0),dt(this,it,e),dt(this,ye,r)}get[Rr](){return!0}toBytes(){return H(this,ye)}toHex(){return Ie(H(this,ye))}toBase64(){return D(H(this,ye))}toBase58(){return He(H(this,ye))}parse(){return H(this,it).parse(H(this,ye))}}it=new WeakMap;ye=new WeakMap;function ht({size:t,...e}){return new J({...e,serializedSize:()=>t})}function St({readMethod:t,writeMethod:e,...r}){return ht({...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 Tt({readMethod:t,writeMethod:e,...r}){return ht({...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 Dn({serialize:t,...e}){const r=new J({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function zn({toBytes:t,fromBytes:e,...r}){return new J({...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=$t(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 Vn(t){let e=null;function r(){return e||(e=t()),e}return new J({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 o={u8(t){return St({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return St({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return St({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return Tt({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return Tt({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return Tt({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return ht({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 Dn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from($t(e)),...t})},bytes(t,e){return ht({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 zn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new J({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 o.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 J({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 J({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 J({name:t,serializedSize:s=>{let i=0;for(const[a,c]of n){const u=c.serializedSize(s[a]);if(u==null)return null;i+=u}return i},read:s=>{const i={};for(const[a,c]of n)i[a]=c.read(s);return i},write:(s,i)=>{for(const[a,c]of n)c.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 J({name:t,read:s=>{const i=s.readULEB(),[a,c]=n[i];return{[a]:(c==null?void 0:c.read(s))??!0}},write:(s,i)=>{const[a,c]=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(c,i);return}}},...r,validate:s=>{var c;if((c=r==null?void 0:r.validate)==null||c.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 o.vector(o.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 Vn(t)}},Ln=32,Re=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof Re){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(Re.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&&qn(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 Re(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
1
|
+
"use strict";var xn=Object.defineProperty;var In=(t,e,r)=>e in t?xn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var te=(t,e,r)=>(In(t,typeof e!="symbol"?e+"":e,r),r);const m=require("./index-DfYc88fY.js"),_r=require("./chain-NLYiTi92.js");/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */function Ar(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function _n(t){const e=Ar(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}const An=t=>Ar(`mnemonic${t}`);function On(t,e=""){return m.pbkdf2(m.sha512,_n(t).nfkd,An(e),{c:2048,dkLen:64})}function Cn(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=n}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var w=0,T=0,k=0,j=p.length;k!==j&&p[k]===0;)k++,w++;for(var P=(j-k)*l+1>>>0,L=new Uint8Array(P);k!==j;){for(var ee=p[k],ge=0,K=P-1;(ee!==0||ge<T)&&K!==-1;K--,ge++)ee+=256*L[K]>>>0,L[K]=ee%a>>>0,ee=ee/a>>>0;if(ee!==0)throw new Error("Non-zero carry");T=ge,k++}for(var ie=P-T;ie!==P&&L[ie]===0;)ie++;for(var Qe=c.repeat(w);ie<P;++ie)Qe+=t.charAt(L[ie]);return Qe}function g(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;for(var w=0,T=0,k=0;p[w]===c;)T++,w++;for(var j=(p.length-w)*u+1>>>0,P=new Uint8Array(j);p[w];){var L=e[p.charCodeAt(w)];if(L===255)return;for(var ee=0,ge=j-1;(L!==0||ee<k)&&ge!==-1;ge--,ee++)L+=a*P[ge]>>>0,P[ge]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");k=ee,w++}for(var K=j-k;K!==j&&P[K]===0;)K++;for(var ie=new Uint8Array(T+(j-K)),Qe=T;K!==j;)ie[Qe++]=P[K++];return ie}function y(p){var w=g(p);if(w)return w;throw new Error("Non-base"+a+" character")}return{encode:f,decodeUnsafe:g,decode:y}}var Bn=Cn;const jn=Bn,Mn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var Pn=jn(Mn);const Or=m.getDefaultExportFromCjs(Pn),He=t=>Or.encode(t),Ze=t=>Or.decode(t);function Y(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const wt=8192;function D(t){if(t.length<wt)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=wt){const n=t.slice(r,r+wt);e+=String.fromCharCode(...n)}return btoa(e)}function Je(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 Ie(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function $t(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 Rn(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 Cr{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}=Rn(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 $n(t,e){switch(e){case"base58":return He(t);case"base64":return D(t);case"hex":return Ie(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Un(t,e){switch(e){case"base58":return Ze(t);case"base64":return Y(t);case"hex":return Je(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Br(t,e=["<",">"]){const[r,n]=e,s=[];let i="",a=0;for(let c=0;c<t.length;c++){const u=t[c];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 jr{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 bt(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return bt(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return bt(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return $t(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 $n(this.toBytes(),e)}}function bt(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 Mr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},H=(t,e,r)=>(Mr(t,e,"read from private field"),r?r.call(t):e.get(t)),lt=(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)},dt=(t,e,r,n)=>(Mr(t,e,"write to private field"),e.set(t,r),r),_e,Pe,it,ye;const Pr=class{constructor(t){lt(this,_e,void 0),lt(this,Pe,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),dt(this,_e,t.write),dt(this,Pe,t.serialize??((e,r)=>{const n=new jr({size:this.serializedSize(e)??void 0,...r});return H(this,_e).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),H(this,_e).call(this,t,e)}serialize(t,e){return this.validate(t),new Nn(this,H(this,Pe).call(this,t,e))}parse(t){const e=new Cr(t);return this.read(e)}transform({name:t,input:e,output:r}){return new Pr({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>H(this,_e).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>H(this,Pe).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let J=Pr;_e=new WeakMap;Pe=new WeakMap;const Rr=Symbol.for("@mysten/serialized-bcs");function Ut(t){return!!t&&typeof t=="object"&&t[Rr]===!0}class Nn{constructor(e,r){lt(this,it,void 0),lt(this,ye,void 0),dt(this,it,e),dt(this,ye,r)}get[Rr](){return!0}toBytes(){return H(this,ye)}toHex(){return Ie(H(this,ye))}toBase64(){return D(H(this,ye))}toBase58(){return He(H(this,ye))}parse(){return H(this,it).parse(H(this,ye))}}it=new WeakMap;ye=new WeakMap;function ht({size:t,...e}){return new J({...e,serializedSize:()=>t})}function St({readMethod:t,writeMethod:e,...r}){return ht({...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 Tt({readMethod:t,writeMethod:e,...r}){return ht({...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 Dn({serialize:t,...e}){const r=new J({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function zn({toBytes:t,fromBytes:e,...r}){return new J({...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=$t(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 Vn(t){let e=null;function r(){return e||(e=t()),e}return new J({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 o={u8(t){return St({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return St({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return St({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return Tt({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return Tt({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return Tt({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return ht({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 Dn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from($t(e)),...t})},bytes(t,e){return ht({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 zn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new J({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 o.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 J({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 J({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 J({name:t,serializedSize:s=>{let i=0;for(const[a,c]of n){const u=c.serializedSize(s[a]);if(u==null)return null;i+=u}return i},read:s=>{const i={};for(const[a,c]of n)i[a]=c.read(s);return i},write:(s,i)=>{for(const[a,c]of n)c.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 J({name:t,read:s=>{const i=s.readULEB(),[a,c]=n[i];return{[a]:(c==null?void 0:c.read(s))??!0}},write:(s,i)=>{const[a,c]=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(c,i);return}}},...r,validate:s=>{var c;if((c=r==null?void 0:r.validate)==null||c.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 o.vector(o.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 Vn(t)}},Ln=32,Re=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof Re){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(Re.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&&qn(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 Re(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=Un(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 Re(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,c,u,l){const f=i.reduce((g,y,p)=>Object.assign(g,{[y]:l[p]}),{});return this._encodeRaw.call(a,new jr(u),c,l,f)},decode(a,c,u){const l=i.reduce((f,g,y)=>Object.assign(f,{[g]:u[y]}),{});return this._decodeRaw.call(a,new Cr(c),u,l)},_encodeRaw(a,c,u,l){if(n(c))return e.call(this,a,c,u,l);throw new Error(`Validation failed for type ${s}, data: ${c}`)},_decodeRaw(a,c,u){return r.call(this,a,c,u)}}),this}registerBcsType(t,e){return this.registerType(t,(r,n,s)=>{const i=s.map(a=>new J({name:String(a),write:(c,u)=>{const{name:l,params:f}=this.parseTypeName(a),g=this.getTypeInterface(l),y=f.reduce((p,w,T)=>Object.assign(p,{[w]:s[T]}),{});return g._encodeRaw.call(this,u,c,f,y)},read:()=>{throw new Error("Not implemented")}}));return e(...i).write(n,r),r},(r,n)=>{const s=n.map(i=>new J({name:String(i),write:(a,c)=>{throw new Error("Not implemented")},read:a=>{const{name:c,params:u}=this.parseTypeName(i),l=this.getTypeInterface(c),f=u.reduce((g,y,p)=>Object.assign(g,{[y]:n[p]}),{});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 Y(i).reduce((a,c)=>a.write8(c),s)},function(s){return D(s.readBytes(e))});case"hex":return this.registerType(t,function(s,i){return Je(i).reduce((a,c)=>a.write8(c),s)},function(s){return Ie(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,c){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:g,params:y}=this.parseTypeName(f);if(this.hasType(g))return this.getTypeInterface(g)._encodeRaw.call(this,u,l,y,c);if(!(g in c))throw new Error(`Unable to find a matching type definition for ${g} in vector; make sure you passed a generic`);let{name:p,params:w}=this.parseTypeName(c[g]);return this.getTypeInterface(p)._encodeRaw.call(this,u,l,w,c)})},function(s,i,a){return s.readVec(c=>{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,c,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:g,params:y}=this.parseTypeName(a[l]);return this.getTypeInterface(g)._decodeRaw.call(this,c,y,a)})})}registerStructType(t,e){for(let a in e){let c=this.tempKey(),u=e[a];!Array.isArray(u)&&typeof u!="string"&&(e[a]=c,this.registerStructType(c,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(c,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 g of n){if(!(g in u))throw new Error(`Struct ${s} requires field ${g}:${r[g]}`);const{name:y,params:p}=this.parseTypeName(r[g]);if(!i.includes(y))this.getTypeInterface(y)._encodeRaw.call(this,c,u[g],p,f);else{const w=i.indexOf(y);let{name:T,params:k}=this.parseTypeName(l[w]);if(this.hasType(T)){this.getTypeInterface(T)._encodeRaw.call(this,c,u[g],k,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:j,params:P}=this.parseTypeName(f[T]);this.getTypeInterface(j)._encodeRaw.call(this,c,u[g],P,f)}}return c},function(c,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 g of n){const{name:y,params:p}=this.parseTypeName(r[g]);if(!i.includes(y))f[g]=this.getTypeInterface(y)._decodeRaw.call(this,c,p,l);else{const w=i.indexOf(y);let{name:T,params:k}=this.parseTypeName(u[w]);if(this.hasType(T)){f[g]=this.getTypeInterface(T)._decodeRaw.call(this,c,k,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:j,params:P}=this.parseTypeName(l[T]);f[g]=this.getTypeInterface(j)._decodeRaw.call(this,c,P,l)}}return f})}registerEnumType(t,e){for(let a in e){let c=this.tempKey(),u=e[a];u!==null&&!Array.isArray(u)&&typeof u!="string"&&(e[a]=c,this.registerStructType(c,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(c,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 g=Object.keys(u)[0];if(g===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let y=n.indexOf(g);if(y===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${g}"`);let p=n[y],w=r[p];if(c.write8(y),w===null)return c;let T=i.indexOf(w),k=T===-1?w:l[T];{let{name:j,params:P}=this.parseTypeName(k);return this.getTypeInterface(j)._encodeRaw.call(this,c,u[g],P,f)}},function(c,u,l){let f=c.readULEB(),g=n[f],y=r[g];if(f===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${f}"`);if(y===null)return{[g]:!0};let p=i.indexOf(y),w=p===-1?y:u[p];{let{name:T,params:k}=this.parseTypeName(w);return{[g]:this.getTypeInterface(T)._decodeRaw.call(this,c,k,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[c,...u]=t;return{name:c,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=Br(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let _=Re;_.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 qn(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(Je(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return Ie(new Uint8Array(r))}),t.registerType(_.BASE58,function(e,r){return e.writeVec(Array.from(Ze(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return He(new Uint8Array(r))}),t.registerType(_.BASE64,function(e,r){return e.writeVec(Array.from(Y(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return D(new Uint8Array(r))})}function Fn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Ln,addressEncoding:"hex"}}const Wn=32;function yr(t){try{return Ze(t).length===Wn}catch{return!1}}const Xe=32;function ce(t){return Kn(t)&&Gn(t)===Xe}function et(t){return ce(t)}function A(t,e=!1){let r=t.toLowerCase();return!e&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(Xe*2,"0")}`}function re(t,e=!1){return A(t,e)}function Kn(t){return/^(0x|0X)?[a-fA-F0-9]+$/.test(t)&&t.length%2===0}function Gn(t){return/^(0x|0X)/.test(t)?(t.length-2)/2:t.length/2}class Hn extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:c}=e,u=c.length===0?s:`At path: ${c.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 Zn(t){return F(t)&&typeof t[Symbol.iterator]=="function"}function F(t){return typeof t=="object"&&t!=null}function W(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function Jn(t){const{done:e,value:r}=t.next();return e?void 0:r}function Xn(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:c,message:u=`Expected a value of type \`${a}\`${c?` with refinement \`${c}\``:""}, but received: \`${W(n)}\``}=t;return{value:n,type:a,refinement:c,key:s[s.length-1],path:s,branch:i,...t,message:u}}function*mr(t,e,r,n){Zn(t)||(t=[t]);for(const s of t){const i=Xn(s,e,r,n);i&&(yield i)}}function*Nt(t,e,r={}){const{path:n=[],branch:s=[t],coerce:i=!1,mask:a=!1}=r,c={path:n,branch:s};if(i&&(t=e.coercer(t,c),a&&e.type!=="type"&&F(e.schema)&&F(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,c))l.explanation=r.message,u="not_valid",yield[l,void 0];for(let[l,f,g]of e.entries(t,c)){const y=Nt(f,g,{path:l===void 0?n:[...n,l],branch:l===void 0?s:[...s,f],coerce:i,mask:a,message:r.message});for(const p of y)p[0]?(u=p[0].refinement!=null?"not_refined":"not_valid",yield[p[0],void 0]):i&&(f=p[1],l===void 0?t=f:t instanceof Map?t.set(l,f):t instanceof Set?t.add(f):F(t)&&(f!==void 0||l in t)&&(t[l]=f))}if(u!=="not_valid")for(const l of e.refiner(t,c))l.explanation=r.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,t])}class se{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=u=>u,entries:c=function*(){}}=e;this.type=r,this.schema=n,this.entries=c,this.coercer=a,s?this.validator=(u,l)=>{const f=s(u,l);return mr(f,l,this,u)}:this.validator=()=>[],i?this.refiner=(u,l)=>{const f=i(u,l);return mr(f,l,this,u)}:this.refiner=()=>[]}assert(e,r){return xt(e,this,r)}create(e,r){return $r(e,this,r)}is(e){return z(e,this)}mask(e,r){return Ur(e,this,r)}validate(e,r={}){return Ye(e,this,r)}}function xt(t,e,r){const n=Ye(t,e,{message:r});if(n[0])throw n[0]}function $r(t,e,r){const n=Ye(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Ur(t,e,r){const n=Ye(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function z(t,e){return!Ye(t,e)[0]}function Ye(t,e,r={}){const n=Nt(t,e,r),s=Jn(n);return s[0]?[new Hn(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Ve(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?Qn(n):h(n)}function V(t,e){return new se({type:t,schema:null,validator:e})}function It(){return V("any",()=>!0)}function E(t){return new se({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: ${W(e)}`}})}function Yn(){return V("bigint",t=>typeof t=="bigint")}function $(){return V("boolean",t=>typeof t=="boolean")}function ne(){return V("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${W(t)}`)}function S(t){const e=W(t),r=typeof t;return new se({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${W(n)}`}})}function Nr(){return V("never",()=>!1)}function B(t){return new se({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function Ee(){return V("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${W(t)}`)}function h(t){const e=t?Object.keys(t):[],r=Nr();return new se({type:"object",schema:t||null,*entries(n){if(t&&F(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 F(n)||`Expected an object, but received: ${W(n)}`},coercer(n){return F(n)?{...n}:n}})}function b(t){return new se({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Q(t,e){return new se({type:"record",schema:null,*entries(r){if(F(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return F(r)||`Expected an object, but received: ${W(r)}`}})}function d(){return V("string",t=>typeof t=="string"||`Expected a string, but received: ${W(t)}`)}function Dr(t){const e=Nr();return new se({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: ${W(r)}`}})}function Qn(t){const e=Object.keys(t);return new se({type:"type",schema:t,*entries(r){if(F(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return F(r)||`Expected an object, but received: ${W(r)}`},coercer(r){return F(r)?{...r}:r}})}function M(t){const e=t.map(r=>r.type).join(" | ");return new se({type:"union",schema:null,coercer(r){for(const n of t){const[s,i]=n.validate(r,{coerce:!0});if(!s)return i}return r},validator(r,n){const s=[];for(const i of t){const[...a]=Nt(r,i,n),[c]=a;if(c[0])for(const[u]of a)u&&s.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${W(r)}`,...s]}})}function zr(){return V("unknown",()=>!0)}BigInt(1e9);const Dt="0x1",Vr="0x2";re("0x6");const es=`${Vr}::sui::SUI`;re("0x5");const Ae="::",ts="0x2::sui::SUI",rs="0.50.1",ns="1.19.0",ss={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class Lr extends Error{}class qr extends Lr{constructor(e,r){super(e),this.code=r,this.type=ss[r]??"ServerError"}}class is extends Lr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var zt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},O=(t,e,r)=>(zt(t,e,"read from private field"),r?r.call(t):e.get(t)),pe=(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)},Ce=(t,e,r,n)=>(zt(t,e,"write to private field"),e.set(t,r),r),as=(t,e,r,n)=>({set _(s){Ce(t,e,s)},get _(){return O(t,e,n)}}),Fr=(t,e,r)=>(zt(t,e,"access private method"),r),Se,De,ue,ve,Le,Be,_t,Wr,Vt,Kr;function os(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const cs={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class us{constructor(e,r={}){if(pe(this,_t),pe(this,Vt),pe(this,Se,0),pe(this,De,0),pe(this,ue,null),pe(this,ve,null),pe(this,Le,new Set),pe(this,Be,new Map),this.endpoint=e,this.options={...cs,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=os(this.endpoint))}async makeRequest(e,r){const n=await Fr(this,_t,Wr).call(this);return new Promise((s,i)=>{Ce(this,Se,O(this,Se)+1),O(this,Be).set(O(this,Se),{resolve:s,reject:i,timeout:setTimeout(()=>{O(this,Be).delete(O(this,Se)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:O(this,Se),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new qr(s.message,s.code);return i})}async subscribe(e){const r=new ls(e);return O(this,Le).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}Se=new WeakMap;De=new WeakMap;ue=new WeakMap;ve=new WeakMap;Le=new WeakMap;Be=new WeakMap;_t=new WeakSet;Wr=function(){return O(this,ve)?O(this,ve):(Ce(this,ve,new Promise(t=>{var e;(e=O(this,ue))==null||e.close(),Ce(this,ue,new this.options.WebSocketConstructor(this.endpoint)),O(this,ue).addEventListener("open",()=>{Ce(this,De,0),t(O(this,ue))}),O(this,ue).addEventListener("close",()=>{as(this,De)._++,O(this,De)<=this.options.maxReconnects&&setTimeout(()=>{Fr(this,Vt,Kr).call(this)},this.options.reconnectTimeout)}),O(this,ue).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&&O(this,Be).has(n.id)){const{resolve:s,timeout:i}=O(this,Be).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;O(this,Le).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),O(this,ve))};Vt=new WeakSet;Kr=async function(){var t;return(t=O(this,ue))==null||t.close(),Ce(this,ve,null),Promise.allSettled([...O(this,Le)].map(e=>e.subscribe(this)))};class ls{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 Lt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},q=(t,e,r)=>(Lt(t,e,"read from private field"),r?r.call(t):e.get(t)),tt=(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)},At=(t,e,r,n)=>(Lt(t,e,"write to private field"),e.set(t,r),r),ds=(t,e,r)=>(Lt(t,e,"access private method"),r),$e,Z,ze,Ot,Gr;class hs{constructor(e){tt(this,Ot),tt(this,$e,0),tt(this,Z,void 0),tt(this,ze,void 0),At(this,Z,e)}fetch(e,r){const n=q(this,Z).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;At(this,$e,q(this,$e)+1);const r=await this.fetch(((s=q(this,Z).rpc)==null?void 0:s.url)??q(this,Z).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":rs,"Client-Target-Api-Version":ns,...(i=q(this,Z).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:q(this,$e),method:e.method,params:e.params})});if(!r.ok)throw new is(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new qr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await ds(this,Ot,Gr).call(this).subscribe(e);return async()=>!!await r()}}$e=new WeakMap;Z=new WeakMap;ze=new WeakMap;Ot=new WeakSet;Gr=function(){var t;if(!q(this,ze)){const e=q(this,Z).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.");At(this,ze,new us(((t=q(this,Z).websocket)==null?void 0:t.url)??q(this,Z).url,{WebSocketConstructor:e,...q(this,Z).websocket}))}return q(this,ze)};const fs=/^vector<(.+)>$/,gs=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class le{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(fs);if(n)return{vector:le.parseFromStr(n[1],r)};const s=e.match(gs);if(s)return{struct:{address:r?A(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:le.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return Br(e).map(n=>le.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<${le.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(le.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const I=new _({...Fn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function Hr(t){return o.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function ps(t){return o.enum("Option",{None:null,Some:t})}function qt(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const X=o.bytes(Xe).transform({input:t=>typeof t=="string"?Je(A(t)):t,output:t=>A(Ie(t))}),Ft=o.vector(o.u8()).transform({name:"ObjectDigest",input:t=>Ze(t),output:t=>He(new Uint8Array(t))}),qe=o.struct("SuiObjectRef",{objectId:X,version:o.u64(),digest:Ft}),Wt=o.struct("SharedObjectRef",{objectId:X,initialSharedVersion:o.u64(),mutable:o.bool()}),ft=o.enum("ObjectArg",{ImmOrOwned:qe,Shared:Wt,Receiving:qe}),Kt=o.enum("CallArg",{Pure:o.vector(o.u8()),Object:ft,ObjVec:o.vector(ft)}),Me=o.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:o.lazy(()=>Me),struct:o.lazy(()=>Yt),u16:null,u32:null,u256:null}),G=qt(o.enum("Argument",{GasCoin:null,Input:o.struct("Input",{index:o.u16()}),Result:o.struct("Result",{index:o.u16()}),NestedResult:o.struct("NestedResult",{index:o.u16(),resultIndex:o.u16()})})),Gt=o.struct("ProgrammableMoveCall",{package:X,module:o.string(),function:o.string(),type_arguments:o.vector(Me),arguments:o.vector(G)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>le.parseFromStr(i,!0));return{package:A(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(le.tagToString)})}),Ht=qt(o.enum("Transaction",{MoveCall:Gt,TransferObjects:o.struct("TransferObjects",{objects:o.vector(G),address:G}),SplitCoins:o.struct("SplitCoins",{coin:G,amounts:o.vector(G)}),MergeCoins:o.struct("MergeCoins",{destination:G,sources:o.vector(G)}),Publish:o.struct("Publish",{modules:o.vector(o.vector(o.u8())),dependencies:o.vector(X)}),MakeMoveVec:o.struct("MakeMoveVec",{type:ps(Me),objects:o.vector(G)}),Upgrade:o.struct("Upgrade",{modules:o.vector(o.vector(o.u8())),dependencies:o.vector(X),packageId:X,ticket:G})})),Zt=o.struct("ProgrammableTransaction",{inputs:o.vector(Kt),transactions:o.vector(Ht)}),Jt=o.enum("TransactionKind",{ProgrammableTransaction:Zt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Xt=o.enum("TransactionExpiration",{None:null,Epoch:Hr()}),Yt=o.struct("StructTag",{address:X,module:o.string(),name:o.string(),typeParams:o.vector(Me)}),Qt=o.struct("GasData",{payment:o.vector(qe),owner:X,price:o.u64(),budget:o.u64()}),er=o.struct("TransactionDataV1",{kind:Jt,sender:X,gasData:Qt,expiration:Xt}),tr=o.enum("TransactionData",{V1:er}),ys=o.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),ms=o.enum("IntentVersion",{V0:null}),ws=o.enum("AppId",{Sui:null}),bs=o.struct("Intent",{scope:ys,version:ms,appId:ws}),Ss=o.generic(["T"],t=>o.struct("IntentMessage<T>",{intent:bs,value:t})),rr=o.enum("CompressedSignature",{ED25519:o.fixedArray(64,o.u8()),Secp256k1:o.fixedArray(64,o.u8()),Secp256r1:o.fixedArray(64,o.u8()),ZkLogin:o.vector(o.u8())}),nr=o.enum("PublicKey",{ED25519:o.fixedArray(32,o.u8()),Secp256k1:o.fixedArray(33,o.u8()),Secp256r1:o.fixedArray(33,o.u8()),ZkLogin:o.vector(o.u8())}),sr=o.struct("MultiSigPkMap",{pubKey:nr,weight:o.u8()}),ir=o.struct("MultiSigPublicKey",{pk_map:o.vector(sr),threshold:o.u16()}),Zr=o.struct("MultiSig",{sigs:o.vector(rr),bitmap:o.u16(),multisig_pk:ir}),Ts=o.vector(o.u8()).transform({input:t=>typeof t=="string"?Y(t):t,output:t=>D(new Uint8Array(t))}),Jr=o.struct("SenderSignedTransaction",{intentMessage:Ss(tr),txSignatures:o.vector(Ts)}),Xr=o.vector(Jr,{name:"SenderSignedData"}),C={...o,U8:o.u8(),U16:o.u16(),U32:o.u32(),U64:o.u64(),U128:o.u128(),U256:o.u256(),ULEB128:o.uleb128(),Bool:o.bool(),String:o.string(),Address:X,Argument:G,CallArg:Kt,CompressedSignature:rr,GasData:Qt,MultiSig:Zr,MultiSigPkMap:sr,MultiSigPublicKey:ir,ObjectArg:ft,ObjectDigest:Ft,ProgrammableMoveCall:Gt,ProgrammableTransaction:Zt,PublicKey:nr,SenderSignedData:Xr,SenderSignedTransaction:Jr,SharedObjectRef:Wt,StructTag:Yt,SuiObjectRef:qe,Transaction:Ht,TransactionData:tr,TransactionDataV1:er,TransactionExpiration:Xt,TransactionKind:Jt,TypeTag:Me,ser:I.ser.bind(I),de:I.de.bind(I),getTypeInterface:I.getTypeInterface.bind(I),hasType:I.hasType.bind(I),parseTypeName:I.parseTypeName.bind(I),registerAddressType:I.registerAddressType.bind(I),registerAlias:I.registerAlias.bind(I),registerBcsType:I.registerBcsType.bind(I),registerEnumType:I.registerEnumType.bind(I),registerStructType:I.registerStructType.bind(I),registerType:I.registerType.bind(I),types:I.types};I.registerBcsType("utf8string",()=>o.string({name:"utf8string"}));I.registerBcsType("unsafe_u64",()=>Hr());I.registerBcsType("enumKind",t=>qt(t));[X,G,Kt,rr,Qt,Zr,sr,ir,ft,Ft,Gt,Zt,nr,Xr,Wt,Yt,qe,Ht,tr,er,Xt,Jt,Me].forEach(t=>{I.registerBcsType(t.name,()=>t)});const ar=M([h({AddressOwner:d()}),h({ObjectOwner:d()}),h({Shared:h({initial_shared_version:B(d())})}),S("Immutable")]);V("SuiJsonValue",()=>!0);const vs=M([h({u32:d()}),h({u64:d()}),h({f64:d()})]);h({attributes:Q(d(),B(vs)),featureFlags:Q(d(),$()),maxSupportedProtocolVersion:d(),minSupportedProtocolVersion:d(),protocolVersion:d()});M([d(),S("package")]);const me=h({digest:d(),objectId:d(),version:M([Ee(),d(),Yn()])});h({owner:ar,reference:me});h({objectId:d(),sequenceNumber:d()});h({payment:E(me),owner:d(),price:d(),budget:d()});const Es=Ve(me,h({type:d(),owner:ar,previousTransaction:d()})),ks=Q(d(),It()),xs=Q(d(),zr()),Is=h({type:d(),fields:ks,hasPublicTransfer:$()}),_s=h({disassembled:xs}),As=M([Ve(Is,h({dataType:S("moveObject")})),Ve(_s,h({dataType:S("package")}))]),Os=h({type:d(),hasPublicTransfer:$(),version:d(),bcsBytes:d()}),Cs=h({id:d(),moduleMap:Q(d(),d())}),Bs=M([Ve(Os,h({dataType:S("moveObject")})),Ve(Cs,h({dataType:S("package")}))]);BigInt(1e9);const Yr=h({code:d(),error:b(d()),object_id:b(d()),parent_object_id:b(d()),version:b(d()),digest:b(d())}),js=h({data:B(b(Q(d(),d()))),error:B(b(Yr))}),Ms=M([js,b(Q(d(),d()))]),Qr=h({objectId:d(),version:d(),digest:d(),type:B(b(d())),content:B(b(As)),bcs:B(b(Bs)),owner:B(b(ar)),previousTransaction:B(b(d())),storageRebate:B(b(d())),display:B(b(Ms))});h({showType:B(b($())),showContent:B(b($())),showBcs:B(b($())),showOwner:B(b($())),showPreviousTransaction:B(b($())),showStorageRebate:B(b($())),showDisplay:B(b($()))});M([S("Exists"),S("notExists"),S("Deleted")]);E(Es);const Ps=h({data:B(b(Qr)),error:B(b(Yr))});function Rs(t){return t.data}function $s(t){if(t.error&&"object_id"in t.error&&"version"in t.error&&"digest"in t.error){const e=t.error;return{objectId:e.object_id,version:e.version,digest:e.digest}}}function wr(t){if("reference"in t)return t.reference;const e=Rs(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:$s(t)}h({objectId:d(),atCheckpoint:b(Ee())});h({data:E(Ps),nextCursor:b(B(d())),hasNextPage:$()});M([h({details:Qr,status:S("VersionFound")}),h({details:d(),status:S("ObjectNotExists")}),h({details:me,status:S("ObjectDeleted")}),h({details:Dr([d(),Ee()]),status:S("VersionNotFound")}),h({details:h({asked_version:Ee(),latest_version:Ee(),object_id:d()}),status:S("VersionTooHigh")})]);const Us=M([d(),h({Object:d()})]);E(Us);const Ns=h({address:d(),name:d()}),Ds=M([S("Private"),S("Public"),S("Friend")]),or=h({abilities:E(d())}),zs=h({constraints:or,isPhantom:$()}),Vs=h({TypeParameter:Ee()}),vt=Dr([h({module:d(),package:d(),function:d()}),d()]);h({rank3Days:E(vt),rank7Days:E(vt),rank30Days:E(vt)});function en(t){if(!t)return!1;if(typeof t=="string"||z(t,Vs)||tn(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(z(e.Reference,je)||z(e.MutableReference,je)||z(e.Vector,je))}const je=V("SuiMoveNormalizedType",en);function tn(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=>en(n)))}V("SuiMoveNormalizedStructType",tn);const Ls=h({visibility:Ds,isEntry:$(),typeParameters:E(or),parameters:E(je),return:E(je)}),qs=h({name:d(),type:je}),Fs=h({abilities:or,typeParameters:E(zs),fields:E(qs)}),Ws=h({fileFormatVersion:Ee(),address:d(),name:d(),friends:E(Ns),structs:Q(d(),Fs),exposedFunctions:Q(d(),Ls)});Q(d(),Ws);function Ct(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function rn(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function cr(t){if(typeof t=="object"&&"Struct"in t)return t;const e=rn(t),r=Ct(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const Ks=M([h({ImmOrOwned:me}),h({Shared:h({objectId:d(),initialSharedVersion:M([ne(),d()]),mutable:$()})}),h({Receiving:me})]),gt=h({Pure:E(ne())}),Bt=h({Object:Ks}),pt=M([gt,Bt]);function Gs(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:Ut(t)?t.toBytes():C.ser(e,t,{maxSize:1/0}).toBytes())}}const N={Pure:Gs,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:A(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:A(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:A(t)}}}}};function br(t){return typeof t=="string"?A(t):"ImmOrOwned"in t.Object?A(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?A(t.Object.Receiving.objectId):A(t.Object.Shared.objectId)}function Hs(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function Zs(t){var e;return((e=Hs(t))==null?void 0:e.mutable)??!1}function Js(t){function e(r,n){return t(r,n)}return e.u8=r=>t(C.U8.serialize(r)),e.u16=r=>t(C.U16.serialize(r)),e.u32=r=>t(C.U32.serialize(r)),e.u64=r=>t(C.U64.serialize(r)),e.u128=r=>t(C.U128.serialize(r)),e.u256=r=>t(C.U256.serialize(r)),e.bool=r=>t(C.Bool.serialize(r)),e.string=r=>t(C.String.serialize(r)),e.address=r=>t(C.Address.serialize(r)),e.id=e.address,e}const Xs="object",Ys="ID",Qs="ascii",ei="String",ti="string",ri="String",ni="option",si="Option",ii={address:Vr,module:Xs,name:Ys},ai={address:Dt,module:Qs,name:ei},oi={address:Dt,module:ti,name:ri},ci={address:Dt,module:ni,name:si},rt=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function ui(t){var r;const e=(r=cr(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 Et(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const li=["Address","Bool","U8","U16","U32","U64","U128","U256"];function jt(t,e){if(typeof t=="string"&&li.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])Et("number",e);else if(t==="Bool")Et("boolean",e);else if(t==="Address"&&(Et("string",e),e&&!ce(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=jt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(rt(t.Struct,ai))return"string";if(rt(t.Struct,oi))return"utf8string";if(rt(t.Struct,ii))return"address";if(rt(t.Struct,ci)){const r={Vector:t.Struct.typeArguments[0]};return jt(r,e)}}}function di(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),m.blake2b(n,{dkLen:32})}function U(t,e){return $r(t,e)}const hi=t=>M([h({None:M([S(!0),S(null)])}),h({Some:t})]),Fe=M([h({kind:S("Input"),index:ne(),value:b(It()),type:b(S("object"))}),h({kind:S("Input"),index:ne(),value:b(It()),type:S("pure")})]),fi=[Fe,h({kind:S("GasCoin")}),h({kind:S("Result"),index:ne()}),h({kind:S("NestedResult"),index:ne(),resultIndex:ne()})],he=M([...fi]),nn=h({kind:S("MoveCall"),target:V("target",d().validator),typeArguments:E(d()),arguments:E(he)}),sn=h({kind:S("TransferObjects"),objects:E(he),address:he}),an=h({kind:S("SplitCoins"),coin:he,amounts:E(he)}),on=h({kind:S("MergeCoins"),destination:he,sources:E(he)}),cn=h({kind:S("MakeMoveVec"),type:b(hi(Q(d(),zr()))),objects:E(he)}),un=h({kind:S("Publish"),modules:E(E(ne())),dependencies:E(d())}),ln=h({kind:S("Upgrade"),modules:E(E(ne())),dependencies:E(d()),packageId:d(),ticket:he}),gi=[nn,sn,an,on,un,ln,cn],pi=M([...gi]),be={MoveCall(t){return U({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},nn)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=N.Pure(C.Address.serialize(e.value))),U({kind:"TransferObjects",objects:t,address:e},sn)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=N.Pure(C.U64.serialize(r.value)))}),U({kind:"SplitCoins",coin:t,amounts:e},an)},MergeCoins(t,e){return U({kind:"MergeCoins",destination:t,sources:e},on)},Publish({modules:t,dependencies:e}){return U({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(Y(r)):r),dependencies:e.map(r=>re(r))},un)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return U({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(Y(s)):s),dependencies:e.map(s=>re(s)),packageId:r,ticket:n},ln)},MakeMoveVec({type:t,objects:e}){return U({kind:"MakeMoveVec",type:t?{Some:le.parseFromStr(t)}:{None:null},objects:e},cn)}},yi=b(B(M([h({Epoch:ne()}),h({None:M([S(!0),S(null)])})]))),Sr=V("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),mi=h({budget:b(Sr),price:b(Sr),payment:b(E(me)),owner:b(d())}),nt=h({version:S(1),sender:b(d()),expiration:yi,gasConfig:mi,inputs:E(Fe),transactions:E(pi)});function Tr(t){return A(t).replace("0x","")}class de{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=C.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=U({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>U({kind:"Input",value:i,index:a,type:z(i,gt)?"pure":"object"},Fe)),transactions:n.transactions},nt);return de.restore(s)}static fromBytes(e){var a;const r=C.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=U({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((c,u)=>U({kind:"Input",value:c,index:u,type:z(c,gt)?"pure":"object"},Fe)),transactions:s.transactions},nt);return de.restore(i)}static restore(e){xt(e,nt);const r=new de;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=di("TransactionData",e);return He(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(f=>(xt(f.value,pt),f.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return C.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,c=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!c)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:Tr(c),expiration:a||{None:!0},gasData:{payment:u.payment,owner:Tr(this.gasConfig.owner??c),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return C.TransactionData.serialize({V1:l},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return de.getDigestFromBytes(e)}snapshot(){return U(this,nt)}}var ur=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},x=(t,e,r)=>(ur(t,e,"read from private field"),r?r.call(t):e.get(t)),ae=(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)},st=(t,e,r,n)=>(ur(t,e,"write to private field"),e.set(t,r),r),R=(t,e,r)=>(ur(t,e,"access private method"),r),v,Ue,at,Ne,ot,we,ke,lr,dn,dr,hn,hr,fn,fr,gn,ct,Mt;const wi={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function bi(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 c=0;for(;;)yield n(c),c++};if(typeof i=="symbol")return;const a=parseInt(i,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function Si(t){const e=cr(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function We(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 pn=Symbol.for("@mysten/transaction"),kt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},Ti=1000n,vi=50,Ei=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function ki(t){return!!t&&typeof t=="object"&&t[pn]===!0}const Pt=class{constructor(t){ae(this,Ue),ae(this,Ne),ae(this,we),ae(this,lr),ae(this,dr),ae(this,hr),ae(this,fr),ae(this,ct),ae(this,v,void 0),st(this,v,new de(t?t.blockData:void 0))}static fromKind(t){const e=new Pt;return st(e,v,de.fromKindBytes(typeof t=="string"?Y(t):t)),e}static from(t){const e=new Pt;return typeof t!="string"||!t.startsWith("{")?st(e,v,de.fromBytes(typeof t=="string"?Y(t):t)):st(e,v,de.restore(JSON.parse(t))),e}setSender(t){x(this,v).sender=t}setSenderIfNotSet(t){x(this,v).sender||(x(this,v).sender=t)}setExpiration(t){x(this,v).expiration=t}setGasPrice(t){x(this,v).gasConfig.price=String(t)}setGasBudget(t){x(this,v).gasConfig.budget=String(t)}setGasOwner(t){x(this,v).gasConfig.owner=t}setGasPayment(t){x(this,v).gasConfig.payment=t.map(e=>Ur(e,me))}get blockData(){return x(this,v).snapshot()}get[pn](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:Js((t,e)=>Ut(t)?R(this,Ue,at).call(this,"pure",{Pure:Array.from(t.toBytes())}):R(this,Ue,at).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=br(t),r=x(this,v).inputs.find(n=>n.type==="object"&&e===br(n.value));return r&&z(r.value,Bt)&&"Shared"in r.value.Object&&z(t,Bt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??R(this,Ue,at).call(this,"object",typeof t=="string"?A(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=x(this,v).transactions.push(t);return bi(e-1)}splitCoins(t,e){return this.add(be.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):R(this,Ne,ot).call(this,r))))}mergeCoins(t,e){return this.add(be.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(be.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(be.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(be.MoveCall({arguments:t==null?void 0:t.map(n=>R(this,Ne,ot).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(be.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):R(this,Ne,ot).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(be.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(x(this,v).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await R(this,ct,Mt).call(this,t),x(this,v).build({maxSizeBytes:R(this,we,ke).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await R(this,ct,Mt).call(this,t),x(this,v).getDigest()}};let xi=Pt;v=new WeakMap;Ue=new WeakSet;at=function(t,e){const r=x(this,v).inputs.length,n=U({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Fe);return x(this,v).inputs.push(n),n};Ne=new WeakSet;ot=function(t){return Ut(t)?this.pure(t):t};we=new WeakSet;ke=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return wi[t];const n=e==null?void 0:e.attributes[kt[t]];if(!n)throw new Error(`Missing expected protocol config: "${kt[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: "${kt[t]}"`);return Number(s)};lr=new WeakSet;dn=function(t){const e=R(this,we,ke).call(this,"maxPureArgumentSize",t);x(this,v).inputs.forEach((r,n)=>{if(z(r.value,gt)&&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`)})};dr=new WeakSet;hn=async function(t){if(x(this,v).gasConfig.payment){const s=R(this,we,ke).call(this,"maxGasObjects",t);if(x(this,v).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||x(this,v).gasConfig.payment)return;const e=x(this,v).gasConfig.owner??x(this,v).sender,n=(await We(t).getCoins({owner:e,coinType:es})).data.filter(s=>!x(this,v).inputs.find(a=>z(a.value,pt)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,R(this,we,ke).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)};hr=new WeakSet;fn=async function(t){t.onlyTransactionKind||x(this,v).gasConfig.price||this.setGasPrice(await We(t).getReferenceGasPrice())};fr=new WeakSet;gn=async function(t){const{inputs:e,transactions:r}=x(this,v),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:A(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(c=>c.kind==="Input"&&!z(e[c.index].value,pt))&&n.push(i),i.kind==="SplitCoins"&&i.amounts.forEach(a=>{if(a.kind==="Input"){const c=e[a.index];typeof c.value!="object"&&(c.value=N.Pure(C.U64.serialize(c.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=N.Pure(C.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,c,u]=i.target.split("::"),l=await We(t).getNormalizedMoveFunction({package:re(a),module:c,function:u}),g=l.parameters.length>0&&ui(l.parameters.at(-1))?l.parameters.slice(0,l.parameters.length-1):l.parameters;if(g.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");g.forEach((y,p)=>{const w=i.arguments[p];if(w.kind!=="Input")return;const T=e[w.index];if(z(T.value,pt))return;const k=T.value,j=jt(y,k);if(j){T.value=N.Pure(k,j);return}if(cr(y)!=null||typeof y=="object"&&"TypeParameter"in y){if(typeof k!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(k,null,2)}`);s.push({id:k,input:T,normalizedType:y});return}throw new Error(`Unknown call arg type ${JSON.stringify(y,null,2)} for value ${JSON.stringify(k,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:f})=>f))],a=Ei(i,vi),c=(await Promise.all(a.map(f=>We(t).multiGetObjects({ids:f,options:{showOwner:!0}})))).flat();let u=new Map(i.map((f,g)=>[f,c[g]]));const l=Array.from(u).filter(([f,g])=>g.error).map(([f,g])=>f);if(l.length)throw new Error(`The following input objects are invalid: ${l.join(", ")}`);s.forEach(({id:f,input:g,normalizedType:y})=>{var k;const p=u.get(f),w=(k=p.data)==null?void 0:k.owner,T=w&&typeof w=="object"&&"Shared"in w?w.Shared.initial_shared_version:void 0;if(T){const j=y!=null&&Ct(y)==null&&rn(y)==null,P=Zs(g.value)||j||y!=null&&Ct(y)!=null;g.value=N.SharedObjectRef({objectId:f,initialSharedVersion:T,mutable:P})}else y&&Si(y)?g.value=N.ReceivingRef(wr(p)):g.value=N.ObjectRef(wr(p))})}};ct=new WeakSet;Mt=async function(t){if(!t.onlyTransactionKind&&!x(this,v).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([R(this,hr,fn).call(this,t),R(this,fr,gn).call(this,t)]),!t.onlyTransactionKind&&(await R(this,dr,hn).call(this,t),!x(this,v).gasConfig.budget)){const e=await We(t).dryRunTransactionBlock({transactionBlock:x(this,v).build({maxSizeBytes:R(this,we,ke).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(R(this,we,ke).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=Ti*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)}R(this,lr,dn).call(this,t)};const Ii=Symbol.for("@mysten/SuiClient");class _i{get[Ii](){return!0}constructor(e){this.transport=e.transport??new hs({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!ce(A(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||!ce(A(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||!ce(A(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||!ce(A(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||!ce(A(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||!et(re(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||!et(re(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(!yr(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(!yr(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:D(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||!ce(A(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||!et(re(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(ki(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=D(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=D(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:D(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!et(re(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=Ze(e.digest);return Ie(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((c,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 yn extends _r.ChainContext{}const Ke="Sui",gr=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},Ai=(t,e)=>{try{return Er(t)===Er(e)}catch{return!1}},Oi=t=>(t==null?void 0:t.type)==="created",Ci=t=>(t==null?void 0:t.type)==="published";function Bi(t){return Array.isArray(t)}function yt(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function mn(t){return typeof t=="object"&&!Bi(t)&&!yt(t)}const ji=16*1024,Mi=t=>C.ser("vector<u8>",t,{maxSize:ji}).toBytes(),Pi=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||!yt(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return Sn(r.content.type)},wn=async(t,e)=>{if(!ce(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return gr(r)};async function Ri(t,e){let r,n;do{const a=await t.getDynamicFields({parentId:e,cursor:n});r=a.data.find(c=>c.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=gr(s);if(!i||!mn(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!yt(i.value))throw new Error("Unable to get package id");return i.value.fields.package}const $i=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 c of i.data){if(!c.data)continue;const{version:u,objectId:l}=c.data;(n===null||u<n)&&(n=u,s=l)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},Ui=async(t,e)=>{const r=new xi,[n]=r.publish({modules:t.modules.map(s=>Array.from(m.b64.decode(s))),dependencies:t.dependencies.map(s=>re(s))});return r.transferObjects([n],r.pure(e)),r},oe=class oe extends _r.PlatformContext{constructor(e,r){super(e,r??m.networkPlatformConfigs(e,oe._platform))}getRpc(e){if(e in this.config)return new _i({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new yn(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!oe.isSupportedChain(r))throw new Error(`invalid chain for ${Ke}: ${r}`);return m.Wormhole.tokenId(r,ts)}static isNativeTokenId(e,r,n){return!oe.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return m.chainToPlatform(e)===oe._platform}static async getDecimals(e,r,n){if(m.isNative(n))return m.nativeDecimals(oe._platform);const s=new fe(n);try{const a=await wn(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.getCoinType()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getBalance(e,r,n,s){if(m.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 c=await this.getBalance(e,r,n,a);return{[m.isNative(a)?"native":new fe(a).toString()]:c}}))).reduce((a,c)=>Object.assign(a,c),{})}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=m.platformNativeChainIdToNetworkChain(oe._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)}};te(oe,"_platform",Ke);let xe=oe;const pr=t=>/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(t),bn=t=>t.replace(/(0x)(0*)/g,"0x");function vr(t){return t=t.startsWith("0x")?t.slice(2):t,t=t.length%2===0?t:"0"+t,`0x${t.length===64?t:m.hex.encode(m.bytes.zpad(m.hex.decode(t),32))}`}const Er=t=>{const e=t.split(Ae);if(e.length!==3)throw new Error(`Invalid Sui type: ${t}`);return[A(e[0]),e[1],e[2]].join(Ae)},Ni=t=>new fe(t).getCoinType(),Sn=t=>new fe(t).getPackageId(),Di=t=>{const e=bn(t).match(/0x2::table::Table<(.*)>/);if(!e)throw new Error(`Invalid table type: ${t}`);if(e.length<2)throw new Error(`Invalid table type: ${t}`);const[r]=e[1].split(",");if(!r||!pr(r))throw new Error(`Invalid key type: ${r}`);return r},Te=class Te{constructor(e){te(this,"address");te(this,"module");if(Te.instanceof(e))this.address=e.address,this.module=e.module;else if(m.UniversalAddress.instanceof(e))this.address=e.toUint8Array();else if(typeof e=="string"){if(pr(e)){const r=e.split(Ae);this.module=r.slice(1).join(Ae),e=r[0]}if(e=vr(e),!m.hex.valid(e))throw new Error("Invalid Sui address: "+e);this.address=m.hex.decode(e)}else this.address=e}unwrap(){const e=this.getPackageId(),r=this.module?Ae+this.module:"";return`${e}${r}`}toString(){return this.unwrap()}toNative(){return this}toUint8Array(){return this.address}toUniversalAddress(){return new m.UniversalAddress(this.toUint8Array())}getPackageId(){return vr(m.hex.encode(this.address))}getCoinType(){return[this.getPackageId(),"coin","COIN"].join(Ae)}static instanceof(e){return e.constructor.platform===Te.platform}equals(e){return Te.instanceof(e)?e.unwrap()===this.unwrap():this.toUniversalAddress().equals(e)}};te(Te,"byteSize",32),te(Te,"platform",xe._platform);let fe=Te;m.registerNative(Ke,fe);var Ge=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))(Ge||{});function zi(t){return[t,0,0]}function Tn(t,e){const r=zi(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const mt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},Vi={ED25519:32,Secp256k1:33,Secp256r1:33},Li={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function qi(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function Fi(t,e){const r=t.toString(16);return m.hexToBytes(r.padStart(e*2,"0").slice(-e*2))}function Wi(t,e){const r=Fi(t,e),n=qi(r);return n===-1?new Uint8Array([0]):r.slice(n)}function Ki(t,e){const r=Wi(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([mt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),A(m.bytesToHex(m.blake2b(s,{dkLen:32})).slice(0,Xe*2))}function Gi(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 Hi(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=Gi(n);e=e.concat(s)}return e}function Zi(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=Hi(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 c=0;c<r.length;c+=8){const u=r.slice(c,c+8),l=parseInt(u.join(""),2);i[a++]=l}return new TextDecoder().decode(i)}function Ji(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 Xi(t,e){const r=Zi(t.value,t.indexMod4),[n,s]=Ji(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const Yi=o.struct("ZkLoginSignature",{inputs:o.struct("ZkLoginSignatureInputs",{proofPoints:o.struct("ZkLoginSignatureInputsProofPoints",{a:o.vector(o.string()),b:o.vector(o.vector(o.string())),c:o.vector(o.string())}),issBase64Details:o.struct("ZkLoginSignatureInputsClaim",{value:o.string(),indexMod4:o.u8()}),headerBase64:o.string(),addressSeed:o.string()}),maxEpoch:o.u64(),userSignature:o.vector(o.u8())});function Qi(t){return Yi.parse(typeof t=="string"?Y(t):t)}function ea({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([mt[e]]),s.set(t,1),s.set(n,1+t.length),D(s)}function ta(t){const e=Y(t),r=Li[e[0]];switch(r){case"MultiSig":const n=C.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:c}=Qi(s),{issBase64Details:u,addressSeed:l}=i,f=Xi(u,"iss"),g=Ki(BigInt(l),f);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:c,iss:f,address:g,addressSeed:BigInt(l)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const y=Vi[r],p=e.slice(1,e.length-y),w=e.slice(1+p.length);return{serializedSignature:t,signatureScheme:r,signature:p,publicKey:w,bytes:e};default:throw new Error("Unsupported signature scheme")}}const ut=32,ra="suiprivkey";class na{async signWithIntent(e,r){const n=Tn(r,e),s=m.blake2b(n,{dkLen:32});return{signature:ea({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:D(e)}}async signTransactionBlock(e){return this.signWithIntent(e,Ge.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(o.vector(o.u8()).serialize(e).toBytes(),Ge.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class sa extends na{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function ia(t,e){if(t.length!==ut)throw new Error("Invalid bytes length");const r=mt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),m.bech32.encode(ra,m.bech32.toWords(n))}function kr(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function aa(t){return On(t,"")}function oa(t){return Ie(aa(t))}const ca="ed25519 seed",ua=2147483648,la=new RegExp("^m(\\/[0-9]+')+$"),vn=t=>t.replace("'",""),da=t=>{const r=m.hmac.create(m.sha512,ca).update(Je(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},ha=({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=m.hmac.create(m.sha512,e).update(i).digest(),c=a.slice(0,32),u=a.slice(32);return{key:c,chainCode:u}},fa=t=>la.test(t)?!t.split("/").slice(1).map(vn).some(isNaN):!1,xr=(t,e,r=ua)=>{if(!fa(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=da(e);return t.split("/").slice(1).map(vn).map(a=>parseInt(a,10)).reduce((a,c)=>ha(a,c+r),{key:n,chainCode:s})};function En(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 ga{equals(e){return En(this.toRawBytes(),e.toRawBytes())}toBase64(){return D(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return D(e)}verifyWithIntent(e,r,n){const s=Tn(n,e),i=m.blake2b(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(C.vector(C.u8()).serialize(e).toBytes(),r,Ge.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,Ge.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return A(m.bytesToHex(m.blake2b(this.toSuiBytes(),{dkLen:32})).slice(0,Xe*2))}}const Rt=32;class kn extends ga{constructor(e){if(super(),typeof e=="string"?this.data=Y(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==Rt)throw new Error(`Invalid public key input. Expected ${Rt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return mt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=ta(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!En(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return m.nacl.sign.detached.verify(e,n,this.toRawBytes())}}kn.SIZE=Rt;const Ir="m/44'/784'/0'/0'/0'";class Oe extends sa{constructor(e){super(),e?this.keypair=e:this.keypair=m.nacl.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Oe(m.nacl.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==ut)throw new Error(`Wrong secretKey size. Expected ${ut} bytes, got ${n}.`);const s=m.nacl.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),c=m.nacl.sign.detached(a,s.secretKey);if(!m.nacl.sign.detached.verify(a,c,s.publicKey))throw new Error("provided secretKey is invalid")}return new Oe(s)}getPublicKey(){return new kn(this.keypair.publicKey)}getSecretKey(){return ia(this.keypair.secretKey.slice(0,ut),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return m.nacl.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=Ir),!kr(r))throw new Error("Invalid derivation path");const{key:n}=xr(r,oa(e));return Oe.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=Ir),!kr(r))throw new Error("Invalid derivation path");const{key:n}=xr(r,e);return Oe.fromSecretKey(n)}}async function pa(t,e){const[,r]=await xe.chainFromRpc(t);return new ya(r,t,Oe.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class ya{constructor(e,r,n,s){te(this,"_chain");te(this,"_client");te(this,"_signer");te(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()}`);const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}return r}}const ma={Address:fe,Platform:xe,getSigner:pa,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-Vqfiz4gq.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-BdZfdhLf.js"))},getChain:(t,e,r)=>new yn(e,new xe(t,m.applyChainsConfigConfigOverrides(t,Ke,{[e]:r})))},wa=Object.freeze(Object.defineProperty({__proto__:null,default:ma},Symbol.toStringTag,{value:"Module"}));exports.SuiAddress=fe;exports.SuiPlatform=xe;exports._platform=Ke;exports.getCoinTypeFromPackageId=Ni;exports.getFieldsFromObjectResponse=gr;exports.getObjectFields=wn;exports.getOldestEmitterCapObjectId=$i;exports.getOriginalPackageId=Pi;exports.getPackageId=Ri;exports.getPackageIdFromType=Sn;exports.getTableKeyType=Di;exports.isMoveStructObject=mn;exports.isMoveStructStruct=yt;exports.isSameType=Ai;exports.isSuiCreateEvent=Oi;exports.isSuiPublishEvent=Ci;exports.isValidSuiType=pr;exports.publishPackage=Ui;exports.sui=wa;exports.trimSuiType=bn;exports.uint8ArrayToBCS=Mi;
|
|
5
|
+
Received: "${JSON.stringify(u)}"`);let g=Object.keys(u)[0];if(g===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let y=n.indexOf(g);if(y===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${g}"`);let p=n[y],w=r[p];if(c.write8(y),w===null)return c;let T=i.indexOf(w),k=T===-1?w:l[T];{let{name:j,params:P}=this.parseTypeName(k);return this.getTypeInterface(j)._encodeRaw.call(this,c,u[g],P,f)}},function(c,u,l){let f=c.readULEB(),g=n[f],y=r[g];if(f===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${f}"`);if(y===null)return{[g]:!0};let p=i.indexOf(y),w=p===-1?y:u[p];{let{name:T,params:k}=this.parseTypeName(w);return{[g]:this.getTypeInterface(T)._decodeRaw.call(this,c,k,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[c,...u]=t;return{name:c,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=Br(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let _=Re;_.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 qn(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(Je(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return Ie(new Uint8Array(r))}),t.registerType(_.BASE58,function(e,r){return e.writeVec(Array.from(Ze(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return He(new Uint8Array(r))}),t.registerType(_.BASE64,function(e,r){return e.writeVec(Array.from(Y(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return D(new Uint8Array(r))})}function Fn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Ln,addressEncoding:"hex"}}const Wn=32;function yr(t){try{return Ze(t).length===Wn}catch{return!1}}const Xe=32;function ce(t){return Kn(t)&&Gn(t)===Xe}function et(t){return ce(t)}function A(t,e=!1){let r=t.toLowerCase();return!e&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(Xe*2,"0")}`}function re(t,e=!1){return A(t,e)}function Kn(t){return/^(0x|0X)?[a-fA-F0-9]+$/.test(t)&&t.length%2===0}function Gn(t){return/^(0x|0X)/.test(t)?(t.length-2)/2:t.length/2}class Hn extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:c}=e,u=c.length===0?s:`At path: ${c.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 Zn(t){return F(t)&&typeof t[Symbol.iterator]=="function"}function F(t){return typeof t=="object"&&t!=null}function W(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function Jn(t){const{done:e,value:r}=t.next();return e?void 0:r}function Xn(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:c,message:u=`Expected a value of type \`${a}\`${c?` with refinement \`${c}\``:""}, but received: \`${W(n)}\``}=t;return{value:n,type:a,refinement:c,key:s[s.length-1],path:s,branch:i,...t,message:u}}function*mr(t,e,r,n){Zn(t)||(t=[t]);for(const s of t){const i=Xn(s,e,r,n);i&&(yield i)}}function*Nt(t,e,r={}){const{path:n=[],branch:s=[t],coerce:i=!1,mask:a=!1}=r,c={path:n,branch:s};if(i&&(t=e.coercer(t,c),a&&e.type!=="type"&&F(e.schema)&&F(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,c))l.explanation=r.message,u="not_valid",yield[l,void 0];for(let[l,f,g]of e.entries(t,c)){const y=Nt(f,g,{path:l===void 0?n:[...n,l],branch:l===void 0?s:[...s,f],coerce:i,mask:a,message:r.message});for(const p of y)p[0]?(u=p[0].refinement!=null?"not_refined":"not_valid",yield[p[0],void 0]):i&&(f=p[1],l===void 0?t=f:t instanceof Map?t.set(l,f):t instanceof Set?t.add(f):F(t)&&(f!==void 0||l in t)&&(t[l]=f))}if(u!=="not_valid")for(const l of e.refiner(t,c))l.explanation=r.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,t])}class se{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=u=>u,entries:c=function*(){}}=e;this.type=r,this.schema=n,this.entries=c,this.coercer=a,s?this.validator=(u,l)=>{const f=s(u,l);return mr(f,l,this,u)}:this.validator=()=>[],i?this.refiner=(u,l)=>{const f=i(u,l);return mr(f,l,this,u)}:this.refiner=()=>[]}assert(e,r){return xt(e,this,r)}create(e,r){return $r(e,this,r)}is(e){return z(e,this)}mask(e,r){return Ur(e,this,r)}validate(e,r={}){return Ye(e,this,r)}}function xt(t,e,r){const n=Ye(t,e,{message:r});if(n[0])throw n[0]}function $r(t,e,r){const n=Ye(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Ur(t,e,r){const n=Ye(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function z(t,e){return!Ye(t,e)[0]}function Ye(t,e,r={}){const n=Nt(t,e,r),s=Jn(n);return s[0]?[new Hn(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Ve(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?Qn(n):h(n)}function V(t,e){return new se({type:t,schema:null,validator:e})}function It(){return V("any",()=>!0)}function E(t){return new se({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: ${W(e)}`}})}function Yn(){return V("bigint",t=>typeof t=="bigint")}function $(){return V("boolean",t=>typeof t=="boolean")}function ne(){return V("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${W(t)}`)}function S(t){const e=W(t),r=typeof t;return new se({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${W(n)}`}})}function Nr(){return V("never",()=>!1)}function B(t){return new se({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function Ee(){return V("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${W(t)}`)}function h(t){const e=t?Object.keys(t):[],r=Nr();return new se({type:"object",schema:t||null,*entries(n){if(t&&F(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 F(n)||`Expected an object, but received: ${W(n)}`},coercer(n){return F(n)?{...n}:n}})}function b(t){return new se({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Q(t,e){return new se({type:"record",schema:null,*entries(r){if(F(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return F(r)||`Expected an object, but received: ${W(r)}`}})}function d(){return V("string",t=>typeof t=="string"||`Expected a string, but received: ${W(t)}`)}function Dr(t){const e=Nr();return new se({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: ${W(r)}`}})}function Qn(t){const e=Object.keys(t);return new se({type:"type",schema:t,*entries(r){if(F(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return F(r)||`Expected an object, but received: ${W(r)}`},coercer(r){return F(r)?{...r}:r}})}function M(t){const e=t.map(r=>r.type).join(" | ");return new se({type:"union",schema:null,coercer(r){for(const n of t){const[s,i]=n.validate(r,{coerce:!0});if(!s)return i}return r},validator(r,n){const s=[];for(const i of t){const[...a]=Nt(r,i,n),[c]=a;if(c[0])for(const[u]of a)u&&s.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${W(r)}`,...s]}})}function zr(){return V("unknown",()=>!0)}BigInt(1e9);const Dt="0x1",Vr="0x2";re("0x6");const es=`${Vr}::sui::SUI`;re("0x5");const Ae="::",ts="0x2::sui::SUI",rs="0.50.1",ns="1.19.0",ss={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class Lr extends Error{}class qr extends Lr{constructor(e,r){super(e),this.code=r,this.type=ss[r]??"ServerError"}}class is extends Lr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var zt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},O=(t,e,r)=>(zt(t,e,"read from private field"),r?r.call(t):e.get(t)),pe=(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)},Ce=(t,e,r,n)=>(zt(t,e,"write to private field"),e.set(t,r),r),as=(t,e,r,n)=>({set _(s){Ce(t,e,s)},get _(){return O(t,e,n)}}),Fr=(t,e,r)=>(zt(t,e,"access private method"),r),Se,De,ue,ve,Le,Be,_t,Wr,Vt,Kr;function os(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const cs={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class us{constructor(e,r={}){if(pe(this,_t),pe(this,Vt),pe(this,Se,0),pe(this,De,0),pe(this,ue,null),pe(this,ve,null),pe(this,Le,new Set),pe(this,Be,new Map),this.endpoint=e,this.options={...cs,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=os(this.endpoint))}async makeRequest(e,r){const n=await Fr(this,_t,Wr).call(this);return new Promise((s,i)=>{Ce(this,Se,O(this,Se)+1),O(this,Be).set(O(this,Se),{resolve:s,reject:i,timeout:setTimeout(()=>{O(this,Be).delete(O(this,Se)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:O(this,Se),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new qr(s.message,s.code);return i})}async subscribe(e){const r=new ls(e);return O(this,Le).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}Se=new WeakMap;De=new WeakMap;ue=new WeakMap;ve=new WeakMap;Le=new WeakMap;Be=new WeakMap;_t=new WeakSet;Wr=function(){return O(this,ve)?O(this,ve):(Ce(this,ve,new Promise(t=>{var e;(e=O(this,ue))==null||e.close(),Ce(this,ue,new this.options.WebSocketConstructor(this.endpoint)),O(this,ue).addEventListener("open",()=>{Ce(this,De,0),t(O(this,ue))}),O(this,ue).addEventListener("close",()=>{as(this,De)._++,O(this,De)<=this.options.maxReconnects&&setTimeout(()=>{Fr(this,Vt,Kr).call(this)},this.options.reconnectTimeout)}),O(this,ue).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&&O(this,Be).has(n.id)){const{resolve:s,timeout:i}=O(this,Be).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;O(this,Le).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),O(this,ve))};Vt=new WeakSet;Kr=async function(){var t;return(t=O(this,ue))==null||t.close(),Ce(this,ve,null),Promise.allSettled([...O(this,Le)].map(e=>e.subscribe(this)))};class ls{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 Lt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},q=(t,e,r)=>(Lt(t,e,"read from private field"),r?r.call(t):e.get(t)),tt=(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)},At=(t,e,r,n)=>(Lt(t,e,"write to private field"),e.set(t,r),r),ds=(t,e,r)=>(Lt(t,e,"access private method"),r),$e,Z,ze,Ot,Gr;class hs{constructor(e){tt(this,Ot),tt(this,$e,0),tt(this,Z,void 0),tt(this,ze,void 0),At(this,Z,e)}fetch(e,r){const n=q(this,Z).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;At(this,$e,q(this,$e)+1);const r=await this.fetch(((s=q(this,Z).rpc)==null?void 0:s.url)??q(this,Z).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":rs,"Client-Target-Api-Version":ns,...(i=q(this,Z).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:q(this,$e),method:e.method,params:e.params})});if(!r.ok)throw new is(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new qr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await ds(this,Ot,Gr).call(this).subscribe(e);return async()=>!!await r()}}$e=new WeakMap;Z=new WeakMap;ze=new WeakMap;Ot=new WeakSet;Gr=function(){var t;if(!q(this,ze)){const e=q(this,Z).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.");At(this,ze,new us(((t=q(this,Z).websocket)==null?void 0:t.url)??q(this,Z).url,{WebSocketConstructor:e,...q(this,Z).websocket}))}return q(this,ze)};const fs=/^vector<(.+)>$/,gs=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class le{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(fs);if(n)return{vector:le.parseFromStr(n[1],r)};const s=e.match(gs);if(s)return{struct:{address:r?A(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:le.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return Br(e).map(n=>le.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<${le.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(le.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const I=new _({...Fn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function Hr(t){return o.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function ps(t){return o.enum("Option",{None:null,Some:t})}function qt(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const X=o.bytes(Xe).transform({input:t=>typeof t=="string"?Je(A(t)):t,output:t=>A(Ie(t))}),Ft=o.vector(o.u8()).transform({name:"ObjectDigest",input:t=>Ze(t),output:t=>He(new Uint8Array(t))}),qe=o.struct("SuiObjectRef",{objectId:X,version:o.u64(),digest:Ft}),Wt=o.struct("SharedObjectRef",{objectId:X,initialSharedVersion:o.u64(),mutable:o.bool()}),ft=o.enum("ObjectArg",{ImmOrOwned:qe,Shared:Wt,Receiving:qe}),Kt=o.enum("CallArg",{Pure:o.vector(o.u8()),Object:ft,ObjVec:o.vector(ft)}),Me=o.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:o.lazy(()=>Me),struct:o.lazy(()=>Yt),u16:null,u32:null,u256:null}),G=qt(o.enum("Argument",{GasCoin:null,Input:o.struct("Input",{index:o.u16()}),Result:o.struct("Result",{index:o.u16()}),NestedResult:o.struct("NestedResult",{index:o.u16(),resultIndex:o.u16()})})),Gt=o.struct("ProgrammableMoveCall",{package:X,module:o.string(),function:o.string(),type_arguments:o.vector(Me),arguments:o.vector(G)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>le.parseFromStr(i,!0));return{package:A(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(le.tagToString)})}),Ht=qt(o.enum("Transaction",{MoveCall:Gt,TransferObjects:o.struct("TransferObjects",{objects:o.vector(G),address:G}),SplitCoins:o.struct("SplitCoins",{coin:G,amounts:o.vector(G)}),MergeCoins:o.struct("MergeCoins",{destination:G,sources:o.vector(G)}),Publish:o.struct("Publish",{modules:o.vector(o.vector(o.u8())),dependencies:o.vector(X)}),MakeMoveVec:o.struct("MakeMoveVec",{type:ps(Me),objects:o.vector(G)}),Upgrade:o.struct("Upgrade",{modules:o.vector(o.vector(o.u8())),dependencies:o.vector(X),packageId:X,ticket:G})})),Zt=o.struct("ProgrammableTransaction",{inputs:o.vector(Kt),transactions:o.vector(Ht)}),Jt=o.enum("TransactionKind",{ProgrammableTransaction:Zt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Xt=o.enum("TransactionExpiration",{None:null,Epoch:Hr()}),Yt=o.struct("StructTag",{address:X,module:o.string(),name:o.string(),typeParams:o.vector(Me)}),Qt=o.struct("GasData",{payment:o.vector(qe),owner:X,price:o.u64(),budget:o.u64()}),er=o.struct("TransactionDataV1",{kind:Jt,sender:X,gasData:Qt,expiration:Xt}),tr=o.enum("TransactionData",{V1:er}),ys=o.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),ms=o.enum("IntentVersion",{V0:null}),ws=o.enum("AppId",{Sui:null}),bs=o.struct("Intent",{scope:ys,version:ms,appId:ws}),Ss=o.generic(["T"],t=>o.struct("IntentMessage<T>",{intent:bs,value:t})),rr=o.enum("CompressedSignature",{ED25519:o.fixedArray(64,o.u8()),Secp256k1:o.fixedArray(64,o.u8()),Secp256r1:o.fixedArray(64,o.u8()),ZkLogin:o.vector(o.u8())}),nr=o.enum("PublicKey",{ED25519:o.fixedArray(32,o.u8()),Secp256k1:o.fixedArray(33,o.u8()),Secp256r1:o.fixedArray(33,o.u8()),ZkLogin:o.vector(o.u8())}),sr=o.struct("MultiSigPkMap",{pubKey:nr,weight:o.u8()}),ir=o.struct("MultiSigPublicKey",{pk_map:o.vector(sr),threshold:o.u16()}),Zr=o.struct("MultiSig",{sigs:o.vector(rr),bitmap:o.u16(),multisig_pk:ir}),Ts=o.vector(o.u8()).transform({input:t=>typeof t=="string"?Y(t):t,output:t=>D(new Uint8Array(t))}),Jr=o.struct("SenderSignedTransaction",{intentMessage:Ss(tr),txSignatures:o.vector(Ts)}),Xr=o.vector(Jr,{name:"SenderSignedData"}),C={...o,U8:o.u8(),U16:o.u16(),U32:o.u32(),U64:o.u64(),U128:o.u128(),U256:o.u256(),ULEB128:o.uleb128(),Bool:o.bool(),String:o.string(),Address:X,Argument:G,CallArg:Kt,CompressedSignature:rr,GasData:Qt,MultiSig:Zr,MultiSigPkMap:sr,MultiSigPublicKey:ir,ObjectArg:ft,ObjectDigest:Ft,ProgrammableMoveCall:Gt,ProgrammableTransaction:Zt,PublicKey:nr,SenderSignedData:Xr,SenderSignedTransaction:Jr,SharedObjectRef:Wt,StructTag:Yt,SuiObjectRef:qe,Transaction:Ht,TransactionData:tr,TransactionDataV1:er,TransactionExpiration:Xt,TransactionKind:Jt,TypeTag:Me,ser:I.ser.bind(I),de:I.de.bind(I),getTypeInterface:I.getTypeInterface.bind(I),hasType:I.hasType.bind(I),parseTypeName:I.parseTypeName.bind(I),registerAddressType:I.registerAddressType.bind(I),registerAlias:I.registerAlias.bind(I),registerBcsType:I.registerBcsType.bind(I),registerEnumType:I.registerEnumType.bind(I),registerStructType:I.registerStructType.bind(I),registerType:I.registerType.bind(I),types:I.types};I.registerBcsType("utf8string",()=>o.string({name:"utf8string"}));I.registerBcsType("unsafe_u64",()=>Hr());I.registerBcsType("enumKind",t=>qt(t));[X,G,Kt,rr,Qt,Zr,sr,ir,ft,Ft,Gt,Zt,nr,Xr,Wt,Yt,qe,Ht,tr,er,Xt,Jt,Me].forEach(t=>{I.registerBcsType(t.name,()=>t)});const ar=M([h({AddressOwner:d()}),h({ObjectOwner:d()}),h({Shared:h({initial_shared_version:B(d())})}),S("Immutable")]);V("SuiJsonValue",()=>!0);const vs=M([h({u32:d()}),h({u64:d()}),h({f64:d()})]);h({attributes:Q(d(),B(vs)),featureFlags:Q(d(),$()),maxSupportedProtocolVersion:d(),minSupportedProtocolVersion:d(),protocolVersion:d()});M([d(),S("package")]);const me=h({digest:d(),objectId:d(),version:M([Ee(),d(),Yn()])});h({owner:ar,reference:me});h({objectId:d(),sequenceNumber:d()});h({payment:E(me),owner:d(),price:d(),budget:d()});const Es=Ve(me,h({type:d(),owner:ar,previousTransaction:d()})),ks=Q(d(),It()),xs=Q(d(),zr()),Is=h({type:d(),fields:ks,hasPublicTransfer:$()}),_s=h({disassembled:xs}),As=M([Ve(Is,h({dataType:S("moveObject")})),Ve(_s,h({dataType:S("package")}))]),Os=h({type:d(),hasPublicTransfer:$(),version:d(),bcsBytes:d()}),Cs=h({id:d(),moduleMap:Q(d(),d())}),Bs=M([Ve(Os,h({dataType:S("moveObject")})),Ve(Cs,h({dataType:S("package")}))]);BigInt(1e9);const Yr=h({code:d(),error:b(d()),object_id:b(d()),parent_object_id:b(d()),version:b(d()),digest:b(d())}),js=h({data:B(b(Q(d(),d()))),error:B(b(Yr))}),Ms=M([js,b(Q(d(),d()))]),Qr=h({objectId:d(),version:d(),digest:d(),type:B(b(d())),content:B(b(As)),bcs:B(b(Bs)),owner:B(b(ar)),previousTransaction:B(b(d())),storageRebate:B(b(d())),display:B(b(Ms))});h({showType:B(b($())),showContent:B(b($())),showBcs:B(b($())),showOwner:B(b($())),showPreviousTransaction:B(b($())),showStorageRebate:B(b($())),showDisplay:B(b($()))});M([S("Exists"),S("notExists"),S("Deleted")]);E(Es);const Ps=h({data:B(b(Qr)),error:B(b(Yr))});function Rs(t){return t.data}function $s(t){if(t.error&&"object_id"in t.error&&"version"in t.error&&"digest"in t.error){const e=t.error;return{objectId:e.object_id,version:e.version,digest:e.digest}}}function wr(t){if("reference"in t)return t.reference;const e=Rs(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:$s(t)}h({objectId:d(),atCheckpoint:b(Ee())});h({data:E(Ps),nextCursor:b(B(d())),hasNextPage:$()});M([h({details:Qr,status:S("VersionFound")}),h({details:d(),status:S("ObjectNotExists")}),h({details:me,status:S("ObjectDeleted")}),h({details:Dr([d(),Ee()]),status:S("VersionNotFound")}),h({details:h({asked_version:Ee(),latest_version:Ee(),object_id:d()}),status:S("VersionTooHigh")})]);const Us=M([d(),h({Object:d()})]);E(Us);const Ns=h({address:d(),name:d()}),Ds=M([S("Private"),S("Public"),S("Friend")]),or=h({abilities:E(d())}),zs=h({constraints:or,isPhantom:$()}),Vs=h({TypeParameter:Ee()}),vt=Dr([h({module:d(),package:d(),function:d()}),d()]);h({rank3Days:E(vt),rank7Days:E(vt),rank30Days:E(vt)});function en(t){if(!t)return!1;if(typeof t=="string"||z(t,Vs)||tn(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(z(e.Reference,je)||z(e.MutableReference,je)||z(e.Vector,je))}const je=V("SuiMoveNormalizedType",en);function tn(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=>en(n)))}V("SuiMoveNormalizedStructType",tn);const Ls=h({visibility:Ds,isEntry:$(),typeParameters:E(or),parameters:E(je),return:E(je)}),qs=h({name:d(),type:je}),Fs=h({abilities:or,typeParameters:E(zs),fields:E(qs)}),Ws=h({fileFormatVersion:Ee(),address:d(),name:d(),friends:E(Ns),structs:Q(d(),Fs),exposedFunctions:Q(d(),Ls)});Q(d(),Ws);function Ct(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function rn(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function cr(t){if(typeof t=="object"&&"Struct"in t)return t;const e=rn(t),r=Ct(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const Ks=M([h({ImmOrOwned:me}),h({Shared:h({objectId:d(),initialSharedVersion:M([ne(),d()]),mutable:$()})}),h({Receiving:me})]),gt=h({Pure:E(ne())}),Bt=h({Object:Ks}),pt=M([gt,Bt]);function Gs(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:Ut(t)?t.toBytes():C.ser(e,t,{maxSize:1/0}).toBytes())}}const N={Pure:Gs,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:A(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:A(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:A(t)}}}}};function br(t){return typeof t=="string"?A(t):"ImmOrOwned"in t.Object?A(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?A(t.Object.Receiving.objectId):A(t.Object.Shared.objectId)}function Hs(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function Zs(t){var e;return((e=Hs(t))==null?void 0:e.mutable)??!1}function Js(t){function e(r,n){return t(r,n)}return e.u8=r=>t(C.U8.serialize(r)),e.u16=r=>t(C.U16.serialize(r)),e.u32=r=>t(C.U32.serialize(r)),e.u64=r=>t(C.U64.serialize(r)),e.u128=r=>t(C.U128.serialize(r)),e.u256=r=>t(C.U256.serialize(r)),e.bool=r=>t(C.Bool.serialize(r)),e.string=r=>t(C.String.serialize(r)),e.address=r=>t(C.Address.serialize(r)),e.id=e.address,e}const Xs="object",Ys="ID",Qs="ascii",ei="String",ti="string",ri="String",ni="option",si="Option",ii={address:Vr,module:Xs,name:Ys},ai={address:Dt,module:Qs,name:ei},oi={address:Dt,module:ti,name:ri},ci={address:Dt,module:ni,name:si},rt=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function ui(t){var r;const e=(r=cr(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 Et(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const li=["Address","Bool","U8","U16","U32","U64","U128","U256"];function jt(t,e){if(typeof t=="string"&&li.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])Et("number",e);else if(t==="Bool")Et("boolean",e);else if(t==="Address"&&(Et("string",e),e&&!ce(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=jt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(rt(t.Struct,ai))return"string";if(rt(t.Struct,oi))return"utf8string";if(rt(t.Struct,ii))return"address";if(rt(t.Struct,ci)){const r={Vector:t.Struct.typeArguments[0]};return jt(r,e)}}}function di(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),m.blake2b(n,{dkLen:32})}function U(t,e){return $r(t,e)}const hi=t=>M([h({None:M([S(!0),S(null)])}),h({Some:t})]),Fe=M([h({kind:S("Input"),index:ne(),value:b(It()),type:b(S("object"))}),h({kind:S("Input"),index:ne(),value:b(It()),type:S("pure")})]),fi=[Fe,h({kind:S("GasCoin")}),h({kind:S("Result"),index:ne()}),h({kind:S("NestedResult"),index:ne(),resultIndex:ne()})],he=M([...fi]),nn=h({kind:S("MoveCall"),target:V("target",d().validator),typeArguments:E(d()),arguments:E(he)}),sn=h({kind:S("TransferObjects"),objects:E(he),address:he}),an=h({kind:S("SplitCoins"),coin:he,amounts:E(he)}),on=h({kind:S("MergeCoins"),destination:he,sources:E(he)}),cn=h({kind:S("MakeMoveVec"),type:b(hi(Q(d(),zr()))),objects:E(he)}),un=h({kind:S("Publish"),modules:E(E(ne())),dependencies:E(d())}),ln=h({kind:S("Upgrade"),modules:E(E(ne())),dependencies:E(d()),packageId:d(),ticket:he}),gi=[nn,sn,an,on,un,ln,cn],pi=M([...gi]),be={MoveCall(t){return U({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},nn)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=N.Pure(C.Address.serialize(e.value))),U({kind:"TransferObjects",objects:t,address:e},sn)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=N.Pure(C.U64.serialize(r.value)))}),U({kind:"SplitCoins",coin:t,amounts:e},an)},MergeCoins(t,e){return U({kind:"MergeCoins",destination:t,sources:e},on)},Publish({modules:t,dependencies:e}){return U({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(Y(r)):r),dependencies:e.map(r=>re(r))},un)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return U({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(Y(s)):s),dependencies:e.map(s=>re(s)),packageId:r,ticket:n},ln)},MakeMoveVec({type:t,objects:e}){return U({kind:"MakeMoveVec",type:t?{Some:le.parseFromStr(t)}:{None:null},objects:e},cn)}},yi=b(B(M([h({Epoch:ne()}),h({None:M([S(!0),S(null)])})]))),Sr=V("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),mi=h({budget:b(Sr),price:b(Sr),payment:b(E(me)),owner:b(d())}),nt=h({version:S(1),sender:b(d()),expiration:yi,gasConfig:mi,inputs:E(Fe),transactions:E(pi)});function Tr(t){return A(t).replace("0x","")}class de{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=C.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=U({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>U({kind:"Input",value:i,index:a,type:z(i,gt)?"pure":"object"},Fe)),transactions:n.transactions},nt);return de.restore(s)}static fromBytes(e){var a;const r=C.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=U({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((c,u)=>U({kind:"Input",value:c,index:u,type:z(c,gt)?"pure":"object"},Fe)),transactions:s.transactions},nt);return de.restore(i)}static restore(e){xt(e,nt);const r=new de;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=di("TransactionData",e);return He(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(f=>(xt(f.value,pt),f.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return C.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,c=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!c)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:Tr(c),expiration:a||{None:!0},gasData:{payment:u.payment,owner:Tr(this.gasConfig.owner??c),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return C.TransactionData.serialize({V1:l},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return de.getDigestFromBytes(e)}snapshot(){return U(this,nt)}}var ur=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},x=(t,e,r)=>(ur(t,e,"read from private field"),r?r.call(t):e.get(t)),ae=(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)},st=(t,e,r,n)=>(ur(t,e,"write to private field"),e.set(t,r),r),R=(t,e,r)=>(ur(t,e,"access private method"),r),v,Ue,at,Ne,ot,we,ke,lr,dn,dr,hn,hr,fn,fr,gn,ct,Mt;const wi={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function bi(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 c=0;for(;;)yield n(c),c++};if(typeof i=="symbol")return;const a=parseInt(i,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function Si(t){const e=cr(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function We(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 pn=Symbol.for("@mysten/transaction"),kt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},Ti=1000n,vi=50,Ei=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function ki(t){return!!t&&typeof t=="object"&&t[pn]===!0}const Pt=class{constructor(t){ae(this,Ue),ae(this,Ne),ae(this,we),ae(this,lr),ae(this,dr),ae(this,hr),ae(this,fr),ae(this,ct),ae(this,v,void 0),st(this,v,new de(t?t.blockData:void 0))}static fromKind(t){const e=new Pt;return st(e,v,de.fromKindBytes(typeof t=="string"?Y(t):t)),e}static from(t){const e=new Pt;return typeof t!="string"||!t.startsWith("{")?st(e,v,de.fromBytes(typeof t=="string"?Y(t):t)):st(e,v,de.restore(JSON.parse(t))),e}setSender(t){x(this,v).sender=t}setSenderIfNotSet(t){x(this,v).sender||(x(this,v).sender=t)}setExpiration(t){x(this,v).expiration=t}setGasPrice(t){x(this,v).gasConfig.price=String(t)}setGasBudget(t){x(this,v).gasConfig.budget=String(t)}setGasOwner(t){x(this,v).gasConfig.owner=t}setGasPayment(t){x(this,v).gasConfig.payment=t.map(e=>Ur(e,me))}get blockData(){return x(this,v).snapshot()}get[pn](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:Js((t,e)=>Ut(t)?R(this,Ue,at).call(this,"pure",{Pure:Array.from(t.toBytes())}):R(this,Ue,at).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=br(t),r=x(this,v).inputs.find(n=>n.type==="object"&&e===br(n.value));return r&&z(r.value,Bt)&&"Shared"in r.value.Object&&z(t,Bt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??R(this,Ue,at).call(this,"object",typeof t=="string"?A(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=x(this,v).transactions.push(t);return bi(e-1)}splitCoins(t,e){return this.add(be.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):R(this,Ne,ot).call(this,r))))}mergeCoins(t,e){return this.add(be.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(be.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(be.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(be.MoveCall({arguments:t==null?void 0:t.map(n=>R(this,Ne,ot).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(be.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):R(this,Ne,ot).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(be.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(x(this,v).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await R(this,ct,Mt).call(this,t),x(this,v).build({maxSizeBytes:R(this,we,ke).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await R(this,ct,Mt).call(this,t),x(this,v).getDigest()}};let xi=Pt;v=new WeakMap;Ue=new WeakSet;at=function(t,e){const r=x(this,v).inputs.length,n=U({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Fe);return x(this,v).inputs.push(n),n};Ne=new WeakSet;ot=function(t){return Ut(t)?this.pure(t):t};we=new WeakSet;ke=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return wi[t];const n=e==null?void 0:e.attributes[kt[t]];if(!n)throw new Error(`Missing expected protocol config: "${kt[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: "${kt[t]}"`);return Number(s)};lr=new WeakSet;dn=function(t){const e=R(this,we,ke).call(this,"maxPureArgumentSize",t);x(this,v).inputs.forEach((r,n)=>{if(z(r.value,gt)&&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`)})};dr=new WeakSet;hn=async function(t){if(x(this,v).gasConfig.payment){const s=R(this,we,ke).call(this,"maxGasObjects",t);if(x(this,v).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||x(this,v).gasConfig.payment)return;const e=x(this,v).gasConfig.owner??x(this,v).sender,n=(await We(t).getCoins({owner:e,coinType:es})).data.filter(s=>!x(this,v).inputs.find(a=>z(a.value,pt)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,R(this,we,ke).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)};hr=new WeakSet;fn=async function(t){t.onlyTransactionKind||x(this,v).gasConfig.price||this.setGasPrice(await We(t).getReferenceGasPrice())};fr=new WeakSet;gn=async function(t){const{inputs:e,transactions:r}=x(this,v),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:A(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(c=>c.kind==="Input"&&!z(e[c.index].value,pt))&&n.push(i),i.kind==="SplitCoins"&&i.amounts.forEach(a=>{if(a.kind==="Input"){const c=e[a.index];typeof c.value!="object"&&(c.value=N.Pure(C.U64.serialize(c.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=N.Pure(C.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,c,u]=i.target.split("::"),l=await We(t).getNormalizedMoveFunction({package:re(a),module:c,function:u}),g=l.parameters.length>0&&ui(l.parameters.at(-1))?l.parameters.slice(0,l.parameters.length-1):l.parameters;if(g.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");g.forEach((y,p)=>{const w=i.arguments[p];if(w.kind!=="Input")return;const T=e[w.index];if(z(T.value,pt))return;const k=T.value,j=jt(y,k);if(j){T.value=N.Pure(k,j);return}if(cr(y)!=null||typeof y=="object"&&"TypeParameter"in y){if(typeof k!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(k,null,2)}`);s.push({id:k,input:T,normalizedType:y});return}throw new Error(`Unknown call arg type ${JSON.stringify(y,null,2)} for value ${JSON.stringify(k,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:f})=>f))],a=Ei(i,vi),c=(await Promise.all(a.map(f=>We(t).multiGetObjects({ids:f,options:{showOwner:!0}})))).flat();let u=new Map(i.map((f,g)=>[f,c[g]]));const l=Array.from(u).filter(([f,g])=>g.error).map(([f,g])=>f);if(l.length)throw new Error(`The following input objects are invalid: ${l.join(", ")}`);s.forEach(({id:f,input:g,normalizedType:y})=>{var k;const p=u.get(f),w=(k=p.data)==null?void 0:k.owner,T=w&&typeof w=="object"&&"Shared"in w?w.Shared.initial_shared_version:void 0;if(T){const j=y!=null&&Ct(y)==null&&rn(y)==null,P=Zs(g.value)||j||y!=null&&Ct(y)!=null;g.value=N.SharedObjectRef({objectId:f,initialSharedVersion:T,mutable:P})}else y&&Si(y)?g.value=N.ReceivingRef(wr(p)):g.value=N.ObjectRef(wr(p))})}};ct=new WeakSet;Mt=async function(t){if(!t.onlyTransactionKind&&!x(this,v).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([R(this,hr,fn).call(this,t),R(this,fr,gn).call(this,t)]),!t.onlyTransactionKind&&(await R(this,dr,hn).call(this,t),!x(this,v).gasConfig.budget)){const e=await We(t).dryRunTransactionBlock({transactionBlock:x(this,v).build({maxSizeBytes:R(this,we,ke).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(R(this,we,ke).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=Ti*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)}R(this,lr,dn).call(this,t)};const Ii=Symbol.for("@mysten/SuiClient");class _i{get[Ii](){return!0}constructor(e){this.transport=e.transport??new hs({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!ce(A(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||!ce(A(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||!ce(A(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||!ce(A(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||!ce(A(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||!et(re(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||!et(re(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(!yr(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(!yr(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:D(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||!ce(A(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||!et(re(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(ki(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=D(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=D(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:D(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!et(re(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=Ze(e.digest);return Ie(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((c,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 yn extends _r.ChainContext{}const Ke="Sui",gr=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},Ai=(t,e)=>{try{return Er(t)===Er(e)}catch{return!1}},Oi=t=>(t==null?void 0:t.type)==="created",Ci=t=>(t==null?void 0:t.type)==="published";function Bi(t){return Array.isArray(t)}function yt(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function mn(t){return typeof t=="object"&&!Bi(t)&&!yt(t)}const ji=16*1024,Mi=t=>C.ser("vector<u8>",t,{maxSize:ji}).toBytes(),Pi=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||!yt(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return Sn(r.content.type)},wn=async(t,e)=>{if(!ce(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return gr(r)};async function Ri(t,e){let r,n;do{const a=await t.getDynamicFields({parentId:e,cursor:n});r=a.data.find(c=>c.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=gr(s);if(!i||!mn(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!yt(i.value))throw new Error("Unable to get package id");return i.value.fields.package}const $i=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 c of i.data){if(!c.data)continue;const{version:u,objectId:l}=c.data;(n===null||u<n)&&(n=u,s=l)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},Ui=async(t,e)=>{const r=new xi,[n]=r.publish({modules:t.modules.map(s=>Array.from(m.b64.decode(s))),dependencies:t.dependencies.map(s=>re(s))});return r.transferObjects([n],r.pure(e)),r},oe=class oe extends _r.PlatformContext{constructor(e,r){super(e,r??m.networkPlatformConfigs(e,oe._platform))}getRpc(e){if(e in this.config)return new _i({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new yn(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!oe.isSupportedChain(r))throw new Error(`invalid chain for ${Ke}: ${r}`);return m.Wormhole.tokenId(r,ts)}static isNativeTokenId(e,r,n){return!oe.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return m.chainToPlatform(e)===oe._platform}static async getDecimals(e,r,n){if(m.isNative(n))return m.nativeDecimals(oe._platform);const s=new fe(n);try{const a=await wn(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.getCoinType()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getBalance(e,r,n,s){if(m.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 c=await this.getBalance(e,r,n,a);return{[m.isNative(a)?"native":new fe(a).toString()]:c}}))).reduce((a,c)=>Object.assign(a,c),{})}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=m.platformNativeChainIdToNetworkChain(oe._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)}};te(oe,"_platform",Ke);let xe=oe;const pr=t=>/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(t),bn=t=>t.replace(/(0x)(0*)/g,"0x");function vr(t){return t=t.startsWith("0x")?t.slice(2):t,t=t.length%2===0?t:"0"+t,`0x${t.length===64?t:m.hex.encode(m.bytes.zpad(m.hex.decode(t),32))}`}const Er=t=>{const e=t.split(Ae);if(e.length!==3)throw new Error(`Invalid Sui type: ${t}`);return[A(e[0]),e[1],e[2]].join(Ae)},Ni=t=>new fe(t).getCoinType(),Sn=t=>new fe(t).getPackageId(),Di=t=>{const e=bn(t).match(/0x2::table::Table<(.*)>/);if(!e)throw new Error(`Invalid table type: ${t}`);if(e.length<2)throw new Error(`Invalid table type: ${t}`);const[r]=e[1].split(",");if(!r||!pr(r))throw new Error(`Invalid key type: ${r}`);return r},Te=class Te{constructor(e){te(this,"address");te(this,"module");if(Te.instanceof(e))this.address=e.address,this.module=e.module;else if(m.UniversalAddress.instanceof(e))this.address=e.toUint8Array();else if(typeof e=="string"){if(pr(e)){const r=e.split(Ae);this.module=r.slice(1).join(Ae),e=r[0]}if(e=vr(e),!m.hex.valid(e))throw new Error("Invalid Sui address: "+e);this.address=m.hex.decode(e)}else this.address=e}unwrap(){const e=this.getPackageId(),r=this.module?Ae+this.module:"";return`${e}${r}`}toString(){return this.unwrap()}toNative(){return this}toUint8Array(){return this.address}toUniversalAddress(){return new m.UniversalAddress(this.toUint8Array())}getPackageId(){return vr(m.hex.encode(this.address))}getCoinType(){return[this.getPackageId(),"coin","COIN"].join(Ae)}static instanceof(e){return e.constructor.platform===Te.platform}equals(e){return Te.instanceof(e)?e.unwrap()===this.unwrap():this.toUniversalAddress().equals(e)}};te(Te,"byteSize",32),te(Te,"platform",xe._platform);let fe=Te;m.registerNative(Ke,fe);var Ge=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))(Ge||{});function zi(t){return[t,0,0]}function Tn(t,e){const r=zi(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const mt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},Vi={ED25519:32,Secp256k1:33,Secp256r1:33},Li={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function qi(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function Fi(t,e){const r=t.toString(16);return m.hexToBytes(r.padStart(e*2,"0").slice(-e*2))}function Wi(t,e){const r=Fi(t,e),n=qi(r);return n===-1?new Uint8Array([0]):r.slice(n)}function Ki(t,e){const r=Wi(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([mt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),A(m.bytesToHex(m.blake2b(s,{dkLen:32})).slice(0,Xe*2))}function Gi(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 Hi(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=Gi(n);e=e.concat(s)}return e}function Zi(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=Hi(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 c=0;c<r.length;c+=8){const u=r.slice(c,c+8),l=parseInt(u.join(""),2);i[a++]=l}return new TextDecoder().decode(i)}function Ji(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 Xi(t,e){const r=Zi(t.value,t.indexMod4),[n,s]=Ji(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const Yi=o.struct("ZkLoginSignature",{inputs:o.struct("ZkLoginSignatureInputs",{proofPoints:o.struct("ZkLoginSignatureInputsProofPoints",{a:o.vector(o.string()),b:o.vector(o.vector(o.string())),c:o.vector(o.string())}),issBase64Details:o.struct("ZkLoginSignatureInputsClaim",{value:o.string(),indexMod4:o.u8()}),headerBase64:o.string(),addressSeed:o.string()}),maxEpoch:o.u64(),userSignature:o.vector(o.u8())});function Qi(t){return Yi.parse(typeof t=="string"?Y(t):t)}function ea({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([mt[e]]),s.set(t,1),s.set(n,1+t.length),D(s)}function ta(t){const e=Y(t),r=Li[e[0]];switch(r){case"MultiSig":const n=C.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:c}=Qi(s),{issBase64Details:u,addressSeed:l}=i,f=Xi(u,"iss"),g=Ki(BigInt(l),f);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:c,iss:f,address:g,addressSeed:BigInt(l)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const y=Vi[r],p=e.slice(1,e.length-y),w=e.slice(1+p.length);return{serializedSignature:t,signatureScheme:r,signature:p,publicKey:w,bytes:e};default:throw new Error("Unsupported signature scheme")}}const ut=32,ra="suiprivkey";class na{async signWithIntent(e,r){const n=Tn(r,e),s=m.blake2b(n,{dkLen:32});return{signature:ea({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:D(e)}}async signTransactionBlock(e){return this.signWithIntent(e,Ge.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(o.vector(o.u8()).serialize(e).toBytes(),Ge.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class sa extends na{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function ia(t,e){if(t.length!==ut)throw new Error("Invalid bytes length");const r=mt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),m.bech32.encode(ra,m.bech32.toWords(n))}function kr(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function aa(t){return On(t,"")}function oa(t){return Ie(aa(t))}const ca="ed25519 seed",ua=2147483648,la=new RegExp("^m(\\/[0-9]+')+$"),vn=t=>t.replace("'",""),da=t=>{const r=m.hmac.create(m.sha512,ca).update(Je(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},ha=({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=m.hmac.create(m.sha512,e).update(i).digest(),c=a.slice(0,32),u=a.slice(32);return{key:c,chainCode:u}},fa=t=>la.test(t)?!t.split("/").slice(1).map(vn).some(isNaN):!1,xr=(t,e,r=ua)=>{if(!fa(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=da(e);return t.split("/").slice(1).map(vn).map(a=>parseInt(a,10)).reduce((a,c)=>ha(a,c+r),{key:n,chainCode:s})};function En(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 ga{equals(e){return En(this.toRawBytes(),e.toRawBytes())}toBase64(){return D(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return D(e)}verifyWithIntent(e,r,n){const s=Tn(n,e),i=m.blake2b(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(C.vector(C.u8()).serialize(e).toBytes(),r,Ge.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,Ge.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return A(m.bytesToHex(m.blake2b(this.toSuiBytes(),{dkLen:32})).slice(0,Xe*2))}}const Rt=32;class kn extends ga{constructor(e){if(super(),typeof e=="string"?this.data=Y(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==Rt)throw new Error(`Invalid public key input. Expected ${Rt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return mt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=ta(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!En(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return m.nacl.sign.detached.verify(e,n,this.toRawBytes())}}kn.SIZE=Rt;const Ir="m/44'/784'/0'/0'/0'";class Oe extends sa{constructor(e){super(),e?this.keypair=e:this.keypair=m.nacl.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Oe(m.nacl.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==ut)throw new Error(`Wrong secretKey size. Expected ${ut} bytes, got ${n}.`);const s=m.nacl.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),c=m.nacl.sign.detached(a,s.secretKey);if(!m.nacl.sign.detached.verify(a,c,s.publicKey))throw new Error("provided secretKey is invalid")}return new Oe(s)}getPublicKey(){return new kn(this.keypair.publicKey)}getSecretKey(){return ia(this.keypair.secretKey.slice(0,ut),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return m.nacl.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=Ir),!kr(r))throw new Error("Invalid derivation path");const{key:n}=xr(r,oa(e));return Oe.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=Ir),!kr(r))throw new Error("Invalid derivation path");const{key:n}=xr(r,e);return Oe.fromSecretKey(n)}}async function pa(t,e){const[,r]=await xe.chainFromRpc(t);return new ya(r,t,Oe.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class ya{constructor(e,r,n,s){te(this,"_chain");te(this,"_client");te(this,"_signer");te(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()}`);const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}return r}}const ma={Address:fe,Platform:xe,getSigner:pa,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-CefRPGIJ.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-Na_--gcE.js"))},getChain:(t,e,r)=>new yn(e,new xe(t,m.applyChainsConfigConfigOverrides(t,Ke,{[e]:r})))},wa=Object.freeze(Object.defineProperty({__proto__:null,default:ma},Symbol.toStringTag,{value:"Module"}));exports.SuiAddress=fe;exports.SuiPlatform=xe;exports._platform=Ke;exports.getCoinTypeFromPackageId=Ni;exports.getFieldsFromObjectResponse=gr;exports.getObjectFields=wn;exports.getOldestEmitterCapObjectId=$i;exports.getOriginalPackageId=Pi;exports.getPackageId=Ri;exports.getPackageIdFromType=Sn;exports.getTableKeyType=Di;exports.isMoveStructObject=mn;exports.isMoveStructStruct=yt;exports.isSameType=Ai;exports.isSuiCreateEvent=Oi;exports.isSuiPublishEvent=Ci;exports.isValidSuiType=pr;exports.publishPackage=Ui;exports.sui=wa;exports.trimSuiType=bn;exports.uint8ArrayToBCS=Mi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var u=(s,e,t)=>e in s?l(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var a=(s,e,t)=>(u(s,typeof e!="symbol"?e+"":e,t),t);const i=require("./cosmwasm-
|
|
1
|
+
"use strict";var l=Object.defineProperty;var u=(s,e,t)=>e in s?l(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var a=(s,e,t)=>(u(s,typeof e!="symbol"?e+"":e,t),t);const i=require("./cosmwasm-BFtZD1Ru.js"),r=require("./index-DfYc88fY.js");function m(s,e){let t=i.averageGasPrices.get(s,e);return t||(t="0.1"),i.build.calculateFee(i.DEFAULT_FEE*1.5,`${t}${i.CosmwasmPlatform.getNativeDenom(s,e)}`)}function g(s,e,t,n){return{typeUrl:i.MSG_EXECUTE_CONTRACT_TYPE_URL,value:r.tx$1.MsgExecuteContract.fromPartial({sender:s,contract:e,msg:r.bytes.encode(JSON.stringify(t)),funds:n})}}class d{constructor(e,t,n,c,o=!1){a(this,"transaction");a(this,"network");a(this,"chain");a(this,"description");a(this,"parallelizable");this.transaction=e,this.network=t,this.chain=n,this.description=c,this.parallelizable=o}}exports.CosmwasmUnsignedTransaction=d;exports.buildExecuteMsg=g;exports.computeFee=m;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var o = Object.defineProperty;
|
|
2
2
|
var c = (e, a, t) => a in e ? o(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
|
|
3
3
|
var s = (e, a, t) => (c(e, typeof a != "symbol" ? a + "" : a, t), t);
|
|
4
|
-
import { $ as l, a0 as m, a1 as u, C as f, a2 as g } from "./cosmwasm-
|
|
5
|
-
import { bn as p, b5 as E } from "./index-
|
|
4
|
+
import { $ as l, a0 as m, a1 as u, C as f, a2 as g } from "./cosmwasm-CGR89px_.mjs";
|
|
5
|
+
import { bn as p, b5 as E } from "./index-C1JlVOwd.mjs";
|
|
6
6
|
function h(e, a) {
|
|
7
7
|
let t = l.get(e, a);
|
|
8
8
|
return t || (t = "0.1"), m.calculateFee(u * 1.5, `${t}${f.getNativeDenom(e, a)}`);
|
package/package.json
CHANGED