@aurora-is-near/intents-swap-widget 3.21.1 → 3.23.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.
- package/dist/components/WidgetTabs.d.ts +8 -0
- package/dist/components/WidgetTabs.js +20 -0
- package/dist/components/WidgetTabs.js.map +1 -0
- package/dist/{config-DAMaL9k2.js → config-0TjbjBo5.js} +183 -183
- package/dist/config-0TjbjBo5.js.map +1 -0
- package/dist/config.d.ts +2 -10
- 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 +1 -1
- package/dist/features/ChainsSelector/index.js +1 -1
- package/dist/features/DepositMethodSwitcher.js +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/SuccessScreen/useSummaryItemsCount.js +1 -1
- package/dist/features/SwapDirectionSwitcher.d.ts +1 -5
- package/dist/features/SwapDirectionSwitcher.js +10 -10
- package/dist/features/SwapDirectionSwitcher.js.map +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 +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 +21 -19
- package/dist/index.js.map +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/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.js +1 -1
- package/dist/machine/subscriptions/checkers/isSendAddressAsConnected.js +1 -1
- package/dist/machine/subscriptions/index.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme/ThemeProvider.js +1 -1
- package/dist/types/chain.d.ts +4 -0
- package/dist/types/config.d.ts +3 -5
- package/dist/utils/intents/signers/near.js +1 -1
- package/dist/utils/intents/signers/privy.js +1 -1
- package/dist/utils/near/getNearNep141StorageBalance.js +1 -1
- package/dist/widgets/Widget/WidgetContent.d.ts +10 -0
- package/dist/widgets/Widget/WidgetContent.js +59 -0
- package/dist/widgets/Widget/WidgetContent.js.map +1 -0
- package/dist/widgets/Widget/index.d.ts +4 -0
- package/dist/widgets/Widget/index.js +23 -0
- package/dist/widgets/Widget/index.js.map +1 -0
- package/dist/widgets/WidgetDeposit/WidgetDepositContent.d.ts +1 -2
- package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +65 -63
- package/dist/widgets/WidgetDeposit/WidgetDepositContent.js.map +1 -1
- package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapContent.d.ts +3 -6
- package/dist/widgets/WidgetSwap/WidgetSwapContent.js +89 -84
- package/dist/widgets/WidgetSwap/WidgetSwapContent.js.map +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.d.ts +1 -2
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +79 -77
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js.map +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
- package/dist/widgets/index.d.ts +1 -0
- package/dist/widgets/index.js +8 -6
- package/dist/widgets/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/WidgetTabs.tsx +33 -0
- package/src/config.tsx +0 -5
- package/src/features/SwapDirectionSwitcher.tsx +4 -6
- package/src/machine/effects/useSelectedTokensEffect.ts +7 -4
- package/src/types/chain.ts +5 -0
- package/src/types/config.ts +4 -4
- package/src/widgets/Widget/WidgetContent.tsx +107 -0
- package/src/widgets/Widget/index.tsx +23 -0
- package/src/widgets/WidgetDeposit/WidgetDeposit.test.tsx +0 -4
- package/src/widgets/WidgetDeposit/WidgetDepositContent.tsx +8 -4
- package/src/widgets/WidgetSwap/WidgetSwapContent.tsx +21 -9
- package/src/widgets/WidgetWithdraw/WidgetWithdrawContent.tsx +6 -4
- package/src/widgets/index.ts +1 -0
- package/dist/config-DAMaL9k2.js.map +0 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { WidgetTab, WidgetTabs } from '../../components/WidgetTabs';
|
|
5
|
+
import {
|
|
6
|
+
Msg as SwapMsg,
|
|
7
|
+
WidgetSwapContent,
|
|
8
|
+
Props as WidgetSwapProps,
|
|
9
|
+
} from '../WidgetSwap/WidgetSwapContent';
|
|
10
|
+
import {
|
|
11
|
+
Msg as DepositMsg,
|
|
12
|
+
WidgetDepositContent,
|
|
13
|
+
Props as WidgetDepositProps,
|
|
14
|
+
} from '../WidgetDeposit/WidgetDepositContent';
|
|
15
|
+
import {
|
|
16
|
+
WidgetWithdrawContent,
|
|
17
|
+
Props as WidgetWithdrawProps,
|
|
18
|
+
Msg as WithdrawMsg,
|
|
19
|
+
} from '../WidgetWithdraw/WidgetWithdrawContent';
|
|
20
|
+
import { useConfig } from '../../config';
|
|
21
|
+
|
|
22
|
+
type WidgetType = 'swap' | 'deposit' | 'withdraw';
|
|
23
|
+
|
|
24
|
+
export type Props = Omit<
|
|
25
|
+
WidgetSwapProps | WidgetDepositProps | WidgetWithdrawProps,
|
|
26
|
+
'onMsg'
|
|
27
|
+
> & {
|
|
28
|
+
onMsg?: (msg: Msg, widget: WidgetType) => void;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type Msg = SwapMsg | DepositMsg | WithdrawMsg;
|
|
32
|
+
|
|
33
|
+
export const WidgetContent = ({ onMsg, ...restProps }: Props) => {
|
|
34
|
+
const [isTabsVisible, setIsTabsVisible] = useState(true);
|
|
35
|
+
const [activeTab, setActiveTab] = useState<WidgetTab>('swap');
|
|
36
|
+
const { enableAccountAbstraction } = useConfig();
|
|
37
|
+
|
|
38
|
+
const switchTab = (tab: WidgetTab) => {
|
|
39
|
+
setActiveTab(tab);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const handleMsg = <T extends Msg>(msg: T, widgetType: WidgetType) => {
|
|
43
|
+
if (msg.type === 'on_tokens_modal_toggled') {
|
|
44
|
+
setIsTabsVisible(!msg.isOpen);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (msg.type === 'on_select_token') {
|
|
48
|
+
setIsTabsVisible(true);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
onMsg?.(msg, widgetType);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!enableAccountAbstraction) {
|
|
56
|
+
setActiveTab('swap');
|
|
57
|
+
}
|
|
58
|
+
}, [enableAccountAbstraction]);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
{enableAccountAbstraction && isTabsVisible && (
|
|
63
|
+
<WidgetTabs activeTab={activeTab} onSelect={switchTab} />
|
|
64
|
+
)}
|
|
65
|
+
|
|
66
|
+
{(() => {
|
|
67
|
+
switch (activeTab) {
|
|
68
|
+
case 'swap': {
|
|
69
|
+
return (
|
|
70
|
+
<WidgetSwapContent
|
|
71
|
+
{...restProps}
|
|
72
|
+
onMsg={(msg) => {
|
|
73
|
+
handleMsg(msg, 'swap');
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
case 'deposit': {
|
|
80
|
+
return (
|
|
81
|
+
<WidgetDepositContent
|
|
82
|
+
{...restProps}
|
|
83
|
+
onMsg={(msg) => {
|
|
84
|
+
handleMsg(msg, 'deposit');
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
case 'withdraw': {
|
|
91
|
+
return (
|
|
92
|
+
<WidgetWithdrawContent
|
|
93
|
+
{...restProps}
|
|
94
|
+
onMsg={(msg) => {
|
|
95
|
+
handleMsg(msg, 'withdraw');
|
|
96
|
+
}}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
default:
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
})()}
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WidgetContainer,
|
|
3
|
+
WidgetContainerProps,
|
|
4
|
+
} from '../../components/WidgetContainer';
|
|
5
|
+
import { Props, WidgetContent } from './WidgetContent';
|
|
6
|
+
|
|
7
|
+
export type WidgetProps = Props & Omit<WidgetContainerProps, 'children'>;
|
|
8
|
+
|
|
9
|
+
export const Widget = ({
|
|
10
|
+
HeaderComponent,
|
|
11
|
+
FooterComponent,
|
|
12
|
+
isFullPage,
|
|
13
|
+
className,
|
|
14
|
+
...widgetProps
|
|
15
|
+
}: WidgetProps) => (
|
|
16
|
+
<WidgetContainer
|
|
17
|
+
className={className}
|
|
18
|
+
isFullPage={isFullPage}
|
|
19
|
+
HeaderComponent={HeaderComponent}
|
|
20
|
+
FooterComponent={FooterComponent}>
|
|
21
|
+
<WidgetContent {...widgetProps} />
|
|
22
|
+
</WidgetContainer>
|
|
23
|
+
);
|
|
@@ -39,10 +39,6 @@ const WidgetDepositSetup = () => {
|
|
|
39
39
|
alchemyApiKey: 'test-alchemy-api-key',
|
|
40
40
|
connectedWallets: { default: mockConnectedWalletAddress('evm') },
|
|
41
41
|
walletSupportedChains: EVM_CHAINS,
|
|
42
|
-
chainsFilter: {
|
|
43
|
-
target: { intents: 'all', external: 'all' },
|
|
44
|
-
source: { intents: 'all', external: 'all' },
|
|
45
|
-
},
|
|
46
42
|
};
|
|
47
43
|
|
|
48
44
|
return (
|
|
@@ -32,7 +32,7 @@ import { isDebug, notReachable } from '@/utils';
|
|
|
32
32
|
|
|
33
33
|
import type { Token, TransferResult } from '@/types';
|
|
34
34
|
|
|
35
|
-
type Msg =
|
|
35
|
+
export type Msg =
|
|
36
36
|
| { type: 'on_select_token'; token: Token; variant: TokenInputType }
|
|
37
37
|
| { type: 'on_change_deposit_type'; isExternal: boolean }
|
|
38
38
|
| { type: 'on_transfer_success' }
|
|
@@ -50,7 +50,6 @@ export const WidgetDepositContent = ({
|
|
|
50
50
|
const { t } = useTypedTranslation();
|
|
51
51
|
const { isDirectNearTokenWithdrawal } = useComputedSnapshot();
|
|
52
52
|
const {
|
|
53
|
-
chainsFilter,
|
|
54
53
|
alchemyApiKey,
|
|
55
54
|
refetchQuoteInterval,
|
|
56
55
|
intentsAccountType,
|
|
@@ -188,8 +187,13 @@ export const WidgetDepositContent = ({
|
|
|
188
187
|
groupTokens={tokenModalOpen === 'source'}
|
|
189
188
|
chainsFilter={
|
|
190
189
|
tokenModalOpen === 'source'
|
|
191
|
-
?
|
|
192
|
-
|
|
190
|
+
? {
|
|
191
|
+
intents: 'none',
|
|
192
|
+
external: ctx.isDepositFromExternalWallet
|
|
193
|
+
? 'all'
|
|
194
|
+
: 'wallet-supported',
|
|
195
|
+
}
|
|
196
|
+
: { intents: 'all', external: 'none' }
|
|
193
197
|
}
|
|
194
198
|
onMsg={(msg) => {
|
|
195
199
|
switch (msg.type) {
|
|
@@ -30,15 +30,25 @@ import { useConfig } from '@/config';
|
|
|
30
30
|
|
|
31
31
|
import { isDebug, notReachable } from '@/utils';
|
|
32
32
|
|
|
33
|
-
import type { Token, TransferResult } from '@/types';
|
|
33
|
+
import type { ChainsFilter, Token, TransferResult } from '@/types';
|
|
34
34
|
|
|
35
|
-
type Msg =
|
|
35
|
+
export type Msg =
|
|
36
36
|
| { type: 'on_tokens_modal_toggled'; isOpen: boolean }
|
|
37
37
|
| { type: 'on_select_token'; token: Token; variant: TokenInputType }
|
|
38
38
|
| { type: 'on_transfer_success' };
|
|
39
39
|
|
|
40
|
-
export type Props = CommonWidgetProps<Msg
|
|
41
|
-
|
|
40
|
+
export type Props = CommonWidgetProps<Msg>;
|
|
41
|
+
|
|
42
|
+
const getSourceTokens = (
|
|
43
|
+
enableAccountAbstraction: boolean,
|
|
44
|
+
walletAddress?: string,
|
|
45
|
+
): ChainsFilter => {
|
|
46
|
+
const enabledIntentsFilter = walletAddress ? 'with-balance' : 'all';
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
intents: enableAccountAbstraction ? enabledIntentsFilter : 'none',
|
|
50
|
+
external: walletAddress ? 'wallet-supported' : 'all',
|
|
51
|
+
};
|
|
42
52
|
};
|
|
43
53
|
|
|
44
54
|
export const WidgetSwapContent = ({
|
|
@@ -46,12 +56,11 @@ export const WidgetSwapContent = ({
|
|
|
46
56
|
makeTransfer,
|
|
47
57
|
onMsg,
|
|
48
58
|
isLoading,
|
|
49
|
-
isOneWay,
|
|
50
59
|
}: Props) => {
|
|
51
60
|
const { ctx } = useUnsafeSnapshot();
|
|
52
61
|
const { isDirectNearTokenWithdrawal } = useComputedSnapshot();
|
|
53
62
|
const {
|
|
54
|
-
|
|
63
|
+
enableAccountAbstraction,
|
|
55
64
|
alchemyApiKey,
|
|
56
65
|
refetchQuoteInterval,
|
|
57
66
|
intentsAccountType,
|
|
@@ -169,8 +178,11 @@ export const WidgetSwapContent = ({
|
|
|
169
178
|
groupTokens={tokenModalOpen === 'source'}
|
|
170
179
|
chainsFilter={
|
|
171
180
|
tokenModalOpen === 'source'
|
|
172
|
-
?
|
|
173
|
-
:
|
|
181
|
+
? getSourceTokens(!!enableAccountAbstraction, ctx.walletAddress)
|
|
182
|
+
: {
|
|
183
|
+
intents: enableAccountAbstraction ? 'with-balance' : 'all',
|
|
184
|
+
external: 'all',
|
|
185
|
+
}
|
|
174
186
|
}
|
|
175
187
|
onMsg={(msg) => {
|
|
176
188
|
switch (msg.type) {
|
|
@@ -217,7 +229,7 @@ export const WidgetSwapContent = ({
|
|
|
217
229
|
}}
|
|
218
230
|
/>
|
|
219
231
|
|
|
220
|
-
<SwapDirectionSwitcher
|
|
232
|
+
<SwapDirectionSwitcher />
|
|
221
233
|
|
|
222
234
|
<TokenInput.Target
|
|
223
235
|
heading={t('tokenInput.heading.target.swap', 'Buy')}
|
|
@@ -31,7 +31,7 @@ import { isDebug, notReachable } from '@/utils';
|
|
|
31
31
|
|
|
32
32
|
import type { Token, TransferResult } from '@/types';
|
|
33
33
|
|
|
34
|
-
type Msg =
|
|
34
|
+
export type Msg =
|
|
35
35
|
| { type: 'on_select_token'; token: Token; variant: TokenInputType }
|
|
36
36
|
| { type: 'on_transfer_success' }
|
|
37
37
|
| { type: 'on_tokens_modal_toggled'; isOpen: boolean };
|
|
@@ -48,7 +48,6 @@ export const WidgetWithdrawContent = ({
|
|
|
48
48
|
const { ctx } = useUnsafeSnapshot();
|
|
49
49
|
const { isDirectNearTokenWithdrawal } = useComputedSnapshot();
|
|
50
50
|
const {
|
|
51
|
-
chainsFilter,
|
|
52
51
|
alchemyApiKey,
|
|
53
52
|
refetchQuoteInterval,
|
|
54
53
|
intentsAccountType,
|
|
@@ -166,8 +165,11 @@ export const WidgetWithdrawContent = ({
|
|
|
166
165
|
groupTokens={false}
|
|
167
166
|
chainsFilter={
|
|
168
167
|
tokenModalOpen === 'source'
|
|
169
|
-
?
|
|
170
|
-
|
|
168
|
+
? {
|
|
169
|
+
intents: 'with-balance',
|
|
170
|
+
external: 'none',
|
|
171
|
+
}
|
|
172
|
+
: { intents: 'none', external: 'all' }
|
|
171
173
|
}
|
|
172
174
|
onMsg={(msg) => {
|
|
173
175
|
switch (msg.type) {
|
package/src/widgets/index.ts
CHANGED