graz 0.0.45-alpha.2 → 0.0.46

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,18 +1,18 @@
1
- import { ChainInfo, AppCurrency, Bech32Config, Keplr, Key, OfflineAminoSigner, OfflineDirectSigner as OfflineDirectSigner$1 } from '@keplr-wallet/types';
1
+ import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
2
+ import { SigningCosmWasmClientOptions, SigningCosmWasmClient, InstantiateOptions, CosmWasmClient, InstantiateResult, ExecuteResult } from '@cosmjs/cosmwasm-stargate';
3
+ import { OfflineDirectSigner, Coin } from '@cosmjs/proto-signing';
4
+ import * as _keplr_wallet_types from '@keplr-wallet/types';
5
+ import { ChainInfo, AppCurrency, Keplr, Key, OfflineAminoSigner } from '@keplr-wallet/types';
2
6
  import { SignClientTypes } from '@walletconnect/types';
3
7
  import { Web3ModalConfig } from '@web3modal/standalone';
4
- import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-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';
9
- import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
8
+ import { SigningStargateClient, StdFee, DeliverTxResponse, QueryClient, StakingExtension, StargateClient, SigningStargateClientOptions } from '@cosmjs/stargate';
10
9
  import { Height } from 'cosmjs-types/ibc/core/client/v1/client';
11
- import { OfflineSigner as OfflineSigner$1 } from '@cosmjs/launchpad';
10
+ import { OfflineSigner } from '@cosmjs/launchpad';
12
11
  import * as _tanstack_react_query from '@tanstack/react-query';
13
12
  import { UseQueryResult, QueryClientProviderProps } from '@tanstack/react-query';
14
13
  import { BondStatusString } from '@cosmjs/stargate/build/modules/staking/queries';
15
14
  import { QueryValidatorsResponse } from 'cosmjs-types/cosmos/staking/v1beta1/query';
15
+ import { Tendermint34Client, Tendermint37Client } from '@cosmjs/tendermint-rpc';
16
16
  import { FC } from 'react';
17
17
 
18
18
  type Dictionary<T = string> = Record<string, T>;
@@ -33,7 +33,6 @@ interface GrazChain {
33
33
  price: string;
34
34
  denom: string;
35
35
  };
36
- bech32Config: Bech32Config;
37
36
  }
38
37
  /**
39
38
  * Helper function to define chain information records (key values).
@@ -158,21 +157,6 @@ declare const testnetChains: {
158
157
  */
159
158
  declare const testnetChainsArray: ChainInfo[];
160
159
 
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
-
176
160
  declare enum WalletType {
177
161
  KEPLR = "keplr",
178
162
  LEAP = "leap",
@@ -189,68 +173,69 @@ type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOffline
189
173
  init?: () => Promise<unknown>;
190
174
  };
191
175
 
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
-
214
176
  type ConnectArgs = Maybe<{
215
- chainId: string[];
177
+ chain?: GrazChain;
178
+ signerOpts?: SigningCosmWasmClientOptions;
216
179
  walletType?: WalletType;
217
180
  autoReconnect?: boolean;
218
181
  }>;
219
182
  interface ConnectResult {
183
+ account: Key;
220
184
  walletType: WalletType;
221
- sessions: GrazAccountSession[];
185
+ chain: GrazChain;
222
186
  }
223
187
  declare const connect: (args?: ConnectArgs) => Promise<ConnectResult>;
188
+ declare const disconnect: (clearRecentChain?: boolean) => Promise<void>;
189
+ type ReconnectArgs = Maybe<{
190
+ onError?: (error: unknown) => void;
191
+ }>;
192
+ declare const reconnect: (args?: ReconnectArgs) => Promise<ConnectResult | undefined>;
224
193
  interface OfflineSigners {
225
- offlineSigner: OfflineAminoSigner & OfflineDirectSigner$1;
194
+ offlineSigner: OfflineAminoSigner & OfflineDirectSigner;
226
195
  offlineSignerAmino: OfflineAminoSigner;
227
- offlineSignerAuto: OfflineAminoSigner | OfflineDirectSigner$1;
196
+ offlineSignerAuto: OfflineAminoSigner | OfflineDirectSigner;
228
197
  }
229
198
  declare const getOfflineSigners: (args?: {
230
199
  walletType?: WalletType;
231
200
  chainId: string;
232
201
  }) => Promise<OfflineSigners>;
233
- declare const disconnect: (args?: {
234
- chainId?: string[];
235
- }) => Promise<void>;
236
- type ReconnectArgs = Maybe<{
237
- onError?: (error: unknown) => void;
238
- }>;
239
- declare const reconnect: (args?: ReconnectArgs) => Promise<ConnectResult | undefined>;
240
202
 
