@0xsquid/react-hooks 8.4.1-beta-interactive-to-amount.0 → 8.5.0

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.
Files changed (29) hide show
  1. package/dist/core/queries/queries-keys.d.ts +1 -1
  2. package/dist/core/types/route.d.ts +1 -1
  3. package/dist/hooks/store/useSquidStore.d.ts +1 -2
  4. package/dist/hooks/swap/useSwap.d.ts +2 -4
  5. package/dist/hooks/transaction/useAllTransactionsStatus.d.ts +1 -0
  6. package/dist/hooks/transaction/useGetRoute.d.ts +0 -1
  7. package/dist/{index-Bg7CS2Uo.js → index-5cyMUZhY.js} +26 -54
  8. package/dist/index-5cyMUZhY.js.map +1 -0
  9. package/dist/{index-DnkELFs9.js → index-BGVXRZI6.js} +27 -54
  10. package/dist/index-BGVXRZI6.js.map +1 -0
  11. package/dist/{index.es-tWag56u3.js → index.es-BfdAGErV.js} +2 -2
  12. package/dist/{index.es-tWag56u3.js.map → index.es-BfdAGErV.js.map} +1 -1
  13. package/dist/{index.es-BQGUcysL.js → index.es-CeHwkxPw.js} +2 -2
  14. package/dist/{index.es-BQGUcysL.js.map → index.es-CeHwkxPw.js.map} +1 -1
  15. package/dist/index.esm.js +1 -1
  16. package/dist/index.js +1 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/{secretService-Bs5SPC6i.js → secretService-BMYOBXhv.js} +2 -2
  19. package/dist/{secretService-Bs5SPC6i.js.map → secretService-BMYOBXhv.js.map} +1 -1
  20. package/dist/{secretService-BXleHutG.js → secretService-D_d3CFdp.js} +2 -2
  21. package/dist/{secretService-BXleHutG.js.map → secretService-D_d3CFdp.js.map} +1 -1
  22. package/dist/services/internal/transactionService.d.ts +0 -7
  23. package/dist/{stellarService.client-li6iEHAu.js → stellarService.client-CIkvwxPo.js} +2 -2
  24. package/dist/{stellarService.client-li6iEHAu.js.map → stellarService.client-CIkvwxPo.js.map} +1 -1
  25. package/dist/{stellarService.client-TTYw1-aB.js → stellarService.client-DOrCdvCd.js} +2 -2
  26. package/dist/{stellarService.client-TTYw1-aB.js.map → stellarService.client-DOrCdvCd.js.map} +1 -1
  27. package/package.json +3 -3
  28. package/dist/index-Bg7CS2Uo.js.map +0 -1
  29. package/dist/index-DnkELFs9.js.map +0 -1
