graz 0.1.0-alpha.3 → 0.1.0-alpha.5

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
@@ -241,7 +241,13 @@ declare const reconnect: (args?: ReconnectArgs) => Promise<ConnectResult | undef
241
241
 
242
242
  declare const clearRecentChain: () => void;
243
243
  declare const getRecentChains: () => string[] | null;
244
- declare const suggestChain: (chainInfo: ChainInfo) => Promise<ChainInfo>;
244
+ declare const suggestChain: ({ chainInfo, walletType }: {
245
+ chainInfo: ChainInfo;
246
+ walletType?: WalletType | undefined;
247
+ }) => Promise<{
248
+ chainInfo: ChainInfo;
249
+ walletType: WalletType | undefined;
250
+ }>;
245
251
  interface SuggestChainAndConnectArgs {
246
252
  chainInfo: ChainInfo;
247
253
  autoReconnect?: boolean;
@@ -652,7 +658,10 @@ declare const useRecentChains: () => {
652
658
  data: string[] | null;
653
659
  clear: () => void;
654
660
  };
655
- type UseSuggestChainArgs = MutationEventArgs<ChainInfo>;
661
+ type UseSuggestChainArgs = MutationEventArgs<{
662
+ chainInfo: ChainInfo;
663
+ walletType?: WalletType;
664
+ }>;
656
665
  /**
657
666
  * graz mutation hook to suggest chain to a Wallet
658
667
  *
@@ -673,8 +682,20 @@ declare const useSuggestChain: ({ onError, onLoading, onSuccess }?: UseSuggestCh
673
682
  error: unknown;
674
683
  isLoading: boolean;
675
684
  isSuccess: boolean;
676
- suggest: _tanstack_react_query.UseMutateFunction<ChainInfo, unknown, ChainInfo, unknown>;
677
- suggestAsync: _tanstack_react_query.UseMutateAsyncFunction<ChainInfo, unknown, ChainInfo, unknown>;
685
+ suggest: _tanstack_react_query.UseMutateFunction<{
686
+ chainInfo: ChainInfo;
687
+ walletType: WalletType | undefined;
688
+ }, unknown, {
689
+ chainInfo: ChainInfo;
690
+ walletType?: WalletType | undefined;
691
+ }, unknown>;
692
+ suggestAsync: _tanstack_react_query.UseMutateAsyncFunction<{
693
+ chainInfo: ChainInfo;
694
+ walletType: WalletType | undefined;
695
+ }, unknown, {
696
+ chainInfo: ChainInfo;
697
+ walletType?: WalletType | undefined;
698
+ }, unknown>;
678
699
  status: "error" | "idle" | "loading" | "success";
679
700
  };
680
701
  type UseSuggestChainAndConnectArgs = MutationEventArgs<SuggestChainAndConnectArgs, ConnectResult>;
@@ -732,7 +753,7 @@ declare const useChain: ({ chainId }: {
732
753
  }) => {
733
754
  convertMinimalDenomToDenom: (searchMinimalDenom: string, value: string) => {
734
755
  denom: string;
735
- value: number;
756
+ value: string;
736
757
  } | undefined;
737
758
  currencies: _keplr_wallet_types.AppCurrency[];
738
759
  data: GrazChain;
package/dist/index.js CHANGED
@@ -1909,17 +1909,21 @@ var clearRecentChain = () => {
1909
1909
  var getRecentChains = () => {
1910
1910
  return useGrazInternalStore.getState().recentChains;
1911
1911
  };
1912
- var suggestChain = async (chainInfo) => {
1913
- const wallet = getWallet();
1912
+ var suggestChain = async ({ chainInfo, walletType }) => {
1913
+ const wallet = getWallet(walletType);
1914
1914
  await wallet.experimentalSuggestChain(chainInfo);
1915
- return chainInfo;
1915
+ return {
1916
+ chainInfo,
1917
+ walletType
1918
+ };
1916
1919
  };
1917
1920
  var suggestChainAndConnect = async (args) => {
1918
- await suggestChain(args.chainInfo);
1921
+ const defaultWalletType = useGrazInternalStore.getState().walletType;
1922
+ await suggestChain({ chainInfo: args.chainInfo, walletType: args.walletType ?? defaultWalletType });
1919
1923
  const result = await connect({
1920
1924
  chainId: [args.chainInfo.chainId],
1921
1925
  autoReconnect: args.autoReconnect,
1922
- walletType: args.walletType
1926
+ walletType: args.walletType ?? defaultWalletType
1923
1927
  });
1924
1928
  return result;
1925
1929
  };
@@ -2569,9 +2573,9 @@ var useRecentChains = () => {
2569
2573
  var useSuggestChain = ({ onError, onLoading, onSuccess } = {}) => {
2570
2574
  const queryKey = ["USE_SUGGEST_CHAIN", onError, onLoading, onSuccess];
2571
2575
  const mutation = (0, import_react_query3.useMutation)(queryKey, suggestChain, {
2572
- onError: (err, chainInfo) => Promise.resolve(onError == null ? void 0 : onError(err, chainInfo)),
2576
+ onError: (err, args) => Promise.resolve(onError == null ? void 0 : onError(err, args)),
2573
2577
  onMutate: onLoading,
2574
- onSuccess: (chainInfo) => Promise.resolve(onSuccess == null ? void 0 : onSuccess(chainInfo))
2578
+ onSuccess: (args) => Promise.resolve(onSuccess == null ? void 0 : onSuccess(args))
2575
2579
  });
2576
2580
  return {
2577
2581
  error: mutation.error,
@@ -2612,7 +2616,7 @@ var useChain = ({ chainId }) => {
2612
2616
  return;
2613
2617
  return {
2614
2618
  denom: currency.coinDenom,
2615
- value: Number(value) * Math.pow(10, currency.coinDecimals)
2619
+ value: String(Number(value) / Math.pow(10, currency.coinDecimals))
2616
2620
  };
2617
2621
  };
2618
2622
  return {
package/dist/index.mjs CHANGED
@@ -1800,17 +1800,21 @@ var clearRecentChain = () => {
1800
1800
  var getRecentChains = () => {
1801
1801
  return useGrazInternalStore.getState().recentChains;
1802
1802
  };
1803
- var suggestChain = async (chainInfo) => {
1804
- const wallet = getWallet();
1803
+ var suggestChain = async ({ chainInfo, walletType }) => {
1804
+ const wallet = getWallet(walletType);
1805
1805
  await wallet.experimentalSuggestChain(chainInfo);
1806
- return chainInfo;
1806
+ return {
1807
+ chainInfo,
1808
+ walletType
1809
+ };
1807
1810
  };
1808
1811
  var suggestChainAndConnect = async (args) => {
1809
- await suggestChain(args.chainInfo);
1812
+ const defaultWalletType = useGrazInternalStore.getState().walletType;
1813
+ await suggestChain({ chainInfo: args.chainInfo, walletType: args.walletType ?? defaultWalletType });
1810
1814
  const result = await connect({
1811
1815
  chainId: [args.chainInfo.chainId],
1812
1816
  autoReconnect: args.autoReconnect,
1813
- walletType: args.walletType
1817
+ walletType: args.walletType ?? defaultWalletType
1814
1818
  });
1815
1819
  return result;
1816
1820
  };
@@ -2460,9 +2464,9 @@ var useRecentChains = () => {
2460
2464
  var useSuggestChain = ({ onError, onLoading, onSuccess } = {}) => {
2461
2465
  const queryKey = ["USE_SUGGEST_CHAIN", onError, onLoading, onSuccess];
2462
2466
  const mutation = useMutation2(queryKey, suggestChain, {
2463
- onError: (err, chainInfo) => Promise.resolve(onError == null ? void 0 : onError(err, chainInfo)),
2467
+ onError: (err, args) => Promise.resolve(onError == null ? void 0 : onError(err, args)),
2464
2468
  onMutate: onLoading,
2465
- onSuccess: (chainInfo) => Promise.resolve(onSuccess == null ? void 0 : onSuccess(chainInfo))
2469
+ onSuccess: (args) => Promise.resolve(onSuccess == null ? void 0 : onSuccess(args))
2466
2470
  });
2467
2471
  return {
2468
2472
  error: mutation.error,
@@ -2503,7 +2507,7 @@ var useChain = ({ chainId }) => {
2503
2507
  return;
2504
2508
  return {
2505
2509
  denom: currency.coinDenom,
2506
- value: Number(value) * Math.pow(10, currency.coinDecimals)
2510
+ value: String(Number(value) / Math.pow(10, currency.coinDecimals))
2507
2511
  };
2508
2512
  };
2509
2513
  return {
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.3",
4
+ "version": "0.1.0-alpha.5",
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",