graz 0.1.6 → 0.1.7
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.js +65 -65
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var encoding = require('@cosmjs/encoding');
|
|
4
4
|
var zustand = require('zustand');
|
|
5
5
|
var middleware = require('zustand/middleware');
|
|
6
|
-
var
|
|
6
|
+
var Ft = require('long');
|
|
7
7
|
var signClient = require('@walletconnect/sign-client');
|
|
8
8
|
var utils = require('@walletconnect/utils');
|
|
9
9
|
var reactQuery = require('@tanstack/react-query');
|
|
@@ -16,80 +16,80 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
16
16
|
|
|
17
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var Ft__default = /*#__PURE__*/_interopDefault(Ft);
|
|
20
20
|
|
|
21
|
-
var Dt=Object.defineProperty,Nt=Object.defineProperties;var Bt=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var qe=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var Ue=(e,t,n)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))qe.call(t,n)&&Ue(e,n,t[n]);if(se)for(var n of se(t))Ge.call(t,n)&&Ue(e,n,t[n]);return e},N=(e,t)=>Nt(e,Bt(t));var Fe=(e,t)=>{var n={};for(var i in e)qe.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&&Ge.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{a(n.next(c));}catch(m){r(m);}},s=c=>{try{a(n.throw(c));}catch(m){r(m);}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,s);a((n=n.apply(e,t)).next());});var H="graz-reconnect-session";var ze=(h=>(h.KEPLR="keplr",h.LEAP="leap",h.VECTIS="vectis",h.COSMOSTATION="cosmostation",h.WALLETCONNECT="walletconnect",h.WC_KEPLR_MOBILE="wc_keplr_mobile",h.WC_LEAP_MOBILE="wc_leap_mobile",h.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",h.METAMASK_SNAP_LEAP="metamask_snap_leap",h.STATION="station",h.XDEFI="xdefi",h.CAPSULE="capsule",h))(ze||{}),Qe=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","metamask_snap_leap","station","xdefi","capsule"];var Kt={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},Z={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Lt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},Ut={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},p=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Z,Lt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Kt,Ut)));var ae=()=>{var E,h;if(!((E=u.getState().capsuleConfig)!=null&&E.apiKey)||!((h=u.getState().capsuleConfig)!=null&&h.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var C,T;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,f=new d({apiKey:(C=u.getState().capsuleConfig)==null?void 0:C.apiKey,env:(T=u.getState().capsuleConfig)==null?void 0:T.env});return p.setState({capsuleClient:f}),f});return {init:e,enable:d=>l(void 0,null,function*(){let f=typeof d=="string"?[d]:d,C=p.getState().capsuleClient;C||(C=yield e()),u.setState({capsuleState:{showModal:!0,chainId:f}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var g;let d=p.getState().capsuleClient,{chains:f}=u.getState();if(!d)throw new Error("Capsule client is not initialized");if(!f)throw new Error("Chains are not set");yield d.enable();let C=(g=u.getState().capsuleState)==null?void 0:g.chainId;if(!C)throw new Error("Chain ids are not set");let T=yield d.getAccount(C[0]),x={};C.forEach(w=>{x[w]={address:encoding.fromBech32(T.address).data,bech32Address:encoding.toBech32(f.find(b=>b.chainId===w).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(T.address).data),algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1};}),p.setState(w=>({accounts:O(O({},w.accounts||{}),x)})),u.setState(w=>({recentChainIds:[...w.recentChainIds||[],...C].filter((b,P,D)=>D.indexOf(b)===P)})),p.setState(w=>({activeChainIds:[...w.activeChainIds||[],...C].filter((b,P,D)=>D.indexOf(b)===P)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");let C=yield f.getAccount(d);return {address:encoding.fromBech32(C.address).data,bech32Address:C.address,algo:C.algo,name:C.username||"",pubKey:C.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSignerDirect(d)},signDirect:(...d)=>l(void 0,null,function*(){let[f,C,T]=d,x=p.getState().capsuleClient;if(!x)throw new Error("Capsule client is not initialized");return x.signDirect(f,C,{bodyBytes:T.bodyBytes,authInfoBytes:T.authInfoBytes,chainId:T.chainId,accountNumber:T.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[f,C,T,x]=d,g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.signAmino(f,C,T,x)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by capsule");},getOfflineSigner:d=>{let f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSignerAmino(d)}}};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 a;let s=()=>{F(),o();};return (a=window.cosmostation)==null||a.cosmos.on("accountChanged",s),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",s);}},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=()=>{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 ue=()=>{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 Ve=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(b=>b.id===e.id&&(!g||b.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 B;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 b=(B=g.split("MetaMask/v")[1])==null?void 0:B.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),s=g=>l(void 0,null,function*(){(yield i())||(yield r());}),a=(g,w,b)=>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:b}}}}),D=b.accountNumber,B=new Gt__default.default(D.low,D.high,D.unsigned);return {signature:P.signature,signed:N(O({},P.signed),{accountNumber:`${B.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),c=(g,w,b)=>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:b}}}})}),m=g=>l(void 0,null,function*(){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,O({},w)}),A=g=>l(void 0,null,function*(){let w=yield m(g);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),E=(...g)=>l(void 0,null,function*(){let[w,b,P,D]=g;return yield c(w,b,P)}),h=(...g)=>l(void 0,null,function*(){let[w,b,P]=g;return yield a(w,b,P)}),d=g=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(g)]}),signDirect:(w,b)=>h(g,w,b)}),f=g=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(g)]}),signAmino:(w,b)=>E(g,w,b)});return {enable:s,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:m,getOfflineSigner:g=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(g)]}),signDirect:(w,b)=>h(g,w,b),signAmino:(w,b)=>E(g,w,b)}),getOfflineSignerAuto:g=>l(void 0,null,function*(){return (yield m(g)).isNanoLedger?f(g):d(g)}),getOfflineSignerOnlyAmino:f,init:o,signAmino:E,signDirect:h}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Ye=()=>Ve({id:"npm:@leapwallet/metamask-cosmos-snap"});var de=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let s=()=>{F(),o();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:o=>l(void 0,null,function*(){let s=yield e.getKey(o);return O({isKeystone:!1},s)}),getOfflineSigner:o=>{try{let s=e.getOfflineSignerOnlyAmino(o);return Object.assign(s,{signDirect:(m,A)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let s=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(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(a=>{var c,m,A;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((c=a.gasPriceStep)==null?void 0:c.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((A=a.gasPriceStep)==null?void 0:A.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),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,s,a,c)=>e.signAmino(o,s,a),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var pe=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>l(void 0,null,function*(){let c=yield e.getKey(a);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:a=>{let c=()=>{F(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>l(void 0,null,function*(){let[c]=a,m=N(O({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>l(void 0,null,function*(){var A;let{1:c,2:m}=a;return e.signDirect(c,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:Gt__default.default.fromString(((A=m.accountNumber)==null?void 0:A.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>l(void 0,null,function*(){let{1:c,2:m}=a;return e.signAmino(c,m)}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}}}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,Xe=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),Je=()=>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 B,ne,Ne;if(!((Ne=(ne=(B=u.getState().walletConnect)==null?void 0:B.options)==null?void 0:ne.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:S,formatNativeUrl:I}=e;if(Q()){if(Xe())if(!y)window.open(S.mobile.android,"_self","noreferrer noopener");else {let v=I(S.mobile.android,y,"android");window.open(v,"_self","noreferrer noopener");}if(Je())if(!y)window.open(S.mobile.ios,"_self","noreferrer noopener");else {let v=I(S.mobile.ios,y,"ios");window.open(v,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=p.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),p.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:S}=p.getState(),I=S.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);}),s=y=>{try{let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let v=I.session.getAll().at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw o(v.topic),new Error("invalid session");try{let W=I.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:y.map(U=>`cosmos:${U}`),events:["chainChanged","accountsChanged"]}}});if(!W.length)throw new Error("no session");return W.at(-1)}catch(W){if(!W.message.toLowerCase().includes("no matching key"))throw W}return v}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}},a=y=>{try{return s(y)}catch(S){return}},c=y=>l(void 0,null,function*(){try{let S=y.core.pairing.pairings.getAll({active:!1});if(!S.length)return;yield Promise.all(S.map(I=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}}),m=()=>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:S}=p.getState(),I=S.get(t);if(I)return I;let v=yield signClient.SignClient.init(y.options);return S.set(t,v),p.setState({wcSignClients:S}),v}),A=y=>{let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)return ()=>{};let v=k=>{let W=p.getState().accounts;if(k.params.event.name==="accountsChanged"&&W&&!Object.values(W).map(U=>U.bech32Address).includes(k.params.event.data[0])){let U=k.params.chainId.split(":")[1];U&&E([U]);}else y();};return I.events.on("session_delete",r),I.events.on("session_expire",r),I.events.on("session_event",v),()=>{I.events.off("session_delete",r),I.events.off("session_expire",r),I.events.off("session_event",v);}},E=y=>l(void 0,null,function*(){var oe;let S=typeof y=="string"?[y]:y,{wcSignClients:I}=p.getState(),v=I.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:k,chains:W}=u.getState();if(!((oe=k==null?void 0:k.options)!=null&&oe.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:U}=yield import('@web3modal/standalone'),$=new U(O({projectId:k.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},k.web3Modal)),Y=a(S);if(!Y){let{uri:K,approval:X}=yield be(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:S.map(G=>`cosmos:${G}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!K)throw new Error("No wallet connect uri");e?i(K):yield $.openModal({uri:K});let ie=G=>l(void 0,null,function*(){return G.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Ie,J)=>{X().then(Be=>{let _e=Be.sessionProperties;if(!_e)return J(new Error("No session properties"));let Ee=JSON.parse(String(_e.keys));if(Ee.length===0)return J(new Error("No accounts"));let Ke=Ee[0];if(!Ke)return J(new Error("No accounts"));let Le={};return S.forEach(re=>{Le[re]=N(O({},Ke),{bech32Address:encoding.toBech32(W.find(Pt=>Pt.chainId===re).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(Ee[0].bech32Address).data)});}),p.setState(re=>({accounts:O(O({},re.accounts||{}),Le)})),Ie(Be)}).catch(J),G.addEventListener("abort",()=>{J(new Error("User closed wallet connect"));},{once:!0});})});try{let G=new AbortController,Ie=G.signal;$.subscribeModal(J=>{J.open||G.abort();}),yield ie(Ie);}catch(G){if($.closeModal(),!G.message.toLowerCase().includes("no matching key"))return Promise.reject(G)}return e||$.closeModal(),Promise.resolve()}try{yield be((()=>l(void 0,null,function*(){let K=yield d(S[0]),X={};S.forEach(ie=>{X[ie]=N(O({},K),{bech32Address:encoding.toBech32(W.find(G=>G.chainId===ie).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(K.bech32Address).data)});}),p.setState({accounts:X});}))(),15e3,new Error("Connection timeout"));}catch(K){if(o(Y.topic),!K.message.toLowerCase().includes("no matching key"))throw K}}),h=y=>l(void 0,null,function*(){var W;let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let v=(W=s([y]))==null?void 0:W.topic;if(!v)throw new Error("No wallet connect session");let k=yield I.request({topic:v,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 S=s([y]);if(!(S!=null&&S.topic))throw new Error("No wallet connect session");let I=S.sessionProperties&&JSON.parse(String(S.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),f=(...y)=>l(void 0,null,function*(){var K,X;let[S,I,v]=y,{accounts:k,wcSignClients:W}=p.getState(),U=W.get(t);if(!U)throw new Error("walletConnect.signClient is not defined");if(!k)throw new Error("account is not defined");let $=(K=s([S]))==null?void 0:K.topic;if(!$)throw new Error("No wallet connect session");if(!v.bodyBytes)throw new Error("No bodyBytes");if(!v.authInfoBytes)throw new Error("No authInfoBytes");let Y={topic:$,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:N(O({},v),{bodyBytes:Buffer.from(v.bodyBytes).toString(n),authInfoBytes:Buffer.from(v.authInfoBytes).toString(n),accountNumber:(X=v.accountNumber)==null?void 0:X.toString()})}}};return i(),yield U.request(Y)}),C=(...y)=>l(void 0,null,function*(){let[S,I,v]=y,{signature:k,signed:W}=yield f(S,I,v);return {signed:{chainId:W.chainId,accountNumber:Gt__default.default.fromString(W.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(W.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(W.bodyBytes,n))},signature:k}}),T=(...y)=>l(void 0,null,function*(){var K;let[S,I,v,k]=y,{wcSignClients:W}=p.getState(),U=W.get(t),{accounts:$}=p.getState();if(!U)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let Y=(K=s([S]))==null?void 0:K.topic;if(!Y)throw new Error("No wallet connect session");return i(),yield U.request({topic:Y,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:v}}})}),x=(...y)=>l(void 0,null,function*(){let[S,I,v,k]=y;return yield T(S,I,v)}),g=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signDirect:(S,I)=>C(y,S,I)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signAmino:(S,I)=>x(y,S,I)});return {enable:E,disable:y=>l(void 0,null,function*(){var v;let{wcSignClients:S}=p.getState(),I=S.get(t);if(y===void 0){let k=I==null?void 0:I.session.getAll();k!==void 0&&(yield Promise.all(k.map(W=>o(W.topic))));}else typeof y=="string"?yield o((v=s([y]))==null?void 0:v.topic):yield Promise.all(y.map(k=>{var W;return o((W=s([k]))==null?void 0:W.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 h(y)]}),signDirect:(S,I)=>C(y,S,I),signAmino:(S,I)=>x(y,S,I)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):g(y)}),getOfflineSignerOnlyAmino:w,signAmino:x,signDirect:C,subscription:A,init:m,setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}};var tt=()=>{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,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return j(e)};var nt=()=>{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,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return j(e)};var ot=()=>{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,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return j(e)};var me=()=>{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);}},setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var _=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},F=()=>{window.sessionStorage.removeItem(H),p.setState(Z);},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 pe();case"walletconnect":return j();case"wc_keplr_mobile":return nt();case"wc_leap_mobile":return ot();case"wc_cosmostation_mobile":return tt();case"metamask_snap_leap":return Ye();case"station":return de();case"xdefi":return me();case"capsule":return ae();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},ni=()=>Object.fromEntries(Qe.map(e=>[e,_(e)])),Oe=e=>e==="capsule",it=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var ee=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(!_(o))throw new Error(`${o} is not available`);let a=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 m=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(m!=null&&m.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),p.setState(d=>{let f=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(T=>{var x;return !((x=d.activeChainIds)!=null&&x.includes(T))}).length>0?{status:"connecting"}:f?{status:"reconnecting"}:{status:"connecting"}});let{accounts:A}=p.getState();if(yield (t=a.init)==null?void 0:t.call(a),Oe(o)&&p.getState().capsuleClient&&Object.values(p.getState().accounts||[]).length>0){let d=c.map(x=>i.find(g=>g.chainId===x)),f=p.getState().accounts;p.setState({status:"connecting"});let C=yield a.getKey(c[0]),T={};return c.forEach(x=>{T[x]=N(O({},C),{bech32Address:encoding.toBech32(i.find(g=>g.chainId===x).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(C.bech32Address).data)});}),p.setState(x=>({accounts:O(O({},x.accounts||{}),T)})),u.setState(x=>({recentChainIds:[...x.recentChainIds||[],...c].filter((g,w,b)=>b.indexOf(g)===w)})),p.setState(x=>({activeChainIds:[...x.activeChainIds||[],...c].filter((g,w,b)=>b.indexOf(g)===w)})),p.setState({status:"connected"}),{accounts:f,walletType:o,chains:d}}if(yield a.enable(c),Oe(o)){let d=c.map(C=>i.find(T=>T.chainId===C)),f=p.getState().accounts;return p.setState({status:"connecting"}),{accounts:f,walletType:o,chains:d}}if(!it(o)){let d=yield a.getKey(c[0]),f={};c.forEach(C=>{f[C]=N(O({},d),{bech32Address:encoding.toBech32(i.find(T=>T.chainId===C).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(d.bech32Address).data)});}),p.setState(C=>({accounts:O(O({},C.accounts||{}),f)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((f,C,T)=>T.indexOf(f)===C)})),p.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((f,C,T)=>T.indexOf(f)===C)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active");let E=c.map(d=>i.find(f=>f.chainId===d));return {accounts:p.getState().accounts,walletType:o,chains:E}}catch(n){throw console.error("connect ",n),p.getState().accounts===null&&p.setState({status:"disconnected"}),p.getState().accounts&&p.getState().activeChainIds&&p.setState({status:"connected"}),n}}),te=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=p.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(p.setState(Z),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(p.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else p.setState(Z),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},z=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=_(n||void 0);if(t&&o&&n)return yield ee({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),te();}}),at=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))throw new Error(`${n} is not available`);let r=R(n),o=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var xe=()=>{u.setState({recentChainIds:null});},gi=()=>u.getState().recentChainIds,Ci=()=>{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},yi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},Si=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Me=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){let i=R(t);return t==="capsule"?yield ee({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),ct=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield Me({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield ee({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var lt=e=>(u.setState(t=>({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 ut=s=>l(void 0,[s],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)}),dt=A=>l(void 0,[A],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:m}){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,s,a,c,m)}),pt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,i,r)}),mt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,s,o)}),ft=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),gt=(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 Mi=e=>e,vi=e=>e;var fe=e=>e?Object.keys(e).length===0:!0;var ve=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Ct=e=>globalThis.DOMException===void 0?new ve(e):new DOMException(e),yt=e=>{let t=e.reason===void 0?Ct("This operation was aborted."):e.reason;return t instanceof Error?t:Ct(t)};function We(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((a,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 m=[],A=[],E=new Map,h=!1,d=!1,f=!1,C=0,T=0,x=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),g=b=>{h=!0,d=!0,c(b);};r&&(r.aborted&&g(yt(r)),r.addEventListener("abort",()=>{g(yt(r));}));let w=()=>l(this,null,function*(){if(d)return;let b=yield x.next(),P=T;if(T++,b.done){if(f=!0,C===0&&!d){if(!i&&A.length>0){g(new AggregateError(A));return}if(d=!0,E.size===0){a(m);return}let D=[];for(let[B,ne]of m.entries())E.get(B)!==St&&D.push(ne);a(D);}return}C++,l(this,null,function*(){try{let D=yield b.value;if(d)return;let B=yield t(D,P);B===St&&E.set(P,B),m[P]=B,C--,yield w();}catch(D){if(i)g(D);else {A.push(D),C--;try{yield w();}catch(B){g(B);}}}});});l(this,null,function*(){for(let b=0;b<n;b++){try{yield w();}catch(P){g(P);break}if(f||h)break}});})})}var St=Symbol("skip");var L=({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]]}},q=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield We(t,n,{concurrency:i});return Object.fromEntries(o.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),ht=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var Pe=e=>{let t=L({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 q(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.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=L({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 q(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.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})},ge=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=L({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:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield q(!!n,a,A=>l(void 0,null,function*(){var C;let E=(C=u.getState().chainsConfig)==null?void 0:C[A.chainId],h={url:A.rpc,headers:O({},(E==null?void 0:E.rpcHeaders)||{})};return yield (s==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(h)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var nr=()=>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"}),shallow.shallow),Ce=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>_(r))};var V=e=>{let t=u(a=>a.walletType),n=p(a=>a.activeChainIds),i=L({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=p(a=>a.accounts),o=p(a=>a.status);return react.useEffect(()=>p.subscribe(a=>a.status,(a,c)=>{var m,A,E;if(a==="connected"){let{accounts:h,activeChainIds:d}=p.getState(),{chains:f}=u.getState(),{walletType:C}=u.getState();if(!h||!d||!f)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(A=e==null?void 0:e.onConnect)==null||A.call(e,{accounts:h,chains:d.map(T=>f.find(x=>x.chainId===T)),walletType:C,isReconnect:c==="reconnecting"});}a==="disconnected"&&((E=e==null?void 0:e.onDisconnect)==null||E.call(e));}),[e]),{data:react.useMemo(()=>r?ht(!!(e!=null&&e.multiChain),i,a=>r[a.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:z,status:o}},tn=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=V(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Pe({chainId:t.map(s=>s.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,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){let h=s==null?void 0:s[E.chainId];if(!h)throw new Error(`Client is not ready ${E.chainId}`);return yield h.getAllBalances(encoding.toBech32(E.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!fe(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},gr=e=>{let t=L({chainId:e.chainId}),{data:n}=V({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=tn({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,i,e.chainId],a=reactQuery.useQuery(s,({queryKey:[,c,m]})=>m==null?void 0:m.find(A=>A.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return N(O({},a),{refetch:c=>l(void 0,null,function*(){return yield o(),a.refetch(c)})})},Cr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],ee,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Ce();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},yr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],te,{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}},Sr=e=>{let t=L({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:s=>l(void 0,[s],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!_(o))throw new Error(`${o} is not available`);return yield q(!!(e!=null&&e.multiChain),r,m=>l(void 0,null,function*(){return yield at({chainId:m.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},hr=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=V(),{data:i}=Pe({chainId:t.map(s=>s.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,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){var d;if(!s)throw new Error("Client is not ready");return yield (d=s[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 Or=()=>{let e=u(i=>i.capsuleState),t=p(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:()=>{te();}}};var Pr=()=>p(e=>e.activeChainIds),nn=()=>{var e;return (e=p(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)},Dr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Nr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Br=({denom:e})=>{let t=nn();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:o.currencies.find(s=>s)})},_r=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,a=>l(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Kr=()=>({data:u(t=>t.recentChainIds),clear:xe}),Lr=()=>{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}},Ur=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],Me,{onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.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}},qr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],ct,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Ce();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Vr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=V(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>ut(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Yr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=V(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>dt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Xr=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=V(),o=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var A;if(!o)throw new Error("senderAddress is undefined");let m=N(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,codeId:e});return pt(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Jr=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=V(),o=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var A,E,h;if(!o)throw new Error("senderAddress is undefined");let m=N(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,contractAddress:e,memo:(E=c.memo)!=null?E:"",funds:(h=c.funds)!=null?h:[]});return mt(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Zr=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 ft(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},es=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 gt(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function ms(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var C,T;if(!(i!=null&&i.includes(m.chainId)))return;if(!_(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),h=(C=u.getState().chainsConfig)==null?void 0:C[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(d,E,e!=null&&e.multiChain?(T=e.opts)==null?void 0:T[m.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 fs(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var T,x;if(!(i!=null&&i.includes(m.chainId)))return;if(!_(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),h=(T=u.getState().chainsConfig)==null?void 0:T[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})},f=h!=null&&h.gas?stargate.GasPrice.fromString(`${h.gas.price}${h.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(d,E,O({gasPrice:f},e!=null&&e.multiChain?(x=e.opts)==null?void 0:x[m.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 gs(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=p(s=>s.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=ge({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,s,A=>l(this,null,function*(){var C;if(!(i!=null&&i.includes(A.chainId)))return;if(!_(a))throw new Error(`${a} is not available`);if(!o)throw new Error("No tendermint client found");let h=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(A.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(A.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(A.chainId);default:return R(a).getOfflineSignerAuto(A.chainId)}}))(),d=e.multiChain?o[A.chainId]:o;return yield stargate.SigningStargateClient.createWithSigner(d,h,e.multiChain?(C=e.opts)==null?void 0:C[A.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Cs(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=p(a=>a.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=ge({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=ge({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:m=>l(this,[m],function*({queryKey:[,a,c]}){if(a.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,a,E=>l(this,null,function*(){var g,w;if(!(i!=null&&i.includes(E.chainId)))return;if(!_(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)}}))(),f=(g=u.getState().chainsConfig)==null?void 0:g[E.chainId],C=f!=null&&f.gas?stargate.GasPrice.fromString(`${f.gas.price}${f.gas.denom}`):void 0,T=e.multiChain?s==null?void 0:s[E.chainId]:o;if(!T)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(T,d,O({gasPrice:C},e.multiChain?(w=e.opts)==null?void 0:w[E.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!fe(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var vt=({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}=u(),{activeChainIds:r,wcSignClients:o}=p(),s=_(i||void 0);return react.useEffect(()=>{if(i){if(!s)return;e&&r?z({onError:n}):!e&&t&&z({onError:n});}},[s]),react.useEffect(()=>{var a,c,m,A,E,h,d,f,C,T,x,g,w,b;if(i){if(!s)return;i==="cosmostation"&&((c=(a=ce()).subscription)==null||c.call(a,()=>{z({onError:n});})),i==="keplr"&&((A=(m=le()).subscription)==null||A.call(m,()=>{z({onError:n});})),i==="leap"&&((h=(E=ue()).subscription)==null||h.call(E,()=>{z({onError:n});})),i==="vectis"&&((f=(d=pe()).subscription)==null||f.call(d,()=>{z({onError:n});})),i==="walletconnect"&&o.has("walletconnect")&&((T=(C=j()).subscription)==null||T.call(C,()=>{z({onError:n});})),i==="station"&&((g=(x=de()).subscription)==null||g.call(x,()=>{z({onError:n});})),i==="xdefi"&&((b=(w=me()).subscription)==null||b.call(w,()=>{z({onError:n});}));}},[i,o,s]),null},kt=()=>(cn(),null);var dn=new reactQuery.QueryClient({}),Gs=i=>{var r=i,{children:e,grazOptions:t}=r,n=Fe(r,["children","grazOptions"]);return lt(t),jsxRuntime.jsx(reactQuery.QueryClientProvider,N(O({client:dn},n),{children:jsxRuntime.jsxs(vt,{children:[e,jsxRuntime.jsx(kt,{})]})}),"graz-provider")};
|
|
21
|
+
var Nt=Object.defineProperty,Bt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(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))Fe.call(t,n)&&qe(e,n,t[n]);return e},N=(e,t)=>Bt(e,Kt(t));var ze=(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&&Fe.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{a(n.next(c));}catch(m){r(m);}},s=c=>{try{a(n.throw(c));}catch(m){r(m);}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,s);a((n=n.apply(e,t)).next());});var H="graz-reconnect-session";var Qe=(h=>(h.KEPLR="keplr",h.LEAP="leap",h.VECTIS="vectis",h.COSMOSTATION="cosmostation",h.WALLETCONNECT="walletconnect",h.WC_KEPLR_MOBILE="wc_keplr_mobile",h.WC_LEAP_MOBILE="wc_leap_mobile",h.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",h.METAMASK_SNAP_LEAP="metamask_snap_leap",h.STATION="station",h.XDEFI="xdefi",h.CAPSULE="capsule",h))(Qe||{}),je=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","metamask_snap_leap","station","xdefi","capsule"];var Lt={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},Z={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Ut={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},p=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Z,Ut))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Lt,qt)));var ae=()=>{var E,h;if(!((E=u.getState().capsuleConfig)!=null&&E.apiKey)||!((h=u.getState().capsuleConfig)!=null&&h.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var C,T;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,g=new d({apiKey:(C=u.getState().capsuleConfig)==null?void 0:C.apiKey,env:(T=u.getState().capsuleConfig)==null?void 0:T.env});return p.setState({capsuleClient:g}),g});return {init:e,enable:d=>l(void 0,null,function*(){let g=typeof d=="string"?[d]:d,C=p.getState().capsuleClient;C||(C=yield e()),u.setState({capsuleState:{showModal:!0,chainId:g}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var f;let d=p.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 C=(f=u.getState().capsuleState)==null?void 0:f.chainId;if(!C)throw new Error("Chain ids are not set");let T=yield d.getAccount(C[0]),x={};C.forEach(w=>{x[w]={address:encoding.fromBech32(T.address).data,bech32Address:encoding.toBech32(g.find(b=>b.chainId===w).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(T.address).data),algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1};}),p.setState(w=>({accounts:O(O({},w.accounts||{}),x)})),u.setState(w=>({recentChainIds:[...w.recentChainIds||[],...C].filter((b,P,D)=>D.indexOf(b)===P)})),p.setState(w=>({activeChainIds:[...w.activeChainIds||[],...C].filter((b,P,D)=>D.indexOf(b)===P)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");let C=yield g.getAccount(d);return {address:encoding.fromBech32(C.address).data,bech32Address:C.address,algo:C.algo,name:C.username||"",pubKey:C.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let g=p.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,C,T]=d,x=p.getState().capsuleClient;if(!x)throw new Error("Capsule client is not initialized");return x.signDirect(g,C,{bodyBytes:T.bodyBytes,authInfoBytes:T.authInfoBytes,chainId:T.chainId,accountNumber:T.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[g,C,T,x]=d,f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.signAmino(g,C,T,x)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by capsule");},getOfflineSigner:d=>{let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerAmino(d)}}};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 a;let s=()=>{F(),o();};return (a=window.cosmostation)==null||a.cosmos.on("accountChanged",s),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",s);}},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=()=>{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 ue=()=>{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={},Ye=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(b=>b.id===e.id&&(!f||b.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 B;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 b=(B=f.split("MetaMask/v")[1])==null?void 0:B.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),s=f=>l(void 0,null,function*(){(yield i())||(yield r());}),a=(f,w,b)=>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:b}}}}),D=b.accountNumber,B=new Ft__default.default(D.low,D.high,D.unsigned);return {signature:P.signature,signed:N(O({},P.signed),{accountNumber:`${B.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),c=(f,w,b)=>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:b}}}})}),m=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]}),A=f=>l(void 0,null,function*(){let w=yield m(f);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),E=(...f)=>l(void 0,null,function*(){let[w,b,P,D]=f;return yield c(w,b,P)}),h=(...f)=>l(void 0,null,function*(){let[w,b,P]=f;return yield a(w,b,P)}),d=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signDirect:(w,b)=>h(f,w,b)}),g=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signAmino:(w,b)=>E(f,w,b)});return {enable:s,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:m,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signDirect:(w,b)=>h(f,w,b),signAmino:(w,b)=>E(f,w,b)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return (yield m(f)).isNanoLedger?g(f):d(f)}),getOfflineSignerOnlyAmino:g,init:o,signAmino:E,signDirect:h}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Xe=()=>Ye({id:"npm:@leapwallet/metamask-cosmos-snap"});var pe=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let s=()=>{F(),o();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:o=>l(void 0,null,function*(){let s=yield e.getKey(o);return O({isKeystone:!1},s)}),getOfflineSigner:o=>{try{let s=e.getOfflineSignerOnlyAmino(o);return Object.assign(s,{signDirect:(m,A)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let s=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(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(a=>{var c,m,A;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((c=a.gasPriceStep)==null?void 0:c.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((A=a.gasPriceStep)==null?void 0:A.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),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,s,a,c)=>e.signAmino(o,s,a),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var me=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>l(void 0,null,function*(){let c=yield e.getKey(a);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:a=>{let c=()=>{F(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>l(void 0,null,function*(){let[c]=a,m=N(O({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>l(void 0,null,function*(){var A;let{1:c,2:m}=a;return e.signDirect(c,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:Ft__default.default.fromString(((A=m.accountNumber)==null?void 0:A.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>l(void 0,null,function*(){let{1:c,2:m}=a;return e.signAmino(c,m)}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}}}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,Je=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),Ze=()=>Q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Oe=(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 B,ne,Be;if(!((Be=(ne=(B=u.getState().walletConnect)==null?void 0:B.options)==null?void 0:ne.projectId)!=null&&Be.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:S,formatNativeUrl:I}=e;if(Q()){if(Je())if(!y)window.open(S.mobile.android,"_self","noreferrer noopener");else {let v=I(S.mobile.android,y,"android");window.open(v,"_self","noreferrer noopener");}if(Ze())if(!y)window.open(S.mobile.ios,"_self","noreferrer noopener");else {let v=I(S.mobile.ios,y,"ios");window.open(v,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=p.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),p.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:S}=p.getState(),I=S.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);}),s=y=>{try{let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let v=I.session.getAll().at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw o(v.topic),new Error("invalid session");try{let W=I.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:y.map(U=>`cosmos:${U}`),events:["chainChanged","accountsChanged"]}}});if(!W.length)throw new Error("no session");return W.at(-1)}catch(W){if(!W.message.toLowerCase().includes("no matching key"))throw W}return v}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}},a=y=>{try{return s(y)}catch(S){return}},c=y=>l(void 0,null,function*(){try{let S=y.core.pairing.pairings.getAll({active:!1});if(!S.length)return;yield Promise.all(S.map(I=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}}),m=()=>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:S}=p.getState(),I=S.get(t);if(I)return I;let v=yield signClient.SignClient.init(y.options);return S.set(t,v),p.setState({wcSignClients:S}),v}),A=y=>{let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)return ()=>{};let v=k=>{let W=p.getState().accounts;if(k.params.event.name==="accountsChanged"&&W&&!Object.values(W).map(U=>U.bech32Address).includes(k.params.event.data[0])){let U=k.params.chainId.split(":")[1];U&&E([U]);}else y();};return I.events.on("session_delete",r),I.events.on("session_expire",r),I.events.on("session_event",v),()=>{I.events.off("session_delete",r),I.events.off("session_expire",r),I.events.off("session_event",v);}},E=y=>l(void 0,null,function*(){var oe;let S=typeof y=="string"?[y]:y,{wcSignClients:I}=p.getState(),v=I.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:k,chains:W}=u.getState();if(!((oe=k==null?void 0:k.options)!=null&&oe.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:U}=yield import('@web3modal/standalone'),$=new U(O({projectId:k.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},k.web3Modal)),Y=a(S);if(!Y){let{uri:_,approval:X}=yield Oe(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:S.map(G=>`cosmos:${G}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!_)throw new Error("No wallet connect uri");e?i(_):yield $.openModal({uri:_});let ie=G=>l(void 0,null,function*(){return G.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Ee,J)=>{X().then(Ke=>{let _e=Ke.sessionProperties;if(!_e)return J(new Error("No session properties"));let Te=JSON.parse(String(_e.keys));if(Te.length===0)return J(new Error("No accounts"));let Le=Te[0];if(!Le)return J(new Error("No accounts"));let Ue={};return S.forEach(re=>{Ue[re]=N(O({},Le),{bech32Address:encoding.toBech32(W.find(Dt=>Dt.chainId===re).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(Te[0].bech32Address).data)});}),p.setState(re=>({accounts:O(O({},re.accounts||{}),Ue)})),Ee(Ke)}).catch(J),G.addEventListener("abort",()=>{J(new Error("User closed wallet connect"));},{once:!0});})});try{let G=new AbortController,Ee=G.signal;$.subscribeModal(J=>{J.open||G.abort();}),yield ie(Ee);}catch(G){if($.closeModal(),!G.message.toLowerCase().includes("no matching key"))return Promise.reject(G)}return e||$.closeModal(),Promise.resolve()}try{yield Oe((()=>l(void 0,null,function*(){let _=yield d(S[0]),X={};S.forEach(ie=>{X[ie]=N(O({},_),{bech32Address:encoding.toBech32(W.find(G=>G.chainId===ie).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(_.bech32Address).data)});}),p.setState({accounts:X});}))(),15e3,new Error("Connection timeout"));}catch(_){if(o(Y.topic),!_.message.toLowerCase().includes("no matching key"))throw _}}),h=y=>l(void 0,null,function*(){var W;let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let v=(W=s([y]))==null?void 0:W.topic;if(!v)throw new Error("No wallet connect session");let k=yield I.request({topic:v,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 S=s([y]);if(!(S!=null&&S.topic))throw new Error("No wallet connect session");let I=S.sessionProperties&&JSON.parse(String(S.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),g=(...y)=>l(void 0,null,function*(){var _,X;let[S,I,v]=y,{accounts:k,wcSignClients:W}=p.getState(),U=W.get(t);if(!U)throw new Error("walletConnect.signClient is not defined");if(!k)throw new Error("account is not defined");let $=(_=s([S]))==null?void 0:_.topic;if(!$)throw new Error("No wallet connect session");if(!v.bodyBytes)throw new Error("No bodyBytes");if(!v.authInfoBytes)throw new Error("No authInfoBytes");let Y={topic:$,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:N(O({},v),{bodyBytes:Buffer.from(v.bodyBytes).toString(n),authInfoBytes:Buffer.from(v.authInfoBytes).toString(n),accountNumber:(X=v.accountNumber)==null?void 0:X.toString()})}}};return i(),yield U.request(Y)}),C=(...y)=>l(void 0,null,function*(){let[S,I,v]=y,{signature:k,signed:W}=yield g(S,I,v);return {signed:{chainId:W.chainId,accountNumber:Ft__default.default.fromString(W.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(W.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(W.bodyBytes,n))},signature:k}}),T=(...y)=>l(void 0,null,function*(){var _;let[S,I,v,k]=y,{wcSignClients:W}=p.getState(),U=W.get(t),{accounts:$}=p.getState();if(!U)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let Y=(_=s([S]))==null?void 0:_.topic;if(!Y)throw new Error("No wallet connect session");return i(),yield U.request({topic:Y,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:v}}})}),x=(...y)=>l(void 0,null,function*(){let[S,I,v,k]=y;return yield T(S,I,v)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signDirect:(S,I)=>C(y,S,I)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signAmino:(S,I)=>x(y,S,I)});return {enable:E,disable:y=>l(void 0,null,function*(){var v;let{wcSignClients:S}=p.getState(),I=S.get(t);if(y===void 0){let k=I==null?void 0:I.session.getAll();k!==void 0&&(yield Promise.all(k.map(W=>o(W.topic))));}else typeof y=="string"?yield o((v=s([y]))==null?void 0:v.topic):yield Promise.all(y.map(k=>{var W;return o((W=s([k]))==null?void 0:W.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 h(y)]}),signDirect:(S,I)=>C(y,S,I),signAmino:(S,I)=>x(y,S,I)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):f(y)}),getOfflineSignerOnlyAmino:w,signAmino:x,signDirect:C,subscription:A,init:m,setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}};var nt=()=>{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,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return j(e)};var ot=()=>{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,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return j(e)};var it=()=>{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,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return j(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=()=>{F(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var K=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},F=()=>{window.sessionStorage.removeItem(H),p.setState(Z);},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 me();case"walletconnect":return j();case"wc_keplr_mobile":return ot();case"wc_leap_mobile":return it();case"wc_cosmostation_mobile":return nt();case"metamask_snap_leap":return Xe();case"station":return pe();case"xdefi":return fe();case"capsule":return ae();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},oi=()=>Object.fromEntries(je.map(e=>[e,K(e)])),xe=e=>e==="capsule",rt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var ee=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 a=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 m=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(m!=null&&m.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),p.setState(d=>{let g=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(T=>{var x;return !((x=d.activeChainIds)!=null&&x.includes(T))}).length>0?{status:"connecting"}:g?{status:"reconnecting"}:{status:"connecting"}});let{accounts:A}=p.getState();if(yield (t=a.init)==null?void 0:t.call(a),xe(o)&&p.getState().capsuleClient&&Object.values(p.getState().accounts||[]).length>0){let d=c.map(x=>i.find(f=>f.chainId===x)),g=p.getState().accounts;p.setState({status:"connecting"});let C=yield a.getKey(c[0]),T={};return c.forEach(x=>{T[x]=N(O({},C),{bech32Address:encoding.toBech32(i.find(f=>f.chainId===x).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(C.bech32Address).data)});}),p.setState(x=>({accounts:O(O({},x.accounts||{}),T)})),u.setState(x=>({recentChainIds:[...x.recentChainIds||[],...c].filter((f,w,b)=>b.indexOf(f)===w)})),p.setState(x=>({activeChainIds:[...x.activeChainIds||[],...c].filter((f,w,b)=>b.indexOf(f)===w)})),p.setState({status:"connected"}),{accounts:g,walletType:o,chains:d}}if(yield a.enable(c),xe(o)){let d=c.map(C=>i.find(T=>T.chainId===C)),g=p.getState().accounts;return p.setState({status:"connecting"}),{accounts:g,walletType:o,chains:d}}if(!rt(o)){let d=yield a.getKey(c[0]),g={};c.forEach(C=>{g[C]=N(O({},d),{bech32Address:encoding.toBech32(i.find(T=>T.chainId===C).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(d.bech32Address).data)});}),p.setState(C=>({accounts:O(O({},C.accounts||{}),g)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((g,C,T)=>T.indexOf(g)===C)})),p.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((g,C,T)=>T.indexOf(g)===C)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active");let E=c.map(d=>i.find(g=>g.chainId===d));return {accounts:p.getState().accounts,walletType:o,chains:E}}catch(n){throw console.error("connect ",n),p.getState().accounts===null&&p.setState({status:"disconnected"}),p.getState().accounts&&p.getState().activeChainIds&&p.setState({status:"connected"}),n}}),te=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=p.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(p.setState(Z),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(p.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else p.setState(Z),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},z=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 ee({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),te();}}),ct=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=R(n),o=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var Me=()=>{u.setState({recentChainIds:null});},Ci=()=>u.getState().recentChainIds,yi=()=>{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},Si=({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 ee({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),lt=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 ee({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ut=e=>(u.setState(t=>({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=s=>l(void 0,[s],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)}),pt=A=>l(void 0,[A],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:m}){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,s,a,c,m)}),mt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,i,r)}),ft=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,s,o)}),gt=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),Ct=(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 vi=e=>e,Wi=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;}},yt=e=>globalThis.DOMException===void 0?new We(e):new DOMException(e),St=e=>{let t=e.reason===void 0?yt("This operation was aborted."):e.reason;return t instanceof Error?t:yt(t)};function ke(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((a,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 m=[],A=[],E=new Map,h=!1,d=!1,g=!1,C=0,T=0,x=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=b=>{h=!0,d=!0,c(b);};r&&(r.aborted&&f(St(r)),r.addEventListener("abort",()=>{f(St(r));}));let w=()=>l(this,null,function*(){if(d)return;let b=yield x.next(),P=T;if(T++,b.done){if(g=!0,C===0&&!d){if(!i&&A.length>0){f(new AggregateError(A));return}if(d=!0,E.size===0){a(m);return}let D=[];for(let[B,ne]of m.entries())E.get(B)!==ht&&D.push(ne);a(D);}return}C++,l(this,null,function*(){try{let D=yield b.value;if(d)return;let B=yield t(D,P);B===ht&&E.set(P,B),m[P]=B,C--,yield w();}catch(D){if(i)f(D);else {A.push(D),C--;try{yield w();}catch(B){f(B);}}}});});l(this,null,function*(){for(let b=0;b<n;b++){try{yield w();}catch(P){f(P);break}if(g||h)break}});})})}var ht=Symbol("skip");var L=({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]]}},q=(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((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),wt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var De=e=>{let t=L({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 q(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.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=L({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 q(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.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=L({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:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield q(!!n,a,A=>l(void 0,null,function*(){var C;let E=(C=u.getState().chainsConfig)==null?void 0:C[A.chainId],h={url:A.rpc,headers:O({},(E==null?void 0:E.rpcHeaders)||{})};return yield (s==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(h)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var or=()=>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"}),shallow.shallow),ye=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>K(r))};var V=e=>{let t=u(a=>a.walletType),n=p(a=>a.activeChainIds),i=L({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=p(a=>a.accounts),o=p(a=>a.status);return react.useEffect(()=>p.subscribe(a=>a.status,(a,c)=>{var m,A,E;if(a==="connected"){let{accounts:h,activeChainIds:d}=p.getState(),{chains:g}=u.getState(),{walletType:C}=u.getState();if(!h||!d||!g)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(A=e==null?void 0:e.onConnect)==null||A.call(e,{accounts:h,chains:d.map(T=>g.find(x=>x.chainId===T)),walletType:C,isReconnect:c==="reconnecting"});}a==="disconnected"&&((E=e==null?void 0:e.onDisconnect)==null||E.call(e));}),[e]),{data:react.useMemo(()=>r?wt(!!(e!=null&&e.multiChain),i,a=>r[a.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:z,status:o}},nn=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=V(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=De({chainId:t.map(s=>s.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,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){let h=s==null?void 0:s[E.chainId];if(!h)throw new Error(`Client is not ready ${E.chainId}`);return yield h.getAllBalances(encoding.toBech32(E.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})},Cr=e=>{let t=L({chainId:e.chainId}),{data:n}=V({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=nn({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,i,e.chainId],a=reactQuery.useQuery(s,({queryKey:[,c,m]})=>m==null?void 0:m.find(A=>A.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return N(O({},a),{refetch:c=>l(void 0,null,function*(){return yield o(),a.refetch(c)})})},yr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],ee,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=ye();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},Sr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],te,{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=L({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:s=>l(void 0,[s],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 q(!!(e!=null&&e.multiChain),r,m=>l(void 0,null,function*(){return yield ct({chainId:m.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},wr=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=V(),{data:i}=De({chainId:t.map(s=>s.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,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){var d;if(!s)throw new Error("Client is not ready");return yield (d=s[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 xr=()=>{let e=u(i=>i.capsuleState),t=p(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:()=>{te();}}};var Dr=()=>p(e=>e.activeChainIds),on=()=>{var e;return (e=p(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)},Nr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Br=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Kr=({denom:e})=>{let t=on();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:o.currencies.find(s=>s)})},_r=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,a=>l(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Lr=()=>({data:u(t=>t.recentChainIds),clear:Me}),Ur=()=>{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}},qr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],ve,{onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.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}},Gr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],lt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{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 Yr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=V(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>dt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Xr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=V(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>pt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Jr=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=V(),o=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var A;if(!o)throw new Error("senderAddress is undefined");let m=N(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,codeId:e});return mt(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Zr=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=V(),o=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var A,E,h;if(!o)throw new Error("senderAddress is undefined");let m=N(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,contractAddress:e,memo:(E=c.memo)!=null?E:"",funds:(h=c.funds)!=null?h:[]});return ft(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},es=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 gt(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ts=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 Ct(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function fs(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var C,T;if(!(i!=null&&i.includes(m.chainId)))return;if(!K(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),h=(C=u.getState().chainsConfig)==null?void 0:C[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(d,E,e!=null&&e.multiChain?(T=e.opts)==null?void 0:T[m.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 gs(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var T,x;if(!(i!=null&&i.includes(m.chainId)))return;if(!K(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),h=(T=u.getState().chainsConfig)==null?void 0:T[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})},g=h!=null&&h.gas?stargate.GasPrice.fromString(`${h.gas.price}${h.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(d,E,O({gasPrice:g},e!=null&&e.multiChain?(x=e.opts)==null?void 0:x[m.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 Cs(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=p(s=>s.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:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,s,A=>l(this,null,function*(){var C;if(!(i!=null&&i.includes(A.chainId)))return;if(!K(a))throw new Error(`${a} is not available`);if(!o)throw new Error("No tendermint client found");let h=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(A.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(A.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(A.chainId);default:return R(a).getOfflineSignerAuto(A.chainId)}}))(),d=e.multiChain?o[A.chainId]:o;return yield stargate.SigningStargateClient.createWithSigner(d,h,e.multiChain?(C=e.opts)==null?void 0:C[A.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ys(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=p(a=>a.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:s}=Ce({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:m=>l(this,[m],function*({queryKey:[,a,c]}){if(a.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,a,E=>l(this,null,function*(){var f,w;if(!(i!=null&&i.includes(E.chainId)))return;if(!K(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],C=g!=null&&g.gas?stargate.GasPrice.fromString(`${g.gas.price}${g.gas.denom}`):void 0,T=e.multiChain?s==null?void 0:s[E.chainId]:o;if(!T)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(T,d,O({gasPrice:C},e.multiChain?(w=e.opts)==null?void 0:w[E.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!ge(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Wt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var ln=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(H)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i}=u(),{activeChainIds:r,wcSignClients:o}=p(),s=K(i||void 0);return react.useEffect(()=>{if(i){if(!s)return;e&&r?z({onError:n}):!e&&t&&z({onError:n});}},[s]),react.useEffect(()=>{var a,c,m,A,E,h,d,g,C,T,x,f,w,b;if(i){if(!s)return;i==="cosmostation"&&((c=(a=ce()).subscription)==null||c.call(a,()=>{z({onError:n});})),i==="keplr"&&((A=(m=le()).subscription)==null||A.call(m,()=>{z({onError:n});})),i==="leap"&&((h=(E=ue()).subscription)==null||h.call(E,()=>{z({onError:n});})),i==="vectis"&&((g=(d=me()).subscription)==null||g.call(d,()=>{z({onError:n});})),i==="walletconnect"&&o.has("walletconnect")&&((T=(C=j()).subscription)==null||T.call(C,()=>{z({onError:n});})),i==="station"&&((f=(x=pe()).subscription)==null||f.call(x,()=>{z({onError:n});})),i==="xdefi"&&((b=(w=fe()).subscription)==null||b.call(w,()=>{z({onError:n});}));}},[i,o,s]),null},Rt=()=>(ln(),null);var pn=new reactQuery.QueryClient({}),Fs=i=>{var r=i,{children:e,grazOptions:t}=r,n=ze(r,["children","grazOptions"]);return ut(t),jsxRuntime.jsx(reactQuery.QueryClientProvider,N(O({client:pn},n),{children:jsxRuntime.jsxs(Wt,{children:[e,jsxRuntime.jsx(Rt,{})]})}),"graz-provider")};
|
|
22
22
|
|
|
23
|
-
exports.GrazEvents =
|
|
24
|
-
exports.GrazProvider =
|
|
25
|
-
exports.WALLET_TYPES =
|
|
26
|
-
exports.WalletType =
|
|
27
|
-
exports.checkWallet =
|
|
28
|
-
exports.clearRecentChain =
|
|
23
|
+
exports.GrazEvents = Rt;
|
|
24
|
+
exports.GrazProvider = Fs;
|
|
25
|
+
exports.WALLET_TYPES = je;
|
|
26
|
+
exports.WalletType = Qe;
|
|
27
|
+
exports.checkWallet = K;
|
|
28
|
+
exports.clearRecentChain = Me;
|
|
29
29
|
exports.clearSession = F;
|
|
30
|
-
exports.configureGraz =
|
|
30
|
+
exports.configureGraz = ut;
|
|
31
31
|
exports.connect = ee;
|
|
32
|
-
exports.defineChainInfo =
|
|
33
|
-
exports.defineChains =
|
|
32
|
+
exports.defineChainInfo = Wi;
|
|
33
|
+
exports.defineChains = vi;
|
|
34
34
|
exports.disconnect = te;
|
|
35
|
-
exports.executeContract =
|
|
36
|
-
exports.getAvailableWallets =
|
|
37
|
-
exports.getChainInfo =
|
|
38
|
-
exports.getChainInfos =
|
|
35
|
+
exports.executeContract = ft;
|
|
36
|
+
exports.getAvailableWallets = oi;
|
|
37
|
+
exports.getChainInfo = Si;
|
|
38
|
+
exports.getChainInfos = hi;
|
|
39
39
|
exports.getCosmostation = ce;
|
|
40
40
|
exports.getKeplr = le;
|
|
41
41
|
exports.getLeap = ue;
|
|
42
|
-
exports.getMetamaskSnapLeap =
|
|
43
|
-
exports.getOfflineSigners =
|
|
44
|
-
exports.getQueryRaw =
|
|
45
|
-
exports.getQuerySmart =
|
|
46
|
-
exports.getRecentChainIds =
|
|
47
|
-
exports.getRecentChains =
|
|
48
|
-
exports.getVectis =
|
|
49
|
-
exports.getWCCosmostation =
|
|
50
|
-
exports.getWCKeplr =
|
|
51
|
-
exports.getWCLeap =
|
|
42
|
+
exports.getMetamaskSnapLeap = Xe;
|
|
43
|
+
exports.getOfflineSigners = ct;
|
|
44
|
+
exports.getQueryRaw = Ct;
|
|
45
|
+
exports.getQuerySmart = gt;
|
|
46
|
+
exports.getRecentChainIds = Ci;
|
|
47
|
+
exports.getRecentChains = yi;
|
|
48
|
+
exports.getVectis = me;
|
|
49
|
+
exports.getWCCosmostation = nt;
|
|
50
|
+
exports.getWCKeplr = ot;
|
|
51
|
+
exports.getWCLeap = it;
|
|
52
52
|
exports.getWallet = R;
|
|
53
53
|
exports.getWalletConnect = j;
|
|
54
|
-
exports.instantiateContract =
|
|
55
|
-
exports.isCapsule =
|
|
56
|
-
exports.isWalletConnect =
|
|
54
|
+
exports.instantiateContract = mt;
|
|
55
|
+
exports.isCapsule = xe;
|
|
56
|
+
exports.isWalletConnect = rt;
|
|
57
57
|
exports.reconnect = z;
|
|
58
|
-
exports.sendIbcTokens =
|
|
59
|
-
exports.sendTokens =
|
|
60
|
-
exports.suggestChain =
|
|
61
|
-
exports.suggestChainAndConnect =
|
|
58
|
+
exports.sendIbcTokens = pt;
|
|
59
|
+
exports.sendTokens = dt;
|
|
60
|
+
exports.suggestChain = ve;
|
|
61
|
+
exports.suggestChainAndConnect = lt;
|
|
62
62
|
exports.useAccount = V;
|
|
63
|
-
exports.useActiveChainCurrency =
|
|
64
|
-
exports.useActiveChainIds =
|
|
65
|
-
exports.useActiveChains =
|
|
66
|
-
exports.useActiveWalletType =
|
|
67
|
-
exports.useBalance =
|
|
68
|
-
exports.useBalanceStaked =
|
|
69
|
-
exports.useBalances =
|
|
70
|
-
exports.useCapsule =
|
|
71
|
-
exports.useChainInfo =
|
|
72
|
-
exports.useChainInfos =
|
|
73
|
-
exports.useCheckWallet =
|
|
74
|
-
exports.useConnect =
|
|
75
|
-
exports.useCosmWasmClient =
|
|
76
|
-
exports.useCosmWasmSigningClient =
|
|
77
|
-
exports.useCosmWasmTmSigningClient =
|
|
78
|
-
exports.useDisconnect =
|
|
79
|
-
exports.useExecuteContract =
|
|
80
|
-
exports.useGrazEvents =
|
|
81
|
-
exports.useInstantiateContract =
|
|
82
|
-
exports.useOfflineSigners =
|
|
63
|
+
exports.useActiveChainCurrency = Kr;
|
|
64
|
+
exports.useActiveChainIds = Dr;
|
|
65
|
+
exports.useActiveChains = on;
|
|
66
|
+
exports.useActiveWalletType = or;
|
|
67
|
+
exports.useBalance = Cr;
|
|
68
|
+
exports.useBalanceStaked = wr;
|
|
69
|
+
exports.useBalances = nn;
|
|
70
|
+
exports.useCapsule = xr;
|
|
71
|
+
exports.useChainInfo = Nr;
|
|
72
|
+
exports.useChainInfos = Br;
|
|
73
|
+
exports.useCheckWallet = ye;
|
|
74
|
+
exports.useConnect = yr;
|
|
75
|
+
exports.useCosmWasmClient = Ne;
|
|
76
|
+
exports.useCosmWasmSigningClient = gs;
|
|
77
|
+
exports.useCosmWasmTmSigningClient = ys;
|
|
78
|
+
exports.useDisconnect = Sr;
|
|
79
|
+
exports.useExecuteContract = Zr;
|
|
80
|
+
exports.useGrazEvents = ln;
|
|
81
|
+
exports.useInstantiateContract = Jr;
|
|
82
|
+
exports.useOfflineSigners = hr;
|
|
83
83
|
exports.useQueryClientValidators = _r;
|
|
84
|
-
exports.useQueryRaw =
|
|
85
|
-
exports.useQuerySmart =
|
|
86
|
-
exports.useRecentChainIds =
|
|
87
|
-
exports.useRecentChains =
|
|
88
|
-
exports.useSendIbcTokens =
|
|
89
|
-
exports.useSendTokens =
|
|
90
|
-
exports.useStargateClient =
|
|
91
|
-
exports.useStargateSigningClient =
|
|
92
|
-
exports.useStargateTmSigningClient =
|
|
93
|
-
exports.useSuggestChain =
|
|
94
|
-
exports.useSuggestChainAndConnect =
|
|
95
|
-
exports.useTendermintClient =
|
|
84
|
+
exports.useQueryRaw = ts;
|
|
85
|
+
exports.useQuerySmart = es;
|
|
86
|
+
exports.useRecentChainIds = Lr;
|
|
87
|
+
exports.useRecentChains = Ur;
|
|
88
|
+
exports.useSendIbcTokens = Xr;
|
|
89
|
+
exports.useSendTokens = Yr;
|
|
90
|
+
exports.useStargateClient = De;
|
|
91
|
+
exports.useStargateSigningClient = fs;
|
|
92
|
+
exports.useStargateTmSigningClient = Cs;
|
|
93
|
+
exports.useSuggestChain = qr;
|
|
94
|
+
exports.useSuggestChainAndConnect = Gr;
|
|
95
|
+
exports.useTendermintClient = Ce;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fromBech32, toBech32 } from '@cosmjs/encoding';
|
|
2
2
|
import { create } from 'zustand';
|
|
3
3
|
import { createJSONStorage, subscribeWithSelector, persist } from 'zustand/middleware';
|
|
4
|
-
import
|
|
4
|
+
import zt from 'long';
|
|
5
5
|
import { SignClient } from '@walletconnect/sign-client';
|
|
6
6
|
import { getSdkError } from '@walletconnect/utils';
|
|
7
7
|
import { QueryClient, useQuery, useMutation, QueryClientProvider } from '@tanstack/react-query';
|
|
@@ -12,6 +12,6 @@ import { Tendermint37Client, Tendermint34Client } from '@cosmjs/tendermint-rpc';
|
|
|
12
12
|
import { shallow } from 'zustand/shallow';
|
|
13
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
14
|
|
|
15
|
-
var Nt=Object.defineProperty,Bt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))Ge.call(t,n)&&qe(e,n,t[n]);if(ae)for(var n of ae(t))Fe.call(t,n)&&qe(e,n,t[n]);return e},B=(e,t)=>Bt(e,_t(t));var ze=(e,t)=>{var n={};for(var i in e)Ge.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&&Fe.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{a(n.next(c));}catch(m){r(m);}},s=c=>{try{a(n.throw(c));}catch(m){r(m);}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,s);a((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var Qe=(h=>(h.KEPLR="keplr",h.LEAP="leap",h.VECTIS="vectis",h.COSMOSTATION="cosmostation",h.WALLETCONNECT="walletconnect",h.WC_KEPLR_MOBILE="wc_keplr_mobile",h.WC_LEAP_MOBILE="wc_leap_mobile",h.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",h.METAMASK_SNAP_LEAP="metamask_snap_leap",h.STATION="station",h.XDEFI="xdefi",h.CAPSULE="capsule",h))(Qe||{}),je=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","metamask_snap_leap","station","xdefi","capsule"];var Lt={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},ee={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Ut={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},p=create(subscribeWithSelector(persist(()=>ee,Ut))),u=create(subscribeWithSelector(persist(()=>Lt,qt)));var ce=()=>{var E,h;if(!((E=u.getState().capsuleConfig)!=null&&E.apiKey)||!((h=u.getState().capsuleConfig)!=null&&h.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var C,T;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,f=new d({apiKey:(C=u.getState().capsuleConfig)==null?void 0:C.apiKey,env:(T=u.getState().capsuleConfig)==null?void 0:T.env});return p.setState({capsuleClient:f}),f});return {init:e,enable:d=>l(void 0,null,function*(){let f=typeof d=="string"?[d]:d,C=p.getState().capsuleClient;C||(C=yield e()),u.setState({capsuleState:{showModal:!0,chainId:f}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var g;let d=p.getState().capsuleClient,{chains:f}=u.getState();if(!d)throw new Error("Capsule client is not initialized");if(!f)throw new Error("Chains are not set");yield d.enable();let C=(g=u.getState().capsuleState)==null?void 0:g.chainId;if(!C)throw new Error("Chain ids are not set");let T=yield d.getAccount(C[0]),x={};C.forEach(w=>{x[w]={address:fromBech32(T.address).data,bech32Address:toBech32(f.find(b=>b.chainId===w).bech32Config.bech32PrefixAccAddr,fromBech32(T.address).data),algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1};}),p.setState(w=>({accounts:O(O({},w.accounts||{}),x)})),u.setState(w=>({recentChainIds:[...w.recentChainIds||[],...C].filter((b,D,N)=>N.indexOf(b)===D)})),p.setState(w=>({activeChainIds:[...w.activeChainIds||[],...C].filter((b,D,N)=>N.indexOf(b)===D)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");let C=yield f.getAccount(d);return {address:fromBech32(C.address).data,bech32Address:C.address,algo:C.algo,name:C.username||"",pubKey:C.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSignerDirect(d)},signDirect:(...d)=>l(void 0,null,function*(){let[f,C,T]=d,x=p.getState().capsuleClient;if(!x)throw new Error("Capsule client is not initialized");return x.signDirect(f,C,{bodyBytes:T.bodyBytes,authInfoBytes:T.authInfoBytes,chainId:T.chainId,accountNumber:T.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[f,C,T,x]=d,g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.signAmino(f,C,T,x)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by capsule");},getOfflineSigner:d=>{let f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSignerAmino(d)}}};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 a;let s=()=>{z(),o();};return (a=window.cosmostation)==null||a.cosmos.on("accountChanged",s),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",s);}},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 de=()=>{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 Ye=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(b=>b.id===e.id&&(!g||b.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 b=(_=g.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),s=g=>l(void 0,null,function*(){(yield i())||(yield r());}),a=(g,w,b)=>l(void 0,null,function*(){let D=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:g,signerAddress:w,signDoc:b}}}}),N=b.accountNumber,_=new Ft(N.low,N.high,N.unsigned);return {signature:D.signature,signed:B(O({},D.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(D.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(D.signed.bodyBytes))})}}),c=(g,w,b)=>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:b}}}})}),m=g=>l(void 0,null,function*(){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,O({},w)}),A=g=>l(void 0,null,function*(){let w=yield m(g);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),E=(...g)=>l(void 0,null,function*(){let[w,b,D,N]=g;return yield c(w,b,D)}),h=(...g)=>l(void 0,null,function*(){let[w,b,D]=g;return yield a(w,b,D)}),d=g=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(g)]}),signDirect:(w,b)=>h(g,w,b)}),f=g=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(g)]}),signAmino:(w,b)=>E(g,w,b)});return {enable:s,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:m,getOfflineSigner:g=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(g)]}),signDirect:(w,b)=>h(g,w,b),signAmino:(w,b)=>E(g,w,b)}),getOfflineSignerAuto:g=>l(void 0,null,function*(){return (yield m(g)).isNanoLedger?f(g):d(g)}),getOfflineSignerOnlyAmino:f,init:o,signAmino:E,signDirect:h}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Xe=()=>Ye({id:"npm:@leapwallet/metamask-cosmos-snap"});var pe=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let s=()=>{z(),o();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:o=>l(void 0,null,function*(){let s=yield e.getKey(o);return O({isKeystone:!1},s)}),getOfflineSigner:o=>{try{let s=e.getOfflineSignerOnlyAmino(o);return Object.assign(s,{signDirect:(m,A)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let s=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(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(a=>{var c,m,A;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((c=a.gasPriceStep)==null?void 0:c.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((A=a.gasPriceStep)==null?void 0:A.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),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,s,a,c)=>e.signAmino(o,s,a),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var me=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>l(void 0,null,function*(){let c=yield e.getKey(a);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:a=>{let c=()=>{z(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>l(void 0,null,function*(){let[c]=a,m=B(O({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>l(void 0,null,function*(){var A;let{1:c,2:m}=a;return e.signDirect(c,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:Ft.fromString(((A=m.accountNumber)==null?void 0:A.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>l(void 0,null,function*(){let{1:c,2:m}=a;return e.signAmino(c,m)}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var j=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,Je=()=>j()&&navigator.userAgent.toLowerCase().includes("android"),Ze=()=>j()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Oe=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var $=e=>{var _,oe,Be;if(!((Be=(oe=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:oe.projectId)!=null&&Be.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:S,formatNativeUrl:I}=e;if(j()){if(Je())if(!y)window.open(S.mobile.android,"_self","noreferrer noopener");else {let W=I(S.mobile.android,y,"android");window.open(W,"_self","noreferrer noopener");}if(Ze())if(!y)window.open(S.mobile.ios,"_self","noreferrer noopener");else {let W=I(S.mobile.ios,y,"ios");window.open(W,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=p.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),p.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:S}=p.getState(),I=S.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);}),s=y=>{try{let{wcSignClients:S}=p.getState(),I=S.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(q=>`cosmos:${q}`),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(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}},a=y=>{try{return s(y)}catch(S){return}},c=y=>l(void 0,null,function*(){try{let S=y.core.pairing.pairings.getAll({active:!1});if(!S.length)return;yield Promise.all(S.map(I=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}}),m=()=>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:S}=p.getState(),I=S.get(t);if(I)return I;let W=yield SignClient.init(y.options);return S.set(t,W),p.setState({wcSignClients:S}),W}),A=y=>{let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)return ()=>{};let W=R=>{let k=p.getState().accounts;if(R.params.event.name==="accountsChanged"&&k&&!Object.values(k).map(q=>q.bech32Address).includes(R.params.event.data[0])){let q=R.params.chainId.split(":")[1];q&&E([q]);}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 ie;let S=typeof y=="string"?[y]:y,{wcSignClients:I}=p.getState(),W=I.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:R,chains:k}=u.getState();if(!((ie=R==null?void 0:R.options)!=null&&ie.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:q}=yield import('@web3modal/standalone'),H=new q(O({projectId:R.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},R.web3Modal)),X=a(S);if(!X){let{uri:L,approval:J}=yield Oe(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:S.map(F=>`cosmos:${F}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?i(L):yield H.openModal({uri:L});let re=F=>l(void 0,null,function*(){return F.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Ee,Z)=>{J().then(_e=>{let Ke=_e.sessionProperties;if(!Ke)return Z(new Error("No session properties"));let Te=JSON.parse(String(Ke.keys));if(Te.length===0)return Z(new Error("No accounts"));let Le=Te[0];if(!Le)return Z(new Error("No accounts"));let Ue={};return S.forEach(se=>{Ue[se]=B(O({},Le),{bech32Address:toBech32(k.find(Dt=>Dt.chainId===se).bech32Config.bech32PrefixAccAddr,fromBech32(Te[0].bech32Address).data)});}),p.setState(se=>({accounts:O(O({},se.accounts||{}),Ue)})),Ee(_e)}).catch(Z),F.addEventListener("abort",()=>{Z(new Error("User closed wallet connect"));},{once:!0});})});try{let F=new AbortController,Ee=F.signal;H.subscribeModal(Z=>{Z.open||F.abort();}),yield re(Ee);}catch(F){if(H.closeModal(),!F.message.toLowerCase().includes("no matching key"))return Promise.reject(F)}return e||H.closeModal(),Promise.resolve()}try{yield Oe((()=>l(void 0,null,function*(){let L=yield d(S[0]),J={};S.forEach(re=>{J[re]=B(O({},L),{bech32Address:toBech32(k.find(F=>F.chainId===re).bech32Config.bech32PrefixAccAddr,fromBech32(L.bech32Address).data)});}),p.setState({accounts:J});}))(),15e3,new Error("Connection timeout"));}catch(L){if(o(X.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),h=y=>l(void 0,null,function*(){var k;let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let W=(k=s([y]))==null?void 0:k.topic;if(!W)throw new Error("No wallet connect session");let R=yield I.request({topic:W,chainId:`cosmos:${y}`,request:{method:"cosmos_getAccounts",params:{}}});if(!R[0])throw new Error("No wallet connect account");return {address:R[0].address,algo:R[0].algo,pubkey:new Uint8Array(Buffer.from(R[0].pubkey,n))}}),d=y=>l(void 0,null,function*(){let S=s([y]);if(!(S!=null&&S.topic))throw new Error("No wallet connect session");let I=S.sessionProperties&&JSON.parse(String(S.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),f=(...y)=>l(void 0,null,function*(){var L,J;let[S,I,W]=y,{accounts:R,wcSignClients:k}=p.getState(),q=k.get(t);if(!q)throw new Error("walletConnect.signClient is not defined");if(!R)throw new Error("account is not defined");let H=(L=s([S]))==null?void 0:L.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 X={topic:H,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:B(O({},W),{bodyBytes:Buffer.from(W.bodyBytes).toString(n),authInfoBytes:Buffer.from(W.authInfoBytes).toString(n),accountNumber:(J=W.accountNumber)==null?void 0:J.toString()})}}};return i(),yield q.request(X)}),C=(...y)=>l(void 0,null,function*(){let[S,I,W]=y,{signature:R,signed:k}=yield f(S,I,W);return {signed:{chainId:k.chainId,accountNumber:Ft.fromString(k.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(k.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(k.bodyBytes,n))},signature:R}}),T=(...y)=>l(void 0,null,function*(){var L;let[S,I,W,R]=y,{wcSignClients:k}=p.getState(),q=k.get(t),{accounts:H}=p.getState();if(!q)throw new Error("walletConnect.signClient is not defined");if(!H)throw new Error("account is not defined");let X=(L=s([S]))==null?void 0:L.topic;if(!X)throw new Error("No wallet connect session");return i(),yield q.request({topic:X,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:W}}})}),x=(...y)=>l(void 0,null,function*(){let[S,I,W,R]=y;return yield T(S,I,W)}),g=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signDirect:(S,I)=>C(y,S,I)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signAmino:(S,I)=>x(y,S,I)});return {enable:E,disable:y=>l(void 0,null,function*(){var W;let{wcSignClients:S}=p.getState(),I=S.get(t);if(y===void 0){let R=I==null?void 0:I.session.getAll();R!==void 0&&(yield Promise.all(R.map(k=>o(k.topic))));}else typeof y=="string"?yield o((W=s([y]))==null?void 0:W.topic):yield Promise.all(y.map(R=>{var k;return o((k=s([R]))==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 h(y)]}),signDirect:(S,I)=>C(y,S,I),signAmino:(S,I)=>x(y,S,I)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):g(y)}),getOfflineSignerOnlyAmino:w,signAmino:x,signDirect:C,subscription:A,init:m,setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}};var nt=()=>{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(!j())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,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return $(e)};var ot=()=>{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(!j())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,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return $(e)};var it=()=>{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(!j())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,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return $(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=()=>{z(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var K=(e=u.getState().walletType)=>{try{return P(e),!0}catch(t){return !1}},z=()=>{window.sessionStorage.removeItem(V),p.setState(ee);},P=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return ue();case"leap":return de();case"cosmostation":return le();case"vectis":return me();case"walletconnect":return $();case"wc_keplr_mobile":return ot();case"wc_leap_mobile":return it();case"wc_cosmostation_mobile":return nt();case"metamask_snap_leap":return Xe();case"station":return pe();case"xdefi":return fe();case"capsule":return ce();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},oi=()=>Object.fromEntries(je.map(e=>[e,K(e)])),xe=e=>e==="capsule",rt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var te=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 a=P(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 m=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(m!=null&&m.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),p.setState(d=>{let f=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(T=>{var x;return !((x=d.activeChainIds)!=null&&x.includes(T))}).length>0?{status:"connecting"}:f?{status:"reconnecting"}:{status:"connecting"}});let{accounts:A}=p.getState();if(yield (t=a.init)==null?void 0:t.call(a),xe(o)&&p.getState().capsuleClient&&Object.values(p.getState().accounts||[]).length>0){let d=c.map(x=>i.find(g=>g.chainId===x)),f=p.getState().accounts;p.setState({status:"connecting"});let C=yield a.getKey(c[0]),T={};return c.forEach(x=>{T[x]=B(O({},C),{bech32Address:toBech32(i.find(g=>g.chainId===x).bech32Config.bech32PrefixAccAddr,fromBech32(C.bech32Address).data)});}),p.setState(x=>({accounts:O(O({},x.accounts||{}),T)})),u.setState(x=>({recentChainIds:[...x.recentChainIds||[],...c].filter((g,w,b)=>b.indexOf(g)===w)})),p.setState(x=>({activeChainIds:[...x.activeChainIds||[],...c].filter((g,w,b)=>b.indexOf(g)===w)})),p.setState({status:"connected"}),{accounts:f,walletType:o,chains:d}}if(yield a.enable(c),xe(o)){let d=c.map(C=>i.find(T=>T.chainId===C)),f=p.getState().accounts;return p.setState({status:"connecting"}),{accounts:f,walletType:o,chains:d}}if(!rt(o)){let d=yield a.getKey(c[0]),f={};c.forEach(C=>{f[C]=B(O({},d),{bech32Address:toBech32(i.find(T=>T.chainId===C).bech32Config.bech32PrefixAccAddr,fromBech32(d.bech32Address).data)});}),p.setState(C=>({accounts:O(O({},C.accounts||{}),f)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((f,C,T)=>T.indexOf(f)===C)})),p.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((f,C,T)=>T.indexOf(f)===C)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let E=c.map(d=>i.find(f=>f.chainId===d));return {accounts:p.getState().accounts,walletType:o,chains:E}}catch(n){throw console.error("connect ",n),p.getState().accounts===null&&p.setState({status:"disconnected"}),p.getState().accounts&&p.getState().activeChainIds&&p.setState({status:"connected"}),n}}),ne=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=p.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(p.setState(ee),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(p.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else p.setState(ee),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=K(n||void 0);if(t&&o&&n)return yield te({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),ne();}}),ct=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=P(n),o=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var Me=()=>{u.setState({recentChainIds:null});},Ci=()=>u.getState().recentChainIds,yi=()=>{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},Si=({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=P(t);return t==="capsule"?yield te({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),lt=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 te({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ut=e=>(u.setState(t=>({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=s=>l(void 0,[s],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)}),pt=A=>l(void 0,[A],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:m}){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,s,a,c,m)}),mt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,i,r)}),ft=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,s,o)}),gt=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),Ct=(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 vi=e=>e,Wi=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;}},yt=e=>globalThis.DOMException===void 0?new We(e):new DOMException(e),St=e=>{let t=e.reason===void 0?yt("This operation was aborted."):e.reason;return t instanceof Error?t:yt(t)};function ke(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((a,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 m=[],A=[],E=new Map,h=!1,d=!1,f=!1,C=0,T=0,x=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),g=b=>{h=!0,d=!0,c(b);};r&&(r.aborted&&g(St(r)),r.addEventListener("abort",()=>{g(St(r));}));let w=()=>l(this,null,function*(){if(d)return;let b=yield x.next(),D=T;if(T++,b.done){if(f=!0,C===0&&!d){if(!i&&A.length>0){g(new AggregateError(A));return}if(d=!0,E.size===0){a(m);return}let N=[];for(let[_,oe]of m.entries())E.get(_)!==ht&&N.push(oe);a(N);}return}C++,l(this,null,function*(){try{let N=yield b.value;if(d)return;let _=yield t(N,D);_===ht&&E.set(D,_),m[D]=_,C--,yield w();}catch(N){if(i)g(N);else {A.push(N),C--;try{yield w();}catch(_){g(_);}}}});});l(this,null,function*(){for(let b=0;b<n;b++){try{yield w();}catch(D){g(D);break}if(f||h)break}});})})}var ht=Symbol("skip");var U=({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((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),wt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var De=e=>{let t=U({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,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.rpcHeaders)||{})};return yield 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=U({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,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.rpcHeaders)||{})};return yield 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=U({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:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield G(!!n,a,A=>l(void 0,null,function*(){var C;let E=(C=u.getState().chainsConfig)==null?void 0:C[A.chainId],h={url:A.rpc,headers:O({},(E==null?void 0:E.rpcHeaders)||{})};return yield (s==="tm37"?Tendermint37Client:Tendermint34Client).connect(h)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var or=()=>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"}),shallow),ye=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>K(r))};var Y=e=>{let t=u(a=>a.walletType),n=p(a=>a.activeChainIds),i=U({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=p(a=>a.accounts),o=p(a=>a.status);return useEffect(()=>p.subscribe(a=>a.status,(a,c)=>{var m,A,E;if(a==="connected"){let{accounts:h,activeChainIds:d}=p.getState(),{chains:f}=u.getState(),{walletType:C}=u.getState();if(!h||!d||!f)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(A=e==null?void 0:e.onConnect)==null||A.call(e,{accounts:h,chains:d.map(T=>f.find(x=>x.chainId===T)),walletType:C,isReconnect:c==="reconnecting"});}a==="disconnected"&&((E=e==null?void 0:e.onDisconnect)==null||E.call(e));}),[e]),{data:useMemo(()=>r?wt(!!(e!=null&&e.multiChain),i,a=>r[a.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}},nn=e=>{let t=U({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}=De({chainId:t.map(s=>s.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,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){let h=s==null?void 0:s[E.chainId];if(!h)throw new Error(`Client is not ready ${E.chainId}`);return yield h.getAllBalances(toBech32(E.bech32Config.bech32PrefixAccAddr,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})},Cr=e=>{let t=U({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=nn({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,i,e.chainId],a=useQuery(s,({queryKey:[,c,m]})=>m==null?void 0:m.find(A=>A.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return B(O({},a),{refetch:c=>l(void 0,null,function*(){return yield o(),a.refetch(c)})})},yr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],te,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=ye();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},Sr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=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}},hr=e=>{let t=U({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:s=>l(void 0,[s],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,m=>l(void 0,null,function*(){return yield ct({chainId:m.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},wr=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:i}=De({chainId:t.map(s=>s.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,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){var d;if(!s)throw new Error("Client is not ready");return yield (d=s[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 xr=()=>{let e=u(i=>i.capsuleState),t=p(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:()=>{ne();}}};var Dr=()=>p(e=>e.activeChainIds),on=()=>{var e;return (e=p(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)},Nr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Br=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},_r=({denom:e})=>{let t=on();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:o.currencies.find(s=>s)})},Kr=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,a=>l(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Lr=()=>({data:u(t=>t.recentChainIds),clear:Me}),Ur=()=>{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}},qr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],ve,{onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.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}},Gr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],lt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{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 Yr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>dt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Xr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>pt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Jr=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,a=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var A;if(!o)throw new Error("senderAddress is undefined");let m=B(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,codeId:e});return mt(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Zr=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,a=useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var A,E,h;if(!o)throw new Error("senderAddress is undefined");let m=B(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,contractAddress:e,memo:(E=c.memo)!=null?E:"",funds:(h=c.funds)!=null?h:[]});return ft(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},es=e=>{let{data:t}=Ne();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 gt(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ts=e=>{let{data:t}=Ne(),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 Ct(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function fs(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var C,T;if(!(i!=null&&i.includes(m.chainId)))return;if(!K(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return P(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return P(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return P(s).getOfflineSignerOnlyAmino(m.chainId);default:return P(s).getOfflineSignerAuto(m.chainId)}}))(),h=(C=u.getState().chainsConfig)==null?void 0:C[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(d,E,e!=null&&e.multiChain?(T=e.opts)==null?void 0:T[m.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 gs(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var T,x;if(!(i!=null&&i.includes(m.chainId)))return;if(!K(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return P(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return P(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return P(s).getOfflineSignerOnlyAmino(m.chainId);default:return P(s).getOfflineSignerAuto(m.chainId)}}))(),h=(T=u.getState().chainsConfig)==null?void 0:T[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})},f=h!=null&&h.gas?GasPrice.fromString(`${h.gas.price}${h.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(d,E,O({gasPrice:f},e!=null&&e.multiChain?(x=e.opts)==null?void 0:x[m.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 Cs(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=p(s=>s.activeChainIds),r=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 useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,A=>l(this,null,function*(){var C;if(!(i!=null&&i.includes(A.chainId)))return;if(!K(a))throw new Error(`${a} is not available`);if(!o)throw new Error("No tendermint client found");let h=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return P(a).getOfflineSigner(A.chainId);case"offlineSignerAuto":return P(a).getOfflineSignerAuto(A.chainId);case"offlineSignerOnlyAmino":return P(a).getOfflineSignerOnlyAmino(A.chainId);default:return P(a).getOfflineSignerAuto(A.chainId)}}))(),d=e.multiChain?o[A.chainId]:o;return yield SigningStargateClient.createWithSigner(d,h,e.multiChain?(C=e.opts)==null?void 0:C[A.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ys(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=p(a=>a.activeChainIds),r=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:s}=Ce({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:m=>l(this,[m],function*({queryKey:[,a,c]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,E=>l(this,null,function*(){var g,w;if(!(i!=null&&i.includes(E.chainId)))return;if(!K(c))throw new Error(`${c} is not available`);let d=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return P(c).getOfflineSigner(E.chainId);case"offlineSignerAuto":return P(c).getOfflineSignerAuto(E.chainId);case"offlineSignerOnlyAmino":return P(c).getOfflineSignerOnlyAmino(E.chainId);default:return P(c).getOfflineSignerAuto(E.chainId)}}))(),f=(g=u.getState().chainsConfig)==null?void 0:g[E.chainId],C=f!=null&&f.gas?GasPrice.fromString(`${f.gas.price}${f.gas.denom}`):void 0,T=e.multiChain?s==null?void 0:s[E.chainId]:o;if(!T)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(T,d,O({gasPrice:C},e.multiChain?(w=e.opts)==null?void 0:w[E.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!ge(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Wt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var ln=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i}=u(),{activeChainIds:r,wcSignClients:o}=p(),s=K(i||void 0);return useEffect(()=>{if(i){if(!s)return;e&&r?Q({onError:n}):!e&&t&&Q({onError:n});}},[s]),useEffect(()=>{var a,c,m,A,E,h,d,f,C,T,x,g,w,b;if(i){if(!s)return;i==="cosmostation"&&((c=(a=le()).subscription)==null||c.call(a,()=>{Q({onError:n});})),i==="keplr"&&((A=(m=ue()).subscription)==null||A.call(m,()=>{Q({onError:n});})),i==="leap"&&((h=(E=de()).subscription)==null||h.call(E,()=>{Q({onError:n});})),i==="vectis"&&((f=(d=me()).subscription)==null||f.call(d,()=>{Q({onError:n});})),i==="walletconnect"&&o.has("walletconnect")&&((T=(C=$()).subscription)==null||T.call(C,()=>{Q({onError:n});})),i==="station"&&((g=(x=pe()).subscription)==null||g.call(x,()=>{Q({onError:n});})),i==="xdefi"&&((b=(w=fe()).subscription)==null||b.call(w,()=>{Q({onError:n});}));}},[i,o,s]),null},Rt=()=>(ln(),null);var pn=new QueryClient({}),Fs=i=>{var r=i,{children:e,grazOptions:t}=r,n=ze(r,["children","grazOptions"]);return ut(t),jsx(QueryClientProvider,B(O({client:pn},n),{children:jsxs(Wt,{children:[e,jsx(Rt,{})]})}),"graz-provider")};
|
|
15
|
+
var Bt=Object.defineProperty,Kt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Fe=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var Ge=(e,t,n)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))Fe.call(t,n)&&Ge(e,n,t[n]);if(ae)for(var n of ae(t))ze.call(t,n)&&Ge(e,n,t[n]);return e},B=(e,t)=>Kt(e,_t(t));var Qe=(e,t)=>{var n={};for(var i in e)Fe.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&&ze.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{a(n.next(c));}catch(m){r(m);}},s=c=>{try{a(n.throw(c));}catch(m){r(m);}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,s);a((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var je=(h=>(h.KEPLR="keplr",h.LEAP="leap",h.VECTIS="vectis",h.COSMOSTATION="cosmostation",h.WALLETCONNECT="walletconnect",h.WC_KEPLR_MOBILE="wc_keplr_mobile",h.WC_LEAP_MOBILE="wc_leap_mobile",h.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",h.METAMASK_SNAP_LEAP="metamask_snap_leap",h.STATION="station",h.XDEFI="xdefi",h.CAPSULE="capsule",h))(je||{}),$e=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","metamask_snap_leap","station","xdefi","capsule"];var Ut={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},ee={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},qt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Gt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},p=create(subscribeWithSelector(persist(()=>ee,qt))),u=create(subscribeWithSelector(persist(()=>Ut,Gt)));var ce=()=>{var E,h;if(!((E=u.getState().capsuleConfig)!=null&&E.apiKey)||!((h=u.getState().capsuleConfig)!=null&&h.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var C,T;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,g=new d({apiKey:(C=u.getState().capsuleConfig)==null?void 0:C.apiKey,env:(T=u.getState().capsuleConfig)==null?void 0:T.env});return p.setState({capsuleClient:g}),g});return {init:e,enable:d=>l(void 0,null,function*(){let g=typeof d=="string"?[d]:d,C=p.getState().capsuleClient;C||(C=yield e()),u.setState({capsuleState:{showModal:!0,chainId:g}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var f;let d=p.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 C=(f=u.getState().capsuleState)==null?void 0:f.chainId;if(!C)throw new Error("Chain ids are not set");let T=yield d.getAccount(C[0]),x={};C.forEach(w=>{x[w]={address:fromBech32(T.address).data,bech32Address:toBech32(g.find(b=>b.chainId===w).bech32Config.bech32PrefixAccAddr,fromBech32(T.address).data),algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1};}),p.setState(w=>({accounts:O(O({},w.accounts||{}),x)})),u.setState(w=>({recentChainIds:[...w.recentChainIds||[],...C].filter((b,D,N)=>N.indexOf(b)===D)})),p.setState(w=>({activeChainIds:[...w.activeChainIds||[],...C].filter((b,D,N)=>N.indexOf(b)===D)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");let C=yield g.getAccount(d);return {address:fromBech32(C.address).data,bech32Address:C.address,algo:C.algo,name:C.username||"",pubKey:C.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let g=p.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,C,T]=d,x=p.getState().capsuleClient;if(!x)throw new Error("Capsule client is not initialized");return x.signDirect(g,C,{bodyBytes:T.bodyBytes,authInfoBytes:T.authInfoBytes,chainId:T.chainId,accountNumber:T.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[g,C,T,x]=d,f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.signAmino(g,C,T,x)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by capsule");},getOfflineSigner:d=>{let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerAmino(d)}}};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 a;let s=()=>{z(),o();};return (a=window.cosmostation)==null||a.cosmos.on("accountChanged",s),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",s);}},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 de=()=>{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 pe={},Xe=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(b=>b.id===e.id&&(!f||b.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 K;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 b=(K=f.split("MetaMask/v")[1])==null?void 0:K.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),s=f=>l(void 0,null,function*(){(yield i())||(yield r());}),a=(f,w,b)=>l(void 0,null,function*(){let D=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:w,signDoc:b}}}}),N=b.accountNumber,K=new zt(N.low,N.high,N.unsigned);return {signature:D.signature,signed:B(O({},D.signed),{accountNumber:`${K.toString()}`,authInfoBytes:new Uint8Array(Object.values(D.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(D.signed.bodyBytes))})}}),c=(f,w,b)=>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:b}}}})}),m=f=>l(void 0,null,function*(){if(typeof pe[f]!="undefined")return pe[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,pe[f]=w,pe[f]}),A=f=>l(void 0,null,function*(){let w=yield m(f);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),E=(...f)=>l(void 0,null,function*(){let[w,b,D,N]=f;return yield c(w,b,D)}),h=(...f)=>l(void 0,null,function*(){let[w,b,D]=f;return yield a(w,b,D)}),d=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signDirect:(w,b)=>h(f,w,b)}),g=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signAmino:(w,b)=>E(f,w,b)});return {enable:s,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:m,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signDirect:(w,b)=>h(f,w,b),signAmino:(w,b)=>E(f,w,b)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return (yield m(f)).isNanoLedger?g(f):d(f)}),getOfflineSignerOnlyAmino:g,init:o,signAmino:E,signDirect:h}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Je=()=>Xe({id:"npm:@leapwallet/metamask-cosmos-snap"});var me=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let s=()=>{z(),o();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:o=>l(void 0,null,function*(){let s=yield e.getKey(o);return O({isKeystone:!1},s)}),getOfflineSigner:o=>{try{let s=e.getOfflineSignerOnlyAmino(o);return Object.assign(s,{signDirect:(m,A)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let s=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(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(a=>{var c,m,A;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((c=a.gasPriceStep)==null?void 0:c.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((A=a.gasPriceStep)==null?void 0:A.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),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,s,a,c)=>e.signAmino(o,s,a),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}}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:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>l(void 0,null,function*(){let c=yield e.getKey(a);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:a=>{let c=()=>{z(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>l(void 0,null,function*(){let[c]=a,m=B(O({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>l(void 0,null,function*(){var A;let{1:c,2:m}=a;return e.signDirect(c,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:zt.fromString(((A=m.accountNumber)==null?void 0:A.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>l(void 0,null,function*(){let{1:c,2:m}=a;return e.signAmino(c,m)}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var j=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,Ze=()=>j()&&navigator.userAgent.toLowerCase().includes("android"),et=()=>j()&&(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 $=e=>{var K,oe,Ke;if(!((Ke=(oe=(K=u.getState().walletConnect)==null?void 0:K.options)==null?void 0:oe.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:S,formatNativeUrl:I}=e;if(j()){if(Ze())if(!y)window.open(S.mobile.android,"_self","noreferrer noopener");else {let W=I(S.mobile.android,y,"android");window.open(W,"_self","noreferrer noopener");}if(et())if(!y)window.open(S.mobile.ios,"_self","noreferrer noopener");else {let W=I(S.mobile.ios,y,"ios");window.open(W,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=p.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),p.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:S}=p.getState(),I=S.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);}),s=y=>{try{let{wcSignClients:S}=p.getState(),I=S.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(q=>`cosmos:${q}`),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(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}},a=y=>{try{return s(y)}catch(S){return}},c=y=>l(void 0,null,function*(){try{let S=y.core.pairing.pairings.getAll({active:!1});if(!S.length)return;yield Promise.all(S.map(I=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}}),m=()=>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:S}=p.getState(),I=S.get(t);if(I)return I;let W=yield SignClient.init(y.options);return S.set(t,W),p.setState({wcSignClients:S}),W}),A=y=>{let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)return ()=>{};let W=R=>{let k=p.getState().accounts;if(R.params.event.name==="accountsChanged"&&k&&!Object.values(k).map(q=>q.bech32Address).includes(R.params.event.data[0])){let q=R.params.chainId.split(":")[1];q&&E([q]);}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 ie;let S=typeof y=="string"?[y]:y,{wcSignClients:I}=p.getState(),W=I.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:R,chains:k}=u.getState();if(!((ie=R==null?void 0:R.options)!=null&&ie.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:q}=yield import('@web3modal/standalone'),H=new q(O({projectId:R.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},R.web3Modal)),X=a(S);if(!X){let{uri:L,approval:J}=yield xe(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:S.map(F=>`cosmos:${F}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?i(L):yield H.openModal({uri:L});let re=F=>l(void 0,null,function*(){return F.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Te,Z)=>{J().then(_e=>{let Le=_e.sessionProperties;if(!Le)return Z(new Error("No session properties"));let be=JSON.parse(String(Le.keys));if(be.length===0)return Z(new Error("No accounts"));let Ue=be[0];if(!Ue)return Z(new Error("No accounts"));let qe={};return S.forEach(se=>{qe[se]=B(O({},Ue),{bech32Address:toBech32(k.find(Nt=>Nt.chainId===se).bech32Config.bech32PrefixAccAddr,fromBech32(be[0].bech32Address).data)});}),p.setState(se=>({accounts:O(O({},se.accounts||{}),qe)})),Te(_e)}).catch(Z),F.addEventListener("abort",()=>{Z(new Error("User closed wallet connect"));},{once:!0});})});try{let F=new AbortController,Te=F.signal;H.subscribeModal(Z=>{Z.open||F.abort();}),yield re(Te);}catch(F){if(H.closeModal(),!F.message.toLowerCase().includes("no matching key"))return Promise.reject(F)}return e||H.closeModal(),Promise.resolve()}try{yield xe((()=>l(void 0,null,function*(){let L=yield d(S[0]),J={};S.forEach(re=>{J[re]=B(O({},L),{bech32Address:toBech32(k.find(F=>F.chainId===re).bech32Config.bech32PrefixAccAddr,fromBech32(L.bech32Address).data)});}),p.setState({accounts:J});}))(),15e3,new Error("Connection timeout"));}catch(L){if(o(X.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),h=y=>l(void 0,null,function*(){var k;let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let W=(k=s([y]))==null?void 0:k.topic;if(!W)throw new Error("No wallet connect session");let R=yield I.request({topic:W,chainId:`cosmos:${y}`,request:{method:"cosmos_getAccounts",params:{}}});if(!R[0])throw new Error("No wallet connect account");return {address:R[0].address,algo:R[0].algo,pubkey:new Uint8Array(Buffer.from(R[0].pubkey,n))}}),d=y=>l(void 0,null,function*(){let S=s([y]);if(!(S!=null&&S.topic))throw new Error("No wallet connect session");let I=S.sessionProperties&&JSON.parse(String(S.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),g=(...y)=>l(void 0,null,function*(){var L,J;let[S,I,W]=y,{accounts:R,wcSignClients:k}=p.getState(),q=k.get(t);if(!q)throw new Error("walletConnect.signClient is not defined");if(!R)throw new Error("account is not defined");let H=(L=s([S]))==null?void 0:L.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 X={topic:H,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:B(O({},W),{bodyBytes:Buffer.from(W.bodyBytes).toString(n),authInfoBytes:Buffer.from(W.authInfoBytes).toString(n),accountNumber:(J=W.accountNumber)==null?void 0:J.toString()})}}};return i(),yield q.request(X)}),C=(...y)=>l(void 0,null,function*(){let[S,I,W]=y,{signature:R,signed:k}=yield g(S,I,W);return {signed:{chainId:k.chainId,accountNumber:zt.fromString(k.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(k.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(k.bodyBytes,n))},signature:R}}),T=(...y)=>l(void 0,null,function*(){var L;let[S,I,W,R]=y,{wcSignClients:k}=p.getState(),q=k.get(t),{accounts:H}=p.getState();if(!q)throw new Error("walletConnect.signClient is not defined");if(!H)throw new Error("account is not defined");let X=(L=s([S]))==null?void 0:L.topic;if(!X)throw new Error("No wallet connect session");return i(),yield q.request({topic:X,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:W}}})}),x=(...y)=>l(void 0,null,function*(){let[S,I,W,R]=y;return yield T(S,I,W)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signDirect:(S,I)=>C(y,S,I)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signAmino:(S,I)=>x(y,S,I)});return {enable:E,disable:y=>l(void 0,null,function*(){var W;let{wcSignClients:S}=p.getState(),I=S.get(t);if(y===void 0){let R=I==null?void 0:I.session.getAll();R!==void 0&&(yield Promise.all(R.map(k=>o(k.topic))));}else typeof y=="string"?yield o((W=s([y]))==null?void 0:W.topic):yield Promise.all(y.map(R=>{var k;return o((k=s([R]))==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 h(y)]}),signDirect:(S,I)=>C(y,S,I),signAmino:(S,I)=>x(y,S,I)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):f(y)}),getOfflineSignerOnlyAmino:w,signAmino:x,signDirect:C,subscription:A,init:m,setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}};var ot=()=>{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(!j())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,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return $(e)};var it=()=>{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(!j())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,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return $(e)};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(!j())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,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return $(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);}},setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var _=(e=u.getState().walletType)=>{try{return P(e),!0}catch(t){return !1}},z=()=>{window.sessionStorage.removeItem(V),p.setState(ee);},P=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return ue();case"leap":return de();case"cosmostation":return le();case"vectis":return fe();case"walletconnect":return $();case"wc_keplr_mobile":return it();case"wc_leap_mobile":return rt();case"wc_cosmostation_mobile":return ot();case"metamask_snap_leap":return Je();case"station":return me();case"xdefi":return ge();case"capsule":return ce();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},ii=()=>Object.fromEntries($e.map(e=>[e,_(e)])),Me=e=>e==="capsule",st=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var te=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(!_(o))throw new Error(`${o} is not available`);let a=P(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 m=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(m!=null&&m.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),p.setState(d=>{let g=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(T=>{var x;return !((x=d.activeChainIds)!=null&&x.includes(T))}).length>0?{status:"connecting"}:g?{status:"reconnecting"}:{status:"connecting"}});let{accounts:A}=p.getState();if(yield (t=a.init)==null?void 0:t.call(a),Me(o)&&p.getState().capsuleClient&&Object.values(p.getState().accounts||[]).length>0){let d=c.map(x=>i.find(f=>f.chainId===x)),g=p.getState().accounts;p.setState({status:"connecting"});let C=yield a.getKey(c[0]),T={};return c.forEach(x=>{T[x]=B(O({},C),{bech32Address:toBech32(i.find(f=>f.chainId===x).bech32Config.bech32PrefixAccAddr,fromBech32(C.bech32Address).data)});}),p.setState(x=>({accounts:O(O({},x.accounts||{}),T)})),u.setState(x=>({recentChainIds:[...x.recentChainIds||[],...c].filter((f,w,b)=>b.indexOf(f)===w)})),p.setState(x=>({activeChainIds:[...x.activeChainIds||[],...c].filter((f,w,b)=>b.indexOf(f)===w)})),p.setState({status:"connected"}),{accounts:g,walletType:o,chains:d}}if(yield a.enable(c),Me(o)){let d=c.map(C=>i.find(T=>T.chainId===C)),g=p.getState().accounts;return p.setState({status:"connecting"}),{accounts:g,walletType:o,chains:d}}if(!st(o)){let d=yield a.getKey(c[0]),g={};c.forEach(C=>{g[C]=B(O({},d),{bech32Address:toBech32(i.find(T=>T.chainId===C).bech32Config.bech32PrefixAccAddr,fromBech32(d.bech32Address).data)});}),p.setState(C=>({accounts:O(O({},C.accounts||{}),g)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((g,C,T)=>T.indexOf(g)===C)})),p.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((g,C,T)=>T.indexOf(g)===C)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let E=c.map(d=>i.find(g=>g.chainId===d));return {accounts:p.getState().accounts,walletType:o,chains:E}}catch(n){throw console.error("connect ",n),p.getState().accounts===null&&p.setState({status:"disconnected"}),p.getState().accounts&&p.getState().activeChainIds&&p.setState({status:"connected"}),n}}),ne=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=p.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(p.setState(ee),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(p.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else p.setState(ee),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||void 0);if(t&&o&&n)return yield te({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),ne();}}),lt=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))throw new Error(`${n} is not available`);let r=P(n),o=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var ve=()=>{u.setState({recentChainIds:null});},yi=()=>u.getState().recentChainIds,Si=()=>{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)},wi=({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=P(t);return t==="capsule"?yield te({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),ut=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 te({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var dt=e=>(u.setState(t=>({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 pt=s=>l(void 0,[s],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)}),mt=A=>l(void 0,[A],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:m}){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,s,a,c,m)}),ft=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,i,r)}),gt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,s,o)}),Ct=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),yt=(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 Wi=e=>e,ki=e=>e;var Ce=e=>e?Object.keys(e).length===0:!0;var ke=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},St=e=>globalThis.DOMException===void 0?new ke(e):new DOMException(e),ht=e=>{let t=e.reason===void 0?St("This operation was aborted."):e.reason;return t instanceof Error?t:St(t)};function Re(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((a,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 m=[],A=[],E=new Map,h=!1,d=!1,g=!1,C=0,T=0,x=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=b=>{h=!0,d=!0,c(b);};r&&(r.aborted&&f(ht(r)),r.addEventListener("abort",()=>{f(ht(r));}));let w=()=>l(this,null,function*(){if(d)return;let b=yield x.next(),D=T;if(T++,b.done){if(g=!0,C===0&&!d){if(!i&&A.length>0){f(new AggregateError(A));return}if(d=!0,E.size===0){a(m);return}let N=[];for(let[K,oe]of m.entries())E.get(K)!==wt&&N.push(oe);a(N);}return}C++,l(this,null,function*(){try{let N=yield b.value;if(d)return;let K=yield t(N,D);K===wt&&E.set(D,K),m[D]=K,C--,yield w();}catch(N){if(i)f(N);else {A.push(N),C--;try{yield w();}catch(K){f(K);}}}});});l(this,null,function*(){for(let b=0;b<n;b++){try{yield w();}catch(D){f(D);break}if(g||h)break}});})})}var wt=Symbol("skip");var U=({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 Re(t,n,{concurrency:i});return Object.fromEntries(o.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),At=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var Ne=e=>{let t=U({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,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Be=e=>{let t=U({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,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.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=U({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:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield G(!!n,a,A=>l(void 0,null,function*(){var C;let E=(C=u.getState().chainsConfig)==null?void 0:C[A.chainId],h={url:A.rpc,headers:O({},(E==null?void 0:E.rpcHeaders)||{})};return yield (s==="tm37"?Tendermint37Client:Tendermint34Client).connect(h)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var ir=()=>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"}),shallow),Se=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>_(r))};var Y=e=>{let t=u(a=>a.walletType),n=p(a=>a.activeChainIds),i=U({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=p(a=>a.accounts),o=p(a=>a.status);return useEffect(()=>p.subscribe(a=>a.status,(a,c)=>{var m,A,E;if(a==="connected"){let{accounts:h,activeChainIds:d}=p.getState(),{chains:g}=u.getState(),{walletType:C}=u.getState();if(!h||!d||!g)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(A=e==null?void 0:e.onConnect)==null||A.call(e,{accounts:h,chains:d.map(T=>g.find(x=>x.chainId===T)),walletType:C,isReconnect:c==="reconnecting"});}a==="disconnected"&&((E=e==null?void 0:e.onDisconnect)==null||E.call(e));}),[e]),{data:useMemo(()=>r?At(!!(e!=null&&e.multiChain),i,a=>r[a.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}},on=e=>{let t=U({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}=Ne({chainId:t.map(s=>s.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,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){let h=s==null?void 0:s[E.chainId];if(!h)throw new Error(`Client is not ready ${E.chainId}`);return yield h.getAllBalances(toBech32(E.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})},yr=e=>{let t=U({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=on({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,i,e.chainId],a=useQuery(s,({queryKey:[,c,m]})=>m==null?void 0:m.find(A=>A.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return B(O({},a),{refetch:c=>l(void 0,null,function*(){return yield o(),a.refetch(c)})})},Sr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],te,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Se();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),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],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}},wr=e=>{let t=U({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:s=>l(void 0,[s],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!_(o))throw new Error(`${o} is not available`);return yield G(!!(e!=null&&e.multiChain),r,m=>l(void 0,null,function*(){return yield lt({chainId:m.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},Ar=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:i}=Ne({chainId:t.map(s=>s.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,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){var d;if(!s)throw new Error("Client is not ready");return yield (d=s[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 Mr=()=>{let e=u(i=>i.capsuleState),t=p(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:()=>{ne();}}};var Nr=()=>p(e=>e.activeChainIds),rn=()=>{var e;return (e=p(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)},Br=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Kr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},_r=({denom:e})=>{let t=rn();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:o.currencies.find(s=>s)})},Lr=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,a=>l(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Ur=()=>({data:u(t=>t.recentChainIds),clear:ve}),qr=()=>{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}},Gr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],We,{onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.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}},Fr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],ut,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{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 Xr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>pt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Jr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>mt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Zr=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,a=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var A;if(!o)throw new Error("senderAddress is undefined");let m=B(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,codeId:e});return ft(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},es=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,a=useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var A,E,h;if(!o)throw new Error("senderAddress is undefined");let m=B(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,contractAddress:e,memo:(E=c.memo)!=null?E:"",funds:(h=c.funds)!=null?h:[]});return gt(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},ts=e=>{let{data:t}=Be();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 Ct(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ns=e=>{let{data:t}=Be(),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 yt(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function gs(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var C,T;if(!(i!=null&&i.includes(m.chainId)))return;if(!_(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return P(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return P(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return P(s).getOfflineSignerOnlyAmino(m.chainId);default:return P(s).getOfflineSignerAuto(m.chainId)}}))(),h=(C=u.getState().chainsConfig)==null?void 0:C[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(d,E,e!=null&&e.multiChain?(T=e.opts)==null?void 0:T[m.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 Cs(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var T,x;if(!(i!=null&&i.includes(m.chainId)))return;if(!_(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return P(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return P(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return P(s).getOfflineSignerOnlyAmino(m.chainId);default:return P(s).getOfflineSignerAuto(m.chainId)}}))(),h=(T=u.getState().chainsConfig)==null?void 0:T[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})},g=h!=null&&h.gas?GasPrice.fromString(`${h.gas.price}${h.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(d,E,O({gasPrice:g},e!=null&&e.multiChain?(x=e.opts)==null?void 0:x[m.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 ys(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=p(s=>s.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:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,A=>l(this,null,function*(){var C;if(!(i!=null&&i.includes(A.chainId)))return;if(!_(a))throw new Error(`${a} is not available`);if(!o)throw new Error("No tendermint client found");let h=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return P(a).getOfflineSigner(A.chainId);case"offlineSignerAuto":return P(a).getOfflineSignerAuto(A.chainId);case"offlineSignerOnlyAmino":return P(a).getOfflineSignerOnlyAmino(A.chainId);default:return P(a).getOfflineSignerAuto(A.chainId)}}))(),d=e.multiChain?o[A.chainId]:o;return yield SigningStargateClient.createWithSigner(d,h,e.multiChain?(C=e.opts)==null?void 0:C[A.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Ss(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=p(a=>a.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:s}=ye({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:m=>l(this,[m],function*({queryKey:[,a,c]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,E=>l(this,null,function*(){var f,w;if(!(i!=null&&i.includes(E.chainId)))return;if(!_(c))throw new Error(`${c} is not available`);let d=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return P(c).getOfflineSigner(E.chainId);case"offlineSignerAuto":return P(c).getOfflineSignerAuto(E.chainId);case"offlineSignerOnlyAmino":return P(c).getOfflineSignerOnlyAmino(E.chainId);default:return P(c).getOfflineSignerAuto(E.chainId)}}))(),g=(f=u.getState().chainsConfig)==null?void 0:f[E.chainId],C=g!=null&&g.gas?GasPrice.fromString(`${g.gas.price}${g.gas.denom}`):void 0,T=e.multiChain?s==null?void 0:s[E.chainId]:o;if(!T)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(T,d,O({gasPrice:C},e.multiChain?(w=e.opts)==null?void 0:w[E.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!Ce(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var kt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var un=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i}=u(),{activeChainIds:r,wcSignClients:o}=p(),s=_(i||void 0);return useEffect(()=>{if(i){if(!s)return;e&&r?Q({onError:n}):!e&&t&&Q({onError:n});}},[s]),useEffect(()=>{var a,c,m,A,E,h,d,g,C,T,x,f,w,b;if(i){if(!s)return;i==="cosmostation"&&((c=(a=le()).subscription)==null||c.call(a,()=>{Q({onError:n});})),i==="keplr"&&((A=(m=ue()).subscription)==null||A.call(m,()=>{Q({onError:n});})),i==="leap"&&((h=(E=de()).subscription)==null||h.call(E,()=>{Q({onError:n});})),i==="vectis"&&((g=(d=fe()).subscription)==null||g.call(d,()=>{Q({onError:n});})),i==="walletconnect"&&o.has("walletconnect")&&((T=(C=$()).subscription)==null||T.call(C,()=>{Q({onError:n});})),i==="station"&&((f=(x=me()).subscription)==null||f.call(x,()=>{Q({onError:n});})),i==="xdefi"&&((b=(w=ge()).subscription)==null||b.call(w,()=>{Q({onError:n});}));}},[i,o,s]),null},Pt=()=>(un(),null);var mn=new QueryClient({}),zs=i=>{var r=i,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return dt(t),jsx(QueryClientProvider,B(O({client:mn},n),{children:jsxs(kt,{children:[e,jsx(Pt,{})]})}),"graz-provider")};
|
|
16
16
|
|
|
17
|
-
export {
|
|
17
|
+
export { Pt as GrazEvents, zs as GrazProvider, $e as WALLET_TYPES, je as WalletType, _ as checkWallet, ve as clearRecentChain, z as clearSession, dt as configureGraz, te as connect, ki as defineChainInfo, Wi as defineChains, ne as disconnect, gt as executeContract, ii as getAvailableWallets, hi as getChainInfo, wi as getChainInfos, le as getCosmostation, ue as getKeplr, de as getLeap, Je as getMetamaskSnapLeap, lt as getOfflineSigners, yt as getQueryRaw, Ct as getQuerySmart, yi as getRecentChainIds, Si as getRecentChains, fe as getVectis, ot as getWCCosmostation, it as getWCKeplr, rt as getWCLeap, P as getWallet, $ as getWalletConnect, ft as instantiateContract, Me as isCapsule, st as isWalletConnect, Q as reconnect, mt as sendIbcTokens, pt as sendTokens, We as suggestChain, ut as suggestChainAndConnect, Y as useAccount, _r as useActiveChainCurrency, Nr as useActiveChainIds, rn as useActiveChains, ir as useActiveWalletType, yr as useBalance, Ar as useBalanceStaked, on as useBalances, Mr as useCapsule, Br as useChainInfo, Kr as useChainInfos, Se as useCheckWallet, Sr as useConnect, Be as useCosmWasmClient, Cs as useCosmWasmSigningClient, Ss as useCosmWasmTmSigningClient, hr as useDisconnect, es as useExecuteContract, un as useGrazEvents, Zr as useInstantiateContract, wr as useOfflineSigners, Lr as useQueryClientValidators, ns as useQueryRaw, ts as useQuerySmart, Ur as useRecentChainIds, qr as useRecentChains, Jr as useSendIbcTokens, Xr as useSendTokens, Ne as useStargateClient, gs as useStargateSigningClient, ys as useStargateTmSigningClient, Gr as useSuggestChain, Fr as useSuggestChainAndConnect, ye as useTendermintClient };
|
package/package.json
CHANGED