graz 0.1.19 → 0.1.20

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