@wormhole-foundation/wormhole-connect 0.3.22-beta.6-development → 0.3.23-beta.0-development
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ccip-kFE7Egv7.js → ccip-BOQxYwA4.js} +1 -1
- package/dist/assets/cosmos-DpJHRy9R.js +38 -0
- package/dist/assets/{cosmwasm-K-vi4me_.js → cosmwasm-Dngp91th.js} +3 -3
- package/dist/assets/{ens-validation.es6-BaHGKtnQ.js → ens-validation.es6-DY5iRcEw.js} +1 -1
- package/dist/assets/{evm-DyQ3Up1i.js → evm-CXBiqSp9.js} +26 -26
- package/dist/assets/{index-Dqd4pSig.js → index-BhecnthD.js} +1 -1
- package/dist/assets/{index-EkdPNlSn.js → index-BphOrDO3.js} +1 -1
- package/dist/assets/index-BqmJ5ps2.js +3 -0
- package/dist/assets/{index-6ERMnMWg.js → index-CX56YBaw.js} +1 -1
- package/dist/assets/{index-Ci7BRqEw.js → index-DBB96cBs.js} +2 -2
- package/dist/assets/{index-BC4s7rDX.js → index-DwWFp7_d.js} +1 -1
- package/dist/assets/{index.es-BnzPN21S.js → index.es-BWLyUn8A.js} +2 -2
- package/dist/assets/{solana-D0TX7DHf.js → solana-C3hk0iY4.js} +2 -2
- package/dist/assets/{solanaEmbed.esm-CBOtlgbY.js → solanaEmbed.esm-Bzvc2Yau.js} +1 -1
- package/dist/assets/{unsignedTransaction-CWlZwFZw.js → unsignedTransaction-DhgJ038I.js} +1 -1
- package/dist/main.js +9 -9
- package/dist/src/utils/wallet/evm.d.ts.map +1 -1
- package/lib/{algorand-DjUTtqxk.mjs → algorand-kK-8oojN.mjs} +4 -4
- package/lib/{algorand-BgVfTPrs.js → algorand-mZNvVCps.js} +1 -1
- package/lib/{aptos-xxNUHC8o.mjs → aptos-C8ttM75J.mjs} +4 -4
- package/lib/{aptos-JOeRwo7r.js → aptos-CfDDJUg1.js} +2 -2
- package/lib/{aptos-CVVZJ32U.js → aptos-Dct_m6Gg.js} +1 -1
- package/lib/{aptos-BmyHkXb6.mjs → aptos-DgRBytsM.mjs} +1 -1
- package/lib/{browser-B_2ji4LP.mjs → browser-Bf0arMap.mjs} +2 -2
- package/lib/{browser-EzqecQNA.js → browser-DVTB-WO0.js} +1 -1
- package/lib/{browser-ponyfill-yx2re7P5.mjs → browser-ponyfill-BBGnYIgf.mjs} +1 -1
- package/lib/{browser-ponyfill-DH_DuJjr.js → browser-ponyfill-CtGm2L9z.js} +1 -1
- package/lib/{ccip-B2atrHiU.js → ccip-BQ7Z_goB.js} +1 -1
- package/lib/{ccip-JjlhOiF-.mjs → ccip-DzflCjUZ.mjs} +1 -1
- package/lib/{chain-BE2gm6l5.mjs → chain-D1Ms6bPc.mjs} +1 -1
- package/lib/{chain-Ck_2P-B0.js → chain-HMnpkrbl.js} +1 -1
- package/lib/{cosmos-BqA6T2gQ.mjs → cosmos-BIzn30Lo.mjs} +6 -6
- package/lib/cosmos-DFeWBfwa.js +38 -0
- package/lib/{cosmwasm-dpMbVaHd.mjs → cosmwasm-CYZkMUNw.mjs} +6 -6
- package/lib/{cosmwasm-D8-LmG14.js → cosmwasm-Cw-jZjyR.js} +2 -2
- package/lib/{create-CONoHCNu.js → create-BjUw-7kj.js} +1 -1
- package/lib/{create-NSzn0Mjd.mjs → create-D7KM2TbJ.mjs} +1 -1
- package/lib/{ens-validation.es6-DQMHfHaf.js → ens-validation.es6-CSendvHo.js} +1 -1
- package/lib/{ens-validation.es6-SwNVNlnL.mjs → ens-validation.es6-CtTsD9-1.mjs} +2 -2
- package/lib/{evm-BzbkH6iw.mjs → evm-2ARfiEbk.mjs} +6 -6
- package/lib/{evm-DQDZ6407.js → evm-CyCIXNVR.js} +22 -22
- package/lib/{evm-D7ExbjR0.mjs → evm-WeYh1CwH.mjs} +1588 -1596
- package/lib/{evm-CNyEgAvC.js → evm-vq8ExBtp.js} +2 -2
- package/lib/{index-BRY7PwCe.mjs → index-4Diyx7dk.mjs} +3 -3
- package/lib/{index-CHDQPgcS.mjs → index-6g1GFCCq.mjs} +2 -2
- package/lib/{index-Dz2gv_XI.mjs → index-9ZdnzH2d.mjs} +5 -5
- package/lib/{index-DzX0K2kv.js → index-B1oIabF3.js} +1 -1
- package/lib/{index-BiJV97Xz.js → index-B3xO-Vlp.js} +1 -1
- package/lib/{index-BG34ZjNr.mjs → index-B4Wo5ciI.mjs} +4 -4
- package/lib/{index-NS46gHyL.js → index-B9iI7y0N.js} +1 -1
- package/lib/{index-uwGV-Vn3.js → index-BC9O3q0O.js} +1 -1
- package/lib/{index-eFtXd025.mjs → index-BFLX4WxO.mjs} +4 -4
- package/lib/{index-gM7Zj76T.js → index-BPsT8R1K.js} +1 -1
- package/lib/{index-7ZAqkUlU.mjs → index-BSAsS8RD.mjs} +1 -1
- package/lib/{index-CD_ekrEI.mjs → index-BYDoWQJF.mjs} +4 -4
- package/lib/{index-XH2z1iXX.mjs → index-BaO4Z093.mjs} +3 -3
- package/lib/{index-Bd6oWjRV.mjs → index-BeO_qTcl.mjs} +2 -2
- package/lib/{index-wj32vNhH.js → index-BhOoVwl8.js} +1 -1
- package/lib/{index-DvQrjwKV.mjs → index-BtObdPhn.mjs} +4 -4
- package/lib/{index-DW-MTqZy.mjs → index-BzX2BW_O.mjs} +4 -4
- package/lib/{index-BgYENi3t.js → index-C2c8vR42.js} +1 -1
- package/lib/{index-6ZiA60gP.js → index-C2oD47lT.js} +1 -1
- package/lib/{index-DQR7qDM7.mjs → index-C6mDtHMX.mjs} +86 -88
- package/lib/{index-hyVeTz05.js → index-C9SlTWZB.js} +1 -1
- package/lib/{index-BYInpg-j.js → index-CHc9Fnxq.js} +1 -1
- package/lib/{index-Dh1gwYHK.js → index-CIbWgDdT.js} +1 -1
- package/lib/{index-ClJ9xKH_.js → index-CJWNAIq4.js} +1 -1
- package/lib/{index-SL51oRv6.mjs → index-CK0z65I9.mjs} +4 -4
- package/lib/{index-BNxdQt8p.js → index-CMB6PdWJ.js} +1 -1
- package/lib/{index-BozvRZRr.mjs → index-CMxa7eqf.mjs} +5 -5
- package/lib/{index-CeTuOmVc.mjs → index-CNSXR9tB.mjs} +5 -5
- package/lib/{index-BCRhQQj3.mjs → index-CV1VV-zJ.mjs} +3 -3
- package/lib/{index-B3EOWCDT.js → index-CxrhBQyI.js} +1 -1
- package/lib/{index-BS-5mncz.mjs → index-CyGeUScn.mjs} +5 -5
- package/lib/index-D5ZI8OQ5.js +3 -0
- package/lib/{index-DsuNqUD-.mjs → index-DAY2C3ja.mjs} +4 -4
- package/lib/{index-Ci2ZLtDV.js → index-DHPvJyI7.js} +1 -1
- package/lib/{index-THgGZbp0.js → index-DMbFl-Wn.js} +1 -1
- package/lib/{index-DkLEkXih.mjs → index-DVFnDDyZ.mjs} +4 -4
- package/lib/{index-DuiRxqsN.js → index-DjAqAqeU.js} +1 -1
- package/lib/{index-9m7TBK6v.mjs → index-EqiiaA9-.mjs} +4 -4
- package/lib/{index-BRSYiZGo.js → index-GooDQIzI.js} +1 -1
- package/lib/{index-BtH96J3O.mjs → index-IQlvm76i.mjs} +72 -72
- package/lib/{index-iNOxku8i.js → index-Jgr_mZ4Y.js} +1 -1
- package/lib/{index-D4hS9TeC.js → index-L9bSVF77.js} +1 -1
- package/lib/{index-Rl2MOwgU.mjs → index-f8fcieOQ.mjs} +4 -4
- package/lib/{index-C7tR7eyI.js → index-k5MpmioF.js} +1 -1
- package/lib/{index-_YUXIUK8.js → index-nxd7L_DD.js} +1 -1
- package/lib/{index-GGqf7rB-.mjs → index-qsqnFs3a.mjs} +2 -2
- package/lib/{index-Dh6Zmu7D.js → index-rtZ91I3M.js} +8 -8
- package/lib/{index-Fv3-CE1p.mjs → index-yG0Rs8Eb.mjs} +2 -2
- package/lib/{index.es-CKpdDKzf.mjs → index.es-CEImaU7l.mjs} +5 -5
- package/lib/{index.es-Bj1J4jCu.js → index.es-gwZvea5f.js} +2 -2
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{libsodium-wrappers-Dta7f8ar.js → libsodium-wrappers-Bez_KKB1.js} +1 -1
- package/lib/{libsodium-wrappers-B_H4aRTY.mjs → libsodium-wrappers-Cz0uCBox.mjs} +1 -1
- package/lib/{sei-UDsMKtbc.mjs → sei-BYR1KxHW.mjs} +2 -2
- package/lib/{sei-DGdkVzbE.js → sei-BrTMqCke.js} +1 -1
- package/lib/{solana-CkviJVw5.js → solana-0RqhvUa1.js} +1 -1
- package/lib/{solana-DPaJOryR.mjs → solana-BLtdLKKq.mjs} +3 -3
- package/lib/{solana-C9YVHn-W.mjs → solana-CRbkLsWk.mjs} +6 -6
- package/lib/{solana-BZhGAwx6.js → solana-D3NR_tHO.js} +2 -2
- package/lib/{solanaEmbed.esm-DnssMltk.mjs → solanaEmbed.esm-CaR2Md_k.mjs} +2 -2
- package/lib/{solanaEmbed.esm-C0UDKbGU.js → solanaEmbed.esm-E-eNJK6U.js} +1 -1
- package/lib/src/utils/wallet/evm.d.ts.map +1 -1
- package/lib/{sui-8btJKilJ.mjs → sui-BZ_uS8zP.mjs} +1 -1
- package/lib/{sui-c83-J_ow.js → sui-CErMMm5A.js} +2 -2
- package/lib/{sui-CUfyUGKk.mjs → sui-DeoYmh3N.mjs} +4 -4
- package/lib/{sui-6-wJdSqv.js → sui-T81Wy4dP.js} +1 -1
- package/lib/{unsignedTransaction-CWjweDuU.js → unsignedTransaction-DCa77QzH.js} +1 -1
- package/lib/{unsignedTransaction-C293HA6V.mjs → unsignedTransaction-DJSAg3zT.mjs} +2 -2
- package/package.json +1 -1
- package/dist/assets/cosmos-BUbSl2Zd.js +0 -38
- package/dist/assets/index-5a-xin_S.js +0 -3
- package/lib/cosmos-arjQyma2.js +0 -38
- package/lib/index-CgyVAtoK.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../../src/utils/wallet/evm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAEL,cAAc,EACd,aAAa,EACb,mBAAmB,EAEpB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../../src/utils/wallet/evm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAEL,cAAc,EACd,aAAa,EACb,mBAAmB,EAEpB,MAAM,mCAAmC,CAAC;AAiD3C,eAAO,MAAM,OAAO;;;;CAiBnB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,UAAU,UAAiB,SAAS,UAAU,MAAM,kBAQhE,CAAC;AAEF,wBAAsB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,iBAEpE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as nM, R as SM } from "./wallets-BrkMAo24.mjs";
|
|
2
|
-
import { W as CM, c as q, a9 as zM, aa as _, N as EM, B as Z } from "./index-
|
|
2
|
+
import { W as CM, c as q, a9 as zM, aa as _, N as EM, B as Z } from "./index-C6mDtHMX.mjs";
|
|
3
3
|
class wM extends TypeError {
|
|
4
4
|
constructor(i, t) {
|
|
5
5
|
let A;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var Kn=Object.defineProperty;var Gn=(t,e,r)=>e in t?Kn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ie=(t,e,r)=>(Gn(t,typeof e!="symbol"?e+"":e,r),r);const S=require("./index-Dh6Zmu7D.js"),Hr=require("./chain-Ck_2P-B0.js");function Fe(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Zn(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Jt(t,...e){if(!Zn(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Fr(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Fe(t.outputLen),Fe(t.blockLen)}function St(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Jn(t,e){Jt(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const gt=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Xn(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ke(t){return typeof t=="string"&&(t=Xn(t)),Jt(t),t}class qr{clone(){return this._cloneInto()}}const Yn={}.toString;function Qn(t,e){if(e!==void 0&&Yn.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function es(t){const e=n=>t().update(Ke(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}class Wr extends qr{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Fr(e);const n=Ke(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?e.create().update(n).digest():n);for(let a=0;a<i.length;a++)i[a]^=54;this.iHash.update(i),this.oHash=e.create();for(let a=0;a<i.length;a++)i[a]^=106;this.oHash.update(i),i.fill(0)}update(e){return St(this),this.iHash.update(e),this}digestInto(e){St(this),Jt(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:n,finished:s,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Kr=(t,e,r)=>new Wr(t,e).update(r).digest();Kr.create=(t,e)=>new Wr(t,e);function ts(t,e,r,n){Fr(t);const s=Qn({dkLen:32,asyncTick:10},n),{c:i,dkLen:a,asyncTick:o}=s;if(Fe(i),Fe(a),Fe(o),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=Ke(e),d=Ke(r),h=new Uint8Array(a),l=Kr.create(t,c),g=l._cloneInto().update(d);return{c:i,dkLen:a,asyncTick:o,DK:h,PRF:l,PRFSalt:g}}function rs(t,e,r,n,s){return t.destroy(),e.destroy(),n&&n.destroy(),s.fill(0),r}function ns(t,e,r,n){const{c:s,dkLen:i,DK:a,PRF:o,PRFSalt:c}=ts(t,e,r,n);let d;const h=new Uint8Array(4),l=gt(h),g=new Uint8Array(o.outputLen);for(let y=1,m=0;m<i;y++,m+=o.outputLen){const w=a.subarray(m,m+o.outputLen);l.setInt32(0,y,!1),(d=c._cloneInto(d)).update(h).digestInto(g),w.set(g.subarray(0,w.length));for(let b=1;b<s;b++){o._cloneInto(d).update(g).digestInto(g);for(let I=0;I<w.length;I++)w[I]^=g[I]}}return rs(o,c,a,d,g)}function ss(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const s=BigInt(32),i=BigInt(4294967295),a=Number(r>>s&i),o=Number(r&i),c=n?4:0,d=n?0:4;t.setUint32(e+c,a,n),t.setUint32(e+d,o,n)}class is extends qr{constructor(e,r,n,s){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=gt(this.buffer)}update(e){St(this);const{view:r,buffer:n,blockLen:s}=this;e=Ke(e);const i=e.length;for(let a=0;a<i;){const o=Math.min(s-this.pos,i-a);if(o===s){const c=gt(e);for(;s<=i-a;a+=s)this.process(c,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){St(this),Jn(e,this),this.finished=!0;const{buffer:r,view:n,blockLen:s,isLE:i}=this;let{pos:a}=this;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>s-a&&(this.process(n,0),a=0);for(let l=a;l<s;l++)r[l]=0;ss(n,s-8,BigInt(this.length*8),i),this.process(n,0);const o=gt(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=c/4,h=this.get();if(d>h.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)o.setUint32(4*l,h[l],i)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:n,length:s,finished:i,destroyed:a,pos:o}=this;return e.length=s,e.pos=o,e.finished=i,e.destroyed=a,s%r&&e.buffer.set(n),e}}const ct=BigInt(2**32-1),Nt=BigInt(32);function Gr(t,e=!1){return e?{h:Number(t&ct),l:Number(t>>Nt&ct)}:{h:Number(t>>Nt&ct)|0,l:Number(t&ct)|0}}function as(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:i,l:a}=Gr(t[s],e);[r[s],n[s]]=[i,a]}return[r,n]}const os=(t,e)=>BigInt(t>>>0)<<Nt|BigInt(e>>>0),cs=(t,e,r)=>t>>>r,us=(t,e,r)=>t<<32-r|e>>>r,ds=(t,e,r)=>t>>>r|e<<32-r,ls=(t,e,r)=>t<<32-r|e>>>r,hs=(t,e,r)=>t<<64-r|e>>>r-32,fs=(t,e,r)=>t>>>r-32|e<<64-r,gs=(t,e)=>e,ps=(t,e)=>t,ys=(t,e,r)=>t<<r|e>>>32-r,ms=(t,e,r)=>e<<r|t>>>32-r,ws=(t,e,r)=>e<<r-32|t>>>64-r,bs=(t,e,r)=>t<<r-32|e>>>64-r;function Ss(t,e,r,n){const s=(e>>>0)+(n>>>0);return{h:t+r+(s/2**32|0)|0,l:s|0}}const Ts=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),xs=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Es=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),vs=(t,e,r,n,s)=>e+r+n+s+(t/2**32|0)|0,ks=(t,e,r,n,s)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(s>>>0),Is=(t,e,r,n,s,i)=>e+r+n+s+i+(t/2**32|0)|0,T={fromBig:Gr,split:as,toBig:os,shrSH:cs,shrSL:us,rotrSH:ds,rotrSL:ls,rotrBH:hs,rotrBL:fs,rotr32H:gs,rotr32L:ps,rotlSH:ys,rotlSL:ms,rotlBH:ws,rotlBL:bs,add:Ss,add3L:Ts,add3H:xs,add4L:Es,add4H:vs,add5H:Is,add5L:ks},[As,_s]=T.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),we=new Uint32Array(80),be=new Uint32Array(80);class Bs extends is{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:n,Bl:s,Ch:i,Cl:a,Dh:o,Dl:c,Eh:d,El:h,Fh:l,Fl:g,Gh:y,Gl:m,Hh:w,Hl:b}=this;return[e,r,n,s,i,a,o,c,d,h,l,g,y,m,w,b]}set(e,r,n,s,i,a,o,c,d,h,l,g,y,m,w,b){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=s|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=c|0,this.Eh=d|0,this.El=h|0,this.Fh=l|0,this.Fl=g|0,this.Gh=y|0,this.Gl=m|0,this.Hh=w|0,this.Hl=b|0}process(e,r){for(let x=0;x<16;x++,r+=4)we[x]=e.getUint32(r),be[x]=e.getUint32(r+=4);for(let x=16;x<80;x++){const $=we[x-15]|0,D=be[x-15]|0,L=T.rotrSH($,D,1)^T.rotrSH($,D,8)^T.shrSH($,D,7),H=T.rotrSL($,D,1)^T.rotrSL($,D,8)^T.shrSL($,D,7),z=we[x-2]|0,ue=be[x-2]|0,at=T.rotrSH(z,ue,19)^T.rotrBH(z,ue,61)^T.shrSH(z,ue,6),Bt=T.rotrSL(z,ue,19)^T.rotrBL(z,ue,61)^T.shrSL(z,ue,6),ot=T.add4L(H,Bt,be[x-7],be[x-16]),Ot=T.add4H(ot,L,at,we[x-7],we[x-16]);we[x]=Ot|0,be[x]=ot|0}let{Ah:n,Al:s,Bh:i,Bl:a,Ch:o,Cl:c,Dh:d,Dl:h,Eh:l,El:g,Fh:y,Fl:m,Gh:w,Gl:b,Hh:I,Hl:O}=this;for(let x=0;x<80;x++){const $=T.rotrSH(l,g,14)^T.rotrSH(l,g,18)^T.rotrBH(l,g,41),D=T.rotrSL(l,g,14)^T.rotrSL(l,g,18)^T.rotrBL(l,g,41),L=l&y^~l&w,H=g&m^~g&b,z=T.add5L(O,D,H,_s[x],be[x]),ue=T.add5H(z,I,$,L,As[x],we[x]),at=z|0,Bt=T.rotrSH(n,s,28)^T.rotrBH(n,s,34)^T.rotrBH(n,s,39),ot=T.rotrSL(n,s,28)^T.rotrBL(n,s,34)^T.rotrBL(n,s,39),Ot=n&i^n&o^i&o,Wn=s&a^s&c^a&c;I=w|0,O=b|0,w=y|0,b=m|0,y=l|0,m=g|0,{h:l,l:g}=T.add(d|0,h|0,ue|0,at|0),d=o|0,h=c|0,o=i|0,c=a|0,i=n|0,a=s|0;const Cr=T.add3L(at,ot,Wn);n=T.add3H(Cr,ue,Bt,Ot),s=Cr|0}({h:n,l:s}=T.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:a}=T.add(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:c}=T.add(this.Ch|0,this.Cl|0,o|0,c|0),{h:d,l:h}=T.add(this.Dh|0,this.Dl|0,d|0,h|0),{h:l,l:g}=T.add(this.Eh|0,this.El|0,l|0,g|0),{h:y,l:m}=T.add(this.Fh|0,this.Fl|0,y|0,m|0),{h:w,l:b}=T.add(this.Gh|0,this.Gl|0,w|0,b|0),{h:I,l:O}=T.add(this.Hh|0,this.Hl|0,I|0,O|0),this.set(n,s,i,a,o,c,d,h,l,g,y,m,w,b,I,O)}roundClean(){we.fill(0),be.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Os=es(()=>new Bs);/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */function Zr(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function Cs(t){const e=Zr(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}const js=t=>Zr(`mnemonic${t}`);function Us(t,e=""){return ns(Os,Cs(t).nfkd,js(e),{c:2048,dkLen:64})}function Ms(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=n}var a=t.length,o=t.charAt(0),c=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function h(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var m=0,w=0,b=0,I=y.length;b!==I&&y[b]===0;)b++,m++;for(var O=(I-b)*d+1>>>0,x=new Uint8Array(O);b!==I;){for(var $=y[b],D=0,L=O-1;($!==0||D<w)&&L!==-1;L--,D++)$+=256*x[L]>>>0,x[L]=$%a>>>0,$=$/a>>>0;if($!==0)throw new Error("Non-zero carry");w=D,b++}for(var H=O-w;H!==O&&x[H]===0;)H++;for(var z=o.repeat(m);H<O;++H)z+=t.charAt(x[H]);return z}function l(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;for(var m=0,w=0,b=0;y[m]===o;)w++,m++;for(var I=(y.length-m)*c+1>>>0,O=new Uint8Array(I);y[m];){var x=e[y.charCodeAt(m)];if(x===255)return;for(var $=0,D=I-1;(x!==0||$<b)&&D!==-1;D--,$++)x+=a*O[D]>>>0,O[D]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");b=$,m++}for(var L=I-b;L!==I&&O[L]===0;)L++;for(var H=new Uint8Array(w+(I-L)),z=w;L!==I;)H[z++]=O[L++];return H}function g(y){var m=l(y);if(m)return m;throw new Error("Non-base"+a+" character")}return{encode:h,decodeUnsafe:l,decode:g}}var Ps=Ms;const Rs=Ps,$s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var Ns=Rs($s);const Jr=S.getDefaultExportFromCjs(Ns),tt=t=>Jr.encode(t),rt=t=>Jr.decode(t);function ne(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const Ct=8192;function W(t){if(t.length<Ct)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=Ct){const n=t.slice(r,r+Ct);e+=String.fromCharCode(...n)}return btoa(e)}function nt(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 Ce(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function Xt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function Ds(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 Xr{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}=Ds(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 Ls(t,e){switch(e){case"base58":return tt(t);case"base64":return W(t);case"hex":return Ce(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function zs(t,e){switch(e){case"base58":return rt(t);case"base64":return ne(t);case"hex":return nt(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Yr(t,e=["<",">"]){const[r,n]=e,s=[];let i="",a=0;for(let o=0;o<t.length;o++){const c=t[o];if(c===r&&a++,c===n&&a--,a===0&&c===","){s.push(i.trim()),i="";continue}i+=c}return s.push(i.trim()),s}class Qr{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 jt(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return jt(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return jt(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return Xt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,s)=>r(this,n,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return Ls(this.toBytes(),e)}}function jt(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 en=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},Q=(t,e,r)=>(en(t,e,"read from private field"),r?r.call(t):e.get(t)),Tt=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},xt=(t,e,r,n)=>(en(t,e,"write to private field"),e.set(t,r),r),je,De,pt,Te;const tn=class{constructor(t){Tt(this,je,void 0),Tt(this,De,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),xt(this,je,t.write),xt(this,De,t.serialize??((e,r)=>{const n=new Qr({size:this.serializedSize(e)??void 0,...r});return Q(this,je).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),Q(this,je).call(this,t,e)}serialize(t,e){return this.validate(t),new Vs(this,Q(this,De).call(this,t,e))}parse(t){const e=new Xr(t);return this.read(e)}transform({name:t,input:e,output:r}){return new tn({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>Q(this,je).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>Q(this,De).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let te=tn;je=new WeakMap;De=new WeakMap;const rn=Symbol.for("@mysten/serialized-bcs");function Yt(t){return!!t&&typeof t=="object"&&t[rn]===!0}class Vs{constructor(e,r){Tt(this,pt,void 0),Tt(this,Te,void 0),xt(this,pt,e),xt(this,Te,r)}get[rn](){return!0}toBytes(){return Q(this,Te)}toHex(){return Ce(Q(this,Te))}toBase64(){return W(Q(this,Te))}toBase58(){return tt(Q(this,Te))}parse(){return Q(this,pt).parse(Q(this,Te))}}pt=new WeakMap;Te=new WeakMap;function Et({size:t,...e}){return new te({...e,serializedSize:()=>t})}function Ut({readMethod:t,writeMethod:e,...r}){return Et({...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 Mt({readMethod:t,writeMethod:e,...r}){return Et({...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 Hs({serialize:t,...e}){const r=new te({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function Fs({toBytes:t,fromBytes:e,...r}){return new te({...r,read:n=>{const s=n.readULEB(),i=n.readBytes(s);return e(i)},write:(n,s)=>{const i=t(n);s.writeULEB(i.length);for(let a=0;a<i.length;a++)s.write8(i[a])},serialize:n=>{const s=t(n),i=Xt(s.length),a=new Uint8Array(i.length+s.length);return a.set(i,0),a.set(s,i.length),a},validate:n=>{var s;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(s=r.validate)==null||s.call(r,n)}})}function qs(t){let e=null;function r(){return e||(e=t()),e}return new te({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 u={u8(t){return Ut({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return Ut({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return Ut({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return Mt({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return Mt({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return Mt({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Et({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 Hs({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Xt(e)),...t})},bytes(t,e){return Et({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 Fs({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new te({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 u.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 te({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 te({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 te({name:t,serializedSize:s=>{let i=0;for(const[a,o]of n){const c=o.serializedSize(s[a]);if(c==null)return null;i+=c}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 te({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 c=0;c<n.length;c++){const[d,h]=n[c];if(d===a){i.writeULEB(c),h==null||h.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 u.vector(u.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 qs(t)}},Ws=32,Le=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof Le){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(Le.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&&Ks(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 Le(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
1
|
+
"use strict";var Kn=Object.defineProperty;var Gn=(t,e,r)=>e in t?Kn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ie=(t,e,r)=>(Gn(t,typeof e!="symbol"?e+"":e,r),r);const S=require("./index-rtZ91I3M.js"),Hr=require("./chain-HMnpkrbl.js");function Fe(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Zn(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Jt(t,...e){if(!Zn(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Fr(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Fe(t.outputLen),Fe(t.blockLen)}function St(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Jn(t,e){Jt(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const gt=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Xn(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ke(t){return typeof t=="string"&&(t=Xn(t)),Jt(t),t}class qr{clone(){return this._cloneInto()}}const Yn={}.toString;function Qn(t,e){if(e!==void 0&&Yn.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function es(t){const e=n=>t().update(Ke(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}class Wr extends qr{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Fr(e);const n=Ke(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?e.create().update(n).digest():n);for(let a=0;a<i.length;a++)i[a]^=54;this.iHash.update(i),this.oHash=e.create();for(let a=0;a<i.length;a++)i[a]^=106;this.oHash.update(i),i.fill(0)}update(e){return St(this),this.iHash.update(e),this}digestInto(e){St(this),Jt(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:n,finished:s,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Kr=(t,e,r)=>new Wr(t,e).update(r).digest();Kr.create=(t,e)=>new Wr(t,e);function ts(t,e,r,n){Fr(t);const s=Qn({dkLen:32,asyncTick:10},n),{c:i,dkLen:a,asyncTick:o}=s;if(Fe(i),Fe(a),Fe(o),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=Ke(e),d=Ke(r),h=new Uint8Array(a),l=Kr.create(t,c),g=l._cloneInto().update(d);return{c:i,dkLen:a,asyncTick:o,DK:h,PRF:l,PRFSalt:g}}function rs(t,e,r,n,s){return t.destroy(),e.destroy(),n&&n.destroy(),s.fill(0),r}function ns(t,e,r,n){const{c:s,dkLen:i,DK:a,PRF:o,PRFSalt:c}=ts(t,e,r,n);let d;const h=new Uint8Array(4),l=gt(h),g=new Uint8Array(o.outputLen);for(let y=1,m=0;m<i;y++,m+=o.outputLen){const w=a.subarray(m,m+o.outputLen);l.setInt32(0,y,!1),(d=c._cloneInto(d)).update(h).digestInto(g),w.set(g.subarray(0,w.length));for(let b=1;b<s;b++){o._cloneInto(d).update(g).digestInto(g);for(let I=0;I<w.length;I++)w[I]^=g[I]}}return rs(o,c,a,d,g)}function ss(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const s=BigInt(32),i=BigInt(4294967295),a=Number(r>>s&i),o=Number(r&i),c=n?4:0,d=n?0:4;t.setUint32(e+c,a,n),t.setUint32(e+d,o,n)}class is extends qr{constructor(e,r,n,s){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=gt(this.buffer)}update(e){St(this);const{view:r,buffer:n,blockLen:s}=this;e=Ke(e);const i=e.length;for(let a=0;a<i;){const o=Math.min(s-this.pos,i-a);if(o===s){const c=gt(e);for(;s<=i-a;a+=s)this.process(c,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){St(this),Jn(e,this),this.finished=!0;const{buffer:r,view:n,blockLen:s,isLE:i}=this;let{pos:a}=this;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>s-a&&(this.process(n,0),a=0);for(let l=a;l<s;l++)r[l]=0;ss(n,s-8,BigInt(this.length*8),i),this.process(n,0);const o=gt(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=c/4,h=this.get();if(d>h.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)o.setUint32(4*l,h[l],i)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:n,length:s,finished:i,destroyed:a,pos:o}=this;return e.length=s,e.pos=o,e.finished=i,e.destroyed=a,s%r&&e.buffer.set(n),e}}const ct=BigInt(2**32-1),Nt=BigInt(32);function Gr(t,e=!1){return e?{h:Number(t&ct),l:Number(t>>Nt&ct)}:{h:Number(t>>Nt&ct)|0,l:Number(t&ct)|0}}function as(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:i,l:a}=Gr(t[s],e);[r[s],n[s]]=[i,a]}return[r,n]}const os=(t,e)=>BigInt(t>>>0)<<Nt|BigInt(e>>>0),cs=(t,e,r)=>t>>>r,us=(t,e,r)=>t<<32-r|e>>>r,ds=(t,e,r)=>t>>>r|e<<32-r,ls=(t,e,r)=>t<<32-r|e>>>r,hs=(t,e,r)=>t<<64-r|e>>>r-32,fs=(t,e,r)=>t>>>r-32|e<<64-r,gs=(t,e)=>e,ps=(t,e)=>t,ys=(t,e,r)=>t<<r|e>>>32-r,ms=(t,e,r)=>e<<r|t>>>32-r,ws=(t,e,r)=>e<<r-32|t>>>64-r,bs=(t,e,r)=>t<<r-32|e>>>64-r;function Ss(t,e,r,n){const s=(e>>>0)+(n>>>0);return{h:t+r+(s/2**32|0)|0,l:s|0}}const Ts=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),xs=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Es=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),vs=(t,e,r,n,s)=>e+r+n+s+(t/2**32|0)|0,ks=(t,e,r,n,s)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(s>>>0),Is=(t,e,r,n,s,i)=>e+r+n+s+i+(t/2**32|0)|0,T={fromBig:Gr,split:as,toBig:os,shrSH:cs,shrSL:us,rotrSH:ds,rotrSL:ls,rotrBH:hs,rotrBL:fs,rotr32H:gs,rotr32L:ps,rotlSH:ys,rotlSL:ms,rotlBH:ws,rotlBL:bs,add:Ss,add3L:Ts,add3H:xs,add4L:Es,add4H:vs,add5H:Is,add5L:ks},[As,_s]=T.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),we=new Uint32Array(80),be=new Uint32Array(80);class Bs extends is{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:n,Bl:s,Ch:i,Cl:a,Dh:o,Dl:c,Eh:d,El:h,Fh:l,Fl:g,Gh:y,Gl:m,Hh:w,Hl:b}=this;return[e,r,n,s,i,a,o,c,d,h,l,g,y,m,w,b]}set(e,r,n,s,i,a,o,c,d,h,l,g,y,m,w,b){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=s|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=c|0,this.Eh=d|0,this.El=h|0,this.Fh=l|0,this.Fl=g|0,this.Gh=y|0,this.Gl=m|0,this.Hh=w|0,this.Hl=b|0}process(e,r){for(let x=0;x<16;x++,r+=4)we[x]=e.getUint32(r),be[x]=e.getUint32(r+=4);for(let x=16;x<80;x++){const $=we[x-15]|0,D=be[x-15]|0,L=T.rotrSH($,D,1)^T.rotrSH($,D,8)^T.shrSH($,D,7),H=T.rotrSL($,D,1)^T.rotrSL($,D,8)^T.shrSL($,D,7),z=we[x-2]|0,ue=be[x-2]|0,at=T.rotrSH(z,ue,19)^T.rotrBH(z,ue,61)^T.shrSH(z,ue,6),Bt=T.rotrSL(z,ue,19)^T.rotrBL(z,ue,61)^T.shrSL(z,ue,6),ot=T.add4L(H,Bt,be[x-7],be[x-16]),Ot=T.add4H(ot,L,at,we[x-7],we[x-16]);we[x]=Ot|0,be[x]=ot|0}let{Ah:n,Al:s,Bh:i,Bl:a,Ch:o,Cl:c,Dh:d,Dl:h,Eh:l,El:g,Fh:y,Fl:m,Gh:w,Gl:b,Hh:I,Hl:O}=this;for(let x=0;x<80;x++){const $=T.rotrSH(l,g,14)^T.rotrSH(l,g,18)^T.rotrBH(l,g,41),D=T.rotrSL(l,g,14)^T.rotrSL(l,g,18)^T.rotrBL(l,g,41),L=l&y^~l&w,H=g&m^~g&b,z=T.add5L(O,D,H,_s[x],be[x]),ue=T.add5H(z,I,$,L,As[x],we[x]),at=z|0,Bt=T.rotrSH(n,s,28)^T.rotrBH(n,s,34)^T.rotrBH(n,s,39),ot=T.rotrSL(n,s,28)^T.rotrBL(n,s,34)^T.rotrBL(n,s,39),Ot=n&i^n&o^i&o,Wn=s&a^s&c^a&c;I=w|0,O=b|0,w=y|0,b=m|0,y=l|0,m=g|0,{h:l,l:g}=T.add(d|0,h|0,ue|0,at|0),d=o|0,h=c|0,o=i|0,c=a|0,i=n|0,a=s|0;const Cr=T.add3L(at,ot,Wn);n=T.add3H(Cr,ue,Bt,Ot),s=Cr|0}({h:n,l:s}=T.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:a}=T.add(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:c}=T.add(this.Ch|0,this.Cl|0,o|0,c|0),{h:d,l:h}=T.add(this.Dh|0,this.Dl|0,d|0,h|0),{h:l,l:g}=T.add(this.Eh|0,this.El|0,l|0,g|0),{h:y,l:m}=T.add(this.Fh|0,this.Fl|0,y|0,m|0),{h:w,l:b}=T.add(this.Gh|0,this.Gl|0,w|0,b|0),{h:I,l:O}=T.add(this.Hh|0,this.Hl|0,I|0,O|0),this.set(n,s,i,a,o,c,d,h,l,g,y,m,w,b,I,O)}roundClean(){we.fill(0),be.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Os=es(()=>new Bs);/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */function Zr(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function Cs(t){const e=Zr(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}const js=t=>Zr(`mnemonic${t}`);function Us(t,e=""){return ns(Os,Cs(t).nfkd,js(e),{c:2048,dkLen:64})}function Ms(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=n}var a=t.length,o=t.charAt(0),c=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function h(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var m=0,w=0,b=0,I=y.length;b!==I&&y[b]===0;)b++,m++;for(var O=(I-b)*d+1>>>0,x=new Uint8Array(O);b!==I;){for(var $=y[b],D=0,L=O-1;($!==0||D<w)&&L!==-1;L--,D++)$+=256*x[L]>>>0,x[L]=$%a>>>0,$=$/a>>>0;if($!==0)throw new Error("Non-zero carry");w=D,b++}for(var H=O-w;H!==O&&x[H]===0;)H++;for(var z=o.repeat(m);H<O;++H)z+=t.charAt(x[H]);return z}function l(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;for(var m=0,w=0,b=0;y[m]===o;)w++,m++;for(var I=(y.length-m)*c+1>>>0,O=new Uint8Array(I);y[m];){var x=e[y.charCodeAt(m)];if(x===255)return;for(var $=0,D=I-1;(x!==0||$<b)&&D!==-1;D--,$++)x+=a*O[D]>>>0,O[D]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");b=$,m++}for(var L=I-b;L!==I&&O[L]===0;)L++;for(var H=new Uint8Array(w+(I-L)),z=w;L!==I;)H[z++]=O[L++];return H}function g(y){var m=l(y);if(m)return m;throw new Error("Non-base"+a+" character")}return{encode:h,decodeUnsafe:l,decode:g}}var Ps=Ms;const Rs=Ps,$s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var Ns=Rs($s);const Jr=S.getDefaultExportFromCjs(Ns),tt=t=>Jr.encode(t),rt=t=>Jr.decode(t);function ne(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const Ct=8192;function W(t){if(t.length<Ct)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=Ct){const n=t.slice(r,r+Ct);e+=String.fromCharCode(...n)}return btoa(e)}function nt(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 Ce(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function Xt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function Ds(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 Xr{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}=Ds(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 Ls(t,e){switch(e){case"base58":return tt(t);case"base64":return W(t);case"hex":return Ce(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function zs(t,e){switch(e){case"base58":return rt(t);case"base64":return ne(t);case"hex":return nt(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Yr(t,e=["<",">"]){const[r,n]=e,s=[];let i="",a=0;for(let o=0;o<t.length;o++){const c=t[o];if(c===r&&a++,c===n&&a--,a===0&&c===","){s.push(i.trim()),i="";continue}i+=c}return s.push(i.trim()),s}class Qr{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 jt(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return jt(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return jt(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return Xt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,s)=>r(this,n,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return Ls(this.toBytes(),e)}}function jt(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 en=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},Q=(t,e,r)=>(en(t,e,"read from private field"),r?r.call(t):e.get(t)),Tt=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},xt=(t,e,r,n)=>(en(t,e,"write to private field"),e.set(t,r),r),je,De,pt,Te;const tn=class{constructor(t){Tt(this,je,void 0),Tt(this,De,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),xt(this,je,t.write),xt(this,De,t.serialize??((e,r)=>{const n=new Qr({size:this.serializedSize(e)??void 0,...r});return Q(this,je).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),Q(this,je).call(this,t,e)}serialize(t,e){return this.validate(t),new Vs(this,Q(this,De).call(this,t,e))}parse(t){const e=new Xr(t);return this.read(e)}transform({name:t,input:e,output:r}){return new tn({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>Q(this,je).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>Q(this,De).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let te=tn;je=new WeakMap;De=new WeakMap;const rn=Symbol.for("@mysten/serialized-bcs");function Yt(t){return!!t&&typeof t=="object"&&t[rn]===!0}class Vs{constructor(e,r){Tt(this,pt,void 0),Tt(this,Te,void 0),xt(this,pt,e),xt(this,Te,r)}get[rn](){return!0}toBytes(){return Q(this,Te)}toHex(){return Ce(Q(this,Te))}toBase64(){return W(Q(this,Te))}toBase58(){return tt(Q(this,Te))}parse(){return Q(this,pt).parse(Q(this,Te))}}pt=new WeakMap;Te=new WeakMap;function Et({size:t,...e}){return new te({...e,serializedSize:()=>t})}function Ut({readMethod:t,writeMethod:e,...r}){return Et({...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 Mt({readMethod:t,writeMethod:e,...r}){return Et({...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 Hs({serialize:t,...e}){const r=new te({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function Fs({toBytes:t,fromBytes:e,...r}){return new te({...r,read:n=>{const s=n.readULEB(),i=n.readBytes(s);return e(i)},write:(n,s)=>{const i=t(n);s.writeULEB(i.length);for(let a=0;a<i.length;a++)s.write8(i[a])},serialize:n=>{const s=t(n),i=Xt(s.length),a=new Uint8Array(i.length+s.length);return a.set(i,0),a.set(s,i.length),a},validate:n=>{var s;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(s=r.validate)==null||s.call(r,n)}})}function qs(t){let e=null;function r(){return e||(e=t()),e}return new te({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 u={u8(t){return Ut({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return Ut({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return Ut({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return Mt({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return Mt({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return Mt({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Et({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 Hs({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Xt(e)),...t})},bytes(t,e){return Et({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 Fs({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new te({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 u.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 te({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 te({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 te({name:t,serializedSize:s=>{let i=0;for(const[a,o]of n){const c=o.serializedSize(s[a]);if(c==null)return null;i+=c}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 te({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 c=0;c<n.length;c++){const[d,h]=n[c];if(d===a){i.writeULEB(c),h==null||h.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 u.vector(u.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 qs(t)}},Ws=32,Le=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof Le){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(Le.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&&Ks(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 Le(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
2
2
|
${JSON.stringify(t)}`)}de(t,e,r){if(typeof e=="string")if(r)e=zs(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 Le(this),s=this.tempKey();return n.registerStructType(s,t).de(s,e,r)}throw new Error(`Incorrect type passed into the '.de()' function.
|
|
3
3
|
${JSON.stringify(t)}`)}hasType(t){return this.types.has(t)}registerAlias(t,e){return this.types.set(t,e),this}registerType(t,e,r,n=()=>!0){const{name:s,params:i}=this.parseTypeName(t);return this.types.set(s,{encode(a,o,c,d){const h=i.reduce((l,g,y)=>Object.assign(l,{[g]:d[y]}),{});return this._encodeRaw.call(a,new Qr(c),o,d,h)},decode(a,o,c){const d=i.reduce((h,l,g)=>Object.assign(h,{[l]:c[g]}),{});return this._decodeRaw.call(a,new Xr(o),c,d)},_encodeRaw(a,o,c,d){if(n(o))return e.call(this,a,o,c,d);throw new Error(`Validation failed for type ${s}, data: ${o}`)},_decodeRaw(a,o,c){return r.call(this,a,o,c)}}),this}registerBcsType(t,e){return this.registerType(t,(r,n,s)=>{const i=s.map(a=>new te({name:String(a),write:(o,c)=>{const{name:d,params:h}=this.parseTypeName(a),l=this.getTypeInterface(d),g=h.reduce((y,m,w)=>Object.assign(y,{[m]:s[w]}),{});return l._encodeRaw.call(this,c,o,h,g)},read:()=>{throw new Error("Not implemented")}}));return e(...i).write(n,r),r},(r,n)=>{const s=n.map(i=>new te({name:String(i),write:(a,o)=>{throw new Error("Not implemented")},read:a=>{const{name:o,params:c}=this.parseTypeName(i),d=this.getTypeInterface(o),h=c.reduce((l,g,y)=>Object.assign(l,{[g]:n[y]}),{});return d._decodeRaw.call(this,a,c,h)}}));return e(...s).read(r)}),this}registerAddressType(t,e,r="hex"){switch(r){case"base64":return this.registerType(t,function(s,i){return ne(i).reduce((a,o)=>a.write8(o),s)},function(s){return W(s.readBytes(e))});case"hex":return this.registerType(t,function(s,i){return nt(i).reduce((a,o)=>a.write8(o),s)},function(s){return Ce(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,(c,d)=>{let h=a[0];if(!h)throw new Error(`Incorrect number of type parameters passed a to vector '${t}'`);let{name:l,params:g}=this.parseTypeName(h);if(this.hasType(l))return this.getTypeInterface(l)._encodeRaw.call(this,c,d,g,o);if(!(l in o))throw new Error(`Unable to find a matching type definition for ${l} in vector; make sure you passed a generic`);let{name:y,params:m}=this.parseTypeName(o[l]);return this.getTypeInterface(y)._encodeRaw.call(this,c,d,m,o)})},function(s,i,a){return s.readVec(o=>{let c=i[0];if(!c)throw new Error(`Incorrect number of type parameters passed to a vector '${t}'`);let{name:d,params:h}=this.parseTypeName(c);if(this.hasType(d))return this.getTypeInterface(d)._decodeRaw.call(this,o,h,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:l,params:g}=this.parseTypeName(a[d]);return this.getTypeInterface(l)._decodeRaw.call(this,o,g,a)})})}registerStructType(t,e){for(let a in e){let o=this.tempKey(),c=e[a];!Array.isArray(c)&&typeof c!="string"&&(e[a]=o,this.registerStructType(o,c))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,c,d,h){if(!c||c.constructor!==Object)throw new Error(`Expected ${s} to be an Object, got: ${c}`);if(d.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${d.length}`);for(let l of n){if(!(l in c))throw new Error(`Struct ${s} requires field ${l}:${r[l]}`);const{name:g,params:y}=this.parseTypeName(r[l]);if(!i.includes(g))this.getTypeInterface(g)._encodeRaw.call(this,o,c[l],y,h);else{const m=i.indexOf(g);let{name:w,params:b}=this.parseTypeName(d[m]);if(this.hasType(w)){this.getTypeInterface(w)._encodeRaw.call(this,o,c[l],b,h);continue}if(!(w in h))throw new Error(`Unable to find a matching type definition for ${w} in ${s}; make sure you passed a generic`);let{name:I,params:O}=this.parseTypeName(h[w]);this.getTypeInterface(I)._encodeRaw.call(this,o,c[l],O,h)}}return o},function(o,c,d){if(c.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${c.length}`);let h={};for(let l of n){const{name:g,params:y}=this.parseTypeName(r[l]);if(!i.includes(g))h[l]=this.getTypeInterface(g)._decodeRaw.call(this,o,y,d);else{const m=i.indexOf(g);let{name:w,params:b}=this.parseTypeName(c[m]);if(this.hasType(w)){h[l]=this.getTypeInterface(w)._decodeRaw.call(this,o,b,d);continue}if(!(w in d))throw new Error(`Unable to find a matching type definition for ${w} in ${s}; make sure you passed a generic`);let{name:I,params:O}=this.parseTypeName(d[w]);h[l]=this.getTypeInterface(I)._decodeRaw.call(this,o,O,d)}}return h})}registerEnumType(t,e){for(let a in e){let o=this.tempKey(),c=e[a];c!==null&&!Array.isArray(c)&&typeof c!="string"&&(e[a]=o,this.registerStructType(o,c))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,c,d,h){if(!c)throw new Error(`Unable to write enum "${s}", missing data.
|
|
4
4
|
Received: "${c}"`);if(typeof c!="object")throw new Error(`Incorrect data passed into enum "${s}", expected object with properties: "${n.join(" | ")}".
|
|
5
|
-
Received: "${JSON.stringify(c)}"`);let l=Object.keys(c)[0];if(l===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let g=n.indexOf(l);if(g===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${l}"`);let y=n[g],m=r[y];if(o.write8(g),m===null)return o;let w=i.indexOf(m),b=w===-1?m:d[w];{let{name:I,params:O}=this.parseTypeName(b);return this.getTypeInterface(I)._encodeRaw.call(this,o,c[l],O,h)}},function(o,c,d){let h=o.readULEB(),l=n[h],g=r[l];if(h===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${h}"`);if(g===null)return{[l]:!0};let y=i.indexOf(g),m=y===-1?g:c[y];{let{name:w,params:b}=this.parseTypeName(m);return{[l]:this.getTypeInterface(w)._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,...c]=t;return{name:o,params:c}}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=Yr(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let C=Le;C.U8="u8";C.U16="u16";C.U32="u32";C.U64="u64";C.U128="u128";C.U256="u256";C.BOOL="bool";C.VECTOR="vector";C.ADDRESS="address";C.STRING="string";C.HEX="hex-string";C.BASE58="base58-string";C.BASE64="base64-string";function Ks(t){t.registerType(C.U8,function(e,r){return e.write8(r)},function(e){return e.read8()},e=>e<256),t.registerType(C.U16,function(e,r){return e.write16(r)},function(e){return e.read16()},e=>e<65536),t.registerType(C.U32,function(e,r){return e.write32(r)},function(e){return e.read32()},e=>e<=4294967296n),t.registerType(C.U64,function(e,r){return e.write64(r)},function(e){return e.read64()}),t.registerType(C.U128,function(e,r){return e.write128(r)},function(e){return e.read128()}),t.registerType(C.U256,function(e,r){return e.write256(r)},function(e){return e.read256()}),t.registerType(C.BOOL,function(e,r){return e.write8(r)},function(e){return e.read8().toString(10)==="1"}),t.registerType(C.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(C.HEX,function(e,r){return e.writeVec(Array.from(nt(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return Ce(new Uint8Array(r))}),t.registerType(C.BASE58,function(e,r){return e.writeVec(Array.from(rt(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return tt(new Uint8Array(r))}),t.registerType(C.BASE64,function(e,r){return e.writeVec(Array.from(ne(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return W(new Uint8Array(r))})}function Gs(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Ws,addressEncoding:"hex"}}const Zs=32;function jr(t){try{return rt(t).length===Zs}catch{return!1}}const st=32;function he(t){return Js(t)&&Xs(t)===st}function ut(t){return he(t)}function j(t,e=!1){let r=t.toLowerCase();return!e&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(st*2,"0")}`}function ae(t,e=!1){return j(t,e)}function Js(t){return/^(0x|0X)?[a-fA-F0-9]+$/.test(t)&&t.length%2===0}function Xs(t){return/^(0x|0X)/.test(t)?(t.length-2)/2:t.length/2}class Ys extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:o}=e,c=o.length===0?s:`At path: ${o.join(".")} -- ${s}`;super(i??c),i!=null&&(this.cause=c),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Qs(t){return J(t)&&typeof t[Symbol.iterator]=="function"}function J(t){return typeof t=="object"&&t!=null}function X(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function ei(t){const{done:e,value:r}=t.next();return e?void 0:r}function ti(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:c=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${X(n)}\``}=t;return{value:n,type:a,refinement:o,key:s[s.length-1],path:s,branch:i,...t,message:c}}function*Ur(t,e,r,n){Qs(t)||(t=[t]);for(const s of t){const i=ti(s,e,r,n);i&&(yield i)}}function*Qt(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"&&J(e.schema)&&J(t)&&!Array.isArray(t)))for(const d in t)e.schema[d]===void 0&&delete t[d];let c="valid";for(const d of e.validator(t,o))d.explanation=r.message,c="not_valid",yield[d,void 0];for(let[d,h,l]of e.entries(t,o)){const g=Qt(h,l,{path:d===void 0?n:[...n,d],branch:d===void 0?s:[...s,h],coerce:i,mask:a,message:r.message});for(const y of g)y[0]?(c=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):i&&(h=y[1],d===void 0?t=h:t instanceof Map?t.set(d,h):t instanceof Set?t.add(h):J(t)&&(h!==void 0||d in t)&&(t[d]=h))}if(c!=="not_valid")for(const d of e.refiner(t,o))d.explanation=r.message,c="not_refined",yield[d,void 0];c==="valid"&&(yield[void 0,t])}class ce{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=c=>c,entries:o=function*(){}}=e;this.type=r,this.schema=n,this.entries=o,this.coercer=a,s?this.validator=(c,d)=>{const h=s(c,d);return Ur(h,d,this,c)}:this.validator=()=>[],i?this.refiner=(c,d)=>{const h=i(c,d);return Ur(h,d,this,c)}:this.refiner=()=>[]}assert(e,r){return Dt(e,this,r)}create(e,r){return nn(e,this,r)}is(e){return K(e,this)}mask(e,r){return sn(e,this,r)}validate(e,r={}){return it(e,this,r)}}function Dt(t,e,r){const n=it(t,e,{message:r});if(n[0])throw n[0]}function nn(t,e,r){const n=it(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function sn(t,e,r){const n=it(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function K(t,e){return!it(t,e)[0]}function it(t,e,r={}){const n=Qt(t,e,r),s=ei(n);return s[0]?[new Ys(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Ge(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?ni(n):p(n)}function G(t,e){return new ce({type:t,schema:null,validator:e})}function Lt(){return G("any",()=>!0)}function A(t){return new ce({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: ${X(e)}`}})}function ri(){return G("bigint",t=>typeof t=="bigint")}function V(){return G("boolean",t=>typeof t=="boolean")}function oe(){return G("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${X(t)}`)}function v(t){const e=X(t),r=typeof t;return new ce({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${X(n)}`}})}function an(){return G("never",()=>!1)}function P(t){return new ce({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function _e(){return G("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${X(t)}`)}function p(t){const e=t?Object.keys(t):[],r=an();return new ce({type:"object",schema:t||null,*entries(n){if(t&&J(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 J(n)||`Expected an object, but received: ${X(n)}`},coercer(n){return J(n)?{...n}:n}})}function E(t){return new ce({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function se(t,e){return new ce({type:"record",schema:null,*entries(r){if(J(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return J(r)||`Expected an object, but received: ${X(r)}`}})}function f(){return G("string",t=>typeof t=="string"||`Expected a string, but received: ${X(t)}`)}function on(t){const e=an();return new ce({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: ${X(r)}`}})}function ni(t){const e=Object.keys(t);return new ce({type:"type",schema:t,*entries(r){if(J(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return J(r)||`Expected an object, but received: ${X(r)}`},coercer(r){return J(r)?{...r}:r}})}function R(t){const e=t.map(r=>r.type).join(" | ");return new ce({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]=Qt(r,i,n),[o]=a;if(o[0])for(const[c]of a)c&&s.push(c);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${X(r)}`,...s]}})}function cn(){return G("unknown",()=>!0)}BigInt(1e9);const er="0x1",un="0x2";ae("0x6");const si=`${un}::sui::SUI`;ae("0x5");const Ue="::",ii="0x2::sui::SUI",ai="0.50.1",oi="1.19.0",ci={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class dn extends Error{}class ln extends dn{constructor(e,r){super(e),this.code=r,this.type=ci[r]??"ServerError"}}class ui extends dn{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var tr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},U=(t,e,r)=>(tr(t,e,"read from private field"),r?r.call(t):e.get(t)),Se=(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)},Pe=(t,e,r,n)=>(tr(t,e,"write to private field"),e.set(t,r),r),di=(t,e,r,n)=>({set _(s){Pe(t,e,s)},get _(){return U(t,e,n)}}),hn=(t,e,r)=>(tr(t,e,"access private method"),r),ke,qe,fe,Ae,Ze,Re,zt,fn,rr,gn;function li(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const hi={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class fi{constructor(e,r={}){if(Se(this,zt),Se(this,rr),Se(this,ke,0),Se(this,qe,0),Se(this,fe,null),Se(this,Ae,null),Se(this,Ze,new Set),Se(this,Re,new Map),this.endpoint=e,this.options={...hi,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=li(this.endpoint))}async makeRequest(e,r){const n=await hn(this,zt,fn).call(this);return new Promise((s,i)=>{Pe(this,ke,U(this,ke)+1),U(this,Re).set(U(this,ke),{resolve:s,reject:i,timeout:setTimeout(()=>{U(this,Re).delete(U(this,ke)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:U(this,ke),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new ln(s.message,s.code);return i})}async subscribe(e){const r=new gi(e);return U(this,Ze).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}ke=new WeakMap;qe=new WeakMap;fe=new WeakMap;Ae=new WeakMap;Ze=new WeakMap;Re=new WeakMap;zt=new WeakSet;fn=function(){return U(this,Ae)?U(this,Ae):(Pe(this,Ae,new Promise(t=>{var e;(e=U(this,fe))==null||e.close(),Pe(this,fe,new this.options.WebSocketConstructor(this.endpoint)),U(this,fe).addEventListener("open",()=>{Pe(this,qe,0),t(U(this,fe))}),U(this,fe).addEventListener("close",()=>{di(this,qe)._++,U(this,qe)<=this.options.maxReconnects&&setTimeout(()=>{hn(this,rr,gn).call(this)},this.options.reconnectTimeout)}),U(this,fe).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&&U(this,Re).has(n.id)){const{resolve:s,timeout:i}=U(this,Re).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;U(this,Ze).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),U(this,Ae))};rr=new WeakSet;gn=async function(){var t;return(t=U(this,fe))==null||t.close(),Pe(this,Ae,null),Promise.allSettled([...U(this,Ze)].map(e=>e.subscribe(this)))};class gi{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 nr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},Z=(t,e,r)=>(nr(t,e,"read from private field"),r?r.call(t):e.get(t)),dt=(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)=>(nr(t,e,"write to private field"),e.set(t,r),r),pi=(t,e,r)=>(nr(t,e,"access private method"),r),ze,ee,We,Ht,pn;class yi{constructor(e){dt(this,Ht),dt(this,ze,0),dt(this,ee,void 0),dt(this,We,void 0),Vt(this,ee,e)}fetch(e,r){const n=Z(this,ee).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,ze,Z(this,ze)+1);const r=await this.fetch(((s=Z(this,ee).rpc)==null?void 0:s.url)??Z(this,ee).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":ai,"Client-Target-Api-Version":oi,...(i=Z(this,ee).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:Z(this,ze),method:e.method,params:e.params})});if(!r.ok)throw new ui(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new ln(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await pi(this,Ht,pn).call(this).subscribe(e);return async()=>!!await r()}}ze=new WeakMap;ee=new WeakMap;We=new WeakMap;Ht=new WeakSet;pn=function(){var t;if(!Z(this,We)){const e=Z(this,ee).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,We,new fi(((t=Z(this,ee).websocket)==null?void 0:t.url)??Z(this,ee).url,{WebSocketConstructor:e,...Z(this,ee).websocket}))}return Z(this,We)};const mi=/^vector<(.+)>$/,wi=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class ge{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(mi);if(n)return{vector:ge.parseFromStr(n[1],r)};const s=e.match(wi);if(s)return{struct:{address:r?j(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:ge.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return Yr(e).map(n=>ge.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<${ge.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(ge.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const B=new C({...Gs(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function yn(t){return u.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function bi(t){return u.enum("Option",{None:null,Some:t})}function sr(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const re=u.bytes(st).transform({input:t=>typeof t=="string"?nt(j(t)):t,output:t=>j(Ce(t))}),ir=u.vector(u.u8()).transform({name:"ObjectDigest",input:t=>rt(t),output:t=>tt(new Uint8Array(t))}),Je=u.struct("SuiObjectRef",{objectId:re,version:u.u64(),digest:ir}),ar=u.struct("SharedObjectRef",{objectId:re,initialSharedVersion:u.u64(),mutable:u.bool()}),vt=u.enum("ObjectArg",{ImmOrOwned:Je,Shared:ar,Receiving:Je}),or=u.enum("CallArg",{Pure:u.vector(u.u8()),Object:vt,ObjVec:u.vector(vt)}),Ne=u.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:u.lazy(()=>Ne),struct:u.lazy(()=>fr),u16:null,u32:null,u256:null}),Y=sr(u.enum("Argument",{GasCoin:null,Input:u.struct("Input",{index:u.u16()}),Result:u.struct("Result",{index:u.u16()}),NestedResult:u.struct("NestedResult",{index:u.u16(),resultIndex:u.u16()})})),cr=u.struct("ProgrammableMoveCall",{package:re,module:u.string(),function:u.string(),type_arguments:u.vector(Ne),arguments:u.vector(Y)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>ge.parseFromStr(i,!0));return{package:j(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(ge.tagToString)})}),ur=sr(u.enum("Transaction",{MoveCall:cr,TransferObjects:u.struct("TransferObjects",{objects:u.vector(Y),address:Y}),SplitCoins:u.struct("SplitCoins",{coin:Y,amounts:u.vector(Y)}),MergeCoins:u.struct("MergeCoins",{destination:Y,sources:u.vector(Y)}),Publish:u.struct("Publish",{modules:u.vector(u.vector(u.u8())),dependencies:u.vector(re)}),MakeMoveVec:u.struct("MakeMoveVec",{type:bi(Ne),objects:u.vector(Y)}),Upgrade:u.struct("Upgrade",{modules:u.vector(u.vector(u.u8())),dependencies:u.vector(re),packageId:re,ticket:Y})})),dr=u.struct("ProgrammableTransaction",{inputs:u.vector(or),transactions:u.vector(ur)}),lr=u.enum("TransactionKind",{ProgrammableTransaction:dr,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),hr=u.enum("TransactionExpiration",{None:null,Epoch:yn()}),fr=u.struct("StructTag",{address:re,module:u.string(),name:u.string(),typeParams:u.vector(Ne)}),gr=u.struct("GasData",{payment:u.vector(Je),owner:re,price:u.u64(),budget:u.u64()}),pr=u.struct("TransactionDataV1",{kind:lr,sender:re,gasData:gr,expiration:hr}),yr=u.enum("TransactionData",{V1:pr}),Si=u.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Ti=u.enum("IntentVersion",{V0:null}),xi=u.enum("AppId",{Sui:null}),Ei=u.struct("Intent",{scope:Si,version:Ti,appId:xi}),vi=u.generic(["T"],t=>u.struct("IntentMessage<T>",{intent:Ei,value:t})),mr=u.enum("CompressedSignature",{ED25519:u.fixedArray(64,u.u8()),Secp256k1:u.fixedArray(64,u.u8()),Secp256r1:u.fixedArray(64,u.u8()),ZkLogin:u.vector(u.u8())}),wr=u.enum("PublicKey",{ED25519:u.fixedArray(32,u.u8()),Secp256k1:u.fixedArray(33,u.u8()),Secp256r1:u.fixedArray(33,u.u8()),ZkLogin:u.vector(u.u8())}),br=u.struct("MultiSigPkMap",{pubKey:wr,weight:u.u8()}),Sr=u.struct("MultiSigPublicKey",{pk_map:u.vector(br),threshold:u.u16()}),mn=u.struct("MultiSig",{sigs:u.vector(mr),bitmap:u.u16(),multisig_pk:Sr}),ki=u.vector(u.u8()).transform({input:t=>typeof t=="string"?ne(t):t,output:t=>W(new Uint8Array(t))}),wn=u.struct("SenderSignedTransaction",{intentMessage:vi(yr),txSignatures:u.vector(ki)}),bn=u.vector(wn,{name:"SenderSignedData"}),M={...u,U8:u.u8(),U16:u.u16(),U32:u.u32(),U64:u.u64(),U128:u.u128(),U256:u.u256(),ULEB128:u.uleb128(),Bool:u.bool(),String:u.string(),Address:re,Argument:Y,CallArg:or,CompressedSignature:mr,GasData:gr,MultiSig:mn,MultiSigPkMap:br,MultiSigPublicKey:Sr,ObjectArg:vt,ObjectDigest:ir,ProgrammableMoveCall:cr,ProgrammableTransaction:dr,PublicKey:wr,SenderSignedData:bn,SenderSignedTransaction:wn,SharedObjectRef:ar,StructTag:fr,SuiObjectRef:Je,Transaction:ur,TransactionData:yr,TransactionDataV1:pr,TransactionExpiration:hr,TransactionKind:lr,TypeTag:Ne,ser:B.ser.bind(B),de:B.de.bind(B),getTypeInterface:B.getTypeInterface.bind(B),hasType:B.hasType.bind(B),parseTypeName:B.parseTypeName.bind(B),registerAddressType:B.registerAddressType.bind(B),registerAlias:B.registerAlias.bind(B),registerBcsType:B.registerBcsType.bind(B),registerEnumType:B.registerEnumType.bind(B),registerStructType:B.registerStructType.bind(B),registerType:B.registerType.bind(B),types:B.types};B.registerBcsType("utf8string",()=>u.string({name:"utf8string"}));B.registerBcsType("unsafe_u64",()=>yn());B.registerBcsType("enumKind",t=>sr(t));[re,Y,or,mr,gr,mn,br,Sr,vt,ir,cr,dr,wr,bn,ar,fr,Je,ur,yr,pr,hr,lr,Ne].forEach(t=>{B.registerBcsType(t.name,()=>t)});const Tr=R([p({AddressOwner:f()}),p({ObjectOwner:f()}),p({Shared:p({initial_shared_version:P(f())})}),v("Immutable")]);G("SuiJsonValue",()=>!0);const Ii=R([p({u32:f()}),p({u64:f()}),p({f64:f()})]);p({attributes:se(f(),P(Ii)),featureFlags:se(f(),V()),maxSupportedProtocolVersion:f(),minSupportedProtocolVersion:f(),protocolVersion:f()});R([f(),v("package")]);const xe=p({digest:f(),objectId:f(),version:R([_e(),f(),ri()])});p({owner:Tr,reference:xe});p({objectId:f(),sequenceNumber:f()});p({payment:A(xe),owner:f(),price:f(),budget:f()});const Ai=Ge(xe,p({type:f(),owner:Tr,previousTransaction:f()})),_i=se(f(),Lt()),Bi=se(f(),cn()),Oi=p({type:f(),fields:_i,hasPublicTransfer:V()}),Ci=p({disassembled:Bi}),ji=R([Ge(Oi,p({dataType:v("moveObject")})),Ge(Ci,p({dataType:v("package")}))]),Ui=p({type:f(),hasPublicTransfer:V(),version:f(),bcsBytes:f()}),Mi=p({id:f(),moduleMap:se(f(),f())}),Pi=R([Ge(Ui,p({dataType:v("moveObject")})),Ge(Mi,p({dataType:v("package")}))]);BigInt(1e9);const Sn=p({code:f(),error:E(f()),object_id:E(f()),parent_object_id:E(f()),version:E(f()),digest:E(f())}),Ri=p({data:P(E(se(f(),f()))),error:P(E(Sn))}),$i=R([Ri,E(se(f(),f()))]),Tn=p({objectId:f(),version:f(),digest:f(),type:P(E(f())),content:P(E(ji)),bcs:P(E(Pi)),owner:P(E(Tr)),previousTransaction:P(E(f())),storageRebate:P(E(f())),display:P(E($i))});p({showType:P(E(V())),showContent:P(E(V())),showBcs:P(E(V())),showOwner:P(E(V())),showPreviousTransaction:P(E(V())),showStorageRebate:P(E(V())),showDisplay:P(E(V()))});R([v("Exists"),v("notExists"),v("Deleted")]);A(Ai);const Ni=p({data:P(E(Tn)),error:P(E(Sn))});function Di(t){return t.data}function Li(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=Di(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:Li(t)}p({objectId:f(),atCheckpoint:E(_e())});p({data:A(Ni),nextCursor:E(P(f())),hasNextPage:V()});R([p({details:Tn,status:v("VersionFound")}),p({details:f(),status:v("ObjectNotExists")}),p({details:xe,status:v("ObjectDeleted")}),p({details:on([f(),_e()]),status:v("VersionNotFound")}),p({details:p({asked_version:_e(),latest_version:_e(),object_id:f()}),status:v("VersionTooHigh")})]);const zi=R([f(),p({Object:f()})]);A(zi);const Vi=p({address:f(),name:f()}),Hi=R([v("Private"),v("Public"),v("Friend")]),xr=p({abilities:A(f())}),Fi=p({constraints:xr,isPhantom:V()}),qi=p({TypeParameter:_e()}),Pt=on([p({module:f(),package:f(),function:f()}),f()]);p({rank3Days:A(Pt),rank7Days:A(Pt),rank30Days:A(Pt)});function xn(t){if(!t)return!1;if(typeof t=="string"||K(t,qi)||En(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(K(e.Reference,$e)||K(e.MutableReference,$e)||K(e.Vector,$e))}const $e=G("SuiMoveNormalizedType",xn);function En(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=>xn(n)))}G("SuiMoveNormalizedStructType",En);const Wi=p({visibility:Hi,isEntry:V(),typeParameters:A(xr),parameters:A($e),return:A($e)}),Ki=p({name:f(),type:$e}),Gi=p({abilities:xr,typeParameters:A(Fi),fields:A(Ki)}),Zi=p({fileFormatVersion:_e(),address:f(),name:f(),friends:A(Vi),structs:se(f(),Gi),exposedFunctions:se(f(),Wi)});se(f(),Zi);function Ft(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function vn(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function Er(t){if(typeof t=="object"&&"Struct"in t)return t;const e=vn(t),r=Ft(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const Ji=R([p({ImmOrOwned:xe}),p({Shared:p({objectId:f(),initialSharedVersion:R([oe(),f()]),mutable:V()})}),p({Receiving:xe})]),kt=p({Pure:A(oe())}),qt=p({Object:Ji}),It=R([kt,qt]);function Xi(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:Yt(t)?t.toBytes():M.ser(e,t,{maxSize:1/0}).toBytes())}}const q={Pure:Xi,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:j(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:j(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:j(t)}}}}};function Pr(t){return typeof t=="string"?j(t):"ImmOrOwned"in t.Object?j(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?j(t.Object.Receiving.objectId):j(t.Object.Shared.objectId)}function Yi(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function Qi(t){var e;return((e=Yi(t))==null?void 0:e.mutable)??!1}function ea(t){function e(r,n){return t(r,n)}return e.u8=r=>t(M.U8.serialize(r)),e.u16=r=>t(M.U16.serialize(r)),e.u32=r=>t(M.U32.serialize(r)),e.u64=r=>t(M.U64.serialize(r)),e.u128=r=>t(M.U128.serialize(r)),e.u256=r=>t(M.U256.serialize(r)),e.bool=r=>t(M.Bool.serialize(r)),e.string=r=>t(M.String.serialize(r)),e.address=r=>t(M.Address.serialize(r)),e.id=e.address,e}const ta="object",ra="ID",na="ascii",sa="String",ia="string",aa="String",oa="option",ca="Option",ua={address:un,module:ta,name:ra},da={address:er,module:na,name:sa},la={address:er,module:ia,name:aa},ha={address:er,module:oa,name:ca},lt=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function fa(t){var r;const e=(r=Er(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 Rt(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const ga=["Address","Bool","U8","U16","U32","U64","U128","U256"];function Wt(t,e){if(typeof t=="string"&&ga.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])Rt("number",e);else if(t==="Bool")Rt("boolean",e);else if(t==="Address"&&(Rt("string",e),e&&!he(e)))throw new Error("Invalid Sui Address");return t.toLowerCase()}else if(typeof t=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(t,null,2)}`);if("Vector"in t){if((e===void 0||typeof e=="string")&&t.Vector==="U8")return"string";if(e!==void 0&&!Array.isArray(e))throw new Error(`Expect ${e} to be a array, received ${typeof e}`);const r=Wt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(lt(t.Struct,da))return"string";if(lt(t.Struct,la))return"utf8string";if(lt(t.Struct,ua))return"address";if(lt(t.Struct,ha)){const r={Vector:t.Struct.typeArguments[0]};return Wt(r,e)}}}function pa(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),S.blake2b(n,{dkLen:32})}function F(t,e){return nn(t,e)}const ya=t=>R([p({None:R([v(!0),v(null)])}),p({Some:t})]),Xe=R([p({kind:v("Input"),index:oe(),value:E(Lt()),type:E(v("object"))}),p({kind:v("Input"),index:oe(),value:E(Lt()),type:v("pure")})]),ma=[Xe,p({kind:v("GasCoin")}),p({kind:v("Result"),index:oe()}),p({kind:v("NestedResult"),index:oe(),resultIndex:oe()})],ye=R([...ma]),kn=p({kind:v("MoveCall"),target:G("target",f().validator),typeArguments:A(f()),arguments:A(ye)}),In=p({kind:v("TransferObjects"),objects:A(ye),address:ye}),An=p({kind:v("SplitCoins"),coin:ye,amounts:A(ye)}),_n=p({kind:v("MergeCoins"),destination:ye,sources:A(ye)}),Bn=p({kind:v("MakeMoveVec"),type:E(ya(se(f(),cn()))),objects:A(ye)}),On=p({kind:v("Publish"),modules:A(A(oe())),dependencies:A(f())}),Cn=p({kind:v("Upgrade"),modules:A(A(oe())),dependencies:A(f()),packageId:f(),ticket:ye}),wa=[kn,In,An,_n,On,Cn,Bn],ba=R([...wa]),ve={MoveCall(t){return F({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},kn)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=q.Pure(M.Address.serialize(e.value))),F({kind:"TransferObjects",objects:t,address:e},In)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=q.Pure(M.U64.serialize(r.value)))}),F({kind:"SplitCoins",coin:t,amounts:e},An)},MergeCoins(t,e){return F({kind:"MergeCoins",destination:t,sources:e},_n)},Publish({modules:t,dependencies:e}){return F({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(ne(r)):r),dependencies:e.map(r=>ae(r))},On)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return F({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(ne(s)):s),dependencies:e.map(s=>ae(s)),packageId:r,ticket:n},Cn)},MakeMoveVec({type:t,objects:e}){return F({kind:"MakeMoveVec",type:t?{Some:ge.parseFromStr(t)}:{None:null},objects:e},Bn)}},Sa=E(P(R([p({Epoch:oe()}),p({None:R([v(!0),v(null)])})]))),Rr=G("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),Ta=p({budget:E(Rr),price:E(Rr),payment:E(A(xe)),owner:E(f())}),ht=p({version:v(1),sender:E(f()),expiration:Sa,gasConfig:Ta,inputs:A(Xe),transactions:A(ba)});function $r(t){return j(t).replace("0x","")}class pe{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=M.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=F({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>F({kind:"Input",value:i,index:a,type:K(i,kt)?"pure":"object"},Xe)),transactions:n.transactions},ht);return pe.restore(s)}static fromBytes(e){var a;const r=M.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=F({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((o,c)=>F({kind:"Input",value:o,index:c,type:K(o,kt)?"pure":"object"},Xe)),transactions:s.transactions},ht);return pe.restore(i)}static restore(e){Dt(e,ht);const r=new pe;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=pa("TransactionData",e);return tt(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(h=>(Dt(h.value,It),h.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return M.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,c={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!c.budget)throw new Error("Missing gas budget");if(!c.payment)throw new Error("Missing gas payment");if(!c.price)throw new Error("Missing gas price");const d={sender:$r(o),expiration:a||{None:!0},gasData:{payment:c.payment,owner:$r(this.gasConfig.owner??o),price:BigInt(c.price),budget:BigInt(c.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return M.TransactionData.serialize({V1:d},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return pe.getDigestFromBytes(e)}snapshot(){return F(this,ht)}}var vr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},_=(t,e,r)=>(vr(t,e,"read from private field"),r?r.call(t):e.get(t)),de=(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)},ft=(t,e,r,n)=>(vr(t,e,"write to private field"),e.set(t,r),r),N=(t,e,r)=>(vr(t,e,"access private method"),r),k,Ve,yt,He,mt,Ee,Be,kr,jn,Ir,Un,Ar,Mn,_r,Pn,wt,Kt;const xa={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function Ea(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 va(t){const e=Er(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Ye(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 Rn=Symbol.for("@mysten/transaction"),$t={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},ka=1000n,Ia=50,Aa=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function _a(t){return!!t&&typeof t=="object"&&t[Rn]===!0}const Gt=class{constructor(t){de(this,Ve),de(this,He),de(this,Ee),de(this,kr),de(this,Ir),de(this,Ar),de(this,_r),de(this,wt),de(this,k,void 0),ft(this,k,new pe(t?t.blockData:void 0))}static fromKind(t){const e=new Gt;return ft(e,k,pe.fromKindBytes(typeof t=="string"?ne(t):t)),e}static from(t){const e=new Gt;return typeof t!="string"||!t.startsWith("{")?ft(e,k,pe.fromBytes(typeof t=="string"?ne(t):t)):ft(e,k,pe.restore(JSON.parse(t))),e}setSender(t){_(this,k).sender=t}setSenderIfNotSet(t){_(this,k).sender||(_(this,k).sender=t)}setExpiration(t){_(this,k).expiration=t}setGasPrice(t){_(this,k).gasConfig.price=String(t)}setGasBudget(t){_(this,k).gasConfig.budget=String(t)}setGasOwner(t){_(this,k).gasConfig.owner=t}setGasPayment(t){_(this,k).gasConfig.payment=t.map(e=>sn(e,xe))}get blockData(){return _(this,k).snapshot()}get[Rn](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:ea((t,e)=>Yt(t)?N(this,Ve,yt).call(this,"pure",{Pure:Array.from(t.toBytes())}):N(this,Ve,yt).call(this,"pure",t instanceof Uint8Array?q.Pure(t):e?q.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=Pr(t),r=_(this,k).inputs.find(n=>n.type==="object"&&e===Pr(n.value));return r&&K(r.value,qt)&&"Shared"in r.value.Object&&K(t,qt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??N(this,Ve,yt).call(this,"object",typeof t=="string"?j(t):t)}objectRef(...t){return this.object(q.ObjectRef(...t))}receivingRef(...t){return this.object(q.ReceivingRef(...t))}sharedObjectRef(...t){return this.object(q.SharedObjectRef(...t))}add(t){const e=_(this,k).transactions.push(t);return Ea(e-1)}splitCoins(t,e){return this.add(ve.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):N(this,He,mt).call(this,r))))}mergeCoins(t,e){return this.add(ve.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(ve.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(ve.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(ve.MoveCall({arguments:t==null?void 0:t.map(n=>N(this,He,mt).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(ve.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):N(this,He,mt).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(ve.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(_(this,k).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await N(this,wt,Kt).call(this,t),_(this,k).build({maxSizeBytes:N(this,Ee,Be).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await N(this,wt,Kt).call(this,t),_(this,k).getDigest()}};let Ba=Gt;k=new WeakMap;Ve=new WeakSet;yt=function(t,e){const r=_(this,k).inputs.length,n=F({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Xe);return _(this,k).inputs.push(n),n};He=new WeakSet;mt=function(t){return Yt(t)?this.pure(t):t};Ee=new WeakSet;Be=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return xa[t];const n=e==null?void 0:e.attributes[$t[t]];if(!n)throw new Error(`Missing expected protocol config: "${$t[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: "${$t[t]}"`);return Number(s)};kr=new WeakSet;jn=function(t){const e=N(this,Ee,Be).call(this,"maxPureArgumentSize",t);_(this,k).inputs.forEach((r,n)=>{if(K(r.value,kt)&&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`)})};Ir=new WeakSet;Un=async function(t){if(_(this,k).gasConfig.payment){const s=N(this,Ee,Be).call(this,"maxGasObjects",t);if(_(this,k).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||_(this,k).gasConfig.payment)return;const e=_(this,k).gasConfig.owner??_(this,k).sender,n=(await Ye(t).getCoins({owner:e,coinType:si})).data.filter(s=>!_(this,k).inputs.find(a=>K(a.value,It)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,N(this,Ee,Be).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)};Ar=new WeakSet;Mn=async function(t){t.onlyTransactionKind||_(this,k).gasConfig.price||this.setGasPrice(await Ye(t).getReferenceGasPrice())};_r=new WeakSet;Pn=async function(t){const{inputs:e,transactions:r}=_(this,k),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:j(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!K(e[o.index].value,It))&&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=q.Pure(M.U64.serialize(o.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=q.Pure(M.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,c]=i.target.split("::"),d=await Ye(t).getNormalizedMoveFunction({package:ae(a),module:o,function:c}),l=d.parameters.length>0&&fa(d.parameters.at(-1))?d.parameters.slice(0,d.parameters.length-1):d.parameters;if(l.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");l.forEach((g,y)=>{const m=i.arguments[y];if(m.kind!=="Input")return;const w=e[m.index];if(K(w.value,It))return;const b=w.value,I=Wt(g,b);if(I){w.value=q.Pure(b,I);return}if(Er(g)!=null||typeof g=="object"&&"TypeParameter"in g){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:w,normalizedType:g});return}throw new Error(`Unknown call arg type ${JSON.stringify(g,null,2)} for value ${JSON.stringify(b,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:h})=>h))],a=Aa(i,Ia),o=(await Promise.all(a.map(h=>Ye(t).multiGetObjects({ids:h,options:{showOwner:!0}})))).flat();let c=new Map(i.map((h,l)=>[h,o[l]]));const d=Array.from(c).filter(([h,l])=>l.error).map(([h,l])=>h);if(d.length)throw new Error(`The following input objects are invalid: ${d.join(", ")}`);s.forEach(({id:h,input:l,normalizedType:g})=>{var b;const y=c.get(h),m=(b=y.data)==null?void 0:b.owner,w=m&&typeof m=="object"&&"Shared"in m?m.Shared.initial_shared_version:void 0;if(w){const I=g!=null&&Ft(g)==null&&vn(g)==null,O=Qi(l.value)||I||g!=null&&Ft(g)!=null;l.value=q.SharedObjectRef({objectId:h,initialSharedVersion:w,mutable:O})}else g&&va(g)?l.value=q.ReceivingRef(Mr(y)):l.value=q.ObjectRef(Mr(y))})}};wt=new WeakSet;Kt=async function(t){if(!t.onlyTransactionKind&&!_(this,k).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([N(this,Ar,Mn).call(this,t),N(this,_r,Pn).call(this,t)]),!t.onlyTransactionKind&&(await N(this,Ir,Un).call(this,t),!_(this,k).gasConfig.budget)){const e=await Ye(t).dryRunTransactionBlock({transactionBlock:_(this,k).build({maxSizeBytes:N(this,Ee,Be).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(N(this,Ee,Be).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=ka*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)}N(this,kr,jn).call(this,t)};const Oa=Symbol.for("@mysten/SuiClient");class Ca{get[Oa](){return!0}constructor(e){this.transport=e.transport??new yi({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!he(j(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||!he(j(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||!he(j(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||!he(j(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||!he(j(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||!ut(ae(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||!ut(ae(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(!jr(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(!jr(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:W(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||!he(j(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||!ut(ae(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(_a(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=W(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=W(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:W(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!ut(ae(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=rt(e.digest);return Ce(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,c)=>{i.addEventListener("abort",()=>c(i.reason))});for(a.catch(()=>{});!i.aborted;){e==null||e.throwIfAborted();try{return await this.getTransactionBlock(s)}catch{await Promise.race([new Promise(c=>setTimeout(c,n)),a])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}class $n extends Hr.ChainContext{}const Qe="Sui",Br=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},ja=(t,e)=>{try{return Dr(t)===Dr(e)}catch{return!1}},Ua=t=>(t==null?void 0:t.type)==="created",Ma=t=>(t==null?void 0:t.type)==="published";function Pa(t){return Array.isArray(t)}function At(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function Nn(t){return typeof t=="object"&&!Pa(t)&&!At(t)}const Ra=16*1024,$a=t=>M.ser("vector<u8>",t,{maxSize:Ra}).toBytes(),Na=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||!At(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return zn(r.content.type)},Dn=async(t,e)=>{if(!he(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return Br(r)};async function Da(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=Br(s);if(!i||!Nn(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!At(i.value))throw new Error("Unable to get package id");return i.value.fields.package}const La=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:c,objectId:d}=o.data;(n===null||c<n)&&(n=c,s=d)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},za=async(t,e)=>{const r=new Ba,[n]=r.publish({modules:t.modules.map(s=>Array.from(S.b64.decode(s))),dependencies:t.dependencies.map(s=>ae(s))});return r.transferObjects([n],r.pure(e)),r},le=class le extends Hr.PlatformContext{constructor(e,r){super(e,r??S.networkPlatformConfigs(e,le._platform))}getRpc(e){if(e in this.config)return new Ca({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new $n(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!le.isSupportedChain(r))throw new Error(`invalid chain for ${Qe}: ${r}`);return S.Wormhole.tokenId(r,ii)}static isNativeTokenId(e,r,n){return!le.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return S.chainToPlatform(e)===le._platform}static async getDecimals(e,r,n){if(S.isNative(n))return S.nativeDecimals(le._platform);const s=new me(n);try{const a=await Dn(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.getCoinType()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getBalance(e,r,n,s){if(S.isNative(s)){const{totalBalance:a}=await r.getBalance({owner:n});return BigInt(a)}const{totalBalance:i}=await r.getBalance({owner:n,coinType:s.toString()});return BigInt(i)}static async getBalances(e,r,n,s){return(await Promise.all(s.map(async a=>{const o=await this.getBalance(e,r,n,a);return{[S.isNative(a)?"native":new me(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=S.platformNativeChainIdToNetworkChain(le._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)}};ie(le,"_platform",Qe);let Oe=le;const Or=t=>/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(t),Ln=t=>t.replace(/(0x)(0*)/g,"0x");function Nr(t){return t=t.startsWith("0x")?t.slice(2):t,t=t.length%2===0?t:"0"+t,`0x${t.length===64?t:S.hex.encode(S.bytes.zpad(S.hex.decode(t),32))}`}const Dr=t=>{const e=t.split(Ue);if(e.length!==3)throw new Error(`Invalid Sui type: ${t}`);return[j(e[0]),e[1],e[2]].join(Ue)},Va=t=>new me(t).getCoinType(),zn=t=>new me(t).getPackageId(),Ha=t=>{const e=Ln(t).match(/0x2::table::Table<(.*)>/);if(!e)throw new Error(`Invalid table type: ${t}`);if(e.length<2)throw new Error(`Invalid table type: ${t}`);const[r]=e[1].split(",");if(!r||!Or(r))throw new Error(`Invalid key type: ${r}`);return r},Ie=class Ie{constructor(e){ie(this,"address");ie(this,"module");if(Ie.instanceof(e))this.address=e.address,this.module=e.module;else if(S.UniversalAddress.instanceof(e))this.address=e.toUint8Array();else if(typeof e=="string"){if(Or(e)){const r=e.split(Ue);this.module=r.slice(1).join(Ue),e=r[0]}if(e=Nr(e),!S.hex.valid(e))throw new Error("Invalid Sui address: "+e);this.address=S.hex.decode(e)}else this.address=e}unwrap(){const e=this.getPackageId(),r=this.module?Ue+this.module:"";return`${e}${r}`}toString(){return this.unwrap()}toNative(){return this}toUint8Array(){return this.address}toUniversalAddress(){return new S.UniversalAddress(this.toUint8Array())}getPackageId(){return Nr(S.hex.encode(this.address))}getCoinType(){return[this.getPackageId(),"coin","COIN"].join(Ue)}static instanceof(e){return e.constructor.platform===Ie.platform}equals(e){return Ie.instanceof(e)?e.unwrap()===this.unwrap():this.toUniversalAddress().equals(e)}};ie(Ie,"byteSize",32),ie(Ie,"platform",Oe._platform);let me=Ie;S.registerNative(Qe,me);var et=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))(et||{});function Fa(t){return[t,0,0]}function Vn(t,e){const r=Fa(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const _t={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},qa={ED25519:32,Secp256k1:33,Secp256r1:33},Wa={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function Ka(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function Ga(t,e){const r=t.toString(16);return S.hexToBytes(r.padStart(e*2,"0").slice(-e*2))}function Za(t,e){const r=Ga(t,e),n=Ka(r);return n===-1?new Uint8Array([0]):r.slice(n)}function Ja(t,e){const r=Za(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([_t.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),j(S.bytesToHex(S.blake2b(s,{dkLen:32})).slice(0,st*2))}function Xa(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 Ya(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=Xa(n);e=e.concat(s)}return e}function Qa(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=Ya(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 c=r.slice(o,o+8),d=parseInt(c.join(""),2);i[a++]=d}return new TextDecoder().decode(i)}function eo(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 to(t,e){const r=Qa(t.value,t.indexMod4),[n,s]=eo(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const ro=u.struct("ZkLoginSignature",{inputs:u.struct("ZkLoginSignatureInputs",{proofPoints:u.struct("ZkLoginSignatureInputsProofPoints",{a:u.vector(u.string()),b:u.vector(u.vector(u.string())),c:u.vector(u.string())}),issBase64Details:u.struct("ZkLoginSignatureInputsClaim",{value:u.string(),indexMod4:u.u8()}),headerBase64:u.string(),addressSeed:u.string()}),maxEpoch:u.u64(),userSignature:u.vector(u.u8())});function no(t){return ro.parse(typeof t=="string"?ne(t):t)}function so({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([_t[e]]),s.set(t,1),s.set(n,1+t.length),W(s)}function io(t){const e=ne(t),r=Wa[e[0]];switch(r){case"MultiSig":const n=M.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}=no(s),{issBase64Details:c,addressSeed:d}=i,h=to(c,"iss"),l=Ja(BigInt(d),h);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:h,address:l,addressSeed:BigInt(d)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const g=qa[r],y=e.slice(1,e.length-g),m=e.slice(1+y.length);return{serializedSignature:t,signatureScheme:r,signature:y,publicKey:m,bytes:e};default:throw new Error("Unsupported signature scheme")}}const bt=32,ao="suiprivkey";class oo{async signWithIntent(e,r){const n=Vn(r,e),s=S.blake2b(n,{dkLen:32});return{signature:so({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:W(e)}}async signTransactionBlock(e){return this.signWithIntent(e,et.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(u.vector(u.u8()).serialize(e).toBytes(),et.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class co extends oo{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function uo(t,e){if(t.length!==bt)throw new Error("Invalid bytes length");const r=_t[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),S.bech32.encode(ao,S.bech32.toWords(n))}function Lr(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function lo(t){return Us(t,"")}function ho(t){return Ce(lo(t))}const fo="ed25519 seed",go=2147483648,po=new RegExp("^m(\\/[0-9]+')+$"),Hn=t=>t.replace("'",""),yo=t=>{const r=S.hmac.create(S.sha512,fo).update(nt(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},mo=({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=S.hmac.create(S.sha512,e).update(i).digest(),o=a.slice(0,32),c=a.slice(32);return{key:o,chainCode:c}},wo=t=>po.test(t)?!t.split("/").slice(1).map(Hn).some(isNaN):!1,zr=(t,e,r=go)=>{if(!wo(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=yo(e);return t.split("/").slice(1).map(Hn).map(a=>parseInt(a,10)).reduce((a,o)=>mo(a,o+r),{key:n,chainCode:s})};function Fn(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 bo{equals(e){return Fn(this.toRawBytes(),e.toRawBytes())}toBase64(){return W(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return W(e)}verifyWithIntent(e,r,n){const s=Vn(n,e),i=S.blake2b(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(M.vector(M.u8()).serialize(e).toBytes(),r,et.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,et.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return j(S.bytesToHex(S.blake2b(this.toSuiBytes(),{dkLen:32})).slice(0,st*2))}}const Zt=32;class qn extends bo{constructor(e){if(super(),typeof e=="string"?this.data=ne(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==Zt)throw new Error(`Invalid public key input. Expected ${Zt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return _t.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=io(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!Fn(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return S.nacl.sign.detached.verify(e,n,this.toRawBytes())}}qn.SIZE=Zt;const Vr="m/44'/784'/0'/0'/0'";class Me extends co{constructor(e){super(),e?this.keypair=e:this.keypair=S.nacl.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Me(S.nacl.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==bt)throw new Error(`Wrong secretKey size. Expected ${bt} bytes, got ${n}.`);const s=S.nacl.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=S.nacl.sign.detached(a,s.secretKey);if(!S.nacl.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new Me(s)}getPublicKey(){return new qn(this.keypair.publicKey)}getSecretKey(){return uo(this.keypair.secretKey.slice(0,bt),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return S.nacl.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=Vr),!Lr(r))throw new Error("Invalid derivation path");const{key:n}=zr(r,ho(e));return Me.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=Vr),!Lr(r))throw new Error("Invalid derivation path");const{key:n}=zr(r,e);return Me.fromSecretKey(n)}}async function So(t,e){const[,r]=await Oe.chainFromRpc(t);return new To(r,t,Me.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class To{constructor(e,r,n,s){ie(this,"_chain");ie(this,"_client");ie(this,"_signer");ie(this,"_debug");this._chain=e,this._client=r,this._signer=n,this._debug=s}chain(){return this._chain}address(){return this._signer.toSuiAddress()}async signAndSend(e){const r=[];for(const n of e){const{description:s,transaction:i}=n;this._debug&&console.log(`Signing ${s} for ${this.address()}`);const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}return r}}const xo={Address:me,Platform:Oe,getSigner:So,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-C7tR7eyI.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-Ci2ZLtDV.js"))},getChain:(t,e,r)=>new $n(e,new Oe(t,S.applyChainsConfigConfigOverrides(t,Qe,{[e]:r})))},Eo=Object.freeze(Object.defineProperty({__proto__:null,default:xo},Symbol.toStringTag,{value:"Module"}));exports.SuiAddress=me;exports.SuiPlatform=Oe;exports._platform=Qe;exports.getCoinTypeFromPackageId=Va;exports.getFieldsFromObjectResponse=Br;exports.getObjectFields=Dn;exports.getOldestEmitterCapObjectId=La;exports.getOriginalPackageId=Na;exports.getPackageId=Da;exports.getPackageIdFromType=zn;exports.getTableKeyType=Ha;exports.isMoveStructObject=Nn;exports.isMoveStructStruct=At;exports.isSameType=ja;exports.isSuiCreateEvent=Ua;exports.isSuiPublishEvent=Ma;exports.isValidSuiType=Or;exports.publishPackage=za;exports.sui=Eo;exports.trimSuiType=Ln;exports.uint8ArrayToBCS=$a;
|
|
5
|
+
Received: "${JSON.stringify(c)}"`);let l=Object.keys(c)[0];if(l===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let g=n.indexOf(l);if(g===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${l}"`);let y=n[g],m=r[y];if(o.write8(g),m===null)return o;let w=i.indexOf(m),b=w===-1?m:d[w];{let{name:I,params:O}=this.parseTypeName(b);return this.getTypeInterface(I)._encodeRaw.call(this,o,c[l],O,h)}},function(o,c,d){let h=o.readULEB(),l=n[h],g=r[l];if(h===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${h}"`);if(g===null)return{[l]:!0};let y=i.indexOf(g),m=y===-1?g:c[y];{let{name:w,params:b}=this.parseTypeName(m);return{[l]:this.getTypeInterface(w)._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,...c]=t;return{name:o,params:c}}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=Yr(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let C=Le;C.U8="u8";C.U16="u16";C.U32="u32";C.U64="u64";C.U128="u128";C.U256="u256";C.BOOL="bool";C.VECTOR="vector";C.ADDRESS="address";C.STRING="string";C.HEX="hex-string";C.BASE58="base58-string";C.BASE64="base64-string";function Ks(t){t.registerType(C.U8,function(e,r){return e.write8(r)},function(e){return e.read8()},e=>e<256),t.registerType(C.U16,function(e,r){return e.write16(r)},function(e){return e.read16()},e=>e<65536),t.registerType(C.U32,function(e,r){return e.write32(r)},function(e){return e.read32()},e=>e<=4294967296n),t.registerType(C.U64,function(e,r){return e.write64(r)},function(e){return e.read64()}),t.registerType(C.U128,function(e,r){return e.write128(r)},function(e){return e.read128()}),t.registerType(C.U256,function(e,r){return e.write256(r)},function(e){return e.read256()}),t.registerType(C.BOOL,function(e,r){return e.write8(r)},function(e){return e.read8().toString(10)==="1"}),t.registerType(C.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(C.HEX,function(e,r){return e.writeVec(Array.from(nt(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return Ce(new Uint8Array(r))}),t.registerType(C.BASE58,function(e,r){return e.writeVec(Array.from(rt(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return tt(new Uint8Array(r))}),t.registerType(C.BASE64,function(e,r){return e.writeVec(Array.from(ne(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return W(new Uint8Array(r))})}function Gs(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Ws,addressEncoding:"hex"}}const Zs=32;function jr(t){try{return rt(t).length===Zs}catch{return!1}}const st=32;function he(t){return Js(t)&&Xs(t)===st}function ut(t){return he(t)}function j(t,e=!1){let r=t.toLowerCase();return!e&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(st*2,"0")}`}function ae(t,e=!1){return j(t,e)}function Js(t){return/^(0x|0X)?[a-fA-F0-9]+$/.test(t)&&t.length%2===0}function Xs(t){return/^(0x|0X)/.test(t)?(t.length-2)/2:t.length/2}class Ys extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:o}=e,c=o.length===0?s:`At path: ${o.join(".")} -- ${s}`;super(i??c),i!=null&&(this.cause=c),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Qs(t){return J(t)&&typeof t[Symbol.iterator]=="function"}function J(t){return typeof t=="object"&&t!=null}function X(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function ei(t){const{done:e,value:r}=t.next();return e?void 0:r}function ti(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:c=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${X(n)}\``}=t;return{value:n,type:a,refinement:o,key:s[s.length-1],path:s,branch:i,...t,message:c}}function*Ur(t,e,r,n){Qs(t)||(t=[t]);for(const s of t){const i=ti(s,e,r,n);i&&(yield i)}}function*Qt(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"&&J(e.schema)&&J(t)&&!Array.isArray(t)))for(const d in t)e.schema[d]===void 0&&delete t[d];let c="valid";for(const d of e.validator(t,o))d.explanation=r.message,c="not_valid",yield[d,void 0];for(let[d,h,l]of e.entries(t,o)){const g=Qt(h,l,{path:d===void 0?n:[...n,d],branch:d===void 0?s:[...s,h],coerce:i,mask:a,message:r.message});for(const y of g)y[0]?(c=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):i&&(h=y[1],d===void 0?t=h:t instanceof Map?t.set(d,h):t instanceof Set?t.add(h):J(t)&&(h!==void 0||d in t)&&(t[d]=h))}if(c!=="not_valid")for(const d of e.refiner(t,o))d.explanation=r.message,c="not_refined",yield[d,void 0];c==="valid"&&(yield[void 0,t])}class ce{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=c=>c,entries:o=function*(){}}=e;this.type=r,this.schema=n,this.entries=o,this.coercer=a,s?this.validator=(c,d)=>{const h=s(c,d);return Ur(h,d,this,c)}:this.validator=()=>[],i?this.refiner=(c,d)=>{const h=i(c,d);return Ur(h,d,this,c)}:this.refiner=()=>[]}assert(e,r){return Dt(e,this,r)}create(e,r){return nn(e,this,r)}is(e){return K(e,this)}mask(e,r){return sn(e,this,r)}validate(e,r={}){return it(e,this,r)}}function Dt(t,e,r){const n=it(t,e,{message:r});if(n[0])throw n[0]}function nn(t,e,r){const n=it(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function sn(t,e,r){const n=it(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function K(t,e){return!it(t,e)[0]}function it(t,e,r={}){const n=Qt(t,e,r),s=ei(n);return s[0]?[new Ys(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Ge(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?ni(n):p(n)}function G(t,e){return new ce({type:t,schema:null,validator:e})}function Lt(){return G("any",()=>!0)}function A(t){return new ce({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: ${X(e)}`}})}function ri(){return G("bigint",t=>typeof t=="bigint")}function V(){return G("boolean",t=>typeof t=="boolean")}function oe(){return G("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${X(t)}`)}function v(t){const e=X(t),r=typeof t;return new ce({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${X(n)}`}})}function an(){return G("never",()=>!1)}function P(t){return new ce({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function _e(){return G("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${X(t)}`)}function p(t){const e=t?Object.keys(t):[],r=an();return new ce({type:"object",schema:t||null,*entries(n){if(t&&J(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 J(n)||`Expected an object, but received: ${X(n)}`},coercer(n){return J(n)?{...n}:n}})}function E(t){return new ce({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function se(t,e){return new ce({type:"record",schema:null,*entries(r){if(J(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return J(r)||`Expected an object, but received: ${X(r)}`}})}function f(){return G("string",t=>typeof t=="string"||`Expected a string, but received: ${X(t)}`)}function on(t){const e=an();return new ce({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: ${X(r)}`}})}function ni(t){const e=Object.keys(t);return new ce({type:"type",schema:t,*entries(r){if(J(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return J(r)||`Expected an object, but received: ${X(r)}`},coercer(r){return J(r)?{...r}:r}})}function R(t){const e=t.map(r=>r.type).join(" | ");return new ce({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]=Qt(r,i,n),[o]=a;if(o[0])for(const[c]of a)c&&s.push(c);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${X(r)}`,...s]}})}function cn(){return G("unknown",()=>!0)}BigInt(1e9);const er="0x1",un="0x2";ae("0x6");const si=`${un}::sui::SUI`;ae("0x5");const Ue="::",ii="0x2::sui::SUI",ai="0.50.1",oi="1.19.0",ci={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class dn extends Error{}class ln extends dn{constructor(e,r){super(e),this.code=r,this.type=ci[r]??"ServerError"}}class ui extends dn{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var tr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},U=(t,e,r)=>(tr(t,e,"read from private field"),r?r.call(t):e.get(t)),Se=(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)},Pe=(t,e,r,n)=>(tr(t,e,"write to private field"),e.set(t,r),r),di=(t,e,r,n)=>({set _(s){Pe(t,e,s)},get _(){return U(t,e,n)}}),hn=(t,e,r)=>(tr(t,e,"access private method"),r),ke,qe,fe,Ae,Ze,Re,zt,fn,rr,gn;function li(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const hi={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class fi{constructor(e,r={}){if(Se(this,zt),Se(this,rr),Se(this,ke,0),Se(this,qe,0),Se(this,fe,null),Se(this,Ae,null),Se(this,Ze,new Set),Se(this,Re,new Map),this.endpoint=e,this.options={...hi,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=li(this.endpoint))}async makeRequest(e,r){const n=await hn(this,zt,fn).call(this);return new Promise((s,i)=>{Pe(this,ke,U(this,ke)+1),U(this,Re).set(U(this,ke),{resolve:s,reject:i,timeout:setTimeout(()=>{U(this,Re).delete(U(this,ke)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:U(this,ke),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new ln(s.message,s.code);return i})}async subscribe(e){const r=new gi(e);return U(this,Ze).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}ke=new WeakMap;qe=new WeakMap;fe=new WeakMap;Ae=new WeakMap;Ze=new WeakMap;Re=new WeakMap;zt=new WeakSet;fn=function(){return U(this,Ae)?U(this,Ae):(Pe(this,Ae,new Promise(t=>{var e;(e=U(this,fe))==null||e.close(),Pe(this,fe,new this.options.WebSocketConstructor(this.endpoint)),U(this,fe).addEventListener("open",()=>{Pe(this,qe,0),t(U(this,fe))}),U(this,fe).addEventListener("close",()=>{di(this,qe)._++,U(this,qe)<=this.options.maxReconnects&&setTimeout(()=>{hn(this,rr,gn).call(this)},this.options.reconnectTimeout)}),U(this,fe).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&&U(this,Re).has(n.id)){const{resolve:s,timeout:i}=U(this,Re).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;U(this,Ze).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),U(this,Ae))};rr=new WeakSet;gn=async function(){var t;return(t=U(this,fe))==null||t.close(),Pe(this,Ae,null),Promise.allSettled([...U(this,Ze)].map(e=>e.subscribe(this)))};class gi{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 nr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},Z=(t,e,r)=>(nr(t,e,"read from private field"),r?r.call(t):e.get(t)),dt=(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)=>(nr(t,e,"write to private field"),e.set(t,r),r),pi=(t,e,r)=>(nr(t,e,"access private method"),r),ze,ee,We,Ht,pn;class yi{constructor(e){dt(this,Ht),dt(this,ze,0),dt(this,ee,void 0),dt(this,We,void 0),Vt(this,ee,e)}fetch(e,r){const n=Z(this,ee).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,ze,Z(this,ze)+1);const r=await this.fetch(((s=Z(this,ee).rpc)==null?void 0:s.url)??Z(this,ee).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":ai,"Client-Target-Api-Version":oi,...(i=Z(this,ee).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:Z(this,ze),method:e.method,params:e.params})});if(!r.ok)throw new ui(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new ln(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await pi(this,Ht,pn).call(this).subscribe(e);return async()=>!!await r()}}ze=new WeakMap;ee=new WeakMap;We=new WeakMap;Ht=new WeakSet;pn=function(){var t;if(!Z(this,We)){const e=Z(this,ee).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,We,new fi(((t=Z(this,ee).websocket)==null?void 0:t.url)??Z(this,ee).url,{WebSocketConstructor:e,...Z(this,ee).websocket}))}return Z(this,We)};const mi=/^vector<(.+)>$/,wi=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class ge{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(mi);if(n)return{vector:ge.parseFromStr(n[1],r)};const s=e.match(wi);if(s)return{struct:{address:r?j(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:ge.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return Yr(e).map(n=>ge.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<${ge.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(ge.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const B=new C({...Gs(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function yn(t){return u.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function bi(t){return u.enum("Option",{None:null,Some:t})}function sr(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const re=u.bytes(st).transform({input:t=>typeof t=="string"?nt(j(t)):t,output:t=>j(Ce(t))}),ir=u.vector(u.u8()).transform({name:"ObjectDigest",input:t=>rt(t),output:t=>tt(new Uint8Array(t))}),Je=u.struct("SuiObjectRef",{objectId:re,version:u.u64(),digest:ir}),ar=u.struct("SharedObjectRef",{objectId:re,initialSharedVersion:u.u64(),mutable:u.bool()}),vt=u.enum("ObjectArg",{ImmOrOwned:Je,Shared:ar,Receiving:Je}),or=u.enum("CallArg",{Pure:u.vector(u.u8()),Object:vt,ObjVec:u.vector(vt)}),Ne=u.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:u.lazy(()=>Ne),struct:u.lazy(()=>fr),u16:null,u32:null,u256:null}),Y=sr(u.enum("Argument",{GasCoin:null,Input:u.struct("Input",{index:u.u16()}),Result:u.struct("Result",{index:u.u16()}),NestedResult:u.struct("NestedResult",{index:u.u16(),resultIndex:u.u16()})})),cr=u.struct("ProgrammableMoveCall",{package:re,module:u.string(),function:u.string(),type_arguments:u.vector(Ne),arguments:u.vector(Y)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>ge.parseFromStr(i,!0));return{package:j(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(ge.tagToString)})}),ur=sr(u.enum("Transaction",{MoveCall:cr,TransferObjects:u.struct("TransferObjects",{objects:u.vector(Y),address:Y}),SplitCoins:u.struct("SplitCoins",{coin:Y,amounts:u.vector(Y)}),MergeCoins:u.struct("MergeCoins",{destination:Y,sources:u.vector(Y)}),Publish:u.struct("Publish",{modules:u.vector(u.vector(u.u8())),dependencies:u.vector(re)}),MakeMoveVec:u.struct("MakeMoveVec",{type:bi(Ne),objects:u.vector(Y)}),Upgrade:u.struct("Upgrade",{modules:u.vector(u.vector(u.u8())),dependencies:u.vector(re),packageId:re,ticket:Y})})),dr=u.struct("ProgrammableTransaction",{inputs:u.vector(or),transactions:u.vector(ur)}),lr=u.enum("TransactionKind",{ProgrammableTransaction:dr,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),hr=u.enum("TransactionExpiration",{None:null,Epoch:yn()}),fr=u.struct("StructTag",{address:re,module:u.string(),name:u.string(),typeParams:u.vector(Ne)}),gr=u.struct("GasData",{payment:u.vector(Je),owner:re,price:u.u64(),budget:u.u64()}),pr=u.struct("TransactionDataV1",{kind:lr,sender:re,gasData:gr,expiration:hr}),yr=u.enum("TransactionData",{V1:pr}),Si=u.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Ti=u.enum("IntentVersion",{V0:null}),xi=u.enum("AppId",{Sui:null}),Ei=u.struct("Intent",{scope:Si,version:Ti,appId:xi}),vi=u.generic(["T"],t=>u.struct("IntentMessage<T>",{intent:Ei,value:t})),mr=u.enum("CompressedSignature",{ED25519:u.fixedArray(64,u.u8()),Secp256k1:u.fixedArray(64,u.u8()),Secp256r1:u.fixedArray(64,u.u8()),ZkLogin:u.vector(u.u8())}),wr=u.enum("PublicKey",{ED25519:u.fixedArray(32,u.u8()),Secp256k1:u.fixedArray(33,u.u8()),Secp256r1:u.fixedArray(33,u.u8()),ZkLogin:u.vector(u.u8())}),br=u.struct("MultiSigPkMap",{pubKey:wr,weight:u.u8()}),Sr=u.struct("MultiSigPublicKey",{pk_map:u.vector(br),threshold:u.u16()}),mn=u.struct("MultiSig",{sigs:u.vector(mr),bitmap:u.u16(),multisig_pk:Sr}),ki=u.vector(u.u8()).transform({input:t=>typeof t=="string"?ne(t):t,output:t=>W(new Uint8Array(t))}),wn=u.struct("SenderSignedTransaction",{intentMessage:vi(yr),txSignatures:u.vector(ki)}),bn=u.vector(wn,{name:"SenderSignedData"}),M={...u,U8:u.u8(),U16:u.u16(),U32:u.u32(),U64:u.u64(),U128:u.u128(),U256:u.u256(),ULEB128:u.uleb128(),Bool:u.bool(),String:u.string(),Address:re,Argument:Y,CallArg:or,CompressedSignature:mr,GasData:gr,MultiSig:mn,MultiSigPkMap:br,MultiSigPublicKey:Sr,ObjectArg:vt,ObjectDigest:ir,ProgrammableMoveCall:cr,ProgrammableTransaction:dr,PublicKey:wr,SenderSignedData:bn,SenderSignedTransaction:wn,SharedObjectRef:ar,StructTag:fr,SuiObjectRef:Je,Transaction:ur,TransactionData:yr,TransactionDataV1:pr,TransactionExpiration:hr,TransactionKind:lr,TypeTag:Ne,ser:B.ser.bind(B),de:B.de.bind(B),getTypeInterface:B.getTypeInterface.bind(B),hasType:B.hasType.bind(B),parseTypeName:B.parseTypeName.bind(B),registerAddressType:B.registerAddressType.bind(B),registerAlias:B.registerAlias.bind(B),registerBcsType:B.registerBcsType.bind(B),registerEnumType:B.registerEnumType.bind(B),registerStructType:B.registerStructType.bind(B),registerType:B.registerType.bind(B),types:B.types};B.registerBcsType("utf8string",()=>u.string({name:"utf8string"}));B.registerBcsType("unsafe_u64",()=>yn());B.registerBcsType("enumKind",t=>sr(t));[re,Y,or,mr,gr,mn,br,Sr,vt,ir,cr,dr,wr,bn,ar,fr,Je,ur,yr,pr,hr,lr,Ne].forEach(t=>{B.registerBcsType(t.name,()=>t)});const Tr=R([p({AddressOwner:f()}),p({ObjectOwner:f()}),p({Shared:p({initial_shared_version:P(f())})}),v("Immutable")]);G("SuiJsonValue",()=>!0);const Ii=R([p({u32:f()}),p({u64:f()}),p({f64:f()})]);p({attributes:se(f(),P(Ii)),featureFlags:se(f(),V()),maxSupportedProtocolVersion:f(),minSupportedProtocolVersion:f(),protocolVersion:f()});R([f(),v("package")]);const xe=p({digest:f(),objectId:f(),version:R([_e(),f(),ri()])});p({owner:Tr,reference:xe});p({objectId:f(),sequenceNumber:f()});p({payment:A(xe),owner:f(),price:f(),budget:f()});const Ai=Ge(xe,p({type:f(),owner:Tr,previousTransaction:f()})),_i=se(f(),Lt()),Bi=se(f(),cn()),Oi=p({type:f(),fields:_i,hasPublicTransfer:V()}),Ci=p({disassembled:Bi}),ji=R([Ge(Oi,p({dataType:v("moveObject")})),Ge(Ci,p({dataType:v("package")}))]),Ui=p({type:f(),hasPublicTransfer:V(),version:f(),bcsBytes:f()}),Mi=p({id:f(),moduleMap:se(f(),f())}),Pi=R([Ge(Ui,p({dataType:v("moveObject")})),Ge(Mi,p({dataType:v("package")}))]);BigInt(1e9);const Sn=p({code:f(),error:E(f()),object_id:E(f()),parent_object_id:E(f()),version:E(f()),digest:E(f())}),Ri=p({data:P(E(se(f(),f()))),error:P(E(Sn))}),$i=R([Ri,E(se(f(),f()))]),Tn=p({objectId:f(),version:f(),digest:f(),type:P(E(f())),content:P(E(ji)),bcs:P(E(Pi)),owner:P(E(Tr)),previousTransaction:P(E(f())),storageRebate:P(E(f())),display:P(E($i))});p({showType:P(E(V())),showContent:P(E(V())),showBcs:P(E(V())),showOwner:P(E(V())),showPreviousTransaction:P(E(V())),showStorageRebate:P(E(V())),showDisplay:P(E(V()))});R([v("Exists"),v("notExists"),v("Deleted")]);A(Ai);const Ni=p({data:P(E(Tn)),error:P(E(Sn))});function Di(t){return t.data}function Li(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=Di(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:Li(t)}p({objectId:f(),atCheckpoint:E(_e())});p({data:A(Ni),nextCursor:E(P(f())),hasNextPage:V()});R([p({details:Tn,status:v("VersionFound")}),p({details:f(),status:v("ObjectNotExists")}),p({details:xe,status:v("ObjectDeleted")}),p({details:on([f(),_e()]),status:v("VersionNotFound")}),p({details:p({asked_version:_e(),latest_version:_e(),object_id:f()}),status:v("VersionTooHigh")})]);const zi=R([f(),p({Object:f()})]);A(zi);const Vi=p({address:f(),name:f()}),Hi=R([v("Private"),v("Public"),v("Friend")]),xr=p({abilities:A(f())}),Fi=p({constraints:xr,isPhantom:V()}),qi=p({TypeParameter:_e()}),Pt=on([p({module:f(),package:f(),function:f()}),f()]);p({rank3Days:A(Pt),rank7Days:A(Pt),rank30Days:A(Pt)});function xn(t){if(!t)return!1;if(typeof t=="string"||K(t,qi)||En(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(K(e.Reference,$e)||K(e.MutableReference,$e)||K(e.Vector,$e))}const $e=G("SuiMoveNormalizedType",xn);function En(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=>xn(n)))}G("SuiMoveNormalizedStructType",En);const Wi=p({visibility:Hi,isEntry:V(),typeParameters:A(xr),parameters:A($e),return:A($e)}),Ki=p({name:f(),type:$e}),Gi=p({abilities:xr,typeParameters:A(Fi),fields:A(Ki)}),Zi=p({fileFormatVersion:_e(),address:f(),name:f(),friends:A(Vi),structs:se(f(),Gi),exposedFunctions:se(f(),Wi)});se(f(),Zi);function Ft(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function vn(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function Er(t){if(typeof t=="object"&&"Struct"in t)return t;const e=vn(t),r=Ft(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const Ji=R([p({ImmOrOwned:xe}),p({Shared:p({objectId:f(),initialSharedVersion:R([oe(),f()]),mutable:V()})}),p({Receiving:xe})]),kt=p({Pure:A(oe())}),qt=p({Object:Ji}),It=R([kt,qt]);function Xi(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:Yt(t)?t.toBytes():M.ser(e,t,{maxSize:1/0}).toBytes())}}const q={Pure:Xi,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:j(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:j(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:j(t)}}}}};function Pr(t){return typeof t=="string"?j(t):"ImmOrOwned"in t.Object?j(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?j(t.Object.Receiving.objectId):j(t.Object.Shared.objectId)}function Yi(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function Qi(t){var e;return((e=Yi(t))==null?void 0:e.mutable)??!1}function ea(t){function e(r,n){return t(r,n)}return e.u8=r=>t(M.U8.serialize(r)),e.u16=r=>t(M.U16.serialize(r)),e.u32=r=>t(M.U32.serialize(r)),e.u64=r=>t(M.U64.serialize(r)),e.u128=r=>t(M.U128.serialize(r)),e.u256=r=>t(M.U256.serialize(r)),e.bool=r=>t(M.Bool.serialize(r)),e.string=r=>t(M.String.serialize(r)),e.address=r=>t(M.Address.serialize(r)),e.id=e.address,e}const ta="object",ra="ID",na="ascii",sa="String",ia="string",aa="String",oa="option",ca="Option",ua={address:un,module:ta,name:ra},da={address:er,module:na,name:sa},la={address:er,module:ia,name:aa},ha={address:er,module:oa,name:ca},lt=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function fa(t){var r;const e=(r=Er(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 Rt(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const ga=["Address","Bool","U8","U16","U32","U64","U128","U256"];function Wt(t,e){if(typeof t=="string"&&ga.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])Rt("number",e);else if(t==="Bool")Rt("boolean",e);else if(t==="Address"&&(Rt("string",e),e&&!he(e)))throw new Error("Invalid Sui Address");return t.toLowerCase()}else if(typeof t=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(t,null,2)}`);if("Vector"in t){if((e===void 0||typeof e=="string")&&t.Vector==="U8")return"string";if(e!==void 0&&!Array.isArray(e))throw new Error(`Expect ${e} to be a array, received ${typeof e}`);const r=Wt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(lt(t.Struct,da))return"string";if(lt(t.Struct,la))return"utf8string";if(lt(t.Struct,ua))return"address";if(lt(t.Struct,ha)){const r={Vector:t.Struct.typeArguments[0]};return Wt(r,e)}}}function pa(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),S.blake2b(n,{dkLen:32})}function F(t,e){return nn(t,e)}const ya=t=>R([p({None:R([v(!0),v(null)])}),p({Some:t})]),Xe=R([p({kind:v("Input"),index:oe(),value:E(Lt()),type:E(v("object"))}),p({kind:v("Input"),index:oe(),value:E(Lt()),type:v("pure")})]),ma=[Xe,p({kind:v("GasCoin")}),p({kind:v("Result"),index:oe()}),p({kind:v("NestedResult"),index:oe(),resultIndex:oe()})],ye=R([...ma]),kn=p({kind:v("MoveCall"),target:G("target",f().validator),typeArguments:A(f()),arguments:A(ye)}),In=p({kind:v("TransferObjects"),objects:A(ye),address:ye}),An=p({kind:v("SplitCoins"),coin:ye,amounts:A(ye)}),_n=p({kind:v("MergeCoins"),destination:ye,sources:A(ye)}),Bn=p({kind:v("MakeMoveVec"),type:E(ya(se(f(),cn()))),objects:A(ye)}),On=p({kind:v("Publish"),modules:A(A(oe())),dependencies:A(f())}),Cn=p({kind:v("Upgrade"),modules:A(A(oe())),dependencies:A(f()),packageId:f(),ticket:ye}),wa=[kn,In,An,_n,On,Cn,Bn],ba=R([...wa]),ve={MoveCall(t){return F({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},kn)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=q.Pure(M.Address.serialize(e.value))),F({kind:"TransferObjects",objects:t,address:e},In)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=q.Pure(M.U64.serialize(r.value)))}),F({kind:"SplitCoins",coin:t,amounts:e},An)},MergeCoins(t,e){return F({kind:"MergeCoins",destination:t,sources:e},_n)},Publish({modules:t,dependencies:e}){return F({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(ne(r)):r),dependencies:e.map(r=>ae(r))},On)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return F({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(ne(s)):s),dependencies:e.map(s=>ae(s)),packageId:r,ticket:n},Cn)},MakeMoveVec({type:t,objects:e}){return F({kind:"MakeMoveVec",type:t?{Some:ge.parseFromStr(t)}:{None:null},objects:e},Bn)}},Sa=E(P(R([p({Epoch:oe()}),p({None:R([v(!0),v(null)])})]))),Rr=G("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),Ta=p({budget:E(Rr),price:E(Rr),payment:E(A(xe)),owner:E(f())}),ht=p({version:v(1),sender:E(f()),expiration:Sa,gasConfig:Ta,inputs:A(Xe),transactions:A(ba)});function $r(t){return j(t).replace("0x","")}class pe{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=M.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=F({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>F({kind:"Input",value:i,index:a,type:K(i,kt)?"pure":"object"},Xe)),transactions:n.transactions},ht);return pe.restore(s)}static fromBytes(e){var a;const r=M.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=F({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((o,c)=>F({kind:"Input",value:o,index:c,type:K(o,kt)?"pure":"object"},Xe)),transactions:s.transactions},ht);return pe.restore(i)}static restore(e){Dt(e,ht);const r=new pe;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=pa("TransactionData",e);return tt(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(h=>(Dt(h.value,It),h.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return M.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,c={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!c.budget)throw new Error("Missing gas budget");if(!c.payment)throw new Error("Missing gas payment");if(!c.price)throw new Error("Missing gas price");const d={sender:$r(o),expiration:a||{None:!0},gasData:{payment:c.payment,owner:$r(this.gasConfig.owner??o),price:BigInt(c.price),budget:BigInt(c.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return M.TransactionData.serialize({V1:d},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return pe.getDigestFromBytes(e)}snapshot(){return F(this,ht)}}var vr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},_=(t,e,r)=>(vr(t,e,"read from private field"),r?r.call(t):e.get(t)),de=(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)},ft=(t,e,r,n)=>(vr(t,e,"write to private field"),e.set(t,r),r),N=(t,e,r)=>(vr(t,e,"access private method"),r),k,Ve,yt,He,mt,Ee,Be,kr,jn,Ir,Un,Ar,Mn,_r,Pn,wt,Kt;const xa={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function Ea(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 va(t){const e=Er(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Ye(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 Rn=Symbol.for("@mysten/transaction"),$t={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},ka=1000n,Ia=50,Aa=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function _a(t){return!!t&&typeof t=="object"&&t[Rn]===!0}const Gt=class{constructor(t){de(this,Ve),de(this,He),de(this,Ee),de(this,kr),de(this,Ir),de(this,Ar),de(this,_r),de(this,wt),de(this,k,void 0),ft(this,k,new pe(t?t.blockData:void 0))}static fromKind(t){const e=new Gt;return ft(e,k,pe.fromKindBytes(typeof t=="string"?ne(t):t)),e}static from(t){const e=new Gt;return typeof t!="string"||!t.startsWith("{")?ft(e,k,pe.fromBytes(typeof t=="string"?ne(t):t)):ft(e,k,pe.restore(JSON.parse(t))),e}setSender(t){_(this,k).sender=t}setSenderIfNotSet(t){_(this,k).sender||(_(this,k).sender=t)}setExpiration(t){_(this,k).expiration=t}setGasPrice(t){_(this,k).gasConfig.price=String(t)}setGasBudget(t){_(this,k).gasConfig.budget=String(t)}setGasOwner(t){_(this,k).gasConfig.owner=t}setGasPayment(t){_(this,k).gasConfig.payment=t.map(e=>sn(e,xe))}get blockData(){return _(this,k).snapshot()}get[Rn](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:ea((t,e)=>Yt(t)?N(this,Ve,yt).call(this,"pure",{Pure:Array.from(t.toBytes())}):N(this,Ve,yt).call(this,"pure",t instanceof Uint8Array?q.Pure(t):e?q.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=Pr(t),r=_(this,k).inputs.find(n=>n.type==="object"&&e===Pr(n.value));return r&&K(r.value,qt)&&"Shared"in r.value.Object&&K(t,qt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??N(this,Ve,yt).call(this,"object",typeof t=="string"?j(t):t)}objectRef(...t){return this.object(q.ObjectRef(...t))}receivingRef(...t){return this.object(q.ReceivingRef(...t))}sharedObjectRef(...t){return this.object(q.SharedObjectRef(...t))}add(t){const e=_(this,k).transactions.push(t);return Ea(e-1)}splitCoins(t,e){return this.add(ve.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):N(this,He,mt).call(this,r))))}mergeCoins(t,e){return this.add(ve.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(ve.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(ve.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(ve.MoveCall({arguments:t==null?void 0:t.map(n=>N(this,He,mt).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(ve.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):N(this,He,mt).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(ve.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(_(this,k).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await N(this,wt,Kt).call(this,t),_(this,k).build({maxSizeBytes:N(this,Ee,Be).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await N(this,wt,Kt).call(this,t),_(this,k).getDigest()}};let Ba=Gt;k=new WeakMap;Ve=new WeakSet;yt=function(t,e){const r=_(this,k).inputs.length,n=F({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Xe);return _(this,k).inputs.push(n),n};He=new WeakSet;mt=function(t){return Yt(t)?this.pure(t):t};Ee=new WeakSet;Be=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return xa[t];const n=e==null?void 0:e.attributes[$t[t]];if(!n)throw new Error(`Missing expected protocol config: "${$t[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: "${$t[t]}"`);return Number(s)};kr=new WeakSet;jn=function(t){const e=N(this,Ee,Be).call(this,"maxPureArgumentSize",t);_(this,k).inputs.forEach((r,n)=>{if(K(r.value,kt)&&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`)})};Ir=new WeakSet;Un=async function(t){if(_(this,k).gasConfig.payment){const s=N(this,Ee,Be).call(this,"maxGasObjects",t);if(_(this,k).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||_(this,k).gasConfig.payment)return;const e=_(this,k).gasConfig.owner??_(this,k).sender,n=(await Ye(t).getCoins({owner:e,coinType:si})).data.filter(s=>!_(this,k).inputs.find(a=>K(a.value,It)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,N(this,Ee,Be).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)};Ar=new WeakSet;Mn=async function(t){t.onlyTransactionKind||_(this,k).gasConfig.price||this.setGasPrice(await Ye(t).getReferenceGasPrice())};_r=new WeakSet;Pn=async function(t){const{inputs:e,transactions:r}=_(this,k),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:j(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!K(e[o.index].value,It))&&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=q.Pure(M.U64.serialize(o.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=q.Pure(M.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,c]=i.target.split("::"),d=await Ye(t).getNormalizedMoveFunction({package:ae(a),module:o,function:c}),l=d.parameters.length>0&&fa(d.parameters.at(-1))?d.parameters.slice(0,d.parameters.length-1):d.parameters;if(l.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");l.forEach((g,y)=>{const m=i.arguments[y];if(m.kind!=="Input")return;const w=e[m.index];if(K(w.value,It))return;const b=w.value,I=Wt(g,b);if(I){w.value=q.Pure(b,I);return}if(Er(g)!=null||typeof g=="object"&&"TypeParameter"in g){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:w,normalizedType:g});return}throw new Error(`Unknown call arg type ${JSON.stringify(g,null,2)} for value ${JSON.stringify(b,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:h})=>h))],a=Aa(i,Ia),o=(await Promise.all(a.map(h=>Ye(t).multiGetObjects({ids:h,options:{showOwner:!0}})))).flat();let c=new Map(i.map((h,l)=>[h,o[l]]));const d=Array.from(c).filter(([h,l])=>l.error).map(([h,l])=>h);if(d.length)throw new Error(`The following input objects are invalid: ${d.join(", ")}`);s.forEach(({id:h,input:l,normalizedType:g})=>{var b;const y=c.get(h),m=(b=y.data)==null?void 0:b.owner,w=m&&typeof m=="object"&&"Shared"in m?m.Shared.initial_shared_version:void 0;if(w){const I=g!=null&&Ft(g)==null&&vn(g)==null,O=Qi(l.value)||I||g!=null&&Ft(g)!=null;l.value=q.SharedObjectRef({objectId:h,initialSharedVersion:w,mutable:O})}else g&&va(g)?l.value=q.ReceivingRef(Mr(y)):l.value=q.ObjectRef(Mr(y))})}};wt=new WeakSet;Kt=async function(t){if(!t.onlyTransactionKind&&!_(this,k).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([N(this,Ar,Mn).call(this,t),N(this,_r,Pn).call(this,t)]),!t.onlyTransactionKind&&(await N(this,Ir,Un).call(this,t),!_(this,k).gasConfig.budget)){const e=await Ye(t).dryRunTransactionBlock({transactionBlock:_(this,k).build({maxSizeBytes:N(this,Ee,Be).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(N(this,Ee,Be).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=ka*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)}N(this,kr,jn).call(this,t)};const Oa=Symbol.for("@mysten/SuiClient");class Ca{get[Oa](){return!0}constructor(e){this.transport=e.transport??new yi({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!he(j(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||!he(j(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||!he(j(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||!he(j(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||!he(j(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||!ut(ae(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||!ut(ae(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(!jr(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(!jr(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:W(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||!he(j(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||!ut(ae(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(_a(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=W(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=W(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:W(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!ut(ae(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=rt(e.digest);return Ce(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,c)=>{i.addEventListener("abort",()=>c(i.reason))});for(a.catch(()=>{});!i.aborted;){e==null||e.throwIfAborted();try{return await this.getTransactionBlock(s)}catch{await Promise.race([new Promise(c=>setTimeout(c,n)),a])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}class $n extends Hr.ChainContext{}const Qe="Sui",Br=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},ja=(t,e)=>{try{return Dr(t)===Dr(e)}catch{return!1}},Ua=t=>(t==null?void 0:t.type)==="created",Ma=t=>(t==null?void 0:t.type)==="published";function Pa(t){return Array.isArray(t)}function At(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function Nn(t){return typeof t=="object"&&!Pa(t)&&!At(t)}const Ra=16*1024,$a=t=>M.ser("vector<u8>",t,{maxSize:Ra}).toBytes(),Na=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||!At(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return zn(r.content.type)},Dn=async(t,e)=>{if(!he(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return Br(r)};async function Da(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=Br(s);if(!i||!Nn(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!At(i.value))throw new Error("Unable to get package id");return i.value.fields.package}const La=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:c,objectId:d}=o.data;(n===null||c<n)&&(n=c,s=d)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},za=async(t,e)=>{const r=new Ba,[n]=r.publish({modules:t.modules.map(s=>Array.from(S.b64.decode(s))),dependencies:t.dependencies.map(s=>ae(s))});return r.transferObjects([n],r.pure(e)),r},le=class le extends Hr.PlatformContext{constructor(e,r){super(e,r??S.networkPlatformConfigs(e,le._platform))}getRpc(e){if(e in this.config)return new Ca({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new $n(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!le.isSupportedChain(r))throw new Error(`invalid chain for ${Qe}: ${r}`);return S.Wormhole.tokenId(r,ii)}static isNativeTokenId(e,r,n){return!le.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return S.chainToPlatform(e)===le._platform}static async getDecimals(e,r,n){if(S.isNative(n))return S.nativeDecimals(le._platform);const s=new me(n);try{const a=await Dn(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.getCoinType()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getBalance(e,r,n,s){if(S.isNative(s)){const{totalBalance:a}=await r.getBalance({owner:n});return BigInt(a)}const{totalBalance:i}=await r.getBalance({owner:n,coinType:s.toString()});return BigInt(i)}static async getBalances(e,r,n,s){return(await Promise.all(s.map(async a=>{const o=await this.getBalance(e,r,n,a);return{[S.isNative(a)?"native":new me(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=S.platformNativeChainIdToNetworkChain(le._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)}};ie(le,"_platform",Qe);let Oe=le;const Or=t=>/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(t),Ln=t=>t.replace(/(0x)(0*)/g,"0x");function Nr(t){return t=t.startsWith("0x")?t.slice(2):t,t=t.length%2===0?t:"0"+t,`0x${t.length===64?t:S.hex.encode(S.bytes.zpad(S.hex.decode(t),32))}`}const Dr=t=>{const e=t.split(Ue);if(e.length!==3)throw new Error(`Invalid Sui type: ${t}`);return[j(e[0]),e[1],e[2]].join(Ue)},Va=t=>new me(t).getCoinType(),zn=t=>new me(t).getPackageId(),Ha=t=>{const e=Ln(t).match(/0x2::table::Table<(.*)>/);if(!e)throw new Error(`Invalid table type: ${t}`);if(e.length<2)throw new Error(`Invalid table type: ${t}`);const[r]=e[1].split(",");if(!r||!Or(r))throw new Error(`Invalid key type: ${r}`);return r},Ie=class Ie{constructor(e){ie(this,"address");ie(this,"module");if(Ie.instanceof(e))this.address=e.address,this.module=e.module;else if(S.UniversalAddress.instanceof(e))this.address=e.toUint8Array();else if(typeof e=="string"){if(Or(e)){const r=e.split(Ue);this.module=r.slice(1).join(Ue),e=r[0]}if(e=Nr(e),!S.hex.valid(e))throw new Error("Invalid Sui address: "+e);this.address=S.hex.decode(e)}else this.address=e}unwrap(){const e=this.getPackageId(),r=this.module?Ue+this.module:"";return`${e}${r}`}toString(){return this.unwrap()}toNative(){return this}toUint8Array(){return this.address}toUniversalAddress(){return new S.UniversalAddress(this.toUint8Array())}getPackageId(){return Nr(S.hex.encode(this.address))}getCoinType(){return[this.getPackageId(),"coin","COIN"].join(Ue)}static instanceof(e){return e.constructor.platform===Ie.platform}equals(e){return Ie.instanceof(e)?e.unwrap()===this.unwrap():this.toUniversalAddress().equals(e)}};ie(Ie,"byteSize",32),ie(Ie,"platform",Oe._platform);let me=Ie;S.registerNative(Qe,me);var et=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))(et||{});function Fa(t){return[t,0,0]}function Vn(t,e){const r=Fa(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const _t={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},qa={ED25519:32,Secp256k1:33,Secp256r1:33},Wa={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function Ka(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function Ga(t,e){const r=t.toString(16);return S.hexToBytes(r.padStart(e*2,"0").slice(-e*2))}function Za(t,e){const r=Ga(t,e),n=Ka(r);return n===-1?new Uint8Array([0]):r.slice(n)}function Ja(t,e){const r=Za(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([_t.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),j(S.bytesToHex(S.blake2b(s,{dkLen:32})).slice(0,st*2))}function Xa(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 Ya(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=Xa(n);e=e.concat(s)}return e}function Qa(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=Ya(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 c=r.slice(o,o+8),d=parseInt(c.join(""),2);i[a++]=d}return new TextDecoder().decode(i)}function eo(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 to(t,e){const r=Qa(t.value,t.indexMod4),[n,s]=eo(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const ro=u.struct("ZkLoginSignature",{inputs:u.struct("ZkLoginSignatureInputs",{proofPoints:u.struct("ZkLoginSignatureInputsProofPoints",{a:u.vector(u.string()),b:u.vector(u.vector(u.string())),c:u.vector(u.string())}),issBase64Details:u.struct("ZkLoginSignatureInputsClaim",{value:u.string(),indexMod4:u.u8()}),headerBase64:u.string(),addressSeed:u.string()}),maxEpoch:u.u64(),userSignature:u.vector(u.u8())});function no(t){return ro.parse(typeof t=="string"?ne(t):t)}function so({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([_t[e]]),s.set(t,1),s.set(n,1+t.length),W(s)}function io(t){const e=ne(t),r=Wa[e[0]];switch(r){case"MultiSig":const n=M.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}=no(s),{issBase64Details:c,addressSeed:d}=i,h=to(c,"iss"),l=Ja(BigInt(d),h);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:h,address:l,addressSeed:BigInt(d)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const g=qa[r],y=e.slice(1,e.length-g),m=e.slice(1+y.length);return{serializedSignature:t,signatureScheme:r,signature:y,publicKey:m,bytes:e};default:throw new Error("Unsupported signature scheme")}}const bt=32,ao="suiprivkey";class oo{async signWithIntent(e,r){const n=Vn(r,e),s=S.blake2b(n,{dkLen:32});return{signature:so({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:W(e)}}async signTransactionBlock(e){return this.signWithIntent(e,et.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(u.vector(u.u8()).serialize(e).toBytes(),et.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class co extends oo{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function uo(t,e){if(t.length!==bt)throw new Error("Invalid bytes length");const r=_t[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),S.bech32.encode(ao,S.bech32.toWords(n))}function Lr(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function lo(t){return Us(t,"")}function ho(t){return Ce(lo(t))}const fo="ed25519 seed",go=2147483648,po=new RegExp("^m(\\/[0-9]+')+$"),Hn=t=>t.replace("'",""),yo=t=>{const r=S.hmac.create(S.sha512,fo).update(nt(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},mo=({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=S.hmac.create(S.sha512,e).update(i).digest(),o=a.slice(0,32),c=a.slice(32);return{key:o,chainCode:c}},wo=t=>po.test(t)?!t.split("/").slice(1).map(Hn).some(isNaN):!1,zr=(t,e,r=go)=>{if(!wo(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=yo(e);return t.split("/").slice(1).map(Hn).map(a=>parseInt(a,10)).reduce((a,o)=>mo(a,o+r),{key:n,chainCode:s})};function Fn(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 bo{equals(e){return Fn(this.toRawBytes(),e.toRawBytes())}toBase64(){return W(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return W(e)}verifyWithIntent(e,r,n){const s=Vn(n,e),i=S.blake2b(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(M.vector(M.u8()).serialize(e).toBytes(),r,et.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,et.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return j(S.bytesToHex(S.blake2b(this.toSuiBytes(),{dkLen:32})).slice(0,st*2))}}const Zt=32;class qn extends bo{constructor(e){if(super(),typeof e=="string"?this.data=ne(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==Zt)throw new Error(`Invalid public key input. Expected ${Zt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return _t.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=io(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!Fn(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return S.nacl.sign.detached.verify(e,n,this.toRawBytes())}}qn.SIZE=Zt;const Vr="m/44'/784'/0'/0'/0'";class Me extends co{constructor(e){super(),e?this.keypair=e:this.keypair=S.nacl.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Me(S.nacl.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==bt)throw new Error(`Wrong secretKey size. Expected ${bt} bytes, got ${n}.`);const s=S.nacl.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=S.nacl.sign.detached(a,s.secretKey);if(!S.nacl.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new Me(s)}getPublicKey(){return new qn(this.keypair.publicKey)}getSecretKey(){return uo(this.keypair.secretKey.slice(0,bt),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return S.nacl.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=Vr),!Lr(r))throw new Error("Invalid derivation path");const{key:n}=zr(r,ho(e));return Me.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=Vr),!Lr(r))throw new Error("Invalid derivation path");const{key:n}=zr(r,e);return Me.fromSecretKey(n)}}async function So(t,e){const[,r]=await Oe.chainFromRpc(t);return new To(r,t,Me.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class To{constructor(e,r,n,s){ie(this,"_chain");ie(this,"_client");ie(this,"_signer");ie(this,"_debug");this._chain=e,this._client=r,this._signer=n,this._debug=s}chain(){return this._chain}address(){return this._signer.toSuiAddress()}async signAndSend(e){const r=[];for(const n of e){const{description:s,transaction:i}=n;this._debug&&console.log(`Signing ${s} for ${this.address()}`);const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}return r}}const xo={Address:me,Platform:Oe,getSigner:So,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-k5MpmioF.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-DHPvJyI7.js"))},getChain:(t,e,r)=>new $n(e,new Oe(t,S.applyChainsConfigConfigOverrides(t,Qe,{[e]:r})))},Eo=Object.freeze(Object.defineProperty({__proto__:null,default:xo},Symbol.toStringTag,{value:"Module"}));exports.SuiAddress=me;exports.SuiPlatform=Oe;exports._platform=Qe;exports.getCoinTypeFromPackageId=Va;exports.getFieldsFromObjectResponse=Br;exports.getObjectFields=Dn;exports.getOldestEmitterCapObjectId=La;exports.getOriginalPackageId=Na;exports.getPackageId=Da;exports.getPackageIdFromType=zn;exports.getTableKeyType=Ha;exports.isMoveStructObject=Nn;exports.isMoveStructStruct=At;exports.isSameType=ja;exports.isSuiCreateEvent=Ua;exports.isSuiPublishEvent=Ma;exports.isValidSuiType=Or;exports.publishPackage=za;exports.sui=Eo;exports.trimSuiType=Ln;exports.uint8ArrayToBCS=$a;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var Jn = Object.defineProperty;
|
|
2
2
|
var Xn = (t, e, r) => e in t ? Jn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
3
|
var se = (t, e, r) => (Xn(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
4
|
-
import { g as Yn, b2 as Ge, b3 as Qn, ax as es, ay as ts, az as rs, aA as jt, aB as ns, aC as ss, av as Ur, au as Fe, aw as is, b4 as as, b5 as os, b6 as qr, b7 as Mr, b8 as Kr, b9 as Gr, ba as ve, aF as cs } from "./index-
|
|
5
|
-
import { C as us, P as ds } from "./chain-
|
|
4
|
+
import { g as Yn, b2 as Ge, b3 as Qn, ax as es, ay as ts, az as rs, aA as jt, aB as ns, aC as ss, av as Ur, au as Fe, aw as is, b4 as as, b5 as os, b6 as qr, b7 as Mr, b8 as Kr, b9 as Gr, ba as ve, aF as cs } from "./index-C6mDtHMX.mjs";
|
|
5
|
+
import { C as us, P as ds } from "./chain-D1Ms6bPc.mjs";
|
|
6
6
|
function We(t) {
|
|
7
7
|
if (!Number.isSafeInteger(t) || t < 0)
|
|
8
8
|
throw new Error(`positive integer expected, not ${t}`);
|
|
@@ -5507,8 +5507,8 @@ const jo = {
|
|
|
5507
5507
|
Platform: $e,
|
|
5508
5508
|
getSigner: Oo,
|
|
5509
5509
|
protocols: {
|
|
5510
|
-
WormholeCore: () => import("./index-
|
|
5511
|
-
TokenBridge: () => import("./index-
|
|
5510
|
+
WormholeCore: () => import("./index-BzX2BW_O.mjs"),
|
|
5511
|
+
TokenBridge: () => import("./index-B4Wo5ciI.mjs")
|
|
5512
5512
|
},
|
|
5513
5513
|
getChain: (t, e, r) => new Vn(e, new $e(t, cs(t, _t, { [e]: r })))
|
|
5514
5514
|
}, qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|