graz 0.0.39 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +36 -40
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
|
|
2
2
|
import { SigningCosmWasmClientOptions, CosmWasmClient, SigningCosmWasmClient, InstantiateOptions, InstantiateResult, ExecuteResult } from '@cosmjs/cosmwasm-stargate';
|
|
3
|
+
import * as _keplr_wallet_types from '@keplr-wallet/types';
|
|
3
4
|
import { ChainInfo, AppCurrency, Key, Keplr } from '@keplr-wallet/types';
|
|
4
5
|
import * as _cosmjs_proto_signing from '@cosmjs/proto-signing';
|
|
5
6
|
import { Coin, OfflineSigner, OfflineDirectSigner } from '@cosmjs/proto-signing';
|
|
@@ -158,7 +159,8 @@ declare const testnetChainsArray: ChainInfo[];
|
|
|
158
159
|
|
|
159
160
|
declare enum WalletType {
|
|
160
161
|
KEPLR = "keplr",
|
|
161
|
-
LEAP = "leap"
|
|
162
|
+
LEAP = "leap",
|
|
163
|
+
COSMOSTATION = "cosmostation"
|
|
162
164
|
}
|
|
163
165
|
declare const WALLET_TYPES: WalletType[];
|
|
164
166
|
|
|
@@ -168,12 +170,17 @@ type ConnectArgs = Maybe<{
|
|
|
168
170
|
walletType?: WalletType;
|
|
169
171
|
autoReconnect?: boolean;
|
|
170
172
|
}>;
|
|
171
|
-
|
|
173
|
+
interface ConnectResult {
|
|
174
|
+
account: Key;
|
|
175
|
+
walletType: WalletType;
|
|
176
|
+
chain: GrazChain;
|
|
177
|
+
}
|
|
178
|
+
declare const connect: (args?: ConnectArgs) => Promise<ConnectResult>;
|
|
172
179
|
declare const disconnect: (clearRecentChain?: boolean) => Promise<void>;
|
|
173
180
|
type ReconnectArgs = Maybe<{
|
|
174
181
|
onError?: (error: unknown) => void;
|
|
175
182
|
}>;
|
|
176
|
-
declare const reconnect: (args?: ReconnectArgs) => Promise<
|
|
183
|
+
declare const reconnect: (args?: ReconnectArgs) => Promise<ConnectResult | undefined>;
|
|
177
184
|
|
|
178
185
|
type ExtensionSetup<P extends object = object> = (queryClient: QueryClient) => P;
|
|
179
186
|
|
|
@@ -211,10 +218,7 @@ interface SuggestChainAndConnectArgs {
|
|
|
211
218
|
path?: string;
|
|
212
219
|
autoReconnect?: boolean;
|
|
213
220
|
}
|
|
214
|
-
declare const suggestChainAndConnect: ({ chainInfo, rpcHeaders, gas, path, ...rest }: SuggestChainAndConnectArgs) => Promise<
|
|
215
|
-
account: Key;
|
|
216
|
-
chain: ChainInfo;
|
|
217
|
-
}>;
|
|
221
|
+
declare const suggestChainAndConnect: ({ chainInfo, rpcHeaders, gas, path, ...rest }: SuggestChainAndConnectArgs) => Promise<ConnectResult>;
|
|
218
222
|
|
|
219
223
|
interface GrazStore {
|
|
220
224
|
account: Key | null;
|
|
@@ -353,9 +357,24 @@ declare const getKeplr: () => Keplr;
|
|
|
353
357
|
* }
|
|
354
358
|
* ```
|
|
355
359
|
*
|
|
356
|
-
* @see https://docs.keplr
|
|
360
|
+
* @see https://docs.leapwallet.io/cosmos/for-dapps-connect-to-leap/add-leap-to-existing-keplr-integration
|
|
357
361
|
*/
|
|
358
362
|
declare const getLeap: () => Keplr;
|
|
363
|
+
/**
|
|
364
|
+
* Function to return cosmostation object (which is {@link Keplr}) and throws and error if it does not exist on `window`.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* try {
|
|
369
|
+
* const cosmostation = getCosmostation();
|
|
370
|
+
* } catch (error: Error) {
|
|
371
|
+
* console.error(error.message);
|
|
372
|
+
* }
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* @see https://docs.cosmostation.io/integration-extension/cosmos/integrate-keplr
|
|
376
|
+
*/
|
|
377
|
+
declare const getCosmostation: () => Keplr;
|
|
359
378
|
/**
|
|
360
379
|
* Function to return wallet object based on given {@link WalletType} or from store and throws an error if it does not
|
|
361
380
|
* exist on `window` or unknown wallet type.
|
|
@@ -397,8 +416,7 @@ interface MutationEventArgs<TInitial = unknown, TSuccess = TInitial> {
|
|
|
397
416
|
}
|
|
398
417
|
|
|
399
418
|
interface UseAccountArgs {
|
|
400
|
-
onConnect?: (args: {
|
|
401
|
-
account: Key;
|
|
419
|
+
onConnect?: (args: ConnectResult & {
|
|
402
420
|
isReconnect: boolean;
|
|
403
421
|
}) => void;
|
|
404
422
|
onDisconnect?: () => void;
|
|
@@ -422,13 +440,13 @@ interface UseAccountArgs {
|
|
|
422
440
|
* ```
|
|
423
441
|
*/
|
|
424
442
|
declare const useAccount: ({ onConnect, onDisconnect }?: UseAccountArgs) => {
|
|
425
|
-
data: Key | null;
|
|
443
|
+
data: _keplr_wallet_types.Key | null;
|
|
426
444
|
isConnected: boolean;
|
|
427
445
|
isConnecting: boolean;
|
|
428
446
|
isDisconnected: boolean;
|
|
429
447
|
isReconnecting: boolean;
|
|
430
448
|
isLoading: boolean;
|
|
431
|
-
reconnect: (args?: ReconnectArgs) => Promise<
|
|
449
|
+
reconnect: (args?: ReconnectArgs) => Promise<ConnectResult | undefined>;
|
|
432
450
|
status: "connected" | "connecting" | "reconnecting" | "disconnected";
|
|
433
451
|
};
|
|
434
452
|
/**
|
|
@@ -466,7 +484,7 @@ declare const useBalances: (bech32Address?: string) => UseQueryResult<Coin[]>;
|
|
|
466
484
|
* ```
|
|
467
485
|
*/
|
|
468
486
|
declare const useBalance: (denom: string, bech32Address?: string) => UseQueryResult<Coin | undefined>;
|
|
469
|
-
type UseConnectChainArgs = MutationEventArgs<ConnectArgs,
|
|
487
|
+
type UseConnectChainArgs = MutationEventArgs<ConnectArgs, ConnectResult>;
|
|
470
488
|
/**
|
|
471
489
|
* graz mutation hook to execute wallet connection with optional arguments to
|
|
472
490
|
* invoke given functions on error, loading, or success event.
|
|
@@ -503,7 +521,7 @@ type UseConnectChainArgs = MutationEventArgs<ConnectArgs, Key>;
|
|
|
503
521
|
*/
|
|
504
522
|
declare const useConnect: ({ onError, onLoading, onSuccess }?: UseConnectChainArgs) => {
|
|
505
523
|
connect: (args?: ConnectArgs) => void;
|
|
506
|
-
connectAsync: (args?: ConnectArgs) => Promise<
|
|
524
|
+
connectAsync: (args?: ConnectArgs) => Promise<ConnectResult>;
|
|
507
525
|
error: unknown;
|
|
508
526
|
isLoading: boolean;
|
|
509
527
|
isSuccess: boolean;
|
|
@@ -670,10 +688,7 @@ declare const useSuggestChain: ({ onError, onLoading, onSuccess }?: UseSuggestCh
|
|
|
670
688
|
suggestAsync: _tanstack_react_query.UseMutateAsyncFunction<ChainInfo, unknown, ChainInfo, unknown>;
|
|
671
689
|
status: "error" | "idle" | "loading" | "success";
|
|
672
690
|
};
|
|
673
|
-
type UseSuggestChainAndConnectArgs = MutationEventArgs<SuggestChainAndConnectArgs,
|
|
674
|
-
chain: ChainInfo;
|
|
675
|
-
account: Key;
|
|
676
|
-
}>;
|
|
691
|
+
type UseSuggestChainAndConnectArgs = MutationEventArgs<SuggestChainAndConnectArgs, ConnectResult>;
|
|
677
692
|
/**
|
|
678
693
|
* graz mutation hook to suggest chain to a Wallet and connect account
|
|
679
694
|
* afterwards
|
|
@@ -710,14 +725,8 @@ declare const useSuggestChainAndConnect: ({ onError, onLoading, onSuccess }?: Us
|
|
|
710
725
|
isSuccess: boolean;
|
|
711
726
|
isSupported: boolean;
|
|
712
727
|
status: "error" | "idle" | "loading" | "success";
|
|
713
|
-
suggestAndConnect: _tanstack_react_query.UseMutateFunction<
|
|
714
|
-
|
|
715
|
-
chain: ChainInfo;
|
|
716
|
-
}, unknown, SuggestChainAndConnectArgs, unknown>;
|
|
717
|
-
suggestAndConnectAsync: _tanstack_react_query.UseMutateAsyncFunction<{
|
|
718
|
-
account: Key;
|
|
719
|
-
chain: ChainInfo;
|
|
720
|
-
}, unknown, SuggestChainAndConnectArgs, unknown>;
|
|
728
|
+
suggestAndConnect: _tanstack_react_query.UseMutateFunction<ConnectResult, unknown, SuggestChainAndConnectArgs, unknown>;
|
|
729
|
+
suggestAndConnectAsync: _tanstack_react_query.UseMutateAsyncFunction<ConnectResult, unknown, SuggestChainAndConnectArgs, unknown>;
|
|
721
730
|
};
|
|
722
731
|
|
|
723
732
|
interface UseQueryClient {
|
|
@@ -928,19 +937,6 @@ declare const useQuerySmart: <TData, TError>(address?: string, queryMsg?: Record
|
|
|
928
937
|
*/
|
|
929
938
|
declare const useQueryRaw: <TError>(address?: string, key?: string) => UseQueryResult<Uint8Array | null, TError>;
|
|
930
939
|
|
|
931
|
-
/**
|
|
932
|
-
* graz hook which returns boolean whether Keplr Wallet is supported
|
|
933
|
-
*
|
|
934
|
-
* @example
|
|
935
|
-
* ```ts
|
|
936
|
-
* import { useCheckKeplr } from "graz";
|
|
937
|
-
*
|
|
938
|
-
* const { data: isSupported } = useCheckKeplr();
|
|
939
|
-
* ```
|
|
940
|
-
*
|
|
941
|
-
* @deprecated prefer using {@link useCheckWallet}
|
|
942
|
-
*/
|
|
943
|
-
declare const useCheckKeplr: () => UseQueryResult<boolean>;
|
|
944
940
|
/**
|
|
945
941
|
* graz query hook to check whether given {@link WalletType} or default configured wallet is supported
|
|
946
942
|
*
|
|
@@ -990,4 +986,4 @@ declare const useGrazEvents: () => null;
|
|
|
990
986
|
*/
|
|
991
987
|
declare const GrazEvents: FC;
|
|
992
988
|
|
|
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,
|
|
989
|
+
export { AccountData, ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, ConnectResult, 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, getCosmostation, getKeplr, getLeap, getQueryRaw, getQuerySmart, getRecentChain, getWallet, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useBalance, useBalanceStaked, useBalances, 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 Ve=Object.create;var D=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var $e=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Ze=(e,t)=>{for(var o in t)D(e,o,{get:t[o],enumerable:!0})},me=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Je(t))!Xe.call(e,n)&&n!==o&&D(e,n,{get:()=>t[n],enumerable:!(r=Ye(t,n))||r.enumerable});return e};var et=(e,t,o)=>(o=e!=null?Ve($e(e)):{},me(t||!e||!e.__esModule?D(o,"default",{value:e,enumerable:!0}):o,e)),tt=e=>me(D({},"__esModule",{value:!0}),e);var Xt={};Ze(Xt,{GrazEvents:()=>ue,GrazProvider:()=>$t,WALLET_TYPES:()=>G,WalletType:()=>v,checkWallet:()=>f,clearRecentChain:()=>z,configureGraz:()=>W,connect:()=>h,createClients:()=>w,createQueryClient:()=>q,createSigningClients:()=>b,defineChain:()=>wt,defineChainInfo:()=>bt,defineChains:()=>ie,disconnect:()=>T,executeContract:()=>L,getActiveChainCurrency:()=>K,getAvailableWallets:()=>ot,getBalanceStaked:()=>_,getBalances:()=>F,getKeplr:()=>ye,getLeap:()=>Ce,getQueryRaw:()=>Y,getQuerySmart:()=>V,getRecentChain:()=>st,getWallet:()=>x,instantiateContract:()=>H,mainnetChains:()=>jt,mainnetChainsArray:()=>Dt,reconnect:()=>l,sendIbcTokens:()=>N,sendTokens:()=>P,suggestChain:()=>I,suggestChainAndConnect:()=>O,testnetChains:()=>kt,testnetChainsArray:()=>Tt,useAccount:()=>d,useActiveChain:()=>qt,useActiveChainCurrency:()=>Mt,useActiveChainValidators:()=>Qt,useBalance:()=>Bt,useBalanceStaked:()=>Ut,useBalances:()=>We,useCheckKeplr:()=>It,useCheckWallet:()=>A,useClients:()=>Ft,useConnect:()=>Rt,useDisconnect:()=>vt,useExecuteContract:()=>Lt,useGrazEvents:()=>Pe,useInstantiateContract:()=>Ht,useOfflineSigners:()=>Fe,useQueryClient:()=>Wt,useQueryRaw:()=>Yt,useQuerySmart:()=>Vt,useRecentChain:()=>zt,useSendIbcTokens:()=>Nt,useSendTokens:()=>Pt,useSigners:()=>Gt,useSigningClients:()=>_t,useSuggestChain:()=>Kt,useSuggestChainAndConnect:()=>Ot});module.exports=tt(Xt);var fe=require("@cosmjs/stargate");var E="graz-reconnect-session";var le=require("zustand"),k=require("zustand/middleware");var v=(o=>(o.KEPLR="keplr",o.LEAP="leap",o))(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},nt={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=(0,le.create)((0,k.subscribeWithSelector)((0,k.persist)(()=>U,nt)));var M=require("@cosmjs/cosmwasm-stargate"),Q=require("@cosmjs/stargate"),ge=require("@cosmjs/tendermint-rpc");var de=require("@cosmjs/stargate"),C=require("@cosmjs/utils");var q=(...e)=>{let{tendermint:t}=c.getState().clients,o=new de.QueryClient(t),r=e.map(n=>n(o));for(let n of r){(0,C.assert)((0,C.isNonNullObject)(n),"Extension must be a non-null object");for(let[i,s]of Object.entries(n)){(0,C.assert)((0,C.isNonNullObject)(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let a=o[i]||{};o[i]={...a,...s}}}return o};var w=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([M.SigningCosmWasmClient.connect(o),Q.SigningStargateClient.connect(o),ge.Tendermint34Client.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},b=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...o||{}}},[a,u]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(s,r,n),Q.SigningStargateClient.connectWithSigner(s,r,i)]);return{cosmWasm:a,stargate:u}};var f=(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")}},ot=()=>Object.fromEntries(G.map(e=>[e,f(e)]));var h=async e=>{try{let{defaultChain:t,recentChain:o,walletType:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=x(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(j=>{let Le=j._reconnect||!!j._reconnectConnector||!!s;return j.activeChain&&j.activeChain.chainId!==s.chainId?{status:"connecting"}:Le?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let a=i.getOfflineSigner(s.chainId),u=i.getOfflineSignerOnlyAmino(s.chainId),p=await i.getOfflineSignerAuto(s.chainId),m=s.gas?fe.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[pe,Ne,He]=await Promise.all([i.getKey(s.chainId),w(s),b({...s,offlineSignerAuto:p,cosmWasmSignerOptions:{gasPrice:m,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:pe,activeChain:s,clients:Ne,offlineSigner:a,offlineSignerAmino:u,offlineSignerAuto:p,recentChain:s,signingClients:He,status:"connected",walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(E,"Active"),pe}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},T=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(E),c.setState(t=>({...U,recentChain:e?null:t.recentChain})),Promise.resolve()),l=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:r}=c.getState(),n=f(o||void 0);try{if(t&&n&&o)return await h({chain:t,walletType:o,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(o=>o.coinMinimalDenom===e)},st=()=>c.getState().recentChain,I=async e=>(await x().experimentalSuggestChain(e),e),O=async({chainInfo:e,rpcHeaders:t,gas:o,path:r,...n})=>{let i=await I(e);return{account:await h({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:r},...n}),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: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)},P=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)},N=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:s,fee:a,memo:u})=>{let{signingClients:p}=c.getState();if(!(p!=null&&p.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return p.stargate.sendIbcTokens(e,t,o,r,n,i,s,a,u)},H=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)},L=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)},V=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)},Y=(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)};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],$={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"},dt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},gt={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,dt,gt,yt,Ct,ft,xt,ht],X={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 Te=require("@keplr-wallet/cosmos"),Ie={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=[Ie,At],Z={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Ie,bip44:{coinType:118},bech32Config:Te.Bech32Address.defaultBech32Config("osmo"),currencies:ke,feeCurrencies:ke};var Re=require("@keplr-wallet/cosmos"),ve={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Be=[ve],ee={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:ve,bip44:{coinType:118},bech32Config:Re.Bech32Address.defaultBech32Config("somm"),currencies:Be,feeCurrencies:Be};var Ue=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"},Ge=[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:Ue.Bech32Address.defaultBech32Config("CRE"),currencies:Ge,feeCurrencies:Ge,stakeCurrency:qe,coinType:118};var Me=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"},St=[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:Me.Bech32Address.defaultBech32Config("juno"),currencies:St,feeCurrencies:[ne],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],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:Qe.Bech32Address.defaultBech32Config("osmo"),currencies:Et,feeCurrencies:[se],coinType:118};var ie=e=>e,wt=e=>e,bt=e=>e,jt=ie({axelar:J,cosmoshub:$,juno:X,osmosis:Z,sommelier:ee}),Dt=[J,$,X,Z,ee],kt=ie({crescent:te,juno:oe,osmosis:re}),Tt=[te,oe,re];var y=require("@tanstack/react-query"),Ke=require("react"),Oe=et(require("zustand/shallow"));var ze=require("@tanstack/react-query");var It=()=>A("keplr"),A=e=>{let o=["USE_CHECK_WALLET",c(n=>e||n.walletType)];return(0,ze.useQuery)(o,({queryKey:[,n]})=>f(n))};var d=({onConnect:e,onDisconnect:t}={})=>{let o=c(n=>n.account),r=c(n=>n.status);return(0,Ke.useEffect)(()=>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:!!o,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:l,status:r}},We=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return(0,y.useQuery)(["USE_BALANCES",o],({queryKey:[,i]})=>F(i),{enabled:!!o})},Bt=(e,t)=>{let{data:o}=We(t);return(0,y.useQuery)(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:!!o})},Rt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,y.useMutation)(["USE_CONNECT",e,t,o],h,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=A();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status}},vt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,y.useMutation)(["USE_DISCONNECT",e,t,o],T,{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}},Fe=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Oe.default),Gt=()=>Fe(),Ut=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return(0,y.useQuery)(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>_(o),{enabled:!!o})};var S=require("@tanstack/react-query");var qt=()=>c(e=>e.activeChain),Mt=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:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),zt=()=>({data:c(t=>t.recentChain),clear:z}),Kt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,S.useMutation)(["USE_SUGGEST_CHAIN",e,t,o],I,{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}},Ot=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,S.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],O,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=A();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};var ce=require("@tanstack/react-query");var _e=require("@tanstack/react-query");var Wt=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,_e.useQuery)(t,({queryKey:[,...r]})=>q(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var Ft=e=>{let t=c(n=>n.clients);return(0,ce.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?w(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},_t=e=>{let t=c(n=>n.signingClients);return(0,ce.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?b(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};var g=require("@tanstack/react-query");var Pt=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=(0,g.useMutation)(["USE_SEND_TOKENS",e,t,o,n],a=>P({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Nt=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=(0,g.useMutation)(["USE_SEND_IBC_TOKENS",e,t,o,n],a=>N({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},Ht=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=(0,g.useMutation)(["USE_INSTANTIATE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,codeId:e};return H(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,instantiateContract:u.mutate,instantiateContractAsync:u.mutateAsync,status:u.status}},Lt=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=(0,g.useMutation)(["USE_EXECUTE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,contractAddress:e,memo:p.memo??"",funds:p.funds??[]};return L(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,executeContract:u.mutate,executeContractAsync:u.mutateAsync,status:u.status}},Vt=(e,t)=>(0,g.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return V(e,t)},{enabled:!!e&&!!t}),Yt=(e,t)=>(0,g.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return Y(e,t)},{enabled:!!e&&!!t});var B=require("@tanstack/react-query");var ae=require("react");var Pe=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(E)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:r,_reconnectConnector:n}=c();return(0,ae.useEffect)(()=>{e&&t?l({onError:r}):!e&&o&&l({onError:r})},[]),(0,ae.useEffect)(()=>{if(n)return window.addEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r})),()=>{window.removeEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r}))}},[n]),null},ue=()=>(Pe(),null);var R=require("react/jsx-runtime"),Jt=new B.QueryClient({}),$t=({children:e,grazOptions:t,...o})=>(t&&W(t),(0,R.jsxs)(B.QueryClientProvider,{client:Jt,...o,children:[(0,R.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});
|
|
1
|
+
"use strict";var Ye=Object.create;var T=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var et=(e,t)=>{for(var o in t)T(e,o,{get:t[o],enumerable:!0})},me=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $e(t))!Ze.call(e,n)&&n!==o&&T(e,n,{get:()=>t[n],enumerable:!(r=Je(t,n))||r.enumerable});return e};var tt=(e,t,o)=>(o=e!=null?Ye(Xe(e)):{},me(t||!e||!e.__esModule?T(o,"default",{value:e,enumerable:!0}):o,e)),nt=e=>me(T({},"__esModule",{value:!0}),e);var Xt={};et(Xt,{GrazEvents:()=>ue,GrazProvider:()=>$t,WALLET_TYPES:()=>G,WalletType:()=>v,checkWallet:()=>f,clearRecentChain:()=>z,configureGraz:()=>F,connect:()=>h,createClients:()=>E,createQueryClient:()=>q,createSigningClients:()=>w,defineChain:()=>bt,defineChainInfo:()=>jt,defineChains:()=>ie,disconnect:()=>k,executeContract:()=>L,getActiveChainCurrency:()=>Q,getAvailableWallets:()=>st,getBalanceStaked:()=>_,getBalances:()=>K,getCosmostation:()=>fe,getKeplr:()=>ye,getLeap:()=>Ce,getQueryRaw:()=>Y,getQuerySmart:()=>V,getRecentChain:()=>rt,getWallet:()=>x,instantiateContract:()=>H,mainnetChains:()=>Tt,mainnetChainsArray:()=>Dt,reconnect:()=>l,sendIbcTokens:()=>N,sendTokens:()=>P,suggestChain:()=>I,suggestChainAndConnect:()=>W,testnetChains:()=>kt,testnetChainsArray:()=>It,useAccount:()=>d,useActiveChain:()=>qt,useActiveChainCurrency:()=>Mt,useActiveChainValidators:()=>Ot,useBalance:()=>Rt,useBalanceStaked:()=>Ut,useBalances:()=>Ke,useCheckWallet:()=>b,useClients:()=>Kt,useConnect:()=>Bt,useDisconnect:()=>vt,useExecuteContract:()=>Lt,useGrazEvents:()=>Ne,useInstantiateContract:()=>Ht,useOfflineSigners:()=>_e,useQueryClient:()=>Ft,useQueryRaw:()=>Yt,useQuerySmart:()=>Vt,useRecentChain:()=>zt,useSendIbcTokens:()=>Nt,useSendTokens:()=>Pt,useSigners:()=>Gt,useSigningClients:()=>_t,useSuggestChain:()=>Qt,useSuggestChainAndConnect:()=>Wt});module.exports=nt(Xt);var xe=require("@cosmjs/stargate");var S="graz-reconnect-session";var le=require("zustand"),D=require("zustand/middleware");var v=(r=>(r.KEPLR="keplr",r.LEAP="leap",r.COSMOSTATION="cosmostation",r))(v||{}),G=["keplr","leap","cosmostation"];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,le.create)((0,D.subscribeWithSelector)((0,D.persist)(()=>U,ot)));var M=require("@cosmjs/cosmwasm-stargate"),O=require("@cosmjs/stargate"),ge=require("@cosmjs/tendermint-rpc");var de=require("@cosmjs/stargate"),C=require("@cosmjs/utils");var q=(...e)=>{let{tendermint:t}=c.getState().clients,o=new de.QueryClient(t),r=e.map(n=>n(o));for(let n of r){(0,C.assert)((0,C.isNonNullObject)(n),"Extension must be a non-null object");for(let[i,s]of Object.entries(n)){(0,C.assert)((0,C.isNonNullObject)(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let a=o[i]||{};o[i]={...a,...s}}}return o};var E=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([M.SigningCosmWasmClient.connect(o),O.SigningStargateClient.connect(o),ge.Tendermint34Client.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},w=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...o||{}}},[a,u]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(s,r,n),O.SigningStargateClient.connectWithSigner(s,r,i)]);return{cosmWasm:a,stargate:u}};var f=(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")},fe=()=>{if(typeof window.cosmostation.providers.keplr<"u")return window.cosmostation.providers.keplr;throw c.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")},x=(e=c.getState().walletType)=>{switch(e){case"keplr":return ye();case"leap":return Ce();case"cosmostation":return fe();default:throw new Error("Unknown wallet type")}},st=()=>Object.fromEntries(G.map(e=>[e,f(e)]));var h=async e=>{try{let{defaultChain:t,recentChain:o,walletType:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=x(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(j=>{let Ve=j._reconnect||!!j._reconnectConnector||!!s;return j.activeChain&&j.activeChain.chainId!==s.chainId?{status:"connecting"}:Ve?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let a=i.getOfflineSigner(s.chainId),u=i.getOfflineSignerOnlyAmino(s.chainId),p=await i.getOfflineSignerAuto(s.chainId),m=s.gas?xe.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[pe,He,Le]=await Promise.all([i.getKey(s.chainId),E(s),w({...s,offlineSignerAuto:p,cosmWasmSignerOptions:{gasPrice:m,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:pe,activeChain:s,clients:He,offlineSigner:a,offlineSignerAmino:u,offlineSignerAuto:p,recentChain:s,signingClients:Le,status:"connected",walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(S,"Active"),{account:pe,walletType:n,chain:s}}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},k=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(S),c.setState(t=>({...U,recentChain:e?null:t.recentChain})),Promise.resolve()),l=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:r}=c.getState(),n=f(o||void 0);try{if(t&&n&&o)return await h({chain:t,walletType:o,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),k()}};var z=()=>{c.setState({recentChain:null})},Q=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(o=>o.coinMinimalDenom===e)},rt=()=>c.getState().recentChain,I=async e=>(await x().experimentalSuggestChain(e),e),W=async({chainInfo:e,rpcHeaders:t,gas:o,path:r,...n})=>{let i=await I(e);return{...await h({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:r},...n}),chain:i}};var F=(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 K=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)},P=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)},N=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:s,fee:a,memo:u})=>{let{signingClients:p}=c.getState();if(!(p!=null&&p.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return p.stargate.sendIbcTokens(e,t,o,r,n,i,s,a,u)},H=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)},L=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)},V=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)},Y=(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)};var Ae=require("@keplr-wallet/cosmos"),Se={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"},he=[Se,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:Se,bip44:{coinType:118},bech32Config:Ae.Bech32Address.defaultBech32Config("axelar"),currencies:he,feeCurrencies:he};var we=require("@keplr-wallet/cosmos"),be={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ee=[be],$={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:be,bip44:{coinType:118},bech32Config:we.Bech32Address.defaultBech32Config("cosmos"),currencies:Ee,feeCurrencies:Ee};var Te=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"},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"},je=[De,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:De,bip44:{coinType:118},bech32Config:Te.Bech32Address.defaultBech32Config("juno"),currencies:je,feeCurrencies:je};var Ie=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"},ke=[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:Ie.Bech32Address.defaultBech32Config("osmo"),currencies:ke,feeCurrencies:ke};var ve=require("@keplr-wallet/cosmos"),Ge={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Be=[Ge],ee={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Ge,bip44:{coinType:118},bech32Config:ve.Bech32Address.defaultBech32Config("somm"),currencies:Be,feeCurrencies:Be};var qe=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"},Ue=[Me],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:qe.Bech32Address.defaultBech32Config("CRE"),currencies:Ue,feeCurrencies:Ue,stakeCurrency:Me,coinType:118};var Oe=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:Oe.Bech32Address.defaultBech32Config("juno"),currencies:Et,feeCurrencies:[ne],coinType:118};var ze=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:ze.Bech32Address.defaultBech32Config("osmo"),currencies:wt,feeCurrencies:[se],coinType:118};var ie=e=>e,bt=e=>e,jt=e=>e,Tt=ie({axelar:J,cosmoshub:$,juno:X,osmosis:Z,sommelier:ee}),Dt=[J,$,X,Z,ee],kt=ie({crescent:te,juno:oe,osmosis:re}),It=[te,oe,re];var y=require("@tanstack/react-query"),We=require("react"),Fe=tt(require("zustand/shallow"));var Qe=require("@tanstack/react-query");var b=e=>{let o=["USE_CHECK_WALLET",c(n=>e||n.walletType)];return(0,Qe.useQuery)(o,({queryKey:[,n]})=>f(n))};var d=({onConnect:e,onDisconnect:t}={})=>{let o=c(n=>n.account),r=c(n=>n.status);return(0,We.useEffect)(()=>c.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let s=c.getState();e==null||e({account:s.account,chain:s.activeChain,walletType:s.walletType,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:!!o,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:l,status:r}},Ke=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return(0,y.useQuery)(["USE_BALANCES",o],({queryKey:[,i]})=>K(i),{enabled:!!o})},Rt=(e,t)=>{let{data:o}=Ke(t);return(0,y.useQuery)(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:!!o})},Bt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,y.useMutation)(["USE_CONNECT",e,t,o],h,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=b();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status}},vt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,y.useMutation)(["USE_DISCONNECT",e,t,o],k,{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}},_e=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Fe.default),Gt=()=>_e(),Ut=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return(0,y.useQuery)(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>_(o),{enabled:!!o})};var A=require("@tanstack/react-query");var qt=()=>c(e=>e.activeChain),Mt=e=>(0,A.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>Q(r)),Ot=(e,t="BOND_STATUS_BONDED")=>(0,A.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),zt=()=>({data:c(t=>t.recentChain),clear:z}),Qt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,A.useMutation)(["USE_SUGGEST_CHAIN",e,t,o],I,{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}},Wt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,A.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],W,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=b();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};var ce=require("@tanstack/react-query");var Pe=require("@tanstack/react-query");var Ft=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,Pe.useQuery)(t,({queryKey:[,...r]})=>q(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var Kt=e=>{let t=c(n=>n.clients);return(0,ce.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?E(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},_t=e=>{let t=c(n=>n.signingClients);return(0,ce.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?w(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};var g=require("@tanstack/react-query");var Pt=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=(0,g.useMutation)(["USE_SEND_TOKENS",e,t,o,n],a=>P({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Nt=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=(0,g.useMutation)(["USE_SEND_IBC_TOKENS",e,t,o,n],a=>N({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},Ht=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=(0,g.useMutation)(["USE_INSTANTIATE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,codeId:e};return H(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,instantiateContract:u.mutate,instantiateContractAsync:u.mutateAsync,status:u.status}},Lt=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=(0,g.useMutation)(["USE_EXECUTE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,contractAddress:e,memo:p.memo??"",funds:p.funds??[]};return L(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,executeContract:u.mutate,executeContractAsync:u.mutateAsync,status:u.status}},Vt=(e,t)=>(0,g.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return V(e,t)},{enabled:!!e&&!!t}),Yt=(e,t)=>(0,g.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return Y(e,t)},{enabled:!!e&&!!t});var R=require("@tanstack/react-query");var ae=require("react");var Ne=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(S)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:r,_reconnectConnector:n}=c();return(0,ae.useEffect)(()=>{e&&t?l({onError:r}):!e&&o&&l({onError:r})},[]),(0,ae.useEffect)(()=>{if(n&&(n==="cosmostation"&&window.cosmostation.cosmos.on("accountChanged",()=>void l({onError:r})),n==="keplr"||n==="leap"))return window.addEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r})),()=>{window.removeEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r}))}},[n]),null},ue=()=>(Ne(),null);var B=require("react/jsx-runtime"),Jt=new R.QueryClient({}),$t=({children:e,grazOptions:t,...o})=>(t&&F(t),(0,B.jsxs)(R.QueryClientProvider,{client:Jt,...o,children:[(0,B.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,getCosmostation,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalanceStaked,useBalances,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{a as g}from"./chunk-V3YUCPIG.mjs";import{GasPrice as Ue}from"@cosmjs/stargate";import{create as De}from"zustand";import{persist as ke,subscribeWithSelector as Te}from"zustand/middleware";var z=(o=>(o.KEPLR="keplr",o.LEAP="leap",o))(z||{}),K=["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,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Ie={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=De(Te(ke(()=>w,Ie)));import{SigningCosmWasmClient as _}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as P}from"@cosmjs/stargate";import{Tendermint34Client as Re}from"@cosmjs/tendermint-rpc";import{QueryClient as Be}from"@cosmjs/stargate";import{assert as W,isNonNullObject as O}from"@cosmjs/utils";var F=(...e)=>{let{tendermint:t}=c.getState().clients,o=new Be(t),r=e.map(n=>n(o));for(let n of r){W(O(n),"Extension must be a non-null object");for(let[i,s]of Object.entries(n)){W(O(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let a=o[i]||{};o[i]={...a,...s}}}return o};var A=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([_.connect(o),P.connect(o),Re.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},S=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...o||{}}},[a,u]=await Promise.all([_.connectWithSigner(s,r,n),P.connectWithSigner(s,r,i)]);return{cosmWasm:a,stargate:u}};var y=(e=c.getState().walletType)=>{try{return C(e),!0}catch(t){return console.error(t),!1}},ve=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ge=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},C=(e=c.getState().walletType)=>{switch(e){case"keplr":return ve();case"leap":return Ge();default:throw new Error("Unknown wallet type")}},qt=()=>Object.fromEntries(K.map(e=>[e,y(e)]));var f=async e=>{try{let{defaultChain:t,recentChain:o,walletType:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=C(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(h=>{let je=h._reconnect||!!h._reconnectConnector||!!s;return h.activeChain&&h.activeChain.chainId!==s.chainId?{status:"connecting"}:je?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let a=i.getOfflineSigner(s.chainId),u=i.getOfflineSignerOnlyAmino(s.chainId),p=await i.getOfflineSignerAuto(s.chainId),m=s.gas?Ue.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[Q,we,be]=await Promise.all([i.getKey(s.chainId),A(s),S({...s,offlineSignerAuto:p,cosmWasmSignerOptions:{gasPrice:m,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:Q,activeChain:s,clients:we,offlineSigner:a,offlineSignerAmino:u,offlineSignerAuto:p,recentChain:s,signingClients:be,status:"connected",walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(g,"Active"),Q}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},b=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(g),c.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()),l=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:r}=c.getState(),n=y(o||void 0);try{if(t&&n&&o)return await f({chain:t,walletType:o,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),b()}};var N=()=>{c.setState({recentChain:null})},H=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(o=>o.coinMinimalDenom===e)},Ht=()=>c.getState().recentChain,j=async e=>(await C().experimentalSuggestChain(e),e),L=async({chainInfo:e,rpcHeaders:t,gas:o,path:r,...n})=>{let i=await j(e);return{account:await f({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:r},...n}),chain:i}};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,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var Y=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)}))},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: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)},X=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:s,fee:a,memo:u})=>{let{signingClients:p}=c.getState();if(!(p!=null&&p.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return p.stargate.sendIbcTokens(e,t,o,r,n,i,s,a,u)},Z=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)},ee=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)},te=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)},ne=(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 qe}from"@keplr-wallet/cosmos";var se={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"},Qe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ze={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Ke={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},We={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},oe=[se,Me,Qe,ze,Ke,We],D={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:se,bip44:{coinType:118},bech32Config:qe.defaultBech32Config("axelar"),currencies:oe,feeCurrencies:oe};import{Bech32Address as Oe}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],k={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ie,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("cosmos"),currencies:re,feeCurrencies:re};import{Bech32Address as Fe}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"},_e={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"},He={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Le={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ve={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ye={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Je={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},$e={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Xe={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ce=[ae,_e,Pe,Ne,He,Le,Ve,Ye,Je,$e,Xe],T={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ae,bip44:{coinType:118},bech32Config:Fe.defaultBech32Config("juno"),currencies:ce,feeCurrencies:ce};import{Bech32Address as Ze}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"},et={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ue=[pe,et],I={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:pe,bip44:{coinType:118},bech32Config:Ze.defaultBech32Config("osmo"),currencies:ue,feeCurrencies:ue};import{Bech32Address as tt}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],B={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:le,bip44:{coinType:118},bech32Config:tt.defaultBech32Config("somm"),currencies:me,feeCurrencies:me};import{Bech32Address as nt}from"@keplr-wallet/cosmos";var ge={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},de=[ge],R={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:nt.defaultBech32Config("CRE"),currencies:de,feeCurrencies:de,stakeCurrency:ge,coinType:118};import{Bech32Address as ot}from"@keplr-wallet/cosmos";var v={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},st=[v],G={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:v,bip44:{coinType:118},bech32Config:ot.defaultBech32Config("juno"),currencies:st,feeCurrencies:[v],coinType:118};import{Bech32Address as rt}from"@keplr-wallet/cosmos";var U={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},it=[U],q={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:U,bip44:{coinType:118},bech32Config:rt.defaultBech32Config("osmo"),currencies:it,feeCurrencies:[U],coinType:118};var ye=e=>e,bn=e=>e,jn=e=>e,Dn=ye({axelar:D,cosmoshub:k,juno:T,osmosis:I,sommelier:B}),kn=[D,k,T,I,B],Tn=ye({crescent:R,juno:G,osmosis:q}),In=[R,G,q];import{useMutation as Ce,useQuery as M}from"@tanstack/react-query";import{useEffect as at}from"react";import ut from"zustand/shallow";import{useQuery as ct}from"@tanstack/react-query";var Un=()=>x("keplr"),x=e=>{let o=["USE_CHECK_WALLET",c(n=>e||n.walletType)];return ct(o,({queryKey:[,n]})=>y(n))};var d=({onConnect:e,onDisconnect:t}={})=>{let o=c(n=>n.account),r=c(n=>n.status);return at(()=>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:!!o,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:l,status:r}},pt=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCES",o],({queryKey:[,i]})=>Y(i),{enabled:!!o})},_n=(e,t)=>{let{data:o}=pt(t);return M(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:!!o})},Pn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=Ce(["USE_CONNECT",e,t,o],f,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=x();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status}},Nn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=Ce(["USE_DISCONNECT",e,t,o],b,{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}},mt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),ut),Hn=()=>mt(),Ln=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>J(o),{enabled:!!o})};import{useMutation as fe,useQuery as xe}from"@tanstack/react-query";var Zn=()=>c(e=>e.activeChain),eo=e=>xe(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>H(r)),to=(e,t="BOND_STATUS_BONDED")=>xe(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),no=()=>({data:c(t=>t.recentChain),clear:N}),oo=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_SUGGEST_CHAIN",e,t,o],j,{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}},so=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],L,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=x();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};import{useQuery as he}from"@tanstack/react-query";import{useQuery as lt}from"@tanstack/react-query";var ao=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return lt(t,({queryKey:[,...r]})=>F(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var go=e=>{let t=c(n=>n.clients);return he(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?A(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},yo=e=>{let t=c(n=>n.signingClients);return he(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?S(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};import{useMutation as E,useQuery as Ae}from"@tanstack/react-query";var So=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=E(["USE_SEND_TOKENS",e,t,o,n],a=>$({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Eo=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=E(["USE_SEND_IBC_TOKENS",e,t,o,n],a=>X({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},wo=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=E(["USE_INSTANTIATE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,codeId:e};return Z(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,instantiateContract:u.mutate,instantiateContractAsync:u.mutateAsync,status:u.status}},bo=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=E(["USE_EXECUTE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,contractAddress:e,memo:p.memo??"",funds:p.funds??[]};return ee(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,executeContract:u.mutate,executeContractAsync:u.mutateAsync,status:u.status}},jo=(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:!!e&&!!t}),Do=(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:!!e&&!!t});import{QueryClient as gt,QueryClientProvider as yt}from"@tanstack/react-query";import{useEffect as Se}from"react";var dt=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(g)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:r,_reconnectConnector:n}=c();return Se(()=>{e&&t?l({onError:r}):!e&&o&&l({onError:r})},[]),Se(()=>{if(n)return window.addEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r})),()=>{window.removeEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r}))}},[n]),null},Ee=()=>(dt(),null);import{jsx as ft,jsxs as xt}from"react/jsx-runtime";var Ct=new gt({}),Mo=({children:e,grazOptions:t,...o})=>(t&&V(t),xt(yt,{client:Ct,...o,children:[ft(Ee,{}),e]}));export{Ee as GrazEvents,Mo as GrazProvider,K as WALLET_TYPES,z as WalletType,y as checkWallet,N as clearRecentChain,V as configureGraz,f as connect,A as createClients,F as createQueryClient,S as createSigningClients,bn as defineChain,jn as defineChainInfo,ye as defineChains,b as disconnect,ee as executeContract,H as getActiveChainCurrency,qt as getAvailableWallets,J as getBalanceStaked,Y as getBalances,ve as getKeplr,Ge as getLeap,ne as getQueryRaw,te as getQuerySmart,Ht as getRecentChain,C as getWallet,Z as instantiateContract,Dn as mainnetChains,kn as mainnetChainsArray,l as reconnect,X as sendIbcTokens,$ as sendTokens,j as suggestChain,L as suggestChainAndConnect,Tn as testnetChains,In as testnetChainsArray,d as useAccount,Zn as useActiveChain,eo as useActiveChainCurrency,to as useActiveChainValidators,_n as useBalance,Ln as useBalanceStaked,pt as useBalances,Un as useCheckKeplr,x as useCheckWallet,go as useClients,Pn as useConnect,Nn as useDisconnect,bo as useExecuteContract,dt as useGrazEvents,wo as useInstantiateContract,mt as useOfflineSigners,ao as useQueryClient,Do as useQueryRaw,jo as useQuerySmart,no as useRecentChain,Eo as useSendIbcTokens,So as useSendTokens,Hn as useSigners,yo as useSigningClients,oo as useSuggestChain,so as useSuggestChainAndConnect};
|
|
1
|
+
import{a as g}from"./chunk-V3YUCPIG.mjs";import{GasPrice as qe}from"@cosmjs/stargate";import{create as Te}from"zustand";import{persist as De,subscribeWithSelector as ke}from"zustand/middleware";var z=(r=>(r.KEPLR="keplr",r.LEAP="leap",r.COSMOSTATION="cosmostation",r))(z||{}),Q=["keplr","leap","cosmostation"];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,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Ie={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=Te(ke(De(()=>w,Ie)));import{SigningCosmWasmClient as _}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as P}from"@cosmjs/stargate";import{Tendermint34Client as Be}from"@cosmjs/tendermint-rpc";import{QueryClient as Re}from"@cosmjs/stargate";import{assert as W,isNonNullObject as F}from"@cosmjs/utils";var K=(...e)=>{let{tendermint:t}=c.getState().clients,o=new Re(t),r=e.map(n=>n(o));for(let n of r){W(F(n),"Extension must be a non-null object");for(let[i,s]of Object.entries(n)){W(F(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let a=o[i]||{};o[i]={...a,...s}}}return o};var h=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([_.connect(o),P.connect(o),Be.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},A=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...o||{}}},[a,u]=await Promise.all([_.connectWithSigner(s,r,n),P.connectWithSigner(s,r,i)]);return{cosmWasm:a,stargate:u}};var y=(e=c.getState().walletType)=>{try{return C(e),!0}catch(t){return console.error(t),!1}},ve=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ge=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},Ue=()=>{if(typeof window.cosmostation.providers.keplr<"u")return window.cosmostation.providers.keplr;throw c.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")},C=(e=c.getState().walletType)=>{switch(e){case"keplr":return ve();case"leap":return Ge();case"cosmostation":return Ue();default:throw new Error("Unknown wallet type")}},Mt=()=>Object.fromEntries(Q.map(e=>[e,y(e)]));var f=async e=>{try{let{defaultChain:t,recentChain:o,walletType:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=C(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(x=>{let je=x._reconnect||!!x._reconnectConnector||!!s;return x.activeChain&&x.activeChain.chainId!==s.chainId?{status:"connecting"}:je?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let a=i.getOfflineSigner(s.chainId),u=i.getOfflineSignerOnlyAmino(s.chainId),p=await i.getOfflineSignerAuto(s.chainId),m=s.gas?qe.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[O,we,be]=await Promise.all([i.getKey(s.chainId),h(s),A({...s,offlineSignerAuto:p,cosmWasmSignerOptions:{gasPrice:m,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:O,activeChain:s,clients:we,offlineSigner:a,offlineSignerAmino:u,offlineSignerAuto:p,recentChain:s,signingClients:be,status:"connected",walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(g,"Active"),{account:O,walletType:n,chain:s}}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},b=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(g),c.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()),l=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:r}=c.getState(),n=y(o||void 0);try{if(t&&n&&o)return await f({chain:t,walletType:o,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),b()}};var N=()=>{c.setState({recentChain:null})},H=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(o=>o.coinMinimalDenom===e)},Lt=()=>c.getState().recentChain,j=async e=>(await C().experimentalSuggestChain(e),e),L=async({chainInfo:e,rpcHeaders:t,gas:o,path:r,...n})=>{let i=await j(e);return{...await f({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:r},...n}),chain:i}};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,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var Y=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)}))},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: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)},X=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:s,fee:a,memo:u})=>{let{signingClients:p}=c.getState();if(!(p!=null&&p.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return p.stargate.sendIbcTokens(e,t,o,r,n,i,s,a,u)},Z=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)},ee=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)},te=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)},ne=(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 se={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Oe={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"},Qe={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"},Fe={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},oe=[se,Oe,ze,Qe,We,Fe],T={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:se,bip44:{coinType:118},bech32Config:Me.defaultBech32Config("axelar"),currencies:oe,feeCurrencies:oe};import{Bech32Address as Ke}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],D={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ie,bip44:{coinType:118},bech32Config:Ke.defaultBech32Config("cosmos"),currencies:re,feeCurrencies:re};import{Bech32Address as _e}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"},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"},ce=[ae,Pe,Ne,He,Le,Ve,Ye,Je,$e,Xe,Ze],k={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ae,bip44:{coinType:118},bech32Config:_e.defaultBech32Config("juno"),currencies:ce,feeCurrencies:ce};import{Bech32Address as et}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"},tt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ue=[pe,tt],I={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:pe,bip44:{coinType:118},bech32Config:et.defaultBech32Config("osmo"),currencies:ue,feeCurrencies:ue};import{Bech32Address as nt}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],R={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:le,bip44:{coinType:118},bech32Config:nt.defaultBech32Config("somm"),currencies:me,feeCurrencies:me};import{Bech32Address as ot}from"@keplr-wallet/cosmos";var ge={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},de=[ge],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:ot.defaultBech32Config("CRE"),currencies:de,feeCurrencies:de,stakeCurrency:ge,coinType:118};import{Bech32Address as st}from"@keplr-wallet/cosmos";var v={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},rt=[v],G={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:v,bip44:{coinType:118},bech32Config:st.defaultBech32Config("juno"),currencies:rt,feeCurrencies:[v],coinType:118};import{Bech32Address as it}from"@keplr-wallet/cosmos";var U={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},ct=[U],q={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:U,bip44:{coinType:118},bech32Config:it.defaultBech32Config("osmo"),currencies:ct,feeCurrencies:[U],coinType:118};var ye=e=>e,jn=e=>e,Tn=e=>e,Dn=ye({axelar:T,cosmoshub:D,juno:k,osmosis:I,sommelier:R}),kn=[T,D,k,I,R],In=ye({crescent:B,juno:G,osmosis:q}),Rn=[B,G,q];import{useMutation as Ce,useQuery as M}from"@tanstack/react-query";import{useEffect as ut}from"react";import pt from"zustand/shallow";import{useQuery as at}from"@tanstack/react-query";var S=e=>{let o=["USE_CHECK_WALLET",c(n=>e||n.walletType)];return at(o,({queryKey:[,n]})=>y(n))};var d=({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,chain:s.activeChain,walletType:s.walletType,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:!!o,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:l,status:r}},mt=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCES",o],({queryKey:[,i]})=>Y(i),{enabled:!!o})},_n=(e,t)=>{let{data:o}=mt(t);return M(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:!!o})},Pn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=Ce(["USE_CONNECT",e,t,o],f,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=S();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status}},Nn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=Ce(["USE_DISCONNECT",e,t,o],b,{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),Hn=()=>lt(),Ln=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>J(o),{enabled:!!o})};import{useMutation as fe,useQuery as xe}from"@tanstack/react-query";var Zn=()=>c(e=>e.activeChain),eo=e=>xe(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>H(r)),to=(e,t="BOND_STATUS_BONDED")=>xe(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),no=()=>({data:c(t=>t.recentChain),clear:N}),oo=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_SUGGEST_CHAIN",e,t,o],j,{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}},so=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],L,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=S();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};import{useQuery as he}from"@tanstack/react-query";import{useQuery as dt}from"@tanstack/react-query";var ao=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return dt(t,({queryKey:[,...r]})=>K(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var go=e=>{let t=c(n=>n.clients);return he(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?h(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},yo=e=>{let t=c(n=>n.signingClients);return he(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?A(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};import{useMutation as E,useQuery as Ae}from"@tanstack/react-query";var So=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=E(["USE_SEND_TOKENS",e,t,o,n],a=>$({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Eo=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=E(["USE_SEND_IBC_TOKENS",e,t,o,n],a=>X({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},wo=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=E(["USE_INSTANTIATE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,codeId:e};return Z(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,instantiateContract:u.mutate,instantiateContractAsync:u.mutateAsync,status:u.status}},bo=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=E(["USE_EXECUTE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,contractAddress:e,memo:p.memo??"",funds:p.funds??[]};return ee(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,executeContract:u.mutate,executeContractAsync:u.mutateAsync,status:u.status}},jo=(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:!!e&&!!t}),To=(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:!!e&&!!t});import{QueryClient as yt,QueryClientProvider as Ct}from"@tanstack/react-query";import{useEffect as Se}from"react";var gt=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(g)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:r,_reconnectConnector:n}=c();return Se(()=>{e&&t?l({onError:r}):!e&&o&&l({onError:r})},[]),Se(()=>{if(n&&(n==="cosmostation"&&window.cosmostation.cosmos.on("accountChanged",()=>void l({onError:r})),n==="keplr"||n==="leap"))return window.addEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r})),()=>{window.removeEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r}))}},[n]),null},Ee=()=>(gt(),null);import{jsx as xt,jsxs as ht}from"react/jsx-runtime";var ft=new yt({}),Mo=({children:e,grazOptions:t,...o})=>(t&&V(t),ht(Ct,{client:ft,...o,children:[xt(Ee,{}),e]}));export{Ee as GrazEvents,Mo as GrazProvider,Q as WALLET_TYPES,z as WalletType,y as checkWallet,N as clearRecentChain,V as configureGraz,f as connect,h as createClients,K as createQueryClient,A as createSigningClients,jn as defineChain,Tn as defineChainInfo,ye as defineChains,b as disconnect,ee as executeContract,H as getActiveChainCurrency,Mt as getAvailableWallets,J as getBalanceStaked,Y as getBalances,Ue as getCosmostation,ve as getKeplr,Ge as getLeap,ne as getQueryRaw,te as getQuerySmart,Lt as getRecentChain,C as getWallet,Z as instantiateContract,Dn as mainnetChains,kn as mainnetChainsArray,l as reconnect,X as sendIbcTokens,$ as sendTokens,j as suggestChain,L as suggestChainAndConnect,In as testnetChains,Rn as testnetChainsArray,d as useAccount,Zn as useActiveChain,eo as useActiveChainCurrency,to as useActiveChainValidators,_n as useBalance,Ln as useBalanceStaked,mt as useBalances,S as useCheckWallet,go as useClients,Pn as useConnect,Nn as useDisconnect,bo as useExecuteContract,gt as useGrazEvents,wo as useInstantiateContract,lt as useOfflineSigners,ao as useQueryClient,To as useQueryRaw,jo as useQuerySmart,no as useRecentChain,Eo as useSendIbcTokens,So as useSendTokens,Hn as useSigners,yo as useSigningClients,oo as useSuggestChain,so 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.
|
|
4
|
+
"version": "0.0.41",
|
|
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",
|