@aurora-is-near/intents-swap-widget 3.21.1 → 3.22.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.
Files changed (120) hide show
  1. package/dist/components/WidgetTabs.d.ts +8 -0
  2. package/dist/components/WidgetTabs.js +20 -0
  3. package/dist/components/WidgetTabs.js.map +1 -0
  4. package/dist/{config-DAMaL9k2.js → config-Opy5ppbU.js} +2 -2
  5. package/dist/{config-DAMaL9k2.js.map → config-Opy5ppbU.js.map} +1 -1
  6. package/dist/config.d.ts +1 -0
  7. package/dist/config.js +1 -1
  8. package/dist/errors.js +1 -1
  9. package/dist/ext/alchemy/index.js +1 -1
  10. package/dist/ext/index.js +1 -1
  11. package/dist/features/BalanceRpcLoader/TokenBalanceLoader.js +1 -1
  12. package/dist/features/BalanceRpcLoader/index.js +1 -1
  13. package/dist/features/BalanceRpcLoader/useTokenBalanceRpc.js +1 -1
  14. package/dist/features/ChainsDropdown/index.js +1 -1
  15. package/dist/features/ChainsSelector/index.js +1 -1
  16. package/dist/features/DepositMethodSwitcher.js +1 -1
  17. package/dist/features/ErrorBoundary.js +1 -1
  18. package/dist/features/ExternalDeposit.js +1 -1
  19. package/dist/features/SendAddress/index.js +1 -1
  20. package/dist/features/SendAddress/useNotification.js +1 -1
  21. package/dist/features/SubmitButton/index.js +1 -1
  22. package/dist/features/SuccessScreen/index.js +1 -1
  23. package/dist/features/SuccessScreen/useSummaryItemsCount.js +1 -1
  24. package/dist/features/SwapDirectionSwitcher.d.ts +1 -5
  25. package/dist/features/SwapDirectionSwitcher.js +10 -10
  26. package/dist/features/SwapDirectionSwitcher.js.map +1 -1
  27. package/dist/features/SwapQuote/SwapQuote.js +1 -1
  28. package/dist/features/SwapQuote/index.js +1 -1
  29. package/dist/features/TokenInput/TokenInput.js +1 -1
  30. package/dist/features/TokenInput/TokenInputEmpty.js +1 -1
  31. package/dist/features/TokenInput/TokenInputSource.js +1 -1
  32. package/dist/features/TokenInput/TokenInputTarget.js +1 -1
  33. package/dist/features/TokenInput/WalletBalance.js +1 -1
  34. package/dist/features/TokenInput/hooks/index.js +1 -1
  35. package/dist/features/TokenInput/hooks/useTokenInputBalance.js +1 -1
  36. package/dist/features/TokenInput/index.js +1 -1
  37. package/dist/features/TokensList/TokenItem.js +1 -1
  38. package/dist/features/TokensList/TokensList.js +1 -1
  39. package/dist/features/TokensList/index.js +1 -1
  40. package/dist/features/TokensModal.js +1 -1
  41. package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js +1 -1
  42. package/dist/features/WalletCompatibilityCheck/index.js +1 -1
  43. package/dist/features/index.js +1 -1
  44. package/dist/hooks/index.js +1 -1
  45. package/dist/hooks/useAllTokens.js +1 -1
  46. package/dist/hooks/useChains.js +1 -1
  47. package/dist/hooks/useCompatibilityCheck.js +1 -1
  48. package/dist/hooks/useDefaultToken.js +1 -1
  49. package/dist/hooks/useExternalDepositStatus/index.js +1 -1
  50. package/dist/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.js +1 -1
  51. package/dist/hooks/useIntentsBalance.js +1 -1
  52. package/dist/hooks/useIsCompatibilityCheckRequired.js +1 -1
  53. package/dist/hooks/useMakeDepositAddress.js +1 -1
  54. package/dist/hooks/useMakeIntentsTransfer.js +1 -1
  55. package/dist/hooks/useMakeNEARFtTransferCall.js +1 -1
  56. package/dist/hooks/useMakeQuote.js +1 -1
  57. package/dist/hooks/useMakeQuoteTransfer.js +1 -1
  58. package/dist/hooks/useMakeTransfer.js +1 -1
  59. package/dist/hooks/useMergedBalance.js +1 -1
  60. package/dist/hooks/useSwitchChain.js +1 -1
  61. package/dist/hooks/useTheme.js +1 -1
  62. package/dist/hooks/useTokenInputPair.js +1 -1
  63. package/dist/hooks/useTokens.js +1 -1
  64. package/dist/hooks/useTokensFiltered.js +1 -1
  65. package/dist/hooks/useTokensIntentsUnique.js +1 -1
  66. package/dist/index.js +21 -19
  67. package/dist/index.js.map +1 -1
  68. package/dist/machine/effects/index.js +1 -1
  69. package/dist/machine/effects/useAlchemyBalanceEffect.js +1 -1
  70. package/dist/machine/effects/useBalancesUpdateEffect.js +1 -1
  71. package/dist/machine/effects/useMakeQuoteEffect.js +1 -1
  72. package/dist/machine/effects/useSelectedTokensEffect.js +1 -1
  73. package/dist/machine/effects/useSetTokenBalanceEffect.js +1 -1
  74. package/dist/machine/effects/useSetTokenIntentsTargetEffect.js +1 -1
  75. package/dist/machine/effects/useWalletConnEffect.js +1 -1
  76. package/dist/machine/events/index.js +1 -1
  77. package/dist/machine/events/tokenSelect.js +1 -1
  78. package/dist/machine/events/validateInputAndMoveTo.js +1 -1
  79. package/dist/machine/events/validateInputs.js +1 -1
  80. package/dist/machine/index.js +1 -1
  81. package/dist/machine/snap.js +1 -1
  82. package/dist/machine/subscriptions/checkers/isSendAddressAsConnected.js +1 -1
  83. package/dist/machine/subscriptions/index.js +1 -1
  84. package/dist/styles.css +1 -1
  85. package/dist/theme/ThemeProvider.js +1 -1
  86. package/dist/types/config.d.ts +1 -0
  87. package/dist/utils/intents/signers/near.js +1 -1
  88. package/dist/utils/intents/signers/privy.js +1 -1
  89. package/dist/utils/near/getNearNep141StorageBalance.js +1 -1
  90. package/dist/widgets/Widget/WidgetContent.d.ts +10 -0
  91. package/dist/widgets/Widget/WidgetContent.js +56 -0
  92. package/dist/widgets/Widget/WidgetContent.js.map +1 -0
  93. package/dist/widgets/Widget/index.d.ts +4 -0
  94. package/dist/widgets/Widget/index.js +23 -0
  95. package/dist/widgets/Widget/index.js.map +1 -0
  96. package/dist/widgets/WidgetDeposit/WidgetDepositContent.d.ts +1 -2
  97. package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +1 -1
  98. package/dist/widgets/WidgetDeposit/WidgetDepositContent.js.map +1 -1
  99. package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
  100. package/dist/widgets/WidgetSwap/WidgetSwapContent.d.ts +3 -6
  101. package/dist/widgets/WidgetSwap/WidgetSwapContent.js +43 -44
  102. package/dist/widgets/WidgetSwap/WidgetSwapContent.js.map +1 -1
  103. package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
  104. package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.d.ts +1 -2
  105. package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +1 -1
  106. package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js.map +1 -1
  107. package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
  108. package/dist/widgets/index.d.ts +1 -0
  109. package/dist/widgets/index.js +8 -6
  110. package/dist/widgets/index.js.map +1 -1
  111. package/package.json +1 -1
  112. package/src/components/WidgetTabs.tsx +33 -0
  113. package/src/features/SwapDirectionSwitcher.tsx +4 -6
  114. package/src/types/config.ts +1 -0
  115. package/src/widgets/Widget/WidgetContent.tsx +99 -0
  116. package/src/widgets/Widget/index.tsx +23 -0
  117. package/src/widgets/WidgetDeposit/WidgetDepositContent.tsx +1 -1
  118. package/src/widgets/WidgetSwap/WidgetSwapContent.tsx +3 -6
  119. package/src/widgets/WidgetWithdraw/WidgetWithdrawContent.tsx +1 -1
  120. package/src/widgets/index.ts +1 -0
