graz 0.0.44 → 0.0.45-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,13 +1,12 @@
1
+ import { ChainInfo, AppCurrency, Bech32Config, Keplr, Key, OfflineAminoSigner, OfflineDirectSigner as OfflineDirectSigner$1 } from '@keplr-wallet/types';
2
+ import { SignClientTypes } from '@walletconnect/types';
3
+ import { Web3ModalConfig } from '@web3modal/standalone';
1
4
  import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
2
- import { SigningCosmWasmClientOptions, CosmWasmClient, SigningCosmWasmClient, InstantiateOptions, InstantiateResult, ExecuteResult } from '@cosmjs/cosmwasm-stargate';
3
- import * as _keplr_wallet_types from '@keplr-wallet/types';
4
- import { ChainInfo, AppCurrency, Keplr, Key } from '@keplr-wallet/types';
5
- import * as _cosmjs_proto_signing from '@cosmjs/proto-signing';
6
- import { Coin, OfflineSigner, OfflineDirectSigner } from '@cosmjs/proto-signing';
7
- import { QueryClient, StargateClient, SigningStargateClient, SigningStargateClientOptions, StdFee, DeliverTxResponse, StakingExtension } from '@cosmjs/stargate';
5
+ import { CosmWasmClient, SigningCosmWasmClientOptions, SigningCosmWasmClient, InstantiateOptions } from '@cosmjs/cosmwasm-stargate';
6
+ import { OfflineSigner, OfflineDirectSigner, Coin } from '@cosmjs/proto-signing';
7
+ import * as _cosmjs_stargate from '@cosmjs/stargate';
8
+ import { StargateClient, StargateClientOptions, SigningStargateClient, StdFee, DeliverTxResponse, QueryClient, StakingExtension, Coin as Coin$1 } from '@cosmjs/stargate';
8
9
  import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
9
- import { ISignClient, SignClientTypes } from '@walletconnect/types';
10
- import { Web3ModalConfig } from '@web3modal/standalone';
11
10
  import { Height } from 'cosmjs-types/ibc/core/client/v1/client';
12
11
  import { OfflineSigner as OfflineSigner$1 } from '@cosmjs/launchpad';
13
12
  import * as _tanstack_react_query from '@tanstack/react-query';
@@ -34,6 +33,7 @@ interface GrazChain {
34
33
  price: string;
35
34
  denom: string;
36
35
  };
36
+ bech32Config: Bech32Config;
37
37
  }
38
38
  /**
39
39
  * Helper function to define chain information records (key values).
@@ -158,6 +158,21 @@ declare const testnetChains: {
158
158
  */
159
159
  declare const testnetChainsArray: ChainInfo[];
160
160
 
161
+ type Clients = "cosmWasm" | "stargate" | "tendermint";
162
+ type ConnectClientArgs<T extends Clients> = Pick<GrazChain, "rpc" | "rpcHeaders"> & {
163
+ client: T;
164
+ };
165
+ type ConnectClient<T> = T extends "cosmWasm" ? CosmWasmClient : T extends "stargate" ? StargateClient : T extends "tendermint" ? Tendermint34Client : never;
166
+ declare const connectClient: <T extends Clients>({ rpc, rpcHeaders, client }: ConnectClientArgs<T>) => Promise<ConnectClient<T>>;
167
+ type SigningClients = "cosmWasm" | "stargate";
168
+ type ConnectSigningClientArgs<T extends SigningClients> = Pick<GrazChain, "rpc" | "rpcHeaders"> & {
169
+ client: T;
170
+ offlineSignerAuto: OfflineSigner | OfflineDirectSigner;
171
+ options?: T extends "cosmWasm" ? SigningCosmWasmClientOptions : T extends "stargate" ? StargateClientOptions : never;
172
+ };
173
+ type ConnectSigningClient<T> = T extends "cosmWasm" ? SigningCosmWasmClient : T extends "stargate" ? SigningStargateClient : never;
174
+ declare const connectSigningClient: <T extends SigningClients>(args: ConnectSigningClientArgs<T>) => Promise<ConnectSigningClient<T>>;
175
+
161
176
  declare enum WalletType {
162
177
  KEPLR = "keplr",
163
178
  LEAP = "leap",
@@ -174,108 +189,68 @@ type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOffline
174
189
  init?: () => Promise<unknown>;
175
190
  };
176
191
 
192
+ interface WalletConnectStore {
193
+ options: SignClientTypes.Options | null;
194
+ web3Modal?: Pick<Web3ModalConfig, "themeVariables" | "themeMode" | "privacyPolicyUrl" | "termsOfServiceUrl"> | null;
195
+ }
196
+ interface GrazInternalStore {
197
+ chains: GrazChain[] | null;
198
+ recentChains: string[] | null;
199
+ defaultClient: Clients;
200
+ defaultSigningClient: SigningClients;
201
+ walletType: WalletType;
202
+ walletConnect: WalletConnectStore | null;
203
+ _notFoundFn: () => void;
204
+ _reconnect: boolean;
205
+ _reconnectConnector: WalletType | null;
206
+ _onReconnectFailed: () => void;
207
+ }
208
+ interface GrazAccountSession {
209
+ account: Key | null;
210
+ chainId: string;
211
+ status: "connected" | "connecting" | "reconnecting" | "disconnected";
212
+ }
213
+
177
214
  type ConnectArgs = Maybe<{
178
- chain?: GrazChain;
179
- signerOpts?: SigningCosmWasmClientOptions;
215
+ chainId: string[];
180
216
  walletType?: WalletType;
181
217
  autoReconnect?: boolean;
182
218
  }>;
