@wormhole-foundation/wormhole-connect 2.0.0-beta.0-development → 2.0.0-beta.2-development
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{aptos-gRn0txr9.js → aptos-CvRULtpx.js} +61 -61
- package/dist/assets/aptos-D4y7Fo3S.js +3 -0
- package/dist/assets/{chunk-OR6GFWLG-Ci0TYwIQ.js → chunk-OR6GFWLG-BZrmB1_W.js} +1 -1
- package/dist/assets/evm-K2ASlzX-.js +2 -0
- package/dist/assets/{index-CTtLxavV.js → index-AaqmNOLf.js} +1 -1
- package/dist/assets/index-BLpnEfNA.js +1 -0
- package/dist/assets/{index-DtASoatx.js → index-BTnVHgr_.js} +1 -1
- package/dist/assets/{index-Cf10mHc-.js → index-BpWlJX3r.js} +1 -1
- package/dist/assets/{index-DTCth0iO.js → index-C1mpuWJz.js} +1 -1
- package/dist/assets/{index-cfzEp_CP.js → index-C1yBHw3e.js} +1 -1
- package/dist/assets/{index-Dwk61kXP.js → index-CEjbqPmT.js} +1 -1
- package/dist/assets/{index-BZKNZDak.js → index-CZHHMApS.js} +1 -1
- package/dist/assets/{index-Cm_KjDDY.js → index-QLnl5sO1.js} +1 -1
- package/dist/assets/{index-D7CrUmY0.js → index-_NuAK6zi.js} +1 -1
- package/dist/assets/index-rryJGGTI.js +1 -0
- package/dist/assets/{signer-BaParnK7.js → signer-dWGaM-mu.js} +1 -1
- package/dist/assets/{solana-5w7FFw9J.js → solana-D2tTKYdq.js} +1 -1
- package/dist/assets/solana-UIzLk1Ne.js +2 -0
- package/dist/assets/{sui-DaosOePU.js → sui-DVNvuW-l.js} +4 -4
- package/dist/assets/unsignedTransaction-DsxtoHjl.js +1 -0
- package/dist/main.js +100 -100
- package/dist/src/config/mainnet/tokens.d.ts.map +1 -1
- package/dist/src/config/testnet/tokens.d.ts.map +1 -1
- package/dist/src/config/utils.d.ts.map +1 -1
- package/dist/src/hooks/useWalletCompatibility.d.ts +14 -0
- package/dist/src/hooks/useWalletCompatibility.d.ts.map +1 -0
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/wallet/aptos.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/AssetPicker/ChainList.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/index.d.ts.map +1 -1
- package/lib/{aptos-G95l4D5Y.mjs → aptos-B3TWiavl.mjs} +59 -57
- package/lib/aptos-DTHJQbIb.js +2 -0
- package/lib/{aptos-CAZnfR2B.js → aptos-Dbfuz96f.js} +9 -9
- package/lib/{aptos-VlcdOXIs.mjs → aptos-KMTKpvnn.mjs} +1229 -1228
- package/lib/{base64-DScLQWIJ.js → base64-Ci4lr2or.js} +1 -1
- package/lib/{base64-SRM73VOK.mjs → base64-D-sBGnCV.mjs} +1 -1
- package/lib/{ccip-CwCUSl64.js → ccip-CBfsTddJ.js} +1 -1
- package/lib/{ccip-ZQo50dYX.mjs → ccip-IV8wn7mX.mjs} +1 -1
- package/lib/{chunk-OR6GFWLG-oZZxBIBy.js → chunk-OR6GFWLG-CFPMvzOj.js} +5 -5
- package/lib/{chunk-OR6GFWLG-qW5dukvV.mjs → chunk-OR6GFWLG-m97dlZZV.mjs} +6 -3
- package/lib/{events-uBYsqfrl.js → events-CjPLRE-d.js} +1 -1
- package/lib/{events-Dgn4K9rN.mjs → events-Dtbo0st9.mjs} +1 -1
- package/lib/{evm-CgSzbeCb.js → evm-BFBdsLYZ.js} +3 -3
- package/lib/{evm-Cocl1Qx2.js → evm-DuCtpTHQ.js} +1 -1
- package/lib/{evm-D5LTDUcP.mjs → evm-JbOZ35C0.mjs} +5 -5
- package/lib/{evm-BM1jPLwl.mjs → evm-kkjU8AsQ.mjs} +6 -6
- package/lib/{index-DU3Jxks1.js → index-B0lJ-tdN.js} +1 -1
- package/lib/{index-CjYsC-nW.js → index-B1ELgSA6.js} +1 -1
- package/lib/{index-C9mu4l7o.mjs → index-B2h28IP4.mjs} +2 -2
- package/lib/{index-DXcVEr2U.mjs → index-B3CeIlMx.mjs} +25135 -25063
- package/lib/{index-xZ5vsuO7.js → index-B4_J2HAU.js} +1 -1
- package/lib/{index-i8-I-Kx6.mjs → index-BE5ihayy.mjs} +2 -2
- package/lib/{index-CXFBf2VR.mjs → index-BL5dRh07.mjs} +2 -2
- package/lib/{index-TdVwI_k_.js → index-BasVT8K7.js} +1 -1
- package/lib/{index-a-G25ciF.js → index-BdUX86K5.js} +1 -1
- package/lib/{index-BWgeRtvV.mjs → index-Bo9bOQTx.mjs} +1 -1
- package/lib/{index-C9_Xqcp_.mjs → index-BoYglZwX.mjs} +38 -38
- package/lib/{index-DgaACuCq.js → index-Br4OTc1S.js} +154 -154
- package/lib/{index-D8yrwfK5.mjs → index-CM5aJCsU.mjs} +3 -3
- package/lib/{index-BLwbqj4f.js → index-CS3m8qJT.js} +1 -1
- package/lib/{index-DZz_hUYe.mjs → index-CWSjFjhh.mjs} +48 -57
- package/lib/{index-tT8fg8Q5.mjs → index-CfVm24rf.mjs} +22 -22
- package/lib/{index-DaLPPso5.mjs → index-D2v_ZH9c.mjs} +2 -2
- package/lib/{index-BCi7GitD.mjs → index-D9NMKVsX.mjs} +2 -2
- package/lib/{index-DRZXoRVn.mjs → index-DCfPCVGM.mjs} +7 -7
- package/lib/{index-DuM5_evN.mjs → index-DFDFr1Hv.mjs} +8 -8
- package/lib/{index-B6JrPvDW.mjs → index-DL2KYGb2.mjs} +1 -1
- package/lib/{index-CZ8GDYHq.js → index-DLegUdzU.js} +1 -1
- package/lib/{index-Cu6RQt8e.js → index-DNNfs5Ot.js} +1 -1
- package/lib/{index-CCDkkZN6.js → index-DPlTznQs.js} +1 -1
- package/lib/index-DUrL3GHD.mjs +102 -0
- package/lib/{index-CoDv0EFX.mjs → index-DWTXe9yU.mjs} +4 -4
- package/lib/{index-CffsvCdp.js → index-DcKePNaA.js} +1 -1
- package/lib/{index-3VUjPBnj.js → index-DlMM2TKj.js} +1 -1
- package/lib/index-DmkA2z4q.js +1 -0
- package/lib/{index-JaS46BVB.js → index-DtJ3gwwu.js} +1 -1
- package/lib/{index-C_045fAm.js → index-Dy3WJQ-h.js} +1 -1
- package/lib/{index-DBJPUF0X.js → index-DzgnqJ7-.js} +1 -1
- package/lib/{index-aw5kQCwX.mjs → index-HF2DcpAR.mjs} +2 -2
- package/lib/{index-DPacNsBv.mjs → index-IbmfT3Tg.mjs} +5 -5
- package/lib/{index-DY59SYJT.mjs → index-MdL7XQBR.mjs} +1 -1
- package/lib/index-QzouONBY.js +1 -0
- package/lib/{index-BpHM17iv.js → index-SrHywpn-.js} +1 -1
- package/lib/{index-SzAoRhpC.js → index-gUz3Q8gE.js} +1 -1
- package/lib/{index-BERVkvac.js → index-pi5LLTZ3.js} +1 -1
- package/lib/{index-CusHYtsc.mjs → index-vlui53ey.mjs} +2 -2
- package/lib/{index.es-c-VQ7iU7.js → index.es-DFpbuPuY.js} +2 -2
- package/lib/{index.es-CfDkO3SA.mjs → index.es-SaEPft-i.mjs} +6 -6
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{signer-Uy7DwUiY.js → signer-CeSFiipD.js} +1 -1
- package/lib/{signer-CsSNNgXY.mjs → signer-RSvbDa7c.mjs} +19 -19
- package/lib/solana-Bwjjv4LB.js +1 -0
- package/lib/{solana-D8Z8oyUb.mjs → solana-ClVJj67l.mjs} +4 -4
- package/lib/solana-DmG1qAvz.mjs +16 -0
- package/lib/{solana-CnbQnU0Q.js → solana-DwgjV-W7.js} +1 -1
- package/lib/{solanaEmbed.esm-CnTsBpfN.mjs → solanaEmbed.esm-Cu2iyuQy.mjs} +959 -959
- package/lib/{solanaEmbed.esm-BMN20IzZ.js → solanaEmbed.esm-DY919Dj0.js} +1 -1
- package/lib/src/config/mainnet/tokens.d.ts.map +1 -1
- package/lib/src/config/testnet/tokens.d.ts.map +1 -1
- package/lib/src/config/utils.d.ts.map +1 -1
- package/lib/src/hooks/useWalletCompatibility.d.ts +14 -0
- package/lib/src/hooks/useWalletCompatibility.d.ts.map +1 -0
- package/lib/src/utils/index.d.ts +1 -1
- package/lib/src/utils/index.d.ts.map +1 -1
- package/lib/src/utils/wallet/aptos.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/AssetPicker/ChainList.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/index.d.ts.map +1 -1
- package/lib/{sui-CkzAXofi.js → sui-BzgBbOVR.js} +2 -2
- package/lib/{sui-a-MPtxai.js → sui-C0CqiXaB.js} +1 -1
- package/lib/{sui-0upbYB1a.mjs → sui-CIBoUTGj.mjs} +1 -1
- package/lib/{sui-Dl3Uvu88.mjs → sui-D1lxvss1.mjs} +5 -5
- package/lib/unsignedTransaction-BDOQhqcZ.mjs +16 -0
- package/lib/unsignedTransaction-C1YeEl4G.js +1 -0
- package/lib/{utf8-YN1IXfNg.mjs → utf8-BZ7GX1-B.mjs} +1 -1
- package/lib/{utf8-PS_55WKJ.js → utf8-CQNNfvVV.js} +1 -1
- package/package.json +18 -18
- package/dist/assets/aptos-Ycl2eNjD.js +0 -3
- package/dist/assets/evm-ETvgEF-D.js +0 -2
- package/dist/assets/index-_2IpGxfE.js +0 -1
- package/dist/assets/solana-u2eYUt3V.js +0 -2
- package/lib/aptos-Ck1Sf3c1.js +0 -2
- package/lib/index-BgSe6vZM.js +0 -1
- package/lib/solana-Doh_jgqw.mjs +0 -16
- package/lib/solana-M-G4laS9.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
var Tn=Object.defineProperty;var En=(t,e,r)=>e in t?Tn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var we=(t,e,r)=>En(t,typeof e!="symbol"?e+"":e,r);import{aI as ut,aJ as Le,aK as O,aL as Mt,aM as oe,aN as vn,aO as Pt,aP as Me,aQ as ce,aR as kn,aS as Ke,aT as gr,ad as _n,aU as pr,aV as xn,aW as In,ae as An,ag as On,ah as Cn,aX as jn,aj as Bn,ak as lt,al as Mn,aY as Je,ao as Pn,aC as Rn,aB as _r,ax as xr,ay as Ir,I as fe,_ as ft,a0 as $n}from"../main.js";import{m as Nn}from"./index-BFMIYSUy.js";function H(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const ht=8192;function N(t){if(t.length<ht)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=ht){const n=t.slice(r,r+ht);e+=String.fromCharCode(...n)}return btoa(e)}function qe(t){var s;const e=t.startsWith("0x")?t.slice(2):t,n=((s=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];return Uint8Array.from(n)}function me(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function Rt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function Un(t){let e=0,r=0,n=0;for(;;){let s=t[n];if(n+=1,e|=(s&127)<<r,!(s&128))break;r+=7}return{value:e,length:n}}class Ar{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:s}=Un(r);return this.shift(s),n}readVec(e){let r=this.readULEB(),n=[];for(let s=0;s<r;s++)n.push(e(this,s,r));return n}}function Dn(t,e){switch(e){case"base58":return Le(t);case"base64":return N(t);case"hex":return me(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Vn(t,e){switch(e){case"base58":return ut(t);case"base64":return H(t);case"hex":return qe(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Or(t,e=["<",">"]){const[r,n]=e,s=[];let i="",a=0;for(let o=0;o<t.length;o++){const u=t[o];if(u===r&&a++,u===n&&a--,a===0&&u===","){s.push(i.trim()),i="";continue}i+=u}return s.push(i.trim()),s}class Cr{constructor({size:e=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=r||e,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const r=this.bytePosition+e;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const s=new ArrayBuffer(this.size);new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(s)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return gt(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return gt(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return gt(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return Rt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,s)=>r(this,n,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return Dn(this.toBytes(),e)}}function gt(t,e){let r=new Uint8Array(e),n=0;for(;t>0;)r[n]=Number(t%BigInt(256)),t=t/BigInt(256),n+=1;return r}var jr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},W=(t,e,r)=>(jr(t,e,"read from private field"),r?r.call(t):e.get(t)),rt=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},nt=(t,e,r,n)=>(jr(t,e,"write to private field"),e.set(t,r),r),be,xe,Xe,ae;const Br=class{constructor(t){rt(this,be,void 0),rt(this,xe,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),nt(this,be,t.write),nt(this,xe,t.serialize??((e,r)=>{const n=new Cr({size:this.serializedSize(e)??void 0,...r});return W(this,be).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),W(this,be).call(this,t,e)}serialize(t,e){return this.validate(t),new zn(this,W(this,xe).call(this,t,e))}parse(t){const e=new Ar(t);return this.read(e)}transform({name:t,input:e,output:r}){return new Br({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>W(this,be).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>W(this,xe).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let F=Br;be=new WeakMap;xe=new WeakMap;const Mr=Symbol.for("@mysten/serialized-bcs");function $t(t){return!!t&&typeof t=="object"&&t[Mr]===!0}class zn{constructor(e,r){rt(this,Xe,void 0),rt(this,ae,void 0),nt(this,Xe,e),nt(this,ae,r)}get[Mr](){return!0}toBytes(){return W(this,ae)}toHex(){return me(W(this,ae))}toBase64(){return N(W(this,ae))}toBase58(){return Le(W(this,ae))}parse(){return W(this,Xe).parse(W(this,ae))}}Xe=new WeakMap;ae=new WeakMap;function st({size:t,...e}){return new F({...e,serializedSize:()=>t})}function pt({readMethod:t,writeMethod:e,...r}){return st({...r,read:n=>n[t](),write:(n,s)=>s[e](n),validate:n=>{var s;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,n)}})}function yt({readMethod:t,writeMethod:e,...r}){return st({...r,read:n=>n[t](),write:(n,s)=>s[e](BigInt(n)),validate:n=>{var i;const s=BigInt(n);if(s<0||s>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${s}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,s)}})}function Ln({serialize:t,...e}){const r=new F({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function qn({toBytes:t,fromBytes:e,...r}){return new F({...r,read:n=>{const s=n.readULEB(),i=n.readBytes(s);return e(i)},write:(n,s)=>{const i=t(n);s.writeULEB(i.length);for(let a=0;a<i.length;a++)s.write8(i[a])},serialize:n=>{const s=t(n),i=Rt(s.length),a=new Uint8Array(i.length+s.length);return a.set(i,0),a.set(s,i.length),a},validate:n=>{var s;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(s=r.validate)==null||s.call(r,n)}})}function Wn(t){let e=null;function r(){return e||(e=t()),e}return new F({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,s)=>r().write(n,s),serialize:(n,s)=>r().serialize(n,s).toBytes()})}const c={u8(t){return pt({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return pt({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return pt({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return yt({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return yt({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return yt({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return st({name:"bool",size:1,read:e=>e.read8()===1,write:(e,r)=>r.write8(e?1:0),...t,validate:e=>{var r;if((r=t==null?void 0:t.validate)==null||r.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return Ln({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Rt(e)),...t})},bytes(t,e){return st({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let s=0;s<t;s++)n.write8(r[s]??0)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t)throw new TypeError(`Expected array of length ${t}, found ${r.length}`)}})},string(t){return qn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new F({name:`${e.name}[${t}]`,read:n=>{const s=new Array(t);for(let i=0;i<t;i++)s[i]=e.read(n);return s},write:(n,s)=>{for(const i of n)e.write(i,s)},...r,validate:n=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,n),!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==t)throw new TypeError(`Expected array of length ${t}, found ${n.length}`)}})},option(t){return c.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>"Some"in e?e.Some:null})},vector(t,e){return new F({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 F({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 F({name:t,serializedSize:s=>{let i=0;for(const[a,o]of n){const u=o.serializedSize(s[a]);if(u==null)return null;i+=u}return i},read:s=>{const i={};for(const[a,o]of n)i[a]=o.read(s);return i},write:(s,i)=>{for(const[a,o]of n)o.write(s[a],i)},...r,validate:s=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`)}})},enum(t,e,r){const n=Object.entries(e);return new F({name:t,read:s=>{const i=s.readULEB(),[a,o]=n[i];return{[a]:(o==null?void 0:o.read(s))??!0}},write:(s,i)=>{const[a,o]=Object.entries(s)[0];for(let u=0;u<n.length;u++){const[d,f]=n[u];if(d===a){i.writeULEB(u),f==null||f.write(o,i);return}}},...r,validate:s=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`);const i=Object.keys(s);if(i.length!==1)throw new TypeError(`Expected object with one key, found ${i.length}`);const[a]=i;if(!Object.hasOwn(e,a))throw new TypeError(`Invalid enum variant ${a}`)}})},map(t,e){return c.vector(c.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[s,i]of r)n.set(s,i);return n}})},generic(t,e){return(...r)=>e(...r).transform({name:`${e.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(t){return Wn(t)}},Kn=32,Ie=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof Ie){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(Ie.ADDRESS,t.addressLength,t.addressEncoding),this.registerVectorType(t.vectorType),t.types&&t.types.structs)for(let e of Object.keys(t.types.structs))this.registerStructType(e,t.types.structs[e]);if(t.types&&t.types.enums)for(let e of Object.keys(t.types.enums))this.registerEnumType(e,t.types.enums[e]);if(t.types&&t.types.aliases)for(let e of Object.keys(t.types.aliases))this.registerAlias(e,t.types.aliases[e]);t.withPrimitives!==!1&&Fn(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,s)}if(typeof t=="object"){const n=this.tempKey();return new Ie(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-_NuAK6zi.js","main.js","main.css","assets/index-BFMIYSUy.js","assets/index-CEjbqPmT.js","assets/unsignedTransaction-arVvzoJx.js","assets/index-BTnVHgr_.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Tn=Object.defineProperty;var En=(t,e,r)=>e in t?Tn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var we=(t,e,r)=>En(t,typeof e!="symbol"?e+"":e,r);import{aI as ut,aJ as Le,aK as O,aL as Mt,aM as oe,aN as vn,aO as Pt,aP as Me,aQ as ce,aR as kn,aS as Ke,aT as gr,ae as _n,aU as pr,aV as xn,aW as In,af as An,ah as On,ai as Cn,aX as Bn,ak as jn,al as lt,am as Mn,aY as Je,ao as Pn,aC as Rn,aB as _r,ax as xr,ay as Ir,I as fe,_ as ft,a1 as $n}from"../main.js";import{m as Nn}from"./index-BFMIYSUy.js";function H(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const ht=8192;function N(t){if(t.length<ht)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=ht){const n=t.slice(r,r+ht);e+=String.fromCharCode(...n)}return btoa(e)}function qe(t){var s;const e=t.startsWith("0x")?t.slice(2):t,n=((s=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];return Uint8Array.from(n)}function me(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function Rt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function Un(t){let e=0,r=0,n=0;for(;;){let s=t[n];if(n+=1,e|=(s&127)<<r,!(s&128))break;r+=7}return{value:e,length:n}}class Ar{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:s}=Un(r);return this.shift(s),n}readVec(e){let r=this.readULEB(),n=[];for(let s=0;s<r;s++)n.push(e(this,s,r));return n}}function Dn(t,e){switch(e){case"base58":return Le(t);case"base64":return N(t);case"hex":return me(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Vn(t,e){switch(e){case"base58":return ut(t);case"base64":return H(t);case"hex":return qe(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Or(t,e=["<",">"]){const[r,n]=e,s=[];let i="",a=0;for(let o=0;o<t.length;o++){const u=t[o];if(u===r&&a++,u===n&&a--,a===0&&u===","){s.push(i.trim()),i="";continue}i+=u}return s.push(i.trim()),s}class Cr{constructor({size:e=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=r||e,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const r=this.bytePosition+e;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const s=new ArrayBuffer(this.size);new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(s)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return gt(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return gt(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return gt(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return Rt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,s)=>r(this,n,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return Dn(this.toBytes(),e)}}function gt(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 Br=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},W=(t,e,r)=>(Br(t,e,"read from private field"),r?r.call(t):e.get(t)),rt=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},nt=(t,e,r,n)=>(Br(t,e,"write to private field"),e.set(t,r),r),be,xe,Xe,ae;const jr=class{constructor(t){rt(this,be,void 0),rt(this,xe,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),nt(this,be,t.write),nt(this,xe,t.serialize??((e,r)=>{const n=new Cr({size:this.serializedSize(e)??void 0,...r});return W(this,be).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),W(this,be).call(this,t,e)}serialize(t,e){return this.validate(t),new zn(this,W(this,xe).call(this,t,e))}parse(t){const e=new Ar(t);return this.read(e)}transform({name:t,input:e,output:r}){return new jr({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>W(this,be).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>W(this,xe).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let F=jr;be=new WeakMap;xe=new WeakMap;const Mr=Symbol.for("@mysten/serialized-bcs");function $t(t){return!!t&&typeof t=="object"&&t[Mr]===!0}class zn{constructor(e,r){rt(this,Xe,void 0),rt(this,ae,void 0),nt(this,Xe,e),nt(this,ae,r)}get[Mr](){return!0}toBytes(){return W(this,ae)}toHex(){return me(W(this,ae))}toBase64(){return N(W(this,ae))}toBase58(){return Le(W(this,ae))}parse(){return W(this,Xe).parse(W(this,ae))}}Xe=new WeakMap;ae=new WeakMap;function st({size:t,...e}){return new F({...e,serializedSize:()=>t})}function pt({readMethod:t,writeMethod:e,...r}){return st({...r,read:n=>n[t](),write:(n,s)=>s[e](n),validate:n=>{var s;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,n)}})}function yt({readMethod:t,writeMethod:e,...r}){return st({...r,read:n=>n[t](),write:(n,s)=>s[e](BigInt(n)),validate:n=>{var i;const s=BigInt(n);if(s<0||s>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${s}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,s)}})}function Ln({serialize:t,...e}){const r=new F({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function qn({toBytes:t,fromBytes:e,...r}){return new F({...r,read:n=>{const s=n.readULEB(),i=n.readBytes(s);return e(i)},write:(n,s)=>{const i=t(n);s.writeULEB(i.length);for(let a=0;a<i.length;a++)s.write8(i[a])},serialize:n=>{const s=t(n),i=Rt(s.length),a=new Uint8Array(i.length+s.length);return a.set(i,0),a.set(s,i.length),a},validate:n=>{var s;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(s=r.validate)==null||s.call(r,n)}})}function Wn(t){let e=null;function r(){return e||(e=t()),e}return new F({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,s)=>r().write(n,s),serialize:(n,s)=>r().serialize(n,s).toBytes()})}const c={u8(t){return pt({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return pt({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return pt({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return yt({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return yt({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return yt({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return st({name:"bool",size:1,read:e=>e.read8()===1,write:(e,r)=>r.write8(e?1:0),...t,validate:e=>{var r;if((r=t==null?void 0:t.validate)==null||r.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return Ln({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Rt(e)),...t})},bytes(t,e){return st({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let s=0;s<t;s++)n.write8(r[s]??0)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t)throw new TypeError(`Expected array of length ${t}, found ${r.length}`)}})},string(t){return qn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new F({name:`${e.name}[${t}]`,read:n=>{const s=new Array(t);for(let i=0;i<t;i++)s[i]=e.read(n);return s},write:(n,s)=>{for(const i of n)e.write(i,s)},...r,validate:n=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,n),!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==t)throw new TypeError(`Expected array of length ${t}, found ${n.length}`)}})},option(t){return c.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>"Some"in e?e.Some:null})},vector(t,e){return new F({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 F({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 F({name:t,serializedSize:s=>{let i=0;for(const[a,o]of n){const u=o.serializedSize(s[a]);if(u==null)return null;i+=u}return i},read:s=>{const i={};for(const[a,o]of n)i[a]=o.read(s);return i},write:(s,i)=>{for(const[a,o]of n)o.write(s[a],i)},...r,validate:s=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`)}})},enum(t,e,r){const n=Object.entries(e);return new F({name:t,read:s=>{const i=s.readULEB(),[a,o]=n[i];return{[a]:(o==null?void 0:o.read(s))??!0}},write:(s,i)=>{const[a,o]=Object.entries(s)[0];for(let u=0;u<n.length;u++){const[d,f]=n[u];if(d===a){i.writeULEB(u),f==null||f.write(o,i);return}}},...r,validate:s=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`);const i=Object.keys(s);if(i.length!==1)throw new TypeError(`Expected object with one key, found ${i.length}`);const[a]=i;if(!Object.hasOwn(e,a))throw new TypeError(`Invalid enum variant ${a}`)}})},map(t,e){return c.vector(c.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[s,i]of r)n.set(s,i);return n}})},generic(t,e){return(...r)=>e(...r).transform({name:`${e.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(t){return Wn(t)}},Kn=32,Ie=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof Ie){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(Ie.ADDRESS,t.addressLength,t.addressEncoding),this.registerVectorType(t.vectorType),t.types&&t.types.structs)for(let e of Object.keys(t.types.structs))this.registerStructType(e,t.types.structs[e]);if(t.types&&t.types.enums)for(let e of Object.keys(t.types.enums))this.registerEnumType(e,t.types.enums[e]);if(t.types&&t.types.aliases)for(let e of Object.keys(t.types.aliases))this.registerAlias(e,t.types.aliases[e]);t.withPrimitives!==!1&&Fn(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,s)}if(typeof t=="object"){const n=this.tempKey();return new Ie(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
3
3
|
${JSON.stringify(t)}`)}de(t,e,r){if(typeof e=="string")if(r)e=Vn(e,r);else throw new Error("To pass a string to `bcs.de`, specify encoding");if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).decode(this,e,s)}if(typeof t=="object"){const n=new Ie(this),s=this.tempKey();return n.registerStructType(s,t).de(s,e,r)}throw new Error(`Incorrect type passed into the '.de()' function.
|
|
4
|
-
${JSON.stringify(t)}`)}hasType(t){return this.types.has(t)}registerAlias(t,e){return this.types.set(t,e),this}registerType(t,e,r,n=()=>!0){const{name:s,params:i}=this.parseTypeName(t);return this.types.set(s,{encode(a,o,u,d){const f=i.reduce((g,p,y)=>Object.assign(g,{[p]:d[y]}),{});return this._encodeRaw.call(a,new Cr(u),o,d,f)},decode(a,o,u){const d=i.reduce((f,g,p)=>Object.assign(f,{[g]:u[p]}),{});return this._decodeRaw.call(a,new Ar(o),u,d)},_encodeRaw(a,o,u,d){if(n(o))return e.call(this,a,o,u,d);throw new Error(`Validation failed for type ${s}, data: ${o}`)},_decodeRaw(a,o,u){return r.call(this,a,o,u)}}),this}registerBcsType(t,e){return this.registerType(t,(r,n,s)=>{const i=s.map(a=>new F({name:String(a),write:(o,u)=>{const{name:d,params:f}=this.parseTypeName(a),g=this.getTypeInterface(d),p=f.reduce((y,k,S)=>Object.assign(y,{[k]:s[S]}),{});return g._encodeRaw.call(this,u,o,f,p)},read:()=>{throw new Error("Not implemented")}}));return e(...i).write(n,r),r},(r,n)=>{const s=n.map(i=>new F({name:String(i),write:(a,o)=>{throw new Error("Not implemented")},read:a=>{const{name:o,params:u}=this.parseTypeName(i),d=this.getTypeInterface(o),f=u.reduce((g,p,y)=>Object.assign(g,{[p]:n[y]}),{});return d._decodeRaw.call(this,a,u,f)}}));return e(...s).read(r)}),this}registerAddressType(t,e,r="hex"){switch(r){case"base64":return this.registerType(t,function(s,i){return H(i).reduce((a,o)=>a.write8(o),s)},function(s){return N(s.readBytes(e))});case"hex":return this.registerType(t,function(s,i){return qe(i).reduce((a,o)=>a.write8(o),s)},function(s){return me(s.readBytes(e))});default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(t){let{name:e,params:r}=this.parseTypeName(t);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+e);return this.registerType(t,function(s,i,a,o){return s.writeVec(i,(u,d)=>{let f=a[0];if(!f)throw new Error(`Incorrect number of type parameters passed a to vector '${t}'`);let{name:g,params:p}=this.parseTypeName(f);if(this.hasType(g))return this.getTypeInterface(g)._encodeRaw.call(this,u,d,p,o);if(!(g in o))throw new Error(`Unable to find a matching type definition for ${g} in vector; make sure you passed a generic`);let{name:y,params:k}=this.parseTypeName(o[g]);return this.getTypeInterface(y)._encodeRaw.call(this,u,d,k,o)})},function(s,i,a){return s.readVec(o=>{let u=i[0];if(!u)throw new Error(`Incorrect number of type parameters passed to a vector '${t}'`);let{name:d,params:f}=this.parseTypeName(u);if(this.hasType(d))return this.getTypeInterface(d)._decodeRaw.call(this,o,f,a);if(!(d in a))throw new Error(`Unable to find a matching type definition for ${d} in vector; make sure you passed a generic`);let{name:g,params:p}=this.parseTypeName(a[d]);return this.getTypeInterface(g)._decodeRaw.call(this,o,p,a)})})}registerStructType(t,e){for(let a in e){let o=this.tempKey(),u=e[a];!Array.isArray(u)&&typeof u!="string"&&(e[a]=o,this.registerStructType(o,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,u,d,f){if(!u||u.constructor!==Object)throw new Error(`Expected ${s} to be an Object, got: ${u}`);if(d.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${d.length}`);for(let g of n){if(!(g in u))throw new Error(`Struct ${s} requires field ${g}:${r[g]}`);const{name:p,params:y}=this.parseTypeName(r[g]);if(!i.includes(p))this.getTypeInterface(p)._encodeRaw.call(this,o,u[g],y,f);else{const k=i.indexOf(p);let{name:S,params:
|
|
4
|
+
${JSON.stringify(t)}`)}hasType(t){return this.types.has(t)}registerAlias(t,e){return this.types.set(t,e),this}registerType(t,e,r,n=()=>!0){const{name:s,params:i}=this.parseTypeName(t);return this.types.set(s,{encode(a,o,u,d){const f=i.reduce((g,p,y)=>Object.assign(g,{[p]:d[y]}),{});return this._encodeRaw.call(a,new Cr(u),o,d,f)},decode(a,o,u){const d=i.reduce((f,g,p)=>Object.assign(f,{[g]:u[p]}),{});return this._decodeRaw.call(a,new Ar(o),u,d)},_encodeRaw(a,o,u,d){if(n(o))return e.call(this,a,o,u,d);throw new Error(`Validation failed for type ${s}, data: ${o}`)},_decodeRaw(a,o,u){return r.call(this,a,o,u)}}),this}registerBcsType(t,e){return this.registerType(t,(r,n,s)=>{const i=s.map(a=>new F({name:String(a),write:(o,u)=>{const{name:d,params:f}=this.parseTypeName(a),g=this.getTypeInterface(d),p=f.reduce((y,k,S)=>Object.assign(y,{[k]:s[S]}),{});return g._encodeRaw.call(this,u,o,f,p)},read:()=>{throw new Error("Not implemented")}}));return e(...i).write(n,r),r},(r,n)=>{const s=n.map(i=>new F({name:String(i),write:(a,o)=>{throw new Error("Not implemented")},read:a=>{const{name:o,params:u}=this.parseTypeName(i),d=this.getTypeInterface(o),f=u.reduce((g,p,y)=>Object.assign(g,{[p]:n[y]}),{});return d._decodeRaw.call(this,a,u,f)}}));return e(...s).read(r)}),this}registerAddressType(t,e,r="hex"){switch(r){case"base64":return this.registerType(t,function(s,i){return H(i).reduce((a,o)=>a.write8(o),s)},function(s){return N(s.readBytes(e))});case"hex":return this.registerType(t,function(s,i){return qe(i).reduce((a,o)=>a.write8(o),s)},function(s){return me(s.readBytes(e))});default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(t){let{name:e,params:r}=this.parseTypeName(t);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+e);return this.registerType(t,function(s,i,a,o){return s.writeVec(i,(u,d)=>{let f=a[0];if(!f)throw new Error(`Incorrect number of type parameters passed a to vector '${t}'`);let{name:g,params:p}=this.parseTypeName(f);if(this.hasType(g))return this.getTypeInterface(g)._encodeRaw.call(this,u,d,p,o);if(!(g in o))throw new Error(`Unable to find a matching type definition for ${g} in vector; make sure you passed a generic`);let{name:y,params:k}=this.parseTypeName(o[g]);return this.getTypeInterface(y)._encodeRaw.call(this,u,d,k,o)})},function(s,i,a){return s.readVec(o=>{let u=i[0];if(!u)throw new Error(`Incorrect number of type parameters passed to a vector '${t}'`);let{name:d,params:f}=this.parseTypeName(u);if(this.hasType(d))return this.getTypeInterface(d)._decodeRaw.call(this,o,f,a);if(!(d in a))throw new Error(`Unable to find a matching type definition for ${d} in vector; make sure you passed a generic`);let{name:g,params:p}=this.parseTypeName(a[d]);return this.getTypeInterface(g)._decodeRaw.call(this,o,p,a)})})}registerStructType(t,e){for(let a in e){let o=this.tempKey(),u=e[a];!Array.isArray(u)&&typeof u!="string"&&(e[a]=o,this.registerStructType(o,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,u,d,f){if(!u||u.constructor!==Object)throw new Error(`Expected ${s} to be an Object, got: ${u}`);if(d.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${d.length}`);for(let g of n){if(!(g in u))throw new Error(`Struct ${s} requires field ${g}:${r[g]}`);const{name:p,params:y}=this.parseTypeName(r[g]);if(!i.includes(p))this.getTypeInterface(p)._encodeRaw.call(this,o,u[g],y,f);else{const k=i.indexOf(p);let{name:S,params:B}=this.parseTypeName(d[k]);if(this.hasType(S)){this.getTypeInterface(S)._encodeRaw.call(this,o,u[g],B,f);continue}if(!(S in f))throw new Error(`Unable to find a matching type definition for ${S} in ${s}; make sure you passed a generic`);let{name:M,params:se}=this.parseTypeName(f[S]);this.getTypeInterface(M)._encodeRaw.call(this,o,u[g],se,f)}}return o},function(o,u,d){if(u.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${u.length}`);let f={};for(let g of n){const{name:p,params:y}=this.parseTypeName(r[g]);if(!i.includes(p))f[g]=this.getTypeInterface(p)._decodeRaw.call(this,o,y,d);else{const k=i.indexOf(p);let{name:S,params:B}=this.parseTypeName(u[k]);if(this.hasType(S)){f[g]=this.getTypeInterface(S)._decodeRaw.call(this,o,B,d);continue}if(!(S in d))throw new Error(`Unable to find a matching type definition for ${S} in ${s}; make sure you passed a generic`);let{name:M,params:se}=this.parseTypeName(d[S]);f[g]=this.getTypeInterface(M)._decodeRaw.call(this,o,se,d)}}return f})}registerEnumType(t,e){for(let a in e){let o=this.tempKey(),u=e[a];u!==null&&!Array.isArray(u)&&typeof u!="string"&&(e[a]=o,this.registerStructType(o,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,u,d,f){if(!u)throw new Error(`Unable to write enum "${s}", missing data.
|
|
5
5
|
Received: "${u}"`);if(typeof u!="object")throw new Error(`Incorrect data passed into enum "${s}", expected object with properties: "${n.join(" | ")}".
|
|
6
|
-
Received: "${JSON.stringify(u)}"`);let g=Object.keys(u)[0];if(g===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let p=n.indexOf(g);if(p===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${g}"`);let y=n[p],k=r[y];if(o.write8(p),k===null)return o;let S=i.indexOf(k),j=S===-1?k:d[S];{let{name:M,params:se}=this.parseTypeName(j);return this.getTypeInterface(M)._encodeRaw.call(this,o,u[g],se,f)}},function(o,u,d){let f=o.readULEB(),g=n[f],p=r[g];if(f===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${f}"`);if(p===null)return{[g]:!0};let y=i.indexOf(p),k=y===-1?p:u[y];{let{name:S,params:j}=this.parseTypeName(k);return{[g]:this.getTypeInterface(S)._decodeRaw.call(this,o,j,d)}}})}getTypeInterface(t){let e=this.types.get(t);if(typeof e=="string"){let r=[];for(;typeof e=="string";){if(r.includes(e))throw new Error(`Recursive definition found: ${r.join(" -> ")} -> ${e}`);r.push(e),e=this.types.get(e)}}if(e===void 0)throw new Error(`Type ${t} is not registered`);return e}parseTypeName(t){if(Array.isArray(t)){let[o,...u]=t;return{name:o,params:u}}if(typeof t!="string")throw new Error(`Illegal type passed as a name of the type: ${t}`);let[e,r]=this.schema.genericSeparators||["<",">"],n=t.indexOf(e),s=Array.from(t).reverse().indexOf(r);if(n===-1&&s===-1)return{name:t,params:[]};if(n===-1||s===-1)throw new Error(`Unclosed generic in name '${t}'`);let i=t.slice(0,n),a=Or(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let _=Ie;_.U8="u8";_.U16="u16";_.U32="u32";_.U64="u64";_.U128="u128";_.U256="u256";_.BOOL="bool";_.VECTOR="vector";_.ADDRESS="address";_.STRING="string";_.HEX="hex-string";_.BASE58="base58-string";_.BASE64="base64-string";function Fn(t){t.registerType(_.U8,function(e,r){return e.write8(r)},function(e){return e.read8()},e=>e<256),t.registerType(_.U16,function(e,r){return e.write16(r)},function(e){return e.read16()},e=>e<65536),t.registerType(_.U32,function(e,r){return e.write32(r)},function(e){return e.read32()},e=>e<=4294967296n),t.registerType(_.U64,function(e,r){return e.write64(r)},function(e){return e.read64()}),t.registerType(_.U128,function(e,r){return e.write128(r)},function(e){return e.read128()}),t.registerType(_.U256,function(e,r){return e.write256(r)},function(e){return e.read256()}),t.registerType(_.BOOL,function(e,r){return e.write8(r)},function(e){return e.read8().toString(10)==="1"}),t.registerType(_.STRING,function(e,r){return e.writeVec(Array.from(r),(n,s)=>n.write8(s.charCodeAt(0)))},function(e){return e.readVec(r=>r.read8()).map(r=>String.fromCharCode(Number(r))).join("")},e=>!0),t.registerType(_.HEX,function(e,r){return e.writeVec(Array.from(qe(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return me(new Uint8Array(r))}),t.registerType(_.BASE58,function(e,r){return e.writeVec(Array.from(ut(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return Le(new Uint8Array(r))}),t.registerType(_.BASE64,function(e,r){return e.writeVec(Array.from(H(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return N(new Uint8Array(r))})}function Gn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Kn,addressEncoding:"hex"}}class Hn extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:o}=e,u=o.length===0?s:`At path: ${o.join(".")} -- ${s}`;super(i??u),i!=null&&(this.cause=u),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Zn(t){return z(t)&&typeof t[Symbol.iterator]=="function"}function z(t){return typeof t=="object"&&t!=null}function L(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:o,message:u=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${L(n)}\``}=t;return{value:n,type:a,refinement:o,key:s[s.length-1],path:s,branch:i,...t,message:u}}function*yr(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,o={path:n,branch:s};if(i&&(t=e.coercer(t,o),a&&e.type!=="type"&&z(e.schema)&&z(t)&&!Array.isArray(t)))for(const d in t)e.schema[d]===void 0&&delete t[d];let u="valid";for(const d of e.validator(t,o))d.explanation=r.message,u="not_valid",yield[d,void 0];for(let[d,f,g]of e.entries(t,o)){const p=Nt(f,g,{path:d===void 0?n:[...n,d],branch:d===void 0?s:[...s,f],coerce:i,mask:a,message:r.message});for(const y of p)y[0]?(u=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):i&&(f=y[1],d===void 0?t=f:t instanceof Map?t.set(d,f):t instanceof Set?t.add(f):z(t)&&(f!==void 0||d in t)&&(t[d]=f))}if(u!=="not_valid")for(const d of e.refiner(t,o))d.explanation=r.message,u="not_refined",yield[d,void 0];u==="valid"&&(yield[void 0,t])}class X{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=u=>u,entries:o=function*(){}}=e;this.type=r,this.schema=n,this.entries=o,this.coercer=a,s?this.validator=(u,d)=>{const f=s(u,d);return yr(f,d,this,u)}:this.validator=()=>[],i?this.refiner=(u,d)=>{const f=i(u,d);return yr(f,d,this,u)}:this.refiner=()=>[]}assert(e,r){return St(e,this,r)}create(e,r){return Pr(e,this,r)}is(e){return U(e,this)}mask(e,r){return Rr(e,this,r)}validate(e,r={}){return We(e,this,r)}}function St(t,e,r){const n=We(t,e,{message:r});if(n[0])throw n[0]}function Pr(t,e,r){const n=We(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Rr(t,e,r){const n=We(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function U(t,e){return!We(t,e)[0]}function We(t,e,r={}){const n=Nt(t,e,r),s=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 Pe(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?Qn(n):h(n)}function D(t,e){return new X({type:t,schema:null,validator:e})}function Tt(){return D("any",()=>!0)}function T(t){return new X({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${L(e)}`}})}function Yn(){return D("bigint",t=>typeof t=="bigint")}function P(){return D("boolean",t=>typeof t=="boolean")}function J(){return D("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${L(t)}`)}function w(t){const e=L(t),r=typeof t;return new X({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${L(n)}`}})}function $r(){return D("never",()=>!1)}function A(t){return new X({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function pe(){return D("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${L(t)}`)}function h(t){const e=t?Object.keys(t):[],r=$r();return new X({type:"object",schema:t||null,*entries(n){if(t&&z(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 z(n)||`Expected an object, but received: ${L(n)}`},coercer(n){return z(n)?{...n}:n}})}function m(t){return new X({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Z(t,e){return new X({type:"record",schema:null,*entries(r){if(z(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return z(r)||`Expected an object, but received: ${L(r)}`}})}function l(){return D("string",t=>typeof t=="string"||`Expected a string, but received: ${L(t)}`)}function Nr(t){const e=$r();return new X({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let s=0;s<n;s++)yield[s,r[s],t[s]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${L(r)}`}})}function Qn(t){const e=Object.keys(t);return new X({type:"type",schema:t,*entries(r){if(z(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return z(r)||`Expected an object, but received: ${L(r)}`},coercer(r){return z(r)?{...r}:r}})}function C(t){const e=t.map(r=>r.type).join(" | ");return new X({type:"union",schema:null,coercer(r){for(const n of t){const[s,i]=n.validate(r,{coerce:!0});if(!s)return i}return r},validator(r,n){const s=[];for(const i of t){const[...a]=Nt(r,i,n),[o]=a;if(o[0])for(const[u]of a)u&&s.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${L(r)}`,...s]}})}function Ur(){return D("unknown",()=>!0)}const es="0.50.1",ts="1.19.0",rs={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class Dr extends Error{}class Vr extends Dr{constructor(e,r){super(e),this.code=r,this.type=rs[r]??"ServerError"}}class ns extends Dr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var Ut=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},x=(t,e,r)=>(Ut(t,e,"read from private field"),r?r.call(t):e.get(t)),ie=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Te=(t,e,r,n)=>(Ut(t,e,"write to private field"),e.set(t,r),r),ss=(t,e,r,n)=>({set _(s){Te(t,e,s)},get _(){return x(t,e,n)}}),zr=(t,e,r)=>(Ut(t,e,"access private method"),r),he,je,ee,ge,Re,Ee,Et,Lr,Dt,qr;function is(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const as={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class os{constructor(e,r={}){if(ie(this,Et),ie(this,Dt),ie(this,he,0),ie(this,je,0),ie(this,ee,null),ie(this,ge,null),ie(this,Re,new Set),ie(this,Ee,new Map),this.endpoint=e,this.options={...as,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=is(this.endpoint))}async makeRequest(e,r){const n=await zr(this,Et,Lr).call(this);return new Promise((s,i)=>{Te(this,he,x(this,he)+1),x(this,Ee).set(x(this,he),{resolve:s,reject:i,timeout:setTimeout(()=>{x(this,Ee).delete(x(this,he)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:x(this,he),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new Vr(s.message,s.code);return i})}async subscribe(e){const r=new cs(e);return x(this,Re).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}he=new WeakMap;je=new WeakMap;ee=new WeakMap;ge=new WeakMap;Re=new WeakMap;Ee=new WeakMap;Et=new WeakSet;Lr=function(){return x(this,ge)?x(this,ge):(Te(this,ge,new Promise(t=>{var e;(e=x(this,ee))==null||e.close(),Te(this,ee,new this.options.WebSocketConstructor(this.endpoint)),x(this,ee).addEventListener("open",()=>{Te(this,je,0),t(x(this,ee))}),x(this,ee).addEventListener("close",()=>{ss(this,je)._++,x(this,je)<=this.options.maxReconnects&&setTimeout(()=>{zr(this,Dt,qr).call(this)},this.options.reconnectTimeout)}),x(this,ee).addEventListener("message",({data:r})=>{let n;try{n=JSON.parse(r)}catch(s){console.error(new Error(`Failed to parse RPC message: ${r}`,{cause:s}));return}if("id"in n&&n.id!=null&&x(this,Ee).has(n.id)){const{resolve:s,timeout:i}=x(this,Ee).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;x(this,Re).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),x(this,ge))};Dt=new WeakSet;qr=async function(){var t;return(t=x(this,ee))==null||t.close(),Te(this,ge,null),Promise.allSettled([...x(this,Re)].map(e=>e.subscribe(this)))};class cs{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 Vt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},V=(t,e,r)=>(Vt(t,e,"read from private field"),r?r.call(t):e.get(t)),Fe=(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)},vt=(t,e,r,n)=>(Vt(t,e,"write to private field"),e.set(t,r),r),us=(t,e,r)=>(Vt(t,e,"access private method"),r),Ae,K,Be,kt,Wr;class ds{constructor(e){Fe(this,kt),Fe(this,Ae,0),Fe(this,K,void 0),Fe(this,Be,void 0),vt(this,K,e)}fetch(e,r){const n=V(this,K).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;vt(this,Ae,V(this,Ae)+1);const r=await this.fetch(((s=V(this,K).rpc)==null?void 0:s.url)??V(this,K).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":es,"Client-Target-Api-Version":ts,...(i=V(this,K).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:V(this,Ae),method:e.method,params:e.params})});if(!r.ok)throw new ns(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new Vr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await us(this,kt,Wr).call(this).subscribe(e);return async()=>!!await r()}}Ae=new WeakMap;K=new WeakMap;Be=new WeakMap;kt=new WeakSet;Wr=function(){var t;if(!V(this,Be)){const e=V(this,K).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.");vt(this,Be,new os(((t=V(this,K).websocket)==null?void 0:t.url)??V(this,K).url,{WebSocketConstructor:e,...V(this,K).websocket}))}return V(this,Be)};const ls=/^vector<(.+)>$/,fs=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class te{static parseFromStr(e,r=!1){if(e==="address")return{address:null};if(e==="bool")return{bool:null};if(e==="u8")return{u8:null};if(e==="u16")return{u16:null};if(e==="u32")return{u32:null};if(e==="u64")return{u64:null};if(e==="u128")return{u128:null};if(e==="u256")return{u256:null};if(e==="signer")return{signer:null};const n=e.match(ls);if(n)return{vector:te.parseFromStr(n[1],r)};const s=e.match(fs);if(s)return{struct:{address:r?O(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:te.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return Or(e).map(n=>te.parseFromStr(n,r))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${te.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(te.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const v=new _({...Gn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function Kr(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function hs(t){return c.enum("Option",{None:null,Some:t})}function zt(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const G=c.bytes(Mt).transform({input:t=>typeof t=="string"?qe(O(t)):t,output:t=>O(me(t))}),Lt=c.vector(c.u8()).transform({name:"ObjectDigest",input:t=>ut(t),output:t=>Le(new Uint8Array(t))}),$e=c.struct("SuiObjectRef",{objectId:G,version:c.u64(),digest:Lt}),qt=c.struct("SharedObjectRef",{objectId:G,initialSharedVersion:c.u64(),mutable:c.bool()}),it=c.enum("ObjectArg",{ImmOrOwned:$e,Shared:qt,Receiving:$e}),Wt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:it,ObjVec:c.vector(it)}),_e=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>_e),struct:c.lazy(()=>Jt),u16:null,u32:null,u256:null}),q=zt(c.enum("Argument",{GasCoin:null,Input:c.struct("Input",{index:c.u16()}),Result:c.struct("Result",{index:c.u16()}),NestedResult:c.struct("NestedResult",{index:c.u16(),resultIndex:c.u16()})})),Kt=c.struct("ProgrammableMoveCall",{package:G,module:c.string(),function:c.string(),type_arguments:c.vector(_e),arguments:c.vector(q)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>te.parseFromStr(i,!0));return{package:O(e),module:r,function:n,type_arguments:s,arguments:t.arguments}},output:t=>({target:[t.package,t.module,t.function].join("::"),arguments:t.arguments,typeArguments:t.type_arguments.map(te.tagToString)})}),Ft=zt(c.enum("Transaction",{MoveCall:Kt,TransferObjects:c.struct("TransferObjects",{objects:c.vector(q),address:q}),SplitCoins:c.struct("SplitCoins",{coin:q,amounts:c.vector(q)}),MergeCoins:c.struct("MergeCoins",{destination:q,sources:c.vector(q)}),Publish:c.struct("Publish",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G)}),MakeMoveVec:c.struct("MakeMoveVec",{type:hs(_e),objects:c.vector(q)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G),packageId:G,ticket:q})})),Gt=c.struct("ProgrammableTransaction",{inputs:c.vector(Wt),transactions:c.vector(Ft)}),Ht=c.enum("TransactionKind",{ProgrammableTransaction:Gt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Zt=c.enum("TransactionExpiration",{None:null,Epoch:Kr()}),Jt=c.struct("StructTag",{address:G,module:c.string(),name:c.string(),typeParams:c.vector(_e)}),Xt=c.struct("GasData",{payment:c.vector($e),owner:G,price:c.u64(),budget:c.u64()}),Yt=c.struct("TransactionDataV1",{kind:Ht,sender:G,gasData:Xt,expiration:Zt}),Qt=c.enum("TransactionData",{V1:Yt}),gs=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),ps=c.enum("IntentVersion",{V0:null}),ys=c.enum("AppId",{Sui:null}),ms=c.struct("Intent",{scope:gs,version:ps,appId:ys}),ws=c.generic(["T"],t=>c.struct("IntentMessage<T>",{intent:ms,value:t})),er=c.enum("CompressedSignature",{ED25519:c.fixedArray(64,c.u8()),Secp256k1:c.fixedArray(64,c.u8()),Secp256r1:c.fixedArray(64,c.u8()),ZkLogin:c.vector(c.u8())}),tr=c.enum("PublicKey",{ED25519:c.fixedArray(32,c.u8()),Secp256k1:c.fixedArray(33,c.u8()),Secp256r1:c.fixedArray(33,c.u8()),ZkLogin:c.vector(c.u8())}),rr=c.struct("MultiSigPkMap",{pubKey:tr,weight:c.u8()}),nr=c.struct("MultiSigPublicKey",{pk_map:c.vector(rr),threshold:c.u16()}),Fr=c.struct("MultiSig",{sigs:c.vector(er),bitmap:c.u16(),multisig_pk:nr}),bs=c.vector(c.u8()).transform({input:t=>typeof t=="string"?H(t):t,output:t=>N(new Uint8Array(t))}),Gr=c.struct("SenderSignedTransaction",{intentMessage:ws(Qt),txSignatures:c.vector(bs)}),Hr=c.vector(Gr,{name:"SenderSignedData"}),I={...c,U8:c.u8(),U16:c.u16(),U32:c.u32(),U64:c.u64(),U128:c.u128(),U256:c.u256(),ULEB128:c.uleb128(),Bool:c.bool(),String:c.string(),Address:G,Argument:q,CallArg:Wt,CompressedSignature:er,GasData:Xt,MultiSig:Fr,MultiSigPkMap:rr,MultiSigPublicKey:nr,ObjectArg:it,ObjectDigest:Lt,ProgrammableMoveCall:Kt,ProgrammableTransaction:Gt,PublicKey:tr,SenderSignedData:Hr,SenderSignedTransaction:Gr,SharedObjectRef:qt,StructTag:Jt,SuiObjectRef:$e,Transaction:Ft,TransactionData:Qt,TransactionDataV1:Yt,TransactionExpiration:Zt,TransactionKind:Ht,TypeTag:_e,ser:v.ser.bind(v),de:v.de.bind(v),getTypeInterface:v.getTypeInterface.bind(v),hasType:v.hasType.bind(v),parseTypeName:v.parseTypeName.bind(v),registerAddressType:v.registerAddressType.bind(v),registerAlias:v.registerAlias.bind(v),registerBcsType:v.registerBcsType.bind(v),registerEnumType:v.registerEnumType.bind(v),registerStructType:v.registerStructType.bind(v),registerType:v.registerType.bind(v),types:v.types};v.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));v.registerBcsType("unsafe_u64",()=>Kr());v.registerBcsType("enumKind",t=>zt(t));[G,q,Wt,er,Xt,Fr,rr,nr,it,Lt,Kt,Gt,tr,Hr,qt,Jt,$e,Ft,Qt,Yt,Zt,Ht,_e].forEach(t=>{v.registerBcsType(t.name,()=>t)});const sr=C([h({AddressOwner:l()}),h({ObjectOwner:l()}),h({Shared:h({initial_shared_version:A(l())})}),w("Immutable")]);D("SuiJsonValue",()=>!0);const Ss=C([h({u32:l()}),h({u64:l()}),h({f64:l()})]);h({attributes:Z(l(),A(Ss)),featureFlags:Z(l(),P()),maxSupportedProtocolVersion:l(),minSupportedProtocolVersion:l(),protocolVersion:l()});C([l(),w("package")]);const ue=h({digest:l(),objectId:l(),version:C([pe(),l(),Yn()])});h({owner:sr,reference:ue});h({objectId:l(),sequenceNumber:l()});h({payment:T(ue),owner:l(),price:l(),budget:l()});const Ts=Pe(ue,h({type:l(),owner:sr,previousTransaction:l()})),Es=Z(l(),Tt()),vs=Z(l(),Ur()),ks=h({type:l(),fields:Es,hasPublicTransfer:P()}),_s=h({disassembled:vs}),xs=C([Pe(ks,h({dataType:w("moveObject")})),Pe(_s,h({dataType:w("package")}))]),Is=h({type:l(),hasPublicTransfer:P(),version:l(),bcsBytes:l()}),As=h({id:l(),moduleMap:Z(l(),l())}),Os=C([Pe(Is,h({dataType:w("moveObject")})),Pe(As,h({dataType:w("package")}))]);BigInt(1e9);const Zr=h({code:l(),error:m(l()),object_id:m(l()),parent_object_id:m(l()),version:m(l()),digest:m(l())}),Cs=h({data:A(m(Z(l(),l()))),error:A(m(Zr))}),js=C([Cs,m(Z(l(),l()))]),Jr=h({objectId:l(),version:l(),digest:l(),type:A(m(l())),content:A(m(xs)),bcs:A(m(Os)),owner:A(m(sr)),previousTransaction:A(m(l())),storageRebate:A(m(l())),display:A(m(js))});h({showType:A(m(P())),showContent:A(m(P())),showBcs:A(m(P())),showOwner:A(m(P())),showPreviousTransaction:A(m(P())),showStorageRebate:A(m(P())),showDisplay:A(m(P()))});C([w("Exists"),w("notExists"),w("Deleted")]);T(Ts);const Bs=h({data:A(m(Jr)),error:A(m(Zr))});function Ms(t){return t.data}function Ps(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 mr(t){if("reference"in t)return t.reference;const e=Ms(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:Ps(t)}h({objectId:l(),atCheckpoint:m(pe())});h({data:T(Bs),nextCursor:m(A(l())),hasNextPage:P()});C([h({details:Jr,status:w("VersionFound")}),h({details:l(),status:w("ObjectNotExists")}),h({details:ue,status:w("ObjectDeleted")}),h({details:Nr([l(),pe()]),status:w("VersionNotFound")}),h({details:h({asked_version:pe(),latest_version:pe(),object_id:l()}),status:w("VersionTooHigh")})]);const Rs=C([l(),h({Object:l()})]);T(Rs);const $s=h({address:l(),name:l()}),Ns=C([w("Private"),w("Public"),w("Friend")]),ir=h({abilities:T(l())}),Us=h({constraints:ir,isPhantom:P()}),Ds=h({TypeParameter:pe()}),mt=Nr([h({module:l(),package:l(),function:l()}),l()]);h({rank3Days:T(mt),rank7Days:T(mt),rank30Days:T(mt)});function Xr(t){if(!t)return!1;if(typeof t=="string"||U(t,Ds)||Yr(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(U(e.Reference,ve)||U(e.MutableReference,ve)||U(e.Vector,ve))}const ve=D("SuiMoveNormalizedType",Xr);function Yr(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=>Xr(n)))}D("SuiMoveNormalizedStructType",Yr);const Vs=h({visibility:Ns,isEntry:P(),typeParameters:T(ir),parameters:T(ve),return:T(ve)}),zs=h({name:l(),type:ve}),Ls=h({abilities:ir,typeParameters:T(Us),fields:T(zs)}),qs=h({fileFormatVersion:pe(),address:l(),name:l(),friends:T($s),structs:Z(l(),Ls),exposedFunctions:Z(l(),Vs)});Z(l(),qs);function _t(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function Qr(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function ar(t){if(typeof t=="object"&&"Struct"in t)return t;const e=Qr(t),r=_t(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const Ws=C([h({ImmOrOwned:ue}),h({Shared:h({objectId:l(),initialSharedVersion:C([J(),l()]),mutable:P()})}),h({Receiving:ue})]),at=h({Pure:T(J())}),xt=h({Object:Ws}),ot=C([at,xt]);function Ks(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:$t(t)?t.toBytes():I.ser(e,t,{maxSize:1/0}).toBytes())}}const $={Pure:Ks,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:O(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:O(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:O(t)}}}}};function wr(t){return typeof t=="string"?O(t):"ImmOrOwned"in t.Object?O(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?O(t.Object.Receiving.objectId):O(t.Object.Shared.objectId)}function Fs(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function Gs(t){var e;return((e=Fs(t))==null?void 0:e.mutable)??!1}function Hs(t){function e(r,n){return t(r,n)}return e.u8=r=>t(I.U8.serialize(r)),e.u16=r=>t(I.U16.serialize(r)),e.u32=r=>t(I.U32.serialize(r)),e.u64=r=>t(I.U64.serialize(r)),e.u128=r=>t(I.U128.serialize(r)),e.u256=r=>t(I.U256.serialize(r)),e.bool=r=>t(I.Bool.serialize(r)),e.string=r=>t(I.String.serialize(r)),e.address=r=>t(I.Address.serialize(r)),e.id=e.address,e}const Zs="object",Js="ID",Xs="ascii",Ys="String",Qs="string",ei="String",ti="option",ri="Option",ni={address:vn,module:Zs,name:Js},si={address:Pt,module:Xs,name:Ys},ii={address:Pt,module:Qs,name:ei},ai={address:Pt,module:ti,name:ri},Ge=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function oi(t){var r;const e=(r=ar(t))==null?void 0:r.Struct;return(e==null?void 0:e.address)==="0x2"&&(e==null?void 0:e.module)==="tx_context"&&(e==null?void 0:e.name)==="TxContext"}function wt(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const ci=["Address","Bool","U8","U16","U32","U64","U128","U256"];function It(t,e){if(typeof t=="string"&&ci.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])wt("number",e);else if(t==="Bool")wt("boolean",e);else if(t==="Address"&&(wt("string",e),e&&!oe(e)))throw new Error("Invalid Sui Address");return t.toLowerCase()}else if(typeof t=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(t,null,2)}`);if("Vector"in t){if((e===void 0||typeof e=="string")&&t.Vector==="U8")return"string";if(e!==void 0&&!Array.isArray(e))throw new Error(`Expect ${e} to be a array, received ${typeof e}`);const r=It(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(Ge(t.Struct,si))return"string";if(Ge(t.Struct,ii))return"utf8string";if(Ge(t.Struct,ni))return"address";if(Ge(t.Struct,ai)){const r={Vector:t.Struct.typeArguments[0]};return It(r,e)}}}function ui(t,e){const r=Array.from(`${t}::`).map(s=>s.charCodeAt(0)),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),Me(n,{dkLen:32})}function R(t,e){return Pr(t,e)}const di=t=>C([h({None:C([w(!0),w(null)])}),h({Some:t})]),Ne=C([h({kind:w("Input"),index:J(),value:m(Tt()),type:m(w("object"))}),h({kind:w("Input"),index:J(),value:m(Tt()),type:w("pure")})]),li=[Ne,h({kind:w("GasCoin")}),h({kind:w("Result"),index:J()}),h({kind:w("NestedResult"),index:J(),resultIndex:J()})],ne=C([...li]),en=h({kind:w("MoveCall"),target:D("target",l().validator),typeArguments:T(l()),arguments:T(ne)}),tn=h({kind:w("TransferObjects"),objects:T(ne),address:ne}),rn=h({kind:w("SplitCoins"),coin:ne,amounts:T(ne)}),nn=h({kind:w("MergeCoins"),destination:ne,sources:T(ne)}),sn=h({kind:w("MakeMoveVec"),type:m(di(Z(l(),Ur()))),objects:T(ne)}),an=h({kind:w("Publish"),modules:T(T(J())),dependencies:T(l())}),on=h({kind:w("Upgrade"),modules:T(T(J())),dependencies:T(l()),packageId:l(),ticket:ne}),fi=[en,tn,rn,nn,an,on,sn],hi=C([...fi]),le={MoveCall(t){return R({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},en)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=$.Pure(I.Address.serialize(e.value))),R({kind:"TransferObjects",objects:t,address:e},tn)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=$.Pure(I.U64.serialize(r.value)))}),R({kind:"SplitCoins",coin:t,amounts:e},rn)},MergeCoins(t,e){return R({kind:"MergeCoins",destination:t,sources:e},nn)},Publish({modules:t,dependencies:e}){return R({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(H(r)):r),dependencies:e.map(r=>ce(r))},an)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return R({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(H(s)):s),dependencies:e.map(s=>ce(s)),packageId:r,ticket:n},on)},MakeMoveVec({type:t,objects:e}){return R({kind:"MakeMoveVec",type:t?{Some:te.parseFromStr(t)}:{None:null},objects:e},sn)}},gi=m(A(C([h({Epoch:J()}),h({None:C([w(!0),w(null)])})]))),br=D("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),pi=h({budget:m(br),price:m(br),payment:m(T(ue)),owner:m(l())}),He=h({version:w(1),sender:m(l()),expiration:gi,gasConfig:pi,inputs:T(Ne),transactions:T(hi)});function Sr(t){return O(t).replace("0x","")}class re{constructor(e){this.version=1,this.sender=e==null?void 0:e.sender,this.expiration=e==null?void 0:e.expiration,this.gasConfig=(e==null?void 0:e.gasConfig)??{},this.inputs=(e==null?void 0:e.inputs)??[],this.transactions=(e==null?void 0:e.transactions)??[]}static fromKindBytes(e){const r=I.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=R({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>R({kind:"Input",value:i,index:a,type:U(i,at)?"pure":"object"},Ne)),transactions:n.transactions},He);return re.restore(s)}static fromBytes(e){var a;const r=I.TransactionData.parse(e),n=r==null?void 0:r.V1,s="ProgrammableTransaction"in n.kind?(a=n==null?void 0:n.kind)==null?void 0:a.ProgrammableTransaction:null;if(!n||!s)throw new Error("Unable to deserialize from bytes.");const i=R({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((o,u)=>R({kind:"Input",value:o,index:u,type:U(o,at)?"pure":"object"},Ne)),transactions:s.transactions},He);return re.restore(i)}static restore(e){St(e,He);const r=new re;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=ui("TransactionData",e);return Le(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(f=>(St(f.value,ot),f.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return I.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,o=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const d={sender:Sr(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:Sr(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return I.TransactionData.serialize({V1:d},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return re.getDigestFromBytes(e)}snapshot(){return R(this,He)}}var or=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},E=(t,e,r)=>(or(t,e,"read from private field"),r?r.call(t):e.get(t)),Y=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Ze=(t,e,r,n)=>(or(t,e,"write to private field"),e.set(t,r),r),B=(t,e,r)=>(or(t,e,"access private method"),r),b,Oe,Ye,Ce,Qe,de,ye,cr,cn,ur,un,dr,dn,lr,ln,et,At;const yi={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function mi(t){const e={kind:"Result",index:t},r=[],n=s=>r[s]??(r[s]={kind:"NestedResult",index:t,resultIndex:s});return new Proxy(e,{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(s,i){if(i in s)return Reflect.get(s,i);if(i===Symbol.iterator)return function*(){let o=0;for(;;)yield n(o),o++};if(typeof i=="symbol")return;const a=parseInt(i,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function wi(t){const e=ar(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Ue(t){if(!t.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return t.client}const fn=Symbol.for("@mysten/transaction"),bt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},bi=1000n,Si=50,Ti=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function Ei(t){return!!t&&typeof t=="object"&&t[fn]===!0}const Ot=class{constructor(t){Y(this,Oe),Y(this,Ce),Y(this,de),Y(this,cr),Y(this,ur),Y(this,dr),Y(this,lr),Y(this,et),Y(this,b,void 0),Ze(this,b,new re(t?t.blockData:void 0))}static fromKind(t){const e=new Ot;return Ze(e,b,re.fromKindBytes(typeof t=="string"?H(t):t)),e}static from(t){const e=new Ot;return typeof t!="string"||!t.startsWith("{")?Ze(e,b,re.fromBytes(typeof t=="string"?H(t):t)):Ze(e,b,re.restore(JSON.parse(t))),e}setSender(t){E(this,b).sender=t}setSenderIfNotSet(t){E(this,b).sender||(E(this,b).sender=t)}setExpiration(t){E(this,b).expiration=t}setGasPrice(t){E(this,b).gasConfig.price=String(t)}setGasBudget(t){E(this,b).gasConfig.budget=String(t)}setGasOwner(t){E(this,b).gasConfig.owner=t}setGasPayment(t){E(this,b).gasConfig.payment=t.map(e=>Rr(e,ue))}get blockData(){return E(this,b).snapshot()}get[fn](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:Hs((t,e)=>$t(t)?B(this,Oe,Ye).call(this,"pure",{Pure:Array.from(t.toBytes())}):B(this,Oe,Ye).call(this,"pure",t instanceof Uint8Array?$.Pure(t):e?$.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=wr(t),r=E(this,b).inputs.find(n=>n.type==="object"&&e===wr(n.value));return r&&U(r.value,xt)&&"Shared"in r.value.Object&&U(t,xt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??B(this,Oe,Ye).call(this,"object",typeof t=="string"?O(t):t)}objectRef(...t){return this.object($.ObjectRef(...t))}receivingRef(...t){return this.object($.ReceivingRef(...t))}sharedObjectRef(...t){return this.object($.SharedObjectRef(...t))}add(t){const e=E(this,b).transactions.push(t);return mi(e-1)}splitCoins(t,e){return this.add(le.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):B(this,Ce,Qe).call(this,r))))}mergeCoins(t,e){return this.add(le.MergeCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="string"?this.object(r):r)))}publish({modules:t,dependencies:e}){return this.add(le.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(le.Upgrade({modules:t,dependencies:e,packageId:r,ticket:typeof n=="string"?this.object(n):n}))}moveCall({arguments:t,typeArguments:e,target:r}){return this.add(le.MoveCall({arguments:t==null?void 0:t.map(n=>B(this,Ce,Qe).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(le.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):B(this,Ce,Qe).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(le.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(E(this,b).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await B(this,et,At).call(this,t),E(this,b).build({maxSizeBytes:B(this,de,ye).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await B(this,et,At).call(this,t),E(this,b).getDigest()}};let vi=Ot;b=new WeakMap;Oe=new WeakSet;Ye=function(t,e){const r=E(this,b).inputs.length,n=R({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Ne);return E(this,b).inputs.push(n),n};Ce=new WeakSet;Qe=function(t){return $t(t)?this.pure(t):t};de=new WeakSet;ye=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return yi[t];const n=e==null?void 0:e.attributes[bt[t]];if(!n)throw new Error(`Missing expected protocol config: "${bt[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: "${bt[t]}"`);return Number(s)};cr=new WeakSet;cn=function(t){const e=B(this,de,ye).call(this,"maxPureArgumentSize",t);E(this,b).inputs.forEach((r,n)=>{if(U(r.value,at)&&r.value.Pure.length>e)throw new Error(`Input at index ${n} is too large, max pure input size is ${e} bytes, got ${r.value.Pure.length} bytes`)})};ur=new WeakSet;un=async function(t){if(E(this,b).gasConfig.payment){const s=B(this,de,ye).call(this,"maxGasObjects",t);if(E(this,b).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||E(this,b).gasConfig.payment)return;const e=E(this,b).gasConfig.owner??E(this,b).sender,n=(await Ue(t).getCoins({owner:e,coinType:kn})).data.filter(s=>!E(this,b).inputs.find(a=>U(a.value,ot)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,B(this,de,ye).call(this,"maxGasObjects",t)-1).map(s=>({objectId:s.coinObjectId,digest:s.digest,version:s.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");this.setGasPayment(n)};dr=new WeakSet;dn=async function(t){t.onlyTransactionKind||E(this,b).gasConfig.price||this.setGasPrice(await Ue(t).getReferenceGasPrice())};lr=new WeakSet;ln=async function(t){const{inputs:e,transactions:r}=E(this,b),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:O(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!U(e[o.index].value,ot))&&n.push(i),i.kind==="SplitCoins"&&i.amounts.forEach(a=>{if(a.kind==="Input"){const o=e[a.index];typeof o.value!="object"&&(o.value=$.Pure(I.U64.serialize(o.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=$.Pure(I.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,u]=i.target.split("::"),d=await Ue(t).getNormalizedMoveFunction({package:ce(a),module:o,function:u}),g=d.parameters.length>0&&oi(d.parameters.at(-1))?d.parameters.slice(0,d.parameters.length-1):d.parameters;if(g.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");g.forEach((p,y)=>{const k=i.arguments[y];if(k.kind!=="Input")return;const S=e[k.index];if(U(S.value,ot))return;const j=S.value,M=It(p,j);if(M){S.value=$.Pure(j,M);return}if(ar(p)!=null||typeof p=="object"&&"TypeParameter"in p){if(typeof j!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(j,null,2)}`);s.push({id:j,input:S,normalizedType:p});return}throw new Error(`Unknown call arg type ${JSON.stringify(p,null,2)} for value ${JSON.stringify(j,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:f})=>f))],a=Ti(i,Si),o=(await Promise.all(a.map(f=>Ue(t).multiGetObjects({ids:f,options:{showOwner:!0}})))).flat();let u=new Map(i.map((f,g)=>[f,o[g]]));const d=Array.from(u).filter(([f,g])=>g.error).map(([f,g])=>f);if(d.length)throw new Error(`The following input objects are invalid: ${d.join(", ")}`);s.forEach(({id:f,input:g,normalizedType:p})=>{var j;const y=u.get(f),k=(j=y.data)==null?void 0:j.owner,S=k&&typeof k=="object"&&"Shared"in k?k.Shared.initial_shared_version:void 0;if(S){const M=p!=null&&_t(p)==null&&Qr(p)==null,se=Gs(g.value)||M||p!=null&&_t(p)!=null;g.value=$.SharedObjectRef({objectId:f,initialSharedVersion:S,mutable:se})}else p&&wi(p)?g.value=$.ReceivingRef(mr(y)):g.value=$.ObjectRef(mr(y))})}};et=new WeakSet;At=async function(t){if(!t.onlyTransactionKind&&!E(this,b).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([B(this,dr,dn).call(this,t),B(this,lr,ln).call(this,t)]),!t.onlyTransactionKind&&(await B(this,ur,un).call(this,t),!E(this,b).gasConfig.budget)){const e=await Ue(t).dryRunTransactionBlock({transactionBlock:E(this,b).build({maxSizeBytes:B(this,de,ye).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(B(this,de,ye).call(this,"maxTxGas",t)),payment:[]}}})});if(e.effects.status.status!=="success")throw new Error(`Dry run failed, could not automatically determine a budget: ${e.effects.status.error}`,{cause:e});const r=bi*BigInt(this.blockData.gasConfig.price||1n),n=BigInt(e.effects.gasUsed.computationCost)+r,s=n+BigInt(e.effects.gasUsed.storageCost)-BigInt(e.effects.gasUsed.storageRebate);this.setGasBudget(s>n?s:n)}B(this,cr,cn).call(this,t)};const ki=Symbol.for("@mysten/SuiClient");class _i{get[ki](){return!0}constructor(e){this.transport=e.transport??new ds({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,r){return await this.transport.request({method:e,params:r})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!Ke(ce(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach(n=>{if(!n||!Ke(ce(n)))throw new Error(`Invalid Sui Object id ${n}`)}),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,(e.order||"descending")==="descending"]})}async getTransactionBlock(e){if(!gr(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach(n=>{if(!gr(n))throw new Error(`Invalid Transaction digest ${n}`)}),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock(e){return await this.transport.request({method:"sui_executeTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:N(e.transactionBlock),Array.isArray(e.signature)?e.signature:[e.signature],e.options,e.requestType]})}async signAndExecuteTransactionBlock({transactionBlock:e,signer:r,...n}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(r.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:a}=await r.signTransactionBlock(s);return this.executeTransactionBlock({transactionBlock:a,signature:i,...n})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach(r=>{if(!r||!Ke(ce(r)))throw new Error(`Invalid Sui Stake id ${r}`)}),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,(e.order||"descending")==="descending"]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){var n;let r;if(Ei(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=N(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=N(e.transactionBlock);else throw new Error("Unknown transaction block format.");return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,r,(n=e.gasPrice)==null?void 0:n.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:N(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!Ke(ce(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e==null?void 0:e.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e==null?void 0:e.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e==null?void 0:e.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"}),r=ut(e.digest);return me(r.slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames(e){return await this.transport.request({method:"suix_resolveNameServiceNames",params:[e.address,e.cursor,e.limit]})}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e==null?void 0:e.version]})}async waitForTransactionBlock({signal:e,timeout:r=60*1e3,pollInterval:n=2*1e3,...s}){const i=AbortSignal.timeout(r),a=new Promise((o,u)=>{i.addEventListener("abort",()=>u(i.reason))});for(a.catch(()=>{});!i.aborted;){e==null||e.throwIfAborted();try{return await this.getTransactionBlock(s)}catch{await Promise.race([new Promise(u=>setTimeout(u,n)),a])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}class hn extends _n{}const Ct="Sui",gn=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},ga=(t,e)=>{try{return pr(t)===pr(e)}catch{return!1}},pa=t=>(t==null?void 0:t.type)==="created",ya=t=>(t==null?void 0:t.type)==="published";function xi(t){return Array.isArray(t)}function fr(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function Ii(t){return typeof t=="object"&&!xi(t)&&!fr(t)}function ma(t){return typeof t=="object"&&"id"in t}const Ai=16*1024,wa=t=>I.ser("vector<u8>",t,{maxSize:Ai}).toBytes(),ba=async(t,e)=>{const{data:r,error:n}=await t.getObject({id:e,options:{showContent:!0}});if(n)throw new Error("Error getting object: "+n);if(!r||!fr(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return xn(r.content.type)},Oi=async(t,e)=>{if(!oe(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return gn(r)},Sa=async(t,e)=>{let r,n;do{const a=await t.getDynamicFields({parentId:e,cursor:n});r=a.data.find(o=>o.name.type.endsWith("CurrentPackage")),n=a.hasNextPage?a.nextCursor:null}while(n&&!r);if(!r)throw new Error("CurrentPackage not found");const s=await t.getObject({id:r.objectId,options:{showContent:!0}}),i=gn(s);if(!i||!Ii(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!fr(i.value))throw new Error("Unable to get package id");return i.value.fields.package},Ta=async(t,e,r)=>{let n=null,s=null,i=null,a;do{if(i=await t.getOwnedObjects({owner:r,filter:{StructType:`${e}::emitter::EmitterCap`},options:{showContent:!0},cursor:a}),!i||!i.data)throw Error("Failed to get owned objects");for(const o of i.data){if(!o.data)continue;const{version:u,objectId:d}=o.data;(n===null||u<n)&&(n=u,s=d)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},Ea=async(t,e)=>{const r=new vi,[n]=r.publish({modules:t.modules.map(s=>Array.from(In.decode(s))),dependencies:t.dependencies.map(s=>ce(s))});return r.transferObjects([n],r.pure(e)),r},Q=class Q extends An{constructor(e,r){super(e,r??On(e,Q._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 hn(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!Q.isSupportedChain(r))throw new Error(`invalid chain for ${Ct}: ${r}`);return Cn.tokenId(r,jn)}static isNativeTokenId(e,r,n){return!Q.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return Bn(e)===Q._platform}static async getDecimals(e,r,n){if(lt(n))return Mn(Q._platform);const s=new Je(n);try{const a=await Oi(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.toString()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getCoins(e,r,n){let s=[],i=null;const a=new Je(r).toString();do{const o=await e.getCoins({owner:a,coinType:n,cursor:i});s=[...s,...o.data],i=o.hasNextPage?o.nextCursor:null}while(i);return s}static async getBalance(e,r,n,s){if(lt(s)){const{totalBalance:a}=await r.getBalance({owner:n});return BigInt(a)}const{totalBalance:i}=await r.getBalance({owner:n,coinType:s.toString()});return BigInt(i)}static async getBalances(e,r,n,s){return(await Promise.all(s.map(async a=>{const o=await this.getBalance(e,r,n,a);return{[lt(a)?"native":new Je(a).toString()]:o}}))).reduce((a,o)=>Object.assign(a,o),{})}static async sendWait(e,r,n){const s=[];for(const i of n){const a=await r.executeTransactionBlock(i);await r.waitForTransactionBlock({digest:a.digest}),s.push(a.digest)}return s}static async getLatestBlock(e){return Number(await e.getLatestCheckpointSequenceNumber())}static async getLatestFinalizedBlock(e){return this.getLatestBlock(e)}static chainFromChainId(e){const r=Pn(Q._platform,e);if(r===void 0)throw new Error(`Unknown native chain id ${e}`);const[n,s]=r;return[n,s]}static async chainFromRpc(e){const r=await e.call("sui_getChainIdentifier",[]);return this.chainFromChainId(r)}};we(Q,"_platform",Ct);let De=Q;var Ve={};Object.defineProperty(Ve,"__esModule",{value:!0});Ve.bech32m=jt=Ve.bech32=void 0;const ct="qpzry9x8gf2tvdw0s3jn54khce6mua7l",pn={};for(let t=0;t<ct.length;t++){const e=ct.charAt(t);pn[e]=t}function ke(t){const e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Tr(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=ke(e)^n>>5}e=ke(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=ke(e)^n&31}return e}function hr(t,e,r,n){let s=0,i=0;const a=(1<<r)-1,o=[];for(let u=0;u<t.length;++u)for(s=s<<e|t[u],i+=e;i>=r;)i-=r,o.push(s>>i&a);if(n)i>0&&o.push(s<<r-i&a);else{if(i>=e)return"Excess padding";if(s<<r-i&a)return"Non-zero padding"}return o}function Ci(t){return hr(t,8,5,!0)}function ji(t){const e=hr(t,5,8,!1);if(Array.isArray(e))return e}function Bi(t){const e=hr(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function yn(t){let e;t==="bech32"?e=1:e=734539939;function r(a,o,u){if(u=u||90,a.length+7+o.length>u)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let d=Tr(a);if(typeof d=="string")throw new Error(d);let f=a+"1";for(let g=0;g<o.length;++g){const p=o[g];if(p>>5)throw new Error("Non 5-bit word");d=ke(d)^p,f+=ct.charAt(p)}for(let g=0;g<6;++g)d=ke(d);d^=e;for(let g=0;g<6;++g){const p=d>>(5-g)*5&31;f+=ct.charAt(p)}return f}function n(a,o){if(o=o||90,a.length<8)return a+" too short";if(a.length>o)return"Exceeds length limit";const u=a.toLowerCase(),d=a.toUpperCase();if(a!==u&&a!==d)return"Mixed-case string "+a;a=u;const f=a.lastIndexOf("1");if(f===-1)return"No separator character for "+a;if(f===0)return"Missing prefix for "+a;const g=a.slice(0,f),p=a.slice(f+1);if(p.length<6)return"Data too short";let y=Tr(g);if(typeof y=="string")return y;const k=[];for(let S=0;S<p.length;++S){const j=p.charAt(S),M=pn[j];if(M===void 0)return"Unknown character "+j;y=ke(y)^M,!(S+6>=p.length)&&k.push(M)}return y!==e?"Invalid checksum for "+a:{prefix:g,words:k}}function s(a,o){const u=n(a,o);if(typeof u=="object")return u}function i(a,o){const u=n(a,o);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:s,decode:i,encode:r,toWords:Ci,fromWordsUnsafe:ji,fromWords:Bi}}var jt=Ve.bech32=yn("bech32");Ve.bech32m=yn("bech32m");var ze=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))(ze||{});function Mi(t){return[t,0,0]}function mn(t,e){const r=Mi(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const dt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},Pi={ED25519:32,Secp256k1:33,Secp256r1:33},Ri={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function $i(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function Ni(t,e){const r=t.toString(16);return Rn(r.padStart(e*2,"0").slice(-32*2))}function Ui(t,e){const r=Ni(t,e),n=$i(r);return n===-1?new Uint8Array([0]):r.slice(n)}function Di(t,e){const r=Ui(t,32);e==="accounts.google.com"&&(e="https://accounts.google.com");const n=new TextEncoder().encode(e),s=new Uint8Array(2+r.length+n.length);return s.set([dt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),O(_r(Me(s,{dkLen:32})).slice(0,Mt*2))}function Vi(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 zi(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=Vi(n);e=e.concat(s)}return e}function Li(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=zi(t);const n=e%4;if(n!==0)if(n===1)r=r.slice(2);else if(n===2)r=r.slice(4);else throw new Error(`Input (s = ${t}) is not tightly packed because i%4 = 3 (i = ${e}))`);const s=(e+t.length-1)%4;if(s!==3)if(s===2)r=r.slice(0,r.length-2);else if(s===1)r=r.slice(0,r.length-4);else throw new Error(`Input (s = ${t}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${e}))`);if(r.length%8!==0)throw new Error("We should never reach here...");const i=new Uint8Array(Math.floor(r.length/8));let a=0;for(let o=0;o<r.length;o+=8){const u=r.slice(o,o+8),d=parseInt(u.join(""),2);i[a++]=d}return new TextDecoder().decode(i)}function qi(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 Wi(t,e){const r=Li(t.value,t.indexMod4),[n,s]=qi(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const Ki=c.struct("ZkLoginSignature",{inputs:c.struct("ZkLoginSignatureInputs",{proofPoints:c.struct("ZkLoginSignatureInputsProofPoints",{a:c.vector(c.string()),b:c.vector(c.vector(c.string())),c:c.vector(c.string())}),issBase64Details:c.struct("ZkLoginSignatureInputsClaim",{value:c.string(),indexMod4:c.u8()}),headerBase64:c.string(),addressSeed:c.string()}),maxEpoch:c.u64(),userSignature:c.vector(c.u8())});function Fi(t){return Ki.parse(typeof t=="string"?H(t):t)}function Gi({signature:t,signatureScheme:e,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const n=r.toRawBytes(),s=new Uint8Array(1+t.length+n.length);return s.set([dt[e]]),s.set(t,1),s.set(n,1+t.length),N(s)}function Hi(t){const e=H(t),r=Ri[e[0]];switch(r){case"MultiSig":const n=I.MultiSig.parse(e.slice(1));return{serializedSignature:t,signatureScheme:r,multisig:n,bytes:e};case"ZkLogin":const s=e.slice(1),{inputs:i,maxEpoch:a,userSignature:o}=Fi(s),{issBase64Details:u,addressSeed:d}=i,f=Wi(u,"iss"),g=Di(BigInt(d),f);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:f,address:g,addressSeed:BigInt(d)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const p=Pi[r],y=e.slice(1,e.length-p),k=e.slice(1+y.length);return{serializedSignature:t,signatureScheme:r,signature:y,publicKey:k,bytes:e};default:throw new Error("Unsupported signature scheme")}}const tt=32,Zi="suiprivkey";class Ji{async signWithIntent(e,r){const n=mn(r,e),s=Me(n,{dkLen:32});return{signature:Gi({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:N(e)}}async signTransactionBlock(e){return this.signWithIntent(e,ze.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(c.vector(c.u8()).serialize(e).toBytes(),ze.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class Xi extends Ji{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function Yi(t,e){if(t.length!==tt)throw new Error("Invalid bytes length");const r=dt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),jt.encode(Zi,jt.toWords(n))}function Er(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function Qi(t){return Nn(t,"")}function ea(t){return me(Qi(t))}const ta="ed25519 seed",ra=2147483648,na=new RegExp("^m(\\/[0-9]+')+$"),wn=t=>t.replace("'",""),sa=t=>{const r=xr.create(Ir,ta).update(qe(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},ia=({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=xr.create(Ir,e).update(i).digest(),o=a.slice(0,32),u=a.slice(32);return{key:o,chainCode:u}},aa=t=>na.test(t)?!t.split("/").slice(1).map(wn).some(isNaN):!1,vr=(t,e,r=ra)=>{if(!aa(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=sa(e);return t.split("/").slice(1).map(wn).map(a=>parseInt(a,10)).reduce((a,o)=>ia(a,o+r),{key:n,chainCode:s})};function bn(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 oa{equals(e){return bn(this.toRawBytes(),e.toRawBytes())}toBase64(){return N(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return N(e)}verifyWithIntent(e,r,n){const s=mn(n,e),i=Me(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(I.vector(I.u8()).serialize(e).toBytes(),r,ze.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,ze.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return O(_r(Me(this.toSuiBytes(),{dkLen:32})).slice(0,Mt*2))}}const Bt=32;class Sn extends oa{constructor(e){if(super(),typeof e=="string"?this.data=H(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==Bt)throw new Error(`Invalid public key input. Expected ${Bt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return dt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=Hi(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!bn(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return fe.sign.detached.verify(e,n,this.toRawBytes())}}Sn.SIZE=Bt;const kr="m/44'/784'/0'/0'/0'";class Se extends Xi{constructor(e){super(),e?this.keypair=e:this.keypair=fe.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Se(fe.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==tt)throw new Error(`Wrong secretKey size. Expected ${tt} bytes, got ${n}.`);const s=fe.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=fe.sign.detached(a,s.secretKey);if(!fe.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new Se(s)}getPublicKey(){return new Sn(this.keypair.publicKey)}getSecretKey(){return Yi(this.keypair.secretKey.slice(0,tt),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return fe.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=kr),!Er(r))throw new Error("Invalid derivation path");const{key:n}=vr(r,ea(e));return Se.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=kr),!Er(r))throw new Error("Invalid derivation path");const{key:n}=vr(r,e);return Se.fromSecretKey(n)}}async function ca(t,e){const[,r]=await De.chainFromRpc(t);return new ua(r,t,Se.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class ua{constructor(e,r,n,s){we(this,"_chain");we(this,"_client");we(this,"_signer");we(this,"_debug");this._chain=e,this._client=r,this._signer=n,this._debug=s}chain(){return this._chain}address(){return this._signer.toSuiAddress()}async signAndSend(e){const r=[];for(const n of e){const{description:s,transaction:i}=n;this._debug&&console.log(`Signing ${s} for ${this.address()}`);try{const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}catch(a){throw a}}return r}}const da={Address:Je,Platform:De,getSigner:ca,protocols:{WormholeCore:()=>ft(()=>import("./index-D7CrUmY0.js"),__vite__mapDeps([0,1,2,3])),TokenBridge:()=>ft(()=>import("./index-Dwk61kXP.js"),__vite__mapDeps([4,1,2,0,3,5])),CircleBridge:()=>ft(()=>import("./index-DtASoatx.js"),__vite__mapDeps([6,1,2,5,3]))},getChain:(t,e,r)=>new hn(e,new De(t,$n(t,Ct,{[e]:r})))},va=Object.freeze(Object.defineProperty({__proto__:null,default:da},Symbol.toStringTag,{value:"Module"}));export{De as S,gn as a,fr as b,ya as c,pa as d,ga as e,Ta as f,Oi as g,Sa as h,Ii as i,ba as j,ma as k,Ea as p,va as s,wa as u};
|
|
6
|
+
Received: "${JSON.stringify(u)}"`);let g=Object.keys(u)[0];if(g===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let p=n.indexOf(g);if(p===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${g}"`);let y=n[p],k=r[y];if(o.write8(p),k===null)return o;let S=i.indexOf(k),B=S===-1?k:d[S];{let{name:M,params:se}=this.parseTypeName(B);return this.getTypeInterface(M)._encodeRaw.call(this,o,u[g],se,f)}},function(o,u,d){let f=o.readULEB(),g=n[f],p=r[g];if(f===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${f}"`);if(p===null)return{[g]:!0};let y=i.indexOf(p),k=y===-1?p:u[y];{let{name:S,params:B}=this.parseTypeName(k);return{[g]:this.getTypeInterface(S)._decodeRaw.call(this,o,B,d)}}})}getTypeInterface(t){let e=this.types.get(t);if(typeof e=="string"){let r=[];for(;typeof e=="string";){if(r.includes(e))throw new Error(`Recursive definition found: ${r.join(" -> ")} -> ${e}`);r.push(e),e=this.types.get(e)}}if(e===void 0)throw new Error(`Type ${t} is not registered`);return e}parseTypeName(t){if(Array.isArray(t)){let[o,...u]=t;return{name:o,params:u}}if(typeof t!="string")throw new Error(`Illegal type passed as a name of the type: ${t}`);let[e,r]=this.schema.genericSeparators||["<",">"],n=t.indexOf(e),s=Array.from(t).reverse().indexOf(r);if(n===-1&&s===-1)return{name:t,params:[]};if(n===-1||s===-1)throw new Error(`Unclosed generic in name '${t}'`);let i=t.slice(0,n),a=Or(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let _=Ie;_.U8="u8";_.U16="u16";_.U32="u32";_.U64="u64";_.U128="u128";_.U256="u256";_.BOOL="bool";_.VECTOR="vector";_.ADDRESS="address";_.STRING="string";_.HEX="hex-string";_.BASE58="base58-string";_.BASE64="base64-string";function Fn(t){t.registerType(_.U8,function(e,r){return e.write8(r)},function(e){return e.read8()},e=>e<256),t.registerType(_.U16,function(e,r){return e.write16(r)},function(e){return e.read16()},e=>e<65536),t.registerType(_.U32,function(e,r){return e.write32(r)},function(e){return e.read32()},e=>e<=4294967296n),t.registerType(_.U64,function(e,r){return e.write64(r)},function(e){return e.read64()}),t.registerType(_.U128,function(e,r){return e.write128(r)},function(e){return e.read128()}),t.registerType(_.U256,function(e,r){return e.write256(r)},function(e){return e.read256()}),t.registerType(_.BOOL,function(e,r){return e.write8(r)},function(e){return e.read8().toString(10)==="1"}),t.registerType(_.STRING,function(e,r){return e.writeVec(Array.from(r),(n,s)=>n.write8(s.charCodeAt(0)))},function(e){return e.readVec(r=>r.read8()).map(r=>String.fromCharCode(Number(r))).join("")},e=>!0),t.registerType(_.HEX,function(e,r){return e.writeVec(Array.from(qe(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return me(new Uint8Array(r))}),t.registerType(_.BASE58,function(e,r){return e.writeVec(Array.from(ut(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return Le(new Uint8Array(r))}),t.registerType(_.BASE64,function(e,r){return e.writeVec(Array.from(H(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return N(new Uint8Array(r))})}function Gn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Kn,addressEncoding:"hex"}}class Hn extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:o}=e,u=o.length===0?s:`At path: ${o.join(".")} -- ${s}`;super(i??u),i!=null&&(this.cause=u),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Zn(t){return z(t)&&typeof t[Symbol.iterator]=="function"}function z(t){return typeof t=="object"&&t!=null}function L(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:o,message:u=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${L(n)}\``}=t;return{value:n,type:a,refinement:o,key:s[s.length-1],path:s,branch:i,...t,message:u}}function*yr(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,o={path:n,branch:s};if(i&&(t=e.coercer(t,o),a&&e.type!=="type"&&z(e.schema)&&z(t)&&!Array.isArray(t)))for(const d in t)e.schema[d]===void 0&&delete t[d];let u="valid";for(const d of e.validator(t,o))d.explanation=r.message,u="not_valid",yield[d,void 0];for(let[d,f,g]of e.entries(t,o)){const p=Nt(f,g,{path:d===void 0?n:[...n,d],branch:d===void 0?s:[...s,f],coerce:i,mask:a,message:r.message});for(const y of p)y[0]?(u=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):i&&(f=y[1],d===void 0?t=f:t instanceof Map?t.set(d,f):t instanceof Set?t.add(f):z(t)&&(f!==void 0||d in t)&&(t[d]=f))}if(u!=="not_valid")for(const d of e.refiner(t,o))d.explanation=r.message,u="not_refined",yield[d,void 0];u==="valid"&&(yield[void 0,t])}class X{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=u=>u,entries:o=function*(){}}=e;this.type=r,this.schema=n,this.entries=o,this.coercer=a,s?this.validator=(u,d)=>{const f=s(u,d);return yr(f,d,this,u)}:this.validator=()=>[],i?this.refiner=(u,d)=>{const f=i(u,d);return yr(f,d,this,u)}:this.refiner=()=>[]}assert(e,r){return St(e,this,r)}create(e,r){return Pr(e,this,r)}is(e){return U(e,this)}mask(e,r){return Rr(e,this,r)}validate(e,r={}){return We(e,this,r)}}function St(t,e,r){const n=We(t,e,{message:r});if(n[0])throw n[0]}function Pr(t,e,r){const n=We(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Rr(t,e,r){const n=We(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function U(t,e){return!We(t,e)[0]}function We(t,e,r={}){const n=Nt(t,e,r),s=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 Pe(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?Qn(n):h(n)}function D(t,e){return new X({type:t,schema:null,validator:e})}function Tt(){return D("any",()=>!0)}function T(t){return new X({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${L(e)}`}})}function Yn(){return D("bigint",t=>typeof t=="bigint")}function P(){return D("boolean",t=>typeof t=="boolean")}function J(){return D("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${L(t)}`)}function w(t){const e=L(t),r=typeof t;return new X({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${L(n)}`}})}function $r(){return D("never",()=>!1)}function A(t){return new X({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function pe(){return D("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${L(t)}`)}function h(t){const e=t?Object.keys(t):[],r=$r();return new X({type:"object",schema:t||null,*entries(n){if(t&&z(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 z(n)||`Expected an object, but received: ${L(n)}`},coercer(n){return z(n)?{...n}:n}})}function m(t){return new X({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Z(t,e){return new X({type:"record",schema:null,*entries(r){if(z(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return z(r)||`Expected an object, but received: ${L(r)}`}})}function l(){return D("string",t=>typeof t=="string"||`Expected a string, but received: ${L(t)}`)}function Nr(t){const e=$r();return new X({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let s=0;s<n;s++)yield[s,r[s],t[s]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${L(r)}`}})}function Qn(t){const e=Object.keys(t);return new X({type:"type",schema:t,*entries(r){if(z(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return z(r)||`Expected an object, but received: ${L(r)}`},coercer(r){return z(r)?{...r}:r}})}function C(t){const e=t.map(r=>r.type).join(" | ");return new X({type:"union",schema:null,coercer(r){for(const n of t){const[s,i]=n.validate(r,{coerce:!0});if(!s)return i}return r},validator(r,n){const s=[];for(const i of t){const[...a]=Nt(r,i,n),[o]=a;if(o[0])for(const[u]of a)u&&s.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${L(r)}`,...s]}})}function Ur(){return D("unknown",()=>!0)}const es="0.50.1",ts="1.19.0",rs={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class Dr extends Error{}class Vr extends Dr{constructor(e,r){super(e),this.code=r,this.type=rs[r]??"ServerError"}}class ns extends Dr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var Ut=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},x=(t,e,r)=>(Ut(t,e,"read from private field"),r?r.call(t):e.get(t)),ie=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Te=(t,e,r,n)=>(Ut(t,e,"write to private field"),e.set(t,r),r),ss=(t,e,r,n)=>({set _(s){Te(t,e,s)},get _(){return x(t,e,n)}}),zr=(t,e,r)=>(Ut(t,e,"access private method"),r),he,Be,ee,ge,Re,Ee,Et,Lr,Dt,qr;function is(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const as={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class os{constructor(e,r={}){if(ie(this,Et),ie(this,Dt),ie(this,he,0),ie(this,Be,0),ie(this,ee,null),ie(this,ge,null),ie(this,Re,new Set),ie(this,Ee,new Map),this.endpoint=e,this.options={...as,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=is(this.endpoint))}async makeRequest(e,r){const n=await zr(this,Et,Lr).call(this);return new Promise((s,i)=>{Te(this,he,x(this,he)+1),x(this,Ee).set(x(this,he),{resolve:s,reject:i,timeout:setTimeout(()=>{x(this,Ee).delete(x(this,he)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:x(this,he),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new Vr(s.message,s.code);return i})}async subscribe(e){const r=new cs(e);return x(this,Re).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}he=new WeakMap;Be=new WeakMap;ee=new WeakMap;ge=new WeakMap;Re=new WeakMap;Ee=new WeakMap;Et=new WeakSet;Lr=function(){return x(this,ge)?x(this,ge):(Te(this,ge,new Promise(t=>{var e;(e=x(this,ee))==null||e.close(),Te(this,ee,new this.options.WebSocketConstructor(this.endpoint)),x(this,ee).addEventListener("open",()=>{Te(this,Be,0),t(x(this,ee))}),x(this,ee).addEventListener("close",()=>{ss(this,Be)._++,x(this,Be)<=this.options.maxReconnects&&setTimeout(()=>{zr(this,Dt,qr).call(this)},this.options.reconnectTimeout)}),x(this,ee).addEventListener("message",({data:r})=>{let n;try{n=JSON.parse(r)}catch(s){console.error(new Error(`Failed to parse RPC message: ${r}`,{cause:s}));return}if("id"in n&&n.id!=null&&x(this,Ee).has(n.id)){const{resolve:s,timeout:i}=x(this,Ee).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;x(this,Re).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),x(this,ge))};Dt=new WeakSet;qr=async function(){var t;return(t=x(this,ee))==null||t.close(),Te(this,ge,null),Promise.allSettled([...x(this,Re)].map(e=>e.subscribe(this)))};class cs{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 Vt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},V=(t,e,r)=>(Vt(t,e,"read from private field"),r?r.call(t):e.get(t)),Fe=(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)},vt=(t,e,r,n)=>(Vt(t,e,"write to private field"),e.set(t,r),r),us=(t,e,r)=>(Vt(t,e,"access private method"),r),Ae,K,je,kt,Wr;class ds{constructor(e){Fe(this,kt),Fe(this,Ae,0),Fe(this,K,void 0),Fe(this,je,void 0),vt(this,K,e)}fetch(e,r){const n=V(this,K).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;vt(this,Ae,V(this,Ae)+1);const r=await this.fetch(((s=V(this,K).rpc)==null?void 0:s.url)??V(this,K).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":es,"Client-Target-Api-Version":ts,...(i=V(this,K).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:V(this,Ae),method:e.method,params:e.params})});if(!r.ok)throw new ns(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new Vr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await us(this,kt,Wr).call(this).subscribe(e);return async()=>!!await r()}}Ae=new WeakMap;K=new WeakMap;je=new WeakMap;kt=new WeakSet;Wr=function(){var t;if(!V(this,je)){const e=V(this,K).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.");vt(this,je,new os(((t=V(this,K).websocket)==null?void 0:t.url)??V(this,K).url,{WebSocketConstructor:e,...V(this,K).websocket}))}return V(this,je)};const ls=/^vector<(.+)>$/,fs=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class te{static parseFromStr(e,r=!1){if(e==="address")return{address:null};if(e==="bool")return{bool:null};if(e==="u8")return{u8:null};if(e==="u16")return{u16:null};if(e==="u32")return{u32:null};if(e==="u64")return{u64:null};if(e==="u128")return{u128:null};if(e==="u256")return{u256:null};if(e==="signer")return{signer:null};const n=e.match(ls);if(n)return{vector:te.parseFromStr(n[1],r)};const s=e.match(fs);if(s)return{struct:{address:r?O(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:te.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return Or(e).map(n=>te.parseFromStr(n,r))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${te.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(te.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const v=new _({...Gn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function Kr(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function hs(t){return c.enum("Option",{None:null,Some:t})}function zt(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const G=c.bytes(Mt).transform({input:t=>typeof t=="string"?qe(O(t)):t,output:t=>O(me(t))}),Lt=c.vector(c.u8()).transform({name:"ObjectDigest",input:t=>ut(t),output:t=>Le(new Uint8Array(t))}),$e=c.struct("SuiObjectRef",{objectId:G,version:c.u64(),digest:Lt}),qt=c.struct("SharedObjectRef",{objectId:G,initialSharedVersion:c.u64(),mutable:c.bool()}),it=c.enum("ObjectArg",{ImmOrOwned:$e,Shared:qt,Receiving:$e}),Wt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:it,ObjVec:c.vector(it)}),_e=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>_e),struct:c.lazy(()=>Jt),u16:null,u32:null,u256:null}),q=zt(c.enum("Argument",{GasCoin:null,Input:c.struct("Input",{index:c.u16()}),Result:c.struct("Result",{index:c.u16()}),NestedResult:c.struct("NestedResult",{index:c.u16(),resultIndex:c.u16()})})),Kt=c.struct("ProgrammableMoveCall",{package:G,module:c.string(),function:c.string(),type_arguments:c.vector(_e),arguments:c.vector(q)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>te.parseFromStr(i,!0));return{package:O(e),module:r,function:n,type_arguments:s,arguments:t.arguments}},output:t=>({target:[t.package,t.module,t.function].join("::"),arguments:t.arguments,typeArguments:t.type_arguments.map(te.tagToString)})}),Ft=zt(c.enum("Transaction",{MoveCall:Kt,TransferObjects:c.struct("TransferObjects",{objects:c.vector(q),address:q}),SplitCoins:c.struct("SplitCoins",{coin:q,amounts:c.vector(q)}),MergeCoins:c.struct("MergeCoins",{destination:q,sources:c.vector(q)}),Publish:c.struct("Publish",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G)}),MakeMoveVec:c.struct("MakeMoveVec",{type:hs(_e),objects:c.vector(q)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G),packageId:G,ticket:q})})),Gt=c.struct("ProgrammableTransaction",{inputs:c.vector(Wt),transactions:c.vector(Ft)}),Ht=c.enum("TransactionKind",{ProgrammableTransaction:Gt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Zt=c.enum("TransactionExpiration",{None:null,Epoch:Kr()}),Jt=c.struct("StructTag",{address:G,module:c.string(),name:c.string(),typeParams:c.vector(_e)}),Xt=c.struct("GasData",{payment:c.vector($e),owner:G,price:c.u64(),budget:c.u64()}),Yt=c.struct("TransactionDataV1",{kind:Ht,sender:G,gasData:Xt,expiration:Zt}),Qt=c.enum("TransactionData",{V1:Yt}),gs=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),ps=c.enum("IntentVersion",{V0:null}),ys=c.enum("AppId",{Sui:null}),ms=c.struct("Intent",{scope:gs,version:ps,appId:ys}),ws=c.generic(["T"],t=>c.struct("IntentMessage<T>",{intent:ms,value:t})),er=c.enum("CompressedSignature",{ED25519:c.fixedArray(64,c.u8()),Secp256k1:c.fixedArray(64,c.u8()),Secp256r1:c.fixedArray(64,c.u8()),ZkLogin:c.vector(c.u8())}),tr=c.enum("PublicKey",{ED25519:c.fixedArray(32,c.u8()),Secp256k1:c.fixedArray(33,c.u8()),Secp256r1:c.fixedArray(33,c.u8()),ZkLogin:c.vector(c.u8())}),rr=c.struct("MultiSigPkMap",{pubKey:tr,weight:c.u8()}),nr=c.struct("MultiSigPublicKey",{pk_map:c.vector(rr),threshold:c.u16()}),Fr=c.struct("MultiSig",{sigs:c.vector(er),bitmap:c.u16(),multisig_pk:nr}),bs=c.vector(c.u8()).transform({input:t=>typeof t=="string"?H(t):t,output:t=>N(new Uint8Array(t))}),Gr=c.struct("SenderSignedTransaction",{intentMessage:ws(Qt),txSignatures:c.vector(bs)}),Hr=c.vector(Gr,{name:"SenderSignedData"}),I={...c,U8:c.u8(),U16:c.u16(),U32:c.u32(),U64:c.u64(),U128:c.u128(),U256:c.u256(),ULEB128:c.uleb128(),Bool:c.bool(),String:c.string(),Address:G,Argument:q,CallArg:Wt,CompressedSignature:er,GasData:Xt,MultiSig:Fr,MultiSigPkMap:rr,MultiSigPublicKey:nr,ObjectArg:it,ObjectDigest:Lt,ProgrammableMoveCall:Kt,ProgrammableTransaction:Gt,PublicKey:tr,SenderSignedData:Hr,SenderSignedTransaction:Gr,SharedObjectRef:qt,StructTag:Jt,SuiObjectRef:$e,Transaction:Ft,TransactionData:Qt,TransactionDataV1:Yt,TransactionExpiration:Zt,TransactionKind:Ht,TypeTag:_e,ser:v.ser.bind(v),de:v.de.bind(v),getTypeInterface:v.getTypeInterface.bind(v),hasType:v.hasType.bind(v),parseTypeName:v.parseTypeName.bind(v),registerAddressType:v.registerAddressType.bind(v),registerAlias:v.registerAlias.bind(v),registerBcsType:v.registerBcsType.bind(v),registerEnumType:v.registerEnumType.bind(v),registerStructType:v.registerStructType.bind(v),registerType:v.registerType.bind(v),types:v.types};v.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));v.registerBcsType("unsafe_u64",()=>Kr());v.registerBcsType("enumKind",t=>zt(t));[G,q,Wt,er,Xt,Fr,rr,nr,it,Lt,Kt,Gt,tr,Hr,qt,Jt,$e,Ft,Qt,Yt,Zt,Ht,_e].forEach(t=>{v.registerBcsType(t.name,()=>t)});const sr=C([h({AddressOwner:l()}),h({ObjectOwner:l()}),h({Shared:h({initial_shared_version:A(l())})}),w("Immutable")]);D("SuiJsonValue",()=>!0);const Ss=C([h({u32:l()}),h({u64:l()}),h({f64:l()})]);h({attributes:Z(l(),A(Ss)),featureFlags:Z(l(),P()),maxSupportedProtocolVersion:l(),minSupportedProtocolVersion:l(),protocolVersion:l()});C([l(),w("package")]);const ue=h({digest:l(),objectId:l(),version:C([pe(),l(),Yn()])});h({owner:sr,reference:ue});h({objectId:l(),sequenceNumber:l()});h({payment:T(ue),owner:l(),price:l(),budget:l()});const Ts=Pe(ue,h({type:l(),owner:sr,previousTransaction:l()})),Es=Z(l(),Tt()),vs=Z(l(),Ur()),ks=h({type:l(),fields:Es,hasPublicTransfer:P()}),_s=h({disassembled:vs}),xs=C([Pe(ks,h({dataType:w("moveObject")})),Pe(_s,h({dataType:w("package")}))]),Is=h({type:l(),hasPublicTransfer:P(),version:l(),bcsBytes:l()}),As=h({id:l(),moduleMap:Z(l(),l())}),Os=C([Pe(Is,h({dataType:w("moveObject")})),Pe(As,h({dataType:w("package")}))]);BigInt(1e9);const Zr=h({code:l(),error:m(l()),object_id:m(l()),parent_object_id:m(l()),version:m(l()),digest:m(l())}),Cs=h({data:A(m(Z(l(),l()))),error:A(m(Zr))}),Bs=C([Cs,m(Z(l(),l()))]),Jr=h({objectId:l(),version:l(),digest:l(),type:A(m(l())),content:A(m(xs)),bcs:A(m(Os)),owner:A(m(sr)),previousTransaction:A(m(l())),storageRebate:A(m(l())),display:A(m(Bs))});h({showType:A(m(P())),showContent:A(m(P())),showBcs:A(m(P())),showOwner:A(m(P())),showPreviousTransaction:A(m(P())),showStorageRebate:A(m(P())),showDisplay:A(m(P()))});C([w("Exists"),w("notExists"),w("Deleted")]);T(Ts);const js=h({data:A(m(Jr)),error:A(m(Zr))});function Ms(t){return t.data}function Ps(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 mr(t){if("reference"in t)return t.reference;const e=Ms(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:Ps(t)}h({objectId:l(),atCheckpoint:m(pe())});h({data:T(js),nextCursor:m(A(l())),hasNextPage:P()});C([h({details:Jr,status:w("VersionFound")}),h({details:l(),status:w("ObjectNotExists")}),h({details:ue,status:w("ObjectDeleted")}),h({details:Nr([l(),pe()]),status:w("VersionNotFound")}),h({details:h({asked_version:pe(),latest_version:pe(),object_id:l()}),status:w("VersionTooHigh")})]);const Rs=C([l(),h({Object:l()})]);T(Rs);const $s=h({address:l(),name:l()}),Ns=C([w("Private"),w("Public"),w("Friend")]),ir=h({abilities:T(l())}),Us=h({constraints:ir,isPhantom:P()}),Ds=h({TypeParameter:pe()}),mt=Nr([h({module:l(),package:l(),function:l()}),l()]);h({rank3Days:T(mt),rank7Days:T(mt),rank30Days:T(mt)});function Xr(t){if(!t)return!1;if(typeof t=="string"||U(t,Ds)||Yr(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(U(e.Reference,ve)||U(e.MutableReference,ve)||U(e.Vector,ve))}const ve=D("SuiMoveNormalizedType",Xr);function Yr(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=>Xr(n)))}D("SuiMoveNormalizedStructType",Yr);const Vs=h({visibility:Ns,isEntry:P(),typeParameters:T(ir),parameters:T(ve),return:T(ve)}),zs=h({name:l(),type:ve}),Ls=h({abilities:ir,typeParameters:T(Us),fields:T(zs)}),qs=h({fileFormatVersion:pe(),address:l(),name:l(),friends:T($s),structs:Z(l(),Ls),exposedFunctions:Z(l(),Vs)});Z(l(),qs);function _t(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function Qr(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function ar(t){if(typeof t=="object"&&"Struct"in t)return t;const e=Qr(t),r=_t(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const Ws=C([h({ImmOrOwned:ue}),h({Shared:h({objectId:l(),initialSharedVersion:C([J(),l()]),mutable:P()})}),h({Receiving:ue})]),at=h({Pure:T(J())}),xt=h({Object:Ws}),ot=C([at,xt]);function Ks(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:$t(t)?t.toBytes():I.ser(e,t,{maxSize:1/0}).toBytes())}}const $={Pure:Ks,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:O(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:O(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:O(t)}}}}};function wr(t){return typeof t=="string"?O(t):"ImmOrOwned"in t.Object?O(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?O(t.Object.Receiving.objectId):O(t.Object.Shared.objectId)}function Fs(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function Gs(t){var e;return((e=Fs(t))==null?void 0:e.mutable)??!1}function Hs(t){function e(r,n){return t(r,n)}return e.u8=r=>t(I.U8.serialize(r)),e.u16=r=>t(I.U16.serialize(r)),e.u32=r=>t(I.U32.serialize(r)),e.u64=r=>t(I.U64.serialize(r)),e.u128=r=>t(I.U128.serialize(r)),e.u256=r=>t(I.U256.serialize(r)),e.bool=r=>t(I.Bool.serialize(r)),e.string=r=>t(I.String.serialize(r)),e.address=r=>t(I.Address.serialize(r)),e.id=e.address,e}const Zs="object",Js="ID",Xs="ascii",Ys="String",Qs="string",ei="String",ti="option",ri="Option",ni={address:vn,module:Zs,name:Js},si={address:Pt,module:Xs,name:Ys},ii={address:Pt,module:Qs,name:ei},ai={address:Pt,module:ti,name:ri},Ge=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function oi(t){var r;const e=(r=ar(t))==null?void 0:r.Struct;return(e==null?void 0:e.address)==="0x2"&&(e==null?void 0:e.module)==="tx_context"&&(e==null?void 0:e.name)==="TxContext"}function wt(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const ci=["Address","Bool","U8","U16","U32","U64","U128","U256"];function It(t,e){if(typeof t=="string"&&ci.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])wt("number",e);else if(t==="Bool")wt("boolean",e);else if(t==="Address"&&(wt("string",e),e&&!oe(e)))throw new Error("Invalid Sui Address");return t.toLowerCase()}else if(typeof t=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(t,null,2)}`);if("Vector"in t){if((e===void 0||typeof e=="string")&&t.Vector==="U8")return"string";if(e!==void 0&&!Array.isArray(e))throw new Error(`Expect ${e} to be a array, received ${typeof e}`);const r=It(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(Ge(t.Struct,si))return"string";if(Ge(t.Struct,ii))return"utf8string";if(Ge(t.Struct,ni))return"address";if(Ge(t.Struct,ai)){const r={Vector:t.Struct.typeArguments[0]};return It(r,e)}}}function ui(t,e){const r=Array.from(`${t}::`).map(s=>s.charCodeAt(0)),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),Me(n,{dkLen:32})}function R(t,e){return Pr(t,e)}const di=t=>C([h({None:C([w(!0),w(null)])}),h({Some:t})]),Ne=C([h({kind:w("Input"),index:J(),value:m(Tt()),type:m(w("object"))}),h({kind:w("Input"),index:J(),value:m(Tt()),type:w("pure")})]),li=[Ne,h({kind:w("GasCoin")}),h({kind:w("Result"),index:J()}),h({kind:w("NestedResult"),index:J(),resultIndex:J()})],ne=C([...li]),en=h({kind:w("MoveCall"),target:D("target",l().validator),typeArguments:T(l()),arguments:T(ne)}),tn=h({kind:w("TransferObjects"),objects:T(ne),address:ne}),rn=h({kind:w("SplitCoins"),coin:ne,amounts:T(ne)}),nn=h({kind:w("MergeCoins"),destination:ne,sources:T(ne)}),sn=h({kind:w("MakeMoveVec"),type:m(di(Z(l(),Ur()))),objects:T(ne)}),an=h({kind:w("Publish"),modules:T(T(J())),dependencies:T(l())}),on=h({kind:w("Upgrade"),modules:T(T(J())),dependencies:T(l()),packageId:l(),ticket:ne}),fi=[en,tn,rn,nn,an,on,sn],hi=C([...fi]),le={MoveCall(t){return R({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},en)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=$.Pure(I.Address.serialize(e.value))),R({kind:"TransferObjects",objects:t,address:e},tn)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=$.Pure(I.U64.serialize(r.value)))}),R({kind:"SplitCoins",coin:t,amounts:e},rn)},MergeCoins(t,e){return R({kind:"MergeCoins",destination:t,sources:e},nn)},Publish({modules:t,dependencies:e}){return R({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(H(r)):r),dependencies:e.map(r=>ce(r))},an)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return R({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(H(s)):s),dependencies:e.map(s=>ce(s)),packageId:r,ticket:n},on)},MakeMoveVec({type:t,objects:e}){return R({kind:"MakeMoveVec",type:t?{Some:te.parseFromStr(t)}:{None:null},objects:e},sn)}},gi=m(A(C([h({Epoch:J()}),h({None:C([w(!0),w(null)])})]))),br=D("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),pi=h({budget:m(br),price:m(br),payment:m(T(ue)),owner:m(l())}),He=h({version:w(1),sender:m(l()),expiration:gi,gasConfig:pi,inputs:T(Ne),transactions:T(hi)});function Sr(t){return O(t).replace("0x","")}class re{constructor(e){this.version=1,this.sender=e==null?void 0:e.sender,this.expiration=e==null?void 0:e.expiration,this.gasConfig=(e==null?void 0:e.gasConfig)??{},this.inputs=(e==null?void 0:e.inputs)??[],this.transactions=(e==null?void 0:e.transactions)??[]}static fromKindBytes(e){const r=I.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=R({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>R({kind:"Input",value:i,index:a,type:U(i,at)?"pure":"object"},Ne)),transactions:n.transactions},He);return re.restore(s)}static fromBytes(e){var a;const r=I.TransactionData.parse(e),n=r==null?void 0:r.V1,s="ProgrammableTransaction"in n.kind?(a=n==null?void 0:n.kind)==null?void 0:a.ProgrammableTransaction:null;if(!n||!s)throw new Error("Unable to deserialize from bytes.");const i=R({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((o,u)=>R({kind:"Input",value:o,index:u,type:U(o,at)?"pure":"object"},Ne)),transactions:s.transactions},He);return re.restore(i)}static restore(e){St(e,He);const r=new re;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=ui("TransactionData",e);return Le(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(f=>(St(f.value,ot),f.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return I.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,o=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const d={sender:Sr(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:Sr(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return I.TransactionData.serialize({V1:d},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return re.getDigestFromBytes(e)}snapshot(){return R(this,He)}}var or=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},E=(t,e,r)=>(or(t,e,"read from private field"),r?r.call(t):e.get(t)),Y=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Ze=(t,e,r,n)=>(or(t,e,"write to private field"),e.set(t,r),r),j=(t,e,r)=>(or(t,e,"access private method"),r),b,Oe,Ye,Ce,Qe,de,ye,cr,cn,ur,un,dr,dn,lr,ln,et,At;const yi={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function mi(t){const e={kind:"Result",index:t},r=[],n=s=>r[s]??(r[s]={kind:"NestedResult",index:t,resultIndex:s});return new Proxy(e,{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(s,i){if(i in s)return Reflect.get(s,i);if(i===Symbol.iterator)return function*(){let o=0;for(;;)yield n(o),o++};if(typeof i=="symbol")return;const a=parseInt(i,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function wi(t){const e=ar(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Ue(t){if(!t.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return t.client}const fn=Symbol.for("@mysten/transaction"),bt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},bi=1000n,Si=50,Ti=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function Ei(t){return!!t&&typeof t=="object"&&t[fn]===!0}const Ot=class{constructor(t){Y(this,Oe),Y(this,Ce),Y(this,de),Y(this,cr),Y(this,ur),Y(this,dr),Y(this,lr),Y(this,et),Y(this,b,void 0),Ze(this,b,new re(t?t.blockData:void 0))}static fromKind(t){const e=new Ot;return Ze(e,b,re.fromKindBytes(typeof t=="string"?H(t):t)),e}static from(t){const e=new Ot;return typeof t!="string"||!t.startsWith("{")?Ze(e,b,re.fromBytes(typeof t=="string"?H(t):t)):Ze(e,b,re.restore(JSON.parse(t))),e}setSender(t){E(this,b).sender=t}setSenderIfNotSet(t){E(this,b).sender||(E(this,b).sender=t)}setExpiration(t){E(this,b).expiration=t}setGasPrice(t){E(this,b).gasConfig.price=String(t)}setGasBudget(t){E(this,b).gasConfig.budget=String(t)}setGasOwner(t){E(this,b).gasConfig.owner=t}setGasPayment(t){E(this,b).gasConfig.payment=t.map(e=>Rr(e,ue))}get blockData(){return E(this,b).snapshot()}get[fn](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:Hs((t,e)=>$t(t)?j(this,Oe,Ye).call(this,"pure",{Pure:Array.from(t.toBytes())}):j(this,Oe,Ye).call(this,"pure",t instanceof Uint8Array?$.Pure(t):e?$.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=wr(t),r=E(this,b).inputs.find(n=>n.type==="object"&&e===wr(n.value));return r&&U(r.value,xt)&&"Shared"in r.value.Object&&U(t,xt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??j(this,Oe,Ye).call(this,"object",typeof t=="string"?O(t):t)}objectRef(...t){return this.object($.ObjectRef(...t))}receivingRef(...t){return this.object($.ReceivingRef(...t))}sharedObjectRef(...t){return this.object($.SharedObjectRef(...t))}add(t){const e=E(this,b).transactions.push(t);return mi(e-1)}splitCoins(t,e){return this.add(le.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):j(this,Ce,Qe).call(this,r))))}mergeCoins(t,e){return this.add(le.MergeCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="string"?this.object(r):r)))}publish({modules:t,dependencies:e}){return this.add(le.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(le.Upgrade({modules:t,dependencies:e,packageId:r,ticket:typeof n=="string"?this.object(n):n}))}moveCall({arguments:t,typeArguments:e,target:r}){return this.add(le.MoveCall({arguments:t==null?void 0:t.map(n=>j(this,Ce,Qe).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(le.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):j(this,Ce,Qe).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(le.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(E(this,b).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await j(this,et,At).call(this,t),E(this,b).build({maxSizeBytes:j(this,de,ye).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await j(this,et,At).call(this,t),E(this,b).getDigest()}};let vi=Ot;b=new WeakMap;Oe=new WeakSet;Ye=function(t,e){const r=E(this,b).inputs.length,n=R({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Ne);return E(this,b).inputs.push(n),n};Ce=new WeakSet;Qe=function(t){return $t(t)?this.pure(t):t};de=new WeakSet;ye=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return yi[t];const n=e==null?void 0:e.attributes[bt[t]];if(!n)throw new Error(`Missing expected protocol config: "${bt[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: "${bt[t]}"`);return Number(s)};cr=new WeakSet;cn=function(t){const e=j(this,de,ye).call(this,"maxPureArgumentSize",t);E(this,b).inputs.forEach((r,n)=>{if(U(r.value,at)&&r.value.Pure.length>e)throw new Error(`Input at index ${n} is too large, max pure input size is ${e} bytes, got ${r.value.Pure.length} bytes`)})};ur=new WeakSet;un=async function(t){if(E(this,b).gasConfig.payment){const s=j(this,de,ye).call(this,"maxGasObjects",t);if(E(this,b).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||E(this,b).gasConfig.payment)return;const e=E(this,b).gasConfig.owner??E(this,b).sender,n=(await Ue(t).getCoins({owner:e,coinType:kn})).data.filter(s=>!E(this,b).inputs.find(a=>U(a.value,ot)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,j(this,de,ye).call(this,"maxGasObjects",t)-1).map(s=>({objectId:s.coinObjectId,digest:s.digest,version:s.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");this.setGasPayment(n)};dr=new WeakSet;dn=async function(t){t.onlyTransactionKind||E(this,b).gasConfig.price||this.setGasPrice(await Ue(t).getReferenceGasPrice())};lr=new WeakSet;ln=async function(t){const{inputs:e,transactions:r}=E(this,b),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:O(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!U(e[o.index].value,ot))&&n.push(i),i.kind==="SplitCoins"&&i.amounts.forEach(a=>{if(a.kind==="Input"){const o=e[a.index];typeof o.value!="object"&&(o.value=$.Pure(I.U64.serialize(o.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=$.Pure(I.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,u]=i.target.split("::"),d=await Ue(t).getNormalizedMoveFunction({package:ce(a),module:o,function:u}),g=d.parameters.length>0&&oi(d.parameters.at(-1))?d.parameters.slice(0,d.parameters.length-1):d.parameters;if(g.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");g.forEach((p,y)=>{const k=i.arguments[y];if(k.kind!=="Input")return;const S=e[k.index];if(U(S.value,ot))return;const B=S.value,M=It(p,B);if(M){S.value=$.Pure(B,M);return}if(ar(p)!=null||typeof p=="object"&&"TypeParameter"in p){if(typeof B!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(B,null,2)}`);s.push({id:B,input:S,normalizedType:p});return}throw new Error(`Unknown call arg type ${JSON.stringify(p,null,2)} for value ${JSON.stringify(B,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:f})=>f))],a=Ti(i,Si),o=(await Promise.all(a.map(f=>Ue(t).multiGetObjects({ids:f,options:{showOwner:!0}})))).flat();let u=new Map(i.map((f,g)=>[f,o[g]]));const d=Array.from(u).filter(([f,g])=>g.error).map(([f,g])=>f);if(d.length)throw new Error(`The following input objects are invalid: ${d.join(", ")}`);s.forEach(({id:f,input:g,normalizedType:p})=>{var B;const y=u.get(f),k=(B=y.data)==null?void 0:B.owner,S=k&&typeof k=="object"&&"Shared"in k?k.Shared.initial_shared_version:void 0;if(S){const M=p!=null&&_t(p)==null&&Qr(p)==null,se=Gs(g.value)||M||p!=null&&_t(p)!=null;g.value=$.SharedObjectRef({objectId:f,initialSharedVersion:S,mutable:se})}else p&&wi(p)?g.value=$.ReceivingRef(mr(y)):g.value=$.ObjectRef(mr(y))})}};et=new WeakSet;At=async function(t){if(!t.onlyTransactionKind&&!E(this,b).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([j(this,dr,dn).call(this,t),j(this,lr,ln).call(this,t)]),!t.onlyTransactionKind&&(await j(this,ur,un).call(this,t),!E(this,b).gasConfig.budget)){const e=await Ue(t).dryRunTransactionBlock({transactionBlock:E(this,b).build({maxSizeBytes:j(this,de,ye).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(j(this,de,ye).call(this,"maxTxGas",t)),payment:[]}}})});if(e.effects.status.status!=="success")throw new Error(`Dry run failed, could not automatically determine a budget: ${e.effects.status.error}`,{cause:e});const r=bi*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)}j(this,cr,cn).call(this,t)};const ki=Symbol.for("@mysten/SuiClient");class _i{get[ki](){return!0}constructor(e){this.transport=e.transport??new ds({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,r){return await this.transport.request({method:e,params:r})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!Ke(ce(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach(n=>{if(!n||!Ke(ce(n)))throw new Error(`Invalid Sui Object id ${n}`)}),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,(e.order||"descending")==="descending"]})}async getTransactionBlock(e){if(!gr(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach(n=>{if(!gr(n))throw new Error(`Invalid Transaction digest ${n}`)}),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock(e){return await this.transport.request({method:"sui_executeTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:N(e.transactionBlock),Array.isArray(e.signature)?e.signature:[e.signature],e.options,e.requestType]})}async signAndExecuteTransactionBlock({transactionBlock:e,signer:r,...n}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(r.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:a}=await r.signTransactionBlock(s);return this.executeTransactionBlock({transactionBlock:a,signature:i,...n})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!oe(O(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach(r=>{if(!r||!Ke(ce(r)))throw new Error(`Invalid Sui Stake id ${r}`)}),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,(e.order||"descending")==="descending"]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){var n;let r;if(Ei(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=N(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=N(e.transactionBlock);else throw new Error("Unknown transaction block format.");return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,r,(n=e.gasPrice)==null?void 0:n.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:N(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!Ke(ce(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e==null?void 0:e.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e==null?void 0:e.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e==null?void 0:e.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"}),r=ut(e.digest);return me(r.slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames(e){return await this.transport.request({method:"suix_resolveNameServiceNames",params:[e.address,e.cursor,e.limit]})}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e==null?void 0:e.version]})}async waitForTransactionBlock({signal:e,timeout:r=60*1e3,pollInterval:n=2*1e3,...s}){const i=AbortSignal.timeout(r),a=new Promise((o,u)=>{i.addEventListener("abort",()=>u(i.reason))});for(a.catch(()=>{});!i.aborted;){e==null||e.throwIfAborted();try{return await this.getTransactionBlock(s)}catch{await Promise.race([new Promise(u=>setTimeout(u,n)),a])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}class hn extends _n{}const Ct="Sui",gn=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},ga=(t,e)=>{try{return pr(t)===pr(e)}catch{return!1}},pa=t=>(t==null?void 0:t.type)==="created",ya=t=>(t==null?void 0:t.type)==="published";function xi(t){return Array.isArray(t)}function fr(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function Ii(t){return typeof t=="object"&&!xi(t)&&!fr(t)}function ma(t){return typeof t=="object"&&"id"in t}const Ai=16*1024,wa=t=>I.ser("vector<u8>",t,{maxSize:Ai}).toBytes(),ba=async(t,e)=>{const{data:r,error:n}=await t.getObject({id:e,options:{showContent:!0}});if(n)throw new Error("Error getting object: "+n);if(!r||!fr(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return xn(r.content.type)},Oi=async(t,e)=>{if(!oe(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return gn(r)},Sa=async(t,e)=>{let r,n;do{const a=await t.getDynamicFields({parentId:e,cursor:n});r=a.data.find(o=>o.name.type.endsWith("CurrentPackage")),n=a.hasNextPage?a.nextCursor:null}while(n&&!r);if(!r)throw new Error("CurrentPackage not found");const s=await t.getObject({id:r.objectId,options:{showContent:!0}}),i=gn(s);if(!i||!Ii(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!fr(i.value))throw new Error("Unable to get package id");return i.value.fields.package},Ta=async(t,e,r)=>{let n=null,s=null,i=null,a;do{if(i=await t.getOwnedObjects({owner:r,filter:{StructType:`${e}::emitter::EmitterCap`},options:{showContent:!0},cursor:a}),!i||!i.data)throw Error("Failed to get owned objects");for(const o of i.data){if(!o.data)continue;const{version:u,objectId:d}=o.data;(n===null||u<n)&&(n=u,s=d)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},Ea=async(t,e)=>{const r=new vi,[n]=r.publish({modules:t.modules.map(s=>Array.from(In.decode(s))),dependencies:t.dependencies.map(s=>ce(s))});return r.transferObjects([n],r.pure(e)),r},Q=class Q extends An{constructor(e,r){super(e,r??On(e,Q._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 hn(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!Q.isSupportedChain(r))throw new Error(`invalid chain for ${Ct}: ${r}`);return Cn.tokenId(r,Bn)}static isNativeTokenId(e,r,n){return!Q.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return jn(e)===Q._platform}static async getDecimals(e,r,n){if(lt(n))return Mn(Q._platform);const s=new Je(n);try{const a=await Oi(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.toString()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getCoins(e,r,n){let s=[],i=null;const a=new Je(r).toString();do{const o=await e.getCoins({owner:a,coinType:n,cursor:i});s=[...s,...o.data],i=o.hasNextPage?o.nextCursor:null}while(i);return s}static async getBalance(e,r,n,s){if(lt(s)){const{totalBalance:a}=await r.getBalance({owner:n});return BigInt(a)}const{totalBalance:i}=await r.getBalance({owner:n,coinType:s.toString()});return BigInt(i)}static async getBalances(e,r,n,s){return(await Promise.all(s.map(async a=>{const o=await this.getBalance(e,r,n,a);return{[lt(a)?"native":new Je(a).toString()]:o}}))).reduce((a,o)=>Object.assign(a,o),{})}static async sendWait(e,r,n){const s=[];for(const i of n){const a=await r.executeTransactionBlock(i);await r.waitForTransactionBlock({digest:a.digest}),s.push(a.digest)}return s}static async getLatestBlock(e){return Number(await e.getLatestCheckpointSequenceNumber())}static async getLatestFinalizedBlock(e){return this.getLatestBlock(e)}static chainFromChainId(e){const r=Pn(Q._platform,e);if(r===void 0)throw new Error(`Unknown native chain id ${e}`);const[n,s]=r;return[n,s]}static async chainFromRpc(e){const r=await e.call("sui_getChainIdentifier",[]);return this.chainFromChainId(r)}};we(Q,"_platform",Ct);let De=Q;var Ve={};Object.defineProperty(Ve,"__esModule",{value:!0});Ve.bech32m=Bt=Ve.bech32=void 0;const ct="qpzry9x8gf2tvdw0s3jn54khce6mua7l",pn={};for(let t=0;t<ct.length;t++){const e=ct.charAt(t);pn[e]=t}function ke(t){const e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Tr(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=ke(e)^n>>5}e=ke(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=ke(e)^n&31}return e}function hr(t,e,r,n){let s=0,i=0;const a=(1<<r)-1,o=[];for(let u=0;u<t.length;++u)for(s=s<<e|t[u],i+=e;i>=r;)i-=r,o.push(s>>i&a);if(n)i>0&&o.push(s<<r-i&a);else{if(i>=e)return"Excess padding";if(s<<r-i&a)return"Non-zero padding"}return o}function Ci(t){return hr(t,8,5,!0)}function Bi(t){const e=hr(t,5,8,!1);if(Array.isArray(e))return e}function ji(t){const e=hr(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function yn(t){let e;t==="bech32"?e=1:e=734539939;function r(a,o,u){if(u=u||90,a.length+7+o.length>u)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let d=Tr(a);if(typeof d=="string")throw new Error(d);let f=a+"1";for(let g=0;g<o.length;++g){const p=o[g];if(p>>5)throw new Error("Non 5-bit word");d=ke(d)^p,f+=ct.charAt(p)}for(let g=0;g<6;++g)d=ke(d);d^=e;for(let g=0;g<6;++g){const p=d>>(5-g)*5&31;f+=ct.charAt(p)}return f}function n(a,o){if(o=o||90,a.length<8)return a+" too short";if(a.length>o)return"Exceeds length limit";const u=a.toLowerCase(),d=a.toUpperCase();if(a!==u&&a!==d)return"Mixed-case string "+a;a=u;const f=a.lastIndexOf("1");if(f===-1)return"No separator character for "+a;if(f===0)return"Missing prefix for "+a;const g=a.slice(0,f),p=a.slice(f+1);if(p.length<6)return"Data too short";let y=Tr(g);if(typeof y=="string")return y;const k=[];for(let S=0;S<p.length;++S){const B=p.charAt(S),M=pn[B];if(M===void 0)return"Unknown character "+B;y=ke(y)^M,!(S+6>=p.length)&&k.push(M)}return y!==e?"Invalid checksum for "+a:{prefix:g,words:k}}function s(a,o){const u=n(a,o);if(typeof u=="object")return u}function i(a,o){const u=n(a,o);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:s,decode:i,encode:r,toWords:Ci,fromWordsUnsafe:Bi,fromWords:ji}}var Bt=Ve.bech32=yn("bech32");Ve.bech32m=yn("bech32m");var ze=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))(ze||{});function Mi(t){return[t,0,0]}function mn(t,e){const r=Mi(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const dt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},Pi={ED25519:32,Secp256k1:33,Secp256r1:33},Ri={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function $i(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function Ni(t,e){const r=t.toString(16);return Rn(r.padStart(e*2,"0").slice(-32*2))}function Ui(t,e){const r=Ni(t,e),n=$i(r);return n===-1?new Uint8Array([0]):r.slice(n)}function Di(t,e){const r=Ui(t,32);e==="accounts.google.com"&&(e="https://accounts.google.com");const n=new TextEncoder().encode(e),s=new Uint8Array(2+r.length+n.length);return s.set([dt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),O(_r(Me(s,{dkLen:32})).slice(0,Mt*2))}function Vi(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 zi(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=Vi(n);e=e.concat(s)}return e}function Li(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=zi(t);const n=e%4;if(n!==0)if(n===1)r=r.slice(2);else if(n===2)r=r.slice(4);else throw new Error(`Input (s = ${t}) is not tightly packed because i%4 = 3 (i = ${e}))`);const s=(e+t.length-1)%4;if(s!==3)if(s===2)r=r.slice(0,r.length-2);else if(s===1)r=r.slice(0,r.length-4);else throw new Error(`Input (s = ${t}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${e}))`);if(r.length%8!==0)throw new Error("We should never reach here...");const i=new Uint8Array(Math.floor(r.length/8));let a=0;for(let o=0;o<r.length;o+=8){const u=r.slice(o,o+8),d=parseInt(u.join(""),2);i[a++]=d}return new TextDecoder().decode(i)}function qi(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 Wi(t,e){const r=Li(t.value,t.indexMod4),[n,s]=qi(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const Ki=c.struct("ZkLoginSignature",{inputs:c.struct("ZkLoginSignatureInputs",{proofPoints:c.struct("ZkLoginSignatureInputsProofPoints",{a:c.vector(c.string()),b:c.vector(c.vector(c.string())),c:c.vector(c.string())}),issBase64Details:c.struct("ZkLoginSignatureInputsClaim",{value:c.string(),indexMod4:c.u8()}),headerBase64:c.string(),addressSeed:c.string()}),maxEpoch:c.u64(),userSignature:c.vector(c.u8())});function Fi(t){return Ki.parse(typeof t=="string"?H(t):t)}function Gi({signature:t,signatureScheme:e,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const n=r.toRawBytes(),s=new Uint8Array(1+t.length+n.length);return s.set([dt[e]]),s.set(t,1),s.set(n,1+t.length),N(s)}function Hi(t){const e=H(t),r=Ri[e[0]];switch(r){case"MultiSig":const n=I.MultiSig.parse(e.slice(1));return{serializedSignature:t,signatureScheme:r,multisig:n,bytes:e};case"ZkLogin":const s=e.slice(1),{inputs:i,maxEpoch:a,userSignature:o}=Fi(s),{issBase64Details:u,addressSeed:d}=i,f=Wi(u,"iss"),g=Di(BigInt(d),f);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:f,address:g,addressSeed:BigInt(d)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const p=Pi[r],y=e.slice(1,e.length-p),k=e.slice(1+y.length);return{serializedSignature:t,signatureScheme:r,signature:y,publicKey:k,bytes:e};default:throw new Error("Unsupported signature scheme")}}const tt=32,Zi="suiprivkey";class Ji{async signWithIntent(e,r){const n=mn(r,e),s=Me(n,{dkLen:32});return{signature:Gi({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:N(e)}}async signTransactionBlock(e){return this.signWithIntent(e,ze.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(c.vector(c.u8()).serialize(e).toBytes(),ze.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class Xi extends Ji{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function Yi(t,e){if(t.length!==tt)throw new Error("Invalid bytes length");const r=dt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),Bt.encode(Zi,Bt.toWords(n))}function Er(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function Qi(t){return Nn(t,"")}function ea(t){return me(Qi(t))}const ta="ed25519 seed",ra=2147483648,na=new RegExp("^m(\\/[0-9]+')+$"),wn=t=>t.replace("'",""),sa=t=>{const r=xr.create(Ir,ta).update(qe(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},ia=({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=xr.create(Ir,e).update(i).digest(),o=a.slice(0,32),u=a.slice(32);return{key:o,chainCode:u}},aa=t=>na.test(t)?!t.split("/").slice(1).map(wn).some(isNaN):!1,vr=(t,e,r=ra)=>{if(!aa(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=sa(e);return t.split("/").slice(1).map(wn).map(a=>parseInt(a,10)).reduce((a,o)=>ia(a,o+r),{key:n,chainCode:s})};function bn(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 oa{equals(e){return bn(this.toRawBytes(),e.toRawBytes())}toBase64(){return N(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return N(e)}verifyWithIntent(e,r,n){const s=mn(n,e),i=Me(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(I.vector(I.u8()).serialize(e).toBytes(),r,ze.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,ze.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return O(_r(Me(this.toSuiBytes(),{dkLen:32})).slice(0,Mt*2))}}const jt=32;class Sn extends oa{constructor(e){if(super(),typeof e=="string"?this.data=H(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==jt)throw new Error(`Invalid public key input. Expected ${jt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return dt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=Hi(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!bn(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return fe.sign.detached.verify(e,n,this.toRawBytes())}}Sn.SIZE=jt;const kr="m/44'/784'/0'/0'/0'";class Se extends Xi{constructor(e){super(),e?this.keypair=e:this.keypair=fe.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Se(fe.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==tt)throw new Error(`Wrong secretKey size. Expected ${tt} bytes, got ${n}.`);const s=fe.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=fe.sign.detached(a,s.secretKey);if(!fe.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new Se(s)}getPublicKey(){return new Sn(this.keypair.publicKey)}getSecretKey(){return Yi(this.keypair.secretKey.slice(0,tt),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return fe.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=kr),!Er(r))throw new Error("Invalid derivation path");const{key:n}=vr(r,ea(e));return Se.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=kr),!Er(r))throw new Error("Invalid derivation path");const{key:n}=vr(r,e);return Se.fromSecretKey(n)}}async function ca(t,e){const[,r]=await De.chainFromRpc(t);return new ua(r,t,Se.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class ua{constructor(e,r,n,s){we(this,"_chain");we(this,"_client");we(this,"_signer");we(this,"_debug");this._chain=e,this._client=r,this._signer=n,this._debug=s}chain(){return this._chain}address(){return this._signer.toSuiAddress()}async signAndSend(e){const r=[];for(const n of e){const{description:s,transaction:i}=n;this._debug&&console.log(`Signing ${s} for ${this.address()}`);try{const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}catch(a){throw a}}return r}}const da={Address:Je,Platform:De,getSigner:ca,protocols:{WormholeCore:()=>ft(()=>import("./index-_NuAK6zi.js"),__vite__mapDeps([0,1,2,3])),TokenBridge:()=>ft(()=>import("./index-CEjbqPmT.js"),__vite__mapDeps([4,1,2,0,3,5])),CircleBridge:()=>ft(()=>import("./index-BTnVHgr_.js"),__vite__mapDeps([6,1,2,5,3]))},getChain:(t,e,r)=>new hn(e,new De(t,$n(t,Ct,{[e]:r})))},va=Object.freeze(Object.defineProperty({__proto__:null,default:da},Symbol.toStringTag,{value:"Module"}));export{De as S,gn as a,fr as b,ya as c,pa as d,ga as e,Ta as f,Oi as g,Sa as h,Ii as i,ba as j,ma as k,Ea as p,va as s,wa as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=Object.defineProperty;var c=(a,t,i)=>t in a?o(a,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[t]=i;var s=(a,t,i)=>c(a,typeof t!="symbol"?t+"":t,i);class h{constructor(t,i,n,r,e=!1){s(this,"transaction");s(this,"network");s(this,"chain");s(this,"description");s(this,"parallelizable");this.transaction=t,this.network=i,this.chain=n,this.description=r,this.parallelizable=e}}export{h as A};
|