graz 0.1.31 → 0.2.0-alpha.0

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.mjs CHANGED
@@ -4,18 +4,18 @@ import { encodeEd25519Pubkey, encodeSecp256k1Pubkey, pubkeyType, rawEd25519Pubke
4
4
  import { fromBech32, toBech32 } from '@cosmjs/encoding';
5
5
  import { Cosmiframe, isInIframe } from '@dao-dao/cosmiframe';
6
6
  import { isSnapInstalled, installSnap, CosmosSnap } from '@cosmsnap/snapper';
7
- import mt from 'long';
7
+ import lt from 'long';
8
8
  import { SignClient } from '@walletconnect/sign-client';
9
9
  import { getSdkError } from '@walletconnect/utils';
10
10
  import { WalletConnectModal } from '@walletconnect/modal';
11
- import { QueryClient, useQuery, useMutation, QueryClientProvider } from '@tanstack/react-query';
11
+ import { useQuery, useMutation } from '@tanstack/react-query';
12
12
  import { useMemo, useEffect, useState } from 'react';
13
13
  import { CosmWasmClient, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
14
14
  import { StargateClient, SigningStargateClient, GasPrice } from '@cosmjs/stargate';
15
15
  import { Tendermint37Client, Tendermint34Client } from '@cosmjs/tendermint-rpc';
16
16
  import { shallow } from 'zustand/shallow';
17
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
17
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
18
18
 
19
- var Ft=Object.defineProperty,Gt=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var je=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable;var Qe=(e,t,i)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,M=(e,t)=>{for(var i in t||(t={}))je.call(t,i)&&Qe(e,i,t[i]);if(ce)for(var i of ce(t))$e.call(t,i)&&Qe(e,i,t[i]);return e},G=(e,t)=>Gt(e,zt(t));var Ve=(e,t)=>{var i={};for(var o in e)je.call(e,o)&&t.indexOf(o)<0&&(i[o]=e[o]);if(e!=null&&ce)for(var o of ce(e))t.indexOf(o)<0&&$e.call(e,o)&&(i[o]=e[o]);return i};var l=(e,t,i)=>new Promise((o,r)=>{var n=c=>{try{s(i.next(c));}catch(f){r(f);}},a=c=>{try{s(i.throw(c));}catch(f){r(f);}},s=c=>c.done?o(c.value):Promise.resolve(c.value).then(n,a);s((i=i.apply(e,t)).next());});var J="graz-reconnect-session";var He=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.CAPSULE="capsule",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p))(He||{}),Xe=["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","okx"];var jt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ie={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},$t={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Vt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},g=create(subscribeWithSelector(persist(()=>ie,$t))),u=create(subscribeWithSelector(persist(()=>jt,Vt)));var le=()=>{var S,y;if(!((S=u.getState().capsuleConfig)!=null&&S.apiKey)||!((y=u.getState().capsuleConfig)!=null&&y.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var h,x;let m=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,C=new m({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(x=u.getState().capsuleConfig)==null?void 0:x.env});return g.setState({capsuleClient:C}),C});return {init:e,enable:m=>l(void 0,null,function*(){let C=typeof m=="string"?[m]:m,h=g.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:C}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var p;let m=g.getState().capsuleClient,{chains:C}=u.getState();if(!m)throw new Error("Capsule client is not initialized");if(!C)throw new Error("Chains are not set");yield m.enable();let h=(p=u.getState().capsuleState)==null?void 0:p.chainId;if(!h)throw new Error("Chain ids are not set");let x=Object.fromEntries(yield Promise.all(h.map(I=>l(void 0,null,function*(){let b=yield m.getAccount(I);return [I,{address:fromBech32(b.address).data,bech32Address:b.address,algo:b.algo,name:b.username||"",pubKey:b.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));g.setState(I=>({accounts:M(M({},I.accounts||{}),x)})),u.setState(I=>({recentChainIds:[...I.recentChainIds||[],...h].filter((b,W,K)=>K.indexOf(b)===W)})),g.setState(I=>({activeChainIds:[...I.activeChainIds||[],...h].filter((b,W,K)=>K.indexOf(b)===W)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(J,"Active"),u.setState({capsuleState:null});}),getKey:m=>l(void 0,null,function*(){let C=g.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");let h=yield C.getAccount(m);return {address:fromBech32(h.address).data,bech32Address:h.address,algo:h.algo,name:h.username||"",pubKey:h.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:m=>l(void 0,null,function*(){let C=g.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerDirect(m)}),getOfflineSignerDirect:m=>{let C=g.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerDirect(m)},signDirect:(...m)=>l(void 0,null,function*(){let[C,h,x]=m,p=g.getState().capsuleClient;if(!p)throw new Error("Capsule client is not initialized");return p.signDirect(C,h,{bodyBytes:x.bodyBytes,authInfoBytes:x.authInfoBytes,chainId:x.chainId,accountNumber:x.accountNumber})}),signAmino:(...m)=>l(void 0,null,function*(){let[C,h,x,p]=m,I=g.getState().capsuleClient;if(!I)throw new Error("Capsule client is not initialized");return I.signAmino(C,h,x,p)}),signArbitrary:(m,C,h)=>l(void 0,null,function*(){let x=g.getState().capsuleClient;if(!x)throw new Error("Capsule client is not initialized");let p=yield x.getAccount(m);if(!p)throw new Error(`Wallet not connected to account ${C}`);let I=(()=>{switch(p.algo){case"secp256k1":return encodeSecp256k1Pubkey(p.pubkey);case"ed25519":return encodeEd25519Pubkey(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield x.signArbitrary(m,C,h),pub_key:{type:p.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:I.value}}}),experimentalSuggestChain:(...m)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:m=>{let C=g.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSigner(m)},getOfflineSignerAmino:m=>{let C=g.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerAmino(m)}}};var ue=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var pe=()=>{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 ot={},rt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var w;let n=yield e.request({method:"web3_clientVersion"});if(!n.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=n.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:n=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:n=>t.getOfflineSigner(n),experimentalSuggestChain:n=>l(void 0,null,function*(){if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(G(M({},n),{stakeCurrency:n.stakeCurrency,bech32Config:n.bech32Config}));}),signAmino:(n,a,s)=>l(void 0,null,function*(){return t.signAmino(n,a,s)}),getKey:n=>l(void 0,null,function*(){return typeof ot[n]!="undefined"?ot[n]:t.getKey(n)}),getOfflineSignerAuto:n=>l(void 0,null,function*(){return (yield t.getKey(n)).isNanoLedger?t.getOfflineSignerOnlyAmino(n):t.getOfflineSigner(n)}),getOfflineSignerOnlyAmino:n=>t.getOfflineSignerOnlyAmino(n),signDirect:(n,a,s)=>l(void 0,null,function*(){return t.signDirect(n,a,s)}),signArbitrary:(n,a,s)=>l(void 0,null,function*(){return t.signArbitrary(n,a,s)}),disable:n=>l(void 0,null,function*(){n&&(yield t.deleteChain(n));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var me=()=>{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:n=>{let a=()=>{B(),n();};return window.addEventListener("cosmostation_keystorechange",a),()=>{window.removeEventListener("cosmostation_keystorechange",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var rn=e=>{let{bodyBytes:t,authInfoBytes:i,chainId:o,accountNumber:r}=e;if(!t||!i||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:i,chainId:o,accountNumber:r}},sn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,at=()=>{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),[y]=yield S.getAccounts();if(!y)throw new Error("Wallet connection failed");let m=(()=>{switch(y.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(y.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:sn(y.address),algo:y.algo,pubKey:y.pubkey,bech32Address:y.address,address:m,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:d=>{let S=e.getOfflineSigner(d),y=e.getOfflineSignerOnlyAmino(d);return {getAccounts:S.getAccounts.bind(S),signDirect:S.signDirect.bind(S),signAmino:y.signAmino.bind(y)}},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 y,m,C;return {denom:S.coinDenom,amount:S.coinMinimalDenom,low_gas_price:(y=S.gasPriceStep)==null?void 0:y.low,average_gas_price:(m=S.gasPriceStep)==null?void 0:m.average,high_gas_price:(C=S.gasPriceStep)==null?void 0:C.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[S,y,m]=d;return e.getOfflineSigner(S).signDirect(y,rn(m))},signAmino:(...d)=>{let[S,y,m]=d;return e.getOfflineSignerOnlyAmino(S).signAmino(y,m)},signArbitrary:(d,S,y)=>l(void 0,null,function*(){let h=(yield e.getOfflineSigner(d).getAccounts()).find(I=>I.address===S);if(!h)throw new Error(`Wallet not connected to account ${S}`);let x=(()=>{switch(h.algo){case"secp256k1":return encodeSecp256k1Pubkey(h.pubkey);case"ed25519":return encodeEd25519Pubkey(h.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(y),pub_key:{type:h.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:x.value}}}),subscription:d=>{let S=()=>{B(),d();};return window.addEventListener("initia_keystorechange",S),()=>{window.removeEventListener("initia_keystorechange",S);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var de=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var fe=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ge={},ct=e=>{let t=window.ethereum;if(t&&e){let i=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=p=>l(void 0,null,function*(){try{let I=yield i();return Object.values(I).find(b=>b.id===e.id&&(!p||b.version===p))}catch(I){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),n=()=>l(void 0,null,function*(){var N;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(N=p.split("MetaMask/v")[1])==null?void 0:N.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),a=p=>l(void 0,null,function*(){(yield o())||(yield r());}),s=(p,I,b)=>l(void 0,null,function*(){let W=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:I,signDoc:b}}}}),K=b.accountNumber,N=new mt(K.low,K.high,K.unsigned);return {signature:W.signature,signed:G(M({},W.signed),{accountNumber:`${N.toString()}`,authInfoBytes:new Uint8Array(Object.values(W.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(W.signed.bodyBytes))})}}),c=(p,I,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:I,signDoc:b}}}})}),f=p=>l(void 0,null,function*(){if(typeof ge[p]!="undefined")return ge[p];let I=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!I)throw new Error("No response from Metamask");return I.pubKey=Uint8Array.from(Object.values(I.pubkey)),delete I.pubkey,ge[p]=I,ge[p]}),w=p=>l(void 0,null,function*(){let I=yield f(p);return {address:I.bech32Address,algo:I.algo,pubkey:I.pubKey}}),d=(...p)=>l(void 0,null,function*(){let[I,b,W,K]=p;return yield c(I,b,W)}),S=(...p)=>l(void 0,null,function*(){let[I,b,W]=p;return yield s(I,b,W)}),m=p=>({getAccounts:()=>l(void 0,null,function*(){return [yield w(p)]}),signAmino:(I,b)=>d(p,I,b)});return {enable:a,experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield n(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:f,getOfflineSigner:p=>({getAccounts:()=>l(void 0,null,function*(){return [yield w(p)]}),signDirect:(I,b)=>S(p,I,b),signAmino:(I,b)=>d(p,I,b)}),getOfflineSignerAuto:p=>l(void 0,null,function*(){return m(p)}),getOfflineSignerOnlyAmino:m,init:n,signAmino:d,signDirect:S}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var lt=()=>ct({id:"npm:@leapwallet/metamask-cosmos-snap"});var ye=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:n=>{var s;let a=()=>{B(),n();};return (s=window.okxwallet)==null||s.on("accountsChanged",a),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var Ce=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:n=>{let a=()=>{B(),n();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:n=>l(void 0,null,function*(){let a=yield e.getKey(n);return M({isKeystone:!1},a)}),getOfflineSigner:n=>{try{let a=e.getOfflineSignerOnlyAmino(n);return Object.assign(a,{signDirect:(f,w)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:n=>l(void 0,null,function*(){try{if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");let a=Object.assign(n,{bech32Config:n.bech32Config,chainSymbolImageUrl:n.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:n.stakeCurrency.coinDecimals,coinDenom:n.stakeCurrency.coinDenom,coinImageUrl:n.stakeCurrency.coinImageUrl||"",coinMinimalDenom:n.stakeCurrency.coinMinimalDenom},currencies:n.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:n.feeCurrencies.map(s=>{var c,f,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:((f=s.gasPriceStep)==null?void 0:f.high)||0,low:((w=s.gasPriceStep)==null?void 0:w.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:n=>e.enable(n),disable:n=>e.disable(n),getOfflineSignerAuto:n=>e.getOfflineSignerAuto(n),getOfflineSignerOnlyAmino:n=>e.getOfflineSignerOnlyAmino(n),signDirect:()=>e.signDirect(),signAmino:(n,a,s,c)=>e.signAmino(n,a,s)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Se=()=>{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=()=>{B(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>{let c=s[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...s)=>l(void 0,null,function*(){var w;let[c]=s;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(w=c.bech32Config)==null?void 0:w.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...s)=>l(void 0,null,function*(){var w;let{1:c,2:f}=s;return e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:mt.fromString(((w=f.accountNumber)==null?void 0:w.toString())||"",!1),chainId:f.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:f}=s;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var Q=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},ut=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),pt=()=>Q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var ve=(e,t,i=new Error("Promise timed out"))=>{let o=new Promise((r,n)=>{setTimeout(()=>{n(i);},t);});return Promise.race([e,o])};var j=e=>{var N,te,oe;if(!((oe=(te=(N=u.getState().walletConnect)==null?void 0:N.options)==null?void 0:te.projectId)!=null&&oe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",i=(e==null?void 0:e.encoding)||"base64",o=A=>{if(!e)return;let{appUrl:O,formatNativeUrl:E}=e;if(Q()){if(ut()){let v=E(O.mobile.android,A,"android");window.open(v,"_self","noreferrer noopener");}if(pt()){let v=E(O.mobile.ios,A,"ios");window.open(v,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:A}=g.getState();if(!A.get(t))throw new Error("walletConnect.signClient is not defined");A.delete(t),g.setState({wcSignClients:A}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},n=A=>l(void 0,null,function*(){let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");if(!A)throw new Error("No wallet connect session");yield E.disconnect({topic:A,reason:getSdkError("USER_DISCONNECTED")}),yield c(E);}),a=A=>{try{let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let v=E.session.getAll(),R=v.at(-1);if(!R)return;if(!(R.expiry*1e3>Date.now()+1e3))throw n(R.topic),new Error("invalid session");try{let _=v.find($=>{var X,Y;return (Y=(X=$.requiredNamespaces.cosmos)==null?void 0:X.chains)==null?void 0:Y.includes(`cosmos:${A}`)});if(!_)throw new Error("no session");return _}catch(_){if(!_.message.toLowerCase().includes("no matching key"))throw _}return R}catch(O){if(!O.message.toLowerCase().includes("no matching key"))throw O}},s=A=>{try{return a(A)}catch(O){return}},c=A=>l(void 0,null,function*(){try{let O=A.core.pairing.pairings.getAll({active:!1});if(!O.length)return;yield Promise.all(O.map(E=>l(void 0,null,function*(){yield A.core.pairing.pairings.delete(E.topic,{code:7001,message:"clear pairing"});})));}catch(O){if(!O.message.toLowerCase().includes("no matching key"))throw O}}),f=()=>l(void 0,null,function*(){let{walletConnect:A}=u.getState();if(!(A!=null&&A.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:O}=g.getState(),E=O.get(t);if(E)return E;let v=yield SignClient.init(A.options);return O.set(t,v),g.setState({wcSignClients:O}),v}),w=A=>{let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)return ()=>{};let v=R=>{let P=g.getState().accounts;if(R.params.event.name==="accountsChanged"&&P&&!Object.values(P).map(_=>_.bech32Address).includes(R.params.event.data[0])){let _=R.params.chainId.split(":")[1];_&&d([_]);}else A();};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=A=>l(void 0,null,function*(){var Y;let O=typeof A=="string"?[A]:A,{wcSignClients:E,activeChainIds:v}=g.getState(),R=E.get(t);if(!R)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:P,chains:_}=u.getState();if(!((Y=P==null?void 0:P.options)!=null&&Y.projectId))throw new Error("walletConnect.options.projectId is not defined");let $=new WalletConnectModal(M({projectId:P.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.walletConnectModal)),X=s(O);if(!X){let{uri:F,approval:se}=yield ve(R.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:O.map(V=>`cosmos:${V}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!F)throw new Error("No wallet connect uri");e?o(F):yield $.openModal({uri:F});let ae=V=>l(void 0,null,function*(){return V.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((xe,ne)=>{se().then(Fe=>{let Ge=Fe.sessionProperties;if(!Ge)return ne(new Error("No session properties"));let Me=JSON.parse(String(Ge.keys));if(Me.length===0)return ne(new Error("No accounts"));if(!Me[0])return ne(new Error("No accounts"));let ze={};return Me.forEach(H=>{ze[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),g.setState(H=>({accounts:M(M({},H.accounts||{}),ze)})),xe(Fe)}).catch(ne),V.addEventListener("abort",()=>{ne(new Error("User closed wallet connect"));},{once:!0});})});try{let V=new AbortController,xe=V.signal;$.subscribeModal(ne=>{ne.open||V.abort();}),yield ae(xe);}catch(V){if($.closeModal(),!V.message.toLowerCase().includes("no matching key"))return Promise.reject(V)}return e||$.closeModal(),Promise.resolve()}try{yield ve((()=>l(void 0,null,function*(){var se;let F=Object.fromEntries(yield Promise.all((se=v||O)==null?void 0:se.map(ae=>l(void 0,null,function*(){return [ae,yield y(ae)]}))));g.setState({accounts:F});}))(),15e3,new Error("Connection timeout"));}catch(F){if(n(X.topic),!F.message.toLowerCase().includes("no matching key"))throw F}}),S=A=>l(void 0,null,function*(){let O=yield y(A);return {address:O.bech32Address,algo:O.algo,pubkey:O.pubKey}}),y=A=>l(void 0,null,function*(){let O=a([A]);if(!(O!=null&&O.topic))throw new Error("No wallet connect session");let E=O.sessionProperties&&JSON.parse(String(O.sessionProperties.keys));if(!E)throw new Error("No wallet connect key");if(E.length===0)throw new Error("No wallet connect session");let v=E.find(R=>R.chainId===A);if(!v)throw new Error(`No wallet connect key for chainId ${A}`);return G(M({},v),{pubKey:Buffer.from(String(v.pubKey),i)})}),m=(...A)=>l(void 0,null,function*(){var Y,F;let[O,E,v]=A,{accounts:R,wcSignClients:P}=g.getState(),_=P.get(t);if(!_)throw new Error("walletConnect.signClient is not defined");if(!R)throw new Error("account is not defined");let $=(Y=a([O]))==null?void 0:Y.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");return o(),yield _.request({topic:$,chainId:`cosmos:${O}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:{chainId:v.chainId,accountNumber:(F=v.accountNumber)==null?void 0:F.toString(),bodyBytes:v.bodyBytes?Buffer.from(v.bodyBytes).toString(i):null,authInfoBytes:v.authInfoBytes?Buffer.from(v.authInfoBytes).toString(i):null}}}})}),C=(...A)=>l(void 0,null,function*(){var _;let[O,E,v]=A,{signature:R,signed:P}=yield m(O,E,v);return {signed:{chainId:(_=P.chainId)!=null?_:"",accountNumber:P.accountNumber?mt.fromString(P.accountNumber):new mt(0),authInfoBytes:P.authInfoBytes?new Uint8Array(Buffer.from(P.authInfoBytes,i)):new Uint8Array([]),bodyBytes:P.bodyBytes?new Uint8Array(Buffer.from(P.bodyBytes,i)):new Uint8Array([])},signature:R}}),h=(...A)=>l(void 0,null,function*(){var F;let[O,E,v,R]=A,{wcSignClients:P}=g.getState(),_=P.get(t),{accounts:$}=g.getState();if(!_)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let X=(F=a([O]))==null?void 0:F.topic;if(!X)throw new Error("No wallet connect session");return o(),yield _.request({topic:X,chainId:`cosmos:${O}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:v}}})}),x=(...A)=>l(void 0,null,function*(){let[O,E,v,R]=A;return yield h(O,E,v)}),p=A=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(A)]}),signDirect:(O,E)=>C(A,O,E)}),I=A=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(A)]}),signAmino:(O,E)=>x(A,O,E)});return {enable:d,disable:A=>l(void 0,null,function*(){var v;let{wcSignClients:O}=g.getState(),E=O.get(t);if(A===void 0){let R=E==null?void 0:E.session.getAll();R!==void 0&&(yield Promise.all(R.map(P=>n(P.topic))));}else typeof A=="string"?yield n((v=a([A]))==null?void 0:v.topic):yield Promise.all(A.map(R=>{var P;return n((P=a([R]))==null?void 0:P.topic)}));(E==null?void 0:E.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...A)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:y,getOfflineSigner:A=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(A)]}),signDirect:(O,E)=>C(A,O,E),signAmino:(O,E)=>x(A,O,E)}),getOfflineSignerAuto:A=>l(void 0,null,function*(){return (yield y(A)).isNanoLedger?I(A):p(A)}),getOfflineSignerOnlyAmino:I,signAmino:x,signDirect:C,subscription:w,init:f}};var dt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.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,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return j(e)};var ft=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.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,n,a)=>{let s=r.replaceAll("/","").replaceAll(":","");return n?`${s}://wc?${n}`:`${s}://wc`}};return j(e)};var gt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.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,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${s}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return j(e)};var yt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.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,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${s}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return j(e)};var he=()=>{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 n=()=>{B(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var L=(e=u.getState().walletType)=>{try{return D(e),!0}catch(t){return !1}},B=()=>{window.sessionStorage.removeItem(J),g.setState(ie);},D=(e=u.getState().walletType)=>{var o;let t=(()=>{switch(e){case"keplr":return de();case"leap":return fe();case"cosmostation":return me();case"vectis":return Se();case"walletconnect":return j();case"wc_keplr_mobile":return gt();case"wc_leap_mobile":return yt();case"wc_cosmostation_mobile":return ft();case"wc_clot_mobile":return dt();case"metamask_snap_leap":return lt();case"metamask_snap_cosmos":return rt();case"station":return Ce();case"xdefi":return he();case"capsule":return le();case"cosmiframe":return pe();case"compass":return ue();case"initia":return at();case"okx":return ye();default:throw new Error("Unknown wallet type")}})(),i=u.getState().walletDefaultOptions;return i&&((o=t.setDefaultOptions)==null||o.call(t,i)),t},rr=()=>Object.fromEntries(Xe.map(e=>[e,L(e)])),Pe=e=>e==="capsule",We=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Z=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:i,chains:o,walletType:r}=u.getState(),n=(e==null?void 0:e.walletType)||r;if(!L(n))throw new Error(`${n} is not available`);let s=D(n),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||i;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let f=o==null?void 0:o.map(y=>y.chainId);c.forEach(y=>{if(!(f!=null&&f.includes(y)))throw new Error(`Chain ${y} is not provided in GrazProvider`)}),g.setState(y=>{let m=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return y.activeChainIds&&c.filter(h=>{var x;return !((x=y.activeChainIds)!=null&&x.includes(h))}).length>0?{status:"connecting"}:m?{status:"reconnecting"}:{status:"connecting"}});let{accounts:w}=g.getState();if(yield (t=s.init)==null?void 0:t.call(s),Pe(n)&&g.getState().capsuleClient&&Object.values(g.getState().accounts||[]).length>0){let y=c.map(h=>o.find(x=>x.chainId===h)),m=g.getState().accounts;g.setState({status:"connecting"});let C=Object.fromEntries(yield Promise.all(c.map(h=>l(void 0,null,function*(){return [h,yield s.getKey(h)]}))));return g.setState(h=>({accounts:M(M({},h.accounts||{}),C)})),u.setState(h=>({recentChainIds:[...h.recentChainIds||[],...c].filter((x,p,I)=>I.indexOf(x)===p)})),g.setState(h=>({activeChainIds:[...h.activeChainIds||[],...c].filter((x,p,I)=>I.indexOf(x)===p)})),g.setState({status:"connected"}),{accounts:m,walletType:n,chains:y}}if(yield s.enable(c),Pe(n)){let y=c.map(C=>o.find(h=>h.chainId===C)),m=g.getState().accounts;return g.setState({status:"connecting"}),{accounts:m,walletType:n,chains:y}}if(!We(n)){let y=Object.fromEntries(yield Promise.all(c.map(m=>l(void 0,null,function*(){return [m,yield s.getKey(m)]}))));g.setState(m=>({accounts:M(M({},m.accounts||{}),y)}));}u.setState(y=>({recentChainIds:[...y.recentChainIds||[],...c].filter((m,C,h)=>h.indexOf(m)===C)})),g.setState(y=>({activeChainIds:[...y.activeChainIds||[],...c].filter((m,C,h)=>h.indexOf(m)===C)})),u.setState({walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(J,"Active");let d=c.map(y=>o.find(m=>m.chainId===y));return {accounts:g.getState().accounts,walletType:n,chains:d}}catch(i){throw console.error("connect ",i),g.getState().accounts===null&&g.setState({status:"disconnected"}),g.getState().accounts&&g.getState().activeChainIds&&g.setState({status:"connected"}),i}}),re=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(J);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let i=g.getState().accounts;t.forEach(r=>{i==null||delete i[r];}),Object.values(i||{}).length===0?(g.setState(ie),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(g.setState(r=>{var n;return {activeChainIds:(n=r.activeChainIds)==null?void 0:n.filter(a=>!t.includes(a)),accounts:i}}),u.setState(r=>{var n;return {recentChainIds:(n=r.recentChainIds)==null?void 0:n.filter(a=>!t.includes(a))}}));}else g.setState(ie),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},U=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:i,_reconnect:o}=u.getState();try{let n=L(i||void 0);if(t&&n&&i)return We(i)?void 0:yield Z({chainId:t,walletType:i,autoReconnect:o})}catch(n){(r=e==null?void 0:e.onError)==null||r.call(e,n),re();}}),Ct=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),i=e.walletType||t;if(!L(i))throw new Error(`${i} is not available`);let r=D(i),n=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:n,offlineSignerAmino:a,offlineSignerAuto:s}});var Re=()=>{u.setState({recentChainIds:null});},Cr=()=>u.getState().recentChainIds,Sr=()=>{var i;let{recentChainIds:e,chains:t}=u.getState();return (i=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?i:null},hr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(i=>i.chainId===e)},wr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},De=i=>l(void 0,[i],function*({chainInfo:e,walletType:t}){let o=D(t);return t==="capsule"?yield Z({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),St=e=>l(void 0,null,function*(){var o;let t=u.getState().walletType;return yield De({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield Z({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ht=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 wt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:i,amount:o,fee:r,memo:n}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,i,o,r,n)}),At=w=>l(void 0,[w],function*({signingClient:e,senderAddress:t,recipientAddress:i,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,i,o,r,n,a,s,c,f)}),It=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:i,fee:o,options:r,label:n,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,i,n,o,r)}),Ot=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:i,fee:o,contractAddress:r,funds:n,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,i,o,a,n)}),Et=(e,t,i)=>l(void 0,null,function*(){if(!i)throw new Error("CosmWasm client is not ready");return yield i.queryContractSmart(e,t)}),bt=(e,t,i)=>{if(!i)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return i.queryContractRaw(e,o)};var vr=e=>e,Pr=e=>e;var we=e=>e?Object.keys(e).length===0:!0;var Ke=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Tt=e=>globalThis.DOMException===void 0?new Ke(e):new DOMException(e),kt=e=>{let t=e.reason===void 0?Tt("This operation was aborted."):e.reason;return t instanceof Error?t:Tt(t)};function _e(n,a){return l(this,arguments,function*(e,t,{concurrency:i=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(i)||i===Number.POSITIVE_INFINITY)&&i>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`);let f=[],w=[],d=new Map,S=!1,y=!1,m=!1,C=0,h=0,x=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=b=>{S=!0,y=!0,c(b);};r&&(r.aborted&&p(kt(r)),r.addEventListener("abort",()=>{p(kt(r));}));let I=()=>l(this,null,function*(){if(y)return;let b=yield x.next(),W=h;if(h++,b.done){if(m=!0,C===0&&!y){if(!o&&w.length>0){p(new AggregateError(w));return}if(y=!0,d.size===0){s(f);return}let K=[];for(let[N,te]of f.entries())d.get(N)!==xt&&K.push(te);s(K);}return}C++,l(this,null,function*(){try{let K=yield b.value;if(y)return;let N=yield t(K,W);N===xt&&d.set(W,N),f[W]=N,C--,yield I();}catch(K){if(o)p(K);else {w.push(K),C--;try{yield I();}catch(N){p(N);}}}});});l(this,null,function*(){for(let b=0;b<i;b++){try{yield I();}catch(W){p(W);break}if(m||S)break}});})})}var xt=Symbol("skip");var q=({chainId:e,multiChain:t})=>{let i=u(r=>r.chains);if(!i)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>i.find(n=>n.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>i.find(n=>n.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return i;default:return [i[0]]}},z=(e,t,i)=>l(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let n=yield _e(t,i,{concurrency:o});return Object.fromEntries(n.map((a,s)=>[t[s].chainId,a]))}return yield i(t[0])}),Mt=(e,t,i)=>{if(e){let r=t.map(i);return Object.fromEntries(r.map((n,a)=>[t[a].chainId,n]))}return i(t[0])};var Le=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:i,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: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})},Ue=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:i,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: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})},Ae=({type:e,chainId:t,multiChain:i,enabled:o})=>{let r=q({chainId:t,multiChain:i}),n=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:n,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield z(!!i,s,w=>l(void 0,null,function*(){var C;let d=(C=u.getState().chainsConfig)==null?void 0:C[w.chainId],S={url:w.rpc,headers:M({},(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 os=()=>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),Ie=e=>{let i=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(i,({queryKey:[,r]})=>L(r))};var ee=e=>{let t=u(s=>s.walletType),i=g(s=>s.activeChainIds),o=q({chainId:e!=null&&e.chainId?e.chainId:i||void 0,multiChain:e==null?void 0:e.multiChain}),r=g(s=>s.accounts),n=g(s=>s.status);return useEffect(()=>g.subscribe(s=>s.status,(s,c)=>{var f,w,d;if(s==="connected"){let{accounts:S,activeChainIds:y}=g.getState(),{chains:m}=u.getState(),{walletType:C}=u.getState();if(!S||!y||!m)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(w=e==null?void 0:e.onConnect)==null||w.call(e,{accounts:S,chains:y.map(h=>m.find(x=>x.chainId===h)),walletType:C,isReconnect:c==="reconnecting"});}s==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:useMemo(()=>r?Mt(!!(e!=null&&e.multiChain),o,s=>r[s.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:n==="connected",isConnecting:n==="connecting",isDisconnected:n==="disconnected",isReconnecting:n==="reconnecting",isLoading:n==="connecting"||n==="reconnecting",walletType:n==="connected"?t:void 0,reconnect:U,status:n}},wn=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=ee(),o=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),{data:r}=Le({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),n=useMemo(()=>["USE_ALL_BALANCES",r,t,o,e==null?void 0:e.chainId],[o,e==null?void 0:e.chainId,t,r]);return useQuery(n,f=>l(void 0,[f],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 m;let S=a==null?void 0:a[d.chainId];if(!S)throw new Error(`Client is not ready ${d.chainId}`);if(!((m=d.bech32Config)!=null&&m.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield S.getAllBalances(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!o&&!!t&&t.length>0&&!we(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Cs=e=>{let t=q({chainId:e.chainId}),{data:i}=ee({chainId:e.chainId}),o=e.bech32Address||(i==null?void 0:i.bech32Address),{data:r,refetch:n}=wn({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,f]})=>f==null?void 0:f.find(w=>w.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return G(M({},s),{refetch:c=>l(void 0,null,function*(){return yield n(),s.refetch(c)})})},Ss=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation(["USE_CONNECT",e,t,i],Z,{onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))}),{data:n}=Ie();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!n,status:r.status}},hs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,i],re,{onError:n=>Promise.resolve(e==null?void 0:e(n,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(i==null?void 0:i(void 0))});return {disconnect:n=>r.mutate(n),disconnectAsync:n=>r.mutateAsync(n),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},ws=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(r=>r.walletType),o=useMemo(()=>["USE_OFFLINE_SIGNERS",t,i],[t,i]);return useQuery({queryKey:o,queryFn:a=>l(void 0,[a],function*({queryKey:[,r,n]}){if(r.length<1)throw new Error("No chain found");if(!L(n))throw new Error(`${n} is not available`);return yield z(!!(e!=null&&e.multiChain),r,f=>l(void 0,null,function*(){return yield Ct({chainId:f.chainId,walletType:n})}))}),enabled:!!t&&t.length>0&&!!i,refetchOnWindowFocus:!1})},As=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=ee(),{data:o}=Le({chainId:t.map(a=>a.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),n=useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return useQuery(n,f=>l(void 0,[f],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 y,m;if(!a)throw new Error("Client is not ready");if(!((y=d.bech32Config)!=null&&y.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (m=a[d.chainId])==null?void 0:m.getBalanceStaked(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var xs=()=>{let e=u(o=>o.capsuleState),t=g(o=>o.capsuleClient),i=le();return {setModalState:o=>{u.setState(r=>{var n;return {capsuleState:{showModal:o,chainId:(n=r.capsuleState)==null?void 0:n.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:i.onAfterLoginSuccessful,onLoginFailure:()=>{re();}}};var Ks=()=>g(e=>e.activeChainIds),An=()=>{var e;return (e=g(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let i=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(i)return i}).filter(Boolean)},_s=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(i=>i.chainId===e)},Ns=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},Bs=({denom:e})=>{let t=An();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var n;return (n=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:n.currencies.find(a=>a)})},Ls=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",i=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(i,s=>l(void 0,[s],function*({queryKey:[,n,a]}){if(!n)throw new Error("Query client is not defined");return yield n.staking.validators(a)}),{enabled:typeof e.queryClient!="undefined"})},Us=()=>({data:u(t=>t.recentChainIds),clear:Re}),qs=()=>{var t;return {data:(t=u(i=>i.recentChainIds))==null?void 0:t.map(i=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(n=>n.chainId===i);if(o)return o}).filter(Boolean),clear:Re}},Fs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,i],De,{onError:(n,a)=>Promise.resolve(e==null?void 0:e(n,a.chainInfo)),onMutate:n=>t==null?void 0:t(n.chainInfo),onSuccess:n=>Promise.resolve(i==null?void 0:i(n))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Gs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,i],St,{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(i==null?void 0:i(a))}),{data:n}=Ie();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!n,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Ys=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:o}=ee(),r=o==null?void 0:o.bech32Address,n=useMutation(["USE_SEND_TOKENS",e,t,i,r],a=>wt(M({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))});return {error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,sendTokens:n.mutate,sendTokensAsync:n.mutateAsync,status:n.status}},Js=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:o}=ee(),r=o==null?void 0:o.bech32Address,n=useMutation(["USE_SEND_IBC_TOKENS",e,t,i,r],a=>At(M({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))});return {error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,sendIbcTokens:n.mutate,sendIbcTokensAsync:n.mutateAsync,status:n.status}},Zs=({codeId:e,onError:t,onLoading:i,onSuccess:o})=>{let{data:r}=ee(),n=r==null?void 0:r.bech32Address,s=useMutation(["USE_INSTANTIATE_CONTRACT",t,i,o,e,n],c=>{var w;if(!n)throw new Error("senderAddress is undefined");let f=G(M({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:n,codeId:e});return It(f)},{onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:i,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}},ea=({contractAddress:e,onError:t,onLoading:i,onSuccess:o})=>{let{data:r}=ee(),n=r==null?void 0:r.bech32Address,s=useMutation(["USE_EXECUTE_CONTRACT",t,i,o,e,n],c=>{var w,d,S;if(!n)throw new Error("senderAddress is undefined");let f=G(M({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:n,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(S=c.funds)!=null?S:[]});return Ot(f)},{onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:i,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}},ta=e=>{let{data:t}=Ue();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 Et(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},na=e=>{let{data:t}=Ue(),i=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(i,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return bt(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function ga(e){let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(n=>n.walletType),o=g(n=>n.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),n,f=>l(this,null,function*(){var C,h;if(!(o!=null&&o.includes(f.chainId)))return null;if(!L(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(f.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(f.chainId);default:return D(a).getOfflineSignerAuto(f.chainId)}}))(),S=(C=u.getState().chainsConfig)==null?void 0:C[f.chainId],y={url:f.rpc,headers:M({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(y,d,e!=null&&e.multiChain?(h=e.opts)==null?void 0:h[f.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!i&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ya(e){let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(n=>n.walletType),o=g(n=>n.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),n,f=>l(this,null,function*(){var h,x;if(!(o!=null&&o.includes(f.chainId)))return null;if(!L(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(f.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(f.chainId);default:return D(a).getOfflineSignerAuto(f.chainId)}}))(),S=(h=u.getState().chainsConfig)==null?void 0:h[f.chainId],y={url:f.rpc,headers:M({},(S==null?void 0:S.rpcHeaders)||{})},m=S!=null&&S.gas?GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(y,d,M({gasPrice:m},e!=null&&e.multiChain?(x=e.opts)==null?void 0:x[f.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!i&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Ca(e){let t=q({chainId:e.chainId,multiChain:e.multiChain}),i=u(a=>a.walletType),o=g(a=>a.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]),{data:n}=Ae({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 C;if(!(o!=null&&o.includes(w.chainId)))return null;if(!L(s))throw new Error(`${s} is not available`);if(!n)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)}}))(),y=e.multiChain?n[w.chainId]:n;return yield SigningStargateClient.createWithSigner(y,S,e.multiChain?(C=e.opts)==null?void 0:C[w.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!i&&!!n&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Sa(e){let t=q({chainId:e.chainId,multiChain:e.multiChain}),i=u(s=>s.walletType),o=g(s=>s.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]),{data:n}=Ae({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=Ae({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:f=>l(this,[f],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 p,I;if(!(o!=null&&o.includes(d.chainId)))return null;if(!L(c))throw new Error(`${c} is not available`);let y=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)}}))(),m=(p=u.getState().chainsConfig)==null?void 0:p[d.chainId],C=m!=null&&m.gas?GasPrice.fromString(`${m.gas.price}${m.gas.denom}`):void 0,h=e.multiChain?a==null?void 0:a[d.chainId]:n;if(!h)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(h,y,M({gasPrice:C},e.multiChain?(I=e.opts)==null?void 0:I[d.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!i&&(!!n||!we(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Lt=({children:e})=>{let[t,i]=useState(!1);return useEffect(()=>{i(!0);},[]),jsx(Fragment,{children:t?e:null})};var kn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(J)==="Active",{_reconnect:t,_onReconnectFailed:i,_reconnectConnector:o,iframeOptions:r,chains:n}=u(),{activeChainIds:a,wcSignClients:s}=g(),c=L(o||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!n)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(w=>{if(w)return Z({chainId:n.map(d=>d.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(o){if(!c)return;e&&a?U({onError:i}):!e&&t&&U({onError:i});}},[c]),useEffect(()=>{var f,w,d,S,y,m,C,h,x,p,I,b,W,K,N,te,oe,A,O,E;if(o){if(!c)return;o==="cosmostation"&&((w=(f=me()).subscription)==null||w.call(f,()=>{U({onError:i});})),o==="keplr"&&((S=(d=de()).subscription)==null||S.call(d,()=>{U({onError:i});})),o==="leap"&&((m=(y=fe()).subscription)==null||m.call(y,()=>{U({onError:i});})),o==="compass"&&((h=(C=ue()).subscription)==null||h.call(C,()=>{U({onError:i});})),o==="vectis"&&((p=(x=Se()).subscription)==null||p.call(x,()=>{U({onError:i});})),o==="walletconnect"&&s.has("walletconnect")&&((b=(I=j()).subscription)==null||b.call(I,()=>{U({onError:i});})),o==="station"&&((K=(W=Ce()).subscription)==null||K.call(W,()=>{U({onError:i});})),o==="xdefi"&&((te=(N=he()).subscription)==null||te.call(N,()=>{U({onError:i});})),o==="cosmiframe"&&((A=(oe=pe()).subscription)==null||A.call(oe,()=>{U({onError:i});})),o==="okx"&&((E=(O=ye()).subscription)==null||E.call(O,()=>{U({onError:i});}));}},[o,s,c]),null},Ut=()=>(kn(),null);var Pn=new QueryClient({}),Ha=o=>{var r=o,{children:e,grazOptions:t}=r,i=Ve(r,["children","grazOptions"]);return useEffect(()=>{ht(t);},[t]),jsx(QueryClientProvider,G(M({client:Pn},i),{children:jsxs(Lt,{children:[e,jsx(Ut,{})]})}),"graz-provider")};
19
+ var Bt=Object.defineProperty,Lt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var ze=Object.getOwnPropertySymbols;var Ft=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable;var Qe=(e,t,i)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,v=(e,t)=>{for(var i in t||(t={}))Ft.call(t,i)&&Qe(e,i,t[i]);if(ze)for(var i of ze(t))qt.call(t,i)&&Qe(e,i,t[i]);return e},$=(e,t)=>Lt(e,Ut(t));var l=(e,t,i)=>new Promise((o,r)=>{var n=c=>{try{s(i.next(c));}catch(f){r(f);}},a=c=>{try{s(i.throw(c));}catch(f){r(f);}},s=c=>c.done?o(c.value):Promise.resolve(c.value).then(n,a);s((i=i.apply(e,t)).next());});var J="graz-reconnect-session";var je=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.CAPSULE="capsule",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p))(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","okx"];var zt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ie={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Qt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},jt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},g=create(subscribeWithSelector(persist(()=>ie,Qt))),u=create(subscribeWithSelector(persist(()=>zt,jt)));var ce=()=>{var C,y;if(!((C=u.getState().capsuleConfig)!=null&&C.apiKey)||!((y=u.getState().capsuleConfig)!=null&&y.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var h,M;let m=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,S=new m({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(M=u.getState().capsuleConfig)==null?void 0:M.env});return g.setState({capsuleClient:S}),S});return {init:e,enable:m=>l(void 0,null,function*(){let S=typeof m=="string"?[m]:m,h=g.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:S}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var p;let m=g.getState().capsuleClient,{chains:S}=u.getState();if(!m)throw new Error("Capsule client is not initialized");if(!S)throw new Error("Chains are not set");yield m.enable();let h=(p=u.getState().capsuleState)==null?void 0:p.chainId;if(!h)throw new Error("Chain ids are not set");let M=Object.fromEntries(yield Promise.all(h.map(I=>l(void 0,null,function*(){let b=yield m.getAccount(I);return [I,{address:fromBech32(b.address).data,bech32Address:b.address,algo:b.algo,name:b.username||"",pubKey:b.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));g.setState(I=>({accounts:v(v({},I.accounts||{}),M)})),u.setState(I=>({recentChainIds:[...I.recentChainIds||[],...h].filter((b,W,D)=>D.indexOf(b)===W)})),g.setState(I=>({activeChainIds:[...I.activeChainIds||[],...h].filter((b,W,D)=>D.indexOf(b)===W)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(J,"Active"),u.setState({capsuleState:null});}),getKey:m=>l(void 0,null,function*(){let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let h=yield S.getAccount(m);return {address:fromBech32(h.address).data,bech32Address:h.address,algo:h.algo,name:h.username||"",pubKey:h.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:m=>l(void 0,null,function*(){let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(m)}),getOfflineSignerDirect:m=>{let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(m)},signDirect:(...m)=>l(void 0,null,function*(){let[S,h,M]=m,p=g.getState().capsuleClient;if(!p)throw new Error("Capsule client is not initialized");return p.signDirect(S,h,{bodyBytes:M.bodyBytes,authInfoBytes:M.authInfoBytes,chainId:M.chainId,accountNumber:M.accountNumber})}),signAmino:(...m)=>l(void 0,null,function*(){let[S,h,M,p]=m,I=g.getState().capsuleClient;if(!I)throw new Error("Capsule client is not initialized");return I.signAmino(S,h,M,p)}),signArbitrary:(m,S,h)=>l(void 0,null,function*(){let M=g.getState().capsuleClient;if(!M)throw new Error("Capsule client is not initialized");let p=yield M.getAccount(m);if(!p)throw new Error(`Wallet not connected to account ${S}`);let I=(()=>{switch(p.algo){case"secp256k1":return encodeSecp256k1Pubkey(p.pubkey);case"ed25519":return encodeEd25519Pubkey(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield M.signArbitrary(m,S,h),pub_key:{type:p.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:I.value}}}),experimentalSuggestChain:(...m)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:m=>{let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSigner(m)},getOfflineSignerAmino:m=>{let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerAmino(m)}}};var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},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 n=yield e.request({method:"web3_clientVersion"});if(!n.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=n.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:n=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:n=>t.getOfflineSigner(n),experimentalSuggestChain:n=>l(void 0,null,function*(){if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain($(v({},n),{stakeCurrency:n.stakeCurrency,bech32Config:n.bech32Config}));}),signAmino:(n,a,s)=>l(void 0,null,function*(){return t.signAmino(n,a,s)}),getKey:n=>l(void 0,null,function*(){return typeof tt[n]!="undefined"?tt[n]:t.getKey(n)}),getOfflineSignerAuto:n=>l(void 0,null,function*(){return (yield t.getKey(n)).isNanoLedger?t.getOfflineSignerOnlyAmino(n):t.getOfflineSigner(n)}),getOfflineSignerOnlyAmino:n=>t.getOfflineSignerOnlyAmino(n),signDirect:(n,a,s)=>l(void 0,null,function*(){return t.signDirect(n,a,s)}),signArbitrary:(n,a,s)=>l(void 0,null,function*(){return t.signArbitrary(n,a,s)}),disable:n=>l(void 0,null,function*(){n&&(yield t.deleteChain(n));})};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:n=>{let a=()=>{B(),n();};return window.addEventListener("cosmostation_keystorechange",a),()=>{window.removeEventListener("cosmostation_keystorechange",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var nn=e=>{let{bodyBytes:t,authInfoBytes:i,chainId:o,accountNumber:r}=e;if(!t||!i||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:i,chainId:o,accountNumber:r}},on=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 C=e.getOfflineSigner(d),[y]=yield C.getAccounts();if(!y)throw new Error("Wallet connection failed");let m=(()=>{switch(y.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(y.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:on(y.address),algo:y.algo,pubKey:y.pubkey,bech32Address:y.address,address:m,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:d=>{let C=e.getOfflineSigner(d),y=e.getOfflineSignerOnlyAmino(d);return {getAccounts:C.getAccounts.bind(C),signDirect:C.signDirect.bind(C),signAmino:y.signAmino.bind(y)}},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(C=>{var y,m,S;return {denom:C.coinDenom,amount:C.coinMinimalDenom,low_gas_price:(y=C.gasPriceStep)==null?void 0:y.low,average_gas_price:(m=C.gasPriceStep)==null?void 0:m.average,high_gas_price:(S=C.gasPriceStep)==null?void 0:S.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[C,y,m]=d;return e.getOfflineSigner(C).signDirect(y,nn(m))},signAmino:(...d)=>{let[C,y,m]=d;return e.getOfflineSignerOnlyAmino(C).signAmino(y,m)},signArbitrary:(d,C,y)=>l(void 0,null,function*(){let h=(yield e.getOfflineSigner(d).getAccounts()).find(I=>I.address===C);if(!h)throw new Error(`Wallet not connected to account ${C}`);let M=(()=>{switch(h.algo){case"secp256k1":return encodeSecp256k1Pubkey(h.pubkey);case"ed25519":return encodeEd25519Pubkey(h.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(y),pub_key:{type:h.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:M.value}}}),subscription:d=>{let C=()=>{B(),d();};return window.addEventListener("initia_keystorechange",C),()=>{window.removeEventListener("initia_keystorechange",C);}}}}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 n=()=>{B(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}},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 n=()=>{B(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},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 i=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=p=>l(void 0,null,function*(){try{let I=yield i();return Object.values(I).find(b=>b.id===e.id&&(!p||b.version===p))}catch(I){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),n=()=>l(void 0,null,function*(){var N;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(N=p.split("MetaMask/v")[1])==null?void 0:N.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),a=p=>l(void 0,null,function*(){(yield o())||(yield r());}),s=(p,I,b)=>l(void 0,null,function*(){let W=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:I,signDoc:b}}}}),D=b.accountNumber,N=new lt(D.low,D.high,D.unsigned);return {signature:W.signature,signed:$(v({},W.signed),{accountNumber:`${N.toString()}`,authInfoBytes:new Uint8Array(Object.values(W.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(W.signed.bodyBytes))})}}),c=(p,I,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:I,signDoc:b}}}})}),f=p=>l(void 0,null,function*(){if(typeof fe[p]!="undefined")return fe[p];let I=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!I)throw new Error("No response from Metamask");return I.pubKey=Uint8Array.from(Object.values(I.pubkey)),delete I.pubkey,fe[p]=I,fe[p]}),w=p=>l(void 0,null,function*(){let I=yield f(p);return {address:I.bech32Address,algo:I.algo,pubkey:I.pubKey}}),d=(...p)=>l(void 0,null,function*(){let[I,b,W,D]=p;return yield c(I,b,W)}),C=(...p)=>l(void 0,null,function*(){let[I,b,W]=p;return yield s(I,b,W)}),m=p=>({getAccounts:()=>l(void 0,null,function*(){return [yield w(p)]}),signAmino:(I,b)=>d(p,I,b)});return {enable:a,experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield n(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:f,getOfflineSigner:p=>({getAccounts:()=>l(void 0,null,function*(){return [yield w(p)]}),signDirect:(I,b)=>C(p,I,b),signAmino:(I,b)=>d(p,I,b)}),getOfflineSignerAuto:p=>l(void 0,null,function*(){return m(p)}),getOfflineSignerOnlyAmino:m,init:n,signAmino:d,signDirect:C}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var st=()=>rt({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:n=>{var s;let a=()=>{B(),n();};return (s=window.okxwallet)==null||s.on("accountsChanged",a),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var ye=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:n=>{let a=()=>{B(),n();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:n=>l(void 0,null,function*(){let a=yield e.getKey(n);return v({isKeystone:!1},a)}),getOfflineSigner:n=>{try{let a=e.getOfflineSignerOnlyAmino(n);return Object.assign(a,{signDirect:(f,w)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:n=>l(void 0,null,function*(){try{if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");let a=Object.assign(n,{bech32Config:n.bech32Config,chainSymbolImageUrl:n.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:n.stakeCurrency.coinDecimals,coinDenom:n.stakeCurrency.coinDenom,coinImageUrl:n.stakeCurrency.coinImageUrl||"",coinMinimalDenom:n.stakeCurrency.coinMinimalDenom},currencies:n.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:n.feeCurrencies.map(s=>{var c,f,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:((f=s.gasPriceStep)==null?void 0:f.high)||0,low:((w=s.gasPriceStep)==null?void 0:w.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:n=>e.enable(n),disable:n=>e.disable(n),getOfflineSignerAuto:n=>e.getOfflineSignerAuto(n),getOfflineSignerOnlyAmino:n=>e.getOfflineSignerOnlyAmino(n),signDirect:()=>e.signDirect(),signAmino:(n,a,s,c)=>e.signAmino(n,a,s)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Se=()=>{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=()=>{B(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>{let c=s[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...s)=>l(void 0,null,function*(){var w;let[c]=s;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(w=c.bech32Config)==null?void 0:w.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...s)=>l(void 0,null,function*(){var w;let{1:c,2:f}=s;return e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:lt.fromString(((w=f.accountNumber)==null?void 0:w.toString())||"",!1),chainId:f.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:f}=s;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},at=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),ct=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var ke=(e,t,i=new Error("Promise timed out"))=>{let o=new Promise((r,n)=>{setTimeout(()=>{n(i);},t);});return Promise.race([e,o])};var Q=e=>{var N,te,oe;if(!((oe=(te=(N=u.getState().walletConnect)==null?void 0:N.options)==null?void 0:te.projectId)!=null&&oe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",i=(e==null?void 0:e.encoding)||"base64",o=A=>{if(!e)return;let{appUrl:O,formatNativeUrl:E}=e;if(z()){if(at()){let k=E(O.mobile.android,A,"android");window.open(k,"_self","noreferrer noopener");}if(ct()){let k=E(O.mobile.ios,A,"ios");window.open(k,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:A}=g.getState();if(!A.get(t))throw new Error("walletConnect.signClient is not defined");A.delete(t),g.setState({wcSignClients:A}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},n=A=>l(void 0,null,function*(){let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");if(!A)throw new Error("No wallet connect session");yield E.disconnect({topic:A,reason:getSdkError("USER_DISCONNECTED")}),yield c(E);}),a=A=>{try{let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let k=E.session.getAll(),R=k.at(-1);if(!R)return;if(!(R.expiry*1e3>Date.now()+1e3))throw n(R.topic),new Error("invalid session");try{let _=k.find(j=>{var X,Y;return (Y=(X=j.requiredNamespaces.cosmos)==null?void 0:X.chains)==null?void 0:Y.includes(`cosmos:${A}`)});if(!_)throw new Error("no session");return _}catch(_){if(!_.message.toLowerCase().includes("no matching key"))throw _}return R}catch(O){if(!O.message.toLowerCase().includes("no matching key"))throw O}},s=A=>{try{return a(A)}catch(O){return}},c=A=>l(void 0,null,function*(){try{let O=A.core.pairing.pairings.getAll({active:!1});if(!O.length)return;yield Promise.all(O.map(E=>l(void 0,null,function*(){yield A.core.pairing.pairings.delete(E.topic,{code:7001,message:"clear pairing"});})));}catch(O){if(!O.message.toLowerCase().includes("no matching key"))throw O}}),f=()=>l(void 0,null,function*(){let{walletConnect:A}=u.getState();if(!(A!=null&&A.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:O}=g.getState(),E=O.get(t);if(E)return E;let k=yield SignClient.init(A.options);return O.set(t,k),g.setState({wcSignClients:O}),k}),w=A=>{let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)return ()=>{};let k=R=>{let P=g.getState().accounts;if(R.params.event.name==="accountsChanged"&&P&&!Object.values(P).map(_=>_.bech32Address).includes(R.params.event.data[0])){let _=R.params.chainId.split(":")[1];_&&d([_]);}else A();};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=A=>l(void 0,null,function*(){var Y;let O=typeof A=="string"?[A]:A,{wcSignClients:E,activeChainIds:k}=g.getState(),R=E.get(t);if(!R)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:P,chains:_}=u.getState();if(!((Y=P==null?void 0:P.options)!=null&&Y.projectId))throw new Error("walletConnect.options.projectId is not defined");let j=new WalletConnectModal(v({projectId:P.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.walletConnectModal)),X=s(O);if(!X){let{uri:q,approval:se}=yield ke(R.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:O.map(V=>`cosmos:${V}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!q)throw new Error("No wallet connect uri");e?o(q):yield j.openModal({uri:q});let ae=V=>l(void 0,null,function*(){return V.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((xe,ne)=>{se().then(Fe=>{let qe=Fe.sessionProperties;if(!qe)return ne(new Error("No session properties"));let Me=JSON.parse(String(qe.keys));if(Me.length===0)return ne(new Error("No accounts"));if(!Me[0])return ne(new Error("No accounts"));let Ge={};return Me.forEach(H=>{Ge[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),g.setState(H=>({accounts:v(v({},H.accounts||{}),Ge)})),xe(Fe)}).catch(ne),V.addEventListener("abort",()=>{ne(new Error("User closed wallet connect"));},{once:!0});})});try{let V=new AbortController,xe=V.signal;j.subscribeModal(ne=>{ne.open||V.abort();}),yield ae(xe);}catch(V){if(j.closeModal(),!V.message.toLowerCase().includes("no matching key"))return Promise.reject(V)}return e||j.closeModal(),Promise.resolve()}try{yield ke((()=>l(void 0,null,function*(){var se;let q=Object.fromEntries(yield Promise.all((se=k||O)==null?void 0:se.map(ae=>l(void 0,null,function*(){return [ae,yield y(ae)]}))));g.setState({accounts:q});}))(),15e3,new Error("Connection timeout"));}catch(q){if(n(X.topic),!q.message.toLowerCase().includes("no matching key"))throw q}}),C=A=>l(void 0,null,function*(){let O=yield y(A);return {address:O.bech32Address,algo:O.algo,pubkey:O.pubKey}}),y=A=>l(void 0,null,function*(){let O=a([A]);if(!(O!=null&&O.topic))throw new Error("No wallet connect session");let E=O.sessionProperties&&JSON.parse(String(O.sessionProperties.keys));if(!E)throw new Error("No wallet connect key");if(E.length===0)throw new Error("No wallet connect session");let k=E.find(R=>R.chainId===A);if(!k)throw new Error(`No wallet connect key for chainId ${A}`);return $(v({},k),{pubKey:Buffer.from(String(k.pubKey),i)})}),m=(...A)=>l(void 0,null,function*(){var Y,q;let[O,E,k]=A,{accounts:R,wcSignClients:P}=g.getState(),_=P.get(t);if(!_)throw new Error("walletConnect.signClient is not defined");if(!R)throw new Error("account is not defined");let j=(Y=a([O]))==null?void 0:Y.topic;if(!j)throw new Error("No wallet connect session");if(!k.bodyBytes)throw new Error("No bodyBytes");if(!k.authInfoBytes)throw new Error("No authInfoBytes");return o(),yield _.request({topic:j,chainId:`cosmos:${O}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:{chainId:k.chainId,accountNumber:(q=k.accountNumber)==null?void 0:q.toString(),bodyBytes:k.bodyBytes?Buffer.from(k.bodyBytes).toString(i):null,authInfoBytes:k.authInfoBytes?Buffer.from(k.authInfoBytes).toString(i):null}}}})}),S=(...A)=>l(void 0,null,function*(){var _;let[O,E,k]=A,{signature:R,signed:P}=yield m(O,E,k);return {signed:{chainId:(_=P.chainId)!=null?_:"",accountNumber:P.accountNumber?lt.fromString(P.accountNumber):new lt(0),authInfoBytes:P.authInfoBytes?new Uint8Array(Buffer.from(P.authInfoBytes,i)):new Uint8Array([]),bodyBytes:P.bodyBytes?new Uint8Array(Buffer.from(P.bodyBytes,i)):new Uint8Array([])},signature:R}}),h=(...A)=>l(void 0,null,function*(){var q;let[O,E,k,R]=A,{wcSignClients:P}=g.getState(),_=P.get(t),{accounts:j}=g.getState();if(!_)throw new Error("walletConnect.signClient is not defined");if(!j)throw new Error("account is not defined");let X=(q=a([O]))==null?void 0:q.topic;if(!X)throw new Error("No wallet connect session");return o(),yield _.request({topic:X,chainId:`cosmos:${O}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:k}}})}),M=(...A)=>l(void 0,null,function*(){let[O,E,k,R]=A;return yield h(O,E,k)}),p=A=>({getAccounts:()=>l(void 0,null,function*(){return [yield C(A)]}),signDirect:(O,E)=>S(A,O,E)}),I=A=>({getAccounts:()=>l(void 0,null,function*(){return [yield C(A)]}),signAmino:(O,E)=>M(A,O,E)});return {enable:d,disable:A=>l(void 0,null,function*(){var k;let{wcSignClients:O}=g.getState(),E=O.get(t);if(A===void 0){let R=E==null?void 0:E.session.getAll();R!==void 0&&(yield Promise.all(R.map(P=>n(P.topic))));}else typeof A=="string"?yield n((k=a([A]))==null?void 0:k.topic):yield Promise.all(A.map(R=>{var P;return n((P=a([R]))==null?void 0:P.topic)}));(E==null?void 0:E.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...A)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:y,getOfflineSigner:A=>({getAccounts:()=>l(void 0,null,function*(){return [yield C(A)]}),signDirect:(O,E)=>S(A,O,E),signAmino:(O,E)=>M(A,O,E)}),getOfflineSignerAuto:A=>l(void 0,null,function*(){return (yield y(A)).isNanoLedger?I(A):p(A)}),getOfflineSignerOnlyAmino:I,signAmino:M,signDirect:S,subscription:w,init:f}};var ut=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.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,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return Q(e)};var pt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.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,n,a)=>{let s=r.replaceAll("/","").replaceAll(":","");return n?`${s}://wc?${n}`:`${s}://wc`}};return Q(e)};var mt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.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,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${s}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return Q(e)};var dt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.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,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${s}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};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 n=()=>{B(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var L=(e=u.getState().walletType)=>{try{return K(e),!0}catch(t){return !1}},B=()=>{window.sessionStorage.removeItem(J),g.setState(ie);},K=(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 Se();case"walletconnect":return Q();case"wc_keplr_mobile":return mt();case"wc_leap_mobile":return dt();case"wc_cosmostation_mobile":return pt();case"wc_clot_mobile":return ut();case"metamask_snap_leap":return st();case"metamask_snap_cosmos":return nt();case"station":return ye();case"xdefi":return Ce();case"capsule":return ce();case"cosmiframe":return ue();case"compass":return le();case"initia":return ot();case"okx":return ge();default:throw new Error("Unknown wallet type")}})(),i=u.getState().walletDefaultOptions;return i&&((o=t.setDefaultOptions)==null||o.call(t,i)),t},tr=()=>Object.fromEntries($e.map(e=>[e,L(e)])),ve=e=>e==="capsule",Pe=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Z=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:i,chains:o,walletType:r}=u.getState(),n=(e==null?void 0:e.walletType)||r;if(!L(n))throw new Error(`${n} is not available`);let s=K(n),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||i;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let f=o==null?void 0:o.map(y=>y.chainId);c.forEach(y=>{if(!(f!=null&&f.includes(y)))throw new Error(`Chain ${y} is not provided in GrazProvider`)}),g.setState(y=>{let m=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return y.activeChainIds&&c.filter(h=>{var M;return !((M=y.activeChainIds)!=null&&M.includes(h))}).length>0?{status:"connecting"}:m?{status:"reconnecting"}:{status:"connecting"}});let{accounts:w}=g.getState();if(yield (t=s.init)==null?void 0:t.call(s),ve(n)&&g.getState().capsuleClient&&Object.values(g.getState().accounts||[]).length>0){let y=c.map(h=>o.find(M=>M.chainId===h)),m=g.getState().accounts;g.setState({status:"connecting"});let S=Object.fromEntries(yield Promise.all(c.map(h=>l(void 0,null,function*(){return [h,yield s.getKey(h)]}))));return g.setState(h=>({accounts:v(v({},h.accounts||{}),S)})),u.setState(h=>({recentChainIds:[...h.recentChainIds||[],...c].filter((M,p,I)=>I.indexOf(M)===p)})),g.setState(h=>({activeChainIds:[...h.activeChainIds||[],...c].filter((M,p,I)=>I.indexOf(M)===p)})),g.setState({status:"connected"}),{accounts:m,walletType:n,chains:y}}if(yield s.enable(c),ve(n)){let y=c.map(S=>o.find(h=>h.chainId===S)),m=g.getState().accounts;return g.setState({status:"connecting"}),{accounts:m,walletType:n,chains:y}}if(!Pe(n)){let y=Object.fromEntries(yield Promise.all(c.map(m=>l(void 0,null,function*(){return [m,yield s.getKey(m)]}))));g.setState(m=>({accounts:v(v({},m.accounts||{}),y)}));}u.setState(y=>({recentChainIds:[...y.recentChainIds||[],...c].filter((m,S,h)=>h.indexOf(m)===S)})),g.setState(y=>({activeChainIds:[...y.activeChainIds||[],...c].filter((m,S,h)=>h.indexOf(m)===S)})),u.setState({walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(J,"Active");let d=c.map(y=>o.find(m=>m.chainId===y));return {accounts:g.getState().accounts,walletType:n,chains:d}}catch(i){throw console.error("connect ",i),g.getState().accounts===null&&g.setState({status:"disconnected"}),g.getState().accounts&&g.getState().activeChainIds&&g.setState({status:"connected"}),i}}),re=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(J);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let i=g.getState().accounts;t.forEach(r=>{i==null||delete i[r];}),Object.values(i||{}).length===0?(g.setState(ie),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(g.setState(r=>{var n;return {activeChainIds:(n=r.activeChainIds)==null?void 0:n.filter(a=>!t.includes(a)),accounts:i}}),u.setState(r=>{var n;return {recentChainIds:(n=r.recentChainIds)==null?void 0:n.filter(a=>!t.includes(a))}}));}else g.setState(ie),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},U=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:i,_reconnect:o}=u.getState();try{let n=L(i||void 0);if(t&&n&&i)return Pe(i)?void 0:yield Z({chainId:t,walletType:i,autoReconnect:o})}catch(n){(r=e==null?void 0:e.onError)==null||r.call(e,n),re();}}),ft=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),i=e.walletType||t;if(!L(i))throw new Error(`${i} is not available`);let r=K(i),n=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:n,offlineSignerAmino:a,offlineSignerAuto:s}});var We=()=>{u.setState({recentChainIds:null});},dr=()=>u.getState().recentChainIds,fr=()=>{var i;let{recentChainIds:e,chains:t}=u.getState();return (i=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?i:null},gr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(i=>i.chainId===e)},yr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},Re=i=>l(void 0,[i],function*({chainInfo:e,walletType:t}){let o=K(t);return t==="capsule"?yield Z({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 Re({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield Z({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:i,amount:o,fee:r,memo:n}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,i,o,r,n)}),Ct=w=>l(void 0,[w],function*({signingClient:e,senderAddress:t,recipientAddress:i,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,i,o,r,n,a,s,c,f)}),ht=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:i,fee:o,options:r,label:n,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,i,n,o,r)}),wt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:i,fee:o,contractAddress:r,funds:n,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,i,o,a,n)}),At=(e,t,i)=>l(void 0,null,function*(){if(!i)throw new Error("CosmWasm client is not ready");return yield i.queryContractSmart(e,t)}),It=(e,t,i)=>{if(!i)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return i.queryContractRaw(e,o)};var Tr=e=>e,xr=e=>e;var he=e=>e?Object.keys(e).length===0:!0;var Ke=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Ot=e=>globalThis.DOMException===void 0?new Ke(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 De(n,a){return l(this,arguments,function*(e,t,{concurrency:i=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(i)||i===Number.POSITIVE_INFINITY)&&i>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`);let f=[],w=[],d=new Map,C=!1,y=!1,m=!1,S=0,h=0,M=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=b=>{C=!0,y=!0,c(b);};r&&(r.aborted&&p(Et(r)),r.addEventListener("abort",()=>{p(Et(r));}));let I=()=>l(this,null,function*(){if(y)return;let b=yield M.next(),W=h;if(h++,b.done){if(m=!0,S===0&&!y){if(!o&&w.length>0){p(new AggregateError(w));return}if(y=!0,d.size===0){s(f);return}let D=[];for(let[N,te]of f.entries())d.get(N)!==bt&&D.push(te);s(D);}return}S++,l(this,null,function*(){try{let D=yield b.value;if(y)return;let N=yield t(D,W);N===bt&&d.set(W,N),f[W]=N,S--,yield I();}catch(D){if(o)p(D);else {w.push(D),S--;try{yield I();}catch(N){p(N);}}}});});l(this,null,function*(){for(let b=0;b<i;b++){try{yield I();}catch(W){p(W);break}if(m||C)break}});})})}var bt=Symbol("skip");var F=({chainId:e,multiChain:t})=>{let i=u(r=>r.chains);if(!i)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>i.find(n=>n.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>i.find(n=>n.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return i;default:return [i[0]]}},G=(e,t,i)=>l(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let n=yield De(t,i,{concurrency:o});return Object.fromEntries(n.map((a,s)=>[t[s].chainId,a]))}return yield i(t[0])}),Tt=(e,t,i)=>{if(e){let r=t.map(i);return Object.fromEntries(r.map((n,a)=>[t[a].chainId,n]))}return i(t[0])};var Be=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:i,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:v({},(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})},Le=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:i,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:v({},(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})},we=({type:e,chainId:t,multiChain:i,enabled:o})=>{let r=F({chainId:t,multiChain:i}),n=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:n,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield G(!!i,s,w=>l(void 0,null,function*(){var S;let d=(S=u.getState().chainsConfig)==null?void 0:S[w.chainId],C={url:w.rpc,headers:v({},(d==null?void 0:d.rpcHeaders)||{})};return yield (a==="tm37"?Tendermint37Client:Tendermint34Client).connect(C)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var es=()=>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),Ae=e=>{let i=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery({queryKey:i,queryFn:({queryKey:[,r]})=>L(r)})};var ee=e=>{let t=u(s=>s.walletType),i=g(s=>s.activeChainIds),o=F({chainId:e!=null&&e.chainId?e.chainId:i||void 0,multiChain:e==null?void 0:e.multiChain}),r=g(s=>s.accounts),n=g(s=>s.status);return useEffect(()=>g.subscribe(s=>s.status,(s,c)=>{var f,w,d;if(s==="connected"){let{accounts:C,activeChainIds:y}=g.getState(),{chains:m}=u.getState(),{walletType:S}=u.getState();if(!C||!y||!m)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(w=e==null?void 0:e.onConnect)==null||w.call(e,{accounts:C,chains:y.map(h=>m.find(M=>M.chainId===h)),walletType:S,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:n==="connected",isConnecting:n==="connecting",isDisconnected:n==="disconnected",isReconnecting:n==="reconnecting",isLoading:n==="connecting"||n==="reconnecting",walletType:n==="connected"?t:void 0,reconnect:U,status:n}},Cn=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=ee(),o=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),{data:r}=Be({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),n=useMemo(()=>["USE_ALL_BALANCES",r,t,o,e==null?void 0:e.chainId],[o,e==null?void 0:e.chainId,t,r]);return useQuery({queryKey:n,queryFn:f=>l(void 0,[f],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 m;let C=a==null?void 0:a[d.chainId];if(!C)throw new Error(`Client is not ready ${d.chainId}`);if(!((m=d.bech32Config)!=null&&m.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield C.getAllBalances(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!o&&!!t&&t.length>0&&!he(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ds=e=>{let t=F({chainId:e.chainId}),{data:i}=ee({chainId:e.chainId}),o=e.bech32Address||(i==null?void 0:i.bech32Address),{data:r,refetch:n}=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=useQuery({queryKey:a,queryFn:({queryKey:[,c,f]})=>f==null?void 0:f.find(w=>w.denom===c),enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return $(v({},s),{refetch:c=>l(void 0,null,function*(){return yield n(),s.refetch(c)})})},fs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation({mutationKey:["USE_CONNECT",e,t,i],mutationFn:Z,onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))}),{data:n}=Ae();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,isSupported:!!n,status:r.status}},gs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation({mutationKey:["USE_DISCONNECT",e,t,i],mutationFn:re,onError:n=>Promise.resolve(e==null?void 0:e(n,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(i==null?void 0:i(void 0))});return {disconnect:n=>r.mutate(n),disconnectAsync:n=>r.mutateAsync(n),error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,status:r.status}},ys=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(r=>r.walletType),o=useMemo(()=>["USE_OFFLINE_SIGNERS",t,i],[t,i]);return useQuery({queryKey:o,queryFn:a=>l(void 0,[a],function*({queryKey:[,r,n]}){if(r.length<1)throw new Error("No chain found");if(!L(n))throw new Error(`${n} is not available`);return yield G(!!(e!=null&&e.multiChain),r,f=>l(void 0,null,function*(){return yield ft({chainId:f.chainId,walletType:n})}))}),enabled:!!t&&t.length>0&&!!i,refetchOnWindowFocus:!1})},Ss=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=ee(),{data:o}=Be({chainId:t.map(a=>a.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),n=useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return useQuery({queryKey:n,queryFn:f=>l(void 0,[f],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 y,m;if(!a)throw new Error("Client is not ready");if(!((y=d.bech32Config)!=null&&y.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (m=a[d.chainId])==null?void 0:m.getBalanceStaked(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Es=()=>{let e=u(o=>o.capsuleState),t=g(o=>o.capsuleClient),i=ce();return {setModalState:o=>{u.setState(r=>{var n;return {capsuleState:{showModal:o,chainId:(n=r.capsuleState)==null?void 0:n.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:i.onAfterLoginSuccessful,onLoginFailure:()=>{re();}}};var Ps=()=>g(e=>e.activeChainIds),hn=()=>{var e;return (e=g(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let i=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(i)return i}).filter(Boolean)},Ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(i=>i.chainId===e)},Rs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},Ks=({denom:e})=>{let t=hn();return useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,r]})=>{var n;return (n=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:n.currencies.find(a=>a)}})},Ds=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",i=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery({queryKey:i,queryFn:s=>l(void 0,[s],function*({queryKey:[,n,a]}){if(!n)throw new Error("Query client is not defined");return yield n.staking.validators(a)}),enabled:typeof e.queryClient!="undefined"})},_s=()=>({data:u(t=>t.recentChainIds),clear:We}),Ns=()=>{var t;return {data:(t=u(i=>i.recentChainIds))==null?void 0:t.map(i=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(n=>n.chainId===i);if(o)return o}).filter(Boolean),clear:We}},Bs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,i],mutationFn:Re,onError:(n,a)=>Promise.resolve(e==null?void 0:e(n,a.chainInfo)),onMutate:n=>t==null?void 0:t(n.chainInfo),onSuccess:n=>Promise.resolve(i==null?void 0:i(n))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Ls=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,i],mutationFn: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(i==null?void 0:i(a))}),{data:n}=Ae();return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,isSupported:!!n,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var $s=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:o}=ee(),r=o==null?void 0:o.bech32Address,n=useMutation({mutationKey:["USE_SEND_TOKENS",e,t,i,r],mutationFn:a=>St(v({senderAddress:r},a)),onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendTokens:n.mutate,sendTokensAsync:n.mutateAsync,status:n.status}},Vs=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:o}=ee(),r=o==null?void 0:o.bech32Address,n=useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,i,r],mutationFn:a=>Ct(v({senderAddress:r},a)),onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendIbcTokens:n.mutate,sendIbcTokensAsync:n.mutateAsync,status:n.status}},Hs=({codeId:e,onError:t,onLoading:i,onSuccess:o})=>{let{data:r}=ee(),n=r==null?void 0:r.bech32Address,s=useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,i,o,e,n],mutationFn:c=>{var w;if(!n)throw new Error("senderAddress is undefined");let f=$(v({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:n,codeId:e});return ht(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:i,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Xs=({contractAddress:e,onError:t,onLoading:i,onSuccess:o})=>{let{data:r}=ee(),n=r==null?void 0:r.bech32Address,s=useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,i,o,e,n],mutationFn:c=>{var w,d,C;if(!n)throw new Error("senderAddress is undefined");let f=$(v({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:n,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(C=c.funds)!=null?C:[]});return wt(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:i,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},Ys=e=>{let{data:t}=Le();return useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({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}=Le(),i=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery({queryKey:i,queryFn:({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 pa(e){let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(n=>n.walletType),o=g(n=>n.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),n,f=>l(this,null,function*(){var S,h;if(!(o!=null&&o.includes(f.chainId)))return null;if(!L(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 K(a).getOfflineSigner(f.chainId);case"offlineSignerAuto":return K(a).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return K(a).getOfflineSignerOnlyAmino(f.chainId);default:return K(a).getOfflineSignerAuto(f.chainId)}}))(),C=(S=u.getState().chainsConfig)==null?void 0:S[f.chainId],y={url:f.rpc,headers:v({},(C==null?void 0:C.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(y,d,e!=null&&e.multiChain?(h=e.opts)==null?void 0:h[f.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!i&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ma(e){let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(n=>n.walletType),o=g(n=>n.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),n,f=>l(this,null,function*(){var h,M;if(!(o!=null&&o.includes(f.chainId)))return null;if(!L(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 K(a).getOfflineSigner(f.chainId);case"offlineSignerAuto":return K(a).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return K(a).getOfflineSignerOnlyAmino(f.chainId);default:return K(a).getOfflineSignerAuto(f.chainId)}}))(),C=(h=u.getState().chainsConfig)==null?void 0:h[f.chainId],y={url:f.rpc,headers:v({},(C==null?void 0:C.rpcHeaders)||{})},m=C!=null&&C.gas?GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(y,d,v({gasPrice:m},e!=null&&e.multiChain?(M=e.opts)==null?void 0:M[f.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!i&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function da(e){let t=F({chainId:e.chainId,multiChain:e.multiChain}),i=u(a=>a.walletType),o=g(a=>a.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]),{data:n}=we({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,w=>l(this,null,function*(){var S;if(!(o!=null&&o.includes(w.chainId)))return null;if(!L(s))throw new Error(`${s} is not available`);if(!n)throw new Error("No tendermint client found");let C=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return K(s).getOfflineSigner(w.chainId);case"offlineSignerAuto":return K(s).getOfflineSignerAuto(w.chainId);case"offlineSignerOnlyAmino":return K(s).getOfflineSignerOnlyAmino(w.chainId);default:return K(s).getOfflineSignerAuto(w.chainId)}}))(),y=e.multiChain?n[w.chainId]:n;return yield SigningStargateClient.createWithSigner(y,C,e.multiChain?(S=e.opts)==null?void 0:S[w.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!i&&!!n&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function fa(e){let t=F({chainId:e.chainId,multiChain:e.multiChain}),i=u(s=>s.walletType),o=g(s=>s.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]),{data:n}=we({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=we({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:f=>l(this,[f],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 p,I;if(!(o!=null&&o.includes(d.chainId)))return null;if(!L(c))throw new Error(`${c} is not available`);let y=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return K(c).getOfflineSigner(d.chainId);case"offlineSignerAuto":return K(c).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return K(c).getOfflineSignerOnlyAmino(d.chainId);default:return K(c).getOfflineSignerAuto(d.chainId)}}))(),m=(p=u.getState().chainsConfig)==null?void 0:p[d.chainId],S=m!=null&&m.gas?GasPrice.fromString(`${m.gas.price}${m.gas.denom}`):void 0,h=e.multiChain?a==null?void 0:a[d.chainId]:n;if(!h)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(h,y,v({gasPrice:S},e.multiChain?(I=e.opts)==null?void 0:I[d.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!i&&(!!n||!he(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var _t=({children:e})=>{let[t,i]=useState(!1);return useEffect(()=>{i(!0);},[]),jsx(Fragment,{children:t?e:null})};var bn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(J)==="Active",{_reconnect:t,_onReconnectFailed:i,_reconnectConnector:o,iframeOptions:r,chains:n}=u(),{activeChainIds:a,wcSignClients:s}=g(),c=L(o||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!n)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(w=>{if(w)return Z({chainId:n.map(d=>d.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(o){if(!c)return;e&&a?U({onError:i}):!e&&t&&U({onError:i});}},[c]),useEffect(()=>{var f,w,d,C,y,m,S,h,M,p,I,b,W,D,N,te,oe,A,O,E;if(o){if(!c)return;o==="cosmostation"&&((w=(f=pe()).subscription)==null||w.call(f,()=>{U({onError:i});})),o==="keplr"&&((C=(d=me()).subscription)==null||C.call(d,()=>{U({onError:i});})),o==="leap"&&((m=(y=de()).subscription)==null||m.call(y,()=>{U({onError:i});})),o==="compass"&&((h=(S=le()).subscription)==null||h.call(S,()=>{U({onError:i});})),o==="vectis"&&((p=(M=Se()).subscription)==null||p.call(M,()=>{U({onError:i});})),o==="walletconnect"&&s.has("walletconnect")&&((b=(I=Q()).subscription)==null||b.call(I,()=>{U({onError:i});})),o==="station"&&((D=(W=ye()).subscription)==null||D.call(W,()=>{U({onError:i});})),o==="xdefi"&&((te=(N=Ce()).subscription)==null||te.call(N,()=>{U({onError:i});})),o==="cosmiframe"&&((A=(oe=ue()).subscription)==null||A.call(oe,()=>{U({onError:i});})),o==="okx"&&((E=(O=ge()).subscription)==null||E.call(O,()=>{U({onError:i});}));}},[o,s,c]),null},Nt=()=>(bn(),null);var za=({children:e,grazOptions:t})=>(useEffect(()=>{yt(t);},[t]),jsxs(_t,{children:[e,jsx(Nt,{})]}));
20
20
 
21
- export { Ut as GrazEvents, Ha as GrazProvider, Xe as WALLET_TYPES, He as WalletType, L as checkWallet, Re as clearRecentChain, B as clearSession, ht as configureGraz, Z as connect, Pr as defineChainInfo, vr as defineChains, re as disconnect, Ot as executeContract, rr as getAvailableWallets, hr as getChainInfo, wr as getChainInfos, me as getCosmostation, de as getKeplr, fe as getLeap, lt as getMetamaskSnapLeap, Ct as getOfflineSigners, bt as getQueryRaw, Et as getQuerySmart, Cr as getRecentChainIds, Sr as getRecentChains, Se as getVectis, ft as getWCCosmostation, gt as getWCKeplr, yt as getWCLeap, D as getWallet, j as getWalletConnect, It as instantiateContract, Pe as isCapsule, We as isWalletConnect, U as reconnect, At as sendIbcTokens, wt as sendTokens, De as suggestChain, St as suggestChainAndConnect, ee as useAccount, Bs as useActiveChainCurrency, Ks as useActiveChainIds, An as useActiveChains, os as useActiveWalletType, Cs as useBalance, As as useBalanceStaked, wn as useBalances, xs as useCapsule, _s as useChainInfo, Ns as useChainInfos, Ie as useCheckWallet, Ss as useConnect, Ue as useCosmWasmClient, ya as useCosmWasmSigningClient, Sa as useCosmWasmTmSigningClient, hs as useDisconnect, ea as useExecuteContract, kn as useGrazEvents, Zs as useInstantiateContract, ws as useOfflineSigners, Ls as useQueryClientValidators, na as useQueryRaw, ta as useQuerySmart, Us as useRecentChainIds, qs as useRecentChains, Js as useSendIbcTokens, Ys as useSendTokens, Le as useStargateClient, ga as useStargateSigningClient, Ca as useStargateTmSigningClient, Fs as useSuggestChain, Gs as useSuggestChainAndConnect, Ae as useTendermintClient };
21
+ export { Nt as GrazEvents, za as GrazProvider, $e as WALLET_TYPES, je as WalletType, L as checkWallet, We as clearRecentChain, B as clearSession, yt as configureGraz, Z as connect, xr as defineChainInfo, Tr as defineChains, re as disconnect, wt as executeContract, tr as getAvailableWallets, gr as getChainInfo, yr as getChainInfos, pe as getCosmostation, me as getKeplr, de as getLeap, st as getMetamaskSnapLeap, ft as getOfflineSigners, It as getQueryRaw, At as getQuerySmart, dr as getRecentChainIds, fr as getRecentChains, Se as getVectis, pt as getWCCosmostation, mt as getWCKeplr, dt as getWCLeap, K as getWallet, Q as getWalletConnect, ht as instantiateContract, ve as isCapsule, Pe as isWalletConnect, U as reconnect, Ct as sendIbcTokens, St as sendTokens, Re as suggestChain, gt as suggestChainAndConnect, ee as useAccount, Ks as useActiveChainCurrency, Ps as useActiveChainIds, hn as useActiveChains, es as useActiveWalletType, ds as useBalance, Ss as useBalanceStaked, Cn as useBalances, Es as useCapsule, Ws as useChainInfo, Rs as useChainInfos, Ae as useCheckWallet, fs as useConnect, Le as useCosmWasmClient, ma as useCosmWasmSigningClient, fa as useCosmWasmTmSigningClient, gs as useDisconnect, Xs as useExecuteContract, bn as useGrazEvents, Hs as useInstantiateContract, ys as useOfflineSigners, Ds as useQueryClientValidators, Js as useQueryRaw, Ys as useQuerySmart, _s as useRecentChainIds, Ns as useRecentChains, Vs as useSendIbcTokens, $s as useSendTokens, Be as useStargateClient, pa as useStargateSigningClient, da as useStargateTmSigningClient, Bs as useSuggestChain, Ls as useSuggestChainAndConnect, we 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.31",
4
+ "version": "0.2.0-alpha.0",
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",
@@ -33,6 +33,14 @@
33
33
  "env.d.ts"
34
34
  ],
35
35
  "sideEffects": false,
36
+ "scripts": {
37
+ "build": "tsup",
38
+ "clean": "rm -rf dist/*",
39
+ "cli": "node dist/cli.js",
40
+ "dev": "tsup --watch",
41
+ "lint": "eslint --fix \"src/**/*.{ts,tsx}\"",
42
+ "prepublishOnly": "pnpm build"
43
+ },
36
44
  "peerDependencies": {
37
45
  "@cosmjs/amino": "<=0.31.3",
38
46
  "@cosmjs/cosmwasm-stargate": "<=0.31.3",
@@ -41,6 +49,7 @@
41
49
  "@cosmjs/stargate": "<=0.31.3",
42
50
  "@cosmjs/tendermint-rpc": "<=0.31.3",
43
51
  "@leapwallet/cosmos-social-login-capsule-provider": "^0.0.41",
52
+ "@tanstack/react-query": ">=5.62.0",
44
53
  "react": ">=17"
45
54
  },
46
55
  "dependencies": {
@@ -49,7 +58,6 @@
49
58
  "@dao-dao/cosmiframe": "0.1.0",
50
59
  "@keplr-wallet/cosmos": "0.12.156",
51
60
  "@metamask/providers": "12.0.0",
52
- "@tanstack/react-query": "4.35.0",
53
61
  "@terra-money/station-connector": "1.1.0",
54
62
  "@vectis/extension-client": "^0.7.2",
55
63
  "@walletconnect/sign-client": "2.17.2",
@@ -77,12 +85,5 @@
77
85
  "graz-sh",
78
86
  "use-keplr"
79
87
  ],
80
- "license": "MIT",
81
- "scripts": {
82
- "build": "tsup",
83
- "clean": "rm -rf dist/*",
84
- "cli": "node dist/cli.js",
85
- "dev": "tsup --watch",
86
- "lint": "eslint --fix \"src/**/*.{ts,tsx}\""
87
- }
88
- }
88
+ "license": "MIT"
89
+ }