graz 0.1.0-alpha.1 → 0.1.0-alpha.3
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 +93 -40
- package/dist/index.js +47 -58
- package/dist/index.mjs +45 -57
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -248,6 +248,9 @@ interface SuggestChainAndConnectArgs {
|
|
|
248
248
|
walletType?: WalletType;
|
|
249
249
|
}
|
|
250
250
|
declare const suggestChainAndConnect: (args: SuggestChainAndConnectArgs) => Promise<ConnectResult>;
|
|
251
|
+
declare const getChain: ({ chainId }: {
|
|
252
|
+
chainId: string;
|
|
253
|
+
}) => GrazChain | undefined;
|
|
251
254
|
|
|
252
255
|
interface ConfigureGrazArgs {
|
|
253
256
|
chains?: GrazChain[];
|
|
@@ -461,7 +464,7 @@ interface ChainIdArgs {
|
|
|
461
464
|
/**
|
|
462
465
|
* if provided, it will only return the data of the given chainId
|
|
463
466
|
*/
|
|
464
|
-
chainId?: string | undefined;
|
|
467
|
+
chainId?: string | string[] | undefined;
|
|
465
468
|
}
|
|
466
469
|
type HookResultDataWithChainId<T, U extends ChainIdArgs> = U["chainId"] extends string ? T : Record<string, T>;
|
|
467
470
|
|
|
@@ -479,15 +482,29 @@ interface UseAccountArgs {
|
|
|
479
482
|
onDisconnect?: () => void;
|
|
480
483
|
}
|
|
481
484
|
/**
|
|
482
|
-
* graz query hook to retrieve account data
|
|
483
|
-
*
|
|
485
|
+
* graz query hook to retrieve account data
|
|
486
|
+
*
|
|
487
|
+
* @param chainId - if provided, it will only return the data of the given chainId
|
|
488
|
+
* @param onConnect - callback function when the account is connected
|
|
489
|
+
* @param onDisconnect - callback function when the account is disconnected
|
|
484
490
|
*
|
|
485
491
|
* @example
|
|
486
492
|
* ```tsx
|
|
487
493
|
* import { useAccount } from "graz";
|
|
488
494
|
*
|
|
489
|
-
* //
|
|
490
|
-
* const
|
|
495
|
+
* // single chain
|
|
496
|
+
* const account = useAccount({
|
|
497
|
+
* chainId: "cosmoshub-4",
|
|
498
|
+
* })
|
|
499
|
+
*
|
|
500
|
+
* return <div>{account?.account.bech32Address}</div>
|
|
501
|
+
*
|
|
502
|
+
* // multi chain
|
|
503
|
+
* const accounts = useAccount();
|
|
504
|
+
*
|
|
505
|
+
* Object.entries(accounts).map(([chainId, account]) => {
|
|
506
|
+
* return <div key={chainId}>{account?.account.bech32Address}</div>
|
|
507
|
+
* })
|
|
491
508
|
*
|
|
492
509
|
* // with event arguments
|
|
493
510
|
* useAccount({
|
|
@@ -502,6 +519,10 @@ type UseConnectChainArgs = MutationEventArgs<ConnectArgs, ConnectResult>;
|
|
|
502
519
|
* graz mutation hook to execute wallet connection with optional arguments to
|
|
503
520
|
* invoke given functions on error, loading, or success event.
|
|
504
521
|
*
|
|
522
|
+
* @param onError - callback function when the connection is failed
|
|
523
|
+
* @param onLoading - callback function when the connection is loading
|
|
524
|
+
* @param onSuccess - callback function when the connection is successful
|
|
525
|
+
*
|
|
505
526
|
* @example
|
|
506
527
|
* ```ts
|
|
507
528
|
* import { useConnect, mainnetChains } from "graz";
|
|
@@ -516,17 +537,8 @@ type UseConnectChainArgs = MutationEventArgs<ConnectArgs, ConnectResult>;
|
|
|
516
537
|
* onSuccess: (account) => { ... },
|
|
517
538
|
* });
|
|
518
539
|
*
|
|
519
|
-
* // use graz provided chain information
|
|
520
|
-
* connect(mainnetChains.cosmos);
|
|
521
|
-
*
|
|
522
|
-
* // use custom chain information
|
|
523
540
|
* connect({
|
|
524
|
-
*
|
|
525
|
-
* rpc: "https://rpc.juno.strange.love",
|
|
526
|
-
* rest: "https://api.juno.strange.love",
|
|
527
|
-
* chainId: "juno-1",
|
|
528
|
-
* ...
|
|
529
|
-
* }
|
|
541
|
+
* chainId: ["cosmoshub-4"],
|
|
530
542
|
* });
|
|
531
543
|
* ```
|
|
532
544
|
*
|
|
@@ -545,6 +557,10 @@ declare const useConnect: ({ onError, onLoading, onSuccess }?: UseConnectChainAr
|
|
|
545
557
|
* graz mutation hook to execute wallet disconnection with optional arguments to
|
|
546
558
|
* invoke given functions on error, loading, or success event.
|
|
547
559
|
*
|
|
560
|
+
* @param onError - callback function when the disconnection is failed
|
|
561
|
+
* @param onLoading - callback function when the disconnection is loading
|
|
562
|
+
* @param onSuccess - callback function when the disconnection is successful
|
|
563
|
+
*
|
|
548
564
|
* @example
|
|
549
565
|
* ```ts
|
|
550
566
|
* import { useDisconnect } from "graz";
|
|
@@ -559,8 +575,11 @@ declare const useConnect: ({ onError, onLoading, onSuccess }?: UseConnectChainAr
|
|
|
559
575
|
* onSuccess: () => { ... },
|
|
560
576
|
* });
|
|
561
577
|
*
|
|
562
|
-
* //
|
|
563
|
-
* disconnect(
|
|
578
|
+
* //disconnect all chains
|
|
579
|
+
* disconnect();
|
|
580
|
+
*
|
|
581
|
+
* //disconnect specific chains
|
|
582
|
+
* disconnect({ chainid: ["cosmoshub-4", "juno-1"] });
|
|
564
583
|
* ```
|
|
565
584
|
*
|
|
566
585
|
* @see {@link disconnect}
|
|
@@ -580,12 +599,21 @@ declare const useDisconnect: ({ onError, onLoading, onSuccess }?: MutationEventA
|
|
|
580
599
|
/**
|
|
581
600
|
* graz hook to retrieve offline signer objects (default, amino enabled, and auto).
|
|
582
601
|
*
|
|
583
|
-
*
|
|
602
|
+
* @param chainId - chain id arguments
|
|
603
|
+
*
|
|
604
|
+
* @returns if chainId is string it will return an object, otherwise it will return a record of objects
|
|
584
605
|
*
|
|
585
606
|
* @example
|
|
586
607
|
* ```ts
|
|
587
608
|
* import { useOfflineSigners } from "graz";
|
|
588
|
-
*
|
|
609
|
+
*
|
|
610
|
+
* // single chain
|
|
611
|
+
* const { offlineSigner, offlineSignerAmino, offlineSignerAuto } = useOfflineSigners({ chainId: "cosmoshub-4" });
|
|
612
|
+
*
|
|
613
|
+
* // multi chain
|
|
614
|
+
* const offlineSigners = useOfflineSigners();
|
|
615
|
+
* offlineSigners["cosmoshub-4"].offlineSignerAuto;
|
|
616
|
+
*
|
|
589
617
|
* ```
|
|
590
618
|
*/
|
|
591
619
|
declare const useOfflineSigners: <T extends ChainIdArgs>(args?: T | undefined) => UseQueryResult<HookResultDataWithChainId<OfflineSigners, T> | undefined>;
|
|
@@ -607,22 +635,20 @@ declare const useOfflineSigners: <T extends ChainIdArgs>(args?: T | undefined) =
|
|
|
607
635
|
*/
|
|
608
636
|
declare const useActiveChainValidators: <T extends QueryClient & StakingExtension>(queryClient: T | undefined, status?: BondStatusString) => UseQueryResult<QueryValidatorsResponse>;
|
|
609
637
|
/**
|
|
610
|
-
* graz hook to retrieve last connected chain
|
|
638
|
+
* graz hook to retrieve last connected chain ids
|
|
611
639
|
*
|
|
612
640
|
* @example
|
|
613
641
|
* ```ts
|
|
614
642
|
* import { useRecentChain, connect, mainnetChains } from "graz";
|
|
615
643
|
* const { data: recentChain, clear } = useRecentChain();
|
|
616
644
|
* try {
|
|
617
|
-
* connect(mainnetChains.cosmos);
|
|
645
|
+
* connect({chainId: [mainnetChains.cosmos]});
|
|
618
646
|
* } catch {
|
|
619
|
-
* connect(recentChain);
|
|
647
|
+
* connect({chainId: recentChain});
|
|
620
648
|
* }
|
|
621
649
|
* ```
|
|
622
|
-
*
|
|
623
|
-
* @see {@link useActiveChain}
|
|
624
650
|
*/
|
|
625
|
-
declare const
|
|
651
|
+
declare const useRecentChains: () => {
|
|
626
652
|
data: string[] | null;
|
|
627
653
|
clear: () => void;
|
|
628
654
|
};
|
|
@@ -691,6 +717,16 @@ declare const useSuggestChainAndConnect: ({ onError, onLoading, onSuccess }?: Us
|
|
|
691
717
|
suggestAndConnect: _tanstack_react_query.UseMutateFunction<ConnectResult, unknown, SuggestChainAndConnectArgs, unknown>;
|
|
692
718
|
suggestAndConnectAsync: _tanstack_react_query.UseMutateAsyncFunction<ConnectResult, unknown, SuggestChainAndConnectArgs, unknown>;
|
|
693
719
|
};
|
|
720
|
+
/**
|
|
721
|
+
* graz hook to retrieve chain data and usefull functions with given chainId
|
|
722
|
+
* @param chainId - Chain ID string
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```ts
|
|
726
|
+
* import { useChain } from "graz";
|
|
727
|
+
* const { data: chain } = useChain("cosmoshub-4");
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
694
730
|
declare const useChain: ({ chainId }: {
|
|
695
731
|
chainId: string;
|
|
696
732
|
}) => {
|
|
@@ -703,17 +739,25 @@ declare const useChain: ({ chainId }: {
|
|
|
703
739
|
} | undefined;
|
|
704
740
|
|
|
705
741
|
/**
|
|
706
|
-
* graz query hook to retrieve a CosmWasmClient
|
|
742
|
+
* graz query hook to retrieve a CosmWasmClient or StargateClient or Tendermint34Client.
|
|
743
|
+
*
|
|
744
|
+
* @param client - if provided, it will use the given client instead of the default client
|
|
745
|
+
* @param chainId - if provided, it will only return the data of the given chainId
|
|
746
|
+
* @param onlyConnectedChains - if true, it will only return the client of the current connected chains
|
|
747
|
+
* @param enabled - if false, it will not fetch the data
|
|
748
|
+
*
|
|
749
|
+
* @returns if chainId is string it will return an object, otherwise it will return a record of objects
|
|
707
750
|
*
|
|
708
751
|
* @example
|
|
709
752
|
* ```ts
|
|
710
753
|
* import { useClient } from "graz";
|
|
711
754
|
*
|
|
712
|
-
* //
|
|
713
|
-
* const { data,
|
|
755
|
+
* // single chain
|
|
756
|
+
* const { data, isLoading, ... } = useClient({ client: "stargate" chainId: "cosmoshub-4" });
|
|
757
|
+
*
|
|
758
|
+
* // all chains from GrazProvider example
|
|
759
|
+
* const { data, isLoading, ... } = useClient({ client: "stargate" });
|
|
714
760
|
*
|
|
715
|
-
* // initialize new custom client from given arguments
|
|
716
|
-
* useClient({ rpc: "https://rpc.cosmoshub.strange.love", });
|
|
717
761
|
* ```
|
|
718
762
|
*/
|
|
719
763
|
declare const useConnectClient: <T extends Clients, U extends ChainIdArgs>(args?: ({
|
|
@@ -726,21 +770,24 @@ declare const useConnectClient: <T extends Clients, U extends ChainIdArgs>(args?
|
|
|
726
770
|
enabled?: boolean | undefined;
|
|
727
771
|
} & U) | undefined) => UseQueryResult<HookResultDataWithChainId<ConnectClient<T>, U> | undefined>;
|
|
728
772
|
/**
|
|
729
|
-
* graz query hook to retrieve a SigningCosmWasmClient
|
|
773
|
+
* graz query hook to retrieve a SigningCosmWasmClient or SigningStargateClient.
|
|
774
|
+
*
|
|
775
|
+
* @param client - if provided, it will use the given client instead of the default client
|
|
776
|
+
* @param chainId - if provided, it will only return the data of the given chainId
|
|
777
|
+
* @param options - signing client options of given client
|
|
778
|
+
*
|
|
779
|
+
* @returns if chainId is string it will return an object, otherwise it will return a record of objects
|
|
730
780
|
*
|
|
731
781
|
* @example
|
|
732
782
|
* ```ts
|
|
733
783
|
* import { useSigningClient } from "graz";
|
|
734
784
|
*
|
|
735
|
-
* //
|
|
736
|
-
* const { data,
|
|
785
|
+
* // single chain
|
|
786
|
+
* const { data, isLoading, ... } = useSigningClient({ client: "stargate" chainId: "cosmoshub-4" });
|
|
787
|
+
*
|
|
788
|
+
* // all chains from GrazProvider example
|
|
789
|
+
* const { data, isLoading, ... } = useSigningClient({ client: "stargate" });
|
|
737
790
|
*
|
|
738
|
-
* // initialize new custom client with given args
|
|
739
|
-
* useSigningClient({
|
|
740
|
-
* rpc: "https://rpc.cosmoshub.strange.love",
|
|
741
|
-
* offlineSigner: customOfflineSigner,
|
|
742
|
-
* ...
|
|
743
|
-
* });
|
|
744
791
|
* ```
|
|
745
792
|
*/
|
|
746
793
|
declare const useConnectSigningClient: <T extends SigningClients, U extends ChainIdArgs>(args?: ({
|
|
@@ -781,6 +828,8 @@ declare const useBalance: <T extends "cosmWasm" | "stargate">(args: {
|
|
|
781
828
|
* @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
829
|
* @param client - Optional client, if not provided will use the default client
|
|
783
830
|
*
|
|
831
|
+
* @returns if chainId is string it will return an object, otherwise it will return a record of objects
|
|
832
|
+
*
|
|
784
833
|
* @example
|
|
785
834
|
* ```ts
|
|
786
835
|
* import { useAllBalances } from "graz";
|
|
@@ -809,6 +858,8 @@ declare const useAllBalances: <U extends ChainIdArgs>(args: {
|
|
|
809
858
|
* @param client - Optional client, if not provided will use the default client
|
|
810
859
|
* @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
860
|
*
|
|
861
|
+
* @returns if chainId is string it will return an object, otherwise it will return a record of objects
|
|
862
|
+
*
|
|
812
863
|
* @example
|
|
813
864
|
* ```ts
|
|
814
865
|
* import { useChainBalances } from "graz";
|
|
@@ -837,6 +888,8 @@ declare const useChainBalances: <T extends "cosmWasm" | "stargate", U extends Ch
|
|
|
837
888
|
* @param bech32Address - Optional bech32 account address, if not provided will return undefined
|
|
838
889
|
* @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
|
|
839
890
|
*
|
|
891
|
+
* @returns if chainId is string it will return an object, otherwise it will return a record of objects
|
|
892
|
+
*
|
|
840
893
|
* @example
|
|
841
894
|
* ```ts
|
|
842
895
|
* import { useBalanceStaked } from "graz";
|
|
@@ -1124,4 +1177,4 @@ declare const formatTokenName: (name: string) => string;
|
|
|
1124
1177
|
declare const handleNaN: (value: number) => number;
|
|
1125
1178
|
declare const truncate: (string?: string, slice?: number) => string;
|
|
1126
1179
|
|
|
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,
|
|
1180
|
+
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, getChain, 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, useRecentChains, useSendIbcTokens, useSendTokens, useSuggestChain, useSuggestChainAndConnect };
|
package/dist/index.js
CHANGED
|
@@ -921,6 +921,7 @@ __export(src_exports, {
|
|
|
921
921
|
getAvailableWallets: () => getAvailableWallets,
|
|
922
922
|
getBalance: () => getBalance,
|
|
923
923
|
getBalanceStaked: () => getBalanceStaked,
|
|
924
|
+
getChain: () => getChain,
|
|
924
925
|
getCosmostation: () => getCosmostation,
|
|
925
926
|
getKeplr: () => getKeplr,
|
|
926
927
|
getLeap: () => getLeap,
|
|
@@ -965,7 +966,7 @@ __export(src_exports, {
|
|
|
965
966
|
useOfflineSigners: () => useOfflineSigners,
|
|
966
967
|
useQueryRaw: () => useQueryRaw,
|
|
967
968
|
useQuerySmart: () => useQuerySmart,
|
|
968
|
-
|
|
969
|
+
useRecentChains: () => useRecentChains,
|
|
969
970
|
useSendIbcTokens: () => useSendIbcTokens,
|
|
970
971
|
useSendTokens: () => useSendTokens,
|
|
971
972
|
useSuggestChain: () => useSuggestChain,
|
|
@@ -1922,6 +1923,11 @@ var suggestChainAndConnect = async (args) => {
|
|
|
1922
1923
|
});
|
|
1923
1924
|
return result;
|
|
1924
1925
|
};
|
|
1926
|
+
var getChain = ({ chainId }) => {
|
|
1927
|
+
var _a;
|
|
1928
|
+
const chain = (_a = useGrazInternalStore.getState().chains) == null ? void 0 : _a.find((x) => x.chainId === chainId);
|
|
1929
|
+
return chain;
|
|
1930
|
+
};
|
|
1925
1931
|
|
|
1926
1932
|
// src/actions/clients.ts
|
|
1927
1933
|
var import_cosmwasm_stargate = require("@cosmjs/cosmwasm-stargate");
|
|
@@ -2457,12 +2463,12 @@ var useAccount = (args) => {
|
|
|
2457
2463
|
const res = (0, import_react.useMemo)(() => {
|
|
2458
2464
|
if (!sessions)
|
|
2459
2465
|
return void 0;
|
|
2460
|
-
if (args == null ? void 0 : args.chainId) {
|
|
2466
|
+
if (typeof (args == null ? void 0 : args.chainId) === "string" && args.chainId) {
|
|
2461
2467
|
const singleChainRes = sessions.find((i) => i.chainId === args.chainId);
|
|
2462
2468
|
return singleChainRes;
|
|
2463
2469
|
}
|
|
2464
2470
|
const multiChainRes = {};
|
|
2465
|
-
sessions.forEach((i) => {
|
|
2471
|
+
sessions.filter((x) => (args == null ? void 0 : args.chainId) ? args.chainId.includes(x.chainId) : true).forEach((i) => {
|
|
2466
2472
|
multiChainRes[i.chainId] = i;
|
|
2467
2473
|
});
|
|
2468
2474
|
return multiChainRes;
|
|
@@ -2507,40 +2513,19 @@ var useDisconnect = ({ onError, onLoading, onSuccess } = {}) => {
|
|
|
2507
2513
|
};
|
|
2508
2514
|
var useOfflineSigners = (args) => {
|
|
2509
2515
|
const accounts = useAccount();
|
|
2510
|
-
const { data } = (0, import_react_query2.useQuery)(
|
|
2511
|
-
["OFFLINE_SIGNERS", { accounts }],
|
|
2512
|
-
async () => {
|
|
2513
|
-
if (!accounts)
|
|
2514
|
-
return void 0;
|
|
2515
|
-
const connectedChainIds = Object.values(accounts).map((i) => i == null ? void 0 : i.chainId).filter(Boolean);
|
|
2516
|
-
const res = {};
|
|
2517
|
-
await Promise.all(
|
|
2518
|
-
connectedChainIds.map(async (_chainId) => {
|
|
2519
|
-
const signers = await getOfflineSigners({
|
|
2520
|
-
chainId: _chainId
|
|
2521
|
-
});
|
|
2522
|
-
res[_chainId] = signers;
|
|
2523
|
-
})
|
|
2524
|
-
);
|
|
2525
|
-
return res;
|
|
2526
|
-
},
|
|
2527
|
-
{
|
|
2528
|
-
enabled: Boolean(accounts)
|
|
2529
|
-
}
|
|
2530
|
-
);
|
|
2531
2516
|
const query = (0, import_react_query2.useQuery)(
|
|
2532
2517
|
[
|
|
2533
2518
|
"USE_OFFLINE_SIGNERS",
|
|
2534
2519
|
{
|
|
2535
2520
|
args,
|
|
2536
|
-
|
|
2521
|
+
accounts
|
|
2537
2522
|
}
|
|
2538
2523
|
],
|
|
2539
2524
|
async () => {
|
|
2540
|
-
if (!
|
|
2525
|
+
if (!accounts)
|
|
2541
2526
|
return void 0;
|
|
2542
|
-
const connectedChainIds = Object.keys(
|
|
2543
|
-
if (args == null ? void 0 : args.chainId) {
|
|
2527
|
+
const connectedChainIds = Object.keys(accounts).map(([chainId]) => chainId).filter(Boolean);
|
|
2528
|
+
if (typeof (args == null ? void 0 : args.chainId) === "string" && args.chainId) {
|
|
2544
2529
|
const offlineSigners = await getOfflineSigners({
|
|
2545
2530
|
chainId: args.chainId
|
|
2546
2531
|
});
|
|
@@ -2548,7 +2533,7 @@ var useOfflineSigners = (args) => {
|
|
|
2548
2533
|
}
|
|
2549
2534
|
const res = {};
|
|
2550
2535
|
await Promise.all(
|
|
2551
|
-
connectedChainIds.map(async (_chainId) => {
|
|
2536
|
+
connectedChainIds.filter((x) => (args == null ? void 0 : args.chainId) ? args.chainId.includes(x) : true).map(async (_chainId) => {
|
|
2552
2537
|
const signers = await getOfflineSigners({
|
|
2553
2538
|
chainId: _chainId
|
|
2554
2539
|
});
|
|
@@ -2557,7 +2542,7 @@ var useOfflineSigners = (args) => {
|
|
|
2557
2542
|
);
|
|
2558
2543
|
return res;
|
|
2559
2544
|
},
|
|
2560
|
-
{ enabled: Boolean(
|
|
2545
|
+
{ enabled: Boolean(accounts), refetchOnMount: false, refetchOnWindowFocus: false }
|
|
2561
2546
|
);
|
|
2562
2547
|
return query;
|
|
2563
2548
|
};
|
|
@@ -2577,7 +2562,7 @@ var useActiveChainValidators = (queryClient2, status = "BOND_STATUS_BONDED") =>
|
|
|
2577
2562
|
);
|
|
2578
2563
|
return query;
|
|
2579
2564
|
};
|
|
2580
|
-
var
|
|
2565
|
+
var useRecentChains = () => {
|
|
2581
2566
|
const recentChains = useGrazInternalStore((x) => x.recentChains);
|
|
2582
2567
|
return { data: recentChains, clear: clearRecentChain };
|
|
2583
2568
|
};
|
|
@@ -2645,12 +2630,12 @@ var useConnectClient = (args) => {
|
|
|
2645
2630
|
const _client = (args == null ? void 0 : args.client) ?? useGrazInternalStore.getState().defaultClient;
|
|
2646
2631
|
const _chains = useGrazInternalStore.getState().chains;
|
|
2647
2632
|
const sessionChainIds = (_a = useGrazSessionStore.getState().sessions) == null ? void 0 : _a.map((i) => i.chainId);
|
|
2648
|
-
const singleChain =
|
|
2633
|
+
const singleChain = typeof (args == null ? void 0 : args.chainId) === "string" && (_chains == null ? void 0 : _chains.find((i) => i.chainId === args.chainId));
|
|
2649
2634
|
const sessionChains = sessionChainIds == null ? void 0 : sessionChainIds.map((i) => _chains.find((x) => x.chainId === i));
|
|
2650
2635
|
const chains = (args == null ? void 0 : args.onlyConnectedChains) ? sessionChains : _chains;
|
|
2651
2636
|
const query = (0, import_react_query4.useQuery)(
|
|
2652
2637
|
[
|
|
2653
|
-
"
|
|
2638
|
+
"USE_CONNECT_CLIENT",
|
|
2654
2639
|
{
|
|
2655
2640
|
client: _client,
|
|
2656
2641
|
chainId: args == null ? void 0 : args.chainId,
|
|
@@ -2670,7 +2655,7 @@ var useConnectClient = (args) => {
|
|
|
2670
2655
|
if (!chains)
|
|
2671
2656
|
return void 0;
|
|
2672
2657
|
await Promise.all(
|
|
2673
|
-
chains.map(async (chain) => {
|
|
2658
|
+
chains.filter((x) => (args == null ? void 0 : args.chainId) ? args.chainId.includes(x.chainId) : true).map(async (chain) => {
|
|
2674
2659
|
const client = await connectClient({
|
|
2675
2660
|
client: _client,
|
|
2676
2661
|
rpc: chain.rpc,
|
|
@@ -2694,10 +2679,10 @@ var useConnectSigningClient = (args) => {
|
|
|
2694
2679
|
const _client = (args == null ? void 0 : args.client) ?? useGrazInternalStore.getState().defaultClient;
|
|
2695
2680
|
const _chains = useGrazInternalStore.getState().chains;
|
|
2696
2681
|
const sessionChainIds = (_a = useGrazSessionStore.getState().sessions) == null ? void 0 : _a.map((i) => i.chainId);
|
|
2697
|
-
const singleChain =
|
|
2682
|
+
const singleChain = typeof (args == null ? void 0 : args.chainId) === "string" && (_chains == null ? void 0 : _chains.find((i) => i.chainId === args.chainId));
|
|
2698
2683
|
const sessionChains = sessionChainIds == null ? void 0 : sessionChainIds.map((i) => _chains.find((x) => x.chainId === i));
|
|
2699
2684
|
const queryKey = [
|
|
2700
|
-
"
|
|
2685
|
+
"USE_CONNECT_SIGNING_CLIENT",
|
|
2701
2686
|
{ client: _client, chainId: args == null ? void 0 : args.chainId, options: args == null ? void 0 : args.options }
|
|
2702
2687
|
];
|
|
2703
2688
|
const query = (0, import_react_query4.useQuery)(
|
|
@@ -2708,7 +2693,7 @@ var useConnectSigningClient = (args) => {
|
|
|
2708
2693
|
chainId: singleChain.chainId
|
|
2709
2694
|
});
|
|
2710
2695
|
const gasPrice = singleChain.gas ? import_stargate2.GasPrice.fromString(`${singleChain.gas.price}${singleChain.gas.denom}`) : void 0;
|
|
2711
|
-
const options = _client === "cosmWasm" ? { gasPrice, ...
|
|
2696
|
+
const options = _client === "cosmWasm" ? { gasPrice, ...args.options || {} } : args.options;
|
|
2712
2697
|
const client = await connectSigningClient({
|
|
2713
2698
|
client: _client,
|
|
2714
2699
|
rpc: singleChain.rpc,
|
|
@@ -2722,7 +2707,7 @@ var useConnectSigningClient = (args) => {
|
|
|
2722
2707
|
if (!sessionChains)
|
|
2723
2708
|
return void 0;
|
|
2724
2709
|
await Promise.all(
|
|
2725
|
-
sessionChains.map(async (chain) => {
|
|
2710
|
+
sessionChains.filter((x) => (args == null ? void 0 : args.chainId) ? args.chainId.includes(x.chainId) : true).map(async (chain) => {
|
|
2726
2711
|
var _a2, _b;
|
|
2727
2712
|
const { offlineSignerAuto } = await getOfflineSigners({ chainId: chain.chainId });
|
|
2728
2713
|
const gasPrice = chain.gas ? import_stargate2.GasPrice.fromString(`${chain.gas.price}${chain.gas.denom}`) : void 0;
|
|
@@ -2769,7 +2754,7 @@ var useBalance = (args) => {
|
|
|
2769
2754
|
});
|
|
2770
2755
|
const query = (0, import_react_query5.useQuery)(
|
|
2771
2756
|
[
|
|
2772
|
-
"
|
|
2757
|
+
"USE_BALANCE",
|
|
2773
2758
|
{
|
|
2774
2759
|
client,
|
|
2775
2760
|
...args,
|
|
@@ -2801,15 +2786,16 @@ var useAllBalances = (args) => {
|
|
|
2801
2786
|
const { data: singleClient } = useConnectClient({
|
|
2802
2787
|
client: "stargate",
|
|
2803
2788
|
chainId: args.chainId,
|
|
2804
|
-
enabled: Boolean(args.chainId) && Boolean(args.bech32Address)
|
|
2789
|
+
enabled: Boolean(args.chainId) && typeof args.chainId === "string" && Boolean(args.bech32Address)
|
|
2805
2790
|
});
|
|
2806
2791
|
const { data: multiClient } = useConnectClient({
|
|
2807
2792
|
client: "stargate",
|
|
2808
|
-
|
|
2793
|
+
chainId: args.chainId,
|
|
2794
|
+
enabled: (!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && Boolean(args.bech32Address)
|
|
2809
2795
|
});
|
|
2810
2796
|
const query = (0, import_react_query5.useQuery)(
|
|
2811
2797
|
[
|
|
2812
|
-
"
|
|
2798
|
+
"USE_ALL_BALANCES",
|
|
2813
2799
|
{
|
|
2814
2800
|
singleClient,
|
|
2815
2801
|
multiClient,
|
|
@@ -2818,7 +2804,7 @@ var useAllBalances = (args) => {
|
|
|
2818
2804
|
}
|
|
2819
2805
|
],
|
|
2820
2806
|
async () => {
|
|
2821
|
-
if (args.chainId && singleClient) {
|
|
2807
|
+
if (args.chainId && typeof args.chainId === "string" && singleClient) {
|
|
2822
2808
|
const singleChain = _chains == null ? void 0 : _chains.find((i) => i.chainId === args.chainId);
|
|
2823
2809
|
const res = await getAllBalance({
|
|
2824
2810
|
client: singleClient,
|
|
@@ -2826,11 +2812,11 @@ var useAllBalances = (args) => {
|
|
|
2826
2812
|
});
|
|
2827
2813
|
return res;
|
|
2828
2814
|
}
|
|
2829
|
-
if (!args.chainId && multiClient) {
|
|
2815
|
+
if ((!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && multiClient) {
|
|
2830
2816
|
const multiChain = Object.entries(multiClient);
|
|
2831
2817
|
const res = {};
|
|
2832
2818
|
await Promise.all(
|
|
2833
|
-
multiChain.map(async ([chainId, client]) => {
|
|
2819
|
+
multiChain.filter((x) => args.chainId ? args.chainId.includes(x[0]) : true).map(async ([chainId, client]) => {
|
|
2834
2820
|
const chain = _chains == null ? void 0 : _chains.find((i) => i.chainId === chainId);
|
|
2835
2821
|
if (!chain)
|
|
2836
2822
|
return;
|
|
@@ -2860,15 +2846,16 @@ var useChainBalances = (args) => {
|
|
|
2860
2846
|
const { data: singleClient } = useConnectClient({
|
|
2861
2847
|
client: _client,
|
|
2862
2848
|
chainId: args.chainId,
|
|
2863
|
-
enabled: Boolean(args.chainId) && Boolean(args.bech32Address)
|
|
2849
|
+
enabled: Boolean(args.chainId) && typeof args.chainId === "string" && Boolean(args.bech32Address)
|
|
2864
2850
|
});
|
|
2865
2851
|
const { data: multiClient } = useConnectClient({
|
|
2866
2852
|
client: _client,
|
|
2867
|
-
|
|
2853
|
+
chainId: args.chainId,
|
|
2854
|
+
enabled: (!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && Boolean(args.bech32Address)
|
|
2868
2855
|
});
|
|
2869
2856
|
const query = (0, import_react_query5.useQuery)(
|
|
2870
2857
|
[
|
|
2871
|
-
"
|
|
2858
|
+
"USE_CHAIN_BALANCES",
|
|
2872
2859
|
{
|
|
2873
2860
|
singleClient,
|
|
2874
2861
|
multiClient,
|
|
@@ -2877,7 +2864,7 @@ var useChainBalances = (args) => {
|
|
|
2877
2864
|
}
|
|
2878
2865
|
],
|
|
2879
2866
|
async () => {
|
|
2880
|
-
if (args.chainId && singleClient) {
|
|
2867
|
+
if (typeof args.chainId === "string" && args.chainId && singleClient) {
|
|
2881
2868
|
const singleChain = _chains == null ? void 0 : _chains.find((i) => i.chainId === args.chainId);
|
|
2882
2869
|
const res = await Promise.all(
|
|
2883
2870
|
singleChain.currencies.map(
|
|
@@ -2893,11 +2880,11 @@ var useChainBalances = (args) => {
|
|
|
2893
2880
|
);
|
|
2894
2881
|
return res;
|
|
2895
2882
|
}
|
|
2896
|
-
if (!args.chainId && multiClient) {
|
|
2883
|
+
if ((!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && multiClient) {
|
|
2897
2884
|
const multiChain = Object.entries(multiClient);
|
|
2898
2885
|
const res = {};
|
|
2899
2886
|
await Promise.all(
|
|
2900
|
-
multiChain.map(async ([chainId, client]) => {
|
|
2887
|
+
multiChain.filter((x) => args.chainId ? args.chainId.includes(x[0]) : true).map(async ([chainId, client]) => {
|
|
2901
2888
|
const chain = _chains == null ? void 0 : _chains.find((i) => i.chainId === chainId);
|
|
2902
2889
|
if (!chain)
|
|
2903
2890
|
return;
|
|
@@ -2934,15 +2921,16 @@ var useBalanceStaked = (args) => {
|
|
|
2934
2921
|
const { data: singleClient } = useConnectClient({
|
|
2935
2922
|
client: "stargate",
|
|
2936
2923
|
chainId: args.chainId,
|
|
2937
|
-
enabled: Boolean(args.chainId) && Boolean(args.bech32Address)
|
|
2924
|
+
enabled: Boolean(args.chainId) && typeof args.chainId === "string" && Boolean(args.bech32Address)
|
|
2938
2925
|
});
|
|
2939
2926
|
const { data: multiClient } = useConnectClient({
|
|
2940
2927
|
client: "stargate",
|
|
2941
|
-
|
|
2928
|
+
chainId: args.chainId,
|
|
2929
|
+
enabled: (!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && Boolean(args.bech32Address)
|
|
2942
2930
|
});
|
|
2943
2931
|
const query = (0, import_react_query5.useQuery)(
|
|
2944
2932
|
[
|
|
2945
|
-
"
|
|
2933
|
+
"useBalanceStaked",
|
|
2946
2934
|
{
|
|
2947
2935
|
singleClient,
|
|
2948
2936
|
multiClient,
|
|
@@ -2951,7 +2939,7 @@ var useBalanceStaked = (args) => {
|
|
|
2951
2939
|
}
|
|
2952
2940
|
],
|
|
2953
2941
|
async () => {
|
|
2954
|
-
if (args.chainId && singleClient) {
|
|
2942
|
+
if (args.chainId && typeof args.chainId === "string" && singleClient) {
|
|
2955
2943
|
const singleChain = _chains == null ? void 0 : _chains.find((i) => i.chainId === args.chainId);
|
|
2956
2944
|
if (!singleChain)
|
|
2957
2945
|
throw new Error(`${args.chainId} Chain not found`);
|
|
@@ -2961,11 +2949,11 @@ var useBalanceStaked = (args) => {
|
|
|
2961
2949
|
});
|
|
2962
2950
|
return res;
|
|
2963
2951
|
}
|
|
2964
|
-
if (!args.chainId && multiClient) {
|
|
2952
|
+
if ((!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && multiClient) {
|
|
2965
2953
|
const multiChain = Object.entries(multiClient);
|
|
2966
2954
|
const res = {};
|
|
2967
2955
|
await Promise.all(
|
|
2968
|
-
multiChain.map(async ([chainId, client]) => {
|
|
2956
|
+
multiChain.filter((x) => args.chainId ? args.chainId.includes(x[0]) : true).map(async ([chainId, client]) => {
|
|
2969
2957
|
const chain = _chains == null ? void 0 : _chains.find((i) => i.chainId === chainId);
|
|
2970
2958
|
if (!chain)
|
|
2971
2959
|
return;
|
|
@@ -3359,6 +3347,7 @@ var truncate = (string, slice) => {
|
|
|
3359
3347
|
getAvailableWallets,
|
|
3360
3348
|
getBalance,
|
|
3361
3349
|
getBalanceStaked,
|
|
3350
|
+
getChain,
|
|
3362
3351
|
getCosmostation,
|
|
3363
3352
|
getKeplr,
|
|
3364
3353
|
getLeap,
|
|
@@ -3403,7 +3392,7 @@ var truncate = (string, slice) => {
|
|
|
3403
3392
|
useOfflineSigners,
|
|
3404
3393
|
useQueryRaw,
|
|
3405
3394
|
useQuerySmart,
|
|
3406
|
-
|
|
3395
|
+
useRecentChains,
|
|
3407
3396
|
useSendIbcTokens,
|
|
3408
3397
|
useSendTokens,
|
|
3409
3398
|
useSuggestChain,
|
package/dist/index.mjs
CHANGED
|
@@ -1814,6 +1814,11 @@ var suggestChainAndConnect = async (args) => {
|
|
|
1814
1814
|
});
|
|
1815
1815
|
return result;
|
|
1816
1816
|
};
|
|
1817
|
+
var getChain = ({ chainId }) => {
|
|
1818
|
+
var _a;
|
|
1819
|
+
const chain = (_a = useGrazInternalStore.getState().chains) == null ? void 0 : _a.find((x) => x.chainId === chainId);
|
|
1820
|
+
return chain;
|
|
1821
|
+
};
|
|
1817
1822
|
|
|
1818
1823
|
// src/actions/clients.ts
|
|
1819
1824
|
import { CosmWasmClient, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
|
|
@@ -2349,12 +2354,12 @@ var useAccount = (args) => {
|
|
|
2349
2354
|
const res = useMemo(() => {
|
|
2350
2355
|
if (!sessions)
|
|
2351
2356
|
return void 0;
|
|
2352
|
-
if (args == null ? void 0 : args.chainId) {
|
|
2357
|
+
if (typeof (args == null ? void 0 : args.chainId) === "string" && args.chainId) {
|
|
2353
2358
|
const singleChainRes = sessions.find((i) => i.chainId === args.chainId);
|
|
2354
2359
|
return singleChainRes;
|
|
2355
2360
|
}
|
|
2356
2361
|
const multiChainRes = {};
|
|
2357
|
-
sessions.forEach((i) => {
|
|
2362
|
+
sessions.filter((x) => (args == null ? void 0 : args.chainId) ? args.chainId.includes(x.chainId) : true).forEach((i) => {
|
|
2358
2363
|
multiChainRes[i.chainId] = i;
|
|
2359
2364
|
});
|
|
2360
2365
|
return multiChainRes;
|
|
@@ -2399,40 +2404,19 @@ var useDisconnect = ({ onError, onLoading, onSuccess } = {}) => {
|
|
|
2399
2404
|
};
|
|
2400
2405
|
var useOfflineSigners = (args) => {
|
|
2401
2406
|
const accounts = useAccount();
|
|
2402
|
-
const { data } = useQuery2(
|
|
2403
|
-
["OFFLINE_SIGNERS", { accounts }],
|
|
2404
|
-
async () => {
|
|
2405
|
-
if (!accounts)
|
|
2406
|
-
return void 0;
|
|
2407
|
-
const connectedChainIds = Object.values(accounts).map((i) => i == null ? void 0 : i.chainId).filter(Boolean);
|
|
2408
|
-
const res = {};
|
|
2409
|
-
await Promise.all(
|
|
2410
|
-
connectedChainIds.map(async (_chainId) => {
|
|
2411
|
-
const signers = await getOfflineSigners({
|
|
2412
|
-
chainId: _chainId
|
|
2413
|
-
});
|
|
2414
|
-
res[_chainId] = signers;
|
|
2415
|
-
})
|
|
2416
|
-
);
|
|
2417
|
-
return res;
|
|
2418
|
-
},
|
|
2419
|
-
{
|
|
2420
|
-
enabled: Boolean(accounts)
|
|
2421
|
-
}
|
|
2422
|
-
);
|
|
2423
2407
|
const query = useQuery2(
|
|
2424
2408
|
[
|
|
2425
2409
|
"USE_OFFLINE_SIGNERS",
|
|
2426
2410
|
{
|
|
2427
2411
|
args,
|
|
2428
|
-
|
|
2412
|
+
accounts
|
|
2429
2413
|
}
|
|
2430
2414
|
],
|
|
2431
2415
|
async () => {
|
|
2432
|
-
if (!
|
|
2416
|
+
if (!accounts)
|
|
2433
2417
|
return void 0;
|
|
2434
|
-
const connectedChainIds = Object.keys(
|
|
2435
|
-
if (args == null ? void 0 : args.chainId) {
|
|
2418
|
+
const connectedChainIds = Object.keys(accounts).map(([chainId]) => chainId).filter(Boolean);
|
|
2419
|
+
if (typeof (args == null ? void 0 : args.chainId) === "string" && args.chainId) {
|
|
2436
2420
|
const offlineSigners = await getOfflineSigners({
|
|
2437
2421
|
chainId: args.chainId
|
|
2438
2422
|
});
|
|
@@ -2440,7 +2424,7 @@ var useOfflineSigners = (args) => {
|
|
|
2440
2424
|
}
|
|
2441
2425
|
const res = {};
|
|
2442
2426
|
await Promise.all(
|
|
2443
|
-
connectedChainIds.map(async (_chainId) => {
|
|
2427
|
+
connectedChainIds.filter((x) => (args == null ? void 0 : args.chainId) ? args.chainId.includes(x) : true).map(async (_chainId) => {
|
|
2444
2428
|
const signers = await getOfflineSigners({
|
|
2445
2429
|
chainId: _chainId
|
|
2446
2430
|
});
|
|
@@ -2449,7 +2433,7 @@ var useOfflineSigners = (args) => {
|
|
|
2449
2433
|
);
|
|
2450
2434
|
return res;
|
|
2451
2435
|
},
|
|
2452
|
-
{ enabled: Boolean(
|
|
2436
|
+
{ enabled: Boolean(accounts), refetchOnMount: false, refetchOnWindowFocus: false }
|
|
2453
2437
|
);
|
|
2454
2438
|
return query;
|
|
2455
2439
|
};
|
|
@@ -2469,7 +2453,7 @@ var useActiveChainValidators = (queryClient2, status = "BOND_STATUS_BONDED") =>
|
|
|
2469
2453
|
);
|
|
2470
2454
|
return query;
|
|
2471
2455
|
};
|
|
2472
|
-
var
|
|
2456
|
+
var useRecentChains = () => {
|
|
2473
2457
|
const recentChains = useGrazInternalStore((x) => x.recentChains);
|
|
2474
2458
|
return { data: recentChains, clear: clearRecentChain };
|
|
2475
2459
|
};
|
|
@@ -2537,12 +2521,12 @@ var useConnectClient = (args) => {
|
|
|
2537
2521
|
const _client = (args == null ? void 0 : args.client) ?? useGrazInternalStore.getState().defaultClient;
|
|
2538
2522
|
const _chains = useGrazInternalStore.getState().chains;
|
|
2539
2523
|
const sessionChainIds = (_a = useGrazSessionStore.getState().sessions) == null ? void 0 : _a.map((i) => i.chainId);
|
|
2540
|
-
const singleChain =
|
|
2524
|
+
const singleChain = typeof (args == null ? void 0 : args.chainId) === "string" && (_chains == null ? void 0 : _chains.find((i) => i.chainId === args.chainId));
|
|
2541
2525
|
const sessionChains = sessionChainIds == null ? void 0 : sessionChainIds.map((i) => _chains.find((x) => x.chainId === i));
|
|
2542
2526
|
const chains = (args == null ? void 0 : args.onlyConnectedChains) ? sessionChains : _chains;
|
|
2543
2527
|
const query = useQuery4(
|
|
2544
2528
|
[
|
|
2545
|
-
"
|
|
2529
|
+
"USE_CONNECT_CLIENT",
|
|
2546
2530
|
{
|
|
2547
2531
|
client: _client,
|
|
2548
2532
|
chainId: args == null ? void 0 : args.chainId,
|
|
@@ -2562,7 +2546,7 @@ var useConnectClient = (args) => {
|
|
|
2562
2546
|
if (!chains)
|
|
2563
2547
|
return void 0;
|
|
2564
2548
|
await Promise.all(
|
|
2565
|
-
chains.map(async (chain) => {
|
|
2549
|
+
chains.filter((x) => (args == null ? void 0 : args.chainId) ? args.chainId.includes(x.chainId) : true).map(async (chain) => {
|
|
2566
2550
|
const client = await connectClient({
|
|
2567
2551
|
client: _client,
|
|
2568
2552
|
rpc: chain.rpc,
|
|
@@ -2586,10 +2570,10 @@ var useConnectSigningClient = (args) => {
|
|
|
2586
2570
|
const _client = (args == null ? void 0 : args.client) ?? useGrazInternalStore.getState().defaultClient;
|
|
2587
2571
|
const _chains = useGrazInternalStore.getState().chains;
|
|
2588
2572
|
const sessionChainIds = (_a = useGrazSessionStore.getState().sessions) == null ? void 0 : _a.map((i) => i.chainId);
|
|
2589
|
-
const singleChain =
|
|
2573
|
+
const singleChain = typeof (args == null ? void 0 : args.chainId) === "string" && (_chains == null ? void 0 : _chains.find((i) => i.chainId === args.chainId));
|
|
2590
2574
|
const sessionChains = sessionChainIds == null ? void 0 : sessionChainIds.map((i) => _chains.find((x) => x.chainId === i));
|
|
2591
2575
|
const queryKey = [
|
|
2592
|
-
"
|
|
2576
|
+
"USE_CONNECT_SIGNING_CLIENT",
|
|
2593
2577
|
{ client: _client, chainId: args == null ? void 0 : args.chainId, options: args == null ? void 0 : args.options }
|
|
2594
2578
|
];
|
|
2595
2579
|
const query = useQuery4(
|
|
@@ -2600,7 +2584,7 @@ var useConnectSigningClient = (args) => {
|
|
|
2600
2584
|
chainId: singleChain.chainId
|
|
2601
2585
|
});
|
|
2602
2586
|
const gasPrice = singleChain.gas ? GasPrice.fromString(`${singleChain.gas.price}${singleChain.gas.denom}`) : void 0;
|
|
2603
|
-
const options = _client === "cosmWasm" ? { gasPrice, ...
|
|
2587
|
+
const options = _client === "cosmWasm" ? { gasPrice, ...args.options || {} } : args.options;
|
|
2604
2588
|
const client = await connectSigningClient({
|
|
2605
2589
|
client: _client,
|
|
2606
2590
|
rpc: singleChain.rpc,
|
|
@@ -2614,7 +2598,7 @@ var useConnectSigningClient = (args) => {
|
|
|
2614
2598
|
if (!sessionChains)
|
|
2615
2599
|
return void 0;
|
|
2616
2600
|
await Promise.all(
|
|
2617
|
-
sessionChains.map(async (chain) => {
|
|
2601
|
+
sessionChains.filter((x) => (args == null ? void 0 : args.chainId) ? args.chainId.includes(x.chainId) : true).map(async (chain) => {
|
|
2618
2602
|
var _a2, _b;
|
|
2619
2603
|
const { offlineSignerAuto } = await getOfflineSigners({ chainId: chain.chainId });
|
|
2620
2604
|
const gasPrice = chain.gas ? GasPrice.fromString(`${chain.gas.price}${chain.gas.denom}`) : void 0;
|
|
@@ -2661,7 +2645,7 @@ var useBalance = (args) => {
|
|
|
2661
2645
|
});
|
|
2662
2646
|
const query = useQuery5(
|
|
2663
2647
|
[
|
|
2664
|
-
"
|
|
2648
|
+
"USE_BALANCE",
|
|
2665
2649
|
{
|
|
2666
2650
|
client,
|
|
2667
2651
|
...args,
|
|
@@ -2693,15 +2677,16 @@ var useAllBalances = (args) => {
|
|
|
2693
2677
|
const { data: singleClient } = useConnectClient({
|
|
2694
2678
|
client: "stargate",
|
|
2695
2679
|
chainId: args.chainId,
|
|
2696
|
-
enabled: Boolean(args.chainId) && Boolean(args.bech32Address)
|
|
2680
|
+
enabled: Boolean(args.chainId) && typeof args.chainId === "string" && Boolean(args.bech32Address)
|
|
2697
2681
|
});
|
|
2698
2682
|
const { data: multiClient } = useConnectClient({
|
|
2699
2683
|
client: "stargate",
|
|
2700
|
-
|
|
2684
|
+
chainId: args.chainId,
|
|
2685
|
+
enabled: (!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && Boolean(args.bech32Address)
|
|
2701
2686
|
});
|
|
2702
2687
|
const query = useQuery5(
|
|
2703
2688
|
[
|
|
2704
|
-
"
|
|
2689
|
+
"USE_ALL_BALANCES",
|
|
2705
2690
|
{
|
|
2706
2691
|
singleClient,
|
|
2707
2692
|
multiClient,
|
|
@@ -2710,7 +2695,7 @@ var useAllBalances = (args) => {
|
|
|
2710
2695
|
}
|
|
2711
2696
|
],
|
|
2712
2697
|
async () => {
|
|
2713
|
-
if (args.chainId && singleClient) {
|
|
2698
|
+
if (args.chainId && typeof args.chainId === "string" && singleClient) {
|
|
2714
2699
|
const singleChain = _chains == null ? void 0 : _chains.find((i) => i.chainId === args.chainId);
|
|
2715
2700
|
const res = await getAllBalance({
|
|
2716
2701
|
client: singleClient,
|
|
@@ -2718,11 +2703,11 @@ var useAllBalances = (args) => {
|
|
|
2718
2703
|
});
|
|
2719
2704
|
return res;
|
|
2720
2705
|
}
|
|
2721
|
-
if (!args.chainId && multiClient) {
|
|
2706
|
+
if ((!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && multiClient) {
|
|
2722
2707
|
const multiChain = Object.entries(multiClient);
|
|
2723
2708
|
const res = {};
|
|
2724
2709
|
await Promise.all(
|
|
2725
|
-
multiChain.map(async ([chainId, client]) => {
|
|
2710
|
+
multiChain.filter((x) => args.chainId ? args.chainId.includes(x[0]) : true).map(async ([chainId, client]) => {
|
|
2726
2711
|
const chain = _chains == null ? void 0 : _chains.find((i) => i.chainId === chainId);
|
|
2727
2712
|
if (!chain)
|
|
2728
2713
|
return;
|
|
@@ -2752,15 +2737,16 @@ var useChainBalances = (args) => {
|
|
|
2752
2737
|
const { data: singleClient } = useConnectClient({
|
|
2753
2738
|
client: _client,
|
|
2754
2739
|
chainId: args.chainId,
|
|
2755
|
-
enabled: Boolean(args.chainId) && Boolean(args.bech32Address)
|
|
2740
|
+
enabled: Boolean(args.chainId) && typeof args.chainId === "string" && Boolean(args.bech32Address)
|
|
2756
2741
|
});
|
|
2757
2742
|
const { data: multiClient } = useConnectClient({
|
|
2758
2743
|
client: _client,
|
|
2759
|
-
|
|
2744
|
+
chainId: args.chainId,
|
|
2745
|
+
enabled: (!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && Boolean(args.bech32Address)
|
|
2760
2746
|
});
|
|
2761
2747
|
const query = useQuery5(
|
|
2762
2748
|
[
|
|
2763
|
-
"
|
|
2749
|
+
"USE_CHAIN_BALANCES",
|
|
2764
2750
|
{
|
|
2765
2751
|
singleClient,
|
|
2766
2752
|
multiClient,
|
|
@@ -2769,7 +2755,7 @@ var useChainBalances = (args) => {
|
|
|
2769
2755
|
}
|
|
2770
2756
|
],
|
|
2771
2757
|
async () => {
|
|
2772
|
-
if (args.chainId && singleClient) {
|
|
2758
|
+
if (typeof args.chainId === "string" && args.chainId && singleClient) {
|
|
2773
2759
|
const singleChain = _chains == null ? void 0 : _chains.find((i) => i.chainId === args.chainId);
|
|
2774
2760
|
const res = await Promise.all(
|
|
2775
2761
|
singleChain.currencies.map(
|
|
@@ -2785,11 +2771,11 @@ var useChainBalances = (args) => {
|
|
|
2785
2771
|
);
|
|
2786
2772
|
return res;
|
|
2787
2773
|
}
|
|
2788
|
-
if (!args.chainId && multiClient) {
|
|
2774
|
+
if ((!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && multiClient) {
|
|
2789
2775
|
const multiChain = Object.entries(multiClient);
|
|
2790
2776
|
const res = {};
|
|
2791
2777
|
await Promise.all(
|
|
2792
|
-
multiChain.map(async ([chainId, client]) => {
|
|
2778
|
+
multiChain.filter((x) => args.chainId ? args.chainId.includes(x[0]) : true).map(async ([chainId, client]) => {
|
|
2793
2779
|
const chain = _chains == null ? void 0 : _chains.find((i) => i.chainId === chainId);
|
|
2794
2780
|
if (!chain)
|
|
2795
2781
|
return;
|
|
@@ -2826,15 +2812,16 @@ var useBalanceStaked = (args) => {
|
|
|
2826
2812
|
const { data: singleClient } = useConnectClient({
|
|
2827
2813
|
client: "stargate",
|
|
2828
2814
|
chainId: args.chainId,
|
|
2829
|
-
enabled: Boolean(args.chainId) && Boolean(args.bech32Address)
|
|
2815
|
+
enabled: Boolean(args.chainId) && typeof args.chainId === "string" && Boolean(args.bech32Address)
|
|
2830
2816
|
});
|
|
2831
2817
|
const { data: multiClient } = useConnectClient({
|
|
2832
2818
|
client: "stargate",
|
|
2833
|
-
|
|
2819
|
+
chainId: args.chainId,
|
|
2820
|
+
enabled: (!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && Boolean(args.bech32Address)
|
|
2834
2821
|
});
|
|
2835
2822
|
const query = useQuery5(
|
|
2836
2823
|
[
|
|
2837
|
-
"
|
|
2824
|
+
"useBalanceStaked",
|
|
2838
2825
|
{
|
|
2839
2826
|
singleClient,
|
|
2840
2827
|
multiClient,
|
|
@@ -2843,7 +2830,7 @@ var useBalanceStaked = (args) => {
|
|
|
2843
2830
|
}
|
|
2844
2831
|
],
|
|
2845
2832
|
async () => {
|
|
2846
|
-
if (args.chainId && singleClient) {
|
|
2833
|
+
if (args.chainId && typeof args.chainId === "string" && singleClient) {
|
|
2847
2834
|
const singleChain = _chains == null ? void 0 : _chains.find((i) => i.chainId === args.chainId);
|
|
2848
2835
|
if (!singleChain)
|
|
2849
2836
|
throw new Error(`${args.chainId} Chain not found`);
|
|
@@ -2853,11 +2840,11 @@ var useBalanceStaked = (args) => {
|
|
|
2853
2840
|
});
|
|
2854
2841
|
return res;
|
|
2855
2842
|
}
|
|
2856
|
-
if (!args.chainId && multiClient) {
|
|
2843
|
+
if ((!args.chainId || Boolean(args.chainId) && Array.isArray(args.chainId)) && multiClient) {
|
|
2857
2844
|
const multiChain = Object.entries(multiClient);
|
|
2858
2845
|
const res = {};
|
|
2859
2846
|
await Promise.all(
|
|
2860
|
-
multiChain.map(async ([chainId, client]) => {
|
|
2847
|
+
multiChain.filter((x) => args.chainId ? args.chainId.includes(x[0]) : true).map(async ([chainId, client]) => {
|
|
2861
2848
|
const chain = _chains == null ? void 0 : _chains.find((i) => i.chainId === chainId);
|
|
2862
2849
|
if (!chain)
|
|
2863
2850
|
return;
|
|
@@ -3250,6 +3237,7 @@ export {
|
|
|
3250
3237
|
getAvailableWallets,
|
|
3251
3238
|
getBalance,
|
|
3252
3239
|
getBalanceStaked,
|
|
3240
|
+
getChain,
|
|
3253
3241
|
getCosmostation,
|
|
3254
3242
|
getKeplr,
|
|
3255
3243
|
getLeap,
|
|
@@ -3294,7 +3282,7 @@ export {
|
|
|
3294
3282
|
useOfflineSigners,
|
|
3295
3283
|
useQueryRaw,
|
|
3296
3284
|
useQuerySmart,
|
|
3297
|
-
|
|
3285
|
+
useRecentChains,
|
|
3298
3286
|
useSendIbcTokens,
|
|
3299
3287
|
useSendTokens,
|
|
3300
3288
|
useSuggestChain,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.3",
|
|
5
5
|
"author": "Griko Nibras <griko@strange.love>",
|
|
6
6
|
"repository": "https://github.com/strangelove-ventures/graz.git",
|
|
7
7
|
"homepage": "https://github.com/strangelove-ventures/graz",
|