graz 0.0.5 → 0.0.8
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/README.md +4 -10
- package/dist/chunk-L7O257ZE.mjs +1 -0
- package/dist/cosmjs.d.ts +3 -0
- package/dist/cosmjs.js +1 -0
- package/dist/cosmjs.mjs +1 -0
- package/dist/index.d.ts +390 -28
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/keplr.d.ts +2 -0
- package/dist/keplr.js +1 -0
- package/dist/keplr.mjs +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
# graz
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/graz)
|
|
4
|
+
[](https://www.npmjs.com/package/graz)
|
|
5
|
+
[](https://github.com/strangelove-ventures/graz)
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
# using npm
|
|
7
|
-
npm install graz
|
|
8
|
-
|
|
9
|
-
# using yarn
|
|
10
|
-
yarn add graz
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Learn more about graz on the [official GitHub repository](https://github.com/strangelove-ventures/graz).
|
|
7
|
+
React hooks for Cosmos. Learn more about graz on the [official GitHub repository](https://github.com/strangelove-ventures/graz).
|
|
14
8
|
|
|
15
9
|
[MIT License, Copyright (c) 2022 Strangelove Ventures](./LICENSE)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";export{e as a};
|
package/dist/cosmjs.d.ts
ADDED
package/dist/cosmjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("@cosmjs/cosmwasm-stargate"),module.exports);r(o,require("@cosmjs/proto-signing"),module.exports);r(o,require("@cosmjs/stargate"),module.exports);
|
package/dist/cosmjs.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-L7O257ZE.mjs";export*from"@cosmjs/cosmwasm-stargate";export*from"@cosmjs/proto-signing";export*from"@cosmjs/stargate";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import * as _cosmjs_stargate from '@cosmjs/stargate';
|
|
2
|
-
import * as _keplr_wallet_types from '@keplr-wallet/types';
|
|
3
|
-
import { AppCurrency, ChainInfo, Key } from '@keplr-wallet/types';
|
|
4
1
|
import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
|
|
5
|
-
import { SigningCosmWasmClientOptions } from '@cosmjs/cosmwasm-stargate';
|
|
2
|
+
import { SigningCosmWasmClientOptions, CosmWasmClient, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
|
|
6
3
|
import * as _cosmjs_proto_signing from '@cosmjs/proto-signing';
|
|
7
|
-
import { OfflineSigner } from '@cosmjs/proto-signing';
|
|
4
|
+
import { Coin, OfflineSigner } from '@cosmjs/proto-signing';
|
|
5
|
+
import * as _keplr_wallet_types from '@keplr-wallet/types';
|
|
6
|
+
import { AppCurrency, Key, ChainInfo, Keplr } from '@keplr-wallet/types';
|
|
8
7
|
import * as react_query from 'react-query';
|
|
9
8
|
import * as _cosmjs_amino from '@cosmjs/amino';
|
|
10
9
|
import { ReactNode } from 'react';
|
|
11
10
|
|
|
12
11
|
declare type Dictionary<T = string> = Record<string, T>;
|
|
12
|
+
declare type Maybe<T> = T | undefined;
|
|
13
13
|
|
|
14
14
|
interface GrazChain {
|
|
15
15
|
chainId: string;
|
|
@@ -22,20 +22,134 @@ interface GrazChain {
|
|
|
22
22
|
denom: string;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Helper function to define chain information records (key values).
|
|
27
|
+
*
|
|
28
|
+
* This function does not do anything special else than providing type safety
|
|
29
|
+
* when defining chain informations.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { connect, defineChains } from "graz";
|
|
34
|
+
*
|
|
35
|
+
* const myChains = defineChains({
|
|
36
|
+
* cosmoshub: {
|
|
37
|
+
* rpc: "https://rpc.cosmoshub.strange.love",
|
|
38
|
+
* rest: "https://api.cosmoshub.strange.love",
|
|
39
|
+
* chainId: "cosmoshub-4",
|
|
40
|
+
* ...
|
|
41
|
+
* },
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* connect(myChains.cosmoshub);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare function defineChains<T extends Dictionary<GrazChain>>(chains: T): T;
|
|
48
|
+
/**
|
|
49
|
+
* Provided mainnet chains
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { connect, mainnetChains } from "graz";
|
|
54
|
+
* connect(mainnetChains.cosmos);
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @see {@link testnetChains}
|
|
58
|
+
*/
|
|
59
|
+
declare const mainnetChains: {
|
|
60
|
+
axelar: _keplr_wallet_types.ChainInfo;
|
|
27
61
|
cosmos: _keplr_wallet_types.ChainInfo;
|
|
28
62
|
juno: _keplr_wallet_types.ChainInfo;
|
|
29
63
|
osmosis: _keplr_wallet_types.ChainInfo;
|
|
64
|
+
sommelier: _keplr_wallet_types.ChainInfo;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Arary version on {@link mainnetChains}
|
|
68
|
+
*
|
|
69
|
+
* @see {@link mainnetChains}
|
|
70
|
+
*/
|
|
71
|
+
declare const mainnetChainsArray: _keplr_wallet_types.ChainInfo[];
|
|
72
|
+
/**
|
|
73
|
+
* Provided testnet chains
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { connect, testnetChains } from "graz";
|
|
78
|
+
* connect(testnetChains.osmosis);
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @see {@link mainnetChains}
|
|
82
|
+
*/
|
|
83
|
+
declare const testnetChains: {
|
|
84
|
+
crescent: _keplr_wallet_types.ChainInfo;
|
|
85
|
+
osmosis: _keplr_wallet_types.ChainInfo;
|
|
30
86
|
};
|
|
31
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Arary version on {@link testnetChains}
|
|
89
|
+
*
|
|
90
|
+
* @see {@link testnetChains}
|
|
91
|
+
*/
|
|
92
|
+
declare const testnetChainsArray: _keplr_wallet_types.ChainInfo[];
|
|
32
93
|
|
|
33
|
-
declare
|
|
34
|
-
|
|
35
|
-
|
|
94
|
+
declare type ConnectArgs = Maybe<GrazChain & {
|
|
95
|
+
signerOpts?: SigningCosmWasmClientOptions;
|
|
96
|
+
}>;
|
|
97
|
+
declare function connect(args?: ConnectArgs): Promise<Key>;
|
|
98
|
+
declare function disconnect(clearRecentChain?: boolean): Promise<void>;
|
|
99
|
+
declare function getBalances(bech32Address: string): Promise<Coin[]>;
|
|
36
100
|
declare function reconnect(): void;
|
|
37
101
|
|
|
102
|
+
declare function configureDefaultChain(chain: GrazChain): GrazChain;
|
|
103
|
+
declare function getRecentChain(): GrazChain | null;
|
|
104
|
+
declare function clearRecentChain(): void;
|
|
38
105
|
declare function suggestChain(chainInfo: ChainInfo): Promise<ChainInfo>;
|
|
106
|
+
declare function suggestChainAndConnect(chainInfo: ChainInfo): Promise<{
|
|
107
|
+
account: Key;
|
|
108
|
+
chain: ChainInfo;
|
|
109
|
+
}>;
|
|
110
|
+
|
|
111
|
+
declare type CreateClientArgs = Pick<GrazChain, "rpc" | "rpcHeaders">;
|
|
112
|
+
declare function createClient({ rpc, rpcHeaders }: CreateClientArgs): Promise<CosmWasmClient>;
|
|
113
|
+
declare type CreateSigningClientArgs = CreateClientArgs & {
|
|
114
|
+
offlineSigner: OfflineSigner;
|
|
115
|
+
signerOptions?: SigningCosmWasmClientOptions;
|
|
116
|
+
};
|
|
117
|
+
declare function createSigningClient(args: CreateSigningClientArgs): Promise<SigningCosmWasmClient>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Function to return {@link Keplr} object and throws and error if it does not exist on `window`.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* try {
|
|
125
|
+
* const keplr = getKeplr();
|
|
126
|
+
* } catch (error: Error) {
|
|
127
|
+
* console.error(error.message);
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @see https://docs.keplr.app
|
|
132
|
+
*/
|
|
133
|
+
declare function getKeplr(): Keplr;
|
|
134
|
+
/**
|
|
135
|
+
* Register a callback to run when invoking {@link getKeplr} throws an error.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* registerKeplrNotFound(() => {
|
|
140
|
+
* console.error("keplr not found");
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @see {@link unregisterKeplrNotFound}
|
|
145
|
+
*/
|
|
146
|
+
declare function registerKeplrNotFound(fn: () => void): void;
|
|
147
|
+
/**
|
|
148
|
+
* Clear registered callback when using {@link registerKeplrNotFound}.
|
|
149
|
+
*
|
|
150
|
+
* @see {@link registerKeplrNotFound}
|
|
151
|
+
*/
|
|
152
|
+
declare function unregisterKeplrNotFound(): void;
|
|
39
153
|
|
|
40
154
|
interface MutationEventArgs<TInitial = unknown, TSuccess = TInitial> {
|
|
41
155
|
onError?: (error: unknown, data: TInitial) => unknown;
|
|
@@ -50,6 +164,24 @@ interface UseAccountArgs {
|
|
|
50
164
|
}) => void;
|
|
51
165
|
onDisconnect?: () => void;
|
|
52
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* graz query hook to retrieve account data with optional arguments to invoke
|
|
169
|
+
* given function on connect/disconnect.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```tsx
|
|
173
|
+
* import { useAccount } from "graz";
|
|
174
|
+
*
|
|
175
|
+
* // basic example
|
|
176
|
+
* const { data, isConnecting, isConnected, ... } = useAccount();
|
|
177
|
+
*
|
|
178
|
+
* // with event arguments
|
|
179
|
+
* useAccount({
|
|
180
|
+
* onConnect: ({ account, isReconnect }) => { ... },
|
|
181
|
+
* onDisconnect: () => { ... },
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
53
185
|
declare function useAccount({ onConnect, onDisconnect }?: UseAccountArgs): {
|
|
54
186
|
data: Key | null;
|
|
55
187
|
isConnected: boolean;
|
|
@@ -59,6 +191,22 @@ declare function useAccount({ onConnect, onDisconnect }?: UseAccountArgs): {
|
|
|
59
191
|
reconnect: typeof reconnect;
|
|
60
192
|
status: "connected" | "connecting" | "reconnecting" | "disconnected";
|
|
61
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* graz query hook to retrieve list of balances from current account or given address.
|
|
196
|
+
*
|
|
197
|
+
* @param bech32Address - Optional bech32 account address, defaults to connected account address
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* import { useBalances } from "graz";
|
|
202
|
+
*
|
|
203
|
+
* // basic example
|
|
204
|
+
* const { data, isFetching, refetch, ... } = useBalances();
|
|
205
|
+
*
|
|
206
|
+
* // with custom bech32 address
|
|
207
|
+
* useBalances("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
62
210
|
declare function useBalances(bech32Address?: string): {
|
|
63
211
|
data: _cosmjs_amino.Coin[] | undefined;
|
|
64
212
|
error: unknown;
|
|
@@ -69,32 +217,144 @@ declare function useBalances(bech32Address?: string): {
|
|
|
69
217
|
refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<_cosmjs_amino.Coin[], unknown>>;
|
|
70
218
|
status: "idle" | "error" | "loading" | "success";
|
|
71
219
|
};
|
|
72
|
-
declare type UseConnectChainArgs = MutationEventArgs<
|
|
220
|
+
declare type UseConnectChainArgs = MutationEventArgs<ConnectArgs, Key>;
|
|
221
|
+
/**
|
|
222
|
+
* graz mutation hook to execute wallet connection with optional arguments to
|
|
223
|
+
* invoke given functions on error, loading, or success event.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* import { useConnect, mainnetChains } from "graz";
|
|
228
|
+
*
|
|
229
|
+
* // basic example
|
|
230
|
+
* const { connect, isLoading, isSuccess, ... } = useConnect();
|
|
231
|
+
*
|
|
232
|
+
* // with event arguments
|
|
233
|
+
* useConnect({
|
|
234
|
+
* onError: (err, chain) => { ... },
|
|
235
|
+
* onLoading: (chain) => { ... },
|
|
236
|
+
* onSuccess: (account) => { ... },
|
|
237
|
+
* });
|
|
238
|
+
*
|
|
239
|
+
* // use graz provided chain information
|
|
240
|
+
* connect(mainnetChains.cosmos);
|
|
241
|
+
*
|
|
242
|
+
* // use custom chain information
|
|
243
|
+
* connect({
|
|
244
|
+
* rpc: "https://rpc.juno.strange.love",
|
|
245
|
+
* rest: "https://api.juno.strange.love",
|
|
246
|
+
* chainId: "juno-1",
|
|
247
|
+
* ...
|
|
248
|
+
* });
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* @see {@link connect}
|
|
252
|
+
*/
|
|
73
253
|
declare function useConnect({ onError, onLoading, onSuccess }?: UseConnectChainArgs): {
|
|
254
|
+
connect: (args?: ConnectArgs) => void;
|
|
255
|
+
connectAsync: (args?: ConnectArgs) => Promise<Key>;
|
|
74
256
|
error: unknown;
|
|
75
257
|
isLoading: boolean;
|
|
76
258
|
isSuccess: boolean;
|
|
77
259
|
isSupported: boolean;
|
|
78
|
-
connect: react_query.UseMutateFunction<Key, unknown, GrazChain, unknown>;
|
|
79
|
-
connectAsync: react_query.UseMutateAsyncFunction<Key, unknown, GrazChain, unknown>;
|
|
80
260
|
status: "idle" | "error" | "loading" | "success";
|
|
81
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* graz mutation hook to execute wallet disconnection with optional arguments to
|
|
264
|
+
* invoke given functions on error, loading, or success event.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```ts
|
|
268
|
+
* import { useDisconnect } from "graz";
|
|
269
|
+
*
|
|
270
|
+
* // basic eaxmple
|
|
271
|
+
* const { disconnect, isLoading, isSuccess, ... } = useDisconnect();
|
|
272
|
+
*
|
|
273
|
+
* // with event arguments
|
|
274
|
+
* useDisconnect({
|
|
275
|
+
* onError: (err) => { ... },
|
|
276
|
+
* onLoading: () => { ... },
|
|
277
|
+
* onSuccess: () => { ... },
|
|
278
|
+
* });
|
|
279
|
+
*
|
|
280
|
+
* // pass `true` on disconnect to clear recent connected chain
|
|
281
|
+
* disconnect(true);
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* @see {@link disconnect}
|
|
285
|
+
*/
|
|
82
286
|
declare function useDisconnect({ onError, onLoading, onSuccess }?: MutationEventArgs): {
|
|
287
|
+
disconnect: (forget?: boolean) => void;
|
|
288
|
+
disconnectAsync: (forget?: boolean) => Promise<void>;
|
|
83
289
|
error: unknown;
|
|
84
290
|
isLoading: boolean;
|
|
85
291
|
isSuccess: boolean;
|
|
86
|
-
disconnect: react_query.UseMutateFunction<void, unknown, unknown, unknown>;
|
|
87
|
-
disconnectAsync: react_query.UseMutateAsyncFunction<void, unknown, unknown, unknown>;
|
|
88
292
|
status: "idle" | "error" | "loading" | "success";
|
|
89
293
|
};
|
|
294
|
+
/**
|
|
295
|
+
* graz hook to retrieve offline signer objects (default, amino enabled, and auto).
|
|
296
|
+
*
|
|
297
|
+
* Note: signer objects is initialized after connecting an account.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```ts
|
|
301
|
+
* import { useSigners } from "graz";
|
|
302
|
+
* const { signer, signerAmino, signerAuto } = useSigners();
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
90
305
|
declare function useSigners(): {
|
|
91
306
|
signer: (_cosmjs_proto_signing.OfflineSigner & _cosmjs_proto_signing.OfflineDirectSigner) | null;
|
|
92
307
|
signerAmino: _cosmjs_proto_signing.OfflineSigner | null;
|
|
93
308
|
signerAuto: _cosmjs_proto_signing.OfflineSigner | null;
|
|
94
309
|
};
|
|
95
310
|
|
|
311
|
+
/**
|
|
312
|
+
* graz hook to retrieve connected account's active chain
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```ts
|
|
316
|
+
* import { useActiveChain } from "graz";
|
|
317
|
+
* const { rpc, rest, chainId, currencies } = useActiveChain();
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
96
320
|
declare function useActiveChain(): GrazChain | null;
|
|
321
|
+
/**
|
|
322
|
+
* graz hook to retrieve last connected chain info
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* import { useRecentChain, connect, mainnetChains } from "graz";
|
|
327
|
+
* const recentChain = useRecentChain();
|
|
328
|
+
* try {
|
|
329
|
+
* connect();
|
|
330
|
+
* } catch {
|
|
331
|
+
* connect(mainnetChains.cosmos);
|
|
332
|
+
* }
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* @see {@link useActiveChain}
|
|
336
|
+
*/
|
|
337
|
+
declare function useRecentChain(): {
|
|
338
|
+
data: GrazChain | null;
|
|
339
|
+
clear: typeof clearRecentChain;
|
|
340
|
+
};
|
|
97
341
|
declare type UseSuggestChainArgs = MutationEventArgs<ChainInfo>;
|
|
342
|
+
/**
|
|
343
|
+
* graz mutation hook to suggest chain to Keplr Wallet
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* import { useSuggestChain } from "graz";
|
|
348
|
+
* const { suggest, isLoading, isSuccess, ... } = useSuggestChain();
|
|
349
|
+
*
|
|
350
|
+
* suggest({
|
|
351
|
+
* rpc: "https://rpc.cosmoshub.strange.love",
|
|
352
|
+
* rest: "https://api.cosmoshub.strange.love",
|
|
353
|
+
* chainId: "cosmoshub-4",
|
|
354
|
+
* ...
|
|
355
|
+
* });
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
98
358
|
declare function useSuggestChain({ onError, onLoading, onSuccess }?: UseSuggestChainArgs): {
|
|
99
359
|
error: unknown;
|
|
100
360
|
isLoading: boolean;
|
|
@@ -103,16 +363,70 @@ declare function useSuggestChain({ onError, onLoading, onSuccess }?: UseSuggestC
|
|
|
103
363
|
suggestAsync: react_query.UseMutateAsyncFunction<ChainInfo, unknown, ChainInfo, unknown>;
|
|
104
364
|
status: "idle" | "error" | "loading" | "success";
|
|
105
365
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
366
|
+
declare type UseSuggestChainAndConnectArgs = MutationEventArgs<ChainInfo, {
|
|
367
|
+
chain: ChainInfo;
|
|
368
|
+
account: Key;
|
|
369
|
+
}>;
|
|
370
|
+
/**
|
|
371
|
+
* graz mutation hook to suggest chain to Keplr Wallet and connect account
|
|
372
|
+
* afterwards
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```ts
|
|
376
|
+
* import { useSuggestChainAndConnect } from "graz";
|
|
377
|
+
*
|
|
378
|
+
* // basic example
|
|
379
|
+
* const { suggestAndConnect } = useSuggestChainAndConnect();
|
|
380
|
+
*
|
|
381
|
+
* // with event arguments
|
|
382
|
+
* useSuggestChainAndConnect({
|
|
383
|
+
* onError: (err, chainInfo) => { ... },
|
|
384
|
+
* onLoading: () => { ... },
|
|
385
|
+
* onSuccess: ({ account, chain }) => { ... },
|
|
386
|
+
* });
|
|
387
|
+
*
|
|
388
|
+
* // suggest and connect usage
|
|
389
|
+
* suggestAndConnect({
|
|
390
|
+
* rpc: "https://rpc.cosmoshub.strange.love",
|
|
391
|
+
* rest: "https://api.cosmoshub.strange.love",
|
|
392
|
+
* chainId: "cosmoshub-4",
|
|
393
|
+
* ...
|
|
394
|
+
* });
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
declare function useSuggestChainAndConnect({ onError, onLoading, onSuccess }?: UseSuggestChainAndConnectArgs): {
|
|
398
|
+
error: unknown;
|
|
399
|
+
isLoading: boolean;
|
|
400
|
+
isSuccess: boolean;
|
|
401
|
+
isSupported: boolean;
|
|
402
|
+
status: "idle" | "error" | "loading" | "success";
|
|
403
|
+
suggestAndConnect: react_query.UseMutateFunction<{
|
|
404
|
+
account: Key;
|
|
405
|
+
chain: ChainInfo;
|
|
406
|
+
}, unknown, ChainInfo, unknown>;
|
|
407
|
+
suggestAndConnectAsync: react_query.UseMutateAsyncFunction<{
|
|
408
|
+
account: Key;
|
|
409
|
+
chain: ChainInfo;
|
|
410
|
+
}, unknown, ChainInfo, unknown>;
|
|
111
411
|
};
|
|
112
412
|
|
|
113
413
|
declare type WithRefetchOpts<T> = T & {
|
|
114
414
|
keepRefetchBehavior?: boolean;
|
|
115
415
|
};
|
|
416
|
+
/**
|
|
417
|
+
* graz query hook to retrieve a CosmWasmClient. If there's no given arguments it will be using the current connected client
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* ```ts
|
|
421
|
+
* import { useClient } from "graz";
|
|
422
|
+
*
|
|
423
|
+
* // use connected client's cosmwasm client
|
|
424
|
+
* const { data, isFetching, refetch, ... } = useClient();
|
|
425
|
+
*
|
|
426
|
+
* // initialize new custom client from given arguments
|
|
427
|
+
* useClient({ rpc: "https://rpc.cosmoshub.strange.love", });
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
116
430
|
declare function useClient(args?: WithRefetchOpts<CreateClientArgs>): {
|
|
117
431
|
data: _cosmjs_cosmwasm_stargate.CosmWasmClient | null | undefined;
|
|
118
432
|
error: unknown;
|
|
@@ -123,6 +437,24 @@ declare function useClient(args?: WithRefetchOpts<CreateClientArgs>): {
|
|
|
123
437
|
refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<_cosmjs_cosmwasm_stargate.CosmWasmClient | null, unknown>>;
|
|
124
438
|
status: "idle" | "error" | "loading" | "success";
|
|
125
439
|
};
|
|
440
|
+
/**
|
|
441
|
+
* graz query hook to retrieve a SigningCosmWasmClient. If there's no given args it will be using the current connected signer
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* ```ts
|
|
445
|
+
* import { useSigningClient } from "graz";
|
|
446
|
+
*
|
|
447
|
+
* // get connected client's cosmwasm client
|
|
448
|
+
* const { data, isFetching, refetch, ... } = useSigningClient();
|
|
449
|
+
*
|
|
450
|
+
* // initialize new custom client with given args
|
|
451
|
+
* useSigningClient({
|
|
452
|
+
* rpc: "https://rpc.cosmoshub.strange.love",
|
|
453
|
+
* offlineSigner: customOfflineSigner,
|
|
454
|
+
* ...
|
|
455
|
+
* });
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
126
458
|
declare function useSigningClient(args?: WithRefetchOpts<CreateSigningClientArgs>): {
|
|
127
459
|
data: _cosmjs_cosmwasm_stargate.SigningCosmWasmClient | null | undefined;
|
|
128
460
|
error: unknown;
|
|
@@ -134,14 +466,44 @@ declare function useSigningClient(args?: WithRefetchOpts<CreateSigningClientArgs
|
|
|
134
466
|
status: "idle" | "error" | "loading" | "success";
|
|
135
467
|
};
|
|
136
468
|
|
|
469
|
+
/**
|
|
470
|
+
* graz hook which returns boolean whether Keplr Wallet is supported
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```ts
|
|
474
|
+
* import { useCheckKeplr } from "graz";
|
|
475
|
+
*
|
|
476
|
+
* // basic example
|
|
477
|
+
* const isSupported = useCheckKeplr();
|
|
478
|
+
* if (isSupported) {
|
|
479
|
+
* ...
|
|
480
|
+
* }
|
|
481
|
+
* ```
|
|
482
|
+
*
|
|
483
|
+
* @see {@link getKeplr}
|
|
484
|
+
*/
|
|
137
485
|
declare function useCheckKeplr(): boolean;
|
|
138
486
|
|
|
139
|
-
|
|
140
|
-
declare function registerKeplrNotFound(fn: () => void): void;
|
|
141
|
-
declare function unregisterKeplrNotFound(): void;
|
|
142
|
-
|
|
143
|
-
declare function GrazProvider({ children }: {
|
|
487
|
+
interface GrazProviderProps {
|
|
144
488
|
children: ReactNode;
|
|
145
|
-
}
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Provider component which wraps `react-query`'s {@link QueryClientProvider} and various `graz` side effects
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```tsx
|
|
495
|
+
* // example next.js application in _app.tsx
|
|
496
|
+
* export default function CustomApp({ Component, pageProps }: AppProps) {
|
|
497
|
+
* return (
|
|
498
|
+
* <GrazProvider>
|
|
499
|
+
* <Component {...pageProps} />
|
|
500
|
+
* </GrazProvider>
|
|
501
|
+
* );
|
|
502
|
+
* }
|
|
503
|
+
* ```
|
|
504
|
+
*
|
|
505
|
+
* @see https://react-query-v3.tanstack.com/reference/QueryClientProvider
|
|
506
|
+
*/
|
|
507
|
+
declare function GrazProvider({ children }: GrazProviderProps): JSX.Element;
|
|
146
508
|
|
|
147
|
-
export { GrazChain, GrazProvider, UseAccountArgs, UseConnectChainArgs, UseSuggestChainArgs, connect,
|
|
509
|
+
export { ConnectArgs, CreateClientArgs, CreateSigningClientArgs, GrazChain, GrazProvider, GrazProviderProps, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, clearRecentChain, configureDefaultChain, connect, createClient, createSigningClient, defineChains, disconnect, getBalances, getKeplr, getRecentChain, mainnetChains, mainnetChainsArray, reconnect, registerKeplrNotFound, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, unregisterKeplrNotFound, useAccount, useActiveChain, useBalances, useCheckKeplr, useClient, useConnect, useDisconnect, useRecentChain, useSigners, useSigningClient, useSuggestChain, useSuggestChainAndConnect };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Y=Object.create;var l=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var oe=(e,o)=>{for(var t in o)l(e,t,{get:o[t],enumerable:!0})},O=(e,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of ee(o))!te.call(e,n)&&n!==t&&l(e,n,{get:()=>o[n],enumerable:!(i=Z(o,n))||i.enumerable});return e};var S=(e,o,t)=>(t=e!=null?Y(ne(e)):{},O(o||!e||!e.__esModule?l(t,"default",{value:e,enumerable:!0}):t,e)),ie=e=>O(l({},"__esModule",{value:!0}),e);var qe={};oe(qe,{GrazProvider:()=>Oe,connect:()=>y,defaultChains:()=>Se,defaultChainsArray:()=>we,defineChains:()=>Ce,disconnect:()=>k,getBalances:()=>v,getKeplr:()=>u,reconnect:()=>m,registerKeplrNotFound:()=>re,suggestChain:()=>x,unregisterKeplrNotFound:()=>se,useAccount:()=>L,useActiveChain:()=>je,useBalances:()=>Ae,useCheckKeplr:()=>I,useClient:()=>De,useConnect:()=>ke,useDisconnect:()=>ve,useSigners:()=>xe,useSigningClient:()=>Ie,useSuggestChain:()=>be});module.exports=ie(qe);var c=S(require("react"));var G=require("@cosmjs/stargate");var q=S(require("zustand")),g=require("zustand/middleware"),w={account:null,activeChain:null,balances:null,client:null,offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,signingClient:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},r=(0,q.default)((0,g.subscribeWithSelector)((0,g.persist)(()=>({...w}),{name:"graz",partialize:e=>({activeChain:e.activeChain,_reconnect:e._reconnect}),version:1})));function u(){if(typeof window.keplr<"u")return window.keplr;throw r.getState()._notFoundFn(),new Error("Keplr is not defined")}function re(e){r.setState({_notFoundFn:e})}function se(){r.setState({_notFoundFn:()=>null})}var A=require("@cosmjs/cosmwasm-stargate");async function f({rpc:e,rpcHeaders:o}){let t={url:e,headers:{...o||{}}};return await A.SigningCosmWasmClient.connect(t)}async function h(e){let{rpc:o,rpcHeaders:t,offlineSigner:i,signerOptions:n={}}=e,s={url:o,headers:{...t||{}}};return await A.SigningCosmWasmClient.connectWithSigner(s,i,n)}async function y(e,o={}){try{let t=u();r.setState(C=>{let X=C._reconnect;return C.activeChain&&C.activeChain.chainId!==e.chainId?{status:"connecting"}:X?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(e.chainId);let i=t.getOfflineSigner(e.chainId),n=t.getOfflineSignerOnlyAmino(e.chainId),s=e.gas?G.GasPrice.fromString(`${e.gas.price}${e.gas.denom}`):void 0,[a,J,V,$]=await Promise.all([t.getKey(e.chainId),f(e),t.getOfflineSignerAuto(e.chainId),h({...e,offlineSigner:i,signerOptions:{gasPrice:s,...o}})]);return r.setState({account:a,activeChain:e,client:J,offlineSigner:i,offlineSignerAmino:n,offlineSignerAuto:V,signingClient:$,status:"connected",_reconnect:!0}),a}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function k(){return r.setState(e=>({...w,_supported:e._supported})),Promise.resolve()}async function v(e){let{activeChain:o,signingClient:t}=r.getState();if(!o||!t)throw new Error("No connected account detected");return await Promise.all(o.currencies.map(async n=>t.getBalance(e,n.coinMinimalDenom)))}function m(){let{activeChain:e}=r.getState();e&&y(e)}async function x(e){return await u().experimentalSuggestChain(e),e}var M=require("@keplr-wallet/cosmos"),U={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},K=[U],j={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:U,bip44:{coinType:118},bech32Config:M.Bech32Address.defaultBech32Config("cosmos"),currencies:K,feeCurrencies:K};var E=require("@keplr-wallet/cosmos"),R={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},ce={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},ae={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},me={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},ue={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},pe={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},le={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ge={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},fe={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},he={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ye={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},B=[R,ce,ae,me,ue,pe,le,ge,fe,he,ye],b={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:R,bip44:{coinType:118},bech32Config:E.Bech32Address.defaultBech32Config("juno"),currencies:B,feeCurrencies:B};var W=require("@keplr-wallet/cosmos"),_={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},de={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},N=[_,de],D={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:_,bip44:{coinType:118},bech32Config:W.Bech32Address.defaultBech32Config("osmo"),currencies:N,feeCurrencies:N};function Ce(e){return e}var Se={cosmos:j,juno:b,osmosis:D},we=[j,b,D];var F=require("react"),p=require("react-query"),T=S(require("zustand/shallow"));function I(){return r(e=>e._supported)}function L({onConnect:e,onDisconnect:o}={}){let t=r(n=>n.account),i=r(n=>n.status);return(0,F.useEffect)(()=>r.subscribe(n=>n.status,(n,s)=>{if(n==="connected"){let a=r.getState();e==null||e({account:a.account,isReconnect:s==="reconnecting"})}n==="disconnected"&&(o==null||o())}),[e,o]),{data:t,isConnected:Boolean(t),isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",reconnect:m,status:i}}function Ae(e){let{data:o}=L(),t=e||(o==null?void 0:o.bech32Address),n=(0,p.useQuery)(["WADESTA_USE_BALANCES",t],({queryKey:[,s]})=>v(s),{enabled:Boolean(t)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function ke({onError:e,onLoading:o,onSuccess:t}={}){let n=(0,p.useMutation)(["WADESTA_USE_CONNECT",e,o,t],y,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:o,onSuccess:s=>Promise.resolve(t==null?void 0:t(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:I(),connect:n.mutate,connectAsync:n.mutateAsync,status:n.status}}function ve({onError:e,onLoading:o,onSuccess:t}={}){let n=(0,p.useMutation)(["WADESTA_USE_DISCONNECT",e,o,t],k,{onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:o,onSuccess:()=>Promise.resolve(t==null?void 0:t(void 0))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,disconnect:n.mutate,disconnectAsync:n.mutateAsync,status:n.status}}function xe(){return r(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),T.default)}var P=require("react-query");function je(){return r(e=>e.activeChain)}function be({onError:e,onLoading:o,onSuccess:t}={}){let n=(0,P.useMutation)(["WADESTA_USE_SUGGEST_CHAIN",e,o,t],x,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:o,onSuccess:s=>Promise.resolve(t==null?void 0:t(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}var z=require("react-query");function De(e){let o=r(n=>n.client),i=(0,z.useQuery)(["USE_CLIENT",e,o],({queryKey:[,n,s]})=>n!=null&&n.rpc?f(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:i.data,error:i.error,isFetching:i.isFetching,isLoading:i.isLoading,isRefetching:i.isRefetching,isSuccess:i.isSuccess,refetch:i.refetch,status:i.status}}function Ie(e){let o=r(n=>n.signingClient),i=(0,z.useQuery)(["USE_SIGNING_CLIENT",e,o],({queryKey:[,n,s]})=>n!=null&&n.rpc?h(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:i.data,error:i.error,isFetching:i.isFetching,isLoading:i.isLoading,isRefetching:i.isRefetching,isSuccess:i.isSuccess,refetch:i.refetch,status:i.status}}var d=require("react-query");var H=require("react");function Q(){return(0,H.useEffect)(()=>{r.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=r.getState();return e&&m(),window.addEventListener("focus",m),window.addEventListener("keplr_keystorechange",m),()=>{window.removeEventListener("focus",m),window.removeEventListener("keplr_keystorechange",m)}},[]),null}var ze=new d.QueryClient({defaultOptions:{queries:{notifyOnChangeProps:"tracked"}}});function Oe({children:e}){return c.createElement(d.QueryClientProvider,{key:"graz-query-client",client:ze},c.createElement(Q,null),e)}0&&(module.exports={GrazProvider,connect,defaultChains,defaultChainsArray,defineChains,disconnect,getBalances,getKeplr,reconnect,registerKeplrNotFound,suggestChain,unregisterKeplrNotFound,useAccount,useActiveChain,useBalances,useCheckKeplr,useClient,useConnect,useDisconnect,useSigners,useSigningClient,useSuggestChain});
|
|
1
|
+
"use strict";var ye=Object.create;var C=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Ae=Object.getPrototypeOf,Se=Object.prototype.hasOwnProperty;var xe=(e,t)=>{for(var o in t)C(e,o,{get:t[o],enumerable:!0})},R=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of we(t))!Se.call(e,n)&&n!==o&&C(e,n,{get:()=>t[n],enumerable:!(i=de(t,n))||i.enumerable});return e};var S=(e,t,o)=>(o=e!=null?ye(Ae(e)):{},R(t||!e||!e.__esModule?C(o,"default",{value:e,enumerable:!0}):o,e)),ke=e=>R(C({},"__esModule",{value:!0}),e);var mn={};xe(mn,{GrazProvider:()=>an,clearRecentChain:()=>v,configureDefaultChain:()=>ve,connect:()=>p,createClient:()=>u,createSigningClient:()=>l,defineChains:()=>Le,disconnect:()=>I,getBalances:()=>D,getKeplr:()=>g,getRecentChain:()=>be,mainnetChains:()=>He,mainnetChainsArray:()=>Qe,reconnect:()=>m,registerKeplrNotFound:()=>Ie,suggestChain:()=>d,suggestChainAndConnect:()=>b,testnetChains:()=>Je,testnetChainsArray:()=>Ve,unregisterKeplrNotFound:()=>De,useAccount:()=>me,useActiveChain:()=>en,useBalances:()=>Xe,useCheckKeplr:()=>h,useClient:()=>rn,useConnect:()=>$e,useDisconnect:()=>Ye,useRecentChain:()=>nn,useSigners:()=>Ze,useSigningClient:()=>sn,useSuggestChain:()=>tn,useSuggestChainAndConnect:()=>on});module.exports=ke(mn);var c=S(require("react"));var E=require("@cosmjs/stargate");var P=S(require("zustand")),y=require("zustand/middleware"),x={account:null,activeChain:null,balances:null,client:null,defaultChain:null,offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClient:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},s=(0,P.default)((0,y.subscribeWithSelector)((0,y.persist)(()=>({...x}),{name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1})));var k=require("@cosmjs/cosmwasm-stargate");async function u({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}};return await k.SigningCosmWasmClient.connect(o)}async function l(e){let{rpc:t,rpcHeaders:o,offlineSigner:i,signerOptions:n={}}=e,r={url:t,headers:{...o||{}}};return await k.SigningCosmWasmClient.connectWithSigner(r,i,n)}function g(){if(typeof window.keplr<"u")return window.keplr;throw s.getState()._notFoundFn(),new Error("Keplr is not defined")}function Ie(e){s.setState({_notFoundFn:e})}function De(){s.setState({_notFoundFn:()=>null})}async function p(e){try{let t=g(),{defaultChain:o,recentChain:i}=s.getState(),n=e||i||o;if(!n)throw new Error("No last known connected chain, connect action requires chain info");s.setState(A=>{let Ce=A._reconnect;return A.activeChain&&A.activeChain.chainId!==n.chainId?{status:"connecting"}:Ce?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let r=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),le=n.gas?E.GasPrice.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[N,ge,he,fe]=await Promise.all([t.getKey(n.chainId),u(n),t.getOfflineSignerAuto(n.chainId),l({...n,offlineSigner:r,signerOptions:{gasPrice:le,...(e==null?void 0:e.signerOpts)||{}}})]);return s.setState({account:N,activeChain:n,client:ge,offlineSigner:r,offlineSignerAmino:a,offlineSignerAuto:he,recentChain:n,signingClient:fe,status:"connected",_reconnect:!0}),N}catch(t){throw s.getState().account===null&&s.setState({status:"disconnected"}),t}}async function I(e=!1){return s.setState(t=>({...x,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function D(e){let{activeChain:t,signingClient:o}=s.getState();if(!t||!o)throw new Error("No connected account detected");return await Promise.all(t.currencies.map(async n=>o.getBalance(e,n.coinMinimalDenom)))}function m(){let{activeChain:e}=s.getState();e&&p(e)}function ve(e){return s.setState({defaultChain:e}),e}function be(){return s.getState().recentChain}function v(){s.setState({recentChain:null})}async function d(e){return await g().experimentalSuggestChain(e),e}async function b(e){let t=await d(e);return{account:await p(e),chain:t}}var _=require("@keplr-wallet/cosmos"),F={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},je={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"},Ge={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Oe={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Me={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},W=[F,je,ze,Ge,Oe,Me],j={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:F,bip44:{coinType:118},bech32Config:_.Bech32Address.defaultBech32Config("axelar"),currencies:W,feeCurrencies:W};var H=require("@keplr-wallet/cosmos"),Q={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},L=[Q],z={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:Q,bip44:{coinType:118},bech32Config:H.Bech32Address.defaultBech32Config("cosmos"),currencies:L,feeCurrencies:L};var V=require("@keplr-wallet/cosmos"),X={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},J=[X],G={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:V.Bech32Address.defaultBech32Config("CRE"),currencies:J,feeCurrencies:J,stakeCurrency:X,coinType:118};var Y=require("@keplr-wallet/cosmos"),Z={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},qe={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Ue={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Ke={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Be={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Te={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ne={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Re={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Pe={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Ee={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},We={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},$=[Z,qe,Ue,Ke,Be,Te,Ne,Re,Pe,Ee,We],O={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Z,bip44:{coinType:118},bech32Config:Y.Bech32Address.defaultBech32Config("juno"),currencies:$,feeCurrencies:$};var ne=require("@keplr-wallet/cosmos"),te={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},_e={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ee=[te,_e],M={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:te,bip44:{coinType:118},bech32Config:ne.Bech32Address.defaultBech32Config("osmo"),currencies:ee,feeCurrencies:ee};var oe=require("@keplr-wallet/cosmos"),q={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Fe=[q],U={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:oe.Bech32Address.defaultBech32Config("osmo"),currencies:Fe,feeCurrencies:[q],coinType:118};var re=require("@keplr-wallet/cosmos"),se={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},ie=[se],K={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:se,bip44:{coinType:118},bech32Config:re.Bech32Address.defaultBech32Config("somm"),currencies:ie,feeCurrencies:ie};function Le(e){return e}var He={axelar:j,cosmos:z,juno:O,osmosis:M,sommelier:K},Qe=[j,z,O,M,K],Je={crescent:G,osmosis:U},Ve=[G,U];var ce=require("react"),f=require("react-query"),ae=S(require("zustand/shallow"));function h(){return s(e=>e._supported)}function me({onConnect:e,onDisconnect:t}={}){let o=s(n=>n.account),i=s(n=>n.status);return(0,ce.useEffect)(()=>s.subscribe(n=>n.status,(n,r)=>{if(n==="connected"){let a=s.getState();e==null||e({account:a.account,isReconnect:r==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",reconnect:m,status:i}}function Xe(e){let{data:t}=me(),o=e||(t==null?void 0:t.bech32Address),n=(0,f.useQuery)(["USE_BALANCES",o],({queryKey:[,r]})=>D(r),{enabled:Boolean(o)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function $e({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,f.useMutation)(["USE_CONNECT",e,t,o],p,{onError:(r,a)=>Promise.resolve(e==null?void 0:e(r,a)),onMutate:t,onSuccess:r=>Promise.resolve(o==null?void 0:o(r))});return{connect:r=>n.mutate(r),connectAsync:r=>n.mutateAsync(r),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status}}function Ye({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,f.useMutation)(["USE_DISCONNECT",e,t,o],I,{onError:r=>Promise.resolve(e==null?void 0:e(r,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:r=>n.mutate(r),disconnectAsync:r=>n.mutateAsync(r),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function Ze(){return s(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),ae.default)}var B=require("react-query");function en(){return s(e=>e.activeChain)}function nn(){return{data:s(t=>t.recentChain),clear:v}}function tn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,B.useMutation)(["USE_SUGGEST_CHAIN",e,t,o],d,{onError:(r,a)=>Promise.resolve(e==null?void 0:e(r,a)),onMutate:t,onSuccess:r=>Promise.resolve(o==null?void 0:o(r))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function on({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,B.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],b,{onError:(r,a)=>Promise.resolve(e==null?void 0:e(r,a)),onMutate:t,onSuccess:r=>Promise.resolve(o==null?void 0:o(r))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}var T=require("react-query");function rn(e){let t=s(n=>n.client),i=(0,T.useQuery)(["USE_CLIENT",e,t],({queryKey:[,n,r]})=>n!=null&&n.rpc?u(n):r,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:i.data,error:i.error,isFetching:i.isFetching,isLoading:i.isLoading,isRefetching:i.isRefetching,isSuccess:i.isSuccess,refetch:i.refetch,status:i.status}}function sn(e){let t=s(n=>n.signingClient),i=(0,T.useQuery)(["USE_SIGNING_CLIENT",e,t],({queryKey:[,n,r]})=>n!=null&&n.rpc?l(n):r,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:i.data,error:i.error,isFetching:i.isFetching,isLoading:i.isLoading,isRefetching:i.isRefetching,isSuccess:i.isSuccess,refetch:i.refetch,status:i.status}}var w=require("react-query");var pe=require("react");function ue(){return(0,pe.useEffect)(()=>{s.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=s.getState();return e&&m(),window.addEventListener("keplr_keystorechange",m),()=>{window.removeEventListener("keplr_keystorechange",m)}},[]),null}var cn=new w.QueryClient({defaultOptions:{queries:{notifyOnChangeProps:"tracked"}}});function an({children:e}){return c.createElement(w.QueryClientProvider,{key:"graz-query-client",client:cn},c.createElement(ue,null),e)}0&&(module.exports={GrazProvider,clearRecentChain,configureDefaultChain,connect,createClient,createSigningClient,defineChains,disconnect,getBalances,getKeplr,getRecentChain,mainnetChains,mainnetChainsArray,reconnect,registerKeplrNotFound,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,unregisterKeplrNotFound,useAccount,useActiveChain,useBalances,useCheckKeplr,useClient,useConnect,useDisconnect,useRecentChain,useSigners,useSigningClient,useSuggestChain,useSuggestChainAndConnect});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as c from"react";import{GasPrice as W}from"@cosmjs/stargate";import E from"zustand";import{persist as R,subscribeWithSelector as N}from"zustand/middleware";var f={account:null,activeChain:null,balances:null,client:null,offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,signingClient:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},r=E(N(R(()=>({...f}),{name:"graz",partialize:e=>({activeChain:e.activeChain,_reconnect:e._reconnect}),version:1})));function u(){if(typeof window.keplr<"u")return window.keplr;throw r.getState()._notFoundFn(),new Error("Keplr is not defined")}function ye(e){r.setState({_notFoundFn:e})}function de(){r.setState({_notFoundFn:()=>null})}import{SigningCosmWasmClient as S}from"@cosmjs/cosmwasm-stargate";async function p({rpc:e,rpcHeaders:i}){let t={url:e,headers:{...i||{}}};return await S.connect(t)}async function l(e){let{rpc:i,rpcHeaders:t,offlineSigner:o,signerOptions:n={}}=e,s={url:i,headers:{...t||{}}};return await S.connectWithSigner(s,o,n)}async function h(e,i={}){try{let t=u();r.setState(g=>{let B=g._reconnect;return g.activeChain&&g.activeChain.chainId!==e.chainId?{status:"connecting"}:B?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(e.chainId);let o=t.getOfflineSigner(e.chainId),n=t.getOfflineSignerOnlyAmino(e.chainId),s=e.gas?W.fromString(`${e.gas.price}${e.gas.denom}`):void 0,[a,K,M,U]=await Promise.all([t.getKey(e.chainId),p(e),t.getOfflineSignerAuto(e.chainId),l({...e,offlineSigner:o,signerOptions:{gasPrice:s,...i}})]);return r.setState({account:a,activeChain:e,client:K,offlineSigner:o,offlineSignerAmino:n,offlineSignerAuto:M,signingClient:U,status:"connected",_reconnect:!0}),a}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function w(){return r.setState(e=>({...f,_supported:e._supported})),Promise.resolve()}async function A(e){let{activeChain:i,signingClient:t}=r.getState();if(!i||!t)throw new Error("No connected account detected");return await Promise.all(i.currencies.map(async n=>t.getBalance(e,n.coinMinimalDenom)))}function m(){let{activeChain:e}=r.getState();e&&h(e)}async function k(e){return await u().experimentalSuggestChain(e),e}import{Bech32Address as _}from"@keplr-wallet/cosmos";var x={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},v=[x],y={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:x,bip44:{coinType:118},bech32Config:_.defaultBech32Config("cosmos"),currencies:v,feeCurrencies:v};import{Bech32Address as F}from"@keplr-wallet/cosmos";var b={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},T={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},L={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},P={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},H={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Q={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},J={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},V={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},$={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},X={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Y={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},j=[b,T,L,P,H,Q,J,V,$,X,Y],d={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:b,bip44:{coinType:118},bech32Config:F.defaultBech32Config("juno"),currencies:j,feeCurrencies:j};import{Bech32Address as Z}from"@keplr-wallet/cosmos";var I={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ee={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},D=[I,ee],C={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:I,bip44:{coinType:118},bech32Config:Z.defaultBech32Config("osmo"),currencies:D,feeCurrencies:D};function Ee(e){return e}var Re={cosmos:y,juno:d,osmosis:C},Ne=[y,d,C];import{useEffect as ne}from"react";import{useMutation as O,useQuery as te}from"react-query";import oe from"zustand/shallow";function z(){return r(e=>e._supported)}function ie({onConnect:e,onDisconnect:i}={}){let t=r(n=>n.account),o=r(n=>n.status);return ne(()=>r.subscribe(n=>n.status,(n,s)=>{if(n==="connected"){let a=r.getState();e==null||e({account:a.account,isReconnect:s==="reconnecting"})}n==="disconnected"&&(i==null||i())}),[e,i]),{data:t,isConnected:Boolean(t),isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",reconnect:m,status:o}}function Ve(e){let{data:i}=ie(),t=e||(i==null?void 0:i.bech32Address),n=te(["WADESTA_USE_BALANCES",t],({queryKey:[,s]})=>A(s),{enabled:Boolean(t)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function $e({onError:e,onLoading:i,onSuccess:t}={}){let n=O(["WADESTA_USE_CONNECT",e,i,t],h,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:i,onSuccess:s=>Promise.resolve(t==null?void 0:t(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:z(),connect:n.mutate,connectAsync:n.mutateAsync,status:n.status}}function Xe({onError:e,onLoading:i,onSuccess:t}={}){let n=O(["WADESTA_USE_DISCONNECT",e,i,t],w,{onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:i,onSuccess:()=>Promise.resolve(t==null?void 0:t(void 0))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,disconnect:n.mutate,disconnectAsync:n.mutateAsync,status:n.status}}function Ye(){return r(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),oe)}import{useMutation as re}from"react-query";function on(){return r(e=>e.activeChain)}function rn({onError:e,onLoading:i,onSuccess:t}={}){let n=re(["WADESTA_USE_SUGGEST_CHAIN",e,i,t],k,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:i,onSuccess:s=>Promise.resolve(t==null?void 0:t(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}import{useQuery as q}from"react-query";function un(e){let i=r(n=>n.client),o=q(["USE_CLIENT",e,i],({queryKey:[,n,s]})=>n!=null&&n.rpc?p(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:o.data,error:o.error,isFetching:o.isFetching,isLoading:o.isLoading,isRefetching:o.isRefetching,isSuccess:o.isSuccess,refetch:o.refetch,status:o.status}}function pn(e){let i=r(n=>n.signingClient),o=q(["USE_SIGNING_CLIENT",e,i],({queryKey:[,n,s]})=>n!=null&&n.rpc?l(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:o.data,error:o.error,isFetching:o.isFetching,isLoading:o.isLoading,isRefetching:o.isRefetching,isSuccess:o.isSuccess,refetch:o.refetch,status:o.status}}import{QueryClient as ce,QueryClientProvider as ae}from"react-query";import{useEffect as se}from"react";function G(){return se(()=>{r.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=r.getState();return e&&m(),window.addEventListener("focus",m),window.addEventListener("keplr_keystorechange",m),()=>{window.removeEventListener("focus",m),window.removeEventListener("keplr_keystorechange",m)}},[]),null}var me=new ce({defaultOptions:{queries:{notifyOnChangeProps:"tracked"}}});function Sn({children:e}){return c.createElement(ae,{key:"graz-query-client",client:me},c.createElement(G,null),e)}export{Sn as GrazProvider,h as connect,Re as defaultChains,Ne as defaultChainsArray,Ee as defineChains,w as disconnect,A as getBalances,u as getKeplr,m as reconnect,ye as registerKeplrNotFound,k as suggestChain,de as unregisterKeplrNotFound,ie as useAccount,on as useActiveChain,Ve as useBalances,z as useCheckKeplr,un as useClient,$e as useConnect,Xe as useDisconnect,Ye as useSigners,pn as useSigningClient,rn as useSuggestChain};
|
|
1
|
+
import{a as c}from"./chunk-L7O257ZE.mjs";import{GasPrice as te}from"@cosmjs/stargate";import Z from"zustand";import{persist as ee,subscribeWithSelector as ne}from"zustand/middleware";var C={account:null,activeChain:null,balances:null,client:null,defaultChain:null,offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClient:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},r=Z(ne(ee(()=>({...C}),{name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1})));import{SigningCosmWasmClient as b}from"@cosmjs/cosmwasm-stargate";async function u({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}};return await b.connect(o)}async function l(e){let{rpc:t,rpcHeaders:o,offlineSigner:s,signerOptions:n={}}=e,i={url:t,headers:{...o||{}}};return await b.connectWithSigner(i,s,n)}function g(){if(typeof window.keplr<"u")return window.keplr;throw r.getState()._notFoundFn(),new Error("Keplr is not defined")}function We(e){r.setState({_notFoundFn:e})}function _e(){r.setState({_notFoundFn:()=>null})}async function p(e){try{let t=g(),{defaultChain:o,recentChain:s}=r.getState(),n=e||s||o;if(!n)throw new Error("No last known connected chain, connect action requires chain info");r.setState(f=>{let Y=f._reconnect;return f.activeChain&&f.activeChain.chainId!==n.chainId?{status:"connecting"}:Y?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let i=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),J=n.gas?te.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[v,V,X,$]=await Promise.all([t.getKey(n.chainId),u(n),t.getOfflineSignerAuto(n.chainId),l({...n,offlineSigner:i,signerOptions:{gasPrice:J,...(e==null?void 0:e.signerOpts)||{}}})]);return r.setState({account:v,activeChain:n,client:V,offlineSigner:i,offlineSignerAmino:a,offlineSignerAuto:X,recentChain:n,signingClient:$,status:"connected",_reconnect:!0}),v}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function j(e=!1){return r.setState(t=>({...C,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function z(e){let{activeChain:t,signingClient:o}=r.getState();if(!t||!o)throw new Error("No connected account detected");return await Promise.all(t.currencies.map(async n=>o.getBalance(e,n.coinMinimalDenom)))}function m(){let{activeChain:e}=r.getState();e&&p(e)}function Ze(e){return r.setState({defaultChain:e}),e}function en(){return r.getState().recentChain}function G(){r.setState({recentChain:null})}async function y(e){return await g().experimentalSuggestChain(e),e}async function O(e){let t=await y(e);return{account:await p(e),chain:t}}import{Bech32Address as oe}from"@keplr-wallet/cosmos";var q={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},ie={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},re={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},se={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ce={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ae={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},M=[q,ie,re,se,ce,ae],d={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:q,bip44:{coinType:118},bech32Config:oe.defaultBech32Config("axelar"),currencies:M,feeCurrencies:M};import{Bech32Address as me}from"@keplr-wallet/cosmos";var K={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},U=[K],w={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:K,bip44:{coinType:118},bech32Config:me.defaultBech32Config("cosmos"),currencies:U,feeCurrencies:U};import{Bech32Address as pe}from"@keplr-wallet/cosmos";var T={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},B=[T],A={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:pe.defaultBech32Config("CRE"),currencies:B,feeCurrencies:B,stakeCurrency:T,coinType:118};import{Bech32Address as ue}from"@keplr-wallet/cosmos";var P={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},le={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},ge={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"},fe={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ce={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"},de={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},we={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Ae={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Se={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},N=[P,le,ge,he,fe,Ce,ye,de,we,Ae,Se],S={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:P,bip44:{coinType:118},bech32Config:ue.defaultBech32Config("juno"),currencies:N,feeCurrencies:N};import{Bech32Address as xe}from"@keplr-wallet/cosmos";var E={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ke={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},R=[E,ke],x={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:E,bip44:{coinType:118},bech32Config:xe.defaultBech32Config("osmo"),currencies:R,feeCurrencies:R};import{Bech32Address as Ie}from"@keplr-wallet/cosmos";var k={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},De=[k],I={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:k,bip44:{coinType:118},bech32Config:Ie.defaultBech32Config("osmo"),currencies:De,feeCurrencies:[k],coinType:118};import{Bech32Address as ve}from"@keplr-wallet/cosmos";var _={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},W=[_],D={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:_,bip44:{coinType:118},bech32Config:ve.defaultBech32Config("somm"),currencies:W,feeCurrencies:W};function In(e){return e}var Dn={axelar:d,cosmos:w,juno:S,osmosis:x,sommelier:D},vn=[d,w,S,x,D],bn={crescent:A,osmosis:I},jn=[A,I];import{useEffect as be}from"react";import{useMutation as F,useQuery as je}from"react-query";import ze from"zustand/shallow";function h(){return r(e=>e._supported)}function Ge({onConnect:e,onDisconnect:t}={}){let o=r(n=>n.account),s=r(n=>n.status);return be(()=>r.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let a=r.getState();e==null||e({account:a.account,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:s==="connecting",isDisconnected:s==="disconnected",isReconnecting:s==="reconnecting",reconnect:m,status:s}}function Nn(e){let{data:t}=Ge(),o=e||(t==null?void 0:t.bech32Address),n=je(["USE_BALANCES",o],({queryKey:[,i]})=>z(i),{enabled:Boolean(o)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function Pn({onError:e,onLoading:t,onSuccess:o}={}){let n=F(["USE_CONNECT",e,t,o],p,{onError:(i,a)=>Promise.resolve(e==null?void 0:e(i,a)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{connect:i=>n.mutate(i),connectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status}}function Rn({onError:e,onLoading:t,onSuccess:o}={}){let n=F(["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}}function En(){return r(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),ze)}import{useMutation as L}from"react-query";function Qn(){return r(e=>e.activeChain)}function Jn(){return{data:r(t=>t.recentChain),clear:G}}function Vn({onError:e,onLoading:t,onSuccess:o}={}){let n=L(["USE_SUGGEST_CHAIN",e,t,o],y,{onError:(i,a)=>Promise.resolve(e==null?void 0:e(i,a)),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}}function Xn({onError:e,onLoading:t,onSuccess:o}={}){let n=L(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],O,{onError:(i,a)=>Promise.resolve(e==null?void 0:e(i,a)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}import{useQuery as H}from"react-query";function nt(e){let t=r(n=>n.client),s=H(["USE_CLIENT",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?u(n):i,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:s.data,error:s.error,isFetching:s.isFetching,isLoading:s.isLoading,isRefetching:s.isRefetching,isSuccess:s.isSuccess,refetch:s.refetch,status:s.status}}function tt(e){let t=r(n=>n.signingClient),s=H(["USE_SIGNING_CLIENT",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?l(n):i,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:s.data,error:s.error,isFetching:s.isFetching,isLoading:s.isLoading,isRefetching:s.isRefetching,isSuccess:s.isSuccess,refetch:s.refetch,status:s.status}}import{QueryClient as Me,QueryClientProvider as qe}from"react-query";import{useEffect as Oe}from"react";function Q(){return Oe(()=>{r.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=r.getState();return e&&m(),window.addEventListener("keplr_keystorechange",m),()=>{window.removeEventListener("keplr_keystorechange",m)}},[]),null}var Ue=new Me({defaultOptions:{queries:{notifyOnChangeProps:"tracked"}}});function pt({children:e}){return c.createElement(qe,{key:"graz-query-client",client:Ue},c.createElement(Q,null),e)}export{pt as GrazProvider,G as clearRecentChain,Ze as configureDefaultChain,p as connect,u as createClient,l as createSigningClient,In as defineChains,j as disconnect,z as getBalances,g as getKeplr,en as getRecentChain,Dn as mainnetChains,vn as mainnetChainsArray,m as reconnect,We as registerKeplrNotFound,y as suggestChain,O as suggestChainAndConnect,bn as testnetChains,jn as testnetChainsArray,_e as unregisterKeplrNotFound,Ge as useAccount,Qn as useActiveChain,Nn as useBalances,h as useCheckKeplr,nt as useClient,Pn as useConnect,Rn as useDisconnect,Jn as useRecentChain,En as useSigners,tt as useSigningClient,Vn as useSuggestChain,Xn as useSuggestChainAndConnect};
|
package/dist/keplr.d.ts
ADDED
package/dist/keplr.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("@keplr-wallet/cosmos"),module.exports);r(o,require("@keplr-wallet/types"),module.exports);
|
package/dist/keplr.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-L7O257ZE.mjs";export*from"@keplr-wallet/cosmos";export*from"@keplr-wallet/types";
|
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.8",
|
|
5
5
|
"author": "Griko Nibras <griko@stranvgelove.ventures>",
|
|
6
6
|
"repository": "https://github.com/strangelove-ventures/graz.git",
|
|
7
7
|
"homepage": "https://github.com/strangelove-ventures/graz",
|