@sodax/dapp-kit 2.0.0-rc.19 → 2.0.0-rc.20

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
@@ -4,6 +4,33 @@ export * from '@sodax/sdk';
4
4
  import { Address } from 'viem';
5
5
  import { ReactNode, ReactElement } from 'react';
6
6
 
7
+ /**
8
+ * Predicate for the canonical "user cancelled the wallet prompt" outcome.
9
+ *
10
+ * The SDK classifies wallet rejection at the source: `intentCreationFailed` / `approveFailed`
11
+ * wrappers emit `SodaxError<'USER_REJECTED'>` whenever the underlying cause matches a known
12
+ * rejection shape (viem `4001` / `UserRejectedRequestError`, ICON Hana `CANCEL_SIGNING`,
13
+ * Solana / Sui / Stellar / Stacks / NEAR / Injective name + message patterns). Consumers
14
+ * branch on this code to render a "Cancelled" UI instead of a "Failed" toast — user
15
+ * cancellation is a normal flow, not a failure.
16
+ *
17
+ * Use after `mutateAsyncSafe` (or inside an `onError` / `catch`):
18
+ *
19
+ * ```ts
20
+ * const result = await swap.mutateAsyncSafe({ params, walletProvider });
21
+ * if (!result.ok) {
22
+ * if (isUserRejectedError(result.error)) return; // silent — user cancelled
23
+ * toast.error(getErrorMessage(result.error)); // real failure
24
+ * }
25
+ * ```
26
+ *
27
+ * The check trusts the SDK's classification — it does NOT re-scan message content. Errors
28
+ * raised outside the SDK boundary (e.g. a non-SodaxError thrown from a `queryFn`) will not
29
+ * match, which is intentional: only the SDK's `USER_REJECTED` is the canonical "cancelled"
30
+ * signal.
31
+ */
32
+ declare function isUserRejectedError(error: unknown): boolean;
33
+
7
34
  /**
8
35
  * Subset of `UseQueryOptions` consumers may override on dapp-kit read hooks.
9
36
  *
@@ -257,7 +284,7 @@ type UseXBalancesParams = ReadHookParams<Record<string, bigint>, XBalancesInputs
257
284
  * tests and for advanced callers that compose their own `useQuery` wrapper.
258
285
  */
259
286
  declare function getXBalancesQueryOptions({ xService, xChainId, xTokens, address }: XBalancesInputs): {
260
- queryKey: readonly ["shared", "xBalances", "0xa86a.avax" | "0xa4b1.arbitrum" | "0x2105.base" | "0x38.bsc" | "injective-1" | "sonic" | "0x1.icon" | "sui" | "0xa.optimism" | "0x89.polygon" | "solana" | "stellar" | "hyper" | "lightlink" | "near" | "ethereum" | "bitcoin" | "redbelly" | "0x2019.kaia" | "stacks" | undefined, (readonly [string, string])[], string | undefined];
287
+ queryKey: readonly ["shared", "xBalances", "0xa86a.avax" | "0xa4b1.arbitrum" | "0x2105.base" | "0x38.bsc" | "injective-1" | "sonic" | "0x1.icon" | "sui" | "0xa.optimism" | "0x89.polygon" | "solana" | "stellar" | "hyper" | "lightlink" | "near" | "ethereum" | "bitcoin" | "redbelly" | "0x2019.kaia" | "stacks" | "hedera" | undefined, (readonly [string, string])[], string | undefined];
261
288
  queryFn: () => Promise<Record<string, bigint>>;
262
289
  enabled: boolean;
263
290
  refetchInterval: number;
@@ -1190,7 +1217,7 @@ type UseSwapsApiSubmitTxStatusParams = ReadHookParams<SubmitTxStatusResponseV2 |
1190
1217
  * });
1191
1218
  *
1192
1219
  * @remarks
1193
- * - Default refetch interval is 1 second; stops on 'executed' or 'failed' status.
1220
+ * - Default refetch interval is 1 second; stops on 'solved' or 'failed' status.
1194
1221
  */
1195
1222
  declare const useSwapsApiSubmitTxStatus: ({ params, queryOptions, }?: UseSwapsApiSubmitTxStatusParams) => UseQueryResult<SubmitTxStatusResponseV2 | undefined, Error>;
1196
1223
 
