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