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