183
219
  interface ConnectResult {
184
- account: Key;
185
220
  walletType: WalletType;
186
- chain: GrazChain;
221
+ sessions: GrazAccountSession[];
187
222
  }
188
223
  declare const connect: (args?: ConnectArgs) => Promise<ConnectResult>;
189
- declare const disconnect: (clearRecentChain?: boolean) => Promise<void>;
224
+ interface OfflineSigners {
225
+ offlineSigner: OfflineAminoSigner & OfflineDirectSigner$1;
226
+ offlineSignerAmino: OfflineAminoSigner;
227
+ offlineSignerAuto: OfflineAminoSigner | OfflineDirectSigner$1;
228
+ }
229
+ declare const getOfflineSigners: (args?: {
230
+ walletType?: WalletType;
231
+ chainId: string;
232
+ }) => Promise<OfflineSigners>;
233
+ declare const disconnect: (args?: {
234
+ chainId?: string[];
235
+ }) => Promise<void>;
190
236
  type ReconnectArgs = Maybe<{
191
237
  onError?: (error: unknown) => void;
192
238
  }>;
193
239
  declare const reconnect: (args?: ReconnectArgs) => Promise<ConnectResult | undefined>;
194
240
 
195
- type ExtensionSetup<P extends object = object> = (queryClient: QueryClient) => P;
196
-
197
- interface CreateQueryClient {
198
- (): QueryClient;
199
- <A extends object>(setupA: ExtensionSetup<A>): QueryClient & A;
200
- <A extends object, B extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>): QueryClient & A & B;
201
- <A extends object, B extends object, C extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>): QueryClient & A & B & C;
202
- <A extends object, B extends object, C extends object, D extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>): QueryClient & A & B & C & D;
203
- <A extends object, B extends object, C extends object, D extends object, E extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>, setupE: ExtensionSetup<E>): QueryClient & A & B & C & D & E;
204
- <A extends object, B extends object, C extends object, D extends object, E extends object, F extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>, setupE: ExtensionSetup<E>, setupF: ExtensionSetup<F>): QueryClient & A & B & C & D & E & F;
205
- <A extends object, B extends object, C extends object, D extends object, E extends object, F extends object, G extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>, setupE: ExtensionSetup<E>, setupF: ExtensionSetup<F>, setupG: ExtensionSetup<G>): QueryClient & A & B & C & D & E & F & G;
206
- <A extends object, B extends object, C extends object, D extends object, E extends object, F extends object, G extends object, H extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>, setupE: ExtensionSetup<E>, setupF: ExtensionSetup<F>, setupG: ExtensionSetup<G>, setupH: ExtensionSetup<H>): QueryClient & A & B & C & D & E & F & G & H;
207
- <A extends object, B extends object, C extends object, D extends object, E extends object, F extends object, G extends object, H extends object, I extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>, setupE: ExtensionSetup<E>, setupF: ExtensionSetup<F>, setupG: ExtensionSetup<G>, setupH: ExtensionSetup<H>, setupI: ExtensionSetup<I>): QueryClient & A & B & C & D & E & F & G & H & I;
208
- }
209
- /**
210
- * Note: `createQueryClient` creates \@cosmjs/stargate's {@link QueryClient},
211
- * NOT to be confused with \@tanstack/react-query query client
212
- */
213
- declare const createQueryClient: CreateQueryClient;
214
-
215
241
  declare const clearRecentChain: () => void;
216
- declare const getActiveChainCurrency: (denom: string) => AppCurrency | undefined;
217
- declare const getRecentChain: () => GrazChain | null;
242
+ declare const getRecentChains: () => string[] | null;
218
243
  declare const suggestChain: (chainInfo: ChainInfo) => Promise<ChainInfo>;
219
244
  interface SuggestChainAndConnectArgs {
220
245
  chainInfo: ChainInfo;
221
- signerOpts?: SigningCosmWasmClientOptions;
222
- walletType?: WalletType;
223
- gas?: {
224
- price: string;
225
- denom: string;
226
- };
227
- rpcHeaders?: Dictionary;
228
- path?: string;
229
246
  autoReconnect?: boolean;
247
+ walletType?: WalletType;
230
248
  }
