@wormhole-foundation/wormhole-connect 3.0.0-beta.7-development → 3.0.0-beta.9-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/main.js +48 -48
- package/dist/src/config/tokens.d.ts +0 -1
- package/dist/src/config/tokens.d.ts.map +1 -1
- package/dist/src/contexts/TokensContext.d.ts.map +1 -1
- package/dist/src/utils/errors.d.ts +1 -0
- package/dist/src/utils/errors.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/WalletConnector/Sidebar.d.ts.map +1 -1
- package/dist/src/views/v2/Redeem/TransactionDetails/index.d.ts.map +1 -1
- package/lib/{account-QG_Hi4er.js → account-BSFuCEgk.js} +1 -1
- package/lib/{account-BK8xMTUI.mjs → account-y1ICRMSr.mjs} +1 -1
- package/lib/{address-B-_yHNB2.js → address-BwcXVurJ.js} +1 -1
- package/lib/{address-CNhzoegm.js → address-D8qNQEOW.js} +1 -1
- package/lib/{address-BWXkejmE.mjs → address-DaoiwqzU.mjs} +1 -1
- package/lib/{address-RcMobNYE.js → address-DnSRsubO.js} +7 -7
- package/lib/{address-CBux52Na.mjs → address-DqsMcbcT.mjs} +612 -588
- package/lib/{address-DKHa7TFU.mjs → address-S7wMItHX.mjs} +1 -1
- package/lib/{aptos-9aq-5gkF.mjs → aptos-CSVdIYqJ.mjs} +3 -3
- package/lib/{aptos-XxKO9242.js → aptos-C_j04MF5.js} +1 -1
- package/lib/{aptos-C180o9od.mjs → aptos-C_sLjrbm.mjs} +15 -15
- package/lib/{aptos-BZ2mcuTd.js → aptos-ma6bumqy.js} +2 -2
- package/lib/{base64-Dmj19Uvu.mjs → base64-B2xumR3a.mjs} +3 -2
- package/lib/{base64-BfY07bq5.js → base64-a1Dr6hMt.js} +1 -1
- package/lib/{blake2b-CgbIfNRX.mjs → blake2b-CR50AGep.mjs} +1 -1
- package/lib/{blake2b-CoM94_cH.js → blake2b-Dkm1d7Wp.js} +1 -1
- package/lib/{browser-ponyfill-BAEAyXvw.js → browser-ponyfill-BTt_ELXG.js} +1 -1
- package/lib/{browser-ponyfill-BecG2Lnb.mjs → browser-ponyfill-uCX78ltK.mjs} +1 -1
- package/lib/{ccip-CUqskd5M.mjs → ccip-69mFHkV9.mjs} +1 -1
- package/lib/{ccip-oytFtCzk.js → ccip-BFyWlloE.js} +1 -1
- package/lib/{chain-itK5uGYL.js → chain-Cio41-Lr.js} +1 -1
- package/lib/{chain-sKZNJgPZ.mjs → chain-DbmG-oEQ.mjs} +1 -1
- package/lib/{chunk-IMTC3J2M-DKLPKqnP.mjs → chunk-IMTC3J2M-CmFt3nz5.mjs} +137 -135
- package/lib/chunk-IMTC3J2M-NMBEZ4p8.js +471 -0
- package/lib/{constants-DrDsewBe.mjs → constants-JcrZQeMq.mjs} +3 -3
- package/lib/{constants-Bmrui4ZY.js → constants-lsjPx3va.js} +1 -1
- package/lib/{contract-MJZ8ZoSX.js → contract-CcVq6MSa.js} +1 -1
- package/lib/{contract-BVaUamai.mjs → contract-DrK81GRi.mjs} +109 -109
- package/lib/create-BtJgfMdJ.mjs +18 -0
- package/lib/{create-DO_-1_Hb.js → create-Q6N34YQz.js} +1 -1
- package/lib/{evm-IjnSHeSg.mjs → evm--hXXT-db.mjs} +9 -9
- package/lib/{evm-C-aa4dBG.mjs → evm-BBqhcxFC.mjs} +83 -83
- package/lib/{evm-D_r84vhS.js → evm-CNq2zXwl.js} +3 -3
- package/lib/{evm-ZSzF-61X.js → evm-l0300AWS.js} +2 -2
- package/lib/executor.js +470 -1
- package/lib/executor.mjs +7106 -560
- package/lib/hosted.js +1 -1
- package/lib/hosted.mjs +1 -1
- package/lib/{index-aA-2Ygs3.mjs → index-98w8rrCe.mjs} +1 -1
- package/lib/{index-Bb8InrQU.mjs → index-9dr91dtY.mjs} +2 -2
- package/lib/{index-DNaxNpBa.js → index-BABC5__9.js} +1 -1
- package/lib/{index-CapdlI6H.js → index-BAjc-UZH.js} +1 -1
- package/lib/{index-Cx-ODuWg.mjs → index-BN-aj3dN.mjs} +4 -4
- package/lib/{index-BeQ668oT.js → index-BV7XVrd8.js} +1 -1
- package/lib/{index-CKaF7Gzs.mjs → index-BbUxOO56.mjs} +14 -14
- package/lib/{index-D3cDkU4S.js → index-BfPE3vDw.js} +1 -1
- package/lib/{index-Batb-GTa.mjs → index-BlCHxlUD.mjs} +5 -5
- package/lib/{index-CZYUYK5K.js → index-BnCQiOiA.js} +1 -1
- package/lib/{index-CsdQttEt.mjs → index-BqmCeCU_.mjs} +5 -5
- package/lib/{index-Ce0EI1tW.mjs → index-BtrXSq3R.mjs} +5 -5
- package/lib/{index-CE0rxdUf.js → index-C-ORpsiU.js} +1 -1
- package/lib/{index-DyE-3pz1.js → index-C0un9IYm.js} +1 -1
- package/lib/{index-DdvRmaTh.mjs → index-C4HPXgbm.mjs} +7 -7
- package/lib/{index-DgIxcujP.mjs → index-COkYtNvE.mjs} +36 -36
- package/lib/{index-CLy98PXT.mjs → index-COs6VyCx.mjs} +13 -13
- package/lib/{index-43m4zMem.js → index-COsUDXFI.js} +1 -1
- package/lib/{index-B36we0ml.mjs → index-CUYHyKgr.mjs} +7 -7
- package/lib/{index-BcAXCy1h.js → index-CUyxr8OX.js} +1 -1
- package/lib/{index-DDBLdcME.mjs → index-CX0qxE9A.mjs} +11 -11
- package/lib/{index-C2Pe6i5V.js → index-CiFTvTwg.js} +1 -1
- package/lib/{index-DNcx7dMI.mjs → index-CofxOTyV.mjs} +5 -5
- package/lib/{index-BGqRY1Ww.js → index-CsR_y9ji.js} +1 -1
- package/lib/{index-CA5XKv-J.js → index-CuoxLyOv.js} +1 -1
- package/lib/{index-DRCX2iXw.js → index-CvEfOpn2.js} +1 -1
- package/lib/{index-CV3K6bKD.js → index-Cxwfq1al.js} +1 -1
- package/lib/{index-CjroDahP.mjs → index-D0tl0B36.mjs} +2 -2
- package/lib/{index-f_27F6WX.js → index-D4KtQtgE.js} +1 -1
- package/lib/{index-D2o0FZvZ.js → index-D74ZE0n9.js} +1 -1
- package/lib/{index-DkZjpCle.js → index-DLFGcXjy.js} +1 -1
- package/lib/{index-07cEoDZD.mjs → index-DNvr2HlM.mjs} +13 -13
- package/lib/{index-Cu7gFSJv.mjs → index-DPfKYdEf.mjs} +1 -1
- package/lib/{index-Bogu114a.js → index-Db3GFx2x.js} +1 -1
- package/lib/{index-Dt-63Ecw.js → index-DbJV-Hi3.js} +1 -1
- package/lib/{index-B-S6avdv.js → index-DebLDCcs.js} +1 -1
- package/lib/{index-DC1ot7tO.js → index-DjbQ-yfQ.js} +1 -1
- package/lib/{index-Cry2AYTm.mjs → index-DsKRmXnW.mjs} +3 -3
- package/lib/{index-FCA-cXcS.js → index-DtUeWT1n.js} +1 -1
- package/lib/{index-DyvQhGPY.mjs → index-DtfwfGsA.mjs} +2 -2
- package/lib/{index-DDBdrN7Y.mjs → index-DvozGHS-.mjs} +7070 -7093
- package/lib/{index-Cyo0tNu5.mjs → index-Dx7nqevs.mjs} +2 -2
- package/lib/{index-Blzzdktm.js → index-LJw0S70V.js} +1 -1
- package/lib/{index-rAnJYuJr.mjs → index-Nh2mSVy3.mjs} +9 -9
- package/lib/{index-B5XhLD_L.mjs → index-S_O9ybUy.mjs} +5 -5
- package/lib/{index-CIhJm6vf.js → index-S_dcknx7.js} +86 -86
- package/lib/{index-Dsaj5lf_.js → index-U1ceHkB6.js} +1 -1
- package/lib/{index-BUlzgqNa.mjs → index-Yp3NfcfI.mjs} +4 -4
- package/lib/{index-DRleG63r.mjs → index-Z48MvcFr.mjs} +1 -1
- package/lib/{index-B9hin5U8.mjs → index-ejTR4WLF.mjs} +5 -5
- package/lib/{index-BUfjw4S2.mjs → index-kyD2rWx8.mjs} +11 -11
- package/lib/{index-BL4H4RbP.js → index-lG1-neJv.js} +1 -1
- package/lib/{index-CuDLHfKb.mjs → index-sz4KACqf.mjs} +5 -5
- package/lib/{index-dpkTW-H8.js → index-vIUqmO0o.js} +1 -1
- package/lib/{index.es-MXzok_Dp.js → index.es-C4RhqFy8.js} +2 -2
- package/lib/{index.es-C6ziEcYX.mjs → index.es-D5O0G4Af.mjs} +7 -7
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/mayan.js +1 -1
- package/lib/mayan.mjs +10 -10
- package/lib/{mint-C3SdQH_S.mjs → mint-CKsi-DrV.mjs} +2 -2
- package/lib/{mint-BxtkCWBh.js → mint-DNcbNuI1.js} +1 -1
- package/lib/ntt.js +1 -1
- package/lib/ntt.mjs +10 -10
- package/lib/{platform-Czq0KkFa.mjs → platform-BCxJ-CNM.mjs} +7 -7
- package/lib/{platform-CG_VHRJU.js → platform-BqUizEYV.js} +1 -1
- package/lib/{platform-CUeBR_i4.mjs → platform-CB3TPh7I.mjs} +17 -17
- package/lib/{platform-CyTWPtDR.js → platform-CGIgJRY3.js} +1 -1
- package/lib/{platform-PNwsacZi.js → platform-D7pe3gG2.js} +1 -1
- package/lib/{platform-Droe0nZu.mjs → platform-DTVt42uH.mjs} +4 -4
- package/lib/provider-jsonrpc-DYBOGqdj.js +1 -0
- package/lib/{provider-jsonrpc-CVWSLk8g.mjs → provider-jsonrpc-MOE1VIOF.mjs} +155 -155
- package/lib/{sha3-BMK6V2DM.mjs → sha3-BZUtvEPh.mjs} +1 -1
- package/lib/{sha3-uufRWTnZ.js → sha3-c6o5MDKC.js} +1 -1
- package/lib/{signer-L9IdBy4K.js → signer-BAFbrQDv.js} +1 -1
- package/lib/{signer-CYkXKdE1.mjs → signer-CwtXMDcn.mjs} +25 -25
- package/lib/solana-Cg0N1W8e.js +1 -0
- package/lib/{solana-iU2xZ6yu.js → solana-DIO5mbHM.js} +1 -1
- package/lib/{solana-CE7DDmW7.mjs → solana-Dr5BmG1x.mjs} +6 -6
- package/lib/solana-mJ922Ek9.mjs +18 -0
- package/lib/{solanaEmbed.esm-BtaI5pum.mjs → solanaEmbed.esm-C4t2kCSL.mjs} +3 -3
- package/lib/{solanaEmbed.esm-DUsdVcC-.js → solanaEmbed.esm-D0xXx6VI.js} +1 -1
- package/lib/src/config/tokens.d.ts +0 -1
- package/lib/src/config/tokens.d.ts.map +1 -1
- package/lib/src/contexts/TokensContext.d.ts.map +1 -1
- package/lib/src/utils/errors.d.ts +1 -0
- package/lib/src/utils/errors.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/WalletConnector/Sidebar.d.ts.map +1 -1
- package/lib/src/views/v2/Redeem/TransactionDetails/index.d.ts.map +1 -1
- package/lib/{sui-BIE_b_7o.mjs → sui-AbsMI4yt.mjs} +3 -3
- package/lib/{sui-CNPKXqM6.js → sui-BSJIqJNt.js} +1 -1
- package/lib/{sui-Dva2w10T.js → sui-Bzh8kAZm.js} +1 -1
- package/lib/{sui-BJsKaZg2.mjs → sui-CZTSBdD4.mjs} +16 -16
- package/lib/{tokens-D4usSvOD.js → tokens-BUeRxOcP.js} +1 -1
- package/lib/{tokens-CQnhplD_.mjs → tokens-Vm--egzg.mjs} +4 -4
- package/lib/{units-CPUigdwl.js → units-LPlUOt3D.js} +1 -1
- package/lib/{units-YkCOGDr9.mjs → units-b10-QTSu.mjs} +28 -28
- package/lib/{unsignedTransaction-C0WXQMmv.mjs → unsignedTransaction-BJw0T6uN.mjs} +28 -28
- package/lib/{unsignedTransaction-DFUF8DSp.js → unsignedTransaction-CIkLJt6N.js} +1 -1
- package/lib/{web3-B3Usc-Qj.mjs → web3-BHuP7CTp.mjs} +7 -7
- package/lib/{web3-CjTx3huW.js → web3-SO_UBSxv.js} +1 -1
- package/package.json +2 -2
- package/lib/chunk-IMTC3J2M-D-un3eDX.js +0 -471
- package/lib/create-CQ6n4Ga8.mjs +0 -18
- package/lib/provider-jsonrpc-1gjszS3Q.js +0 -1
- package/lib/solana-BRQmi9BN.js +0 -1
- package/lib/solana-Bs7_C3BS.mjs +0 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Me=Object.defineProperty;var Ie=(r,e,t)=>e in r?Me(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>Ie(r,typeof e!="symbol"?e+"":e,t);const i=require("./address-RcMobNYE.js"),m=require("./index-FCA-cXcS.js"),p=require("./account-QG_Hi4er.js"),X=require("./unsignedTransaction-DFUF8DSp.js"),Ee=require("./create-DO_-1_Hb.js"),Pe=require("./chain-itK5uGYL.js"),O=new i.PublicKey("BPFLoaderUpgradeab1e11111111111111111111111");function te(r){return p.deriveAddress([new i.PublicKey(r).toBuffer()],O)}class Be extends Error{constructor(e){super(e),this.name="IdlError"}}function Y(r,e){switch(e.type.kind){case"struct":return e.type.fields.map(t=>M(r,t.type)).reduce((t,n)=>t+n,0);case"enum":{const t=e.type.variants.map(n=>n.fields?n.fields.map(s=>typeof s=="object"&&"name"in s?M(r,s.type):M(r,s)).reduce((s,a)=>s+a,0):0);return Math.max(...t)+1}case"alias":return M(r,e.type.value)}}function M(r,e){var t;switch(e){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"publicKey":return 32;default:if("vec"in e)return 1;if("option"in e)return 1+M(r,e.option);if("coption"in e)return 4+M(r,e.coption);if("defined"in e){const n=((t=r.types)==null?void 0:t.filter(a=>a.name===e.defined))??[];if(n.length!==1)throw new Be(`Type not found: ${JSON.stringify(e)}`);let s=n[0];return Y(r,s)}if("array"in e){let n=e.array[0],s=e.array[1];return M(r,n)*s}throw new Error(`Invalid type ${JSON.stringify(e)}`)}}function L(r){return r.replace(/(?:^\w|[A-Z]|\b\w)/g,function(e,t){return t===0?e.toLowerCase():e.toUpperCase()}).replace(/[\s\-_]+/g,"")}function xe(r){return r.charAt(0).toUpperCase()+r.slice(1)}const ne=[{name:"discriminator",binary:"bytes",size:4},{name:"consistencyLevel",binary:"uint",size:1,endianness:"little"},{name:"emitterAuthority",...i.universalAddressItem},{name:"messageStatus",binary:"uint",size:1,endianness:"little"},{name:"gap",binary:"uint",size:3},{name:"timestamp",binary:"uint",size:4,endianness:"little"},{name:"nonce",binary:"uint",size:4,endianness:"little"},{name:"sequence",binary:"uint",size:8,endianness:"little"},{name:"emitterChain",binary:"uint",size:2,endianness:"little"},{name:"emitterAddress",...i.universalAddressItem},{name:"payloadLength",binary:"uint",size:4,endianness:"little"},{name:"payload",binary:"bytes"}];function re(r){return i.deserialize$1(ne,r)}function E(r,e,t,n){const s=typeof e=="string"?i.dist.Buffer.from(e,"hex"):i.dist.Buffer.from(e);if(s.length!=32)throw Error("address.length != 32");const a=i.dist.Buffer.alloc(8);return a.writeBigUInt64BE(typeof n=="number"?BigInt(n):n),p.deriveAddress([s,(()=>{const o=i.dist.Buffer.alloc(2);return o.writeUInt16BE(t),o})(),a],r)}async function se(r,e,t,n,s,a){return r.getAccountInfo(E(e,t,n,s),a).then(o=>!!p.getAccountData(o)[0])}function h(r){return p.deriveAddress([i.dist.Buffer.from("Bridge")],r)}async function ie(r,e,t){return r.getAccountInfo(h(e),t).then(n=>k.deserialize(p.getAccountData(n)))}class v{constructor(e,t){c(this,"guardianSetExpirationTime");c(this,"fee");this.guardianSetExpirationTime=e,this.fee=t}static deserialize(e){if(e.length!=12)throw new Error("data.length != 12");const t=e.readUInt32LE(0),n=e.readBigUInt64LE(4);return new v(t,n)}}class k{constructor(e,t,n){c(this,"guardianSetIndex");c(this,"lastLamports");c(this,"config");this.guardianSetIndex=e,this.lastLamports=t,this.config=n}static deserialize(e){if(e.length!=24)throw new Error("data.length != 24");const t=e.readUInt32LE(0),n=e.readBigUInt64LE(4),s=v.deserialize(e.subarray(12));return new k(t,n,s)}}function C(r,e){return p.deriveAddress([i.dist.Buffer.from("Sequence"),new i.PublicKey(r).toBytes()],e)}async function ae(r,e,t,n){return r.getAccountInfo(C(e,t),n).then(s=>z.deserialize(p.getAccountData(s)))}class z{constructor(e,t,n){c(this,"sequence");c(this,"bump");c(this,"emitterType");this.sequence=e,this.bump=t,this.emitterType=n}static deserialize(e){if(e.length!==8&&e.length!==10)throw new Error("data.length != 8 or data.length != 10");let t,n;const s=e.readBigUInt64LE(0);return e.length===10&&(t=e[8],n=e[9]),new z(s,t,n)}value(){return this.sequence}}function q(r){return p.deriveAddress([i.dist.Buffer.from("emitter")],r)}function N(r,e){const t=q(r);return{emitter:t,sequence:C(t,e)}}async function oe(r,e,t,n){return ae(r,q(e),t,n)}function P(r){return p.deriveAddress([i.dist.Buffer.from("fee_collector")],r)}const Z=65,U=20;function Ke(r,e,t){return new i.TransactionInstruction({keys:[],programId:i.Secp256k1Program.programId,data:Le.serialize(r,e,t)})}class Le{static serialize(e,t,n){if(e.length==0)throw Error("signatures.length == 0");if(e.length!=t.length)throw Error("signatures.length != keys.length");if(n.length!=32)throw Error("message.length != 32");const s=e.length,a=11,o=1+s*a,u=Z+U,d=o+s*u,f=32,g=i.dist.Buffer.alloc(d+f);g.writeUInt8(s,0),g.write(n.toString("hex"),d,"hex");for(let l=0;l<s;++l){const y=e.at(l);if((y==null?void 0:y.length)!=Z)throw Error(`signatures[${l}].length != 65`);const S=t.at(l);if((S==null?void 0:S.length)!=U)throw Error(`keys[${l}].length != 20`);const A=o+u*l,K=A+65;g.writeUInt16LE(A,1+l*a),g.writeUInt8(0,3+l*a),g.writeUInt16LE(K,4+l*a),g.writeUInt8(0,6+l*a),g.writeUInt16LE(d,7+l*a),g.writeUInt16LE(f,9+l*a),g.writeUInt8(0,10+l*a),g.write(y.toString("hex"),A,"hex"),g.write(S.toString("hex"),K,"hex")}return g}}function I(r,e){return p.deriveAddress([i.dist.Buffer.from("GuardianSet"),(()=>{const t=i.dist.Buffer.alloc(4);return t.writeUInt32BE(e),t})()],r)}async function G(r,e,t,n){return r.getAccountInfo(I(e,t),n).then(s=>V.deserialize(p.getAccountData(s)))}class V{constructor(e,t,n,s){c(this,"index");c(this,"keys");c(this,"creationTime");c(this,"expirationTime");this.index=e,this.keys=t,this.creationTime=n,this.expirationTime=s}static deserialize(e){const t=e.readUInt32LE(0),n=e.readUInt32LE(4),s=8+n*U,a=e.readUInt32LE(s),o=e.readUInt32LE(4+s),u=[];for(let d=0;d<n;++d){const f=8+d*U;u.push(e.subarray(f,f+U))}return new V(t,u,a,o)}}function b(r,e){return p.deriveAddress([i.dist.Buffer.from("PostedVAA"),e],r)}async function Ue(r,e,t){return r.getAccountInfo(new i.PublicKey(e),t).then(n=>D.deserialize(p.getAccountData(n)))}class D{constructor(e,t,n){c(this,"signatures");c(this,"hash");c(this,"guardianSetIndex");this.signatures=e,this.hash=t,this.guardianSetIndex=n}static deserialize(e){const t=e.readUInt32LE(0),n=[...e.subarray(4,4+t)].map(u=>u!=0),s=4+t,a=e.subarray(s,s+32),o=e.readUInt32LE(s+32);return new D(n,a,o)}}function $(r){return p.deriveAddress([i.dist.Buffer.from("upgrade")],r)}function W(r,e,t){return i.SystemProgram.transfer({fromPubkey:new i.PublicKey(e),toPubkey:P(r),lamports:t})}class Ce{constructor(e){c(this,"idl");this.idl=e}async encode(e,t){switch(e){default:throw new Error(`Invalid account name: ${e}`)}}decode(e,t){return this.decodeUnchecked(e,t)}decodeUnchecked(e,t){switch(e){default:throw new Error(`Invalid account name: ${e}`)}}memcmp(e,t){switch(e){case"postVaa":return{dataSize:56};default:throw new Error(`Invalid account name: ${e}`)}}size(e){return Y(this.idl,e)??0}}class _e{constructor(e){}decode(e){throw new Error("Wormhole program does not have events")}}class B{static fieldLayout(e,t){const n=e.name!==void 0?L(e.name):void 0;switch(e.type){case"bool":return m.dist.bool(n);case"u8":return m.dist.u8(n);case"i8":return m.dist.i8(n);case"u16":return m.dist.u16(n);case"i16":return m.dist.i16(n);case"u32":return m.dist.u32(n);case"i32":return m.dist.i32(n);case"f32":return m.dist.f32(n);case"u64":return m.dist.u64(n);case"i64":return m.dist.i64(n);case"f64":return m.dist.f64(n);case"u128":return m.dist.u128(n);case"i128":return m.dist.i128(n);case"u256":return m.dist.u256(n);case"i256":return m.dist.i256(n);case"bytes":return m.dist.vecU8(n);case"string":return m.dist.str(n);case"publicKey":return m.dist.publicKey(n);default:{if("vec"in e.type)return m.dist.vec(B.fieldLayout({name:void 0,type:e.type.vec},t),n);if("option"in e.type)return m.dist.option(B.fieldLayout({name:void 0,type:e.type.option},t),n);if("array"in e.type){let s=e.type.array[0],a=e.type.array[1],o=B.fieldLayout({name:void 0,type:s},t);return m.dist.array(o,a,n)}else throw new Error(`Not yet implemented: ${e}`)}}}}class j{constructor(e){c(this,"ixLayout");this.ixLayout=j.parseIxLayout(e)}static parseIxLayout(e){const n=(e.instructions?e.instructions:[]).map(s=>{let a=s.args.map(u=>B.fieldLayout(u,Array.from([...e.accounts??[],...e.types??[]])));const o=L(s.name);return[o,m.dist.struct(a,o)]}).concat(e.instructions.map(s=>{let a=s.args.map(u=>B.fieldLayout(u,Array.from([...e.accounts??[],...e.types??[]])));const o=L(s.name);return[o,m.dist.struct(a,o)]}));return new Map(n)}encode(e,t){const n=i.dist.Buffer.alloc(1e3),s=L(e),a=this.ixLayout.get(s);if(!a)throw new Error(`Unknown method: ${s}`);const o=a.encode(t,n),u=n.slice(0,o);return Te(T[xe(s)],u)}encodeState(e,t){throw new Error("Wormhole program does not have state")}decode(e,t="hex"){var u;typeof e=="string"&&(e=t==="hex"?i.dist.Buffer.from(e,"hex"):i.b58.decode(e));let n=i.dist.Buffer.from(e.slice(0,1)).readInt8(),s=i.dist.Buffer.from(e.slice(1)),a=L(T[n]??"");return this.ixLayout.get(a)?{data:(u=this.ixLayout.get(a))==null?void 0:u.decode(s),name:a}:null}}var T;(function(r){r[r.Initialize=0]="Initialize",r[r.PostMessage=1]="PostMessage",r[r.PostVaa=2]="PostVaa",r[r.SetFees=3]="SetFees",r[r.TransferFees=4]="TransferFees",r[r.UpgradeContract=5]="UpgradeContract",r[r.UpgradeGuardianSet=6]="UpgradeGuardianSet",r[r.VerifySignatures=7]="VerifySignatures",r[r.PostMessageUnreliable=8]="PostMessageUnreliable"})(T||(T={}));function Te(r,e){const t=i.dist.Buffer.alloc(1+(e===void 0?0:e.length));return t.writeUInt8(r,0),e!==void 0&&t.write(e.toString("hex"),1,"hex"),t}class ve{constructor(e){}encode(e,t){throw new Error("Wormhole program does not have state")}decode(e){throw new Error("Wormhole program does not have state")}}class ke{constructor(e){}encode(e,t){throw new Error("Wormhole program does not have user-defined types")}decode(e,t){throw new Error("Wormhole program does not have user-defined types")}}class ze{constructor(e){c(this,"instruction");c(this,"accounts");c(this,"state");c(this,"events");c(this,"types");this.instruction=new j(e),this.accounts=new Ce(e),this.state=new ve(e),this.events=new _e(e),this.types=new ke(e)}}const H={version:"0.1.0",name:"wormhole",instructions:[{name:"initialize",accounts:[{name:"bridge",isMut:!0,isSigner:!1},{name:"guardianSet",isMut:!0,isSigner:!1},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"guardianSetExpirationTime",type:"u32"},{name:"fee",type:"u64"},{name:"initialGuardians",type:{vec:{array:["u8",20]}}}]},{name:"postMessage",accounts:[{name:"bridge",isMut:!0,isSigner:!1},{name:"message",isMut:!0,isSigner:!0},{name:"emitter",isMut:!1,isSigner:!0},{name:"sequence",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"payload",type:"bytes"},{name:"consistencyLevel",type:"u8"}]},{name:"postVaa",accounts:[{name:"guardianSet",isMut:!1,isSigner:!1},{name:"bridge",isMut:!1,isSigner:!1},{name:"signatureSet",isMut:!1,isSigner:!1},{name:"vaa",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"version",type:"u8"},{name:"guardianSetIndex",type:"u32"},{name:"timestamp",type:"u32"},{name:"nonce",type:"u32"},{name:"emitterChain",type:"u16"},{name:"emitterAddress",type:{array:["u8",32]}},{name:"sequence",type:"u64"},{name:"consistencyLevel",type:"u8"},{name:"payload",type:"bytes"}]},{name:"setFees",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"transferFees",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"recipient",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"upgradeContract",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"upgradeAuthority",isMut:!1,isSigner:!1},{name:"spill",isMut:!0,isSigner:!1},{name:"implementation",isMut:!0,isSigner:!1},{name:"programData",isMut:!0,isSigner:!1},{name:"wormholeProgram",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"bpfLoaderUpgradeable",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"upgradeGuardianSet",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"guardianSetOld",isMut:!0,isSigner:!1},{name:"guardianSetNew",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"verifySignatures",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"guardianSet",isMut:!1,isSigner:!1},{name:"signatureSet",isMut:!0,isSigner:!0},{name:"instructions",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"signatureStatus",type:{array:["i8",19]}}]},{name:"postMessageUnreliable",accounts:[{name:"bridge",isMut:!0,isSigner:!1},{name:"message",isMut:!0,isSigner:!0},{name:"emitter",isMut:!1,isSigner:!0},{name:"sequence",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"payload",type:"bytes"},{name:"consistencyLevel",type:"u8"}]}],accounts:[{name:"PostedMessage",type:{kind:"struct",fields:[{name:"vaaVersion",type:"u8"},{name:"consistencyLevel",type:"u8"},{name:"vaaTime",type:"u32"},{name:"vaaSignatureAccount",type:"publicKey"},{name:"submissionTime",type:"u32"},{name:"nonce",type:"u32"},{name:"sequence",type:"u64"},{name:"emitterChain",type:"u16"},{name:"emitterAddress",type:{array:["u8",32]}},{name:"payload",type:"bytes"}]}},{name:"PostedVAA",type:{kind:"struct",fields:[{name:"vaaVersion",type:"u8"},{name:"consistencyLevel",type:"u8"},{name:"vaaTime",type:"u32"},{name:"vaaSignatureAccount",type:"publicKey"},{name:"submissionTime",type:"u32"},{name:"nonce",type:"u32"},{name:"sequence",type:"u64"},{name:"emitterChain",type:"u16"},{name:"emitterAddress",type:{array:["u8",32]}},{name:"payload",type:"bytes"}]}}]};function ue(r,e){return new m.Program(H,new i.PublicKey(r),e===void 0?{connection:null}:e,ce())}function w(r,e){return ue(r,m.createReadOnlyProvider(e))}function ce(){return new ze(H)}function qe(r,e,t,n){const s=w(e,r).methods.setFees();return s._ixFn(...s._args,{accounts:de(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function de(r,e,t){return{payer:new i.PublicKey(e),bridge:h(r),vaa:b(r,i.dist.Buffer.from(t.hash)),claim:E(r,t.emitterAddress.toString(),i.toChainId(t.emitterChain),t.sequence),systemProgram:i.SystemProgram.programId}}function Ve(r,e,t,n,s){const a=w(e,r).methods.transferFees();return a._ixFn(...a._args,{accounts:ge(e,t,n,s),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function ge(r,e,t,n){return{payer:new i.PublicKey(e),bridge:h(r),vaa:b(r,i.dist.Buffer.from(n.hash)),claim:E(r,n.emitterAddress.toString(),i.toChainId(n.emitterChain),n.sequence),feeCollector:P(r),recipient:new i.PublicKey(t),rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function De(r,e,t,n){const s=w(e,r).methods.upgradeGuardianSet();return s._ixFn(...s._args,{accounts:fe(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function fe(r,e,t){return{payer:new i.PublicKey(e),bridge:h(r),vaa:b(r,i.dist.Buffer.from(t.hash)),claim:E(r,t.emitterAddress.toString(),i.toChainId(t.emitterChain),t.sequence),guardianSetOld:I(r,t.guardianSet),guardianSetNew:I(r,t.guardianSet+1),systemProgram:i.SystemProgram.programId}}function Fe(r,e,t,n){const s=w(e,r).methods.upgradeContract();return s._ixFn(...s._args,{accounts:me(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function me(r,e,t,n){const{newContract:s}=t.payload.actionArgs;return{payer:new i.PublicKey(e),bridge:h(r),vaa:b(r,i.dist.Buffer.from(t.hash)),claim:E(r,t.emitterAddress.toString(),i.toChainId(t.emitterChain),t.sequence),upgradeAuthority:$(r),spill:new i.PublicKey(n===void 0?e:n),implementation:new i.SolanaAddress(s).unwrap(),programData:te(r),wormholeProgram:new i.PublicKey(r),rent:i.SYSVAR_RENT_PUBKEY,clock:i.SYSVAR_CLOCK_PUBKEY,bpfLoaderUpgradeable:O,systemProgram:i.SystemProgram.programId}}function Re(r,e,t,n,s,a){const o=w(e,r).methods.initialize(n,new i.BN(s.toString()),[...a.map(u=>[...new Uint8Array(u)])]);return o._ixFn(...o._args,{accounts:le(e,t),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function le(r,e){return{bridge:h(r),guardianSet:I(r,0),feeCollector:P(r),payer:new i.PublicKey(e),clock:i.SYSVAR_CLOCK_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function ye(r,e,t,n,s,a,o){const u=w(e,r).methods.postMessage(a,i.dist.Buffer.from(s),o);return u._ixFn(...u._args,{accounts:F(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function F(r,e,t,n){let s;return n?{emitter:n,sequence:s}=N(n,r):(n=e,s=C(n,r)),{bridge:h(r),message:new i.PublicKey(t),emitter:new i.PublicKey(n),sequence:s,payer:new i.PublicKey(e),feeCollector:P(r),clock:i.SYSVAR_CLOCK_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function pe(r,e,t,n,s){const a=w(e,r).methods.postVaa(1,n.guardianSet,n.timestamp,n.nonce,i.toChainId(n.emitterChain),[...n.emitterAddress.toUint8Array()],new i.BN(n.sequence.toString()),n.consistencyLevel,i.dist.Buffer.from(i.serializePayload(n.payloadLiteral,n.payload)));return a._ixFn(...a._args,{accounts:he(e,t,s,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function he(r,e,t,n){return{guardianSet:I(r,n.guardianSet),bridge:h(r),signatureSet:new i.PublicKey(t),vaa:b(r,i.dist.Buffer.from(n.hash)),payer:new i.PublicKey(e),clock:i.SYSVAR_CLOCK_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}const Oe=19;async function Se(r,e,t,n,s,a){const o=n.guardianSet,u=await G(r,e,o,a),d=n.signatures,f=u.keys,g=7,l=[];for(let y=0;y<Math.ceil(d.length/g);++y){const S=y*g,A=Math.min(d.length,(y+1)*g),K=new Array(Oe).fill(-1),J=[],Q=[];for(let _=0;_<A-S;++_){const R=d.at(_+S);J.push(i.dist.Buffer.from(R.signature.encode())),Q.push(f.at(R.guardianIndex)),K[R.guardianIndex]=_}l.push(Ke(J,Q,i.dist.Buffer.from(n.hash))),l.push(Ye(r,e,t,n,s,K))}return l}function Ye(r,e,t,n,s,a){const o=w(e,r).methods.verifySignatures(a);return o._ixFn(...o._args,{accounts:we(e,t,s,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function we(r,e,t,n){return{payer:new i.PublicKey(e),guardianSet:I(r,n.guardianSet),signatureSet:new i.PublicKey(t),instructions:i.SYSVAR_INSTRUCTIONS_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function Ae(r,e){const{emitter:t,sequence:n}=N(r,e);return{wormholeBridge:h(e),wormholeEmitter:t,wormholeSequence:n,wormholeFeeCollector:P(e)}}function be(r,e,t,n){const s=F(e,t,n,r);return{payer:s.payer,wormholeBridge:s.bridge,wormholeMessage:s.message,wormholeEmitter:s.emitter,wormholeSequence:s.sequence,wormholeFeeCollector:s.feeCollector,clock:s.clock,rent:s.rent,systemProgram:s.systemProgram}}const Ne=Object.freeze(Object.defineProperty({__proto__:null,BridgeConfig:v,BridgeData:k,GuardianSetData:V,SequenceTracker:z,SignatureSetData:D,coder:ce,createBridgeFeeTransferInstruction:W,createInitializeInstruction:Re,createPostMessageInstruction:ye,createPostVaaInstruction:pe,createReadOnlyWormholeProgramInterface:w,createSetFeesInstruction:qe,createTransferFeesInstruction:Ve,createUpgradeContractInstruction:Fe,createUpgradeGuardianSetInstruction:De,createVerifySignaturesInstructions:Se,createWormholeProgramInterface:ue,deriveClaimKey:E,deriveEmitterSequenceKey:C,deriveFeeCollectorKey:P,deriveGuardianSetKey:I,derivePostedVaaKey:b,deriveUpgradeAuthorityKey:$,deriveWormholeBridgeDataKey:h,deriveWormholeEmitterKey:q,getClaim:se,getEmitterKeys:N,getGuardianSet:G,getInitializeAccounts:le,getPostMessageAccounts:F,getPostMessageCpiAccounts:be,getPostVaaAccounts:he,getProgramSequenceTracker:oe,getSequenceTracker:ae,getSetFeesAccounts:de,getSignatureSetData:Ue,getTransferFeesAccounts:ge,getUpgradeContractAccounts:me,getUpgradeGuardianSetAccounts:fe,getVerifySignatureAccounts:we,getWormholeBridgeData:ie,getWormholeDerivedAccounts:Ae},Symbol.toStringTag,{value:"Module"})),ee="Program log: Sequence: ";class x{constructor(e,t,n,s){c(this,"network");c(this,"chain");c(this,"connection");c(this,"contracts");c(this,"chainId");c(this,"coreBridge");c(this,"address");c(this,"bridgeData");this.network=e,this.chain=t,this.connection=n,this.contracts=s,this.chainId=i.toChainId(t);const a=s.coreBridge;if(!a)throw new Error(`CoreBridge contract Address for chain ${t} not found`);this.address=a,this.coreBridge=w(a,n)}async getGuardianSet(e){const t=await G(this.connection,this.coreBridge.programId,e);return{index:t.index,keys:t.keys.map(n=>n.toString("hex")),expiry:BigInt(t.expirationTime)}}static async fromRpc(e,t){const[n,s]=await X.SolanaPlatform.chainFromRpc(e),a=t[s];if(a.network!==n)throw new Error(`Network mismatch for chain ${s}: ${a.network} != ${n}`);return new x(n,s,e,t[s].contracts)}async ensureBridgeConfig(){this.bridgeData||(this.bridgeData=await ie(this.connection,this.coreBridge.programId))}async getMessageFee(){return await this.ensureBridgeConfig(),this.bridgeData.config.fee}async getGuardianSetIndex(){return await this.ensureBridgeConfig(),this.bridgeData.guardianSetIndex}async*publishMessage(e,t,n,s){const a=i.Keypair.generate(),o=new i.SolanaAddress(e).unwrap(),u=ye(this.connection,this.coreBridge.programId,o,a.publicKey,t,n,s),d=await this.getMessageFee(),f=W(this.coreBridge.programId,o,d),g=new i.Transaction;g.feePayer=o,g.add(f,u),yield this.createUnsignedTx({transaction:g,signers:[a]},"Core.PublishMessage")}async*verifyMessage(e,t){yield*this.postVaa(e,t)}async*postVaa(e,t){const n=b(this.coreBridge.programId,i.dist.Buffer.from(t.hash));if(await this.connection.getAccountInfo(n))return;const a=new i.SolanaAddress(e).unwrap(),o=i.Keypair.generate(),u=await Se(this.connection,this.coreBridge.programId,a,t,o.publicKey);for(let f=0;f<u.length;f+=2){const g=new i.Transaction().add(...u.slice(f,f+2));g.feePayer=a,yield this.createUnsignedTx({transaction:g,signers:[o]},"Core.VerifySignature",!0)}const d=new i.Transaction().add(pe(this.connection,this.coreBridge.programId,a,t,o.publicKey));d.feePayer=a,yield this.createUnsignedTx({transaction:d},"Core.PostVAA")}static parseSequenceFromLog(e,t){var d,f,g,l;const{meta:n,transaction:{message:s}}=t;if(!((d=n==null?void 0:n.innerInstructions)!=null&&d.length))return[];const a=s.staticAccountKeys;if(a.filter(y=>y.toString()===e).length===0)return[];const o=(l=(g=(f=n==null?void 0:n.logMessages)==null?void 0:f.filter(y=>y.startsWith(ee)))==null?void 0:g[0])==null?void 0:l.replace(ee,"");if(!o)return[];const u=[];for(const y of n==null?void 0:n.innerInstructions){const S=y.instructions;u.push(...S.filter(A=>A.programIdIndex in a&&a[A.programIdIndex].toString()===e))}return u.length<1?[]:a.length<3?[]:u.map(y=>[new i.SolanaAddress(a[y.accounts[2]]).toUniversalAddress(),BigInt(o)]).filter(y=>y!==null)}async getMessageAccountKeys(e){let t;if(typeof e.transaction.message.version!="string")if(e.meta.loadedAddresses)t=e.transaction.message.getAccountKeys({accountKeysFromLookups:e.meta.loadedAddresses});else{const n=await Promise.all(e.transaction.message.addressTableLookups.map(async s=>{const a=await this.connection.getAddressLookupTable(s.accountKey);if(!a||!a.value)throw new Error("Could not resolve lookup table: "+s.accountKey.toBase58());return a.value}));t=e.transaction.message.getAccountKeys({addressLookupTableAccounts:n})}else t=e.transaction.message.getAccountKeys();return t}async findInstructions(e,t){var d;const{meta:n,transaction:{message:s}}=t,a=this.coreBridge.programId,o=(d=n.innerInstructions)==null?void 0:d.flatMap(f=>f.instructions.filter(g=>a.toString()===e.get(g.programIdIndex).toString())).map(f=>({programIdIndex:f.programIdIndex,accountKeyIndexes:f.accounts})),u=s.compiledInstructions.filter(f=>a.toString()===e.get(f.programIdIndex).toString());return[...o,...u]}async parsePostMessageAccount(e){const t=await this.connection.getAccountInfo(e);if(!(t!=null&&t.data))throw new Error("No data found in message account");const{timestamp:n,emitterAddress:s,emitterChain:a,consistencyLevel:o,sequence:u,nonce:d,payload:f}=re(new Uint8Array(t==null?void 0:t.data));return Ee.createVAA("Uint8Array",{guardianSet:await this.getGuardianSetIndex(),emitterChain:i.toChain(a),timestamp:n,emitterAddress:s,consistencyLevel:o,sequence:u,nonce:d,payload:f,signatures:[]})}async parseTransaction(e){const t=await this.connection.getTransaction(e,{maxSupportedTransactionVersion:0});if(!t||!t.meta||!t.meta.innerInstructions)throw new Error("transaction not found");try{const o=x.parseSequenceFromLog(this.coreBridge.programId.toBase58(),t);if(o.length>0){const[u,d]=o[0];return[{chain:this.chain,emitter:u,sequence:d}]}}catch{}const n=await this.getMessageAccountKeys(t),s=await this.findInstructions(n,t);if(!s||s.length===0)throw new Error("no bridge messages found");const a=s.map(async o=>{const u=n.get(o.accountKeyIndexes[1]),d=await this.parsePostMessageAccount(u);return{chain:d.emitterChain,emitter:d.emitterAddress,sequence:d.sequence}});return await Promise.all(a)}async parseMessages(e){const t=await this.connection.getTransaction(e,{maxSupportedTransactionVersion:0});if(!t||!t.meta||!t.meta.innerInstructions)throw new Error("transaction not found");const n=await this.getMessageAccountKeys(t),s=await this.findInstructions(n,t);if(!s||s.length===0)throw new Error("no bridge messages found");const a=s.map(async o=>{const u=n.get(o.accountKeyIndexes[1]);return await this.parsePostMessageAccount(u)});return await Promise.all(a)}createUnsignedTx(e,t,n=!1){return new X.SolanaUnsignedTransaction(e,this.network,this.chain,t,n)}}Pe.registerProtocol(i._platform$1,"WormholeCore",x);const Ge=Object.freeze(Object.defineProperty({__proto__:null,IDL:H,SolanaWormholeCore:x,deserializePostMessage:re,postMessageLayout:ne,utils:Ne},Symbol.toStringTag,{value:"Module"}));exports.BPF_LOADER_UPGRADEABLE_PROGRAM_ID=O;exports.SolanaWormholeCore=x;exports.accountSize=Y;exports.createBridgeFeeTransferInstruction=W;exports.deriveClaimKey=E;exports.deriveEmitterSequenceKey=C;exports.deriveFeeCollectorKey=P;exports.derivePostedVaaKey=b;exports.deriveProgramDataAddress=te;exports.deriveUpgradeAuthorityKey=$;exports.deriveWormholeBridgeDataKey=h;exports.deriveWormholeEmitterKey=q;exports.getClaim=se;exports.getPostMessageAccounts=F;exports.getPostMessageCpiAccounts=be;exports.getProgramSequenceTracker=oe;exports.getWormholeDerivedAccounts=Ae;exports.index=Ge;
|
|
1
|
+
"use strict";var Me=Object.defineProperty;var Ie=(r,e,t)=>e in r?Me(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>Ie(r,typeof e!="symbol"?e+"":e,t);const i=require("./address-DnSRsubO.js"),m=require("./index-DtUeWT1n.js"),p=require("./account-BSFuCEgk.js"),X=require("./unsignedTransaction-CIkLJt6N.js"),Ee=require("./create-Q6N34YQz.js"),Pe=require("./chain-Cio41-Lr.js"),O=new i.PublicKey("BPFLoaderUpgradeab1e11111111111111111111111");function te(r){return p.deriveAddress([new i.PublicKey(r).toBuffer()],O)}class Be extends Error{constructor(e){super(e),this.name="IdlError"}}function Y(r,e){switch(e.type.kind){case"struct":return e.type.fields.map(t=>M(r,t.type)).reduce((t,n)=>t+n,0);case"enum":{const t=e.type.variants.map(n=>n.fields?n.fields.map(s=>typeof s=="object"&&"name"in s?M(r,s.type):M(r,s)).reduce((s,a)=>s+a,0):0);return Math.max(...t)+1}case"alias":return M(r,e.type.value)}}function M(r,e){var t;switch(e){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"publicKey":return 32;default:if("vec"in e)return 1;if("option"in e)return 1+M(r,e.option);if("coption"in e)return 4+M(r,e.coption);if("defined"in e){const n=((t=r.types)==null?void 0:t.filter(a=>a.name===e.defined))??[];if(n.length!==1)throw new Be(`Type not found: ${JSON.stringify(e)}`);let s=n[0];return Y(r,s)}if("array"in e){let n=e.array[0],s=e.array[1];return M(r,n)*s}throw new Error(`Invalid type ${JSON.stringify(e)}`)}}function L(r){return r.replace(/(?:^\w|[A-Z]|\b\w)/g,function(e,t){return t===0?e.toLowerCase():e.toUpperCase()}).replace(/[\s\-_]+/g,"")}function xe(r){return r.charAt(0).toUpperCase()+r.slice(1)}const ne=[{name:"discriminator",binary:"bytes",size:4},{name:"consistencyLevel",binary:"uint",size:1,endianness:"little"},{name:"emitterAuthority",...i.universalAddressItem},{name:"messageStatus",binary:"uint",size:1,endianness:"little"},{name:"gap",binary:"uint",size:3},{name:"timestamp",binary:"uint",size:4,endianness:"little"},{name:"nonce",binary:"uint",size:4,endianness:"little"},{name:"sequence",binary:"uint",size:8,endianness:"little"},{name:"emitterChain",binary:"uint",size:2,endianness:"little"},{name:"emitterAddress",...i.universalAddressItem},{name:"payloadLength",binary:"uint",size:4,endianness:"little"},{name:"payload",binary:"bytes"}];function re(r){return i.deserialize$1(ne,r)}function E(r,e,t,n){const s=typeof e=="string"?i.dist.Buffer.from(e,"hex"):i.dist.Buffer.from(e);if(s.length!=32)throw Error("address.length != 32");const a=i.dist.Buffer.alloc(8);return a.writeBigUInt64BE(typeof n=="number"?BigInt(n):n),p.deriveAddress([s,(()=>{const o=i.dist.Buffer.alloc(2);return o.writeUInt16BE(t),o})(),a],r)}async function se(r,e,t,n,s,a){return r.getAccountInfo(E(e,t,n,s),a).then(o=>!!p.getAccountData(o)[0])}function h(r){return p.deriveAddress([i.dist.Buffer.from("Bridge")],r)}async function ie(r,e,t){return r.getAccountInfo(h(e),t).then(n=>k.deserialize(p.getAccountData(n)))}class v{constructor(e,t){c(this,"guardianSetExpirationTime");c(this,"fee");this.guardianSetExpirationTime=e,this.fee=t}static deserialize(e){if(e.length!=12)throw new Error("data.length != 12");const t=e.readUInt32LE(0),n=e.readBigUInt64LE(4);return new v(t,n)}}class k{constructor(e,t,n){c(this,"guardianSetIndex");c(this,"lastLamports");c(this,"config");this.guardianSetIndex=e,this.lastLamports=t,this.config=n}static deserialize(e){if(e.length!=24)throw new Error("data.length != 24");const t=e.readUInt32LE(0),n=e.readBigUInt64LE(4),s=v.deserialize(e.subarray(12));return new k(t,n,s)}}function C(r,e){return p.deriveAddress([i.dist.Buffer.from("Sequence"),new i.PublicKey(r).toBytes()],e)}async function ae(r,e,t,n){return r.getAccountInfo(C(e,t),n).then(s=>z.deserialize(p.getAccountData(s)))}class z{constructor(e,t,n){c(this,"sequence");c(this,"bump");c(this,"emitterType");this.sequence=e,this.bump=t,this.emitterType=n}static deserialize(e){if(e.length!==8&&e.length!==10)throw new Error("data.length != 8 or data.length != 10");let t,n;const s=e.readBigUInt64LE(0);return e.length===10&&(t=e[8],n=e[9]),new z(s,t,n)}value(){return this.sequence}}function q(r){return p.deriveAddress([i.dist.Buffer.from("emitter")],r)}function N(r,e){const t=q(r);return{emitter:t,sequence:C(t,e)}}async function oe(r,e,t,n){return ae(r,q(e),t,n)}function P(r){return p.deriveAddress([i.dist.Buffer.from("fee_collector")],r)}const Z=65,U=20;function Ke(r,e,t){return new i.TransactionInstruction({keys:[],programId:i.Secp256k1Program.programId,data:Le.serialize(r,e,t)})}class Le{static serialize(e,t,n){if(e.length==0)throw Error("signatures.length == 0");if(e.length!=t.length)throw Error("signatures.length != keys.length");if(n.length!=32)throw Error("message.length != 32");const s=e.length,a=11,o=1+s*a,u=Z+U,d=o+s*u,f=32,g=i.dist.Buffer.alloc(d+f);g.writeUInt8(s,0),g.write(n.toString("hex"),d,"hex");for(let l=0;l<s;++l){const y=e.at(l);if((y==null?void 0:y.length)!=Z)throw Error(`signatures[${l}].length != 65`);const S=t.at(l);if((S==null?void 0:S.length)!=U)throw Error(`keys[${l}].length != 20`);const A=o+u*l,K=A+65;g.writeUInt16LE(A,1+l*a),g.writeUInt8(0,3+l*a),g.writeUInt16LE(K,4+l*a),g.writeUInt8(0,6+l*a),g.writeUInt16LE(d,7+l*a),g.writeUInt16LE(f,9+l*a),g.writeUInt8(0,10+l*a),g.write(y.toString("hex"),A,"hex"),g.write(S.toString("hex"),K,"hex")}return g}}function I(r,e){return p.deriveAddress([i.dist.Buffer.from("GuardianSet"),(()=>{const t=i.dist.Buffer.alloc(4);return t.writeUInt32BE(e),t})()],r)}async function G(r,e,t,n){return r.getAccountInfo(I(e,t),n).then(s=>V.deserialize(p.getAccountData(s)))}class V{constructor(e,t,n,s){c(this,"index");c(this,"keys");c(this,"creationTime");c(this,"expirationTime");this.index=e,this.keys=t,this.creationTime=n,this.expirationTime=s}static deserialize(e){const t=e.readUInt32LE(0),n=e.readUInt32LE(4),s=8+n*U,a=e.readUInt32LE(s),o=e.readUInt32LE(4+s),u=[];for(let d=0;d<n;++d){const f=8+d*U;u.push(e.subarray(f,f+U))}return new V(t,u,a,o)}}function b(r,e){return p.deriveAddress([i.dist.Buffer.from("PostedVAA"),e],r)}async function Ue(r,e,t){return r.getAccountInfo(new i.PublicKey(e),t).then(n=>D.deserialize(p.getAccountData(n)))}class D{constructor(e,t,n){c(this,"signatures");c(this,"hash");c(this,"guardianSetIndex");this.signatures=e,this.hash=t,this.guardianSetIndex=n}static deserialize(e){const t=e.readUInt32LE(0),n=[...e.subarray(4,4+t)].map(u=>u!=0),s=4+t,a=e.subarray(s,s+32),o=e.readUInt32LE(s+32);return new D(n,a,o)}}function $(r){return p.deriveAddress([i.dist.Buffer.from("upgrade")],r)}function W(r,e,t){return i.SystemProgram.transfer({fromPubkey:new i.PublicKey(e),toPubkey:P(r),lamports:t})}class Ce{constructor(e){c(this,"idl");this.idl=e}async encode(e,t){switch(e){default:throw new Error(`Invalid account name: ${e}`)}}decode(e,t){return this.decodeUnchecked(e,t)}decodeUnchecked(e,t){switch(e){default:throw new Error(`Invalid account name: ${e}`)}}memcmp(e,t){switch(e){case"postVaa":return{dataSize:56};default:throw new Error(`Invalid account name: ${e}`)}}size(e){return Y(this.idl,e)??0}}class _e{constructor(e){}decode(e){throw new Error("Wormhole program does not have events")}}class B{static fieldLayout(e,t){const n=e.name!==void 0?L(e.name):void 0;switch(e.type){case"bool":return m.dist.bool(n);case"u8":return m.dist.u8(n);case"i8":return m.dist.i8(n);case"u16":return m.dist.u16(n);case"i16":return m.dist.i16(n);case"u32":return m.dist.u32(n);case"i32":return m.dist.i32(n);case"f32":return m.dist.f32(n);case"u64":return m.dist.u64(n);case"i64":return m.dist.i64(n);case"f64":return m.dist.f64(n);case"u128":return m.dist.u128(n);case"i128":return m.dist.i128(n);case"u256":return m.dist.u256(n);case"i256":return m.dist.i256(n);case"bytes":return m.dist.vecU8(n);case"string":return m.dist.str(n);case"publicKey":return m.dist.publicKey(n);default:{if("vec"in e.type)return m.dist.vec(B.fieldLayout({name:void 0,type:e.type.vec},t),n);if("option"in e.type)return m.dist.option(B.fieldLayout({name:void 0,type:e.type.option},t),n);if("array"in e.type){let s=e.type.array[0],a=e.type.array[1],o=B.fieldLayout({name:void 0,type:s},t);return m.dist.array(o,a,n)}else throw new Error(`Not yet implemented: ${e}`)}}}}class j{constructor(e){c(this,"ixLayout");this.ixLayout=j.parseIxLayout(e)}static parseIxLayout(e){const n=(e.instructions?e.instructions:[]).map(s=>{let a=s.args.map(u=>B.fieldLayout(u,Array.from([...e.accounts??[],...e.types??[]])));const o=L(s.name);return[o,m.dist.struct(a,o)]}).concat(e.instructions.map(s=>{let a=s.args.map(u=>B.fieldLayout(u,Array.from([...e.accounts??[],...e.types??[]])));const o=L(s.name);return[o,m.dist.struct(a,o)]}));return new Map(n)}encode(e,t){const n=i.dist.Buffer.alloc(1e3),s=L(e),a=this.ixLayout.get(s);if(!a)throw new Error(`Unknown method: ${s}`);const o=a.encode(t,n),u=n.slice(0,o);return Te(T[xe(s)],u)}encodeState(e,t){throw new Error("Wormhole program does not have state")}decode(e,t="hex"){var u;typeof e=="string"&&(e=t==="hex"?i.dist.Buffer.from(e,"hex"):i.b58.decode(e));let n=i.dist.Buffer.from(e.slice(0,1)).readInt8(),s=i.dist.Buffer.from(e.slice(1)),a=L(T[n]??"");return this.ixLayout.get(a)?{data:(u=this.ixLayout.get(a))==null?void 0:u.decode(s),name:a}:null}}var T;(function(r){r[r.Initialize=0]="Initialize",r[r.PostMessage=1]="PostMessage",r[r.PostVaa=2]="PostVaa",r[r.SetFees=3]="SetFees",r[r.TransferFees=4]="TransferFees",r[r.UpgradeContract=5]="UpgradeContract",r[r.UpgradeGuardianSet=6]="UpgradeGuardianSet",r[r.VerifySignatures=7]="VerifySignatures",r[r.PostMessageUnreliable=8]="PostMessageUnreliable"})(T||(T={}));function Te(r,e){const t=i.dist.Buffer.alloc(1+(e===void 0?0:e.length));return t.writeUInt8(r,0),e!==void 0&&t.write(e.toString("hex"),1,"hex"),t}class ve{constructor(e){}encode(e,t){throw new Error("Wormhole program does not have state")}decode(e){throw new Error("Wormhole program does not have state")}}class ke{constructor(e){}encode(e,t){throw new Error("Wormhole program does not have user-defined types")}decode(e,t){throw new Error("Wormhole program does not have user-defined types")}}class ze{constructor(e){c(this,"instruction");c(this,"accounts");c(this,"state");c(this,"events");c(this,"types");this.instruction=new j(e),this.accounts=new Ce(e),this.state=new ve(e),this.events=new _e(e),this.types=new ke(e)}}const H={version:"0.1.0",name:"wormhole",instructions:[{name:"initialize",accounts:[{name:"bridge",isMut:!0,isSigner:!1},{name:"guardianSet",isMut:!0,isSigner:!1},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"guardianSetExpirationTime",type:"u32"},{name:"fee",type:"u64"},{name:"initialGuardians",type:{vec:{array:["u8",20]}}}]},{name:"postMessage",accounts:[{name:"bridge",isMut:!0,isSigner:!1},{name:"message",isMut:!0,isSigner:!0},{name:"emitter",isMut:!1,isSigner:!0},{name:"sequence",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"payload",type:"bytes"},{name:"consistencyLevel",type:"u8"}]},{name:"postVaa",accounts:[{name:"guardianSet",isMut:!1,isSigner:!1},{name:"bridge",isMut:!1,isSigner:!1},{name:"signatureSet",isMut:!1,isSigner:!1},{name:"vaa",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"version",type:"u8"},{name:"guardianSetIndex",type:"u32"},{name:"timestamp",type:"u32"},{name:"nonce",type:"u32"},{name:"emitterChain",type:"u16"},{name:"emitterAddress",type:{array:["u8",32]}},{name:"sequence",type:"u64"},{name:"consistencyLevel",type:"u8"},{name:"payload",type:"bytes"}]},{name:"setFees",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"transferFees",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"recipient",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"upgradeContract",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"upgradeAuthority",isMut:!1,isSigner:!1},{name:"spill",isMut:!0,isSigner:!1},{name:"implementation",isMut:!0,isSigner:!1},{name:"programData",isMut:!0,isSigner:!1},{name:"wormholeProgram",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"bpfLoaderUpgradeable",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"upgradeGuardianSet",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"guardianSetOld",isMut:!0,isSigner:!1},{name:"guardianSetNew",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"verifySignatures",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"guardianSet",isMut:!1,isSigner:!1},{name:"signatureSet",isMut:!0,isSigner:!0},{name:"instructions",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"signatureStatus",type:{array:["i8",19]}}]},{name:"postMessageUnreliable",accounts:[{name:"bridge",isMut:!0,isSigner:!1},{name:"message",isMut:!0,isSigner:!0},{name:"emitter",isMut:!1,isSigner:!0},{name:"sequence",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"payload",type:"bytes"},{name:"consistencyLevel",type:"u8"}]}],accounts:[{name:"PostedMessage",type:{kind:"struct",fields:[{name:"vaaVersion",type:"u8"},{name:"consistencyLevel",type:"u8"},{name:"vaaTime",type:"u32"},{name:"vaaSignatureAccount",type:"publicKey"},{name:"submissionTime",type:"u32"},{name:"nonce",type:"u32"},{name:"sequence",type:"u64"},{name:"emitterChain",type:"u16"},{name:"emitterAddress",type:{array:["u8",32]}},{name:"payload",type:"bytes"}]}},{name:"PostedVAA",type:{kind:"struct",fields:[{name:"vaaVersion",type:"u8"},{name:"consistencyLevel",type:"u8"},{name:"vaaTime",type:"u32"},{name:"vaaSignatureAccount",type:"publicKey"},{name:"submissionTime",type:"u32"},{name:"nonce",type:"u32"},{name:"sequence",type:"u64"},{name:"emitterChain",type:"u16"},{name:"emitterAddress",type:{array:["u8",32]}},{name:"payload",type:"bytes"}]}}]};function ue(r,e){return new m.Program(H,new i.PublicKey(r),e===void 0?{connection:null}:e,ce())}function w(r,e){return ue(r,m.createReadOnlyProvider(e))}function ce(){return new ze(H)}function qe(r,e,t,n){const s=w(e,r).methods.setFees();return s._ixFn(...s._args,{accounts:de(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function de(r,e,t){return{payer:new i.PublicKey(e),bridge:h(r),vaa:b(r,i.dist.Buffer.from(t.hash)),claim:E(r,t.emitterAddress.toString(),i.toChainId(t.emitterChain),t.sequence),systemProgram:i.SystemProgram.programId}}function Ve(r,e,t,n,s){const a=w(e,r).methods.transferFees();return a._ixFn(...a._args,{accounts:ge(e,t,n,s),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function ge(r,e,t,n){return{payer:new i.PublicKey(e),bridge:h(r),vaa:b(r,i.dist.Buffer.from(n.hash)),claim:E(r,n.emitterAddress.toString(),i.toChainId(n.emitterChain),n.sequence),feeCollector:P(r),recipient:new i.PublicKey(t),rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function De(r,e,t,n){const s=w(e,r).methods.upgradeGuardianSet();return s._ixFn(...s._args,{accounts:fe(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function fe(r,e,t){return{payer:new i.PublicKey(e),bridge:h(r),vaa:b(r,i.dist.Buffer.from(t.hash)),claim:E(r,t.emitterAddress.toString(),i.toChainId(t.emitterChain),t.sequence),guardianSetOld:I(r,t.guardianSet),guardianSetNew:I(r,t.guardianSet+1),systemProgram:i.SystemProgram.programId}}function Fe(r,e,t,n){const s=w(e,r).methods.upgradeContract();return s._ixFn(...s._args,{accounts:me(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function me(r,e,t,n){const{newContract:s}=t.payload.actionArgs;return{payer:new i.PublicKey(e),bridge:h(r),vaa:b(r,i.dist.Buffer.from(t.hash)),claim:E(r,t.emitterAddress.toString(),i.toChainId(t.emitterChain),t.sequence),upgradeAuthority:$(r),spill:new i.PublicKey(n===void 0?e:n),implementation:new i.SolanaAddress(s).unwrap(),programData:te(r),wormholeProgram:new i.PublicKey(r),rent:i.SYSVAR_RENT_PUBKEY,clock:i.SYSVAR_CLOCK_PUBKEY,bpfLoaderUpgradeable:O,systemProgram:i.SystemProgram.programId}}function Re(r,e,t,n,s,a){const o=w(e,r).methods.initialize(n,new i.BN(s.toString()),[...a.map(u=>[...new Uint8Array(u)])]);return o._ixFn(...o._args,{accounts:le(e,t),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function le(r,e){return{bridge:h(r),guardianSet:I(r,0),feeCollector:P(r),payer:new i.PublicKey(e),clock:i.SYSVAR_CLOCK_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function ye(r,e,t,n,s,a,o){const u=w(e,r).methods.postMessage(a,i.dist.Buffer.from(s),o);return u._ixFn(...u._args,{accounts:F(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function F(r,e,t,n){let s;return n?{emitter:n,sequence:s}=N(n,r):(n=e,s=C(n,r)),{bridge:h(r),message:new i.PublicKey(t),emitter:new i.PublicKey(n),sequence:s,payer:new i.PublicKey(e),feeCollector:P(r),clock:i.SYSVAR_CLOCK_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function pe(r,e,t,n,s){const a=w(e,r).methods.postVaa(1,n.guardianSet,n.timestamp,n.nonce,i.toChainId(n.emitterChain),[...n.emitterAddress.toUint8Array()],new i.BN(n.sequence.toString()),n.consistencyLevel,i.dist.Buffer.from(i.serializePayload(n.payloadLiteral,n.payload)));return a._ixFn(...a._args,{accounts:he(e,t,s,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function he(r,e,t,n){return{guardianSet:I(r,n.guardianSet),bridge:h(r),signatureSet:new i.PublicKey(t),vaa:b(r,i.dist.Buffer.from(n.hash)),payer:new i.PublicKey(e),clock:i.SYSVAR_CLOCK_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}const Oe=19;async function Se(r,e,t,n,s,a){const o=n.guardianSet,u=await G(r,e,o,a),d=n.signatures,f=u.keys,g=7,l=[];for(let y=0;y<Math.ceil(d.length/g);++y){const S=y*g,A=Math.min(d.length,(y+1)*g),K=new Array(Oe).fill(-1),J=[],Q=[];for(let _=0;_<A-S;++_){const R=d.at(_+S);J.push(i.dist.Buffer.from(R.signature.encode())),Q.push(f.at(R.guardianIndex)),K[R.guardianIndex]=_}l.push(Ke(J,Q,i.dist.Buffer.from(n.hash))),l.push(Ye(r,e,t,n,s,K))}return l}function Ye(r,e,t,n,s,a){const o=w(e,r).methods.verifySignatures(a);return o._ixFn(...o._args,{accounts:we(e,t,s,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function we(r,e,t,n){return{payer:new i.PublicKey(e),guardianSet:I(r,n.guardianSet),signatureSet:new i.PublicKey(t),instructions:i.SYSVAR_INSTRUCTIONS_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function Ae(r,e){const{emitter:t,sequence:n}=N(r,e);return{wormholeBridge:h(e),wormholeEmitter:t,wormholeSequence:n,wormholeFeeCollector:P(e)}}function be(r,e,t,n){const s=F(e,t,n,r);return{payer:s.payer,wormholeBridge:s.bridge,wormholeMessage:s.message,wormholeEmitter:s.emitter,wormholeSequence:s.sequence,wormholeFeeCollector:s.feeCollector,clock:s.clock,rent:s.rent,systemProgram:s.systemProgram}}const Ne=Object.freeze(Object.defineProperty({__proto__:null,BridgeConfig:v,BridgeData:k,GuardianSetData:V,SequenceTracker:z,SignatureSetData:D,coder:ce,createBridgeFeeTransferInstruction:W,createInitializeInstruction:Re,createPostMessageInstruction:ye,createPostVaaInstruction:pe,createReadOnlyWormholeProgramInterface:w,createSetFeesInstruction:qe,createTransferFeesInstruction:Ve,createUpgradeContractInstruction:Fe,createUpgradeGuardianSetInstruction:De,createVerifySignaturesInstructions:Se,createWormholeProgramInterface:ue,deriveClaimKey:E,deriveEmitterSequenceKey:C,deriveFeeCollectorKey:P,deriveGuardianSetKey:I,derivePostedVaaKey:b,deriveUpgradeAuthorityKey:$,deriveWormholeBridgeDataKey:h,deriveWormholeEmitterKey:q,getClaim:se,getEmitterKeys:N,getGuardianSet:G,getInitializeAccounts:le,getPostMessageAccounts:F,getPostMessageCpiAccounts:be,getPostVaaAccounts:he,getProgramSequenceTracker:oe,getSequenceTracker:ae,getSetFeesAccounts:de,getSignatureSetData:Ue,getTransferFeesAccounts:ge,getUpgradeContractAccounts:me,getUpgradeGuardianSetAccounts:fe,getVerifySignatureAccounts:we,getWormholeBridgeData:ie,getWormholeDerivedAccounts:Ae},Symbol.toStringTag,{value:"Module"})),ee="Program log: Sequence: ";class x{constructor(e,t,n,s){c(this,"network");c(this,"chain");c(this,"connection");c(this,"contracts");c(this,"chainId");c(this,"coreBridge");c(this,"address");c(this,"bridgeData");this.network=e,this.chain=t,this.connection=n,this.contracts=s,this.chainId=i.toChainId(t);const a=s.coreBridge;if(!a)throw new Error(`CoreBridge contract Address for chain ${t} not found`);this.address=a,this.coreBridge=w(a,n)}async getGuardianSet(e){const t=await G(this.connection,this.coreBridge.programId,e);return{index:t.index,keys:t.keys.map(n=>n.toString("hex")),expiry:BigInt(t.expirationTime)}}static async fromRpc(e,t){const[n,s]=await X.SolanaPlatform.chainFromRpc(e),a=t[s];if(a.network!==n)throw new Error(`Network mismatch for chain ${s}: ${a.network} != ${n}`);return new x(n,s,e,t[s].contracts)}async ensureBridgeConfig(){this.bridgeData||(this.bridgeData=await ie(this.connection,this.coreBridge.programId))}async getMessageFee(){return await this.ensureBridgeConfig(),this.bridgeData.config.fee}async getGuardianSetIndex(){return await this.ensureBridgeConfig(),this.bridgeData.guardianSetIndex}async*publishMessage(e,t,n,s){const a=i.Keypair.generate(),o=new i.SolanaAddress(e).unwrap(),u=ye(this.connection,this.coreBridge.programId,o,a.publicKey,t,n,s),d=await this.getMessageFee(),f=W(this.coreBridge.programId,o,d),g=new i.Transaction;g.feePayer=o,g.add(f,u),yield this.createUnsignedTx({transaction:g,signers:[a]},"Core.PublishMessage")}async*verifyMessage(e,t){yield*this.postVaa(e,t)}async*postVaa(e,t){const n=b(this.coreBridge.programId,i.dist.Buffer.from(t.hash));if(await this.connection.getAccountInfo(n))return;const a=new i.SolanaAddress(e).unwrap(),o=i.Keypair.generate(),u=await Se(this.connection,this.coreBridge.programId,a,t,o.publicKey);for(let f=0;f<u.length;f+=2){const g=new i.Transaction().add(...u.slice(f,f+2));g.feePayer=a,yield this.createUnsignedTx({transaction:g,signers:[o]},"Core.VerifySignature",!0)}const d=new i.Transaction().add(pe(this.connection,this.coreBridge.programId,a,t,o.publicKey));d.feePayer=a,yield this.createUnsignedTx({transaction:d},"Core.PostVAA")}static parseSequenceFromLog(e,t){var d,f,g,l;const{meta:n,transaction:{message:s}}=t;if(!((d=n==null?void 0:n.innerInstructions)!=null&&d.length))return[];const a=s.staticAccountKeys;if(a.filter(y=>y.toString()===e).length===0)return[];const o=(l=(g=(f=n==null?void 0:n.logMessages)==null?void 0:f.filter(y=>y.startsWith(ee)))==null?void 0:g[0])==null?void 0:l.replace(ee,"");if(!o)return[];const u=[];for(const y of n==null?void 0:n.innerInstructions){const S=y.instructions;u.push(...S.filter(A=>A.programIdIndex in a&&a[A.programIdIndex].toString()===e))}return u.length<1?[]:a.length<3?[]:u.map(y=>[new i.SolanaAddress(a[y.accounts[2]]).toUniversalAddress(),BigInt(o)]).filter(y=>y!==null)}async getMessageAccountKeys(e){let t;if(typeof e.transaction.message.version!="string")if(e.meta.loadedAddresses)t=e.transaction.message.getAccountKeys({accountKeysFromLookups:e.meta.loadedAddresses});else{const n=await Promise.all(e.transaction.message.addressTableLookups.map(async s=>{const a=await this.connection.getAddressLookupTable(s.accountKey);if(!a||!a.value)throw new Error("Could not resolve lookup table: "+s.accountKey.toBase58());return a.value}));t=e.transaction.message.getAccountKeys({addressLookupTableAccounts:n})}else t=e.transaction.message.getAccountKeys();return t}async findInstructions(e,t){var d;const{meta:n,transaction:{message:s}}=t,a=this.coreBridge.programId,o=(d=n.innerInstructions)==null?void 0:d.flatMap(f=>f.instructions.filter(g=>a.toString()===e.get(g.programIdIndex).toString())).map(f=>({programIdIndex:f.programIdIndex,accountKeyIndexes:f.accounts})),u=s.compiledInstructions.filter(f=>a.toString()===e.get(f.programIdIndex).toString());return[...o,...u]}async parsePostMessageAccount(e){const t=await this.connection.getAccountInfo(e);if(!(t!=null&&t.data))throw new Error("No data found in message account");const{timestamp:n,emitterAddress:s,emitterChain:a,consistencyLevel:o,sequence:u,nonce:d,payload:f}=re(new Uint8Array(t==null?void 0:t.data));return Ee.createVAA("Uint8Array",{guardianSet:await this.getGuardianSetIndex(),emitterChain:i.toChain(a),timestamp:n,emitterAddress:s,consistencyLevel:o,sequence:u,nonce:d,payload:f,signatures:[]})}async parseTransaction(e){const t=await this.connection.getTransaction(e,{maxSupportedTransactionVersion:0});if(!t||!t.meta||!t.meta.innerInstructions)throw new Error("transaction not found");try{const o=x.parseSequenceFromLog(this.coreBridge.programId.toBase58(),t);if(o.length>0){const[u,d]=o[0];return[{chain:this.chain,emitter:u,sequence:d}]}}catch{}const n=await this.getMessageAccountKeys(t),s=await this.findInstructions(n,t);if(!s||s.length===0)throw new Error("no bridge messages found");const a=s.map(async o=>{const u=n.get(o.accountKeyIndexes[1]),d=await this.parsePostMessageAccount(u);return{chain:d.emitterChain,emitter:d.emitterAddress,sequence:d.sequence}});return await Promise.all(a)}async parseMessages(e){const t=await this.connection.getTransaction(e,{maxSupportedTransactionVersion:0});if(!t||!t.meta||!t.meta.innerInstructions)throw new Error("transaction not found");const n=await this.getMessageAccountKeys(t),s=await this.findInstructions(n,t);if(!s||s.length===0)throw new Error("no bridge messages found");const a=s.map(async o=>{const u=n.get(o.accountKeyIndexes[1]);return await this.parsePostMessageAccount(u)});return await Promise.all(a)}createUnsignedTx(e,t,n=!1){return new X.SolanaUnsignedTransaction(e,this.network,this.chain,t,n)}}Pe.registerProtocol(i._platform$1,"WormholeCore",x);const Ge=Object.freeze(Object.defineProperty({__proto__:null,IDL:H,SolanaWormholeCore:x,deserializePostMessage:re,postMessageLayout:ne,utils:Ne},Symbol.toStringTag,{value:"Module"}));exports.BPF_LOADER_UPGRADEABLE_PROGRAM_ID=O;exports.SolanaWormholeCore=x;exports.accountSize=Y;exports.createBridgeFeeTransferInstruction=W;exports.deriveClaimKey=E;exports.deriveEmitterSequenceKey=C;exports.deriveFeeCollectorKey=P;exports.derivePostedVaaKey=b;exports.deriveProgramDataAddress=te;exports.deriveUpgradeAuthorityKey=$;exports.deriveWormholeBridgeDataKey=h;exports.deriveWormholeEmitterKey=q;exports.getClaim=se;exports.getPostMessageAccounts=F;exports.getPostMessageCpiAccounts=be;exports.getProgramSequenceTracker=oe;exports.getWormholeDerivedAccounts=Ae;exports.index=Ge;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Fe=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Fe=require("./index-S_dcknx7.js"),Y=require("./address-DnSRsubO.js"),He=require("./evm-CNq2zXwl.js"),j=require("./index-Db3GFx2x.js"),E=require("./index-lG1-neJv.js"),pu=require("./browser-ponyfill-BTt_ELXG.js");var ne={};Object.defineProperty(ne,"__esModule",{value:!0});ne.getLocalStorage=ne.getLocalStorageOrThrow=ne.getCrypto=ne.getCryptoOrThrow=ne.getLocation=ne.getLocationOrThrow=ne.getNavigator=ne.getNavigatorOrThrow=ne.getDocument=ne.getDocumentOrThrow=ne.getFromWindowOrThrow=ne.getFromWindow=void 0;function nr(a){let t;return typeof window<"u"&&typeof window[a]<"u"&&(t=window[a]),t}ne.getFromWindow=nr;function $r(a){const t=nr(a);if(!t)throw new Error(`${a} is not defined in Window`);return t}ne.getFromWindowOrThrow=$r;function iw(){return $r("document")}ne.getDocumentOrThrow=iw;function sw(){return nr("document")}ne.getDocument=sw;function nw(){return $r("navigator")}ne.getNavigatorOrThrow=nw;function ow(){return nr("navigator")}ne.getNavigator=ow;function aw(){return $r("location")}ne.getLocationOrThrow=aw;function cw(){return nr("location")}ne.getLocation=cw;function uw(){return $r("crypto")}ne.getCryptoOrThrow=uw;function hw(){return nr("crypto")}ne.getCrypto=hw;function lw(){return $r("localStorage")}ne.getLocalStorageOrThrow=lw;function pw(){return nr("localStorage")}ne.getLocalStorage=pw;var Eo={};Object.defineProperty(Eo,"__esModule",{value:!0});Eo.getWindowMetadata=void 0;const fu=ne;function fw(){let a,t;try{a=fu.getDocumentOrThrow(),t=fu.getLocationOrThrow()}catch{return null}function r(){const O=a.getElementsByTagName("link"),N=[];for(let q=0;q<O.length;q++){const x=O[q],K=x.getAttribute("rel");if(K&&K.toLowerCase().indexOf("icon")>-1){const D=x.getAttribute("href");if(D)if(D.toLowerCase().indexOf("https:")===-1&&D.toLowerCase().indexOf("http:")===-1&&D.indexOf("//")!==0){let G=t.protocol+"//"+t.host;if(D.indexOf("/")===0)G+=D;else{const fe=t.pathname.split("/");fe.pop();const Z=fe.join("/");G+=Z+"/"+D}N.push(G)}else if(D.indexOf("//")===0){const G=t.protocol+D;N.push(G)}else N.push(D)}}return N}function s(...O){const N=a.getElementsByTagName("meta");for(let q=0;q<N.length;q++){const x=N[q],K=["itemprop","property","name"].map(D=>x.getAttribute(D)).filter(D=>D?O.includes(D):!1);if(K.length&&K){const D=x.getAttribute("content");if(D)return D}}return""}function o(){let O=s("name","og:site_name","og:title","twitter:title");return O||(O=a.title),O}function u(){return s("description","og:description","twitter:description","keywords")}const l=o(),g=u(),w=t.origin,b=r();return{description:g,url:w,icons:b,name:l}}Eo.getWindowMetadata=fw;function dw(a,t=[]){const r=[];return Object.keys(a).forEach(s=>{if(t.length&&!t.includes(s))return;const o=a[s];r.push(...o.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 yw(a,t){const{message:r,code:s}=gw[a];return{message:r,code:s}}function uo(a,t){return!!Array.isArray(a)}var Tr={};/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -43,4 +43,4 @@ __p += '`),Q&&(R+=`' +
|
|
|
43
43
|
function print() { __p += __j.call(arguments, '') }
|
|
44
44
|
`:`;
|
|
45
45
|
`)+R+`return __p
|
|
46
|
-
}`;var V=uu(function(){return X(f,F+"return "+R).apply(r,d)});if(V.source=R,Mn(V))throw V;return V}function hm(e){return te(e).toLowerCase()}function lm(e){return te(e).toUpperCase()}function pm(e,i,n){if(e=te(e),e&&(n||i===r))return ma(e);if(!e||!(i=Be(i)))return e;var c=ct(e),h=ct(i),f=wa(c,h),d=_a(c,h)+1;return kt(c,f,d).join("")}function fm(e,i,n){if(e=te(e),e&&(n||i===r))return e.slice(0,Ea(e)+1);if(!e||!(i=Be(i)))return e;var c=ct(e),h=_a(c,ct(i))+1;return kt(c,0,h).join("")}function dm(e,i,n){if(e=te(e),e&&(n||i===r))return e.replace(Us,"");if(!e||!(i=Be(i)))return e;var c=ct(e),h=wa(c,ct(i));return kt(c,h).join("")}function gm(e,i){var n=al,c=cl;if(le(i)){var h="separator"in i?i.separator:h;n="length"in i?H(i.length):n,c="omission"in i?Be(i.omission):c}e=te(e);var f=e.length;if(dr(e)){var d=ct(e);f=d.length}if(n>=f)return e;var y=n-gr(c);if(y<1)return c;var m=d?kt(d,0,y).join(""):e.slice(0,y);if(h===r)return m+c;if(d&&(y+=m.length-y),Ln(h)){if(e.slice(y).search(h)){var P,S=m;for(h.global||(h=tn(h.source,te(Lo.exec(h))+"g")),h.lastIndex=0;P=h.exec(S);)var R=P.index;m=m.slice(0,R===r?y:R)}}else if(e.indexOf(Be(h),y)!=y){var T=m.lastIndexOf(h);T>-1&&(m=m.slice(0,T))}return m+c}function ym(e){return e=te(e),e&&Ol.test(e)?e.replace(qo,Vp):e}var vm=Er(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Hn=hc("toUpperCase");function cu(e,i,n){return e=te(e),i=n?r:i,i===r?Mp(e)?Wp(e):$p(e):e.match(i)||[]}var uu=B(function(e,i){try{return Ve(e,r,i)}catch(n){return Mn(n)?n:new k(n)}}),mm=Pt(function(e,i){return Ze(i,function(n){n=vt(n),Et(e,n,qn(e[n],e))}),e});function wm(e){var i=e==null?0:e.length,n=U();return e=i?ce(e,function(c){if(typeof c[1]!="function")throw new Xe(l);return[n(c[0]),c[1]]}):[],B(function(c){for(var h=-1;++h<i;){var f=e[h];if(Ve(f[0],this,c))return Ve(f[1],this,c)}})}function _m(e){return Kf(tt(e,O))}function Vn(e){return function(){return e}}function bm(e,i){return e==null||e!==e?i:e}var Em=pc(),Im=pc(!0);function Le(e){return e}function Kn(e){return za(typeof e=="function"?e:tt(e,O))}function Pm(e){return Va(tt(e,O))}function Sm(e,i){return Ka(e,tt(i,O))}var Om=B(function(e,i){return function(n){return Yr(n,e,i)}}),Rm=B(function(e,i){return function(n){return Yr(e,n,i)}});function Bn(e,i,n){var c=be(i),h=Wi(i,c);n==null&&!(le(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Wi(i,be(i)));var f=!(le(n)&&"chain"in n)||!!n.chain,d=Ot(e);return Ze(h,function(y){var m=i[y];e[y]=m,d&&(e.prototype[y]=function(){var P=this.__chain__;if(f||P){var S=e(this.__wrapped__),R=S.__actions__=qe(this.__actions__);return R.push({func:m,args:arguments,thisArg:e}),S.__chain__=P,S}return m.apply(e,Ft([this.value()],arguments))})}),e}function Nm(){return Ie._===this&&(Ie._=Xp),this}function Wn(){}function Cm(e){return e=H(e),B(function(i){return Ba(i,e)})}var $m=Pn(ce),Tm=Pn(fa),Am=Pn(Js);function hu(e){return Tn(e)?Gs(vt(e)):cd(e)}function xm(e){return function(i){return e==null?r:Zt(e,i)}}var Dm=dc(),Fm=dc(!0);function Jn(){return[]}function Gn(){return!1}function jm(){return{}}function qm(){return""}function Um(){return!0}function Mm(e,i){if(e=H(e),e<1||e>ur)return[];var n=dt,c=Oe(e,dt);i=U(i),e-=dt;for(var h=Zs(c,i);++n<e;)i(n);return h}function Lm(e){return z(e)?ce(e,vt):We(e)?[e]:qe($c(te(e)))}function km(e){var i=++Yp;return te(e)+i}var zm=Xi(function(e,i){return e+i},0),Hm=Sn("ceil"),Vm=Xi(function(e,i){return e/i},1),Km=Sn("floor");function Bm(e){return e&&e.length?Bi(e,Le,hn):r}function Wm(e,i){return e&&e.length?Bi(e,U(i,2),hn):r}function Jm(e){return ya(e,Le)}function Gm(e,i){return ya(e,U(i,2))}function Qm(e){return e&&e.length?Bi(e,Le,dn):r}function Ym(e,i){return e&&e.length?Bi(e,U(i,2),dn):r}var Zm=Xi(function(e,i){return e*i},1),Xm=Sn("round"),ew=Xi(function(e,i){return e-i},0);function tw(e){return e&&e.length?Ys(e,Le):0}function rw(e,i){return e&&e.length?Ys(e,U(i,2)):0}return p.after=Py,p.ary=kc,p.assign=lv,p.assignIn=tu,p.assignInWith=ps,p.assignWith=pv,p.at=fv,p.before=zc,p.bind=qn,p.bindAll=mm,p.bindKey=Hc,p.castArray=jy,p.chain=Uc,p.chunk=Kd,p.compact=Bd,p.concat=Wd,p.cond=wm,p.conforms=_m,p.constant=Vn,p.countBy=ty,p.create=dv,p.curry=Vc,p.curryRight=Kc,p.debounce=Bc,p.defaults=gv,p.defaultsDeep=yv,p.defer=Sy,p.delay=Oy,p.difference=Jd,p.differenceBy=Gd,p.differenceWith=Qd,p.drop=Yd,p.dropRight=Zd,p.dropRightWhile=Xd,p.dropWhile=eg,p.fill=tg,p.filter=iy,p.flatMap=oy,p.flatMapDeep=ay,p.flatMapDepth=cy,p.flatten=Dc,p.flattenDeep=rg,p.flattenDepth=ig,p.flip=Ry,p.flow=Em,p.flowRight=Im,p.fromPairs=sg,p.functions=Iv,p.functionsIn=Pv,p.groupBy=uy,p.initial=og,p.intersection=ag,p.intersectionBy=cg,p.intersectionWith=ug,p.invert=Ov,p.invertBy=Rv,p.invokeMap=ly,p.iteratee=Kn,p.keyBy=py,p.keys=be,p.keysIn=Me,p.map=os,p.mapKeys=Cv,p.mapValues=$v,p.matches=Pm,p.matchesProperty=Sm,p.memoize=cs,p.merge=Tv,p.mergeWith=ru,p.method=Om,p.methodOf=Rm,p.mixin=Bn,p.negate=us,p.nthArg=Cm,p.omit=Av,p.omitBy=xv,p.once=Ny,p.orderBy=fy,p.over=$m,p.overArgs=Cy,p.overEvery=Tm,p.overSome=Am,p.partial=Un,p.partialRight=Wc,p.partition=dy,p.pick=Dv,p.pickBy=iu,p.property=hu,p.propertyOf=xm,p.pull=fg,p.pullAll=jc,p.pullAllBy=dg,p.pullAllWith=gg,p.pullAt=yg,p.range=Dm,p.rangeRight=Fm,p.rearg=$y,p.reject=vy,p.remove=vg,p.rest=Ty,p.reverse=Fn,p.sampleSize=wy,p.set=jv,p.setWith=qv,p.shuffle=_y,p.slice=mg,p.sortBy=Iy,p.sortedUniq=Sg,p.sortedUniqBy=Og,p.split=om,p.spread=Ay,p.tail=Rg,p.take=Ng,p.takeRight=Cg,p.takeRightWhile=$g,p.takeWhile=Tg,p.tap=Bg,p.throttle=xy,p.thru=ns,p.toArray=Zc,p.toPairs=su,p.toPairsIn=nu,p.toPath=Lm,p.toPlainObject=eu,p.transform=Uv,p.unary=Dy,p.union=Ag,p.unionBy=xg,p.unionWith=Dg,p.uniq=Fg,p.uniqBy=jg,p.uniqWith=qg,p.unset=Mv,p.unzip=jn,p.unzipWith=qc,p.update=Lv,p.updateWith=kv,p.values=Sr,p.valuesIn=zv,p.without=Ug,p.words=cu,p.wrap=Fy,p.xor=Mg,p.xorBy=Lg,p.xorWith=kg,p.zip=zg,p.zipObject=Hg,p.zipObjectDeep=Vg,p.zipWith=Kg,p.entries=su,p.entriesIn=nu,p.extend=tu,p.extendWith=ps,Bn(p,p),p.add=zm,p.attempt=uu,p.camelCase=Bv,p.capitalize=ou,p.ceil=Hm,p.clamp=Hv,p.clone=qy,p.cloneDeep=My,p.cloneDeepWith=Ly,p.cloneWith=Uy,p.conformsTo=ky,p.deburr=au,p.defaultTo=bm,p.divide=Vm,p.endsWith=Wv,p.eq=ht,p.escape=Jv,p.escapeRegExp=Gv,p.every=ry,p.find=sy,p.findIndex=Ac,p.findKey=vv,p.findLast=ny,p.findLastIndex=xc,p.findLastKey=mv,p.floor=Km,p.forEach=Mc,p.forEachRight=Lc,p.forIn=wv,p.forInRight=_v,p.forOwn=bv,p.forOwnRight=Ev,p.get=kn,p.gt=zy,p.gte=Hy,p.has=Sv,p.hasIn=zn,p.head=Fc,p.identity=Le,p.includes=hy,p.indexOf=ng,p.inRange=Vv,p.invoke=Nv,p.isArguments=tr,p.isArray=z,p.isArrayBuffer=Vy,p.isArrayLike=Ue,p.isArrayLikeObject=ge,p.isBoolean=Ky,p.isBuffer=zt,p.isDate=By,p.isElement=Wy,p.isEmpty=Jy,p.isEqual=Gy,p.isEqualWith=Qy,p.isError=Mn,p.isFinite=Yy,p.isFunction=Ot,p.isInteger=Jc,p.isLength=hs,p.isMap=Gc,p.isMatch=Zy,p.isMatchWith=Xy,p.isNaN=ev,p.isNative=tv,p.isNil=iv,p.isNull=rv,p.isNumber=Qc,p.isObject=le,p.isObjectLike=pe,p.isPlainObject=ii,p.isRegExp=Ln,p.isSafeInteger=sv,p.isSet=Yc,p.isString=ls,p.isSymbol=We,p.isTypedArray=Pr,p.isUndefined=nv,p.isWeakMap=ov,p.isWeakSet=av,p.join=hg,p.kebabCase=Qv,p.last=it,p.lastIndexOf=lg,p.lowerCase=Yv,p.lowerFirst=Zv,p.lt=cv,p.lte=uv,p.max=Bm,p.maxBy=Wm,p.mean=Jm,p.meanBy=Gm,p.min=Qm,p.minBy=Ym,p.stubArray=Jn,p.stubFalse=Gn,p.stubObject=jm,p.stubString=qm,p.stubTrue=Um,p.multiply=Zm,p.nth=pg,p.noConflict=Nm,p.noop=Wn,p.now=as,p.pad=Xv,p.padEnd=em,p.padStart=tm,p.parseInt=rm,p.random=Kv,p.reduce=gy,p.reduceRight=yy,p.repeat=im,p.replace=sm,p.result=Fv,p.round=Xm,p.runInContext=v,p.sample=my,p.size=by,p.snakeCase=nm,p.some=Ey,p.sortedIndex=wg,p.sortedIndexBy=_g,p.sortedIndexOf=bg,p.sortedLastIndex=Eg,p.sortedLastIndexBy=Ig,p.sortedLastIndexOf=Pg,p.startCase=am,p.startsWith=cm,p.subtract=ew,p.sum=tw,p.sumBy=rw,p.template=um,p.times=Mm,p.toFinite=Rt,p.toInteger=H,p.toLength=Xc,p.toLower=hm,p.toNumber=st,p.toSafeInteger=hv,p.toString=te,p.toUpper=lm,p.trim=pm,p.trimEnd=fm,p.trimStart=dm,p.truncate=gm,p.unescape=ym,p.uniqueId=km,p.upperCase=vm,p.upperFirst=Hn,p.each=Mc,p.eachRight=Lc,p.first=Fc,Bn(p,function(){var e={};return gt(p,function(i,n){re.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,Ze(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Ze(["drop","take"],function(e,i){J.prototype[e]=function(n){n=n===r?1:_e(H(n),0);var c=this.__filtered__&&!i?new J(this):this.clone();return c.__filtered__?c.__takeCount__=Oe(n,c.__takeCount__):c.__views__.push({size:Oe(n,dt),type:e+(c.__dir__<0?"Right":"")}),c},J.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ze(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==Do||n==pl;J.prototype[e]=function(h){var f=this.clone();return f.__iteratees__.push({iteratee:U(h,3),type:n}),f.__filtered__=f.__filtered__||c,f}}),Ze(["head","last"],function(e,i){var n="take"+(i?"Right":"");J.prototype[e]=function(){return this[n](1).value()[0]}}),Ze(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");J.prototype[e]=function(){return this.__filtered__?new J(this):this[n](1)}}),J.prototype.compact=function(){return this.filter(Le)},J.prototype.find=function(e){return this.filter(e).head()},J.prototype.findLast=function(e){return this.reverse().find(e)},J.prototype.invokeMap=B(function(e,i){return typeof e=="function"?new J(this):this.map(function(n){return Yr(n,e,i)})}),J.prototype.reject=function(e){return this.filter(us(U(e)))},J.prototype.slice=function(e,i){e=H(e);var n=this;return n.__filtered__&&(e>0||i<0)?new J(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)},J.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},J.prototype.toArray=function(){return this.take(dt)},gt(J.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],f=c||/^find/.test(i);h&&(p.prototype[i]=function(){var d=this.__wrapped__,y=c?[1]:arguments,m=d instanceof J,P=y[0],S=m||z(d),R=function(W){var Q=h.apply(p,Ft([W],y));return c&&T?Q[0]:Q};S&&n&&typeof P=="function"&&P.length!=1&&(m=S=!1);var T=this.__chain__,F=!!this.__actions__.length,M=f&&!T,V=m&&!F;if(!f&&S){d=V?d:new J(this);var L=e.apply(d,y);return L.__actions__.push({func:ns,args:[R],thisArg:r}),new et(L,T)}return M&&V?e.apply(this,y):(L=this.thru(R),M?c?L.value()[0]:L.value():L)})}),Ze(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ti[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 f=this.value();return i.apply(z(f)?f:[],h)}return this[n](function(d){return i.apply(z(d)?d:[],h)})}}),gt(J.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";re.call(wr,c)||(wr[c]=[]),wr[c].push({name:i,func:n})}}),wr[Zi(r,G).name]=[{name:"wrapper",func:r}],J.prototype.clone=yf,J.prototype.reverse=vf,J.prototype.value=mf,p.prototype.at=Wg,p.prototype.chain=Jg,p.prototype.commit=Gg,p.prototype.next=Qg,p.prototype.plant=Zg,p.prototype.reverse=Xg,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=ey,p.prototype.first=p.prototype.head,Vr&&(p.prototype[Vr]=Yg),p},yr=Jp();Wt?((Wt.exports=yr)._=yr,Vs._=yr):Ie._=yr}).call(hi)})(bo,bo.exports);var kE=Object.defineProperty,zE=Object.defineProperties,HE=Object.getOwnPropertyDescriptors,ph=Object.getOwnPropertySymbols,VE=Object.prototype.hasOwnProperty,KE=Object.prototype.propertyIsEnumerable,fh=(a,t,r)=>t in a?kE(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,gs=(a,t)=>{for(var r in t||(t={}))VE.call(t,r)&&fh(a,r,t[r]);if(ph)for(var r of ph(t))KE.call(t,r)&&fh(a,r,t[r]);return a},BE=(a,t)=>zE(a,HE(t));function Kt(a,t,r){var s;const o=d_(a);return((s=t.rpcMap)==null?void 0:s[o.reference])||`${LE}?chainId=${o.namespace}:${o.reference}&projectId=${r}`}function cr(a){return a.includes(":")?a.split(":")[1]:a}function il(a){return a.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function WE(a,t){const r=Object.keys(t.namespaces).filter(o=>o.includes(a));if(!r.length)return[];const s=[];return r.forEach(o=>{const u=t.namespaces[o].accounts;s.push(...u)}),s}function JE(a={},t={}){const r=dh(a),s=dh(t);return bo.exports.merge(r,s)}function dh(a){var t,r,s,o;const u={};if(!Cr(a))return u;for(const[l,g]of Object.entries(a)){const w=Co(l)?[l]:g.chains,b=g.methods||[],C=g.events||[],O=g.rpcMap||{},N=li(l);u[N]=BE(gs(gs({},u[N]),g),{chains:Zn(w,(t=u[N])==null?void 0:t.chains),methods:Zn(b,(r=u[N])==null?void 0:r.methods),events:Zn(C,(s=u[N])==null?void 0:s.events),rpcMap:gs(gs({},O),(o=u[N])==null?void 0:o.rpcMap)})}return u}function GE(a){return a.includes(":")?a.split(":")[2]:a}function QE(a){const t={};for(const[r,s]of Object.entries(a)){const o=s.methods||[],u=s.events||[],l=s.accounts||[],g=Co(r)?[r]:s.chains?s.chains:il(s.accounts);t[r]={chains:g,methods:o,events:u,accounts:l}}return t}function no(a){return typeof a=="number"?a:a.includes("0x")?parseInt(a,16):a.includes(":")?Number(a.split(":")[1]):Number(a)}const sl={},ue=a=>sl[a],oo=(a,t)=>{sl[a]=t};class YE{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(At.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 o=cr(r);t[o]=this.createHttpProvider(o,(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||Kt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(s,ue("disableProviderPing")))}}class ZE{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(At.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||Kt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(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 o=parseInt(cr(r));t[o]=this.createHttpProvider(o,(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 o=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const u=parseInt(o,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:o}]},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 XE{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(At.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 o=cr(r);t[o]=this.createHttpProvider(o,(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||Kt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(s,ue("disableProviderPing")))}}class eI{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(At.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 o=cr(r);t[o]=this.createHttpProvider(o,(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||Kt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(s,ue("disableProviderPing")))}}class tI{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(At.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),o=cr(r);t[o]=this.createHttpProvider(o,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 Tt(new Bt(s,ue("disableProviderPing")))}}class rI{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(At.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 o=cr(r);t[o]=this.createHttpProvider(o,(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||Kt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(s,ue("disableProviderPing")))}}class iI{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(At.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 o=cr(r);t[o]=this.createHttpProvider(o,(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||Kt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(s,ue("disableProviderPing")))}}class sI{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||Kt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(At.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||Kt(t,this.namespace);return typeof s>"u"?void 0:new Tt(new Bt(s,ue("disableProviderPing")))}}var nI=Object.defineProperty,oI=Object.defineProperties,aI=Object.getOwnPropertyDescriptors,gh=Object.getOwnPropertySymbols,cI=Object.prototype.hasOwnProperty,uI=Object.prototype.propertyIsEnumerable,yh=(a,t,r)=>t in a?nI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,ys=(a,t)=>{for(var r in t||(t={}))cI.call(t,r)&&yh(a,r,t[r]);if(gh)for(var r of gh(t))uI.call(t,r)&&yh(a,r,t[r]);return a},ao=(a,t)=>oI(a,aI(t));class xo{constructor(t){this.events=new Fe.ss,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:E.Tt(E.k({level:(t==null?void 0:t.logger)||hh})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new xo(t);return await r.initialize(),r}async request(t,r){const[s,o]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:ys({},t),chainId:`${s}:${o}`,topic:this.session.topic})}sendAsync(t,r,s){const o=new Date().getTime();this.request(t,s).then(u=>r(null,E.formatJsonRpcResult(o,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:ve("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:o}=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 o().then(u=>{this.session=u,this.namespaces||(this.namespaces=QE(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==tl)throw u;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[s,o]=this.validateChain(t);this.getProvider(s).setDefaultChain(o,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(sr(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 OE.init({logger:this.providerOpts.logger||hh,relayUrl:this.providerOpts.relayUrl||qE,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=>li(r)))];oo("client",this.client),oo("events",this.events),oo("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=WE(r,this.session),o=il(s),u=JE(this.namespaces,this.optionalNamespaces),l=ao(ys({},u[r]),{accounts:s,chains:o});switch(r){case"eip155":this.rpcProviders[r]=new ZE({namespace:l});break;case"solana":this.rpcProviders[r]=new XE({namespace:l});break;case"cosmos":this.rpcProviders[r]=new eI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new YE({namespace:l});break;case"cip34":this.rpcProviders[r]=new tI({namespace:l});break;case"elrond":this.rpcProviders[r]=new rI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new iI({namespace:l});break;case"near":this.rpcProviders[r]=new sI({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 o=s.data;o&&sr(o)&&this.events.emit("accountsChanged",o.map(GE))}else if(s.name==="chainChanged"){const o=r.chainId,u=r.event.data,l=li(o),g=no(o)!==no(u)?`${l}:${no(u)}`:o;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:o}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=ao(ys({},u),{namespaces:o}),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",ao(ys({},ve("USER_DISCONNECTED")),{data:t.topic}))}),this.on(At.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:o}=t;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=o,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=>li(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 o=li(Object.keys(this.namespaces)[0]),u=this.rpcProviders[o].getDefaultChain();return[o,u]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var s;if(!this.namespaces)return;const[o,u]=this.validateChain(t);r||this.getProvider(o).setDefaultChain(u),((s=this.namespaces[o])!=null?s:this.namespaces[`${o}:${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(`${lh}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${lh}/${t}`)}}const hI=xo,lI="wc",pI="ethereum_provider",fI=`${lI}@2:${pI}:`,dI="https://rpc.walletconnect.com/v1/",bs=["eth_sendTransaction","personal_sign"],nl=["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"],Es=["chainChanged","accountsChanged"],ol=["chainChanged","accountsChanged","message","disconnect","connect"];var gI=Object.defineProperty,yI=Object.defineProperties,vI=Object.getOwnPropertyDescriptors,vh=Object.getOwnPropertySymbols,mI=Object.prototype.hasOwnProperty,wI=Object.prototype.propertyIsEnumerable,mh=(a,t,r)=>t in a?gI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,fi=(a,t)=>{for(var r in t||(t={}))mI.call(t,r)&&mh(a,r,t[r]);if(vh)for(var r of vh(t))wI.call(t,r)&&mh(a,r,t[r]);return a},wh=(a,t)=>yI(a,vI(t));function Is(a){return Number(a[0].split(":")[1])}function co(a){return`0x${a.toString(16)}`}function _I(a){const{chains:t,optionalChains:r,methods:s,optionalMethods:o,events:u,optionalEvents:l,rpcMap:g}=a;if(!uo(t))throw new Error("Invalid chains");const w={chains:t,methods:s||bs,events:u||Es,rpcMap:fi({},t.length?{[Is(t)]:g[Is(t)]}:{})},b=u==null?void 0:u.filter(q=>!Es.includes(q)),C=s==null?void 0:s.filter(q=>!bs.includes(q));if(!r&&!l&&!o&&!(b!=null&&b.length)&&!(C!=null&&C.length))return{required:t.length?w:void 0};const O=(b==null?void 0:b.length)&&(C==null?void 0:C.length)||!r,N={chains:[...new Set(O?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(o!=null&&o.length?o:nl))],events:[...new Set(w.events.concat(l!=null&&l.length?l:ol))],rpcMap:g};return{required:t.length?w:void 0,optional:r.length?N:void 0}}class Rs{constructor(){this.events=new Fe.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=fI,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 Rs;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}=_I(this.rpc);try{const o=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(wh(fi({namespaces:fi({},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(!o)return;const u=dw(o.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:co(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}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",co(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",wh(fi({},yw("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",co(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,o]=t.split(":");return{chainId:`${r}:${s}`,address:o}}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 o=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=o.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=o.length?(t==null?void 0:t.methods)||bs:[],w=o.length?(t==null?void 0:t.events)||Es:[],b=(t==null?void 0:t.optionalMethods)||[],C=(t==null?void 0:t.optionalEvents)||[],O=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),N=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(q=>this.formatChainId(q)),optionalChains:u.map(q=>this.formatChainId(q)),methods:g,events:w,optionalMethods:b,optionalEvents:C,rpcMap:O,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:N,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const s={};return t.forEach(o=>{s[o]=this.getRpcUrl(o,r)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?Is(this.rpc.chains):Is(this.rpc.optionalChains),this.signer=await hI.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 Promise.resolve().then(()=>require("./index-DRCX2iXw.js")).then(o=>o.index);r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(fi({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:o}=t;r&&uo(r)&&(this.rpc.chains=r.map(u=>this.formatChainId(u)),r.forEach(u=>{this.rpc.rpcMap[u]=(o==null?void 0:o[u])||this.getRpcUrl(u)})),s&&uo(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(u=>this.formatChainId(u)),s.forEach(u=>{this.rpc.rpcMap[u]=(o==null?void 0:o[u])||this.getRpcUrl(u)}))}getRpcUrl(t,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${dI}?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 bI=Rs;exports.EthereumProvider=bI;exports.OPTIONAL_EVENTS=ol;exports.OPTIONAL_METHODS=nl;exports.REQUIRED_EVENTS=Es;exports.REQUIRED_METHODS=bs;exports.default=Rs;
|
|
46
|
+
}`;var V=uu(function(){return X(f,F+"return "+R).apply(r,d)});if(V.source=R,Mn(V))throw V;return V}function hm(e){return te(e).toLowerCase()}function lm(e){return te(e).toUpperCase()}function pm(e,i,n){if(e=te(e),e&&(n||i===r))return ma(e);if(!e||!(i=Be(i)))return e;var c=ct(e),h=ct(i),f=wa(c,h),d=_a(c,h)+1;return kt(c,f,d).join("")}function fm(e,i,n){if(e=te(e),e&&(n||i===r))return e.slice(0,Ea(e)+1);if(!e||!(i=Be(i)))return e;var c=ct(e),h=_a(c,ct(i))+1;return kt(c,0,h).join("")}function dm(e,i,n){if(e=te(e),e&&(n||i===r))return e.replace(Us,"");if(!e||!(i=Be(i)))return e;var c=ct(e),h=wa(c,ct(i));return kt(c,h).join("")}function gm(e,i){var n=al,c=cl;if(le(i)){var h="separator"in i?i.separator:h;n="length"in i?H(i.length):n,c="omission"in i?Be(i.omission):c}e=te(e);var f=e.length;if(dr(e)){var d=ct(e);f=d.length}if(n>=f)return e;var y=n-gr(c);if(y<1)return c;var m=d?kt(d,0,y).join(""):e.slice(0,y);if(h===r)return m+c;if(d&&(y+=m.length-y),Ln(h)){if(e.slice(y).search(h)){var P,S=m;for(h.global||(h=tn(h.source,te(Lo.exec(h))+"g")),h.lastIndex=0;P=h.exec(S);)var R=P.index;m=m.slice(0,R===r?y:R)}}else if(e.indexOf(Be(h),y)!=y){var T=m.lastIndexOf(h);T>-1&&(m=m.slice(0,T))}return m+c}function ym(e){return e=te(e),e&&Ol.test(e)?e.replace(qo,Vp):e}var vm=Er(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Hn=hc("toUpperCase");function cu(e,i,n){return e=te(e),i=n?r:i,i===r?Mp(e)?Wp(e):$p(e):e.match(i)||[]}var uu=B(function(e,i){try{return Ve(e,r,i)}catch(n){return Mn(n)?n:new k(n)}}),mm=Pt(function(e,i){return Ze(i,function(n){n=vt(n),Et(e,n,qn(e[n],e))}),e});function wm(e){var i=e==null?0:e.length,n=U();return e=i?ce(e,function(c){if(typeof c[1]!="function")throw new Xe(l);return[n(c[0]),c[1]]}):[],B(function(c){for(var h=-1;++h<i;){var f=e[h];if(Ve(f[0],this,c))return Ve(f[1],this,c)}})}function _m(e){return Kf(tt(e,O))}function Vn(e){return function(){return e}}function bm(e,i){return e==null||e!==e?i:e}var Em=pc(),Im=pc(!0);function Le(e){return e}function Kn(e){return za(typeof e=="function"?e:tt(e,O))}function Pm(e){return Va(tt(e,O))}function Sm(e,i){return Ka(e,tt(i,O))}var Om=B(function(e,i){return function(n){return Yr(n,e,i)}}),Rm=B(function(e,i){return function(n){return Yr(e,n,i)}});function Bn(e,i,n){var c=be(i),h=Wi(i,c);n==null&&!(le(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Wi(i,be(i)));var f=!(le(n)&&"chain"in n)||!!n.chain,d=Ot(e);return Ze(h,function(y){var m=i[y];e[y]=m,d&&(e.prototype[y]=function(){var P=this.__chain__;if(f||P){var S=e(this.__wrapped__),R=S.__actions__=qe(this.__actions__);return R.push({func:m,args:arguments,thisArg:e}),S.__chain__=P,S}return m.apply(e,Ft([this.value()],arguments))})}),e}function Nm(){return Ie._===this&&(Ie._=Xp),this}function Wn(){}function Cm(e){return e=H(e),B(function(i){return Ba(i,e)})}var $m=Pn(ce),Tm=Pn(fa),Am=Pn(Js);function hu(e){return Tn(e)?Gs(vt(e)):cd(e)}function xm(e){return function(i){return e==null?r:Zt(e,i)}}var Dm=dc(),Fm=dc(!0);function Jn(){return[]}function Gn(){return!1}function jm(){return{}}function qm(){return""}function Um(){return!0}function Mm(e,i){if(e=H(e),e<1||e>ur)return[];var n=dt,c=Oe(e,dt);i=U(i),e-=dt;for(var h=Zs(c,i);++n<e;)i(n);return h}function Lm(e){return z(e)?ce(e,vt):We(e)?[e]:qe($c(te(e)))}function km(e){var i=++Yp;return te(e)+i}var zm=Xi(function(e,i){return e+i},0),Hm=Sn("ceil"),Vm=Xi(function(e,i){return e/i},1),Km=Sn("floor");function Bm(e){return e&&e.length?Bi(e,Le,hn):r}function Wm(e,i){return e&&e.length?Bi(e,U(i,2),hn):r}function Jm(e){return ya(e,Le)}function Gm(e,i){return ya(e,U(i,2))}function Qm(e){return e&&e.length?Bi(e,Le,dn):r}function Ym(e,i){return e&&e.length?Bi(e,U(i,2),dn):r}var Zm=Xi(function(e,i){return e*i},1),Xm=Sn("round"),ew=Xi(function(e,i){return e-i},0);function tw(e){return e&&e.length?Ys(e,Le):0}function rw(e,i){return e&&e.length?Ys(e,U(i,2)):0}return p.after=Py,p.ary=kc,p.assign=lv,p.assignIn=tu,p.assignInWith=ps,p.assignWith=pv,p.at=fv,p.before=zc,p.bind=qn,p.bindAll=mm,p.bindKey=Hc,p.castArray=jy,p.chain=Uc,p.chunk=Kd,p.compact=Bd,p.concat=Wd,p.cond=wm,p.conforms=_m,p.constant=Vn,p.countBy=ty,p.create=dv,p.curry=Vc,p.curryRight=Kc,p.debounce=Bc,p.defaults=gv,p.defaultsDeep=yv,p.defer=Sy,p.delay=Oy,p.difference=Jd,p.differenceBy=Gd,p.differenceWith=Qd,p.drop=Yd,p.dropRight=Zd,p.dropRightWhile=Xd,p.dropWhile=eg,p.fill=tg,p.filter=iy,p.flatMap=oy,p.flatMapDeep=ay,p.flatMapDepth=cy,p.flatten=Dc,p.flattenDeep=rg,p.flattenDepth=ig,p.flip=Ry,p.flow=Em,p.flowRight=Im,p.fromPairs=sg,p.functions=Iv,p.functionsIn=Pv,p.groupBy=uy,p.initial=og,p.intersection=ag,p.intersectionBy=cg,p.intersectionWith=ug,p.invert=Ov,p.invertBy=Rv,p.invokeMap=ly,p.iteratee=Kn,p.keyBy=py,p.keys=be,p.keysIn=Me,p.map=os,p.mapKeys=Cv,p.mapValues=$v,p.matches=Pm,p.matchesProperty=Sm,p.memoize=cs,p.merge=Tv,p.mergeWith=ru,p.method=Om,p.methodOf=Rm,p.mixin=Bn,p.negate=us,p.nthArg=Cm,p.omit=Av,p.omitBy=xv,p.once=Ny,p.orderBy=fy,p.over=$m,p.overArgs=Cy,p.overEvery=Tm,p.overSome=Am,p.partial=Un,p.partialRight=Wc,p.partition=dy,p.pick=Dv,p.pickBy=iu,p.property=hu,p.propertyOf=xm,p.pull=fg,p.pullAll=jc,p.pullAllBy=dg,p.pullAllWith=gg,p.pullAt=yg,p.range=Dm,p.rangeRight=Fm,p.rearg=$y,p.reject=vy,p.remove=vg,p.rest=Ty,p.reverse=Fn,p.sampleSize=wy,p.set=jv,p.setWith=qv,p.shuffle=_y,p.slice=mg,p.sortBy=Iy,p.sortedUniq=Sg,p.sortedUniqBy=Og,p.split=om,p.spread=Ay,p.tail=Rg,p.take=Ng,p.takeRight=Cg,p.takeRightWhile=$g,p.takeWhile=Tg,p.tap=Bg,p.throttle=xy,p.thru=ns,p.toArray=Zc,p.toPairs=su,p.toPairsIn=nu,p.toPath=Lm,p.toPlainObject=eu,p.transform=Uv,p.unary=Dy,p.union=Ag,p.unionBy=xg,p.unionWith=Dg,p.uniq=Fg,p.uniqBy=jg,p.uniqWith=qg,p.unset=Mv,p.unzip=jn,p.unzipWith=qc,p.update=Lv,p.updateWith=kv,p.values=Sr,p.valuesIn=zv,p.without=Ug,p.words=cu,p.wrap=Fy,p.xor=Mg,p.xorBy=Lg,p.xorWith=kg,p.zip=zg,p.zipObject=Hg,p.zipObjectDeep=Vg,p.zipWith=Kg,p.entries=su,p.entriesIn=nu,p.extend=tu,p.extendWith=ps,Bn(p,p),p.add=zm,p.attempt=uu,p.camelCase=Bv,p.capitalize=ou,p.ceil=Hm,p.clamp=Hv,p.clone=qy,p.cloneDeep=My,p.cloneDeepWith=Ly,p.cloneWith=Uy,p.conformsTo=ky,p.deburr=au,p.defaultTo=bm,p.divide=Vm,p.endsWith=Wv,p.eq=ht,p.escape=Jv,p.escapeRegExp=Gv,p.every=ry,p.find=sy,p.findIndex=Ac,p.findKey=vv,p.findLast=ny,p.findLastIndex=xc,p.findLastKey=mv,p.floor=Km,p.forEach=Mc,p.forEachRight=Lc,p.forIn=wv,p.forInRight=_v,p.forOwn=bv,p.forOwnRight=Ev,p.get=kn,p.gt=zy,p.gte=Hy,p.has=Sv,p.hasIn=zn,p.head=Fc,p.identity=Le,p.includes=hy,p.indexOf=ng,p.inRange=Vv,p.invoke=Nv,p.isArguments=tr,p.isArray=z,p.isArrayBuffer=Vy,p.isArrayLike=Ue,p.isArrayLikeObject=ge,p.isBoolean=Ky,p.isBuffer=zt,p.isDate=By,p.isElement=Wy,p.isEmpty=Jy,p.isEqual=Gy,p.isEqualWith=Qy,p.isError=Mn,p.isFinite=Yy,p.isFunction=Ot,p.isInteger=Jc,p.isLength=hs,p.isMap=Gc,p.isMatch=Zy,p.isMatchWith=Xy,p.isNaN=ev,p.isNative=tv,p.isNil=iv,p.isNull=rv,p.isNumber=Qc,p.isObject=le,p.isObjectLike=pe,p.isPlainObject=ii,p.isRegExp=Ln,p.isSafeInteger=sv,p.isSet=Yc,p.isString=ls,p.isSymbol=We,p.isTypedArray=Pr,p.isUndefined=nv,p.isWeakMap=ov,p.isWeakSet=av,p.join=hg,p.kebabCase=Qv,p.last=it,p.lastIndexOf=lg,p.lowerCase=Yv,p.lowerFirst=Zv,p.lt=cv,p.lte=uv,p.max=Bm,p.maxBy=Wm,p.mean=Jm,p.meanBy=Gm,p.min=Qm,p.minBy=Ym,p.stubArray=Jn,p.stubFalse=Gn,p.stubObject=jm,p.stubString=qm,p.stubTrue=Um,p.multiply=Zm,p.nth=pg,p.noConflict=Nm,p.noop=Wn,p.now=as,p.pad=Xv,p.padEnd=em,p.padStart=tm,p.parseInt=rm,p.random=Kv,p.reduce=gy,p.reduceRight=yy,p.repeat=im,p.replace=sm,p.result=Fv,p.round=Xm,p.runInContext=v,p.sample=my,p.size=by,p.snakeCase=nm,p.some=Ey,p.sortedIndex=wg,p.sortedIndexBy=_g,p.sortedIndexOf=bg,p.sortedLastIndex=Eg,p.sortedLastIndexBy=Ig,p.sortedLastIndexOf=Pg,p.startCase=am,p.startsWith=cm,p.subtract=ew,p.sum=tw,p.sumBy=rw,p.template=um,p.times=Mm,p.toFinite=Rt,p.toInteger=H,p.toLength=Xc,p.toLower=hm,p.toNumber=st,p.toSafeInteger=hv,p.toString=te,p.toUpper=lm,p.trim=pm,p.trimEnd=fm,p.trimStart=dm,p.truncate=gm,p.unescape=ym,p.uniqueId=km,p.upperCase=vm,p.upperFirst=Hn,p.each=Mc,p.eachRight=Lc,p.first=Fc,Bn(p,function(){var e={};return gt(p,function(i,n){re.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,Ze(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Ze(["drop","take"],function(e,i){J.prototype[e]=function(n){n=n===r?1:_e(H(n),0);var c=this.__filtered__&&!i?new J(this):this.clone();return c.__filtered__?c.__takeCount__=Oe(n,c.__takeCount__):c.__views__.push({size:Oe(n,dt),type:e+(c.__dir__<0?"Right":"")}),c},J.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ze(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==Do||n==pl;J.prototype[e]=function(h){var f=this.clone();return f.__iteratees__.push({iteratee:U(h,3),type:n}),f.__filtered__=f.__filtered__||c,f}}),Ze(["head","last"],function(e,i){var n="take"+(i?"Right":"");J.prototype[e]=function(){return this[n](1).value()[0]}}),Ze(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");J.prototype[e]=function(){return this.__filtered__?new J(this):this[n](1)}}),J.prototype.compact=function(){return this.filter(Le)},J.prototype.find=function(e){return this.filter(e).head()},J.prototype.findLast=function(e){return this.reverse().find(e)},J.prototype.invokeMap=B(function(e,i){return typeof e=="function"?new J(this):this.map(function(n){return Yr(n,e,i)})}),J.prototype.reject=function(e){return this.filter(us(U(e)))},J.prototype.slice=function(e,i){e=H(e);var n=this;return n.__filtered__&&(e>0||i<0)?new J(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)},J.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},J.prototype.toArray=function(){return this.take(dt)},gt(J.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],f=c||/^find/.test(i);h&&(p.prototype[i]=function(){var d=this.__wrapped__,y=c?[1]:arguments,m=d instanceof J,P=y[0],S=m||z(d),R=function(W){var Q=h.apply(p,Ft([W],y));return c&&T?Q[0]:Q};S&&n&&typeof P=="function"&&P.length!=1&&(m=S=!1);var T=this.__chain__,F=!!this.__actions__.length,M=f&&!T,V=m&&!F;if(!f&&S){d=V?d:new J(this);var L=e.apply(d,y);return L.__actions__.push({func:ns,args:[R],thisArg:r}),new et(L,T)}return M&&V?e.apply(this,y):(L=this.thru(R),M?c?L.value()[0]:L.value():L)})}),Ze(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ti[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 f=this.value();return i.apply(z(f)?f:[],h)}return this[n](function(d){return i.apply(z(d)?d:[],h)})}}),gt(J.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";re.call(wr,c)||(wr[c]=[]),wr[c].push({name:i,func:n})}}),wr[Zi(r,G).name]=[{name:"wrapper",func:r}],J.prototype.clone=yf,J.prototype.reverse=vf,J.prototype.value=mf,p.prototype.at=Wg,p.prototype.chain=Jg,p.prototype.commit=Gg,p.prototype.next=Qg,p.prototype.plant=Zg,p.prototype.reverse=Xg,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=ey,p.prototype.first=p.prototype.head,Vr&&(p.prototype[Vr]=Yg),p},yr=Jp();Wt?((Wt.exports=yr)._=yr,Vs._=yr):Ie._=yr}).call(hi)})(bo,bo.exports);var kE=Object.defineProperty,zE=Object.defineProperties,HE=Object.getOwnPropertyDescriptors,ph=Object.getOwnPropertySymbols,VE=Object.prototype.hasOwnProperty,KE=Object.prototype.propertyIsEnumerable,fh=(a,t,r)=>t in a?kE(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,gs=(a,t)=>{for(var r in t||(t={}))VE.call(t,r)&&fh(a,r,t[r]);if(ph)for(var r of ph(t))KE.call(t,r)&&fh(a,r,t[r]);return a},BE=(a,t)=>zE(a,HE(t));function Kt(a,t,r){var s;const o=d_(a);return((s=t.rpcMap)==null?void 0:s[o.reference])||`${LE}?chainId=${o.namespace}:${o.reference}&projectId=${r}`}function cr(a){return a.includes(":")?a.split(":")[1]:a}function il(a){return a.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function WE(a,t){const r=Object.keys(t.namespaces).filter(o=>o.includes(a));if(!r.length)return[];const s=[];return r.forEach(o=>{const u=t.namespaces[o].accounts;s.push(...u)}),s}function JE(a={},t={}){const r=dh(a),s=dh(t);return bo.exports.merge(r,s)}function dh(a){var t,r,s,o;const u={};if(!Cr(a))return u;for(const[l,g]of Object.entries(a)){const w=Co(l)?[l]:g.chains,b=g.methods||[],C=g.events||[],O=g.rpcMap||{},N=li(l);u[N]=BE(gs(gs({},u[N]),g),{chains:Zn(w,(t=u[N])==null?void 0:t.chains),methods:Zn(b,(r=u[N])==null?void 0:r.methods),events:Zn(C,(s=u[N])==null?void 0:s.events),rpcMap:gs(gs({},O),(o=u[N])==null?void 0:o.rpcMap)})}return u}function GE(a){return a.includes(":")?a.split(":")[2]:a}function QE(a){const t={};for(const[r,s]of Object.entries(a)){const o=s.methods||[],u=s.events||[],l=s.accounts||[],g=Co(r)?[r]:s.chains?s.chains:il(s.accounts);t[r]={chains:g,methods:o,events:u,accounts:l}}return t}function no(a){return typeof a=="number"?a:a.includes("0x")?parseInt(a,16):a.includes(":")?Number(a.split(":")[1]):Number(a)}const sl={},ue=a=>sl[a],oo=(a,t)=>{sl[a]=t};class YE{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(At.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 o=cr(r);t[o]=this.createHttpProvider(o,(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||Kt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(s,ue("disableProviderPing")))}}class ZE{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(At.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||Kt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(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 o=parseInt(cr(r));t[o]=this.createHttpProvider(o,(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 o=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const u=parseInt(o,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:o}]},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 XE{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(At.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 o=cr(r);t[o]=this.createHttpProvider(o,(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||Kt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(s,ue("disableProviderPing")))}}class eI{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(At.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 o=cr(r);t[o]=this.createHttpProvider(o,(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||Kt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(s,ue("disableProviderPing")))}}class tI{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(At.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),o=cr(r);t[o]=this.createHttpProvider(o,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 Tt(new Bt(s,ue("disableProviderPing")))}}class rI{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(At.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 o=cr(r);t[o]=this.createHttpProvider(o,(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||Kt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(s,ue("disableProviderPing")))}}class iI{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(At.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 o=cr(r);t[o]=this.createHttpProvider(o,(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||Kt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Tt(new Bt(s,ue("disableProviderPing")))}}class sI{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||Kt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(At.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||Kt(t,this.namespace);return typeof s>"u"?void 0:new Tt(new Bt(s,ue("disableProviderPing")))}}var nI=Object.defineProperty,oI=Object.defineProperties,aI=Object.getOwnPropertyDescriptors,gh=Object.getOwnPropertySymbols,cI=Object.prototype.hasOwnProperty,uI=Object.prototype.propertyIsEnumerable,yh=(a,t,r)=>t in a?nI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,ys=(a,t)=>{for(var r in t||(t={}))cI.call(t,r)&&yh(a,r,t[r]);if(gh)for(var r of gh(t))uI.call(t,r)&&yh(a,r,t[r]);return a},ao=(a,t)=>oI(a,aI(t));class xo{constructor(t){this.events=new Fe.ss,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:E.Tt(E.k({level:(t==null?void 0:t.logger)||hh})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new xo(t);return await r.initialize(),r}async request(t,r){const[s,o]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:ys({},t),chainId:`${s}:${o}`,topic:this.session.topic})}sendAsync(t,r,s){const o=new Date().getTime();this.request(t,s).then(u=>r(null,E.formatJsonRpcResult(o,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:ve("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:o}=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 o().then(u=>{this.session=u,this.namespaces||(this.namespaces=QE(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==tl)throw u;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[s,o]=this.validateChain(t);this.getProvider(s).setDefaultChain(o,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(sr(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 OE.init({logger:this.providerOpts.logger||hh,relayUrl:this.providerOpts.relayUrl||qE,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=>li(r)))];oo("client",this.client),oo("events",this.events),oo("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=WE(r,this.session),o=il(s),u=JE(this.namespaces,this.optionalNamespaces),l=ao(ys({},u[r]),{accounts:s,chains:o});switch(r){case"eip155":this.rpcProviders[r]=new ZE({namespace:l});break;case"solana":this.rpcProviders[r]=new XE({namespace:l});break;case"cosmos":this.rpcProviders[r]=new eI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new YE({namespace:l});break;case"cip34":this.rpcProviders[r]=new tI({namespace:l});break;case"elrond":this.rpcProviders[r]=new rI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new iI({namespace:l});break;case"near":this.rpcProviders[r]=new sI({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 o=s.data;o&&sr(o)&&this.events.emit("accountsChanged",o.map(GE))}else if(s.name==="chainChanged"){const o=r.chainId,u=r.event.data,l=li(o),g=no(o)!==no(u)?`${l}:${no(u)}`:o;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:o}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=ao(ys({},u),{namespaces:o}),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",ao(ys({},ve("USER_DISCONNECTED")),{data:t.topic}))}),this.on(At.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:o}=t;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=o,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=>li(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 o=li(Object.keys(this.namespaces)[0]),u=this.rpcProviders[o].getDefaultChain();return[o,u]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var s;if(!this.namespaces)return;const[o,u]=this.validateChain(t);r||this.getProvider(o).setDefaultChain(u),((s=this.namespaces[o])!=null?s:this.namespaces[`${o}:${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(`${lh}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${lh}/${t}`)}}const hI=xo,lI="wc",pI="ethereum_provider",fI=`${lI}@2:${pI}:`,dI="https://rpc.walletconnect.com/v1/",bs=["eth_sendTransaction","personal_sign"],nl=["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"],Es=["chainChanged","accountsChanged"],ol=["chainChanged","accountsChanged","message","disconnect","connect"];var gI=Object.defineProperty,yI=Object.defineProperties,vI=Object.getOwnPropertyDescriptors,vh=Object.getOwnPropertySymbols,mI=Object.prototype.hasOwnProperty,wI=Object.prototype.propertyIsEnumerable,mh=(a,t,r)=>t in a?gI(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,fi=(a,t)=>{for(var r in t||(t={}))mI.call(t,r)&&mh(a,r,t[r]);if(vh)for(var r of vh(t))wI.call(t,r)&&mh(a,r,t[r]);return a},wh=(a,t)=>yI(a,vI(t));function Is(a){return Number(a[0].split(":")[1])}function co(a){return`0x${a.toString(16)}`}function _I(a){const{chains:t,optionalChains:r,methods:s,optionalMethods:o,events:u,optionalEvents:l,rpcMap:g}=a;if(!uo(t))throw new Error("Invalid chains");const w={chains:t,methods:s||bs,events:u||Es,rpcMap:fi({},t.length?{[Is(t)]:g[Is(t)]}:{})},b=u==null?void 0:u.filter(q=>!Es.includes(q)),C=s==null?void 0:s.filter(q=>!bs.includes(q));if(!r&&!l&&!o&&!(b!=null&&b.length)&&!(C!=null&&C.length))return{required:t.length?w:void 0};const O=(b==null?void 0:b.length)&&(C==null?void 0:C.length)||!r,N={chains:[...new Set(O?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(o!=null&&o.length?o:nl))],events:[...new Set(w.events.concat(l!=null&&l.length?l:ol))],rpcMap:g};return{required:t.length?w:void 0,optional:r.length?N:void 0}}class Rs{constructor(){this.events=new Fe.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=fI,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 Rs;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}=_I(this.rpc);try{const o=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(wh(fi({namespaces:fi({},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(!o)return;const u=dw(o.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:co(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}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",co(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",wh(fi({},yw("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",co(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,o]=t.split(":");return{chainId:`${r}:${s}`,address:o}}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 o=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=o.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=o.length?(t==null?void 0:t.methods)||bs:[],w=o.length?(t==null?void 0:t.events)||Es:[],b=(t==null?void 0:t.optionalMethods)||[],C=(t==null?void 0:t.optionalEvents)||[],O=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),N=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(q=>this.formatChainId(q)),optionalChains:u.map(q=>this.formatChainId(q)),methods:g,events:w,optionalMethods:b,optionalEvents:C,rpcMap:O,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:N,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const s={};return t.forEach(o=>{s[o]=this.getRpcUrl(o,r)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?Is(this.rpc.chains):Is(this.rpc.optionalChains),this.signer=await hI.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 Promise.resolve().then(()=>require("./index-CvEfOpn2.js")).then(o=>o.index);r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(fi({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:o}=t;r&&uo(r)&&(this.rpc.chains=r.map(u=>this.formatChainId(u)),r.forEach(u=>{this.rpc.rpcMap[u]=(o==null?void 0:o[u])||this.getRpcUrl(u)})),s&&uo(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(u=>this.formatChainId(u)),s.forEach(u=>{this.rpc.rpcMap[u]=(o==null?void 0:o[u])||this.getRpcUrl(u)}))}getRpcUrl(t,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${dI}?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 bI=Rs;exports.EthereumProvider=bI;exports.OPTIONAL_EVENTS=ol;exports.OPTIONAL_METHODS=nl;exports.REQUIRED_EVENTS=Es;exports.REQUIRED_METHODS=bs;exports.default=Rs;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { q as ot, y as xo } from "./index-
|
|
2
|
-
import { a as Do, d as Z, g as Ow } from "./address-
|
|
3
|
-
import { s as Fo, x as Lh, r as kh, H as Rw, c as zh, q as Ss } from "./evm-
|
|
4
|
-
import { c as F } from "./index-
|
|
5
|
-
import { I as ur, f as gt, t as nt, c as $u, C as $w, d as Cw, r as Nw, a as xr, g as Hh, i as bt, b as Cs, e as Cu, h as Tw, j as Aw, k as Ns, p as Vh, T as Ts, l as As, E as ke, m as xw, y as Qe, P as Nu, Q as Dw, n as Fw, o as qo, q as xs, s as Bt, _ as qw, u as jw, v as Tu } from "./index-
|
|
6
|
-
import { o as Au } from "./browser-ponyfill-
|
|
1
|
+
import { q as ot, y as xo } from "./index-DvozGHS-.mjs";
|
|
2
|
+
import { a as Do, d as Z, g as Ow } from "./address-DqsMcbcT.mjs";
|
|
3
|
+
import { s as Fo, x as Lh, r as kh, H as Rw, c as zh, q as Ss } from "./evm--hXXT-db.mjs";
|
|
4
|
+
import { c as F } from "./index-98w8rrCe.mjs";
|
|
5
|
+
import { I as ur, f as gt, t as nt, c as $u, C as $w, d as Cw, r as Nw, a as xr, g as Hh, i as bt, b as Cs, e as Cu, h as Tw, j as Aw, k as Ns, p as Vh, T as Ts, l as As, E as ke, m as xw, y as Qe, P as Nu, Q as Dw, n as Fw, o as qo, q as xs, s as Bt, _ as qw, u as jw, v as Tu } from "./index-D0tl0B36.mjs";
|
|
6
|
+
import { o as Au } from "./browser-ponyfill-uCX78ltK.mjs";
|
|
7
7
|
var se = {};
|
|
8
8
|
Object.defineProperty(se, "__esModule", { value: !0 });
|
|
9
9
|
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;
|
|
@@ -7675,7 +7675,7 @@ class Qo {
|
|
|
7675
7675
|
if (this.rpc = this.getRpcConfig(t), this.chainId = this.rpc.chains.length ? $s(this.rpc.chains) : $s(this.rpc.optionalChains), this.signer = await KI.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) {
|
|
7676
7676
|
let r;
|
|
7677
7677
|
try {
|
|
7678
|
-
const { WalletConnectModal: s } = await import("./index-
|
|
7678
|
+
const { WalletConnectModal: s } = await import("./index-DPfKYdEf.mjs").then((o) => o.i);
|
|
7679
7679
|
r = s;
|
|
7680
7680
|
} catch {
|
|
7681
7681
|
throw new Error("To use QR modal, please install @walletconnect/modal package");
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=require("./index-S_dcknx7.js");exports.AutomaticCCTPRoute=R.AutomaticCCTPRoute;exports.AutomaticPorticoRoute=R.AutomaticPorticoRoute;exports.AutomaticTokenBridgeRoute=R.AutomaticTokenBridgeRoute;exports.CCTPRoute=R.CCTPRoute;exports.DEFAULT_ROUTES=R.DEFAULT_ROUTES;exports.ERR_AMOUNT_TOO_LARGE=R.ERR_AMOUNT_TOO_LARGE;exports.ERR_AMOUNT_TOO_SMALL=R.ERR_AMOUNT_TOO_SMALL;exports.ERR_DESTINATION_CONTRACT_PAUSED=R.ERR_DESTINATION_CONTRACT_PAUSED;exports.ERR_INSUFFICIENT_ALLOWANCE=R.ERR_INSUFFICIENT_ALLOWANCE;exports.ERR_INSUFFICIENT_GAS=R.ERR_INSUFFICIENT_GAS;exports.ERR_NOT_ENOUGH_CAPACITY=R.ERR_NOT_ENOUGH_CAPACITY;exports.ERR_RELAY_FAILED=R.ERR_RELAY_FAILED;exports.ERR_SOURCE_CONTRACT_PAUSED=R.ERR_SOURCE_CONTRACT_PAUSED;exports.ERR_TIMEOUT=R.ERR_TIMEOUT;exports.ERR_UNKNOWN=R.ERR_UNKNOWN;exports.ERR_UNSUPPORTED_ABI_VERSION=R.ERR_UNSUPPORTED_ABI_VERSION;exports.ERR_USER_REJECTED=R.ERR_USER_REJECTED;exports.MAINNET=R.MAINNET;exports.TESTNET=R.TESTNET;exports.Token=R.Token;exports.TokenBridgeRoute=R.TokenBridgeRoute;exports.buildConfig=R.buildConfig;exports.config=R.types;exports.default=R.WormholeConnect;exports.getTokenDetails=R.getTokenDetails;exports.getTransferDetails=R.getTransferDetails;
|
package/lib/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as E, O as T, I as _, L as s, H as A, $ as N, a0 as O, Y as e, U as o, _ as t, V as C, a4 as U, X as I, a2 as S, a3 as i, Z as u, a1 as D, M as L, T as P, G as n, J as r, F, P as g, E as M, Q as c, R as f } from "./index-
|
|
1
|
+
import { K as E, O as T, I as _, L as s, H as A, $ as N, a0 as O, Y as e, U as o, _ as t, V as C, a4 as U, X as I, a2 as S, a3 as i, Z as u, a1 as D, M as L, T as P, G as n, J as r, F, P as g, E as M, Q as c, R as f } from "./index-DvozGHS-.mjs";
|
|
2
2
|
export {
|
|
3
3
|
E as AutomaticCCTPRoute,
|
|
4
4
|
T as AutomaticPorticoRoute,
|