@@ -0,0 +1,99 @@
1
+ 'use client';
2
+
3
+ import { 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
+
21
+ type WidgetType = 'swap' | 'deposit' | 'withdraw';
22
+
23
+ export type Props = Omit<
24
+ WidgetSwapProps | WidgetDepositProps | WidgetWithdrawProps,
25
+ 'onMsg'
26
+ > & {
27
+ onMsg?: (msg: Msg, widget: WidgetType) => void;
28
+ };
29
+
30
+ type Msg = SwapMsg | DepositMsg | WithdrawMsg;
31
+
32
+ export const WidgetContent = ({ onMsg, ...restProps }: Props) => {
33
+ const [isTabsVisible, setIsTabsVisible] = useState(true);
34
+ const [activeTab, setActiveTab] = useState<WidgetTab>('swap');
35
+
36
+ const switchTab = (tab: WidgetTab) => {
37
+ setActiveTab(tab);
38
+ };
39
+
40
+ const handleMsg = <T extends Msg>(msg: T, widgetType: WidgetType) => {
41
+ if (msg.type === 'on_tokens_modal_toggled') {
42
+ setIsTabsVisible(!msg.isOpen);
43
+ }
44
+
45
+ if (msg.type === 'on_select_token') {
46
+ setIsTabsVisible(true);
47
+ }
48
+
49
+ onMsg?.(msg, widgetType);
50
+ };
51
+
52
+ return (
53
+ <>
54
+ {isTabsVisible && (
55
+ <WidgetTabs activeTab={activeTab} onSelect={switchTab} />
56
+ )}
57
+
58
+ {(() => {
59
+ switch (activeTab) {
60
+ case 'swap': {
61
+ return (
62
+ <WidgetSwapContent
63
+ {...restProps}
64
+ onMsg={(msg) => {
65
+ handleMsg(msg, 'swap');
66
+ }}
67
+ />
68
+ );
69
+ }
70
+
71
+ case 'deposit': {
72
+ return (
73
+ <WidgetDepositContent
74
+ {...restProps}
75
+ onMsg={(msg) => {
76
+ handleMsg(msg, 'deposit');
77
+ }}
78
+ />
79
+ );
80
+ }
81
+
82
+ case 'withdraw': {
83
+ return (
84
+ <WidgetWithdrawContent
85
+ {...restProps}
86
+ onMsg={(msg) => {
87
+ handleMsg(msg, 'withdraw');
88
+ }}
89
+ />
90
+ );
91
+ }
92
+
93
+ default:
94
+ return null;
95
+ }
96
+ })()}
97
+ </>
98
+ );
99
+ };
@@ -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
+ );
@@ -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' }
@@ -32,21 +32,18 @@ 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_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
- isOneWay?: boolean;
42
- };
40
+ export type Props = CommonWidgetProps<Msg>;
43
41
 
44
42
  export const WidgetSwapContent = ({
45
43
  providers,
46
44
  makeTransfer,
47
45
  onMsg,
48
46
  isLoading,
49
- isOneWay,
50
47
  }: Props) => {
51
48
  const { ctx } = useUnsafeSnapshot();
52
49
  const { isDirectNearTokenWithdrawal } = useComputedSnapshot();
@@ -217,7 +214,7 @@ export const WidgetSwapContent = ({
217
214
  }}
218
215
  />
219
216
 
220
- <SwapDirectionSwitcher disabled={isOneWay} />
217
+ <SwapDirectionSwitcher />
221
218
 
222
219
  <TokenInput.Target
223
220
  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 };
@@ -1,3 +1,4 @@
1
+ export { Widget } from './Widget';
1
2
  export { WidgetSwap } from './WidgetSwap';
2
3
  export { WidgetDeposit } from './WidgetDeposit';
3
4
  export { WidgetWithdraw } from './WidgetWithdraw';