@aurora-is-near/intents-swap-widget 3.14.0-redesign.9 → 3.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/{config-CG-NCoEP.js → config-QBojKcju.js} +584 -569
  2. package/dist/config-QBojKcju.js.map +1 -0
  3. package/dist/config.js +1 -1
  4. package/dist/errors.js +1 -1
  5. package/dist/ext/alchemy/index.js +1 -1
  6. package/dist/ext/index.js +1 -1
  7. package/dist/features/BalanceRpcLoader/TokenBalanceLoader.js +1 -1
  8. package/dist/features/BalanceRpcLoader/index.js +1 -1
  9. package/dist/features/BalanceRpcLoader/useTokenBalanceRpc.js +1 -1
  10. package/dist/features/ChainsDropdown/index.js +31 -31
  11. package/dist/features/ChainsDropdown/index.js.map +1 -1
  12. package/dist/features/DepositMethodSwitcher.js +12 -10
  13. package/dist/features/DepositMethodSwitcher.js.map +1 -1
  14. package/dist/features/ErrorBoundary.js +1 -1
  15. package/dist/features/ExternalDeposit.js +1 -1
  16. package/dist/features/SendAddress/index.js +1 -1
  17. package/dist/features/SendAddress/useNotification.js +1 -1
  18. package/dist/features/SubmitButton/index.js +1 -1
  19. package/dist/features/SuccessScreen/index.js +1 -1
  20. package/dist/features/SwapDirectionSwitcher.js +1 -1
  21. package/dist/features/SwapQuote/SwapQuote.js +1 -1
  22. package/dist/features/SwapQuote/index.js +1 -1
  23. package/dist/features/TokenInput/TokenInput.js +1 -1
  24. package/dist/features/TokenInput/TokenInputEmpty.js +1 -1
  25. package/dist/features/TokenInput/TokenInputSource.js +1 -1
  26. package/dist/features/TokenInput/TokenInputTarget.js +1 -1
  27. package/dist/features/TokenInput/WalletBalance.js +1 -1
  28. package/dist/features/TokenInput/hooks/index.js +1 -1
  29. package/dist/features/TokenInput/hooks/useTokenInputBalance.js +1 -1
  30. package/dist/features/TokenInput/index.js +1 -1
  31. package/dist/features/TokensList/TokenItem.js +1 -1
  32. package/dist/features/TokensList/TokensList.js +1 -1
  33. package/dist/features/TokensList/index.js +1 -1
  34. package/dist/features/TokensModal.js +1 -1
  35. package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js +1 -1
  36. package/dist/features/WalletCompatibilityCheck/index.js +1 -1
  37. package/dist/features/index.js +1 -1
  38. package/dist/hooks/index.js +1 -1
  39. package/dist/hooks/useAllTokens.js +1 -1
  40. package/dist/hooks/useChains.js +1 -1
  41. package/dist/hooks/useCompatibilityCheck.js +1 -1
  42. package/dist/hooks/useDefaultToken.js +1 -1
  43. package/dist/hooks/useExternalDepositStatus/index.js +1 -1
  44. package/dist/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.js +1 -1
  45. package/dist/hooks/useIntentsBalance.js +1 -1
  46. package/dist/hooks/useIsCompatibilityCheckRequired.js +1 -1
  47. package/dist/hooks/useMakeDepositAddress.js +1 -1
  48. package/dist/hooks/useMakeIntentsTransfer.js +3 -2
  49. package/dist/hooks/useMakeIntentsTransfer.js.map +1 -1
  50. package/dist/hooks/useMakeNEARFtTransferCall.js +1 -1
  51. package/dist/hooks/useMakeQuote.js +1 -1
  52. package/dist/hooks/useMakeQuoteTransfer.js +1 -1
  53. package/dist/hooks/useMakeTransfer.js +1 -1
  54. package/dist/hooks/useMergedBalance.js +1 -1
  55. package/dist/hooks/useSwitchChain.js +1 -1
  56. package/dist/hooks/useTheme.js +1 -1
  57. package/dist/hooks/useTokenInputPair.js +1 -1
  58. package/dist/hooks/useTokens.js +1 -1
  59. package/dist/hooks/useTokensFiltered.js +1 -1
  60. package/dist/hooks/useTokensIntentsUnique.js +1 -1
  61. package/dist/index.js +1 -1
  62. package/dist/machine/effects/index.js +1 -1
  63. package/dist/machine/effects/useAlchemyBalanceEffect.js +1 -1
  64. package/dist/machine/effects/useBalancesUpdateEffect.js +1 -1
  65. package/dist/machine/effects/useMakeQuoteEffect.js +1 -1
  66. package/dist/machine/effects/useSelectedTokensEffect.js +1 -1
  67. package/dist/machine/effects/useSetTokenBalanceEffect.js +1 -1
  68. package/dist/machine/effects/useSetTokenIntentsTargetEffect.js +1 -1
  69. package/dist/machine/effects/useWalletConnEffect.js +1 -1
  70. package/dist/machine/errors.d.ts +5 -0
  71. package/dist/machine/errors.js.map +1 -1
  72. package/dist/machine/events/index.js +1 -1
  73. package/dist/machine/events/tokenSelect.js +1 -1
  74. package/dist/machine/events/validateInputAndMoveTo.js +1 -1
  75. package/dist/machine/events/validateInputs.js +1 -1
  76. package/dist/machine/index.js +1 -1
  77. package/dist/machine/snap.d.ts +15 -0
  78. package/dist/machine/snap.js +1 -1
  79. package/dist/machine/subscriptions/checkers/isSendAddressAsConnected.js +1 -1
  80. package/dist/machine/subscriptions/index.js +1 -1
  81. package/dist/theme/ThemeProvider.js +1 -1
  82. package/dist/utils/intents/signers/near.js +1 -1
  83. package/dist/utils/intents/signers/privy.js +1 -1
  84. package/dist/utils/localstorage.d.ts +2 -2
  85. package/dist/utils/localstorage.js +1 -0
  86. package/dist/utils/localstorage.js.map +1 -1
  87. package/dist/utils/near/getNearNep141StorageBalance.js +1 -1
  88. package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +1 -1
  89. package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
  90. package/dist/widgets/WidgetSwap/WidgetSwapContent.js +1 -1
  91. package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
  92. package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +1 -1
  93. package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
  94. package/package.json +3 -3
  95. package/src/features/ChainsDropdown/index.tsx +1 -1
  96. package/src/features/DepositMethodSwitcher.tsx +2 -0
  97. package/src/features/SubmitButton/index.tsx +4 -1
  98. package/src/features/TokensList/TokensList.tsx +1 -1
  99. package/src/hooks/useMakeIntentsTransfer.ts +22 -0
  100. package/src/machine/errors.ts +1 -0
  101. package/src/tests/mock-localstorage.ts +32 -0
  102. package/src/utils/localstorage.ts +2 -2
  103. package/src/widgets/WidgetDeposit/WidgetDeposit.test.tsx +6 -0
  104. package/dist/config-CG-NCoEP.js.map +0 -1