241
203
  declare const clearRecentChain: () => void;
242
- declare const getRecentChains: () => string[] | null;
204
+ declare const getActiveChainCurrency: (denom: string) => AppCurrency | undefined;
205
+ declare const getRecentChain: () => GrazChain | null;
243
206
  declare const suggestChain: (chainInfo: ChainInfo) => Promise<ChainInfo>;
244
207
  interface SuggestChainAndConnectArgs {
245
208
  chainInfo: ChainInfo;
246
- autoReconnect?: boolean;
209
+ signerOpts?: SigningCosmWasmClientOptions;
247
210
  walletType?: WalletType;
211
+ gas?: {
212
+ price: string;
213
+ denom: string;
214
+ };
215
+ rpcHeaders?: Dictionary;
216
+ path?: string;
217
+ autoReconnect?: boolean;
218
+ }
219
+ declare const suggestChainAndConnect: ({ chainInfo, rpcHeaders, gas, path, ...rest }: SuggestChainAndConnectArgs) => Promise<ConnectResult>;
220
+
221
+ interface WalletConnectStore {
222
+ options: SignClientTypes.Options | null;
223
+ web3Modal?: Pick<Web3ModalConfig, "themeVariables" | "themeMode" | "privacyPolicyUrl" | "termsOfServiceUrl"> | null;
224
+ }
225
+ interface GrazInternalStore {
226
+ defaultChain: GrazChain | null;
227
+ defaultSigningClient: "cosmWasm" | "stargate";
228
+ recentChain: GrazChain | null;
229
+ walletType: WalletType;
230
+ walletConnect: WalletConnectStore | null;
231
+ _notFoundFn: () => void;
232
+ _reconnect: boolean;
233
+ _reconnectConnector: WalletType | null;
234
+ _onReconnectFailed: () => void;
248
235
  }
249
- declare const suggestChainAndConnect: (args: SuggestChainAndConnectArgs) => Promise<ConnectResult>;
250
236
 
