@aurora-is-near/intents-swap-widget 3.14.0-redesign.2 → 3.14.0-redesign.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.
Files changed (101) hide show
  1. package/dist/{config-Bmc4hOIl.js → config-1EcDCy24.js} +603 -584
  2. package/dist/config-1EcDCy24.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 +1 -1
  11. package/dist/features/DepositMethodSwitcher.js +1 -1
  12. package/dist/features/ErrorBoundary.js +1 -1
  13. package/dist/features/ExternalDeposit.js +18 -18
  14. package/dist/features/ExternalDeposit.js.map +1 -1
  15. package/dist/features/SendAddress/index.js +1 -1
  16. package/dist/features/SendAddress/useNotification.js +1 -1
  17. package/dist/features/SubmitButton/index.js +1 -1
  18. package/dist/features/SuccessScreen/index.js +1 -1
  19. package/dist/features/SwapDirectionSwitcher.js +1 -1
  20. package/dist/features/SwapQuote/SwapQuote.js +1 -1
  21. package/dist/features/SwapQuote/index.js +1 -1
  22. package/dist/features/TokenInput/TokenInput.js +1 -1
  23. package/dist/features/TokenInput/TokenInputEmpty.js +1 -1
  24. package/dist/features/TokenInput/TokenInputSource.js +1 -1
  25. package/dist/features/TokenInput/TokenInputTarget.js +1 -1
  26. package/dist/features/TokenInput/WalletBalance.js +1 -1
  27. package/dist/features/TokenInput/hooks/index.js +1 -1
  28. package/dist/features/TokenInput/hooks/useTokenInputBalance.js +1 -1
  29. package/dist/features/TokenInput/index.js +1 -1
  30. package/dist/features/TokensList/TokenItem.js +1 -1
  31. package/dist/features/TokensList/TokensList.js +1 -1
  32. package/dist/features/TokensList/index.js +1 -1
  33. package/dist/features/TokensModal.js +1 -1
  34. package/dist/features/WalletCompatibilityCheck/index.js +1 -1
  35. package/dist/features/index.js +1 -1
  36. package/dist/hooks/index.js +1 -1
  37. package/dist/hooks/useAllTokens.js +1 -1
  38. package/dist/hooks/useChains.js +1 -1
  39. package/dist/hooks/useCompatibilityCheck.js +1 -1
  40. package/dist/hooks/useDefaultToken.js +1 -1
  41. package/dist/hooks/useExternalDepositStatus/index.js +1 -1
  42. package/dist/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.js +1 -1
  43. package/dist/hooks/useIntentsBalance.js +1 -1
  44. package/dist/hooks/useIsCompatibilityCheckRequired.js +1 -1
  45. package/dist/hooks/useMakeDepositAddress.js +1 -1
  46. package/dist/hooks/useMakeIntentsTransfer.js +1 -1
  47. package/dist/hooks/useMakeNEARFtTransferCall.js +1 -1
  48. package/dist/hooks/useMakeQuote.js +1 -1
  49. package/dist/hooks/useMakeQuoteTransfer.js +1 -1
  50. package/dist/hooks/useMakeTransfer.js +1 -1
  51. package/dist/hooks/useMergedBalance.js +1 -1
  52. package/dist/hooks/useSwitchChain.js +1 -1
  53. package/dist/hooks/useTokenInputPair.js +1 -1
  54. package/dist/hooks/useTokens.js +1 -1
  55. package/dist/hooks/useTokensFiltered.js +1 -1
  56. package/dist/hooks/useTokensIntentsUnique.js +1 -1
  57. package/dist/index.js +1 -1
  58. package/dist/machine/computed/getIsDirectNearTokenWithdrawal.js +1 -1
  59. package/dist/machine/computed/getIsDirectNearTokenWithdrawal.js.map +1 -1
  60. package/dist/machine/computed/getIsDirectTokenOnNearDeposit.js +1 -1
  61. package/dist/machine/computed/getIsDirectTokenOnNearDeposit.js.map +1 -1
  62. package/dist/machine/computed/getIsDirectTokenOnNearTransfer.js +1 -1
  63. package/dist/machine/computed/getIsDirectTokenOnNearTransfer.js.map +1 -1
  64. package/dist/machine/effects/index.js +1 -1
  65. package/dist/machine/effects/useAlchemyBalanceEffect.js +1 -1
  66. package/dist/machine/effects/useBalancesUpdateEffect.js +1 -1
  67. package/dist/machine/effects/useMakeQuoteEffect.js +1 -1
  68. package/dist/machine/effects/useSelectedTokensEffect.js +1 -1
  69. package/dist/machine/effects/useSetTokenBalanceEffect.js +1 -1
  70. package/dist/machine/effects/useSetTokenIntentsTargetEffect.js +1 -1
  71. package/dist/machine/effects/useWalletConnEffect.js +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.js +1 -1
  78. package/dist/machine/subscriptions/checkers/isSendAddressAsConnected.js +1 -1
  79. package/dist/machine/subscriptions/index.js +1 -1
  80. package/dist/types/localisation.d.ts +1 -1
  81. package/dist/utils/intents/signers/near.js +1 -1
  82. package/dist/utils/intents/signers/privy.js +1 -1
  83. package/dist/utils/localstorage.js +41 -28
  84. package/dist/utils/localstorage.js.map +1 -1
  85. package/dist/utils/near/getNearNep141StorageBalance.js +1 -1
  86. package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +1 -1
  87. package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
  88. package/dist/widgets/WidgetSwap/WidgetSwapContent.js +1 -1
  89. package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
  90. package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +1 -1
  91. package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
  92. package/package.json +2 -2
  93. package/src/features/ExternalDeposit.tsx +2 -1
  94. package/src/features/SubmitButton/index.tsx +40 -0
  95. package/src/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.ts +2 -1
  96. package/src/machine/computed/getIsDirectNearTokenWithdrawal.ts +2 -1
  97. package/src/machine/computed/getIsDirectTokenOnNearDeposit.ts +2 -1
  98. package/src/machine/computed/getIsDirectTokenOnNearTransfer.ts +2 -1
  99. package/src/types/localisation.ts +3 -0
  100. package/src/utils/localstorage.ts +35 -10
  101. package/dist/config-Bmc4hOIl.js.map +0 -1
