graz 0.0.47 → 0.0.49-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +52 -23
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +14 -12
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
|
|
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
|
|
387
|
+
* const leapMetamaskSnap = getMetamaskSnapLeap();
|
|
351
388
|
* } catch (error: Error) {
|
|
352
389
|
* console.error(error.message);
|
|
353
390
|
* }
|
|
354
391
|
* ```
|
|
355
392
|
*
|
|
356
|
-
*
|
|
393
|
+
*
|
|
357
394
|
*/
|
|
358
|
-
declare const
|
|
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,
|
|
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 } =
|
|
910
|
+
* const { data: signingClient } = useCosmWasmSigningClient()
|
|
882
911
|
* const { executeContract } = useExecuteContract<ExecuteMessage>({ contractAddress });
|
|
883
912
|
*
|
|
884
913
|
* executeContract({
|
|
@@ -1057,4 +1086,4 @@ declare const useGrazEvents: () => null;
|
|
|
1057
1086
|
*/
|
|
1058
1087
|
declare const GrazEvents: FC;
|
|
1059
1088
|
|
|
1060
|
-
export { AccountData, ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, ConnectResult, Connector, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs,
|
|
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 gn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),pn=(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=gn((To,Et)=>{"use strict";Et.exports=w;var _=null;try{_=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 W(t){return(t&&t.__isLong__)===!0}w.isLong=W;var pt={},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=pt[t],r)?r:(n=S(t,t<0?-1:0,!1),o&&(pt[t]=n),n))}w.fromInt=z;function F(t,e){if(isNaN(t))return e?j:M;if(e){if(t<0)return j;if(t>=Ct)return At}else{if(t<=-dt)return N;if(t+1>=dt)return St}return t<0?F(-t,e).neg():S(t%$|0,t/$|0,e)}w.fromNumber=F;function S(t,e,n){return new w(t,e,n)}w.fromBits=S;var ce=Math.pow;function Ne(t,e,n){if(t.length===0)throw Error("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return M;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 Ne(t.substring(1),e,n).neg();for(var o=F(ce(n,8)),i=M,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 g=F(ce(n,a));i=i.mul(g).add(F(c))}else i=i.mul(o),i=i.add(F(c))}return i.unsigned=e,i}w.fromString=Ne;function D(t,e){return typeof t=="number"?F(t,e):typeof t=="string"?Ne(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),M=z(0);w.ZERO=M;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 N=S(0,-2147483648,!1);w.MIN_VALUE=N;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(N)){var n=F(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=F(ce(e,6),this.unsigned),s=this,a="";;){var c=s.div(i),g=s.sub(c.mul(i)).toInt()>>>0,d=g.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(N)?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 W(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(W(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(N)?N:this.not().add(V)};l.neg=l.negate;l.add=function(e){W(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,g=e.low&65535,d=0,I=0,C=0,b=0;return b+=i+g,C+=b>>>16,b&=65535,C+=o+c,I+=C>>>16,C&=65535,I+=r+a,d+=I>>>16,I&=65535,d+=n+s,d&=65535,S(C<<16|b,d<<16|I,this.unsigned)};l.subtract=function(e){return W(e)||(e=D(e)),this.add(e.neg())};l.sub=l.subtract;l.multiply=function(e){if(this.isZero())return M;if(W(e)||(e=D(e)),_){var n=_.mul(this.low,this.high,e.low,e.high);return S(n,_.get_high(),this.unsigned)}if(e.isZero())return M;if(this.eq(N))return e.isOdd()?N:M;if(e.eq(N))return this.isOdd()?N:M;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 F(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,g=e.low>>>16,d=e.low&65535,I=0,C=0,b=0,k=0;return k+=s*d,b+=k>>>16,k&=65535,b+=i*d,C+=b>>>16,b&=65535,b+=s*g,C+=b>>>16,b&=65535,C+=o*d,I+=C>>>16,C&=65535,C+=i*g,I+=C>>>16,C&=65535,C+=s*c,I+=C>>>16,C&=65535,I+=r*d+o*g+i*c+s*a,I&=65535,S(b<<16|k,I<<16|C,this.unsigned)};l.mul=l.multiply;l.divide=function(e){if(W(e)||(e=D(e)),e.isZero())throw Error("division by zero");if(_){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?_.div_u:_.div_s)(this.low,this.high,e.low,e.high);return S(n,_.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?j:M;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(N)){if(e.eq(V)||e.eq(Oe))return N;if(e.eq(N))return V;var s=this.shr(1);return r=s.div(e).shl(1),r.eq(M)?e.isNegative()?V:Oe:(o=this.sub(e.mul(r)),i=r.add(o.div(e)),i)}else if(e.eq(N))return this.unsigned?j:M;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=M}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),g=F(r),d=g.mul(e);d.isNegative()||d.gt(o);)r-=c,g=F(r,this.unsigned),d=g.mul(e);g.isZero()&&(g=V),i=i.add(g),o=o.sub(d)}return i};l.div=l.divide;l.modulo=function(e){if(W(e)||(e=D(e)),_){var n=(this.unsigned?_.rem_u:_.rem_s)(this.low,this.high,e.low,e.high);return S(n,_.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 W(e)||(e=D(e)),S(this.low&e.low,this.high&e.high,this.unsigned)};l.or=function(e){return W(e)||(e=D(e)),S(this.low|e.low,this.high|e.high,this.unsigned)};l.xor=function(e){return W(e)||(e=D(e)),S(this.low^e.low,this.high^e.high,this.unsigned)};l.shiftLeft=function(e){return W(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 W(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(W(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={};pn(ho,{GrazEvents:()=>rt,GrazProvider:()=>fo,WALLET_TYPES:()=>xe,WalletType:()=>be,checkWallet:()=>v,clearRecentChain:()=>Me,configureGraz:()=>Ue,connect:()=>Z,defineChain:()=>Ln,defineChainInfo:()=>Pn,defineChains:()=>et,disconnect:()=>pe,executeContract:()=>Be,getActiveChainCurrency:()=>De,getAvailableWallets:()=>wn,getCosmostation:()=>me,getKeplr:()=>le,getLeap:()=>ue,getOfflineSigners:()=>Fe,getQueryRaw:()=>je,getQuerySmart:()=>Ge,getRecentChain:()=>Sn,getVectis:()=>ge,getWCCosmostation:()=>Wt,getWCKeplr:()=>Ot,getWCLeap:()=>Nt,getWallet:()=>A,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:()=>go,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"),gt=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,gt.createJSONStorage)(()=>sessionStorage)},yn={name:"graz-internal",partialize:t=>({recentChain:t.recentChain,_reconnect:t._reconnect,_reconnectConnector:t._reconnectConnector}),version:1},p=(0,ve.create)((0,H.subscribeWithSelector)((0,H.persist)(()=>ee,dn))),h=(0,ve.create)((0,H.subscribeWithSelector)((0,H.persist)(()=>hn,yn)));var ke=require("@cosmjs/encoding"),xt=require("@walletconnect/sign-client"),vt=require("@walletconnect/utils"),_e=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 We=(t,e,n=new Error("Promise timed out"))=>{let r=new Promise((o,i)=>{setTimeout(()=>{i(n)},e)});return Promise.race([t,r])};var v=(t=h.getState().walletType)=>{try{return A(t),!0}catch{return!1}},q=()=>{window.sessionStorage.removeItem(G),p.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")},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,ke.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,g={...c,rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr};return t.suggestChains([g])},signDirect:async(...a)=>{var d;let{1:c,2:g}=a;return t.signDirect(c,{bodyBytes:g.bodyBytes||Uint8Array.from([]),authInfoBytes:g.authInfoBytes||Uint8Array.from([]),accountNumber:_e.default.fromString(((d=g.accountNumber)==null?void 0:d.toString())||"",!1),chainId:g.chainId||""})},signAmino:async(...a)=>{let{1:c,2:g}=a;return t.signAmino(c,g)}}}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}=p.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}=p.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}=p.getState();if(!y)throw new Error("walletConnect.signClient is not defined");let E=y.session.getAll().at(-1);if(!E)return;let T=(f=(u=y.session.getAll().at(-1))==null?void 0:u.namespaces.cosmos)==null?void 0:f.accounts.find(x=>x.startsWith(`cosmos:${m}`));if(!(E.expiry*1e3>Date.now()+1e3))throw o(E.topic),new Error("invalid session");if(!T)try{let x=y.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${m}`],events:["chainChanged","accountsChanged"]}}});if(!x.length)throw new Error("no session");return x.at(-1)}catch(x){if(!x.message.toLowerCase().includes("no matching key"))throw x}return E}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}=p.getState();if(u)return p.setState({wcSignClient:u}),u;let f=await xt.SignClient.init(m.options);return p.setState({wcSignClient:f}),f},g=m=>{let{wcSignClient:u}=p.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,E;if(f.params.event.name==="accountsChanged"&&((y=f.params.event.data)==null?void 0:y[0])!==((E=p.getState().account)==null?void 0:E.bech32Address)){let T=f.params.chainId.split(":")[1];T&&d(T)}else m()}),()=>{u.events.off("session_delete",f=>{r()}),u.events.off("session_expire",f=>{r()}),u.events.off("session_event",f=>{var y,E;if(f.params.event.name==="accountsChanged"&&((y=f.params.event.data)==null?void 0:y[0])!==((E=p.getState().account)==null?void 0:E.bech32Address)){let T=f.params.chainId.split(":")[1];T&&d(T)}else m()})}},d=async m=>{var ie;let{wcSignClient:u}=p.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"),E=new y({projectId:f.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE",...f.web3Modal}),{account:T,activeChain:U}=p.getState(),x=s(m);if((U==null?void 0:U.chainId)!==m&&!x||!T){let{uri:O,approval:se}=await u.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${m}`],events:["chainChanged","accountsChanged"]}}});if(!O)throw new Error("No wallet connect uri");t?n(O):await E.openModal({uri:O});try{await We((async()=>{await se()})(),4e4,new Error("Modal approval timeout"))}catch(lt){if(E.closeModal(),!lt.message.toLowerCase().includes("no matching key"))return Promise.reject(lt)}return t||E.closeModal(),Promise.resolve()}try{await We((async()=>{let O=await C(m);p.setState({account:O})})(),1e4,new Error("Connection timeout"))}catch(O){if(o(x==null?void 0:x.topic),!O.message.toLowerCase().includes("no matching key"))throw O}},I=async m=>{var E;let{wcSignClient:u}=p.getState();if(!u)throw new Error("walletConnect.signClient is not defined");let f=(E=i(m))==null?void 0:E.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 I(m);return{address:(0,ke.fromBech32)(u).data,algo:f,bech32Address:u,name:"",pubKey:y,isKeystone:!1,isNanoLedger:!1}},b=async(...m)=>{var O,se;let[u,f,y]=m,{account:E,wcSignClient:T}=p.getState();if(!T)throw new Error("walletConnect.signClient is not defined");if(!E)throw new Error("account is not defined");let U=(O=i(u))==null?void 0:O.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 x={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 T.request(x)},k=async(...m)=>{let[u,f,y]=m,{signature:E,signed:T}=await b(u,f,y);return{signed:{chainId:T.chainId,accountNumber:_e.default.fromString(T.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(T.authInfoBytes,e)),bodyBytes:new Uint8Array(Buffer.from(T.bodyBytes,e))},signature:E}},re=async(...m)=>{var O;let[u,f,y,E]=m,{wcSignClient:T}=p.getState(),{account:U}=p.getState();if(!T)throw new Error("walletConnect.signClient is not defined");if(!U)throw new Error("account is not defined");let x=(O=i(u))==null?void 0:O.topic;if(!x)throw new Error("No wallet connect session");return n(),await T.request({topic:x,chainId:`cosmos:${u}`,request:{method:"cosmos_signDirect",params:{signerAddress:f,signDoc:y}}})},Te=async(...m)=>{let[u,f,y,E]=m;return await re(u,f,y)},sn=m=>({getAccounts:async()=>[await I(m)],signDirect:(u,f)=>k(m,u,f)}),it=m=>({getAccounts:async()=>[await I(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 I(m)],signDirect:(u,f)=>k(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:k,subscription:g,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)},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:"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)},Wt=()=>{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)},A=(t=h.getState().walletType)=>{switch(t){case"keplr":return le();case"leap":return ue();case"cosmostation":return me();case"vectis":return ge();case"walletconnect":return Q();case"wc_keplr_mobile":return Ot();case"wc_leap_mobile":return Nt();case"wc_cosmostation_mobile":return Wt();default:throw new Error("Unknown wallet type")}},wn=()=>Object.fromEntries(xe.map(t=>[t,v(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(!v(i))throw new Error(`${i} is not available`);let a=A(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");p.setState(C=>{let b=h.getState()._reconnect||!!h.getState()._reconnectConnector||!!c;return C.activeChain&&C.activeChain.chainId!==c.chainId?{status:"connecting"}:b?{status:"reconnecting"}:{status:"connecting"}});let{account:g,activeChain:d}=p.getState();if(await((e=a.init)==null?void 0:e.call(a)),!g||(d==null?void 0:d.chainId)!==c.chainId){await a.enable(c.chainId);let C=await a.getKey(c.chainId);p.setState({account:C})}h.setState({recentChain:c,walletType:i,_reconnect:!!(t!=null&&t.autoReconnect),_reconnectConnector:i}),p.setState({activeChain:c,status:"connected"}),typeof window<"u"&&window.sessionStorage.setItem(G,"Active");let{account:I}=p.getState();return{account:I,walletType:i,chain:c}}catch(n){throw console.error("connect ",n),p.getState().account===null&&p.setState({status:"disconnected"}),p.getState().account&&p.getState().activeChain&&p.setState({status:"connected"}),n}},pe=async(t=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(G),p.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=v(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),pe()}},Fe=async t=>{if(!(t!=null&&t.chainId))throw new Error("chainId is required");let{walletType:e}=h.getState(),n=t.walletType||e;if(!v(n))throw new Error(`${n} is not available`);let o=A(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}=p.getState();return e==null?void 0:e.currencies.find(n=>n.coinMinimalDenom===t)},Sn=()=>h.getState().recentChain,fe=async t=>(await A().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:g})=>{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,g)},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 _t=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"},kt=[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:_t.Bech32Address.defaultBech32Config("axelar"),currencies:kt,feeCurrencies:kt};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"},Nn={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Wn={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},kn={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},_n={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,Nn,Wn,kn,_n,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=p(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=p(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=p(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]})=>v(o))};var P=({onConnect:t,onDisconnect:e}={})=>{let n=p(o=>o.account),r=p(o=>o.status);return(0,Y.useEffect)(()=>p.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let{account:s,activeChain:a}=p.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}=p.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,g]})=>{if(!c||!a)throw new Error("No connected account detected");if(!g)throw new Error("address is not defined");return await a.getAllBalances(g)},{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],pe,{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=p(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(!v(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}=p.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,g]})=>{if(!c||!a)throw new Error("No connected account detected");if(!g)throw new Error("address is not defined");return await a.getBalanceStaked(g)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var X=require("@tanstack/react-query");var Yn=()=>p(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 g={...c,fee:c.fee??"auto",senderAddress:i,codeId:t};return Pe(g)},{onError:(c,g)=>Promise.resolve(e==null?void 0:e(c,g)),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 g={...c,fee:c.fee??"auto",senderAddress:i,contractAddress:t,memo:c.memo??"",funds:c.funds??[]};return Be(g)},{onError:(c,g)=>Promise.resolve(e==null?void 0:e(c,g)),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=p(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(!v(i))throw new Error(`${i} is not available`);let c=await(async()=>{switch(t==null?void 0:t.offlineSigner){case"offlineSigner":return A(i).getOfflineSigner(o.chainId);case"offlineSignerAuto":return A(i).getOfflineSignerAuto(o.chainId);case"offlineSignerOnlyAmino":return A(i).getOfflineSignerOnlyAmino(o.chainId);default:return A(i).getOfflineSignerAuto(o.chainId)}})(),g={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await nt.SigningStargateClient.connectWithSigner(g,c,s==null?void 0:s.opts)},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},uo=t=>{let e=p(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(!v(i))throw new Error(`${i} is not available`);let c=await(async()=>{switch(t==null?void 0:t.offlineSigner){case"offlineSigner":return A(i).getOfflineSigner(o.chainId);case"offlineSignerAuto":return A(i).getOfflineSignerAuto(o.chainId);case"offlineSignerOnlyAmino":return A(i).getOfflineSignerOnlyAmino(o.chainId);default:return A(i).getOfflineSignerAuto(o.chainId)}})(),g={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await tt.SigningCosmWasmClient.connectWithSigner(g,c,s==null?void 0:s.opts)},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},mo=t=>{let e=p(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:async({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!v(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let g=await(async()=>{switch(t.offlineSigner){case"offlineSigner":return A(s).getOfflineSigner(i.chainId);case"offlineSignerAuto":return A(s).getOfflineSignerAuto(i.chainId);case"offlineSignerOnlyAmino":return A(s).getOfflineSignerOnlyAmino(i.chainId);default:return A(s).getOfflineSignerAuto(i.chainId)}})();return nt.SigningStargateClient.createWithSigner(o,g,a.opts)},enabled:!!e&&!!n&&!!o,refetchOnWindowFocus:!1})},go=t=>{let e=p(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:async({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!v(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let g=await(async()=>{switch(t.offlineSigner){case"offlineSigner":return A(s).getOfflineSigner(i.chainId);case"offlineSignerAuto":return A(s).getOfflineSignerAuto(i.chainId);case"offlineSignerOnlyAmino":return A(s).getOfflineSignerOnlyAmino(i.chainId);default:return A(s).getOfflineSignerAuto(i.chainId)}})();return tt.SigningCosmWasmClient.createWithSigner(o,g,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}=p();return(0,ot.useEffect)(()=>{r&&(t&&o?R({onError:n}):!t&&e&&R({onError:n}))},[]),(0,ot.useEffect)(()=>{var s,a,c,g,d,I,C,b,k,re;r&&(r==="cosmostation"&&((a=(s=me()).subscription)==null||a.call(s,()=>{R({onError:n})})),r==="keplr"&&((g=(c=le()).subscription)==null||g.call(c,()=>{R({onError:n})})),r==="leap"&&((I=(d=ue()).subscription)==null||I.call(d,()=>{R({onError:n})})),r==="vectis"&&((b=(C=ge()).subscription)==null||b.call(C,()=>{R({onError:n})})),r==="walletconnect"&&i&&((re=(k=Q()).subscription)==null||re.call(k,()=>{R({onError:n})})))},[r,i]),null},rt=()=>(on(),null);var J=require("react/jsx-runtime"),po=new Ie.QueryClient({}),fo=({children:t,grazOptions:e,debug:n,...r})=>(e&&Ue(e),(0,J.jsxs)(Ie.QueryClientProvider,{client:po,...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 J(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=J;function R(t,e){if(isNaN(t))return e?X:q;if(e){if(t<0)return X;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%ne|0,t/ne|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,ne=It*It,xt=ne*ne,bt=xt/2,Tt=J(kn),q=J(0);E.ZERO=q;var X=J(0,!0);E.UZERO=X;var te=J(1);E.ONE=te;var vt=J(1,!0);E.UONE=vt;var Ue=J(-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)*ne+(this.low>>>0):this.high*ne+(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(te)};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,N=0;return N+=s*h,x+=N>>>16,N&=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|N,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?X:q;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return X;if(e.gt(this.shru(1)))return vt;i=X}else{if(this.eq(F)){if(e.eq(te)||e.eq(Ue))return F;if(e.eq(F))return te;var s=this.shr(1);return r=s.div(e).shl(1),r.eq(q)?e.isNegative()?te:Ue:(o=this.sub(e.mul(r)),i=r.add(o.div(e)),i)}else if(e.eq(F))return this.unsigned?X: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=te),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:()=>W,clearRecentChain:()=>He,clearSession:()=>M,configureGraz:()=>Ze,connect:()=>oe,defineChain:()=>Zn,defineChainInfo:()=>Yn,defineChains:()=>gt,disconnect:()=>Te,executeContract:()=>et,getActiveChainCurrency:()=>Ve,getAvailableWallets:()=>Wn,getCosmostation:()=>me,getKeplr:()=>pe,getLeap:()=>ge,getMetamaskSnapLeap:()=>Ge,getOfflineSigners:()=>Qe,getQueryRaw:()=>nt,getQuerySmart:()=>tt,getRecentChain:()=>Nn,getVectis:()=>fe,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:()=>de,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 Y="graz-reconnect-session";var Le=require("zustand"),St=require("zustand/middleware"),ee=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},ue={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,ee.subscribeWithSelector)((0,ee.persist)(()=>ue,vn))),f=(0,Le.create)((0,ee.subscribeWithSelector)((0,ee.persist)(()=>xn,On)));var 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",()=>{M(),r()}),()=>{window.cosmostation.cosmos.off("accountChanged",()=>{M(),r()})})})}throw f.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var pe=()=>{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 ge=()=>{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 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,le=new Nt.default(Q.low,Q.high,Q.unsigned);return{signature:G.signature,signed:{...G.signed,accountNumber:`${le.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)}),N=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?N(w):x(w),getOfflineSignerOnlyAmino:N,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 fe=()=>{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",()=>{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: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,le,wt;if(!((wt=(le=(Q=f.getState().walletConnect)==null?void 0:Q.options)==null?void 0:le.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");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:(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)},N=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}},ce=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}}})},Z=async(...p)=>{let[m,d,y,b]=p;return await ce(m,d,y)},yt=p=>({getAccounts:async()=>[await A(p)],signDirect:(m,d)=>N(p,m,d)}),w=p=>({getAccounts:async()=>[await A(p)],signAmino:(m,d)=>Z(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)=>N(p,m,d),signAmino:(m,d)=>Z(p,m,d)}),getOfflineSignerAuto:async p=>(await C(p)).isNanoLedger?w(p):yt(p),getOfflineSignerOnlyAmino:w,signAmino:Z,signDirect:N,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 W=(t=f.getState().walletType)=>{try{return T(t),!0}catch{return!1}},M=()=>{window.sessionStorage.removeItem(Y),g.setState(ue)},T=(t=f.getState().walletType)=>{switch(t){case"keplr":return pe();case"leap":return ge();case"cosmostation":return me();case"vectis":return fe();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,W(t)]));var oe=async t=>{var e;try{let{defaultChain:n,recentChain:r,walletType:o}=f.getState(),i=(t==null?void 0:t.walletType)||o;if(!W(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(Y,"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(Y),g.setState(ue),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=W(n||void 0);if(e&&i&&n)return await oe({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(!W(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 oe({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"),re=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),de=t=>{let n=["USE_CHECK_WALLET",f(o=>t||o.walletType)];return(0,mn.useQuery)(n,({queryKey:[,o]})=>W(o))};var z=({onConnect:t,onDisconnect:e}={})=>{let n=g(o=>o.account),r=g(o=>o.status);return(0,re.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,re.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],oe,{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}=de();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,re.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(!W(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,re.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 ie=require("@tanstack/react-query");var co=()=>g(t=>t.activeChain),lo=t=>(0,ie.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",t],({queryKey:[,r]})=>Ve(r)),uo=(t,e="BOND_STATUS_BONDED")=>(0,ie.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,ie.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,ie.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}=de();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"),se=require("@cosmjs/stargate"),he=require("@tanstack/react-query"),ye=require("react");var Ao=t=>{let e=g(o=>o.activeChain),n=f(o=>o.walletType),r=(0,ye.useMemo)(()=>["USE_STARGATE_SIGNING_CLIENT",e,n,t],[t,e,n]);return(0,he.useQuery)({queryKey:r,queryFn:async({queryKey:[,o,i,s]})=>{if(!o)throw new Error("No chain found");if(!W(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 se.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,ye.useMemo)(()=>["USE_COSMWASM_SIGNING_CLIENT",e,n,t],[t,e,n]);return(0,he.useQuery)({queryKey:r,queryFn:async({queryKey:[,o,i,s]})=>{if(!o)throw new Error("No chain found");if(!W(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?se.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,ye.useMemo)(()=>["USE_STARGATE_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=Me(t.type);return(0,he.useQuery)({queryKey:r,queryFn:async({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!W(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 se.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,ye.useMemo)(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=Me(t.type);return(0,he.useQuery)({queryKey:r,queryFn:async({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!W(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?se.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(Y)==="Active",{_reconnect:e,_onReconnectFailed:n,_reconnectConnector:r}=f(),{activeChain:o,wcSignClient:i}=g(),s=W(r||void 0);return(0,dt.useEffect)(()=>{if(r){if(!s)return;t&&o?B({onError:n}):!t&&e&&B({onError:n})}},[s]),(0,dt.useEffect)(()=>{var a,c,u,h,A,C,x,N,ce,Z;if(r){if(!s)return;r==="cosmostation"&&((c=(a=me()).subscription)==null||c.call(a,()=>{B({onError:n})})),r==="keplr"&&((h=(u=pe()).subscription)==null||h.call(u,()=>{B({onError:n})})),r==="leap"&&((C=(A=ge()).subscription)==null||C.call(A,()=>{B({onError:n})})),r==="vectis"&&((N=(x=fe()).subscription)==null||N.call(x,()=>{B({onError:n})})),r==="walletconnect"&&i&&((Z=(ce=U()).subscription)==null||Z.call(ce,()=>{B({onError:n})}))}},[r,i,s]),null},ht=()=>(dn(),null);var ae=require("react/jsx-runtime"),To=new _e.QueryClient({}),xo=({children:t,grazOptions:e,debug:n,...r})=>(e&&Ze(e),(0,ae.jsxs)(_e.QueryClientProvider,{client:To,...r,children:[(0,ae.jsxs)(fn,{children:[t,(0,ae.jsx)(ht,{})]}),n?(0,ae.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 F=null;try{F=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 N(t){return(t&&t.__isLong__)===!0}w.isLong=N;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 _(t,e){if(isNaN(t))return e?P:M;if(e){if(t<0)return P;if(t>=Qe)return $e}else{if(t<=-ze)return O;if(t+1>=ze)return Ve}return t<0?_(-t,e).neg():S(t%K|0,t/K|0,e)}w.fromNumber=_;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 M;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=_(X(n,8)),i=M,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 g=_(X(n,a));i=i.mul(g).add(_(c))}else i=i.mul(o),i=i.add(_(c))}return i.unsigned=e,i}w.fromString=se;function D(t,e){return typeof t=="number"?_(t,e):typeof t=="string"?se(t,e):S(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}w.fromValue=D;var je=65536,jt=1<<24,K=je*je,Qe=K*K,ze=Qe/2,Ke=B(jt),M=B(0);w.ZERO=M;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 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)*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(O)){var n=_(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=_(X(e,6),this.unsigned),s=this,a="";;){var c=s.div(i),g=s.sub(c.mul(i)).toInt()>>>0,d=g.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 N(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(N(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(z)};l.neg=l.negate;l.add=function(e){N(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,g=e.low&65535,d=0,I=0,C=0,b=0;return b+=i+g,C+=b>>>16,b&=65535,C+=o+c,I+=C>>>16,C&=65535,I+=r+a,d+=I>>>16,I&=65535,d+=n+s,d&=65535,S(C<<16|b,d<<16|I,this.unsigned)};l.subtract=function(e){return N(e)||(e=D(e)),this.add(e.neg())};l.sub=l.subtract;l.multiply=function(e){if(this.isZero())return M;if(N(e)||(e=D(e)),F){var n=F.mul(this.low,this.high,e.low,e.high);return S(n,F.get_high(),this.unsigned)}if(e.isZero())return M;if(this.eq(O))return e.isOdd()?O:M;if(e.eq(O))return this.isOdd()?O:M;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 _(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,g=e.low>>>16,d=e.low&65535,I=0,C=0,b=0,k=0;return k+=s*d,b+=k>>>16,k&=65535,b+=i*d,C+=b>>>16,b&=65535,b+=s*g,C+=b>>>16,b&=65535,C+=o*d,I+=C>>>16,C&=65535,C+=i*g,I+=C>>>16,C&=65535,C+=s*c,I+=C>>>16,C&=65535,I+=r*d+o*g+i*c+s*a,I&=65535,S(b<<16|k,I<<16|C,this.unsigned)};l.mul=l.multiply;l.divide=function(e){if(N(e)||(e=D(e)),e.isZero())throw Error("division by zero");if(F){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?F.div_u:F.div_s)(this.low,this.high,e.low,e.high);return S(n,F.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?P:M;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(O)){if(e.eq(z)||e.eq(ie))return O;if(e.eq(O))return z;var s=this.shr(1);return r=s.div(e).shl(1),r.eq(M)?e.isNegative()?z:ie:(o=this.sub(e.mul(r)),i=r.add(o.div(e)),i)}else if(e.eq(O))return this.unsigned?P:M;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=M}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),g=_(r),d=g.mul(e);d.isNegative()||d.gt(o);)r-=c,g=_(r,this.unsigned),d=g.mul(e);g.isZero()&&(g=z),i=i.add(g),o=o.sub(d)}return i};l.div=l.divide;l.modulo=function(e){if(N(e)||(e=D(e)),F){var n=(this.unsigned?F.rem_u:F.rem_s)(this.low,this.high,e.low,e.high);return S(n,F.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 N(e)||(e=D(e)),S(this.low&e.low,this.high&e.high,this.unsigned)};l.or=function(e){return N(e)||(e=D(e)),S(this.low|e.low,this.high|e.high,this.unsigned)};l.xor=function(e){return N(e)||(e=D(e)),S(this.low^e.low,this.high^e.high,this.unsigned)};l.shiftLeft=function(e){return N(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 N(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(N(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},p=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 W=(t=h.getState().walletType)=>{try{return E(t),!0}catch{return!1}},q=()=>{window.sessionStorage.removeItem(L),p.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")},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: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,g={...c,rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr};return t.suggestChains([g])},signDirect:async(...a)=>{var d;let{1:c,2:g}=a;return t.signDirect(c,{bodyBytes:g.bodyBytes||Uint8Array.from([]),authInfoBytes:g.authInfoBytes||Uint8Array.from([]),accountNumber:ce.default.fromString(((d=g.accountNumber)==null?void 0:d.toString())||"",!1),chainId:g.chainId||""})},signAmino:async(...a)=>{let{1:c,2:g}=a;return t.signAmino(c,g)}}}throw h.getState()._notFoundFn(),new Error("window.vectis is not defined")},Q=t=>{var Fe,_e,Me;if(!((Me=(_e=(Fe=h.getState().walletConnect)==null?void 0:Fe.options)==null?void 0:_e.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}=p.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}=p.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}=p.getState();if(!y)throw new Error("walletConnect.signClient is not defined");let A=y.session.getAll().at(-1);if(!A)return;let T=(f=(u=y.session.getAll().at(-1))==null?void 0:u.namespaces.cosmos)==null?void 0:f.accounts.find(x=>x.startsWith(`cosmos:${m}`));if(!(A.expiry*1e3>Date.now()+1e3))throw o(A.topic),new Error("invalid session");if(!T)try{let x=y.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${m}`],events:["chainChanged","accountsChanged"]}}});if(!x.length)throw new Error("no session");return x.at(-1)}catch(x){if(!x.message.toLowerCase().includes("no matching key"))throw x}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}=p.getState();if(u)return p.setState({wcSignClient:u}),u;let f=await zt.init(m.options);return p.setState({wcSignClient:f}),f},g=m=>{let{wcSignClient:u}=p.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=p.getState().account)==null?void 0:A.bech32Address)){let T=f.params.chainId.split(":")[1];T&&d(T)}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=p.getState().account)==null?void 0:A.bech32Address)){let T=f.params.chainId.split(":")[1];T&&d(T)}else m()})}},d=async m=>{var Z;let{wcSignClient:u}=p.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:T,activeChain:U}=p.getState(),x=s(m);if((U==null?void 0:U.chainId)!==m&&!x||!T){let{uri:v,approval:Y}=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 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 v=await C(m);p.setState({account:v})})(),1e4,new Error("Connection timeout"))}catch(v){if(o(x==null?void 0:x.topic),!v.message.toLowerCase().includes("no matching key"))throw v}},I=async m=>{var A;let{wcSignClient:u}=p.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 I(m);return{address:et(u).data,algo:f,bech32Address:u,name:"",pubKey:y,isKeystone:!1,isNanoLedger:!1}},b=async(...m)=>{var v,Y;let[u,f,y]=m,{account:A,wcSignClient:T}=p.getState();if(!T)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 x={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 T.request(x)},k=async(...m)=>{let[u,f,y]=m,{signature:A,signed:T}=await b(u,f,y);return{signed:{chainId:T.chainId,accountNumber:ce.default.fromString(T.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(T.authInfoBytes,e)),bodyBytes:new Uint8Array(Buffer.from(T.bodyBytes,e))},signature:A}},$=async(...m)=>{var v;let[u,f,y,A]=m,{wcSignClient:T}=p.getState(),{account:U}=p.getState();if(!T)throw new Error("walletConnect.signClient is not defined");if(!U)throw new Error("account is not defined");let x=(v=i(u))==null?void 0:v.topic;if(!x)throw new Error("No wallet connect session");return n(),await T.request({topic:x,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 I(m)],signDirect:(u,f)=>k(m,u,f)}),ke=m=>({getAccounts:async()=>[await I(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 I(m)],signDirect:(u,f)=>k(m,u,f),signAmino:(u,f)=>re(m,u,f)}),getOfflineSignerAuto:async m=>(await C(m)).isNanoLedger?ke(m):Rt(m),getOfflineSignerOnlyAmino:ke,signAmino:re,signDirect:k,subscription:g,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)},E=(t=h.getState().walletType)=>{switch(t){case"keplr":return le();case"leap":return ue();case"cosmostation":return me();case"vectis":return ge();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,W(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(!W(i))throw new Error(`${i} is not available`);let a=E(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");p.setState(C=>{let b=h.getState()._reconnect||!!h.getState()._reconnectConnector||!!c;return C.activeChain&&C.activeChain.chainId!==c.chainId?{status:"connecting"}:b?{status:"reconnecting"}:{status:"connecting"}});let{account:g,activeChain:d}=p.getState();if(await((e=a.init)==null?void 0:e.call(a)),!g||(d==null?void 0:d.chainId)!==c.chainId){await a.enable(c.chainId);let C=await a.getKey(c.chainId);p.setState({account:C})}h.setState({recentChain:c,walletType:i,_reconnect:!!(t!=null&&t.autoReconnect),_reconnectConnector:i}),p.setState({activeChain:c,status:"connected"}),typeof window<"u"&&window.sessionStorage.setItem(L,"Active");let{account:I}=p.getState();return{account:I,walletType:i,chain:c}}catch(n){throw console.error("connect ",n),p.getState().account===null&&p.setState({status:"disconnected"}),p.getState().account&&p.getState().activeChain&&p.setState({status:"connected"}),n}},pe=async(t=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(L),p.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=W(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),pe()}},tt=async t=>{if(!(t!=null&&t.chainId))throw new Error("chainId is required");let{walletType:e}=h.getState(),n=t.walletType||e;if(!W(n))throw new Error(`${n} is not available`);let o=E(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}=p.getState();return e==null?void 0:e.currencies.find(n=>n.coinMinimalDenom===t)},po=()=>h.getState().recentChain,fe=async t=>(await E().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:g})=>{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,g)},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 pt={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"},gt=[pt,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:pt,bip44:{coinType:118},bech32Config:$t.defaultBech32Config("axelar"),currencies:gt,feeCurrencies:gt};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"},gn={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},pn={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,gn,pn],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 We}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=p(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=p(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})},Ne=t=>{let e=p(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]})=>W(o))};var j=({onConnect:t,onDisconnect:e}={})=>{let n=p(o=>o.account),r=p(o=>o.status);return On(()=>p.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let{account:s,activeChain:a}=p.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}},Nn=t=>{let{data:e}=j(),{data:n}=ve(),{activeChain:r}=p.getState(),o=t||(e==null?void 0:e.bech32Address),i=We(()=>["USE_ALL_BALANCES",n,r,o],[r,o,n]);return ee(i,async({queryKey:[,a,c,g]})=>{if(!c||!a)throw new Error("No connected account detected");if(!g)throw new Error("address is not defined");return await a.getAllBalances(g)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},dr=(t,e)=>{let{data:n}=Nn(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],pe,{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=p(r=>r.activeChain),e=h(r=>r.walletType),n=We(()=>["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(!W(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}=p.getState(),o=t||(e==null?void 0:e.bech32Address),i=We(()=>["USE_BALANCE_STAKED",n,r,o],[r,o,n]);return ee(i,async({queryKey:[,a,c,g]})=>{if(!c||!a)throw new Error("No connected account detected");if(!g)throw new Error("address is not defined");return await a.getBalanceStaked(g)},{enabled:!!o&&!!r&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};import{useMutation as xt,useQuery as vt}from"@tanstack/react-query";var xr=()=>p(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"}),Nr=()=>({data:h(e=>e.recentChain),clear:nt}),Wr=({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}},kr=({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 g={...c,fee:c.fee??"auto",senderAddress:i,codeId:t};return ct(g)},{onError:(c,g)=>Promise.resolve(e==null?void 0:e(c,g)),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 g={...c,fee:c.fee??"auto",senderAddress:i,contractAddress:t,memo:c.memo??"",funds:c.funds??[]};return lt(g)},{onError:(c,g)=>Promise.resolve(e==null?void 0:e(c,g)),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 Nt}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as Wt}from"@cosmjs/stargate";import{useQuery as ne}from"@tanstack/react-query";import{useMemo as oe}from"react";var Yr=t=>{let e=p(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(!W(i))throw new Error(`${i} is not available`);let c=await(async()=>{switch(t==null?void 0:t.offlineSigner){case"offlineSigner":return E(i).getOfflineSigner(o.chainId);case"offlineSignerAuto":return E(i).getOfflineSignerAuto(o.chainId);case"offlineSignerOnlyAmino":return E(i).getOfflineSignerOnlyAmino(o.chainId);default:return E(i).getOfflineSignerAuto(o.chainId)}})(),g={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await Wt.connectWithSigner(g,c,s==null?void 0:s.opts)},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},Xr=t=>{let e=p(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(!W(i))throw new Error(`${i} is not available`);let c=await(async()=>{switch(t==null?void 0:t.offlineSigner){case"offlineSigner":return E(i).getOfflineSigner(o.chainId);case"offlineSignerAuto":return E(i).getOfflineSignerAuto(o.chainId);case"offlineSignerOnlyAmino":return E(i).getOfflineSignerOnlyAmino(o.chainId);default:return E(i).getOfflineSignerAuto(o.chainId)}})(),g={url:o.rpc,headers:{...o.rpcHeaders||{}}};return await Nt.connectWithSigner(g,c,s==null?void 0:s.opts)},enabled:!!e&&!!n,refetchOnWindowFocus:!1})},Jr=t=>{let e=p(i=>i.activeChain),n=h(i=>i.walletType),r=oe(()=>["USE_STARGATE_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=Ne(t.type);return ne({queryKey:r,queryFn:async({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!W(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let g=await(async()=>{switch(t.offlineSigner){case"offlineSigner":return E(s).getOfflineSigner(i.chainId);case"offlineSignerAuto":return E(s).getOfflineSignerAuto(i.chainId);case"offlineSignerOnlyAmino":return E(s).getOfflineSignerOnlyAmino(i.chainId);default:return E(s).getOfflineSignerAuto(i.chainId)}})();return Wt.createWithSigner(o,g,a.opts)},enabled:!!e&&!!n&&!!o,refetchOnWindowFocus:!1})},ei=t=>{let e=p(i=>i.activeChain),n=h(i=>i.walletType),r=oe(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",e,n,t],[t,e,n]),{data:o}=Ne(t.type);return ne({queryKey:r,queryFn:async({queryKey:[,i,s,a]})=>{if(!i)throw new Error("No chain found");if(!W(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let g=await(async()=>{switch(t.offlineSigner){case"offlineSigner":return E(s).getOfflineSigner(i.chainId);case"offlineSignerAuto":return E(s).getOfflineSignerAuto(i.chainId);case"offlineSignerOnlyAmino":return E(s).getOfflineSignerOnlyAmino(i.chainId);default:return E(s).getOfflineSignerAuto(i.chainId)}})();return Nt.createWithSigner(o,g,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 Wn,useState as kn}from"react";import{Fragment as Fn,jsx as _n}from"react/jsx-runtime";var kt=({children:t})=>{let[e,n]=kn(!1);return Wn(()=>{n(!0)},[]),_n(Fn,{children:e?t:null})};import{useEffect as Ft}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}=p();return Ft(()=>{r&&(t&&o?R({onError:n}):!t&&e&&R({onError:n}))},[]),Ft(()=>{var s,a,c,g,d,I,C,b,k,$;r&&(r==="cosmostation"&&((a=(s=me()).subscription)==null||a.call(s,()=>{R({onError:n})})),r==="keplr"&&((g=(c=le()).subscription)==null||g.call(c,()=>{R({onError:n})})),r==="leap"&&((I=(d=ue()).subscription)==null||I.call(d,()=>{R({onError:n})})),r==="vectis"&&((b=(C=ge()).subscription)==null||b.call(C,()=>{R({onError:n})})),r==="walletconnect"&&i&&(($=(k=Q()).subscription)==null||$.call(k,()=>{R({onError:n})})))},[r,i]),null},_t=()=>(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(kt,{children:[Mt(_t,{}),t]}),n?Mt(Un,{initialIsOpen:!1,position:"bottom-right"}):null]},"graz-provider"));export{_t as GrazEvents,di as GrazProvider,Ue as WALLET_TYPES,Re as WalletType,W as checkWallet,nt as clearRecentChain,it as configureGraz,V as connect,jo as defineChain,zo as defineChainInfo,Tt as defineChains,pe 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,po as getRecentChain,ge as getVectis,Vt as getWCCosmostation,Qt as getWCKeplr,Ht as getWCLeap,E 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,Nn 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,Nr as useRecentChain,qr as useSendIbcTokens,Ur as useSendTokens,ve as useStargateClient,Yr as useStargateSigningClient,Jr as useStargateTmSigningClient,Wr as useSuggestChain,kr as useSuggestChainAndConnect,Ne as useTendermintClient};
|
|
1
|
+
import{a as Yt,b as Ce,c as $}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 _(t){return(t&&t.__isLong__)===!0}E.isLong=_;var He={},Ve={};function Y(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=Y;function R(t,e){if(isNaN(t))return e?Z:q;if(e){if(t<0)return Z;if(t>=Xe)return tt}else{if(t<=-Ze)return F;if(t+1>=Ze)return et}return t<0?R(-t,e).neg():I(t%J|0,t/J|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,J=$e*$e,Xe=J*J,Ze=Xe/2,Ye=Y(nn),q=Y(0);E.ZERO=q;var Z=Y(0,!0);E.UZERO=Z;var X=Y(1);E.ONE=X;var Je=Y(1,!0);E.UONE=Je;var Se=Y(-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 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)*J+(this.low>>>0):this.high*J+(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(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(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(X)};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(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,N=0;return N+=s*h,x+=N>>>16,N&=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|N,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?Z:q;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Z;if(e.gt(this.shru(1)))return Je;i=Z}else{if(this.eq(F)){if(e.eq(X)||e.eq(Se))return F;if(e.eq(F))return X;var s=this.shr(1);return r=s.div(e).shl(1),r.eq(q)?e.isNegative()?X:Se:(o=this.sub(e.mul(r)),i=r.add(o.div(e)),i)}else if(e.eq(F))return this.unsigned?Z: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=X),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)}});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},ne={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(()=>ne,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",()=>{D(),r()}),()=>{window.cosmostation.cosmos.off("accountChanged",()=>{D(),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",()=>{D(),r()}),()=>{window.removeEventListener("keplr_keystorechange",()=>{D(),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",()=>{D(),r()}),()=>{window.removeEventListener("leap_keystorechange",()=>{D(),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,te=new ot.default(z.low,z.high,z.unsigned);return{signature:U.signature,signed:{...U.signed,accountNumber:`${te.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)}),N=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?N(w):x(w),getOfflineSignerOnlyAmino:N,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",()=>{D(),a()}),()=>{window.removeEventListener("vectis_accountChanged",()=>{D(),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,te,Be;if(!((Be=(te=(z=f.getState().walletConnect)==null?void 0:z.options)==null?void 0:te.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");D(),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:M,approval:ie}=await m.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:[`cosmos:${p}`],events:["chainChanged","accountsChanged"]}}});if(!M)throw new Error("No wallet connect uri");t?n(M):await b.openModal({uri:M});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 M=await C(p);g.setState({account:M})})(),15e3,new Error("Connection timeout"))}catch(M){if(o(k==null?void 0:k.topic),!M.message.toLowerCase().includes("no matching key"))throw M}},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 M,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=(M=i(m))==null?void 0:M.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)},N=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}},ee=async(...p)=>{var M;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=(M=i(m))==null?void 0:M.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}}})},V=async(...p)=>{let[m,d,y,b]=p;return await ee(m,d,y)},Ue=p=>({getAccounts:async()=>[await A(p)],signDirect:(m,d)=>N(p,m,d)}),w=p=>({getAccounts:async()=>[await A(p)],signAmino:(m,d)=>V(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)=>N(p,m,d),signAmino:(m,d)=>V(p,m,d)}),getOfflineSignerAuto:async p=>(await C(p)).isNanoLedger?w(p):Ue(p),getOfflineSignerOnlyAmino:w,signAmino:V,signDirect:N,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 W=(t=f.getState().walletType)=>{try{return T(t),!0}catch{return!1}},D=()=>{window.sessionStorage.removeItem($),g.setState(ne)},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,W(t)]));var oe=async t=>{var e;try{let{defaultChain:n,recentChain:r,walletType:o}=f.getState(),i=(t==null?void 0:t.walletType)||o;if(!W(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($,"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($),g.setState(ne),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=W(n||void 0);if(e&&i&&n)return await oe({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(!W(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 oe({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]})=>W(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],oe,{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(!W(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(!W(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(!W(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(!W(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(!W(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($)==="Active",{_reconnect:e,_onReconnectFailed:n,_reconnectConnector:r}=f(),{activeChain:o,wcSignClient:i}=g(),s=W(r||void 0);return Qt(()=>{if(r){if(!s)return;t&&o?j({onError:n}):!t&&e&&j({onError:n})}},[s]),Qt(()=>{var a,c,u,h,A,C,x,N,ee,V;if(r){if(!s)return;r==="cosmostation"&&((c=(a=ae()).subscription)==null||c.call(a,()=>{j({onError:n})})),r==="keplr"&&((h=(u=ce()).subscription)==null||h.call(u,()=>{j({onError:n})})),r==="leap"&&((C=(A=le()).subscription)==null||C.call(A,()=>{j({onError:n})})),r==="vectis"&&((N=(x=pe()).subscription)==null||N.call(x,()=>{j({onError:n})})),r==="walletconnect"&&i&&((V=(ee=G()).subscription)==null||V.call(ee,()=>{j({onError:n})}))}},[r,i,s]),null},Ht=()=>(Qn(),null);import{jsx as Vt,jsxs as $t}from"react/jsx-runtime";var Zn=new Hn({}),ys=({children:t,grazOptions:e,debug:n,...r})=>(e&&wt(e),$t(Vn,{client:Zn,...r,children:[$t(zt,{children:[t,Vt(Ht,{})]}),n?Vt($n,{initialIsOpen:!1,position:"bottom-right"}):null]},"graz-provider"));export{Ht as GrazEvents,ys as GrazProvider,je as WALLET_TYPES,Ge as WalletType,W as checkWallet,dt as clearRecentChain,D as clearSession,wt as configureGraz,oe 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.
|
|
4
|
+
"version": "0.0.49-alpha.0",
|
|
5
5
|
"author": "Griko Nibras <griko@strange.love>",
|
|
6
6
|
"repository": "https://github.com/graz-sh/graz.git",
|
|
7
7
|
"homepage": "https://github.com/graz-sh/graz",
|
|
@@ -21,6 +21,14 @@
|
|
|
21
21
|
"dist/*.mjs"
|
|
22
22
|
],
|
|
23
23
|
"sideEffects": false,
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"clean": "rm -rf dist/*",
|
|
27
|
+
"cli": "node cli.mjs",
|
|
28
|
+
"dev": "tsup --watch",
|
|
29
|
+
"lint": "eslint --fix \"src/**/*.{ts,tsx}\"",
|
|
30
|
+
"prepublishOnly": "pnpm build"
|
|
31
|
+
},
|
|
24
32
|
"dependencies": {
|
|
25
33
|
"@cosmjs/cosmwasm-stargate": "^0.31.0",
|
|
26
34
|
"@cosmjs/launchpad": "^0.27.1",
|
|
@@ -28,12 +36,11 @@
|
|
|
28
36
|
"@cosmjs/stargate": "^0.31.0",
|
|
29
37
|
"@cosmjs/tendermint-rpc": "^0.31.0",
|
|
30
38
|
"@keplr-wallet/cosmos": "^0.12.20",
|
|
31
|
-
"@
|
|
39
|
+
"@metamask/providers": "^11.1.1",
|
|
32
40
|
"@tanstack/react-query": "^4.29.14",
|
|
33
41
|
"@tanstack/react-query-devtools": "^4.29.14",
|
|
34
42
|
"@vectis/extension-client": "^0.7.1",
|
|
35
43
|
"@walletconnect/sign-client": "^2.8.1",
|
|
36
|
-
"@walletconnect/types": "^2.8.1",
|
|
37
44
|
"@walletconnect/utils": "^2.8.1",
|
|
38
45
|
"@web3modal/standalone": "^2.4.3",
|
|
39
46
|
"arg": "^5.0.2",
|
|
@@ -41,8 +48,10 @@
|
|
|
41
48
|
"zustand": "^4.3.8"
|
|
42
49
|
},
|
|
43
50
|
"devDependencies": {
|
|
51
|
+
"@keplr-wallet/types": "^0.12.20",
|
|
44
52
|
"@types/node": "^20.3.1",
|
|
45
53
|
"@types/react": "^18.2.12",
|
|
54
|
+
"@walletconnect/types": "^2.8.1",
|
|
46
55
|
"react": "^18.2.0",
|
|
47
56
|
"typescript": "^5.1.3"
|
|
48
57
|
},
|
|
@@ -57,12 +66,5 @@
|
|
|
57
66
|
"graz-sh",
|
|
58
67
|
"use-keplr"
|
|
59
68
|
],
|
|
60
|
-
"license": "MIT"
|
|
61
|
-
|
|
62
|
-
"build": "tsup",
|
|
63
|
-
"clean": "rm -rf dist/*",
|
|
64
|
-
"cli": "node cli.mjs",
|
|
65
|
-
"dev": "tsup --watch",
|
|
66
|
-
"lint": "eslint --fix \"src/**/*.{ts,tsx}\""
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
+
"license": "MIT"
|
|
70
|
+
}
|