231
- declare const suggestChainAndConnect: ({ chainInfo, rpcHeaders, gas, path, ...rest }: SuggestChainAndConnectArgs) => Promise<ConnectResult>;
232
-
233
- interface WalletConnectStore {
234
- options: SignClientTypes.Options | null;
235
- web3Modal?: Pick<Web3ModalConfig, "themeVariables" | "themeMode" | "privacyPolicyUrl" | "termsOfServiceUrl"> | null;
236
- }
237
- interface GrazInternalStore {
238
- defaultChain: GrazChain | null;
239
- defaultSigningClient: "cosmWasm" | "stargate";
240
- recentChain: GrazChain | null;
241
- walletType: WalletType;
242
- walletConnect: WalletConnectStore | null;
243
- _notFoundFn: () => void;
244
- _reconnect: boolean;
245
- _reconnectConnector: WalletType | null;
246
- _onReconnectFailed: () => void;
247
- }
248
- interface GrazSessionStore {
249
- account: Key | null;
250
- activeChain: GrazChain | null;
251
- balances: Coin[] | null;
252
- clients: {
253
- cosmWasm: CosmWasmClient;
254
- stargate: StargateClient;
255
- tendermint: Tendermint34Client;
256
- } | null;
257
- offlineSigner: (OfflineSigner & OfflineDirectSigner) | null;
258
- offlineSignerAmino: OfflineSigner | null;
259
- offlineSignerAuto: (OfflineSigner | OfflineDirectSigner) | null;
260
- signingClients: {
261
- cosmWasm: SigningCosmWasmClient;
262
- stargate: SigningStargateClient;
263
- } | null;
264
- status: "connected" | "connecting" | "reconnecting" | "disconnected";
265
- wcSignClient?: ISignClient | null;
266
- }
267
-
268
- type CreateClientArgs = Pick<GrazChain, "rpc" | "rpcHeaders">;
269
- declare const createClients: ({ rpc, rpcHeaders }: CreateClientArgs) => Promise<GrazSessionStore["clients"]>;
270
- type CreateSigningClientArgs = CreateClientArgs & {
271
- offlineSignerAuto: OfflineSigner | OfflineDirectSigner;
272
- cosmWasmSignerOptions?: SigningCosmWasmClientOptions;
273
- stargateSignerOptions?: SigningStargateClientOptions;
274
- };
275
- declare const createSigningClients: (args: CreateSigningClientArgs) => Promise<GrazSessionStore["signingClients"]>;
249
+ declare const suggestChainAndConnect: (args: SuggestChainAndConnectArgs) => Promise<ConnectResult>;
276
250
 
