graz 0.0.45-alpha.1 → 0.0.45

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,31 +420,14 @@ 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
- interface UseAccount {
470
- data?: GrazAccountSession;
471
- isConnected: boolean;
472
- isConnecting: boolean;
473
- isDisconnected: boolean;
474
- isReconnecting: boolean;
475
- isLoading: boolean;
476
- status?: GrazAccountSession["status"];
477
- }
478
429
  interface UseAccountArgs {
479
- onConnect?: (args: GrazAccountSession & {
430
+ onConnect?: (args: ConnectResult & {
480
431
  isReconnect: boolean;
481
432
  }) => void;
482
433
  onDisconnect?: () => void;
@@ -499,7 +450,51 @@ interface UseAccountArgs {
499
450
  * });
500
451
  * ```
501
452
  */
502
- declare const useAccount: <T extends ChainIdArgs>(args?: (UseAccountArgs & T) | undefined) => HookResultDataWithChainId<UseAccount, 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>;
503
498
  type UseConnectChainArgs = MutationEventArgs<ConnectArgs, ConnectResult>;
504
499
  /**
505
500
  * graz mutation hook to execute wallet connection with optional arguments to
@@ -542,7 +537,7 @@ declare const useConnect: ({ onError, onLoading, onSuccess }?: UseConnectChainAr
542
537
  isLoading: boolean;
543
538
  isSuccess: boolean;
544
539
  isSupported: boolean;
545
- status: "error" | "idle" | "loading" | "success";
540
+ status: "error" | "success" | "loading" | "idle";
546
541
  };
547
542
  /**
548
543
  * graz mutation hook to execute wallet disconnection with optional arguments to
@@ -569,16 +564,12 @@ declare const useConnect: ({ onError, onLoading, onSuccess }?: UseConnectChainAr
569
564
  * @see {@link disconnect}
570
565
  */
571
566
  declare const useDisconnect: ({ onError, onLoading, onSuccess }?: MutationEventArgs) => {
572
- disconnect: (args?: {
573
- chainid?: string[];
574
- }) => void;
575
- disconnectAsync: (args?: {
576
- chainid?: string[];
577
- }) => Promise<void>;
567
+ disconnect: (forget?: boolean) => void;
568
+ disconnectAsync: (forget?: boolean) => Promise<void>;
578
569
  error: unknown;
579
570
  isLoading: boolean;
580
571
  isSuccess: boolean;
581
- status: "error" | "idle" | "loading" | "success";
572
+ status: "error" | "success" | "loading" | "idle";
582
573
  };
583
574
  /**
584
575
  * graz hook to retrieve offline signer objects (default, amino enabled, and auto).
@@ -588,11 +579,50 @@ declare const useDisconnect: ({ onError, onLoading, onSuccess }?: MutationEventA
588
579
  * @example
589
580
  * ```ts
590
581
  * import { useOfflineSigners } from "graz";
591
- * 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");
592
600
  * ```
593
601
  */
594
- declare const useOfflineSigners: <T extends ChainIdArgs>(args?: T | undefined) => UseQueryResult<HookResultDataWithChainId<OfflineSigners, T> | undefined>;
602
+ declare const useBalanceStaked: (bech32Address?: string) => UseQueryResult<Coin | null>;
595
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>;
596
626
  /**
597
627
  * graz hook to retrieve active chain validators with given query client and optional bond status
598
628
  *
@@ -626,7 +656,7 @@ declare const useActiveChainValidators: <T extends QueryClient & StakingExtensio
626
656
  * @see {@link useActiveChain}
627
657
  */
628
658
  declare const useRecentChain: () => {
629
- data: string[] | null;
659
+ data: GrazChain | null;
630
660
  clear: () => void;
631
661
  };
632
662
  type UseSuggestChainArgs = MutationEventArgs<ChainInfo>;
@@ -652,7 +682,7 @@ declare const useSuggestChain: ({ onError, onLoading, onSuccess }?: UseSuggestCh
652
682
  isSuccess: boolean;
653
683
  suggest: _tanstack_react_query.UseMutateFunction<ChainInfo, unknown, ChainInfo, unknown>;
654
684
  suggestAsync: _tanstack_react_query.UseMutateAsyncFunction<ChainInfo, unknown, ChainInfo, unknown>;
655
- status: "error" | "idle" | "loading" | "success";
685
+ status: "error" | "success" | "loading" | "idle";
656
686
  };
657
687
  type UseSuggestChainAndConnectArgs = MutationEventArgs<SuggestChainAndConnectArgs, ConnectResult>;
658
688
  /**
@@ -690,109 +720,268 @@ declare const useSuggestChainAndConnect: ({ onError, onLoading, onSuccess }?: Us
690
720
  isLoading: boolean;
691
721
  isSuccess: boolean;
692
722
  isSupported: boolean;
693
- status: "error" | "idle" | "loading" | "success";
723
+ status: "error" | "success" | "loading" | "idle";
694
724
  suggestAndConnect: _tanstack_react_query.UseMutateFunction<ConnectResult, unknown, SuggestChainAndConnectArgs, unknown>;
695
725
  suggestAndConnectAsync: _tanstack_react_query.UseMutateAsyncFunction<ConnectResult, unknown, SuggestChainAndConnectArgs, unknown>;
696
726
  };
697
727
 
698
728
  /**
699
- * 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.
700
730
  *
701
731
  * @example
702
732
  * ```ts
703
- * import { useClient } from "graz";
733
+ * import { useStargateClient } from "graz";
734
+ *
735
+ * const { data:client, isFetching, refetch, ... } = useStargateClient();
704
736
  *
705
- * // use connected client's cosmwasm client
706
- * const { data, isFetching, refetch, ... } = useClient();
737
+ * client.getAccount("address")
707
738
  *
708
- * // initialize new custom client from given arguments
709
- * useClient({ rpc: "https://rpc.cosmoshub.strange.love", });
710
739
  * ```
711
740
  */
712
- declare const useConnectClient: <T extends Clients, U extends ChainIdArgs>(args?: ({
713
- client?: T | undefined;
714
- /**
715
- *
716
- * if true, it will only return the client of the given connected chains
717
- */
718
- onlyConnectedChains?: boolean | undefined;
719
- enabled?: boolean | undefined;
720
- } & U) | undefined) => UseQueryResult<HookResultDataWithChainId<ConnectClient<T>, U> | undefined>;
741
+ declare const useStargateClient: () => UseQueryResult<StargateClient, unknown>;
721
742
  /**
722
- * 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.
723
744
  *
724
745
  * @example
725
746
  * ```ts
726
- * import { useSigningClient } from "graz";
747
+ * import { useCosmWasmClient } from "graz";
727
748
  *
728
- * // get connected client's cosmwasm client
729
- * const { data, isFetching, refetch, ... } = useSigningClient();
749
+ * const { data:client, isFetching, refetch, ... } = useCosmWasmClient();
750
+ *
751
+ * client.getAccount("address")
730
752
  *
731
- * // initialize new custom client with given args
732
- * useSigningClient({
733
- * rpc: "https://rpc.cosmoshub.strange.love",
734
- * offlineSigner: customOfflineSigner,
735
- * ...
736
- * });
737
753
  * ```
738
754
  */
739
- declare const useConnectSigningClient: <T extends SigningClients, U extends ChainIdArgs>(args?: ({
740
- client?: T | undefined;
741
- 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;
742
- } & U) | undefined) => UseQueryResult<HookResultDataWithChainId<ConnectSigningClient<T>, U> | undefined>;
743
-
755
+ declare const useCosmWasmClient: () => UseQueryResult<CosmWasmClient, unknown>;
744
756
  /**
745
- * graz query hook to retrieve list of balances from current account or given address.
757
+ * graz query hook to retrieve a TendermintClient.
746
758
  *
747
- * @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.
748
773
  *
749
774
  * @example
750
775
  * ```ts
751
- * import { useBalances } from "graz";
776
+ * import { useSendTokens, useStargateSigningClient } from "graz";
752
777
  *
753
778
  * // basic example
754
- * const { data, isFetching, refetch, ... } = useBalances();
779
+ * const { data: signingClient } = useStargateSigningClient()
780
+ * const { sendTokens } = useSendTokens();
755
781
  *
756
- * // with custom bech32 address
757
- * useBalances("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
782
+ * sendTokens({
783
+ * signingClient,
784
+ * recipientAddress: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430";
785
+ * amount: [coin];
786
+ * ...
787
+ * })
758
788
  * ```
789
+ *
790
+ * @see {@link sendTokens}
759
791
  */
760
- declare const useBalances: <T extends "cosmWasm" | "stargate", U extends ChainIdArgs>(args: {
761
- bech32Address?: string | undefined;
762
- client?: T | undefined;
763
- } & 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
+ };
764
800
  /**
765
- * 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.
766
802
  *
767
- * @param bech32Address - Optional bech32 account address, defaults to connected account address
768
803
  *
769
804
  * @example
770
805
  * ```ts
771
- * import { useBalanceStaked } from "graz";
806
+ * import { useSendIbcTokens, useStargateSigningClient } from "graz";
772
807
  *
773
808
  * // basic example
774
- * const { data, isFetching, refetch, ... } = useBalanceStaked();
809
+ * const { data: signingClient } = useStargateSigningClient()
810
+ * const { sendIbcTokens } = useSendIbcTokens();
775
811
  *
776
- * // with custom bech32 address
777
- * useBalanceStaked("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
812
+ * sendIbcTokens({
813
+ * signingClient,
814
+ * recipientAddress: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430",
815
+ * transferAmount: coin,
816
+ * ...
817
+ * })
778
818
  * ```
779
819
  */
780
- declare const useBalanceStaked: <T extends "stargate", U extends ChainIdArgs>(args: {
781
- bech32Address?: string | undefined;
782
- client?: T | undefined;
783
- } & U) => UseQueryResult<HookResultDataWithChainId<Coin$1 | null, U>>;
784
- declare const useSendTokens: <T extends SigningClients>({ signingClient, signingClientOptions, chainId, onError, onLoading, onSuccess, }: MutationEventArgs<SendTokensArgs<T>, DeliverTxResponse> & {
785
- signingClient?: T | undefined;
786
- signingClientOptions?: (T extends "cosmWasm" ? _cosmjs_cosmwasm_stargate.SigningCosmWasmClientOptions : T extends "stargate" ? _cosmjs_stargate.StargateClientOptions : never) | undefined;
787
- chainId: string;
788
- }) => {
820
+ declare const useSendIbcTokens: ({ onError, onLoading, onSuccess, }?: MutationEventArgs<SendIbcTokensArgs, DeliverTxResponse>) => {
789
821
  error: unknown;
790
822
  isLoading: boolean;
791
823
  isSuccess: boolean;
792
- sendTokens: _tanstack_react_query.UseMutateFunction<DeliverTxResponse, unknown, SendTokensArgs<T>, unknown>;
793
- sendTokensAsync: _tanstack_react_query.UseMutateAsyncFunction<DeliverTxResponse, unknown, SendTokensArgs<T>, unknown>;
794
- 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";
795
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>;
796
985
 
797
986
  /**
798
987
  * graz hook to retrieve current active {@link WalletType}
@@ -827,23 +1016,9 @@ declare const useActiveWalletType: () => {
827
1016
  */
828
1017
  declare const useCheckWallet: (type?: WalletType) => UseQueryResult<boolean>;
829
1018
 
830
- /**
831
- * Graz custom hook to track `keplr_keystorechange`, `leap_keystorechange`, `accountChanged` event and reconnect state
832
- *
833
- * **Note: only use this hook if not using graz's provider component.**
834
- */
835
- declare const useGrazEvents: () => null;
836
- /**
837
- * Null component to run {@link useGrazEvents} without affecting component tree.
838
- *
839
- * **Note: only use this component if not using graz's provider component.**
840
- */
841
- declare const GrazEvents: FC;
842
-
843
1019
  type GrazProviderProps = Partial<QueryClientProviderProps> & {
844
- grazConfig: Omit<ConfigureGrazArgs, "chains"> & {
845
- chains: GrazChain[];
846
- };
1020
+ grazOptions?: ConfigureGrazArgs;
1021
+ debug?: boolean;
847
1022
  };
848
1023
  /**
849
1024
  * Provider component which extends `@tanstack/react-query`'s {@link QueryClientProvider} with built-in query client
@@ -865,4 +1040,17 @@ type GrazProviderProps = Partial<QueryClientProviderProps> & {
865
1040
  */
866
1041
  declare const GrazProvider: FC<GrazProviderProps>;
867
1042
 
868
- export { AccountData, ChainInfoWithPath, Clients, ConfigureGrazArgs, ConnectArgs, ConnectClient, ConnectClientArgs, ConnectResult, ConnectSigningClient, ConnectSigningClientArgs, Connector, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GetWalletConnectParams, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, OfflineSigners, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SigningClients, SuggestChainAndConnectArgs, UseAccount, 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 };