graz 0.0.45-alpha.1 → 0.1.0-alpha.1
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 +300 -41
- package/dist/index.js +417 -52
- package/dist/index.mjs +399 -50
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import * as _keplr_wallet_types from '@keplr-wallet/types';
|
|
1
2
|
import { ChainInfo, AppCurrency, Bech32Config, Keplr, Key, OfflineAminoSigner, OfflineDirectSigner as OfflineDirectSigner$1 } from '@keplr-wallet/types';
|
|
2
3
|
import { SignClientTypes } from '@walletconnect/types';
|
|
3
4
|
import { Web3ModalConfig } from '@web3modal/standalone';
|
|
4
5
|
import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
|
|
5
|
-
import { CosmWasmClient, SigningCosmWasmClientOptions, SigningCosmWasmClient, InstantiateOptions } from '@cosmjs/cosmwasm-stargate';
|
|
6
|
+
import { CosmWasmClient, SigningCosmWasmClientOptions, SigningCosmWasmClient, InstantiateOptions, InstantiateResult, ExecuteResult } from '@cosmjs/cosmwasm-stargate';
|
|
6
7
|
import { OfflineSigner, OfflineDirectSigner, Coin } from '@cosmjs/proto-signing';
|
|
7
8
|
import * as _cosmjs_stargate from '@cosmjs/stargate';
|
|
8
9
|
import { StargateClient, StargateClientOptions, SigningStargateClient, StdFee, DeliverTxResponse, QueryClient, StakingExtension, Coin as Coin$1 } from '@cosmjs/stargate';
|
|
@@ -263,11 +264,15 @@ interface ConfigureGrazArgs {
|
|
|
263
264
|
}
|
|
264
265
|
declare const configureGraz: (args: ConfigureGrazArgs) => ConfigureGrazArgs;
|
|
265
266
|
|
|
266
|
-
declare const
|
|
267
|
-
currencies: AppCurrency[];
|
|
267
|
+
declare const getAllBalance: <T extends "stargate">({ bech32Address, client, }: {
|
|
268
268
|
bech32Address: string;
|
|
269
269
|
client: ConnectClient<T>;
|
|
270
270
|
}) => Promise<Coin[]>;
|
|
271
|
+
declare const getBalance: <T extends "cosmWasm" | "stargate">({ bech32Address, client, searchDenom, }: {
|
|
272
|
+
searchDenom: string;
|
|
273
|
+
bech32Address: string;
|
|
274
|
+
client: ConnectClient<T>;
|
|
275
|
+
}) => Promise<Coin>;
|
|
271
276
|
declare const getBalanceStaked: ({ bech32Address, client, }: {
|
|
272
277
|
bech32Address: string;
|
|
273
278
|
client: ConnectClient<"stargate">;
|
|
@@ -303,7 +308,7 @@ interface InstantiateContractArgs<Message extends Record<string, unknown>> {
|
|
|
303
308
|
senderAddress: string;
|
|
304
309
|
codeId: number;
|
|
305
310
|
}
|
|
306
|
-
type InstantiateContractMutationArgs<Message extends Record<string, unknown>> = Omit<InstantiateContractArgs<Message>, "codeId" | "senderAddress" | "fee"> & {
|
|
311
|
+
type InstantiateContractMutationArgs<Message extends Record<string, unknown>> = Omit<InstantiateContractArgs<Message>, "codeId" | "senderAddress" | "fee" | "signingClient"> & {
|
|
307
312
|
fee?: StdFee | "auto" | number;
|
|
308
313
|
};
|
|
309
314
|
declare const instantiateContract: <Message extends Record<string, unknown>>({ signingClient, senderAddress, msg, fee, options, label, codeId, }: InstantiateContractArgs<Message>) => Promise<_cosmjs_cosmwasm_stargate.InstantiateResult>;
|
|
@@ -316,7 +321,7 @@ interface ExecuteContractArgs<Message extends Record<string, unknown>> {
|
|
|
316
321
|
funds: Coin[];
|
|
317
322
|
memo: string;
|
|
318
323
|
}
|
|
319
|
-
type ExecuteContractMutationArgs<Message extends Record<string, unknown>> = Omit<ExecuteContractArgs<Message>, "contractAddress" | "senderAddress" | "fee" | "funds" | "memo"> & {
|
|
324
|
+
type ExecuteContractMutationArgs<Message extends Record<string, unknown>> = Omit<ExecuteContractArgs<Message>, "contractAddress" | "senderAddress" | "fee" | "funds" | "memo" | "signingClient"> & {
|
|
320
325
|
fee?: StdFee | "auto" | number;
|
|
321
326
|
funds?: Coin[];
|
|
322
327
|
memo?: string;
|
|
@@ -466,19 +471,11 @@ interface MutationEventArgs<TInitial = unknown, TSuccess = TInitial> {
|
|
|
466
471
|
onSuccess?: (data: TSuccess) => unknown;
|
|
467
472
|
}
|
|
468
473
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
isConnecting: boolean;
|
|
473
|
-
isDisconnected: boolean;
|
|
474
|
-
isReconnecting: boolean;
|
|
475
|
-
isLoading: boolean;
|
|
476
|
-
status?: GrazAccountSession["status"];
|
|
477
|
-
}
|
|
474
|
+
type UseConnectOnConnect = GrazAccountSession & {
|
|
475
|
+
isReconnect: boolean;
|
|
476
|
+
};
|
|
478
477
|
interface UseAccountArgs {
|
|
479
|
-
onConnect?: (args:
|
|
480
|
-
isReconnect: boolean;
|
|
481
|
-
}) => void;
|
|
478
|
+
onConnect?: (args: UseConnectOnConnect) => void;
|
|
482
479
|
onDisconnect?: () => void;
|
|
483
480
|
}
|
|
484
481
|
/**
|
|
@@ -499,7 +496,7 @@ interface UseAccountArgs {
|
|
|
499
496
|
* });
|
|
500
497
|
* ```
|
|
501
498
|
*/
|
|
502
|
-
declare const useAccount: <T extends ChainIdArgs>(args?: (UseAccountArgs & T) | undefined) => HookResultDataWithChainId<
|
|
499
|
+
declare const useAccount: <T extends ChainIdArgs>(args?: (UseAccountArgs & T) | undefined) => HookResultDataWithChainId<GrazAccountSession | undefined, T> | undefined;
|
|
503
500
|
type UseConnectChainArgs = MutationEventArgs<ConnectArgs, ConnectResult>;
|
|
504
501
|
/**
|
|
505
502
|
* graz mutation hook to execute wallet connection with optional arguments to
|
|
@@ -694,6 +691,16 @@ declare const useSuggestChainAndConnect: ({ onError, onLoading, onSuccess }?: Us
|
|
|
694
691
|
suggestAndConnect: _tanstack_react_query.UseMutateFunction<ConnectResult, unknown, SuggestChainAndConnectArgs, unknown>;
|
|
695
692
|
suggestAndConnectAsync: _tanstack_react_query.UseMutateAsyncFunction<ConnectResult, unknown, SuggestChainAndConnectArgs, unknown>;
|
|
696
693
|
};
|
|
694
|
+
declare const useChain: ({ chainId }: {
|
|
695
|
+
chainId: string;
|
|
696
|
+
}) => {
|
|
697
|
+
convertMinimalDenomToDenom: (searchMinimalDenom: string, value: string) => {
|
|
698
|
+
denom: string;
|
|
699
|
+
value: number;
|
|
700
|
+
} | undefined;
|
|
701
|
+
currencies: _keplr_wallet_types.AppCurrency[];
|
|
702
|
+
data: GrazChain;
|
|
703
|
+
} | undefined;
|
|
697
704
|
|
|
698
705
|
/**
|
|
699
706
|
* graz query hook to retrieve a CosmWasmClient, StargateClient and Tendermint34Client. If there's no given arguments it will be using the current connected client
|
|
@@ -742,50 +749,145 @@ declare const useConnectSigningClient: <T extends SigningClients, U extends Chai
|
|
|
742
749
|
} & U) | undefined) => UseQueryResult<HookResultDataWithChainId<ConnectSigningClient<T>, U> | undefined>;
|
|
743
750
|
|
|
744
751
|
/**
|
|
745
|
-
* graz query hook to retrieve
|
|
752
|
+
* graz query hook to retrieve balance from given address, denom and chainId
|
|
746
753
|
*
|
|
747
|
-
* @param bech32Address - Optional bech32
|
|
754
|
+
* @param bech32Address - Optional bech32 address, if not provided will return undefined
|
|
755
|
+
* @param searchDenom - Optional search denom, if not provided will return undefined
|
|
756
|
+
* @param chainId - Required chainId to retrieve the balances from given address
|
|
757
|
+
* @param client - Optional client, if not provided will use the default client
|
|
748
758
|
*
|
|
749
759
|
* @example
|
|
750
760
|
* ```ts
|
|
751
|
-
* import {
|
|
761
|
+
* import { useBalance } from "graz";
|
|
752
762
|
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
763
|
+
* const { data, isFetching, refetch, ... } = useBalance({
|
|
764
|
+
* client: "stargate",
|
|
765
|
+
* chainId: "cosmoshub-4",
|
|
766
|
+
* bech32Address: "cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu",
|
|
767
|
+
* })
|
|
755
768
|
*
|
|
756
|
-
* // with custom bech32 address
|
|
757
|
-
* useBalances("cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu");
|
|
758
769
|
* ```
|
|
759
770
|
*/
|
|
760
|
-
declare const
|
|
771
|
+
declare const useBalance: <T extends "cosmWasm" | "stargate">(args: {
|
|
772
|
+
bech32Address?: string | undefined;
|
|
773
|
+
client?: T | undefined;
|
|
774
|
+
chainId: string;
|
|
775
|
+
searchDenom?: string | undefined;
|
|
776
|
+
}) => UseQueryResult<Coin$1 | undefined>;
|
|
777
|
+
/**
|
|
778
|
+
* graz query hook to retrieve list of balances from given address.
|
|
779
|
+
*
|
|
780
|
+
* @param bech32Address - Optional bech32 address, if not provided will return undefined
|
|
781
|
+
* @param chainId - Optional chainId to retrieve the balances from given address and chainId, if not provided will return all balances currencies from all chains provided from GrazProvider
|
|
782
|
+
* @param client - Optional client, if not provided will use the default client
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* ```ts
|
|
786
|
+
* import { useAllBalances } from "graz";
|
|
787
|
+
*
|
|
788
|
+
* // single chain example
|
|
789
|
+
* const { data, isFetching, refetch, ... } = useAllBalances({
|
|
790
|
+
* client: "stargate",
|
|
791
|
+
* chainId: "cosmoshub-4",
|
|
792
|
+
* bech32Address: "cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu",
|
|
793
|
+
* })
|
|
794
|
+
*
|
|
795
|
+
* // all chains from GrazProvider example
|
|
796
|
+
* const { data, isFetching, refetch, ... } = useAllBalances({
|
|
797
|
+
* client: "stargate",
|
|
798
|
+
* bech32Address: "cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu",
|
|
799
|
+
* })
|
|
800
|
+
* ```
|
|
801
|
+
*/
|
|
802
|
+
declare const useAllBalances: <U extends ChainIdArgs>(args: {
|
|
803
|
+
bech32Address?: string | undefined;
|
|
804
|
+
} & U) => UseQueryResult<HookResultDataWithChainId<Coin$1[] | undefined, U>>;
|
|
805
|
+
/**
|
|
806
|
+
* graz query hook to retrieve list of currencies from defined chains in GrazProvider and given address.
|
|
807
|
+
*
|
|
808
|
+
* @param bech32Address - Optional bech32 address, if not provided will return undefined
|
|
809
|
+
* @param client - Optional client, if not provided will use the default client
|
|
810
|
+
* @param chainId - Optional chainId to retrieve the balances from given address and chainId, if not provided will return all balances currencies from all chains provided from GrazProvider
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* ```ts
|
|
814
|
+
* import { useChainBalances } from "graz";
|
|
815
|
+
*
|
|
816
|
+
* // single chain example
|
|
817
|
+
* const { data, isFetching, refetch, ... } = useChainBalances({
|
|
818
|
+
* client: "stargate",
|
|
819
|
+
* chainId: "cosmoshub-4",
|
|
820
|
+
* bech32Address: "cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu",
|
|
821
|
+
* })
|
|
822
|
+
*
|
|
823
|
+
* // all chains from GrazProvider example
|
|
824
|
+
* const { data, isFetching, refetch, ... } = useChainBalances({
|
|
825
|
+
* client: "stargate",
|
|
826
|
+
* bech32Address: "cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu",
|
|
827
|
+
* })
|
|
828
|
+
* ```
|
|
829
|
+
*/
|
|
830
|
+
declare const useChainBalances: <T extends "cosmWasm" | "stargate", U extends ChainIdArgs>(args: {
|
|
761
831
|
bech32Address?: string | undefined;
|
|
762
832
|
client?: T | undefined;
|
|
763
833
|
} & U) => UseQueryResult<HookResultDataWithChainId<Coin$1[], U>>;
|
|
764
834
|
/**
|
|
765
835
|
* graz query hook to retrieve list of staked balances from current account or given address.
|
|
766
836
|
*
|
|
767
|
-
* @param bech32Address - Optional bech32 account address,
|
|
837
|
+
* @param bech32Address - Optional bech32 account address, if not provided will return undefined
|
|
838
|
+
* @param chainId - Optional chainId to retrieve the balances from given address and chainId, if not provided will return all balances currencies from all chains provided from GrazProvider
|
|
768
839
|
*
|
|
769
840
|
* @example
|
|
770
841
|
* ```ts
|
|
771
842
|
* import { useBalanceStaked } from "graz";
|
|
772
843
|
*
|
|
773
|
-
* //
|
|
774
|
-
* const { data, isFetching, refetch, ... } = useBalanceStaked(
|
|
844
|
+
* // single chain example
|
|
845
|
+
* const { data, isFetching, refetch, ... } = useBalanceStaked({
|
|
846
|
+
* chainId: "cosmoshub-4",
|
|
847
|
+
* bech32Address: "cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu",
|
|
848
|
+
* });
|
|
775
849
|
*
|
|
776
|
-
* //
|
|
777
|
-
* useBalanceStaked(
|
|
850
|
+
* // all chains from GrazProvider example
|
|
851
|
+
* const { data, isFetching, refetch, ... } = useBalanceStaked({
|
|
852
|
+
* bech32Address: "cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu",
|
|
853
|
+
* });
|
|
778
854
|
* ```
|
|
779
855
|
*/
|
|
780
|
-
declare const useBalanceStaked: <
|
|
856
|
+
declare const useBalanceStaked: <U extends ChainIdArgs>(args: {
|
|
781
857
|
bech32Address?: string | undefined;
|
|
782
|
-
client?: T | undefined;
|
|
783
858
|
} & U) => UseQueryResult<HookResultDataWithChainId<Coin$1 | null, U>>;
|
|
784
|
-
|
|
785
|
-
signingClient?: T
|
|
786
|
-
signingClientOptions?:
|
|
859
|
+
interface UseSendTokens<T extends SigningClients> {
|
|
860
|
+
signingClient?: T;
|
|
861
|
+
signingClientOptions?: ConnectSigningClientArgs<T>["options"];
|
|
787
862
|
chainId: string;
|
|
788
|
-
}
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* graz mutation hook to send tokens.
|
|
866
|
+
*
|
|
867
|
+
* @param signingClient - Optional ("stargate" | "cosmWasm") signing client to use, if not provided will use default signing client from GrazProvider
|
|
868
|
+
* @param signingClientOptions - Optional signing client options to use.
|
|
869
|
+
* @param chainId - Required chainId to send tokens to.
|
|
870
|
+
* @param onError - Optional error callback function.
|
|
871
|
+
* @param onLoading - Optional loading callback function.
|
|
872
|
+
* @param onSuccess - Optional success callback function.
|
|
873
|
+
*
|
|
874
|
+
* @example
|
|
875
|
+
* ```ts
|
|
876
|
+
* import { useSendTokens } from "graz";
|
|
877
|
+
*
|
|
878
|
+
* // basic example
|
|
879
|
+
* const { sendTokens } = useSendTokens();
|
|
880
|
+
*
|
|
881
|
+
* sendTokens({
|
|
882
|
+
* recipientAddress: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430";
|
|
883
|
+
* amount: [coin];
|
|
884
|
+
* ...
|
|
885
|
+
* })
|
|
886
|
+
* ```
|
|
887
|
+
*
|
|
888
|
+
* @see {@link sendTokens}
|
|
889
|
+
*/
|
|
890
|
+
declare const useSendTokens: <T extends SigningClients>({ signingClient, signingClientOptions, chainId, onError, onLoading, onSuccess, }: MutationEventArgs<SendTokensArgs<T>, DeliverTxResponse> & UseSendTokens<T>) => {
|
|
789
891
|
error: unknown;
|
|
790
892
|
isLoading: boolean;
|
|
791
893
|
isSuccess: boolean;
|
|
@@ -793,6 +895,154 @@ declare const useSendTokens: <T extends SigningClients>({ signingClient, signing
|
|
|
793
895
|
sendTokensAsync: _tanstack_react_query.UseMutateAsyncFunction<DeliverTxResponse, unknown, SendTokensArgs<T>, unknown>;
|
|
794
896
|
status: "error" | "idle" | "loading" | "success";
|
|
795
897
|
};
|
|
898
|
+
interface UseSendIbcTokens {
|
|
899
|
+
signingClientOptions?: ConnectSigningClientArgs<"stargate">["options"];
|
|
900
|
+
chainId: string;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* graz mutation hook to send IBC tokens.
|
|
904
|
+
*
|
|
905
|
+
* @param chainId - Required chainId to send tokens to.
|
|
906
|
+
* @param signingClientOptions - Optional signing client options to use.
|
|
907
|
+
* @param onError - Optional error callback function.
|
|
908
|
+
* @param onLoading - Optional loading callback function.
|
|
909
|
+
* @param onSuccess - Optional success callback function.
|
|
910
|
+
*
|
|
911
|
+
* @example
|
|
912
|
+
* ```ts
|
|
913
|
+
* import { useSendIbcTokens } from "graz";
|
|
914
|
+
*
|
|
915
|
+
* // basic example
|
|
916
|
+
* const { sendIbcTokens } = useSendIbcTokens();
|
|
917
|
+
*
|
|
918
|
+
* sendIbcTokens({
|
|
919
|
+
* recipientAddress: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430",
|
|
920
|
+
* transferAmount: coin,
|
|
921
|
+
* ...
|
|
922
|
+
* })
|
|
923
|
+
* ```
|
|
924
|
+
*/
|
|
925
|
+
declare const useSendIbcTokens: ({ chainId, signingClientOptions, onError, onLoading, onSuccess, }: MutationEventArgs<SendIbcTokensArgs, DeliverTxResponse> & UseSendIbcTokens) => {
|
|
926
|
+
error: unknown;
|
|
927
|
+
isLoading: boolean;
|
|
928
|
+
isSuccess: boolean;
|
|
929
|
+
sendIbcTokens: _tanstack_react_query.UseMutateFunction<DeliverTxResponse, unknown, SendIbcTokensArgs, unknown>;
|
|
930
|
+
sendIbcTokensAsync: _tanstack_react_query.UseMutateAsyncFunction<DeliverTxResponse, unknown, SendIbcTokensArgs, unknown>;
|
|
931
|
+
status: "error" | "idle" | "loading" | "success";
|
|
932
|
+
};
|
|
933
|
+
type UseInstantiateContractArgs<Message extends Record<string, unknown>> = {
|
|
934
|
+
codeId: number;
|
|
935
|
+
chainId: string;
|
|
936
|
+
signingClientOptions?: ConnectSigningClientArgs<"cosmWasm">["options"];
|
|
937
|
+
} & MutationEventArgs<InstantiateContractMutationArgs<Message>, InstantiateResult>;
|
|
938
|
+
/**
|
|
939
|
+
* graz mutation hook to instantiate a CosmWasm smart contract when supported.
|
|
940
|
+
*
|
|
941
|
+
* @param codeId - Required codeId to instantiate.
|
|
942
|
+
* @param chainId - Required chainId to instantiate contract on.
|
|
943
|
+
* @param signingClientOptions - Optional signing client options to use.
|
|
944
|
+
* @param onError - Optional error callback function.
|
|
945
|
+
* @param onLoading - Optional loading callback function.
|
|
946
|
+
* @param onSuccess - Optional success callback function.
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```ts
|
|
950
|
+
* import { useInstantiateContract } from "graz"
|
|
951
|
+
*
|
|
952
|
+
* const { instantiateContract: instantiateMyContract } = useInstantiateContract({
|
|
953
|
+
* codeId: 4,
|
|
954
|
+
* onSuccess: ({ contractAddress }) => console.log('Address:', contractAddress)
|
|
955
|
+
* })
|
|
956
|
+
*
|
|
957
|
+
* const instantiateMessage = { foo: 'bar' };
|
|
958
|
+
* instantiateMyContract({
|
|
959
|
+
* msg: instatiateMessage,
|
|
960
|
+
* label: "test"
|
|
961
|
+
* });
|
|
962
|
+
* ```
|
|
963
|
+
*/
|
|
964
|
+
declare const useInstantiateContract: <Message extends Record<string, unknown>>({ chainId, codeId, signingClientOptions, onError, onLoading, onSuccess, }: UseInstantiateContractArgs<Message>) => {
|
|
965
|
+
error: unknown;
|
|
966
|
+
isLoading: boolean;
|
|
967
|
+
isSuccess: boolean;
|
|
968
|
+
instantiateContract: _tanstack_react_query.UseMutateFunction<InstantiateResult, unknown, InstantiateContractMutationArgs<Message>, unknown>;
|
|
969
|
+
instantiateContractAsync: _tanstack_react_query.UseMutateAsyncFunction<InstantiateResult, unknown, InstantiateContractMutationArgs<Message>, unknown>;
|
|
970
|
+
status: "error" | "idle" | "loading" | "success";
|
|
971
|
+
};
|
|
972
|
+
type UseExecuteContractArgs<Message extends Record<string, unknown>> = {
|
|
973
|
+
contractAddress: string;
|
|
974
|
+
chainId: string;
|
|
975
|
+
signingClientOptions?: ConnectSigningClientArgs<"cosmWasm">["options"];
|
|
976
|
+
} & MutationEventArgs<ExecuteContractMutationArgs<Message>, ExecuteResult>;
|
|
977
|
+
/**
|
|
978
|
+
* graz mutation hook for executing transactions against a CosmWasm smart
|
|
979
|
+
* contract.
|
|
980
|
+
*
|
|
981
|
+
* @param contractAddress - Required contractAddress to execute against.
|
|
982
|
+
* @param chainId - Required chainId to execute contract on.
|
|
983
|
+
* @param signingClientOptions - Optional signing client options to use.
|
|
984
|
+
* @param onError - Optional error callback function.
|
|
985
|
+
* @param onLoading - Optional loading callback function.
|
|
986
|
+
* @param onSuccess - Optional success callback function.
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* ```ts
|
|
990
|
+
* import { useExecuteContract } from "graz"
|
|
991
|
+
*
|
|
992
|
+
* interface GreetMessage {
|
|
993
|
+
* name: string;
|
|
994
|
+
* }
|
|
995
|
+
*
|
|
996
|
+
* interface GreetResponse {
|
|
997
|
+
* message: string;
|
|
998
|
+
* }
|
|
999
|
+
*
|
|
1000
|
+
* const contractAddress = "cosmosfoobarbaz";
|
|
1001
|
+
* const { executeContract } = useExecuteContract<ExecuteMessage>({ contractAddress });
|
|
1002
|
+
* executeContract({ msg: {
|
|
1003
|
+
* foo: "bar"
|
|
1004
|
+
* }}, {
|
|
1005
|
+
* onSuccess: (data: GreetResponse) => console.log('Got message:', data.message);
|
|
1006
|
+
* });
|
|
1007
|
+
* ```
|
|
1008
|
+
*/
|
|
1009
|
+
declare const useExecuteContract: <Message extends Record<string, unknown>>({ chainId, contractAddress, signingClientOptions, onError, onLoading, onSuccess, }: UseExecuteContractArgs<Message>) => {
|
|
1010
|
+
error: unknown;
|
|
1011
|
+
isLoading: boolean;
|
|
1012
|
+
isSuccess: boolean;
|
|
1013
|
+
executeContract: _tanstack_react_query.UseMutateFunction<ExecuteResult, unknown, ExecuteContractMutationArgs<Message>, unknown>;
|
|
1014
|
+
executeContractAsync: _tanstack_react_query.UseMutateAsyncFunction<ExecuteResult, unknown, ExecuteContractMutationArgs<Message>, unknown>;
|
|
1015
|
+
status: "error" | "idle" | "loading" | "success";
|
|
1016
|
+
};
|
|
1017
|
+
/**
|
|
1018
|
+
* graz query hook for dispatching a "smart" query to a CosmWasm smart
|
|
1019
|
+
* contract.
|
|
1020
|
+
*
|
|
1021
|
+
* @param address - The address of the contract to query
|
|
1022
|
+
* @param queryMsg - The query message to send to the contract
|
|
1023
|
+
* @param chainId - The chainId to query on
|
|
1024
|
+
*
|
|
1025
|
+
* @returns A query result with the result returned by the smart contract.
|
|
1026
|
+
*/
|
|
1027
|
+
declare const useQuerySmart: <TData, TError>({ address, queryMsg, chainId, }: {
|
|
1028
|
+
address?: string | undefined;
|
|
1029
|
+
queryMsg?: Record<string, unknown> | undefined;
|
|
1030
|
+
chainId: string;
|
|
1031
|
+
}) => UseQueryResult<TData, TError>;
|
|
1032
|
+
/**
|
|
1033
|
+
* graz query hook for dispatching a "raw" query to a CosmWasm smart contract.
|
|
1034
|
+
*
|
|
1035
|
+
* @param address - The address of the contract to query
|
|
1036
|
+
* @param key - The key to lookup in the contract storage
|
|
1037
|
+
* @param chainId - The chainId to query on
|
|
1038
|
+
*
|
|
1039
|
+
* @returns A query result with raw byte array stored at the key queried.
|
|
1040
|
+
*/
|
|
1041
|
+
declare const useQueryRaw: <TError>({ address, key, chainId, }: {
|
|
1042
|
+
address?: string | undefined;
|
|
1043
|
+
key?: string | undefined;
|
|
1044
|
+
chainId: string;
|
|
1045
|
+
}) => UseQueryResult<Uint8Array | null, TError>;
|
|
796
1046
|
|
|
797
1047
|
/**
|
|
798
1048
|
* graz hook to retrieve current active {@link WalletType}
|
|
@@ -840,10 +1090,11 @@ declare const useGrazEvents: () => null;
|
|
|
840
1090
|
*/
|
|
841
1091
|
declare const GrazEvents: FC;
|
|
842
1092
|
|
|
1093
|
+
type GrazConfig = Omit<ConfigureGrazArgs, "chains"> & {
|
|
1094
|
+
chains: GrazChain[];
|
|
1095
|
+
};
|
|
843
1096
|
type GrazProviderProps = Partial<QueryClientProviderProps> & {
|
|
844
|
-
grazConfig:
|
|
845
|
-
chains: GrazChain[];
|
|
846
|
-
};
|
|
1097
|
+
grazConfig: GrazConfig;
|
|
847
1098
|
};
|
|
848
1099
|
/**
|
|
849
1100
|
* Provider component which extends `@tanstack/react-query`'s {@link QueryClientProvider} with built-in query client
|
|
@@ -865,4 +1116,12 @@ type GrazProviderProps = Partial<QueryClientProviderProps> & {
|
|
|
865
1116
|
*/
|
|
866
1117
|
declare const GrazProvider: FC<GrazProviderProps>;
|
|
867
1118
|
|
|
868
|
-
|
|
1119
|
+
declare const convertMicroDenomToDenom: (value: number | string, decimals: number) => number;
|
|
1120
|
+
declare const convertDenomToMicroDenom: (value: number | string, decimals: number) => number;
|
|
1121
|
+
declare const convertFromMicroDenom: (denom: string) => string;
|
|
1122
|
+
declare const convertToFixedDecimals: (value: number | string, fractionDigits?: number) => string;
|
|
1123
|
+
declare const formatTokenName: (name: string) => string;
|
|
1124
|
+
declare const handleNaN: (value: number) => number;
|
|
1125
|
+
declare const truncate: (string?: string, slice?: number) => string;
|
|
1126
|
+
|
|
1127
|
+
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, UseExecuteContractArgs, UseInstantiateContractArgs, UseSendIbcTokens, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, Wallet, WalletType, checkWallet, clearRecentChain, configureGraz, connect, connectClient, connectSigningClient, convertDenomToMicroDenom, convertFromMicroDenom, convertMicroDenomToDenom, convertToFixedDecimals, defineChain, defineChainInfo, defineChains, disconnect, executeContract, formatTokenName, getAllBalance, getAvailableWallets, getBalance, getBalanceStaked, getCosmostation, getKeplr, getLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, handleNaN, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, truncate, useAccount, useActiveChainValidators, useActiveWalletType, useAllBalances, useBalance, useBalanceStaked, useChain, useChainBalances, useCheckWallet, useConnect, useConnectClient, useConnectSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useSuggestChain, useSuggestChainAndConnect };
|