277
251
  interface ConfigureGrazArgs {
278
- defaultChain?: GrazChain;
252
+ chains?: GrazChain[];
253
+ defaultClient?: GrazInternalStore["defaultClient"];
279
254
  defaultSigningClient?: GrazInternalStore["defaultSigningClient"];
280
255
  defaultWallet?: WalletType;
281
256
  onNotFound?: () => void;
@@ -286,20 +261,29 @@ interface ConfigureGrazArgs {
286
261
  */
287
262
  autoReconnect?: boolean;
288
263
  }
289
- declare const configureGraz: (args?: ConfigureGrazArgs) => ConfigureGrazArgs;
264
+ declare const configureGraz: (args: ConfigureGrazArgs) => ConfigureGrazArgs;
290
265
 
291
- declare const getBalances: (bech32Address: string) => Promise<Coin[]>;
292
- declare const getBalanceStaked: (bech32Address: string) => Promise<Coin | null>;
293
- interface SendTokensArgs {
294
- senderAddress?: string;
266
+ declare const getBalances: <T extends "cosmWasm" | "stargate">({ bech32Address, client, currencies, }: {
267
+ currencies: AppCurrency[];
268
+ bech32Address: string;
269
+ client: ConnectClient<T>;
270
+ }) => Promise<Coin[]>;
271
+ declare const getBalanceStaked: ({ bech32Address, client, }: {
272
+ bech32Address: string;
273
+ client: ConnectClient<"stargate">;
274
+ }) => Promise<Coin | null>;
275
+ interface SendTokensArgs<T> {
276
+ signingClient: ConnectSigningClient<T>;
277
+ senderAddress: string;
295
278
  recipientAddress: string;
296
279
  amount: Coin[];
297
280
  fee: number | StdFee | "auto";
298
281
  memo?: string;
299
282
  }
300
- declare const sendTokens: ({ senderAddress, recipientAddress, amount, fee, memo, }: SendTokensArgs) => Promise<DeliverTxResponse>;
283
+ declare const sendTokens: <T extends SigningClients>({ senderAddress, recipientAddress, amount, fee, memo, signingClient, }: SendTokensArgs<T>) => Promise<DeliverTxResponse>;
301
284
  interface SendIbcTokensArgs {
302
- senderAddress?: string;
285
+ signingClient: ConnectSigningClient<"stargate">;
286
+ senderAddress: string;
303
287
  recipientAddress: string;
304
288
  transferAmount: Coin;
305
289
  sourcePort: string;
@@ -309,8 +293,9 @@ interface SendIbcTokensArgs {
309
293
  fee: number | StdFee | "auto";
310
294
  memo?: string;
311
295
  }
312
- declare const sendIbcTokens: ({ senderAddress, recipientAddress, transferAmount, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, fee, memo, }: SendIbcTokensArgs) => Promise<DeliverTxResponse>;
296
+ declare const sendIbcTokens: ({ signingClient, senderAddress, recipientAddress, transferAmount, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, fee, memo, }: SendIbcTokensArgs) => Promise<DeliverTxResponse>;
313
297
  interface InstantiateContractArgs<Message extends Record<string, unknown>> {
298
+ signingClient: ConnectSigningClient<"cosmWasm">;
314
299
  msg: Message;
315
300
  label: string;
316
301
  fee: StdFee | "auto" | number;
@@ -321,8 +306,9 @@ interface InstantiateContractArgs<Message extends Record<string, unknown>> {
321
306
  type InstantiateContractMutationArgs<Message extends Record<string, unknown>> = Omit<InstantiateContractArgs<Message>, "codeId" | "senderAddress" | "fee"> & {
322
307
  fee?: StdFee | "auto" | number;
323
308
  };
324
- declare const instantiateContract: <Message extends Record<string, unknown>>({ senderAddress, msg, fee, options, label, codeId, }: InstantiateContractArgs<Message>) => Promise<_cosmjs_cosmwasm_stargate.InstantiateResult>;
309
+ declare const instantiateContract: <Message extends Record<string, unknown>>({ signingClient, senderAddress, msg, fee, options, label, codeId, }: InstantiateContractArgs<Message>) => Promise<_cosmjs_cosmwasm_stargate.InstantiateResult>;
325
310
  interface ExecuteContractArgs<Message extends Record<string, unknown>> {
311
+ signingClient: ConnectSigningClient<"cosmWasm">;
326
312
  msg: Message;
327
313
  fee: StdFee | "auto" | number;
328
314
  senderAddress: string;
@@ -335,9 +321,17 @@ type ExecuteContractMutationArgs<Message extends Record<string, unknown>> = Omit
335
321
  funds?: Coin[];
336
322
  memo?: string;
337
323
  };
338
- declare const executeContract: <Message extends Record<string, unknown>>({ senderAddress, msg, fee, contractAddress, funds, memo, }: ExecuteContractArgs<Message>) => Promise<_cosmjs_cosmwasm_stargate.ExecuteResult>;
339
- declare const getQuerySmart: <TData>(address: string, queryMsg: Record<string, unknown>) => Promise<TData>;
340
- declare const getQueryRaw: (address: string, keyStr: string) => Promise<Uint8Array | null>;
324
+ declare const executeContract: <Message extends Record<string, unknown>>({ signingClient, senderAddress, msg, fee, contractAddress, funds, memo, }: ExecuteContractArgs<Message>) => Promise<_cosmjs_cosmwasm_stargate.ExecuteResult>;
325
+ declare const getQuerySmart: <TData>({ client, address, queryMsg, }: {
326
+ client: ConnectClient<"cosmWasm">;
327
+ address: string;
328
+ queryMsg: Record<string, unknown>;
329
+ }) => Promise<TData>;
330
+ declare const getQueryRaw: ({ client, address, keyStr, }: {
331
+ client: ConnectClient<"cosmWasm">;
332
+ address: string;
333
+ keyStr: string;
334
+ }) => Promise<Uint8Array | null>;
341
335
 
342
336
  /**
343
337
  * Function to check whether given {@link WalletType} or default configured wallet exists.
@@ -458,16 +452,25 @@ interface GrazAdapter extends Connector {
458
452
  keystoreEvent: string;
459
453
  }
460
454
 
455
+ interface ChainIdArgs {
456
+ /**
457
+ * if provided, it will only return the data of the given chainId
458
+ */
459
+ chainId?: string | undefined;
460
+ }
461
+ type HookResultDataWithChainId<T, U extends ChainIdArgs> = U["chainId"] extends string ? T : Record<string, T>;
462
+
461
463
  interface MutationEventArgs<TInitial = unknown, TSuccess = TInitial> {
462
464
  onError?: (error: unknown, data: TInitial) => unknown;
463
465
  onLoading?: (data: TInitial) => unknown;
464
466
  onSuccess?: (data: TSuccess) => unknown;
465
467
  }
466
468
 
469
+ type UseConnectOnConnect = GrazAccountSession & {
470
+ isReconnect: boolean;
471
+ };
467
472
  interface UseAccountArgs {
468
- onConnect?: (args: ConnectResult & {
469
- isReconnect: boolean;
470
- }) => void;
473
+ onConnect?: (args: UseConnectOnConnect) => void;
471
474
  onDisconnect?: () => void;
472
475
  }
473
476
  /**
@@ -488,51 +491,7 @@ interface UseAccountArgs {
488
491
  * });
489
492
  * ```
490
493
  */
491
- declare const useAccount: ({ onConnect, onDisconnect }?: UseAccountArgs) => {
492
- data: _keplr_wallet_types.Key | null;
493
- isConnected: boolean;
494
- isConnecting: boolean;
495
- isDisconnected: boolean;
496
- isReconnecting: boolean;
497
- isLoading: boolean;
498
- reconnect: (args?: ReconnectArgs) => Promise<ConnectResult | undefined>;
499
- status: "connected" | "connecting" | "reconnecting" | "disconnected";
500
- };
501
- /**
502
- * graz query hook to retrieve list of balances from current account or given address.
503
- *
504
- * @param bech32Address - Optional bech32 account address, defaults to connected account address
505
- *
506
- * @example
507
- * ```ts
508
- * import { useBalances } from "graz";
509
- *
510
- * // basic example
511
- * const { data, isFetching, refetch, ... } = useBalances();
512
- *
513
- * // with custom bech32 address
514
- * useBalances("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
515
- * ```
516
- */
517
- declare const useBalances: (bech32Address?: string) => UseQueryResult<Coin[]>;
518
- /**
519
- * graz query hook to retrieve specific asset balance from current account or given address.
520
- *
521
- * @param denom - Asset denom to search
522
- * @param bech32Address - Optional bech32 account address, defaults to connected account address
523
- *
524
- * @example
525
- * ```ts
526
- * import { useBalance } from "graz";
527
- *
528
- * // basic example
529
- * const { data, isFetching, refetch, ... } = useBalance("atom");
530
- *
531
- * // with custom bech32 address
532
- * useBalance("atom", "cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
533
- * ```
534
- */
535
- declare const useBalance: (denom: string, bech32Address?: string) => UseQueryResult<Coin | undefined>;
494
+ declare const useAccount: <T extends ChainIdArgs>(args?: (UseAccountArgs & T) | undefined) => HookResultDataWithChainId<GrazAccountSession | undefined, T> | undefined;
536
495
  type UseConnectChainArgs = MutationEventArgs<ConnectArgs, ConnectResult>;
537
496
  /**
538
497
  * graz mutation hook to execute wallet connection with optional arguments to
@@ -602,8 +561,12 @@ declare const useConnect: ({ onError, onLoading, onSuccess }?: UseConnectChainAr
602
561
  * @see {@link disconnect}
603
562
  */
604
563
  declare const useDisconnect: ({ onError, onLoading, onSuccess }?: MutationEventArgs) => {
605
- disconnect: (forget?: boolean) => void;
606
- disconnectAsync: (forget?: boolean) => Promise<void>;
564
+ disconnect: (args?: {
565
+ chainid?: string[];
566
+ }) => void;
567
+ disconnectAsync: (args?: {
568
+ chainid?: string[];
569
+ }) => Promise<void>;
607
570
  error: unknown;
608
571
  isLoading: boolean;
609
572
  isSuccess: boolean;
@@ -620,62 +583,8 @@ declare const useDisconnect: ({ onError, onLoading, onSuccess }?: MutationEventA
620
583
  * const { signer, signerAmino, signerAuto } = useOfflineSigners();
621
584
  * ```
622
585
  */
623
- declare const useOfflineSigners: () => {
624
- signer: (_cosmjs_proto_signing.OfflineSigner & _cosmjs_proto_signing.OfflineDirectSigner) | null;
625
- signerAmino: _cosmjs_proto_signing.OfflineSigner | null;
626
- signerAuto: _cosmjs_proto_signing.OfflineSigner | null;
627
- };
628
- /**
629
- * graz hook to retrieve offline signer objects (default, amino enabled, and auto).
630
- *
631
- * @deprecated prefer using {@link useOfflineSigners}
632
- * @see {@link useOfflineSigners}
633
- */
634
- declare const useSigners: () => {
635
- signer: (_cosmjs_proto_signing.OfflineSigner & _cosmjs_proto_signing.OfflineDirectSigner) | null;
636
- signerAmino: _cosmjs_proto_signing.OfflineSigner | null;
637
- signerAuto: _cosmjs_proto_signing.OfflineSigner | null;
638
- };
639
- /**
640
- * graz query hook to retrieve list of staked balances from current account or given address.
641
- *
642
- * @param bech32Address - Optional bech32 account address, defaults to connected account address
643
- *
644
- * @example
645
- * ```ts
646
- * import { useBalanceStaked } from "graz";
647
- *
648
- * // basic example
649
- * const { data, isFetching, refetch, ... } = useBalanceStaked();
650
- *
651
- * // with custom bech32 address
652
- * useBalanceStaked("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
653
- * ```
654
- */
655
- declare const useBalanceStaked: (bech32Address?: string) => UseQueryResult<Coin | null>;
586
+ declare const useOfflineSigners: <T extends ChainIdArgs>(args?: T | undefined) => UseQueryResult<HookResultDataWithChainId<OfflineSigners, T> | undefined>;
656
587
 
657
- /**
658
- * graz hook to retrieve connected account's active chain
659
- *
660
- * @example
661
- * ```ts
662
- * import { useActiveChain } from "graz";
663
- * const { rpc, rest, chainId, currencies } = useActiveChain();
664
- * ```
665
- */
666
- declare const useActiveChain: () => GrazChain | null;
667
- /**
668
- * graz hook to retrieve specific connected account's currency
669
- *
670
- * @param denom - Currency denom to search
671
- *
672
- * @example
673
- * ```ts
674
- * import { useActiveChainCurrency } from "graz";
675
- * const { data: currency, ... } = useActiveChainCurrency("juno");
676
- * ```
677
- */
678
- declare const useActiveChainCurrency: (denom: string) => UseQueryResult<AppCurrency | undefined>;
679
588
  /**
680
589
  * graz hook to retrieve active chain validators with given query client and optional bond status
681
590
  *
@@ -709,7 +618,7 @@ declare const useActiveChainValidators: <T extends QueryClient & StakingExtensio
709
618
  * @see {@link useActiveChain}
710
619
  */
711
620
  declare const useRecentChain: () => {
712
- data: GrazChain | null;
621
+ data: string[] | null;
713
622
  clear: () => void;
714
623
  };
715
624
  type UseSuggestChainArgs = MutationEventArgs<ChainInfo>;
@@ -792,7 +701,15 @@ declare const useSuggestChainAndConnect: ({ onError, onLoading, onSuccess }?: Us
792
701
  * useClient({ rpc: "https://rpc.cosmoshub.strange.love", });
793
702
  * ```
794
703
  */
795
- declare const useClients: (args?: CreateClientArgs) => UseQueryResult<GrazSessionStore["clients"]>;
704
+ declare const useConnectClient: <T extends Clients, U extends ChainIdArgs>(args?: ({
705
+ client?: T | undefined;
706
+ /**
707
+ *
708
+ * if true, it will only return the client of the given connected chains
709
+ */
710
+ onlyConnectedChains?: boolean | undefined;
711
+ enabled?: boolean | undefined;
712
+ } & U) | undefined) => UseQueryResult<HookResultDataWithChainId<ConnectClient<T>, U> | undefined>;
796
713
  /**
797
714
  * graz query hook to retrieve a SigningCosmWasmClient. If there's no given args it will be using the current connected signer
798
715
  *
@@ -811,180 +728,63 @@ declare const useClients: (args?: CreateClientArgs) => UseQueryResult<GrazSessio
811
728
  * });
812
729
  * ```
813
730
  */
814
- declare const useSigningClients: (args?: CreateSigningClientArgs) => UseQueryResult<GrazSessionStore["signingClients"]>;
731
+ declare const useConnectSigningClient: <T extends SigningClients, U extends ChainIdArgs>(args?: ({
732
+ client?: T | undefined;
733
+ options?: (U["chainId"] extends string ? (T extends "cosmWasm" ? _cosmjs_cosmwasm_stargate.SigningCosmWasmClientOptions : T extends "stargate" ? _cosmjs_stargate.StargateClientOptions : never) | undefined : Record<string, (T extends "cosmWasm" ? _cosmjs_cosmwasm_stargate.SigningCosmWasmClientOptions : T extends "stargate" ? _cosmjs_stargate.StargateClientOptions : never) | undefined>) | undefined;
734
+ } & U) | undefined) => UseQueryResult<HookResultDataWithChainId<ConnectSigningClient<T>, U> | undefined>;
815
735
 
816
- interface UseQueryClient {
817
- (): UseQueryResult<QueryClient>;
818
- <A extends object>(setupA: ExtensionSetup<A>): UseQueryResult<QueryClient & A>;
819
- <A extends object, B extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>): UseQueryResult<QueryClient & A & B>;
820
- <A extends object, B extends object, C extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>): UseQueryResult<QueryClient & A & B & C>;
821
- <A extends object, B extends object, C extends object, D extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>): UseQueryResult<QueryClient & A & B & C & D>;
822
- <A extends object, B extends object, C extends object, D extends object, E extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>, setupE: ExtensionSetup<E>): UseQueryResult<QueryClient & A & B & C & D & E>;
823
- <A extends object, B extends object, C extends object, D extends object, E extends object, F extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>, setupE: ExtensionSetup<E>, setupF: ExtensionSetup<F>): UseQueryResult<QueryClient & A & B & C & D & E & F>;
824
- <A extends object, B extends object, C extends object, D extends object, E extends object, F extends object, G extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>, setupE: ExtensionSetup<E>, setupF: ExtensionSetup<F>, setupG: ExtensionSetup<G>): UseQueryResult<QueryClient & A & B & C & D & E & F & G>;
825
- <A extends object, B extends object, C extends object, D extends object, E extends object, F extends object, G extends object, H extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>, setupE: ExtensionSetup<E>, setupF: ExtensionSetup<F>, setupG: ExtensionSetup<G>, setupH: ExtensionSetup<H>): UseQueryResult<QueryClient & A & B & C & D & E & F & G & H>;
826
- <A extends object, B extends object, C extends object, D extends object, E extends object, F extends object, G extends object, H extends object, I extends object>(setupA: ExtensionSetup<A>, setupB: ExtensionSetup<B>, setupC: ExtensionSetup<C>, setupD: ExtensionSetup<D>, setupE: ExtensionSetup<E>, setupF: ExtensionSetup<F>, setupG: ExtensionSetup<G>, setupH: ExtensionSetup<H>, setupI: ExtensionSetup<I>): UseQueryResult<QueryClient & A & B & C & D & E & F & G & H & I>;
827
- }
828
736
  /**
829
- * graz query hook to create and use {@link QueryClient} similar when using {@link QueryClient.withExtensions}.
830
- *
831
- * Note: `useQueryClient` returns \@cosmjs/stargate's {@link QueryClient},
832
- * NOT to be confused with \@tanstack/react-query useQueryClient.
833
- *
834
- * @example
835
- * ```ts
836
- * // example without extensions
837
- * import { useQueryClient } from "graz";
838
- *
839
- * const queryClient = useQueryClient();
840
- *
841
- * // example with extensions
842
- * import { useQueryClient } from "graz";
843
- * import { setupAuthExtension, setupIbcExtension } from "@cosmjs/stargate";
844
- *
845
- * const queryClientWithExtensions = useQueryClient(setupAuthExtension, setupIbcExtension);
846
- * ```
737
+ * graz query hook to retrieve list of balances from current account or given address.
847
738
  *
848
- * @see {@link createQueryClient}
849
- */
850
- declare const useQueryClient: UseQueryClient;
851
-
852
- /**
853
- * graz mutation hook to send tokens. Note: if `senderAddress` undefined, it will use current connected account address.
739
+ * @param bech32Address - Optional bech32 account address, defaults to connected account address
854
740
  *
855
741
  * @example
856
742
  * ```ts
857
- * import { useSendTokens } from "graz";
743
+ * import { useBalances } from "graz";
858
744
  *
859
745
  * // basic example
860
- * const { sendTokens } = useSendTokens();
746
+ * const { data, isFetching, refetch, ... } = useBalances();
861
747
  *
862
- * sendTokens({
863
- * recipientAddress: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430";
864
- * amount: [coin];
865
- * ...
866
- * })
748
+ * // with custom bech32 address
749
+ * useBalances("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
867
750
  * ```
868
- *
869
- * @see {@link sendTokens}
870
751
  */
