graz 0.0.46 → 0.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -165,13 +165,16 @@ declare enum WalletType {
165
165
  WALLETCONNECT = "walletconnect",
166
166
  WC_KEPLR_MOBILE = "wc_keplr_mobile",
167
167
  WC_LEAP_MOBILE = "wc_leap_mobile",
168
- WC_COSMOSTATION_MOBILE = "wc_cosmostation_mobile"
168
+ WC_COSMOSTATION_MOBILE = "wc_cosmostation_mobile",
169
+ METAMASK_SNAP_LEAP = "metamask_snap_leap"
169
170
  }
170
171
  declare const WALLET_TYPES: WalletType[];
171
172
  type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOfflineSignerAuto" | "getOfflineSignerOnlyAmino" | "experimentalSuggestChain" | "signDirect" | "signAmino"> & {
172
173
  subscription?: (reconnect: () => void) => void;
173
174
  init?: () => Promise<unknown>;
174
175
  };
176
+ type SignDirectParams = Parameters<Wallet["signDirect"]>;
177
+ type SignAminoParams = Parameters<Wallet["signAmino"]>;
175
178
 
176
179
  type ConnectArgs = Maybe<{
177
180
  chain?: GrazChain;
@@ -311,6 +314,38 @@ declare const getQueryRaw: (address: string, keyStr: string, client?: CosmWasmCl
311
314
  * ```
312
315
  */
313
316
  declare const checkWallet: (type?: WalletType) => boolean;
317
+ declare const clearSession: () => void;
318
+ /**
319
+ * Function to return wallet object based on given {@link WalletType} or from store and throws an error if it does not
320
+ * exist on `window` or unknown wallet type.
321
+ *
322
+ * @example
323
+ * ```ts
324
+ * const wallet = getWallet();
325
+ * const keplr = getWallet("keplr");
326
+ * ```
327
+ *
328
+ * @see {@link getKeplr}
329
+ */
330
+ declare const getWallet: (type?: WalletType) => Wallet;
331
+ declare const getAvailableWallets: () => Record<WalletType, boolean>;
332
+
333
+ /**
334
+ * Function to return cosmostation object (which is {@link Wallet}) and throws and error if it does not exist on `window`.
335
+ *
336
+ * @example
337
+ * ```ts
338
+ * try {
339
+ * const cosmostation = getCosmostation();
340
+ * } catch (error: Error) {
341
+ * console.error(error.message);
342
+ * }
343
+ * ```
344
+ *
345
+ * @see https://docs.cosmostation.io/integration-extension/cosmos/integrate-keplr
346
+ */
347
+ declare const getCosmostation: () => Wallet;
348
+
314
349
  /**
315
350
  * Function to return {@link Wallet} object and throws and error if it does not exist on `window`.
316
351
  *
@@ -326,6 +361,7 @@ declare const checkWallet: (type?: WalletType) => boolean;
326
361
  * @see https://docs.keplr.app
327
362
  */
328
363
  declare const getKeplr: () => Wallet;
364
+
329
365
  /**
330
366
  * Function to return Leap object (which is {@link Wallet}) and throws and error if it does not exist on `window`.
331
367
  *
@@ -341,21 +377,23 @@ declare const getKeplr: () => Wallet;
341
377
  * @see https://docs.leapwallet.io/cosmos/for-dapps-connect-to-leap/add-leap-to-existing-keplr-integration
342
378
  */
343
379
  declare const getLeap: () => Wallet;
380
+
344
381
  /**
345
- * Function to return cosmostation object (which is {@link Wallet}) and throws and error if it does not exist on `window`.
382
+ * Function to return {@link Wallet} object and throws and error if it does not exist on `window`.
346
383
  *
347
384
  * @example
348
385
  * ```ts
349
386
  * try {
350
- * const cosmostation = getCosmostation();
387
+ * const leapMetamaskSnap = getMetamaskSnapLeap();
351
388
  * } catch (error: Error) {
352
389
  * console.error(error.message);
353
390
  * }
354
391
  * ```
355
392
  *
356
- * @see https://docs.cosmostation.io/integration-extension/cosmos/integrate-keplr
393
+ *
357
394
  */
358
- declare const getCosmostation: () => Wallet;
395
+ declare const getMetamaskSnapLeap: () => Wallet;
396
+
359
397
  /**
360
398
  * Function to return {@link Wallet} object and throws and error if it does not exist on `window`.
361
399
  *
@@ -371,6 +409,7 @@ declare const getCosmostation: () => Wallet;
371
409
  *
372
410
  */
373
411
  declare const getVectis: () => Wallet;
412
+
374
413
  interface GetWalletConnectParams {
375
414
  encoding: BufferEncoding;
376
415
  walletType: WalletType.WC_KEPLR_MOBILE | WalletType.WC_LEAP_MOBILE;
@@ -382,24 +421,14 @@ interface GetWalletConnectParams {
382
421
  };
383
422
  formatNativeUrl: (appUrl: string, wcUri: string, os?: "android" | "ios") => string;
384
423
  }
424
+
385
425
  declare const getWalletConnect: (params?: GetWalletConnectParams) => Wallet;
426
+
427
+ declare const getWCCosmostation: () => Wallet;
428
+
386
429
  declare const getWCKeplr: () => Wallet;
430
+
387
431
  declare const getWCLeap: () => Wallet;
388
- declare const getWCCosmostation: () => Wallet;
389
- /**
390
- * Function to return wallet object based on given {@link WalletType} or from store and throws an error if it does not
391
- * exist on `window` or unknown wallet type.
392
- *
393
- * @example
394
- * ```ts
395
- * const wallet = getWallet();
396
- * const keplr = getWallet("keplr");
397
- * ```
398
- *
399
- * @see {@link getKeplr}
400
- */
401
- declare const getWallet: (type?: WalletType) => Wallet;
402
- declare const getAvailableWallets: () => Record<WalletType, boolean>;
403
432
 
404
433
  interface AccountData {
405
434
  address: Uint8Array;
@@ -866,7 +895,7 @@ type UseExecuteContractArgs<Message extends Record<string, unknown>> = {
866
895
  *
867
896
  * @example
868
897
  * ```ts
869
- * import { useExecuteContract, useCosmwasmSigningClient } from "graz"
898
+ * import { useExecuteContract, useCosmWasmSigningClient } from "graz"
870
899
  *
871
900
  * interface GreetMessage {
872
901
  * name: string;
@@ -878,7 +907,7 @@ type UseExecuteContractArgs<Message extends Record<string, unknown>> = {
878
907
  *
879
908
  * const contractAddress = "cosmosfoobarbaz";
880
909
  *
881
- * const { data: signingClient } = useCosmwasmSigningClient()
910
+ * const { data: signingClient } = useCosmWasmSigningClient()
882
911
  * const { executeContract } = useExecuteContract<ExecuteMessage>({ contractAddress });
883
912
  *
884
913
  * executeContract({
@@ -931,6 +960,7 @@ declare const useQueryRaw: <TError>(address?: string, key?: string) => UseQueryR
931
960
  */
932
961
  declare const useStargateSigningClient: (args?: {
933
962
  opts?: SigningStargateClientOptions;
963
+ offlineSigner?: "offlineSigner" | "offlineSignerAuto" | "offlineSignerOnlyAmino";
934
964
  }) => _tanstack_react_query.UseQueryResult<SigningStargateClient, unknown>;
935
965
  /**
936
966
  * graz query hook to retrieve a SigningCosmWasmClient.
@@ -947,6 +977,7 @@ declare const useStargateSigningClient: (args?: {
947
977
  */
948
978
  declare const useCosmWasmSigningClient: (args?: {
949
979
  opts?: SigningCosmWasmClientOptions;
980
+ offlineSigner?: "offlineSigner" | "offlineSignerAuto" | "offlineSignerOnlyAmino";
950
981
  }) => _tanstack_react_query.UseQueryResult<SigningCosmWasmClient, unknown>;
951
982
  /**
952
983
  * graz query hook to retrieve a SigningStargateClient with tendermint client.
@@ -964,6 +995,7 @@ declare const useCosmWasmSigningClient: (args?: {
964
995
  declare const useStargateTmSigningClient: (args: {
965
996
  type: "tm34" | "tm37";
966
997
  opts?: SigningStargateClientOptions;
998
+ offlineSigner?: "offlineSigner" | "offlineSignerAuto" | "offlineSignerOnlyAmino";
967
999
  }) => _tanstack_react_query.UseQueryResult<SigningStargateClient, unknown>;
968
1000
  /**
969
1001
  * graz query hook to retrieve a SigningCosmWasmClient with tendermint client.
@@ -981,6 +1013,7 @@ declare const useStargateTmSigningClient: (args: {
981
1013
  declare const useCosmWasmTmSigningClient: (args: {
982
1014
  type: "tm34" | "tm37";
983
1015
  opts?: SigningCosmWasmClientOptions;
1016
+ offlineSigner?: "offlineSigner" | "offlineSignerAuto" | "offlineSignerOnlyAmino";
984
1017
  }) => _tanstack_react_query.UseQueryResult<SigningCosmWasmClient, unknown>;
985
1018
 
986
1019
  /**
@@ -1053,4 +1086,4 @@ declare const useGrazEvents: () => null;
1053
1086
  */
1054
1087
  declare const GrazEvents: FC;
1055
1088
 
1056
- export { AccountData, ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, ConnectResult, Connector, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GetWalletConnectParams, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, OfflineSigners, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, Wallet, WalletType, checkWallet, clearRecentChain, configureGraz, connect, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAvailableWallets, getCosmostation, getKeplr, getLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChain, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useCosmWasmTmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useStargateTmSigningClient, useSuggestChain, useSuggestChainAndConnect, useTendermintClient };
1089
+ export { AccountData, ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, ConnectResult, Connector, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, OfflineSigners, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SignAminoParams, SignDirectParams, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAvailableWallets, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChain, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useCosmWasmTmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useStargateTmSigningClient, useSuggestChain, useSuggestChainAndConnect, useTendermintClient };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var an=Object.create;var ae=Object.defineProperty;var cn=Object.getOwnPropertyDescriptor;var ln=Object.getOwnPropertyNames;var un=Object.getPrototypeOf,mn=Object.prototype.hasOwnProperty;var pn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),gn=(t,e)=>{for(var n in e)ae(t,n,{get:e[n],enumerable:!0})},ut=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ln(e))!mn.call(t,o)&&o!==n&&ae(t,o,{get:()=>e[o],enumerable:!(r=cn(e,o))||r.enumerable});return t};var mt=(t,e,n)=>(n=t!=null?an(un(t)):{},ut(e||!t||!t.__esModule?ae(n,"default",{value:t,enumerable:!0}):n,t)),fn=t=>ut(ae({},"__esModule",{value:!0}),t);var It=pn((To,Et)=>{"use strict";Et.exports=w;var W=null;try{W=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function w(t,e,n){this.low=t|0,this.high=e|0,this.unsigned=!!n}w.prototype.__isLong__;Object.defineProperty(w.prototype,"__isLong__",{value:!0});function _(t){return(t&&t.__isLong__)===!0}w.isLong=_;var gt={},ft={};function z(t,e){var n,r,o;return e?(t>>>=0,(o=0<=t&&t<256)&&(r=ft[t],r)?r:(n=S(t,(t|0)<0?-1:0,!0),o&&(ft[t]=n),n)):(t|=0,(o=-128<=t&&t<128)&&(r=gt[t],r)?r:(n=S(t,t<0?-1:0,!1),o&&(gt[t]=n),n))}w.fromInt=z;function k(t,e){if(isNaN(t))return e?j:F;if(e){if(t<0)return j;if(t>=Ct)return At}else{if(t<=-dt)return O;if(t+1>=dt)return St}return t<0?k(-t,e).neg():S(t%$|0,t/$|0,e)}w.fromNumber=k;function S(t,e,n){return new w(t,e,n)}w.fromBits=S;var ce=Math.pow;function _e(t,e,n){if(t.length===0)throw Error("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return F;if(typeof e=="number"?(n=e,e=!1):e=!!e,n=n||10,n<2||36<n)throw RangeError("radix");var r;if((r=t.indexOf("-"))>0)throw Error("interior hyphen");if(r===0)return _e(t.substring(1),e,n).neg();for(var o=k(ce(n,8)),i=F,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),c=parseInt(t.substring(s,s+a),n);if(a<8){var p=k(ce(n,a));i=i.mul(p).add(k(c))}else i=i.mul(o),i=i.add(k(c))}return i.unsigned=e,i}w.fromString=_e;function D(t,e){return typeof t=="number"?k(t,e):typeof t=="string"?_e(t,e):S(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}w.fromValue=D;var ht=65536,Cn=1<<24,$=ht*ht,Ct=$*$,dt=Ct/2,yt=z(Cn),F=z(0);w.ZERO=F;var j=z(0,!0);w.UZERO=j;var V=z(1);w.ONE=V;var wt=z(1,!0);w.UONE=wt;var Oe=z(-1);w.NEG_ONE=Oe;var St=S(-1,2147483647,!1);w.MAX_VALUE=St;var At=S(-1,-1,!0);w.MAX_UNSIGNED_VALUE=At;var O=S(0,-2147483648,!1);w.MIN_VALUE=O;var l=w.prototype;l.toInt=function(){return this.unsigned?this.low>>>0:this.low};l.toNumber=function(){return this.unsigned?(this.high>>>0)*$+(this.low>>>0):this.high*$+(this.low>>>0)};l.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(O)){var n=k(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var i=k(ce(e,6),this.unsigned),s=this,a="";;){var c=s.div(i),p=s.sub(c.mul(i)).toInt()>>>0,d=p.toString(e);if(s=c,s.isZero())return d+a;for(;d.length<6;)d="0"+d;a=""+d+a}};l.getHighBits=function(){return this.high};l.getHighBitsUnsigned=function(){return this.high>>>0};l.getLowBits=function(){return this.low};l.getLowBitsUnsigned=function(){return this.low>>>0};l.getNumBitsAbs=function(){if(this.isNegative())return this.eq(O)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<<n);n--);return this.high!=0?n+33:n+1};l.isZero=function(){return this.high===0&&this.low===0};l.eqz=l.isZero;l.isNegative=function(){return!this.unsigned&&this.high<0};l.isPositive=function(){return this.unsigned||this.high>=0};l.isOdd=function(){return(this.low&1)===1};l.isEven=function(){return(this.low&1)===0};l.equals=function(e){return _(e)||(e=D(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};l.eq=l.equals;l.notEquals=function(e){return!this.eq(e)};l.neq=l.notEquals;l.ne=l.notEquals;l.lessThan=function(e){return this.comp(e)<0};l.lt=l.lessThan;l.lessThanOrEqual=function(e){return this.comp(e)<=0};l.lte=l.lessThanOrEqual;l.le=l.lessThanOrEqual;l.greaterThan=function(e){return this.comp(e)>0};l.gt=l.greaterThan;l.greaterThanOrEqual=function(e){return this.comp(e)>=0};l.gte=l.greaterThanOrEqual;l.ge=l.greaterThanOrEqual;l.compare=function(e){if(_(e)||(e=D(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};l.comp=l.compare;l.negate=function(){return!this.unsigned&&this.eq(O)?O:this.not().add(V)};l.neg=l.negate;l.add=function(e){_(e)||(e=D(e));var n=this.high>>>16,r=this.high&65535,o=this.low>>>16,i=this.low&65535,s=e.high>>>16,a=e.high&65535,c=e.low>>>16,p=e.low&65535,d=0,E=0,C=0,T=0;return T+=i+p,C+=T>>>16,T&=65535,C+=o+c,E+=C>>>16,C&=65535,E+=r+a,d+=E>>>16,E&=65535,d+=n+s,d&=65535,S(C<<16|T,d<<16|E,this.unsigned)};l.subtract=function(e){return _(e)||(e=D(e)),this.add(e.neg())};l.sub=l.subtract;l.multiply=function(e){if(this.isZero())return F;if(_(e)||(e=D(e)),W){var n=W.mul(this.low,this.high,e.low,e.high);return S(n,W.get_high(),this.unsigned)}if(e.isZero())return F;if(this.eq(O))return e.isOdd()?O:F;if(e.eq(O))return this.isOdd()?O:F;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(yt)&&e.lt(yt))return k(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=this.high&65535,i=this.low>>>16,s=this.low&65535,a=e.high>>>16,c=e.high&65535,p=e.low>>>16,d=e.low&65535,E=0,C=0,T=0,N=0;return N+=s*d,T+=N>>>16,N&=65535,T+=i*d,C+=T>>>16,T&=65535,T+=s*p,C+=T>>>16,T&=65535,C+=o*d,E+=C>>>16,C&=65535,C+=i*p,E+=C>>>16,C&=65535,C+=s*c,E+=C>>>16,C&=65535,E+=r*d+o*p+i*c+s*a,E&=65535,S(T<<16|N,E<<16|C,this.unsigned)};l.mul=l.multiply;l.divide=function(e){if(_(e)||(e=D(e)),e.isZero())throw Error("division by zero");if(W){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?W.div_u:W.div_s)(this.low,this.high,e.low,e.high);return S(n,W.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?j:F;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return j;if(e.gt(this.shru(1)))return wt;i=j}else{if(this.eq(O)){if(e.eq(V)||e.eq(Oe))return O;if(e.eq(O))return V;var s=this.shr(1);return r=s.div(e).shl(1),r.eq(F)?e.isNegative()?V:Oe:(o=this.sub(e.mul(r)),i=r.add(o.div(e)),i)}else if(e.eq(O))return this.unsigned?j:F;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=F}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(r)/Math.LN2),c=a<=48?1:ce(2,a-48),p=k(r),d=p.mul(e);d.isNegative()||d.gt(o);)r-=c,p=k(r,this.unsigned),d=p.mul(e);p.isZero()&&(p=V),i=i.add(p),o=o.sub(d)}return i};l.div=l.divide;l.modulo=function(e){if(_(e)||(e=D(e)),W){var n=(this.unsigned?W.rem_u:W.rem_s)(this.low,this.high,e.low,e.high);return S(n,W.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};l.mod=l.modulo;l.rem=l.modulo;l.not=function(){return S(~this.low,~this.high,this.unsigned)};l.and=function(e){return _(e)||(e=D(e)),S(this.low&e.low,this.high&e.high,this.unsigned)};l.or=function(e){return _(e)||(e=D(e)),S(this.low|e.low,this.high|e.high,this.unsigned)};l.xor=function(e){return _(e)||(e=D(e)),S(this.low^e.low,this.high^e.high,this.unsigned)};l.shiftLeft=function(e){return _(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?S(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):S(0,this.low<<e-32,this.unsigned)};l.shl=l.shiftLeft;l.shiftRight=function(e){return _(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?S(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):S(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};l.shr=l.shiftRight;l.shiftRightUnsigned=function(e){if(_(e)&&(e=e.toInt()),e&=63,e===0)return this;var n=this.high;if(e<32){var r=this.low;return S(r>>>e|n<<32-e,n>>>e,this.unsigned)}else return e===32?S(n,0,this.unsigned):S(n>>>e-32,0,this.unsigned)};l.shru=l.shiftRightUnsigned;l.shr_u=l.shiftRightUnsigned;l.toSigned=function(){return this.unsigned?S(this.low,this.high,!1):this};l.toUnsigned=function(){return this.unsigned?this:S(this.low,this.high,!0)};l.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};l.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};l.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};w.fromBytes=function(e,n,r){return r?w.fromBytesLE(e,n):w.fromBytesBE(e,n)};w.fromBytesLE=function(e,n){return new w(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)};w.fromBytesBE=function(e,n){return new w(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)}});var ho={};gn(ho,{GrazEvents:()=>rt,GrazProvider:()=>fo,WALLET_TYPES:()=>xe,WalletType:()=>be,checkWallet:()=>x,clearRecentChain:()=>Me,configureGraz:()=>Ue,connect:()=>Z,defineChain:()=>Ln,defineChainInfo:()=>Pn,defineChains:()=>et,disconnect:()=>ge,executeContract:()=>Be,getActiveChainCurrency:()=>De,getAvailableWallets:()=>wn,getCosmostation:()=>me,getKeplr:()=>le,getLeap:()=>ue,getOfflineSigners:()=>Fe,getQueryRaw:()=>je,getQuerySmart:()=>Ge,getRecentChain:()=>Sn,getVectis:()=>pe,getWCCosmostation:()=>Nt,getWCKeplr:()=>Ot,getWCLeap:()=>_t,getWallet:()=>M,getWalletConnect:()=>Q,instantiateContract:()=>Pe,mainnetChains:()=>Bn,mainnetChainsArray:()=>Gn,reconnect:()=>R,sendIbcTokens:()=>Le,sendTokens:()=>qe,suggestChain:()=>fe,suggestChainAndConnect:()=>Re,testnetChains:()=>jn,testnetChainsArray:()=>zn,useAccount:()=>P,useActiveChain:()=>Yn,useActiveChainCurrency:()=>Xn,useActiveChainValidators:()=>Jn,useActiveWalletType:()=>Kn,useBalance:()=>Qn,useBalanceStaked:()=>Zn,useBalances:()=>tn,useCheckWallet:()=>te,useConnect:()=>Hn,useCosmWasmClient:()=>we,useCosmWasmSigningClient:()=>uo,useCosmWasmTmSigningClient:()=>po,useDisconnect:()=>Vn,useExecuteContract:()=>so,useGrazEvents:()=>on,useInstantiateContract:()=>io,useOfflineSigners:()=>$n,useQueryRaw:()=>co,useQuerySmart:()=>ao,useRecentChain:()=>eo,useSendIbcTokens:()=>ro,useSendTokens:()=>oo,useStargateClient:()=>Ce,useStargateSigningClient:()=>lo,useStargateTmSigningClient:()=>mo,useSuggestChain:()=>to,useSuggestChainAndConnect:()=>no,useTendermintClient:()=>Se});module.exports=fn(ho);var G="graz-reconnect-session";var ve=require("zustand"),pt=require("zustand/middleware"),H=require("zustand/middleware");var be=(c=>(c.KEPLR="keplr",c.LEAP="leap",c.VECTIS="vectis",c.COSMOSTATION="cosmostation",c.WALLETCONNECT="walletconnect",c.WC_KEPLR_MOBILE="wc_keplr_mobile",c.WC_LEAP_MOBILE="wc_leap_mobile",c.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",c))(be||{}),xe=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile"];var hn={recentChain:null,defaultChain:null,defaultSigningClient:"stargate",walletType:"keplr",walletConnect:{options:null,web3Modal:null},_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ee={account:null,activeChain:null,balances:null,status:"disconnected",wcSignClient:null},dn={name:"graz-session",version:1,partialize:t=>({account:t.account,activeChain:t.activeChain}),storage:(0,pt.createJSONStorage)(()=>sessionStorage)},yn={name:"graz-internal",partialize:t=>({recentChain:t.recentChain,_reconnect:t._reconnect,_reconnectConnector:t._reconnectConnector}),version:1},g=(0,ve.create)((0,H.subscribeWithSelector)((0,H.persist)(()=>ee,dn))),h=(0,ve.create)((0,H.subscribeWithSelector)((0,H.persist)(()=>hn,yn)));var We=require("@cosmjs/encoding"),xt=require("@walletconnect/sign-client"),vt=require("@walletconnect/utils"),ke=mt(It());var K=()=>typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,Tt=()=>K()&&navigator.userAgent.toLowerCase().includes("android"),bt=()=>K()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Ne=(t,e,n=new Error("Promise timed out"))=>{let r=new Promise((o,i)=>{setTimeout(()=>{i(n)},e)});return Promise.race([t,r])};var x=(t=h.getState().walletType)=>{try{return M(t),!0}catch{return!1}},q=()=>{window.sessionStorage.removeItem(G),g.setState(ee)},le=()=>{if(typeof window.keplr<"u"){let t=window.keplr;return Object.assign(t,{subscription:r=>(window.addEventListener("keplr_keystorechange",()=>{q(),r()}),()=>{window.removeEventListener("keplr_keystorechange",()=>{q(),r()})})})}throw h.getState()._notFoundFn(),new Error("window.keplr is not defined")},ue=()=>{if(typeof window.leap<"u"){let t=window.leap;return Object.assign(t,{subscription:r=>(window.addEventListener("leap_keystorechange",()=>{q(),r()}),()=>{window.removeEventListener("leap_keystorechange",()=>{q(),r()})})})}throw h.getState()._notFoundFn(),new Error("window.leap is not defined")},me=()=>{if(typeof window.cosmostation.providers.keplr<"u"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:r=>(window.cosmostation.cosmos.on("accountChanged",()=>{q(),r()}),()=>{window.cosmostation.cosmos.off("accountChanged",()=>{q(),r()})})})}throw h.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")},pe=()=>{if(typeof window.vectis<"u"){let t=window.vectis.cosmos;return{enable:a=>t.enable(a),getOfflineSigner:a=>t.getOfflineSigner(a),getOfflineSignerAuto:a=>t.getOfflineSignerAuto(a),getKey:async a=>{let c=await t.getKey(a);return{address:(0,We.fromBech32)(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}},subscription:a=>(window.addEventListener("vectis_accountChanged",()=>{q(),a()}),()=>{window.removeEventListener("vectis_accountChanged",()=>{q(),a()})}),getOfflineSignerOnlyAmino:(...a)=>t.getOfflineSignerAmino(...a),experimentalSuggestChain:async(...a)=>{let[c]=a,p={...c,rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr};return t.suggestChains([p])},signDirect:async(...a)=>{var d;let{1:c,2:p}=a;return t.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:ke.default.fromString(((d=p.accountNumber)==null?void 0:d.toString())||"",!1),chainId:p.chainId||""})},signAmino:async(...a)=>{let{1:c,2:p}=a;return t.signAmino(c,p)}}}throw h.getState()._notFoundFn(),new Error("window.vectis is not defined")},Q=t=>{var st,at,ct;if(!((ct=(at=(st=h.getState().walletConnect)==null?void 0:st.options)==null?void 0:at.projectId)!=null&&ct.trim()))throw new Error("walletConnect.options.projectId is not defined");let e=(t==null?void 0:t.encoding)||"base64",n=m=>{if(!t)return;let{appUrl:u,formatNativeUrl:f}=t;if(K()){if(Tt())if(!m)window.open(u.mobile.android,"_self","noreferrer noopener");else{let y=f(u.mobile.android,m,"android");window.open(y,"_self","noreferrer noopener")}if(bt())if(!m)window.open(u.mobile.ios,"_self","noreferrer noopener");else{let y=f(u.mobile.ios,m,"ios");window.open(y,"_self","noreferrer noopener")}}},r=()=>{let{wcSignClient:m}=g.getState();if(!m)throw new Error("walletConnect.signClient is not defined");q(),h.setState({_reconnect:!1,_reconnectConnector:null,recentChain:null})},o=async m=>{let{wcSignClient:u}=g.getState();if(!u)throw new Error("walletConnect.signClient is not defined");if(!m)throw new Error("No wallet connect session");await u.disconnect({topic:m,reason:(0,vt.getSdkError)("USER_DISCONNECTED")}),await a(u),r()},i=m=>{var u,f;try{let{wcSignClient:y}=g.getState();if(!y)throw new Error("walletConnect.signClient is not defined");let A=y.session.getAll().at(-1);if(!A)return;let I=(f=(u=y.session.getAll().at(-1))==null?void 0:u.namespaces.cosmos)==null?void 0:f.accounts.find(b=>b.startsWith(`cosmos:${m}`));if(!(A.expiry*1e3>Date.now()+1e3))throw o(A.topic),new Error("invalid session");if(!I)try{let b=y.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${m}`],events:["chainChanged","accountsChanged"]}}});if(!b.length)throw new Error("no session");return b.at(-1)}catch(b){if(!b.message.toLowerCase().includes("no matching key"))throw b}return A}catch(y){if(!y.message.toLowerCase().includes("no matching key"))throw y}},s=m=>{try{return i(m)}catch{return}},a=async m=>{try{let u=m.core.pairing.pairings.getAll({active:!1});if(!u.length)return;await Promise.all(u.map(async f=>{await m.core.pairing.pairings.delete(f.topic,{code:7001,message:"clear pairing"})}))}catch(u){if(!u.message.toLowerCase().includes("no matching key"))throw u}},c=async()=>{let{walletConnect:m}=h.getState();if(!(m!=null&&m.options))throw new Error("walletConnect.options is not defined");let{wcSignClient:u}=g.getState();if(u)return g.setState({wcSignClient:u}),u;let f=await xt.SignClient.init(m.options);return g.setState({wcSignClient:f}),f},p=m=>{let{wcSignClient:u}=g.getState();if(u)return u.events.on("session_delete",f=>{r()}),u.events.on("session_expire",f=>{r()}),u.events.on("session_event",f=>{var y,A;if(f.params.event.name==="accountsChanged"&&((y=f.params.event.data)==null?void 0:y[0])!==((A=g.getState().account)==null?void 0:A.bech32Address)){let I=f.params.chainId.split(":")[1];I&&d(I)}else m()}),()=>{u.events.off("session_delete",f=>{r()}),u.events.off("session_expire",f=>{r()}),u.events.off("session_event",f=>{var y,A;if(f.params.event.name==="accountsChanged"&&((y=f.params.event.data)==null?void 0:y[0])!==((A=g.getState().account)==null?void 0:A.bech32Address)){let I=f.params.chainId.split(":")[1];I&&d(I)}else m()})}},d=async m=>{var ie;let{wcSignClient:u}=g.getState();if(!u)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:f}=h.getState();if(!((ie=f==null?void 0:f.options)!=null&&ie.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:y}=await import("@web3modal/standalone"),A=new y({projectId:f.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE",...f.web3Modal}),{account:I,activeChain:U}=g.getState(),b=s(m);if((U==null?void 0:U.chainId)!==m&&!b||!I){let{uri:v,approval:se}=await u.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${m}`],events:["chainChanged","accountsChanged"]}}});if(!v)throw new Error("No wallet connect uri");t?n(v):await A.openModal({uri:v});try{await Ne((async()=>{await se()})(),4e4,new Error("Modal approval timeout"))}catch(lt){if(A.closeModal(),!lt.message.toLowerCase().includes("no matching key"))return Promise.reject(lt)}return t||A.closeModal(),Promise.resolve()}try{await Ne((async()=>{let v=await C(m);g.setState({account:v})})(),1e4,new Error("Connection timeout"))}catch(v){if(o(b==null?void 0:b.topic),!v.message.toLowerCase().includes("no matching key"))throw v}},E=async m=>{var A;let{wcSignClient:u}=g.getState();if(!u)throw new Error("walletConnect.signClient is not defined");let f=(A=i(m))==null?void 0:A.topic;if(!f)throw new Error("No wallet connect session");n();let y=await u.request({topic:f,chainId:`cosmos:${m}`,request:{method:"cosmos_getAccounts",params:{}}});if(!y[0])throw new Error("No wallet connect account");return{address:y[0].address,algo:y[0].algo,pubkey:new Uint8Array(Buffer.from(y[0].pubkey,e))}},C=async m=>{let{address:u,algo:f,pubkey:y}=await E(m);return{address:(0,We.fromBech32)(u).data,algo:f,bech32Address:u,name:"",pubKey:y,isKeystone:!1,isNanoLedger:!1}},T=async(...m)=>{var v,se;let[u,f,y]=m,{account:A,wcSignClient:I}=g.getState();if(!I)throw new Error("walletConnect.signClient is not defined");if(!A)throw new Error("account is not defined");let U=(v=i(u))==null?void 0:v.topic;if(!U)throw new Error("No wallet connect session");if(!y.bodyBytes)throw new Error("No bodyBytes");if(!y.authInfoBytes)throw new Error("No authInfoBytes");let b={topic:U,chainId:`cosmos:${u}`,request:{method:"cosmos_signDirect",params:{signerAddress:f,signDoc:{...y,bodyBytes:Buffer.from(y.bodyBytes).toString(e),authInfoBytes:Buffer.from(y.authInfoBytes).toString(e),accountNumber:(se=y.accountNumber)==null?void 0:se.toString()}}}};return n(),await I.request(b)},N=async(...m)=>{let[u,f,y]=m,{signature:A,signed:I}=await T(u,f,y);return{signed:{chainId:I.chainId,accountNumber:ke.default.fromString(I.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(I.authInfoBytes,e)),bodyBytes:new Uint8Array(Buffer.from(I.bodyBytes,e))},signature:A}},re=async(...m)=>{var v;let[u,f,y,A]=m,{wcSignClient:I}=g.getState(),{account:U}=g.getState();if(!I)throw new Error("walletConnect.signClient is not defined");if(!U)throw new Error("account is not defined");let b=(v=i(u))==null?void 0:v.topic;if(!b)throw new Error("No wallet connect session");return n(),await I.request({topic:b,chainId:`cosmos:${u}`,request:{method:"cosmos_signDirect",params:{signerAddress:f,signDoc:y}}})},Te=async(...m)=>{let[u,f,y,A]=m;return await re(u,f,y)},sn=m=>({getAccounts:async()=>[await E(m)],signDirect:(u,f)=>N(m,u,f)}),it=m=>({getAccounts:async()=>[await E(m)],signAmino:(u,f)=>Te(m,u,f)});return{enable:d,experimentalSuggestChain:async(...m)=>{await Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"))},getKey:C,getOfflineSigner:m=>({getAccounts:async()=>[await E(m)],signDirect:(u,f)=>N(m,u,f),signAmino:(u,f)=>Te(m,u,f)}),getOfflineSignerAuto:async m=>(await C(m)).isNanoLedger?it(m):sn(m),getOfflineSignerOnlyAmino:it,signAmino:Te,signDirect:N,subscription:p,init:c}},Ot=()=>{var e,n,r;if(!((r=(n=(e=h.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!K())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let t={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(o,i,s)=>{let a=o.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);switch(s){case"ios":return`${a}://wcV2?${c}`;case"android":return`${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return`${a}://wc?uri=${c}`}}};return Q(t)},_t=()=>{var e,n,r;if(!((r=(n=(e=h.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!K())throw new Error("WalletConnect Leap mobile is only supported in mobile");let t={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(o,i,s)=>{let a=o.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);switch(s){case"ios":return`${a}://wcV2?${c}`;case"android":return`${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return`${a}://wc?uri=${c}`}}};return Q(t)},Nt=()=>{var e,n,r;if(!((r=(n=(e=h.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!K())throw new Error("WalletConnect Leap mobile is only supported in mobile");let t={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_leap_mobile",formatNativeUrl:(o,i,s)=>`${o.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return Q(t)},M=(t=h.getState().walletType)=>{switch(t){case"keplr":return le();case"leap":return ue();case"cosmostation":return me();case"vectis":return pe();case"walletconnect":return Q();case"wc_keplr_mobile":return Ot();case"wc_leap_mobile":return _t();case"wc_cosmostation_mobile":return Nt();default:throw new Error("Unknown wallet type")}},wn=()=>Object.fromEntries(xe.map(t=>[t,x(t)]));var Z=async t=>{var e;try{let{defaultChain:n,recentChain:r,walletType:o}=h.getState(),i=(t==null?void 0:t.walletType)||o;if(!x(i))throw new Error(`${i} is not available`);let a=M(i),c=(t==null?void 0:t.chain)||r||n;if(!c)throw new Error("No last known connected chain, connect action requires chain info");g.setState(C=>{let T=h.getState()._reconnect||!!h.getState()._reconnectConnector||!!c;return C.activeChain&&C.activeChain.chainId!==c.chainId?{status:"connecting"}:T?{status:"reconnecting"}:{status:"connecting"}});let{account:p,activeChain:d}=g.getState();if(await((e=a.init)==null?void 0:e.call(a)),!p||(d==null?void 0:d.chainId)!==c.chainId){await a.enable(c.chainId);let C=await a.getKey(c.chainId);g.setState({account:C})}h.setState({recentChain:c,walletType:i,_reconnect:!!(t!=null&&t.autoReconnect),_reconnectConnector:i}),g.setState({activeChain:c,status:"connected"}),typeof window<"u"&&window.sessionStorage.setItem(G,"Active");let{account:E}=g.getState();return{account:E,walletType:i,chain:c}}catch(n){throw console.error("connect ",n),g.getState().account===null&&g.setState({status:"disconnected"}),g.getState().account&&g.getState().activeChain&&g.setState({status:"connected"}),n}},ge=async(t=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(G),g.setState(ee),h.setState(e=>({_reconnect:!1,_reconnectConnector:null,recentChain:t?null:e.recentChain})),Promise.resolve()),R=async t=>{var o;let{recentChain:e,_reconnectConnector:n,_reconnect:r}=h.getState();try{let i=x(n||void 0);if(e&&i&&n)return await Z({chain:e,walletType:n,autoReconnect:r})}catch(i){(o=t==null?void 0:t.onError)==null||o.call(t,i),ge()}},Fe=async t=>{if(!(t!=null&&t.chainId))throw new Error("chainId is required");let{walletType:e}=h.getState(),n=t.walletType||e;if(!x(n))throw new Error(`${n} is not available`);let o=M(n),i=o.getOfflineSigner(t.chainId),s=o.getOfflineSignerOnlyAmino(t.chainId),a=await o.getOfflineSignerAuto(t.chainId);return{offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}};var Me=()=>{h.setState({recentChain:null})},De=t=>{let{activeChain:e}=g.getState();return e==null?void 0:e.currencies.find(n=>n.coinMinimalDenom===t)},Sn=()=>h.getState().recentChain,fe=async t=>(await M().experimentalSuggestChain(t),t),Re=async({chainInfo:t,rpcHeaders:e,gas:n,path:r,...o})=>{let i=await fe(t);return{...await Z({chain:{chainId:t.chainId,currencies:t.currencies,rest:t.rest,rpc:t.rpc,rpcHeaders:e,gas:n,path:r},...o}),chain:i}};var Ue=(t={})=>(h.setState(e=>({defaultChain:t.defaultChain||e.defaultChain,defaultSigningClient:t.defaultSigningClient||e.defaultSigningClient,walletConnect:t.walletConnect||e.walletConnect,walletType:t.defaultWallet||e.walletType,_notFoundFn:t.onNotFound||e._notFoundFn,_onReconnectFailed:t.onReconnectFailed||e._onReconnectFailed,_reconnect:t.autoReconnect===void 0?!0:t.autoReconnect||e._reconnect})),t);var qe=async({signingClient:t,senderAddress:e,recipientAddress:n,amount:r,fee:o,memo:i})=>{if(!t)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return t.sendTokens(e,n,r,o,i)},Le=async({signingClient:t,senderAddress:e,recipientAddress:n,transferAmount:r,sourcePort:o,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:p})=>{if(!t)throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return t.sendIbcTokens(e,n,r,o,i,s,a,c,p)},Pe=async({signingClient:t,senderAddress:e,msg:n,fee:r,options:o,label:i,codeId:s})=>{if(!t)throw new Error("CosmWasm signing client is not ready");return t.instantiate(e,s,n,i,r,o)},Be=async({signingClient:t,senderAddress:e,msg:n,fee:r,contractAddress:o,funds:i,memo:s})=>{if(!t)throw new Error("CosmWasm signing client is not ready");return t.execute(e,o,n,r,s,i)},Ge=async(t,e,n)=>{if(!n)throw new Error("CosmWasm client is not ready");return await n.queryContractSmart(t,e)},je=(t,e,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(e);return n.queryContractRaw(t,r)};var kt=require("@keplr-wallet/cosmos"),Ft={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},An={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},En={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},In={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Tn={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},bn={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Wt=[Ft,An,En,In,Tn,bn],ze={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Ft,bip44:{coinType:118},bech32Config:kt.Bech32Address.defaultBech32Config("axelar"),currencies:Wt,feeCurrencies:Wt};var Dt=require("@keplr-wallet/cosmos"),Rt={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Mt=[Rt],Ke={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:Rt,bip44:{coinType:118},bech32Config:Dt.Bech32Address.defaultBech32Config("cosmos"),currencies:Mt,feeCurrencies:Mt};var qt=require("@keplr-wallet/cosmos"),Lt={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},xn={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},vn={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},On={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},_n={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Nn={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Wn={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},kn={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Fn={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Mn={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Dn={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},Ut=[Lt,xn,vn,On,_n,Nn,Wn,kn,Fn,Mn,Dn],Qe={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Lt,bip44:{coinType:118},bech32Config:qt.Bech32Address.defaultBech32Config("juno"),currencies:Ut,feeCurrencies:Ut};var Bt=require("@keplr-wallet/cosmos"),Gt={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Rn={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Pt=[Gt,Rn],He={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Gt,bip44:{coinType:118},bech32Config:Bt.Bech32Address.defaultBech32Config("osmo"),currencies:Pt,feeCurrencies:Pt};var zt=require("@keplr-wallet/cosmos"),Kt={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},jt=[Kt],Ve={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Kt,bip44:{coinType:118},bech32Config:zt.Bech32Address.defaultBech32Config("somm"),currencies:jt,feeCurrencies:jt};var Ht=require("@keplr-wallet/cosmos"),Vt={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},Qt=[Vt],$e={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:Ht.Bech32Address.defaultBech32Config("CRE"),currencies:Qt,feeCurrencies:Qt,stakeCurrency:Vt,coinType:118};var $t=require("@keplr-wallet/cosmos"),Ze={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Un=[Ze],Ye={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:Ze,bip44:{coinType:118},bech32Config:$t.Bech32Address.defaultBech32Config("juno"),currencies:Un,feeCurrencies:[Ze],coinType:118};var Zt=require("@keplr-wallet/cosmos"),Xe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},qn=[Xe],Je={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:Xe,bip44:{coinType:118},bech32Config:Zt.Bech32Address.defaultBech32Config("osmo"),currencies:qn,feeCurrencies:[Xe],coinType:118};var et=t=>t,Ln=t=>t,Pn=t=>t,Bn=et({axelar:ze,cosmoshub:Ke,juno:Qe,osmosis:He,sommelier:Ve}),Gn=[ze,Ke,Qe,He,Ve],jn=et({crescent:$e,juno:Ye,osmosis:Je}),zn=[$e,Ye,Je];var L=require("@tanstack/react-query"),Y=require("react");var Yt=require("@cosmjs/cosmwasm-stargate"),Xt=require("@cosmjs/stargate"),he=require("@cosmjs/tendermint-rpc"),de=require("@tanstack/react-query"),ye=require("react");var Ce=()=>{let t=g(n=>n.activeChain),e=(0,ye.useMemo)(()=>["USE_STARGATE_CLIENT",t],[t]);return(0,de.useQuery)({queryKey:e,queryFn:async({queryKey:[,n]})=>{if(!n)throw new Error("No chain found");let r={url:n.rpc,headers:{...n.rpcHeaders||{}}};return await Xt.StargateClient.connect(r)},enabled:!!t,refetchOnWindowFocus:!1})},we=()=>{let t=g(n=>n.activeChain),e=(0,ye.useMemo)(()=>["USE_COSMWASM_CLIENT",t],[t]);return(0,de.useQuery)({queryKey:e,queryFn:async({queryKey:[,n]})=>{if(!n)throw new Error("No chain found");let r={url:n.rpc,headers:{...n.rpcHeaders||{}}};return await Yt.CosmWasmClient.connect(r)},enabled:!!t,refetchOnWindowFocus:!1})},Se=t=>{let e=g(r=>r.activeChain),n=(0,ye.useMemo)(()=>["USE_TENDERMINT_CLIENT",t,e],[t,e]);return(0,de.useQuery)({queryKey:n,queryFn:async({queryKey:[,r,o]})=>{if(!o)throw new Error("No chain found");let i={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await(r==="tm37"?he.Tendermint37Client:he.Tendermint34Client).connect(i)},enabled:!!e,refetchOnWindowFocus:!1})};var Jt=require("@tanstack/react-query"),en=require("zustand/shallow");var Kn=()=>h(t=>({walletType:t.walletType,isCosmostation:t.walletType==="cosmostation",isCosmostationMobile:t.walletType==="wc_cosmostation_mobile",isKeplr:t.walletType==="keplr",isKeplrMobile:t.walletType==="wc_keplr_mobile",isLeap:t.walletType==="leap",isLeapMobile:t.walletType==="wc_leap_mobile",isVectis:t.walletType==="vectis",isWalletConnect:t.walletType==="walletconnect"}),en.shallow),te=t=>{let n=["USE_CHECK_WALLET",h(o=>t||o.walletType)];return(0,Jt.useQuery)(n,({queryKey:[,o]})=>x(o))};var P=({onConnect:t,onDisconnect:e}={})=>{let n=g(o=>o.account),r=g(o=>o.status);return(0,Y.useEffect)(()=>g.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let{account:s,activeChain:a}=g.getState(),{walletType:c}=h.getState();t==null||t({account:s,chain:a,walletType:c,isReconnect:i==="reconnecting"})}o==="disconnected"&&(e==null||e())}),[t,e]),{data:n,isConnected:!!n,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:R,status:r}},tn=t=>{let{data:e}=P(),{data:n}=Ce(),{activeChain:r}=g.getState(),o=t||(e==null?void 0:e.bech32Address),i=(0,Y.useMemo)(()=>["USE_ALL_BALANCES",n,r,o],[r,o,n]);return(0,L.useQuery)(i,async({queryKey:[,a,c,p]})=>{if(!c||!a)throw new Error("No connected account detected");if(!p)throw new Error("address is not defined");return await a.getAllBalances(p)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Qn=(t,e)=>{let{data:n}=tn(e);return(0,L.useQuery)(["USE_BALANCE",n,t,e],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===t),{enabled:!!n})},Hn=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=(0,L.useMutation)(["USE_CONNECT",t,e,n],Z,{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=te();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status}},Vn=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=(0,L.useMutation)(["USE_DISCONNECT",t,e,n],ge,{onError:i=>Promise.resolve(t==null?void 0:t(i,void 0)),onMutate:e,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>o.mutate(i),disconnectAsync:i=>o.mutateAsync(i),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,status:o.status}},$n=()=>{let t=g(r=>r.activeChain),e=h(r=>r.walletType),n=(0,Y.useMemo)(()=>["USE_OFFLINE_SIGNERS",t,e],[t,e]);return(0,L.useQuery)({queryKey:n,queryFn:async({queryKey:[,r,o]})=>{if(!r)throw new Error("No chain found");if(!x(o))throw new Error(`${o} is not available`);return await Fe({chainId:r.chainId,walletType:o})},enabled:!!t&&!!e,refetchOnWindowFocus:!1})},Zn=t=>{let{data:e}=P(),{data:n}=Ce(),{activeChain:r}=g.getState(),o=t||(e==null?void 0:e.bech32Address),i=(0,Y.useMemo)(()=>["USE_BALANCE_STAKED",n,r,o],[r,o,n]);return(0,L.useQuery)(i,async({queryKey:[,a,c,p]})=>{if(!c||!a)throw new Error("No connected account detected");if(!p)throw new Error("address is not defined");return await a.getBalanceStaked(p)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var X=require("@tanstack/react-query");var Yn=()=>g(t=>t.activeChain),Xn=t=>(0,X.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",t],({queryKey:[,r]})=>De(r)),Jn=(t,e="BOND_STATUS_BONDED")=>(0,X.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",t,e],async({queryKey:[,o,i]})=>{if(!o)throw new Error("Query client is not defined");return await o.staking.validators(i)},{enabled:typeof t<"u"}),eo=()=>({data:h(e=>e.recentChain),clear:Me}),to=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=(0,X.useMutation)(["USE_SUGGEST_CHAIN",t,e,n],fe,{onError:(i,s)=>Promise.resolve(t==null?void 0:t(i,s)),onMutate:e,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,suggest:o.mutate,suggestAsync:o.mutateAsync,status:o.status}},no=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=(0,X.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",t,e,n],Re,{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:s=>e==null?void 0:e(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=te();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};var B=require("@tanstack/react-query");var oo=({onError:t,onLoading:e,onSuccess:n}={})=>{let{data:r}=P(),o=r==null?void 0:r.bech32Address,i=(0,B.useMutation)(["USE_SEND_TOKENS",t,e,n,o],s=>qe({senderAddress:o,...s}),{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return{error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},ro=({onError:t,onLoading:e,onSuccess:n}={})=>{let{data:r}=P(),o=r==null?void 0:r.bech32Address,i=(0,B.useMutation)(["USE_SEND_IBC_TOKENS",t,e,n,o],s=>Le({senderAddress:o,...s}),{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return{error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},io=({codeId:t,onError:e,onLoading:n,onSuccess:r})=>{let{data:o}=P(),i=o==null?void 0:o.bech32Address,a=(0,B.useMutation)(["USE_INSTANTIATE_CONTRACT",e,n,r,t,i],c=>{if(!i)throw new Error("senderAddress is undefined");let p={...c,fee:c.fee??"auto",senderAddress:i,codeId:t};return Pe(p)},{onError:(c,p)=>Promise.resolve(e==null?void 0:e(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return{error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},so=({contractAddress:t,onError:e,onLoading:n,onSuccess:r})=>{let{data:o}=P(),i=o==null?void 0:o.bech32Address,a=(0,B.useMutation)(["USE_EXECUTE_CONTRACT",e,n,r,t,i],c=>{if(!i)throw new Error("senderAddress is undefined");let p={...c,fee:c.fee??"auto",senderAddress:i,contractAddress:t,memo:c.memo??"",funds:c.funds??[]};return Be(p)},{onError:(c,p)=>Promise.resolve(e==null?void 0:e(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return{error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},ao=(t,e)=>{let{data:n}=we();return(0,B.useQuery)(["USE_QUERY_SMART",t,e,n],({queryKey:[,o]})=>{if(!t||!e)throw new Error("address or queryMsg undefined");return Ge(t,e,n)},{enabled:!!t&&!!e&&!!n})},co=(t,e)=>{let{data:n}=we();return(0,B.useQuery)(["USE_QUERY_RAW",e,t,n],({queryKey:[,i]})=>{if(!t||!e)throw new Error("address or key undefined");return je(t,e,n)},{enabled:!!t&&!!e&&!!n})};var tt=require("@cosmjs/cosmwasm-stargate"),nt=require("@cosmjs/stargate"),ne=require("@tanstack/react-query"),oe=require("react");var lo=t=>{let e=g(o=>o.activeChain),n=h(o=>o.walletType),r=(0,oe.useMemo)(()=>["USE_STARGATE_SIGNING_CLIENT",e,n,t],[t,e,n]);return(0,ne.useQuery)({queryKey:r,queryFn:async({queryKey:[,o,i,s]})=>{if(!o)throw new Error("No chain found");if(!x(i))throw new Error(`${i} is not available`);let c=M(i).getOfflineSigner(o.chainId),p={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await nt.SigningStargateClient.connectWithSigner(p,c,s==null?void 0:s.opts)},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},uo=t=>{let e=g(o=>o.activeChain),n=h(o=>o.walletType),r=(0,oe.useMemo)(()=>["USE_COSMWASM_SIGNING_CLIENT",e,n,t],[t,e,n]);return(0,ne.useQuery)({queryKey:r,queryFn:async({queryKey:[,o,i,s]})=>{if(!o)throw new Error("No chain found");if(!x(i))throw new Error(`${i} is not available`);let c=M(i).getOfflineSigner(o.chainId),p={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await tt.SigningCosmWasmClient.connectWithSigner(p,c,s==null?void 0:s.opts)},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},mo=t=>{let e=g(i=>i.activeChain),n=h(i=>i.walletType),r=(0,oe.useMemo)(()=>["USE_STARGATE_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=Se(t.type);return(0,ne.useQuery)({queryKey:r,queryFn:({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!x(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let p=M(s).getOfflineSigner(i.chainId);return nt.SigningStargateClient.createWithSigner(o,p,a.opts)},enabled:!!e&&!!n&&!!o,refetchOnWindowFocus:!1})},po=t=>{let e=g(i=>i.activeChain),n=h(i=>i.walletType),r=(0,oe.useMemo)(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=Se(t.type);return(0,ne.useQuery)({queryKey:r,queryFn:({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!x(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let p=M(s).getOfflineSigner(i.chainId);return tt.SigningCosmWasmClient.createWithSigner(o,p,a.opts)},enabled:!!e&&!!n&&!!o,refetchOnWindowFocus:!1})};var Ie=require("@tanstack/react-query"),rn=require("@tanstack/react-query-devtools");var Ae=require("react"),Ee=require("react/jsx-runtime"),nn=({children:t})=>{let[e,n]=(0,Ae.useState)(!1);return(0,Ae.useEffect)(()=>{n(!0)},[]),(0,Ee.jsx)(Ee.Fragment,{children:e?t:null})};var ot=require("react");var on=()=>{let t=typeof window<"u"&&window.sessionStorage.getItem(G)==="Active",{_reconnect:e,_onReconnectFailed:n,_reconnectConnector:r}=h(),{activeChain:o,wcSignClient:i}=g();return(0,ot.useEffect)(()=>{r&&(t&&o?R({onError:n}):!t&&e&&R({onError:n}))},[]),(0,ot.useEffect)(()=>{var s,a,c,p,d,E,C,T,N,re;r&&(r==="cosmostation"&&((a=(s=me()).subscription)==null||a.call(s,()=>{R({onError:n})})),r==="keplr"&&((p=(c=le()).subscription)==null||p.call(c,()=>{R({onError:n})})),r==="leap"&&((E=(d=ue()).subscription)==null||E.call(d,()=>{R({onError:n})})),r==="vectis"&&((T=(C=pe()).subscription)==null||T.call(C,()=>{R({onError:n})})),r==="walletconnect"&&i&&((re=(N=Q()).subscription)==null||re.call(N,()=>{R({onError:n})})))},[r,i]),null},rt=()=>(on(),null);var J=require("react/jsx-runtime"),go=new Ie.QueryClient({}),fo=({children:t,grazOptions:e,debug:n,...r})=>(e&&Ue(e),(0,J.jsxs)(Ie.QueryClientProvider,{client:go,...r,children:[(0,J.jsxs)(nn,{children:[(0,J.jsx)(rt,{}),t]}),n?(0,J.jsx)(rn.ReactQueryDevtools,{initialIsOpen:!1,position:"bottom-right"}):null]},"graz-provider"));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAvailableWallets,getCosmostation,getKeplr,getLeap,getOfflineSigners,getQueryRaw,getQuerySmart,getRecentChain,getVectis,getWCCosmostation,getWCKeplr,getWCLeap,getWallet,getWalletConnect,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useActiveWalletType,useBalance,useBalanceStaked,useBalances,useCheckWallet,useConnect,useCosmWasmClient,useCosmWasmSigningClient,useCosmWasmTmSigningClient,useDisconnect,useExecuteContract,useGrazEvents,useInstantiateContract,useOfflineSigners,useQueryRaw,useQuerySmart,useRecentChain,useSendIbcTokens,useSendTokens,useStargateClient,useStargateSigningClient,useStargateTmSigningClient,useSuggestChain,useSuggestChainAndConnect,useTendermintClient});
1
+ "use strict";var wn=Object.create;var Ae=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var An=Object.getPrototypeOf,En=Object.prototype.hasOwnProperty;var In=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),bn=(t,e)=>{for(var n in e)Ae(t,n,{get:e[n],enumerable:!0})},Ct=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Sn(e))!En.call(t,o)&&o!==n&&Ae(t,o,{get:()=>e[o],enumerable:!(r=Cn(e,o))||r.enumerable});return t};var Ee=(t,e,n)=>(n=t!=null?wn(An(t)):{},Ct(e||!t||!t.__esModule?Ae(n,"default",{value:t,enumerable:!0}):n,t)),Tn=t=>Ct(Ae({},"__esModule",{value:!0}),t);var be=In((Bo,Wt)=>{"use strict";Wt.exports=E;var P=null;try{P=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function E(t,e,n){this.low=t|0,this.high=e|0,this.unsigned=!!n}E.prototype.__isLong__;Object.defineProperty(E.prototype,"__isLong__",{value:!0});function _(t){return(t&&t.__isLong__)===!0}E.isLong=_;var At={},Et={};function X(t,e){var n,r,o;return e?(t>>>=0,(o=0<=t&&t<256)&&(r=Et[t],r)?r:(n=I(t,(t|0)<0?-1:0,!0),o&&(Et[t]=n),n)):(t|=0,(o=-128<=t&&t<128)&&(r=At[t],r)?r:(n=I(t,t<0?-1:0,!1),o&&(At[t]=n),n))}E.fromInt=X;function R(t,e){if(isNaN(t))return e?Y:q;if(e){if(t<0)return Y;if(t>=xt)return kt}else{if(t<=-bt)return F;if(t+1>=bt)return Ot}return t<0?R(-t,e).neg():I(t%te|0,t/te|0,e)}E.fromNumber=R;function I(t,e,n){return new E(t,e,n)}E.fromBits=I;var Ie=Math.pow;function Be(t,e,n){if(t.length===0)throw Error("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return q;if(typeof e=="number"?(n=e,e=!1):e=!!e,n=n||10,n<2||36<n)throw RangeError("radix");var r;if((r=t.indexOf("-"))>0)throw Error("interior hyphen");if(r===0)return Be(t.substring(1),e,n).neg();for(var o=R(Ie(n,8)),i=q,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),c=parseInt(t.substring(s,s+a),n);if(a<8){var u=R(Ie(n,a));i=i.mul(u).add(R(c))}else i=i.mul(o),i=i.add(R(c))}return i.unsigned=e,i}E.fromString=Be;function L(t,e){return typeof t=="number"?R(t,e):typeof t=="string"?Be(t,e):I(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}E.fromValue=L;var It=65536,kn=1<<24,te=It*It,xt=te*te,bt=xt/2,Tt=X(kn),q=X(0);E.ZERO=q;var Y=X(0,!0);E.UZERO=Y;var ee=X(1);E.ONE=ee;var vt=X(1,!0);E.UONE=vt;var Ue=X(-1);E.NEG_ONE=Ue;var Ot=I(-1,2147483647,!1);E.MAX_VALUE=Ot;var kt=I(-1,-1,!0);E.MAX_UNSIGNED_VALUE=kt;var F=I(0,-2147483648,!1);E.MIN_VALUE=F;var l=E.prototype;l.toInt=function(){return this.unsigned?this.low>>>0:this.low};l.toNumber=function(){return this.unsigned?(this.high>>>0)*te+(this.low>>>0):this.high*te+(this.low>>>0)};l.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(F)){var n=R(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var i=R(Ie(e,6),this.unsigned),s=this,a="";;){var c=s.div(i),u=s.sub(c.mul(i)).toInt()>>>0,h=u.toString(e);if(s=c,s.isZero())return h+a;for(;h.length<6;)h="0"+h;a=""+h+a}};l.getHighBits=function(){return this.high};l.getHighBitsUnsigned=function(){return this.high>>>0};l.getLowBits=function(){return this.low};l.getLowBitsUnsigned=function(){return this.low>>>0};l.getNumBitsAbs=function(){if(this.isNegative())return this.eq(F)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<<n);n--);return this.high!=0?n+33:n+1};l.isZero=function(){return this.high===0&&this.low===0};l.eqz=l.isZero;l.isNegative=function(){return!this.unsigned&&this.high<0};l.isPositive=function(){return this.unsigned||this.high>=0};l.isOdd=function(){return(this.low&1)===1};l.isEven=function(){return(this.low&1)===0};l.equals=function(e){return _(e)||(e=L(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};l.eq=l.equals;l.notEquals=function(e){return!this.eq(e)};l.neq=l.notEquals;l.ne=l.notEquals;l.lessThan=function(e){return this.comp(e)<0};l.lt=l.lessThan;l.lessThanOrEqual=function(e){return this.comp(e)<=0};l.lte=l.lessThanOrEqual;l.le=l.lessThanOrEqual;l.greaterThan=function(e){return this.comp(e)>0};l.gt=l.greaterThan;l.greaterThanOrEqual=function(e){return this.comp(e)>=0};l.gte=l.greaterThanOrEqual;l.ge=l.greaterThanOrEqual;l.compare=function(e){if(_(e)||(e=L(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};l.comp=l.compare;l.negate=function(){return!this.unsigned&&this.eq(F)?F:this.not().add(ee)};l.neg=l.negate;l.add=function(e){_(e)||(e=L(e));var n=this.high>>>16,r=this.high&65535,o=this.low>>>16,i=this.low&65535,s=e.high>>>16,a=e.high&65535,c=e.low>>>16,u=e.low&65535,h=0,A=0,C=0,x=0;return x+=i+u,C+=x>>>16,x&=65535,C+=o+c,A+=C>>>16,C&=65535,A+=r+a,h+=A>>>16,A&=65535,h+=n+s,h&=65535,I(C<<16|x,h<<16|A,this.unsigned)};l.subtract=function(e){return _(e)||(e=L(e)),this.add(e.neg())};l.sub=l.subtract;l.multiply=function(e){if(this.isZero())return q;if(_(e)||(e=L(e)),P){var n=P.mul(this.low,this.high,e.low,e.high);return I(n,P.get_high(),this.unsigned)}if(e.isZero())return q;if(this.eq(F))return e.isOdd()?F:q;if(e.eq(F))return this.isOdd()?F:q;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(Tt)&&e.lt(Tt))return R(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=this.high&65535,i=this.low>>>16,s=this.low&65535,a=e.high>>>16,c=e.high&65535,u=e.low>>>16,h=e.low&65535,A=0,C=0,x=0,W=0;return W+=s*h,x+=W>>>16,W&=65535,x+=i*h,C+=x>>>16,x&=65535,x+=s*u,C+=x>>>16,x&=65535,C+=o*h,A+=C>>>16,C&=65535,C+=i*u,A+=C>>>16,C&=65535,C+=s*c,A+=C>>>16,C&=65535,A+=r*h+o*u+i*c+s*a,A&=65535,I(x<<16|W,A<<16|C,this.unsigned)};l.mul=l.multiply;l.divide=function(e){if(_(e)||(e=L(e)),e.isZero())throw Error("division by zero");if(P){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?P.div_u:P.div_s)(this.low,this.high,e.low,e.high);return I(n,P.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Y:q;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Y;if(e.gt(this.shru(1)))return vt;i=Y}else{if(this.eq(F)){if(e.eq(ee)||e.eq(Ue))return F;if(e.eq(F))return ee;var s=this.shr(1);return r=s.div(e).shl(1),r.eq(q)?e.isNegative()?ee:Ue:(o=this.sub(e.mul(r)),i=r.add(o.div(e)),i)}else if(e.eq(F))return this.unsigned?Y:q;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=q}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(r)/Math.LN2),c=a<=48?1:Ie(2,a-48),u=R(r),h=u.mul(e);h.isNegative()||h.gt(o);)r-=c,u=R(r,this.unsigned),h=u.mul(e);u.isZero()&&(u=ee),i=i.add(u),o=o.sub(h)}return i};l.div=l.divide;l.modulo=function(e){if(_(e)||(e=L(e)),P){var n=(this.unsigned?P.rem_u:P.rem_s)(this.low,this.high,e.low,e.high);return I(n,P.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};l.mod=l.modulo;l.rem=l.modulo;l.not=function(){return I(~this.low,~this.high,this.unsigned)};l.and=function(e){return _(e)||(e=L(e)),I(this.low&e.low,this.high&e.high,this.unsigned)};l.or=function(e){return _(e)||(e=L(e)),I(this.low|e.low,this.high|e.high,this.unsigned)};l.xor=function(e){return _(e)||(e=L(e)),I(this.low^e.low,this.high^e.high,this.unsigned)};l.shiftLeft=function(e){return _(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?I(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):I(0,this.low<<e-32,this.unsigned)};l.shl=l.shiftLeft;l.shiftRight=function(e){return _(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?I(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):I(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};l.shr=l.shiftRight;l.shiftRightUnsigned=function(e){if(_(e)&&(e=e.toInt()),e&=63,e===0)return this;var n=this.high;if(e<32){var r=this.low;return I(r>>>e|n<<32-e,n>>>e,this.unsigned)}else return e===32?I(n,0,this.unsigned):I(n>>>e-32,0,this.unsigned)};l.shru=l.shiftRightUnsigned;l.shr_u=l.shiftRightUnsigned;l.toSigned=function(){return this.unsigned?I(this.low,this.high,!1):this};l.toUnsigned=function(){return this.unsigned?this:I(this.low,this.high,!0)};l.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};l.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};l.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};E.fromBytes=function(e,n,r){return r?E.fromBytesLE(e,n):E.fromBytesBE(e,n)};E.fromBytesLE=function(e,n){return new E(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)};E.fromBytesBE=function(e,n){return new E(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)}});var vo={};bn(vo,{GrazEvents:()=>ht,GrazProvider:()=>xo,WALLET_TYPES:()=>qe,WalletType:()=>Re,checkWallet:()=>M,clearRecentChain:()=>He,clearSession:()=>N,configureGraz:()=>Ze,connect:()=>ne,defineChain:()=>Zn,defineChainInfo:()=>Yn,defineChains:()=>gt,disconnect:()=>Te,executeContract:()=>et,getActiveChainCurrency:()=>Ve,getAvailableWallets:()=>Wn,getCosmostation:()=>ue,getKeplr:()=>me,getLeap:()=>pe,getMetamaskSnapLeap:()=>Ge,getOfflineSigners:()=>Qe,getQueryRaw:()=>nt,getQuerySmart:()=>tt,getRecentChain:()=>Nn,getVectis:()=>ge,getWCCosmostation:()=>je,getWCKeplr:()=>Ke,getWCLeap:()=>ze,getWallet:()=>T,getWalletConnect:()=>U,instantiateContract:()=>Je,mainnetChains:()=>Xn,mainnetChainsArray:()=>Jn,reconnect:()=>B,sendIbcTokens:()=>Xe,sendTokens:()=>Ye,suggestChain:()=>xe,suggestChainAndConnect:()=>$e,testnetChains:()=>eo,testnetChainsArray:()=>to,useAccount:()=>z,useActiveChain:()=>co,useActiveChainCurrency:()=>lo,useActiveChainValidators:()=>uo,useActiveWalletType:()=>no,useBalance:()=>oo,useBalanceStaked:()=>ao,useBalances:()=>gn,useCheckWallet:()=>fe,useConnect:()=>ro,useCosmWasmClient:()=>Ne,useCosmWasmSigningClient:()=>Eo,useCosmWasmTmSigningClient:()=>bo,useDisconnect:()=>io,useExecuteContract:()=>wo,useGrazEvents:()=>dn,useInstantiateContract:()=>yo,useOfflineSigners:()=>so,useQueryRaw:()=>So,useQuerySmart:()=>Co,useRecentChain:()=>mo,useSendIbcTokens:()=>ho,useSendTokens:()=>fo,useStargateClient:()=>We,useStargateSigningClient:()=>Ao,useStargateTmSigningClient:()=>Io,useSuggestChain:()=>po,useSuggestChainAndConnect:()=>go,useTendermintClient:()=>Me});module.exports=Tn(vo);var Z="graz-reconnect-session";var Le=require("zustand"),St=require("zustand/middleware"),J=require("zustand/middleware");var Re=(u=>(u.KEPLR="keplr",u.LEAP="leap",u.VECTIS="vectis",u.COSMOSTATION="cosmostation",u.WALLETCONNECT="walletconnect",u.WC_KEPLR_MOBILE="wc_keplr_mobile",u.WC_LEAP_MOBILE="wc_leap_mobile",u.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",u.METAMASK_SNAP_LEAP="metamask_snap_leap",u))(Re||{}),qe=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","metamask_snap_leap"];var xn={recentChain:null,defaultChain:null,defaultSigningClient:"stargate",walletType:"keplr",walletConnect:{options:null,web3Modal:null},_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},le={account:null,activeChain:null,balances:null,status:"disconnected",wcSignClient:null},vn={name:"graz-session",version:1,partialize:t=>({account:t.account,activeChain:t.activeChain}),storage:(0,St.createJSONStorage)(()=>sessionStorage)},On={name:"graz-internal",partialize:t=>({recentChain:t.recentChain,_reconnect:t._reconnect,_reconnectConnector:t._reconnectConnector}),version:1},g=(0,Le.create)((0,J.subscribeWithSelector)((0,J.persist)(()=>le,vn))),f=(0,Le.create)((0,J.subscribeWithSelector)((0,J.persist)(()=>xn,On)));var ue=()=>{if(typeof window.cosmostation.providers.keplr<"u"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:r=>(window.cosmostation.cosmos.on("accountChanged",()=>{N(),r()}),()=>{window.cosmostation.cosmos.off("accountChanged",()=>{N(),r()})})})}throw f.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var me=()=>{if(typeof window.keplr<"u"){let t=window.keplr;return Object.assign(t,{subscription:r=>(window.addEventListener("keplr_keystorechange",()=>{N(),r()}),()=>{window.removeEventListener("keplr_keystorechange",()=>{N(),r()})})})}throw f.getState()._notFoundFn(),new Error("window.keplr is not defined")};var pe=()=>{if(typeof window.leap<"u"){let t=window.leap;return Object.assign(t,{subscription:r=>(window.addEventListener("leap_keystorechange",()=>{N(),r()}),()=>{window.removeEventListener("leap_keystorechange",()=>{N(),r()})})})}throw f.getState()._notFoundFn(),new Error("window.leap is not defined")};var Nt=Ee(be());var Mt=t=>{let e=window.ethereum;if(e&&t){let n=async()=>await e.request({method:"wallet_getSnaps"}),r=async w=>{try{let S=await n();return Object.values(S).find(O=>O.id===t.id&&(!w||O.version===w))}catch{return}},o=async()=>{await e.request({method:"wallet_requestSnaps",params:{[t.id]:t.params||{}}})},i=async()=>{let w=await e.request({method:"web3_clientVersion"});if(!(w==null?void 0:w.includes("flask")))throw new Error("Metamask Flask is not detected");return!0},s=async w=>{await r()||await o()},a=async(w,S,O)=>{let G=await e.request({method:"wallet_invokeSnap",params:{snapId:t.id,request:{method:"signDirect",params:{chainId:w,signerAddress:S,signDoc:O}}}}),Q=O.accountNumber,ce=new Nt.default(Q.low,Q.high,Q.unsigned);return{signature:G.signature,signed:{...G.signed,accountNumber:`${ce.toString()}`,authInfoBytes:new Uint8Array(Object.values(G.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(G.signed.bodyBytes))}}},c=async(w,S,O)=>await e.request({method:"wallet_invokeSnap",params:{snapId:t.id,request:{method:"signAmino",params:{chainId:w,signerAddress:S,signDoc:O}}}}),u=async w=>{let S=await e.request({method:"wallet_invokeSnap",params:{snapId:t.id,request:{method:"getKey",params:{chainId:w}}}});if(!S)throw new Error("No response from Metamask");return S.pubKey=Uint8Array.from(Object.values(S.pubkey)),delete S.pubkey,{...S}},h=async w=>{let S=await u(w);return{address:S.bech32Address,algo:S.algo,pubkey:S.pubKey}},A=async(...w)=>{let[S,O,G,Q]=w;return await c(S,O,G)},C=async(...w)=>{let[S,O,G]=w;return await a(S,O,G)},x=w=>({getAccounts:async()=>[await h(w)],signDirect:(S,O)=>C(w,S,O)}),W=w=>({getAccounts:async()=>[await h(w)],signAmino:(S,O)=>A(w,S,O)});return{getKey:u,getOfflineSigner:w=>({getAccounts:async()=>[await h(w)],signDirect:(S,O)=>C(w,S,O),signAmino:(S,O)=>A(w,S,O)}),getOfflineSignerAuto:async w=>(await u(w)).isNanoLedger?W(w):x(w),getOfflineSignerOnlyAmino:W,signDirect:C,signAmino:A,enable:s,experimentalSuggestChain:async(...w)=>{await Promise.reject(new Error("Metamask does not support experimentalSuggestChain"))},init:i}}throw f.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Ge=()=>Mt({id:"npm:@leapwallet/metamask-cosmos-snap"});var Dt=require("@cosmjs/encoding"),Ft=Ee(be());var ge=()=>{if(typeof window.vectis<"u"){let t=window.vectis.cosmos;return{enable:a=>t.enable(a),getOfflineSigner:a=>t.getOfflineSigner(a),getOfflineSignerAuto:a=>t.getOfflineSignerAuto(a),getKey:async a=>{let c=await t.getKey(a);return{address:(0,Dt.fromBech32)(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}},subscription:a=>(window.addEventListener("vectis_accountChanged",()=>{N(),a()}),()=>{window.removeEventListener("vectis_accountChanged",()=>{N(),a()})}),getOfflineSignerOnlyAmino:(...a)=>t.getOfflineSignerAmino(...a),experimentalSuggestChain:async(...a)=>{let[c]=a,u={...c,rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr};return t.suggestChains([u])},signDirect:async(...a)=>{var h;let{1:c,2:u}=a;return t.signDirect(c,{bodyBytes:u.bodyBytes||Uint8Array.from([]),authInfoBytes:u.authInfoBytes||Uint8Array.from([]),accountNumber:Ft.default.fromString(((h=u.accountNumber)==null?void 0:h.toString())||"",!1),chainId:u.chainId||""})},signAmino:async(...a)=>{let{1:c,2:u}=a;return t.signAmino(c,u)}}}throw f.getState()._notFoundFn(),new Error("window.vectis is not defined")};var qt=require("@cosmjs/encoding"),Lt=require("@walletconnect/sign-client"),Ut=require("@walletconnect/utils"),Bt=Ee(be());var j=()=>typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,_t=()=>j()&&navigator.userAgent.toLowerCase().includes("android"),Pt=()=>j()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Rt=(t,e,n=new Error("Promise timed out"))=>{let r=new Promise((o,i)=>{setTimeout(()=>{i(n)},e)});return Promise.race([t,r])};var U=t=>{var Q,ce,wt;if(!((wt=(ce=(Q=f.getState().walletConnect)==null?void 0:Q.options)==null?void 0:ce.projectId)!=null&&wt.trim()))throw new Error("walletConnect.options.projectId is not defined");let e=(t==null?void 0:t.encoding)||"base64",n=p=>{if(!t)return;let{appUrl:m,formatNativeUrl:d}=t;if(j()){if(_t())if(!p)window.open(m.mobile.android,"_self","noreferrer noopener");else{let y=d(m.mobile.android,p,"android");window.open(y,"_self","noreferrer noopener")}if(Pt())if(!p)window.open(m.mobile.ios,"_self","noreferrer noopener");else{let y=d(m.mobile.ios,p,"ios");window.open(y,"_self","noreferrer noopener")}}},r=()=>{let{wcSignClient:p}=g.getState();if(!p)throw new Error("walletConnect.signClient is not defined");N(),f.setState({_reconnect:!1,_reconnectConnector:null,recentChain:null})},o=async p=>{let{wcSignClient:m}=g.getState();if(!m)throw new Error("walletConnect.signClient is not defined");if(!p)throw new Error("No wallet connect session");await m.disconnect({topic:p,reason:(0,Ut.getSdkError)("USER_DISCONNECTED")}),await a(m),r()},i=p=>{var m,d;try{let{wcSignClient:y}=g.getState();if(!y)throw new Error("walletConnect.signClient is not defined");let b=y.session.getAll().at(-1);if(!b)return;let v=(d=(m=y.session.getAll().at(-1))==null?void 0:m.namespaces.cosmos)==null?void 0:d.accounts.find(k=>k.startsWith(`cosmos:${p}`));if(!(b.expiry*1e3>Date.now()+1e3))throw o(b.topic),new Error("invalid session");if(!v)try{let k=y.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${p}`],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 b}catch(y){if(!y.message.toLowerCase().includes("no matching key"))throw y}},s=p=>{try{return i(p)}catch{return}},a=async p=>{try{let m=p.core.pairing.pairings.getAll({active:!1});if(!m.length)return;await Promise.all(m.map(async d=>{await p.core.pairing.pairings.delete(d.topic,{code:7001,message:"clear pairing"})}))}catch(m){if(!m.message.toLowerCase().includes("no matching key"))throw m}},c=async()=>{let{walletConnect:p}=f.getState();if(!(p!=null&&p.options))throw new Error("walletConnect.options is not defined");let{wcSignClient:m}=g.getState();if(m)return g.setState({wcSignClient:m}),m;let d=await Lt.SignClient.init(p.options);return g.setState({wcSignClient:d}),d},u=p=>{let{wcSignClient:m}=g.getState();if(m)return m.events.on("session_delete",d=>{r()}),m.events.on("session_expire",d=>{r()}),m.events.on("session_event",d=>{var y,b;if(d.params.event.name==="accountsChanged"&&((y=d.params.event.data)==null?void 0:y[0])!==((b=g.getState().account)==null?void 0:b.bech32Address)){let v=d.params.chainId.split(":")[1];v&&h(v)}else p()}),()=>{m.events.off("session_delete",d=>{r()}),m.events.off("session_expire",d=>{r()}),m.events.off("session_event",d=>{var y,b;if(d.params.event.name==="accountsChanged"&&((y=d.params.event.data)==null?void 0:y[0])!==((b=g.getState().account)==null?void 0:b.bech32Address)){let v=d.params.chainId.split(":")[1];v&&h(v)}else p()})}},h=async p=>{var we;let{wcSignClient:m}=g.getState();if(!m)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:d}=f.getState();if(!((we=d==null?void 0:d.options)!=null&&we.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:y}=await import("@web3modal/standalone"),b=new y({projectId:d.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE",...d.web3Modal}),{account:v,activeChain:K}=g.getState(),k=s(p);if((K==null?void 0:K.chainId)!==p&&!k||!v){let{uri:D,approval:Ce}=await m.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${p}`],events:["chainChanged","accountsChanged"]}}});if(!D)throw new Error("No wallet connect uri");t?n(D):await b.openModal({uri:D});let yn=async H=>H.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Pe,Se)=>{Ce().then(Pe).catch(Se),H.addEventListener("abort",()=>{Se(new Error("User closed wallet connect"))})});try{let H=new AbortController,Pe=H.signal;b.subscribeModal(Se=>{Se.open||H.abort()}),await yn(Pe)}catch(H){if(b.closeModal(),!H.message.toLowerCase().includes("no matching key"))return Promise.reject(H)}return t||b.closeModal(),Promise.resolve()}try{await Rt((async()=>{let D=await C(p);g.setState({account:D})})(),15e3,new Error("Connection timeout"))}catch(D){if(o(k==null?void 0:k.topic),!D.message.toLowerCase().includes("no matching key"))throw D}},A=async p=>{var b;let{wcSignClient:m}=g.getState();if(!m)throw new Error("walletConnect.signClient is not defined");let d=(b=i(p))==null?void 0:b.topic;if(!d)throw new Error("No wallet connect session");n();let y=await m.request({topic:d,chainId:`cosmos:${p}`,request:{method:"cosmos_getAccounts",params:{}}});if(!y[0])throw new Error("No wallet connect account");return{address:y[0].address,algo:y[0].algo,pubkey:new Uint8Array(Buffer.from(y[0].pubkey,e))}},C=async p=>{let{address:m,algo:d,pubkey:y}=await A(p);return{address:(0,qt.fromBech32)(m).data,algo:d,bech32Address:m,name:"",pubKey:y,isKeystone:!1,isNanoLedger:!1}},x=async(...p)=>{var D,Ce;let[m,d,y]=p,{account:b,wcSignClient:v}=g.getState();if(!v)throw new Error("walletConnect.signClient is not defined");if(!b)throw new Error("account is not defined");let K=(D=i(m))==null?void 0:D.topic;if(!K)throw new Error("No wallet connect session");if(!y.bodyBytes)throw new Error("No bodyBytes");if(!y.authInfoBytes)throw new Error("No authInfoBytes");let k={topic:K,chainId:`cosmos:${m}`,request:{method:"cosmos_signDirect",params:{signerAddress:d,signDoc:{...y,bodyBytes:Buffer.from(y.bodyBytes).toString(e),authInfoBytes:Buffer.from(y.authInfoBytes).toString(e),accountNumber:(Ce=y.accountNumber)==null?void 0:Ce.toString()}}}};return n(),await v.request(k)},W=async(...p)=>{let[m,d,y]=p,{signature:b,signed:v}=await x(m,d,y);return{signed:{chainId:v.chainId,accountNumber:Bt.default.fromString(v.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(v.authInfoBytes,e)),bodyBytes:new Uint8Array(Buffer.from(v.bodyBytes,e))},signature:b}},ae=async(...p)=>{var D;let[m,d,y,b]=p,{wcSignClient:v}=g.getState(),{account:K}=g.getState();if(!v)throw new Error("walletConnect.signClient is not defined");if(!K)throw new Error("account is not defined");let k=(D=i(m))==null?void 0:D.topic;if(!k)throw new Error("No wallet connect session");return n(),await v.request({topic:k,chainId:`cosmos:${m}`,request:{method:"cosmos_signDirect",params:{signerAddress:d,signDoc:y}}})},ye=async(...p)=>{let[m,d,y,b]=p;return await ae(m,d,y)},yt=p=>({getAccounts:async()=>[await A(p)],signDirect:(m,d)=>W(p,m,d)}),w=p=>({getAccounts:async()=>[await A(p)],signAmino:(m,d)=>ye(p,m,d)});return{enable:h,experimentalSuggestChain:async(...p)=>{await Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"))},getKey:C,getOfflineSigner:p=>({getAccounts:async()=>[await A(p)],signDirect:(m,d)=>W(p,m,d),signAmino:(m,d)=>ye(p,m,d)}),getOfflineSignerAuto:async p=>(await C(p)).isNanoLedger?w(p):yt(p),getOfflineSignerOnlyAmino:w,signAmino:ye,signDirect:W,subscription:u,init:c}};var je=()=>{var e,n,r;if(!((r=(n=(e=f.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!j())throw new Error("WalletConnect Leap mobile is only supported in mobile");let t={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_leap_mobile",formatNativeUrl:(o,i,s)=>`${o.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return U(t)};var Ke=()=>{var e,n,r;if(!((r=(n=(e=f.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!j())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let t={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(o,i,s)=>{let a=o.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);switch(s){case"ios":return`${a}://wcV2?${c}`;case"android":return`${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return`${a}://wc?uri=${c}`}}};return U(t)};var ze=()=>{var e,n,r;if(!((r=(n=(e=f.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!j())throw new Error("WalletConnect Leap mobile is only supported in mobile");let t={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(o,i,s)=>{let a=o.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);switch(s){case"ios":return`${a}://wcV2?${c}`;case"android":return`${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return`${a}://wc?uri=${c}`}}};return U(t)};var M=(t=f.getState().walletType)=>{try{return T(t),!0}catch{return!1}},N=()=>{window.sessionStorage.removeItem(Z),g.setState(le)},T=(t=f.getState().walletType)=>{switch(t){case"keplr":return me();case"leap":return pe();case"cosmostation":return ue();case"vectis":return ge();case"walletconnect":return U();case"wc_keplr_mobile":return Ke();case"wc_leap_mobile":return ze();case"wc_cosmostation_mobile":return je();case"metamask_snap_leap":return Ge();default:throw new Error("Unknown wallet type")}},Wn=()=>Object.fromEntries(qe.map(t=>[t,M(t)]));var ne=async t=>{var e;try{let{defaultChain:n,recentChain:r,walletType:o}=f.getState(),i=(t==null?void 0:t.walletType)||o;if(!M(i))throw new Error(`${i} is not available`);let a=T(i),c=(t==null?void 0:t.chain)||r||n;if(!c)throw new Error("No last known connected chain, connect action requires chain info");g.setState(C=>{let x=f.getState()._reconnect||!!f.getState()._reconnectConnector||!!c;return C.activeChain&&C.activeChain.chainId!==c.chainId?{status:"connecting"}:x?{status:"reconnecting"}:{status:"connecting"}});let{account:u,activeChain:h}=g.getState();if(await((e=a.init)==null?void 0:e.call(a)),!u||(h==null?void 0:h.chainId)!==c.chainId){await a.enable(c.chainId);let C=await a.getKey(c.chainId);g.setState({account:C})}f.setState({recentChain:c,walletType:i,_reconnect:!!(t!=null&&t.autoReconnect),_reconnectConnector:i}),g.setState({activeChain:c,status:"connected"}),typeof window<"u"&&window.sessionStorage.setItem(Z,"Active");let{account:A}=g.getState();return{account:A,walletType:i,chain:c}}catch(n){throw console.error("connect ",n),g.getState().account===null&&g.setState({status:"disconnected"}),g.getState().account&&g.getState().activeChain&&g.setState({status:"connected"}),n}},Te=async(t=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(Z),g.setState(le),f.setState(e=>({_reconnect:!1,_reconnectConnector:null,recentChain:t?null:e.recentChain})),Promise.resolve()),B=async t=>{var o;let{recentChain:e,_reconnectConnector:n,_reconnect:r}=f.getState();try{let i=M(n||void 0);if(e&&i&&n)return await ne({chain:e,walletType:n,autoReconnect:r})}catch(i){(o=t==null?void 0:t.onError)==null||o.call(t,i),Te()}},Qe=async t=>{if(!(t!=null&&t.chainId))throw new Error("chainId is required");let{walletType:e}=f.getState(),n=t.walletType||e;if(!M(n))throw new Error(`${n} is not available`);let o=T(n),i=o.getOfflineSigner(t.chainId),s=o.getOfflineSignerOnlyAmino(t.chainId),a=await o.getOfflineSignerAuto(t.chainId);return{offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}};var He=()=>{f.setState({recentChain:null})},Ve=t=>{let{activeChain:e}=g.getState();return e==null?void 0:e.currencies.find(n=>n.coinMinimalDenom===t)},Nn=()=>f.getState().recentChain,xe=async t=>(await T().experimentalSuggestChain(t),t),$e=async({chainInfo:t,rpcHeaders:e,gas:n,path:r,...o})=>{let i=await xe(t);return{...await ne({chain:{chainId:t.chainId,currencies:t.currencies,rest:t.rest,rpc:t.rpc,rpcHeaders:e,gas:n,path:r},...o}),chain:i}};var Ze=(t={})=>(f.setState(e=>({defaultChain:t.defaultChain||e.defaultChain,defaultSigningClient:t.defaultSigningClient||e.defaultSigningClient,walletConnect:t.walletConnect||e.walletConnect,walletType:t.defaultWallet||e.walletType,_notFoundFn:t.onNotFound||e._notFoundFn,_onReconnectFailed:t.onReconnectFailed||e._onReconnectFailed,_reconnect:t.autoReconnect===void 0?!0:t.autoReconnect||e._reconnect})),t);var Ye=async({signingClient:t,senderAddress:e,recipientAddress:n,amount:r,fee:o,memo:i})=>{if(!t)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return t.sendTokens(e,n,r,o,i)},Xe=async({signingClient:t,senderAddress:e,recipientAddress:n,transferAmount:r,sourcePort:o,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:u})=>{if(!t)throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return t.sendIbcTokens(e,n,r,o,i,s,a,c,u)},Je=async({signingClient:t,senderAddress:e,msg:n,fee:r,options:o,label:i,codeId:s})=>{if(!t)throw new Error("CosmWasm signing client is not ready");return t.instantiate(e,s,n,i,r,o)},et=async({signingClient:t,senderAddress:e,msg:n,fee:r,contractAddress:o,funds:i,memo:s})=>{if(!t)throw new Error("CosmWasm signing client is not ready");return t.execute(e,o,n,r,s,i)},tt=async(t,e,n)=>{if(!n)throw new Error("CosmWasm client is not ready");return await n.queryContractSmart(t,e)},nt=(t,e,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(e);return n.queryContractRaw(t,r)};var jt=require("@keplr-wallet/cosmos"),Kt={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Mn={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Dn={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Fn={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},_n={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Pn={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Gt=[Kt,Mn,Dn,Fn,_n,Pn],ot={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Kt,bip44:{coinType:118},bech32Config:jt.Bech32Address.defaultBech32Config("axelar"),currencies:Gt,feeCurrencies:Gt};var Qt=require("@keplr-wallet/cosmos"),Ht={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},zt=[Ht],rt={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:Ht,bip44:{coinType:118},bech32Config:Qt.Bech32Address.defaultBech32Config("cosmos"),currencies:zt,feeCurrencies:zt};var $t=require("@keplr-wallet/cosmos"),Zt={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Rn={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},qn={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Ln={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Un={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Bn={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Gn={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},jn={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Kn={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},zn={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Qn={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},Vt=[Zt,Rn,qn,Ln,Un,Bn,Gn,jn,Kn,zn,Qn],it={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Zt,bip44:{coinType:118},bech32Config:$t.Bech32Address.defaultBech32Config("juno"),currencies:Vt,feeCurrencies:Vt};var Xt=require("@keplr-wallet/cosmos"),Jt={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Hn={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Yt=[Jt,Hn],st={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Jt,bip44:{coinType:118},bech32Config:Xt.Bech32Address.defaultBech32Config("osmo"),currencies:Yt,feeCurrencies:Yt};var tn=require("@keplr-wallet/cosmos"),nn={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},en=[nn],at={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:nn,bip44:{coinType:118},bech32Config:tn.Bech32Address.defaultBech32Config("somm"),currencies:en,feeCurrencies:en};var rn=require("@keplr-wallet/cosmos"),sn={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},on=[sn],ct={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:rn.Bech32Address.defaultBech32Config("CRE"),currencies:on,feeCurrencies:on,stakeCurrency:sn,coinType:118};var an=require("@keplr-wallet/cosmos"),lt={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Vn=[lt],ut={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:lt,bip44:{coinType:118},bech32Config:an.Bech32Address.defaultBech32Config("juno"),currencies:Vn,feeCurrencies:[lt],coinType:118};var cn=require("@keplr-wallet/cosmos"),mt={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},$n=[mt],pt={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:mt,bip44:{coinType:118},bech32Config:cn.Bech32Address.defaultBech32Config("osmo"),currencies:$n,feeCurrencies:[mt],coinType:118};var gt=t=>t,Zn=t=>t,Yn=t=>t,Xn=gt({axelar:ot,cosmoshub:rt,juno:it,osmosis:st,sommelier:at}),Jn=[ot,rt,it,st,at],eo=gt({crescent:ct,juno:ut,osmosis:pt}),to=[ct,ut,pt];var V=require("@tanstack/react-query"),oe=require("react");var ln=require("@cosmjs/cosmwasm-stargate"),un=require("@cosmjs/stargate"),ve=require("@cosmjs/tendermint-rpc"),Oe=require("@tanstack/react-query"),ke=require("react");var We=()=>{let t=g(n=>n.activeChain),e=(0,ke.useMemo)(()=>["USE_STARGATE_CLIENT",t],[t]);return(0,Oe.useQuery)({queryKey:e,queryFn:async({queryKey:[,n]})=>{if(!n)throw new Error("No chain found");let r={url:n.rpc,headers:{...n.rpcHeaders||{}}};return await un.StargateClient.connect(r)},enabled:!!t,refetchOnWindowFocus:!1})},Ne=()=>{let t=g(n=>n.activeChain),e=(0,ke.useMemo)(()=>["USE_COSMWASM_CLIENT",t],[t]);return(0,Oe.useQuery)({queryKey:e,queryFn:async({queryKey:[,n]})=>{if(!n)throw new Error("No chain found");let r={url:n.rpc,headers:{...n.rpcHeaders||{}}};return await ln.CosmWasmClient.connect(r)},enabled:!!t,refetchOnWindowFocus:!1})},Me=t=>{let e=g(r=>r.activeChain),n=(0,ke.useMemo)(()=>["USE_TENDERMINT_CLIENT",t,e],[t,e]);return(0,Oe.useQuery)({queryKey:n,queryFn:async({queryKey:[,r,o]})=>{if(!o)throw new Error("No chain found");let i={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await(r==="tm37"?ve.Tendermint37Client:ve.Tendermint34Client).connect(i)},enabled:!!e,refetchOnWindowFocus:!1})};var mn=require("@tanstack/react-query"),pn=require("zustand/shallow");var no=()=>f(t=>({walletType:t.walletType,isCosmostation:t.walletType==="cosmostation",isCosmostationMobile:t.walletType==="wc_cosmostation_mobile",isKeplr:t.walletType==="keplr",isKeplrMobile:t.walletType==="wc_keplr_mobile",isLeap:t.walletType==="leap",isLeapMobile:t.walletType==="wc_leap_mobile",isVectis:t.walletType==="vectis",isWalletConnect:t.walletType==="walletconnect"}),pn.shallow),fe=t=>{let n=["USE_CHECK_WALLET",f(o=>t||o.walletType)];return(0,mn.useQuery)(n,({queryKey:[,o]})=>M(o))};var z=({onConnect:t,onDisconnect:e}={})=>{let n=g(o=>o.account),r=g(o=>o.status);return(0,oe.useEffect)(()=>g.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let{account:s,activeChain:a}=g.getState(),{walletType:c}=f.getState();t==null||t({account:s,chain:a,walletType:c,isReconnect:i==="reconnecting"})}o==="disconnected"&&(e==null||e())}),[t,e]),{data:n,isConnected:!!n,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:B,status:r}},gn=t=>{let{data:e}=z(),{data:n}=We(),{activeChain:r}=g.getState(),o=t||(e==null?void 0:e.bech32Address),i=(0,oe.useMemo)(()=>["USE_ALL_BALANCES",n,r,o],[r,o,n]);return(0,V.useQuery)(i,async({queryKey:[,a,c,u]})=>{if(!c||!a)throw new Error("No connected account detected");if(!u)throw new Error("address is not defined");return await a.getAllBalances(u)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},oo=(t,e)=>{let{data:n}=z(),r=e||(n==null?void 0:n.bech32Address),{data:o,refetch:i}=gn(r),a=(0,V.useQuery)(["USE_BALANCE",o,t,e],({queryKey:[,c]})=>c==null?void 0:c.find(u=>u.denom===t),{enabled:!!o});return{...a,refetch:async()=>(await i(),a.refetch())}},ro=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=(0,V.useMutation)(["USE_CONNECT",t,e,n],ne,{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=fe();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status}},io=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=(0,V.useMutation)(["USE_DISCONNECT",t,e,n],Te,{onError:i=>Promise.resolve(t==null?void 0:t(i,void 0)),onMutate:e,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>o.mutate(i),disconnectAsync:i=>o.mutateAsync(i),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,status:o.status}},so=()=>{let t=g(r=>r.activeChain),e=f(r=>r.walletType),n=(0,oe.useMemo)(()=>["USE_OFFLINE_SIGNERS",t,e],[t,e]);return(0,V.useQuery)({queryKey:n,queryFn:async({queryKey:[,r,o]})=>{if(!r)throw new Error("No chain found");if(!M(o))throw new Error(`${o} is not available`);return await Qe({chainId:r.chainId,walletType:o})},enabled:!!t&&!!e,refetchOnWindowFocus:!1})},ao=t=>{let{data:e}=z(),{data:n}=We(),{activeChain:r}=g.getState(),o=t||(e==null?void 0:e.bech32Address),i=(0,oe.useMemo)(()=>["USE_BALANCE_STAKED",n,r,o],[r,o,n]);return(0,V.useQuery)(i,async({queryKey:[,a,c,u]})=>{if(!c||!a)throw new Error("No connected account detected");if(!u)throw new Error("address is not defined");return await a.getBalanceStaked(u)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var re=require("@tanstack/react-query");var co=()=>g(t=>t.activeChain),lo=t=>(0,re.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",t],({queryKey:[,r]})=>Ve(r)),uo=(t,e="BOND_STATUS_BONDED")=>(0,re.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",t,e],async({queryKey:[,o,i]})=>{if(!o)throw new Error("Query client is not defined");return await o.staking.validators(i)},{enabled:typeof t<"u"}),mo=()=>({data:f(e=>e.recentChain),clear:He}),po=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=(0,re.useMutation)(["USE_SUGGEST_CHAIN",t,e,n],xe,{onError:(i,s)=>Promise.resolve(t==null?void 0:t(i,s)),onMutate:e,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,suggest:o.mutate,suggestAsync:o.mutateAsync,status:o.status}},go=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=(0,re.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",t,e,n],$e,{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:s=>e==null?void 0:e(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=fe();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};var $=require("@tanstack/react-query");var fo=({onError:t,onLoading:e,onSuccess:n}={})=>{let{data:r}=z(),o=r==null?void 0:r.bech32Address,i=(0,$.useMutation)(["USE_SEND_TOKENS",t,e,n,o],s=>Ye({senderAddress:o,...s}),{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return{error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},ho=({onError:t,onLoading:e,onSuccess:n}={})=>{let{data:r}=z(),o=r==null?void 0:r.bech32Address,i=(0,$.useMutation)(["USE_SEND_IBC_TOKENS",t,e,n,o],s=>Xe({senderAddress:o,...s}),{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return{error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},yo=({codeId:t,onError:e,onLoading:n,onSuccess:r})=>{let{data:o}=z(),i=o==null?void 0:o.bech32Address,a=(0,$.useMutation)(["USE_INSTANTIATE_CONTRACT",e,n,r,t,i],c=>{if(!i)throw new Error("senderAddress is undefined");let u={...c,fee:c.fee??"auto",senderAddress:i,codeId:t};return Je(u)},{onError:(c,u)=>Promise.resolve(e==null?void 0:e(c,u)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return{error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},wo=({contractAddress:t,onError:e,onLoading:n,onSuccess:r})=>{let{data:o}=z(),i=o==null?void 0:o.bech32Address,a=(0,$.useMutation)(["USE_EXECUTE_CONTRACT",e,n,r,t,i],c=>{if(!i)throw new Error("senderAddress is undefined");let u={...c,fee:c.fee??"auto",senderAddress:i,contractAddress:t,memo:c.memo??"",funds:c.funds??[]};return et(u)},{onError:(c,u)=>Promise.resolve(e==null?void 0:e(c,u)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return{error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Co=(t,e)=>{let{data:n}=Ne();return(0,$.useQuery)(["USE_QUERY_SMART",t,e,n],({queryKey:[,o]})=>{if(!t||!e)throw new Error("address or queryMsg undefined");return tt(t,e,n)},{enabled:!!t&&!!e&&!!n})},So=(t,e)=>{let{data:n}=Ne();return(0,$.useQuery)(["USE_QUERY_RAW",e,t,n],({queryKey:[,i]})=>{if(!t||!e)throw new Error("address or key undefined");return nt(t,e,n)},{enabled:!!t&&!!e&&!!n})};var ft=require("@cosmjs/cosmwasm-stargate"),ie=require("@cosmjs/stargate"),de=require("@tanstack/react-query"),he=require("react");var Ao=t=>{let e=g(o=>o.activeChain),n=f(o=>o.walletType),r=(0,he.useMemo)(()=>["USE_STARGATE_SIGNING_CLIENT",e,n,t],[t,e,n]);return(0,de.useQuery)({queryKey:r,queryFn:async({queryKey:[,o,i,s]})=>{if(!o)throw new Error("No chain found");if(!M(i))throw new Error(`${i} is not available`);let c=await(async()=>{switch(t==null?void 0:t.offlineSigner){case"offlineSigner":return T(i).getOfflineSigner(o.chainId);case"offlineSignerAuto":return T(i).getOfflineSignerAuto(o.chainId);case"offlineSignerOnlyAmino":return T(i).getOfflineSignerOnlyAmino(o.chainId);default:return T(i).getOfflineSignerAuto(o.chainId)}})(),u={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await ie.SigningStargateClient.connectWithSigner(u,c,s==null?void 0:s.opts)},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},Eo=t=>{let e=g(o=>o.activeChain),n=f(o=>o.walletType),r=(0,he.useMemo)(()=>["USE_COSMWASM_SIGNING_CLIENT",e,n,t],[t,e,n]);return(0,de.useQuery)({queryKey:r,queryFn:async({queryKey:[,o,i,s]})=>{if(!o)throw new Error("No chain found");if(!M(i))throw new Error(`${i} is not available`);let c=await(async()=>{switch(t==null?void 0:t.offlineSigner){case"offlineSigner":return T(i).getOfflineSigner(o.chainId);case"offlineSignerAuto":return T(i).getOfflineSignerAuto(o.chainId);case"offlineSignerOnlyAmino":return T(i).getOfflineSignerOnlyAmino(o.chainId);default:return T(i).getOfflineSignerAuto(o.chainId)}})(),u={url:o.rpc,headers:{...o.rpcHeaders||{}}},h=o.gas?ie.GasPrice.fromString(`${o.gas.price}${o.gas.denom}`):void 0;return await ft.SigningCosmWasmClient.connectWithSigner(u,c,{gasPrice:h,...(s==null?void 0:s.opts)||{}})},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},Io=t=>{let e=g(i=>i.activeChain),n=f(i=>i.walletType),r=(0,he.useMemo)(()=>["USE_STARGATE_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=Me(t.type);return(0,de.useQuery)({queryKey:r,queryFn:async({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!M(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let u=await(async()=>{switch(t.offlineSigner){case"offlineSigner":return T(s).getOfflineSigner(i.chainId);case"offlineSignerAuto":return T(s).getOfflineSignerAuto(i.chainId);case"offlineSignerOnlyAmino":return T(s).getOfflineSignerOnlyAmino(i.chainId);default:return T(s).getOfflineSignerAuto(i.chainId)}})();return ie.SigningStargateClient.createWithSigner(o,u,a.opts)},enabled:!!e&&!!n&&!!o,refetchOnWindowFocus:!1})},bo=t=>{let e=g(i=>i.activeChain),n=f(i=>i.walletType),r=(0,he.useMemo)(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=Me(t.type);return(0,de.useQuery)({queryKey:r,queryFn:async({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!M(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let u=await(async()=>{switch(t.offlineSigner){case"offlineSigner":return T(s).getOfflineSigner(i.chainId);case"offlineSignerAuto":return T(s).getOfflineSignerAuto(i.chainId);case"offlineSignerOnlyAmino":return T(s).getOfflineSignerOnlyAmino(i.chainId);default:return T(s).getOfflineSignerAuto(i.chainId)}})(),h=i.gas?ie.GasPrice.fromString(`${i.gas.price}${i.gas.denom}`):void 0;return ft.SigningCosmWasmClient.createWithSigner(o,u,{gasPrice:h,...(a==null?void 0:a.opts)||{}})},enabled:!!e&&!!n&&!!o,refetchOnWindowFocus:!1})};var _e=require("@tanstack/react-query"),hn=require("@tanstack/react-query-devtools");var De=require("react"),Fe=require("react/jsx-runtime"),fn=({children:t})=>{let[e,n]=(0,De.useState)(!1);return(0,De.useEffect)(()=>{n(!0)},[]),(0,Fe.jsx)(Fe.Fragment,{children:e?t:null})};var dt=require("react");var dn=()=>{let t=typeof window<"u"&&window.sessionStorage.getItem(Z)==="Active",{_reconnect:e,_onReconnectFailed:n,_reconnectConnector:r}=f(),{activeChain:o,wcSignClient:i}=g();return(0,dt.useEffect)(()=>{r&&(t&&o?B({onError:n}):!t&&e&&B({onError:n}))},[]),(0,dt.useEffect)(()=>{var s,a,c,u,h,A,C,x,W,ae;r&&(r==="cosmostation"&&((a=(s=ue()).subscription)==null||a.call(s,()=>{B({onError:n})})),r==="keplr"&&((u=(c=me()).subscription)==null||u.call(c,()=>{B({onError:n})})),r==="leap"&&((A=(h=pe()).subscription)==null||A.call(h,()=>{B({onError:n})})),r==="vectis"&&((x=(C=ge()).subscription)==null||x.call(C,()=>{B({onError:n})})),r==="walletconnect"&&i&&((ae=(W=U()).subscription)==null||ae.call(W,()=>{B({onError:n})})))},[r,i]),null},ht=()=>(dn(),null);var se=require("react/jsx-runtime"),To=new _e.QueryClient({}),xo=({children:t,grazOptions:e,debug:n,...r})=>(e&&Ze(e),(0,se.jsxs)(_e.QueryClientProvider,{client:To,...r,children:[(0,se.jsxs)(fn,{children:[(0,se.jsx)(ht,{}),t]}),n?(0,se.jsx)(hn.ReactQueryDevtools,{initialIsOpen:!1,position:"bottom-right"}):null]},"graz-provider"));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,clearSession,configureGraz,connect,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAvailableWallets,getCosmostation,getKeplr,getLeap,getMetamaskSnapLeap,getOfflineSigners,getQueryRaw,getQuerySmart,getRecentChain,getVectis,getWCCosmostation,getWCKeplr,getWCLeap,getWallet,getWalletConnect,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useActiveWalletType,useBalance,useBalanceStaked,useBalances,useCheckWallet,useConnect,useCosmWasmClient,useCosmWasmSigningClient,useCosmWasmTmSigningClient,useDisconnect,useExecuteContract,useGrazEvents,useInstantiateContract,useOfflineSigners,useQueryRaw,useQuerySmart,useRecentChain,useSendIbcTokens,useSendTokens,useStargateClient,useStargateSigningClient,useStargateTmSigningClient,useSuggestChain,useSuggestChainAndConnect,useTendermintClient});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as Ut,b as qt,c as L}from"./chunk-HBC2VYPF.mjs";var Ye=Ut((Hn,Ze)=>{"use strict";Ze.exports=w;var W=null;try{W=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function w(t,e,n){this.low=t|0,this.high=e|0,this.unsigned=!!n}w.prototype.__isLong__;Object.defineProperty(w.prototype,"__isLong__",{value:!0});function O(t){return(t&&t.__isLong__)===!0}w.isLong=O;var Be={},Ge={};function B(t,e){var n,r,o;return e?(t>>>=0,(o=0<=t&&t<256)&&(r=Ge[t],r)?r:(n=S(t,(t|0)<0?-1:0,!0),o&&(Ge[t]=n),n)):(t|=0,(o=-128<=t&&t<128)&&(r=Be[t],r)?r:(n=S(t,t<0?-1:0,!1),o&&(Be[t]=n),n))}w.fromInt=B;function k(t,e){if(isNaN(t))return e?P:F;if(e){if(t<0)return P;if(t>=Qe)return $e}else{if(t<=-ze)return v;if(t+1>=ze)return Ve}return t<0?k(-t,e).neg():S(t%K|0,t/K|0,e)}w.fromNumber=k;function S(t,e,n){return new w(t,e,n)}w.fromBits=S;var X=Math.pow;function se(t,e,n){if(t.length===0)throw Error("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return F;if(typeof e=="number"?(n=e,e=!1):e=!!e,n=n||10,n<2||36<n)throw RangeError("radix");var r;if((r=t.indexOf("-"))>0)throw Error("interior hyphen");if(r===0)return se(t.substring(1),e,n).neg();for(var o=k(X(n,8)),i=F,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),c=parseInt(t.substring(s,s+a),n);if(a<8){var p=k(X(n,a));i=i.mul(p).add(k(c))}else i=i.mul(o),i=i.add(k(c))}return i.unsigned=e,i}w.fromString=se;function M(t,e){return typeof t=="number"?k(t,e):typeof t=="string"?se(t,e):S(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}w.fromValue=M;var je=65536,jt=1<<24,K=je*je,Qe=K*K,ze=Qe/2,Ke=B(jt),F=B(0);w.ZERO=F;var P=B(0,!0);w.UZERO=P;var z=B(1);w.ONE=z;var He=B(1,!0);w.UONE=He;var ie=B(-1);w.NEG_ONE=ie;var Ve=S(-1,2147483647,!1);w.MAX_VALUE=Ve;var $e=S(-1,-1,!0);w.MAX_UNSIGNED_VALUE=$e;var v=S(0,-2147483648,!1);w.MIN_VALUE=v;var l=w.prototype;l.toInt=function(){return this.unsigned?this.low>>>0:this.low};l.toNumber=function(){return this.unsigned?(this.high>>>0)*K+(this.low>>>0):this.high*K+(this.low>>>0)};l.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(v)){var n=k(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var i=k(X(e,6),this.unsigned),s=this,a="";;){var c=s.div(i),p=s.sub(c.mul(i)).toInt()>>>0,d=p.toString(e);if(s=c,s.isZero())return d+a;for(;d.length<6;)d="0"+d;a=""+d+a}};l.getHighBits=function(){return this.high};l.getHighBitsUnsigned=function(){return this.high>>>0};l.getLowBits=function(){return this.low};l.getLowBitsUnsigned=function(){return this.low>>>0};l.getNumBitsAbs=function(){if(this.isNegative())return this.eq(v)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<<n);n--);return this.high!=0?n+33:n+1};l.isZero=function(){return this.high===0&&this.low===0};l.eqz=l.isZero;l.isNegative=function(){return!this.unsigned&&this.high<0};l.isPositive=function(){return this.unsigned||this.high>=0};l.isOdd=function(){return(this.low&1)===1};l.isEven=function(){return(this.low&1)===0};l.equals=function(e){return O(e)||(e=M(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};l.eq=l.equals;l.notEquals=function(e){return!this.eq(e)};l.neq=l.notEquals;l.ne=l.notEquals;l.lessThan=function(e){return this.comp(e)<0};l.lt=l.lessThan;l.lessThanOrEqual=function(e){return this.comp(e)<=0};l.lte=l.lessThanOrEqual;l.le=l.lessThanOrEqual;l.greaterThan=function(e){return this.comp(e)>0};l.gt=l.greaterThan;l.greaterThanOrEqual=function(e){return this.comp(e)>=0};l.gte=l.greaterThanOrEqual;l.ge=l.greaterThanOrEqual;l.compare=function(e){if(O(e)||(e=M(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};l.comp=l.compare;l.negate=function(){return!this.unsigned&&this.eq(v)?v:this.not().add(z)};l.neg=l.negate;l.add=function(e){O(e)||(e=M(e));var n=this.high>>>16,r=this.high&65535,o=this.low>>>16,i=this.low&65535,s=e.high>>>16,a=e.high&65535,c=e.low>>>16,p=e.low&65535,d=0,E=0,C=0,T=0;return T+=i+p,C+=T>>>16,T&=65535,C+=o+c,E+=C>>>16,C&=65535,E+=r+a,d+=E>>>16,E&=65535,d+=n+s,d&=65535,S(C<<16|T,d<<16|E,this.unsigned)};l.subtract=function(e){return O(e)||(e=M(e)),this.add(e.neg())};l.sub=l.subtract;l.multiply=function(e){if(this.isZero())return F;if(O(e)||(e=M(e)),W){var n=W.mul(this.low,this.high,e.low,e.high);return S(n,W.get_high(),this.unsigned)}if(e.isZero())return F;if(this.eq(v))return e.isOdd()?v:F;if(e.eq(v))return this.isOdd()?v:F;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(Ke)&&e.lt(Ke))return k(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=this.high&65535,i=this.low>>>16,s=this.low&65535,a=e.high>>>16,c=e.high&65535,p=e.low>>>16,d=e.low&65535,E=0,C=0,T=0,N=0;return N+=s*d,T+=N>>>16,N&=65535,T+=i*d,C+=T>>>16,T&=65535,T+=s*p,C+=T>>>16,T&=65535,C+=o*d,E+=C>>>16,C&=65535,C+=i*p,E+=C>>>16,C&=65535,C+=s*c,E+=C>>>16,C&=65535,E+=r*d+o*p+i*c+s*a,E&=65535,S(T<<16|N,E<<16|C,this.unsigned)};l.mul=l.multiply;l.divide=function(e){if(O(e)||(e=M(e)),e.isZero())throw Error("division by zero");if(W){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?W.div_u:W.div_s)(this.low,this.high,e.low,e.high);return S(n,W.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?P:F;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return P;if(e.gt(this.shru(1)))return He;i=P}else{if(this.eq(v)){if(e.eq(z)||e.eq(ie))return v;if(e.eq(v))return z;var s=this.shr(1);return r=s.div(e).shl(1),r.eq(F)?e.isNegative()?z:ie:(o=this.sub(e.mul(r)),i=r.add(o.div(e)),i)}else if(e.eq(v))return this.unsigned?P:F;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=F}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(r)/Math.LN2),c=a<=48?1:X(2,a-48),p=k(r),d=p.mul(e);d.isNegative()||d.gt(o);)r-=c,p=k(r,this.unsigned),d=p.mul(e);p.isZero()&&(p=z),i=i.add(p),o=o.sub(d)}return i};l.div=l.divide;l.modulo=function(e){if(O(e)||(e=M(e)),W){var n=(this.unsigned?W.rem_u:W.rem_s)(this.low,this.high,e.low,e.high);return S(n,W.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};l.mod=l.modulo;l.rem=l.modulo;l.not=function(){return S(~this.low,~this.high,this.unsigned)};l.and=function(e){return O(e)||(e=M(e)),S(this.low&e.low,this.high&e.high,this.unsigned)};l.or=function(e){return O(e)||(e=M(e)),S(this.low|e.low,this.high|e.high,this.unsigned)};l.xor=function(e){return O(e)||(e=M(e)),S(this.low^e.low,this.high^e.high,this.unsigned)};l.shiftLeft=function(e){return O(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?S(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):S(0,this.low<<e-32,this.unsigned)};l.shl=l.shiftLeft;l.shiftRight=function(e){return O(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?S(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):S(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};l.shr=l.shiftRight;l.shiftRightUnsigned=function(e){if(O(e)&&(e=e.toInt()),e&=63,e===0)return this;var n=this.high;if(e<32){var r=this.low;return S(r>>>e|n<<32-e,n>>>e,this.unsigned)}else return e===32?S(n,0,this.unsigned):S(n>>>e-32,0,this.unsigned)};l.shru=l.shiftRightUnsigned;l.shr_u=l.shiftRightUnsigned;l.toSigned=function(){return this.unsigned?S(this.low,this.high,!1):this};l.toUnsigned=function(){return this.unsigned?this:S(this.low,this.high,!0)};l.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};l.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};l.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};w.fromBytes=function(e,n,r){return r?w.fromBytesLE(e,n):w.fromBytesBE(e,n)};w.fromBytesLE=function(e,n){return new w(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)};w.fromBytesBE=function(e,n){return new w(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)}});import{create as qe}from"zustand";import{createJSONStorage as Lt}from"zustand/middleware";import{persist as Le,subscribeWithSelector as Pe}from"zustand/middleware";var Re=(c=>(c.KEPLR="keplr",c.LEAP="leap",c.VECTIS="vectis",c.COSMOSTATION="cosmostation",c.WALLETCONNECT="walletconnect",c.WC_KEPLR_MOBILE="wc_keplr_mobile",c.WC_LEAP_MOBILE="wc_leap_mobile",c.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",c))(Re||{}),Ue=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile"];var Pt={recentChain:null,defaultChain:null,defaultSigningClient:"stargate",walletType:"keplr",walletConnect:{options:null,web3Modal:null},_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},H={account:null,activeChain:null,balances:null,status:"disconnected",wcSignClient:null},Bt={name:"graz-session",version:1,partialize:t=>({account:t.account,activeChain:t.activeChain}),storage:Lt(()=>sessionStorage)},Gt={name:"graz-internal",partialize:t=>({recentChain:t.recentChain,_reconnect:t._reconnect,_reconnectConnector:t._reconnectConnector}),version:1},g=qe(Pe(Le(()=>H,Bt))),h=qe(Pe(Le(()=>Pt,Gt)));var ce=qt(Ye());import{fromBech32 as et}from"@cosmjs/encoding";import{SignClient as zt}from"@walletconnect/sign-client";import{getSdkError as Kt}from"@walletconnect/utils";var G=()=>typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,Xe=()=>G()&&navigator.userAgent.toLowerCase().includes("android"),Je=()=>G()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var ae=(t,e,n=new Error("Promise timed out"))=>{let r=new Promise((o,i)=>{setTimeout(()=>{i(n)},e)});return Promise.race([t,r])};var _=(t=h.getState().walletType)=>{try{return D(t),!0}catch{return!1}},q=()=>{window.sessionStorage.removeItem(L),g.setState(H)},le=()=>{if(typeof window.keplr<"u"){let t=window.keplr;return Object.assign(t,{subscription:r=>(window.addEventListener("keplr_keystorechange",()=>{q(),r()}),()=>{window.removeEventListener("keplr_keystorechange",()=>{q(),r()})})})}throw h.getState()._notFoundFn(),new Error("window.keplr is not defined")},ue=()=>{if(typeof window.leap<"u"){let t=window.leap;return Object.assign(t,{subscription:r=>(window.addEventListener("leap_keystorechange",()=>{q(),r()}),()=>{window.removeEventListener("leap_keystorechange",()=>{q(),r()})})})}throw h.getState()._notFoundFn(),new Error("window.leap is not defined")},me=()=>{if(typeof window.cosmostation.providers.keplr<"u"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:r=>(window.cosmostation.cosmos.on("accountChanged",()=>{q(),r()}),()=>{window.cosmostation.cosmos.off("accountChanged",()=>{q(),r()})})})}throw h.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")},pe=()=>{if(typeof window.vectis<"u"){let t=window.vectis.cosmos;return{enable:a=>t.enable(a),getOfflineSigner:a=>t.getOfflineSigner(a),getOfflineSignerAuto:a=>t.getOfflineSignerAuto(a),getKey:async a=>{let c=await t.getKey(a);return{address:et(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}},subscription:a=>(window.addEventListener("vectis_accountChanged",()=>{q(),a()}),()=>{window.removeEventListener("vectis_accountChanged",()=>{q(),a()})}),getOfflineSignerOnlyAmino:(...a)=>t.getOfflineSignerAmino(...a),experimentalSuggestChain:async(...a)=>{let[c]=a,p={...c,rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr};return t.suggestChains([p])},signDirect:async(...a)=>{var d;let{1:c,2:p}=a;return t.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:ce.default.fromString(((d=p.accountNumber)==null?void 0:d.toString())||"",!1),chainId:p.chainId||""})},signAmino:async(...a)=>{let{1:c,2:p}=a;return t.signAmino(c,p)}}}throw h.getState()._notFoundFn(),new Error("window.vectis is not defined")},Q=t=>{var ke,Fe,Me;if(!((Me=(Fe=(ke=h.getState().walletConnect)==null?void 0:ke.options)==null?void 0:Fe.projectId)!=null&&Me.trim()))throw new Error("walletConnect.options.projectId is not defined");let e=(t==null?void 0:t.encoding)||"base64",n=m=>{if(!t)return;let{appUrl:u,formatNativeUrl:f}=t;if(G()){if(Xe())if(!m)window.open(u.mobile.android,"_self","noreferrer noopener");else{let y=f(u.mobile.android,m,"android");window.open(y,"_self","noreferrer noopener")}if(Je())if(!m)window.open(u.mobile.ios,"_self","noreferrer noopener");else{let y=f(u.mobile.ios,m,"ios");window.open(y,"_self","noreferrer noopener")}}},r=()=>{let{wcSignClient:m}=g.getState();if(!m)throw new Error("walletConnect.signClient is not defined");q(),h.setState({_reconnect:!1,_reconnectConnector:null,recentChain:null})},o=async m=>{let{wcSignClient:u}=g.getState();if(!u)throw new Error("walletConnect.signClient is not defined");if(!m)throw new Error("No wallet connect session");await u.disconnect({topic:m,reason:Kt("USER_DISCONNECTED")}),await a(u),r()},i=m=>{var u,f;try{let{wcSignClient:y}=g.getState();if(!y)throw new Error("walletConnect.signClient is not defined");let A=y.session.getAll().at(-1);if(!A)return;let I=(f=(u=y.session.getAll().at(-1))==null?void 0:u.namespaces.cosmos)==null?void 0:f.accounts.find(b=>b.startsWith(`cosmos:${m}`));if(!(A.expiry*1e3>Date.now()+1e3))throw o(A.topic),new Error("invalid session");if(!I)try{let b=y.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${m}`],events:["chainChanged","accountsChanged"]}}});if(!b.length)throw new Error("no session");return b.at(-1)}catch(b){if(!b.message.toLowerCase().includes("no matching key"))throw b}return A}catch(y){if(!y.message.toLowerCase().includes("no matching key"))throw y}},s=m=>{try{return i(m)}catch{return}},a=async m=>{try{let u=m.core.pairing.pairings.getAll({active:!1});if(!u.length)return;await Promise.all(u.map(async f=>{await m.core.pairing.pairings.delete(f.topic,{code:7001,message:"clear pairing"})}))}catch(u){if(!u.message.toLowerCase().includes("no matching key"))throw u}},c=async()=>{let{walletConnect:m}=h.getState();if(!(m!=null&&m.options))throw new Error("walletConnect.options is not defined");let{wcSignClient:u}=g.getState();if(u)return g.setState({wcSignClient:u}),u;let f=await zt.init(m.options);return g.setState({wcSignClient:f}),f},p=m=>{let{wcSignClient:u}=g.getState();if(u)return u.events.on("session_delete",f=>{r()}),u.events.on("session_expire",f=>{r()}),u.events.on("session_event",f=>{var y,A;if(f.params.event.name==="accountsChanged"&&((y=f.params.event.data)==null?void 0:y[0])!==((A=g.getState().account)==null?void 0:A.bech32Address)){let I=f.params.chainId.split(":")[1];I&&d(I)}else m()}),()=>{u.events.off("session_delete",f=>{r()}),u.events.off("session_expire",f=>{r()}),u.events.off("session_event",f=>{var y,A;if(f.params.event.name==="accountsChanged"&&((y=f.params.event.data)==null?void 0:y[0])!==((A=g.getState().account)==null?void 0:A.bech32Address)){let I=f.params.chainId.split(":")[1];I&&d(I)}else m()})}},d=async m=>{var Z;let{wcSignClient:u}=g.getState();if(!u)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:f}=h.getState();if(!((Z=f==null?void 0:f.options)!=null&&Z.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:y}=await import("@web3modal/standalone"),A=new y({projectId:f.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE",...f.web3Modal}),{account:I,activeChain:U}=g.getState(),b=s(m);if((U==null?void 0:U.chainId)!==m&&!b||!I){let{uri:x,approval:Y}=await u.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${m}`],events:["chainChanged","accountsChanged"]}}});if(!x)throw new Error("No wallet connect uri");t?n(x):await A.openModal({uri:x});try{await ae((async()=>{await Y()})(),4e4,new Error("Modal approval timeout"))}catch(De){if(A.closeModal(),!De.message.toLowerCase().includes("no matching key"))return Promise.reject(De)}return t||A.closeModal(),Promise.resolve()}try{await ae((async()=>{let x=await C(m);g.setState({account:x})})(),1e4,new Error("Connection timeout"))}catch(x){if(o(b==null?void 0:b.topic),!x.message.toLowerCase().includes("no matching key"))throw x}},E=async m=>{var A;let{wcSignClient:u}=g.getState();if(!u)throw new Error("walletConnect.signClient is not defined");let f=(A=i(m))==null?void 0:A.topic;if(!f)throw new Error("No wallet connect session");n();let y=await u.request({topic:f,chainId:`cosmos:${m}`,request:{method:"cosmos_getAccounts",params:{}}});if(!y[0])throw new Error("No wallet connect account");return{address:y[0].address,algo:y[0].algo,pubkey:new Uint8Array(Buffer.from(y[0].pubkey,e))}},C=async m=>{let{address:u,algo:f,pubkey:y}=await E(m);return{address:et(u).data,algo:f,bech32Address:u,name:"",pubKey:y,isKeystone:!1,isNanoLedger:!1}},T=async(...m)=>{var x,Y;let[u,f,y]=m,{account:A,wcSignClient:I}=g.getState();if(!I)throw new Error("walletConnect.signClient is not defined");if(!A)throw new Error("account is not defined");let U=(x=i(u))==null?void 0:x.topic;if(!U)throw new Error("No wallet connect session");if(!y.bodyBytes)throw new Error("No bodyBytes");if(!y.authInfoBytes)throw new Error("No authInfoBytes");let b={topic:U,chainId:`cosmos:${u}`,request:{method:"cosmos_signDirect",params:{signerAddress:f,signDoc:{...y,bodyBytes:Buffer.from(y.bodyBytes).toString(e),authInfoBytes:Buffer.from(y.authInfoBytes).toString(e),accountNumber:(Y=y.accountNumber)==null?void 0:Y.toString()}}}};return n(),await I.request(b)},N=async(...m)=>{let[u,f,y]=m,{signature:A,signed:I}=await T(u,f,y);return{signed:{chainId:I.chainId,accountNumber:ce.default.fromString(I.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(I.authInfoBytes,e)),bodyBytes:new Uint8Array(Buffer.from(I.bodyBytes,e))},signature:A}},$=async(...m)=>{var x;let[u,f,y,A]=m,{wcSignClient:I}=g.getState(),{account:U}=g.getState();if(!I)throw new Error("walletConnect.signClient is not defined");if(!U)throw new Error("account is not defined");let b=(x=i(u))==null?void 0:x.topic;if(!b)throw new Error("No wallet connect session");return n(),await I.request({topic:b,chainId:`cosmos:${u}`,request:{method:"cosmos_signDirect",params:{signerAddress:f,signDoc:y}}})},re=async(...m)=>{let[u,f,y,A]=m;return await $(u,f,y)},Rt=m=>({getAccounts:async()=>[await E(m)],signDirect:(u,f)=>N(m,u,f)}),We=m=>({getAccounts:async()=>[await E(m)],signAmino:(u,f)=>re(m,u,f)});return{enable:d,experimentalSuggestChain:async(...m)=>{await Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"))},getKey:C,getOfflineSigner:m=>({getAccounts:async()=>[await E(m)],signDirect:(u,f)=>N(m,u,f),signAmino:(u,f)=>re(m,u,f)}),getOfflineSignerAuto:async m=>(await C(m)).isNanoLedger?We(m):Rt(m),getOfflineSignerOnlyAmino:We,signAmino:re,signDirect:N,subscription:p,init:c}},Qt=()=>{var e,n,r;if(!((r=(n=(e=h.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let t={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(o,i,s)=>{let a=o.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);switch(s){case"ios":return`${a}://wcV2?${c}`;case"android":return`${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return`${a}://wc?uri=${c}`}}};return Q(t)},Ht=()=>{var e,n,r;if(!((r=(n=(e=h.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Leap mobile is only supported in mobile");let t={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(o,i,s)=>{let a=o.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);switch(s){case"ios":return`${a}://wcV2?${c}`;case"android":return`${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return`${a}://wc?uri=${c}`}}};return Q(t)},Vt=()=>{var e,n,r;if(!((r=(n=(e=h.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Leap mobile is only supported in mobile");let t={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_leap_mobile",formatNativeUrl:(o,i,s)=>`${o.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return Q(t)},D=(t=h.getState().walletType)=>{switch(t){case"keplr":return le();case"leap":return ue();case"cosmostation":return me();case"vectis":return pe();case"walletconnect":return Q();case"wc_keplr_mobile":return Qt();case"wc_leap_mobile":return Ht();case"wc_cosmostation_mobile":return Vt();default:throw new Error("Unknown wallet type")}},ro=()=>Object.fromEntries(Ue.map(t=>[t,_(t)]));var V=async t=>{var e;try{let{defaultChain:n,recentChain:r,walletType:o}=h.getState(),i=(t==null?void 0:t.walletType)||o;if(!_(i))throw new Error(`${i} is not available`);let a=D(i),c=(t==null?void 0:t.chain)||r||n;if(!c)throw new Error("No last known connected chain, connect action requires chain info");g.setState(C=>{let T=h.getState()._reconnect||!!h.getState()._reconnectConnector||!!c;return C.activeChain&&C.activeChain.chainId!==c.chainId?{status:"connecting"}:T?{status:"reconnecting"}:{status:"connecting"}});let{account:p,activeChain:d}=g.getState();if(await((e=a.init)==null?void 0:e.call(a)),!p||(d==null?void 0:d.chainId)!==c.chainId){await a.enable(c.chainId);let C=await a.getKey(c.chainId);g.setState({account:C})}h.setState({recentChain:c,walletType:i,_reconnect:!!(t!=null&&t.autoReconnect),_reconnectConnector:i}),g.setState({activeChain:c,status:"connected"}),typeof window<"u"&&window.sessionStorage.setItem(L,"Active");let{account:E}=g.getState();return{account:E,walletType:i,chain:c}}catch(n){throw console.error("connect ",n),g.getState().account===null&&g.setState({status:"disconnected"}),g.getState().account&&g.getState().activeChain&&g.setState({status:"connected"}),n}},ge=async(t=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(L),g.setState(H),h.setState(e=>({_reconnect:!1,_reconnectConnector:null,recentChain:t?null:e.recentChain})),Promise.resolve()),R=async t=>{var o;let{recentChain:e,_reconnectConnector:n,_reconnect:r}=h.getState();try{let i=_(n||void 0);if(e&&i&&n)return await V({chain:e,walletType:n,autoReconnect:r})}catch(i){(o=t==null?void 0:t.onError)==null||o.call(t,i),ge()}},tt=async t=>{if(!(t!=null&&t.chainId))throw new Error("chainId is required");let{walletType:e}=h.getState(),n=t.walletType||e;if(!_(n))throw new Error(`${n} is not available`);let o=D(n),i=o.getOfflineSigner(t.chainId),s=o.getOfflineSignerOnlyAmino(t.chainId),a=await o.getOfflineSignerAuto(t.chainId);return{offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}};var nt=()=>{h.setState({recentChain:null})},ot=t=>{let{activeChain:e}=g.getState();return e==null?void 0:e.currencies.find(n=>n.coinMinimalDenom===t)},go=()=>h.getState().recentChain,fe=async t=>(await D().experimentalSuggestChain(t),t),rt=async({chainInfo:t,rpcHeaders:e,gas:n,path:r,...o})=>{let i=await fe(t);return{...await V({chain:{chainId:t.chainId,currencies:t.currencies,rest:t.rest,rpc:t.rpc,rpcHeaders:e,gas:n,path:r},...o}),chain:i}};var it=(t={})=>(h.setState(e=>({defaultChain:t.defaultChain||e.defaultChain,defaultSigningClient:t.defaultSigningClient||e.defaultSigningClient,walletConnect:t.walletConnect||e.walletConnect,walletType:t.defaultWallet||e.walletType,_notFoundFn:t.onNotFound||e._notFoundFn,_onReconnectFailed:t.onReconnectFailed||e._onReconnectFailed,_reconnect:t.autoReconnect===void 0?!0:t.autoReconnect||e._reconnect})),t);var st=async({signingClient:t,senderAddress:e,recipientAddress:n,amount:r,fee:o,memo:i})=>{if(!t)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return t.sendTokens(e,n,r,o,i)},at=async({signingClient:t,senderAddress:e,recipientAddress:n,transferAmount:r,sourcePort:o,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:p})=>{if(!t)throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return t.sendIbcTokens(e,n,r,o,i,s,a,c,p)},ct=async({signingClient:t,senderAddress:e,msg:n,fee:r,options:o,label:i,codeId:s})=>{if(!t)throw new Error("CosmWasm signing client is not ready");return t.instantiate(e,s,n,i,r,o)},lt=async({signingClient:t,senderAddress:e,msg:n,fee:r,contractAddress:o,funds:i,memo:s})=>{if(!t)throw new Error("CosmWasm signing client is not ready");return t.execute(e,o,n,r,s,i)},ut=async(t,e,n)=>{if(!n)throw new Error("CosmWasm client is not ready");return await n.queryContractSmart(t,e)},mt=(t,e,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(e);return n.queryContractRaw(t,r)};import{Bech32Address as $t}from"@keplr-wallet/cosmos";var gt={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Zt={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Yt={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Xt={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Jt={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},en={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},pt=[gt,Zt,Yt,Xt,Jt,en],he={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:gt,bip44:{coinType:118},bech32Config:$t.defaultBech32Config("axelar"),currencies:pt,feeCurrencies:pt};import{Bech32Address as tn}from"@keplr-wallet/cosmos";var ht={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ft=[ht],de={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ht,bip44:{coinType:118},bech32Config:tn.defaultBech32Config("cosmos"),currencies:ft,feeCurrencies:ft};import{Bech32Address as nn}from"@keplr-wallet/cosmos";var yt={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},on={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},rn={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},sn={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},an={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},cn={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},ln={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},un={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},mn={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},pn={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},gn={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},dt=[yt,on,rn,sn,an,cn,ln,un,mn,pn,gn],ye={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:yt,bip44:{coinType:118},bech32Config:nn.defaultBech32Config("juno"),currencies:dt,feeCurrencies:dt};import{Bech32Address as fn}from"@keplr-wallet/cosmos";var wt={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},hn={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Ct=[wt,hn],Ce={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:wt,bip44:{coinType:118},bech32Config:fn.defaultBech32Config("osmo"),currencies:Ct,feeCurrencies:Ct};import{Bech32Address as dn}from"@keplr-wallet/cosmos";var At={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},St=[At],we={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:At,bip44:{coinType:118},bech32Config:dn.defaultBech32Config("somm"),currencies:St,feeCurrencies:St};import{Bech32Address as yn}from"@keplr-wallet/cosmos";var It={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},Et=[It],Se={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:yn.defaultBech32Config("CRE"),currencies:Et,feeCurrencies:Et,stakeCurrency:It,coinType:118};import{Bech32Address as Cn}from"@keplr-wallet/cosmos";var Ae={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},wn=[Ae],Ee={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:Ae,bip44:{coinType:118},bech32Config:Cn.defaultBech32Config("juno"),currencies:wn,feeCurrencies:[Ae],coinType:118};import{Bech32Address as Sn}from"@keplr-wallet/cosmos";var Ie={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},An=[Ie],Te={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:Ie,bip44:{coinType:118},bech32Config:Sn.defaultBech32Config("osmo"),currencies:An,feeCurrencies:[Ie],coinType:118};var Tt=t=>t,jo=t=>t,zo=t=>t,Ko=Tt({axelar:he,cosmoshub:de,juno:ye,osmosis:Ce,sommelier:we}),Qo=[he,de,ye,Ce,we],Ho=Tt({crescent:Se,juno:Ee,osmosis:Te}),Vo=[Se,Ee,Te];import{useMutation as bt,useQuery as ee}from"@tanstack/react-query";import{useEffect as On,useMemo as Ne}from"react";import{CosmWasmClient as En}from"@cosmjs/cosmwasm-stargate";import{StargateClient as In}from"@cosmjs/stargate";import{Tendermint34Client as Tn,Tendermint37Client as bn}from"@cosmjs/tendermint-rpc";import{useQuery as be}from"@tanstack/react-query";import{useMemo as xe}from"react";var ve=()=>{let t=g(n=>n.activeChain),e=xe(()=>["USE_STARGATE_CLIENT",t],[t]);return be({queryKey:e,queryFn:async({queryKey:[,n]})=>{if(!n)throw new Error("No chain found");let r={url:n.rpc,headers:{...n.rpcHeaders||{}}};return await In.connect(r)},enabled:!!t,refetchOnWindowFocus:!1})},Oe=()=>{let t=g(n=>n.activeChain),e=xe(()=>["USE_COSMWASM_CLIENT",t],[t]);return be({queryKey:e,queryFn:async({queryKey:[,n]})=>{if(!n)throw new Error("No chain found");let r={url:n.rpc,headers:{...n.rpcHeaders||{}}};return await En.connect(r)},enabled:!!t,refetchOnWindowFocus:!1})},_e=t=>{let e=g(r=>r.activeChain),n=xe(()=>["USE_TENDERMINT_CLIENT",t,e],[t,e]);return be({queryKey:n,queryFn:async({queryKey:[,r,o]})=>{if(!o)throw new Error("No chain found");let i={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await(r==="tm37"?bn:Tn).connect(i)},enabled:!!e,refetchOnWindowFocus:!1})};import{useQuery as xn}from"@tanstack/react-query";import{shallow as vn}from"zustand/shallow";var ar=()=>h(t=>({walletType:t.walletType,isCosmostation:t.walletType==="cosmostation",isCosmostationMobile:t.walletType==="wc_cosmostation_mobile",isKeplr:t.walletType==="keplr",isKeplrMobile:t.walletType==="wc_keplr_mobile",isLeap:t.walletType==="leap",isLeapMobile:t.walletType==="wc_leap_mobile",isVectis:t.walletType==="vectis",isWalletConnect:t.walletType==="walletconnect"}),vn),J=t=>{let n=["USE_CHECK_WALLET",h(o=>t||o.walletType)];return xn(n,({queryKey:[,o]})=>_(o))};var j=({onConnect:t,onDisconnect:e}={})=>{let n=g(o=>o.account),r=g(o=>o.status);return On(()=>g.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let{account:s,activeChain:a}=g.getState(),{walletType:c}=h.getState();t==null||t({account:s,chain:a,walletType:c,isReconnect:i==="reconnecting"})}o==="disconnected"&&(e==null||e())}),[t,e]),{data:n,isConnected:!!n,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:R,status:r}},_n=t=>{let{data:e}=j(),{data:n}=ve(),{activeChain:r}=g.getState(),o=t||(e==null?void 0:e.bech32Address),i=Ne(()=>["USE_ALL_BALANCES",n,r,o],[r,o,n]);return ee(i,async({queryKey:[,a,c,p]})=>{if(!c||!a)throw new Error("No connected account detected");if(!p)throw new Error("address is not defined");return await a.getAllBalances(p)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},dr=(t,e)=>{let{data:n}=_n(e);return ee(["USE_BALANCE",n,t,e],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===t),{enabled:!!n})},yr=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=bt(["USE_CONNECT",t,e,n],V,{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=J();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status}},Cr=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=bt(["USE_DISCONNECT",t,e,n],ge,{onError:i=>Promise.resolve(t==null?void 0:t(i,void 0)),onMutate:e,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>o.mutate(i),disconnectAsync:i=>o.mutateAsync(i),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,status:o.status}},wr=()=>{let t=g(r=>r.activeChain),e=h(r=>r.walletType),n=Ne(()=>["USE_OFFLINE_SIGNERS",t,e],[t,e]);return ee({queryKey:n,queryFn:async({queryKey:[,r,o]})=>{if(!r)throw new Error("No chain found");if(!_(o))throw new Error(`${o} is not available`);return await tt({chainId:r.chainId,walletType:o})},enabled:!!t&&!!e,refetchOnWindowFocus:!1})},Sr=t=>{let{data:e}=j(),{data:n}=ve(),{activeChain:r}=g.getState(),o=t||(e==null?void 0:e.bech32Address),i=Ne(()=>["USE_BALANCE_STAKED",n,r,o],[r,o,n]);return ee(i,async({queryKey:[,a,c,p]})=>{if(!c||!a)throw new Error("No connected account detected");if(!p)throw new Error("address is not defined");return await a.getBalanceStaked(p)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};import{useMutation as xt,useQuery as vt}from"@tanstack/react-query";var xr=()=>g(t=>t.activeChain),vr=t=>vt(["USE_ACTIVE_CHAIN_CURRENCY",t],({queryKey:[,r]})=>ot(r)),Or=(t,e="BOND_STATUS_BONDED")=>vt(["USE_ACTIVE_CHAIN_VALIDATORS",t,e],async({queryKey:[,o,i]})=>{if(!o)throw new Error("Query client is not defined");return await o.staking.validators(i)},{enabled:typeof t<"u"}),_r=()=>({data:h(e=>e.recentChain),clear:nt}),Nr=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=xt(["USE_SUGGEST_CHAIN",t,e,n],fe,{onError:(i,s)=>Promise.resolve(t==null?void 0:t(i,s)),onMutate:e,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,suggest:o.mutate,suggestAsync:o.mutateAsync,status:o.status}},Wr=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=xt(["USE_SUGGEST_CHAIN_AND_CONNECT",t,e,n],rt,{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:s=>e==null?void 0:e(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=J();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};import{useMutation as te,useQuery as Ot}from"@tanstack/react-query";var Ur=({onError:t,onLoading:e,onSuccess:n}={})=>{let{data:r}=j(),o=r==null?void 0:r.bech32Address,i=te(["USE_SEND_TOKENS",t,e,n,o],s=>st({senderAddress:o,...s}),{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return{error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},qr=({onError:t,onLoading:e,onSuccess:n}={})=>{let{data:r}=j(),o=r==null?void 0:r.bech32Address,i=te(["USE_SEND_IBC_TOKENS",t,e,n,o],s=>at({senderAddress:o,...s}),{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return{error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},Lr=({codeId:t,onError:e,onLoading:n,onSuccess:r})=>{let{data:o}=j(),i=o==null?void 0:o.bech32Address,a=te(["USE_INSTANTIATE_CONTRACT",e,n,r,t,i],c=>{if(!i)throw new Error("senderAddress is undefined");let p={...c,fee:c.fee??"auto",senderAddress:i,codeId:t};return ct(p)},{onError:(c,p)=>Promise.resolve(e==null?void 0:e(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return{error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Pr=({contractAddress:t,onError:e,onLoading:n,onSuccess:r})=>{let{data:o}=j(),i=o==null?void 0:o.bech32Address,a=te(["USE_EXECUTE_CONTRACT",e,n,r,t,i],c=>{if(!i)throw new Error("senderAddress is undefined");let p={...c,fee:c.fee??"auto",senderAddress:i,contractAddress:t,memo:c.memo??"",funds:c.funds??[]};return lt(p)},{onError:(c,p)=>Promise.resolve(e==null?void 0:e(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return{error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Br=(t,e)=>{let{data:n}=Oe();return Ot(["USE_QUERY_SMART",t,e,n],({queryKey:[,o]})=>{if(!t||!e)throw new Error("address or queryMsg undefined");return ut(t,e,n)},{enabled:!!t&&!!e&&!!n})},Gr=(t,e)=>{let{data:n}=Oe();return Ot(["USE_QUERY_RAW",e,t,n],({queryKey:[,i]})=>{if(!t||!e)throw new Error("address or key undefined");return mt(t,e,n)},{enabled:!!t&&!!e&&!!n})};import{SigningCosmWasmClient as _t}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as Nt}from"@cosmjs/stargate";import{useQuery as ne}from"@tanstack/react-query";import{useMemo as oe}from"react";var Yr=t=>{let e=g(o=>o.activeChain),n=h(o=>o.walletType),r=oe(()=>["USE_STARGATE_SIGNING_CLIENT",e,n,t],[t,e,n]);return ne({queryKey:r,queryFn:async({queryKey:[,o,i,s]})=>{if(!o)throw new Error("No chain found");if(!_(i))throw new Error(`${i} is not available`);let c=D(i).getOfflineSigner(o.chainId),p={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await Nt.connectWithSigner(p,c,s==null?void 0:s.opts)},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},Xr=t=>{let e=g(o=>o.activeChain),n=h(o=>o.walletType),r=oe(()=>["USE_COSMWASM_SIGNING_CLIENT",e,n,t],[t,e,n]);return ne({queryKey:r,queryFn:async({queryKey:[,o,i,s]})=>{if(!o)throw new Error("No chain found");if(!_(i))throw new Error(`${i} is not available`);let c=D(i).getOfflineSigner(o.chainId),p={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await _t.connectWithSigner(p,c,s==null?void 0:s.opts)},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},Jr=t=>{let e=g(i=>i.activeChain),n=h(i=>i.walletType),r=oe(()=>["USE_STARGATE_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=_e(t.type);return ne({queryKey:r,queryFn:({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!_(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let p=D(s).getOfflineSigner(i.chainId);return Nt.createWithSigner(o,p,a.opts)},enabled:!!e&&!!n&&!!o,refetchOnWindowFocus:!1})},ei=t=>{let e=g(i=>i.activeChain),n=h(i=>i.walletType),r=oe(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=_e(t.type);return ne({queryKey:r,queryFn:({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!_(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let p=D(s).getOfflineSigner(i.chainId);return _t.createWithSigner(o,p,a.opts)},enabled:!!e&&!!n&&!!o,refetchOnWindowFocus:!1})};import{QueryClient as Dn,QueryClientProvider as Rn}from"@tanstack/react-query";import{ReactQueryDevtools as Un}from"@tanstack/react-query-devtools";import{useEffect as Nn,useState as Wn}from"react";import{Fragment as kn,jsx as Fn}from"react/jsx-runtime";var Wt=({children:t})=>{let[e,n]=Wn(!1);return Nn(()=>{n(!0)},[]),Fn(kn,{children:e?t:null})};import{useEffect as kt}from"react";var Mn=()=>{let t=typeof window<"u"&&window.sessionStorage.getItem(L)==="Active",{_reconnect:e,_onReconnectFailed:n,_reconnectConnector:r}=h(),{activeChain:o,wcSignClient:i}=g();return kt(()=>{r&&(t&&o?R({onError:n}):!t&&e&&R({onError:n}))},[]),kt(()=>{var s,a,c,p,d,E,C,T,N,$;r&&(r==="cosmostation"&&((a=(s=me()).subscription)==null||a.call(s,()=>{R({onError:n})})),r==="keplr"&&((p=(c=le()).subscription)==null||p.call(c,()=>{R({onError:n})})),r==="leap"&&((E=(d=ue()).subscription)==null||E.call(d,()=>{R({onError:n})})),r==="vectis"&&((T=(C=pe()).subscription)==null||T.call(C,()=>{R({onError:n})})),r==="walletconnect"&&i&&(($=(N=Q()).subscription)==null||$.call(N,()=>{R({onError:n})})))},[r,i]),null},Ft=()=>(Mn(),null);import{jsx as Mt,jsxs as Dt}from"react/jsx-runtime";var qn=new Dn({}),di=({children:t,grazOptions:e,debug:n,...r})=>(e&&it(e),Dt(Rn,{client:qn,...r,children:[Dt(Wt,{children:[Mt(Ft,{}),t]}),n?Mt(Un,{initialIsOpen:!1,position:"bottom-right"}):null]},"graz-provider"));export{Ft as GrazEvents,di as GrazProvider,Ue as WALLET_TYPES,Re as WalletType,_ as checkWallet,nt as clearRecentChain,it as configureGraz,V as connect,jo as defineChain,zo as defineChainInfo,Tt as defineChains,ge as disconnect,lt as executeContract,ot as getActiveChainCurrency,ro as getAvailableWallets,me as getCosmostation,le as getKeplr,ue as getLeap,tt as getOfflineSigners,mt as getQueryRaw,ut as getQuerySmart,go as getRecentChain,pe as getVectis,Vt as getWCCosmostation,Qt as getWCKeplr,Ht as getWCLeap,D as getWallet,Q as getWalletConnect,ct as instantiateContract,Ko as mainnetChains,Qo as mainnetChainsArray,R as reconnect,at as sendIbcTokens,st as sendTokens,fe as suggestChain,rt as suggestChainAndConnect,Ho as testnetChains,Vo as testnetChainsArray,j as useAccount,xr as useActiveChain,vr as useActiveChainCurrency,Or as useActiveChainValidators,ar as useActiveWalletType,dr as useBalance,Sr as useBalanceStaked,_n as useBalances,J as useCheckWallet,yr as useConnect,Oe as useCosmWasmClient,Xr as useCosmWasmSigningClient,ei as useCosmWasmTmSigningClient,Cr as useDisconnect,Pr as useExecuteContract,Mn as useGrazEvents,Lr as useInstantiateContract,wr as useOfflineSigners,Gr as useQueryRaw,Br as useQuerySmart,_r as useRecentChain,qr as useSendIbcTokens,Ur as useSendTokens,ve as useStargateClient,Yr as useStargateSigningClient,Jr as useStargateTmSigningClient,Nr as useSuggestChain,Wr as useSuggestChainAndConnect,_e as useTendermintClient};
1
+ import{a as Yt,b as Ce,c as V}from"./chunk-HBC2VYPF.mjs";var me=Yt((mo,nt)=>{"use strict";nt.exports=E;var P=null;try{P=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function E(t,e,n){this.low=t|0,this.high=e|0,this.unsigned=!!n}E.prototype.__isLong__;Object.defineProperty(E.prototype,"__isLong__",{value:!0});function F(t){return(t&&t.__isLong__)===!0}E.isLong=F;var He={},Ve={};function Z(t,e){var n,r,o;return e?(t>>>=0,(o=0<=t&&t<256)&&(r=Ve[t],r)?r:(n=I(t,(t|0)<0?-1:0,!0),o&&(Ve[t]=n),n)):(t|=0,(o=-128<=t&&t<128)&&(r=He[t],r)?r:(n=I(t,t<0?-1:0,!1),o&&(He[t]=n),n))}E.fromInt=Z;function R(t,e){if(isNaN(t))return e?$:q;if(e){if(t<0)return $;if(t>=Xe)return tt}else{if(t<=-Ze)return D;if(t+1>=Ze)return et}return t<0?R(-t,e).neg():I(t%X|0,t/X|0,e)}E.fromNumber=R;function I(t,e,n){return new E(t,e,n)}E.fromBits=I;var ue=Math.pow;function Ae(t,e,n){if(t.length===0)throw Error("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return q;if(typeof e=="number"?(n=e,e=!1):e=!!e,n=n||10,n<2||36<n)throw RangeError("radix");var r;if((r=t.indexOf("-"))>0)throw Error("interior hyphen");if(r===0)return Ae(t.substring(1),e,n).neg();for(var o=R(ue(n,8)),i=q,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),c=parseInt(t.substring(s,s+a),n);if(a<8){var u=R(ue(n,a));i=i.mul(u).add(R(c))}else i=i.mul(o),i=i.add(R(c))}return i.unsigned=e,i}E.fromString=Ae;function L(t,e){return typeof t=="number"?R(t,e):typeof t=="string"?Ae(t,e):I(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}E.fromValue=L;var $e=65536,nn=1<<24,X=$e*$e,Xe=X*X,Ze=Xe/2,Ye=Z(nn),q=Z(0);E.ZERO=q;var $=Z(0,!0);E.UZERO=$;var Y=Z(1);E.ONE=Y;var Je=Z(1,!0);E.UONE=Je;var Se=Z(-1);E.NEG_ONE=Se;var et=I(-1,2147483647,!1);E.MAX_VALUE=et;var tt=I(-1,-1,!0);E.MAX_UNSIGNED_VALUE=tt;var D=I(0,-2147483648,!1);E.MIN_VALUE=D;var l=E.prototype;l.toInt=function(){return this.unsigned?this.low>>>0:this.low};l.toNumber=function(){return this.unsigned?(this.high>>>0)*X+(this.low>>>0):this.high*X+(this.low>>>0)};l.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(D)){var n=R(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var i=R(ue(e,6),this.unsigned),s=this,a="";;){var c=s.div(i),u=s.sub(c.mul(i)).toInt()>>>0,h=u.toString(e);if(s=c,s.isZero())return h+a;for(;h.length<6;)h="0"+h;a=""+h+a}};l.getHighBits=function(){return this.high};l.getHighBitsUnsigned=function(){return this.high>>>0};l.getLowBits=function(){return this.low};l.getLowBitsUnsigned=function(){return this.low>>>0};l.getNumBitsAbs=function(){if(this.isNegative())return this.eq(D)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<<n);n--);return this.high!=0?n+33:n+1};l.isZero=function(){return this.high===0&&this.low===0};l.eqz=l.isZero;l.isNegative=function(){return!this.unsigned&&this.high<0};l.isPositive=function(){return this.unsigned||this.high>=0};l.isOdd=function(){return(this.low&1)===1};l.isEven=function(){return(this.low&1)===0};l.equals=function(e){return F(e)||(e=L(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};l.eq=l.equals;l.notEquals=function(e){return!this.eq(e)};l.neq=l.notEquals;l.ne=l.notEquals;l.lessThan=function(e){return this.comp(e)<0};l.lt=l.lessThan;l.lessThanOrEqual=function(e){return this.comp(e)<=0};l.lte=l.lessThanOrEqual;l.le=l.lessThanOrEqual;l.greaterThan=function(e){return this.comp(e)>0};l.gt=l.greaterThan;l.greaterThanOrEqual=function(e){return this.comp(e)>=0};l.gte=l.greaterThanOrEqual;l.ge=l.greaterThanOrEqual;l.compare=function(e){if(F(e)||(e=L(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};l.comp=l.compare;l.negate=function(){return!this.unsigned&&this.eq(D)?D:this.not().add(Y)};l.neg=l.negate;l.add=function(e){F(e)||(e=L(e));var n=this.high>>>16,r=this.high&65535,o=this.low>>>16,i=this.low&65535,s=e.high>>>16,a=e.high&65535,c=e.low>>>16,u=e.low&65535,h=0,A=0,C=0,x=0;return x+=i+u,C+=x>>>16,x&=65535,C+=o+c,A+=C>>>16,C&=65535,A+=r+a,h+=A>>>16,A&=65535,h+=n+s,h&=65535,I(C<<16|x,h<<16|A,this.unsigned)};l.subtract=function(e){return F(e)||(e=L(e)),this.add(e.neg())};l.sub=l.subtract;l.multiply=function(e){if(this.isZero())return q;if(F(e)||(e=L(e)),P){var n=P.mul(this.low,this.high,e.low,e.high);return I(n,P.get_high(),this.unsigned)}if(e.isZero())return q;if(this.eq(D))return e.isOdd()?D:q;if(e.eq(D))return this.isOdd()?D:q;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(Ye)&&e.lt(Ye))return R(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=this.high&65535,i=this.low>>>16,s=this.low&65535,a=e.high>>>16,c=e.high&65535,u=e.low>>>16,h=e.low&65535,A=0,C=0,x=0,W=0;return W+=s*h,x+=W>>>16,W&=65535,x+=i*h,C+=x>>>16,x&=65535,x+=s*u,C+=x>>>16,x&=65535,C+=o*h,A+=C>>>16,C&=65535,C+=i*u,A+=C>>>16,C&=65535,C+=s*c,A+=C>>>16,C&=65535,A+=r*h+o*u+i*c+s*a,A&=65535,I(x<<16|W,A<<16|C,this.unsigned)};l.mul=l.multiply;l.divide=function(e){if(F(e)||(e=L(e)),e.isZero())throw Error("division by zero");if(P){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?P.div_u:P.div_s)(this.low,this.high,e.low,e.high);return I(n,P.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?$:q;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return $;if(e.gt(this.shru(1)))return Je;i=$}else{if(this.eq(D)){if(e.eq(Y)||e.eq(Se))return D;if(e.eq(D))return Y;var s=this.shr(1);return r=s.div(e).shl(1),r.eq(q)?e.isNegative()?Y:Se:(o=this.sub(e.mul(r)),i=r.add(o.div(e)),i)}else if(e.eq(D))return this.unsigned?$:q;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=q}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(r)/Math.LN2),c=a<=48?1:ue(2,a-48),u=R(r),h=u.mul(e);h.isNegative()||h.gt(o);)r-=c,u=R(r,this.unsigned),h=u.mul(e);u.isZero()&&(u=Y),i=i.add(u),o=o.sub(h)}return i};l.div=l.divide;l.modulo=function(e){if(F(e)||(e=L(e)),P){var n=(this.unsigned?P.rem_u:P.rem_s)(this.low,this.high,e.low,e.high);return I(n,P.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};l.mod=l.modulo;l.rem=l.modulo;l.not=function(){return I(~this.low,~this.high,this.unsigned)};l.and=function(e){return F(e)||(e=L(e)),I(this.low&e.low,this.high&e.high,this.unsigned)};l.or=function(e){return F(e)||(e=L(e)),I(this.low|e.low,this.high|e.high,this.unsigned)};l.xor=function(e){return F(e)||(e=L(e)),I(this.low^e.low,this.high^e.high,this.unsigned)};l.shiftLeft=function(e){return F(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?I(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):I(0,this.low<<e-32,this.unsigned)};l.shl=l.shiftLeft;l.shiftRight=function(e){return F(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?I(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):I(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};l.shr=l.shiftRight;l.shiftRightUnsigned=function(e){if(F(e)&&(e=e.toInt()),e&=63,e===0)return this;var n=this.high;if(e<32){var r=this.low;return I(r>>>e|n<<32-e,n>>>e,this.unsigned)}else return e===32?I(n,0,this.unsigned):I(n>>>e-32,0,this.unsigned)};l.shru=l.shiftRightUnsigned;l.shr_u=l.shiftRightUnsigned;l.toSigned=function(){return this.unsigned?I(this.low,this.high,!1):this};l.toUnsigned=function(){return this.unsigned?this:I(this.low,this.high,!0)};l.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};l.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};l.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};E.fromBytes=function(e,n,r){return r?E.fromBytesLE(e,n):E.fromBytesBE(e,n)};E.fromBytesLE=function(e,n){return new E(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)};E.fromBytesBE=function(e,n){return new E(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)}});import{create as Ke}from"zustand";import{createJSONStorage as Xt}from"zustand/middleware";import{persist as ze,subscribeWithSelector as Qe}from"zustand/middleware";var Ge=(u=>(u.KEPLR="keplr",u.LEAP="leap",u.VECTIS="vectis",u.COSMOSTATION="cosmostation",u.WALLETCONNECT="walletconnect",u.WC_KEPLR_MOBILE="wc_keplr_mobile",u.WC_LEAP_MOBILE="wc_leap_mobile",u.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",u.METAMASK_SNAP_LEAP="metamask_snap_leap",u))(Ge||{}),je=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","metamask_snap_leap"];var Jt={recentChain:null,defaultChain:null,defaultSigningClient:"stargate",walletType:"keplr",walletConnect:{options:null,web3Modal:null},_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},te={account:null,activeChain:null,balances:null,status:"disconnected",wcSignClient:null},en={name:"graz-session",version:1,partialize:t=>({account:t.account,activeChain:t.activeChain}),storage:Xt(()=>sessionStorage)},tn={name:"graz-internal",partialize:t=>({recentChain:t.recentChain,_reconnect:t._reconnect,_reconnectConnector:t._reconnectConnector}),version:1},g=Ke(Qe(ze(()=>te,en))),f=Ke(Qe(ze(()=>Jt,tn)));var ae=()=>{if(typeof window.cosmostation.providers.keplr<"u"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:r=>(window.cosmostation.cosmos.on("accountChanged",()=>{M(),r()}),()=>{window.cosmostation.cosmos.off("accountChanged",()=>{M(),r()})})})}throw f.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var ce=()=>{if(typeof window.keplr<"u"){let t=window.keplr;return Object.assign(t,{subscription:r=>(window.addEventListener("keplr_keystorechange",()=>{M(),r()}),()=>{window.removeEventListener("keplr_keystorechange",()=>{M(),r()})})})}throw f.getState()._notFoundFn(),new Error("window.keplr is not defined")};var le=()=>{if(typeof window.leap<"u"){let t=window.leap;return Object.assign(t,{subscription:r=>(window.addEventListener("leap_keystorechange",()=>{M(),r()}),()=>{window.removeEventListener("leap_keystorechange",()=>{M(),r()})})})}throw f.getState()._notFoundFn(),new Error("window.leap is not defined")};var ot=Ce(me());var rt=t=>{let e=window.ethereum;if(e&&t){let n=async()=>await e.request({method:"wallet_getSnaps"}),r=async w=>{try{let S=await n();return Object.values(S).find(O=>O.id===t.id&&(!w||O.version===w))}catch{return}},o=async()=>{await e.request({method:"wallet_requestSnaps",params:{[t.id]:t.params||{}}})},i=async()=>{let w=await e.request({method:"web3_clientVersion"});if(!(w==null?void 0:w.includes("flask")))throw new Error("Metamask Flask is not detected");return!0},s=async w=>{await r()||await o()},a=async(w,S,O)=>{let U=await e.request({method:"wallet_invokeSnap",params:{snapId:t.id,request:{method:"signDirect",params:{chainId:w,signerAddress:S,signDoc:O}}}}),z=O.accountNumber,ee=new ot.default(z.low,z.high,z.unsigned);return{signature:U.signature,signed:{...U.signed,accountNumber:`${ee.toString()}`,authInfoBytes:new Uint8Array(Object.values(U.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(U.signed.bodyBytes))}}},c=async(w,S,O)=>await e.request({method:"wallet_invokeSnap",params:{snapId:t.id,request:{method:"signAmino",params:{chainId:w,signerAddress:S,signDoc:O}}}}),u=async w=>{let S=await e.request({method:"wallet_invokeSnap",params:{snapId:t.id,request:{method:"getKey",params:{chainId:w}}}});if(!S)throw new Error("No response from Metamask");return S.pubKey=Uint8Array.from(Object.values(S.pubkey)),delete S.pubkey,{...S}},h=async w=>{let S=await u(w);return{address:S.bech32Address,algo:S.algo,pubkey:S.pubKey}},A=async(...w)=>{let[S,O,U,z]=w;return await c(S,O,U)},C=async(...w)=>{let[S,O,U]=w;return await a(S,O,U)},x=w=>({getAccounts:async()=>[await h(w)],signDirect:(S,O)=>C(w,S,O)}),W=w=>({getAccounts:async()=>[await h(w)],signAmino:(S,O)=>A(w,S,O)});return{getKey:u,getOfflineSigner:w=>({getAccounts:async()=>[await h(w)],signDirect:(S,O)=>C(w,S,O),signAmino:(S,O)=>A(w,S,O)}),getOfflineSignerAuto:async w=>(await u(w)).isNanoLedger?W(w):x(w),getOfflineSignerOnlyAmino:W,signDirect:C,signAmino:A,enable:s,experimentalSuggestChain:async(...w)=>{await Promise.reject(new Error("Metamask does not support experimentalSuggestChain"))},init:i}}throw f.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var it=()=>rt({id:"npm:@leapwallet/metamask-cosmos-snap"});var st=Ce(me());import{fromBech32 as on}from"@cosmjs/encoding";var pe=()=>{if(typeof window.vectis<"u"){let t=window.vectis.cosmos;return{enable:a=>t.enable(a),getOfflineSigner:a=>t.getOfflineSigner(a),getOfflineSignerAuto:a=>t.getOfflineSignerAuto(a),getKey:async a=>{let c=await t.getKey(a);return{address:on(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}},subscription:a=>(window.addEventListener("vectis_accountChanged",()=>{M(),a()}),()=>{window.removeEventListener("vectis_accountChanged",()=>{M(),a()})}),getOfflineSignerOnlyAmino:(...a)=>t.getOfflineSignerAmino(...a),experimentalSuggestChain:async(...a)=>{let[c]=a,u={...c,rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr};return t.suggestChains([u])},signDirect:async(...a)=>{var h;let{1:c,2:u}=a;return t.signDirect(c,{bodyBytes:u.bodyBytes||Uint8Array.from([]),authInfoBytes:u.authInfoBytes||Uint8Array.from([]),accountNumber:st.default.fromString(((h=u.accountNumber)==null?void 0:h.toString())||"",!1),chainId:u.chainId||""})},signAmino:async(...a)=>{let{1:c,2:u}=a;return t.signAmino(c,u)}}}throw f.getState()._notFoundFn(),new Error("window.vectis is not defined")};var ut=Ce(me());import{fromBech32 as rn}from"@cosmjs/encoding";import{SignClient as sn}from"@walletconnect/sign-client";import{getSdkError as an}from"@walletconnect/utils";var B=()=>typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,at=()=>B()&&navigator.userAgent.toLowerCase().includes("android"),ct=()=>B()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var lt=(t,e,n=new Error("Promise timed out"))=>{let r=new Promise((o,i)=>{setTimeout(()=>{i(n)},e)});return Promise.race([t,r])};var G=t=>{var z,ee,Be;if(!((Be=(ee=(z=f.getState().walletConnect)==null?void 0:z.options)==null?void 0:ee.projectId)!=null&&Be.trim()))throw new Error("walletConnect.options.projectId is not defined");let e=(t==null?void 0:t.encoding)||"base64",n=p=>{if(!t)return;let{appUrl:m,formatNativeUrl:d}=t;if(B()){if(at())if(!p)window.open(m.mobile.android,"_self","noreferrer noopener");else{let y=d(m.mobile.android,p,"android");window.open(y,"_self","noreferrer noopener")}if(ct())if(!p)window.open(m.mobile.ios,"_self","noreferrer noopener");else{let y=d(m.mobile.ios,p,"ios");window.open(y,"_self","noreferrer noopener")}}},r=()=>{let{wcSignClient:p}=g.getState();if(!p)throw new Error("walletConnect.signClient is not defined");M(),f.setState({_reconnect:!1,_reconnectConnector:null,recentChain:null})},o=async p=>{let{wcSignClient:m}=g.getState();if(!m)throw new Error("walletConnect.signClient is not defined");if(!p)throw new Error("No wallet connect session");await m.disconnect({topic:p,reason:an("USER_DISCONNECTED")}),await a(m),r()},i=p=>{var m,d;try{let{wcSignClient:y}=g.getState();if(!y)throw new Error("walletConnect.signClient is not defined");let b=y.session.getAll().at(-1);if(!b)return;let v=(d=(m=y.session.getAll().at(-1))==null?void 0:m.namespaces.cosmos)==null?void 0:d.accounts.find(k=>k.startsWith(`cosmos:${p}`));if(!(b.expiry*1e3>Date.now()+1e3))throw o(b.topic),new Error("invalid session");if(!v)try{let k=y.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${p}`],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 b}catch(y){if(!y.message.toLowerCase().includes("no matching key"))throw y}},s=p=>{try{return i(p)}catch{return}},a=async p=>{try{let m=p.core.pairing.pairings.getAll({active:!1});if(!m.length)return;await Promise.all(m.map(async d=>{await p.core.pairing.pairings.delete(d.topic,{code:7001,message:"clear pairing"})}))}catch(m){if(!m.message.toLowerCase().includes("no matching key"))throw m}},c=async()=>{let{walletConnect:p}=f.getState();if(!(p!=null&&p.options))throw new Error("walletConnect.options is not defined");let{wcSignClient:m}=g.getState();if(m)return g.setState({wcSignClient:m}),m;let d=await sn.init(p.options);return g.setState({wcSignClient:d}),d},u=p=>{let{wcSignClient:m}=g.getState();if(m)return m.events.on("session_delete",d=>{r()}),m.events.on("session_expire",d=>{r()}),m.events.on("session_event",d=>{var y,b;if(d.params.event.name==="accountsChanged"&&((y=d.params.event.data)==null?void 0:y[0])!==((b=g.getState().account)==null?void 0:b.bech32Address)){let v=d.params.chainId.split(":")[1];v&&h(v)}else p()}),()=>{m.events.off("session_delete",d=>{r()}),m.events.off("session_expire",d=>{r()}),m.events.off("session_event",d=>{var y,b;if(d.params.event.name==="accountsChanged"&&((y=d.params.event.data)==null?void 0:y[0])!==((b=g.getState().account)==null?void 0:b.bech32Address)){let v=d.params.chainId.split(":")[1];v&&h(v)}else p()})}},h=async p=>{var re;let{wcSignClient:m}=g.getState();if(!m)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:d}=f.getState();if(!((re=d==null?void 0:d.options)!=null&&re.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:y}=await import("@web3modal/standalone"),b=new y({projectId:d.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE",...d.web3Modal}),{account:v,activeChain:K}=g.getState(),k=s(p);if((K==null?void 0:K.chainId)!==p&&!k||!v){let{uri:N,approval:ie}=await m.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${p}`],events:["chainChanged","accountsChanged"]}}});if(!N)throw new Error("No wallet connect uri");t?n(N):await b.openModal({uri:N});let Zt=async Q=>Q.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((we,se)=>{ie().then(we).catch(se),Q.addEventListener("abort",()=>{se(new Error("User closed wallet connect"))})});try{let Q=new AbortController,we=Q.signal;b.subscribeModal(se=>{se.open||Q.abort()}),await Zt(we)}catch(Q){if(b.closeModal(),!Q.message.toLowerCase().includes("no matching key"))return Promise.reject(Q)}return t||b.closeModal(),Promise.resolve()}try{await lt((async()=>{let N=await C(p);g.setState({account:N})})(),15e3,new Error("Connection timeout"))}catch(N){if(o(k==null?void 0:k.topic),!N.message.toLowerCase().includes("no matching key"))throw N}},A=async p=>{var b;let{wcSignClient:m}=g.getState();if(!m)throw new Error("walletConnect.signClient is not defined");let d=(b=i(p))==null?void 0:b.topic;if(!d)throw new Error("No wallet connect session");n();let y=await m.request({topic:d,chainId:`cosmos:${p}`,request:{method:"cosmos_getAccounts",params:{}}});if(!y[0])throw new Error("No wallet connect account");return{address:y[0].address,algo:y[0].algo,pubkey:new Uint8Array(Buffer.from(y[0].pubkey,e))}},C=async p=>{let{address:m,algo:d,pubkey:y}=await A(p);return{address:rn(m).data,algo:d,bech32Address:m,name:"",pubKey:y,isKeystone:!1,isNanoLedger:!1}},x=async(...p)=>{var N,ie;let[m,d,y]=p,{account:b,wcSignClient:v}=g.getState();if(!v)throw new Error("walletConnect.signClient is not defined");if(!b)throw new Error("account is not defined");let K=(N=i(m))==null?void 0:N.topic;if(!K)throw new Error("No wallet connect session");if(!y.bodyBytes)throw new Error("No bodyBytes");if(!y.authInfoBytes)throw new Error("No authInfoBytes");let k={topic:K,chainId:`cosmos:${m}`,request:{method:"cosmos_signDirect",params:{signerAddress:d,signDoc:{...y,bodyBytes:Buffer.from(y.bodyBytes).toString(e),authInfoBytes:Buffer.from(y.authInfoBytes).toString(e),accountNumber:(ie=y.accountNumber)==null?void 0:ie.toString()}}}};return n(),await v.request(k)},W=async(...p)=>{let[m,d,y]=p,{signature:b,signed:v}=await x(m,d,y);return{signed:{chainId:v.chainId,accountNumber:ut.default.fromString(v.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(v.authInfoBytes,e)),bodyBytes:new Uint8Array(Buffer.from(v.bodyBytes,e))},signature:b}},J=async(...p)=>{var N;let[m,d,y,b]=p,{wcSignClient:v}=g.getState(),{account:K}=g.getState();if(!v)throw new Error("walletConnect.signClient is not defined");if(!K)throw new Error("account is not defined");let k=(N=i(m))==null?void 0:N.topic;if(!k)throw new Error("No wallet connect session");return n(),await v.request({topic:k,chainId:`cosmos:${m}`,request:{method:"cosmos_signDirect",params:{signerAddress:d,signDoc:y}}})},oe=async(...p)=>{let[m,d,y,b]=p;return await J(m,d,y)},Ue=p=>({getAccounts:async()=>[await A(p)],signDirect:(m,d)=>W(p,m,d)}),w=p=>({getAccounts:async()=>[await A(p)],signAmino:(m,d)=>oe(p,m,d)});return{enable:h,experimentalSuggestChain:async(...p)=>{await Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"))},getKey:C,getOfflineSigner:p=>({getAccounts:async()=>[await A(p)],signDirect:(m,d)=>W(p,m,d),signAmino:(m,d)=>oe(p,m,d)}),getOfflineSignerAuto:async p=>(await C(p)).isNanoLedger?w(p):Ue(p),getOfflineSignerOnlyAmino:w,signAmino:oe,signDirect:W,subscription:u,init:c}};var mt=()=>{var e,n,r;if(!((r=(n=(e=f.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!B())throw new Error("WalletConnect Leap mobile is only supported in mobile");let t={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_leap_mobile",formatNativeUrl:(o,i,s)=>`${o.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return G(t)};var pt=()=>{var e,n,r;if(!((r=(n=(e=f.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!B())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let t={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(o,i,s)=>{let a=o.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);switch(s){case"ios":return`${a}://wcV2?${c}`;case"android":return`${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return`${a}://wc?uri=${c}`}}};return G(t)};var gt=()=>{var e,n,r;if(!((r=(n=(e=f.getState().walletConnect)==null?void 0:e.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!B())throw new Error("WalletConnect Leap mobile is only supported in mobile");let t={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(o,i,s)=>{let a=o.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);switch(s){case"ios":return`${a}://wcV2?${c}`;case"android":return`${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return`${a}://wc?uri=${c}`}}};return G(t)};var _=(t=f.getState().walletType)=>{try{return T(t),!0}catch{return!1}},M=()=>{window.sessionStorage.removeItem(V),g.setState(te)},T=(t=f.getState().walletType)=>{switch(t){case"keplr":return ce();case"leap":return le();case"cosmostation":return ae();case"vectis":return pe();case"walletconnect":return G();case"wc_keplr_mobile":return pt();case"wc_leap_mobile":return gt();case"wc_cosmostation_mobile":return mt();case"metamask_snap_leap":return it();default:throw new Error("Unknown wallet type")}},tr=()=>Object.fromEntries(je.map(t=>[t,_(t)]));var ne=async t=>{var e;try{let{defaultChain:n,recentChain:r,walletType:o}=f.getState(),i=(t==null?void 0:t.walletType)||o;if(!_(i))throw new Error(`${i} is not available`);let a=T(i),c=(t==null?void 0:t.chain)||r||n;if(!c)throw new Error("No last known connected chain, connect action requires chain info");g.setState(C=>{let x=f.getState()._reconnect||!!f.getState()._reconnectConnector||!!c;return C.activeChain&&C.activeChain.chainId!==c.chainId?{status:"connecting"}:x?{status:"reconnecting"}:{status:"connecting"}});let{account:u,activeChain:h}=g.getState();if(await((e=a.init)==null?void 0:e.call(a)),!u||(h==null?void 0:h.chainId)!==c.chainId){await a.enable(c.chainId);let C=await a.getKey(c.chainId);g.setState({account:C})}f.setState({recentChain:c,walletType:i,_reconnect:!!(t!=null&&t.autoReconnect),_reconnectConnector:i}),g.setState({activeChain:c,status:"connected"}),typeof window<"u"&&window.sessionStorage.setItem(V,"Active");let{account:A}=g.getState();return{account:A,walletType:i,chain:c}}catch(n){throw console.error("connect ",n),g.getState().account===null&&g.setState({status:"disconnected"}),g.getState().account&&g.getState().activeChain&&g.setState({status:"connected"}),n}},Ee=async(t=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(V),g.setState(te),f.setState(e=>({_reconnect:!1,_reconnectConnector:null,recentChain:t?null:e.recentChain})),Promise.resolve()),j=async t=>{var o;let{recentChain:e,_reconnectConnector:n,_reconnect:r}=f.getState();try{let i=_(n||void 0);if(e&&i&&n)return await ne({chain:e,walletType:n,autoReconnect:r})}catch(i){(o=t==null?void 0:t.onError)==null||o.call(t,i),Ee()}},ft=async t=>{if(!(t!=null&&t.chainId))throw new Error("chainId is required");let{walletType:e}=f.getState(),n=t.walletType||e;if(!_(n))throw new Error(`${n} is not available`);let o=T(n),i=o.getOfflineSigner(t.chainId),s=o.getOfflineSignerOnlyAmino(t.chainId),a=await o.getOfflineSignerAuto(t.chainId);return{offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}};var dt=()=>{f.setState({recentChain:null})},ht=t=>{let{activeChain:e}=g.getState();return e==null?void 0:e.currencies.find(n=>n.coinMinimalDenom===t)},ur=()=>f.getState().recentChain,Ie=async t=>(await T().experimentalSuggestChain(t),t),yt=async({chainInfo:t,rpcHeaders:e,gas:n,path:r,...o})=>{let i=await Ie(t);return{...await ne({chain:{chainId:t.chainId,currencies:t.currencies,rest:t.rest,rpc:t.rpc,rpcHeaders:e,gas:n,path:r},...o}),chain:i}};var wt=(t={})=>(f.setState(e=>({defaultChain:t.defaultChain||e.defaultChain,defaultSigningClient:t.defaultSigningClient||e.defaultSigningClient,walletConnect:t.walletConnect||e.walletConnect,walletType:t.defaultWallet||e.walletType,_notFoundFn:t.onNotFound||e._notFoundFn,_onReconnectFailed:t.onReconnectFailed||e._onReconnectFailed,_reconnect:t.autoReconnect===void 0?!0:t.autoReconnect||e._reconnect})),t);var Ct=async({signingClient:t,senderAddress:e,recipientAddress:n,amount:r,fee:o,memo:i})=>{if(!t)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return t.sendTokens(e,n,r,o,i)},St=async({signingClient:t,senderAddress:e,recipientAddress:n,transferAmount:r,sourcePort:o,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:u})=>{if(!t)throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return t.sendIbcTokens(e,n,r,o,i,s,a,c,u)},At=async({signingClient:t,senderAddress:e,msg:n,fee:r,options:o,label:i,codeId:s})=>{if(!t)throw new Error("CosmWasm signing client is not ready");return t.instantiate(e,s,n,i,r,o)},Et=async({signingClient:t,senderAddress:e,msg:n,fee:r,contractAddress:o,funds:i,memo:s})=>{if(!t)throw new Error("CosmWasm signing client is not ready");return t.execute(e,o,n,r,s,i)},It=async(t,e,n)=>{if(!n)throw new Error("CosmWasm client is not ready");return await n.queryContractSmart(t,e)},bt=(t,e,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(e);return n.queryContractRaw(t,r)};import{Bech32Address as cn}from"@keplr-wallet/cosmos";var xt={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},ln={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},un={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},mn={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},pn={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},gn={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Tt=[xt,ln,un,mn,pn,gn],be={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:xt,bip44:{coinType:118},bech32Config:cn.defaultBech32Config("axelar"),currencies:Tt,feeCurrencies:Tt};import{Bech32Address as fn}from"@keplr-wallet/cosmos";var Ot={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},vt=[Ot],Te={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:Ot,bip44:{coinType:118},bech32Config:fn.defaultBech32Config("cosmos"),currencies:vt,feeCurrencies:vt};import{Bech32Address as dn}from"@keplr-wallet/cosmos";var Wt={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},hn={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},yn={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},wn={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Cn={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Sn={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},An={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},En={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},In={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},bn={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Tn={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},kt=[Wt,hn,yn,wn,Cn,Sn,An,En,In,bn,Tn],xe={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Wt,bip44:{coinType:118},bech32Config:dn.defaultBech32Config("juno"),currencies:kt,feeCurrencies:kt};import{Bech32Address as xn}from"@keplr-wallet/cosmos";var Mt={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},vn={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Nt=[Mt,vn],ve={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Mt,bip44:{coinType:118},bech32Config:xn.defaultBech32Config("osmo"),currencies:Nt,feeCurrencies:Nt};import{Bech32Address as On}from"@keplr-wallet/cosmos";var Ft={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Dt=[Ft],Oe={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Ft,bip44:{coinType:118},bech32Config:On.defaultBech32Config("somm"),currencies:Dt,feeCurrencies:Dt};import{Bech32Address as kn}from"@keplr-wallet/cosmos";var Pt={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},_t=[Pt],ke={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:kn.defaultBech32Config("CRE"),currencies:_t,feeCurrencies:_t,stakeCurrency:Pt,coinType:118};import{Bech32Address as Wn}from"@keplr-wallet/cosmos";var We={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Nn=[We],Ne={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:We,bip44:{coinType:118},bech32Config:Wn.defaultBech32Config("juno"),currencies:Nn,feeCurrencies:[We],coinType:118};import{Bech32Address as Mn}from"@keplr-wallet/cosmos";var Me={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Dn=[Me],De={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:Me,bip44:{coinType:118},bech32Config:Mn.defaultBech32Config("osmo"),currencies:Dn,feeCurrencies:[Me],coinType:118};var Rt=t=>t,Lr=t=>t,Ur=t=>t,Br=Rt({axelar:be,cosmoshub:Te,juno:xe,osmosis:ve,sommelier:Oe}),Gr=[be,Te,xe,ve,Oe],jr=Rt({crescent:ke,juno:Ne,osmosis:De}),Kr=[ke,Ne,De];import{useMutation as qt,useQuery as fe}from"@tanstack/react-query";import{useEffect as Un,useMemo as Le}from"react";import{CosmWasmClient as Fn}from"@cosmjs/cosmwasm-stargate";import{StargateClient as _n}from"@cosmjs/stargate";import{Tendermint34Client as Pn,Tendermint37Client as Rn}from"@cosmjs/tendermint-rpc";import{useQuery as Fe}from"@tanstack/react-query";import{useMemo as _e}from"react";var Pe=()=>{let t=g(n=>n.activeChain),e=_e(()=>["USE_STARGATE_CLIENT",t],[t]);return Fe({queryKey:e,queryFn:async({queryKey:[,n]})=>{if(!n)throw new Error("No chain found");let r={url:n.rpc,headers:{...n.rpcHeaders||{}}};return await _n.connect(r)},enabled:!!t,refetchOnWindowFocus:!1})},Re=()=>{let t=g(n=>n.activeChain),e=_e(()=>["USE_COSMWASM_CLIENT",t],[t]);return Fe({queryKey:e,queryFn:async({queryKey:[,n]})=>{if(!n)throw new Error("No chain found");let r={url:n.rpc,headers:{...n.rpcHeaders||{}}};return await Fn.connect(r)},enabled:!!t,refetchOnWindowFocus:!1})},qe=t=>{let e=g(r=>r.activeChain),n=_e(()=>["USE_TENDERMINT_CLIENT",t,e],[t,e]);return Fe({queryKey:n,queryFn:async({queryKey:[,r,o]})=>{if(!o)throw new Error("No chain found");let i={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await(r==="tm37"?Rn:Pn).connect(i)},enabled:!!e,refetchOnWindowFocus:!1})};import{useQuery as qn}from"@tanstack/react-query";import{shallow as Ln}from"zustand/shallow";var oi=()=>f(t=>({walletType:t.walletType,isCosmostation:t.walletType==="cosmostation",isCosmostationMobile:t.walletType==="wc_cosmostation_mobile",isKeplr:t.walletType==="keplr",isKeplrMobile:t.walletType==="wc_keplr_mobile",isLeap:t.walletType==="leap",isLeapMobile:t.walletType==="wc_leap_mobile",isVectis:t.walletType==="vectis",isWalletConnect:t.walletType==="walletconnect"}),Ln),ge=t=>{let n=["USE_CHECK_WALLET",f(o=>t||o.walletType)];return qn(n,({queryKey:[,o]})=>_(o))};var H=({onConnect:t,onDisconnect:e}={})=>{let n=g(o=>o.account),r=g(o=>o.status);return Un(()=>g.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let{account:s,activeChain:a}=g.getState(),{walletType:c}=f.getState();t==null||t({account:s,chain:a,walletType:c,isReconnect:i==="reconnecting"})}o==="disconnected"&&(e==null||e())}),[t,e]),{data:n,isConnected:!!n,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:j,status:r}},Bn=t=>{let{data:e}=H(),{data:n}=Pe(),{activeChain:r}=g.getState(),o=t||(e==null?void 0:e.bech32Address),i=Le(()=>["USE_ALL_BALANCES",n,r,o],[r,o,n]);return fe(i,async({queryKey:[,a,c,u]})=>{if(!c||!a)throw new Error("No connected account detected");if(!u)throw new Error("address is not defined");return await a.getAllBalances(u)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},pi=(t,e)=>{let{data:n}=H(),r=e||(n==null?void 0:n.bech32Address),{data:o,refetch:i}=Bn(r),a=fe(["USE_BALANCE",o,t,e],({queryKey:[,c]})=>c==null?void 0:c.find(u=>u.denom===t),{enabled:!!o});return{...a,refetch:async()=>(await i(),a.refetch())}},gi=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=qt(["USE_CONNECT",t,e,n],ne,{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=ge();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status}},fi=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=qt(["USE_DISCONNECT",t,e,n],Ee,{onError:i=>Promise.resolve(t==null?void 0:t(i,void 0)),onMutate:e,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>o.mutate(i),disconnectAsync:i=>o.mutateAsync(i),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,status:o.status}},di=()=>{let t=g(r=>r.activeChain),e=f(r=>r.walletType),n=Le(()=>["USE_OFFLINE_SIGNERS",t,e],[t,e]);return fe({queryKey:n,queryFn:async({queryKey:[,r,o]})=>{if(!r)throw new Error("No chain found");if(!_(o))throw new Error(`${o} is not available`);return await ft({chainId:r.chainId,walletType:o})},enabled:!!t&&!!e,refetchOnWindowFocus:!1})},hi=t=>{let{data:e}=H(),{data:n}=Pe(),{activeChain:r}=g.getState(),o=t||(e==null?void 0:e.bech32Address),i=Le(()=>["USE_BALANCE_STAKED",n,r,o],[r,o,n]);return fe(i,async({queryKey:[,a,c,u]})=>{if(!c||!a)throw new Error("No connected account detected");if(!u)throw new Error("address is not defined");return await a.getBalanceStaked(u)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};import{useMutation as Lt,useQuery as Ut}from"@tanstack/react-query";var Ei=()=>g(t=>t.activeChain),Ii=t=>Ut(["USE_ACTIVE_CHAIN_CURRENCY",t],({queryKey:[,r]})=>ht(r)),bi=(t,e="BOND_STATUS_BONDED")=>Ut(["USE_ACTIVE_CHAIN_VALIDATORS",t,e],async({queryKey:[,o,i]})=>{if(!o)throw new Error("Query client is not defined");return await o.staking.validators(i)},{enabled:typeof t<"u"}),Ti=()=>({data:f(e=>e.recentChain),clear:dt}),xi=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=Lt(["USE_SUGGEST_CHAIN",t,e,n],Ie,{onError:(i,s)=>Promise.resolve(t==null?void 0:t(i,s)),onMutate:e,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,suggest:o.mutate,suggestAsync:o.mutateAsync,status:o.status}},vi=({onError:t,onLoading:e,onSuccess:n}={})=>{let o=Lt(["USE_SUGGEST_CHAIN_AND_CONNECT",t,e,n],yt,{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:s=>e==null?void 0:e(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=ge();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};import{useMutation as de,useQuery as Bt}from"@tanstack/react-query";var Di=({onError:t,onLoading:e,onSuccess:n}={})=>{let{data:r}=H(),o=r==null?void 0:r.bech32Address,i=de(["USE_SEND_TOKENS",t,e,n,o],s=>Ct({senderAddress:o,...s}),{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return{error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},Fi=({onError:t,onLoading:e,onSuccess:n}={})=>{let{data:r}=H(),o=r==null?void 0:r.bech32Address,i=de(["USE_SEND_IBC_TOKENS",t,e,n,o],s=>St({senderAddress:o,...s}),{onError:(s,a)=>Promise.resolve(t==null?void 0:t(s,a)),onMutate:e,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return{error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},_i=({codeId:t,onError:e,onLoading:n,onSuccess:r})=>{let{data:o}=H(),i=o==null?void 0:o.bech32Address,a=de(["USE_INSTANTIATE_CONTRACT",e,n,r,t,i],c=>{if(!i)throw new Error("senderAddress is undefined");let u={...c,fee:c.fee??"auto",senderAddress:i,codeId:t};return At(u)},{onError:(c,u)=>Promise.resolve(e==null?void 0:e(c,u)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return{error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Pi=({contractAddress:t,onError:e,onLoading:n,onSuccess:r})=>{let{data:o}=H(),i=o==null?void 0:o.bech32Address,a=de(["USE_EXECUTE_CONTRACT",e,n,r,t,i],c=>{if(!i)throw new Error("senderAddress is undefined");let u={...c,fee:c.fee??"auto",senderAddress:i,contractAddress:t,memo:c.memo??"",funds:c.funds??[]};return Et(u)},{onError:(c,u)=>Promise.resolve(e==null?void 0:e(c,u)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return{error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Ri=(t,e)=>{let{data:n}=Re();return Bt(["USE_QUERY_SMART",t,e,n],({queryKey:[,o]})=>{if(!t||!e)throw new Error("address or queryMsg undefined");return It(t,e,n)},{enabled:!!t&&!!e&&!!n})},qi=(t,e)=>{let{data:n}=Re();return Bt(["USE_QUERY_RAW",e,t,n],({queryKey:[,i]})=>{if(!t||!e)throw new Error("address or key undefined");return bt(t,e,n)},{enabled:!!t&&!!e&&!!n})};import{SigningCosmWasmClient as Gt}from"@cosmjs/cosmwasm-stargate";import{GasPrice as jt,SigningStargateClient as Kt}from"@cosmjs/stargate";import{useQuery as he}from"@tanstack/react-query";import{useMemo as ye}from"react";var Hi=t=>{let e=g(o=>o.activeChain),n=f(o=>o.walletType),r=ye(()=>["USE_STARGATE_SIGNING_CLIENT",e,n,t],[t,e,n]);return he({queryKey:r,queryFn:async({queryKey:[,o,i,s]})=>{if(!o)throw new Error("No chain found");if(!_(i))throw new Error(`${i} is not available`);let c=await(async()=>{switch(t==null?void 0:t.offlineSigner){case"offlineSigner":return T(i).getOfflineSigner(o.chainId);case"offlineSignerAuto":return T(i).getOfflineSignerAuto(o.chainId);case"offlineSignerOnlyAmino":return T(i).getOfflineSignerOnlyAmino(o.chainId);default:return T(i).getOfflineSignerAuto(o.chainId)}})(),u={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await Kt.connectWithSigner(u,c,s==null?void 0:s.opts)},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},Vi=t=>{let e=g(o=>o.activeChain),n=f(o=>o.walletType),r=ye(()=>["USE_COSMWASM_SIGNING_CLIENT",e,n,t],[t,e,n]);return he({queryKey:r,queryFn:async({queryKey:[,o,i,s]})=>{if(!o)throw new Error("No chain found");if(!_(i))throw new Error(`${i} is not available`);let c=await(async()=>{switch(t==null?void 0:t.offlineSigner){case"offlineSigner":return T(i).getOfflineSigner(o.chainId);case"offlineSignerAuto":return T(i).getOfflineSignerAuto(o.chainId);case"offlineSignerOnlyAmino":return T(i).getOfflineSignerOnlyAmino(o.chainId);default:return T(i).getOfflineSignerAuto(o.chainId)}})(),u={url:o.rpc,headers:{...o.rpcHeaders||{}}},h=o.gas?jt.fromString(`${o.gas.price}${o.gas.denom}`):void 0;return await Gt.connectWithSigner(u,c,{gasPrice:h,...(s==null?void 0:s.opts)||{}})},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},$i=t=>{let e=g(i=>i.activeChain),n=f(i=>i.walletType),r=ye(()=>["USE_STARGATE_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=qe(t.type);return he({queryKey:r,queryFn:async({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!_(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let u=await(async()=>{switch(t.offlineSigner){case"offlineSigner":return T(s).getOfflineSigner(i.chainId);case"offlineSignerAuto":return T(s).getOfflineSignerAuto(i.chainId);case"offlineSignerOnlyAmino":return T(s).getOfflineSignerOnlyAmino(i.chainId);default:return T(s).getOfflineSignerAuto(i.chainId)}})();return Kt.createWithSigner(o,u,a.opts)},enabled:!!e&&!!n&&!!o,refetchOnWindowFocus:!1})},Zi=t=>{let e=g(i=>i.activeChain),n=f(i=>i.walletType),r=ye(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=qe(t.type);return he({queryKey:r,queryFn:async({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!_(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let u=await(async()=>{switch(t.offlineSigner){case"offlineSigner":return T(s).getOfflineSigner(i.chainId);case"offlineSignerAuto":return T(s).getOfflineSignerAuto(i.chainId);case"offlineSignerOnlyAmino":return T(s).getOfflineSignerOnlyAmino(i.chainId);default:return T(s).getOfflineSignerAuto(i.chainId)}})(),h=i.gas?jt.fromString(`${i.gas.price}${i.gas.denom}`):void 0;return Gt.createWithSigner(o,u,{gasPrice:h,...(a==null?void 0:a.opts)||{}})},enabled:!!e&&!!n&&!!o,refetchOnWindowFocus:!1})};import{QueryClient as Hn,QueryClientProvider as Vn}from"@tanstack/react-query";import{ReactQueryDevtools as $n}from"@tanstack/react-query-devtools";import{useEffect as Gn,useState as jn}from"react";import{Fragment as Kn,jsx as zn}from"react/jsx-runtime";var zt=({children:t})=>{let[e,n]=jn(!1);return Gn(()=>{n(!0)},[]),zn(Kn,{children:e?t:null})};import{useEffect as Qt}from"react";var Qn=()=>{let t=typeof window<"u"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:e,_onReconnectFailed:n,_reconnectConnector:r}=f(),{activeChain:o,wcSignClient:i}=g();return Qt(()=>{r&&(t&&o?j({onError:n}):!t&&e&&j({onError:n}))},[]),Qt(()=>{var s,a,c,u,h,A,C,x,W,J;r&&(r==="cosmostation"&&((a=(s=ae()).subscription)==null||a.call(s,()=>{j({onError:n})})),r==="keplr"&&((u=(c=ce()).subscription)==null||u.call(c,()=>{j({onError:n})})),r==="leap"&&((A=(h=le()).subscription)==null||A.call(h,()=>{j({onError:n})})),r==="vectis"&&((x=(C=pe()).subscription)==null||x.call(C,()=>{j({onError:n})})),r==="walletconnect"&&i&&((J=(W=G()).subscription)==null||J.call(W,()=>{j({onError:n})})))},[r,i]),null},Ht=()=>(Qn(),null);import{jsx as Vt,jsxs as $t}from"react/jsx-runtime";var Zn=new Hn({}),hs=({children:t,grazOptions:e,debug:n,...r})=>(e&&wt(e),$t(Vn,{client:Zn,...r,children:[$t(zt,{children:[Vt(Ht,{}),t]}),n?Vt($n,{initialIsOpen:!1,position:"bottom-right"}):null]},"graz-provider"));export{Ht as GrazEvents,hs as GrazProvider,je as WALLET_TYPES,Ge as WalletType,_ as checkWallet,dt as clearRecentChain,M as clearSession,wt as configureGraz,ne as connect,Lr as defineChain,Ur as defineChainInfo,Rt as defineChains,Ee as disconnect,Et as executeContract,ht as getActiveChainCurrency,tr as getAvailableWallets,ae as getCosmostation,ce as getKeplr,le as getLeap,it as getMetamaskSnapLeap,ft as getOfflineSigners,bt as getQueryRaw,It as getQuerySmart,ur as getRecentChain,pe as getVectis,mt as getWCCosmostation,pt as getWCKeplr,gt as getWCLeap,T as getWallet,G as getWalletConnect,At as instantiateContract,Br as mainnetChains,Gr as mainnetChainsArray,j as reconnect,St as sendIbcTokens,Ct as sendTokens,Ie as suggestChain,yt as suggestChainAndConnect,jr as testnetChains,Kr as testnetChainsArray,H as useAccount,Ei as useActiveChain,Ii as useActiveChainCurrency,bi as useActiveChainValidators,oi as useActiveWalletType,pi as useBalance,hi as useBalanceStaked,Bn as useBalances,ge as useCheckWallet,gi as useConnect,Re as useCosmWasmClient,Vi as useCosmWasmSigningClient,Zi as useCosmWasmTmSigningClient,fi as useDisconnect,Pi as useExecuteContract,Qn as useGrazEvents,_i as useInstantiateContract,di as useOfflineSigners,qi as useQueryRaw,Ri as useQuerySmart,Ti as useRecentChain,Fi as useSendIbcTokens,Di as useSendTokens,Pe as useStargateClient,Hi as useStargateSigningClient,$i as useStargateTmSigningClient,xi as useSuggestChain,vi as useSuggestChainAndConnect,qe 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.0.46",
4
+ "version": "0.0.48",
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",
@@ -28,12 +28,11 @@
28
28
  "@cosmjs/stargate": "^0.31.0",
29
29
  "@cosmjs/tendermint-rpc": "^0.31.0",
30
30
  "@keplr-wallet/cosmos": "^0.12.20",
31
- "@keplr-wallet/types": "^0.12.20",
31
+ "@metamask/providers": "^11.1.1",
32
32
  "@tanstack/react-query": "^4.29.14",
33
33
  "@tanstack/react-query-devtools": "^4.29.14",
34
34
  "@vectis/extension-client": "^0.7.1",
35
35
  "@walletconnect/sign-client": "^2.8.1",
36
- "@walletconnect/types": "^2.8.1",
37
36
  "@walletconnect/utils": "^2.8.1",
38
37
  "@web3modal/standalone": "^2.4.3",
39
38
  "arg": "^5.0.2",
@@ -41,8 +40,10 @@
41
40
  "zustand": "^4.3.8"
42
41
  },
43
42
  "devDependencies": {
43
+ "@keplr-wallet/types": "^0.12.20",
44
44
  "@types/node": "^20.3.1",
45
45
  "@types/react": "^18.2.12",
46
+ "@walletconnect/types": "^2.8.1",
46
47
  "react": "^18.2.0",
47
48
  "typescript": "^5.1.3"
48
49
  },