graz 0.1.18 → 0.1.19
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/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +70 -70
- package/dist/index.mjs +3 -3
- package/package.json +2 -2
- package/types/global.d.ts +1 -0
package/dist/index.d.mts
CHANGED
|
@@ -33,7 +33,8 @@ declare enum WalletType {
|
|
|
33
33
|
STATION = "station",
|
|
34
34
|
XDEFI = "xdefi",
|
|
35
35
|
CAPSULE = "capsule",
|
|
36
|
-
COSMIFRAME = "cosmiframe"
|
|
36
|
+
COSMIFRAME = "cosmiframe",
|
|
37
|
+
COMPASS = "compass"
|
|
37
38
|
}
|
|
38
39
|
declare const WALLET_TYPES: WalletType[];
|
|
39
40
|
type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOfflineSignerAuto" | "getOfflineSignerOnlyAmino" | "experimentalSuggestChain" | "signDirect" | "signAmino"> & {
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,8 @@ declare enum WalletType {
|
|
|
33
33
|
STATION = "station",
|
|
34
34
|
XDEFI = "xdefi",
|
|
35
35
|
CAPSULE = "capsule",
|
|
36
|
-
COSMIFRAME = "cosmiframe"
|
|
36
|
+
COSMIFRAME = "cosmiframe",
|
|
37
|
+
COMPASS = "compass"
|
|
37
38
|
}
|
|
38
39
|
declare const WALLET_TYPES: WalletType[];
|
|
39
40
|
type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOfflineSignerAuto" | "getOfflineSignerOnlyAmino" | "experimentalSuggestChain" | "signDirect" | "signAmino"> & {
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var middleware = require('zustand/middleware');
|
|
|
5
5
|
var encoding = require('@cosmjs/encoding');
|
|
6
6
|
var cosmiframe = require('@dao-dao/cosmiframe');
|
|
7
7
|
var snapper = require('@cosmsnap/snapper');
|
|
8
|
-
var
|
|
8
|
+
var Ht = require('long');
|
|
9
9
|
var signClient = require('@walletconnect/sign-client');
|
|
10
10
|
var utils = require('@walletconnect/utils');
|
|
11
11
|
var reactQuery = require('@tanstack/react-query');
|
|
@@ -18,80 +18,80 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
18
18
|
|
|
19
19
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var Ht__default = /*#__PURE__*/_interopDefault(Ht);
|
|
22
22
|
|
|
23
|
-
var Kt=Object.defineProperty,Bt=Object.defineProperties;var Lt=Object.getOwnPropertyDescriptors;var re=Object.getOwnPropertySymbols;var Fe=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))Fe.call(t,n)&&qe(e,n,t[n]);if(re)for(var n of re(t))Ge.call(t,n)&&qe(e,n,t[n]);return e},U=(e,t)=>Bt(e,Lt(t));var ze=(e,t)=>{var n={};for(var i in e)Fe.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&re)for(var i of re(e))t.indexOf(i)<0&&Ge.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{s(n.next(c));}catch(p){r(p);}},a=c=>{try{s(n.throw(c));}catch(p){r(p);}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,a);s((n=n.apply(e,t)).next());});var H="graz-reconnect-session";var Qe=(f=>(f.KEPLR="keplr",f.LEAP="leap",f.VECTIS="vectis",f.COSMOSTATION="cosmostation",f.WALLETCONNECT="walletconnect",f.WC_KEPLR_MOBILE="wc_keplr_mobile",f.WC_LEAP_MOBILE="wc_leap_mobile",f.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",f.WC_CLOT_MOBILE="wc_clot_mobile",f.METAMASK_SNAP_LEAP="metamask_snap_leap",f.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",f.STATION="station",f.XDEFI="xdefi",f.CAPSULE="capsule",f.COSMIFRAME="cosmiframe",f))(Qe||{}),je=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe"];var qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},te={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Ft={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},Gt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},m=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>te,Ft))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>qt,Gt)));var se=()=>{var I,O;if(!((I=u.getState().capsuleConfig)!=null&&I.apiKey)||!((O=u.getState().capsuleConfig)!=null&&O.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var f,E;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,C=new d({apiKey:(f=u.getState().capsuleConfig)==null?void 0:f.apiKey,env:(E=u.getState().capsuleConfig)==null?void 0:E.env});return m.setState({capsuleClient:C}),C});return {init:e,enable:d=>l(void 0,null,function*(){let C=typeof d=="string"?[d]:d,f=m.getState().capsuleClient;f||(f=yield e()),u.setState({capsuleState:{showModal:!0,chainId:C}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var W;let d=m.getState().capsuleClient,{chains:C}=u.getState();if(!d)throw new Error("Capsule client is not initialized");if(!C)throw new Error("Chains are not set");yield d.enable();let f=(W=u.getState().capsuleState)==null?void 0:W.chainId;if(!f)throw new Error("Chain ids are not set");let E=Object.fromEntries(yield Promise.all(f.map(g=>l(void 0,null,function*(){let w=yield d.getAccount(g);return [g,{address:encoding.fromBech32(w.address).data,bech32Address:w.address,algo:w.algo,name:w.username||"",pubKey:w.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));m.setState(g=>({accounts:b(b({},g.accounts||{}),E)})),u.setState(g=>({recentChainIds:[...g.recentChainIds||[],...f].filter((w,M,P)=>P.indexOf(w)===M)})),m.setState(g=>({activeChainIds:[...g.activeChainIds||[],...f].filter((w,M,P)=>P.indexOf(w)===M)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let C=m.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");let f=yield C.getAccount(d);return {address:encoding.fromBech32(f.address).data,bech32Address:f.address,algo:f.algo,name:f.username||"",pubKey:f.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let C=m.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let C=m.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerDirect(d)},signDirect:(...d)=>l(void 0,null,function*(){let[C,f,E]=d,W=m.getState().capsuleClient;if(!W)throw new Error("Capsule client is not initialized");return W.signDirect(C,f,{bodyBytes:E.bodyBytes,authInfoBytes:E.authInfoBytes,chainId:E.chainId,accountNumber:E.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[C,f,E,W]=d,g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.signAmino(C,f,E,W)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:d=>{let C=m.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let C=m.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerAmino(d)}}};var ae=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!cosmiframe.isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new cosmiframe.Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var Ze={},et=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var S;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let s=(S=o.split("MetaMask/v")[1])==null?void 0:S.split(".")[0];if(!(Number(s)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,!0}),enable:o=>l(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){yield t.experimentalSuggestChain(o);}),signAmino:(o,a,s)=>l(void 0,null,function*(){return t.signAmino(o,a,s)}),getKey:o=>l(void 0,null,function*(){return typeof Ze[o]!="undefined"?Ze[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,a,s)=>l(void 0,null,function*(){return t.signDirect(o,a,s)}),signArbitrary:(o,a,s)=>l(void 0,null,function*(){return t.signArbitrary(o,a,s)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ce=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{var s;let a=()=>{G(),o();};return (s=window.cosmostation)==null||s.cosmos.on("accountChanged",a),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",a);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var le=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let o=()=>{G(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var ue=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let o=()=>{G(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var pe={},tt=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=g=>l(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(M=>M.id===e.id&&(!g||M.version===g))}catch(w){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var D;let g=yield t.request({method:"web3_clientVersion"});if(!g.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let M=(D=g.split("MetaMask/v")[1])==null?void 0:D.split(".")[0];if(!(Number(M)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),a=g=>l(void 0,null,function*(){(yield i())||(yield r());}),s=(g,w,M)=>l(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:g,signerAddress:w,signDoc:M}}}}),_=M.accountNumber,D=new $t__default.default(_.low,_.high,_.unsigned);return {signature:P.signature,signed:U(b({},P.signed),{accountNumber:`${D.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),c=(g,w,M)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:g,signerAddress:w,signDoc:M}}}})}),p=g=>l(void 0,null,function*(){if(typeof pe[g]!="undefined")return pe[g];let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:g}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,pe[g]=w,pe[g]}),S=g=>l(void 0,null,function*(){let w=yield p(g);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),I=(...g)=>l(void 0,null,function*(){let[w,M,P,_]=g;return yield c(w,M,P)}),O=(...g)=>l(void 0,null,function*(){let[w,M,P]=g;return yield s(w,M,P)}),C=g=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(g)]}),signAmino:(w,M)=>I(g,w,M)});return {enable:a,experimentalSuggestChain:(...g)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:g[0]}}}});}),getKey:p,getOfflineSigner:g=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(g)]}),signDirect:(w,M)=>O(g,w,M),signAmino:(w,M)=>I(g,w,M)}),getOfflineSignerAuto:g=>l(void 0,null,function*(){return C(g)}),getOfflineSignerOnlyAmino:C,init:o,signAmino:I,signDirect:O}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var nt=()=>tt({id:"npm:@leapwallet/metamask-cosmos-snap"});var me=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let a=()=>{G(),o();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:o=>l(void 0,null,function*(){let a=yield e.getKey(o);return b({isKeystone:!1},a)}),getOfflineSigner:o=>{try{let a=e.getOfflineSignerOnlyAmino(o);return Object.assign(a,{signDirect:(p,S)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let a=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(s=>{var c,p,S;return {coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom,gasPriceStep:{average:((c=s.gasPriceStep)==null?void 0:c.average)||0,high:((p=s.gasPriceStep)==null?void 0:p.high)||0,low:((S=s.gasPriceStep)==null?void 0:S.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,a,s,c)=>e.signAmino(o,a,s)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var de=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:s=>e.enable(s),getOfflineSigner:s=>e.getOfflineSigner(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getKey:s=>l(void 0,null,function*(){let c=yield e.getKey(s);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:s=>{let c=()=>{G(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>e.getOfflineSignerAmino(...s),experimentalSuggestChain:(...s)=>l(void 0,null,function*(){let[c]=s,p=U(b({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([p])}),signDirect:(...s)=>l(void 0,null,function*(){var S;let{1:c,2:p}=s;return e.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:$t__default.default.fromString(((S=p.accountNumber)==null?void 0:S.toString())||"",!1),chainId:p.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:p}=s;return e.signAmino(c,p)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,ot=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),it=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Te=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var Q=e=>{var D,X,Ne;if(!((Ne=(X=(D=u.getState().walletConnect)==null?void 0:D.options)==null?void 0:X.projectId)!=null&&Ne.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",i=y=>{if(!e)return;let{appUrl:h,formatNativeUrl:A}=e;if(z()){if(ot())if(!y)window.open(h.mobile.android,"_self","noreferrer noopener");else {let x=A(h.mobile.android,y,"android");window.open(x,"_self","noreferrer noopener");}if(it())if(!y)window.open(h.mobile.ios,"_self","noreferrer noopener");else {let x=A(h.mobile.ios,y,"ios");window.open(x,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=m.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),m.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:h}=m.getState(),A=h.get(t);if(!A)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield A.disconnect({topic:y,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(A);}),a=y=>{try{let{wcSignClients:h}=m.getState(),A=h.get(t);if(!A)throw new Error("walletConnect.signClient is not defined");let x=A.session.getAll().at(-1);if(!x)return;if(!(x.expiry*1e3>Date.now()+1e3))throw o(x.topic),new Error("invalid session");try{let v=A.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:y.map(B=>`cosmos:${B}`),events:["chainChanged","accountsChanged"]}}});if(!v.length)throw new Error("no session");return v.at(-1)}catch(v){if(!v.message.toLowerCase().includes("no matching key"))throw v}return x}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}},s=y=>{try{return a(y)}catch(h){return}},c=y=>l(void 0,null,function*(){try{let h=y.core.pairing.pairings.getAll({active:!1});if(!h.length)return;yield Promise.all(h.map(A=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(A.topic,{code:7001,message:"clear pairing"});})));}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}}),p=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:h}=m.getState(),A=h.get(t);if(A)return A;let x=yield signClient.SignClient.init(y.options);return h.set(t,x),m.setState({wcSignClients:h}),x}),S=y=>{let{wcSignClients:h}=m.getState(),A=h.get(t);if(!A)return ()=>{};let x=k=>{let v=m.getState().accounts;if(k.params.event.name==="accountsChanged"&&v&&!Object.values(v).map(B=>B.bech32Address).includes(k.params.event.data[0])){let B=k.params.chainId.split(":")[1];B&&I([B]);}else y();};return A.events.on("session_delete",r),A.events.on("session_expire",r),A.events.on("session_event",x),()=>{A.events.off("session_delete",r),A.events.off("session_expire",r),A.events.off("session_event",x);}},I=y=>l(void 0,null,function*(){var oe;let h=typeof y=="string"?[y]:y,{wcSignClients:A}=m.getState(),x=A.get(t);if(!x)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:k,chains:v}=u.getState();if(!((oe=k==null?void 0:k.options)!=null&&oe.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:B}=yield import('@web3modal/standalone'),$=new B(b({projectId:k.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},k.web3Modal)),J=s(h);if(!J){let{uri:L,approval:Z}=yield Te(x.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:h.map(j=>`cosmos:${j}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?i(L):yield $.openModal({uri:L});let _t=j=>l(void 0,null,function*(){return j.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Ee,ee)=>{Z().then(Ke=>{let Be=Ke.sessionProperties;if(!Be)return ee(new Error("No session properties"));let Oe=JSON.parse(String(Be.keys));if(Oe.length===0)return ee(new Error("No accounts"));let Le=Oe[0];if(!Le)return ee(new Error("No accounts"));let Ue={};return h.forEach(ie=>{Ue[ie]=U(b({},Le),{bech32Address:encoding.toBech32(v.find(Nt=>Nt.chainId===ie).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(Oe[0].bech32Address).data)});}),m.setState(ie=>({accounts:b(b({},ie.accounts||{}),Ue)})),Ee(Ke)}).catch(ee),j.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:!0});})});try{let j=new AbortController,Ee=j.signal;$.subscribeModal(ee=>{ee.open||j.abort();}),yield _t(Ee);}catch(j){if($.closeModal(),!j.message.toLowerCase().includes("no matching key"))return Promise.reject(j)}return e||$.closeModal(),Promise.resolve()}try{yield Te((()=>l(void 0,null,function*(){let L=Object.fromEntries(yield Promise.all(h.map(Z=>l(void 0,null,function*(){return [Z,yield d(Z)]}))));m.setState({accounts:L});}))(),15e3,new Error("Connection timeout"));}catch(L){if(o(J.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),O=y=>l(void 0,null,function*(){var v;let{wcSignClients:h}=m.getState(),A=h.get(t);if(!A)throw new Error("walletConnect.signClient is not defined");let x=(v=a([y]))==null?void 0:v.topic;if(!x)throw new Error("No wallet connect session");let k=yield A.request({topic:x,chainId:`cosmos:${y}`,request:{method:"cosmos_getAccounts",params:{}}});if(!k[0])throw new Error("No wallet connect account");return {address:k[0].address,algo:k[0].algo,pubkey:new Uint8Array(Buffer.from(k[0].pubkey,n))}}),d=y=>l(void 0,null,function*(){let h=a([y]);if(!(h!=null&&h.topic))throw new Error("No wallet connect session");let A=h.sessionProperties&&JSON.parse(String(h.sessionProperties.keys))[0];if(!A)throw new Error("No wallet connect key");return A}),C=(...y)=>l(void 0,null,function*(){var L,Z;let[h,A,x]=y,{accounts:k,wcSignClients:v}=m.getState(),B=v.get(t);if(!B)throw new Error("walletConnect.signClient is not defined");if(!k)throw new Error("account is not defined");let $=(L=a([h]))==null?void 0:L.topic;if(!$)throw new Error("No wallet connect session");if(!x.bodyBytes)throw new Error("No bodyBytes");if(!x.authInfoBytes)throw new Error("No authInfoBytes");let J={topic:$,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:A,signDoc:U(b({},x),{bodyBytes:Buffer.from(x.bodyBytes).toString(n),authInfoBytes:Buffer.from(x.authInfoBytes).toString(n),accountNumber:(Z=x.accountNumber)==null?void 0:Z.toString()})}}};return i(),yield B.request(J)}),f=(...y)=>l(void 0,null,function*(){let[h,A,x]=y,{signature:k,signed:v}=yield C(h,A,x);return {signed:{chainId:v.chainId,accountNumber:$t__default.default.fromString(v.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(v.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(v.bodyBytes,n))},signature:k}}),E=(...y)=>l(void 0,null,function*(){var L;let[h,A,x,k]=y,{wcSignClients:v}=m.getState(),B=v.get(t),{accounts:$}=m.getState();if(!B)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let J=(L=a([h]))==null?void 0:L.topic;if(!J)throw new Error("No wallet connect session");return i(),yield B.request({topic:J,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:A,signDoc:x}}})}),W=(...y)=>l(void 0,null,function*(){let[h,A,x,k]=y;return yield E(h,A,x)}),g=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,A)=>f(y,h,A)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signAmino:(h,A)=>W(y,h,A)});return {enable:I,disable:y=>l(void 0,null,function*(){var x;let{wcSignClients:h}=m.getState(),A=h.get(t);if(y===void 0){let k=A==null?void 0:A.session.getAll();k!==void 0&&(yield Promise.all(k.map(v=>o(v.topic))));}else typeof y=="string"?yield o((x=a([y]))==null?void 0:x.topic):yield Promise.all(y.map(k=>{var v;return o((v=a([k]))==null?void 0:v.topic)}));(A==null?void 0:A.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:d,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,A)=>f(y,h,A),signAmino:(h,A)=>W(y,h,A)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):g(y)}),getOfflineSignerOnlyAmino:w,signAmino:W,signDirect:f,subscription:S,init:p}};var rt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;default:return `${s}://wc?uri=${c}`}}};return Q(e)};var st=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,o,a)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return Q(e)};var at=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return Q(e)};var ct=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return Q(e)};var fe=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{G(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var N=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},G=()=>{window.sessionStorage.removeItem(H),m.setState(te);},R=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return le();case"leap":return ue();case"cosmostation":return ce();case"vectis":return de();case"walletconnect":return Q();case"wc_keplr_mobile":return at();case"wc_leap_mobile":return ct();case"wc_cosmostation_mobile":return st();case"wc_clot_mobile":return rt();case"metamask_snap_leap":return nt();case"metamask_snap_cosmos":return et();case"station":return me();case"xdefi":return fe();case"capsule":return se();case"cosmiframe":return ae();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},Mi=()=>Object.fromEntries(je.map(e=>[e,N(e)])),be=e=>e==="capsule",lt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var V=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!N(o))throw new Error(`${o} is not available`);let s=R(o),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let p=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(p!=null&&p.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),m.setState(d=>{let C=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(E=>{var W;return !((W=d.activeChainIds)!=null&&W.includes(E))}).length>0?{status:"connecting"}:C?{status:"reconnecting"}:{status:"connecting"}});let{accounts:S}=m.getState();if(yield (t=s.init)==null?void 0:t.call(s),be(o)&&m.getState().capsuleClient&&Object.values(m.getState().accounts||[]).length>0){let d=c.map(E=>i.find(W=>W.chainId===E)),C=m.getState().accounts;m.setState({status:"connecting"});let f=Object.fromEntries(yield Promise.all(c.map(E=>l(void 0,null,function*(){return [E,yield s.getKey(E)]}))));return m.setState(E=>({accounts:b(b({},E.accounts||{}),f)})),u.setState(E=>({recentChainIds:[...E.recentChainIds||[],...c].filter((W,g,w)=>w.indexOf(W)===g)})),m.setState(E=>({activeChainIds:[...E.activeChainIds||[],...c].filter((W,g,w)=>w.indexOf(W)===g)})),m.setState({status:"connected"}),{accounts:C,walletType:o,chains:d}}if(yield s.enable(c),be(o)){let d=c.map(f=>i.find(E=>E.chainId===f)),C=m.getState().accounts;return m.setState({status:"connecting"}),{accounts:C,walletType:o,chains:d}}if(!lt(o)){let d=Object.fromEntries(yield Promise.all(c.map(C=>l(void 0,null,function*(){return [C,yield s.getKey(C)]}))));m.setState(C=>({accounts:b(b({},C.accounts||{}),d)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((C,f,E)=>E.indexOf(C)===f)})),m.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((C,f,E)=>E.indexOf(C)===f)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active");let I=c.map(d=>i.find(C=>C.chainId===d));return {accounts:m.getState().accounts,walletType:o,chains:I}}catch(n){throw console.error("connect ",n),m.getState().accounts===null&&m.setState({status:"disconnected"}),m.getState().accounts&&m.getState().activeChainIds&&m.setState({status:"connected"}),n}}),ne=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(H);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=m.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(m.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(m.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(a=>!t.includes(a)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(a=>!t.includes(a))}}));}else m.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},q=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=N(n||void 0);if(t&&o&&n)return yield V({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),ne();}}),ut=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!N(n))throw new Error(`${n} is not available`);let r=R(n),o=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:a,offlineSignerAuto:s}});var Me=()=>{u.setState({recentChainIds:null});},Li=()=>u.getState().recentChainIds,Ui=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},qi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},Fi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},xe=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){let i=R(t);return t==="capsule"?yield V({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),pt=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield xe({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield V({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var mt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var dt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,i,r,o)}),ft=S=>l(void 0,[S],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:p}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,i,r,o,a,s,c,p)}),gt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,n,o,i,r)}),Ct=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,a,o)}),yt=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),St=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var Ji=e=>e,Zi=e=>e;var ge=e=>e?Object.keys(e).length===0:!0;var We=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},ht=e=>globalThis.DOMException===void 0?new We(e):new DOMException(e),wt=e=>{let t=e.reason===void 0?ht("This operation was aborted."):e.reason;return t instanceof Error?t:ht(t)};function ve(o,a){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((s,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let p=[],S=[],I=new Map,O=!1,d=!1,C=!1,f=0,E=0,W=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),g=M=>{O=!0,d=!0,c(M);};r&&(r.aborted&&g(wt(r)),r.addEventListener("abort",()=>{g(wt(r));}));let w=()=>l(this,null,function*(){if(d)return;let M=yield W.next(),P=E;if(E++,M.done){if(C=!0,f===0&&!d){if(!i&&S.length>0){g(new AggregateError(S));return}if(d=!0,I.size===0){s(p);return}let _=[];for(let[D,X]of p.entries())I.get(D)!==At&&_.push(X);s(_);}return}f++,l(this,null,function*(){try{let _=yield M.value;if(d)return;let D=yield t(_,P);D===At&&I.set(P,D),p[P]=D,f--,yield w();}catch(_){if(i)g(_);else {S.push(_),f--;try{yield w();}catch(D){g(D);}}}});});l(this,null,function*(){for(let M=0;M<n;M++){try{yield w();}catch(P){g(P);break}if(C||O)break}});})})}var At=Symbol("skip");var K=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},F=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield ve(t,n,{concurrency:i});return Object.fromEntries(o.map((a,s)=>[t[s].chainId,a]))}return yield n(t[0])}),It=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,a)=>[t[a].chainId,o]))}return n(t[0])};var Re=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield F(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:b({},(s==null?void 0:s.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},De=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield F(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:b({},(s==null?void 0:s.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ce=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=K({chainId:t,multiChain:n}),o=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:o,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield F(!!n,s,S=>l(void 0,null,function*(){var f;let I=(f=u.getState().chainsConfig)==null?void 0:f[S.chainId],O={url:S.rpc,headers:b({},(I==null?void 0:I.rpcHeaders)||{})};return yield (a==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(O)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var br=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow.shallow),ye=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>N(r))};var Y=e=>{let t=u(s=>s.walletType),n=m(s=>s.activeChainIds),i=K({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=m(s=>s.accounts),o=m(s=>s.status);return react.useEffect(()=>m.subscribe(s=>s.status,(s,c)=>{var p,S,I;if(s==="connected"){let{accounts:O,activeChainIds:d}=m.getState(),{chains:C}=u.getState(),{walletType:f}=u.getState();if(!O||!d||!C)return (p=e==null?void 0:e.onDisconnect)==null?void 0:p.call(e);(S=e==null?void 0:e.onConnect)==null||S.call(e,{accounts:O,chains:d.map(E=>C.find(W=>W.chainId===E)),walletType:f,isReconnect:c==="reconnecting"});}s==="disconnected"&&((I=e==null?void 0:e.onDisconnect)==null||I.call(e));}),[e]),{data:react.useMemo(()=>r?It(!!(e!=null&&e.multiChain),i,s=>r[s.chainId]):void 0,[r,i,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:q,status:o}},ln=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Re({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=react.useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return reactQuery.useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield F(!!(e!=null&&e.multiChain),s,I=>l(void 0,null,function*(){let O=a==null?void 0:a[I.chainId];if(!O)throw new Error(`Client is not ready ${I.chainId}`);return yield O.getAllBalances(encoding.toBech32(I.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!ge(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Lr=e=>{let t=K({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=ln({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,r,t,i,e.chainId],s=reactQuery.useQuery(a,({queryKey:[,c,p]})=>p==null?void 0:p.find(S=>S.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return U(b({},s),{refetch:c=>l(void 0,null,function*(){return yield o(),s.refetch(c)})})},Ur=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],V,{onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=ye();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},qr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],ne,{onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},Fr=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:i,queryFn:a=>l(void 0,[a],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!N(o))throw new Error(`${o} is not available`);return yield F(!!(e!=null&&e.multiChain),r,p=>l(void 0,null,function*(){return yield ut({chainId:p.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},Gr=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:i}=Re({chainId:t.map(a=>a.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=react.useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return reactQuery.useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield F(!!(e!=null&&e.multiChain),s,I=>l(void 0,null,function*(){var d;if(!a)throw new Error("Client is not ready");return yield (d=a[I.chainId])==null?void 0:d.getBalanceStaked(encoding.toBech32(I.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Yr=()=>{let e=u(i=>i.capsuleState),t=m(i=>i.capsuleClient),n=se();return {setModalState:i=>{u.setState(r=>{var o;return {capsuleState:{showModal:i,chainId:(o=r.capsuleState)==null?void 0:o.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{ne();}}};var os=()=>m(e=>e.activeChainIds),un=()=>{var e;return (e=m(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},is=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},rs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ss=({denom:e})=>{let t=un();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:o.currencies.find(a=>a)})},as=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery(n,s=>l(void 0,[s],function*({queryKey:[,o,a]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(a)}),{enabled:typeof e.queryClient!="undefined"})},cs=()=>({data:u(t=>t.recentChainIds),clear:Me}),ls=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:Me}},us=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],xe,{onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},ps=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],pt,{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=ye();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var hs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],a=>dt(b({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},ws=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],a=>ft(b({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},As=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,s=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var S;if(!o)throw new Error("senderAddress is undefined");let p=U(b({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,codeId:e});return gt(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Is=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,s=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var S,I,O;if(!o)throw new Error("senderAddress is undefined");let p=U(b({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,contractAddress:e,memo:(I=c.memo)!=null?I:"",funds:(O=c.funds)!=null?O:[]});return Ct(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},Es=e=>{let{data:t}=De();return reactQuery.useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return yt(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Os=e=>{let{data:t}=De(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return St(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Ks(e){let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield F(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var f,E;if(!(i!=null&&i.includes(p.chainId)))return null;if(!N(a))throw new Error(`${a} is not available`);let I=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(p.chainId);default:return R(a).getOfflineSignerAuto(p.chainId)}}))(),O=(f=u.getState().chainsConfig)==null?void 0:f[p.chainId],d={url:p.rpc,headers:b({},(O==null?void 0:O.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(d,I,e!=null&&e.multiChain?(E=e.opts)==null?void 0:E[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Bs(e){let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield F(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var E,W;if(!(i!=null&&i.includes(p.chainId)))return null;if(!N(a))throw new Error(`${a} is not available`);let I=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(p.chainId);default:return R(a).getOfflineSignerAuto(p.chainId)}}))(),O=(E=u.getState().chainsConfig)==null?void 0:E[p.chainId],d={url:p.rpc,headers:b({},(O==null?void 0:O.rpcHeaders)||{})},C=O!=null&&O.gas?stargate.GasPrice.fromString(`${O.gas.price}${O.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(d,I,b({gasPrice:C},e!=null&&e.multiChain?(W=e.opts)==null?void 0:W[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Ls(e){let t=K({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=m(a=>a.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=Ce({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield F(!!e.multiChain,a,S=>l(this,null,function*(){var f;if(!(i!=null&&i.includes(S.chainId)))return null;if(!N(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let O=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(S.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(S.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(S.chainId);default:return R(s).getOfflineSignerAuto(S.chainId)}}))(),d=e.multiChain?o[S.chainId]:o;return yield stargate.SigningStargateClient.createWithSigner(d,O,e.multiChain?(f=e.opts)==null?void 0:f[S.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Us(e){let t=K({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=m(s=>s.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=Ce({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=Ce({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:p=>l(this,[p],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield F(!!e.multiChain,s,I=>l(this,null,function*(){var g,w;if(!(i!=null&&i.includes(I.chainId)))return null;if(!N(c))throw new Error(`${c} is not available`);let d=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(c).getOfflineSigner(I.chainId);case"offlineSignerAuto":return R(c).getOfflineSignerAuto(I.chainId);case"offlineSignerOnlyAmino":return R(c).getOfflineSignerOnlyAmino(I.chainId);default:return R(c).getOfflineSignerAuto(I.chainId)}}))(),C=(g=u.getState().chainsConfig)==null?void 0:g[I.chainId],f=C!=null&&C.gas?stargate.GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0,E=e.multiChain?a==null?void 0:a[I.chainId]:o;if(!E)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(E,d,b({gasPrice:f},e.multiChain?(w=e.opts)==null?void 0:w[I.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!ge(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Pt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var Cn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(H)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i,iframeOptions:r,chains:o}=u(),{activeChainIds:a,wcSignClients:s}=m(),c=N(i||void 0);return react.useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!o)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(S=>{if(S)return V({chainId:o.map(I=>I.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(i){if(!c)return;e&&a?q({onError:n}):!e&&t&&q({onError:n});}},[c]),react.useEffect(()=>{var p,S,I,O,d,C,f,E,W,g,w,M,P,_,D,X;if(i){if(!c)return;i==="cosmostation"&&((S=(p=ce()).subscription)==null||S.call(p,()=>{q({onError:n});})),i==="keplr"&&((O=(I=le()).subscription)==null||O.call(I,()=>{q({onError:n});})),i==="leap"&&((C=(d=ue()).subscription)==null||C.call(d,()=>{q({onError:n});})),i==="vectis"&&((E=(f=de()).subscription)==null||E.call(f,()=>{q({onError:n});})),i==="walletconnect"&&s.has("walletconnect")&&((g=(W=Q()).subscription)==null||g.call(W,()=>{q({onError:n});})),i==="station"&&((M=(w=me()).subscription)==null||M.call(w,()=>{q({onError:n});})),i==="xdefi"&&((_=(P=fe()).subscription)==null||_.call(P,()=>{q({onError:n});})),i==="cosmiframe"&&((X=(D=ae()).subscription)==null||X.call(D,()=>{q({onError:n});}));}},[i,s,c]),null},Rt=()=>(Cn(),null);var hn=new reactQuery.QueryClient({}),fa=i=>{var r=i,{children:e,grazOptions:t}=r,n=ze(r,["children","grazOptions"]);return mt(t),jsxRuntime.jsx(reactQuery.QueryClientProvider,U(b({client:hn},n),{children:jsxRuntime.jsxs(Pt,{children:[e,jsxRuntime.jsx(Rt,{})]})}),"graz-provider")};
|
|
23
|
+
var Bt=Object.defineProperty,Lt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))Ge.call(t,n)&&qe(e,n,t[n]);if(se)for(var n of se(t))ze.call(t,n)&&qe(e,n,t[n]);return e},U=(e,t)=>Lt(e,Ut(t));var Qe=(e,t)=>{var n={};for(var i in e)Ge.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&se)for(var i of se(e))t.indexOf(i)<0&&ze.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{s(n.next(c));}catch(p){r(p);}},a=c=>{try{s(n.throw(c));}catch(p){r(p);}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,a);s((n=n.apply(e,t)).next());});var H="graz-reconnect-session";var je=(C=>(C.KEPLR="keplr",C.LEAP="leap",C.VECTIS="vectis",C.COSMOSTATION="cosmostation",C.WALLETCONNECT="walletconnect",C.WC_KEPLR_MOBILE="wc_keplr_mobile",C.WC_LEAP_MOBILE="wc_leap_mobile",C.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",C.WC_CLOT_MOBILE="wc_clot_mobile",C.METAMASK_SNAP_LEAP="metamask_snap_leap",C.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",C.STATION="station",C.XDEFI="xdefi",C.CAPSULE="capsule",C.COSMIFRAME="cosmiframe",C.COMPASS="compass",C))(je||{}),$e=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass"];var qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},te={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Gt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},zt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},m=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>te,Gt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>qt,zt)));var ae=()=>{var E,O;if(!((E=u.getState().capsuleConfig)!=null&&E.apiKey)||!((O=u.getState().capsuleConfig)!=null&&O.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var A,C;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,g=new d({apiKey:(A=u.getState().capsuleConfig)==null?void 0:A.apiKey,env:(C=u.getState().capsuleConfig)==null?void 0:C.env});return m.setState({capsuleClient:g}),g});return {init:e,enable:d=>l(void 0,null,function*(){let g=typeof d=="string"?[d]:d,A=m.getState().capsuleClient;A||(A=yield e()),u.setState({capsuleState:{showModal:!0,chainId:g}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var W;let d=m.getState().capsuleClient,{chains:g}=u.getState();if(!d)throw new Error("Capsule client is not initialized");if(!g)throw new Error("Chains are not set");yield d.enable();let A=(W=u.getState().capsuleState)==null?void 0:W.chainId;if(!A)throw new Error("Chain ids are not set");let C=Object.fromEntries(yield Promise.all(A.map(f=>l(void 0,null,function*(){let w=yield d.getAccount(f);return [f,{address:encoding.fromBech32(w.address).data,bech32Address:w.address,algo:w.algo,name:w.username||"",pubKey:w.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));m.setState(f=>({accounts:b(b({},f.accounts||{}),C)})),u.setState(f=>({recentChainIds:[...f.recentChainIds||[],...A].filter((w,M,P)=>P.indexOf(w)===M)})),m.setState(f=>({activeChainIds:[...f.activeChainIds||[],...A].filter((w,M,P)=>P.indexOf(w)===M)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");let A=yield g.getAccount(d);return {address:encoding.fromBech32(A.address).data,bech32Address:A.address,algo:A.algo,name:A.username||"",pubKey:A.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)},signDirect:(...d)=>l(void 0,null,function*(){let[g,A,C]=d,W=m.getState().capsuleClient;if(!W)throw new Error("Capsule client is not initialized");return W.signDirect(g,A,{bodyBytes:C.bodyBytes,authInfoBytes:C.authInfoBytes,chainId:C.chainId,accountNumber:C.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[g,A,C,W]=d,f=m.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.signAmino(g,A,C,W)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerAmino(d)}}};var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var le=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!cosmiframe.isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new cosmiframe.Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var et={},tt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var S;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let s=(S=o.split("MetaMask/v")[1])==null?void 0:S.split(".")[0];if(!(Number(s)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,!0}),enable:o=>l(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){yield t.experimentalSuggestChain(o);}),signAmino:(o,a,s)=>l(void 0,null,function*(){return t.signAmino(o,a,s)}),getKey:o=>l(void 0,null,function*(){return typeof et[o]!="undefined"?et[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,a,s)=>l(void 0,null,function*(){return t.signDirect(o,a,s)}),signArbitrary:(o,a,s)=>l(void 0,null,function*(){return t.signArbitrary(o,a,s)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ue=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{var s;let a=()=>{F(),o();};return (s=window.cosmostation)==null||s.cosmos.on("accountChanged",a),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",a);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var pe=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var me=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var de={},nt=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=f=>l(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(M=>M.id===e.id&&(!f||M.version===f))}catch(w){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var D;let f=yield t.request({method:"web3_clientVersion"});if(!f.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let M=(D=f.split("MetaMask/v")[1])==null?void 0:D.split(".")[0];if(!(Number(M)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),a=f=>l(void 0,null,function*(){(yield i())||(yield r());}),s=(f,w,M)=>l(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:w,signDoc:M}}}}),_=M.accountNumber,D=new Ht__default.default(_.low,_.high,_.unsigned);return {signature:P.signature,signed:U(b({},P.signed),{accountNumber:`${D.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),c=(f,w,M)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:f,signerAddress:w,signDoc:M}}}})}),p=f=>l(void 0,null,function*(){if(typeof de[f]!="undefined")return de[f];let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:f}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,de[f]=w,de[f]}),S=f=>l(void 0,null,function*(){let w=yield p(f);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),E=(...f)=>l(void 0,null,function*(){let[w,M,P,_]=f;return yield c(w,M,P)}),O=(...f)=>l(void 0,null,function*(){let[w,M,P]=f;return yield s(w,M,P)}),g=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(f)]}),signAmino:(w,M)=>E(f,w,M)});return {enable:a,experimentalSuggestChain:(...f)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:f[0]}}}});}),getKey:p,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(f)]}),signDirect:(w,M)=>O(f,w,M),signAmino:(w,M)=>E(f,w,M)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return g(f)}),getOfflineSignerOnlyAmino:g,init:o,signAmino:E,signDirect:O}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ot=()=>nt({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let a=()=>{F(),o();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:o=>l(void 0,null,function*(){let a=yield e.getKey(o);return b({isKeystone:!1},a)}),getOfflineSigner:o=>{try{let a=e.getOfflineSignerOnlyAmino(o);return Object.assign(a,{signDirect:(p,S)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let a=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(s=>{var c,p,S;return {coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom,gasPriceStep:{average:((c=s.gasPriceStep)==null?void 0:c.average)||0,high:((p=s.gasPriceStep)==null?void 0:p.high)||0,low:((S=s.gasPriceStep)==null?void 0:S.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,a,s,c)=>e.signAmino(o,a,s)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ge=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:s=>e.enable(s),getOfflineSigner:s=>e.getOfflineSigner(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getKey:s=>l(void 0,null,function*(){let c=yield e.getKey(s);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:s=>{let c=()=>{F(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>e.getOfflineSignerAmino(...s),experimentalSuggestChain:(...s)=>l(void 0,null,function*(){let[c]=s,p=U(b({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([p])}),signDirect:(...s)=>l(void 0,null,function*(){var S;let{1:c,2:p}=s;return e.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:Ht__default.default.fromString(((S=p.accountNumber)==null?void 0:S.toString())||"",!1),chainId:p.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:p}=s;return e.signAmino(c,p)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,it=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),rt=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Me=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var Q=e=>{var D,X,ne;if(!((ne=(X=(D=u.getState().walletConnect)==null?void 0:D.options)==null?void 0:X.projectId)!=null&&ne.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",i=y=>{if(!e)return;let{appUrl:h,formatNativeUrl:I}=e;if(z()){if(it())if(!y)window.open(h.mobile.android,"_self","noreferrer noopener");else {let x=I(h.mobile.android,y,"android");window.open(x,"_self","noreferrer noopener");}if(rt())if(!y)window.open(h.mobile.ios,"_self","noreferrer noopener");else {let x=I(h.mobile.ios,y,"ios");window.open(x,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=m.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),m.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield I.disconnect({topic:y,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(I);}),a=y=>{try{let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let x=I.session.getAll().at(-1);if(!x)return;if(!(x.expiry*1e3>Date.now()+1e3))throw o(x.topic),new Error("invalid session");try{let v=I.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:y.map(B=>`cosmos:${B}`),events:["chainChanged","accountsChanged"]}}});if(!v.length)throw new Error("no session");return v.at(-1)}catch(v){if(!v.message.toLowerCase().includes("no matching key"))throw v}return x}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}},s=y=>{try{return a(y)}catch(h){return}},c=y=>l(void 0,null,function*(){try{let h=y.core.pairing.pairings.getAll({active:!1});if(!h.length)return;yield Promise.all(h.map(I=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}}),p=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:h}=m.getState(),I=h.get(t);if(I)return I;let x=yield signClient.SignClient.init(y.options);return h.set(t,x),m.setState({wcSignClients:h}),x}),S=y=>{let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)return ()=>{};let x=k=>{let v=m.getState().accounts;if(k.params.event.name==="accountsChanged"&&v&&!Object.values(v).map(B=>B.bech32Address).includes(k.params.event.data[0])){let B=k.params.chainId.split(":")[1];B&&E([B]);}else y();};return I.events.on("session_delete",r),I.events.on("session_expire",r),I.events.on("session_event",x),()=>{I.events.off("session_delete",r),I.events.off("session_expire",r),I.events.off("session_event",x);}},E=y=>l(void 0,null,function*(){var ie;let h=typeof y=="string"?[y]:y,{wcSignClients:I}=m.getState(),x=I.get(t);if(!x)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:k,chains:v}=u.getState();if(!((ie=k==null?void 0:k.options)!=null&&ie.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:B}=yield import('@web3modal/standalone'),$=new B(b({projectId:k.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},k.web3Modal)),J=s(h);if(!J){let{uri:L,approval:Z}=yield Me(x.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:h.map(j=>`cosmos:${j}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?i(L):yield $.openModal({uri:L});let Nt=j=>l(void 0,null,function*(){return j.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Te,ee)=>{Z().then(Be=>{let Le=Be.sessionProperties;if(!Le)return ee(new Error("No session properties"));let be=JSON.parse(String(Le.keys));if(be.length===0)return ee(new Error("No accounts"));let Ue=be[0];if(!Ue)return ee(new Error("No accounts"));let Fe={};return h.forEach(re=>{Fe[re]=U(b({},Ue),{bech32Address:encoding.toBech32(v.find(Kt=>Kt.chainId===re).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(be[0].bech32Address).data)});}),m.setState(re=>({accounts:b(b({},re.accounts||{}),Fe)})),Te(Be)}).catch(ee),j.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:!0});})});try{let j=new AbortController,Te=j.signal;$.subscribeModal(ee=>{ee.open||j.abort();}),yield Nt(Te);}catch(j){if($.closeModal(),!j.message.toLowerCase().includes("no matching key"))return Promise.reject(j)}return e||$.closeModal(),Promise.resolve()}try{yield Me((()=>l(void 0,null,function*(){let L=Object.fromEntries(yield Promise.all(h.map(Z=>l(void 0,null,function*(){return [Z,yield d(Z)]}))));m.setState({accounts:L});}))(),15e3,new Error("Connection timeout"));}catch(L){if(o(J.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),O=y=>l(void 0,null,function*(){var v;let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let x=(v=a([y]))==null?void 0:v.topic;if(!x)throw new Error("No wallet connect session");let k=yield I.request({topic:x,chainId:`cosmos:${y}`,request:{method:"cosmos_getAccounts",params:{}}});if(!k[0])throw new Error("No wallet connect account");return {address:k[0].address,algo:k[0].algo,pubkey:new Uint8Array(Buffer.from(k[0].pubkey,n))}}),d=y=>l(void 0,null,function*(){let h=a([y]);if(!(h!=null&&h.topic))throw new Error("No wallet connect session");let I=h.sessionProperties&&JSON.parse(String(h.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),g=(...y)=>l(void 0,null,function*(){var L,Z;let[h,I,x]=y,{accounts:k,wcSignClients:v}=m.getState(),B=v.get(t);if(!B)throw new Error("walletConnect.signClient is not defined");if(!k)throw new Error("account is not defined");let $=(L=a([h]))==null?void 0:L.topic;if(!$)throw new Error("No wallet connect session");if(!x.bodyBytes)throw new Error("No bodyBytes");if(!x.authInfoBytes)throw new Error("No authInfoBytes");let J={topic:$,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:U(b({},x),{bodyBytes:Buffer.from(x.bodyBytes).toString(n),authInfoBytes:Buffer.from(x.authInfoBytes).toString(n),accountNumber:(Z=x.accountNumber)==null?void 0:Z.toString()})}}};return i(),yield B.request(J)}),A=(...y)=>l(void 0,null,function*(){let[h,I,x]=y,{signature:k,signed:v}=yield g(h,I,x);return {signed:{chainId:v.chainId,accountNumber:Ht__default.default.fromString(v.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(v.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(v.bodyBytes,n))},signature:k}}),C=(...y)=>l(void 0,null,function*(){var L;let[h,I,x,k]=y,{wcSignClients:v}=m.getState(),B=v.get(t),{accounts:$}=m.getState();if(!B)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let J=(L=a([h]))==null?void 0:L.topic;if(!J)throw new Error("No wallet connect session");return i(),yield B.request({topic:J,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:x}}})}),W=(...y)=>l(void 0,null,function*(){let[h,I,x,k]=y;return yield C(h,I,x)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,I)=>A(y,h,I)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signAmino:(h,I)=>W(y,h,I)});return {enable:E,disable:y=>l(void 0,null,function*(){var x;let{wcSignClients:h}=m.getState(),I=h.get(t);if(y===void 0){let k=I==null?void 0:I.session.getAll();k!==void 0&&(yield Promise.all(k.map(v=>o(v.topic))));}else typeof y=="string"?yield o((x=a([y]))==null?void 0:x.topic):yield Promise.all(y.map(k=>{var v;return o((v=a([k]))==null?void 0:v.topic)}));(I==null?void 0:I.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:d,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,I)=>A(y,h,I),signAmino:(h,I)=>W(y,h,I)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):f(y)}),getOfflineSignerOnlyAmino:w,signAmino:W,signDirect:A,subscription:S,init:p}};var st=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;default:return `${s}://wc?uri=${c}`}}};return Q(e)};var at=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,o,a)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return Q(e)};var ct=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return Q(e)};var lt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return Q(e)};var Ce=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var N=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},F=()=>{window.sessionStorage.removeItem(H),m.setState(te);},R=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return pe();case"leap":return me();case"cosmostation":return ue();case"vectis":return ge();case"walletconnect":return Q();case"wc_keplr_mobile":return ct();case"wc_leap_mobile":return lt();case"wc_cosmostation_mobile":return at();case"wc_clot_mobile":return st();case"metamask_snap_leap":return ot();case"metamask_snap_cosmos":return tt();case"station":return fe();case"xdefi":return Ce();case"capsule":return ae();case"cosmiframe":return le();case"compass":return ce();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},Ri=()=>Object.fromEntries($e.map(e=>[e,N(e)])),xe=e=>e==="capsule",ut=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var V=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!N(o))throw new Error(`${o} is not available`);let s=R(o),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let p=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(p!=null&&p.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),m.setState(d=>{let g=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(C=>{var W;return !((W=d.activeChainIds)!=null&&W.includes(C))}).length>0?{status:"connecting"}:g?{status:"reconnecting"}:{status:"connecting"}});let{accounts:S}=m.getState();if(yield (t=s.init)==null?void 0:t.call(s),xe(o)&&m.getState().capsuleClient&&Object.values(m.getState().accounts||[]).length>0){let d=c.map(C=>i.find(W=>W.chainId===C)),g=m.getState().accounts;m.setState({status:"connecting"});let A=Object.fromEntries(yield Promise.all(c.map(C=>l(void 0,null,function*(){return [C,yield s.getKey(C)]}))));return m.setState(C=>({accounts:b(b({},C.accounts||{}),A)})),u.setState(C=>({recentChainIds:[...C.recentChainIds||[],...c].filter((W,f,w)=>w.indexOf(W)===f)})),m.setState(C=>({activeChainIds:[...C.activeChainIds||[],...c].filter((W,f,w)=>w.indexOf(W)===f)})),m.setState({status:"connected"}),{accounts:g,walletType:o,chains:d}}if(yield s.enable(c),xe(o)){let d=c.map(A=>i.find(C=>C.chainId===A)),g=m.getState().accounts;return m.setState({status:"connecting"}),{accounts:g,walletType:o,chains:d}}if(!ut(o)){let d=Object.fromEntries(yield Promise.all(c.map(g=>l(void 0,null,function*(){return [g,yield s.getKey(g)]}))));m.setState(g=>({accounts:b(b({},g.accounts||{}),d)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((g,A,C)=>C.indexOf(g)===A)})),m.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((g,A,C)=>C.indexOf(g)===A)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active");let E=c.map(d=>i.find(g=>g.chainId===d));return {accounts:m.getState().accounts,walletType:o,chains:E}}catch(n){throw console.error("connect ",n),m.getState().accounts===null&&m.setState({status:"disconnected"}),m.getState().accounts&&m.getState().activeChainIds&&m.setState({status:"connected"}),n}}),oe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(H);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=m.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(m.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(m.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(a=>!t.includes(a)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(a=>!t.includes(a))}}));}else m.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},q=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=N(n||void 0);if(t&&o&&n)return yield V({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),oe();}}),pt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!N(n))throw new Error(`${n} is not available`);let r=R(n),o=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:a,offlineSignerAuto:s}});var We=()=>{u.setState({recentChainIds:null});},Qi=()=>u.getState().recentChainIds,ji=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},$i=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},Hi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ve=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){let i=R(t);return t==="capsule"?yield V({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),mt=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield ve({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield V({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var dt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var ft=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,i,r,o)}),gt=S=>l(void 0,[S],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:p}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,i,r,o,a,s,c,p)}),Ct=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,n,o,i,r)}),yt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,a,o)}),St=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),ht=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var ir=e=>e,rr=e=>e;var ye=e=>e?Object.keys(e).length===0:!0;var ke=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},wt=e=>globalThis.DOMException===void 0?new ke(e):new DOMException(e),At=e=>{let t=e.reason===void 0?wt("This operation was aborted."):e.reason;return t instanceof Error?t:wt(t)};function Pe(o,a){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((s,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let p=[],S=[],E=new Map,O=!1,d=!1,g=!1,A=0,C=0,W=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=M=>{O=!0,d=!0,c(M);};r&&(r.aborted&&f(At(r)),r.addEventListener("abort",()=>{f(At(r));}));let w=()=>l(this,null,function*(){if(d)return;let M=yield W.next(),P=C;if(C++,M.done){if(g=!0,A===0&&!d){if(!i&&S.length>0){f(new AggregateError(S));return}if(d=!0,E.size===0){s(p);return}let _=[];for(let[D,X]of p.entries())E.get(D)!==It&&_.push(X);s(_);}return}A++,l(this,null,function*(){try{let _=yield M.value;if(d)return;let D=yield t(_,P);D===It&&E.set(P,D),p[P]=D,A--,yield w();}catch(_){if(i)f(_);else {S.push(_),A--;try{yield w();}catch(D){f(D);}}}});});l(this,null,function*(){for(let M=0;M<n;M++){try{yield w();}catch(P){f(P);break}if(g||O)break}});})})}var It=Symbol("skip");var K=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},G=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield Pe(t,n,{concurrency:i});return Object.fromEntries(o.map((a,s)=>[t[s].chainId,a]))}return yield n(t[0])}),Et=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,a)=>[t[a].chainId,o]))}return n(t[0])};var _e=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:b({},(s==null?void 0:s.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ne=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:b({},(s==null?void 0:s.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Se=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=K({chainId:t,multiChain:n}),o=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:o,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield G(!!n,s,S=>l(void 0,null,function*(){var A;let E=(A=u.getState().chainsConfig)==null?void 0:A[S.chainId],O={url:S.rpc,headers:b({},(E==null?void 0:E.rpcHeaders)||{})};return yield (a==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(O)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var Pr=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow.shallow),he=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>N(r))};var Y=e=>{let t=u(s=>s.walletType),n=m(s=>s.activeChainIds),i=K({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=m(s=>s.accounts),o=m(s=>s.status);return react.useEffect(()=>m.subscribe(s=>s.status,(s,c)=>{var p,S,E;if(s==="connected"){let{accounts:O,activeChainIds:d}=m.getState(),{chains:g}=u.getState(),{walletType:A}=u.getState();if(!O||!d||!g)return (p=e==null?void 0:e.onDisconnect)==null?void 0:p.call(e);(S=e==null?void 0:e.onConnect)==null||S.call(e,{accounts:O,chains:d.map(C=>g.find(W=>W.chainId===C)),walletType:A,isReconnect:c==="reconnecting"});}s==="disconnected"&&((E=e==null?void 0:e.onDisconnect)==null||E.call(e));}),[e]),{data:react.useMemo(()=>r?Et(!!(e!=null&&e.multiChain),i,s=>r[s.chainId]):void 0,[r,i,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:q,status:o}},un=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=_e({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=react.useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return reactQuery.useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),s,E=>l(void 0,null,function*(){let O=a==null?void 0:a[E.chainId];if(!O)throw new Error(`Client is not ready ${E.chainId}`);return yield O.getAllBalances(encoding.toBech32(E.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!ye(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Qr=e=>{let t=K({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=un({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,r,t,i,e.chainId],s=reactQuery.useQuery(a,({queryKey:[,c,p]})=>p==null?void 0:p.find(S=>S.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return U(b({},s),{refetch:c=>l(void 0,null,function*(){return yield o(),s.refetch(c)})})},jr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],V,{onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=he();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},$r=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],oe,{onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},Hr=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:i,queryFn:a=>l(void 0,[a],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!N(o))throw new Error(`${o} is not available`);return yield G(!!(e!=null&&e.multiChain),r,p=>l(void 0,null,function*(){return yield pt({chainId:p.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},Vr=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:i}=_e({chainId:t.map(a=>a.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=react.useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return reactQuery.useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),s,E=>l(void 0,null,function*(){var d;if(!a)throw new Error("Client is not ready");return yield (d=a[E.chainId])==null?void 0:d.getBalanceStaked(encoding.toBech32(E.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var ns=()=>{let e=u(i=>i.capsuleState),t=m(i=>i.capsuleClient),n=ae();return {setModalState:i=>{u.setState(r=>{var o;return {capsuleState:{showModal:i,chainId:(o=r.capsuleState)==null?void 0:o.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{oe();}}};var ls=()=>m(e=>e.activeChainIds),pn=()=>{var e;return (e=m(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},us=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},ps=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ms=({denom:e})=>{let t=pn();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:o.currencies.find(a=>a)})},ds=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery(n,s=>l(void 0,[s],function*({queryKey:[,o,a]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(a)}),{enabled:typeof e.queryClient!="undefined"})},fs=()=>({data:u(t=>t.recentChainIds),clear:We}),gs=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:We}},Cs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],ve,{onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},ys=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],mt,{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=he();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Ts=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],a=>ft(b({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],a=>gt(b({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Ms=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,s=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var S;if(!o)throw new Error("senderAddress is undefined");let p=U(b({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,codeId:e});return Ct(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},xs=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,s=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var S,E,O;if(!o)throw new Error("senderAddress is undefined");let p=U(b({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,contractAddress:e,memo:(E=c.memo)!=null?E:"",funds:(O=c.funds)!=null?O:[]});return yt(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},Ws=e=>{let{data:t}=Ne();return reactQuery.useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return St(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},vs=e=>{let{data:t}=Ne(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return ht(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Gs(e){let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var A,C;if(!(i!=null&&i.includes(p.chainId)))return null;if(!N(a))throw new Error(`${a} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(p.chainId);default:return R(a).getOfflineSignerAuto(p.chainId)}}))(),O=(A=u.getState().chainsConfig)==null?void 0:A[p.chainId],d={url:p.rpc,headers:b({},(O==null?void 0:O.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(d,E,e!=null&&e.multiChain?(C=e.opts)==null?void 0:C[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function zs(e){let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var C,W;if(!(i!=null&&i.includes(p.chainId)))return null;if(!N(a))throw new Error(`${a} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(p.chainId);default:return R(a).getOfflineSignerAuto(p.chainId)}}))(),O=(C=u.getState().chainsConfig)==null?void 0:C[p.chainId],d={url:p.rpc,headers:b({},(O==null?void 0:O.rpcHeaders)||{})},g=O!=null&&O.gas?stargate.GasPrice.fromString(`${O.gas.price}${O.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(d,E,b({gasPrice:g},e!=null&&e.multiChain?(W=e.opts)==null?void 0:W[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Qs(e){let t=K({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=m(a=>a.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=Se({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,S=>l(this,null,function*(){var A;if(!(i!=null&&i.includes(S.chainId)))return null;if(!N(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let O=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(S.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(S.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(S.chainId);default:return R(s).getOfflineSignerAuto(S.chainId)}}))(),d=e.multiChain?o[S.chainId]:o;return yield stargate.SigningStargateClient.createWithSigner(d,O,e.multiChain?(A=e.opts)==null?void 0:A[S.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function js(e){let t=K({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=m(s=>s.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=Se({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=Se({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:p=>l(this,[p],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,E=>l(this,null,function*(){var f,w;if(!(i!=null&&i.includes(E.chainId)))return null;if(!N(c))throw new Error(`${c} is not available`);let d=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(c).getOfflineSigner(E.chainId);case"offlineSignerAuto":return R(c).getOfflineSignerAuto(E.chainId);case"offlineSignerOnlyAmino":return R(c).getOfflineSignerOnlyAmino(E.chainId);default:return R(c).getOfflineSignerAuto(E.chainId)}}))(),g=(f=u.getState().chainsConfig)==null?void 0:f[E.chainId],A=g!=null&&g.gas?stargate.GasPrice.fromString(`${g.gas.price}${g.gas.denom}`):void 0,C=e.multiChain?a==null?void 0:a[E.chainId]:o;if(!C)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(C,d,b({gasPrice:A},e.multiChain?(w=e.opts)==null?void 0:w[E.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!ye(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Rt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var yn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(H)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i,iframeOptions:r,chains:o}=u(),{activeChainIds:a,wcSignClients:s}=m(),c=N(i||void 0);return react.useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!o)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(S=>{if(S)return V({chainId:o.map(E=>E.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(i){if(!c)return;e&&a?q({onError:n}):!e&&t&&q({onError:n});}},[c]),react.useEffect(()=>{var p,S,E,O,d,g,A,C,W,f,w,M,P,_,D,X,ne,y;if(i){if(!c)return;i==="cosmostation"&&((S=(p=ue()).subscription)==null||S.call(p,()=>{q({onError:n});})),i==="keplr"&&((O=(E=pe()).subscription)==null||O.call(E,()=>{q({onError:n});})),i==="leap"&&((g=(d=me()).subscription)==null||g.call(d,()=>{q({onError:n});})),i==="compass"&&((C=(A=ce()).subscription)==null||C.call(A,()=>{q({onError:n});})),i==="vectis"&&((f=(W=ge()).subscription)==null||f.call(W,()=>{q({onError:n});})),i==="walletconnect"&&s.has("walletconnect")&&((M=(w=Q()).subscription)==null||M.call(w,()=>{q({onError:n});})),i==="station"&&((_=(P=fe()).subscription)==null||_.call(P,()=>{q({onError:n});})),i==="xdefi"&&((X=(D=Ce()).subscription)==null||X.call(D,()=>{q({onError:n});})),i==="cosmiframe"&&((y=(ne=le()).subscription)==null||y.call(ne,()=>{q({onError:n});}));}},[i,s,c]),null},Dt=()=>(yn(),null);var wn=new reactQuery.QueryClient({}),Aa=i=>{var r=i,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return dt(t),jsxRuntime.jsx(reactQuery.QueryClientProvider,U(b({client:wn},n),{children:jsxRuntime.jsxs(Rt,{children:[e,jsxRuntime.jsx(Dt,{})]})}),"graz-provider")};
|
|
24
24
|
|
|
25
|
-
exports.GrazEvents =
|
|
26
|
-
exports.GrazProvider =
|
|
27
|
-
exports.WALLET_TYPES =
|
|
28
|
-
exports.WalletType =
|
|
25
|
+
exports.GrazEvents = Dt;
|
|
26
|
+
exports.GrazProvider = Aa;
|
|
27
|
+
exports.WALLET_TYPES = $e;
|
|
28
|
+
exports.WalletType = je;
|
|
29
29
|
exports.checkWallet = N;
|
|
30
|
-
exports.clearRecentChain =
|
|
31
|
-
exports.clearSession =
|
|
32
|
-
exports.configureGraz =
|
|
30
|
+
exports.clearRecentChain = We;
|
|
31
|
+
exports.clearSession = F;
|
|
32
|
+
exports.configureGraz = dt;
|
|
33
33
|
exports.connect = V;
|
|
34
|
-
exports.defineChainInfo =
|
|
35
|
-
exports.defineChains =
|
|
36
|
-
exports.disconnect =
|
|
37
|
-
exports.executeContract =
|
|
38
|
-
exports.getAvailableWallets =
|
|
39
|
-
exports.getChainInfo =
|
|
40
|
-
exports.getChainInfos =
|
|
41
|
-
exports.getCosmostation =
|
|
42
|
-
exports.getKeplr =
|
|
43
|
-
exports.getLeap =
|
|
44
|
-
exports.getMetamaskSnapLeap =
|
|
45
|
-
exports.getOfflineSigners =
|
|
46
|
-
exports.getQueryRaw =
|
|
47
|
-
exports.getQuerySmart =
|
|
48
|
-
exports.getRecentChainIds =
|
|
49
|
-
exports.getRecentChains =
|
|
50
|
-
exports.getVectis =
|
|
51
|
-
exports.getWCCosmostation =
|
|
52
|
-
exports.getWCKeplr =
|
|
53
|
-
exports.getWCLeap =
|
|
34
|
+
exports.defineChainInfo = rr;
|
|
35
|
+
exports.defineChains = ir;
|
|
36
|
+
exports.disconnect = oe;
|
|
37
|
+
exports.executeContract = yt;
|
|
38
|
+
exports.getAvailableWallets = Ri;
|
|
39
|
+
exports.getChainInfo = $i;
|
|
40
|
+
exports.getChainInfos = Hi;
|
|
41
|
+
exports.getCosmostation = ue;
|
|
42
|
+
exports.getKeplr = pe;
|
|
43
|
+
exports.getLeap = me;
|
|
44
|
+
exports.getMetamaskSnapLeap = ot;
|
|
45
|
+
exports.getOfflineSigners = pt;
|
|
46
|
+
exports.getQueryRaw = ht;
|
|
47
|
+
exports.getQuerySmart = St;
|
|
48
|
+
exports.getRecentChainIds = Qi;
|
|
49
|
+
exports.getRecentChains = ji;
|
|
50
|
+
exports.getVectis = ge;
|
|
51
|
+
exports.getWCCosmostation = at;
|
|
52
|
+
exports.getWCKeplr = ct;
|
|
53
|
+
exports.getWCLeap = lt;
|
|
54
54
|
exports.getWallet = R;
|
|
55
55
|
exports.getWalletConnect = Q;
|
|
56
|
-
exports.instantiateContract =
|
|
57
|
-
exports.isCapsule =
|
|
58
|
-
exports.isWalletConnect =
|
|
56
|
+
exports.instantiateContract = Ct;
|
|
57
|
+
exports.isCapsule = xe;
|
|
58
|
+
exports.isWalletConnect = ut;
|
|
59
59
|
exports.reconnect = q;
|
|
60
|
-
exports.sendIbcTokens =
|
|
61
|
-
exports.sendTokens =
|
|
62
|
-
exports.suggestChain =
|
|
63
|
-
exports.suggestChainAndConnect =
|
|
60
|
+
exports.sendIbcTokens = gt;
|
|
61
|
+
exports.sendTokens = ft;
|
|
62
|
+
exports.suggestChain = ve;
|
|
63
|
+
exports.suggestChainAndConnect = mt;
|
|
64
64
|
exports.useAccount = Y;
|
|
65
|
-
exports.useActiveChainCurrency =
|
|
66
|
-
exports.useActiveChainIds =
|
|
67
|
-
exports.useActiveChains =
|
|
68
|
-
exports.useActiveWalletType =
|
|
69
|
-
exports.useBalance =
|
|
70
|
-
exports.useBalanceStaked =
|
|
71
|
-
exports.useBalances =
|
|
72
|
-
exports.useCapsule =
|
|
73
|
-
exports.useChainInfo =
|
|
74
|
-
exports.useChainInfos =
|
|
75
|
-
exports.useCheckWallet =
|
|
76
|
-
exports.useConnect =
|
|
77
|
-
exports.useCosmWasmClient =
|
|
78
|
-
exports.useCosmWasmSigningClient =
|
|
79
|
-
exports.useCosmWasmTmSigningClient =
|
|
80
|
-
exports.useDisconnect =
|
|
81
|
-
exports.useExecuteContract =
|
|
82
|
-
exports.useGrazEvents =
|
|
83
|
-
exports.useInstantiateContract =
|
|
84
|
-
exports.useOfflineSigners =
|
|
85
|
-
exports.useQueryClientValidators =
|
|
86
|
-
exports.useQueryRaw =
|
|
87
|
-
exports.useQuerySmart =
|
|
88
|
-
exports.useRecentChainIds =
|
|
89
|
-
exports.useRecentChains =
|
|
90
|
-
exports.useSendIbcTokens =
|
|
91
|
-
exports.useSendTokens =
|
|
92
|
-
exports.useStargateClient =
|
|
93
|
-
exports.useStargateSigningClient =
|
|
94
|
-
exports.useStargateTmSigningClient =
|
|
95
|
-
exports.useSuggestChain =
|
|
96
|
-
exports.useSuggestChainAndConnect =
|
|
97
|
-
exports.useTendermintClient =
|
|
65
|
+
exports.useActiveChainCurrency = ms;
|
|
66
|
+
exports.useActiveChainIds = ls;
|
|
67
|
+
exports.useActiveChains = pn;
|
|
68
|
+
exports.useActiveWalletType = Pr;
|
|
69
|
+
exports.useBalance = Qr;
|
|
70
|
+
exports.useBalanceStaked = Vr;
|
|
71
|
+
exports.useBalances = un;
|
|
72
|
+
exports.useCapsule = ns;
|
|
73
|
+
exports.useChainInfo = us;
|
|
74
|
+
exports.useChainInfos = ps;
|
|
75
|
+
exports.useCheckWallet = he;
|
|
76
|
+
exports.useConnect = jr;
|
|
77
|
+
exports.useCosmWasmClient = Ne;
|
|
78
|
+
exports.useCosmWasmSigningClient = zs;
|
|
79
|
+
exports.useCosmWasmTmSigningClient = js;
|
|
80
|
+
exports.useDisconnect = $r;
|
|
81
|
+
exports.useExecuteContract = xs;
|
|
82
|
+
exports.useGrazEvents = yn;
|
|
83
|
+
exports.useInstantiateContract = Ms;
|
|
84
|
+
exports.useOfflineSigners = Hr;
|
|
85
|
+
exports.useQueryClientValidators = ds;
|
|
86
|
+
exports.useQueryRaw = vs;
|
|
87
|
+
exports.useQuerySmart = Ws;
|
|
88
|
+
exports.useRecentChainIds = fs;
|
|
89
|
+
exports.useRecentChains = gs;
|
|
90
|
+
exports.useSendIbcTokens = bs;
|
|
91
|
+
exports.useSendTokens = Ts;
|
|
92
|
+
exports.useStargateClient = _e;
|
|
93
|
+
exports.useStargateSigningClient = Gs;
|
|
94
|
+
exports.useStargateTmSigningClient = Qs;
|
|
95
|
+
exports.useSuggestChain = Cs;
|
|
96
|
+
exports.useSuggestChainAndConnect = ys;
|
|
97
|
+
exports.useTendermintClient = Se;
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { createJSONStorage, subscribeWithSelector, persist } from 'zustand/middl
|
|
|
3
3
|
import { fromBech32, toBech32 } from '@cosmjs/encoding';
|
|
4
4
|
import { Cosmiframe, isInIframe } from '@dao-dao/cosmiframe';
|
|
5
5
|
import { isSnapInstalled, installSnap, CosmosSnap } from '@cosmsnap/snapper';
|
|
6
|
-
import
|
|
6
|
+
import Vt from 'long';
|
|
7
7
|
import { SignClient } from '@walletconnect/sign-client';
|
|
8
8
|
import { getSdkError } from '@walletconnect/utils';
|
|
9
9
|
import { QueryClient, useQuery, useMutation, QueryClientProvider } from '@tanstack/react-query';
|
|
@@ -14,6 +14,6 @@ import { Tendermint37Client, Tendermint34Client } from '@cosmjs/tendermint-rpc';
|
|
|
14
14
|
import { shallow } from 'zustand/shallow';
|
|
15
15
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
16
16
|
|
|
17
|
-
var Bt=Object.defineProperty,Lt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var Fe=(e,t,n)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))Ge.call(t,n)&&Fe(e,n,t[n]);if(se)for(var n of se(t))ze.call(t,n)&&Fe(e,n,t[n]);return e},q=(e,t)=>Lt(e,Ut(t));var Qe=(e,t)=>{var n={};for(var i in e)Ge.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&se)for(var i of se(e))t.indexOf(i)<0&&ze.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{s(n.next(c));}catch(p){r(p);}},a=c=>{try{s(n.throw(c));}catch(p){r(p);}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,a);s((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var je=(f=>(f.KEPLR="keplr",f.LEAP="leap",f.VECTIS="vectis",f.COSMOSTATION="cosmostation",f.WALLETCONNECT="walletconnect",f.WC_KEPLR_MOBILE="wc_keplr_mobile",f.WC_LEAP_MOBILE="wc_leap_mobile",f.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",f.WC_CLOT_MOBILE="wc_clot_mobile",f.METAMASK_SNAP_LEAP="metamask_snap_leap",f.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",f.STATION="station",f.XDEFI="xdefi",f.CAPSULE="capsule",f.COSMIFRAME="cosmiframe",f))(je||{}),$e=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe"];var Ft={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Gt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},zt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},m=create(subscribeWithSelector(persist(()=>ne,Gt))),u=create(subscribeWithSelector(persist(()=>Ft,zt)));var ae=()=>{var I,O;if(!((I=u.getState().capsuleConfig)!=null&&I.apiKey)||!((O=u.getState().capsuleConfig)!=null&&O.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var f,E;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,C=new d({apiKey:(f=u.getState().capsuleConfig)==null?void 0:f.apiKey,env:(E=u.getState().capsuleConfig)==null?void 0:E.env});return m.setState({capsuleClient:C}),C});return {init:e,enable:d=>l(void 0,null,function*(){let C=typeof d=="string"?[d]:d,f=m.getState().capsuleClient;f||(f=yield e()),u.setState({capsuleState:{showModal:!0,chainId:C}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var v;let d=m.getState().capsuleClient,{chains:C}=u.getState();if(!d)throw new Error("Capsule client is not initialized");if(!C)throw new Error("Chains are not set");yield d.enable();let f=(v=u.getState().capsuleState)==null?void 0:v.chainId;if(!f)throw new Error("Chain ids are not set");let E=Object.fromEntries(yield Promise.all(f.map(g=>l(void 0,null,function*(){let w=yield d.getAccount(g);return [g,{address:fromBech32(w.address).data,bech32Address:w.address,algo:w.algo,name:w.username||"",pubKey:w.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));m.setState(g=>({accounts:M(M({},g.accounts||{}),E)})),u.setState(g=>({recentChainIds:[...g.recentChainIds||[],...f].filter((w,x,R)=>R.indexOf(w)===x)})),m.setState(g=>({activeChainIds:[...g.activeChainIds||[],...f].filter((w,x,R)=>R.indexOf(w)===x)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let C=m.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");let f=yield C.getAccount(d);return {address:fromBech32(f.address).data,bech32Address:f.address,algo:f.algo,name:f.username||"",pubKey:f.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let C=m.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let C=m.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerDirect(d)},signDirect:(...d)=>l(void 0,null,function*(){let[C,f,E]=d,v=m.getState().capsuleClient;if(!v)throw new Error("Capsule client is not initialized");return v.signDirect(C,f,{bodyBytes:E.bodyBytes,authInfoBytes:E.authInfoBytes,chainId:E.chainId,accountNumber:E.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[C,f,E,v]=d,g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.signAmino(C,f,E,v)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:d=>{let C=m.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let C=m.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerAmino(d)}}};var ce=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var et={},tt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var S;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let s=(S=o.split("MetaMask/v")[1])==null?void 0:S.split(".")[0];if(!(Number(s)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:o=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){yield t.experimentalSuggestChain(o);}),signAmino:(o,a,s)=>l(void 0,null,function*(){return t.signAmino(o,a,s)}),getKey:o=>l(void 0,null,function*(){return typeof et[o]!="undefined"?et[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,a,s)=>l(void 0,null,function*(){return t.signDirect(o,a,s)}),signArbitrary:(o,a,s)=>l(void 0,null,function*(){return t.signArbitrary(o,a,s)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var le=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{var s;let a=()=>{z(),o();};return (s=window.cosmostation)==null||s.cosmos.on("accountChanged",a),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",a);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var ue=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let o=()=>{z(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var pe=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let o=()=>{z(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var me={},nt=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=g=>l(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(x=>x.id===e.id&&(!g||x.version===g))}catch(w){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var _;let g=yield t.request({method:"web3_clientVersion"});if(!g.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let x=(_=g.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(x)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),a=g=>l(void 0,null,function*(){(yield i())||(yield r());}),s=(g,w,x)=>l(void 0,null,function*(){let R=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:g,signerAddress:w,signDoc:x}}}}),N=x.accountNumber,_=new Ht(N.low,N.high,N.unsigned);return {signature:R.signature,signed:q(M({},R.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(R.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(R.signed.bodyBytes))})}}),c=(g,w,x)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:g,signerAddress:w,signDoc:x}}}})}),p=g=>l(void 0,null,function*(){if(typeof me[g]!="undefined")return me[g];let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:g}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,me[g]=w,me[g]}),S=g=>l(void 0,null,function*(){let w=yield p(g);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),I=(...g)=>l(void 0,null,function*(){let[w,x,R,N]=g;return yield c(w,x,R)}),O=(...g)=>l(void 0,null,function*(){let[w,x,R]=g;return yield s(w,x,R)}),C=g=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(g)]}),signAmino:(w,x)=>I(g,w,x)});return {enable:a,experimentalSuggestChain:(...g)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:g[0]}}}});}),getKey:p,getOfflineSigner:g=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(g)]}),signDirect:(w,x)=>O(g,w,x),signAmino:(w,x)=>I(g,w,x)}),getOfflineSignerAuto:g=>l(void 0,null,function*(){return C(g)}),getOfflineSignerOnlyAmino:C,init:o,signAmino:I,signDirect:O}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ot=()=>nt({id:"npm:@leapwallet/metamask-cosmos-snap"});var de=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let a=()=>{z(),o();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:o=>l(void 0,null,function*(){let a=yield e.getKey(o);return M({isKeystone:!1},a)}),getOfflineSigner:o=>{try{let a=e.getOfflineSignerOnlyAmino(o);return Object.assign(a,{signDirect:(p,S)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let a=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(s=>{var c,p,S;return {coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom,gasPriceStep:{average:((c=s.gasPriceStep)==null?void 0:c.average)||0,high:((p=s.gasPriceStep)==null?void 0:p.high)||0,low:((S=s.gasPriceStep)==null?void 0:S.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,a,s,c)=>e.signAmino(o,a,s)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var fe=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:s=>e.enable(s),getOfflineSigner:s=>e.getOfflineSigner(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getKey:s=>l(void 0,null,function*(){let c=yield e.getKey(s);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:s=>{let c=()=>{z(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>e.getOfflineSignerAmino(...s),experimentalSuggestChain:(...s)=>l(void 0,null,function*(){let[c]=s,p=q(M({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([p])}),signDirect:(...s)=>l(void 0,null,function*(){var S;let{1:c,2:p}=s;return e.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:Ht.fromString(((S=p.accountNumber)==null?void 0:S.toString())||"",!1),chainId:p.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:p}=s;return e.signAmino(c,p)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var Q=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,it=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),rt=()=>Q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var be=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var j=e=>{var _,J,Ke;if(!((Ke=(J=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:J.projectId)!=null&&Ke.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",i=y=>{if(!e)return;let{appUrl:h,formatNativeUrl:A}=e;if(Q()){if(it())if(!y)window.open(h.mobile.android,"_self","noreferrer noopener");else {let W=A(h.mobile.android,y,"android");window.open(W,"_self","noreferrer noopener");}if(rt())if(!y)window.open(h.mobile.ios,"_self","noreferrer noopener");else {let W=A(h.mobile.ios,y,"ios");window.open(W,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=m.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),m.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:h}=m.getState(),A=h.get(t);if(!A)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield A.disconnect({topic:y,reason:getSdkError("USER_DISCONNECTED")}),yield c(A);}),a=y=>{try{let{wcSignClients:h}=m.getState(),A=h.get(t);if(!A)throw new Error("walletConnect.signClient is not defined");let W=A.session.getAll().at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw o(W.topic),new Error("invalid session");try{let k=A.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:y.map(L=>`cosmos:${L}`),events:["chainChanged","accountsChanged"]}}});if(!k.length)throw new Error("no session");return k.at(-1)}catch(k){if(!k.message.toLowerCase().includes("no matching key"))throw k}return W}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}},s=y=>{try{return a(y)}catch(h){return}},c=y=>l(void 0,null,function*(){try{let h=y.core.pairing.pairings.getAll({active:!1});if(!h.length)return;yield Promise.all(h.map(A=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(A.topic,{code:7001,message:"clear pairing"});})));}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}}),p=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:h}=m.getState(),A=h.get(t);if(A)return A;let W=yield SignClient.init(y.options);return h.set(t,W),m.setState({wcSignClients:h}),W}),S=y=>{let{wcSignClients:h}=m.getState(),A=h.get(t);if(!A)return ()=>{};let W=P=>{let k=m.getState().accounts;if(P.params.event.name==="accountsChanged"&&k&&!Object.values(k).map(L=>L.bech32Address).includes(P.params.event.data[0])){let L=P.params.chainId.split(":")[1];L&&I([L]);}else y();};return A.events.on("session_delete",r),A.events.on("session_expire",r),A.events.on("session_event",W),()=>{A.events.off("session_delete",r),A.events.off("session_expire",r),A.events.off("session_event",W);}},I=y=>l(void 0,null,function*(){var ie;let h=typeof y=="string"?[y]:y,{wcSignClients:A}=m.getState(),W=A.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:P,chains:k}=u.getState();if(!((ie=P==null?void 0:P.options)!=null&&ie.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:L}=yield import('@web3modal/standalone'),H=new L(M({projectId:P.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.web3Modal)),Z=s(h);if(!Z){let{uri:U,approval:ee}=yield be(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:h.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?i(U):yield H.openModal({uri:U});let Nt=$=>l(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Oe,te)=>{ee().then(Be=>{let Le=Be.sessionProperties;if(!Le)return te(new Error("No session properties"));let Te=JSON.parse(String(Le.keys));if(Te.length===0)return te(new Error("No accounts"));let Ue=Te[0];if(!Ue)return te(new Error("No accounts"));let qe={};return h.forEach(re=>{qe[re]=q(M({},Ue),{bech32Address:toBech32(k.find(Kt=>Kt.chainId===re).bech32Config.bech32PrefixAccAddr,fromBech32(Te[0].bech32Address).data)});}),m.setState(re=>({accounts:M(M({},re.accounts||{}),qe)})),Oe(Be)}).catch(te),$.addEventListener("abort",()=>{te(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,Oe=$.signal;H.subscribeModal(te=>{te.open||$.abort();}),yield Nt(Oe);}catch($){if(H.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||H.closeModal(),Promise.resolve()}try{yield be((()=>l(void 0,null,function*(){let U=Object.fromEntries(yield Promise.all(h.map(ee=>l(void 0,null,function*(){return [ee,yield d(ee)]}))));m.setState({accounts:U});}))(),15e3,new Error("Connection timeout"));}catch(U){if(o(Z.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),O=y=>l(void 0,null,function*(){var k;let{wcSignClients:h}=m.getState(),A=h.get(t);if(!A)throw new Error("walletConnect.signClient is not defined");let W=(k=a([y]))==null?void 0:k.topic;if(!W)throw new Error("No wallet connect session");let P=yield A.request({topic:W,chainId:`cosmos:${y}`,request:{method:"cosmos_getAccounts",params:{}}});if(!P[0])throw new Error("No wallet connect account");return {address:P[0].address,algo:P[0].algo,pubkey:new Uint8Array(Buffer.from(P[0].pubkey,n))}}),d=y=>l(void 0,null,function*(){let h=a([y]);if(!(h!=null&&h.topic))throw new Error("No wallet connect session");let A=h.sessionProperties&&JSON.parse(String(h.sessionProperties.keys))[0];if(!A)throw new Error("No wallet connect key");return A}),C=(...y)=>l(void 0,null,function*(){var U,ee;let[h,A,W]=y,{accounts:P,wcSignClients:k}=m.getState(),L=k.get(t);if(!L)throw new Error("walletConnect.signClient is not defined");if(!P)throw new Error("account is not defined");let H=(U=a([h]))==null?void 0:U.topic;if(!H)throw new Error("No wallet connect session");if(!W.bodyBytes)throw new Error("No bodyBytes");if(!W.authInfoBytes)throw new Error("No authInfoBytes");let Z={topic:H,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:A,signDoc:q(M({},W),{bodyBytes:Buffer.from(W.bodyBytes).toString(n),authInfoBytes:Buffer.from(W.authInfoBytes).toString(n),accountNumber:(ee=W.accountNumber)==null?void 0:ee.toString()})}}};return i(),yield L.request(Z)}),f=(...y)=>l(void 0,null,function*(){let[h,A,W]=y,{signature:P,signed:k}=yield C(h,A,W);return {signed:{chainId:k.chainId,accountNumber:Ht.fromString(k.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(k.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(k.bodyBytes,n))},signature:P}}),E=(...y)=>l(void 0,null,function*(){var U;let[h,A,W,P]=y,{wcSignClients:k}=m.getState(),L=k.get(t),{accounts:H}=m.getState();if(!L)throw new Error("walletConnect.signClient is not defined");if(!H)throw new Error("account is not defined");let Z=(U=a([h]))==null?void 0:U.topic;if(!Z)throw new Error("No wallet connect session");return i(),yield L.request({topic:Z,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:A,signDoc:W}}})}),v=(...y)=>l(void 0,null,function*(){let[h,A,W,P]=y;return yield E(h,A,W)}),g=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,A)=>f(y,h,A)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signAmino:(h,A)=>v(y,h,A)});return {enable:I,disable:y=>l(void 0,null,function*(){var W;let{wcSignClients:h}=m.getState(),A=h.get(t);if(y===void 0){let P=A==null?void 0:A.session.getAll();P!==void 0&&(yield Promise.all(P.map(k=>o(k.topic))));}else typeof y=="string"?yield o((W=a([y]))==null?void 0:W.topic):yield Promise.all(y.map(P=>{var k;return o((k=a([P]))==null?void 0:k.topic)}));(A==null?void 0:A.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:d,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,A)=>f(y,h,A),signAmino:(h,A)=>v(y,h,A)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):g(y)}),getOfflineSignerOnlyAmino:w,signAmino:v,signDirect:f,subscription:S,init:p}};var st=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;default:return `${s}://wc?uri=${c}`}}};return j(e)};var at=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,o,a)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return j(e)};var ct=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return j(e)};var lt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return j(e)};var ge=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{z(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var K=(e=u.getState().walletType)=>{try{return D(e),!0}catch(t){return !1}},z=()=>{window.sessionStorage.removeItem(V),m.setState(ne);},D=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return ue();case"leap":return pe();case"cosmostation":return le();case"vectis":return fe();case"walletconnect":return j();case"wc_keplr_mobile":return ct();case"wc_leap_mobile":return lt();case"wc_cosmostation_mobile":return at();case"wc_clot_mobile":return st();case"metamask_snap_leap":return ot();case"metamask_snap_cosmos":return tt();case"station":return de();case"xdefi":return ge();case"capsule":return ae();case"cosmiframe":return ce();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},xi=()=>Object.fromEntries($e.map(e=>[e,K(e)])),Me=e=>e==="capsule",ut=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Y=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!K(o))throw new Error(`${o} is not available`);let s=D(o),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let p=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(p!=null&&p.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),m.setState(d=>{let C=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(E=>{var v;return !((v=d.activeChainIds)!=null&&v.includes(E))}).length>0?{status:"connecting"}:C?{status:"reconnecting"}:{status:"connecting"}});let{accounts:S}=m.getState();if(yield (t=s.init)==null?void 0:t.call(s),Me(o)&&m.getState().capsuleClient&&Object.values(m.getState().accounts||[]).length>0){let d=c.map(E=>i.find(v=>v.chainId===E)),C=m.getState().accounts;m.setState({status:"connecting"});let f=Object.fromEntries(yield Promise.all(c.map(E=>l(void 0,null,function*(){return [E,yield s.getKey(E)]}))));return m.setState(E=>({accounts:M(M({},E.accounts||{}),f)})),u.setState(E=>({recentChainIds:[...E.recentChainIds||[],...c].filter((v,g,w)=>w.indexOf(v)===g)})),m.setState(E=>({activeChainIds:[...E.activeChainIds||[],...c].filter((v,g,w)=>w.indexOf(v)===g)})),m.setState({status:"connected"}),{accounts:C,walletType:o,chains:d}}if(yield s.enable(c),Me(o)){let d=c.map(f=>i.find(E=>E.chainId===f)),C=m.getState().accounts;return m.setState({status:"connecting"}),{accounts:C,walletType:o,chains:d}}if(!ut(o)){let d=Object.fromEntries(yield Promise.all(c.map(C=>l(void 0,null,function*(){return [C,yield s.getKey(C)]}))));m.setState(C=>({accounts:M(M({},C.accounts||{}),d)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((C,f,E)=>E.indexOf(C)===f)})),m.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((C,f,E)=>E.indexOf(C)===f)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let I=c.map(d=>i.find(C=>C.chainId===d));return {accounts:m.getState().accounts,walletType:o,chains:I}}catch(n){throw console.error("connect ",n),m.getState().accounts===null&&m.setState({status:"disconnected"}),m.getState().accounts&&m.getState().activeChainIds&&m.setState({status:"connected"}),n}}),oe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(V);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=m.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(m.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(m.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(a=>!t.includes(a)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(a=>!t.includes(a))}}));}else m.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},F=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=K(n||void 0);if(t&&o&&n)return yield Y({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),oe();}}),pt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!K(n))throw new Error(`${n} is not available`);let r=D(n),o=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:a,offlineSignerAuto:s}});var xe=()=>{u.setState({recentChainIds:null});},Ui=()=>u.getState().recentChainIds,qi=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},Fi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},Gi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},We=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){let i=D(t);return t==="capsule"?yield Y({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),mt=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield We({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield Y({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var dt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var ft=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,i,r,o)}),gt=S=>l(void 0,[S],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:p}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,i,r,o,a,s,c,p)}),Ct=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,n,o,i,r)}),yt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,a,o)}),St=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),ht=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var Zi=e=>e,er=e=>e;var Ce=e=>e?Object.keys(e).length===0:!0;var ve=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},wt=e=>globalThis.DOMException===void 0?new ve(e):new DOMException(e),At=e=>{let t=e.reason===void 0?wt("This operation was aborted."):e.reason;return t instanceof Error?t:wt(t)};function ke(o,a){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((s,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let p=[],S=[],I=new Map,O=!1,d=!1,C=!1,f=0,E=0,v=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),g=x=>{O=!0,d=!0,c(x);};r&&(r.aborted&&g(At(r)),r.addEventListener("abort",()=>{g(At(r));}));let w=()=>l(this,null,function*(){if(d)return;let x=yield v.next(),R=E;if(E++,x.done){if(C=!0,f===0&&!d){if(!i&&S.length>0){g(new AggregateError(S));return}if(d=!0,I.size===0){s(p);return}let N=[];for(let[_,J]of p.entries())I.get(_)!==It&&N.push(J);s(N);}return}f++,l(this,null,function*(){try{let N=yield x.value;if(d)return;let _=yield t(N,R);_===It&&I.set(R,_),p[R]=_,f--,yield w();}catch(N){if(i)g(N);else {S.push(N),f--;try{yield w();}catch(_){g(_);}}}});});l(this,null,function*(){for(let x=0;x<n;x++){try{yield w();}catch(R){g(R);break}if(C||O)break}});})})}var It=Symbol("skip");var B=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},G=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield ke(t,n,{concurrency:i});return Object.fromEntries(o.map((a,s)=>[t[s].chainId,a]))}return yield n(t[0])}),Et=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,a)=>[t[a].chainId,o]))}return n(t[0])};var De=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:M({},(s==null?void 0:s.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},_e=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:M({},(s==null?void 0:s.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},ye=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=B({chainId:t,multiChain:n}),o=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:o,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield G(!!n,s,S=>l(void 0,null,function*(){var f;let I=(f=u.getState().chainsConfig)==null?void 0:f[S.chainId],O={url:S.rpc,headers:M({},(I==null?void 0:I.rpcHeaders)||{})};return yield (a==="tm37"?Tendermint37Client:Tendermint34Client).connect(O)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var Mr=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow),Se=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>K(r))};var X=e=>{let t=u(s=>s.walletType),n=m(s=>s.activeChainIds),i=B({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=m(s=>s.accounts),o=m(s=>s.status);return useEffect(()=>m.subscribe(s=>s.status,(s,c)=>{var p,S,I;if(s==="connected"){let{accounts:O,activeChainIds:d}=m.getState(),{chains:C}=u.getState(),{walletType:f}=u.getState();if(!O||!d||!C)return (p=e==null?void 0:e.onDisconnect)==null?void 0:p.call(e);(S=e==null?void 0:e.onConnect)==null||S.call(e,{accounts:O,chains:d.map(E=>C.find(v=>v.chainId===E)),walletType:f,isReconnect:c==="reconnecting"});}s==="disconnected"&&((I=e==null?void 0:e.onDisconnect)==null||I.call(e));}),[e]),{data:useMemo(()=>r?Et(!!(e!=null&&e.multiChain),i,s=>r[s.chainId]):void 0,[r,i,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:F,status:o}},un=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=De({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),s,I=>l(void 0,null,function*(){let O=a==null?void 0:a[I.chainId];if(!O)throw new Error(`Client is not ready ${I.chainId}`);return yield O.getAllBalances(toBech32(I.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!Ce(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Ur=e=>{let t=B({chainId:e.chainId}),{data:n}=X({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=un({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,r,t,i,e.chainId],s=useQuery(a,({queryKey:[,c,p]})=>p==null?void 0:p.find(S=>S.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return q(M({},s),{refetch:c=>l(void 0,null,function*(){return yield o(),s.refetch(c)})})},qr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],Y,{onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=Se();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},Fr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,n],oe,{onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},Gr=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:i,queryFn:a=>l(void 0,[a],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!K(o))throw new Error(`${o} is not available`);return yield G(!!(e!=null&&e.multiChain),r,p=>l(void 0,null,function*(){return yield pt({chainId:p.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},zr=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),{data:i}=De({chainId:t.map(a=>a.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),s,I=>l(void 0,null,function*(){var d;if(!a)throw new Error("Client is not ready");return yield (d=a[I.chainId])==null?void 0:d.getBalanceStaked(toBech32(I.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Xr=()=>{let e=u(i=>i.capsuleState),t=m(i=>i.capsuleClient),n=ae();return {setModalState:i=>{u.setState(r=>{var o;return {capsuleState:{showModal:i,chainId:(o=r.capsuleState)==null?void 0:o.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{oe();}}};var is=()=>m(e=>e.activeChainIds),pn=()=>{var e;return (e=m(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},rs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},ss=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},as=({denom:e})=>{let t=pn();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:o.currencies.find(a=>a)})},cs=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,s=>l(void 0,[s],function*({queryKey:[,o,a]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(a)}),{enabled:typeof e.queryClient!="undefined"})},ls=()=>({data:u(t=>t.recentChainIds),clear:xe}),us=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:xe}},ps=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],We,{onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},ms=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],mt,{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=Se();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var ws=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=X(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_TOKENS",e,t,n,r],a=>ft(M({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},As=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=X(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],a=>gt(M({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Is=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=X(),o=r==null?void 0:r.bech32Address,s=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var S;if(!o)throw new Error("senderAddress is undefined");let p=q(M({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,codeId:e});return Ct(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Es=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=X(),o=r==null?void 0:r.bech32Address,s=useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var S,I,O;if(!o)throw new Error("senderAddress is undefined");let p=q(M({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,contractAddress:e,memo:(I=c.memo)!=null?I:"",funds:(O=c.funds)!=null?O:[]});return yt(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},Os=e=>{let{data:t}=_e();return useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return St(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Ts=e=>{let{data:t}=_e(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return ht(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Bs(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var f,E;if(!(i!=null&&i.includes(p.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);let I=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(p.chainId);default:return D(a).getOfflineSignerAuto(p.chainId)}}))(),O=(f=u.getState().chainsConfig)==null?void 0:f[p.chainId],d={url:p.rpc,headers:M({},(O==null?void 0:O.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(d,I,e!=null&&e.multiChain?(E=e.opts)==null?void 0:E[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Ls(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var E,v;if(!(i!=null&&i.includes(p.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);let I=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(p.chainId);default:return D(a).getOfflineSignerAuto(p.chainId)}}))(),O=(E=u.getState().chainsConfig)==null?void 0:E[p.chainId],d={url:p.rpc,headers:M({},(O==null?void 0:O.rpcHeaders)||{})},C=O!=null&&O.gas?GasPrice.fromString(`${O.gas.price}${O.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(d,I,M({gasPrice:C},e!=null&&e.multiChain?(v=e.opts)==null?void 0:v[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Us(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=m(a=>a.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=ye({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,S=>l(this,null,function*(){var f;if(!(i!=null&&i.includes(S.chainId)))return null;if(!K(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let O=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(S.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(S.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(S.chainId);default:return D(s).getOfflineSignerAuto(S.chainId)}}))(),d=e.multiChain?o[S.chainId]:o;return yield SigningStargateClient.createWithSigner(d,O,e.multiChain?(f=e.opts)==null?void 0:f[S.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function qs(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=m(s=>s.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=ye({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=ye({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:p=>l(this,[p],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,I=>l(this,null,function*(){var g,w;if(!(i!=null&&i.includes(I.chainId)))return null;if(!K(c))throw new Error(`${c} is not available`);let d=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(c).getOfflineSigner(I.chainId);case"offlineSignerAuto":return D(c).getOfflineSignerAuto(I.chainId);case"offlineSignerOnlyAmino":return D(c).getOfflineSignerOnlyAmino(I.chainId);default:return D(c).getOfflineSignerAuto(I.chainId)}}))(),C=(g=u.getState().chainsConfig)==null?void 0:g[I.chainId],f=C!=null&&C.gas?GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0,E=e.multiChain?a==null?void 0:a[I.chainId]:o;if(!E)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(E,d,M({gasPrice:f},e.multiChain?(w=e.opts)==null?void 0:w[I.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!Ce(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Rt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var yn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i,iframeOptions:r,chains:o}=u(),{activeChainIds:a,wcSignClients:s}=m(),c=K(i||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!o)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(S=>{if(S)return Y({chainId:o.map(I=>I.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(i){if(!c)return;e&&a?F({onError:n}):!e&&t&&F({onError:n});}},[c]),useEffect(()=>{var p,S,I,O,d,C,f,E,v,g,w,x,R,N,_,J;if(i){if(!c)return;i==="cosmostation"&&((S=(p=le()).subscription)==null||S.call(p,()=>{F({onError:n});})),i==="keplr"&&((O=(I=ue()).subscription)==null||O.call(I,()=>{F({onError:n});})),i==="leap"&&((C=(d=pe()).subscription)==null||C.call(d,()=>{F({onError:n});})),i==="vectis"&&((E=(f=fe()).subscription)==null||E.call(f,()=>{F({onError:n});})),i==="walletconnect"&&s.has("walletconnect")&&((g=(v=j()).subscription)==null||g.call(v,()=>{F({onError:n});})),i==="station"&&((x=(w=de()).subscription)==null||x.call(w,()=>{F({onError:n});})),i==="xdefi"&&((N=(R=ge()).subscription)==null||N.call(R,()=>{F({onError:n});})),i==="cosmiframe"&&((J=(_=ce()).subscription)==null||J.call(_,()=>{F({onError:n});}));}},[i,s,c]),null},Dt=()=>(yn(),null);var wn=new QueryClient({}),ga=i=>{var r=i,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return dt(t),jsx(QueryClientProvider,q(M({client:wn},n),{children:jsxs(Rt,{children:[e,jsx(Dt,{})]})}),"graz-provider")};
|
|
17
|
+
var Lt=Object.defineProperty,Ut=Object.defineProperties;var Ft=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var Ge=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))ze.call(t,n)&&Ge(e,n,t[n]);if(ae)for(var n of ae(t))Qe.call(t,n)&&Ge(e,n,t[n]);return e},F=(e,t)=>Ut(e,Ft(t));var je=(e,t)=>{var n={};for(var i in e)ze.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&ae)for(var i of ae(e))t.indexOf(i)<0&&Qe.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{s(n.next(c));}catch(p){r(p);}},a=c=>{try{s(n.throw(c));}catch(p){r(p);}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,a);s((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var $e=(C=>(C.KEPLR="keplr",C.LEAP="leap",C.VECTIS="vectis",C.COSMOSTATION="cosmostation",C.WALLETCONNECT="walletconnect",C.WC_KEPLR_MOBILE="wc_keplr_mobile",C.WC_LEAP_MOBILE="wc_leap_mobile",C.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",C.WC_CLOT_MOBILE="wc_clot_mobile",C.METAMASK_SNAP_LEAP="metamask_snap_leap",C.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",C.STATION="station",C.XDEFI="xdefi",C.CAPSULE="capsule",C.COSMIFRAME="cosmiframe",C.COMPASS="compass",C))($e||{}),He=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass"];var Gt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},zt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},m=create(subscribeWithSelector(persist(()=>ne,zt))),u=create(subscribeWithSelector(persist(()=>Gt,Qt)));var ce=()=>{var E,O;if(!((E=u.getState().capsuleConfig)!=null&&E.apiKey)||!((O=u.getState().capsuleConfig)!=null&&O.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var A,C;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,g=new d({apiKey:(A=u.getState().capsuleConfig)==null?void 0:A.apiKey,env:(C=u.getState().capsuleConfig)==null?void 0:C.env});return m.setState({capsuleClient:g}),g});return {init:e,enable:d=>l(void 0,null,function*(){let g=typeof d=="string"?[d]:d,A=m.getState().capsuleClient;A||(A=yield e()),u.setState({capsuleState:{showModal:!0,chainId:g}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var v;let d=m.getState().capsuleClient,{chains:g}=u.getState();if(!d)throw new Error("Capsule client is not initialized");if(!g)throw new Error("Chains are not set");yield d.enable();let A=(v=u.getState().capsuleState)==null?void 0:v.chainId;if(!A)throw new Error("Chain ids are not set");let C=Object.fromEntries(yield Promise.all(A.map(f=>l(void 0,null,function*(){let w=yield d.getAccount(f);return [f,{address:fromBech32(w.address).data,bech32Address:w.address,algo:w.algo,name:w.username||"",pubKey:w.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));m.setState(f=>({accounts:M(M({},f.accounts||{}),C)})),u.setState(f=>({recentChainIds:[...f.recentChainIds||[],...A].filter((w,x,R)=>R.indexOf(w)===x)})),m.setState(f=>({activeChainIds:[...f.activeChainIds||[],...A].filter((w,x,R)=>R.indexOf(w)===x)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");let A=yield g.getAccount(d);return {address:fromBech32(A.address).data,bech32Address:A.address,algo:A.algo,name:A.username||"",pubKey:A.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)},signDirect:(...d)=>l(void 0,null,function*(){let[g,A,C]=d,v=m.getState().capsuleClient;if(!v)throw new Error("Capsule client is not initialized");return v.signDirect(g,A,{bodyBytes:C.bodyBytes,authInfoBytes:C.authInfoBytes,chainId:C.chainId,accountNumber:C.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[g,A,C,v]=d,f=m.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.signAmino(g,A,C,v)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerAmino(d)}}};var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let o=()=>{q(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ue=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var tt={},nt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var S;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let s=(S=o.split("MetaMask/v")[1])==null?void 0:S.split(".")[0];if(!(Number(s)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:o=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){yield t.experimentalSuggestChain(o);}),signAmino:(o,a,s)=>l(void 0,null,function*(){return t.signAmino(o,a,s)}),getKey:o=>l(void 0,null,function*(){return typeof tt[o]!="undefined"?tt[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,a,s)=>l(void 0,null,function*(){return t.signDirect(o,a,s)}),signArbitrary:(o,a,s)=>l(void 0,null,function*(){return t.signArbitrary(o,a,s)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var pe=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{var s;let a=()=>{q(),o();};return (s=window.cosmostation)==null||s.cosmos.on("accountChanged",a),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",a);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var me=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let o=()=>{q(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let o=()=>{q(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},ot=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=f=>l(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(x=>x.id===e.id&&(!f||x.version===f))}catch(w){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var _;let f=yield t.request({method:"web3_clientVersion"});if(!f.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let x=(_=f.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(x)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),a=f=>l(void 0,null,function*(){(yield i())||(yield r());}),s=(f,w,x)=>l(void 0,null,function*(){let R=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:w,signDoc:x}}}}),N=x.accountNumber,_=new Vt(N.low,N.high,N.unsigned);return {signature:R.signature,signed:F(M({},R.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(R.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(R.signed.bodyBytes))})}}),c=(f,w,x)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:f,signerAddress:w,signDoc:x}}}})}),p=f=>l(void 0,null,function*(){if(typeof fe[f]!="undefined")return fe[f];let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:f}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,fe[f]=w,fe[f]}),S=f=>l(void 0,null,function*(){let w=yield p(f);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),E=(...f)=>l(void 0,null,function*(){let[w,x,R,N]=f;return yield c(w,x,R)}),O=(...f)=>l(void 0,null,function*(){let[w,x,R]=f;return yield s(w,x,R)}),g=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(f)]}),signAmino:(w,x)=>E(f,w,x)});return {enable:a,experimentalSuggestChain:(...f)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:f[0]}}}});}),getKey:p,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(f)]}),signDirect:(w,x)=>O(f,w,x),signAmino:(w,x)=>E(f,w,x)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return g(f)}),getOfflineSignerOnlyAmino:g,init:o,signAmino:E,signDirect:O}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var it=()=>ot({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let a=()=>{q(),o();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:o=>l(void 0,null,function*(){let a=yield e.getKey(o);return M({isKeystone:!1},a)}),getOfflineSigner:o=>{try{let a=e.getOfflineSignerOnlyAmino(o);return Object.assign(a,{signDirect:(p,S)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let a=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(s=>{var c,p,S;return {coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom,gasPriceStep:{average:((c=s.gasPriceStep)==null?void 0:c.average)||0,high:((p=s.gasPriceStep)==null?void 0:p.high)||0,low:((S=s.gasPriceStep)==null?void 0:S.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,a,s,c)=>e.signAmino(o,a,s)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Ce=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:s=>e.enable(s),getOfflineSigner:s=>e.getOfflineSigner(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getKey:s=>l(void 0,null,function*(){let c=yield e.getKey(s);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:s=>{let c=()=>{q(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>e.getOfflineSignerAmino(...s),experimentalSuggestChain:(...s)=>l(void 0,null,function*(){let[c]=s,p=F(M({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([p])}),signDirect:(...s)=>l(void 0,null,function*(){var S;let{1:c,2:p}=s;return e.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:Vt.fromString(((S=p.accountNumber)==null?void 0:S.toString())||"",!1),chainId:p.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:p}=s;return e.signAmino(c,p)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var Q=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,rt=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),st=()=>Q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var xe=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var j=e=>{var _,J,oe;if(!((oe=(J=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:J.projectId)!=null&&oe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",i=y=>{if(!e)return;let{appUrl:h,formatNativeUrl:I}=e;if(Q()){if(rt())if(!y)window.open(h.mobile.android,"_self","noreferrer noopener");else {let W=I(h.mobile.android,y,"android");window.open(W,"_self","noreferrer noopener");}if(st())if(!y)window.open(h.mobile.ios,"_self","noreferrer noopener");else {let W=I(h.mobile.ios,y,"ios");window.open(W,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=m.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),m.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield I.disconnect({topic:y,reason:getSdkError("USER_DISCONNECTED")}),yield c(I);}),a=y=>{try{let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let W=I.session.getAll().at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw o(W.topic),new Error("invalid session");try{let k=I.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:y.map(L=>`cosmos:${L}`),events:["chainChanged","accountsChanged"]}}});if(!k.length)throw new Error("no session");return k.at(-1)}catch(k){if(!k.message.toLowerCase().includes("no matching key"))throw k}return W}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}},s=y=>{try{return a(y)}catch(h){return}},c=y=>l(void 0,null,function*(){try{let h=y.core.pairing.pairings.getAll({active:!1});if(!h.length)return;yield Promise.all(h.map(I=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}}),p=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:h}=m.getState(),I=h.get(t);if(I)return I;let W=yield SignClient.init(y.options);return h.set(t,W),m.setState({wcSignClients:h}),W}),S=y=>{let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)return ()=>{};let W=P=>{let k=m.getState().accounts;if(P.params.event.name==="accountsChanged"&&k&&!Object.values(k).map(L=>L.bech32Address).includes(P.params.event.data[0])){let L=P.params.chainId.split(":")[1];L&&E([L]);}else y();};return I.events.on("session_delete",r),I.events.on("session_expire",r),I.events.on("session_event",W),()=>{I.events.off("session_delete",r),I.events.off("session_expire",r),I.events.off("session_event",W);}},E=y=>l(void 0,null,function*(){var re;let h=typeof y=="string"?[y]:y,{wcSignClients:I}=m.getState(),W=I.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:P,chains:k}=u.getState();if(!((re=P==null?void 0:P.options)!=null&&re.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:L}=yield import('@web3modal/standalone'),H=new L(M({projectId:P.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.web3Modal)),Z=s(h);if(!Z){let{uri:U,approval:ee}=yield xe(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:h.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?i(U):yield H.openModal({uri:U});let Kt=$=>l(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((be,te)=>{ee().then(Le=>{let Ue=Le.sessionProperties;if(!Ue)return te(new Error("No session properties"));let Me=JSON.parse(String(Ue.keys));if(Me.length===0)return te(new Error("No accounts"));let Fe=Me[0];if(!Fe)return te(new Error("No accounts"));let qe={};return h.forEach(se=>{qe[se]=F(M({},Fe),{bech32Address:toBech32(k.find(Bt=>Bt.chainId===se).bech32Config.bech32PrefixAccAddr,fromBech32(Me[0].bech32Address).data)});}),m.setState(se=>({accounts:M(M({},se.accounts||{}),qe)})),be(Le)}).catch(te),$.addEventListener("abort",()=>{te(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,be=$.signal;H.subscribeModal(te=>{te.open||$.abort();}),yield Kt(be);}catch($){if(H.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||H.closeModal(),Promise.resolve()}try{yield xe((()=>l(void 0,null,function*(){let U=Object.fromEntries(yield Promise.all(h.map(ee=>l(void 0,null,function*(){return [ee,yield d(ee)]}))));m.setState({accounts:U});}))(),15e3,new Error("Connection timeout"));}catch(U){if(o(Z.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),O=y=>l(void 0,null,function*(){var k;let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let W=(k=a([y]))==null?void 0:k.topic;if(!W)throw new Error("No wallet connect session");let P=yield I.request({topic:W,chainId:`cosmos:${y}`,request:{method:"cosmos_getAccounts",params:{}}});if(!P[0])throw new Error("No wallet connect account");return {address:P[0].address,algo:P[0].algo,pubkey:new Uint8Array(Buffer.from(P[0].pubkey,n))}}),d=y=>l(void 0,null,function*(){let h=a([y]);if(!(h!=null&&h.topic))throw new Error("No wallet connect session");let I=h.sessionProperties&&JSON.parse(String(h.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),g=(...y)=>l(void 0,null,function*(){var U,ee;let[h,I,W]=y,{accounts:P,wcSignClients:k}=m.getState(),L=k.get(t);if(!L)throw new Error("walletConnect.signClient is not defined");if(!P)throw new Error("account is not defined");let H=(U=a([h]))==null?void 0:U.topic;if(!H)throw new Error("No wallet connect session");if(!W.bodyBytes)throw new Error("No bodyBytes");if(!W.authInfoBytes)throw new Error("No authInfoBytes");let Z={topic:H,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:F(M({},W),{bodyBytes:Buffer.from(W.bodyBytes).toString(n),authInfoBytes:Buffer.from(W.authInfoBytes).toString(n),accountNumber:(ee=W.accountNumber)==null?void 0:ee.toString()})}}};return i(),yield L.request(Z)}),A=(...y)=>l(void 0,null,function*(){let[h,I,W]=y,{signature:P,signed:k}=yield g(h,I,W);return {signed:{chainId:k.chainId,accountNumber:Vt.fromString(k.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(k.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(k.bodyBytes,n))},signature:P}}),C=(...y)=>l(void 0,null,function*(){var U;let[h,I,W,P]=y,{wcSignClients:k}=m.getState(),L=k.get(t),{accounts:H}=m.getState();if(!L)throw new Error("walletConnect.signClient is not defined");if(!H)throw new Error("account is not defined");let Z=(U=a([h]))==null?void 0:U.topic;if(!Z)throw new Error("No wallet connect session");return i(),yield L.request({topic:Z,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:W}}})}),v=(...y)=>l(void 0,null,function*(){let[h,I,W,P]=y;return yield C(h,I,W)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,I)=>A(y,h,I)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signAmino:(h,I)=>v(y,h,I)});return {enable:E,disable:y=>l(void 0,null,function*(){var W;let{wcSignClients:h}=m.getState(),I=h.get(t);if(y===void 0){let P=I==null?void 0:I.session.getAll();P!==void 0&&(yield Promise.all(P.map(k=>o(k.topic))));}else typeof y=="string"?yield o((W=a([y]))==null?void 0:W.topic):yield Promise.all(y.map(P=>{var k;return o((k=a([P]))==null?void 0:k.topic)}));(I==null?void 0:I.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:d,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,I)=>A(y,h,I),signAmino:(h,I)=>v(y,h,I)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):f(y)}),getOfflineSignerOnlyAmino:w,signAmino:v,signDirect:A,subscription:S,init:p}};var at=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;default:return `${s}://wc?uri=${c}`}}};return j(e)};var ct=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,o,a)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return j(e)};var lt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return j(e)};var ut=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return j(e)};var ye=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{q(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var K=(e=u.getState().walletType)=>{try{return D(e),!0}catch(t){return !1}},q=()=>{window.sessionStorage.removeItem(V),m.setState(ne);},D=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return me();case"leap":return de();case"cosmostation":return pe();case"vectis":return Ce();case"walletconnect":return j();case"wc_keplr_mobile":return lt();case"wc_leap_mobile":return ut();case"wc_cosmostation_mobile":return ct();case"wc_clot_mobile":return at();case"metamask_snap_leap":return it();case"metamask_snap_cosmos":return nt();case"station":return ge();case"xdefi":return ye();case"capsule":return ce();case"cosmiframe":return ue();case"compass":return le();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},Di=()=>Object.fromEntries(He.map(e=>[e,K(e)])),We=e=>e==="capsule",pt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Y=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!K(o))throw new Error(`${o} is not available`);let s=D(o),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let p=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(p!=null&&p.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),m.setState(d=>{let g=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(C=>{var v;return !((v=d.activeChainIds)!=null&&v.includes(C))}).length>0?{status:"connecting"}:g?{status:"reconnecting"}:{status:"connecting"}});let{accounts:S}=m.getState();if(yield (t=s.init)==null?void 0:t.call(s),We(o)&&m.getState().capsuleClient&&Object.values(m.getState().accounts||[]).length>0){let d=c.map(C=>i.find(v=>v.chainId===C)),g=m.getState().accounts;m.setState({status:"connecting"});let A=Object.fromEntries(yield Promise.all(c.map(C=>l(void 0,null,function*(){return [C,yield s.getKey(C)]}))));return m.setState(C=>({accounts:M(M({},C.accounts||{}),A)})),u.setState(C=>({recentChainIds:[...C.recentChainIds||[],...c].filter((v,f,w)=>w.indexOf(v)===f)})),m.setState(C=>({activeChainIds:[...C.activeChainIds||[],...c].filter((v,f,w)=>w.indexOf(v)===f)})),m.setState({status:"connected"}),{accounts:g,walletType:o,chains:d}}if(yield s.enable(c),We(o)){let d=c.map(A=>i.find(C=>C.chainId===A)),g=m.getState().accounts;return m.setState({status:"connecting"}),{accounts:g,walletType:o,chains:d}}if(!pt(o)){let d=Object.fromEntries(yield Promise.all(c.map(g=>l(void 0,null,function*(){return [g,yield s.getKey(g)]}))));m.setState(g=>({accounts:M(M({},g.accounts||{}),d)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((g,A,C)=>C.indexOf(g)===A)})),m.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((g,A,C)=>C.indexOf(g)===A)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let E=c.map(d=>i.find(g=>g.chainId===d));return {accounts:m.getState().accounts,walletType:o,chains:E}}catch(n){throw console.error("connect ",n),m.getState().accounts===null&&m.setState({status:"disconnected"}),m.getState().accounts&&m.getState().activeChainIds&&m.setState({status:"connected"}),n}}),ie=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(V);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=m.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(m.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(m.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(a=>!t.includes(a)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(a=>!t.includes(a))}}));}else m.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},G=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=K(n||void 0);if(t&&o&&n)return yield Y({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),ie();}}),mt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!K(n))throw new Error(`${n} is not available`);let r=D(n),o=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:a,offlineSignerAuto:s}});var ve=()=>{u.setState({recentChainIds:null});},ji=()=>u.getState().recentChainIds,$i=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},Hi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},Vi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ke=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){let i=D(t);return t==="capsule"?yield Y({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),dt=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield ke({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield Y({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ft=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var gt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,i,r,o)}),Ct=S=>l(void 0,[S],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:p}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,i,r,o,a,s,c,p)}),yt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,n,o,i,r)}),St=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,a,o)}),ht=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),wt=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var rr=e=>e,sr=e=>e;var Se=e=>e?Object.keys(e).length===0:!0;var Pe=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},At=e=>globalThis.DOMException===void 0?new Pe(e):new DOMException(e),It=e=>{let t=e.reason===void 0?At("This operation was aborted."):e.reason;return t instanceof Error?t:At(t)};function Re(o,a){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((s,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let p=[],S=[],E=new Map,O=!1,d=!1,g=!1,A=0,C=0,v=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=x=>{O=!0,d=!0,c(x);};r&&(r.aborted&&f(It(r)),r.addEventListener("abort",()=>{f(It(r));}));let w=()=>l(this,null,function*(){if(d)return;let x=yield v.next(),R=C;if(C++,x.done){if(g=!0,A===0&&!d){if(!i&&S.length>0){f(new AggregateError(S));return}if(d=!0,E.size===0){s(p);return}let N=[];for(let[_,J]of p.entries())E.get(_)!==Et&&N.push(J);s(N);}return}A++,l(this,null,function*(){try{let N=yield x.value;if(d)return;let _=yield t(N,R);_===Et&&E.set(R,_),p[R]=_,A--,yield w();}catch(N){if(i)f(N);else {S.push(N),A--;try{yield w();}catch(_){f(_);}}}});});l(this,null,function*(){for(let x=0;x<n;x++){try{yield w();}catch(R){f(R);break}if(g||O)break}});})})}var Et=Symbol("skip");var B=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},z=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield Re(t,n,{concurrency:i});return Object.fromEntries(o.map((a,s)=>[t[s].chainId,a]))}return yield n(t[0])}),Ot=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,a)=>[t[a].chainId,o]))}return n(t[0])};var Ne=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:M({},(s==null?void 0:s.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ke=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:M({},(s==null?void 0:s.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},he=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=B({chainId:t,multiChain:n}),o=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:o,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield z(!!n,s,S=>l(void 0,null,function*(){var A;let E=(A=u.getState().chainsConfig)==null?void 0:A[S.chainId],O={url:S.rpc,headers:M({},(E==null?void 0:E.rpcHeaders)||{})};return yield (a==="tm37"?Tendermint37Client:Tendermint34Client).connect(O)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var Rr=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow),we=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>K(r))};var X=e=>{let t=u(s=>s.walletType),n=m(s=>s.activeChainIds),i=B({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=m(s=>s.accounts),o=m(s=>s.status);return useEffect(()=>m.subscribe(s=>s.status,(s,c)=>{var p,S,E;if(s==="connected"){let{accounts:O,activeChainIds:d}=m.getState(),{chains:g}=u.getState(),{walletType:A}=u.getState();if(!O||!d||!g)return (p=e==null?void 0:e.onDisconnect)==null?void 0:p.call(e);(S=e==null?void 0:e.onConnect)==null||S.call(e,{accounts:O,chains:d.map(C=>g.find(v=>v.chainId===C)),walletType:A,isReconnect:c==="reconnecting"});}s==="disconnected"&&((E=e==null?void 0:e.onDisconnect)==null||E.call(e));}),[e]),{data:useMemo(()=>r?Ot(!!(e!=null&&e.multiChain),i,s=>r[s.chainId]):void 0,[r,i,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:G,status:o}},pn=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Ne({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),s,E=>l(void 0,null,function*(){let O=a==null?void 0:a[E.chainId];if(!O)throw new Error(`Client is not ready ${E.chainId}`);return yield O.getAllBalances(toBech32(E.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!Se(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},jr=e=>{let t=B({chainId:e.chainId}),{data:n}=X({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=pn({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,r,t,i,e.chainId],s=useQuery(a,({queryKey:[,c,p]})=>p==null?void 0:p.find(S=>S.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return F(M({},s),{refetch:c=>l(void 0,null,function*(){return yield o(),s.refetch(c)})})},$r=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],Y,{onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=we();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},Hr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,n],ie,{onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},Vr=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:i,queryFn:a=>l(void 0,[a],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!K(o))throw new Error(`${o} is not available`);return yield z(!!(e!=null&&e.multiChain),r,p=>l(void 0,null,function*(){return yield mt({chainId:p.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},Yr=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),{data:i}=Ne({chainId:t.map(a=>a.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),s,E=>l(void 0,null,function*(){var d;if(!a)throw new Error("Client is not ready");return yield (d=a[E.chainId])==null?void 0:d.getBalanceStaked(toBech32(E.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var os=()=>{let e=u(i=>i.capsuleState),t=m(i=>i.capsuleClient),n=ce();return {setModalState:i=>{u.setState(r=>{var o;return {capsuleState:{showModal:i,chainId:(o=r.capsuleState)==null?void 0:o.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{ie();}}};var us=()=>m(e=>e.activeChainIds),mn=()=>{var e;return (e=m(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},ps=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},ms=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ds=({denom:e})=>{let t=mn();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:o.currencies.find(a=>a)})},fs=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,s=>l(void 0,[s],function*({queryKey:[,o,a]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(a)}),{enabled:typeof e.queryClient!="undefined"})},gs=()=>({data:u(t=>t.recentChainIds),clear:ve}),Cs=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:ve}},ys=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],ke,{onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Ss=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],dt,{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=we();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=X(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_TOKENS",e,t,n,r],a=>gt(M({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Ms=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=X(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],a=>Ct(M({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},xs=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=X(),o=r==null?void 0:r.bech32Address,s=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var S;if(!o)throw new Error("senderAddress is undefined");let p=F(M({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,codeId:e});return yt(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Ws=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=X(),o=r==null?void 0:r.bech32Address,s=useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var S,E,O;if(!o)throw new Error("senderAddress is undefined");let p=F(M({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,contractAddress:e,memo:(E=c.memo)!=null?E:"",funds:(O=c.funds)!=null?O:[]});return St(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},vs=e=>{let{data:t}=Ke();return useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return ht(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ks=e=>{let{data:t}=Ke(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return wt(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function zs(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var A,C;if(!(i!=null&&i.includes(p.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(p.chainId);default:return D(a).getOfflineSignerAuto(p.chainId)}}))(),O=(A=u.getState().chainsConfig)==null?void 0:A[p.chainId],d={url:p.rpc,headers:M({},(O==null?void 0:O.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(d,E,e!=null&&e.multiChain?(C=e.opts)==null?void 0:C[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Qs(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var C,v;if(!(i!=null&&i.includes(p.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(p.chainId);default:return D(a).getOfflineSignerAuto(p.chainId)}}))(),O=(C=u.getState().chainsConfig)==null?void 0:C[p.chainId],d={url:p.rpc,headers:M({},(O==null?void 0:O.rpcHeaders)||{})},g=O!=null&&O.gas?GasPrice.fromString(`${O.gas.price}${O.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(d,E,M({gasPrice:g},e!=null&&e.multiChain?(v=e.opts)==null?void 0:v[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function js(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=m(a=>a.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=he({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,a,S=>l(this,null,function*(){var A;if(!(i!=null&&i.includes(S.chainId)))return null;if(!K(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let O=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(S.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(S.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(S.chainId);default:return D(s).getOfflineSignerAuto(S.chainId)}}))(),d=e.multiChain?o[S.chainId]:o;return yield SigningStargateClient.createWithSigner(d,O,e.multiChain?(A=e.opts)==null?void 0:A[S.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function $s(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=m(s=>s.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=he({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=he({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:p=>l(this,[p],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,s,E=>l(this,null,function*(){var f,w;if(!(i!=null&&i.includes(E.chainId)))return null;if(!K(c))throw new Error(`${c} is not available`);let d=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(c).getOfflineSigner(E.chainId);case"offlineSignerAuto":return D(c).getOfflineSignerAuto(E.chainId);case"offlineSignerOnlyAmino":return D(c).getOfflineSignerOnlyAmino(E.chainId);default:return D(c).getOfflineSignerAuto(E.chainId)}}))(),g=(f=u.getState().chainsConfig)==null?void 0:f[E.chainId],A=g!=null&&g.gas?GasPrice.fromString(`${g.gas.price}${g.gas.denom}`):void 0,C=e.multiChain?a==null?void 0:a[E.chainId]:o;if(!C)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(C,d,M({gasPrice:A},e.multiChain?(w=e.opts)==null?void 0:w[E.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!Se(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Dt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var Sn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i,iframeOptions:r,chains:o}=u(),{activeChainIds:a,wcSignClients:s}=m(),c=K(i||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!o)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(S=>{if(S)return Y({chainId:o.map(E=>E.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(i){if(!c)return;e&&a?G({onError:n}):!e&&t&&G({onError:n});}},[c]),useEffect(()=>{var p,S,E,O,d,g,A,C,v,f,w,x,R,N,_,J,oe,y;if(i){if(!c)return;i==="cosmostation"&&((S=(p=pe()).subscription)==null||S.call(p,()=>{G({onError:n});})),i==="keplr"&&((O=(E=me()).subscription)==null||O.call(E,()=>{G({onError:n});})),i==="leap"&&((g=(d=de()).subscription)==null||g.call(d,()=>{G({onError:n});})),i==="compass"&&((C=(A=le()).subscription)==null||C.call(A,()=>{G({onError:n});})),i==="vectis"&&((f=(v=Ce()).subscription)==null||f.call(v,()=>{G({onError:n});})),i==="walletconnect"&&s.has("walletconnect")&&((x=(w=j()).subscription)==null||x.call(w,()=>{G({onError:n});})),i==="station"&&((N=(R=ge()).subscription)==null||N.call(R,()=>{G({onError:n});})),i==="xdefi"&&((J=(_=ye()).subscription)==null||J.call(_,()=>{G({onError:n});})),i==="cosmiframe"&&((y=(oe=ue()).subscription)==null||y.call(oe,()=>{G({onError:n});}));}},[i,s,c]),null},_t=()=>(Sn(),null);var An=new QueryClient({}),Ia=i=>{var r=i,{children:e,grazOptions:t}=r,n=je(r,["children","grazOptions"]);return ft(t),jsx(QueryClientProvider,F(M({client:An},n),{children:jsxs(Dt,{children:[e,jsx(_t,{})]})}),"graz-provider")};
|
|
18
18
|
|
|
19
|
-
export {
|
|
19
|
+
export { _t as GrazEvents, Ia as GrazProvider, He as WALLET_TYPES, $e as WalletType, K as checkWallet, ve as clearRecentChain, q as clearSession, ft as configureGraz, Y as connect, sr as defineChainInfo, rr as defineChains, ie as disconnect, St as executeContract, Di as getAvailableWallets, Hi as getChainInfo, Vi as getChainInfos, pe as getCosmostation, me as getKeplr, de as getLeap, it as getMetamaskSnapLeap, mt as getOfflineSigners, wt as getQueryRaw, ht as getQuerySmart, ji as getRecentChainIds, $i as getRecentChains, Ce as getVectis, ct as getWCCosmostation, lt as getWCKeplr, ut as getWCLeap, D as getWallet, j as getWalletConnect, yt as instantiateContract, We as isCapsule, pt as isWalletConnect, G as reconnect, Ct as sendIbcTokens, gt as sendTokens, ke as suggestChain, dt as suggestChainAndConnect, X as useAccount, ds as useActiveChainCurrency, us as useActiveChainIds, mn as useActiveChains, Rr as useActiveWalletType, jr as useBalance, Yr as useBalanceStaked, pn as useBalances, os as useCapsule, ps as useChainInfo, ms as useChainInfos, we as useCheckWallet, $r as useConnect, Ke as useCosmWasmClient, Qs as useCosmWasmSigningClient, $s as useCosmWasmTmSigningClient, Hr as useDisconnect, Ws as useExecuteContract, Sn as useGrazEvents, xs as useInstantiateContract, Vr as useOfflineSigners, fs as useQueryClientValidators, ks as useQueryRaw, vs as useQuerySmart, gs as useRecentChainIds, Cs as useRecentChains, Ms as useSendIbcTokens, bs as useSendTokens, Ne as useStargateClient, zs as useStargateSigningClient, js as useStargateTmSigningClient, ys as useSuggestChain, Ss as useSuggestChainAndConnect, he as useTendermintClient };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.19",
|
|
5
5
|
"author": "Griko Nibras <griko@strange.love>",
|
|
6
6
|
"repository": "https://github.com/graz-sh/graz.git",
|
|
7
7
|
"homepage": "https://github.com/graz-sh/graz",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@cosmjs/proto-signing": "*",
|
|
41
41
|
"@cosmjs/stargate": "*",
|
|
42
42
|
"@cosmjs/tendermint-rpc": "*",
|
|
43
|
-
"@leapwallet/cosmos-social-login-capsule-provider": "^0.0.
|
|
43
|
+
"@leapwallet/cosmos-social-login-capsule-provider": "^0.0.39",
|
|
44
44
|
"react": ">=17"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
package/types/global.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type VectisWindow = import("@vectis/extension-client").VectisWindow;
|
|
|
6
6
|
declare global {
|
|
7
7
|
interface Window extends KeplrWindow, VectisWindow {
|
|
8
8
|
leap?: KeplrWindow["keplr"];
|
|
9
|
+
compass?: KeplrWindow["keplr"];
|
|
9
10
|
cosmostation?: {
|
|
10
11
|
cosmos: {
|
|
11
12
|
on: (type: string, listener: EventListenerOrEventListenerObject) => void;
|