graz 0.0.35 → 0.0.37

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.
@@ -0,0 +1 @@
1
+ var n="graz-reconnect-session";export{n as a};
@@ -0,0 +1,3 @@
1
+ declare const RECONNECT_SESSION_KEY = "graz-reconnect-session";
2
+
3
+ export { RECONNECT_SESSION_KEY };
@@ -0,0 +1 @@
1
+ "use strict";var E=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var S=(n,e)=>{for(var s in e)E(n,s,{get:e[s],enumerable:!0})},C=(n,e,s,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of t(e))!N.call(n,o)&&o!==s&&E(n,o,{get:()=>e[o],enumerable:!(c=r(e,o))||c.enumerable});return n};var O=n=>C(E({},"__esModule",{value:!0}),n);var a={};S(a,{RECONNECT_SESSION_KEY:()=>_});module.exports=O(a);var _="graz-reconnect-session";0&&(module.exports={RECONNECT_SESSION_KEY});
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-ETISV7IF.mjs";export{a as RECONNECT_SESSION_KEY};
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { Coin, OfflineSigner, OfflineDirectSigner } from '@cosmjs/proto-signing'
6
6
  import { QueryClient, StargateClient, SigningStargateClient, SigningStargateClientOptions, StdFee, DeliverTxResponse, StakingExtension } from '@cosmjs/stargate';
7
7
  import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
8
8
  import { Height } from 'cosmjs-types/ibc/core/client/v1/client';
9
+ import { OfflineSigner as OfflineSigner$1 } from '@cosmjs/launchpad';
9
10
  import * as _tanstack_react_query from '@tanstack/react-query';
10
11
  import { UseQueryResult, QueryClientProviderProps } from '@tanstack/react-query';
11
12
  import { BondStatusString } from '@cosmjs/stargate/build/modules/staking/queries';