@@ -2242,4 +2269,4 @@ interface NearStorageGateState {
2242
2269
  */
2243
2270
  declare function resolveNearStorageGate(chainKey: SpokeChainKey, check: NearStorageCheckResult): NearStorageGateState;
2244
2271
 
2245
- export { type ATokenData, type BackendPaginationParams, type BitcoinTradingSetup, type CreateSodaxQueryClientOptions, type DecreaseLiquidityParamsCore, type DepositParamsCore, type LeverageYieldShareHolder, type LeverageYieldShareHolding, type MutationHookOptions, type MutationHookParams, type NearStorageCheckResult, type NearStorageGateState, type RadfiSession, type ReadHookParams, type ReadQueryOptions, type ReserveUsdFormat, type SafeUseMutationResult, SodaxProvider, type UseATokenParams, type UseATokensBalancesParams, type UseApproveTokenVars, type UseBitcoinBalanceParams, type UseBitcoinTradingSetupParams, type UseBorrowVars, type UseBridgeAllowanceParams, type UseBridgeApproveVars, type UseBridgeVars, type UseClaimRewardsVars, type UseCreateDecreaseLiquidityParamsProps, type UseCreateDepositParamsProps, type UseCreateLimitOrderVars, type UseCreateSupplyLiquidityParamsProps, type UseCreateSupplyLiquidityParamsResult, type UseCreateWithdrawParamsProps, type UseDecreaseLiquidityVars, type UseDeriveUserWalletAddressParams, type UseDexAllowanceParams, type UseDexApproveVars, type UseDexDepositVars, type UseDexWithdrawVars, type UseEnsureRadfiAccessTokenVars, type UseExpiredUtxosParams, type UseFeeClaimSwapVars, type UseFeeClaimWithdrawVars, type UseFetchAssetsBalancesParams, type UseFundTradingWalletVars, type UseGetAutoSwapPreferencesParams, type UseGetBridgeableAmountParams, type UseGetBridgeableTokensParams, type UseGetIntentDetailsParams, type UseGetUserHubWalletAddressParams, type UseGetUserIntentParams, type UseHubAssetBalancesParams, type UseIsTokenApprovedParams, type UseLeverageYieldDepositVars, type UseLeverageYieldEffectiveAprParams, type UseLeverageYieldNotifySolverVars, type UseLeverageYieldPositionParams, type UseLeverageYieldPreviewRedeemParams, type UseLeverageYieldShareBalancesParams, type UseLeverageYieldTotalAssetsParams, type UseLeverageYieldVaultSwapVars, type UseLeverageYieldWithdrawVars, type UseLiquidityAmountsResult, type UseMMAllowanceParams, type UseMMApproveVars, type UseMigrateBalnVars, type UseMigrateIcxToSodaVars, type UseMigratebnUSDVars, type UseMigrationAllowanceInputs, type UseMigrationAllowanceParams, type UseMigrationApproveVars, type UseNearStorageCheckParams, type UsePartnerCancelIntentVars, type UsePoolBalancesParams, type UsePoolBalancesResponse, type UsePoolDataParams, type UsePoolsParams, type UsePositionInfoParams, type UsePositionInfoResponse, type UseQuoteParams, type UseRadfiAuthVars, type UseRadfiSessionReturn, type UseRadfiWithdrawVars, type UseRegisterNearStorageVars, type UseRenewUtxosVars, type UseRepayVars, type UseReservesDataParams, type UseReservesHumanizedParams, type UseReservesListParams, type UseReservesUsdFormatParams, type UseRevertMigrateSodaToIcxVars, type UseSetSwapPreferenceVars, type UseSetSwapPreferenceVarsHub, type UseStatusParams, type UseStellarTrustlineCheckParams, type UseSupplyLiquidityVars, type UseSupplyVars, type UseSwapAllowanceParams, type UseSwapApproveVars, type UseSwapVars, type UseSwapsApiAllowanceParams, type UseSwapsApiApproveVars, type UseSwapsApiCancelIntentVars, type UseSwapsApiCreateIntentVars, type UseSwapsApiCreateLimitOrderVars, type UseSwapsApiDeadlineParams, type UseSwapsApiEstimateGasParams, type UseSwapsApiFilledIntentParams, type UseSwapsApiIntentExtraDataParams, type UseSwapsApiIntentHashParams, type UseSwapsApiIntentPacketParams, type UseSwapsApiIntentParams, type UseSwapsApiPartnerFeeParams, type UseSwapsApiQuoteParams, type UseSwapsApiSolverFeeParams, type UseSwapsApiStatusParams, type UseSwapsApiSubmitIntentVars, type UseSwapsApiSubmitTxStatusParams, type UseSwapsApiSubmitTxVars, type UseSwapsApiTokensByChainParams, type UseSwapsApiTokensParams, type UseTradingWalletBalanceParams, type UseUserFormattedSummaryParams, type UseUserReservesDataParams, type UseWithdrawHubAssetVars, type UseWithdrawVars, type UseXBalancesParams, type WithdrawParamsCore, type XBalancesInputs, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getXBalancesQueryOptions, isTerminalSwapIntentStatus, loadRadfiSession, resolveNearStorageGate, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
2272
+ export { type ATokenData, type BackendPaginationParams, type BitcoinTradingSetup, type CreateSodaxQueryClientOptions, type DecreaseLiquidityParamsCore, type DepositParamsCore, type LeverageYieldShareHolder, type LeverageYieldShareHolding, type MutationHookOptions, type MutationHookParams, type NearStorageCheckResult, type NearStorageGateState, type RadfiSession, type ReadHookParams, type ReadQueryOptions, type ReserveUsdFormat, type SafeUseMutationResult, SodaxProvider, type UseATokenParams, type UseATokensBalancesParams, type UseApproveTokenVars, type UseBitcoinBalanceParams, type UseBitcoinTradingSetupParams, type UseBorrowVars, type UseBridgeAllowanceParams, type UseBridgeApproveVars, type UseBridgeVars, type UseClaimRewardsVars, type UseCreateDecreaseLiquidityParamsProps, type UseCreateDepositParamsProps, type UseCreateLimitOrderVars, type UseCreateSupplyLiquidityParamsProps, type UseCreateSupplyLiquidityParamsResult, type UseCreateWithdrawParamsProps, type UseDecreaseLiquidityVars, type UseDeriveUserWalletAddressParams, type UseDexAllowanceParams, type UseDexApproveVars, type UseDexDepositVars, type UseDexWithdrawVars, type UseEnsureRadfiAccessTokenVars, type UseExpiredUtxosParams, type UseFeeClaimSwapVars, type UseFeeClaimWithdrawVars, type UseFetchAssetsBalancesParams, type UseFundTradingWalletVars, type UseGetAutoSwapPreferencesParams, type UseGetBridgeableAmountParams, type UseGetBridgeableTokensParams, type UseGetIntentDetailsParams, type UseGetUserHubWalletAddressParams, type UseGetUserIntentParams, type UseHubAssetBalancesParams, type UseIsTokenApprovedParams, type UseLeverageYieldDepositVars, type UseLeverageYieldEffectiveAprParams, type UseLeverageYieldNotifySolverVars, type UseLeverageYieldPositionParams, type UseLeverageYieldPreviewRedeemParams, type UseLeverageYieldShareBalancesParams, type UseLeverageYieldTotalAssetsParams, type UseLeverageYieldVaultSwapVars, type UseLeverageYieldWithdrawVars, type UseLiquidityAmountsResult, type UseMMAllowanceParams, type UseMMApproveVars, type UseMigrateBalnVars, type UseMigrateIcxToSodaVars, type UseMigratebnUSDVars, type UseMigrationAllowanceInputs, type UseMigrationAllowanceParams, type UseMigrationApproveVars, type UseNearStorageCheckParams, type UsePartnerCancelIntentVars, type UsePoolBalancesParams, type UsePoolBalancesResponse, type UsePoolDataParams, type UsePoolsParams, type UsePositionInfoParams, type UsePositionInfoResponse, type UseQuoteParams, type UseRadfiAuthVars, type UseRadfiSessionReturn, type UseRadfiWithdrawVars, type UseRegisterNearStorageVars, type UseRenewUtxosVars, type UseRepayVars, type UseReservesDataParams, type UseReservesHumanizedParams, type UseReservesListParams, type UseReservesUsdFormatParams, type UseRevertMigrateSodaToIcxVars, type UseSetSwapPreferenceVars, type UseSetSwapPreferenceVarsHub, type UseStatusParams, type UseStellarTrustlineCheckParams, type UseSupplyLiquidityVars, type UseSupplyVars, type UseSwapAllowanceParams, type UseSwapApproveVars, type UseSwapVars, type UseSwapsApiAllowanceParams, type UseSwapsApiApproveVars, type UseSwapsApiCancelIntentVars, type UseSwapsApiCreateIntentVars, type UseSwapsApiCreateLimitOrderVars, type UseSwapsApiDeadlineParams, type UseSwapsApiEstimateGasParams, type UseSwapsApiFilledIntentParams, type UseSwapsApiIntentExtraDataParams, type UseSwapsApiIntentHashParams, type UseSwapsApiIntentPacketParams, type UseSwapsApiIntentParams, type UseSwapsApiPartnerFeeParams, type UseSwapsApiQuoteParams, type UseSwapsApiSolverFeeParams, type UseSwapsApiStatusParams, type UseSwapsApiSubmitIntentVars, type UseSwapsApiSubmitTxStatusParams, type UseSwapsApiSubmitTxVars, type UseSwapsApiTokensByChainParams, type UseSwapsApiTokensParams, type UseTradingWalletBalanceParams, type UseUserFormattedSummaryParams, type UseUserReservesDataParams, type UseWithdrawHubAssetVars, type UseWithdrawVars, type UseXBalancesParams, type WithdrawParamsCore, type XBalancesInputs, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getXBalancesQueryOptions, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
package/dist/index.mjs CHANGED
@@ -1,10 +1,15 @@
1
+ import { isSodaxError, ChainKeys, RadfiApiError, normalizePsbtToBase64, ClService, Sodax } from '@sodax/sdk';
2
+ export * from '@sodax/sdk';
1
3
  import { useMutation, useQuery, useQueryClient, useQueries, QueryClient, MutationCache } from '@tanstack/react-query';
2
4
  import { createContext, useCallback, useContext, useState, useRef, useEffect, useMemo } from 'react';
3
- import { ChainKeys, RadfiApiError, normalizePsbtToBase64, ClService, Sodax } from '@sodax/sdk';
4
- export * from '@sodax/sdk';
5
5
  import { isAddress, erc20Abi, parseUnits } from 'viem';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
 
8
+ // src/hooks/shared/isUserRejectedError.ts
9
+ function isUserRejectedError(error) {
10
+ return isSodaxError(error) && error.code === "USER_REJECTED";
11
+ }
12
+
8
13
  // src/hooks/shared/unwrapResult.ts
9
14
  function unwrapResult(result) {
10
15
  if (!result.ok) {
@@ -1579,7 +1584,7 @@ var useSwapsApiSubmitTxStatus = ({
1579
1584
  retry: 3,
1580
1585
  refetchInterval: (query) => {
1581
1586
  const status = query.state.data?.data?.status;
1582
- if (status === "executed" || status === "failed") return false;
1587
+ if (status === "solved" || status === "failed") return false;
1583
1588
  return 1e3;
1584
1589
  },
1585
1590
  ...queryOptions
@@ -3209,4 +3214,4 @@ function createSodaxQueryClient({
3209
3214
  });
3210
3215
  }
3211
3216
 
3212
- export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getXBalancesQueryOptions, isTerminalSwapIntentStatus, loadRadfiSession, resolveNearStorageGate, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
3217
+ export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getXBalancesQueryOptions, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "access": "public"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "2.0.0-rc.19",
8
+ "version": "2.0.0-rc.20",
9
9
  "description": "React hooks for building dApps on the SODAX cross-chain DeFi platform",
10
10
  "keywords": [
11
11
  "sodax",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "viem": "2.29.2",
37
- "@sodax/sdk": "2.0.0-rc.19"
37
+ "@sodax/sdk": "2.0.0-rc.20"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@arethetypeswrong/cli": "0.17.4",
@@ -1,3 +1,4 @@
1
+ export * from './isUserRejectedError.js';
1
2
  export * from './types.js';
2
3
  export * from './unwrapResult.js';
3
4
  export * from './useSafeMutation.js';
@@ -0,0 +1,42 @@
1
+ import { SodaxError } from '@sodax/sdk';
2
+ import { describe, expect, it } from 'vitest';
3
+ import { isUserRejectedError } from './isUserRejectedError.js';
4
+
5
+ describe('isUserRejectedError', () => {
6
+ it('matches SodaxError with code USER_REJECTED', () => {
7
+ const err = new SodaxError('USER_REJECTED', 'User rejected the request', { feature: 'swap' });
8
+ expect(isUserRejectedError(err)).toBe(true);
9
+ });
10
+
11
+ it('does not match SodaxError with any other code', () => {
12
+ const cases: SodaxError[] = [
13
+ new SodaxError('INTENT_CREATION_FAILED', 'sim revert', { feature: 'swap' }),
14
+ new SodaxError('VALIDATION_FAILED', 'user rejected by invariant', { feature: 'staking' }),
15
+ new SodaxError('APPROVE_FAILED', 'allowance', { feature: 'moneyMarket' }),
16
+ new SodaxError('EXECUTION_FAILED', 'orchestrator', { feature: 'bridge' }),
17
+ new SodaxError('UNKNOWN', 'fallback', { feature: 'dex' }),
18
+ ];
19
+ for (const err of cases) expect(isUserRejectedError(err)).toBe(false);
20
+ });
21
+
22
+ it('does not match a plain Error whose message contains rejection prose', () => {
23
+ // The predicate trusts SDK classification; it does NOT re-scan message content. A bare
24
+ // Error from outside the SDK boundary (e.g. a non-canonical throw in a queryFn) is not a
25
+ // canonical USER_REJECTED — it should fall through to the generic failure UI.
26
+ expect(isUserRejectedError(new Error('User rejected the request'))).toBe(false);
27
+ });
28
+
29
+ it('does not match viem-shaped objects or wallet-library shapes', () => {
30
+ expect(isUserRejectedError({ name: 'UserRejectedRequestError', message: 'denied' })).toBe(false);
31
+ expect(isUserRejectedError({ code: 4001, message: 'reject' })).toBe(false);
32
+ expect(isUserRejectedError({ code: 'ACTION_REJECTED' })).toBe(false);
33
+ });
34
+
35
+ it('does not match non-error values', () => {
36
+ expect(isUserRejectedError(undefined)).toBe(false);
37
+ expect(isUserRejectedError(null)).toBe(false);
38
+ expect(isUserRejectedError('User rejected the request')).toBe(false);
39
+ expect(isUserRejectedError({})).toBe(false);
40
+ expect(isUserRejectedError(0)).toBe(false);
41
+ });
42
+ });
@@ -0,0 +1,30 @@
1
+ import { isSodaxError } from '@sodax/sdk';
2
+
3
+ /**
4
+ * Predicate for the canonical "user cancelled the wallet prompt" outcome.
5
+ *
6
+ * The SDK classifies wallet rejection at the source: `intentCreationFailed` / `approveFailed`
7
+ * wrappers emit `SodaxError<'USER_REJECTED'>` whenever the underlying cause matches a known
8
+ * rejection shape (viem `4001` / `UserRejectedRequestError`, ICON Hana `CANCEL_SIGNING`,
9
+ * Solana / Sui / Stellar / Stacks / NEAR / Injective name + message patterns). Consumers
10
+ * branch on this code to render a "Cancelled" UI instead of a "Failed" toast — user
11
+ * cancellation is a normal flow, not a failure.
12
+ *
13
+ * Use after `mutateAsyncSafe` (or inside an `onError` / `catch`):
14
+ *
15
+ * ```ts
16
+ * const result = await swap.mutateAsyncSafe({ params, walletProvider });
17
+ * if (!result.ok) {
18
+ * if (isUserRejectedError(result.error)) return; // silent — user cancelled
19
+ * toast.error(getErrorMessage(result.error)); // real failure
20
+ * }
21
+ * ```
22
+ *
23
+ * The check trusts the SDK's classification — it does NOT re-scan message content. Errors
24
+ * raised outside the SDK boundary (e.g. a non-SodaxError thrown from a `queryFn`) will not
25
+ * match, which is intentional: only the SDK's `USER_REJECTED` is the canonical "cancelled"
26
+ * signal.
27
+ */
28
+ export function isUserRejectedError(error: unknown): boolean {
29
+ return isSodaxError(error) && error.code === 'USER_REJECTED';
30
+ }
@@ -24,7 +24,7 @@ export type UseSwapsApiSubmitTxStatusParams = ReadHookParams<
24
24
  * });
25
25
  *
26
26
  * @remarks
27
- * - Default refetch interval is 1 second; stops on 'executed' or 'failed' status.
27
+ * - Default refetch interval is 1 second; stops on 'solved' or 'failed' status.
28
28
  */
29
29
  export const useSwapsApiSubmitTxStatus = ({
30
30
  params,
@@ -47,7 +47,7 @@ export const useSwapsApiSubmitTxStatus = ({
47
47
  retry: 3,
48
48
  refetchInterval: query => {
49
49
  const status = query.state.data?.data?.status;
50
- if (status === 'executed' || status === 'failed') return false;
50
+ if (status === 'solved' || status === 'failed') return false;
51
51
  return 1000;
52
52
  },
53
53
  ...queryOptions,