@@ -3,6 +3,8 @@ import {
3
3
  createIntentSignerNEP413,
4
4
  createInternalTransferRoute,
5
5
  createNearWithdrawalRoute,
6
+ FeeExceedsAmountError,
7
+ MinWithdrawalAmountError,
6
8
  type RouteConfig,
7
9
  } from '@defuse-protocol/bridge-sdk';
8
10
  import type { NearWalletBase as NearWallet } from '@hot-labs/near-connect/build/types/wallet';
@@ -20,6 +22,7 @@ import { localStorageTyped } from '@/utils/localstorage';
20
22
  import { queryContract } from '@/utils/near/queryContract';
21
23
  import { IntentSignerPrivy } from '@/utils/intents/signers/privy';
22
24
  import { createNearWalletSigner } from '@/utils/intents/signers/near';
25
+ import { formatBigToHuman } from '@/utils/formatters/formatBigToHuman';
23
26
  import { getIntentsAccountId } from '@/utils/intents/getIntentsAccountId';
24
27
  import { getTransactionLink } from '@/utils/formatters/getTransactionLink';
25
28
  import { isUserDeniedSigning } from '@/utils/checkers/isUserDeniedSigning';
@@ -291,6 +294,25 @@ export const useMakeIntentsTransfer = ({ providers }: IntentsTransferArgs) => {
291
294
  } catch (e: unknown) {
292
295
  logger.error('[TRANSFER ERROR]', e);
293
296
 
297
+ if (e instanceof MinWithdrawalAmountError) {
298
+ throw new TransferError({
299
+ code: 'MIN_WITHDRAWAL_AMOUNT_ERROR',
300
+ meta: {
301
+ minAmount: formatBigToHuman(
302
+ e.minAmount.toString(),
303
+ ctx.sourceToken.decimals,
304
+ ),
305
+ },
306
+ });
307
+ }
308
+
309
+ if (e instanceof FeeExceedsAmountError) {
310
+ throw new TransferError({
311
+ code: 'TRANSFER_INVALID_INITIAL',
312
+ meta: { message: 'Fee is above the maximum allowed' },
313
+ });
314
+ }
315
+
294
316
  if (e instanceof Error) {
295
317
  if (e.message.includes('Fee is not estimated')) {
296
318
  throw new TransferError({
@@ -48,6 +48,7 @@ export type InputValidWalletError =
48
48
  | { code: 'QUOTE_NO_ONE_TIME_ADDRESS' };
49
49
 
50
50
  export type QuoteSuccessDirectTransferError =
51
+ | { code: 'MIN_WITHDRAWAL_AMOUNT_ERROR'; meta: { minAmount?: string } }
51
52
  | { code: 'DIRECT_TRANSFER_ERROR'; meta?: { message?: string } }
52
53
  | { code: 'BRIDGE_SDK_FAILED' }
53
54
  | { code: 'FEES_NOT_ESTIMATED' };
@@ -0,0 +1,32 @@
1
+ type LocalStorageKeys =
2
+ | 'sw.verifiedWallets'
3
+ | 'sw.verifiedNearAccounts'
4
+ | 'sw.nearWalletsPk';
5
+
6
+ const defaultStoreValues: Record<LocalStorageKeys, string> = {
7
+ 'sw.verifiedWallets': JSON.stringify([]),
8
+ 'sw.verifiedNearAccounts': JSON.stringify([]),
9
+ 'sw.nearWalletsPk': JSON.stringify({}),
10
+ };
11
+
12
+ export const mockedLocalStorage = (() => {
13
+ let store: Record<LocalStorageKeys, string> = defaultStoreValues;
14
+
15
+ return {
16
+ getItem: (key: LocalStorageKeys) => store[key] || null,
17
+ setItem: (key: LocalStorageKeys, value: string) => {
18
+ store[key] = value;
19
+ },
20
+ removeItem: (key: LocalStorageKeys) => {
21
+ delete store[key];
22
+ },
23
+ clear: () => {
24
+ store = defaultStoreValues;
25
+ },
26
+ };
27
+ })();
28
+
29
+ Object.defineProperty(globalThis, 'localStorage', {
30
+ value: mockedLocalStorage,
31
+ writable: true,
32
+ });
@@ -1,12 +1,12 @@
1
1
  import { logger } from '@/logger';
2
2
 
3
- type LocalStorage = {
3
+ export type LocalStorage = {
4
4
  verifiedWallets: string[];
5
5
  verifiedNearAccounts: string[];
6
6
  nearWalletsPk: Record<string, string>;
7
7
  };
8
8
 
9
- const defaultValues: LocalStorage = {
9
+ export const defaultValues: LocalStorage = {
10
10
  verifiedWallets: [],
11
11
  verifiedNearAccounts: [],
12
12
  nearWalletsPk: {},
@@ -11,6 +11,7 @@ import { mockAlchemyResponse } from '../../tests/mock-alchemy-response';
11
11
  import { mockGetIntentsBalances } from '../../tests/mock-get-intents-balances';
12
12
  import { mockConnectedWalletAddress } from '../../tests/mock-connected-wallet-address';
13
13
  import { mockOneClickQuote } from '../../tests/mock-one-click-quote';
14
+ import { mockedLocalStorage } from '../../tests/mock-localstorage';
14
15
  import { mockOneClickSDK } from '../../tests/mock-one-click-sdk';
15
16
 
16
17
  import { setup } from '../../tests/setup';
@@ -81,6 +82,11 @@ const targetToken = {
81
82
 
82
83
  describe('Deposit', () => {
83
84
  beforeEach(() => {
85
+ mockedLocalStorage.setItem(
86
+ 'sw.verifiedWallets',
87
+ JSON.stringify([mockConnectedWalletAddress('evm')]),
88
+ );
89
+
84
90
  mockGetIntentsBalances.mockResolvedValue({
85
91
  'nep141:eth.bridge.near': 0,
86
92
  'nep141:eth.omft.near': 0,