@wormhole-foundation/wormhole-connect 2.0.0-beta.1-development → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{aptos-gRn0txr9.js → aptos-CvRULtpx.js} +61 -61
- package/dist/assets/aptos-D4y7Fo3S.js +3 -0
- package/dist/assets/{chunk-OR6GFWLG-Ci0TYwIQ.js → chunk-OR6GFWLG-BZrmB1_W.js} +1 -1
- package/dist/assets/evm-K2ASlzX-.js +2 -0
- package/dist/assets/{index-CTtLxavV.js → index-AaqmNOLf.js} +1 -1
- package/dist/assets/index-BLpnEfNA.js +1 -0
- package/dist/assets/{index-DtASoatx.js → index-BTnVHgr_.js} +1 -1
- package/dist/assets/{index-Cf10mHc-.js → index-BpWlJX3r.js} +1 -1
- package/dist/assets/{index-DTCth0iO.js → index-C1mpuWJz.js} +1 -1
- package/dist/assets/{index-cfzEp_CP.js → index-C1yBHw3e.js} +1 -1
- package/dist/assets/{index-Dwk61kXP.js → index-CEjbqPmT.js} +1 -1
- package/dist/assets/{index-BZKNZDak.js → index-CZHHMApS.js} +1 -1
- package/dist/assets/{index-Cm_KjDDY.js → index-QLnl5sO1.js} +1 -1
- package/dist/assets/{index-D7CrUmY0.js → index-_NuAK6zi.js} +1 -1
- package/dist/assets/index-rryJGGTI.js +1 -0
- package/dist/assets/{signer-BaParnK7.js → signer-dWGaM-mu.js} +1 -1
- package/dist/assets/{solana-5w7FFw9J.js → solana-D2tTKYdq.js} +1 -1
- package/dist/assets/solana-UIzLk1Ne.js +2 -0
- package/dist/assets/{sui-DaosOePU.js → sui-DVNvuW-l.js} +4 -4
- package/dist/assets/unsignedTransaction-DsxtoHjl.js +1 -0
- package/dist/main.js +100 -100
- package/dist/src/config/mainnet/tokens.d.ts.map +1 -1
- package/dist/src/config/testnet/tokens.d.ts.map +1 -1
- package/dist/src/hooks/useWalletCompatibility.d.ts +14 -0
- package/dist/src/hooks/useWalletCompatibility.d.ts.map +1 -0
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/wallet/aptos.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/index.d.ts.map +1 -1
- package/lib/aptos-CH5PkH0s.js +2 -0
- package/lib/{aptos-szFJdwGu.mjs → aptos-DQLx8hgI.mjs} +59 -57
- package/lib/{aptos-ZmgQfu2i.mjs → aptos-Ma7G2qxg.mjs} +1229 -1228
- package/lib/{aptos-DBP3jmW7.js → aptos-b8R7xC2M.js} +9 -9
- package/lib/{base64-BFA_udDL.js → base64-BoCuDrAB.js} +1 -1
- package/lib/{base64-DJKqMaey.mjs → base64-mN6OGBib.mjs} +1 -1
- package/lib/{ccip-DA2Nx1SC.js → ccip-B9dsdqqe.js} +1 -1
- package/lib/{ccip-urjf2Ohy.mjs → ccip-D9a8gGDP.mjs} +1 -1
- package/lib/{chunk-OR6GFWLG-DMRHoX5e.js → chunk-OR6GFWLG-D0VxCcX2.js} +5 -5
- package/lib/{chunk-OR6GFWLG-BxTMqzEc.mjs → chunk-OR6GFWLG-DVAlj5GC.mjs} +6 -3
- package/lib/{events-CeUTM3JY.js → events-BiLMWAJd.js} +1 -1
- package/lib/{events-VkSlTRL0.mjs → events-exed8Lkm.mjs} +1 -1
- package/lib/{evm-CVR26OSW.mjs → evm-Bn4_N0e_.mjs} +6 -6
- package/lib/{evm-rBfvNQnC.js → evm-D5JyNa99.js} +1 -1
- package/lib/{evm-DR1h6onf.js → evm-DOSrblQ4.js} +3 -3
- package/lib/{evm-DSWmFw3D.mjs → evm-DbuXa17H.mjs} +5 -5
- package/lib/{index-y6JzKy7h.js → index-B14q08ea.js} +1 -1
- package/lib/{index-D2ZFuAXe.mjs → index-B4hte2VB.mjs} +1 -1
- package/lib/{index-CUD_KSHh.mjs → index-B5Deg2Mr.mjs} +4 -4
- package/lib/{index-CtzDS4Ek.js → index-B7xiGLlo.js} +1 -1
- package/lib/{index-BD-n4Jda.js → index-BEg_FhHj.js} +1 -1
- package/lib/{index-CP1YtvQl.mjs → index-BEjIjDI_.mjs} +2 -2
- package/lib/{index-DdleqS-C.js → index-BL3U9o8r.js} +1 -1
- package/lib/{index-B54uaK5S.mjs → index-BQmtmaUN.mjs} +3 -3
- package/lib/{index-Ccg2yYsG.mjs → index-BVa8vX0X.mjs} +2 -2
- package/lib/index-BWwLFE0K.mjs +102 -0
- package/lib/{index-Bb6FMstR.js → index-Ba2rdKMd.js} +1 -1
- package/lib/{index-BVdejQdc.js → index-BaF9FXkh.js} +1 -1
- package/lib/{index-C92Lbp7R.js → index-BdbY6Nvl.js} +1 -1
- package/lib/{index-Ds36ZJFd.js → index-BsRDGZ_9.js} +1 -1
- package/lib/{index-DbFTlikk.js → index-Bt41X2O-.js} +1 -1
- package/lib/{index-fTMcBh-E.js → index-BtBZ1mGN.js} +1 -1
- package/lib/{index-BdgBgC9M.mjs → index-ByaJFPk7.mjs} +2 -2
- package/lib/{index-Gq0crvhx.js → index-CMcnZ-nu.js} +1 -1
- package/lib/{index-Cm2DqtOc.mjs → index-CT8zJiLG.mjs} +48 -57
- package/lib/{index-BN7FfORx.mjs → index-CTdUTRp6.mjs} +25133 -25060
- package/lib/index-CTywhroc.js +1 -0
- package/lib/{index-COMVJ9EC.js → index-CeiDJddc.js} +1 -1
- package/lib/{index-2Hoo-RF7.mjs → index-CjC_JXyt.mjs} +1 -1
- package/lib/{index-Bh_VUH6w.js → index-CoYZ1p1j.js} +154 -154
- package/lib/{index-BGMRuYE4.mjs → index-CyZSCH1P.mjs} +22 -22
- package/lib/{index-C23ZcDqk.mjs → index-CztHxO-n.mjs} +2 -2
- package/lib/{index-Coap6PLP.mjs → index-D-8Ng1L-.mjs} +8 -8
- package/lib/{index-DGzYkbea.mjs → index-D08eoAwY.mjs} +7 -7
- package/lib/{index-CMS03ogd.js → index-D5i-Hwy3.js} +1 -1
- package/lib/{index-42eVh0Hb.mjs → index-D6uakBm-.mjs} +2 -2
- package/lib/{index-CCwF2yAJ.mjs → index-DKvD1ciD.mjs} +5 -5
- package/lib/{index-BZWHrS5h.mjs → index-DNQTwT9U.mjs} +2 -2
- package/lib/{index-DaebrvyB.js → index-DuaKRUyC.js} +1 -1
- package/lib/index-DudwgIzb.js +1 -0
- package/lib/{index-KKiy1Hrx.mjs → index-DzFW4H-c.mjs} +1 -1
- package/lib/{index-BXHKeAv4.mjs → index-_f9fa-SF.mjs} +2 -2
- package/lib/{index-sGgOiMAb.js → index-dmXJ0lij.js} +1 -1
- package/lib/{index-pf1Hd87D.js → index-t_N-kr6F.js} +1 -1
- package/lib/{index-Fsd-hYv7.mjs → index-yHv6yF_6.mjs} +38 -38
- package/lib/{index-B6Cq1iZ2.js → index-zkkhgyCt.js} +1 -1
- package/lib/{index.es-BwVfbE63.mjs → index.es-BU6v666-.mjs} +6 -6
- package/lib/{index.es-Bb3szEaY.js → index.es-HUYc3ygi.js} +2 -2
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{signer-DOhyF9G-.mjs → signer-B5bRCRbp.mjs} +19 -19
- package/lib/{signer-BYquDVs4.js → signer-_8JGUZ18.js} +1 -1
- package/lib/{solana-C7zGAW8V.mjs → solana-C5maMKhK.mjs} +4 -4
- package/lib/solana-C8ERuccx.mjs +16 -0
- package/lib/solana-CFT736gU.js +1 -0
- package/lib/{solana-cxRzZXbi.js → solana-Vkj_NP_7.js} +1 -1
- package/lib/{solanaEmbed.esm-DYuDmeOj.mjs → solanaEmbed.esm-CeLkcZUT.mjs} +959 -959
- package/lib/{solanaEmbed.esm-Bw4WVPNb.js → solanaEmbed.esm-GokLVSoz.js} +1 -1
- package/lib/src/config/mainnet/tokens.d.ts.map +1 -1
- package/lib/src/config/testnet/tokens.d.ts.map +1 -1
- package/lib/src/hooks/useWalletCompatibility.d.ts +14 -0
- package/lib/src/hooks/useWalletCompatibility.d.ts.map +1 -0
- package/lib/src/utils/index.d.ts +1 -1
- package/lib/src/utils/index.d.ts.map +1 -1
- package/lib/src/utils/wallet/aptos.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/index.d.ts.map +1 -1
- package/lib/{sui-BAj9wCLR.mjs → sui-BgpwzAcZ.mjs} +1 -1
- package/lib/{sui-D2Lx7sNr.js → sui-CFB02A_e.js} +1 -1
- package/lib/{sui--QzlscdW.mjs → sui-CXLpQ4w9.mjs} +5 -5
- package/lib/{sui-DFYvs2lh.js → sui-DwGUL_nC.js} +2 -2
- package/lib/unsignedTransaction-BDOQhqcZ.mjs +16 -0
- package/lib/unsignedTransaction-C1YeEl4G.js +1 -0
- package/lib/{utf8-C9mhtl0f.js → utf8-BBrW0GUg.js} +1 -1
- package/lib/{utf8-D8MD86af.mjs → utf8-Dg51R0Wb.mjs} +1 -1
- package/package.json +18 -18
- package/dist/assets/aptos-Ycl2eNjD.js +0 -3
- package/dist/assets/evm-ETvgEF-D.js +0 -2
- package/dist/assets/index-_2IpGxfE.js +0 -1
- package/dist/assets/solana-u2eYUt3V.js +0 -2
- package/lib/aptos-C698CxDU.js +0 -2
- package/lib/index-DVxKNFdQ.js +0 -1
- package/lib/solana-B0yxLYge.mjs +0 -16
- package/lib/solana-i-1aVGyQ.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Zr=Object.defineProperty;var Yr=(t,e,r)=>e in t?Zr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var M=(t,e,r)=>Yr(t,typeof e!="symbol"?e+"":e,r);import{j as Qr,aP as en,cG as ft,aV as tn,cH as hr,cI as ve,by as rn,bZ as nt,bD as nn,b_ as nr,bw as ce,aY as ge,ak as oe,bA as sn,c3 as ir,c0 as an,cJ as on,bE as ht,aW as cn,aa as De,cx as un,ce as sr,cK as dn,aX as ar,bJ as gr}from"../main.js";import{g as tt,a as gt,i as Ve,S as Q,b as H,p as ln,c as fn,d as it,u as ze,e as pr,f as hn,h as He,j as gn,k as pn}from"./sui-DaosOePU.js";import"./index-D7CrUmY0.js";import{S as yr}from"./unsignedTransaction-arVvzoJx.js";import"./index-BFMIYSUy.js";class yn extends TypeError{constructor(e,r){let n;const{message:i,explanation:s,...c}=e,{path:a}=e,o=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??o),s!=null&&(this.cause=o),Object.assign(this,c),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function mn(t){return L(t)&&typeof t[Symbol.iterator]=="function"}function L(t){return typeof t=="object"&&t!=null}function W(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function wn(t){const{done:e,value:r}=t.next();return e?void 0:r}function bn(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:s}=e,{type:c}=r,{refinement:a,message:o=`Expected a value of type \`${c}\`${a?` with refinement \`${a}\``:""}, but received: \`${W(n)}\``}=t;return{value:n,type:c,refinement:a,key:i[i.length-1],path:i,branch:s,...t,message:o}}function*or(t,e,r,n){mn(t)||(t=[t]);for(const i of t){const s=bn(i,e,r,n);s&&(yield s)}}function*kt(t,e,r={}){const{path:n=[],branch:i=[t],coerce:s=!1,mask:c=!1}=r,a={path:n,branch:i};if(s&&(t=e.coercer(t,a),c&&e.type!=="type"&&L(e.schema)&&L(t)&&!Array.isArray(t)))for(const d in t)e.schema[d]===void 0&&delete t[d];let o="valid";for(const d of e.validator(t,a))d.explanation=r.message,o="not_valid",yield[d,void 0];for(let[d,u,g]of e.entries(t,a)){const m=kt(u,g,{path:d===void 0?n:[...n,d],branch:d===void 0?i:[...i,u],coerce:s,mask:c,message:r.message});for(const y of m)y[0]?(o=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):s&&(u=y[1],d===void 0?t=u:t instanceof Map?t.set(d,u):t instanceof Set?t.add(u):L(t)&&(u!==void 0||d in t)&&(t[d]=u))}if(o!=="not_valid")for(const d of e.refiner(t,a))d.explanation=r.message,o="not_refined",yield[d,void 0];o==="valid"&&(yield[void 0,t])}class te{constructor(e){const{type:r,schema:n,validator:i,refiner:s,coercer:c=o=>o,entries:a=function*(){}}=e;this.type=r,this.schema=n,this.entries=a,this.coercer=c,i?this.validator=(o,d)=>{const u=i(o,d);return or(u,d,this,o)}:this.validator=()=>[],s?this.refiner=(o,d)=>{const u=s(o,d);return or(u,d,this,o)}:this.refiner=()=>[]}assert(e,r){return pt(e,this,r)}create(e,r){return mr(e,this,r)}is(e){return F(e,this)}mask(e,r){return wr(e,this,r)}validate(e,r={}){return Ce(e,this,r)}}function pt(t,e,r){const n=Ce(t,e,{message:r});if(n[0])throw n[0]}function mr(t,e,r){const n=Ce(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function wr(t,e,r){const n=Ce(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function F(t,e){return!Ce(t,e)[0]}function Ce(t,e,r={}){const n=kt(t,e,r),i=wn(n);return i[0]?[new yn(i[0],function*(){for(const c of n)c[0]&&(yield c[0])}),void 0]:[void 0,i[1]]}function Ae(...t){const e=t[0].type==="type",r=t.map(i=>i.schema),n=Object.assign({},...r);return e?Tn(n):p(n)}function G(t,e){return new te({type:t,schema:null,validator:e})}function yt(){return G("any",()=>!0)}function I(t){return new te({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${W(e)}`}})}function Sn(){return G("bigint",t=>typeof t=="bigint")}function D(){return G("boolean",t=>typeof t=="boolean")}function ee(){return G("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${W(t)}`)}function T(t){const e=W(t),r=typeof t;return new te({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${W(n)}`}})}function br(){return G("never",()=>!1)}function B(t){return new te({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function ye(){return G("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${W(t)}`)}function p(t){const e=t?Object.keys(t):[],r=br();return new te({type:"object",schema:t||null,*entries(n){if(t&&L(n)){const i=new Set(Object.keys(n));for(const s of e)i.delete(s),yield[s,n[s],t[s]];for(const s of i)yield[s,n[s],r]}},validator(n){return L(n)||`Expected an object, but received: ${W(n)}`},coercer(n){return L(n)?{...n}:n}})}function S(t){return new te({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Y(t,e){return new te({type:"record",schema:null,*entries(r){if(L(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator(r){return L(r)||`Expected an object, but received: ${W(r)}`}})}function h(){return G("string",t=>typeof t=="string"||`Expected a string, but received: ${W(t)}`)}function Sr(t){const e=br();return new te({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;i<n;i++)yield[i,r[i],t[i]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${W(r)}`}})}function Tn(t){const e=Object.keys(t);return new te({type:"type",schema:t,*entries(r){if(L(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return L(r)||`Expected an object, but received: ${W(r)}`},coercer(r){return L(r)?{...r}:r}})}function C(t){const e=t.map(r=>r.type).join(" | ");return new te({type:"union",schema:null,coercer(r){for(const n of t){const[i,s]=n.validate(r,{coerce:!0});if(!i)return s}return r},validator(r,n){const i=[];for(const s of t){const[...c]=kt(r,s,n),[a]=c;if(a[0])for(const[o]of c)o&&i.push(o);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${W(r)}`,...i]}})}function Tr(){return G("unknown",()=>!0)}const vt=C([p({AddressOwner:h()}),p({ObjectOwner:h()}),p({Shared:p({initial_shared_version:B(h())})}),T("Immutable")]);G("SuiJsonValue",()=>!0);const kn=C([p({u32:h()}),p({u64:h()}),p({f64:h()})]);p({attributes:Y(h(),B(kn)),featureFlags:Y(h(),D()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});C([h(),T("package")]);const de=p({digest:h(),objectId:h(),version:C([ye(),h(),Sn()])});p({owner:vt,reference:de});p({objectId:h(),sequenceNumber:h()});p({payment:I(de),owner:h(),price:h(),budget:h()});const vn=Ae(de,p({type:h(),owner:vt,previousTransaction:h()})),In=Y(h(),yt()),jn=Y(h(),Tr()),En=p({type:h(),fields:In,hasPublicTransfer:D()}),On=p({disassembled:jn}),An=C([Ae(En,p({dataType:T("moveObject")})),Ae(On,p({dataType:T("package")}))]),_n=p({type:h(),hasPublicTransfer:D(),version:h(),bcsBytes:h()}),xn=p({id:h(),moduleMap:Y(h(),h())}),Bn=C([Ae(_n,p({dataType:T("moveObject")})),Ae(xn,p({dataType:T("package")}))]);BigInt(1e9);const kr=p({code:h(),error:S(h()),object_id:S(h()),parent_object_id:S(h()),version:S(h()),digest:S(h())}),Cn=p({data:B(S(Y(h(),h()))),error:B(S(kr))}),$n=C([Cn,S(Y(h(),h()))]),vr=p({objectId:h(),version:h(),digest:h(),type:B(S(h())),content:B(S(An)),bcs:B(S(Bn)),owner:B(S(vt)),previousTransaction:B(S(h())),storageRebate:B(S(h())),display:B(S($n))});p({showType:B(S(D())),showContent:B(S(D())),showBcs:B(S(D())),showOwner:B(S(D())),showPreviousTransaction:B(S(D())),showStorageRebate:B(S(D())),showDisplay:B(S(D()))});C([T("Exists"),T("notExists"),T("Deleted")]);I(vn);const Un=p({data:B(S(vr)),error:B(S(kr))});function Rn(t){return t.data}function Pn(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 cr(t){if("reference"in t)return t.reference;const e=Rn(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:Pn(t)}p({objectId:h(),atCheckpoint:S(ye())});p({data:I(Un),nextCursor:S(B(h())),hasNextPage:D()});C([p({details:vr,status:T("VersionFound")}),p({details:h(),status:T("ObjectNotExists")}),p({details:de,status:T("ObjectDeleted")}),p({details:Sr([h(),ye()]),status:T("VersionNotFound")}),p({details:p({asked_version:ye(),latest_version:ye(),object_id:h()}),status:T("VersionTooHigh")})]);const Mn=C([h(),p({Object:h()})]);I(Mn);const Nn=p({address:h(),name:h()}),Dn=C([T("Private"),T("Public"),T("Friend")]),It=p({abilities:I(h())}),Vn=p({constraints:It,isPhantom:D()}),zn=p({TypeParameter:ye()}),st=Sr([p({module:h(),package:h(),function:h()}),h()]);p({rank3Days:I(st),rank7Days:I(st),rank30Days:I(st)});function Ir(t){if(!t)return!1;if(typeof t=="string"||F(t,zn)||jr(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(F(e.Reference,Se)||F(e.MutableReference,Se)||F(e.Vector,Se))}const Se=G("SuiMoveNormalizedType",Ir);function jr(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=>Ir(n)))}G("SuiMoveNormalizedStructType",jr);const Fn=p({visibility:Dn,isEntry:D(),typeParameters:I(It),parameters:I(Se),return:I(Se)}),Gn=p({name:h(),type:Se}),Ln=p({abilities:It,typeParameters:I(Vn),fields:I(Gn)}),Wn=p({fileFormatVersion:ye(),address:h(),name:h(),friends:I(Nn),structs:Y(h(),Ln),exposedFunctions:Y(h(),Fn)});Y(h(),Wn);function mt(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function Er(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function jt(t){if(typeof t=="object"&&"Struct"in t)return t;const e=Er(t),r=mt(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}function Kn(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 i=t.charAt(n),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=n}var c=t.length,a=t.charAt(0),o=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function u(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 w=0,b=0,f=0,j=y.length;f!==j&&y[f]===0;)f++,w++;for(var _=(j-f)*d+1>>>0,$=new Uint8Array(_);f!==j;){for(var E=y[f],v=0,U=_-1;(E!==0||v<b)&&U!==-1;U--,v++)E+=256*$[U]>>>0,$[U]=E%c>>>0,E=E/c>>>0;if(E!==0)throw new Error("Non-zero carry");b=v,f++}for(var K=_-b;K!==_&&$[K]===0;)K++;for(var we=a.repeat(w);K<_;++K)we+=t.charAt($[K]);return we}function g(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;for(var w=0,b=0,f=0;y[w]===a;)b++,w++;for(var j=(y.length-w)*o+1>>>0,_=new Uint8Array(j);y[w];){var $=e[y.charCodeAt(w)];if($===255)return;for(var E=0,v=j-1;($!==0||E<f)&&v!==-1;v--,E++)$+=c*_[v]>>>0,_[v]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");f=E,w++}for(var U=j-f;U!==j&&_[U]===0;)U++;for(var K=new Uint8Array(b+(j-U)),we=b;U!==j;)K[we++]=_[U++];return K}function m(y){var w=g(y);if(w)return w;throw new Error("Non-base"+c+" character")}return{encode:u,decodeUnsafe:g,decode:m}}var Jn=Kn;const Hn=Jn,Xn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var qn=Hn(Xn);const Or=Qr(qn),$e=t=>Or.encode(t),Et=t=>Or.decode(t);function le(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const at=8192;function Ue(t){if(t.length<at)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=at){const n=t.slice(r,r+at);e+=String.fromCharCode(...n)}return btoa(e)}function rt(t){var i;const e=t.startsWith("0x")?t.slice(2):t,n=((i=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:i.map(s=>parseInt(s,16)))??[];return Uint8Array.from(n)}function Re(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function Ot(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 Zn(t){let e=0,r=0,n=0;for(;;){let i=t[n];if(n+=1,e|=(i&127)<<r,!(i&128))break;r+=7}return{value:e,length:n}}class Ar{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:i}=Zn(r);return this.shift(i),n}readVec(e){let r=this.readULEB(),n=[];for(let i=0;i<r;i++)n.push(e(this,i,r));return n}}function Yn(t,e){switch(e){case"base58":return $e(t);case"base64":return Ue(t);case"hex":return Re(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Qn(t,e){switch(e){case"base58":return Et(t);case"base64":return le(t);case"hex":return rt(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function At(t,e=["<",">"]){const[r,n]=e,i=[];let s="",c=0;for(let a=0;a<t.length;a++){const o=t[a];if(o===r&&c++,o===n&&c--,c===0&&o===","){i.push(s.trim()),s="";continue}s+=o}return i.push(s.trim()),i}class _r{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 i=new ArrayBuffer(this.size);new Uint8Array(i).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(i)}}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 ot(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return ot(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return ot(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return Ot(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,i)=>r(this,n,i,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 Yn(this.toBytes(),e)}}function ot(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 xr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},X=(t,e,r)=>(xr(t,e,"read from private field"),r?r.call(t):e.get(t)),Xe=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},qe=(t,e,r,n)=>(xr(t,e,"write to private field"),e.set(t,r),r),be,Ie,Fe,ae;const Br=class{constructor(t){Xe(this,be,void 0),Xe(this,Ie,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),qe(this,be,t.write),qe(this,Ie,t.serialize??((e,r)=>{const n=new _r({size:this.serializedSize(e)??void 0,...r});return X(this,be).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),X(this,be).call(this,t,e)}serialize(t,e){return this.validate(t),new ei(this,X(this,Ie).call(this,t,e))}parse(t){const e=new Ar(t);return this.read(e)}transform({name:t,input:e,output:r}){return new Br({name:t??this.name,read:n=>r(this.read(n)),write:(n,i)=>X(this,be).call(this,e(n),i),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,i)=>X(this,Ie).call(this,e(n),i),validate:n=>this.validate(e(n))})}};let q=Br;be=new WeakMap;Ie=new WeakMap;const Cr=Symbol.for("@mysten/serialized-bcs");function _t(t){return!!t&&typeof t=="object"&&t[Cr]===!0}class ei{constructor(e,r){Xe(this,Fe,void 0),Xe(this,ae,void 0),qe(this,Fe,e),qe(this,ae,r)}get[Cr](){return!0}toBytes(){return X(this,ae)}toHex(){return Re(X(this,ae))}toBase64(){return Ue(X(this,ae))}toBase58(){return $e(X(this,ae))}parse(){return X(this,Fe).parse(X(this,ae))}}Fe=new WeakMap;ae=new WeakMap;function Ze({size:t,...e}){return new q({...e,serializedSize:()=>t})}function ct({readMethod:t,writeMethod:e,...r}){return Ze({...r,read:n=>n[t](),write:(n,i)=>i[e](n),validate:n=>{var i;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,n)}})}function ut({readMethod:t,writeMethod:e,...r}){return Ze({...r,read:n=>n[t](),write:(n,i)=>i[e](BigInt(n)),validate:n=>{var s;const i=BigInt(n);if(i<0||i>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${i}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,i)}})}function ti({serialize:t,...e}){const r=new q({...e,serialize:t,write:(n,i)=>{for(const s of r.serialize(n).toBytes())i.write8(s)}});return r}function ri({toBytes:t,fromBytes:e,...r}){return new q({...r,read:n=>{const i=n.readULEB(),s=n.readBytes(i);return e(s)},write:(n,i)=>{const s=t(n);i.writeULEB(s.length);for(let c=0;c<s.length;c++)i.write8(s[c])},serialize:n=>{const i=t(n),s=Ot(i.length),c=new Uint8Array(s.length+i.length);return c.set(s,0),c.set(i,s.length),c},validate:n=>{var i;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(i=r.validate)==null||i.call(r,n)}})}function ni(t){let e=null;function r(){return e||(e=t()),e}return new q({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,i)=>r().write(n,i),serialize:(n,i)=>r().serialize(n,i).toBytes()})}const l={u8(t){return ct({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return ct({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return ct({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return ut({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return ut({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return ut({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Ze({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 ti({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Ot(e)),...t})},bytes(t,e){return Ze({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let i=0;i<t;i++)n.write8(r[i]??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 ri({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new q({name:`${e.name}[${t}]`,read:n=>{const i=new Array(t);for(let s=0;s<t;s++)i[s]=e.read(n);return i},write:(n,i)=>{for(const s of n)e.write(s,i)},...r,validate:n=>{var i;if((i=r==null?void 0:r.validate)==null||i.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 l.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 q({name:`vector<${t.name}>`,read:r=>{const n=r.readULEB(),i=new Array(n);for(let s=0;s<n;s++)i[s]=t.read(r);return i},write:(r,n)=>{n.writeULEB(r.length);for(const i of r)t.write(i,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 q({name:`(${t.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let i=0;i<t.length;i++){const s=t[i].serializedSize(r[i]);if(s==null)return null;n+=s}return n},read:r=>{const n=[];for(const i of t)n.push(i.read(r));return n},write:(r,n)=>{for(let i=0;i<t.length;i++)t[i].write(r[i],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 q({name:t,serializedSize:i=>{let s=0;for(const[c,a]of n){const o=a.serializedSize(i[c]);if(o==null)return null;s+=o}return s},read:i=>{const s={};for(const[c,a]of n)s[c]=a.read(i);return s},write:(i,s)=>{for(const[c,a]of n)a.write(i[c],s)},...r,validate:i=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`)}})},enum(t,e,r){const n=Object.entries(e);return new q({name:t,read:i=>{const s=i.readULEB(),[c,a]=n[s];return{[c]:(a==null?void 0:a.read(i))??!0}},write:(i,s)=>{const[c,a]=Object.entries(i)[0];for(let o=0;o<n.length;o++){const[d,u]=n[o];if(d===c){s.writeULEB(o),u==null||u.write(a,s);return}}},...r,validate:i=>{var a;if((a=r==null?void 0:r.validate)==null||a.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`);const s=Object.keys(i);if(s.length!==1)throw new TypeError(`Expected object with one key, found ${s.length}`);const[c]=s;if(!Object.hasOwn(e,c))throw new TypeError(`Invalid enum variant ${c}`)}})},map(t,e){return l.vector(l.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[i,s]of r)n.set(i,s);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 ni(t)}},ii=32,je=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof je){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(je.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&&si(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:i}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,i)}if(typeof t=="object"){const n=this.tempKey();return new je(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
1
|
+
var Zr=Object.defineProperty;var Yr=(t,e,r)=>e in t?Zr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var M=(t,e,r)=>Yr(t,typeof e!="symbol"?e+"":e,r);import{j as Qr,aP as en,cI as ft,aV as tn,cJ as hr,cK as ve,by as rn,bZ as nt,bD as nn,b_ as nr,bw as ce,aY as ge,al as oe,bA as sn,c3 as ir,c0 as an,cL as on,bE as ht,aW as cn,ab as De,cx as un,ce as sr,cM as dn,aX as ar,bJ as gr}from"../main.js";import{g as tt,a as gt,i as Ve,S as Q,b as H,p as ln,c as fn,d as it,u as ze,e as pr,f as hn,h as He,j as gn,k as pn}from"./sui-DVNvuW-l.js";import"./index-_NuAK6zi.js";import{S as yr}from"./unsignedTransaction-arVvzoJx.js";import"./index-BFMIYSUy.js";class yn extends TypeError{constructor(e,r){let n;const{message:i,explanation:s,...c}=e,{path:a}=e,o=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??o),s!=null&&(this.cause=o),Object.assign(this,c),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function mn(t){return L(t)&&typeof t[Symbol.iterator]=="function"}function L(t){return typeof t=="object"&&t!=null}function W(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function wn(t){const{done:e,value:r}=t.next();return e?void 0:r}function bn(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:s}=e,{type:c}=r,{refinement:a,message:o=`Expected a value of type \`${c}\`${a?` with refinement \`${a}\``:""}, but received: \`${W(n)}\``}=t;return{value:n,type:c,refinement:a,key:i[i.length-1],path:i,branch:s,...t,message:o}}function*or(t,e,r,n){mn(t)||(t=[t]);for(const i of t){const s=bn(i,e,r,n);s&&(yield s)}}function*kt(t,e,r={}){const{path:n=[],branch:i=[t],coerce:s=!1,mask:c=!1}=r,a={path:n,branch:i};if(s&&(t=e.coercer(t,a),c&&e.type!=="type"&&L(e.schema)&&L(t)&&!Array.isArray(t)))for(const d in t)e.schema[d]===void 0&&delete t[d];let o="valid";for(const d of e.validator(t,a))d.explanation=r.message,o="not_valid",yield[d,void 0];for(let[d,u,g]of e.entries(t,a)){const m=kt(u,g,{path:d===void 0?n:[...n,d],branch:d===void 0?i:[...i,u],coerce:s,mask:c,message:r.message});for(const y of m)y[0]?(o=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):s&&(u=y[1],d===void 0?t=u:t instanceof Map?t.set(d,u):t instanceof Set?t.add(u):L(t)&&(u!==void 0||d in t)&&(t[d]=u))}if(o!=="not_valid")for(const d of e.refiner(t,a))d.explanation=r.message,o="not_refined",yield[d,void 0];o==="valid"&&(yield[void 0,t])}class te{constructor(e){const{type:r,schema:n,validator:i,refiner:s,coercer:c=o=>o,entries:a=function*(){}}=e;this.type=r,this.schema=n,this.entries=a,this.coercer=c,i?this.validator=(o,d)=>{const u=i(o,d);return or(u,d,this,o)}:this.validator=()=>[],s?this.refiner=(o,d)=>{const u=s(o,d);return or(u,d,this,o)}:this.refiner=()=>[]}assert(e,r){return pt(e,this,r)}create(e,r){return mr(e,this,r)}is(e){return F(e,this)}mask(e,r){return wr(e,this,r)}validate(e,r={}){return Ce(e,this,r)}}function pt(t,e,r){const n=Ce(t,e,{message:r});if(n[0])throw n[0]}function mr(t,e,r){const n=Ce(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function wr(t,e,r){const n=Ce(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function F(t,e){return!Ce(t,e)[0]}function Ce(t,e,r={}){const n=kt(t,e,r),i=wn(n);return i[0]?[new yn(i[0],function*(){for(const c of n)c[0]&&(yield c[0])}),void 0]:[void 0,i[1]]}function Ae(...t){const e=t[0].type==="type",r=t.map(i=>i.schema),n=Object.assign({},...r);return e?Tn(n):p(n)}function G(t,e){return new te({type:t,schema:null,validator:e})}function yt(){return G("any",()=>!0)}function I(t){return new te({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${W(e)}`}})}function Sn(){return G("bigint",t=>typeof t=="bigint")}function D(){return G("boolean",t=>typeof t=="boolean")}function ee(){return G("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${W(t)}`)}function T(t){const e=W(t),r=typeof t;return new te({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${W(n)}`}})}function br(){return G("never",()=>!1)}function B(t){return new te({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function ye(){return G("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${W(t)}`)}function p(t){const e=t?Object.keys(t):[],r=br();return new te({type:"object",schema:t||null,*entries(n){if(t&&L(n)){const i=new Set(Object.keys(n));for(const s of e)i.delete(s),yield[s,n[s],t[s]];for(const s of i)yield[s,n[s],r]}},validator(n){return L(n)||`Expected an object, but received: ${W(n)}`},coercer(n){return L(n)?{...n}:n}})}function S(t){return new te({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Y(t,e){return new te({type:"record",schema:null,*entries(r){if(L(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator(r){return L(r)||`Expected an object, but received: ${W(r)}`}})}function h(){return G("string",t=>typeof t=="string"||`Expected a string, but received: ${W(t)}`)}function Sr(t){const e=br();return new te({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;i<n;i++)yield[i,r[i],t[i]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${W(r)}`}})}function Tn(t){const e=Object.keys(t);return new te({type:"type",schema:t,*entries(r){if(L(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return L(r)||`Expected an object, but received: ${W(r)}`},coercer(r){return L(r)?{...r}:r}})}function C(t){const e=t.map(r=>r.type).join(" | ");return new te({type:"union",schema:null,coercer(r){for(const n of t){const[i,s]=n.validate(r,{coerce:!0});if(!i)return s}return r},validator(r,n){const i=[];for(const s of t){const[...c]=kt(r,s,n),[a]=c;if(a[0])for(const[o]of c)o&&i.push(o);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${W(r)}`,...i]}})}function Tr(){return G("unknown",()=>!0)}const vt=C([p({AddressOwner:h()}),p({ObjectOwner:h()}),p({Shared:p({initial_shared_version:B(h())})}),T("Immutable")]);G("SuiJsonValue",()=>!0);const kn=C([p({u32:h()}),p({u64:h()}),p({f64:h()})]);p({attributes:Y(h(),B(kn)),featureFlags:Y(h(),D()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});C([h(),T("package")]);const de=p({digest:h(),objectId:h(),version:C([ye(),h(),Sn()])});p({owner:vt,reference:de});p({objectId:h(),sequenceNumber:h()});p({payment:I(de),owner:h(),price:h(),budget:h()});const vn=Ae(de,p({type:h(),owner:vt,previousTransaction:h()})),In=Y(h(),yt()),jn=Y(h(),Tr()),En=p({type:h(),fields:In,hasPublicTransfer:D()}),On=p({disassembled:jn}),An=C([Ae(En,p({dataType:T("moveObject")})),Ae(On,p({dataType:T("package")}))]),_n=p({type:h(),hasPublicTransfer:D(),version:h(),bcsBytes:h()}),xn=p({id:h(),moduleMap:Y(h(),h())}),Bn=C([Ae(_n,p({dataType:T("moveObject")})),Ae(xn,p({dataType:T("package")}))]);BigInt(1e9);const kr=p({code:h(),error:S(h()),object_id:S(h()),parent_object_id:S(h()),version:S(h()),digest:S(h())}),Cn=p({data:B(S(Y(h(),h()))),error:B(S(kr))}),$n=C([Cn,S(Y(h(),h()))]),vr=p({objectId:h(),version:h(),digest:h(),type:B(S(h())),content:B(S(An)),bcs:B(S(Bn)),owner:B(S(vt)),previousTransaction:B(S(h())),storageRebate:B(S(h())),display:B(S($n))});p({showType:B(S(D())),showContent:B(S(D())),showBcs:B(S(D())),showOwner:B(S(D())),showPreviousTransaction:B(S(D())),showStorageRebate:B(S(D())),showDisplay:B(S(D()))});C([T("Exists"),T("notExists"),T("Deleted")]);I(vn);const Un=p({data:B(S(vr)),error:B(S(kr))});function Rn(t){return t.data}function Pn(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 cr(t){if("reference"in t)return t.reference;const e=Rn(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:Pn(t)}p({objectId:h(),atCheckpoint:S(ye())});p({data:I(Un),nextCursor:S(B(h())),hasNextPage:D()});C([p({details:vr,status:T("VersionFound")}),p({details:h(),status:T("ObjectNotExists")}),p({details:de,status:T("ObjectDeleted")}),p({details:Sr([h(),ye()]),status:T("VersionNotFound")}),p({details:p({asked_version:ye(),latest_version:ye(),object_id:h()}),status:T("VersionTooHigh")})]);const Mn=C([h(),p({Object:h()})]);I(Mn);const Nn=p({address:h(),name:h()}),Dn=C([T("Private"),T("Public"),T("Friend")]),It=p({abilities:I(h())}),Vn=p({constraints:It,isPhantom:D()}),zn=p({TypeParameter:ye()}),st=Sr([p({module:h(),package:h(),function:h()}),h()]);p({rank3Days:I(st),rank7Days:I(st),rank30Days:I(st)});function Ir(t){if(!t)return!1;if(typeof t=="string"||F(t,zn)||jr(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(F(e.Reference,Se)||F(e.MutableReference,Se)||F(e.Vector,Se))}const Se=G("SuiMoveNormalizedType",Ir);function jr(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=>Ir(n)))}G("SuiMoveNormalizedStructType",jr);const Fn=p({visibility:Dn,isEntry:D(),typeParameters:I(It),parameters:I(Se),return:I(Se)}),Gn=p({name:h(),type:Se}),Ln=p({abilities:It,typeParameters:I(Vn),fields:I(Gn)}),Wn=p({fileFormatVersion:ye(),address:h(),name:h(),friends:I(Nn),structs:Y(h(),Ln),exposedFunctions:Y(h(),Fn)});Y(h(),Wn);function mt(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function Er(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function jt(t){if(typeof t=="object"&&"Struct"in t)return t;const e=Er(t),r=mt(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}function Kn(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 i=t.charAt(n),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=n}var c=t.length,a=t.charAt(0),o=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function u(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 w=0,b=0,f=0,j=y.length;f!==j&&y[f]===0;)f++,w++;for(var _=(j-f)*d+1>>>0,$=new Uint8Array(_);f!==j;){for(var E=y[f],v=0,U=_-1;(E!==0||v<b)&&U!==-1;U--,v++)E+=256*$[U]>>>0,$[U]=E%c>>>0,E=E/c>>>0;if(E!==0)throw new Error("Non-zero carry");b=v,f++}for(var K=_-b;K!==_&&$[K]===0;)K++;for(var we=a.repeat(w);K<_;++K)we+=t.charAt($[K]);return we}function g(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;for(var w=0,b=0,f=0;y[w]===a;)b++,w++;for(var j=(y.length-w)*o+1>>>0,_=new Uint8Array(j);y[w];){var $=e[y.charCodeAt(w)];if($===255)return;for(var E=0,v=j-1;($!==0||E<f)&&v!==-1;v--,E++)$+=c*_[v]>>>0,_[v]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");f=E,w++}for(var U=j-f;U!==j&&_[U]===0;)U++;for(var K=new Uint8Array(b+(j-U)),we=b;U!==j;)K[we++]=_[U++];return K}function m(y){var w=g(y);if(w)return w;throw new Error("Non-base"+c+" character")}return{encode:u,decodeUnsafe:g,decode:m}}var Jn=Kn;const Hn=Jn,Xn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var qn=Hn(Xn);const Or=Qr(qn),$e=t=>Or.encode(t),Et=t=>Or.decode(t);function le(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const at=8192;function Ue(t){if(t.length<at)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=at){const n=t.slice(r,r+at);e+=String.fromCharCode(...n)}return btoa(e)}function rt(t){var i;const e=t.startsWith("0x")?t.slice(2):t,n=((i=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:i.map(s=>parseInt(s,16)))??[];return Uint8Array.from(n)}function Re(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function Ot(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 Zn(t){let e=0,r=0,n=0;for(;;){let i=t[n];if(n+=1,e|=(i&127)<<r,!(i&128))break;r+=7}return{value:e,length:n}}class Ar{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:i}=Zn(r);return this.shift(i),n}readVec(e){let r=this.readULEB(),n=[];for(let i=0;i<r;i++)n.push(e(this,i,r));return n}}function Yn(t,e){switch(e){case"base58":return $e(t);case"base64":return Ue(t);case"hex":return Re(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function Qn(t,e){switch(e){case"base58":return Et(t);case"base64":return le(t);case"hex":return rt(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function At(t,e=["<",">"]){const[r,n]=e,i=[];let s="",c=0;for(let a=0;a<t.length;a++){const o=t[a];if(o===r&&c++,o===n&&c--,c===0&&o===","){i.push(s.trim()),s="";continue}s+=o}return i.push(s.trim()),i}class _r{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 i=new ArrayBuffer(this.size);new Uint8Array(i).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(i)}}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 ot(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return ot(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return ot(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return Ot(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,i)=>r(this,n,i,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 Yn(this.toBytes(),e)}}function ot(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 xr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},X=(t,e,r)=>(xr(t,e,"read from private field"),r?r.call(t):e.get(t)),Xe=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},qe=(t,e,r,n)=>(xr(t,e,"write to private field"),e.set(t,r),r),be,Ie,Fe,ae;const Br=class{constructor(t){Xe(this,be,void 0),Xe(this,Ie,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),qe(this,be,t.write),qe(this,Ie,t.serialize??((e,r)=>{const n=new _r({size:this.serializedSize(e)??void 0,...r});return X(this,be).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),X(this,be).call(this,t,e)}serialize(t,e){return this.validate(t),new ei(this,X(this,Ie).call(this,t,e))}parse(t){const e=new Ar(t);return this.read(e)}transform({name:t,input:e,output:r}){return new Br({name:t??this.name,read:n=>r(this.read(n)),write:(n,i)=>X(this,be).call(this,e(n),i),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,i)=>X(this,Ie).call(this,e(n),i),validate:n=>this.validate(e(n))})}};let q=Br;be=new WeakMap;Ie=new WeakMap;const Cr=Symbol.for("@mysten/serialized-bcs");function _t(t){return!!t&&typeof t=="object"&&t[Cr]===!0}class ei{constructor(e,r){Xe(this,Fe,void 0),Xe(this,ae,void 0),qe(this,Fe,e),qe(this,ae,r)}get[Cr](){return!0}toBytes(){return X(this,ae)}toHex(){return Re(X(this,ae))}toBase64(){return Ue(X(this,ae))}toBase58(){return $e(X(this,ae))}parse(){return X(this,Fe).parse(X(this,ae))}}Fe=new WeakMap;ae=new WeakMap;function Ze({size:t,...e}){return new q({...e,serializedSize:()=>t})}function ct({readMethod:t,writeMethod:e,...r}){return Ze({...r,read:n=>n[t](),write:(n,i)=>i[e](n),validate:n=>{var i;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,n)}})}function ut({readMethod:t,writeMethod:e,...r}){return Ze({...r,read:n=>n[t](),write:(n,i)=>i[e](BigInt(n)),validate:n=>{var s;const i=BigInt(n);if(i<0||i>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${i}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,i)}})}function ti({serialize:t,...e}){const r=new q({...e,serialize:t,write:(n,i)=>{for(const s of r.serialize(n).toBytes())i.write8(s)}});return r}function ri({toBytes:t,fromBytes:e,...r}){return new q({...r,read:n=>{const i=n.readULEB(),s=n.readBytes(i);return e(s)},write:(n,i)=>{const s=t(n);i.writeULEB(s.length);for(let c=0;c<s.length;c++)i.write8(s[c])},serialize:n=>{const i=t(n),s=Ot(i.length),c=new Uint8Array(s.length+i.length);return c.set(s,0),c.set(i,s.length),c},validate:n=>{var i;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(i=r.validate)==null||i.call(r,n)}})}function ni(t){let e=null;function r(){return e||(e=t()),e}return new q({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,i)=>r().write(n,i),serialize:(n,i)=>r().serialize(n,i).toBytes()})}const l={u8(t){return ct({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return ct({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return ct({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return ut({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return ut({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return ut({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Ze({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 ti({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Ot(e)),...t})},bytes(t,e){return Ze({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let i=0;i<t;i++)n.write8(r[i]??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 ri({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new q({name:`${e.name}[${t}]`,read:n=>{const i=new Array(t);for(let s=0;s<t;s++)i[s]=e.read(n);return i},write:(n,i)=>{for(const s of n)e.write(s,i)},...r,validate:n=>{var i;if((i=r==null?void 0:r.validate)==null||i.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 l.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 q({name:`vector<${t.name}>`,read:r=>{const n=r.readULEB(),i=new Array(n);for(let s=0;s<n;s++)i[s]=t.read(r);return i},write:(r,n)=>{n.writeULEB(r.length);for(const i of r)t.write(i,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 q({name:`(${t.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let i=0;i<t.length;i++){const s=t[i].serializedSize(r[i]);if(s==null)return null;n+=s}return n},read:r=>{const n=[];for(const i of t)n.push(i.read(r));return n},write:(r,n)=>{for(let i=0;i<t.length;i++)t[i].write(r[i],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 q({name:t,serializedSize:i=>{let s=0;for(const[c,a]of n){const o=a.serializedSize(i[c]);if(o==null)return null;s+=o}return s},read:i=>{const s={};for(const[c,a]of n)s[c]=a.read(i);return s},write:(i,s)=>{for(const[c,a]of n)a.write(i[c],s)},...r,validate:i=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`)}})},enum(t,e,r){const n=Object.entries(e);return new q({name:t,read:i=>{const s=i.readULEB(),[c,a]=n[s];return{[c]:(a==null?void 0:a.read(i))??!0}},write:(i,s)=>{const[c,a]=Object.entries(i)[0];for(let o=0;o<n.length;o++){const[d,u]=n[o];if(d===c){s.writeULEB(o),u==null||u.write(a,s);return}}},...r,validate:i=>{var a;if((a=r==null?void 0:r.validate)==null||a.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`);const s=Object.keys(i);if(s.length!==1)throw new TypeError(`Expected object with one key, found ${s.length}`);const[c]=s;if(!Object.hasOwn(e,c))throw new TypeError(`Invalid enum variant ${c}`)}})},map(t,e){return l.vector(l.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[i,s]of r)n.set(i,s);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 ni(t)}},ii=32,je=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof je){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(je.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&&si(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:i}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,i)}if(typeof t=="object"){const n=this.tempKey();return new je(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=Qn(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:i}=this.parseTypeName(t);return this.getTypeInterface(n).decode(this,e,i)}if(typeof t=="object"){const n=new je(this),i=this.tempKey();return n.registerStructType(i,t).de(i,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:i,params:s}=this.parseTypeName(t);return this.types.set(i,{encode(c,a,o,d){const u=s.reduce((g,m,y)=>Object.assign(g,{[m]:d[y]}),{});return this._encodeRaw.call(c,new _r(o),a,d,u)},decode(c,a,o){const d=s.reduce((u,g,m)=>Object.assign(u,{[g]:o[m]}),{});return this._decodeRaw.call(c,new Ar(a),o,d)},_encodeRaw(c,a,o,d){if(n(a))return e.call(this,c,a,o,d);throw new Error(`Validation failed for type ${i}, data: ${a}`)},_decodeRaw(c,a,o){return r.call(this,c,a,o)}}),this}registerBcsType(t,e){return this.registerType(t,(r,n,i)=>{const s=i.map(c=>new q({name:String(c),write:(a,o)=>{const{name:d,params:u}=this.parseTypeName(c),g=this.getTypeInterface(d),m=u.reduce((y,w,b)=>Object.assign(y,{[w]:i[b]}),{});return g._encodeRaw.call(this,o,a,u,m)},read:()=>{throw new Error("Not implemented")}}));return e(...s).write(n,r),r},(r,n)=>{const i=n.map(s=>new q({name:String(s),write:(c,a)=>{throw new Error("Not implemented")},read:c=>{const{name:a,params:o}=this.parseTypeName(s),d=this.getTypeInterface(a),u=o.reduce((g,m,y)=>Object.assign(g,{[m]:n[y]}),{});return d._decodeRaw.call(this,c,o,u)}}));return e(...i).read(r)}),this}registerAddressType(t,e,r="hex"){switch(r){case"base64":return this.registerType(t,function(i,s){return le(s).reduce((c,a)=>c.write8(a),i)},function(i){return Ue(i.readBytes(e))});case"hex":return this.registerType(t,function(i,s){return rt(s).reduce((c,a)=>c.write8(a),i)},function(i){return Re(i.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(i,s,c,a){return i.writeVec(s,(o,d)=>{let u=c[0];if(!u)throw new Error(`Incorrect number of type parameters passed a to vector '${t}'`);let{name:g,params:m}=this.parseTypeName(u);if(this.hasType(g))return this.getTypeInterface(g)._encodeRaw.call(this,o,d,m,a);if(!(g in a))throw new Error(`Unable to find a matching type definition for ${g} in vector; make sure you passed a generic`);let{name:y,params:w}=this.parseTypeName(a[g]);return this.getTypeInterface(y)._encodeRaw.call(this,o,d,w,a)})},function(i,s,c){return i.readVec(a=>{let o=s[0];if(!o)throw new Error(`Incorrect number of type parameters passed to a vector '${t}'`);let{name:d,params:u}=this.parseTypeName(o);if(this.hasType(d))return this.getTypeInterface(d)._decodeRaw.call(this,a,u,c);if(!(d in c))throw new Error(`Unable to find a matching type definition for ${d} in vector; make sure you passed a generic`);let{name:g,params:m}=this.parseTypeName(c[d]);return this.getTypeInterface(g)._decodeRaw.call(this,a,m,c)})})}registerStructType(t,e){for(let c in e){let a=this.tempKey(),o=e[c];!Array.isArray(o)&&typeof o!="string"&&(e[c]=a,this.registerStructType(a,o))}let r=Object.freeze(e),n=Object.keys(r),{name:i,params:s}=this.parseTypeName(t);return this.registerType(t,function(a,o,d,u){if(!o||o.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${o}`);if(d.length!==s.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${s.length}, got: ${d.length}`);for(let g of n){if(!(g in o))throw new Error(`Struct ${i} requires field ${g}:${r[g]}`);const{name:m,params:y}=this.parseTypeName(r[g]);if(!s.includes(m))this.getTypeInterface(m)._encodeRaw.call(this,a,o[g],y,u);else{const w=s.indexOf(m);let{name:b,params:f}=this.parseTypeName(d[w]);if(this.hasType(b)){this.getTypeInterface(b)._encodeRaw.call(this,a,o[g],f,u);continue}if(!(b in u))throw new Error(`Unable to find a matching type definition for ${b} in ${i}; make sure you passed a generic`);let{name:j,params:_}=this.parseTypeName(u[b]);this.getTypeInterface(j)._encodeRaw.call(this,a,o[g],_,u)}}return a},function(a,o,d){if(o.length!==s.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${s.length}, got: ${o.length}`);let u={};for(let g of n){const{name:m,params:y}=this.parseTypeName(r[g]);if(!s.includes(m))u[g]=this.getTypeInterface(m)._decodeRaw.call(this,a,y,d);else{const w=s.indexOf(m);let{name:b,params:f}=this.parseTypeName(o[w]);if(this.hasType(b)){u[g]=this.getTypeInterface(b)._decodeRaw.call(this,a,f,d);continue}if(!(b in d))throw new Error(`Unable to find a matching type definition for ${b} in ${i}; make sure you passed a generic`);let{name:j,params:_}=this.parseTypeName(d[b]);u[g]=this.getTypeInterface(j)._decodeRaw.call(this,a,_,d)}}return u})}registerEnumType(t,e){for(let c in e){let a=this.tempKey(),o=e[c];o!==null&&!Array.isArray(o)&&typeof o!="string"&&(e[c]=a,this.registerStructType(a,o))}let r=Object.freeze(e),n=Object.keys(r),{name:i,params:s}=this.parseTypeName(t);return this.registerType(t,function(a,o,d,u){if(!o)throw new Error(`Unable to write enum "${i}", missing data.
|
|
4
4
|
Received: "${o}"`);if(typeof o!="object")throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${n.join(" | ")}".
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var G=Object.defineProperty;var L=(p,e,t)=>e in p?G(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t;var u=(p,e,t)=>L(p,typeof e!="symbol"?e+"":e,t);import{bv as D,
|
|
1
|
+
var G=Object.defineProperty;var L=(p,e,t)=>e in p?G(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t;var u=(p,e,t)=>L(p,typeof e!="symbol"?e+"":e,t);import{bv as D,al as C,ab as T,bw as S,aH as I,ai as s,bx as V,by as _,Y as B,$ as F,bz as f,bA as h,bB as M,bC as g,bD as j,p as y,bE as Y,bF as J,bG as K,bH as X,bI as Z,bJ as tt,a2 as et}from"../main.js";import{EvmTokenBridge as nt}from"./index-QLnl5sO1.js";const v=new D(["function start((bytes32,address,address,address,address,address,uint256,uint256,uint256,uint256)) returns (address,uint16,uint64)","function receiveMessageAndSwap(bytes)"]),ot=new D(["function quoteExactInputSingle((address,address,uint256,uint24,uint160)) public view returns (uint256,uint160,uint32,uint256)"]),st="https://gfx.relayers.xlabs.xyz/api/v1/swap/quote";class rt{static async quoteRelayer(e,t,o){var i;if(C(t)||C(o))throw new Error("how did you get here tho?");const n=T.encode(t.toUniversalAddress().toUint8Array(),!1),r=T.encode(o.toUniversalAddress().toUint8Array(),!1),a={targetChain:S(e),sourceToken:n,targetToken:r};try{const c=await I.post(st,a);return BigInt(c.data.fee)}catch(c){throw I.isAxiosError(c)?new Error(`Error getting relayer fee: ${(i=c.response)==null?void 0:i.statusText}`):c}}}const A=100,x={ETH:[s.tokenId("Arbitrum","native"),s.tokenId("Base","native"),s.tokenId("Ethereum","native"),s.tokenId("Optimism","native")],WETH:[s.tokenId("Arbitrum","0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),s.tokenId("Avalanche","0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB"),s.tokenId("Base","0x4200000000000000000000000000000000000006"),s.tokenId("Bsc","0x2170Ed0880ac9A755fd29B2688956BD959F933F8"),s.tokenId("Ethereum","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),s.tokenId("Optimism","0x4200000000000000000000000000000000000006"),s.tokenId("Polygon","0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619")],wstETH:[s.tokenId("Arbitrum","0x5979D7b546E38E414F7E9822514be443A4800529"),s.tokenId("Base","0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452"),s.tokenId("Ethereum","0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"),s.tokenId("Optimism","0x1F32b1c2345538c0c6f582fCB022739c4A194Ebb"),s.tokenId("Polygon","0x03b54A6e9a984069379fae1a4fC4dBAE93B3bCCD")],USDT:[s.tokenId("Arbitrum","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),s.tokenId("Avalanche","0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7"),s.tokenId("Base","0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2"),s.tokenId("Bsc","0x55d398326f99059fF775485246999027B3197955"),s.tokenId("Ethereum","0xdAC17F958D2ee523a2206206994597C13D831ec7"),s.tokenId("Optimism","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"),s.tokenId("Polygon","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"),s.tokenId("Celo","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e")]};class b{constructor(e,t,o,n){u(this,"network");u(this,"chain");u(this,"provider");u(this,"contracts");u(this,"chainId");u(this,"core");u(this,"tokenBridge");if(this.network=e,this.chain=t,this.provider=o,this.contracts=n,!n.portico)throw new Error("Unsupported chain, no contract addresses for: "+t);this.core=new V(e,t,o,n),this.tokenBridge=new nt(e,t,o,n),this.chainId=_.get(e,t)}static async fromRpc(e,t){const[o,n]=await B.chainFromRpc(e),r=t[n];if(r.network!==o)throw new Error(`Network mismatch: ${r.network} != ${o}`);return new b(o,n,e,r.contracts)}async*transfer(e,t,o,n,r,d,a){const{minAmountStart:i,minAmountFinish:c}=a.swapAmounts;if(i===0n)throw new Error("Invalid min swap amount");if(c===0n)throw new Error("Invalid min swap amount");const w=new F(e).toString(),[k,E]=f(this.network,this.chain,o),[U,P]=f(this.network,t.chain,r),l=h(E),q=h(await this.getTransferrableToken(l)),R=h(t),N=h(P),O=new Date().valueOf()%2**4,$=M.serializeFlagSet({flags:{shouldWrapNative:k,shouldUnwrapNative:U},recipientChain:S(t.chain),bridgeNonce:O,feeTierStart:A,feeTierFinish:A,padding:new Uint8Array(19)}),Q=v.encodeFunctionData("start",[[$,l.toLowerCase(),q,N.toLowerCase(),R,d,n.toString(),i.toString(),c.toString(),a.relayerFee.toString()]]),W=this.getTokenGroup(E.address.toString()),m=this.getPorticoAddress(W);k||(yield*this.approve(l,w,n,m));const H=await this.core.getMessageFee(),z={to:m,data:Q,value:H+(k?n:0n)};yield this.createUnsignedTransaction(g(z,w),"PorticoBridge.Transfer")}async*redeem(e,t){const o=j(t.payload.payload.flagSet.recipientChain),n=t.payload.payload.finalTokenAddress.toNative(o).toString(),r=this.getTokenGroup(n),d=this.getPorticoAddress(r),i=await new y(d,v.fragments,this.provider).getFunction("receiveMessageAndSwap").populateTransaction(Y(t)),c=new F(e).toString();yield this.createUnsignedTransaction(g(i,c),"PorticoBridge.Redeem")}async isTransferCompleted(e){return await this.tokenBridge.tokenBridge.isTransferCompleted(J(e.hash))}async quoteSwap(e,t,o,n){const[,r]=f(this.network,this.chain,e),[,d]=f(this.network,this.chain,t),a=h(r),i=h(d);if(K(a,i))return n;const c=this.getQuoterAddress(o);return(await new y(c,ot.fragments,this.provider).getFunction("quoteExactInputSingle").staticCall([a,i,n,A,0]))[0]}async quoteRelay(e,t){return await rt.quoteRelayer(this.chain,e,t)}async getTransferrableToken(e){const t=s.tokenId(this.chain,e),[,o]=f(this.network,this.chain,t);if(this.chain==="Ethereum")return o;const n=Object.values(x).find(a=>a.find(i=>i.chain===this.chain&&h(i)===h(o)));if(!n)throw new Error(`No token group found for ${e} on ${this.chain}`);const r=n.find(a=>a.chain==="Ethereum");if(!r)throw new Error(`No Ethereum origin token found for ${e} on ${this.chain}`);const d=await this.tokenBridge.getWrappedAsset(r);return s.tokenId(this.chain,d.toString())}supportedTokens(){const e=[];for(const[t,o]of Object.entries(x))for(const n of o)n.chain===this.chain&&e.push({group:t,token:n});return e}getTokenGroup(e){const o=this.supportedTokens().find(n=>h(n.token)===e);if(!o)throw new Error("Token not found");return o.group}async*approve(e,t,o,n){const r=B.getTokenImplementation(this.provider,e);if(await r.allowance(t,n)<o){const a=await r.approve.populateTransaction(n,o);yield this.createUnsignedTransaction(g(a,t),"PorticoBridge.Approve")}}createUnsignedTransaction(e,t){return new X(Z(e,this.chainId),this.network,this.chain,t,!1)}getPorticoAddress(e){const t=this.contracts.portico;return e==="USDT"&&t.porticoPancakeSwap||t.porticoUniswap}getQuoterAddress(e){const t=this.contracts.portico;return e==="USDT"&&t.pancakeSwapQuoterV2||t.uniswapQuoterV2}}tt(et,"PorticoBridge",b);export{b as EvmPorticoBridge};
|