@wormhole-foundation/wormhole-connect 1.1.4-beta.1-development → 1.1.4-beta.2-development
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{algorand-CL9E7qV4.js → algorand-CyJRjYjt.js} +2 -2
- package/dist/assets/{aptos-CYfJ6QKV.js → aptos-k14Q8oIC.js} +2 -2
- package/dist/assets/{ccip-Cfs6IR2H.js → ccip-BNTHR_fq.js} +1 -1
- package/dist/assets/{cosmwasm-B8f9g9-e.js → cosmwasm-Bb55TeV-.js} +3 -3
- package/dist/assets/{evm-BeHPA-N8.js → evm-BxXdWj24.js} +5 -5
- package/dist/assets/{evm-DsaBFKKm.js → evm-C-buBtRY.js} +2 -2
- package/dist/assets/{index-DzWKLl_i.js → index-BAmVCbB-.js} +1 -1
- package/dist/assets/{index-C0jKBHol.js → index-BEc0YFBn.js} +1 -1
- package/dist/assets/{index-DW2PHjzW.js → index-BLMTT3rM.js} +1 -1
- package/dist/assets/{index-CVz7Lfsa.js → index-BY0kgWx8.js} +1 -1
- package/dist/assets/{index-BtIDaBGl.js → index-BfDApobA.js} +1 -1
- package/dist/assets/{index-Cka3pqB6.js → index-BwBQHmYt.js} +1 -1
- package/dist/assets/{index-B1Zd6Tbj.js → index-C0psfra-.js} +1 -1
- package/dist/assets/{index-Dmt4H-sz.js → index-C2FPBPlV.js} +1 -1
- package/dist/assets/{index-DyOk_vKo.js → index-C3Sky6pw.js} +1 -1
- package/dist/assets/{index-DEXJQ6UW.js → index-C87qdc5P.js} +1 -1
- package/dist/assets/{index-QCp2fK6U.js → index-D2LZykJf.js} +2 -2
- package/dist/assets/{index-DSNr6Aeg.js → index-DoWu6bTw.js} +1 -1
- package/dist/assets/{index-DkQt9fOR.js → index-Dqm3REGN.js} +1 -1
- package/dist/assets/{index-BQIi8F3e.js → index-FQGd6qGV.js} +1 -1
- package/dist/assets/{index-QJ2zlRk3.js → index-IlqLhD3I.js} +1 -1
- package/dist/assets/{index-q0W2SHor.js → index-YIP9QK2L.js} +1 -1
- package/dist/assets/{index-TrUYBc0F.js → index-nosdUF9i.js} +1 -1
- package/dist/assets/{index-CFYbGyvs.js → index-xo-ROtuF.js} +1 -1
- package/dist/assets/{index-CZCNUCD6.js → index-yAX3aWkW.js} +1 -1
- package/dist/assets/{index.es-xWGpyzms.js → index.es--WISYjTj.js} +3 -3
- package/dist/assets/{keccak-Dh1-j093.js → keccak-DYzglTc3.js} +1 -1
- package/dist/assets/{solana-FuO6ds45.js → solana-BmGIyTEt.js} +2 -2
- package/dist/assets/{solana-HXT1gH4s.js → solana-D5RkygmT.js} +2 -2
- package/dist/assets/{solanaEmbed.esm-CmWxi_NO.js → solanaEmbed.esm-CFdxIRQj.js} +1 -1
- package/dist/assets/{sui-CQYR74Ws.js → sui-CW05lm4n.js} +2 -2
- package/dist/assets/{unsignedTransaction-YIv7ff3U.js → unsignedTransaction-DAYPmfUj.js} +1 -1
- package/dist/main.js +69 -69
- package/lib/{algorand-DMWnCGDD.js → algorand-B9Pcx34H.js} +1 -1
- package/lib/{algorand-CKeviXZg.mjs → algorand-BfdC8LMm.mjs} +3 -3
- package/lib/{aptos-LGyhejg2.mjs → aptos-CuQYjxz4.mjs} +1 -1
- package/lib/{aptos-DBFfVz6j.js → aptos-D8msRZYc.js} +1 -1
- package/lib/{aptos-DNei2Fw9.mjs → aptos-DISEuAM4.mjs} +3 -3
- package/lib/{aptos-CAJat9Bn.js → aptos-DlboPucS.js} +2 -2
- package/lib/{ccip-E64BZKbj.js → ccip-BqkngZ6V.js} +1 -1
- package/lib/{ccip-gtLK9yzS.mjs → ccip-DV1T5CQz.mjs} +1 -1
- package/lib/{cosmwasm-CnK43h4P.mjs → cosmwasm-BFPK6deV.mjs} +111 -7
- package/lib/{cosmwasm-CmkeZSLD.js → cosmwasm-D3ZKcsjq.js} +2 -2
- package/lib/{events-dBi7i6gd.mjs → events-CaIL5tL1.mjs} +1 -1
- package/lib/{events-D5Nem7a2.js → events-Cxw8aBUy.js} +1 -1
- package/lib/{evm-DyPy8X4q.mjs → evm-7idwo4la.mjs} +5 -5
- package/lib/{evm-Bsq-lyhx.mjs → evm-D11YbeC_.mjs} +7 -7
- package/lib/{evm-BEkpevR1.js → evm-D12EHZXD.js} +4 -4
- package/lib/{evm-JR5REYuq.js → evm-UrRoO3lT.js} +1 -1
- package/lib/{index-DWFG3ux-.js → index-B-m7_r9W.js} +1 -1
- package/lib/{index-BZTaoymt.mjs → index-BEfsEC8g.mjs} +3 -3
- package/lib/{index-Cc_mraT5.mjs → index-BKeG3u48.mjs} +2 -2
- package/lib/{index-FW1hHPsY.js → index-BMLK3kVY.js} +1 -1
- package/lib/{index-CrVV6hQ2.js → index-BMsGsrRe.js} +1 -1
- package/lib/{index-xr-_5YwS.mjs → index-BPD6tZ5I.mjs} +7575 -5146
- package/lib/{index-CL3ekJSh.js → index-BQI2oZiv.js} +1 -1
- package/lib/{index-CeksQZJ0.mjs → index-BUGIe9Q0.mjs} +4 -4
- package/lib/{index-CvX8wxOG.mjs → index-BkUc_QzZ.mjs} +2 -2
- package/lib/{index-DE7BjSqw.js → index-Br_1eyUd.js} +1 -1
- package/lib/{index-C8MkGmi-.mjs → index-C1KUJpQh.mjs} +1 -1
- package/lib/{index-B_wAMidq.js → index-C6ww0FoG.js} +1 -1
- package/lib/{index-YigUyjDr.mjs → index-CBnSdTOm.mjs} +1 -1
- package/lib/{index-DD4g5WJB.mjs → index-CDGkVXf1.mjs} +2 -2
- package/lib/{index-D5un17aL.mjs → index-CG2dc9k1.mjs} +13 -13
- package/lib/{index-CsYGJh8i.js → index-CGqBKzB5.js} +1 -1
- package/lib/{index-TidzojcT.js → index-CHGr1Xo0.js} +1 -1
- package/lib/{index-BHnHO_u8.js → index-CJ8hOjdz.js} +1 -1
- package/lib/{index-BlRWSvuT.js → index-COW9BRyV.js} +1 -1
- package/lib/{index-jnHYrj-0.mjs → index-CeK6G0Jr.mjs} +2 -2
- package/lib/{index-u9NHndtJ.mjs → index-Cfupv0rQ.mjs} +4 -4
- package/lib/{index-C-MpEmke.mjs → index-Cg19mcso.mjs} +1 -1
- package/lib/{index-DhJzyV8c.js → index-Cg6LDJti.js} +1 -1
- package/lib/{index-Cwf7_SpM.js → index-CkHXWtPG.js} +1 -1
- package/lib/{index-B9YINx-j.mjs → index-ClI_55nW.mjs} +7 -7
- package/lib/{index-BSXkcZeB.mjs → index-ClbyJuae.mjs} +2 -2
- package/lib/{index-DRTJX6NI.mjs → index-Cs8OaRdq.mjs} +2 -2
- package/lib/{index-B6Yxe_gd.mjs → index-D4FfgE9k.mjs} +2 -2
- package/lib/{index-PebPsVgf.js → index-D9Ezmk4f.js} +1 -1
- package/lib/{index-BIhEJqD8.js → index-DgKyQSTc.js} +1 -1
- package/lib/{index-BxaWYSOO.js → index-Dh6mkRtz.js} +74 -74
- package/lib/{index-w88sWpdI.js → index-DjZ438HP.js} +1 -1
- package/lib/{index-DSJ41rGf.mjs → index-DlXF_HRr.mjs} +2 -2
- package/lib/{index-DRDlsqLC.js → index-DsMw6BFg.js} +1 -1
- package/lib/{index-CtuM0Nhj.mjs → index-GKdJmpc9.mjs} +2 -2
- package/lib/{index-CAOx_2w0.mjs → index-IwSEAKjs.mjs} +3 -3
- package/lib/{index-CvLvO-ub.mjs → index-VO5jvtPN.mjs} +1 -1
- package/lib/{index-fpX08H1Q.js → index-Vouac_sN.js} +1 -1
- package/lib/{index-snvFYwLU.mjs → index-f6MztC_k.mjs} +2 -2
- package/lib/{index-BrZMeh8Y.js → index-hb33T1qT.js} +1 -1
- package/lib/{index-D9LNItFN.js → index-s_6sncui.js} +1 -1
- package/lib/{index-CN4S3GOd.mjs → index-vmVyLCAM.mjs} +3 -3
- package/lib/{index-CLImffCI.js → index-xTifobUX.js} +1 -1
- package/lib/{index-Brws-ttZ.js → index-yYbCizsj.js} +1 -1
- package/lib/{index.es-BgIY-CJP.mjs → index.es-Bld6bvmZ.mjs} +5 -5
- package/lib/{index.es-DA6xjT-p.js → index.es-DWCjm6mS.js} +2 -2
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{keccak-D3kXYcOs.mjs → keccak-BwFcIiaM.mjs} +1 -1
- package/lib/{keccak-xKB7Kino.js → keccak-C8mX3bFz.js} +1 -1
- package/lib/{pbkdf2-DCnqfxZR.js → pbkdf2-Bk-3RPXm.js} +1 -1
- package/lib/{pbkdf2-Dg0HWbq4.mjs → pbkdf2-CeHVjwwG.mjs} +1 -1
- package/lib/{signer-DIzVzPl8.mjs → signer-DXNU3KLz.mjs} +1 -1
- package/lib/{signer-CbcYYMJ7.js → signer-LadskxdY.js} +1 -1
- package/lib/solana-B15fGx9S.js +1 -0
- package/lib/{solana-BVgObkcE.mjs → solana-BasjNE9K.mjs} +4 -4
- package/lib/{solana-DmCHygOA.js → solana-C9iEiCkx.js} +1 -1
- package/lib/{solana-HKO9jNRD.mjs → solana-CfCGAR-_.mjs} +5 -5
- package/lib/{solanaEmbed.esm-DqNfqaxI.js → solanaEmbed.esm-CJdWWBYT.js} +1 -1
- package/lib/{solanaEmbed.esm-DEAHXGVn.mjs → solanaEmbed.esm-pwzJ8Zc0.mjs} +3 -3
- package/lib/{sui-DN8E0m68.mjs → sui-B9B-EQyp.mjs} +4 -4
- package/lib/{sui-BDoIBdRb.js → sui-BJBxQjSI.js} +2 -2
- package/lib/{sui-Bp2zLhA_.mjs → sui-HC466JTC.mjs} +1 -1
- package/lib/{sui-W_WW-YXK.js → sui-iJeaGeqF.js} +1 -1
- package/lib/{unsignedTransaction-Dkfjd5_o.js → unsignedTransaction-CmgkSLIX.js} +1 -1
- package/lib/unsignedTransaction-Di5zQIK0.mjs +35 -0
- package/package.json +3 -3
- package/lib/solana-BYXqKgjy.js +0 -1
- package/lib/unsignedTransaction-C32EJDkZ.mjs +0 -35
|
@@ -1 +1 @@
|
|
|
1
|
-
var d=Object.defineProperty;var h=(i,e,r)=>e in i?d(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var o=(i,e,r)=>h(i,typeof e!="symbol"?e+"":e,r);import{
|
|
1
|
+
var d=Object.defineProperty;var h=(i,e,r)=>e in i?d(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var o=(i,e,r)=>h(i,typeof e!="symbol"?e+"":e,r);import{b2 as m,cT as w,aH as g,c1 as p}from"../main.js";import{S as u}from"./sui-CW05lm4n.js";import"./pbkdf2-CTUZRYZs.js";class c{constructor(e,r,t,n){o(this,"network");o(this,"chain");o(this,"provider");o(this,"contracts");o(this,"chainId");o(this,"coreBridgePackageId");this.network=e,this.chain=r,this.provider=t,this.contracts=n,this.chainId=m(r);const s=n.coreBridge;if(!s)throw new Error(`CoreBridge contract Address for chain ${r} not found`);this.coreBridgePackageId=s}getGuardianSet(e){throw new Error("Method not implemented.")}getMessageFee(){throw new Error("Method not implemented.")}static async fromRpc(e,r){const[t,n]=await u.chainFromRpc(e),s=r[n];if(s.network!==t)throw new Error(`Network mismatch: ${s.network} !== ${t}`);return new c(t,n,e,s.contracts)}async*verifyMessage(e,r){throw new Error("Method not implemented.")}async*publishMessage(e,r){throw new Error("Method not implemented.")}async parseTransaction(e){return(await this.parseMessages(e)).map(t=>({emitter:t.emitterAddress,sequence:t.sequence,chain:this.chain}))}async getGuardianSetIndex(){throw new Error("Method not implemented.")}async parseMessages(e){var n;const t=(n=(await this.provider.getTransactionBlock({digest:e,options:{showEvents:!0,showEffects:!0,showInput:!0}})).events)==null?void 0:n.filter(s=>s.type.endsWith("WormholeMessage"));if(!t||t.length==0)throw new Error("WormholeMessage not found");return t.map(s=>{const a=s.parsedJson;return w("Uint8Array",{emitterChain:this.chain,emitterAddress:new g(a.sender).toUniversalAddress(),sequence:BigInt(a.sequence),guardianSet:0,timestamp:Number(a.timestamp),consistencyLevel:a.consistency_level,nonce:a.nonce,signatures:[],payload:new Uint8Array(a.payload)})})}}p("Sui","WormholeCore",c);export{c as SuiWormholeCore};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as _t,s as ce,T as N,t as H,a as C,o as ot,R as Bo,p as K,y as gt}from"./index-
|
|
1
|
+
import{n as _t,s as ce,T as N,t as H,a as C,o as ot,R as Bo,p as K,y as gt}from"./index-D2LZykJf.js";import{d as Do}from"./dijkstra-D_NXgYpA.js";import"../main.js";/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -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 C=(t,e,r)=>Yr(t,typeof e!="symbol"?e+"":e,r);import{s as Qr,ay as en,c_ as ft,aE as tn,c$ as hr,d0 as ke,be as rn,ch as nt,bX as nn,ci as nr,b1 as ce,aH as ge,al as oe,bU as sn,cn as ir,ck as an,d1 as on,bY as ht,aF as cn,ad as De,a_ as un,cy as sr,d2 as dn,aG as ar,c1 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-CQYR74Ws.js";import"./index-q0W2SHor.js";import"./pbkdf2-CTUZRYZs.js";class yr{constructor(e,r,n,i,s=!1){C(this,"transaction");C(this,"network");C(this,"chain");C(this,"description");C(this,"parallelizable");this.transaction=e,this.network=r,this.chain=n,this.description=i,this.parallelizable=s}}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*vt(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=vt(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=vt(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 $(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]=vt(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 kt=$([p({AddressOwner:h()}),p({ObjectOwner:h()}),p({Shared:p({initial_shared_version:B(h())})}),T("Immutable")]);G("SuiJsonValue",()=>!0);const vn=$([p({u32:h()}),p({u64:h()}),p({f64:h()})]);p({attributes:Y(h(),B(vn)),featureFlags:Y(h(),D()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});$([h(),T("package")]);const de=p({digest:h(),objectId:h(),version:$([ye(),h(),Sn()])});p({owner:kt,reference:de});p({objectId:h(),sequenceNumber:h()});p({payment:I(de),owner:h(),price:h(),budget:h()});const kn=Ae(de,p({type:h(),owner:kt,previousTransaction:h()})),In=Y(h(),yt()),jn=Y(h(),Tr()),En=p({type:h(),fields:In,hasPublicTransfer:D()}),On=p({disassembled:jn}),An=$([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=$([Ae(_n,p({dataType:T("moveObject")})),Ae(xn,p({dataType:T("package")}))]);BigInt(1e9);const vr=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(vr))}),$n=$([Cn,S(Y(h(),h()))]),kr=p({objectId:h(),version:h(),digest:h(),type:B(S(h())),content:B(S(An)),bcs:B(S(Bn)),owner:B(S(kt)),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()))});$([T("Exists"),T("notExists"),T("Deleted")]);I(kn);const Un=p({data:B(S(kr)),error:B(S(vr))});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()});$([p({details:kr,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=$([h(),p({Object:h()})]);I(Mn);const Nn=p({address:h(),name:h()}),Dn=$([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,U=new Uint8Array(_);f!==j;){for(var E=y[f],k=0,R=_-1;(E!==0||k<b)&&R!==-1;R--,k++)E+=256*U[R]>>>0,U[R]=E%c>>>0,E=E/c>>>0;if(E!==0)throw new Error("Non-zero carry");b=k,f++}for(var K=_-b;K!==_&&U[K]===0;)K++;for(var we=a.repeat(w);K<_;++K)we+=t.charAt(U[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 U=e[y.charCodeAt(w)];if(U===255)return;for(var E=0,k=j-1;(U!==0||E<f)&&k!==-1;k--,E++)U+=c*_[k]>>>0,_[k]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");f=E,w++}for(var R=j-f;R!==j&&_[R]===0;)R++;for(var K=new Uint8Array(b+(j-R)),we=b;R!==j;)K[we++]=_[R++];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 C=(t,e,r)=>Yr(t,typeof e!="symbol"?e+"":e,r);import{s as Qr,ay as en,c_ as ft,aE as tn,c$ as hr,d0 as ke,be as rn,ch as nt,bX as nn,ci as nr,b2 as ce,aH as ge,al as oe,bU as sn,cn as ir,ck as an,d1 as on,bY as ht,aF as cn,ad as De,a$ as un,cy as sr,d2 as dn,aG as ar,c1 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-CW05lm4n.js";import"./index-YIP9QK2L.js";import"./pbkdf2-CTUZRYZs.js";class yr{constructor(e,r,n,i,s=!1){C(this,"transaction");C(this,"network");C(this,"chain");C(this,"description");C(this,"parallelizable");this.transaction=e,this.network=r,this.chain=n,this.description=i,this.parallelizable=s}}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*vt(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=vt(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=vt(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 $(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]=vt(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 kt=$([p({AddressOwner:h()}),p({ObjectOwner:h()}),p({Shared:p({initial_shared_version:B(h())})}),T("Immutable")]);G("SuiJsonValue",()=>!0);const vn=$([p({u32:h()}),p({u64:h()}),p({f64:h()})]);p({attributes:Y(h(),B(vn)),featureFlags:Y(h(),D()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});$([h(),T("package")]);const de=p({digest:h(),objectId:h(),version:$([ye(),h(),Sn()])});p({owner:kt,reference:de});p({objectId:h(),sequenceNumber:h()});p({payment:I(de),owner:h(),price:h(),budget:h()});const kn=Ae(de,p({type:h(),owner:kt,previousTransaction:h()})),In=Y(h(),yt()),jn=Y(h(),Tr()),En=p({type:h(),fields:In,hasPublicTransfer:D()}),On=p({disassembled:jn}),An=$([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=$([Ae(_n,p({dataType:T("moveObject")})),Ae(xn,p({dataType:T("package")}))]);BigInt(1e9);const vr=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(vr))}),$n=$([Cn,S(Y(h(),h()))]),kr=p({objectId:h(),version:h(),digest:h(),type:B(S(h())),content:B(S(An)),bcs:B(S(Bn)),owner:B(S(kt)),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()))});$([T("Exists"),T("notExists"),T("Deleted")]);I(kn);const Un=p({data:B(S(kr)),error:B(S(vr))});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()});$([p({details:kr,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=$([h(),p({Object:h()})]);I(Mn);const Nn=p({address:h(),name:h()}),Dn=$([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,U=new Uint8Array(_);f!==j;){for(var E=y[f],k=0,R=_-1;(E!==0||k<b)&&R!==-1;R--,k++)E+=256*U[R]>>>0,U[R]=E%c>>>0,E=E/c>>>0;if(E!==0)throw new Error("Non-zero carry");b=k,f++}for(var K=_-b;K!==_&&U[K]===0;)K++;for(var we=a.repeat(w);K<_;++K)we+=t.charAt(U[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 U=e[y.charCodeAt(w)];if(U===255)return;for(var E=0,k=j-1;(U!==0||E<f)&&k!==-1;k--,E++)U+=c*_[k]>>>0,_[k]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");f=E,w++}for(var R=j-f;R!==j&&_[R]===0;)R++;for(var K=new Uint8Array(b+(j-R)),we=b;R!==j;)K[we++]=_[R++];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 J=(O,e,t)=>e in O?G(O,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):O[e]=t;var d=(O,e,t)=>J(O,typeof e!="symbol"?e+"":e,t);import{A as S,S as g,a as Q}from"./index-
|
|
1
|
+
var G=Object.defineProperty;var J=(O,e,t)=>e in O?G(O,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):O[e]=t;var d=(O,e,t)=>J(O,typeof e!="symbol"?e+"":e,t);import{A as S,S as g,a as Q}from"./index-C0psfra-.js";import{dv as Z,a$ as C,b2 as $,dj as _,bo as I,dw as v,dm as q,bX as tt,cy as b,ci as et,al as z,cn as H,dn as y,dh as u,dp as k,ds as U,bY as L,di as K,dx as st,dy as V,dz as ot,c1 as nt,bl as rt}from"../main.js";import{A as at}from"./algorand-CyJRjYjt.js";const X=Z.fromSignature("portal_transfer(byte[])byte[]"),c=class c{constructor(e,t,n,o){d(this,"network");d(this,"chain");d(this,"connection");d(this,"contracts");d(this,"chainId");d(this,"coreBridge");d(this,"coreAppId");d(this,"coreAppAddress");d(this,"tokenBridgeAppId");d(this,"tokenBridgeAddress");if(this.network=e,this.chain=t,this.connection=n,this.contracts=o,this.chainId=$(t),!o.coreBridge)throw new Error(`Core contract address for chain ${t} not found`);const r=BigInt(o.coreBridge);if(this.coreAppId=r,this.coreAppAddress=_(r),this.coreBridge=new S(e,t,n,o),!o.tokenBridge)throw new Error(`TokenBridge contract address for chain ${t} not found`);const a=BigInt(o.tokenBridge);this.tokenBridgeAppId=a,this.tokenBridgeAddress=_(a)}static async fromRpc(e,t){const[n,o]=await at.chainFromRpc(e),r=t[o];if(r.network!==n)throw new Error(`Network mismatch: ${r.network} != ${n}`);return new c(n,o,e,r.contracts)}async isWrappedAsset(e){const t=new I(e).toInt();if(t===0)return!1;const n=await this.connection.getAssetByID(t).do(),r=v.from_obj_for_encoding(n).params.creator,a=await this.connection.accountInformation(r).exclude("all").do(),s=q.from_obj_for_encoding(a);return(s==null?void 0:s.authAddr)===this.tokenBridgeAddress}async getOriginalAsset(e){const t=new I(e).toInt(),n=await this.connection.getAssetByID(t).do(),o=v.from_obj_for_encoding(n),r=await g.decodeLocalState(this.connection,this.tokenBridgeAppId,o.params.creator);if(r.length<94)throw new Error("Invalid local state data");const a=r.slice(92,94),s=tt(b.decode(a)),p=new et(r.slice(60,92));return{chain:s,address:p}}async getTokenUniversalAddress(e){return new I(e).toUniversalAddress()}async getTokenNativeAddress(e,t){return new I(t).toNative()}async getWrappedAsset(e){if(z(e.address))throw new Error("native asset cannot be a wrapped asset");const t=g.forWrappedAsset(this.tokenBridgeAppId,e),n=await g.decodeLocalState(this.connection,this.tokenBridgeAppId,t.address());if(n.length<8)throw new Error("Invalid wrapped asset data");return H(this.chain,b.decode(n.slice(0,8)).toString())}async hasWrappedAsset(e){try{return await this.getWrappedAsset(e),!0}catch{}return!1}async getWrappedNative(){return H(this.chain,"0")}async isTransferCompleted(e){const t=g.forMessageId(this.tokenBridgeAppId,{sequence:e.sequence,chain:e.emitterChain,emitter:e.emitterAddress});try{return await g.checkBitsSet(this.connection,this.tokenBridgeAppId,t.address(),e.sequence)}catch{}return!1}async*createAttestation(e,t){if(!t)throw new Error("Payer required to create attestation");const n=new I(t).toString(),o=new I(e).toInt(),r=[],a=await this.connection.getTransactionParams().do(),s=g.forEmitter(this.coreAppId,new I(this.tokenBridgeAddress).toUint8Array()),{accounts:[p],txs:w}=await S.maybeCreateStorageTx(this.connection,n,this.coreAppId,s,a);r.push(...w);let f="",i;if(o!==0){const m=await this.connection.getAssetByID(o).do(),j=v.from_obj_for_encoding(m),E=await this.connection.accountInformation(j.params.creator).do();if(i=q.from_obj_for_encoding(E),i.authAddr===this.tokenBridgeAddress.toString())throw new Error("Cannot re-attest wormhole assets")}const T=g.forNativeAsset(this.tokenBridgeAppId,BigInt(o)),B=await S.maybeCreateStorageTx(this.connection,n,this.tokenBridgeAppId,T);f=B.accounts[0],r.push(...B.txs);const l=y({from:n,appIndex:u(this.tokenBridgeAppId),onComplete:k.NoOpOC,appArgs:[c.noop],suggestedParams:a});r.push({tx:l});const A=await this.coreBridge.getMessageFee();if(A>BigInt(0)){const m=U({from:n,suggestedParams:a,to:this.tokenBridgeAddress,amount:A});r.push({tx:m})}let W=[p,f,this.coreAppAddress];i&&W.push(i.address);let h=y({appArgs:[c.attestToken,b.toBytes(o,8)],accounts:W,appIndex:u(this.tokenBridgeAppId),foreignApps:[u(this.coreAppId)],foreignAssets:[o],from:n,onComplete:k.NoOpOC,suggestedParams:a});A>BigInt(0)?h.fee*=3:h.fee*=2,r.push({tx:h});for(const m of r)yield this.createUnsignedTx(m,"TokenBridge.createAttestation",!0)}async*submitAttestation(e,t,n){if(!t)throw new Error("Sender required to submit attestation");n||(n=await this.connection.getTransactionParams().do());const o=t.toString(),a=g.forWrappedAsset(this.tokenBridgeAppId,e.payload.token).address(),s=[],p=[],w=await g.decodeLocalState(this.connection,this.tokenBridgeAppId,a);w.length>8&&p.push(new I(w.slice(0,8)).toInt()),s.push({tx:U({from:o,to:a,amount:1e5,suggestedParams:n})});let f=new Uint8Array(1);f[0]=1,s.push({tx:y({appArgs:[c.noop,f],appIndex:u(this.tokenBridgeAppId),from:o,onComplete:k.NoOpOC,suggestedParams:n})}),f=new Uint8Array(1),f[0]=2,s.push({tx:y({appArgs:[c.noop,f],appIndex:u(this.tokenBridgeAppId),from:o,onComplete:k.NoOpOC,suggestedParams:n})}),s.push({tx:y({accounts:[],appArgs:[c.receiveAttest,L(e)],appIndex:u(this.tokenBridgeAppId),foreignAssets:p,from:o,onComplete:k.NoOpOC,suggestedParams:n})}),s[s.length-1].tx.fee=s[s.length-1].tx.fee*2;for(const i of s)yield this.createUnsignedTx(i,"TokenBridge.submitAttestation",!0)}async*transfer(e,t,n,o,r){const a=e.toString(),s=z(n)?0:new I(n).toInt(),p=o,w=$(t.chain),f=t.address.toUniversalAddress().toUint8Array(),i=await this.connection.getTransactionParams().do(),T=BigInt(0),B=g.fromData({appId:this.coreAppId,appAddress:K(this.coreAppAddress).publicKey,idx:BigInt(0),address:K(this.tokenBridgeAddress).publicKey}),l=[],{accounts:[A],txs:W}=await S.maybeCreateStorageTx(this.connection,a,this.coreAppId,B,i);l.push(...W);let h="",m,j=!1;if(s!==0){const x=await this.connection.getAssetByID(s).do();h=v.from_obj_for_encoding(x).params.creator;const R=await this.connection.accountInformation(h).do();m=q.from_obj_for_encoding(R),j=m.authAddr===this.tokenBridgeAddress.toString()}const E=await this.coreBridge.getMessageFee();if(E>0&&l.push({tx:U({from:a,to:this.tokenBridgeAddress,amount:E,suggestedParams:i})}),!j){const x=g.forNativeAsset(this.tokenBridgeAppId,BigInt(s)),{accounts:[N],txs:R}=await S.maybeCreateStorageTx(this.connection,a,this.tokenBridgeAppId,x,i);h=N,R.push(...R)}if(s!==0&&!await c.isOptedInToAsset(this.connection,h,s)){const x=U({from:a,to:h,amount:1e5,suggestedParams:i});let N=y({from:a,appIndex:u(this.tokenBridgeAppId),onComplete:k.NoOpOC,appArgs:[c.optIn,st(s,8)],foreignAssets:[s],accounts:[h],suggestedParams:i});N.fee*=2,l.unshift({tx:x},{tx:N})}const Y=y({from:a,appIndex:u(this.tokenBridgeAppId),onComplete:k.NoOpOC,appArgs:[c.noop],suggestedParams:i});l.push({tx:Y});let F=[];if(s===0){const x=U({from:a,to:h,amount:p,suggestedParams:i});l.push({tx:x}),F=[A,h,h]}else{const x=V({from:a,to:h,amount:p,assetIndex:s,suggestedParams:i});l.push({tx:x}),F=m!=null&&m.address?[A,h,m.address]:[A,h]}const M=[c.sendTransfer,b.toBytes(s,8),b.toBytes(p,8),f,b.toBytes(w,8),b.toBytes(T,8)];r&&M.push(r);const P=y({from:a,appIndex:u(this.tokenBridgeAppId),onComplete:k.NoOpOC,appArgs:M,foreignApps:[u(this.coreAppId)],foreignAssets:[s],accounts:F,suggestedParams:i});P.fee*=2,l.push({tx:P});for(const x of l)yield this.createUnsignedTx(x,"TokenBridge.transfer",!0)}async*redeem(e,t,n=!0,o){o||(o=await this.connection.getTransactionParams().do());const r=new I(e).toString(),{accounts:a,txs:s}=await S.submitVAAHeader(this.connection,this.coreAppId,this.tokenBridgeAppId,t,r);let p,w="",f=[],i=0;if(t.payload.token.chain!==this.chain){p=g.forWrappedAsset(this.tokenBridgeAppId,t.payload.token),w=p.address();const A=await g.decodeLocalState(this.connection,this.tokenBridgeAppId,w);i=new I(A.slice(0,8)).toInt()}else{const A=new I(t.payload.token.address).toBigInt();p=g.forNativeAsset(this.tokenBridgeAppId,A),w=p.address(),i=u(A)}a.push(w);let T=0,B="";if(t.payloadName==="TransferWithPayload"?(T=new I(t.payload.to.address).toInt(),B=_(T)):B=new I(t.payload.to.address.toUint8Array()).toString(),a.push(B),i!==0&&(f.push(i),!await c.isOptedInToAsset(this.connection,B,i))){if(r!=B)throw new Error("Cannot ASA optin for somebody else (asset "+i.toString()+")");s.unshift({tx:V({amount:0,assetIndex:i,from:r,suggestedParams:o,to:r})})}const l={accounts:a,appArgs:[c.completeTransfer,L(t)],appIndex:u(this.tokenBridgeAppId),foreignAssets:f,from:r,onComplete:k.NoOpOC,suggestedParams:o};s.push({tx:y(l)}),s[s.length-1].tx.fee=s[s.length-1].tx.fee*(t.payloadName==="Transfer"&&t.payload.fee!==void 0&&t.payload.fee===0n?2:3),t.payloadName==="TransferWithPayload"&&(s[s.length-1].tx.appForeignApps=[T],s.push({tx:y({appArgs:[X.getSelector(),X.args[0].type.encode(L(t))],appIndex:T,foreignAssets:f,from:r,onComplete:k.NoOpOC,suggestedParams:o})}));for(const A of s)yield this.createUnsignedTx(A,"TokenBridge.redeem",!0)}static async isOptedInToAsset(e,t,n){var o;try{const r=await e.accountAssetInformation(t,n).do();return(((o=ot.from_obj_for_encoding(r).assetHolding)==null?void 0:o.amount)??0)>0}catch{}return!1}createUnsignedTx(e,t,n=!0){return new Q(e,this.network,this.chain,t,n)}};d(c,"sendTransfer",C.encode("sendTransfer")),d(c,"attestToken",C.encode("attestToken")),d(c,"noop",C.encode("nop")),d(c,"optIn",C.encode("optin")),d(c,"completeTransfer",C.encode("completeTransfer")),d(c,"receiveAttest",C.encode("receiveAttest"));let D=c;nt(rt,"TokenBridge",D);export{D as AlgorandTokenBridge,X as TransferMethodSelector};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{O as xo,bD as Iw,i as te,s as Pw,_ as Sw}from"../main.js";import{e as bt,a as Ao}from"./events-C1UiYlrP.js";import{c as q,s as Do,x as zh,r as Hh,H as Ow,a as Vh,q as Ss}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D2LZykJf.js","main.js","main.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{O as xo,bD as Iw,i as te,s as Pw,_ as Sw}from"../main.js";import{e as bt,a as Ao}from"./events-C1UiYlrP.js";import{c as q,s as Do,x as zh,r as Hh,H as Ow,a as Vh,q as Ss}from"./index-C3Sky6pw.js";import{I as lr,f as ft,t as nt,c as $u,C as Rw,r as Nw,a as Dr,g as Kh,i as _t,b as $s,d as $w,E as ze,y as Qe,q as Cs,k as Ts,h as Cw,e as Cu,j as Tw,s as xw,l as Aw,m as qo,n as xs,o as jo,p as Bt,u as Dw,v as Tu,w as qw}from"./index-BwBQHmYt.js";import{o as xu}from"./browser-ponyfill-IMf0p6VP.js";var se={};Object.defineProperty(se,"__esModule",{value:!0});se.getLocalStorage=se.getLocalStorageOrThrow=se.getCrypto=se.getCryptoOrThrow=se.getLocation=se.getLocationOrThrow=se.getNavigator=se.getNavigatorOrThrow=se.getDocument=se.getDocumentOrThrow=se.getFromWindowOrThrow=se.getFromWindow=void 0;function pr(o){let t;return typeof window<"u"&&typeof window[o]<"u"&&(t=window[o]),t}se.getFromWindow=pr;function Ur(o){const t=pr(o);if(!t)throw new Error(`${o} is not defined in Window`);return t}se.getFromWindowOrThrow=Ur;function jw(){return Ur("document")}se.getDocumentOrThrow=jw;function Uw(){return pr("document")}se.getDocument=Uw;function Mw(){return Ur("navigator")}se.getNavigatorOrThrow=Mw;function Lw(){return pr("navigator")}se.getNavigator=Lw;function kw(){return Ur("location")}se.getLocationOrThrow=kw;function zw(){return pr("location")}se.getLocation=zw;function Hw(){return Ur("crypto")}se.getCryptoOrThrow=Hw;function Vw(){return pr("crypto")}se.getCrypto=Vw;function Kw(){return Ur("localStorage")}se.getLocalStorageOrThrow=Kw;function Fw(){return pr("localStorage")}se.getLocalStorage=Fw;var Uo={};Object.defineProperty(Uo,"__esModule",{value:!0});Uo.getWindowMetadata=void 0;const Au=se;function Ww(){let o,t;try{o=Au.getDocumentOrThrow(),t=Au.getLocationOrThrow()}catch{return null}function r(){const S=o.getElementsByTagName("link"),R=[];for(let j=0;j<S.length;j++){const x=S[j],K=x.getAttribute("rel");if(K&&K.toLowerCase().indexOf("icon")>-1){const A=x.getAttribute("href");if(A)if(A.toLowerCase().indexOf("https:")===-1&&A.toLowerCase().indexOf("http:")===-1&&A.indexOf("//")!==0){let B=t.protocol+"//"+t.host;if(A.indexOf("/")===0)B+=A;else{const pe=t.pathname.split("/");pe.pop();const J=pe.join("/");B+=J+"/"+A}R.push(B)}else if(A.indexOf("//")===0){const B=t.protocol+A;R.push(B)}else R.push(A)}}return R}function s(...S){const R=o.getElementsByTagName("meta");for(let j=0;j<R.length;j++){const x=R[j],K=["itemprop","property","name"].map(A=>x.getAttribute(A)).filter(A=>A?S.includes(A):!1);if(K.length&&K){const A=x.getAttribute("content");if(A)return A}}return""}function a(){let S=s("name","og:site_name","og:title","twitter:title");return S||(S=o.title),S}function u(){return s("description","og:description","twitter:description","keywords")}const l=a(),g=u(),w=t.origin,b=r();return{description:g,url:w,icons:b,name:l}}Uo.getWindowMetadata=Ww;function Bw(o,t=[]){const r=[];return Object.keys(o).forEach(s=>{if(t.length&&!t.includes(s))return;const a=o[s];r.push(...a.accounts)}),r}const Gw={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}};function Qw(o,t){const{message:r,code:s}=Gw[o];return{message:r,code:s}}function mo(o,t){return!!Array.isArray(o)}var Mr={};/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
5
5
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -44,4 +44,4 @@ __p += '`),Q&&(O+=`' +
|
|
|
44
44
|
function print() { __p += __j.call(arguments, '') }
|
|
45
45
|
`:`;
|
|
46
46
|
`)+O+`return __p
|
|
47
|
-
}`;var V=Ou(function(){return Z(d,D+"return "+O).apply(r,f)});if(V.source=O,Bn(V))throw V;return V}function Cm(e){return X(e).toLowerCase()}function Tm(e){return X(e).toUpperCase()}function xm(e,i,n){if(e=X(e),e&&(n||i===r))return qa(e);if(!e||!(i=Ke(i)))return e;var c=ct(e),h=ct(i),d=ja(c,h),f=Ua(c,h)+1;return Ft(c,d,f).join("")}function Am(e,i,n){if(e=X(e),e&&(n||i===r))return e.slice(0,La(e)+1);if(!e||!(i=Ke(i)))return e;var c=ct(e),h=Ua(c,ct(i))+1;return Ft(c,0,h).join("")}function Dm(e,i,n){if(e=X(e),e&&(n||i===r))return e.replace(Ws,"");if(!e||!(i=Ke(i)))return e;var c=ct(e),h=ja(c,ct(i));return Ft(c,h).join("")}function qm(e,i){var n=Rl,c=Nl;if(he(i)){var h="separator"in i?i.separator:h;n="length"in i?H(i.length):n,c="omission"in i?Ke(i.omission):c}e=X(e);var d=e.length;if(_r(e)){var f=ct(e);d=f.length}if(n>=d)return e;var y=n-br(c);if(y<1)return c;var m=f?Ft(f,0,y).join(""):e.slice(0,y);if(h===r)return m+c;if(f&&(y+=m.length-y),Gn(h)){if(e.slice(y).search(h)){var I,P=m;for(h.global||(h=hn(h.source,X(ia.exec(h))+"g")),h.lastIndex=0;I=h.exec(P);)var O=I.index;m=m.slice(0,O===r?y:O)}}else if(e.indexOf(Ke(h),y)!=y){var C=m.lastIndexOf(h);C>-1&&(m=m.slice(0,C))}return m+c}function jm(e){return e=X(e),e&&Wl.test(e)?e.replace(ea,hd):e}var Um=Nr(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Yn=Rc("toUpperCase");function Su(e,i,n){return e=X(e),i=n?r:i,i===r?nd(e)?dd(e):Jp(e):e.match(i)||[]}var Ou=F(function(e,i){try{return He(e,r,i)}catch(n){return Bn(n)?n:new k(n)}}),Mm=Rt(function(e,i){return Ye(i,function(n){n=mt(n),St(e,n,Fn(e[n],e))}),e});function Lm(e){var i=e==null?0:e.length,n=U();return e=i?ce(e,function(c){if(typeof c[1]!="function")throw new Ze(l);return[n(c[0]),c[1]]}):[],F(function(c){for(var h=-1;++h<i;){var d=e[h];if(He(d[0],this,c))return He(d[1],this,c)}})}function km(e){return lf(et(e,S))}function Zn(e){return function(){return e}}function zm(e,i){return e==null||e!==e?i:e}var Hm=$c(),Vm=$c(!0);function Ue(e){return e}function Xn(e){return nc(typeof e=="function"?e:et(e,S))}function Km(e){return ac(et(e,S))}function Fm(e,i){return cc(e,et(i,S))}var Wm=F(function(e,i){return function(n){return si(n,e,i)}}),Bm=F(function(e,i){return function(n){return si(e,n,i)}});function eo(e,i,n){var c=_e(i),h=Xi(i,c);n==null&&!(he(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Xi(i,_e(i)));var d=!(he(n)&&"chain"in n)||!!n.chain,f=$t(e);return Ye(h,function(y){var m=i[y];e[y]=m,f&&(e.prototype[y]=function(){var I=this.__chain__;if(d||I){var P=e(this.__wrapped__),O=P.__actions__=De(this.__actions__);return O.push({func:m,args:arguments,thisArg:e}),P.__chain__=I,P}return m.apply(e,Lt([this.value()],arguments))})}),e}function Gm(){return Ee._===this&&(Ee._=wd),this}function to(){}function Qm(e){return e=H(e),F(function(i){return uc(i,e)})}var Jm=xn(ce),Ym=xn(Ca),Zm=xn(rn);function Ru(e){return Ln(e)?sn(mt(e)):Nf(e)}function Xm(e){return function(i){return e==null?r:sr(e,i)}}var ew=Tc(),tw=Tc(!0);function ro(){return[]}function io(){return!1}function rw(){return{}}function iw(){return""}function sw(){return!0}function nw(e,i){if(e=H(e),e<1||e>Ut)return[];var n=gt,c=Se(e,gt);i=U(i),e-=gt;for(var h=an(c,i);++n<e;)i(n);return h}function ow(e){return z(e)?ce(e,mt):Fe(e)?[e]:De(Bc(X(e)))}function aw(e){var i=++vd;return X(e)+i}var cw=ns(function(e,i){return e+i},0),uw=An("ceil"),hw=ns(function(e,i){return e/i},1),lw=An("floor");function pw(e){return e&&e.length?Zi(e,Ue,mn):r}function dw(e,i){return e&&e.length?Zi(e,U(i,2),mn):r}function fw(e){return Aa(e,Ue)}function gw(e,i){return Aa(e,U(i,2))}function yw(e){return e&&e.length?Zi(e,Ue,En):r}function vw(e,i){return e&&e.length?Zi(e,U(i,2),En):r}var mw=ns(function(e,i){return e*i},1),ww=An("round"),_w=ns(function(e,i){return e-i},0);function bw(e){return e&&e.length?on(e,Ue):0}function Ew(e,i){return e&&e.length?on(e,U(i,2)):0}return p.after=Ky,p.ary=su,p.assign=Tv,p.assignIn=mu,p.assignInWith=ms,p.assignWith=xv,p.at=Av,p.before=nu,p.bind=Fn,p.bindAll=Mm,p.bindKey=ou,p.castArray=rv,p.chain=tu,p.chunk=lg,p.compact=pg,p.concat=dg,p.cond=Lm,p.conforms=km,p.constant=Zn,p.countBy=by,p.create=Dv,p.curry=au,p.curryRight=cu,p.debounce=uu,p.defaults=qv,p.defaultsDeep=jv,p.defer=Fy,p.delay=Wy,p.difference=fg,p.differenceBy=gg,p.differenceWith=yg,p.drop=vg,p.dropRight=mg,p.dropRightWhile=wg,p.dropWhile=_g,p.fill=bg,p.filter=Iy,p.flatMap=Oy,p.flatMapDeep=Ry,p.flatMapDepth=Ny,p.flatten=Yc,p.flattenDeep=Eg,p.flattenDepth=Ig,p.flip=By,p.flow=Hm,p.flowRight=Vm,p.fromPairs=Pg,p.functions=Vv,p.functionsIn=Kv,p.groupBy=$y,p.initial=Og,p.intersection=Rg,p.intersectionBy=Ng,p.intersectionWith=$g,p.invert=Wv,p.invertBy=Bv,p.invokeMap=Ty,p.iteratee=Xn,p.keyBy=xy,p.keys=_e,p.keysIn=je,p.map=ps,p.mapKeys=Qv,p.mapValues=Jv,p.matches=Km,p.matchesProperty=Fm,p.memoize=fs,p.merge=Yv,p.mergeWith=wu,p.method=Wm,p.methodOf=Bm,p.mixin=eo,p.negate=gs,p.nthArg=Qm,p.omit=Zv,p.omitBy=Xv,p.once=Gy,p.orderBy=Ay,p.over=Jm,p.overArgs=Qy,p.overEvery=Ym,p.overSome=Zm,p.partial=Wn,p.partialRight=hu,p.partition=Dy,p.pick=em,p.pickBy=_u,p.property=Ru,p.propertyOf=Xm,p.pull=Ag,p.pullAll=Xc,p.pullAllBy=Dg,p.pullAllWith=qg,p.pullAt=jg,p.range=ew,p.rangeRight=tw,p.rearg=Jy,p.reject=Uy,p.remove=Ug,p.rest=Yy,p.reverse=Vn,p.sampleSize=Ly,p.set=rm,p.setWith=im,p.shuffle=ky,p.slice=Mg,p.sortBy=Vy,p.sortedUniq=Fg,p.sortedUniqBy=Wg,p.split=Om,p.spread=Zy,p.tail=Bg,p.take=Gg,p.takeRight=Qg,p.takeRightWhile=Jg,p.takeWhile=Yg,p.tap=py,p.throttle=Xy,p.thru=ls,p.toArray=gu,p.toPairs=bu,p.toPairsIn=Eu,p.toPath=ow,p.toPlainObject=vu,p.transform=sm,p.unary=ev,p.union=Zg,p.unionBy=Xg,p.unionWith=ey,p.uniq=ty,p.uniqBy=ry,p.uniqWith=iy,p.unset=nm,p.unzip=Kn,p.unzipWith=eu,p.update=om,p.updateWith=am,p.values=Tr,p.valuesIn=cm,p.without=sy,p.words=Su,p.wrap=tv,p.xor=ny,p.xorBy=oy,p.xorWith=ay,p.zip=cy,p.zipObject=uy,p.zipObjectDeep=hy,p.zipWith=ly,p.entries=bu,p.entriesIn=Eu,p.extend=mu,p.extendWith=ms,eo(p,p),p.add=cw,p.attempt=Ou,p.camelCase=pm,p.capitalize=Iu,p.ceil=uw,p.clamp=um,p.clone=iv,p.cloneDeep=nv,p.cloneDeepWith=ov,p.cloneWith=sv,p.conformsTo=av,p.deburr=Pu,p.defaultTo=zm,p.divide=hw,p.endsWith=dm,p.eq=ht,p.escape=fm,p.escapeRegExp=gm,p.every=Ey,p.find=Py,p.findIndex=Qc,p.findKey=Uv,p.findLast=Sy,p.findLastIndex=Jc,p.findLastKey=Mv,p.floor=lw,p.forEach=ru,p.forEachRight=iu,p.forIn=Lv,p.forInRight=kv,p.forOwn=zv,p.forOwnRight=Hv,p.get=Qn,p.gt=cv,p.gte=uv,p.has=Fv,p.hasIn=Jn,p.head=Zc,p.identity=Ue,p.includes=Cy,p.indexOf=Sg,p.inRange=hm,p.invoke=Gv,p.isArguments=ar,p.isArray=z,p.isArrayBuffer=hv,p.isArrayLike=qe,p.isArrayLikeObject=fe,p.isBoolean=lv,p.isBuffer=Wt,p.isDate=pv,p.isElement=dv,p.isEmpty=fv,p.isEqual=gv,p.isEqualWith=yv,p.isError=Bn,p.isFinite=vv,p.isFunction=$t,p.isInteger=lu,p.isLength=ys,p.isMap=pu,p.isMatch=mv,p.isMatchWith=wv,p.isNaN=_v,p.isNative=bv,p.isNil=Iv,p.isNull=Ev,p.isNumber=du,p.isObject=he,p.isObjectLike=le,p.isPlainObject=hi,p.isRegExp=Gn,p.isSafeInteger=Pv,p.isSet=fu,p.isString=vs,p.isSymbol=Fe,p.isTypedArray=Cr,p.isUndefined=Sv,p.isWeakMap=Ov,p.isWeakSet=Rv,p.join=Cg,p.kebabCase=ym,p.last=rt,p.lastIndexOf=Tg,p.lowerCase=vm,p.lowerFirst=mm,p.lt=Nv,p.lte=$v,p.max=pw,p.maxBy=dw,p.mean=fw,p.meanBy=gw,p.min=yw,p.minBy=vw,p.stubArray=ro,p.stubFalse=io,p.stubObject=rw,p.stubString=iw,p.stubTrue=sw,p.multiply=mw,p.nth=xg,p.noConflict=Gm,p.noop=to,p.now=ds,p.pad=wm,p.padEnd=_m,p.padStart=bm,p.parseInt=Em,p.random=lm,p.reduce=qy,p.reduceRight=jy,p.repeat=Im,p.replace=Pm,p.result=tm,p.round=ww,p.runInContext=v,p.sample=My,p.size=zy,p.snakeCase=Sm,p.some=Hy,p.sortedIndex=Lg,p.sortedIndexBy=kg,p.sortedIndexOf=zg,p.sortedLastIndex=Hg,p.sortedLastIndexBy=Vg,p.sortedLastIndexOf=Kg,p.startCase=Rm,p.startsWith=Nm,p.subtract=_w,p.sum=bw,p.sumBy=Ew,p.template=$m,p.times=nw,p.toFinite=Ct,p.toInteger=H,p.toLength=yu,p.toLower=Cm,p.toNumber=it,p.toSafeInteger=Cv,p.toString=X,p.toUpper=Tm,p.trim=xm,p.trimEnd=Am,p.trimStart=Dm,p.truncate=qm,p.unescape=jm,p.uniqueId=aw,p.upperCase=Um,p.upperFirst=Yn,p.each=ru,p.eachRight=iu,p.first=Zc,eo(p,function(){var e={};return yt(p,function(i,n){ee.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,Ye(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Ye(["drop","take"],function(e,i){G.prototype[e]=function(n){n=n===r?1:we(H(n),0);var c=this.__filtered__&&!i?new G(this):this.clone();return c.__filtered__?c.__takeCount__=Se(n,c.__takeCount__):c.__views__.push({size:Se(n,gt),type:e+(c.__dir__<0?"Right":"")}),c},G.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ye(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==Yo||n==xl;G.prototype[e]=function(h){var d=this.clone();return d.__iteratees__.push({iteratee:U(h,3),type:n}),d.__filtered__=d.__filtered__||c,d}}),Ye(["head","last"],function(e,i){var n="take"+(i?"Right":"");G.prototype[e]=function(){return this[n](1).value()[0]}}),Ye(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");G.prototype[e]=function(){return this.__filtered__?new G(this):this[n](1)}}),G.prototype.compact=function(){return this.filter(Ue)},G.prototype.find=function(e){return this.filter(e).head()},G.prototype.findLast=function(e){return this.reverse().find(e)},G.prototype.invokeMap=F(function(e,i){return typeof e=="function"?new G(this):this.map(function(n){return si(n,e,i)})}),G.prototype.reject=function(e){return this.filter(gs(U(e)))},G.prototype.slice=function(e,i){e=H(e);var n=this;return n.__filtered__&&(e>0||i<0)?new G(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=H(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},G.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},G.prototype.toArray=function(){return this.take(gt)},yt(G.prototype,function(e,i){var n=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),h=p[c?"take"+(i=="last"?"Right":""):i],d=c||/^find/.test(i);h&&(p.prototype[i]=function(){var f=this.__wrapped__,y=c?[1]:arguments,m=f instanceof G,I=y[0],P=m||z(f),O=function(W){var Q=h.apply(p,Lt([W],y));return c&&C?Q[0]:Q};P&&n&&typeof I=="function"&&I.length!=1&&(m=P=!1);var C=this.__chain__,D=!!this.__actions__.length,M=d&&!C,V=m&&!D;if(!d&&P){f=V?f:new G(this);var L=e.apply(f,y);return L.__actions__.push({func:ls,args:[O],thisArg:r}),new Xe(L,C)}return M&&V?e.apply(this,y):(L=this.thru(O),M?c?L.value()[0]:L.value():L)})}),Ye(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ui[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);p.prototype[e]=function(){var h=arguments;if(c&&!this.__chain__){var d=this.value();return i.apply(z(d)?d:[],h)}return this[n](function(f){return i.apply(z(f)?f:[],h)})}}),yt(G.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";ee.call(Sr,c)||(Sr[c]=[]),Sr[c].push({name:i,func:n})}}),Sr[ss(r,B).name]=[{name:"wrapper",func:r}],G.prototype.clone=qd,G.prototype.reverse=jd,G.prototype.value=Ud,p.prototype.at=dy,p.prototype.chain=fy,p.prototype.commit=gy,p.prototype.next=yy,p.prototype.plant=my,p.prototype.reverse=wy,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=_y,p.prototype.first=p.prototype.head,Yr&&(p.prototype[Yr]=vy),p},Er=fd();Xt?((Xt.exports=Er)._=Er,Zs._=Er):Ee._=Er}).call(vi)})($o,$o.exports);var DI=Object.defineProperty,qI=Object.defineProperties,jI=Object.getOwnPropertyDescriptors,Ah=Object.getOwnPropertySymbols,UI=Object.prototype.hasOwnProperty,MI=Object.prototype.propertyIsEnumerable,Dh=(o,t,r)=>t in o?DI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,bs=(o,t)=>{for(var r in t||(t={}))UI.call(t,r)&&Dh(o,r,t[r]);if(Ah)for(var r of Ah(t))MI.call(t,r)&&Dh(o,r,t[r]);return o},LI=(o,t)=>qI(o,jI(t));function Jt(o,t,r){var s;const a=u_(o);return((s=t.rpcMap)==null?void 0:s[a.reference])||`${AI}?chainId=${a.namespace}:${a.reference}&projectId=${r}`}function gr(o){return o.includes(":")?o.split(":")[1]:o}function Sl(o){return o.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function kI(o,t){const r=Object.keys(t.namespaces).filter(a=>a.includes(o));if(!r.length)return[];const s=[];return r.forEach(a=>{const u=t.namespaces[a].accounts;s.push(...u)}),s}function zI(o={},t={}){const r=qh(o),s=qh(t);return $o.exports.merge(r,s)}function qh(o){var t,r,s,a;const u={};if(!jr(o))return u;for(const[l,g]of Object.entries(o)){const w=Ko(l)?[l]:g.chains,b=g.methods||[],N=g.events||[],S=g.rpcMap||{},R=mi(l);u[R]=LI(bs(bs({},u[R]),g),{chains:oo(w,(t=u[R])==null?void 0:t.chains),methods:oo(b,(r=u[R])==null?void 0:r.methods),events:oo(N,(s=u[R])==null?void 0:s.events),rpcMap:bs(bs({},S),(a=u[R])==null?void 0:a.rpcMap)})}return u}function HI(o){return o.includes(":")?o.split(":")[2]:o}function VI(o){const t={};for(const[r,s]of Object.entries(o)){const a=s.methods||[],u=s.events||[],l=s.accounts||[],g=Ko(r)?[r]:s.chains?s.chains:Sl(s.accounts);t[r]={chains:g,methods:a,events:u,accounts:l}}return t}function fo(o){return typeof o=="number"?o:o.includes("0x")?parseInt(o,16):o.includes(":")?Number(o.split(":")[1]):Number(o)}const Ol={},ue=o=>Ol[o],go=(o,t)=>{Ol[o]=t};class KI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class FI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(parseInt(t),r),this.chainId=parseInt(t),this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,r){const s=r||Jt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=parseInt(gr(r));t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}async handleSwitchChain(t){var r,s;let a=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";a=a.startsWith("0x")?a:`0x${a}`;const u=parseInt(a,16);if(this.isChainApproved(u))this.setDefaultChain(`${u}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:a}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${u}`);else throw new Error(`Failed to switch to chain 'eip155:${u}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}}class WI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class BI{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class GI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{const s=this.getCardanoRPCUrl(r),a=gr(r);t[a]=this.createHttpProvider(a,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}getCardanoRPCUrl(t){const r=this.namespace.rpcMap;if(r)return r[t]}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class QI{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class JI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class YI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(this.chainId=t,!this.httpProviders[t]){const s=r||Jt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace);return typeof s>"u"?void 0:new Dt(new Yt(s,ue("disableProviderPing")))}}var ZI=Object.defineProperty,XI=Object.defineProperties,eP=Object.getOwnPropertyDescriptors,jh=Object.getOwnPropertySymbols,tP=Object.prototype.hasOwnProperty,rP=Object.prototype.propertyIsEnumerable,Uh=(o,t,r)=>t in o?ZI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,Es=(o,t)=>{for(var r in t||(t={}))tP.call(t,r)&&Uh(o,r,t[r]);if(jh)for(var r of jh(t))rP.call(t,r)&&Uh(o,r,t[r]);return o},yo=(o,t)=>XI(o,eP(t));class Qo{constructor(t){this.events=new Ao,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Cs(Ts({level:(t==null?void 0:t.logger)||Th})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new Qo(t);return await r.initialize(),r}async request(t,r){const[s,a]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Es({},t),chainId:`${s}:${a}`,topic:this.session.topic})}sendAsync(t,r,s){const a=new Date().getTime();this.request(t,s).then(u=>r(null,xs(a,u))).catch(u=>r(u,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:ye("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}removeListener(t,r){this.events.removeListener(t,r)}off(t,r){this.events.off(t,r)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:a}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await a().then(u=>{this.session=u,this.namespaces||(this.namespaces=VI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==Il)throw u;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[s,a]=this.validateChain(t);this.getProvider(s).setDefaultChain(a,r)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(hr(r)){for(const s of r)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await wI.init({logger:this.providerOpts.logger||Th,relayUrl:this.providerOpts.relayUrl||CI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(r=>mi(r)))];go("client",this.client),go("events",this.events),go("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=kI(r,this.session),a=Sl(s),u=zI(this.namespaces,this.optionalNamespaces),l=yo(Es({},u[r]),{accounts:s,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new FI({namespace:l});break;case"solana":this.rpcProviders[r]=new WI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new BI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new KI({namespace:l});break;case"cip34":this.rpcProviders[r]=new GI({namespace:l});break;case"elrond":this.rpcProviders[r]=new QI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new JI({namespace:l});break;case"near":this.rpcProviders[r]=new YI({namespace:l});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:r}=t,{event:s}=r;if(s.name==="accountsChanged"){const a=s.data;a&&hr(a)&&this.events.emit("accountsChanged",a.map(HI))}else if(s.name==="chainChanged"){const a=r.chainId,u=r.event.data,l=mi(a),g=fo(a)!==fo(u)?`${l}:${fo(u)}`:a;this.onChainChanged(g)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var s;const{namespaces:a}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=yo(Es({},u),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:r})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",yo(Es({},ye("USER_DISCONNECTED")),{data:t.topic}))}),this.on(qt.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var r;this.getProvider(t).updateNamespace((r=this.session)==null?void 0:r.namespaces[t])})}setNamespaces(t){const{namespaces:r,optionalNamespaces:s,sessionProperties:a}=t;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=a,this.persist("namespaces",r),this.persist("optionalNamespaces",s)}validateChain(t){const[r,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,s];if(r&&!Object.keys(this.namespaces||{}).map(l=>mi(l)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&s)return[r,s];const a=mi(Object.keys(this.namespaces)[0]),u=this.rpcProviders[a].getDefaultChain();return[a,u]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var s;if(!this.namespaces)return;const[a,u]=this.validateChain(t);r||this.getProvider(a).setDefaultChain(u),((s=this.namespaces[a])!=null?s:this.namespaces[`${a}:${u}`]).defaultChain=u,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",u)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,r){this.client.core.storage.setItem(`${xh}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${xh}/${t}`)}}const iP=Qo,sP="wc",nP="ethereum_provider",oP=`${sP}@2:${nP}:`,aP="https://rpc.walletconnect.com/v1/",Co=["eth_sendTransaction","personal_sign"],cP=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],To=["chainChanged","accountsChanged"],uP=["chainChanged","accountsChanged","message","disconnect","connect"];var hP=Object.defineProperty,lP=Object.defineProperties,pP=Object.getOwnPropertyDescriptors,Mh=Object.getOwnPropertySymbols,dP=Object.prototype.hasOwnProperty,fP=Object.prototype.propertyIsEnumerable,Lh=(o,t,r)=>t in o?hP(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,_i=(o,t)=>{for(var r in t||(t={}))dP.call(t,r)&&Lh(o,r,t[r]);if(Mh)for(var r of Mh(t))fP.call(t,r)&&Lh(o,r,t[r]);return o},kh=(o,t)=>lP(o,pP(t));function Ns(o){return Number(o[0].split(":")[1])}function vo(o){return`0x${o.toString(16)}`}function gP(o){const{chains:t,optionalChains:r,methods:s,optionalMethods:a,events:u,optionalEvents:l,rpcMap:g}=o;if(!mo(t))throw new Error("Invalid chains");const w={chains:t,methods:s||Co,events:u||To,rpcMap:_i({},t.length?{[Ns(t)]:g[Ns(t)]}:{})},b=u==null?void 0:u.filter(j=>!To.includes(j)),N=s==null?void 0:s.filter(j=>!Co.includes(j));if(!r&&!l&&!a&&!(b!=null&&b.length)&&!(N!=null&&N.length))return{required:t.length?w:void 0};const S=(b==null?void 0:b.length)&&(N==null?void 0:N.length)||!r,R={chains:[...new Set(S?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(a!=null&&a.length?a:cP))],events:[...new Set(w.events.concat(l!=null&&l.length?l:uP))],rpcMap:g};return{required:t.length?w:void 0,optional:r.length?R:void 0}}class Jo{constructor(){this.events=new bt.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=oP,this.on=(t,r)=>(this.events.on(t,r),this),this.once=(t,r)=>(this.events.once(t,r),this),this.removeListener=(t,r)=>(this.events.removeListener(t,r),this),this.off=(t,r)=>(this.events.off(t,r),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const r=new Jo;return await r.initialize(t),r}async request(t){return await this.signer.request(t,this.formatChainId(this.chainId))}sendAsync(t,r){this.signer.sendAsync(t,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:r,optional:s}=gP(this.rpc);try{const a=await new Promise(async(l,g)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),g(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(kh(_i({namespaces:_i({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(b=>{l(b)}).catch(b=>{g(new Error(b.message))})});if(!a)return;const u=Bw(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:vo(this.chainId)})}catch(a){throw this.signer.logger.error(a),a}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:r}=t,{event:s}=r;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const r=parseInt(t);this.chainId=r,this.events.emit("chainChanged",vo(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",kh(_i({},Qw("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var r,s;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(s=this.modal)==null||s.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const r=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",vo(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,s,a]=t.split(":");return{chainId:`${r}:${s}`,address:a}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,s;const a=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=a.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=a.length?(t==null?void 0:t.methods)||Co:[],w=a.length?(t==null?void 0:t.events)||To:[],b=(t==null?void 0:t.optionalMethods)||[],N=(t==null?void 0:t.optionalEvents)||[],S=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),R=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(j=>this.formatChainId(j)),optionalChains:u.map(j=>this.formatChainId(j)),methods:g,events:w,optionalMethods:b,optionalEvents:N,rpcMap:S,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:R,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const s={};return t.forEach(a=>{s[a]=this.getRpcUrl(a,r)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?Ns(this.rpc.chains):Ns(this.rpc.optionalChains),this.signer=await iP.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:s}=await Sw(()=>import("./index-QCp2fK6U.js").then(a=>a.i),__vite__mapDeps([0,1,2]));r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(_i({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:r,optionalChains:s,rpcMap:a}=t;r&&mo(r)&&(this.rpc.chains=r.map(u=>this.formatChainId(u)),r.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)})),s&&mo(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(u=>this.formatChainId(u)),s.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)}))}getRpcUrl(t,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${aP}?chainId=eip155:${t}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(r=>this.parseAccount(r))}}const AP=Jo;export{AP as EthereumProvider,uP as OPTIONAL_EVENTS,cP as OPTIONAL_METHODS,To as REQUIRED_EVENTS,Co as REQUIRED_METHODS,Jo as default};
|
|
47
|
+
}`;var V=Ou(function(){return Z(d,D+"return "+O).apply(r,f)});if(V.source=O,Bn(V))throw V;return V}function Cm(e){return X(e).toLowerCase()}function Tm(e){return X(e).toUpperCase()}function xm(e,i,n){if(e=X(e),e&&(n||i===r))return qa(e);if(!e||!(i=Ke(i)))return e;var c=ct(e),h=ct(i),d=ja(c,h),f=Ua(c,h)+1;return Ft(c,d,f).join("")}function Am(e,i,n){if(e=X(e),e&&(n||i===r))return e.slice(0,La(e)+1);if(!e||!(i=Ke(i)))return e;var c=ct(e),h=Ua(c,ct(i))+1;return Ft(c,0,h).join("")}function Dm(e,i,n){if(e=X(e),e&&(n||i===r))return e.replace(Ws,"");if(!e||!(i=Ke(i)))return e;var c=ct(e),h=ja(c,ct(i));return Ft(c,h).join("")}function qm(e,i){var n=Rl,c=Nl;if(he(i)){var h="separator"in i?i.separator:h;n="length"in i?H(i.length):n,c="omission"in i?Ke(i.omission):c}e=X(e);var d=e.length;if(_r(e)){var f=ct(e);d=f.length}if(n>=d)return e;var y=n-br(c);if(y<1)return c;var m=f?Ft(f,0,y).join(""):e.slice(0,y);if(h===r)return m+c;if(f&&(y+=m.length-y),Gn(h)){if(e.slice(y).search(h)){var I,P=m;for(h.global||(h=hn(h.source,X(ia.exec(h))+"g")),h.lastIndex=0;I=h.exec(P);)var O=I.index;m=m.slice(0,O===r?y:O)}}else if(e.indexOf(Ke(h),y)!=y){var C=m.lastIndexOf(h);C>-1&&(m=m.slice(0,C))}return m+c}function jm(e){return e=X(e),e&&Wl.test(e)?e.replace(ea,hd):e}var Um=Nr(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Yn=Rc("toUpperCase");function Su(e,i,n){return e=X(e),i=n?r:i,i===r?nd(e)?dd(e):Jp(e):e.match(i)||[]}var Ou=F(function(e,i){try{return He(e,r,i)}catch(n){return Bn(n)?n:new k(n)}}),Mm=Rt(function(e,i){return Ye(i,function(n){n=mt(n),St(e,n,Fn(e[n],e))}),e});function Lm(e){var i=e==null?0:e.length,n=U();return e=i?ce(e,function(c){if(typeof c[1]!="function")throw new Ze(l);return[n(c[0]),c[1]]}):[],F(function(c){for(var h=-1;++h<i;){var d=e[h];if(He(d[0],this,c))return He(d[1],this,c)}})}function km(e){return lf(et(e,S))}function Zn(e){return function(){return e}}function zm(e,i){return e==null||e!==e?i:e}var Hm=$c(),Vm=$c(!0);function Ue(e){return e}function Xn(e){return nc(typeof e=="function"?e:et(e,S))}function Km(e){return ac(et(e,S))}function Fm(e,i){return cc(e,et(i,S))}var Wm=F(function(e,i){return function(n){return si(n,e,i)}}),Bm=F(function(e,i){return function(n){return si(e,n,i)}});function eo(e,i,n){var c=_e(i),h=Xi(i,c);n==null&&!(he(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Xi(i,_e(i)));var d=!(he(n)&&"chain"in n)||!!n.chain,f=$t(e);return Ye(h,function(y){var m=i[y];e[y]=m,f&&(e.prototype[y]=function(){var I=this.__chain__;if(d||I){var P=e(this.__wrapped__),O=P.__actions__=De(this.__actions__);return O.push({func:m,args:arguments,thisArg:e}),P.__chain__=I,P}return m.apply(e,Lt([this.value()],arguments))})}),e}function Gm(){return Ee._===this&&(Ee._=wd),this}function to(){}function Qm(e){return e=H(e),F(function(i){return uc(i,e)})}var Jm=xn(ce),Ym=xn(Ca),Zm=xn(rn);function Ru(e){return Ln(e)?sn(mt(e)):Nf(e)}function Xm(e){return function(i){return e==null?r:sr(e,i)}}var ew=Tc(),tw=Tc(!0);function ro(){return[]}function io(){return!1}function rw(){return{}}function iw(){return""}function sw(){return!0}function nw(e,i){if(e=H(e),e<1||e>Ut)return[];var n=gt,c=Se(e,gt);i=U(i),e-=gt;for(var h=an(c,i);++n<e;)i(n);return h}function ow(e){return z(e)?ce(e,mt):Fe(e)?[e]:De(Bc(X(e)))}function aw(e){var i=++vd;return X(e)+i}var cw=ns(function(e,i){return e+i},0),uw=An("ceil"),hw=ns(function(e,i){return e/i},1),lw=An("floor");function pw(e){return e&&e.length?Zi(e,Ue,mn):r}function dw(e,i){return e&&e.length?Zi(e,U(i,2),mn):r}function fw(e){return Aa(e,Ue)}function gw(e,i){return Aa(e,U(i,2))}function yw(e){return e&&e.length?Zi(e,Ue,En):r}function vw(e,i){return e&&e.length?Zi(e,U(i,2),En):r}var mw=ns(function(e,i){return e*i},1),ww=An("round"),_w=ns(function(e,i){return e-i},0);function bw(e){return e&&e.length?on(e,Ue):0}function Ew(e,i){return e&&e.length?on(e,U(i,2)):0}return p.after=Ky,p.ary=su,p.assign=Tv,p.assignIn=mu,p.assignInWith=ms,p.assignWith=xv,p.at=Av,p.before=nu,p.bind=Fn,p.bindAll=Mm,p.bindKey=ou,p.castArray=rv,p.chain=tu,p.chunk=lg,p.compact=pg,p.concat=dg,p.cond=Lm,p.conforms=km,p.constant=Zn,p.countBy=by,p.create=Dv,p.curry=au,p.curryRight=cu,p.debounce=uu,p.defaults=qv,p.defaultsDeep=jv,p.defer=Fy,p.delay=Wy,p.difference=fg,p.differenceBy=gg,p.differenceWith=yg,p.drop=vg,p.dropRight=mg,p.dropRightWhile=wg,p.dropWhile=_g,p.fill=bg,p.filter=Iy,p.flatMap=Oy,p.flatMapDeep=Ry,p.flatMapDepth=Ny,p.flatten=Yc,p.flattenDeep=Eg,p.flattenDepth=Ig,p.flip=By,p.flow=Hm,p.flowRight=Vm,p.fromPairs=Pg,p.functions=Vv,p.functionsIn=Kv,p.groupBy=$y,p.initial=Og,p.intersection=Rg,p.intersectionBy=Ng,p.intersectionWith=$g,p.invert=Wv,p.invertBy=Bv,p.invokeMap=Ty,p.iteratee=Xn,p.keyBy=xy,p.keys=_e,p.keysIn=je,p.map=ps,p.mapKeys=Qv,p.mapValues=Jv,p.matches=Km,p.matchesProperty=Fm,p.memoize=fs,p.merge=Yv,p.mergeWith=wu,p.method=Wm,p.methodOf=Bm,p.mixin=eo,p.negate=gs,p.nthArg=Qm,p.omit=Zv,p.omitBy=Xv,p.once=Gy,p.orderBy=Ay,p.over=Jm,p.overArgs=Qy,p.overEvery=Ym,p.overSome=Zm,p.partial=Wn,p.partialRight=hu,p.partition=Dy,p.pick=em,p.pickBy=_u,p.property=Ru,p.propertyOf=Xm,p.pull=Ag,p.pullAll=Xc,p.pullAllBy=Dg,p.pullAllWith=qg,p.pullAt=jg,p.range=ew,p.rangeRight=tw,p.rearg=Jy,p.reject=Uy,p.remove=Ug,p.rest=Yy,p.reverse=Vn,p.sampleSize=Ly,p.set=rm,p.setWith=im,p.shuffle=ky,p.slice=Mg,p.sortBy=Vy,p.sortedUniq=Fg,p.sortedUniqBy=Wg,p.split=Om,p.spread=Zy,p.tail=Bg,p.take=Gg,p.takeRight=Qg,p.takeRightWhile=Jg,p.takeWhile=Yg,p.tap=py,p.throttle=Xy,p.thru=ls,p.toArray=gu,p.toPairs=bu,p.toPairsIn=Eu,p.toPath=ow,p.toPlainObject=vu,p.transform=sm,p.unary=ev,p.union=Zg,p.unionBy=Xg,p.unionWith=ey,p.uniq=ty,p.uniqBy=ry,p.uniqWith=iy,p.unset=nm,p.unzip=Kn,p.unzipWith=eu,p.update=om,p.updateWith=am,p.values=Tr,p.valuesIn=cm,p.without=sy,p.words=Su,p.wrap=tv,p.xor=ny,p.xorBy=oy,p.xorWith=ay,p.zip=cy,p.zipObject=uy,p.zipObjectDeep=hy,p.zipWith=ly,p.entries=bu,p.entriesIn=Eu,p.extend=mu,p.extendWith=ms,eo(p,p),p.add=cw,p.attempt=Ou,p.camelCase=pm,p.capitalize=Iu,p.ceil=uw,p.clamp=um,p.clone=iv,p.cloneDeep=nv,p.cloneDeepWith=ov,p.cloneWith=sv,p.conformsTo=av,p.deburr=Pu,p.defaultTo=zm,p.divide=hw,p.endsWith=dm,p.eq=ht,p.escape=fm,p.escapeRegExp=gm,p.every=Ey,p.find=Py,p.findIndex=Qc,p.findKey=Uv,p.findLast=Sy,p.findLastIndex=Jc,p.findLastKey=Mv,p.floor=lw,p.forEach=ru,p.forEachRight=iu,p.forIn=Lv,p.forInRight=kv,p.forOwn=zv,p.forOwnRight=Hv,p.get=Qn,p.gt=cv,p.gte=uv,p.has=Fv,p.hasIn=Jn,p.head=Zc,p.identity=Ue,p.includes=Cy,p.indexOf=Sg,p.inRange=hm,p.invoke=Gv,p.isArguments=ar,p.isArray=z,p.isArrayBuffer=hv,p.isArrayLike=qe,p.isArrayLikeObject=fe,p.isBoolean=lv,p.isBuffer=Wt,p.isDate=pv,p.isElement=dv,p.isEmpty=fv,p.isEqual=gv,p.isEqualWith=yv,p.isError=Bn,p.isFinite=vv,p.isFunction=$t,p.isInteger=lu,p.isLength=ys,p.isMap=pu,p.isMatch=mv,p.isMatchWith=wv,p.isNaN=_v,p.isNative=bv,p.isNil=Iv,p.isNull=Ev,p.isNumber=du,p.isObject=he,p.isObjectLike=le,p.isPlainObject=hi,p.isRegExp=Gn,p.isSafeInteger=Pv,p.isSet=fu,p.isString=vs,p.isSymbol=Fe,p.isTypedArray=Cr,p.isUndefined=Sv,p.isWeakMap=Ov,p.isWeakSet=Rv,p.join=Cg,p.kebabCase=ym,p.last=rt,p.lastIndexOf=Tg,p.lowerCase=vm,p.lowerFirst=mm,p.lt=Nv,p.lte=$v,p.max=pw,p.maxBy=dw,p.mean=fw,p.meanBy=gw,p.min=yw,p.minBy=vw,p.stubArray=ro,p.stubFalse=io,p.stubObject=rw,p.stubString=iw,p.stubTrue=sw,p.multiply=mw,p.nth=xg,p.noConflict=Gm,p.noop=to,p.now=ds,p.pad=wm,p.padEnd=_m,p.padStart=bm,p.parseInt=Em,p.random=lm,p.reduce=qy,p.reduceRight=jy,p.repeat=Im,p.replace=Pm,p.result=tm,p.round=ww,p.runInContext=v,p.sample=My,p.size=zy,p.snakeCase=Sm,p.some=Hy,p.sortedIndex=Lg,p.sortedIndexBy=kg,p.sortedIndexOf=zg,p.sortedLastIndex=Hg,p.sortedLastIndexBy=Vg,p.sortedLastIndexOf=Kg,p.startCase=Rm,p.startsWith=Nm,p.subtract=_w,p.sum=bw,p.sumBy=Ew,p.template=$m,p.times=nw,p.toFinite=Ct,p.toInteger=H,p.toLength=yu,p.toLower=Cm,p.toNumber=it,p.toSafeInteger=Cv,p.toString=X,p.toUpper=Tm,p.trim=xm,p.trimEnd=Am,p.trimStart=Dm,p.truncate=qm,p.unescape=jm,p.uniqueId=aw,p.upperCase=Um,p.upperFirst=Yn,p.each=ru,p.eachRight=iu,p.first=Zc,eo(p,function(){var e={};return yt(p,function(i,n){ee.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,Ye(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Ye(["drop","take"],function(e,i){G.prototype[e]=function(n){n=n===r?1:we(H(n),0);var c=this.__filtered__&&!i?new G(this):this.clone();return c.__filtered__?c.__takeCount__=Se(n,c.__takeCount__):c.__views__.push({size:Se(n,gt),type:e+(c.__dir__<0?"Right":"")}),c},G.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ye(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==Yo||n==xl;G.prototype[e]=function(h){var d=this.clone();return d.__iteratees__.push({iteratee:U(h,3),type:n}),d.__filtered__=d.__filtered__||c,d}}),Ye(["head","last"],function(e,i){var n="take"+(i?"Right":"");G.prototype[e]=function(){return this[n](1).value()[0]}}),Ye(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");G.prototype[e]=function(){return this.__filtered__?new G(this):this[n](1)}}),G.prototype.compact=function(){return this.filter(Ue)},G.prototype.find=function(e){return this.filter(e).head()},G.prototype.findLast=function(e){return this.reverse().find(e)},G.prototype.invokeMap=F(function(e,i){return typeof e=="function"?new G(this):this.map(function(n){return si(n,e,i)})}),G.prototype.reject=function(e){return this.filter(gs(U(e)))},G.prototype.slice=function(e,i){e=H(e);var n=this;return n.__filtered__&&(e>0||i<0)?new G(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=H(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},G.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},G.prototype.toArray=function(){return this.take(gt)},yt(G.prototype,function(e,i){var n=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),h=p[c?"take"+(i=="last"?"Right":""):i],d=c||/^find/.test(i);h&&(p.prototype[i]=function(){var f=this.__wrapped__,y=c?[1]:arguments,m=f instanceof G,I=y[0],P=m||z(f),O=function(W){var Q=h.apply(p,Lt([W],y));return c&&C?Q[0]:Q};P&&n&&typeof I=="function"&&I.length!=1&&(m=P=!1);var C=this.__chain__,D=!!this.__actions__.length,M=d&&!C,V=m&&!D;if(!d&&P){f=V?f:new G(this);var L=e.apply(f,y);return L.__actions__.push({func:ls,args:[O],thisArg:r}),new Xe(L,C)}return M&&V?e.apply(this,y):(L=this.thru(O),M?c?L.value()[0]:L.value():L)})}),Ye(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ui[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);p.prototype[e]=function(){var h=arguments;if(c&&!this.__chain__){var d=this.value();return i.apply(z(d)?d:[],h)}return this[n](function(f){return i.apply(z(f)?f:[],h)})}}),yt(G.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";ee.call(Sr,c)||(Sr[c]=[]),Sr[c].push({name:i,func:n})}}),Sr[ss(r,B).name]=[{name:"wrapper",func:r}],G.prototype.clone=qd,G.prototype.reverse=jd,G.prototype.value=Ud,p.prototype.at=dy,p.prototype.chain=fy,p.prototype.commit=gy,p.prototype.next=yy,p.prototype.plant=my,p.prototype.reverse=wy,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=_y,p.prototype.first=p.prototype.head,Yr&&(p.prototype[Yr]=vy),p},Er=fd();Xt?((Xt.exports=Er)._=Er,Zs._=Er):Ee._=Er}).call(vi)})($o,$o.exports);var DI=Object.defineProperty,qI=Object.defineProperties,jI=Object.getOwnPropertyDescriptors,Ah=Object.getOwnPropertySymbols,UI=Object.prototype.hasOwnProperty,MI=Object.prototype.propertyIsEnumerable,Dh=(o,t,r)=>t in o?DI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,bs=(o,t)=>{for(var r in t||(t={}))UI.call(t,r)&&Dh(o,r,t[r]);if(Ah)for(var r of Ah(t))MI.call(t,r)&&Dh(o,r,t[r]);return o},LI=(o,t)=>qI(o,jI(t));function Jt(o,t,r){var s;const a=u_(o);return((s=t.rpcMap)==null?void 0:s[a.reference])||`${AI}?chainId=${a.namespace}:${a.reference}&projectId=${r}`}function gr(o){return o.includes(":")?o.split(":")[1]:o}function Sl(o){return o.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function kI(o,t){const r=Object.keys(t.namespaces).filter(a=>a.includes(o));if(!r.length)return[];const s=[];return r.forEach(a=>{const u=t.namespaces[a].accounts;s.push(...u)}),s}function zI(o={},t={}){const r=qh(o),s=qh(t);return $o.exports.merge(r,s)}function qh(o){var t,r,s,a;const u={};if(!jr(o))return u;for(const[l,g]of Object.entries(o)){const w=Ko(l)?[l]:g.chains,b=g.methods||[],N=g.events||[],S=g.rpcMap||{},R=mi(l);u[R]=LI(bs(bs({},u[R]),g),{chains:oo(w,(t=u[R])==null?void 0:t.chains),methods:oo(b,(r=u[R])==null?void 0:r.methods),events:oo(N,(s=u[R])==null?void 0:s.events),rpcMap:bs(bs({},S),(a=u[R])==null?void 0:a.rpcMap)})}return u}function HI(o){return o.includes(":")?o.split(":")[2]:o}function VI(o){const t={};for(const[r,s]of Object.entries(o)){const a=s.methods||[],u=s.events||[],l=s.accounts||[],g=Ko(r)?[r]:s.chains?s.chains:Sl(s.accounts);t[r]={chains:g,methods:a,events:u,accounts:l}}return t}function fo(o){return typeof o=="number"?o:o.includes("0x")?parseInt(o,16):o.includes(":")?Number(o.split(":")[1]):Number(o)}const Ol={},ue=o=>Ol[o],go=(o,t)=>{Ol[o]=t};class KI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class FI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(parseInt(t),r),this.chainId=parseInt(t),this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,r){const s=r||Jt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=parseInt(gr(r));t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}async handleSwitchChain(t){var r,s;let a=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";a=a.startsWith("0x")?a:`0x${a}`;const u=parseInt(a,16);if(this.isChainApproved(u))this.setDefaultChain(`${u}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:a}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${u}`);else throw new Error(`Failed to switch to chain 'eip155:${u}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}}class WI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class BI{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class GI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{const s=this.getCardanoRPCUrl(r),a=gr(r);t[a]=this.createHttpProvider(a,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}getCardanoRPCUrl(t){const r=this.namespace.rpcMap;if(r)return r[t]}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class QI{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class JI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class YI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(this.chainId=t,!this.httpProviders[t]){const s=r||Jt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace);return typeof s>"u"?void 0:new Dt(new Yt(s,ue("disableProviderPing")))}}var ZI=Object.defineProperty,XI=Object.defineProperties,eP=Object.getOwnPropertyDescriptors,jh=Object.getOwnPropertySymbols,tP=Object.prototype.hasOwnProperty,rP=Object.prototype.propertyIsEnumerable,Uh=(o,t,r)=>t in o?ZI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,Es=(o,t)=>{for(var r in t||(t={}))tP.call(t,r)&&Uh(o,r,t[r]);if(jh)for(var r of jh(t))rP.call(t,r)&&Uh(o,r,t[r]);return o},yo=(o,t)=>XI(o,eP(t));class Qo{constructor(t){this.events=new Ao,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Cs(Ts({level:(t==null?void 0:t.logger)||Th})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new Qo(t);return await r.initialize(),r}async request(t,r){const[s,a]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Es({},t),chainId:`${s}:${a}`,topic:this.session.topic})}sendAsync(t,r,s){const a=new Date().getTime();this.request(t,s).then(u=>r(null,xs(a,u))).catch(u=>r(u,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:ye("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}removeListener(t,r){this.events.removeListener(t,r)}off(t,r){this.events.off(t,r)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:a}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await a().then(u=>{this.session=u,this.namespaces||(this.namespaces=VI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==Il)throw u;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[s,a]=this.validateChain(t);this.getProvider(s).setDefaultChain(a,r)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(hr(r)){for(const s of r)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await wI.init({logger:this.providerOpts.logger||Th,relayUrl:this.providerOpts.relayUrl||CI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(r=>mi(r)))];go("client",this.client),go("events",this.events),go("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=kI(r,this.session),a=Sl(s),u=zI(this.namespaces,this.optionalNamespaces),l=yo(Es({},u[r]),{accounts:s,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new FI({namespace:l});break;case"solana":this.rpcProviders[r]=new WI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new BI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new KI({namespace:l});break;case"cip34":this.rpcProviders[r]=new GI({namespace:l});break;case"elrond":this.rpcProviders[r]=new QI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new JI({namespace:l});break;case"near":this.rpcProviders[r]=new YI({namespace:l});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:r}=t,{event:s}=r;if(s.name==="accountsChanged"){const a=s.data;a&&hr(a)&&this.events.emit("accountsChanged",a.map(HI))}else if(s.name==="chainChanged"){const a=r.chainId,u=r.event.data,l=mi(a),g=fo(a)!==fo(u)?`${l}:${fo(u)}`:a;this.onChainChanged(g)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var s;const{namespaces:a}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=yo(Es({},u),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:r})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",yo(Es({},ye("USER_DISCONNECTED")),{data:t.topic}))}),this.on(qt.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var r;this.getProvider(t).updateNamespace((r=this.session)==null?void 0:r.namespaces[t])})}setNamespaces(t){const{namespaces:r,optionalNamespaces:s,sessionProperties:a}=t;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=a,this.persist("namespaces",r),this.persist("optionalNamespaces",s)}validateChain(t){const[r,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,s];if(r&&!Object.keys(this.namespaces||{}).map(l=>mi(l)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&s)return[r,s];const a=mi(Object.keys(this.namespaces)[0]),u=this.rpcProviders[a].getDefaultChain();return[a,u]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var s;if(!this.namespaces)return;const[a,u]=this.validateChain(t);r||this.getProvider(a).setDefaultChain(u),((s=this.namespaces[a])!=null?s:this.namespaces[`${a}:${u}`]).defaultChain=u,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",u)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,r){this.client.core.storage.setItem(`${xh}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${xh}/${t}`)}}const iP=Qo,sP="wc",nP="ethereum_provider",oP=`${sP}@2:${nP}:`,aP="https://rpc.walletconnect.com/v1/",Co=["eth_sendTransaction","personal_sign"],cP=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],To=["chainChanged","accountsChanged"],uP=["chainChanged","accountsChanged","message","disconnect","connect"];var hP=Object.defineProperty,lP=Object.defineProperties,pP=Object.getOwnPropertyDescriptors,Mh=Object.getOwnPropertySymbols,dP=Object.prototype.hasOwnProperty,fP=Object.prototype.propertyIsEnumerable,Lh=(o,t,r)=>t in o?hP(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,_i=(o,t)=>{for(var r in t||(t={}))dP.call(t,r)&&Lh(o,r,t[r]);if(Mh)for(var r of Mh(t))fP.call(t,r)&&Lh(o,r,t[r]);return o},kh=(o,t)=>lP(o,pP(t));function Ns(o){return Number(o[0].split(":")[1])}function vo(o){return`0x${o.toString(16)}`}function gP(o){const{chains:t,optionalChains:r,methods:s,optionalMethods:a,events:u,optionalEvents:l,rpcMap:g}=o;if(!mo(t))throw new Error("Invalid chains");const w={chains:t,methods:s||Co,events:u||To,rpcMap:_i({},t.length?{[Ns(t)]:g[Ns(t)]}:{})},b=u==null?void 0:u.filter(j=>!To.includes(j)),N=s==null?void 0:s.filter(j=>!Co.includes(j));if(!r&&!l&&!a&&!(b!=null&&b.length)&&!(N!=null&&N.length))return{required:t.length?w:void 0};const S=(b==null?void 0:b.length)&&(N==null?void 0:N.length)||!r,R={chains:[...new Set(S?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(a!=null&&a.length?a:cP))],events:[...new Set(w.events.concat(l!=null&&l.length?l:uP))],rpcMap:g};return{required:t.length?w:void 0,optional:r.length?R:void 0}}class Jo{constructor(){this.events=new bt.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=oP,this.on=(t,r)=>(this.events.on(t,r),this),this.once=(t,r)=>(this.events.once(t,r),this),this.removeListener=(t,r)=>(this.events.removeListener(t,r),this),this.off=(t,r)=>(this.events.off(t,r),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const r=new Jo;return await r.initialize(t),r}async request(t){return await this.signer.request(t,this.formatChainId(this.chainId))}sendAsync(t,r){this.signer.sendAsync(t,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:r,optional:s}=gP(this.rpc);try{const a=await new Promise(async(l,g)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),g(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(kh(_i({namespaces:_i({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(b=>{l(b)}).catch(b=>{g(new Error(b.message))})});if(!a)return;const u=Bw(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:vo(this.chainId)})}catch(a){throw this.signer.logger.error(a),a}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:r}=t,{event:s}=r;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const r=parseInt(t);this.chainId=r,this.events.emit("chainChanged",vo(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",kh(_i({},Qw("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var r,s;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(s=this.modal)==null||s.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const r=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",vo(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,s,a]=t.split(":");return{chainId:`${r}:${s}`,address:a}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,s;const a=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=a.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=a.length?(t==null?void 0:t.methods)||Co:[],w=a.length?(t==null?void 0:t.events)||To:[],b=(t==null?void 0:t.optionalMethods)||[],N=(t==null?void 0:t.optionalEvents)||[],S=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),R=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(j=>this.formatChainId(j)),optionalChains:u.map(j=>this.formatChainId(j)),methods:g,events:w,optionalMethods:b,optionalEvents:N,rpcMap:S,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:R,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const s={};return t.forEach(a=>{s[a]=this.getRpcUrl(a,r)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?Ns(this.rpc.chains):Ns(this.rpc.optionalChains),this.signer=await iP.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:s}=await Sw(()=>import("./index-D2LZykJf.js").then(a=>a.i),__vite__mapDeps([0,1,2]));r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(_i({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:r,optionalChains:s,rpcMap:a}=t;r&&mo(r)&&(this.rpc.chains=r.map(u=>this.formatChainId(u)),r.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)})),s&&mo(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(u=>this.formatChainId(u)),s.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)}))}getRpcUrl(t,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${aP}?chainId=eip155:${t}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(r=>this.parseAccount(r))}}const AP=Jo;export{AP as EthereumProvider,uP as OPTIONAL_EVENTS,cP as OPTIONAL_METHODS,To as REQUIRED_EVENTS,Co as REQUIRED_METHODS,Jo as default};
|