251
237
  interface ConfigureGrazArgs {
252
- chains?: GrazChain[];
253
- defaultClient?: GrazInternalStore["defaultClient"];
238
+ defaultChain?: GrazChain;
254
239
  defaultSigningClient?: GrazInternalStore["defaultSigningClient"];
255
240
  defaultWallet?: WalletType;
256
241
  onNotFound?: () => void;
@@ -261,29 +246,20 @@ interface ConfigureGrazArgs {
261
246
  */
262
247
  autoReconnect?: boolean;
263
248
  }
264
- declare const configureGraz: (args: ConfigureGrazArgs) => ConfigureGrazArgs;
249
+ declare const configureGraz: (args?: ConfigureGrazArgs) => ConfigureGrazArgs;
265
250
 
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;
251
+ interface SendTokensArgs {
252
+ signingClient?: SigningStargateClient | SigningCosmWasmClient;
253
+ senderAddress?: string;
278
254
  recipientAddress: string;
279
255
  amount: Coin[];
280
256
  fee: number | StdFee | "auto";
281
257
  memo?: string;
282
258
  }
283
- declare const sendTokens: <T extends SigningClients>({ senderAddress, recipientAddress, amount, fee, memo, signingClient, }: SendTokensArgs<T>) => Promise<DeliverTxResponse>;
259
+ declare const sendTokens: ({ signingClient, senderAddress, recipientAddress, amount, fee, memo, }: SendTokensArgs) => Promise<DeliverTxResponse>;
284
260
  interface SendIbcTokensArgs {
285
- signingClient: ConnectSigningClient<"stargate">;
286
- senderAddress: string;
261
+ signingClient?: SigningStargateClient;
262
+ senderAddress?: string;
287
263
  recipientAddress: string;
288
264
  transferAmount: Coin;
289
265
  sourcePort: string;
@@ -295,7 +271,7 @@ interface SendIbcTokensArgs {
295
271
  }
296
272
  declare const sendIbcTokens: ({ signingClient, senderAddress, recipientAddress, transferAmount, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, fee, memo, }: SendIbcTokensArgs) => Promise<DeliverTxResponse>;
297
273
  interface InstantiateContractArgs<Message extends Record<string, unknown>> {
298
- signingClient: ConnectSigningClient<"cosmWasm">;
274
+ signingClient?: SigningCosmWasmClient;
299
275
  msg: Message;
300
276
  label: string;
301
277
  fee: StdFee | "auto" | number;
@@ -308,7 +284,7 @@ type InstantiateContractMutationArgs<Message extends Record<string, unknown>> =
308
284
  };
309
285
  declare const instantiateContract: <Message extends Record<string, unknown>>({ signingClient, senderAddress, msg, fee, options, label, codeId, }: InstantiateContractArgs<Message>) => Promise<_cosmjs_cosmwasm_stargate.InstantiateResult>;
310
286
  interface ExecuteContractArgs<Message extends Record<string, unknown>> {
311
- signingClient: ConnectSigningClient<"cosmWasm">;
287
+ signingClient?: SigningCosmWasmClient;
312
288
  msg: Message;
313
289
  fee: StdFee | "auto" | number;
314
290
  senderAddress: string;
@@ -322,16 +298,8 @@ type ExecuteContractMutationArgs<Message extends Record<string, unknown>> = Omit
322
298
  memo?: string;
323
299
  };
324
300
  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>;
301
+ declare const getQuerySmart: <TData>(address: string, queryMsg: Record<string, unknown>, client?: CosmWasmClient) => Promise<TData>;
302
+ declare const getQueryRaw: (address: string, keyStr: string, client?: CosmWasmClient) => Promise<Uint8Array | null>;
335
303
 
336
304
  /**
337
305
  * Function to check whether given {@link WalletType} or default configured wallet exists.
@@ -442,9 +410,9 @@ interface AccountData {
442
410
  interface Connector {
443
411
  checkConnector: () => boolean;
444
412
  getAccount: (chainId: string, prefix?: string) => Promise<AccountData>;
445
- getOfflineSigner: (chainId: string) => OfflineSigner$1 & OfflineDirectSigner;
446
- getOfflineSignerOnlyAmino: (chainId: string) => OfflineSigner$1;
447
- getOfflineSignerAuto: (chainId: string) => Promise<OfflineSigner$1 | OfflineDirectSigner>;
413
+ getOfflineSigner: (chainId: string) => OfflineSigner & OfflineDirectSigner;
414
+ getOfflineSignerOnlyAmino: (chainId: string) => OfflineSigner;
415
+ getOfflineSignerAuto: (chainId: string) => Promise<OfflineSigner | OfflineDirectSigner>;
448
416
  }
449
417
  interface GrazAdapter extends Connector {
450
418
  name: string;
@@ -452,25 +420,16 @@ interface GrazAdapter extends Connector {
452
420
  keystoreEvent: string;
453
421
  }
454
422
 
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
-
463
423
  interface MutationEventArgs<TInitial = unknown, TSuccess = TInitial> {
464
424
  onError?: (error: unknown, data: TInitial) => unknown;
465
425
  onLoading?: (data: TInitial) => unknown;
466
426
  onSuccess?: (data: TSuccess) => unknown;
467
427
  }
468
428
 
469
- type UseConnectOnConnect = GrazAccountSession & {
470
- isReconnect: boolean;
471
- };
472
429
  interface UseAccountArgs {
473
- onConnect?: (args: UseConnectOnConnect) => void;
430
+ onConnect?: (args: ConnectResult & {
431
+ isReconnect: boolean;
432
+ }) => void;
474
433
  onDisconnect?: () => void;
475
434
  }
476
435
  /**
@@ -491,7 +450,51 @@ interface UseAccountArgs {
491
450
  * });
492
451
  * ```
493
452
  */
494
- declare const useAccount: <T extends ChainIdArgs>(args?: (UseAccountArgs & T) | undefined) => HookResultDataWithChainId<GrazAccountSession | undefined, T> | undefined;
453
+ declare const useAccount: ({ onConnect, onDisconnect }?: UseAccountArgs) => {
454
+ data: _keplr_wallet_types.Key | null;
455
+ isConnected: boolean;
456
+ isConnecting: boolean;
457
+ isDisconnected: boolean;
458
+ isReconnecting: boolean;
459
+ isLoading: boolean;
460
+ reconnect: (args?: ReconnectArgs) => Promise<ConnectResult | undefined>;
461
+ status: "connected" | "connecting" | "reconnecting" | "disconnected";
462
+ };
463
+ /**
464
+ * graz query hook to retrieve list of balances from current account or given address.
465
+ *
466
+ * @param bech32Address - Optional bech32 account address, defaults to connected account address
467
+ *
468
+ * @example
469
+ * ```ts
470
+ * import { useBalances } from "graz";
471
+ *
472
+ * // basic example
473
+ * const { data, isFetching, refetch, ... } = useBalances();
474
+ *
475
+ * // with custom bech32 address
476
+ * useBalances("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
477
+ * ```
478
+ */
479
+ declare const useBalances: (bech32Address?: string) => UseQueryResult<Coin[]>;
480
+ /**
481
+ * graz query hook to retrieve specific asset balance from current account or given address.
482
+ *
483
+ * @param denom - Asset denom to search
484
+ * @param bech32Address - Optional bech32 account address, defaults to connected account address
485
+ *
486
+ * @example
487
+ * ```ts
488
+ * import { useBalance } from "graz";
489
+ *
490
+ * // basic example
491
+ * const { data, isFetching, refetch, ... } = useBalance("atom");
492
+ *
493
+ * // with custom bech32 address
494
+ * useBalance("atom", "cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
495
+ * ```
496
+ */
497
+ declare const useBalance: (denom: string, bech32Address?: string) => UseQueryResult<Coin | undefined>;
495
498
  type UseConnectChainArgs = MutationEventArgs<ConnectArgs, ConnectResult>;
496
499
  /**
497
500
  * graz mutation hook to execute wallet connection with optional arguments to
@@ -534,7 +537,7 @@ declare const useConnect: ({ onError, onLoading, onSuccess }?: UseConnectChainAr
534
537
  isLoading: boolean;
535
538
  isSuccess: boolean;
536
539
  isSupported: boolean;
537
- status: "error" | "idle" | "loading" | "success";
540
+ status: "error" | "success" | "loading" | "idle";
538
541
  };
539
542
  /**
540
543
  * graz mutation hook to execute wallet disconnection with optional arguments to
@@ -561,16 +564,12 @@ declare const useConnect: ({ onError, onLoading, onSuccess }?: UseConnectChainAr
561
564
  * @see {@link disconnect}
562
565
  */
563
566
  declare const useDisconnect: ({ onError, onLoading, onSuccess }?: MutationEventArgs) => {
564
- disconnect: (args?: {
565
- chainid?: string[];
566
- }) => void;
567
- disconnectAsync: (args?: {
568
- chainid?: string[];
569
- }) => Promise<void>;
567
+ disconnect: (forget?: boolean) => void;
568
+ disconnectAsync: (forget?: boolean) => Promise<void>;
570
569
  error: unknown;
571
570
  isLoading: boolean;
572
571
  isSuccess: boolean;
573
- status: "error" | "idle" | "loading" | "success";
572
+ status: "error" | "success" | "loading" | "idle";
574
573
  };
575
574
  /**
576
575
  * graz hook to retrieve offline signer objects (default, amino enabled, and auto).
@@ -580,11 +579,50 @@ declare const useDisconnect: ({ onError, onLoading, onSuccess }?: MutationEventA
580
579
  * @example
581
580
  * ```ts
582
581
  * import { useOfflineSigners } from "graz";
583
- * const { signer, signerAmino, signerAuto } = useOfflineSigners();
582
+ * const { offlineSigner, offlineSignerAmino, offlineSignerAuto } = useOfflineSigners();
583
+ * ```
584
+ */
585
+ declare const useOfflineSigners: () => UseQueryResult<OfflineSigners, unknown>;
586
+ /**
587
+ * graz query hook to retrieve list of staked balances from current account or given address.
588
+ *
589
+ * @param bech32Address - Optional bech32 account address, defaults to connected account address
590
+ *
591
+ * @example
592
+ * ```ts
593
+ * import { useBalanceStaked } from "graz";
594
+ *
595
+ * // basic example
596
+ * const { data, isFetching, refetch, ... } = useBalanceStaked();
597
+ *
598
+ * // with custom bech32 address
599
+ * useBalanceStaked("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
584
600
  * ```
585
601
  */
586
- declare const useOfflineSigners: <T extends ChainIdArgs>(args?: T | undefined) => UseQueryResult<HookResultDataWithChainId<OfflineSigners, T> | undefined>;
602
+ declare const useBalanceStaked: (bech32Address?: string) => UseQueryResult<Coin | null>;
587
603
 
604
+ /**
605
+ * graz hook to retrieve connected account's active chain
606
+ *
607
+ * @example
608
+ * ```ts
609
+ * import { useActiveChain } from "graz";
610
+ * const { rpc, rest, chainId, currencies } = useActiveChain();
611
+ * ```
612
+ */
613
+ declare const useActiveChain: () => GrazChain | null;
614
+ /**
615
+ * graz hook to retrieve specific connected account's currency
616
+ *
617
+ * @param denom - Currency denom to search
618
+ *
619
+ * @example
620
+ * ```ts
621
+ * import { useActiveChainCurrency } from "graz";
622
+ * const { data: currency, ... } = useActiveChainCurrency("juno");
623
+ * ```
624
+ */
625
+ declare const useActiveChainCurrency: (denom: string) => UseQueryResult<AppCurrency | undefined>;
588
626
  /**
589
627
  * graz hook to retrieve active chain validators with given query client and optional bond status
590
628
  *
@@ -618,7 +656,7 @@ declare const useActiveChainValidators: <T extends QueryClient & StakingExtensio
618
656
  * @see {@link useActiveChain}
619
657
  */
620
658
  declare const useRecentChain: () => {
621
- data: string[] | null;
659
+ data: GrazChain | null;
622
660
  clear: () => void;
623
661
  };
624
662
  type UseSuggestChainArgs = MutationEventArgs<ChainInfo>;
@@ -644,7 +682,7 @@ declare const useSuggestChain: ({ onError, onLoading, onSuccess }?: UseSuggestCh
644
682
  isSuccess: boolean;
645
683
  suggest: _tanstack_react_query.UseMutateFunction<ChainInfo, unknown, ChainInfo, unknown>;
646
684
  suggestAsync: _tanstack_react_query.UseMutateAsyncFunction<ChainInfo, unknown, ChainInfo, unknown>;
647
- status: "error" | "idle" | "loading" | "success";
685
+ status: "error" | "success" | "loading" | "idle";
648
686
  };
649
687
  type UseSuggestChainAndConnectArgs = MutationEventArgs<SuggestChainAndConnectArgs, ConnectResult>;
650
688
  /**
@@ -682,109 +720,268 @@ declare const useSuggestChainAndConnect: ({ onError, onLoading, onSuccess }?: Us
682
720
  isLoading: boolean;
683
721
  isSuccess: boolean;
684
722
  isSupported: boolean;
685
- status: "error" | "idle" | "loading" | "success";
723
+ status: "error" | "success" | "loading" | "idle";
686
724
  suggestAndConnect: _tanstack_react_query.UseMutateFunction<ConnectResult, unknown, SuggestChainAndConnectArgs, unknown>;
687
725
  suggestAndConnectAsync: _tanstack_react_query.UseMutateAsyncFunction<ConnectResult, unknown, SuggestChainAndConnectArgs, unknown>;
688
726
  };
689
727
 
690
728
  /**
691
- * graz query hook to retrieve a CosmWasmClient, StargateClient and Tendermint34Client. If there's no given arguments it will be using the current connected client
729
+ * graz query hook to retrieve a StargateClient.
692
730
  *
693
731
  * @example
694
732
  * ```ts
695
- * import { useClient } from "graz";
733
+ * import { useStargateClient } from "graz";
734
+ *
735
+ * const { data:client, isFetching, refetch, ... } = useStargateClient();
696
736
  *
697
- * // use connected client's cosmwasm client
698
- * const { data, isFetching, refetch, ... } = useClient();
737
+ * client.getAccount("address")
699
738
  *
700
- * // initialize new custom client from given arguments
701
- * useClient({ rpc: "https://rpc.cosmoshub.strange.love", });
702
739
  * ```
703
740
  */
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>;
741
+ declare const useStargateClient: () => UseQueryResult<StargateClient, unknown>;
713
742
  /**
714
- * graz query hook to retrieve a SigningCosmWasmClient. If there's no given args it will be using the current connected signer
743
+ * graz query hook to retrieve a CosmWasmClient.
715
744
  *
716
745
  * @example
717
746
  * ```ts
718
- * import { useSigningClient } from "graz";
747
+ * import { useCosmWasmClient } from "graz";
719
748
  *
720
- * // get connected client's cosmwasm client
721
- * const { data, isFetching, refetch, ... } = useSigningClient();
749
+ * const { data:client, isFetching, refetch, ... } = useCosmWasmClient();
750
+ *
751
+ * client.getAccount("address")
722
752
  *
723
- * // initialize new custom client with given args
724
- * useSigningClient({
725
- * rpc: "https://rpc.cosmoshub.strange.love",
726
- * offlineSigner: customOfflineSigner,
727
- * ...
728
- * });
729
753
  * ```
730
754
  */
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>;
735
-
755
+ declare const useCosmWasmClient: () => UseQueryResult<CosmWasmClient, unknown>;
736
756
  /**
737
- * graz query hook to retrieve list of balances from current account or given address.
757
+ * graz query hook to retrieve a TendermintClient.
738
758
  *
739
- * @param bech32Address - Optional bech32 account address, defaults to connected account address
759
+ * @example
760
+ * ```ts
761
+ * import { useCosmWasmClient } from "graz";
762
+ *
763
+ * const { data:client, isFetching, refetch, ... } = useTendermintClient("tm37");
764
+ *
765
+ * client.getAccount("address")
766
+ *
767
+ * ```
768
+ */
769
+ declare const useTendermintClient: <T extends "tm34" | "tm37">(type: T) => UseQueryResult<T extends "tm34" ? Tendermint34Client : Tendermint37Client>;
770
+
771
+ /**
772
+ * graz mutation hook to send tokens. Note: if `senderAddress` undefined, it will use current connected account address.
740
773
  *
741
774
  * @example
742
775
  * ```ts
743
- * import { useBalances } from "graz";
776
+ * import { useSendTokens, useStargateSigningClient } from "graz";
744
777
  *
745
778
  * // basic example
746
- * const { data, isFetching, refetch, ... } = useBalances();
779
+ * const { data: signingClient } = useStargateSigningClient()
780
+ * const { sendTokens } = useSendTokens();
747
781
  *
748
- * // with custom bech32 address
749
- * useBalances("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
782
+ * sendTokens({
783
+ * signingClient,
784
+ * recipientAddress: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430";
785
+ * amount: [coin];
786
+ * ...
787
+ * })
750
788
  * ```
789
+ *
790
+ * @see {@link sendTokens}
751
791
  */
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>>;
792
+ declare const useSendTokens: ({ onError, onLoading, onSuccess, }?: MutationEventArgs<SendTokensArgs, DeliverTxResponse>) => {
793
+ error: unknown;
794
+ isLoading: boolean;
795
+ isSuccess: boolean;
796
+ sendTokens: _tanstack_react_query.UseMutateFunction<DeliverTxResponse, unknown, SendTokensArgs, unknown>;
797
+ sendTokensAsync: _tanstack_react_query.UseMutateAsyncFunction<DeliverTxResponse, unknown, SendTokensArgs, unknown>;
798
+ status: "error" | "success" | "loading" | "idle";
799
+ };
756
800
  /**
757
- * graz query hook to retrieve list of staked balances from current account or given address.
801
+ * graz mutation hook to send IBC tokens. Note: if `senderAddress` undefined, it will use current connected account address.
758
802
  *
759
- * @param bech32Address - Optional bech32 account address, defaults to connected account address
760
803
  *
761
804
  * @example
762
805
  * ```ts
763
- * import { useBalanceStaked } from "graz";
806
+ * import { useSendIbcTokens, useStargateSigningClient } from "graz";
764
807
  *
765
808
  * // basic example
766
- * const { data, isFetching, refetch, ... } = useBalanceStaked();
809
+ * const { data: signingClient } = useStargateSigningClient()
810
+ * const { sendIbcTokens } = useSendIbcTokens();
767
811
  *
768
- * // with custom bech32 address
769
- * useBalanceStaked("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
812
+ * sendIbcTokens({
813
+ * signingClient,
814
+ * recipientAddress: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430",
815
+ * transferAmount: coin,
816
+ * ...
817
+ * })
770
818
  * ```
771
819
  */
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
- }) => {
820
+ declare const useSendIbcTokens: ({ onError, onLoading, onSuccess, }?: MutationEventArgs<SendIbcTokensArgs, DeliverTxResponse>) => {
781
821
  error: unknown;
782
822
  isLoading: boolean;
783
823
  isSuccess: boolean;
784
- sendTokens: _tanstack_react_query.UseMutateFunction<DeliverTxResponse, unknown, SendTokensArgs<T>, unknown>;
785
- sendTokensAsync: _tanstack_react_query.UseMutateAsyncFunction<DeliverTxResponse, unknown, SendTokensArgs<T>, unknown>;
786
- status: "error" | "idle" | "loading" | "success";
824
+ sendIbcTokens: _tanstack_react_query.UseMutateFunction<DeliverTxResponse, unknown, SendIbcTokensArgs, unknown>;
825
+ sendIbcTokensAsync: _tanstack_react_query.UseMutateAsyncFunction<DeliverTxResponse, unknown, SendIbcTokensArgs, unknown>;
826
+ status: "error" | "success" | "loading" | "idle";
787
827
  };
828
+ type UseInstantiateContractArgs<Message extends Record<string, unknown>> = {
829
+ codeId: number;
830
+ } & MutationEventArgs<InstantiateContractMutationArgs<Message>, InstantiateResult>;
831
+ /**
832
+ * graz mutation hook to instantiate a CosmWasm smart contract when supported.
833
+ *
834
+ * @example
835
+ * ```ts
836
+ * import { useInstantiateContract, useCosmwasmSigningClient } from "graz"
837
+ *
838
+ * const { data: signingClient } = useCosmwasmSigningClient()
839
+ * const { instantiateContract: instantiateMyContract } = useInstantiateContract({
840
+ * codeId: 4,
841
+ * onSuccess: ({ contractAddress }) => console.log('Address:', contractAddress)
842
+ * })
843
+ *
844
+ * const instantiateMessage = { foo: 'bar' };
845
+ * instantiateMyContract({
846
+ * signingClient,
847
+ * msg: instatiateMessage,
848
+ * label: "test"
849
+ * });
850
+ * ```
851
+ */
852
+ declare const useInstantiateContract: <Message extends Record<string, unknown>>({ codeId, onError, onLoading, onSuccess, }: UseInstantiateContractArgs<Message>) => {
853
+ error: unknown;
854
+ isLoading: boolean;
855
+ isSuccess: boolean;
856
+ instantiateContract: _tanstack_react_query.UseMutateFunction<InstantiateResult, unknown, InstantiateContractMutationArgs<Message>, unknown>;
857
+ instantiateContractAsync: _tanstack_react_query.UseMutateAsyncFunction<InstantiateResult, unknown, InstantiateContractMutationArgs<Message>, unknown>;
858
+ status: "error" | "success" | "loading" | "idle";
859
+ };
860
+ type UseExecuteContractArgs<Message extends Record<string, unknown>> = {
861
+ contractAddress: string;
862
+ } & MutationEventArgs<ExecuteContractMutationArgs<Message>, ExecuteResult>;
863
+ /**
864
+ * graz mutation hook for executing transactions against a CosmWasm smart
865
+ * contract.
866
+ *
867
+ * @example
868
+ * ```ts
869
+ * import { useExecuteContract, useCosmwasmSigningClient } from "graz"
870
+ *
871
+ * interface GreetMessage {
872
+ * name: string;
873
+ * }
874
+ *
875
+ * interface GreetResponse {
876
+ * message: string;
877
+ * }
878
+ *
879
+ * const contractAddress = "cosmosfoobarbaz";
880
+ *
881
+ * const { data: signingClient } = useCosmwasmSigningClient()
882
+ * const { executeContract } = useExecuteContract<ExecuteMessage>({ contractAddress });
883
+ *
884
+ * executeContract({
885
+ * signingClient,
886
+ * msg: {
887
+ * foo: "bar"
888
+ * }}, {
889
+ * onSuccess: (data: GreetResponse) => console.log('Got message:', data.message);
890
+ * });
891
+ * ```
892
+ */
893
+ declare const useExecuteContract: <Message extends Record<string, unknown>>({ contractAddress, onError, onLoading, onSuccess, }: UseExecuteContractArgs<Message>) => {
894
+ error: unknown;
895
+ isLoading: boolean;
896
+ isSuccess: boolean;
897
+ executeContract: _tanstack_react_query.UseMutateFunction<ExecuteResult, unknown, ExecuteContractMutationArgs<Message>, unknown>;
898
+ executeContractAsync: _tanstack_react_query.UseMutateAsyncFunction<ExecuteResult, unknown, ExecuteContractMutationArgs<Message>, unknown>;
899
+ status: "error" | "success" | "loading" | "idle";
900
+ };
901
+ /**
902
+ * graz query hook for dispatching a "smart" query to a CosmWasm smart
903
+ * contract.
904
+ *
905
+ * @param address - The address of the contract to query
906
+ * @param queryMsg - The query message to send to the contract
907
+ * @returns A query result with the result returned by the smart contract.
908
+ */
909
+ declare const useQuerySmart: <TData, TError>(address?: string, queryMsg?: Record<string, unknown>) => UseQueryResult<TData, TError>;
910
+ /**
911
+ * graz query hook for dispatching a "raw" query to a CosmWasm smart contract.
912
+ *
913
+ * @param address - The address of the contract to query
914
+ * @param key - The key to lookup in the contract storage
915
+ * @returns A query result with raw byte array stored at the key queried.
916
+ */
917
+ declare const useQueryRaw: <TError>(address?: string, key?: string) => UseQueryResult<Uint8Array | null, TError>;
918
+
919
+ /**
920
+ * graz query hook to retrieve a SigningStargateClient.
921
+ *
922
+ * @example
923
+ * ```ts
924
+ * import { useStargateSigningClient } from "graz";
925
+ *
926
+ * const { data:signingClient, isFetching, refetch, ... } = useStargateSigningClient();
927
+ *
928
+ * signingClient.getAccount("address")
929
+ *
930
+ * ```
931
+ */
932
+ declare const useStargateSigningClient: (args?: {
933
+ opts?: SigningStargateClientOptions;
934
+ }) => _tanstack_react_query.UseQueryResult<SigningStargateClient, unknown>;
935
+ /**
936
+ * graz query hook to retrieve a SigningCosmWasmClient.
937
+ *
938
+ * @example
939
+ * ```ts
940
+ * import { useCosmWasmSigningClient } from "graz";
941
+ *
942
+ * const { data:signingClient, isFetching, refetch, ... } = useCosmWasmSigningClient();
943
+ *
944
+ * signingClient.getAccount("address")
945
+ *
946
+ * ```
947
+ */
948
+ declare const useCosmWasmSigningClient: (args?: {
949
+ opts?: SigningCosmWasmClientOptions;
950
+ }) => _tanstack_react_query.UseQueryResult<SigningCosmWasmClient, unknown>;
951
+ /**
952
+ * graz query hook to retrieve a SigningStargateClient with tendermint client.
953
+ *
954
+ * @example
955
+ * ```ts
956
+ * import { useStargateTmSigningClient } from "graz";
957
+ *
958
+ * const { data:signingClient, isFetching, refetch, ... } = useStargateTmSigningClient("tm34");
959
+ *
960
+ * signingClient.getAccount("address")
961
+ *
962
+ * ```
963
+ */
964
+ declare const useStargateTmSigningClient: (args: {
965
+ type: "tm34" | "tm37";
966
+ opts?: SigningStargateClientOptions;
967
+ }) => _tanstack_react_query.UseQueryResult<SigningStargateClient, unknown>;
968
+ /**
969
+ * graz query hook to retrieve a SigningCosmWasmClient with tendermint client.
970
+ *
971
+ * @example
972
+ * ```ts
973
+ * import { useCosmWasmTmSigningClient } from "graz";
974
+ *
975
+ * const { data:signingClient, isFetching, refetch, ... } = useCosmWasmTmSigningClient("tm34");
976
+ *
977
+ * signingClient.getAccount("address")
978
+ *
979
+ * ```
980
+ */
981
+ declare const useCosmWasmTmSigningClient: (args: {
982
+ type: "tm34" | "tm37";
983
+ opts?: SigningCosmWasmClientOptions;
984
+ }) => _tanstack_react_query.UseQueryResult<SigningCosmWasmClient, unknown>;
788
985
 
789
986
  /**
790
987
  * graz hook to retrieve current active {@link WalletType}
@@ -819,24 +1016,9 @@ declare const useActiveWalletType: () => {
819
1016
  */
820
1017
  declare const useCheckWallet: (type?: WalletType) => UseQueryResult<boolean>;
821
1018
 
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
- };
838
1019
  type GrazProviderProps = Partial<QueryClientProviderProps> & {
839
- grazConfig: GrazConfig;
1020
+ grazOptions?: ConfigureGrazArgs;
1021
+ debug?: boolean;
840
1022
  };
