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