871
- declare const useSendTokens: ({ onError, onLoading, onSuccess, }?: MutationEventArgs<SendTokensArgs, DeliverTxResponse>) => {
872
- error: unknown;
873
- isLoading: boolean;
874
- isSuccess: boolean;
875
- sendTokens: _tanstack_react_query.UseMutateFunction<DeliverTxResponse, unknown, SendTokensArgs, unknown>;
876
- sendTokensAsync: _tanstack_react_query.UseMutateAsyncFunction<DeliverTxResponse, unknown, SendTokensArgs, unknown>;
877
- status: "error" | "idle" | "loading" | "success";
878
- };
752
+ declare const useBalances: <T extends "cosmWasm" | "stargate", U extends ChainIdArgs>(args: {
753
+ bech32Address?: string | undefined;
754
+ client?: T | undefined;
755
+ } & U) => UseQueryResult<HookResultDataWithChainId<Coin$1[], U>>;
879
756
  /**
880
- * graz mutation hook to send IBC tokens. Note: if `senderAddress` undefined, it will use current connected account address.
757
+ * graz query hook to retrieve list of staked balances from current account or given address.
881
758
  *
759
+ * @param bech32Address - Optional bech32 account address, defaults to connected account address
882
760
  *
883
761
  * @example
884
762
  * ```ts
885
- * import { useSendIbcTokens } from "graz";
763
+ * import { useBalanceStaked } from "graz";
886
764
  *
887
765
  * // basic example
888
- * const { sendIbcTokens } = useSendIbcTokens();
889
- *
890
- * sendIbcTokens({
891
- * recipientAddress: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430",
892
- * transferAmount: coin,
893
- * ...
894
- * })
895
- * ```
896
- */
897
- declare const useSendIbcTokens: ({ onError, onLoading, onSuccess, }?: MutationEventArgs<SendIbcTokensArgs, DeliverTxResponse>) => {
898
- error: unknown;
899
- isLoading: boolean;
900
- isSuccess: boolean;
901
- sendIbcTokens: _tanstack_react_query.UseMutateFunction<DeliverTxResponse, unknown, SendIbcTokensArgs, unknown>;
902
- sendIbcTokensAsync: _tanstack_react_query.UseMutateAsyncFunction<DeliverTxResponse, unknown, SendIbcTokensArgs, unknown>;
903
- status: "error" | "idle" | "loading" | "success";
904
- };
905
- type UseInstantiateContractArgs<Message extends Record<string, unknown>> = {
906
- codeId: number;
907
- } & MutationEventArgs<InstantiateContractMutationArgs<Message>, InstantiateResult>;
908
- /**
909
- * graz mutation hook to instantiate a CosmWasm smart contract when supported.
910
- *
911
- * @example
912
- * ```ts
913
- * import { useInstantiateContract } from "graz"
914
- *
915
- * const { instantiateContract: instantiateMyContract } = useInstantiateContract({
916
- * codeId: 4,
917
- * onSuccess: ({ contractAddress }) => console.log('Address:', contractAddress)
918
- * })
919
- *
920
- * const instantiateMessage = { foo: 'bar' };
921
- * instantiateMyContract({
922
- * msg: instatiateMessage,
923
- * label: "test"
924
- * });
925
- * ```
926
- */
927
- declare const useInstantiateContract: <Message extends Record<string, unknown>>({ codeId, onError, onLoading, onSuccess, }: UseInstantiateContractArgs<Message>) => {
928
- error: unknown;
929
- isLoading: boolean;
930
- isSuccess: boolean;
931
- instantiateContract: _tanstack_react_query.UseMutateFunction<InstantiateResult, unknown, InstantiateContractMutationArgs<Message>, unknown>;
932
- instantiateContractAsync: _tanstack_react_query.UseMutateAsyncFunction<InstantiateResult, unknown, InstantiateContractMutationArgs<Message>, unknown>;
933
- status: "error" | "idle" | "loading" | "success";
934
- };
935
- type UseExecuteContractArgs<Message extends Record<string, unknown>> = {
936
- contractAddress: string;
937
- } & MutationEventArgs<ExecuteContractMutationArgs<Message>, ExecuteResult>;
938
- /**
939
- * graz mutation hook for executing transactions against a CosmWasm smart
940
- * contract.
941
- *
942
- * @example
943
- * ```ts
944
- * import { useExecuteContract } from "graz"
945
- *
946
- * interface GreetMessage {
947
- * name: string;
948
- * }
949
- *
950
- * interface GreetResponse {
951
- * message: string;
952
- * }
766
+ * const { data, isFetching, refetch, ... } = useBalanceStaked();
953
767
  *
954
- * const contractAddress = "cosmosfoobarbaz";
955
- * const { executeContract } = useExecuteContract<ExecuteMessage>({ contractAddress });
956
- * executeContract({ msg: {
957
- * foo: "bar"
958
- * }}, {
959
- * onSuccess: (data: GreetResponse) => console.log('Got message:', data.message);
960
- * });
768
+ * // with custom bech32 address
769
+ * useBalanceStaked("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
961
770
  * ```
962
771
  */
