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