@@ -54,7 +54,7 @@ export declare const keys: () => {
54
54
  tokenData: (token?: TokenWithBalance) => (string | undefined)[];
55
55
  balance: (chainId?: number | string, tokenAddress?: string, userAddress?: string) => (string | number | undefined)[];
56
56
  allTokensBalance: (address: string | undefined, chainType: ChainType | undefined, direction?: SwapDirection) => (string | undefined)[];
57
- transaction: (fromChainId: string | undefined, toChainId: string | undefined, toTokenAddress: string | undefined, fromTokenAddress: string | undefined, fromAmount: string | undefined, toAmount: string | undefined, slippage: SlippageOption | undefined, getGasOnDestination: boolean | undefined, sourceUserAddress: string | undefined, degenMode: boolean | undefined, destinationAddress: string | undefined, fallbackAddress: string | undefined, quoteOnly: boolean | undefined, fromChainType: ChainType | undefined, preHook: AppConfig["preHook"] | undefined, postHook: AppConfig["postHook"] | undefined, overrideGasRefundAddress: AppConfig["overrideGasRefundAddress"] | undefined) => (string | number | boolean | Omit<import("@0xsquid/squid-types").Hook, "fundAmount" | "fundToken"> | undefined)[];
57
+ transaction: (fromChainId: string | undefined, toChainId: string | undefined, toTokenAddress: string | undefined, fromTokenAddress: string | undefined, price: string | undefined, slippage: SlippageOption | undefined, getGasOnDestination: boolean | undefined, sourceUserAddress: string | undefined, degenMode: boolean | undefined, destinationAddress: string | undefined, fallbackAddress: string | undefined, quoteOnly: boolean | undefined, fromChainType: ChainType | undefined, preHook: AppConfig["preHook"] | undefined, postHook: AppConfig["postHook"] | undefined, overrideGasRefundAddress: AppConfig["overrideGasRefundAddress"] | undefined) => (string | number | boolean | Omit<import("@0xsquid/squid-types").Hook, "fundAmount" | "fundToken"> | undefined)[];
58
58
  swapTransactionStatus: (transactionId: string | undefined) => (string | undefined)[];
59
59
  fiatToCryptoStatus: (transactionId?: string) => (string | undefined)[];
60
60
  sendTransactionStatus: (txHash: string | undefined, chainId: string | undefined) => (string | undefined)[];
@@ -1,4 +1,4 @@
1
1
  import { RouteRequest as SquidRouteRequest } from "@0xsquid/squid-types";
2
2
  export type RouteRequest = SquidRouteRequest & {
3
- toAmount?: string;
3
+ overrideGasRefundAddress?: string;
4
4
  };
@@ -21,8 +21,7 @@ export interface ConfigState {
21
21
  }
22
22
  export declare const useConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigState>>;
23
23
  interface TransactionState {
24
- fromAmount?: string;
25
- toAmount?: string;
24
+ fromPrice?: string;
26
25
  txLocalId?: string;
27
26
  transactions: Record<string, TransactionParams>;
28
27
  currentTransaction?: TransactionParams;
@@ -7,10 +7,8 @@ export declare const useSwap: () => {
7
7
  };
8
8
  onSwapChange: (inputSwapParams: SwapParams) => SwapParams;
9
9
  invertSwaps: (() => SwapParams) | undefined;
10
- fromAmount: string | undefined;
11
- toAmount: string | undefined;
12
- fromAmountChanged: (amount: string) => void;
13
- toAmountChanged: (amount: string) => void;
10
+ fromPrice: string | undefined;
11
+ fromPriceChanged: (price: string) => void;
14
12
  toToken: import("../../core").Token | undefined;
15
13
  fromToken: import("../../core").Token | undefined;
16
14
  fromChain: import("@0xsquid/squid-types").ChainData | undefined;
@@ -11,6 +11,7 @@ export declare const useAllTransactionsStatus: ({ enabled }: {
11
11
  gasStatus: string;
12
12
  isGMPTransaction?: boolean | undefined;
13
13
  axelarTransactionUrl: string;
14
+ coralTransactionUrl?: string | undefined;
14
15
  fromChain?: {
15
16
  transactionId: string;
16
17
  blockNumber: string;
@@ -16,7 +16,6 @@ export declare const useGetRoute: () => import("@tanstack/react-query").UseMutat
16
16
  sourceUserAddress: string | undefined;
17
17
  destinationAddress: string | undefined;
18
18
  fromPrice: string | undefined;
19
- toPrice: string | undefined;
20
19
  bypassGuardrails: RouteRequest["bypassGuardrails"] | undefined;
21
20
  quoteOnly: boolean | undefined;
22
21
  fromChainType: ChainType | undefined;
@@ -21137,17 +21137,9 @@ function isOnChainTxData(squidData) {
21137
21137
  return [
21138
21138
  squidTypes.SquidDataType.OnChainExecution,
21139
21139
  squidTypes.SquidDataType.DepositAddressWithSignature,
21140
+ squidTypes.SquidDataType.OnChainExecutionWithSignature,
21140
21141
  ].includes(squidData.type);
21141
21142
  }
21142
- /**
21143
- * Checks if a route is of type deposit-with-signature
21144
- *
21145
- * deposit-with-signature routes are on-chain routes
21146
- * that require a signature from the user to execute
21147
- */
21148
- function isDepositWithSignatureTxData(squidData) {
21149
- return squidData.type === squidTypes.SquidDataType.DepositAddressWithSignature;
21150
- }
21151
21143
  function getHistoryTransactionId(tx) {
21152
21144
  switch (tx.txType) {
21153
21145
  case exports.HistoryTxType.SWAP:
@@ -22306,15 +22298,14 @@ const keys = () => ({
22306
22298
  // ============
22307
22299
  // Transactions
22308
22300
  // ============
22309
- transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, fromAmount, toAmount, slippage, getGasOnDestination, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress) => [
22301
+ transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, price, slippage, getGasOnDestination, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress) => [
22310
22302
  ...keys().transactions(),
22311
22303
  exports.QueryKeys.Transaction,
22312
22304
  fromChainId,
22313
22305
  toChainId,
22314
22306
  toTokenAddress,
22315
22307
  fromTokenAddress,
22316
- fromAmount,
22317
- toAmount,
22308
+ price,
22318
22309
  slippage,
22319
22310
  getGasOnDestination,
22320
22311
  sourceUserAddress,
@@ -23179,7 +23170,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23179
23170
  };
23180
23171
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23181
23172
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23182
- const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-BXleHutG.js'); });
23173
+ const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-D_d3CFdp.js'); });
23183
23174
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23184
23175
  };
23185
23176
  function getTokenAssetsKey(token) {
@@ -25036,7 +25027,10 @@ const useConfigStore = zustand.create(() => ({
25036
25027
  isInitialized: false,
25037
25028
  }));
25038
25029
  const useTransactionStore = zustand.create((set, get) => ({
25030
+ fromPrice: undefined,
25031
+ txLocalId: undefined,
25039
25032
  transactions: {},
25033
+ currentTransaction: undefined,
25040
25034
  setTransactionState(txId, tx) {
25041
25035
  if (!txId)
25042
25036
  return;
@@ -26492,7 +26486,7 @@ function useStellarWallets() {
26492
26486
  try {
26493
26487
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
26494
26488
  const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
26495
- const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-li6iEHAu.js'); });
26489
+ const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-CIkvwxPo.js'); });
26496
26490
  const modules = [...initializeAllModules(), new LedgerModule()];
26497
26491
  const promises = modules.map(async (module) => {
26498
26492
  const isAvailable = await module.isAvailable();
@@ -27391,8 +27385,7 @@ const useMultiChainWallet = (chain) => {
27391
27385
 
27392
27386
  const useSwap = () => {
27393
27387
  const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, } = useConfigStore((state) => state.config);
27394
- const fromAmount = useTransactionStore((state) => state.fromAmount);
27395
- const toAmount = useTransactionStore((state) => state.toAmount);
27388
+ const fromPrice = useTransactionStore((state) => state.fromPrice);
27396
27389
  const { swapRoute } = useSwapRoutePersistStore();
27397
27390
  const { tokens } = useSquidTokens();
27398
27391
  const queryClient = reactQuery.useQueryClient();
@@ -27450,17 +27443,8 @@ const useSwap = () => {
27450
27443
  }),
27451
27444
  };
27452
27445
  }, [destAddressData, destAddressEnsData.data, toChain?.chainType]);
27453
- const fromAmountChanged = React.useCallback((amount) => {
27454
- useTransactionStore.setState({
27455
- fromAmount: amount || undefined,
27456
- toAmount: undefined,
27457
- });
27458
- }, []);
27459
- const toAmountChanged = React.useCallback((amount) => {
27460
- useTransactionStore.setState({
27461
- toAmount: amount || undefined,
27462
- fromAmount: undefined,
27463
- });
27446
+ const fromPriceChanged = React.useCallback((price) => {
27447
+ useTransactionStore.setState({ fromPrice: price || undefined });
27464
27448
  }, []);
27465
27449
  /**
27466
27450
  * When user changes something from the SwapView
@@ -27601,10 +27585,8 @@ const useSwap = () => {
27601
27585
  tokenItems,
27602
27586
  onSwapChange,
27603
27587
  invertSwaps,
27604
- fromAmount,
27605
- toAmount,
27606
- fromAmountChanged,
27607
- toAmountChanged,
27588
+ fromPrice,
27589
+ fromPriceChanged,
27608
27590
  toToken,
27609
27591
  fromToken,
27610
27592
  fromChain,
@@ -28004,7 +27986,7 @@ function hederaWalletConnect(parameters) {
28004
27986
  const optionalChains = config.chains.map((x) => x.id);
28005
27987
  if (!optionalChains.length)
28006
27988
  return;
28007
- const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-BQGUcysL.js'); });
27989
+ const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-CeHwkxPw.js'); });
28008
27990
  const rawProvider = await EthereumProvider.init({
28009
27991
  ...restParameters,
28010
27992
  disableProviderPing: true,
@@ -32128,7 +32110,7 @@ const useApproval = ({ squidRoute, }) => {
32128
32110
  const publicClient = wagmi.usePublicClient();
32129
32111
  const queryClient = reactQuery.useQueryClient();
32130
32112
  const squid = useSquidStore((state) => state.squid);
32131
- const { fromChain, fromToken, fromAmount, toAmount, isSameChain } = useSwap();
32113
+ const { fromChain, fromToken, fromPrice, isSameChain } = useSwap();
32132
32114
  const { evmSigner } = useSigner({ chain: fromChain });
32133
32115
  const { connector: activeConnector } = wagmi.useAccount();
32134
32116
  const { getChainType } = useSquidChains();
@@ -32301,7 +32283,7 @@ const useApproval = ({ squidRoute, }) => {
32301
32283
  // This is to ensure we're using the latest expiry timestamp
32302
32284
  if (squidRoute) {
32303
32285
  queryClient.refetchQueries({
32304
- queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromAmount, toAmount, squidRoute.params.slippage, squidRoute.params.receiveGasOnDestination, squidRoute.params.fromAddress, squidRoute.params.bypassGuardrails, squidRoute.params.toAddress, squidRoute.params.fallbackAddresses?.[0]?.address, squidRoute.params.quoteOnly, getChainType(squidRoute.params.fromChain), squidRoute.params.preHook, squidRoute.params.postHook,
32286
+ queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromPrice, squidRoute.params.slippage, squidRoute.params.receiveGasOnDestination, squidRoute.params.fromAddress, squidRoute.params.bypassGuardrails, squidRoute.params.toAddress, squidRoute.params.fallbackAddresses?.[0]?.address, squidRoute.params.quoteOnly, getChainType(squidRoute.params.fromChain), squidRoute.params.preHook, squidRoute.params.postHook,
32305
32287
  // TODO: update types
32306
32288
  squidRoute.params?.overrideGasRefundAddress),
32307
32289
  });
@@ -36114,12 +36096,8 @@ const useGetRoute = () => {
36114
36096
  * These data will be used to trigger the transaction
36115
36097
  * @returns {Route} Route data
36116
36098
  */
36117
- return reactQuery.useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice = "", toPrice = "", bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, overrideGasRefundAddress, }) => {
36118
- if (!fromChain ||
36119
- !toChain ||
36120
- !fromToken ||
36121
- !toToken ||
36122
- (!fromPrice && !toPrice)) {
36099
+ return reactQuery.useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice, bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, overrideGasRefundAddress, }) => {
36100
+ if (!fromChain || !toChain || !fromToken || !toToken || !fromPrice) {
36123
36101
  return undefined;
36124
36102
  }
36125
36103
  // Dispatch requestQuote event
@@ -36129,7 +36107,6 @@ const useGetRoute = () => {
36129
36107
  fromToken: fromToken.address,
36130
36108
  toToken: toToken.address,
36131
36109
  fromAmount: fromPrice,
36132
- toAmount: toPrice,
36133
36110
  fromAddress: sourceUserAddress,
36134
36111
  toAddress: destinationAddress,
36135
36112
  });
@@ -36138,7 +36115,6 @@ const useGetRoute = () => {
36138
36115
  const fromTokenAddress = fromToken.address;
36139
36116
  const toTokenAddress = toToken.address;
36140
36117
  const fromAmount = parseToBigInt(fromPrice?.toString() ?? "0", fromToken?.decimals).toString();
36141
- const toAmount = parseToBigInt(toPrice?.toString() ?? "0", toToken?.decimals).toString();
36142
36118
  const fromAddress = sourceUserAddress ??
36143
36119
  chainTypeToZeroAddressMap[fromChainType ?? squidTypes.ChainType.EVM];
36144
36120
  const params = {
@@ -36146,7 +36122,6 @@ const useGetRoute = () => {
36146
36122
  fromToken: fromTokenAddress,
36147
36123
  fromAddress,
36148
36124
  fromAmount,
36149
- toAmount,
36150
36125
  toChain,
36151
36126
  toToken: toTokenAddress,
36152
36127
  toAddress: destinationAddress ?? "",
@@ -36168,7 +36143,7 @@ const useGetRoute = () => {
36168
36143
  });
36169
36144
  // Cache the route data
36170
36145
  // Useful when the getRoute mutation is called from another hook
36171
- queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, toPrice, config.slippage, config.enableGetGasOnDestination, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook, overrideGasRefundAddress), route);
36146
+ queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage, config.enableGetGasOnDestination, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook, overrideGasRefundAddress), route);
36172
36147
  return route;
36173
36148
  });
36174
36149
  };
@@ -36182,7 +36157,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
36182
36157
  const depositRefundAddress = useSwapRoutePersistStore((store) => store.swapRoute?.depositRefundAddress);
36183
36158
  const { isAvailableAsPaymentMethod, isEnabled: isDepositAddressEnabled } = useDepositAddress();
36184
36159
  const getRouteMutation = useGetRoute();
36185
- const { fromChain, toChain, fromAmount, toAmount, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
36160
+ const { fromChain, toChain, fromPrice, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
36186
36161
  const { connectedAddress: { address: sourceConnectedAddress }, } = useMultiChainWallet(fromChain);
36187
36162
  // When the payment method is deposit address, users can specify a refund address on the source chain
36188
36163
  // Tokens will be sent to this address in case of swap failure
@@ -36191,13 +36166,12 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
36191
36166
  const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
36192
36167
  ? depositRefundAddress ?? sourceConnectedAddress
36193
36168
  : sourceConnectedAddress;
36194
- const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromAmount, toAmount, config.slippage, config.enableGetGasOnDestination, sourceUserAddress, config.degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChain?.chainType, config.preHook, config.postHook, config.overrideGasRefundAddress), [
36169
+ const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromPrice, config.slippage, config.enableGetGasOnDestination, sourceUserAddress, config.degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChain?.chainType, config.preHook, config.postHook, config.overrideGasRefundAddress), [
36195
36170
  fromChain?.chainId,
36196
36171
  toChain?.chainId,
36197
36172
  toToken?.address,
36198
36173
  fromToken?.address,
36199
- fromAmount,
36200
- toAmount,
36174
+ fromPrice,
36201
36175
  config.slippage,
36202
36176
  config.enableGetGasOnDestination,
36203
36177
  sourceUserAddress,
@@ -36213,8 +36187,8 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
36213
36187
  const queryEnabled = enabled != undefined
36214
36188
  ? enabled
36215
36189
  : squid !== undefined &&
36216
- ((fromAmount !== undefined && fromAmount !== "0") ||
36217
- (toAmount !== undefined && toAmount !== "0")) &&
36190
+ fromPrice !== undefined &&
36191
+ fromPrice !== "0" &&
36218
36192
  toChain?.chainId !== undefined &&
36219
36193
  toToken?.address !== undefined;
36220
36194
  const queryClient = reactQuery.useQueryClient();
@@ -36232,8 +36206,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
36232
36206
  toToken,
36233
36207
  sourceUserAddress,
36234
36208
  destinationAddress,
36235
- fromPrice: fromAmount,
36236
- toPrice: toAmount,
36209
+ fromPrice,
36237
36210
  bypassGuardrails: config.degenMode,
36238
36211
  quoteOnly,
36239
36212
  fromChainType: fromChain?.chainType,
@@ -37042,7 +37015,6 @@ exports.isChainflipBridgeTransaction = isChainflipBridgeTransaction;
37042
37015
  exports.isCoralBridgeAction = isCoralBridgeAction;
37043
37016
  exports.isCosmosAddressValid = isCosmosAddressValid;
37044
37017
  exports.isDepositRoute = isDepositRoute;
37045
- exports.isDepositWithSignatureTxData = isDepositWithSignatureTxData;
37046
37018
  exports.isEmptyObject = isEmptyObject;
37047
37019
  exports.isEvmChainNotSupportedError = isEvmChainNotSupportedError;
37048
37020
  exports.isEvmosChain = isEvmosChain;
@@ -37177,4 +37149,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
37177
37149
  exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
37178
37150
  exports.walletIconBaseUrl = walletIconBaseUrl;
37179
37151
  exports.walletSupportsChainType = walletSupportsChainType;
37180
- //# sourceMappingURL=index-Bg7CS2Uo.js.map
37152
+ //# sourceMappingURL=index-5cyMUZhY.js.map