@@ -14,11 +14,14 @@ const defaultValues: LocalStorage = {
14
14
 
15
15
  const isBrowser = typeof window !== 'undefined' && !!window.localStorage;
16
16
 
17
+ const KEY_PREFIX = 'sw';
18
+ const getStorageKey = (key: string) => `${KEY_PREFIX}.${key}`;
19
+
17
20
  const getItem = <T extends keyof LocalStorage>(key: T): LocalStorage[T] => {
18
21
  if (!isBrowser) {
19
22
  if (process.env.NODE_ENV === 'development') {
20
23
  logger.debug(
21
- `[WIDGET] Attempted to read ${key} on server; returning default`,
24
+ `[WIDGET] Attempted to read ${getStorageKey(key)} from localstorage on server; returning default`,
22
25
  );
23
26
  }
24
27
 
@@ -26,13 +29,25 @@ const getItem = <T extends keyof LocalStorage>(key: T): LocalStorage[T] => {
26
29
  }
27
30
 
28
31
  try {
32
+ const storedValueLegacy = window.localStorage.getItem(key);
33
+ let storedValue = window.localStorage.getItem(getStorageKey(key));
34
+
35
+ // Migrate legacy key to new namespaced key
36
+ if (storedValueLegacy && !storedValue) {
37
+ storedValue = storedValueLegacy;
38
+ window.localStorage.setItem(getStorageKey(key), storedValueLegacy);
39
+ window.localStorage.removeItem(key);
40
+ }
41
+
29
42
  return (
30
43
  // @ts-expect-error It's ok to pass null to JSON.parse
31
- (JSON.parse(window.localStorage.getItem(key)) as LocalStorage[T]) ??
32
- defaultValues[key]
44
+ (JSON.parse(storedValue) as LocalStorage[T]) ?? defaultValues[key]
33
45
  );
34
46
  } catch (error) {
35
- logger.warn(`[WIDGET] Failed to parse ${key} from localStorage:`, error);
47
+ logger.warn(
48
+ `[WIDGET] Failed to parse ${getStorageKey(key)} from localStorage:`,
49
+ error,
50
+ );
36
51
 
37
52
  return defaultValues[key];
38
53
  }
@@ -44,7 +59,9 @@ const setItem = <T extends keyof LocalStorage>(
44
59
  ) => {
45
60
  if (!isBrowser) {
46
61
  if (process.env.NODE_ENV === 'development') {
47
- logger.debug(`[WIDGET] Attempted to set ${key} on server; skipping`);
62
+ logger.debug(
63
+ `[WIDGET] Attempted to set ${getStorageKey(key)} on server; skipping`,
64
+ );
48
65
  }
49
66
 
50
67
  return;
@@ -58,25 +75,33 @@ const setItem = <T extends keyof LocalStorage>(
58
75
  ? String(value)
59
76
  : JSON.stringify(value);
60
77
 
61
- window.localStorage.setItem(key, serialized);
78
+ window.localStorage.setItem(getStorageKey(key), serialized);
62
79
  } catch (error) {
63
- logger.warn(`[WIDGET] Failed to set ${key} in localStorage:`, error);
80
+ logger.warn(
81
+ `[WIDGET] Failed to set ${getStorageKey(key)} in localStorage:`,
82
+ error,
83
+ );
64
84
  }
65
85
  };
66
86
 
67
87
  const removeItem = (key: keyof LocalStorage) => {
68
88
  if (!isBrowser) {
69
89
  if (process.env.NODE_ENV === 'development') {
70
- logger.debug(`[WIDGET] Attempted to remove ${key} on server; skipping`);
90
+ logger.debug(
91
+ `[WIDGET] Attempted to remove ${getStorageKey(key)} from localstorage on server; skipping`,
92
+ );
71
93
  }
72
94
 
73
95
  return;
74
96
  }
75
97
 
76
98
  try {
77
- window.localStorage.removeItem(key);
99
+ window.localStorage.removeItem(getStorageKey(key));
78
100
  } catch (error) {
79
- logger.warn(`[WIDGET] Failed to remove ${key} from localStorage:`, error);
101
+ logger.warn(
102
+ `[WIDGET] Failed to remove ${getStorageKey(key)} from localStorage:`,
103
+ error,
104
+ );
80
105
  }
81
106
  };
82
107