@@ -105,12 +106,13 @@ declare const defineChainInfo: <T extends ChainInfoWithPath | ChainInfo>(chain:
105
106
  * connect(mainnetChains.cosmos);
106
107
  * ```
107
108
  *
109
+ * Try graz cli to generate ChainInfo from https://cosmos.directory/
110
+ * @see https://graz.strange.love/docs/generate-chain-info
111
+ *
108
112
  * @see {@link testnetChains}
109
113
  */
110
114
  declare const mainnetChains: {
111
115
  axelar: ChainInfo;
112
- /** @deprecated kept for compatibilty purposes; change to `mainnetChains.cosmoshub` */
113
- cosmos: ChainInfo;
114
116
  cosmoshub: ChainInfo;
115
117
  juno: ChainInfo;
116
118
  osmosis: ChainInfo;
@@ -119,6 +121,9 @@ declare const mainnetChains: {
119
121
  /**
120
122
  * Arary version on {@link mainnetChains}
121
123
  *
124
+ * Try graz cli to generate ChainInfo from https://cosmos.directory/
125
+ * @see https://graz.strange.love/docs/generate-chain-info
126
+ *
122
127
  * @see {@link mainnetChains}
123
128
  */
124
129
  declare const mainnetChainsArray: ChainInfo[];
@@ -131,6 +136,9 @@ declare const mainnetChainsArray: ChainInfo[];
131
136
  * connect(testnetChains.osmosis);
132
137
  * ```
133
138
  *
139
+ * Try graz cli to generate ChainInfo from https://cosmos.directory/
140
+ * @see https://graz.strange.love/docs/generate-chain-info
141
+ *
134
142
  * @see {@link mainnetChains}
135
143
  */
136
144
  declare const testnetChains: {
@@ -141,6 +149,9 @@ declare const testnetChains: {
141
149
  /**
142
150
  * Arary version on {@link testnetChains}
143
151
  *
152
+ * Try graz cli to generate ChainInfo from https://cosmos.directory/
153
+ * @see https://graz.strange.love/docs/generate-chain-info
154
+ *
144
155
  * @see {@link testnetChains}
145
156
  */
146
157
  declare const testnetChainsArray: ChainInfo[];
@@ -151,13 +162,18 @@ declare enum WalletType {
151
162
  }
152
163
  declare const WALLET_TYPES: WalletType[];
153
164
 
154
- declare type ConnectArgs = Maybe<GrazChain & {
165
+ declare type ConnectArgs = Maybe<{
166
+ chain?: GrazChain;
155
167
  signerOpts?: SigningCosmWasmClientOptions;
156
168
  walletType?: WalletType;
169
+ autoReconnect?: boolean;
157
170
  }>;
158
171
  declare const connect: (args?: ConnectArgs) => Promise<Key>;
159
172
  declare const disconnect: (clearRecentChain?: boolean) => Promise<void>;
160
- declare const reconnect: () => void;
173
+ declare type ReconnectArgs = Maybe<{
174
+ onError?: (error: unknown) => void;
175
+ }>;
176
+ declare const reconnect: (args?: ReconnectArgs) => Promise<Key | undefined>;
161
177
 
162
178
  declare type ExtensionSetup<P extends object = object> = (queryClient: QueryClient) => P;
163
179
 
@@ -193,8 +209,9 @@ interface SuggestChainAndConnectArgs {
193
209
  };
194
210
  rpcHeaders?: Dictionary;
195
211
  path?: string;
212
+ autoReconnect?: boolean;
196
213
  }
197
- declare const suggestChainAndConnect: ({ chainInfo, ...rest }: SuggestChainAndConnectArgs) => Promise<{
214
+ declare const suggestChainAndConnect: ({ chainInfo, rpcHeaders, gas, path, ...rest }: SuggestChainAndConnectArgs) => Promise<{
198
215
  account: Key;
199
216
  chain: ChainInfo;
200
217
  }>;
@@ -222,6 +239,8 @@ interface GrazStore {
222
239
  walletType: WalletType;
223
240
  _notFoundFn: () => void;
224
241
  _reconnect: boolean;
242
+ _reconnectConnector: WalletType | null;
243
+ _onReconnectFailed: () => void;
225
244
  }
226
245
 
227
246
  declare type CreateClientArgs = Pick<GrazChain, "rpc" | "rpcHeaders">;
@@ -238,6 +257,11 @@ interface ConfigureGrazArgs {
238
257
  defaultSigningClient?: GrazStore["defaultSigningClient"];
239
258
  defaultWallet?: WalletType;
240
259
  onNotFound?: () => void;
260
+ onReconnectFailed?: () => void;
261
+ /**
262
+ * default to true
263
+ */
264
+ autoReconnect?: boolean;
241
265
  }
242
266
  declare const configureGraz: (args?: ConfigureGrazArgs) => ConfigureGrazArgs;
243
267
 
@@ -347,9 +371,23 @@ declare const getLeap: () => Keplr;
347
371
  declare const getWallet: (type?: WalletType) => Keplr;
348
372
  declare const getAvailableWallets: () => Record<WalletType, boolean>;
349
373
 
350
- interface GrazAdapter {
374
+ interface AccountData {
375
+ address: Uint8Array;
376
+ bech32Address: string;
377
+ pubKey: Uint8Array;
378
+ algo: string;
379
+ }
380
+ interface Connector {
381
+ checkConnector: () => boolean;
382
+ getAccount: (chainId: string, prefix?: string) => Promise<AccountData>;
383
+ getOfflineSigner: (chainId: string) => OfflineSigner$1 & OfflineDirectSigner;
384
+ getOfflineSignerOnlyAmino: (chainId: string) => OfflineSigner$1;
385
+ getOfflineSignerAuto: (chainId: string) => Promise<OfflineSigner$1 | OfflineDirectSigner>;
386
+ }
387
+ interface GrazAdapter extends Connector {
351
388
  name: string;
352
389
  id: string;
390
+ keystoreEvent: string;
353
391
  }
354
392
 
355
393
  interface MutationEventArgs<TInitial = unknown, TSuccess = TInitial> {
@@ -389,7 +427,8 @@ declare const useAccount: ({ onConnect, onDisconnect }?: UseAccountArgs) => {
389
427
  isConnecting: boolean;
390
428
  isDisconnected: boolean;
391
429
  isReconnecting: boolean;
392
- reconnect: () => void;
430
+ isLoading: boolean;
431
+ reconnect: (args?: ReconnectArgs) => Promise<Key | undefined>;
393
432
  status: "connected" | "connecting" | "reconnecting" | "disconnected";
394
433
  };
395
434
  /**
@@ -451,10 +490,12 @@ declare type UseConnectChainArgs = MutationEventArgs<ConnectArgs, Key>;
451
490
  *
452
491
  * // use custom chain information
453
492
  * connect({
454
- * rpc: "https://rpc.juno.strange.love",
455
- * rest: "https://api.juno.strange.love",
456
- * chainId: "juno-1",
457
- * ...
493
+ * chain:{
494
+ * rpc: "https://rpc.juno.strange.love",
495
+ * rest: "https://api.juno.strange.love",
496
+ * chainId: "juno-1",
497
+ * ...
498
+ * }
458
499
  * });
459
500
  * ```
460
501
  *
@@ -949,4 +990,4 @@ declare const useGrazEvents: () => null;
949
990
  */
950
991
  declare const GrazEvents: FC;
951
992
 
952
- export { ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateQueryClient, CreateSigningClientArgs, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, SendIbcTokensArgs, SendTokensArgs, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseQueryClient, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createQueryClient, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAvailableWallets, getBalanceStaked, getBalances, getKeplr, getLeap, getQueryRaw, getQuerySmart, getRecentChain, getWallet, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useBalance, useBalanceStaked, useBalances, useCheckKeplr, useCheckWallet, useClients, useConnect, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClient, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
993
+ export { AccountData, ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, Connector, CreateClientArgs, CreateQueryClient, CreateSigningClientArgs, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseQueryClient, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createQueryClient, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAvailableWallets, getBalanceStaked, getBalances, getKeplr, getLeap, getQueryRaw, getQuerySmart, getRecentChain, getWallet, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useBalance, useBalanceStaked, useBalances, useCheckKeplr, useCheckWallet, useClients, useConnect, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClient, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Ye=Object.create;var b=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var et=(e,t)=>{for(var n in t)b(e,n,{get:t[n],enumerable:!0})},pe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of $e(t))!Ze.call(e,s)&&s!==n&&b(e,s,{get:()=>t[s],enumerable:!(r=Je(t,s))||r.enumerable});return e};var me=(e,t,n)=>(n=e!=null?Ye(Xe(e)):{},pe(t||!e||!e.__esModule?b(n,"default",{value:e,enumerable:!0}):n,e)),tt=e=>pe(b({},"__esModule",{value:!0}),e);var Xt={};et(Xt,{GrazEvents:()=>ce,GrazProvider:()=>$t,WALLET_TYPES:()=>U,WalletType:()=>G,checkWallet:()=>D,clearRecentChain:()=>z,configureGraz:()=>O,connect:()=>h,createClients:()=>E,createQueryClient:()=>v,createSigningClients:()=>w,defineChain:()=>wt,defineChainInfo:()=>bt,defineChains:()=>re,disconnect:()=>Q,executeContract:()=>L,getActiveChainCurrency:()=>K,getAvailableWallets:()=>st,getBalanceStaked:()=>P,getBalances:()=>F,getKeplr:()=>ye,getLeap:()=>Ce,getQueryRaw:()=>Y,getQuerySmart:()=>V,getRecentChain:()=>ot,getWallet:()=>x,instantiateContract:()=>H,mainnetChains:()=>jt,mainnetChainsArray:()=>Dt,reconnect:()=>y,sendIbcTokens:()=>_,sendTokens:()=>N,suggestChain:()=>k,suggestChainAndConnect:()=>W,testnetChains:()=>kt,testnetChainsArray:()=>It,useAccount:()=>g,useActiveChain:()=>Mt,useActiveChainCurrency:()=>Rt,useActiveChainValidators:()=>Qt,useBalance:()=>Bt,useBalanceStaked:()=>vt,useBalances:()=>Oe,useCheckKeplr:()=>Tt,useCheckWallet:()=>A,useClients:()=>Ft,useConnect:()=>Gt,useDisconnect:()=>Ut,useExecuteContract:()=>Lt,useGrazEvents:()=>_e,useInstantiateContract:()=>Ht,useOfflineSigners:()=>Fe,useQueryClient:()=>Ot,useQueryRaw:()=>Yt,useQuerySmart:()=>Vt,useRecentChain:()=>zt,useSendIbcTokens:()=>_t,useSendTokens:()=>Nt,useSigners:()=>qt,useSigningClients:()=>Pt,useSuggestChain:()=>Kt,useSuggestChainAndConnect:()=>Wt});module.exports=tt(Xt);var fe=require("@cosmjs/stargate");var le=me(require("zustand")),j=require("zustand/middleware");var G=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(G||{}),U=["keplr","leap"];var q={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_reconnect:!1},nt={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},c=(0,le.default)((0,j.subscribeWithSelector)((0,j.persist)(()=>q,nt)));var M=require("@cosmjs/cosmwasm-stargate"),R=require("@cosmjs/stargate"),de=require("@cosmjs/tendermint-rpc");var ge=require("@cosmjs/stargate"),f=require("@cosmjs/utils");var v=(...e)=>{let{tendermint:t}=c.getState().clients,n=new ge.QueryClient(t),r=e.map(s=>s(n));for(let s of r){(0,f.assert)((0,f.isNonNullObject)(s),"Extension must be a non-null object");for(let[i,o]of Object.entries(s)){(0,f.assert)((0,f.isNonNullObject)(o),`Module must be a non-null object. Found type ${typeof o} for module "${i}".`);let u=n[i]||{};n[i]={...u,...o}}}return n};var E=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[r,s,i]=await Promise.all([M.SigningCosmWasmClient.connect(n),R.SigningStargateClient.connect(n),de.Tendermint34Client.connect(e)]);return{cosmWasm:r,stargate:s,tendermint:i}},w=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:r,cosmWasmSignerOptions:s={},stargateSignerOptions:i={}}=e,o={url:t,headers:{...n||{}}},[u,p]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(o,r,s),R.SigningStargateClient.connectWithSigner(o,r,i)]);return{cosmWasm:u,stargate:p}};var D=(e=c.getState().walletType)=>{try{return x(e),!0}catch(t){return console.error(t),!1}},ye=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ce=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},x=(e=c.getState().walletType)=>{switch(e){case"keplr":return ye();case"leap":return Ce();default:throw new Error("Unknown wallet type")}},st=()=>Object.fromEntries(U.map(e=>[e,D(e)]));var h=async e=>{try{let{defaultChain:t,recentChain:n,walletType:r}=c.getState(),s=(e==null?void 0:e.walletType)||r,i=x(s),o=e||n||t;if(!o)throw new Error("No last known connected chain, connect action requires chain info");c.setState(B=>{let Ve=B._reconnect;return B.activeChain&&B.activeChain.chainId!==o.chainId?{status:"connecting"}:Ve?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(o.chainId);let u=i.getOfflineSigner(o.chainId),p=i.getOfflineSignerOnlyAmino(o.chainId),m=await i.getOfflineSignerAuto(o.chainId),l=o.gas?fe.GasPrice.fromString(`${o.gas.price}${o.gas.denom}`):void 0,[ue,He,Le]=await Promise.all([i.getKey(o.chainId),E(o),w({...o,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:ue,activeChain:o,clients:He,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:o,signingClients:Le,status:"connected",walletType:s,_reconnect:!0}),ue}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},Q=async(e=!1)=>(c.setState(t=>({...q,recentChain:e?null:t.recentChain})),Promise.resolve()),y=()=>{let{activeChain:e}=c.getState();e&&h(e)};var z=()=>{c.setState({recentChain:null})},K=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},ot=()=>c.getState().recentChain,k=async e=>(await x().experimentalSuggestChain(e),e),W=async({chainInfo:e,...t})=>{let n=await k(e);return{account:await h({chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,...t}),chain:n}};var O=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e);var F=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>n[r].getBalance(e,i.coinMinimalDenom)))},P=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},N=async({senderAddress:e,recipientAddress:t,amount:n,fee:r,memo:s})=>{let{signingClients:i,defaultSigningClient:o}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[o].sendTokens(e,t,n,r,s)},_=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:r,sourceChannel:s,timeoutHeight:i,timeoutTimestamp:o,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,n,r,s,i,o,u,p)},H=async({senderAddress:e,msg:t,fee:n,options:r,label:s,codeId:i})=>{let{signingClients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm signing client is not ready");return o.cosmWasm.instantiate(e,i,t,s,n,r)},L=async({senderAddress:e,msg:t,fee:n,contractAddress:r,funds:s,memo:i})=>{let{signingClients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm signing client is not ready");return o.cosmWasm.execute(e,r,t,n,i,s)},V=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},Y=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,r)};var he=require("@keplr-wallet/cosmos"),Ae={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},rt={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},it={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ct={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},at={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ut={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},xe=[Ae,rt,it,ct,at,ut],J={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Ae,bip44:{coinType:118},bech32Config:he.Bech32Address.defaultBech32Config("axelar"),currencies:xe,feeCurrencies:xe};var Ee=require("@keplr-wallet/cosmos"),we={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Se=[we],I={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:we,bip44:{coinType:118},bech32Config:Ee.Bech32Address.defaultBech32Config("cosmos"),currencies:Se,feeCurrencies:Se};var je=require("@keplr-wallet/cosmos"),De={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},pt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},mt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},lt={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},gt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},dt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},yt={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ct={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},ft={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},xt={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ht={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},be=[De,pt,mt,lt,gt,dt,yt,Ct,ft,xt,ht],$={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:De,bip44:{coinType:118},bech32Config:je.Bech32Address.defaultBech32Config("juno"),currencies:be,feeCurrencies:be};var Ie=require("@keplr-wallet/cosmos"),Te={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},At={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ke=[Te,At],X={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Te,bip44:{coinType:118},bech32Config:Ie.Bech32Address.defaultBech32Config("osmo"),currencies:ke,feeCurrencies:ke};var Ge=require("@keplr-wallet/cosmos"),Ue={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Be=[Ue],Z={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Ue,bip44:{coinType:118},bech32Config:Ge.Bech32Address.defaultBech32Config("somm"),currencies:Be,feeCurrencies:Be};var ve=require("@keplr-wallet/cosmos"),Me={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},qe=[Me],ee={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:ve.Bech32Address.defaultBech32Config("CRE"),currencies:qe,feeCurrencies:qe,stakeCurrency:Me,coinType:118};var Re=require("@keplr-wallet/cosmos"),te={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},St=[te],ne={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:te,bip44:{coinType:118},bech32Config:Re.Bech32Address.defaultBech32Config("juno"),currencies:St,feeCurrencies:[te],coinType:118};var Qe=require("@keplr-wallet/cosmos"),se={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Et=[se],oe={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:se,bip44:{coinType:118},bech32Config:Qe.Bech32Address.defaultBech32Config("osmo"),currencies:Et,feeCurrencies:[se],coinType:118};var re=e=>e,wt=e=>e,bt=e=>e,jt=re({axelar:J,cosmos:I,cosmoshub:I,juno:$,osmosis:X,sommelier:Z}),Dt=[J,I,$,X,Z],kt=re({crescent:ee,juno:ne,osmosis:oe}),It=[ee,ne,oe];var C=require("@tanstack/react-query"),Ke=require("react"),We=me(require("zustand/shallow"));var ze=require("@tanstack/react-query");var Tt=()=>A("keplr"),A=e=>{let t=c(s=>e||s.walletType);return(0,ze.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,s]})=>D(s))};var g=({onConnect:e,onDisconnect:t}={})=>{let n=c(s=>s.account),r=c(s=>s.status);return(0,Ke.useEffect)(()=>c.subscribe(s=>s.status,(s,i)=>{if(s==="connected"){let o=c.getState();e==null||e({account:o.account,isReconnect:i==="reconnecting"})}s==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",reconnect:y,status:r}},Oe=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return(0,C.useQuery)(["USE_BALANCES",n],({queryKey:[,i]})=>F(i),{enabled:Boolean(n)})},Bt=(e,t)=>{let{data:n}=Oe(t);return(0,C.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(o=>o.denom===e),{enabled:Boolean(n)})},Gt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,C.useMutation)(["USE_CONNECT",e,t,n],h,{onError:(o,u)=>Promise.resolve(e==null?void 0:e(o,u)),onMutate:t,onSuccess:o=>Promise.resolve(n==null?void 0:n(o))}),{data:i}=A();return{connect:o=>s.mutate(o),connectAsync:o=>s.mutateAsync(o),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status}},Ut=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,C.useMutation)(["USE_DISCONNECT",e,t,n],Q,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>s.mutate(i),disconnectAsync:i=>s.mutateAsync(i),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,status:s.status}},Fe=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),We.default),qt=()=>Fe(),vt=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return(0,C.useQuery)(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>P(n),{enabled:Boolean(n)})};var S=require("@tanstack/react-query");var Mt=()=>c(e=>e.activeChain),Rt=e=>(0,S.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>K(r)),Qt=(e,t="BOND_STATUS_BONDED")=>(0,S.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,s,i]})=>s.staking.validators(i),{enabled:typeof e<"u"}),zt=()=>({data:c(t=>t.recentChain),clear:z}),Kt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,S.useMutation)(["USE_SUGGEST_CHAIN",e,t,n],k,{onError:(i,o)=>Promise.resolve(e==null?void 0:e(i,o)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,suggest:s.mutate,suggestAsync:s.mutateAsync,status:s.status}},Wt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,S.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],W,{onError:(o,u)=>Promise.resolve(e==null?void 0:e(o,u)),onMutate:o=>t==null?void 0:t(o),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))}),{data:i}=A();return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status,suggestAndConnect:s.mutate,suggestAndConnectAsync:s.mutateAsync}};var ie=require("@tanstack/react-query");var Pe=require("@tanstack/react-query");var Ot=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,Pe.useQuery)(t,({queryKey:[,...r]})=>v(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var Ft=e=>{let t=c(s=>s.clients);return(0,ie.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?E(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({clients:s})}})},Pt=e=>{let t=c(s=>s.signingClients);return(0,ie.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?w(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({signingClients:s})}})};var d=require("@tanstack/react-query");var Nt=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=g(),s=r==null?void 0:r.bech32Address,o=(0,d.useMutation)(["USE_SEND_TOKENS",e,t,n,s],u=>N({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},_t=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=g(),s=r==null?void 0:r.bech32Address,o=(0,d.useMutation)(["USE_SEND_IBC_TOKENS",e,t,n,s],u=>_({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Ht=({codeId:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:s}=g(),i=s==null?void 0:s.bech32Address,p=(0,d.useMutation)(["USE_INSTANTIATE_CONTRACT",t,n,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return H(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},Lt=({contractAddress:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:s}=g(),i=s==null?void 0:s.bech32Address,p=(0,d.useMutation)(["USE_EXECUTE_CONTRACT",t,n,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return L(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},Vt=(e,t)=>(0,d.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return V(e,t)},{enabled:Boolean(e)&&Boolean(t)}),Yt=(e,t)=>(0,d.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or key undefined");return Y(e,t)},{enabled:Boolean(e)&&Boolean(t)});var T=require("@tanstack/react-query");var Ne=require("react");var _e=()=>((0,Ne.useEffect)(()=>{let{_reconnect:e}=c.getState();return e&&y(),window.addEventListener("keplr_keystorechange",y),()=>{window.removeEventListener("keplr_keystorechange",y)}},[]),null),ce=()=>(_e(),null);var ae=require("react/jsx-runtime"),Jt=new T.QueryClient({}),$t=({children:e,grazOptions:t,...n})=>(t&&O(t),(0,ae.jsxs)(T.QueryClientProvider,{client:Jt,...n,children:[(0,ae.jsx)(ce,{}),e]}));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAvailableWallets,getBalanceStaked,getBalances,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalanceStaked,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useExecuteContract,useGrazEvents,useInstantiateContract,useOfflineSigners,useQueryClient,useQueryRaw,useQuerySmart,useRecentChain,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
1
+ "use strict";var Je=Object.create;var k=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var tt=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},le=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xe(t))!et.call(e,o)&&o!==n&&k(e,o,{get:()=>t[o],enumerable:!(r=$e(t,o))||r.enumerable});return e};var de=(e,t,n)=>(n=e!=null?Je(Ze(e)):{},le(t||!e||!e.__esModule?k(n,"default",{value:e,enumerable:!0}):n,e)),nt=e=>le(k({},"__esModule",{value:!0}),e);var Zt={};tt(Zt,{GrazEvents:()=>ue,GrazProvider:()=>Xt,WALLET_TYPES:()=>G,WalletType:()=>v,checkWallet:()=>x,clearRecentChain:()=>z,configureGraz:()=>W,connect:()=>A,createClients:()=>b,createQueryClient:()=>q,createSigningClients:()=>j,defineChain:()=>bt,defineChainInfo:()=>jt,defineChains:()=>ie,disconnect:()=>T,executeContract:()=>L,getActiveChainCurrency:()=>K,getAvailableWallets:()=>st,getBalanceStaked:()=>_,getBalances:()=>F,getKeplr:()=>fe,getLeap:()=>xe,getQueryRaw:()=>Y,getQuerySmart:()=>V,getRecentChain:()=>rt,getWallet:()=>h,instantiateContract:()=>H,mainnetChains:()=>Dt,mainnetChainsArray:()=>kt,reconnect:()=>d,sendIbcTokens:()=>N,sendTokens:()=>P,suggestChain:()=>B,suggestChainAndConnect:()=>O,testnetChains:()=>It,testnetChainsArray:()=>Tt,useAccount:()=>g,useActiveChain:()=>Mt,useActiveChainCurrency:()=>Qt,useActiveChainValidators:()=>zt,useBalance:()=>Rt,useBalanceStaked:()=>qt,useBalances:()=>_e,useCheckKeplr:()=>Bt,useCheckWallet:()=>S,useClients:()=>_t,useConnect:()=>vt,useDisconnect:()=>Gt,useExecuteContract:()=>Vt,useGrazEvents:()=>He,useInstantiateContract:()=>Lt,useOfflineSigners:()=>Pe,useQueryClient:()=>Ft,useQueryRaw:()=>Jt,useQuerySmart:()=>Yt,useRecentChain:()=>Kt,useSendIbcTokens:()=>Ht,useSendTokens:()=>Nt,useSigners:()=>Ut,useSigningClients:()=>Pt,useSuggestChain:()=>Ot,useSuggestChainAndConnect:()=>Wt});module.exports=nt(Zt);var he=require("@cosmjs/stargate");var w="graz-reconnect-session";var ge=de(require("zustand")),I=require("zustand/middleware");var v=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(v||{}),G=["keplr","leap"];var U={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ot={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=(0,ge.default)((0,I.subscribeWithSelector)((0,I.persist)(()=>U,ot)));var M=require("@cosmjs/cosmwasm-stargate"),Q=require("@cosmjs/stargate"),Ce=require("@cosmjs/tendermint-rpc");var ye=require("@cosmjs/stargate"),f=require("@cosmjs/utils");var q=(...e)=>{let{tendermint:t}=c.getState().clients,n=new ye.QueryClient(t),r=e.map(o=>o(n));for(let o of r){(0,f.assert)((0,f.isNonNullObject)(o),"Extension must be a non-null object");for(let[i,s]of Object.entries(o)){(0,f.assert)((0,f.isNonNullObject)(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let u=n[i]||{};n[i]={...u,...s}}}return n};var b=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[r,o,i]=await Promise.all([M.SigningCosmWasmClient.connect(n),Q.SigningStargateClient.connect(n),Ce.Tendermint34Client.connect(e)]);return{cosmWasm:r,stargate:o,tendermint:i}},j=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:r,cosmWasmSignerOptions:o={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...n||{}}},[u,p]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(s,r,o),Q.SigningStargateClient.connectWithSigner(s,r,i)]);return{cosmWasm:u,stargate:p}};var x=(e=c.getState().walletType)=>{try{return h(e),!0}catch(t){return console.error(t),!1}},fe=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},xe=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},h=(e=c.getState().walletType)=>{switch(e){case"keplr":return fe();case"leap":return xe();default:throw new Error("Unknown wallet type")}},st=()=>Object.fromEntries(G.map(e=>[e,x(e)]));var A=async e=>{try{let{defaultChain:t,recentChain:n,walletType:r}=c.getState(),o=(e==null?void 0:e.walletType)||r,i=h(o),s=(e==null?void 0:e.chain)||n||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(D=>{let Ye=D._reconnect||Boolean(D._reconnectConnector)||Boolean(s);return D.activeChain&&D.activeChain.chainId!==s.chainId?{status:"connecting"}:Ye?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let u=i.getOfflineSigner(s.chainId),p=i.getOfflineSignerOnlyAmino(s.chainId),m=await i.getOfflineSignerAuto(s.chainId),l=s.gas?he.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[me,Le,Ve]=await Promise.all([i.getKey(s.chainId),b(s),j({...s,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:me,activeChain:s,clients:Le,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:s,signingClients:Ve,status:"connected",walletType:o,_reconnect:Boolean(e==null?void 0:e.autoReconnect),_reconnectConnector:o}),typeof window<"u"&&window.sessionStorage.setItem(w,"Active"),me}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},T=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(w),c.setState(t=>({...U,recentChain:e?null:t.recentChain})),Promise.resolve()),d=async e=>{var i;let{recentChain:t,_reconnectConnector:n,_reconnect:r}=c.getState(),o=x(n||void 0);try{if(t&&o&&n)return await A({chain:t,walletType:n,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),T()}};var z=()=>{c.setState({recentChain:null})},K=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},rt=()=>c.getState().recentChain,B=async e=>(await h().experimentalSuggestChain(e),e),O=async({chainInfo:e,rpcHeaders:t,gas:n,path:r,...o})=>{let i=await B(e);return{account:await A({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:n,path:r},...o}),chain:i}};var W=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var F=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return n[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},_=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},P=async({senderAddress:e,recipientAddress:t,amount:n,fee:r,memo:o})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,n,r,o)},N=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:r,sourceChannel:o,timeoutHeight:i,timeoutTimestamp:s,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,n,r,o,i,s,u,p)},H=async({senderAddress:e,msg:t,fee:n,options:r,label:o,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,o,n,r)},L=async({senderAddress:e,msg:t,fee:n,contractAddress:r,funds:o,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,n,i,o)},V=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},Y=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,r)};var Se=require("@keplr-wallet/cosmos"),Ee={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},it={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},ct={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},at={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ut={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},pt={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Ae=[Ee,it,ct,at,ut,pt],J={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Ee,bip44:{coinType:118},bech32Config:Se.Bech32Address.defaultBech32Config("axelar"),currencies:Ae,feeCurrencies:Ae};var be=require("@keplr-wallet/cosmos"),je={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},we=[je],$={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:je,bip44:{coinType:118},bech32Config:be.Bech32Address.defaultBech32Config("cosmos"),currencies:we,feeCurrencies:we};var ke=require("@keplr-wallet/cosmos"),Ie={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},mt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},lt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},dt={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},gt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},yt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ct={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ft={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},xt={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},ht={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},At={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},De=[Ie,mt,lt,dt,gt,yt,Ct,ft,xt,ht,At],X={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Ie,bip44:{coinType:118},bech32Config:ke.Bech32Address.defaultBech32Config("juno"),currencies:De,feeCurrencies:De};var Be=require("@keplr-wallet/cosmos"),Re={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},St={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Te=[Re,St],Z={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Re,bip44:{coinType:118},bech32Config:Be.Bech32Address.defaultBech32Config("osmo"),currencies:Te,feeCurrencies:Te};var Ge=require("@keplr-wallet/cosmos"),Ue={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},ve=[Ue],ee={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Ue,bip44:{coinType:118},bech32Config:Ge.Bech32Address.defaultBech32Config("somm"),currencies:ve,feeCurrencies:ve};var Me=require("@keplr-wallet/cosmos"),Qe={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},qe=[Qe],te={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:Me.Bech32Address.defaultBech32Config("CRE"),currencies:qe,feeCurrencies:qe,stakeCurrency:Qe,coinType:118};var ze=require("@keplr-wallet/cosmos"),ne={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Et=[ne],oe={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:ne,bip44:{coinType:118},bech32Config:ze.Bech32Address.defaultBech32Config("juno"),currencies:Et,feeCurrencies:[ne],coinType:118};var Ke=require("@keplr-wallet/cosmos"),se={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},wt=[se],re={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:se,bip44:{coinType:118},bech32Config:Ke.Bech32Address.defaultBech32Config("osmo"),currencies:wt,feeCurrencies:[se],coinType:118};var ie=e=>e,bt=e=>e,jt=e=>e,Dt=ie({axelar:J,cosmoshub:$,juno:X,osmosis:Z,sommelier:ee}),kt=[J,$,X,Z,ee],It=ie({crescent:te,juno:oe,osmosis:re}),Tt=[te,oe,re];var C=require("@tanstack/react-query"),We=require("react"),Fe=de(require("zustand/shallow"));var Oe=require("@tanstack/react-query");var Bt=()=>S("keplr"),S=e=>{let t=c(o=>e||o.walletType);return(0,Oe.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,o]})=>x(o))};var g=({onConnect:e,onDisconnect:t}={})=>{let n=c(o=>o.account),r=c(o=>o.status);return(0,We.useEffect)(()=>c.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}o==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:d,status:r}},_e=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return(0,C.useQuery)(["USE_BALANCES",n],({queryKey:[,i]})=>F(i),{enabled:Boolean(n)})},Rt=(e,t)=>{let{data:n}=_e(t);return(0,C.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:Boolean(n)})},vt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,C.useMutation)(["USE_CONNECT",e,t,n],A,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=S();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status}},Gt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,C.useMutation)(["USE_DISCONNECT",e,t,n],T,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>o.mutate(i),disconnectAsync:i=>o.mutateAsync(i),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,status:o.status}},Pe=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Fe.default),Ut=()=>Pe(),qt=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return(0,C.useQuery)(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>_(n),{enabled:Boolean(n)})};var E=require("@tanstack/react-query");var Mt=()=>c(e=>e.activeChain),Qt=e=>(0,E.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>K(r)),zt=(e,t="BOND_STATUS_BONDED")=>(0,E.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,o,i]})=>o.staking.validators(i),{enabled:typeof e<"u"}),Kt=()=>({data:c(t=>t.recentChain),clear:z}),Ot=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,E.useMutation)(["USE_SUGGEST_CHAIN",e,t,n],B,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,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}},Wt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,E.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],O,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=S();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};var ce=require("@tanstack/react-query");var Ne=require("@tanstack/react-query");var Ft=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,Ne.useQuery)(t,({queryKey:[,...r]})=>q(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var _t=e=>{let t=c(o=>o.clients);return(0,ce.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?b(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:o=>{c.setState({clients:o})}})},Pt=e=>{let t=c(o=>o.signingClients);return(0,ce.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?j(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:o=>{c.setState({signingClients:o})}})};var y=require("@tanstack/react-query");var Nt=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=g(),o=r==null?void 0:r.bech32Address,s=(0,y.useMutation)(["USE_SEND_TOKENS",e,t,n,o],u=>P({senderAddress:o,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Ht=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=g(),o=r==null?void 0:r.bech32Address,s=(0,y.useMutation)(["USE_SEND_IBC_TOKENS",e,t,n,o],u=>N({senderAddress:o,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},Lt=({codeId:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:o}=g(),i=o==null?void 0:o.bech32Address,p=(0,y.useMutation)(["USE_INSTANTIATE_CONTRACT",t,n,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return H(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},Vt=({contractAddress:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:o}=g(),i=o==null?void 0:o.bech32Address,p=(0,y.useMutation)(["USE_EXECUTE_CONTRACT",t,n,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return L(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},Yt=(e,t)=>(0,y.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,o]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return V(e,t)},{enabled:Boolean(e)&&Boolean(t)}),Jt=(e,t)=>(0,y.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,o]})=>{if(!e||!t)throw new Error("address or key undefined");return Y(e,t)},{enabled:Boolean(e)&&Boolean(t)});var R=require("@tanstack/react-query");var ae=require("react");var He=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(w)==="Active",{activeChain:t,_reconnect:n,_onReconnectFailed:r}=c.getState();return(0,ae.useEffect)(()=>{e&&Boolean(t)?d({onError:r}):!e&&n&&d({onError:r})},[]),(0,ae.useEffect)(()=>(window.addEventListener("keplr_keystorechange",()=>void d({onError:r})),()=>{window.removeEventListener("keplr_keystorechange",()=>void d({onError:r}))}),[]),null},ue=()=>(He(),null);var pe=require("react/jsx-runtime"),$t=new R.QueryClient({}),Xt=({children:e,grazOptions:t,...n})=>(t&&W(t),(0,pe.jsxs)(R.QueryClientProvider,{client:$t,...n,children:[(0,pe.jsx)(ue,{}),e]}));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAvailableWallets,getBalanceStaked,getBalances,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalanceStaked,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useExecuteContract,useGrazEvents,useInstantiateContract,useOfflineSigners,useQueryClient,useQueryRaw,useQuerySmart,useRecentChain,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{GasPrice as qe}from"@cosmjs/stargate";import je from"zustand";import{persist as De,subscribeWithSelector as ke}from"zustand/middleware";var Q=(s=>(s.KEPLR="keplr",s.LEAP="leap",s))(Q||{}),z=["keplr","leap"];var w={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_reconnect:!1},Ie={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},c=je(ke(De(()=>w,Ie)));import{SigningCosmWasmClient as F}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as P}from"@cosmjs/stargate";import{Tendermint34Client as Be}from"@cosmjs/tendermint-rpc";import{QueryClient as Te}from"@cosmjs/stargate";import{assert as K,isNonNullObject as W}from"@cosmjs/utils";var O=(...e)=>{let{tendermint:t}=c.getState().clients,s=new Te(t),i=e.map(n=>n(s));for(let n of i){K(W(n),"Extension must be a non-null object");for(let[r,o]of Object.entries(n)){K(W(o),`Module must be a non-null object. Found type ${typeof o} for module "${r}".`);let u=s[r]||{};s[r]={...u,...o}}}return s};var x=async({rpc:e,rpcHeaders:t})=>{let s={url:e,headers:{...t||{}}},[i,n,r]=await Promise.all([F.connect(s),P.connect(s),Be.connect(e)]);return{cosmWasm:i,stargate:n,tendermint:r}},h=async e=>{let{rpc:t,rpcHeaders:s,offlineSignerAuto:i,cosmWasmSignerOptions:n={},stargateSignerOptions:r={}}=e,o={url:t,headers:{...s||{}}},[u,p]=await Promise.all([F.connectWithSigner(o,i,n),P.connectWithSigner(o,i,r)]);return{cosmWasm:u,stargate:p}};var b=(e=c.getState().walletType)=>{try{return y(e),!0}catch(t){return console.error(t),!1}},Ge=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ue=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},y=(e=c.getState().walletType)=>{switch(e){case"keplr":return Ge();case"leap":return Ue();default:throw new Error("Unknown wallet type")}},Mt=()=>Object.fromEntries(z.map(e=>[e,b(e)]));var C=async e=>{try{let{defaultChain:t,recentChain:s,walletType:i}=c.getState(),n=(e==null?void 0:e.walletType)||i,r=y(n),o=e||s||t;if(!o)throw new Error("No last known connected chain, connect action requires chain info");c.setState(E=>{let be=E._reconnect;return E.activeChain&&E.activeChain.chainId!==o.chainId?{status:"connecting"}:be?{status:"reconnecting"}:{status:"connecting"}}),await r.enable(o.chainId);let u=r.getOfflineSigner(o.chainId),p=r.getOfflineSignerOnlyAmino(o.chainId),m=await r.getOfflineSignerAuto(o.chainId),l=o.gas?qe.fromString(`${o.gas.price}${o.gas.denom}`):void 0,[R,Ee,we]=await Promise.all([r.getKey(o.chainId),x(o),h({...o,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:R,activeChain:o,clients:Ee,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:o,signingClients:we,status:"connected",walletType:n,_reconnect:!0}),R}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},N=async(e=!1)=>(c.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()),d=()=>{let{activeChain:e}=c.getState();e&&C(e)};var _=()=>{c.setState({recentChain:null})},H=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(s=>s.coinMinimalDenom===e)},_t=()=>c.getState().recentChain,j=async e=>(await y().experimentalSuggestChain(e),e),L=async({chainInfo:e,...t})=>{let s=await j(e);return{account:await C({chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,...t}),chain:s}};var V=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e);var Y=async e=>{let{activeChain:t,signingClients:s}=c.getState();if(!t||!s)throw new Error("No connected account detected");let{defaultSigningClient:i}=c.getState();return await Promise.all(t.currencies.map(async r=>s[i].getBalance(e,r.coinMinimalDenom)))},J=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},$=async({senderAddress:e,recipientAddress:t,amount:s,fee:i,memo:n})=>{let{signingClients:r,defaultSigningClient:o}=c.getState();if(!r)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return r[o].sendTokens(e,t,s,i,n)},X=async({senderAddress:e,recipientAddress:t,transferAmount:s,sourcePort:i,sourceChannel:n,timeoutHeight:r,timeoutTimestamp:o,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,s,i,n,r,o,u,p)},Z=async({senderAddress:e,msg:t,fee:s,options:i,label:n,codeId:r})=>{let{signingClients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm signing client is not ready");return o.cosmWasm.instantiate(e,r,t,n,s,i)},ee=async({senderAddress:e,msg:t,fee:s,contractAddress:i,funds:n,memo:r})=>{let{signingClients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm signing client is not ready");return o.cosmWasm.execute(e,i,t,s,r,n)},te=async(e,t)=>{let{clients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm client is not ready");return await s.cosmWasm.queryContractSmart(e,t)},ne=(e,t)=>{let{clients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return s.cosmWasm.queryContractRaw(e,i)};import{Bech32Address as ve}from"@keplr-wallet/cosmos";var oe={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Me={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Re={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Qe={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ze={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Ke={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},se=[oe,Me,Re,Qe,ze,Ke],D={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:oe,bip44:{coinType:118},bech32Config:ve.defaultBech32Config("axelar"),currencies:se,feeCurrencies:se};import{Bech32Address as We}from"@keplr-wallet/cosmos";var ie={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},re=[ie],A={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ie,bip44:{coinType:118},bech32Config:We.defaultBech32Config("cosmos"),currencies:re,feeCurrencies:re};import{Bech32Address as Oe}from"@keplr-wallet/cosmos";var ae={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Fe={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Pe={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Ne={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},_e={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},He={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Le={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ve={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Ye={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Je={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},$e={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ce=[ae,Fe,Pe,Ne,_e,He,Le,Ve,Ye,Je,$e],k={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ae,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("juno"),currencies:ce,feeCurrencies:ce};import{Bech32Address as Xe}from"@keplr-wallet/cosmos";var pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ze={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ue=[pe,Ze],I={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:pe,bip44:{coinType:118},bech32Config:Xe.defaultBech32Config("osmo"),currencies:ue,feeCurrencies:ue};import{Bech32Address as et}from"@keplr-wallet/cosmos";var le={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},me=[le],T={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:le,bip44:{coinType:118},bech32Config:et.defaultBech32Config("somm"),currencies:me,feeCurrencies:me};import{Bech32Address as tt}from"@keplr-wallet/cosmos";var de={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},ge=[de],B={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:tt.defaultBech32Config("CRE"),currencies:ge,feeCurrencies:ge,stakeCurrency:de,coinType:118};import{Bech32Address as nt}from"@keplr-wallet/cosmos";var G={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},st=[G],U={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:G,bip44:{coinType:118},bech32Config:nt.defaultBech32Config("juno"),currencies:st,feeCurrencies:[G],coinType:118};import{Bech32Address as ot}from"@keplr-wallet/cosmos";var q={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},rt=[q],v={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:q,bip44:{coinType:118},bech32Config:ot.defaultBech32Config("osmo"),currencies:rt,feeCurrencies:[q],coinType:118};var ye=e=>e,wn=e=>e,bn=e=>e,jn=ye({axelar:D,cosmos:A,cosmoshub:A,juno:k,osmosis:I,sommelier:T}),Dn=[D,A,k,I,T],kn=ye({crescent:B,juno:U,osmosis:v}),In=[B,U,v];import{useMutation as Ce,useQuery as M}from"@tanstack/react-query";import{useEffect as ct}from"react";import at from"zustand/shallow";import{useQuery as it}from"@tanstack/react-query";var qn=()=>f("keplr"),f=e=>{let t=c(n=>e||n.walletType);return it(["USE_CHECK_WALLET",t],({queryKey:[,n]})=>b(n))};var g=({onConnect:e,onDisconnect:t}={})=>{let s=c(n=>n.account),i=c(n=>n.status);return ct(()=>c.subscribe(n=>n.status,(n,r)=>{if(n==="connected"){let o=c.getState();e==null||e({account:o.account,isReconnect:r==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:s,isConnected:Boolean(s),isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",reconnect:d,status:i}},ut=e=>{let{data:t}=g(),s=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCES",s],({queryKey:[,r]})=>Y(r),{enabled:Boolean(s)})},Fn=(e,t)=>{let{data:s}=ut(t);return M(["USE_BALANCE",s,e,t],({queryKey:[,r]})=>r==null?void 0:r.find(o=>o.denom===e),{enabled:Boolean(s)})},Pn=({onError:e,onLoading:t,onSuccess:s}={})=>{let n=Ce(["USE_CONNECT",e,t,s],C,{onError:(o,u)=>Promise.resolve(e==null?void 0:e(o,u)),onMutate:t,onSuccess:o=>Promise.resolve(s==null?void 0:s(o))}),{data:r}=f();return{connect:o=>n.mutate(o),connectAsync:o=>n.mutateAsync(o),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(r),status:n.status}},Nn=({onError:e,onLoading:t,onSuccess:s}={})=>{let n=Ce(["USE_DISCONNECT",e,t,s],N,{onError:r=>Promise.resolve(e==null?void 0:e(r,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(s==null?void 0:s(void 0))});return{disconnect:r=>n.mutate(r),disconnectAsync:r=>n.mutateAsync(r),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}},pt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),at),_n=()=>pt(),Hn=e=>{let{data:t}=g(),s=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCE_STAKED",s],({queryKey:[,r]})=>J(s),{enabled:Boolean(s)})};import{useMutation as fe,useQuery as xe}from"@tanstack/react-query";var Xn=()=>c(e=>e.activeChain),Zn=e=>xe(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,i]})=>H(i)),es=(e,t="BOND_STATUS_BONDED")=>xe(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,r]})=>n.staking.validators(r),{enabled:typeof e<"u"}),ts=()=>({data:c(t=>t.recentChain),clear:_}),ns=({onError:e,onLoading:t,onSuccess:s}={})=>{let n=fe(["USE_SUGGEST_CHAIN",e,t,s],j,{onError:(r,o)=>Promise.resolve(e==null?void 0:e(r,o)),onMutate:t,onSuccess:r=>Promise.resolve(s==null?void 0:s(r))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}},ss=({onError:e,onLoading:t,onSuccess:s}={})=>{let n=fe(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,s],L,{onError:(o,u)=>Promise.resolve(e==null?void 0:e(o,u)),onMutate:o=>t==null?void 0:t(o),onSuccess:o=>Promise.resolve(s==null?void 0:s(o))}),{data:r}=f();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(r),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};import{useQuery as he}from"@tanstack/react-query";import{useQuery as mt}from"@tanstack/react-query";var cs=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return mt(t,({queryKey:[,...i]})=>O(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var ls=e=>{let t=c(n=>n.clients);return he(["USE_CLIENTS",e,t],({queryKey:[,n,r]})=>n!=null&&n.rpc?x(n):r,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},gs=e=>{let t=c(n=>n.signingClients);return he(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,r]})=>n!=null&&n.rpc?h(n):r,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};import{useMutation as S,useQuery as Ae}from"@tanstack/react-query";var hs=({onError:e,onLoading:t,onSuccess:s}={})=>{let{data:i}=g(),n=i==null?void 0:i.bech32Address,o=S(["USE_SEND_TOKENS",e,t,s,n],u=>$({senderAddress:n,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(s==null?void 0:s(u))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},As=({onError:e,onLoading:t,onSuccess:s}={})=>{let{data:i}=g(),n=i==null?void 0:i.bech32Address,o=S(["USE_SEND_IBC_TOKENS",e,t,s,n],u=>X({senderAddress:n,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(s==null?void 0:s(u))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Ss=({codeId:e,onError:t,onLoading:s,onSuccess:i})=>{let{data:n}=g(),r=n==null?void 0:n.bech32Address,p=S(["USE_INSTANTIATE_CONTRACT",t,s,i,e,r],m=>{if(!r)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:r,codeId:e};return Z(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:s,onSuccess:m=>Promise.resolve(i==null?void 0:i(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},Es=({contractAddress:e,onError:t,onLoading:s,onSuccess:i})=>{let{data:n}=g(),r=n==null?void 0:n.bech32Address,p=S(["USE_EXECUTE_CONTRACT",t,s,i,e,r],m=>{if(!r)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:r,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return ee(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:s,onSuccess:m=>Promise.resolve(i==null?void 0:i(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},ws=(e,t)=>Ae(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return te(e,t)},{enabled:Boolean(e)&&Boolean(t)}),bs=(e,t)=>Ae(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return ne(e,t)},{enabled:Boolean(e)&&Boolean(t)});import{QueryClient as dt,QueryClientProvider as yt}from"@tanstack/react-query";import{useEffect as lt}from"react";var gt=()=>(lt(()=>{let{_reconnect:e}=c.getState();return e&&d(),window.addEventListener("keplr_keystorechange",d),()=>{window.removeEventListener("keplr_keystorechange",d)}},[]),null),Se=()=>(gt(),null);import{jsx as ft,jsxs as xt}from"react/jsx-runtime";var Ct=new dt({}),qs=({children:e,grazOptions:t,...s})=>(t&&V(t),xt(yt,{client:Ct,...s,children:[ft(Se,{}),e]}));export{Se as GrazEvents,qs as GrazProvider,z as WALLET_TYPES,Q as WalletType,b as checkWallet,_ as clearRecentChain,V as configureGraz,C as connect,x as createClients,O as createQueryClient,h as createSigningClients,wn as defineChain,bn as defineChainInfo,ye as defineChains,N as disconnect,ee as executeContract,H as getActiveChainCurrency,Mt as getAvailableWallets,J as getBalanceStaked,Y as getBalances,Ge as getKeplr,Ue as getLeap,ne as getQueryRaw,te as getQuerySmart,_t as getRecentChain,y as getWallet,Z as instantiateContract,jn as mainnetChains,Dn as mainnetChainsArray,d as reconnect,X as sendIbcTokens,$ as sendTokens,j as suggestChain,L as suggestChainAndConnect,kn as testnetChains,In as testnetChainsArray,g as useAccount,Xn as useActiveChain,Zn as useActiveChainCurrency,es as useActiveChainValidators,Fn as useBalance,Hn as useBalanceStaked,ut as useBalances,qn as useCheckKeplr,f as useCheckWallet,ls as useClients,Pn as useConnect,Nn as useDisconnect,Es as useExecuteContract,gt as useGrazEvents,Ss as useInstantiateContract,pt as useOfflineSigners,cs as useQueryClient,bs as useQueryRaw,ws as useQuerySmart,ts as useRecentChain,As as useSendIbcTokens,hs as useSendTokens,_n as useSigners,gs as useSigningClients,ns as useSuggestChain,ss as useSuggestChainAndConnect};
1
+ import{a as y}from"./chunk-ETISV7IF.mjs";import{GasPrice as qe}from"@cosmjs/stargate";import ke from"zustand";import{persist as Ie,subscribeWithSelector as Te}from"zustand/middleware";var K=(o=>(o.KEPLR="keplr",o.LEAP="leap",o))(K||{}),W=["keplr","leap"];var b={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Be={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=ke(Te(Ie(()=>b,Be)));import{SigningCosmWasmClient as P}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as N}from"@cosmjs/stargate";import{Tendermint34Client as ve}from"@cosmjs/tendermint-rpc";import{QueryClient as Re}from"@cosmjs/stargate";import{assert as O,isNonNullObject as F}from"@cosmjs/utils";var _=(...e)=>{let{tendermint:t}=c.getState().clients,o=new Re(t),r=e.map(n=>n(o));for(let n of r){O(F(n),"Extension must be a non-null object");for(let[i,s]of Object.entries(n)){O(F(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let u=o[i]||{};o[i]={...u,...s}}}return o};var S=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([P.connect(o),N.connect(o),ve.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},E=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...o||{}}},[u,p]=await Promise.all([P.connectWithSigner(s,r,n),N.connectWithSigner(s,r,i)]);return{cosmWasm:u,stargate:p}};var C=(e=c.getState().walletType)=>{try{return f(e),!0}catch(t){return console.error(t),!1}},Ge=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ue=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},f=(e=c.getState().walletType)=>{switch(e){case"keplr":return Ge();case"leap":return Ue();default:throw new Error("Unknown wallet type")}},Mt=()=>Object.fromEntries(W.map(e=>[e,C(e)]));var x=async e=>{try{let{defaultChain:t,recentChain:o,walletType:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=f(n),s=(e==null?void 0:e.chain)||o||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(A=>{let De=A._reconnect||Boolean(A._reconnectConnector)||Boolean(s);return A.activeChain&&A.activeChain.chainId!==s.chainId?{status:"connecting"}:De?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let u=i.getOfflineSigner(s.chainId),p=i.getOfflineSignerOnlyAmino(s.chainId),m=await i.getOfflineSignerAuto(s.chainId),l=s.gas?qe.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[z,be,je]=await Promise.all([i.getKey(s.chainId),S(s),E({...s,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:z,activeChain:s,clients:be,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:s,signingClients:je,status:"connected",walletType:n,_reconnect:Boolean(e==null?void 0:e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(y,"Active"),z}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},j=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(y),c.setState(t=>({...b,recentChain:e?null:t.recentChain})),Promise.resolve()),d=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:r}=c.getState(),n=C(o||void 0);try{if(t&&n&&o)return await x({chain:t,walletType:o,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),j()}};var H=()=>{c.setState({recentChain:null})},L=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(o=>o.coinMinimalDenom===e)},Lt=()=>c.getState().recentChain,D=async e=>(await f().experimentalSuggestChain(e),e),V=async({chainInfo:e,rpcHeaders:t,gas:o,path:r,...n})=>{let i=await D(e);return{account:await x({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:r},...n}),chain:i}};var Y=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var J=async e=>{let{activeChain:t,signingClients:o}=c.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return o[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},$=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},X=async({senderAddress:e,recipientAddress:t,amount:o,fee:r,memo:n})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,o,r,n)},Z=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:s,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,o,r,n,i,s,u,p)},ee=async({senderAddress:e,msg:t,fee:o,options:r,label:n,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,n,o,r)},te=async({senderAddress:e,msg:t,fee:o,contractAddress:r,funds:n,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,o,i,n)},ne=async(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");return await o.cosmWasm.queryContractSmart(e,t)},oe=(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return o.cosmWasm.queryContractRaw(e,r)};import{Bech32Address as Me}from"@keplr-wallet/cosmos";var re={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Qe={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},ze={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Ke={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},We={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Oe={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},se=[re,Qe,ze,Ke,We,Oe],k={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:re,bip44:{coinType:118},bech32Config:Me.defaultBech32Config("axelar"),currencies:se,feeCurrencies:se};import{Bech32Address as Fe}from"@keplr-wallet/cosmos";var ce={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ie=[ce],I={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ce,bip44:{coinType:118},bech32Config:Fe.defaultBech32Config("cosmos"),currencies:ie,feeCurrencies:ie};import{Bech32Address as _e}from"@keplr-wallet/cosmos";var ue={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Pe={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Ne={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},He={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Le={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ve={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ye={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Je={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},$e={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Xe={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Ze={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ae=[ue,Pe,Ne,He,Le,Ve,Ye,Je,$e,Xe,Ze],T={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ue,bip44:{coinType:118},bech32Config:_e.defaultBech32Config("juno"),currencies:ae,feeCurrencies:ae};import{Bech32Address as et}from"@keplr-wallet/cosmos";var me={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},tt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},pe=[me,tt],B={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:me,bip44:{coinType:118},bech32Config:et.defaultBech32Config("osmo"),currencies:pe,feeCurrencies:pe};import{Bech32Address as nt}from"@keplr-wallet/cosmos";var de={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},le=[de],R={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:de,bip44:{coinType:118},bech32Config:nt.defaultBech32Config("somm"),currencies:le,feeCurrencies:le};import{Bech32Address as ot}from"@keplr-wallet/cosmos";var ye={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},ge=[ye],v={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:ot.defaultBech32Config("CRE"),currencies:ge,feeCurrencies:ge,stakeCurrency:ye,coinType:118};import{Bech32Address as st}from"@keplr-wallet/cosmos";var G={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},rt=[G],U={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:G,bip44:{coinType:118},bech32Config:st.defaultBech32Config("juno"),currencies:rt,feeCurrencies:[G],coinType:118};import{Bech32Address as it}from"@keplr-wallet/cosmos";var q={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},ct=[q],M={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:q,bip44:{coinType:118},bech32Config:it.defaultBech32Config("osmo"),currencies:ct,feeCurrencies:[q],coinType:118};var Ce=e=>e,jn=e=>e,Dn=e=>e,kn=Ce({axelar:k,cosmoshub:I,juno:T,osmosis:B,sommelier:R}),In=[k,I,T,B,R],Tn=Ce({crescent:v,juno:U,osmosis:M}),Bn=[v,U,M];import{useMutation as fe,useQuery as Q}from"@tanstack/react-query";import{useEffect as ut}from"react";import pt from"zustand/shallow";import{useQuery as at}from"@tanstack/react-query";var qn=()=>h("keplr"),h=e=>{let t=c(n=>e||n.walletType);return at(["USE_CHECK_WALLET",t],({queryKey:[,n]})=>C(n))};var g=({onConnect:e,onDisconnect:t}={})=>{let o=c(n=>n.account),r=c(n=>n.status);return ut(()=>c.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:d,status:r}},mt=e=>{let{data:t}=g(),o=e||(t==null?void 0:t.bech32Address);return Q(["USE_BALANCES",o],({queryKey:[,i]})=>J(i),{enabled:Boolean(o)})},Pn=(e,t)=>{let{data:o}=mt(t);return Q(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:Boolean(o)})},Nn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_CONNECT",e,t,o],x,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=h();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(i),status:n.status}},Hn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_DISCONNECT",e,t,o],j,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:i=>n.mutate(i),disconnectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}},lt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),pt),Ln=()=>lt(),Vn=e=>{let{data:t}=g(),o=e||(t==null?void 0:t.bech32Address);return Q(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>$(o),{enabled:Boolean(o)})};import{useMutation as xe,useQuery as he}from"@tanstack/react-query";var eo=()=>c(e=>e.activeChain),to=e=>he(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>L(r)),no=(e,t="BOND_STATUS_BONDED")=>he(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),oo=()=>({data:c(t=>t.recentChain),clear:H}),so=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=xe(["USE_SUGGEST_CHAIN",e,t,o],D,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}},ro=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=xe(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],V,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=h();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(i),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};import{useQuery as Ae}from"@tanstack/react-query";import{useQuery as dt}from"@tanstack/react-query";var uo=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return dt(t,({queryKey:[,...r]})=>_(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var yo=e=>{let t=c(n=>n.clients);return Ae(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?S(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},Co=e=>{let t=c(n=>n.signingClients);return Ae(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?E(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};import{useMutation as w,useQuery as Se}from"@tanstack/react-query";var Eo=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=g(),n=r==null?void 0:r.bech32Address,s=w(["USE_SEND_TOKENS",e,t,o,n],u=>X({senderAddress:n,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(o==null?void 0:o(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},wo=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=g(),n=r==null?void 0:r.bech32Address,s=w(["USE_SEND_IBC_TOKENS",e,t,o,n],u=>Z({senderAddress:n,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(o==null?void 0:o(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},bo=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=g(),i=n==null?void 0:n.bech32Address,p=w(["USE_INSTANTIATE_CONTRACT",t,o,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return ee(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:o,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},jo=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=g(),i=n==null?void 0:n.bech32Address,p=w(["USE_EXECUTE_CONTRACT",t,o,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return te(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:o,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},Do=(e,t)=>Se(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return ne(e,t)},{enabled:Boolean(e)&&Boolean(t)}),ko=(e,t)=>Se(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return oe(e,t)},{enabled:Boolean(e)&&Boolean(t)});import{QueryClient as yt,QueryClientProvider as Ct}from"@tanstack/react-query";import{useEffect as Ee}from"react";var gt=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(y)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:r}=c.getState();return Ee(()=>{e&&Boolean(t)?d({onError:r}):!e&&o&&d({onError:r})},[]),Ee(()=>(window.addEventListener("keplr_keystorechange",()=>void d({onError:r})),()=>{window.removeEventListener("keplr_keystorechange",()=>void d({onError:r}))}),[]),null},we=()=>(gt(),null);import{jsx as xt,jsxs as ht}from"react/jsx-runtime";var ft=new yt({}),Qo=({children:e,grazOptions:t,...o})=>(t&&Y(t),ht(Ct,{client:ft,...o,children:[xt(we,{}),e]}));export{we as GrazEvents,Qo as GrazProvider,W as WALLET_TYPES,K as WalletType,C as checkWallet,H as clearRecentChain,Y as configureGraz,x as connect,S as createClients,_ as createQueryClient,E as createSigningClients,jn as defineChain,Dn as defineChainInfo,Ce as defineChains,j as disconnect,te as executeContract,L as getActiveChainCurrency,Mt as getAvailableWallets,$ as getBalanceStaked,J as getBalances,Ge as getKeplr,Ue as getLeap,oe as getQueryRaw,ne as getQuerySmart,Lt as getRecentChain,f as getWallet,ee as instantiateContract,kn as mainnetChains,In as mainnetChainsArray,d as reconnect,Z as sendIbcTokens,X as sendTokens,D as suggestChain,V as suggestChainAndConnect,Tn as testnetChains,Bn as testnetChainsArray,g as useAccount,eo as useActiveChain,to as useActiveChainCurrency,no as useActiveChainValidators,Pn as useBalance,Vn as useBalanceStaked,mt as useBalances,qn as useCheckKeplr,h as useCheckWallet,yo as useClients,Nn as useConnect,Hn as useDisconnect,jo as useExecuteContract,gt as useGrazEvents,bo as useInstantiateContract,lt as useOfflineSigners,uo as useQueryClient,ko as useQueryRaw,Do as useQuerySmart,oo as useRecentChain,wo as useSendIbcTokens,Eo as useSendTokens,Ln as useSigners,Co as useSigningClients,so as useSuggestChain,ro as useSuggestChainAndConnect};
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.35",
4
+ "version": "0.0.37",
5
5
  "author": "Griko Nibras <griko@strangelove.ventures>",
6
6
  "repository": "https://github.com/strangelove-ventures/graz.git",
7
7
  "homepage": "https://github.com/strangelove-ventures/graz",
@@ -36,6 +36,7 @@
36
36
  "sideEffects": false,
37
37
  "dependencies": {
38
38
  "@cosmjs/cosmwasm-stargate": "^0",
39
+ "@cosmjs/launchpad": "^0",
39
40
  "@cosmjs/proto-signing": "^0",
40
41
  "@cosmjs/stargate": "^0",
41
42
  "@cosmjs/tendermint-rpc": "^0",