963
- declare const useExecuteContract: <Message extends Record<string, unknown>>({ contractAddress, onError, onLoading, onSuccess, }: UseExecuteContractArgs<Message>) => {
772
+ declare const useBalanceStaked: <T extends "stargate", U extends ChainIdArgs>(args: {
773
+ bech32Address?: string | undefined;
774
+ client?: T | undefined;
775
+ } & U) => UseQueryResult<HookResultDataWithChainId<Coin$1 | null, U>>;
776
+ declare const useSendTokens: <T extends SigningClients>({ signingClient, signingClientOptions, chainId, onError, onLoading, onSuccess, }: MutationEventArgs<SendTokensArgs<T>, DeliverTxResponse> & {
777
+ signingClient?: T | undefined;
778
+ signingClientOptions?: (T extends "cosmWasm" ? _cosmjs_cosmwasm_stargate.SigningCosmWasmClientOptions : T extends "stargate" ? _cosmjs_stargate.StargateClientOptions : never) | undefined;
779
+ chainId: string;
780
+ }) => {
964
781
  error: unknown;
965
782
  isLoading: boolean;
966
783
  isSuccess: boolean;
967
- executeContract: _tanstack_react_query.UseMutateFunction<ExecuteResult, unknown, ExecuteContractMutationArgs<Message>, unknown>;
968
- executeContractAsync: _tanstack_react_query.UseMutateAsyncFunction<ExecuteResult, unknown, ExecuteContractMutationArgs<Message>, unknown>;
784
+ sendTokens: _tanstack_react_query.UseMutateFunction<DeliverTxResponse, unknown, SendTokensArgs<T>, unknown>;
785
+ sendTokensAsync: _tanstack_react_query.UseMutateAsyncFunction<DeliverTxResponse, unknown, SendTokensArgs<T>, unknown>;
969
786
  status: "error" | "idle" | "loading" | "success";
970
787
  };
971
- /**
972
- * graz query hook for dispatching a "smart" query to a CosmWasm smart
973
- * contract.
974
- *
975
- * @param address - The address of the contract to query
976
- * @param queryMsg - The query message to send to the contract
977
- * @returns A query result with the result returned by the smart contract.
978
- */
979
- declare const useQuerySmart: <TData, TError>(address?: string, queryMsg?: Record<string, unknown>) => UseQueryResult<TData, TError>;
980
- /**
981
- * graz query hook for dispatching a "raw" query to a CosmWasm smart contract.
982
- *
983
- * @param address - The address of the contract to query
984
- * @param key - The key to lookup in the contract storage
985
- * @returns A query result with raw byte array stored at the key queried.
986
- */
987
- declare const useQueryRaw: <TError>(address?: string, key?: string) => UseQueryResult<Uint8Array | null, TError>;
988
788
 
989
789
  /**
990
790
  * graz hook to retrieve current active {@link WalletType}
@@ -1019,9 +819,24 @@ declare const useActiveWalletType: () => {
1019
819
  */
1020
820
  declare const useCheckWallet: (type?: WalletType) => UseQueryResult<boolean>;
1021
821
 
822
+ /**
823
+ * Graz custom hook to track `keplr_keystorechange`, `leap_keystorechange`, `accountChanged` event and reconnect state
824
+ *
825
+ * **Note: only use this hook if not using graz's provider component.**
826
+ */
827
+ declare const useGrazEvents: () => null;
828
+ /**
829
+ * Null component to run {@link useGrazEvents} without affecting component tree.
830
+ *
831
+ * **Note: only use this component if not using graz's provider component.**
832
+ */
833
+ declare const GrazEvents: FC;
834
+
835
+ type GrazConfig = Omit<ConfigureGrazArgs, "chains"> & {
836
+ chains: GrazChain[];
837
+ };
1022
838
  type GrazProviderProps = Partial<QueryClientProviderProps> & {
1023
- grazOptions?: ConfigureGrazArgs;
1024
- debug?: boolean;
839
+ grazConfig: GrazConfig;
1025
840
  };
1026
841
  /**
1027
842
  * Provider component which extends `@tanstack/react-query`'s {@link QueryClientProvider} with built-in query client
@@ -1043,17 +858,4 @@ type GrazProviderProps = Partial<QueryClientProviderProps> & {
1043
858
  */
1044
859
  declare const GrazProvider: FC<GrazProviderProps>;
1045
860
 
1046
- /**
1047
- * Graz custom hook to track `keplr_keystorechange`, `leap_keystorechange`, `accountChanged` event and reconnect state
1048
- *
1049
- * **Note: only use this hook if not using graz's provider component.**
1050
- */
1051
- declare const useGrazEvents: () => null;
1052
- /**
1053
- * Null component to run {@link useGrazEvents} without affecting component tree.
1054
- *
1055
- * **Note: only use this component if not using graz's provider component.**
1056
- */
1057
- declare const GrazEvents: FC;
1058
-
1059
- export { AccountData, ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, ConnectResult, Connector, CreateClientArgs, CreateQueryClient, CreateSigningClientArgs, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GetWalletConnectParams, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseQueryClient, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, Wallet, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createQueryClient, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAvailableWallets, getBalanceStaked, getBalances, getCosmostation, getKeplr, getLeap, getQueryRaw, getQuerySmart, getRecentChain, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useCheckWallet, useClients, useConnect, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClient, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
861
+ export { AccountData, ChainInfoWithPath, Clients, ConfigureGrazArgs, ConnectArgs, ConnectClient, ConnectClientArgs, ConnectResult, ConnectSigningClient, ConnectSigningClientArgs, Connector, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GetWalletConnectParams, GrazAdapter, GrazChain, GrazConfig, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, OfflineSigners, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SigningClients, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, Wallet, WalletType, checkWallet, clearRecentChain, configureGraz, connect, connectClient, connectSigningClient, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getBalanceStaked, getBalances, getCosmostation, getKeplr, getLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChainValidators, useActiveWalletType, useBalanceStaked, useBalances, useCheckWallet, useConnect, useConnectClient, useConnectSigningClient, useDisconnect, useGrazEvents, useOfflineSigners, useRecentChain, useSendTokens, useSuggestChain, useSuggestChainAndConnect };