graz 0.0.34 → 0.0.36
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/cli.mjs +14 -3
- package/dist/chunk-ETISV7IF.mjs +1 -0
- package/dist/constant.d.ts +3 -0
- package/dist/constant.js +1 -0
- package/dist/constant.mjs +1 -0
- package/dist/index.d.ts +37 -164
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -3
package/cli.mjs
CHANGED
|
@@ -9,6 +9,17 @@ import { fileURLToPath } from "url";
|
|
|
9
9
|
|
|
10
10
|
import pmap from "./compiled/p-map/index.mjs";
|
|
11
11
|
|
|
12
|
+
function isNumber(char) {
|
|
13
|
+
return /^\d+$/.test(char);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function chainNaming(name) {
|
|
17
|
+
if (isNumber(name[0])) {
|
|
18
|
+
return `_${name}`;
|
|
19
|
+
}
|
|
20
|
+
return name;
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
const HELP_MESSAGE = `Usage: graz [options]
|
|
13
24
|
|
|
14
25
|
Options:
|
|
@@ -119,7 +130,7 @@ function chainsDir(...args) {
|
|
|
119
130
|
*/
|
|
120
131
|
function makeChainMap(record, { testnet = false } = {}) {
|
|
121
132
|
return Object.keys(record)
|
|
122
|
-
.map((k) => ` ${k}: ${k}
|
|
133
|
+
.map((k) => ` ${chainNaming(k)}: ${chainNaming(k)},`)
|
|
123
134
|
.join("\n");
|
|
124
135
|
}
|
|
125
136
|
|
|
@@ -130,7 +141,7 @@ function makeChainMap(record, { testnet = false } = {}) {
|
|
|
130
141
|
function makeDefs(record, { mjs = false, testnet = false } = {}) {
|
|
131
142
|
return Object.entries(record)
|
|
132
143
|
.map(([k, v]) => {
|
|
133
|
-
const jsVariable = `${k}
|
|
144
|
+
const jsVariable = `${chainNaming(k)}`;
|
|
134
145
|
const jsChainInfo = JSON.stringify(v, null, 2);
|
|
135
146
|
return `${mjs ? "export " : ""}const ${jsVariable} = defineChainInfo(${jsChainInfo});\n`;
|
|
136
147
|
})
|
|
@@ -143,7 +154,7 @@ function makeDefs(record, { mjs = false, testnet = false } = {}) {
|
|
|
143
154
|
*/
|
|
144
155
|
function makeExports(record, { testnet = false } = {}) {
|
|
145
156
|
return Object.keys(record)
|
|
146
|
-
.map((k) => ` ${k}
|
|
157
|
+
.map((k) => ` ${chainNaming(k)},`)
|
|
147
158
|
.join("\n");
|
|
148
159
|
}
|
|
149
160
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n="graz-reconnect-session";export{n as a};
|
package/dist/constant.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var E=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var S=(n,e)=>{for(var s in e)E(n,s,{get:e[s],enumerable:!0})},C=(n,e,s,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of t(e))!N.call(n,o)&&o!==s&&E(n,o,{get:()=>e[o],enumerable:!(c=r(e,o))||c.enumerable});return n};var O=n=>C(E({},"__esModule",{value:!0}),n);var a={};S(a,{RECONNECT_SESSION_KEY:()=>_});module.exports=O(a);var _="graz-reconnect-session";0&&(module.exports={RECONNECT_SESSION_KEY});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-ETISV7IF.mjs";export{a as RECONNECT_SESSION_KEY};
|
package/dist/index.d.ts
CHANGED
|
@@ -105,12 +105,13 @@ declare const defineChainInfo: <T extends ChainInfoWithPath | ChainInfo>(chain:
|
|
|
105
105
|
* connect(mainnetChains.cosmos);
|
|
106
106
|
* ```
|
|
107
107
|
*
|
|
108
|
+
* Try graz cli to generate ChainInfo from https://cosmos.directory/
|
|
109
|
+
* @see https://graz.strange.love/docs/generate-chain-info
|
|
110
|
+
*
|
|
108
111
|
* @see {@link testnetChains}
|
|
109
112
|
*/
|
|
110
113
|
declare const mainnetChains: {
|
|
111
114
|
axelar: ChainInfo;
|
|
112
|
-
/** @deprecated kept for compatibilty purposes; change to `mainnetChains.cosmoshub` */
|
|
113
|
-
cosmos: ChainInfo;
|
|
114
115
|
cosmoshub: ChainInfo;
|
|
115
116
|
juno: ChainInfo;
|
|
116
117
|
osmosis: ChainInfo;
|
|
@@ -119,6 +120,9 @@ declare const mainnetChains: {
|
|
|
119
120
|
/**
|
|
120
121
|
* Arary version on {@link mainnetChains}
|
|
121
122
|
*
|
|
123
|
+
* Try graz cli to generate ChainInfo from https://cosmos.directory/
|
|
124
|
+
* @see https://graz.strange.love/docs/generate-chain-info
|
|
125
|
+
*
|
|
122
126
|
* @see {@link mainnetChains}
|
|
123
127
|
*/
|
|
124
128
|
declare const mainnetChainsArray: ChainInfo[];
|
|
@@ -131,6 +135,9 @@ declare const mainnetChainsArray: ChainInfo[];
|
|
|
131
135
|
* connect(testnetChains.osmosis);
|
|
132
136
|
* ```
|
|
133
137
|
*
|
|
138
|
+
* Try graz cli to generate ChainInfo from https://cosmos.directory/
|
|
139
|
+
* @see https://graz.strange.love/docs/generate-chain-info
|
|
140
|
+
*
|
|
134
141
|
* @see {@link mainnetChains}
|
|
135
142
|
*/
|
|
136
143
|
declare const testnetChains: {
|
|
@@ -141,6 +148,9 @@ declare const testnetChains: {
|
|
|
141
148
|
/**
|
|
142
149
|
* Arary version on {@link testnetChains}
|
|
143
150
|
*
|
|
151
|
+
* Try graz cli to generate ChainInfo from https://cosmos.directory/
|
|
152
|
+
* @see https://graz.strange.love/docs/generate-chain-info
|
|
153
|
+
*
|
|
144
154
|
* @see {@link testnetChains}
|
|
145
155
|
*/
|
|
146
156
|
declare const testnetChainsArray: ChainInfo[];
|
|
@@ -151,13 +161,18 @@ declare enum WalletType {
|
|
|
151
161
|
}
|
|
152
162
|
declare const WALLET_TYPES: WalletType[];
|
|
153
163
|
|
|
154
|
-
declare type ConnectArgs = Maybe<
|
|
164
|
+
declare type ConnectArgs = Maybe<{
|
|
165
|
+
chain?: GrazChain;
|
|
155
166
|
signerOpts?: SigningCosmWasmClientOptions;
|
|
156
167
|
walletType?: WalletType;
|
|
168
|
+
autoReconnect?: boolean;
|
|
157
169
|
}>;
|
|
158
170
|
declare const connect: (args?: ConnectArgs) => Promise<Key>;
|
|
159
171
|
declare const disconnect: (clearRecentChain?: boolean) => Promise<void>;
|
|
160
|
-
declare
|
|
172
|
+
declare type ReconnectArgs = Maybe<{
|
|
173
|
+
onError?: (error: unknown) => void;
|
|
174
|
+
}>;
|
|
175
|
+
declare const reconnect: (args?: ReconnectArgs) => Promise<Key | undefined>;
|
|
161
176
|
|
|
162
177
|
declare type ExtensionSetup<P extends object = object> = (queryClient: QueryClient) => P;
|
|
163
178
|
|
|
@@ -193,8 +208,9 @@ interface SuggestChainAndConnectArgs {
|
|
|
193
208
|
};
|
|
194
209
|
rpcHeaders?: Dictionary;
|
|
195
210
|
path?: string;
|
|
211
|
+
autoReconnect?: boolean;
|
|
196
212
|
}
|
|
197
|
-
declare const suggestChainAndConnect: ({ chainInfo, ...rest }: SuggestChainAndConnectArgs) => Promise<{
|
|
213
|
+
declare const suggestChainAndConnect: ({ chainInfo, rpcHeaders, gas, path, ...rest }: SuggestChainAndConnectArgs) => Promise<{
|
|
198
214
|
account: Key;
|
|
199
215
|
chain: ChainInfo;
|
|
200
216
|
}>;
|
|
@@ -222,6 +238,8 @@ interface GrazStore {
|
|
|
222
238
|
walletType: WalletType;
|
|
223
239
|
_notFoundFn: () => void;
|
|
224
240
|
_reconnect: boolean;
|
|
241
|
+
_reconnectConnector: WalletType | null;
|
|
242
|
+
_onReconnectFailed: () => void;
|
|
225
243
|
}
|
|
226
244
|
|
|
227
245
|
declare type CreateClientArgs = Pick<GrazChain, "rpc" | "rpcHeaders">;
|
|
@@ -238,40 +256,14 @@ interface ConfigureGrazArgs {
|
|
|
238
256
|
defaultSigningClient?: GrazStore["defaultSigningClient"];
|
|
239
257
|
defaultWallet?: WalletType;
|
|
240
258
|
onNotFound?: () => void;
|
|
259
|
+
onReconnectFailed?: () => void;
|
|
260
|
+
/**
|
|
261
|
+
* default to true
|
|
262
|
+
*/
|
|
263
|
+
autoReconnect?: boolean;
|
|
241
264
|
}
|
|
242
265
|
declare const configureGraz: (args?: ConfigureGrazArgs) => ConfigureGrazArgs;
|
|
243
266
|
|
|
244
|
-
interface AddressToIbcDomainReturnValue {
|
|
245
|
-
domain: string;
|
|
246
|
-
domainFull: string;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* @see https://docs.ibc.domains/convert_address.html#relevant-bech32-prefixes
|
|
250
|
-
*/
|
|
251
|
-
declare type KnownChainPrefix = "agoric" | "chihuahua" | "gravity" | "lum" | "sent" | "akash" | "comdex" | "iaa" | "micro" | "sif" | "axelar" | "cosmos" | "inj" | "osmo" | "somm" | "bcna" | "cro" | "ixo" | "panacea" | "star" | "bitsong" | "desmos" | "juno" | "persistence" | "stars" | "bostrom" | "dig" | "ki" | "regen" | "terra" | "certik" | "emoney" | "kujira" | "rebus" | "umee" | "cheqd" | "evmos" | "like" | "secret" | "vdl";
|
|
252
|
-
declare type ChainPrefix = (string & {}) | KnownChainPrefix;
|
|
253
|
-
interface DomainDetails {
|
|
254
|
-
expiration: string | null;
|
|
255
|
-
imageData: string | null;
|
|
256
|
-
twitterId: string | null;
|
|
257
|
-
discordId: string | null;
|
|
258
|
-
telegramId: string | null;
|
|
259
|
-
keybaseId: string | null;
|
|
260
|
-
pgpPublicKey: string | null;
|
|
261
|
-
}
|
|
262
|
-
declare const isIbcDomainPostfix: (value: string) => boolean;
|
|
263
|
-
declare const validateAddress: (address: string, prefix: ChainPrefix) => boolean;
|
|
264
|
-
declare const getIbcDomainByAdress: (address: string, isTestnet?: boolean) => Promise<AddressToIbcDomainReturnValue | null>;
|
|
265
|
-
declare const getAddressesByIbcDomain: (ibcDomain: string, isTestnet?: boolean) => Promise<string[] | null>;
|
|
266
|
-
declare const getChainAddressByIbcDomain: (ibcDomain: string, prefix: ChainPrefix, isTestnet?: boolean) => Promise<string | null>;
|
|
267
|
-
declare const getIbcDomainDetails: (ibcDomain: string, isTestnet?: boolean) => Promise<DomainDetails | null>;
|
|
268
|
-
interface ResolveToChainAddressArgs {
|
|
269
|
-
value: string;
|
|
270
|
-
prefix: ChainPrefix;
|
|
271
|
-
isTestnet?: boolean;
|
|
272
|
-
}
|
|
273
|
-
declare const resolveToChainAddress: ({ value, prefix, isTestnet }: ResolveToChainAddressArgs) => Promise<string>;
|
|
274
|
-
|
|
275
267
|
declare const getBalances: (bech32Address: string) => Promise<Coin[]>;
|
|
276
268
|
declare const getBalanceStaked: (bech32Address: string) => Promise<Coin | null>;
|
|
277
269
|
interface SendTokensArgs {
|
|
@@ -420,7 +412,8 @@ declare const useAccount: ({ onConnect, onDisconnect }?: UseAccountArgs) => {
|
|
|
420
412
|
isConnecting: boolean;
|
|
421
413
|
isDisconnected: boolean;
|
|
422
414
|
isReconnecting: boolean;
|
|
423
|
-
|
|
415
|
+
isLoading: boolean;
|
|
416
|
+
reconnect: (args?: ReconnectArgs) => Promise<Key | undefined>;
|
|
424
417
|
status: "connected" | "connecting" | "reconnecting" | "disconnected";
|
|
425
418
|
};
|
|
426
419
|
/**
|
|
@@ -482,10 +475,12 @@ declare type UseConnectChainArgs = MutationEventArgs<ConnectArgs, Key>;
|
|
|
482
475
|
*
|
|
483
476
|
* // use custom chain information
|
|
484
477
|
* connect({
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
478
|
+
* chain:{
|
|
479
|
+
* rpc: "https://rpc.juno.strange.love",
|
|
480
|
+
* rest: "https://api.juno.strange.love",
|
|
481
|
+
* chainId: "juno-1",
|
|
482
|
+
* ...
|
|
483
|
+
* }
|
|
489
484
|
* });
|
|
490
485
|
* ```
|
|
491
486
|
*
|
|
@@ -781,128 +776,6 @@ declare const useClients: (args?: CreateClientArgs) => UseQueryResult<GrazStore[
|
|
|
781
776
|
*/
|
|
782
777
|
declare const useSigningClients: (args?: CreateSigningClientArgs) => UseQueryResult<GrazStore["signingClients"]>;
|
|
783
778
|
|
|
784
|
-
/**
|
|
785
|
-
* graz query hook to retrieve an ibc domain from given address.
|
|
786
|
-
*
|
|
787
|
-
* @param address - Optional, if address undefined this hook won't run
|
|
788
|
-
* @param isTestnet - Optional for pointing to testnet
|
|
789
|
-
*
|
|
790
|
-
* @example
|
|
791
|
-
* ```ts
|
|
792
|
-
* import { useAddressToIbcDomain } from "graz";
|
|
793
|
-
*
|
|
794
|
-
* // basic example
|
|
795
|
-
* const { data, isFetching, refetch, ... } = useAddressToIbcDomain({
|
|
796
|
-
* address: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430",
|
|
797
|
-
* });
|
|
798
|
-
*
|
|
799
|
-
* ```
|
|
800
|
-
*/
|
|
801
|
-
declare const useAddressToIbcDomain: ({ address, isTestnet, }: {
|
|
802
|
-
address?: string | undefined;
|
|
803
|
-
isTestnet?: boolean | undefined;
|
|
804
|
-
}) => UseQueryResult<AddressToIbcDomainReturnValue | null>;
|
|
805
|
-
/**
|
|
806
|
-
* graz query hook to retrieve an addresses from given ibc domain.
|
|
807
|
-
*
|
|
808
|
-
* @param ibcDomain - Optional ibc domain, if ibc domain undefined this hook won't run
|
|
809
|
-
* @param isTestnet - Optional for pointing to testnet
|
|
810
|
-
*
|
|
811
|
-
* @example
|
|
812
|
-
* ```ts
|
|
813
|
-
* import { useIbcDomainToAddresses } from "graz";
|
|
814
|
-
*
|
|
815
|
-
* // basic example
|
|
816
|
-
* const { data, isFetching, refetch, ... } = useIbcDomainToAddresses({
|
|
817
|
-
* ibcDomain: "kikiding.cosmos",
|
|
818
|
-
* });
|
|
819
|
-
*
|
|
820
|
-
* ```
|
|
821
|
-
*/
|
|
822
|
-
declare const useIbcDomainToAddresses: ({ ibcDomain, isTestnet, }: {
|
|
823
|
-
ibcDomain?: string | undefined;
|
|
824
|
-
isTestnet?: boolean | undefined;
|
|
825
|
-
}) => UseQueryResult<string[] | null>;
|
|
826
|
-
/**
|
|
827
|
-
* graz query hook to retrieve an address from given ibc domain and prefix.
|
|
828
|
-
*
|
|
829
|
-
* @param ibcDomain - Optional ibc domain, if ibc domain undefined this hook won't run
|
|
830
|
-
* @param prefix - Optional string or bech32 prefix of the destination chain, for instance "cosmos", "somm", etc
|
|
831
|
-
* @param isTestnet - Optional for pointing to testnet
|
|
832
|
-
*
|
|
833
|
-
* @example
|
|
834
|
-
* ```ts
|
|
835
|
-
* import { useIbcDomainToChainAddress } from "graz";
|
|
836
|
-
*
|
|
837
|
-
* // basic example
|
|
838
|
-
* const { data, isFetching, refetch, ... } = useIbcDomainToChainAddress({
|
|
839
|
-
* ibcDomain: "kikiding.cosmos",
|
|
840
|
-
* prefix: "osmo"
|
|
841
|
-
* });
|
|
842
|
-
*
|
|
843
|
-
* ```
|
|
844
|
-
*/
|
|
845
|
-
declare const useIbcDomainToChainAddress: ({ ibcDomain, prefix, isTestnet, }: {
|
|
846
|
-
ibcDomain?: string | undefined;
|
|
847
|
-
prefix?: ChainPrefix | undefined;
|
|
848
|
-
isTestnet?: boolean | undefined;
|
|
849
|
-
}) => UseQueryResult<string | null>;
|
|
850
|
-
/**
|
|
851
|
-
* graz query hook to retrieve a ibc domain details from given ibc domain.
|
|
852
|
-
*
|
|
853
|
-
* @param ibcDomain - Optional ibc domain, if ibc domain undefined this hook won't run
|
|
854
|
-
* @param isTestnet - Optional for pointing to testnet
|
|
855
|
-
*
|
|
856
|
-
* @example
|
|
857
|
-
* ```ts
|
|
858
|
-
* import { useIbcDomainDetails } from "graz";
|
|
859
|
-
*
|
|
860
|
-
* // basic example
|
|
861
|
-
* const { data, isFetching, refetch, ... } = useIbcDomainDetails({
|
|
862
|
-
* ibcDomain: "kikiding.cosmos",
|
|
863
|
-
* });
|
|
864
|
-
*
|
|
865
|
-
* ```
|
|
866
|
-
*/
|
|
867
|
-
declare const useIbcDomainDetails: ({ ibcDomain, isTestnet }: {
|
|
868
|
-
ibcDomain?: string | undefined;
|
|
869
|
-
isTestnet?: boolean | undefined;
|
|
870
|
-
}) => UseQueryResult<DomainDetails | null, unknown>;
|
|
871
|
-
declare type UseResolveToChainAddressArgs = MutationEventArgs<ResolveToChainAddressArgs, string>;
|
|
872
|
-
/**
|
|
873
|
-
* graz mutation hook to resolve an Ibc domain or an address to bech32 address from given string
|
|
874
|
-
*
|
|
875
|
-
* @example
|
|
876
|
-
* ```ts
|
|
877
|
-
* import { useResolveToChainAddress } from "graz";
|
|
878
|
-
*
|
|
879
|
-
* // basic example
|
|
880
|
-
* const { resolveToChainAddress } = useResolveToChainAddress();
|
|
881
|
-
*
|
|
882
|
-
* // with event arguments
|
|
883
|
-
* useResolveToChainAddress({
|
|
884
|
-
* onError: (err, args) => { ... },
|
|
885
|
-
* onLoading: () => { ... },
|
|
886
|
-
* onSuccess: ({ account, address }) => { ... },
|
|
887
|
-
* });
|
|
888
|
-
*
|
|
889
|
-
* // resolveToChainAddress usage
|
|
890
|
-
* resolveToChainAddress({
|
|
891
|
-
* value: "kikiding.cosmos",
|
|
892
|
-
* prefix: "osmo"
|
|
893
|
-
* ...
|
|
894
|
-
* });
|
|
895
|
-
* ```
|
|
896
|
-
*/
|
|
897
|
-
declare const useResolveToChainAddress: ({ onError, onLoading, onSuccess }?: UseResolveToChainAddressArgs) => {
|
|
898
|
-
error: unknown;
|
|
899
|
-
isLoading: boolean;
|
|
900
|
-
isSuccess: boolean;
|
|
901
|
-
resolveToChainAddress: _tanstack_react_query.UseMutateFunction<string, unknown, ResolveToChainAddressArgs, unknown>;
|
|
902
|
-
resolveToChainAddressAsync: _tanstack_react_query.UseMutateAsyncFunction<string, unknown, ResolveToChainAddressArgs, unknown>;
|
|
903
|
-
status: "error" | "idle" | "loading" | "success";
|
|
904
|
-
};
|
|
905
|
-
|
|
906
779
|
/**
|
|
907
780
|
* graz mutation hook to send tokens. Note: if `senderAddress` undefined, it will use current connected account address.
|
|
908
781
|
*
|
|
@@ -1102,4 +975,4 @@ declare const useGrazEvents: () => null;
|
|
|
1102
975
|
*/
|
|
1103
976
|
declare const GrazEvents: FC;
|
|
1104
977
|
|
|
1105
|
-
export {
|
|
978
|
+
export { ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateQueryClient, CreateSigningClientArgs, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseQueryClient, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createQueryClient, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAvailableWallets, getBalanceStaked, getBalances, getKeplr, getLeap, getQueryRaw, getQuerySmart, getRecentChain, getWallet, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useBalance, useBalanceStaked, useBalances, useCheckKeplr, useCheckWallet, useClients, useConnect, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClient, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var rt=Object.create;var j=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var pt=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},fe=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ct(t))!ut.call(e,s)&&s!==n&&j(e,s,{get:()=>t[s],enumerable:!(o=it(t,s))||o.enumerable});return e};var xe=(e,t,n)=>(n=e!=null?rt(at(e)):{},fe(t||!e||!e.__esModule?j(n,"default",{value:e,enumerable:!0}):n,e)),mt=e=>fe(j({},"__esModule",{value:!0}),e);var dn={};pt(dn,{GrazEvents:()=>de,GrazProvider:()=>gn,WALLET_TYPES:()=>G,WalletType:()=>R,checkWallet:()=>T,clearRecentChain:()=>z,configureGraz:()=>F,connect:()=>S,createClients:()=>w,createQueryClient:()=>K,createSigningClients:()=>D,defineChain:()=>Ut,defineChainInfo:()=>Rt,defineChains:()=>le,disconnect:()=>O,executeContract:()=>ee,getActiveChainCurrency:()=>W,getAddressesByIbcDomain:()=>H,getAvailableWallets:()=>gt,getBalanceStaked:()=>J,getBalances:()=>Y,getChainAddressByIbcDomain:()=>v,getIbcDomainByAdress:()=>N,getIbcDomainDetails:()=>L,getKeplr:()=>Ee,getLeap:()=>be,getQueryRaw:()=>ne,getQuerySmart:()=>te,getRecentChain:()=>dt,getWallet:()=>A,instantiateContract:()=>Z,isIbcDomainPostfix:()=>je,mainnetChains:()=>Gt,mainnetChainsArray:()=>Mt,reconnect:()=>C,resolveToChainAddress:()=>V,sendIbcTokens:()=>X,sendTokens:()=>$,suggestChain:()=>k,suggestChainAndConnect:()=>_,testnetChains:()=>Kt,testnetChainsArray:()=>Qt,useAccount:()=>d,useActiveChain:()=>Nt,useActiveChainCurrency:()=>Ht,useActiveChainValidators:()=>Lt,useAddressToIbcDomain:()=>en,useBalance:()=>Ot,useBalanceStaked:()=>Ft,useBalances:()=>$e,useCheckKeplr:()=>Pt,useCheckWallet:()=>E,useClients:()=>Xt,useConnect:()=>zt,useDisconnect:()=>Wt,useExecuteContract:()=>un,useGrazEvents:()=>tt,useIbcDomainDetails:()=>sn,useIbcDomainToAddresses:()=>tn,useIbcDomainToChainAddress:()=>nn,useInstantiateContract:()=>an,useOfflineSigners:()=>Xe,useQueryClient:()=>$t,useQueryRaw:()=>mn,useQuerySmart:()=>pn,useRecentChain:()=>Vt,useResolveToChainAddress:()=>on,useSendIbcTokens:()=>cn,useSendTokens:()=>rn,useSigners:()=>_t,useSigningClients:()=>Zt,useSuggestChain:()=>Yt,useSuggestChainAndConnect:()=>Jt,validateAddress:()=>Ie});module.exports=mt(dn);var we=require("@cosmjs/stargate");var he=xe(require("zustand")),I=require("zustand/middleware");var R=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(R||{}),G=["keplr","leap"];var M={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_reconnect:!1},lt={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},c=(0,he.default)((0,I.subscribeWithSelector)((0,I.persist)(()=>M,lt)));var Q=require("@cosmjs/cosmwasm-stargate"),P=require("@cosmjs/stargate"),Se=require("@cosmjs/tendermint-rpc");var Ae=require("@cosmjs/stargate"),h=require("@cosmjs/utils");var K=(...e)=>{let{tendermint:t}=c.getState().clients,n=new Ae.QueryClient(t),o=e.map(s=>s(n));for(let s of o){(0,h.assert)((0,h.isNonNullObject)(s),"Extension must be a non-null object");for(let[i,r]of Object.entries(s)){(0,h.assert)((0,h.isNonNullObject)(r),`Module must be a non-null object. Found type ${typeof r} for module "${i}".`);let u=n[i]||{};n[i]={...u,...r}}}return n};var w=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[o,s,i]=await Promise.all([Q.SigningCosmWasmClient.connect(n),P.SigningStargateClient.connect(n),Se.Tendermint34Client.connect(e)]);return{cosmWasm:o,stargate:s,tendermint:i}},D=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:o,cosmWasmSignerOptions:s={},stargateSignerOptions:i={}}=e,r={url:t,headers:{...n||{}}},[u,p]=await Promise.all([Q.SigningCosmWasmClient.connectWithSigner(r,o,s),P.SigningStargateClient.connectWithSigner(r,o,i)]);return{cosmWasm:u,stargate:p}};var T=(e=c.getState().walletType)=>{try{return A(e),!0}catch(t){return console.error(t),!1}},Ee=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},be=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},A=(e=c.getState().walletType)=>{switch(e){case"keplr":return Ee();case"leap":return be();default:throw new Error("Unknown wallet type")}},gt=()=>Object.fromEntries(G.map(e=>[e,T(e)]));var S=async e=>{try{let{defaultChain:t,recentChain:n,walletType:o}=c.getState(),s=(e==null?void 0:e.walletType)||o,i=A(s),r=e||n||t;if(!r)throw new Error("No last known connected chain, connect action requires chain info");c.setState(U=>{let ot=U._reconnect;return U.activeChain&&U.activeChain.chainId!==r.chainId?{status:"connecting"}:ot?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(r.chainId);let u=i.getOfflineSigner(r.chainId),p=i.getOfflineSignerOnlyAmino(r.chainId),m=await i.getOfflineSignerAuto(r.chainId),l=r.gas?we.GasPrice.fromString(`${r.gas.price}${r.gas.denom}`):void 0,[Ce,nt,st]=await Promise.all([i.getKey(r.chainId),w(r),D({...r,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:Ce,activeChain:r,clients:nt,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:r,signingClients:st,status:"connected",walletType:s,_reconnect:!0}),Ce}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},O=async(e=!1)=>(c.setState(t=>({...M,recentChain:e?null:t.recentChain})),Promise.resolve()),C=()=>{let{activeChain:e}=c.getState();e&&S(e)};var z=()=>{c.setState({recentChain:null})},W=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},dt=()=>c.getState().recentChain,k=async e=>(await A().experimentalSuggestChain(e),e),_=async({chainInfo:e,...t})=>{let n=await k(e);return{account:await S({chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,...t}),chain:n}};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})),e);var De=require("bech32"),g=require("ibc-domains-sdk"),je=e=>e.endsWith(".cosmos"),Ie=(e,t)=>{if(!e)return!1;try{return De.bech32.decode(e).prefix===t}catch{return!1}},N=async(e,t)=>{let n=await(0,g.resolvePrimaryDomainByAddress)(e,t);if(n.error)throw new Error(n.error);if(n.value===null)return null;let o=n.value;return{domain:o.domain,domainFull:o.domain_full}},H=async(e,t)=>{let n=await(0,g.resolveDomainIntoAddresses)(e,t);if(n.error)throw new Error(n.error);return n.value===null?null:n.value},v=async(e,t,n)=>{let o=await(0,g.resolveDomainIntoChainAddress)(e,t,n);if(o.error)throw new Error(o.error);return o.value===null?null:o.value},L=async(e,t)=>{let n=await(0,g.resolveDomainDetails)(e,t);if(n.error)throw new Error(n.error);return n.value===null?null:n.value},V=async({value:e,prefix:t,isTestnet:n})=>{if(e.trim()==="")throw new Error("value can't be an empty string");if(je(e)){let i=await v(e,t,n);if(!i)throw new Error("ibc domain not found");return i}if(!Ie(e,t))throw new Error("Address is not valid");return e};var Y=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:o}=c.getState();return await Promise.all(t.currencies.map(async i=>n[o].getBalance(e,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:n,fee:o,memo:s})=>{let{signingClients:i,defaultSigningClient:r}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[r].sendTokens(e,t,n,o,s)},X=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:o,sourceChannel:s,timeoutHeight:i,timeoutTimestamp:r,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,n,o,s,i,r,u,p)},Z=async({senderAddress:e,msg:t,fee:n,options:o,label:s,codeId:i})=>{let{signingClients:r}=c.getState();if(!(r!=null&&r.cosmWasm))throw new Error("CosmWasm signing client is not ready");return r.cosmWasm.instantiate(e,i,t,s,n,o)},ee=async({senderAddress:e,msg:t,fee:n,contractAddress:o,funds:s,memo:i})=>{let{signingClients:r}=c.getState();if(!(r!=null&&r.cosmWasm))throw new Error("CosmWasm signing client is not ready");return r.cosmWasm.execute(e,o,t,n,i,s)},te=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},ne=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,o)};var ke=require("@keplr-wallet/cosmos"),ve={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},yt={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"},ft={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},xt={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ht={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Te=[ve,yt,Ct,ft,xt,ht],se={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:ve,bip44:{coinType:118},bech32Config:ke.Bech32Address.defaultBech32Config("axelar"),currencies:Te,feeCurrencies:Te};var qe=require("@keplr-wallet/cosmos"),Ue={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Be=[Ue],B={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:Ue,bip44:{coinType:118},bech32Config:qe.Bech32Address.defaultBech32Config("cosmos"),currencies:Be,feeCurrencies:Be};var Ge=require("@keplr-wallet/cosmos"),Me={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},At={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},St={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Et={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},bt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},wt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Dt={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},jt={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},It={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Tt={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},kt={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},Re=[Me,At,St,Et,bt,wt,Dt,jt,It,Tt,kt],oe={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Me,bip44:{coinType:118},bech32Config:Ge.Bech32Address.defaultBech32Config("juno"),currencies:Re,feeCurrencies:Re};var Qe=require("@keplr-wallet/cosmos"),Pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},vt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Ke=[Pe,vt],re={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Pe,bip44:{coinType:118},bech32Config:Qe.Bech32Address.defaultBech32Config("osmo"),currencies:Ke,feeCurrencies:Ke};var ze=require("@keplr-wallet/cosmos"),We={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Oe=[We],ie={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:We,bip44:{coinType:118},bech32Config:ze.Bech32Address.defaultBech32Config("somm"),currencies:Oe,feeCurrencies:Oe};var Fe=require("@keplr-wallet/cosmos"),Ne={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},_e=[Ne],ce={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:Fe.Bech32Address.defaultBech32Config("CRE"),currencies:_e,feeCurrencies:_e,stakeCurrency:Ne,coinType:118};var He=require("@keplr-wallet/cosmos"),ae={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Bt=[ae],ue={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:ae,bip44:{coinType:118},bech32Config:He.Bech32Address.defaultBech32Config("juno"),currencies:Bt,feeCurrencies:[ae],coinType:118};var Le=require("@keplr-wallet/cosmos"),pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},qt=[pe],me={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:pe,bip44:{coinType:118},bech32Config:Le.Bech32Address.defaultBech32Config("osmo"),currencies:qt,feeCurrencies:[pe],coinType:118};var le=e=>e,Ut=e=>e,Rt=e=>e,Gt=le({axelar:se,cosmos:B,cosmoshub:B,juno:oe,osmosis:re,sommelier:ie}),Mt=[se,B,oe,re,ie],Kt=le({crescent:ce,juno:ue,osmosis:me}),Qt=[ce,ue,me];var f=require("@tanstack/react-query"),Ye=require("react"),Je=xe(require("zustand/shallow"));var Ve=require("@tanstack/react-query");var Pt=()=>E("keplr"),E=e=>{let t=c(s=>e||s.walletType);return(0,Ve.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,s]})=>T(s))};var d=({onConnect:e,onDisconnect:t}={})=>{let n=c(s=>s.account),o=c(s=>s.status);return(0,Ye.useEffect)(()=>c.subscribe(s=>s.status,(s,i)=>{if(s==="connected"){let r=c.getState();e==null||e({account:r.account,isReconnect:i==="reconnecting"})}s==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",reconnect:C,status:o}},$e=e=>{let{data:t}=d(),n=e||(t==null?void 0:t.bech32Address);return(0,f.useQuery)(["USE_BALANCES",n],({queryKey:[,i]})=>Y(i),{enabled:Boolean(n)})},Ot=(e,t)=>{let{data:n}=$e(t);return(0,f.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(r=>r.denom===e),{enabled:Boolean(n)})},zt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,f.useMutation)(["USE_CONNECT",e,t,n],S,{onError:(r,u)=>Promise.resolve(e==null?void 0:e(r,u)),onMutate:t,onSuccess:r=>Promise.resolve(n==null?void 0:n(r))}),{data:i}=E();return{connect:r=>s.mutate(r),connectAsync:r=>s.mutateAsync(r),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status}},Wt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,f.useMutation)(["USE_DISCONNECT",e,t,n],O,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>s.mutate(i),disconnectAsync:i=>s.mutateAsync(i),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,status:s.status}},Xe=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Je.default),_t=()=>Xe(),Ft=e=>{let{data:t}=d(),n=e||(t==null?void 0:t.bech32Address);return(0,f.useQuery)(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>J(n),{enabled:Boolean(n)})};var b=require("@tanstack/react-query");var Nt=()=>c(e=>e.activeChain),Ht=e=>(0,b.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,o]})=>W(o)),Lt=(e,t="BOND_STATUS_BONDED")=>(0,b.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,s,i]})=>s.staking.validators(i),{enabled:typeof e<"u"}),Vt=()=>({data:c(t=>t.recentChain),clear:z}),Yt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,b.useMutation)(["USE_SUGGEST_CHAIN",e,t,n],k,{onError:(i,r)=>Promise.resolve(e==null?void 0:e(i,r)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,suggest:s.mutate,suggestAsync:s.mutateAsync,status:s.status}},Jt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,b.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],_,{onError:(r,u)=>Promise.resolve(e==null?void 0:e(r,u)),onMutate:r=>t==null?void 0:t(r),onSuccess:r=>Promise.resolve(n==null?void 0:n(r))}),{data:i}=E();return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status,suggestAndConnect:s.mutate,suggestAndConnectAsync:s.mutateAsync}};var ge=require("@tanstack/react-query");var Ze=require("@tanstack/react-query");var $t=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,Ze.useQuery)(t,({queryKey:[,...o]})=>K(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var Xt=e=>{let t=c(s=>s.clients);return(0,ge.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?w(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({clients:s})}})},Zt=e=>{let t=c(s=>s.signingClients);return(0,ge.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?D(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({signingClients:s})}})};var x=require("@tanstack/react-query");var en=({address:e,isTestnet:t})=>(0,x.useQuery)(["USE_ADRESS_TO_IBC_DOMAIN",e,t],()=>N(e,t),{enabled:Boolean(e)}),tn=({ibcDomain:e,isTestnet:t})=>(0,x.useQuery)(["USE_IBC_DOMAIN_TO_ADDRESSES",e,t],()=>H(e,t),{enabled:Boolean(e)}),nn=({ibcDomain:e,prefix:t,isTestnet:n})=>(0,x.useQuery)(["USE_IBC_DOMAIN_TO_CHAIN_ADDRESS",t,e,n],()=>v(e,t,n),{enabled:Boolean(e&&t)}),sn=({ibcDomain:e,isTestnet:t})=>(0,x.useQuery)(["USE_IBC_DOMAIN_DETAILS",e,t],()=>L(e,t),{enabled:Boolean(e)}),on=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,x.useMutation)(["USE_RESOLVE_TO_CHAIN_ADDRESS",e,t,n],V,{onError:(i,r)=>Promise.resolve(e==null?void 0:e(i,r)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,resolveToChainAddress:s.mutate,resolveToChainAddressAsync:s.mutateAsync,status:s.status}};var y=require("@tanstack/react-query");var rn=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=d(),s=o==null?void 0:o.bech32Address,r=(0,y.useMutation)(["USE_SEND_TOKENS",e,t,n,s],u=>$({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,sendTokens:r.mutate,sendTokensAsync:r.mutateAsync,status:r.status}},cn=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=d(),s=o==null?void 0:o.bech32Address,r=(0,y.useMutation)(["USE_SEND_IBC_TOKENS",e,t,n,s],u=>X({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,sendIbcTokens:r.mutate,sendIbcTokensAsync:r.mutateAsync,status:r.status}},an=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:s}=d(),i=s==null?void 0:s.bech32Address,p=(0,y.useMutation)(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return Z(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(o==null?void 0:o(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},un=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:s}=d(),i=s==null?void 0:s.bech32Address,p=(0,y.useMutation)(["USE_EXECUTE_CONTRACT",t,n,o,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return ee(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(o==null?void 0:o(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},pn=(e,t)=>(0,y.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return te(e,t)},{enabled:Boolean(e)&&Boolean(t)}),mn=(e,t)=>(0,y.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or key undefined");return ne(e,t)},{enabled:Boolean(e)&&Boolean(t)});var q=require("@tanstack/react-query");var et=require("react");var tt=()=>((0,et.useEffect)(()=>{let{_reconnect:e}=c.getState();return e&&C(),window.addEventListener("keplr_keystorechange",C),()=>{window.removeEventListener("keplr_keystorechange",C)}},[]),null),de=()=>(tt(),null);var ye=require("react/jsx-runtime"),ln=new q.QueryClient({}),gn=({children:e,grazOptions:t,...n})=>(t&&F(t),(0,ye.jsxs)(q.QueryClientProvider,{client:ln,...n,children:[(0,ye.jsx)(de,{}),e]}));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAddressesByIbcDomain,getAvailableWallets,getBalanceStaked,getBalances,getChainAddressByIbcDomain,getIbcDomainByAdress,getIbcDomainDetails,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,isIbcDomainPostfix,mainnetChains,mainnetChainsArray,reconnect,resolveToChainAddress,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useAddressToIbcDomain,useBalance,useBalanceStaked,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useExecuteContract,useGrazEvents,useIbcDomainDetails,useIbcDomainToAddresses,useIbcDomainToChainAddress,useInstantiateContract,useOfflineSigners,useQueryClient,useQueryRaw,useQuerySmart,useRecentChain,useResolveToChainAddress,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect,validateAddress});
|
|
1
|
+
"use strict";var Je=Object.create;var k=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var tt=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},le=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xe(t))!et.call(e,o)&&o!==n&&k(e,o,{get:()=>t[o],enumerable:!(r=$e(t,o))||r.enumerable});return e};var de=(e,t,n)=>(n=e!=null?Je(Ze(e)):{},le(t||!e||!e.__esModule?k(n,"default",{value:e,enumerable:!0}):n,e)),nt=e=>le(k({},"__esModule",{value:!0}),e);var Zt={};tt(Zt,{GrazEvents:()=>ue,GrazProvider:()=>Xt,WALLET_TYPES:()=>G,WalletType:()=>v,checkWallet:()=>x,clearRecentChain:()=>z,configureGraz:()=>W,connect:()=>A,createClients:()=>b,createQueryClient:()=>q,createSigningClients:()=>j,defineChain:()=>bt,defineChainInfo:()=>jt,defineChains:()=>ie,disconnect:()=>T,executeContract:()=>L,getActiveChainCurrency:()=>K,getAvailableWallets:()=>st,getBalanceStaked:()=>_,getBalances:()=>F,getKeplr:()=>fe,getLeap:()=>xe,getQueryRaw:()=>Y,getQuerySmart:()=>V,getRecentChain:()=>rt,getWallet:()=>h,instantiateContract:()=>H,mainnetChains:()=>Dt,mainnetChainsArray:()=>kt,reconnect:()=>d,sendIbcTokens:()=>N,sendTokens:()=>P,suggestChain:()=>B,suggestChainAndConnect:()=>O,testnetChains:()=>It,testnetChainsArray:()=>Tt,useAccount:()=>g,useActiveChain:()=>Mt,useActiveChainCurrency:()=>Qt,useActiveChainValidators:()=>zt,useBalance:()=>Rt,useBalanceStaked:()=>qt,useBalances:()=>_e,useCheckKeplr:()=>Bt,useCheckWallet:()=>S,useClients:()=>_t,useConnect:()=>vt,useDisconnect:()=>Gt,useExecuteContract:()=>Vt,useGrazEvents:()=>He,useInstantiateContract:()=>Lt,useOfflineSigners:()=>Pe,useQueryClient:()=>Ft,useQueryRaw:()=>Jt,useQuerySmart:()=>Yt,useRecentChain:()=>Kt,useSendIbcTokens:()=>Ht,useSendTokens:()=>Nt,useSigners:()=>Ut,useSigningClients:()=>Pt,useSuggestChain:()=>Ot,useSuggestChainAndConnect:()=>Wt});module.exports=nt(Zt);var he=require("@cosmjs/stargate");var w="graz-reconnect-session";var ge=de(require("zustand")),I=require("zustand/middleware");var v=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(v||{}),G=["keplr","leap"];var U={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ot={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=(0,ge.default)((0,I.subscribeWithSelector)((0,I.persist)(()=>U,ot)));var M=require("@cosmjs/cosmwasm-stargate"),Q=require("@cosmjs/stargate"),Ce=require("@cosmjs/tendermint-rpc");var ye=require("@cosmjs/stargate"),f=require("@cosmjs/utils");var q=(...e)=>{let{tendermint:t}=c.getState().clients,n=new ye.QueryClient(t),r=e.map(o=>o(n));for(let o of r){(0,f.assert)((0,f.isNonNullObject)(o),"Extension must be a non-null object");for(let[i,s]of Object.entries(o)){(0,f.assert)((0,f.isNonNullObject)(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let u=n[i]||{};n[i]={...u,...s}}}return n};var b=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[r,o,i]=await Promise.all([M.SigningCosmWasmClient.connect(n),Q.SigningStargateClient.connect(n),Ce.Tendermint34Client.connect(e)]);return{cosmWasm:r,stargate:o,tendermint:i}},j=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:r,cosmWasmSignerOptions:o={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...n||{}}},[u,p]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(s,r,o),Q.SigningStargateClient.connectWithSigner(s,r,i)]);return{cosmWasm:u,stargate:p}};var x=(e=c.getState().walletType)=>{try{return h(e),!0}catch(t){return console.error(t),!1}},fe=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},xe=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},h=(e=c.getState().walletType)=>{switch(e){case"keplr":return fe();case"leap":return xe();default:throw new Error("Unknown wallet type")}},st=()=>Object.fromEntries(G.map(e=>[e,x(e)]));var A=async e=>{try{let{defaultChain:t,recentChain:n,walletType:r}=c.getState(),o=(e==null?void 0:e.walletType)||r,i=h(o),s=(e==null?void 0:e.chain)||n||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(D=>{let Ye=D._reconnect||Boolean(D._reconnectConnector)||Boolean(s);return D.activeChain&&D.activeChain.chainId!==s.chainId?{status:"connecting"}:Ye?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let u=i.getOfflineSigner(s.chainId),p=i.getOfflineSignerOnlyAmino(s.chainId),m=await i.getOfflineSignerAuto(s.chainId),l=s.gas?he.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[me,Le,Ve]=await Promise.all([i.getKey(s.chainId),b(s),j({...s,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:me,activeChain:s,clients:Le,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:s,signingClients:Ve,status:"connected",walletType:o,_reconnect:Boolean(e==null?void 0:e.autoReconnect),_reconnectConnector:o}),typeof window<"u"&&window.sessionStorage.setItem(w,"Active"),me}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},T=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(w),c.setState(t=>({...U,recentChain:e?null:t.recentChain})),Promise.resolve()),d=async e=>{var i;let{recentChain:t,_reconnectConnector:n,_reconnect:r}=c.getState(),o=x(n||void 0);try{if(t&&o&&n)return await A({chain:t,walletType:n,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),T()}};var z=()=>{c.setState({recentChain:null})},K=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},rt=()=>c.getState().recentChain,B=async e=>(await h().experimentalSuggestChain(e),e),O=async({chainInfo:e,rpcHeaders:t,gas:n,path:r,...o})=>{let i=await B(e);return{account:await A({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:n,path:r},...o}),chain:i}};var W=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var F=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return n[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},_=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},P=async({senderAddress:e,recipientAddress:t,amount:n,fee:r,memo:o})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,n,r,o)},N=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:r,sourceChannel:o,timeoutHeight:i,timeoutTimestamp:s,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,n,r,o,i,s,u,p)},H=async({senderAddress:e,msg:t,fee:n,options:r,label:o,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,o,n,r)},L=async({senderAddress:e,msg:t,fee:n,contractAddress:r,funds:o,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,n,i,o)},V=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},Y=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,r)};var Se=require("@keplr-wallet/cosmos"),Ee={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},it={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},ct={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},at={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ut={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},pt={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Ae=[Ee,it,ct,at,ut,pt],J={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Ee,bip44:{coinType:118},bech32Config:Se.Bech32Address.defaultBech32Config("axelar"),currencies:Ae,feeCurrencies:Ae};var be=require("@keplr-wallet/cosmos"),je={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},we=[je],$={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:je,bip44:{coinType:118},bech32Config:be.Bech32Address.defaultBech32Config("cosmos"),currencies:we,feeCurrencies:we};var ke=require("@keplr-wallet/cosmos"),Ie={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},mt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},lt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},dt={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},gt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},yt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ct={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ft={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},xt={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},ht={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},At={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},De=[Ie,mt,lt,dt,gt,yt,Ct,ft,xt,ht,At],X={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Ie,bip44:{coinType:118},bech32Config:ke.Bech32Address.defaultBech32Config("juno"),currencies:De,feeCurrencies:De};var Be=require("@keplr-wallet/cosmos"),Re={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},St={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Te=[Re,St],Z={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Re,bip44:{coinType:118},bech32Config:Be.Bech32Address.defaultBech32Config("osmo"),currencies:Te,feeCurrencies:Te};var Ge=require("@keplr-wallet/cosmos"),Ue={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},ve=[Ue],ee={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Ue,bip44:{coinType:118},bech32Config:Ge.Bech32Address.defaultBech32Config("somm"),currencies:ve,feeCurrencies:ve};var Me=require("@keplr-wallet/cosmos"),Qe={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},qe=[Qe],te={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:Me.Bech32Address.defaultBech32Config("CRE"),currencies:qe,feeCurrencies:qe,stakeCurrency:Qe,coinType:118};var ze=require("@keplr-wallet/cosmos"),ne={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Et=[ne],oe={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:ne,bip44:{coinType:118},bech32Config:ze.Bech32Address.defaultBech32Config("juno"),currencies:Et,feeCurrencies:[ne],coinType:118};var Ke=require("@keplr-wallet/cosmos"),se={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},wt=[se],re={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:se,bip44:{coinType:118},bech32Config:Ke.Bech32Address.defaultBech32Config("osmo"),currencies:wt,feeCurrencies:[se],coinType:118};var ie=e=>e,bt=e=>e,jt=e=>e,Dt=ie({axelar:J,cosmoshub:$,juno:X,osmosis:Z,sommelier:ee}),kt=[J,$,X,Z,ee],It=ie({crescent:te,juno:oe,osmosis:re}),Tt=[te,oe,re];var C=require("@tanstack/react-query"),We=require("react"),Fe=de(require("zustand/shallow"));var Oe=require("@tanstack/react-query");var Bt=()=>S("keplr"),S=e=>{let t=c(o=>e||o.walletType);return(0,Oe.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,o]})=>x(o))};var g=({onConnect:e,onDisconnect:t}={})=>{let n=c(o=>o.account),r=c(o=>o.status);return(0,We.useEffect)(()=>c.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}o==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:d,status:r}},_e=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return(0,C.useQuery)(["USE_BALANCES",n],({queryKey:[,i]})=>F(i),{enabled:Boolean(n)})},Rt=(e,t)=>{let{data:n}=_e(t);return(0,C.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:Boolean(n)})},vt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,C.useMutation)(["USE_CONNECT",e,t,n],A,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=S();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status}},Gt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,C.useMutation)(["USE_DISCONNECT",e,t,n],T,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>o.mutate(i),disconnectAsync:i=>o.mutateAsync(i),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,status:o.status}},Pe=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Fe.default),Ut=()=>Pe(),qt=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return(0,C.useQuery)(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>_(n),{enabled:Boolean(n)})};var E=require("@tanstack/react-query");var Mt=()=>c(e=>e.activeChain),Qt=e=>(0,E.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>K(r)),zt=(e,t="BOND_STATUS_BONDED")=>(0,E.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,o,i]})=>o.staking.validators(i),{enabled:typeof e<"u"}),Kt=()=>({data:c(t=>t.recentChain),clear:z}),Ot=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,E.useMutation)(["USE_SUGGEST_CHAIN",e,t,n],B,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,suggest:o.mutate,suggestAsync:o.mutateAsync,status:o.status}},Wt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,E.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],O,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=S();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};var ce=require("@tanstack/react-query");var Ne=require("@tanstack/react-query");var Ft=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,Ne.useQuery)(t,({queryKey:[,...r]})=>q(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var _t=e=>{let t=c(o=>o.clients);return(0,ce.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?b(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:o=>{c.setState({clients:o})}})},Pt=e=>{let t=c(o=>o.signingClients);return(0,ce.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?j(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:o=>{c.setState({signingClients:o})}})};var y=require("@tanstack/react-query");var Nt=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=g(),o=r==null?void 0:r.bech32Address,s=(0,y.useMutation)(["USE_SEND_TOKENS",e,t,n,o],u=>P({senderAddress:o,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Ht=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=g(),o=r==null?void 0:r.bech32Address,s=(0,y.useMutation)(["USE_SEND_IBC_TOKENS",e,t,n,o],u=>N({senderAddress:o,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},Lt=({codeId:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:o}=g(),i=o==null?void 0:o.bech32Address,p=(0,y.useMutation)(["USE_INSTANTIATE_CONTRACT",t,n,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return H(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},Vt=({contractAddress:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:o}=g(),i=o==null?void 0:o.bech32Address,p=(0,y.useMutation)(["USE_EXECUTE_CONTRACT",t,n,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return L(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},Yt=(e,t)=>(0,y.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,o]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return V(e,t)},{enabled:Boolean(e)&&Boolean(t)}),Jt=(e,t)=>(0,y.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,o]})=>{if(!e||!t)throw new Error("address or key undefined");return Y(e,t)},{enabled:Boolean(e)&&Boolean(t)});var R=require("@tanstack/react-query");var ae=require("react");var He=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(w)==="Active",{activeChain:t,_reconnect:n,_onReconnectFailed:r}=c.getState();return(0,ae.useEffect)(()=>{e&&Boolean(t)?d({onError:r}):!e&&n&&d({onError:r})},[]),(0,ae.useEffect)(()=>(window.addEventListener("keplr_keystorechange",()=>void d({onError:r})),()=>{window.removeEventListener("keplr_keystorechange",()=>void d({onError:r}))}),[]),null},ue=()=>(He(),null);var pe=require("react/jsx-runtime"),$t=new R.QueryClient({}),Xt=({children:e,grazOptions:t,...n})=>(t&&W(t),(0,pe.jsxs)(R.QueryClientProvider,{client:$t,...n,children:[(0,pe.jsx)(ue,{}),e]}));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAvailableWallets,getBalanceStaked,getBalances,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalanceStaked,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useExecuteContract,useGrazEvents,useInstantiateContract,useOfflineSigners,useQueryClient,useQueryRaw,useQuerySmart,useRecentChain,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GasPrice as Pe}from"@cosmjs/stargate";import Be from"zustand";import{persist as qe,subscribeWithSelector as Ue}from"zustand/middleware";var P=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(P||{}),O=["keplr","leap"];var w={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_reconnect:!1},Re={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},c=Be(Ue(qe(()=>w,Re)));import{SigningCosmWasmClient as F}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as N}from"@cosmjs/stargate";import{Tendermint34Client as Me}from"@cosmjs/tendermint-rpc";import{QueryClient as Ge}from"@cosmjs/stargate";import{assert as z,isNonNullObject as W}from"@cosmjs/utils";var _=(...e)=>{let{tendermint:t}=c.getState().clients,n=new Ge(t),o=e.map(s=>s(n));for(let s of o){z(W(s),"Extension must be a non-null object");for(let[i,r]of Object.entries(s)){z(W(r),`Module must be a non-null object. Found type ${typeof r} for module "${i}".`);let u=n[i]||{};n[i]={...u,...r}}}return n};var x=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[o,s,i]=await Promise.all([F.connect(n),N.connect(n),Me.connect(e)]);return{cosmWasm:o,stargate:s,tendermint:i}},h=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:o,cosmWasmSignerOptions:s={},stargateSignerOptions:i={}}=e,r={url:t,headers:{...n||{}}},[u,p]=await Promise.all([F.connectWithSigner(r,o,s),N.connectWithSigner(r,o,i)]);return{cosmWasm:u,stargate:p}};var D=(e=c.getState().walletType)=>{try{return y(e),!0}catch(t){return console.error(t),!1}},Ke=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Qe=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},y=(e=c.getState().walletType)=>{switch(e){case"keplr":return Ke();case"leap":return Qe();default:throw new Error("Unknown wallet type")}},Yt=()=>Object.fromEntries(O.map(e=>[e,D(e)]));var C=async e=>{try{let{defaultChain:t,recentChain:n,walletType:o}=c.getState(),s=(e==null?void 0:e.walletType)||o,i=y(s),r=e||n||t;if(!r)throw new Error("No last known connected chain, connect action requires chain info");c.setState(b=>{let ve=b._reconnect;return b.activeChain&&b.activeChain.chainId!==r.chainId?{status:"connecting"}:ve?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(r.chainId);let u=i.getOfflineSigner(r.chainId),p=i.getOfflineSignerOnlyAmino(r.chainId),m=await i.getOfflineSignerAuto(r.chainId),l=r.gas?Pe.fromString(`${r.gas.price}${r.gas.denom}`):void 0,[Q,Te,ke]=await Promise.all([i.getKey(r.chainId),x(r),h({...r,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:Q,activeChain:r,clients:Te,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:r,signingClients:ke,status:"connected",walletType:s,_reconnect:!0}),Q}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},H=async(e=!1)=>(c.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()),d=()=>{let{activeChain:e}=c.getState();e&&C(e)};var L=()=>{c.setState({recentChain:null})},V=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},rn=()=>c.getState().recentChain,j=async e=>(await y().experimentalSuggestChain(e),e),Y=async({chainInfo:e,...t})=>{let n=await j(e);return{account:await C({chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,...t}),chain:n}};var J=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e);import{bech32 as Oe}from"bech32";import{resolveDomainDetails as ze,resolveDomainIntoAddresses as We,resolveDomainIntoChainAddress as _e,resolvePrimaryDomainByAddress as Fe}from"ibc-domains-sdk";var Ne=e=>e.endsWith(".cosmos"),He=(e,t)=>{if(!e)return!1;try{return Oe.decode(e).prefix===t}catch{return!1}},$=async(e,t)=>{let n=await Fe(e,t);if(n.error)throw new Error(n.error);if(n.value===null)return null;let o=n.value;return{domain:o.domain,domainFull:o.domain_full}},X=async(e,t)=>{let n=await We(e,t);if(n.error)throw new Error(n.error);return n.value===null?null:n.value},I=async(e,t,n)=>{let o=await _e(e,t,n);if(o.error)throw new Error(o.error);return o.value===null?null:o.value},Z=async(e,t)=>{let n=await ze(e,t);if(n.error)throw new Error(n.error);return n.value===null?null:n.value},ee=async({value:e,prefix:t,isTestnet:n})=>{if(e.trim()==="")throw new Error("value can't be an empty string");if(Ne(e)){let i=await I(e,t,n);if(!i)throw new Error("ibc domain not found");return i}if(!He(e,t))throw new Error("Address is not valid");return e};var te=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:o}=c.getState();return await Promise.all(t.currencies.map(async i=>n[o].getBalance(e,i.coinMinimalDenom)))},ne=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)},se=async({senderAddress:e,recipientAddress:t,amount:n,fee:o,memo:s})=>{let{signingClients:i,defaultSigningClient:r}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[r].sendTokens(e,t,n,o,s)},oe=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:o,sourceChannel:s,timeoutHeight:i,timeoutTimestamp:r,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,n,o,s,i,r,u,p)},re=async({senderAddress:e,msg:t,fee:n,options:o,label:s,codeId:i})=>{let{signingClients:r}=c.getState();if(!(r!=null&&r.cosmWasm))throw new Error("CosmWasm signing client is not ready");return r.cosmWasm.instantiate(e,i,t,s,n,o)},ie=async({senderAddress:e,msg:t,fee:n,contractAddress:o,funds:s,memo:i})=>{let{signingClients:r}=c.getState();if(!(r!=null&&r.cosmWasm))throw new Error("CosmWasm signing client is not ready");return r.cosmWasm.execute(e,o,t,n,i,s)},ce=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},ae=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,o)};import{Bech32Address as Le}from"@keplr-wallet/cosmos";var pe={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Ve={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Ye={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Je={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},$e={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Xe={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},ue=[pe,Ve,Ye,Je,$e,Xe],T={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:pe,bip44:{coinType:118},bech32Config:Le.defaultBech32Config("axelar"),currencies:ue,feeCurrencies:ue};import{Bech32Address as Ze}from"@keplr-wallet/cosmos";var le={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},me=[le],A={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:le,bip44:{coinType:118},bech32Config:Ze.defaultBech32Config("cosmos"),currencies:me,feeCurrencies:me};import{Bech32Address as et}from"@keplr-wallet/cosmos";var de={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},tt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},nt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},st={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},ot={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},rt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},it={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"},at={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},ut={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},pt={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ge=[de,tt,nt,st,ot,rt,it,ct,at,ut,pt],k={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:de,bip44:{coinType:118},bech32Config:et.defaultBech32Config("juno"),currencies:ge,feeCurrencies:ge};import{Bech32Address as mt}from"@keplr-wallet/cosmos";var Ce={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},lt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ye=[Ce,lt],v={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Ce,bip44:{coinType:118},bech32Config:mt.defaultBech32Config("osmo"),currencies:ye,feeCurrencies:ye};import{Bech32Address as gt}from"@keplr-wallet/cosmos";var xe={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},fe=[xe],B={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:xe,bip44:{coinType:118},bech32Config:gt.defaultBech32Config("somm"),currencies:fe,feeCurrencies:fe};import{Bech32Address as dt}from"@keplr-wallet/cosmos";var Ae={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},he=[Ae],q={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:dt.defaultBech32Config("CRE"),currencies:he,feeCurrencies:he,stakeCurrency:Ae,coinType:118};import{Bech32Address as yt}from"@keplr-wallet/cosmos";var U={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Ct=[U],R={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:U,bip44:{coinType:118},bech32Config:yt.defaultBech32Config("juno"),currencies:Ct,feeCurrencies:[U],coinType:118};import{Bech32Address as ft}from"@keplr-wallet/cosmos";var G={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},xt=[G],M={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:G,bip44:{coinType:118},bech32Config:ft.defaultBech32Config("osmo"),currencies:xt,feeCurrencies:[G],coinType:118};var Se=e=>e,On=e=>e,zn=e=>e,Wn=Se({axelar:T,cosmos:A,cosmoshub:A,juno:k,osmosis:v,sommelier:B}),_n=[T,A,k,v,B],Fn=Se({crescent:q,juno:R,osmosis:M}),Nn=[q,R,M];import{useMutation as Ee,useQuery as K}from"@tanstack/react-query";import{useEffect as At}from"react";import St from"zustand/shallow";import{useQuery as ht}from"@tanstack/react-query";var Jn=()=>f("keplr"),f=e=>{let t=c(s=>e||s.walletType);return ht(["USE_CHECK_WALLET",t],({queryKey:[,s]})=>D(s))};var g=({onConnect:e,onDisconnect:t}={})=>{let n=c(s=>s.account),o=c(s=>s.status);return At(()=>c.subscribe(s=>s.status,(s,i)=>{if(s==="connected"){let r=c.getState();e==null||e({account:r.account,isReconnect:i==="reconnecting"})}s==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",reconnect:d,status:o}},Et=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return K(["USE_BALANCES",n],({queryKey:[,i]})=>te(i),{enabled:Boolean(n)})},rs=(e,t)=>{let{data:n}=Et(t);return K(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(r=>r.denom===e),{enabled:Boolean(n)})},is=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=Ee(["USE_CONNECT",e,t,n],C,{onError:(r,u)=>Promise.resolve(e==null?void 0:e(r,u)),onMutate:t,onSuccess:r=>Promise.resolve(n==null?void 0:n(r))}),{data:i}=f();return{connect:r=>s.mutate(r),connectAsync:r=>s.mutateAsync(r),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status}},cs=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=Ee(["USE_DISCONNECT",e,t,n],H,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>s.mutate(i),disconnectAsync:i=>s.mutateAsync(i),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,status:s.status}},bt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),St),as=()=>bt(),us=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return K(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>ne(n),{enabled:Boolean(n)})};import{useMutation as be,useQuery as we}from"@tanstack/react-query";var ys=()=>c(e=>e.activeChain),Cs=e=>we(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,o]})=>V(o)),fs=(e,t="BOND_STATUS_BONDED")=>we(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,s,i]})=>s.staking.validators(i),{enabled:typeof e<"u"}),xs=()=>({data:c(t=>t.recentChain),clear:L}),hs=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=be(["USE_SUGGEST_CHAIN",e,t,n],j,{onError:(i,r)=>Promise.resolve(e==null?void 0:e(i,r)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,suggest:s.mutate,suggestAsync:s.mutateAsync,status:s.status}},As=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=be(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],Y,{onError:(r,u)=>Promise.resolve(e==null?void 0:e(r,u)),onMutate:r=>t==null?void 0:t(r),onSuccess:r=>Promise.resolve(n==null?void 0:n(r))}),{data:i}=f();return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status,suggestAndConnect:s.mutate,suggestAndConnectAsync:s.mutateAsync}};import{useQuery as De}from"@tanstack/react-query";import{useQuery as wt}from"@tanstack/react-query";var ws=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return wt(t,({queryKey:[,...o]})=>_(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var ks=e=>{let t=c(s=>s.clients);return De(["USE_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?x(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({clients:s})}})},vs=e=>{let t=c(s=>s.signingClients);return De(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?h(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({signingClients:s})}})};import{useMutation as Dt,useQuery as S}from"@tanstack/react-query";var Gs=({address:e,isTestnet:t})=>S(["USE_ADRESS_TO_IBC_DOMAIN",e,t],()=>$(e,t),{enabled:Boolean(e)}),Ms=({ibcDomain:e,isTestnet:t})=>S(["USE_IBC_DOMAIN_TO_ADDRESSES",e,t],()=>X(e,t),{enabled:Boolean(e)}),Ks=({ibcDomain:e,prefix:t,isTestnet:n})=>S(["USE_IBC_DOMAIN_TO_CHAIN_ADDRESS",t,e,n],()=>I(e,t,n),{enabled:Boolean(e&&t)}),Qs=({ibcDomain:e,isTestnet:t})=>S(["USE_IBC_DOMAIN_DETAILS",e,t],()=>Z(e,t),{enabled:Boolean(e)}),Ps=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=Dt(["USE_RESOLVE_TO_CHAIN_ADDRESS",e,t,n],ee,{onError:(i,r)=>Promise.resolve(e==null?void 0:e(i,r)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,resolveToChainAddress:s.mutate,resolveToChainAddressAsync:s.mutateAsync,status:s.status}};import{useMutation as E,useQuery as je}from"@tanstack/react-query";var Fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=g(),s=o==null?void 0:o.bech32Address,r=E(["USE_SEND_TOKENS",e,t,n,s],u=>se({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,sendTokens:r.mutate,sendTokensAsync:r.mutateAsync,status:r.status}},Ns=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=g(),s=o==null?void 0:o.bech32Address,r=E(["USE_SEND_IBC_TOKENS",e,t,n,s],u=>oe({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,sendIbcTokens:r.mutate,sendIbcTokensAsync:r.mutateAsync,status:r.status}},Hs=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:s}=g(),i=s==null?void 0:s.bech32Address,p=E(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return re(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(o==null?void 0:o(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},Ls=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:s}=g(),i=s==null?void 0:s.bech32Address,p=E(["USE_EXECUTE_CONTRACT",t,n,o,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return ie(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(o==null?void 0:o(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},Vs=(e,t)=>je(["USE_QUERY_SMART",e,t],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return ce(e,t)},{enabled:Boolean(e)&&Boolean(t)}),Ys=(e,t)=>je(["USE_QUERY_RAW",t,e],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or key undefined");return ae(e,t)},{enabled:Boolean(e)&&Boolean(t)});import{QueryClient as Tt,QueryClientProvider as kt}from"@tanstack/react-query";import{useEffect as jt}from"react";var It=()=>(jt(()=>{let{_reconnect:e}=c.getState();return e&&d(),window.addEventListener("keplr_keystorechange",d),()=>{window.removeEventListener("keplr_keystorechange",d)}},[]),null),Ie=()=>(It(),null);import{jsx as Bt,jsxs as qt}from"react/jsx-runtime";var vt=new Tt({}),oo=({children:e,grazOptions:t,...n})=>(t&&J(t),qt(kt,{client:vt,...n,children:[Bt(Ie,{}),e]}));export{Ie as GrazEvents,oo as GrazProvider,O as WALLET_TYPES,P as WalletType,D as checkWallet,L as clearRecentChain,J as configureGraz,C as connect,x as createClients,_ as createQueryClient,h as createSigningClients,On as defineChain,zn as defineChainInfo,Se as defineChains,H as disconnect,ie as executeContract,V as getActiveChainCurrency,X as getAddressesByIbcDomain,Yt as getAvailableWallets,ne as getBalanceStaked,te as getBalances,I as getChainAddressByIbcDomain,$ as getIbcDomainByAdress,Z as getIbcDomainDetails,Ke as getKeplr,Qe as getLeap,ae as getQueryRaw,ce as getQuerySmart,rn as getRecentChain,y as getWallet,re as instantiateContract,Ne as isIbcDomainPostfix,Wn as mainnetChains,_n as mainnetChainsArray,d as reconnect,ee as resolveToChainAddress,oe as sendIbcTokens,se as sendTokens,j as suggestChain,Y as suggestChainAndConnect,Fn as testnetChains,Nn as testnetChainsArray,g as useAccount,ys as useActiveChain,Cs as useActiveChainCurrency,fs as useActiveChainValidators,Gs as useAddressToIbcDomain,rs as useBalance,us as useBalanceStaked,Et as useBalances,Jn as useCheckKeplr,f as useCheckWallet,ks as useClients,is as useConnect,cs as useDisconnect,Ls as useExecuteContract,It as useGrazEvents,Qs as useIbcDomainDetails,Ms as useIbcDomainToAddresses,Ks as useIbcDomainToChainAddress,Hs as useInstantiateContract,bt as useOfflineSigners,ws as useQueryClient,Ys as useQueryRaw,Vs as useQuerySmart,xs as useRecentChain,Ps as useResolveToChainAddress,Ns as useSendIbcTokens,Fs as useSendTokens,as as useSigners,vs as useSigningClients,hs as useSuggestChain,As as useSuggestChainAndConnect,He as validateAddress};
|
|
1
|
+
import{a as y}from"./chunk-ETISV7IF.mjs";import{GasPrice as qe}from"@cosmjs/stargate";import ke from"zustand";import{persist as Ie,subscribeWithSelector as Te}from"zustand/middleware";var K=(o=>(o.KEPLR="keplr",o.LEAP="leap",o))(K||{}),W=["keplr","leap"];var b={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Be={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=ke(Te(Ie(()=>b,Be)));import{SigningCosmWasmClient as P}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as N}from"@cosmjs/stargate";import{Tendermint34Client as ve}from"@cosmjs/tendermint-rpc";import{QueryClient as Re}from"@cosmjs/stargate";import{assert as O,isNonNullObject as F}from"@cosmjs/utils";var _=(...e)=>{let{tendermint:t}=c.getState().clients,o=new Re(t),r=e.map(n=>n(o));for(let n of r){O(F(n),"Extension must be a non-null object");for(let[i,s]of Object.entries(n)){O(F(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let u=o[i]||{};o[i]={...u,...s}}}return o};var S=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([P.connect(o),N.connect(o),ve.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},E=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...o||{}}},[u,p]=await Promise.all([P.connectWithSigner(s,r,n),N.connectWithSigner(s,r,i)]);return{cosmWasm:u,stargate:p}};var C=(e=c.getState().walletType)=>{try{return f(e),!0}catch(t){return console.error(t),!1}},Ge=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ue=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},f=(e=c.getState().walletType)=>{switch(e){case"keplr":return Ge();case"leap":return Ue();default:throw new Error("Unknown wallet type")}},Mt=()=>Object.fromEntries(W.map(e=>[e,C(e)]));var x=async e=>{try{let{defaultChain:t,recentChain:o,walletType:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=f(n),s=(e==null?void 0:e.chain)||o||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(A=>{let De=A._reconnect||Boolean(A._reconnectConnector)||Boolean(s);return A.activeChain&&A.activeChain.chainId!==s.chainId?{status:"connecting"}:De?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let u=i.getOfflineSigner(s.chainId),p=i.getOfflineSignerOnlyAmino(s.chainId),m=await i.getOfflineSignerAuto(s.chainId),l=s.gas?qe.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[z,be,je]=await Promise.all([i.getKey(s.chainId),S(s),E({...s,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:z,activeChain:s,clients:be,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:s,signingClients:je,status:"connected",walletType:n,_reconnect:Boolean(e==null?void 0:e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(y,"Active"),z}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},j=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(y),c.setState(t=>({...b,recentChain:e?null:t.recentChain})),Promise.resolve()),d=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:r}=c.getState(),n=C(o||void 0);try{if(t&&n&&o)return await x({chain:t,walletType:o,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),j()}};var H=()=>{c.setState({recentChain:null})},L=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(o=>o.coinMinimalDenom===e)},Lt=()=>c.getState().recentChain,D=async e=>(await f().experimentalSuggestChain(e),e),V=async({chainInfo:e,rpcHeaders:t,gas:o,path:r,...n})=>{let i=await D(e);return{account:await x({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:r},...n}),chain:i}};var Y=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var J=async e=>{let{activeChain:t,signingClients:o}=c.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return o[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},$=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},X=async({senderAddress:e,recipientAddress:t,amount:o,fee:r,memo:n})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,o,r,n)},Z=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:s,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,o,r,n,i,s,u,p)},ee=async({senderAddress:e,msg:t,fee:o,options:r,label:n,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,n,o,r)},te=async({senderAddress:e,msg:t,fee:o,contractAddress:r,funds:n,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,o,i,n)},ne=async(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");return await o.cosmWasm.queryContractSmart(e,t)},oe=(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return o.cosmWasm.queryContractRaw(e,r)};import{Bech32Address as Me}from"@keplr-wallet/cosmos";var re={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Qe={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},ze={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Ke={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},We={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Oe={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},se=[re,Qe,ze,Ke,We,Oe],k={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:re,bip44:{coinType:118},bech32Config:Me.defaultBech32Config("axelar"),currencies:se,feeCurrencies:se};import{Bech32Address as Fe}from"@keplr-wallet/cosmos";var ce={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ie=[ce],I={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ce,bip44:{coinType:118},bech32Config:Fe.defaultBech32Config("cosmos"),currencies:ie,feeCurrencies:ie};import{Bech32Address as _e}from"@keplr-wallet/cosmos";var ue={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Pe={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Ne={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},He={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Le={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ve={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ye={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Je={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},$e={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Xe={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Ze={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ae=[ue,Pe,Ne,He,Le,Ve,Ye,Je,$e,Xe,Ze],T={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ue,bip44:{coinType:118},bech32Config:_e.defaultBech32Config("juno"),currencies:ae,feeCurrencies:ae};import{Bech32Address as et}from"@keplr-wallet/cosmos";var me={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},tt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},pe=[me,tt],B={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:me,bip44:{coinType:118},bech32Config:et.defaultBech32Config("osmo"),currencies:pe,feeCurrencies:pe};import{Bech32Address as nt}from"@keplr-wallet/cosmos";var de={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},le=[de],R={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:de,bip44:{coinType:118},bech32Config:nt.defaultBech32Config("somm"),currencies:le,feeCurrencies:le};import{Bech32Address as ot}from"@keplr-wallet/cosmos";var ye={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},ge=[ye],v={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:ot.defaultBech32Config("CRE"),currencies:ge,feeCurrencies:ge,stakeCurrency:ye,coinType:118};import{Bech32Address as st}from"@keplr-wallet/cosmos";var G={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},rt=[G],U={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:G,bip44:{coinType:118},bech32Config:st.defaultBech32Config("juno"),currencies:rt,feeCurrencies:[G],coinType:118};import{Bech32Address as it}from"@keplr-wallet/cosmos";var q={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},ct=[q],M={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:q,bip44:{coinType:118},bech32Config:it.defaultBech32Config("osmo"),currencies:ct,feeCurrencies:[q],coinType:118};var Ce=e=>e,jn=e=>e,Dn=e=>e,kn=Ce({axelar:k,cosmoshub:I,juno:T,osmosis:B,sommelier:R}),In=[k,I,T,B,R],Tn=Ce({crescent:v,juno:U,osmosis:M}),Bn=[v,U,M];import{useMutation as fe,useQuery as Q}from"@tanstack/react-query";import{useEffect as ut}from"react";import pt from"zustand/shallow";import{useQuery as at}from"@tanstack/react-query";var qn=()=>h("keplr"),h=e=>{let t=c(n=>e||n.walletType);return at(["USE_CHECK_WALLET",t],({queryKey:[,n]})=>C(n))};var g=({onConnect:e,onDisconnect:t}={})=>{let o=c(n=>n.account),r=c(n=>n.status);return ut(()=>c.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:d,status:r}},mt=e=>{let{data:t}=g(),o=e||(t==null?void 0:t.bech32Address);return Q(["USE_BALANCES",o],({queryKey:[,i]})=>J(i),{enabled:Boolean(o)})},Pn=(e,t)=>{let{data:o}=mt(t);return Q(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:Boolean(o)})},Nn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_CONNECT",e,t,o],x,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=h();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(i),status:n.status}},Hn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_DISCONNECT",e,t,o],j,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:i=>n.mutate(i),disconnectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}},lt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),pt),Ln=()=>lt(),Vn=e=>{let{data:t}=g(),o=e||(t==null?void 0:t.bech32Address);return Q(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>$(o),{enabled:Boolean(o)})};import{useMutation as xe,useQuery as he}from"@tanstack/react-query";var eo=()=>c(e=>e.activeChain),to=e=>he(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>L(r)),no=(e,t="BOND_STATUS_BONDED")=>he(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),oo=()=>({data:c(t=>t.recentChain),clear:H}),so=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=xe(["USE_SUGGEST_CHAIN",e,t,o],D,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}},ro=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=xe(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],V,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=h();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(i),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};import{useQuery as Ae}from"@tanstack/react-query";import{useQuery as dt}from"@tanstack/react-query";var uo=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return dt(t,({queryKey:[,...r]})=>_(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var yo=e=>{let t=c(n=>n.clients);return Ae(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?S(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},Co=e=>{let t=c(n=>n.signingClients);return Ae(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?E(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};import{useMutation as w,useQuery as Se}from"@tanstack/react-query";var Eo=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=g(),n=r==null?void 0:r.bech32Address,s=w(["USE_SEND_TOKENS",e,t,o,n],u=>X({senderAddress:n,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(o==null?void 0:o(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},wo=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=g(),n=r==null?void 0:r.bech32Address,s=w(["USE_SEND_IBC_TOKENS",e,t,o,n],u=>Z({senderAddress:n,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(o==null?void 0:o(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},bo=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=g(),i=n==null?void 0:n.bech32Address,p=w(["USE_INSTANTIATE_CONTRACT",t,o,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return ee(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:o,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},jo=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=g(),i=n==null?void 0:n.bech32Address,p=w(["USE_EXECUTE_CONTRACT",t,o,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return te(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:o,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},Do=(e,t)=>Se(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return ne(e,t)},{enabled:Boolean(e)&&Boolean(t)}),ko=(e,t)=>Se(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return oe(e,t)},{enabled:Boolean(e)&&Boolean(t)});import{QueryClient as yt,QueryClientProvider as Ct}from"@tanstack/react-query";import{useEffect as Ee}from"react";var gt=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(y)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:r}=c.getState();return Ee(()=>{e&&Boolean(t)?d({onError:r}):!e&&o&&d({onError:r})},[]),Ee(()=>(window.addEventListener("keplr_keystorechange",()=>void d({onError:r})),()=>{window.removeEventListener("keplr_keystorechange",()=>void d({onError:r}))}),[]),null},we=()=>(gt(),null);import{jsx as xt,jsxs as ht}from"react/jsx-runtime";var ft=new yt({}),Qo=({children:e,grazOptions:t,...o})=>(t&&Y(t),ht(Ct,{client:ft,...o,children:[xt(we,{}),e]}));export{we as GrazEvents,Qo as GrazProvider,W as WALLET_TYPES,K as WalletType,C as checkWallet,H as clearRecentChain,Y as configureGraz,x as connect,S as createClients,_ as createQueryClient,E as createSigningClients,jn as defineChain,Dn as defineChainInfo,Ce as defineChains,j as disconnect,te as executeContract,L as getActiveChainCurrency,Mt as getAvailableWallets,$ as getBalanceStaked,J as getBalances,Ge as getKeplr,Ue as getLeap,oe as getQueryRaw,ne as getQuerySmart,Lt as getRecentChain,f as getWallet,ee as instantiateContract,kn as mainnetChains,In as mainnetChainsArray,d as reconnect,Z as sendIbcTokens,X as sendTokens,D as suggestChain,V as suggestChainAndConnect,Tn as testnetChains,Bn as testnetChainsArray,g as useAccount,eo as useActiveChain,to as useActiveChainCurrency,no as useActiveChainValidators,Pn as useBalance,Vn as useBalanceStaked,mt as useBalances,qn as useCheckKeplr,h as useCheckWallet,yo as useClients,Nn as useConnect,Hn as useDisconnect,jo as useExecuteContract,gt as useGrazEvents,bo as useInstantiateContract,lt as useOfflineSigners,uo as useQueryClient,ko as useQueryRaw,Do as useQuerySmart,oo as useRecentChain,wo as useSendIbcTokens,Eo as useSendTokens,Ln as useSigners,Co as useSigningClients,so as useSuggestChain,ro as useSuggestChainAndConnect};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.36",
|
|
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",
|
|
@@ -43,9 +43,7 @@
|
|
|
43
43
|
"@keplr-wallet/types": "^0",
|
|
44
44
|
"@tanstack/react-query": "^4",
|
|
45
45
|
"arg": "^5",
|
|
46
|
-
"bech32": "2.0.0",
|
|
47
46
|
"cosmos-directory-client": "0.0.6",
|
|
48
|
-
"ibc-domains-sdk": "1.0.2",
|
|
49
47
|
"zustand": "^4"
|
|
50
48
|
},
|
|
51
49
|
"devDependencies": {
|