841
1023
  /**
842
1024
  * Provider component which extends `@tanstack/react-query`'s {@link QueryClientProvider} with built-in query client
@@ -858,4 +1040,17 @@ type GrazProviderProps = Partial<QueryClientProviderProps> & {
858
1040
  */
859
1041
  declare const GrazProvider: FC<GrazProviderProps>;
860
1042
 
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 };
1043
+ /**
1044
+ * Graz custom hook to track `keplr_keystorechange`, `leap_keystorechange`, `accountChanged` event and reconnect state
1045
+ *
1046
+ * **Note: only use this hook if not using graz's provider component.**
1047
+ */
1048
+ declare const useGrazEvents: () => null;
1049
+ /**
1050
+ * Null component to run {@link useGrazEvents} without affecting component tree.
1051
+ *
1052
+ * **Note: only use this component if not using graz's provider component.**
1053
+ */
1054
+ declare const GrazEvents: FC;
1055
+
1056
+ export { AccountData, ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, ConnectResult, Connector, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GetWalletConnectParams, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, OfflineSigners, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, Wallet, WalletType, checkWallet, clearRecentChain, configureGraz, connect, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAvailableWallets, getCosmostation, getKeplr, getLeap, getOfflineSigners, 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, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useCosmWasmTmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useStargateTmSigningClient, useSuggestChain, useSuggestChainAndConnect, useTendermintClient };