@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.
- package/dist/{config-CG-NCoEP.js → config-QBojKcju.js} +584 -569
- package/dist/config-QBojKcju.js.map +1 -0
- package/dist/config.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/ext/alchemy/index.js +1 -1
- package/dist/ext/index.js +1 -1
- package/dist/features/BalanceRpcLoader/TokenBalanceLoader.js +1 -1
- package/dist/features/BalanceRpcLoader/index.js +1 -1
- package/dist/features/BalanceRpcLoader/useTokenBalanceRpc.js +1 -1
- package/dist/features/ChainsDropdown/index.js +31 -31
- package/dist/features/ChainsDropdown/index.js.map +1 -1
- package/dist/features/DepositMethodSwitcher.js +12 -10
- package/dist/features/DepositMethodSwitcher.js.map +1 -1
- package/dist/features/ErrorBoundary.js +1 -1
- package/dist/features/ExternalDeposit.js +1 -1
- package/dist/features/SendAddress/index.js +1 -1
- package/dist/features/SendAddress/useNotification.js +1 -1
- package/dist/features/SubmitButton/index.js +1 -1
- package/dist/features/SuccessScreen/index.js +1 -1
- package/dist/features/SwapDirectionSwitcher.js +1 -1
- package/dist/features/SwapQuote/SwapQuote.js +1 -1
- package/dist/features/SwapQuote/index.js +1 -1
- package/dist/features/TokenInput/TokenInput.js +1 -1
- package/dist/features/TokenInput/TokenInputEmpty.js +1 -1
- package/dist/features/TokenInput/TokenInputSource.js +1 -1
- package/dist/features/TokenInput/TokenInputTarget.js +1 -1
- package/dist/features/TokenInput/WalletBalance.js +1 -1
- package/dist/features/TokenInput/hooks/index.js +1 -1
- package/dist/features/TokenInput/hooks/useTokenInputBalance.js +1 -1
- package/dist/features/TokenInput/index.js +1 -1
- package/dist/features/TokensList/TokenItem.js +1 -1
- package/dist/features/TokensList/TokensList.js +1 -1
- package/dist/features/TokensList/index.js +1 -1
- package/dist/features/TokensModal.js +1 -1
- package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js +1 -1
- package/dist/features/WalletCompatibilityCheck/index.js +1 -1
- package/dist/features/index.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useAllTokens.js +1 -1
- package/dist/hooks/useChains.js +1 -1
- package/dist/hooks/useCompatibilityCheck.js +1 -1
- package/dist/hooks/useDefaultToken.js +1 -1
- package/dist/hooks/useExternalDepositStatus/index.js +1 -1
- package/dist/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.js +1 -1
- package/dist/hooks/useIntentsBalance.js +1 -1
- package/dist/hooks/useIsCompatibilityCheckRequired.js +1 -1
- package/dist/hooks/useMakeDepositAddress.js +1 -1
- package/dist/hooks/useMakeIntentsTransfer.js +3 -2
- package/dist/hooks/useMakeIntentsTransfer.js.map +1 -1
- package/dist/hooks/useMakeNEARFtTransferCall.js +1 -1
- package/dist/hooks/useMakeQuote.js +1 -1
- package/dist/hooks/useMakeQuoteTransfer.js +1 -1
- package/dist/hooks/useMakeTransfer.js +1 -1
- package/dist/hooks/useMergedBalance.js +1 -1
- package/dist/hooks/useSwitchChain.js +1 -1
- package/dist/hooks/useTheme.js +1 -1
- package/dist/hooks/useTokenInputPair.js +1 -1
- package/dist/hooks/useTokens.js +1 -1
- package/dist/hooks/useTokensFiltered.js +1 -1
- package/dist/hooks/useTokensIntentsUnique.js +1 -1
- package/dist/index.js +1 -1
- package/dist/machine/effects/index.js +1 -1
- package/dist/machine/effects/useAlchemyBalanceEffect.js +1 -1
- package/dist/machine/effects/useBalancesUpdateEffect.js +1 -1
- package/dist/machine/effects/useMakeQuoteEffect.js +1 -1
- package/dist/machine/effects/useSelectedTokensEffect.js +1 -1
- package/dist/machine/effects/useSetTokenBalanceEffect.js +1 -1
- package/dist/machine/effects/useSetTokenIntentsTargetEffect.js +1 -1
- package/dist/machine/effects/useWalletConnEffect.js +1 -1
- package/dist/machine/errors.d.ts +5 -0
- package/dist/machine/errors.js.map +1 -1
- package/dist/machine/events/index.js +1 -1
- package/dist/machine/events/tokenSelect.js +1 -1
- package/dist/machine/events/validateInputAndMoveTo.js +1 -1
- package/dist/machine/events/validateInputs.js +1 -1
- package/dist/machine/index.js +1 -1
- package/dist/machine/snap.d.ts +15 -0
- package/dist/machine/snap.js +1 -1
- package/dist/machine/subscriptions/checkers/isSendAddressAsConnected.js +1 -1
- package/dist/machine/subscriptions/index.js +1 -1
- package/dist/theme/ThemeProvider.js +1 -1
- package/dist/utils/intents/signers/near.js +1 -1
- package/dist/utils/intents/signers/privy.js +1 -1
- package/dist/utils/localstorage.d.ts +2 -2
- package/dist/utils/localstorage.js +1 -0
- package/dist/utils/localstorage.js.map +1 -1
- package/dist/utils/near/getNearNep141StorageBalance.js +1 -1
- package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +1 -1
- package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapContent.js +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
- package/package.json +3 -3
- package/src/features/ChainsDropdown/index.tsx +1 -1
- package/src/features/DepositMethodSwitcher.tsx +2 -0
- package/src/features/SubmitButton/index.tsx +4 -1
- package/src/features/TokensList/TokensList.tsx +1 -1
- package/src/hooks/useMakeIntentsTransfer.ts +22 -0
- package/src/machine/errors.ts +1 -0
- package/src/tests/mock-localstorage.ts +32 -0
- package/src/utils/localstorage.ts +2 -2
- package/src/widgets/WidgetDeposit/WidgetDeposit.test.tsx +6 -0
- 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({
|
package/src/machine/errors.ts
CHANGED
|
@@ -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,
|