@aurora-is-near/intents-swap-widget 3.22.0 → 3.24.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 (110) hide show
  1. package/dist/{config-Opy5ppbU.js → config-Bg5hUlJL.js} +183 -183
  2. package/dist/config-Bg5hUlJL.js.map +1 -0
  3. package/dist/config.d.ts +1 -10
  4. package/dist/config.js +1 -1
  5. package/dist/errors.js +1 -1
  6. package/dist/ext/alchemy/index.js +1 -1
  7. package/dist/ext/index.js +1 -1
  8. package/dist/features/BalanceRpcLoader/TokenBalanceLoader.js +1 -1
  9. package/dist/features/BalanceRpcLoader/index.js +1 -1
  10. package/dist/features/BalanceRpcLoader/useTokenBalanceRpc.js +1 -1
  11. package/dist/features/ChainsDropdown/index.js +1 -1
  12. package/dist/features/ChainsSelector/index.js +1 -1
  13. package/dist/features/DepositMethodSwitcher.js +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/SuccessScreen/useSummaryItemsCount.js +1 -1
  21. package/dist/features/SwapDirectionSwitcher.js +1 -1
  22. package/dist/features/SwapQuote/SwapQuote.js +1 -1
  23. package/dist/features/SwapQuote/index.js +1 -1
  24. package/dist/features/TokenInput/TokenInput.js +1 -1
  25. package/dist/features/TokenInput/TokenInputEmpty.js +1 -1
  26. package/dist/features/TokenInput/TokenInputSource.js +1 -1
  27. package/dist/features/TokenInput/TokenInputTarget.js +1 -1
  28. package/dist/features/TokenInput/WalletBalance.js +1 -1
  29. package/dist/features/TokenInput/hooks/index.js +1 -1
  30. package/dist/features/TokenInput/hooks/useTokenInputBalance.js +1 -1
  31. package/dist/features/TokenInput/index.js +1 -1
  32. package/dist/features/TokensList/TokenItem.js +1 -1
  33. package/dist/features/TokensList/TokensList.js +1 -1
  34. package/dist/features/TokensList/index.js +1 -1
  35. package/dist/features/TokensModal.js +1 -1
  36. package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js +1 -1
  37. package/dist/features/WalletCompatibilityCheck/index.js +1 -1
  38. package/dist/features/index.js +1 -1
  39. package/dist/hooks/index.js +1 -1
  40. package/dist/hooks/useAllTokens.js +1 -1
  41. package/dist/hooks/useChains.js +1 -1
  42. package/dist/hooks/useCompatibilityCheck.js +1 -1
  43. package/dist/hooks/useDefaultToken.js +1 -1
  44. package/dist/hooks/useExternalDepositStatus/index.js +1 -1
  45. package/dist/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.js +1 -1
  46. package/dist/hooks/useIntentsBalance.js +1 -1
  47. package/dist/hooks/useIsCompatibilityCheckRequired.js +1 -1
  48. package/dist/hooks/useMakeDepositAddress.js +1 -1
  49. package/dist/hooks/useMakeIntentsTransfer.js +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/events/index.js +1 -1
  71. package/dist/machine/events/tokenSelect.js +1 -1
  72. package/dist/machine/events/validateInputAndMoveTo.js +1 -1
  73. package/dist/machine/events/validateInputs.js +1 -1
  74. package/dist/machine/index.js +1 -1
  75. package/dist/machine/snap.js +1 -1
  76. package/dist/machine/subscriptions/checkers/isSendAddressAsConnected.js +1 -1
  77. package/dist/machine/subscriptions/index.js +1 -1
  78. package/dist/theme/ThemeProvider.js +1 -1
  79. package/dist/types/chain.d.ts +4 -0
  80. package/dist/types/config.d.ts +2 -5
  81. package/dist/types/widget.d.ts +1 -0
  82. package/dist/types/widget.js +2 -0
  83. package/dist/types/widget.js.map +1 -0
  84. package/dist/utils/intents/signers/near.js +1 -1
  85. package/dist/utils/intents/signers/privy.js +1 -1
  86. package/dist/utils/near/getNearNep141StorageBalance.js +1 -1
  87. package/dist/widgets/Widget/WidgetContent.d.ts +6 -4
  88. package/dist/widgets/Widget/WidgetContent.js +30 -24
  89. package/dist/widgets/Widget/WidgetContent.js.map +1 -1
  90. package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +65 -63
  91. package/dist/widgets/WidgetDeposit/WidgetDepositContent.js.map +1 -1
  92. package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
  93. package/dist/widgets/WidgetSwap/WidgetSwapContent.js +59 -53
  94. package/dist/widgets/WidgetSwap/WidgetSwapContent.js.map +1 -1
  95. package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
  96. package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +79 -77
  97. package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js.map +1 -1
  98. package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
  99. package/package.json +1 -1
  100. package/src/config.tsx +0 -5
  101. package/src/machine/effects/useSelectedTokensEffect.ts +7 -4
  102. package/src/types/chain.ts +5 -0
  103. package/src/types/config.ts +3 -4
  104. package/src/types/widget.ts +1 -0
  105. package/src/widgets/Widget/WidgetContent.tsx +19 -7
  106. package/src/widgets/WidgetDeposit/WidgetDeposit.test.tsx +0 -4
  107. package/src/widgets/WidgetDeposit/WidgetDepositContent.tsx +7 -3
  108. package/src/widgets/WidgetSwap/WidgetSwapContent.tsx +19 -4
  109. package/src/widgets/WidgetWithdraw/WidgetWithdrawContent.tsx +5 -3
  110. package/dist/config-Opy5ppbU.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import "react";
2
- import { H as i } from "../../config-Opy5ppbU.js";
2
+ import { H as i } from "../../config-Bg5hUlJL.js";
3
3
  import "ethers";
4
4
  import "../machine.js";
5
5
  import "../events/utils/fireEvent.js";
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import "../../hooks/useWalletAddressForToken.js";
3
- import { I as f } from "../../config-Opy5ppbU.js";
3
+ import { I as f } from "../../config-Bg5hUlJL.js";
4
4
  import "../guards/index.js";
5
5
  import "../machine.js";
6
6
  import "../events/utils/fireEvent.js";
@@ -3,7 +3,7 @@ import "./tokenSelectRotate.js";
3
3
  import "./errorSet.js";
4
4
  import "./quoteSet.js";
5
5
  import "./addressSet.js";
6
- import { _ as b } from "../../config-Opy5ppbU.js";
6
+ import { _ as b } from "../../config-Bg5hUlJL.js";
7
7
  import "./tokenSetAmount.js";
8
8
  import "./quoteSetStatus.js";
9
9
  import "./depositTypeSet.js";
@@ -1,6 +1,6 @@
1
1
  import "valtio";
2
2
  import "./tokenSelectRotate.js";
3
- import { Z as p } from "../../config-Opy5ppbU.js";
3
+ import { Z as p } from "../../config-Bg5hUlJL.js";
4
4
  import "../../utils/notReachable.js";
5
5
  export {
6
6
  p as tokenSelect
@@ -1,4 +1,4 @@
1
- import { O as m } from "../../config-Opy5ppbU.js";
1
+ import { O as m } from "../../config-Bg5hUlJL.js";
2
2
  import "ethers";
3
3
  import "../machine.js";
4
4
  import "../guards/checks/isDryQuote.js";
@@ -3,7 +3,7 @@ import "../../utils/near/checkNearAccountExists.js";
3
3
  import "../../utils/checkers/isNotEmptyAmount.js";
4
4
  import "../../utils/checkers/isValidBigint.js";
5
5
  import "../../utils/near/isNearAddress.js";
6
- import { K as I, L as d, N as u } from "../../config-Opy5ppbU.js";
6
+ import { K as I, L as d, N as u } from "../../config-Bg5hUlJL.js";
7
7
  import "../guards/index.js";
8
8
  import "../machine.js";
9
9
  import "../guards/checks/isBalanceSufficient.js";
@@ -1,4 +1,4 @@
1
- import { r as o, u as t, a as r, c as a, b as f } from "../config-Opy5ppbU.js";
1
+ import { r as o, u as t, a as r, c as a, b as f } from "../config-Bg5hUlJL.js";
2
2
  import { guardStates as S } from "./guards/index.js";
3
3
  import { machine as n, moveTo as u } from "./machine.js";
4
4
  import { fireEvent as i } from "./events/utils/fireEvent.js";
@@ -2,7 +2,7 @@ import "valtio";
2
2
  import "derive-valtio";
3
3
  import "./computed/getIsNativeNearDeposit.js";
4
4
  import "./computed/getIsDirectTokenOnNearDeposit.js";
5
- import { u as h, a as b, b as d } from "../config-Opy5ppbU.js";
5
+ import { u as h, a as b, b as d } from "../config-Bg5hUlJL.js";
6
6
  import "./machine.js";
7
7
  import "./guards/index.js";
8
8
  import "./computed/getUsdTradeDelta.js";
@@ -1,5 +1,5 @@
1
1
  import "valtio";
2
- import { V as o } from "../../../config-Opy5ppbU.js";
2
+ import { V as o } from "../../../config-Bg5hUlJL.js";
3
3
  export {
4
4
  o as isSendAddressAsConnected
5
5
  };
@@ -5,7 +5,7 @@ import "./checkers/isOnlyErrorChanged.js";
5
5
  import "./checkers/isValidInitialState.js";
6
6
  import "./checkers/isWalletDisconnected.js";
7
7
  import "./checkers/isSendAddressForbidden.js";
8
- import { X as g, Y as u } from "../../config-Opy5ppbU.js";
8
+ import { X as g, Y as u } from "../../config-Bg5hUlJL.js";
9
9
  import "./checkers/isAmountChangedFromQuote.js";
10
10
  import "ethers";
11
11
  import "../machine.js";
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "./createColorPalette.js";
4
- import { C as i, ad as p } from "../config-Opy5ppbU.js";
4
+ import { C as i, ad as p } from "../config-Bg5hUlJL.js";
5
5
  export {
6
6
  i as ThemeContext,
7
7
  p as ThemeProvider
@@ -9,4 +9,8 @@ export type ChainsFilter = {
9
9
  intents: 'none' | 'all' | 'with-balance';
10
10
  external: 'none' | 'all' | 'wallet-supported';
11
11
  };
12
+ export type ChainsFilters = {
13
+ target: ChainsFilter;
14
+ source: ChainsFilter;
15
+ };
12
16
  export type ChainRpcUrls = Partial<Record<Chains, string[]>>;
@@ -1,5 +1,5 @@
1
1
  import { Quote, QuoteRequest } from '@defuse-protocol/one-click-sdk-typescript';
2
- import { Chains, ChainsFilter } from './chain';
2
+ import { Chains } from './chain';
3
3
  import { SimpleToken, Token } from './token';
4
4
  import { FetchQuoteOptions } from './quote';
5
5
  export type WalletAddresses = Partial<Record<Chains | 'default', string | null>>;
@@ -8,6 +8,7 @@ export type PriorityAssets = ReadonlyArray<string> | ReadonlyArray<readonly [Cha
8
8
  export type WidgetConfig = {
9
9
  appName: string;
10
10
  appIcon?: string;
11
+ enableAccountAbstraction?: boolean;
11
12
  intentsAccountType?: IntentsAccountType;
12
13
  walletSupportedChains: ReadonlyArray<Chains>;
13
14
  connectedWallets: WalletAddresses;
@@ -32,10 +33,6 @@ export type WidgetConfig = {
32
33
  allowedSourceChainsList?: Chains[];
33
34
  allowedTargetChainsList?: Chains[];
34
35
  topChainShortcuts?: (intentsAccountType?: IntentsAccountType) => [Chains, Chains, Chains, Chains];
35
- chainsFilter: {
36
- source: ChainsFilter;
37
- target: ChainsFilter;
38
- };
39
36
  fetchQuote?: (data: QuoteRequest, options: FetchQuoteOptions) => Promise<Quote>;
40
37
  fetchSourceTokens?: () => Promise<SimpleToken[]>;
41
38
  fetchTargetTokens?: () => Promise<SimpleToken[]>;
@@ -0,0 +1 @@
1
+ export type WidgetType = 'swap' | 'deposit' | 'withdraw';
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import "../../../index-DEq3oXQF.js";
2
2
  import "@defuse-protocol/intents-sdk";
3
- import { a2 as o } from "../../../config-Opy5ppbU.js";
3
+ import { a2 as o } from "../../../config-Bg5hUlJL.js";
4
4
  export {
5
5
  o as createNearWalletSigner
6
6
  };
@@ -1,5 +1,5 @@
1
1
  import "@defuse-protocol/internal-utils";
2
- import { a1 as i } from "../../../config-Opy5ppbU.js";
2
+ import { a1 as i } from "../../../config-Bg5hUlJL.js";
3
3
  export {
4
4
  i as IntentSignerPrivy
5
5
  };
@@ -2,7 +2,7 @@ import "../../index-DEq3oXQF.js";
2
2
  import "zod";
3
3
  import "./decodeQueryResult.js";
4
4
  import "./rpc.js";
5
- import { $ as m } from "../../config-Opy5ppbU.js";
5
+ import { $ as m } from "../../config-Bg5hUlJL.js";
6
6
  export {
7
7
  m as getNearNep141StorageBalance
8
8
  };
@@ -1,10 +1,12 @@
1
1
  import { Msg as SwapMsg, Props as WidgetSwapProps } from '../WidgetSwap/WidgetSwapContent';
2
2
  import { Msg as DepositMsg, Props as WidgetDepositProps } from '../WidgetDeposit/WidgetDepositContent';
3
3
  import { Props as WidgetWithdrawProps, Msg as WithdrawMsg } from '../WidgetWithdraw/WidgetWithdrawContent';
4
- type WidgetType = 'swap' | 'deposit' | 'withdraw';
5
- export type Props = Omit<WidgetSwapProps | WidgetDepositProps | WidgetWithdrawProps, 'onMsg'> & {
6
- onMsg?: (msg: Msg, widget: WidgetType) => void;
4
+ import { MakeTransferArgs } from '../../types';
5
+ import { WidgetType } from '../../types/widget';
6
+ export type Props = Omit<WidgetSwapProps | WidgetDepositProps | WidgetWithdrawProps, 'onMsg' | 'makeTransfer'> & {
7
+ onMsg?: (msg: Msg, widgetType: WidgetType) => void;
8
+ makeTransfer?: (args: MakeTransferArgs, widgetType: WidgetType) => void;
7
9
  };
8
10
  type Msg = SwapMsg | DepositMsg | WithdrawMsg;
9
- export declare const WidgetContent: ({ onMsg, ...restProps }: Props) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const WidgetContent: ({ onMsg, makeTransfer, ...restProps }: Props) => import("react/jsx-runtime").JSX.Element;
10
12
  export {};
@@ -1,46 +1,52 @@
1
- import { jsxs as m, Fragment as w, jsx as e } from "react/jsx-runtime";
2
- import { useState as r } from "react";
3
- import { WidgetTabs as u } from "../../components/WidgetTabs.js";
4
- import { WidgetSwapContent as f } from "../WidgetSwap/WidgetSwapContent.js";
5
- import { WidgetDepositContent as g } from "../WidgetDeposit/WidgetDepositContent.js";
6
- import { WidgetWithdrawContent as b } from "../WidgetWithdraw/WidgetWithdrawContent.js";
7
- const x = ({ onMsg: a, ...o }) => {
8
- const [c, i] = r(!0), [s, d] = r("swap"), p = (t) => {
9
- d(t);
10
- }, n = (t, l) => {
11
- t.type === "on_tokens_modal_toggled" && i(!t.isOpen), t.type === "on_select_token" && i(!0), a?.(t, l);
1
+ import { jsxs as u, Fragment as l, jsx as e } from "react/jsx-runtime";
2
+ import { useState as p, useEffect as b } from "react";
3
+ import { WidgetTabs as g } from "../../components/WidgetTabs.js";
4
+ import { WidgetSwapContent as h } from "../WidgetSwap/WidgetSwapContent.js";
5
+ import { WidgetDepositContent as T } from "../WidgetDeposit/WidgetDepositContent.js";
6
+ import { WidgetWithdrawContent as W } from "../WidgetWithdraw/WidgetWithdrawContent.js";
7
+ import { y as C } from "../../config-Bg5hUlJL.js";
8
+ const j = ({ onMsg: d, makeTransfer: o, ...s }) => {
9
+ const [f, r] = p(!0), [a, c] = p("swap"), { enableAccountAbstraction: n } = C(), w = (t) => {
10
+ c(t);
11
+ }, i = (t, m) => {
12
+ t.type === "on_tokens_modal_toggled" && r(!t.isOpen), t.type === "on_select_token" && r(!0), d?.(t, m);
12
13
  };
13
- return /* @__PURE__ */ m(w, { children: [
14
- c && /* @__PURE__ */ e(u, { activeTab: s, onSelect: p }),
14
+ return b(() => {
15
+ n || c("swap");
16
+ }, [n]), /* @__PURE__ */ u(l, { children: [
17
+ n && f && /* @__PURE__ */ e(g, { activeTab: a, onSelect: w }),
15
18
  (() => {
16
- switch (s) {
19
+ switch (a) {
17
20
  case "swap":
18
21
  return /* @__PURE__ */ e(
19
- f,
22
+ h,
20
23
  {
21
- ...o,
24
+ ...s,
25
+ makeTransfer: (t) => o?.(t, "swap"),
22
26
  onMsg: (t) => {
23
- n(t, "swap");
27
+ i(t, "swap");
24
28
  }
25
29
  }
26
30
  );
27
31
  case "deposit":
28
32
  return /* @__PURE__ */ e(
29
- g,
33
+ T,
30
34
  {
31
- ...o,
35
+ ...s,
36
+ makeTransfer: (t) => o?.(t, "deposit"),
32
37
  onMsg: (t) => {
33
- n(t, "deposit");
38
+ i(t, "deposit");
34
39
  }
35
40
  }
36
41
  );
37
42
  case "withdraw":
38
43
  return /* @__PURE__ */ e(
39
- b,
44
+ W,
40
45
  {
41
- ...o,
46
+ ...s,
47
+ makeTransfer: (t) => o?.(t, "withdraw"),
42
48
  onMsg: (t) => {
43
- n(t, "withdraw");
49
+ i(t, "withdraw");
44
50
  }
45
51
  }
46
52
  );
@@ -51,6 +57,6 @@ const x = ({ onMsg: a, ...o }) => {
51
57
  ] });
52
58
  };
53
59
  export {
54
- x as WidgetContent
60
+ j as WidgetContent
55
61
  };
56
62
  //# sourceMappingURL=WidgetContent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WidgetContent.js","sources":["../../../src/widgets/Widget/WidgetContent.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\nimport { WidgetTab, WidgetTabs } from '../../components/WidgetTabs';\nimport {\n Msg as SwapMsg,\n WidgetSwapContent,\n Props as WidgetSwapProps,\n} from '../WidgetSwap/WidgetSwapContent';\nimport {\n Msg as DepositMsg,\n WidgetDepositContent,\n Props as WidgetDepositProps,\n} from '../WidgetDeposit/WidgetDepositContent';\nimport {\n WidgetWithdrawContent,\n Props as WidgetWithdrawProps,\n Msg as WithdrawMsg,\n} from '../WidgetWithdraw/WidgetWithdrawContent';\n\ntype WidgetType = 'swap' | 'deposit' | 'withdraw';\n\nexport type Props = Omit<\n WidgetSwapProps | WidgetDepositProps | WidgetWithdrawProps,\n 'onMsg'\n> & {\n onMsg?: (msg: Msg, widget: WidgetType) => void;\n};\n\ntype Msg = SwapMsg | DepositMsg | WithdrawMsg;\n\nexport const WidgetContent = ({ onMsg, ...restProps }: Props) => {\n const [isTabsVisible, setIsTabsVisible] = useState(true);\n const [activeTab, setActiveTab] = useState<WidgetTab>('swap');\n\n const switchTab = (tab: WidgetTab) => {\n setActiveTab(tab);\n };\n\n const handleMsg = <T extends Msg>(msg: T, widgetType: WidgetType) => {\n if (msg.type === 'on_tokens_modal_toggled') {\n setIsTabsVisible(!msg.isOpen);\n }\n\n if (msg.type === 'on_select_token') {\n setIsTabsVisible(true);\n }\n\n onMsg?.(msg, widgetType);\n };\n\n return (\n <>\n {isTabsVisible && (\n <WidgetTabs activeTab={activeTab} onSelect={switchTab} />\n )}\n\n {(() => {\n switch (activeTab) {\n case 'swap': {\n return (\n <WidgetSwapContent\n {...restProps}\n onMsg={(msg) => {\n handleMsg(msg, 'swap');\n }}\n />\n );\n }\n\n case 'deposit': {\n return (\n <WidgetDepositContent\n {...restProps}\n onMsg={(msg) => {\n handleMsg(msg, 'deposit');\n }}\n />\n );\n }\n\n case 'withdraw': {\n return (\n <WidgetWithdrawContent\n {...restProps}\n onMsg={(msg) => {\n handleMsg(msg, 'withdraw');\n }}\n />\n );\n }\n\n default:\n return null;\n }\n })()}\n </>\n );\n};\n"],"names":["WidgetContent","onMsg","restProps","isTabsVisible","setIsTabsVisible","useState","activeTab","setActiveTab","switchTab","tab","handleMsg","msg","widgetType","jsxs","Fragment","jsx","WidgetTabs","WidgetSwapContent","WidgetDepositContent","WidgetWithdrawContent"],"mappings":";;;;;;AA+BO,MAAMA,IAAgB,CAAC,EAAE,OAAAC,GAAO,GAAGC,QAAuB;AAC/D,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAS,EAAI,GACjD,CAACC,GAAWC,CAAY,IAAIF,EAAoB,MAAM,GAEtDG,IAAY,CAACC,MAAmB;AACpC,IAAAF,EAAaE,CAAG;AAAA,EAClB,GAEMC,IAAY,CAAgBC,GAAQC,MAA2B;AACnE,IAAID,EAAI,SAAS,6BACfP,EAAiB,CAACO,EAAI,MAAM,GAG1BA,EAAI,SAAS,qBACfP,EAAiB,EAAI,GAGvBH,IAAQU,GAAKC,CAAU;AAAA,EACzB;AAEA,SACE,gBAAAC,EAAAC,GAAA,EACG,UAAA;AAAA,IAAAX,KACC,gBAAAY,EAACC,GAAA,EAAW,WAAAV,GAAsB,UAAUE,GAAW;AAAA,KAGvD,MAAM;AACN,cAAQF,GAAA;AAAA,QACN,KAAK;AACH,iBACE,gBAAAS;AAAA,YAACE;AAAA,YAAA;AAAA,cACE,GAAGf;AAAA,cACJ,OAAO,CAACS,MAAQ;AACd,gBAAAD,EAAUC,GAAK,MAAM;AAAA,cACvB;AAAA,YAAA;AAAA,UAAA;AAAA,QAKN,KAAK;AACH,iBACE,gBAAAI;AAAA,YAACG;AAAA,YAAA;AAAA,cACE,GAAGhB;AAAA,cACJ,OAAO,CAACS,MAAQ;AACd,gBAAAD,EAAUC,GAAK,SAAS;AAAA,cAC1B;AAAA,YAAA;AAAA,UAAA;AAAA,QAKN,KAAK;AACH,iBACE,gBAAAI;AAAA,YAACI;AAAA,YAAA;AAAA,cACE,GAAGjB;AAAA,cACJ,OAAO,CAACS,MAAQ;AACd,gBAAAD,EAAUC,GAAK,UAAU;AAAA,cAC3B;AAAA,YAAA;AAAA,UAAA;AAAA,QAKN;AACE,iBAAO;AAAA,MAAA;AAAA,IAEb,GAAA;AAAA,EAAG,GACL;AAEJ;"}
1
+ {"version":3,"file":"WidgetContent.js","sources":["../../../src/widgets/Widget/WidgetContent.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\nimport { WidgetTab, WidgetTabs } from '../../components/WidgetTabs';\nimport {\n Msg as SwapMsg,\n WidgetSwapContent,\n Props as WidgetSwapProps,\n} from '../WidgetSwap/WidgetSwapContent';\nimport {\n Msg as DepositMsg,\n WidgetDepositContent,\n Props as WidgetDepositProps,\n} from '../WidgetDeposit/WidgetDepositContent';\nimport {\n WidgetWithdrawContent,\n Props as WidgetWithdrawProps,\n Msg as WithdrawMsg,\n} from '../WidgetWithdraw/WidgetWithdrawContent';\nimport { useConfig } from '../../config';\nimport { MakeTransferArgs } from '../../types';\nimport { WidgetType } from '../../types/widget';\n\nexport type Props = Omit<\n WidgetSwapProps | WidgetDepositProps | WidgetWithdrawProps,\n 'onMsg' | 'makeTransfer'\n> & {\n onMsg?: (msg: Msg, widgetType: WidgetType) => void;\n makeTransfer?: (args: MakeTransferArgs, widgetType: WidgetType) => void;\n};\n\ntype Msg = SwapMsg | DepositMsg | WithdrawMsg;\n\nexport const WidgetContent = ({ onMsg, makeTransfer, ...restProps }: Props) => {\n const [isTabsVisible, setIsTabsVisible] = useState(true);\n const [activeTab, setActiveTab] = useState<WidgetTab>('swap');\n const { enableAccountAbstraction } = useConfig();\n\n const switchTab = (tab: WidgetTab) => {\n setActiveTab(tab);\n };\n\n const handleMsg = <T extends Msg>(msg: T, widgetType: WidgetType) => {\n if (msg.type === 'on_tokens_modal_toggled') {\n setIsTabsVisible(!msg.isOpen);\n }\n\n if (msg.type === 'on_select_token') {\n setIsTabsVisible(true);\n }\n\n onMsg?.(msg, widgetType);\n };\n\n useEffect(() => {\n if (!enableAccountAbstraction) {\n setActiveTab('swap');\n }\n }, [enableAccountAbstraction]);\n\n return (\n <>\n {enableAccountAbstraction && isTabsVisible && (\n <WidgetTabs activeTab={activeTab} onSelect={switchTab} />\n )}\n\n {(() => {\n switch (activeTab) {\n case 'swap': {\n return (\n <WidgetSwapContent\n {...restProps}\n makeTransfer={(args) => makeTransfer?.(args, 'swap')}\n onMsg={(msg) => {\n handleMsg(msg, 'swap');\n }}\n />\n );\n }\n\n case 'deposit': {\n return (\n <WidgetDepositContent\n {...restProps}\n makeTransfer={(args) => makeTransfer?.(args, 'deposit')}\n onMsg={(msg) => {\n handleMsg(msg, 'deposit');\n }}\n />\n );\n }\n\n case 'withdraw': {\n return (\n <WidgetWithdrawContent\n {...restProps}\n makeTransfer={(args) => makeTransfer?.(args, 'withdraw')}\n onMsg={(msg) => {\n handleMsg(msg, 'withdraw');\n }}\n />\n );\n }\n\n default:\n return null;\n }\n })()}\n </>\n );\n};\n"],"names":["WidgetContent","onMsg","makeTransfer","restProps","isTabsVisible","setIsTabsVisible","useState","activeTab","setActiveTab","enableAccountAbstraction","useConfig","switchTab","tab","handleMsg","msg","widgetType","useEffect","jsxs","Fragment","jsx","WidgetTabs","WidgetSwapContent","args","WidgetDepositContent","WidgetWithdrawContent"],"mappings":";;;;;;;AAiCO,MAAMA,IAAgB,CAAC,EAAE,OAAAC,GAAO,cAAAC,GAAc,GAAGC,QAAuB;AAC7E,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAS,EAAI,GACjD,CAACC,GAAWC,CAAY,IAAIF,EAAoB,MAAM,GACtD,EAAE,0BAAAG,EAAA,IAA6BC,EAAA,GAE/BC,IAAY,CAACC,MAAmB;AACpC,IAAAJ,EAAaI,CAAG;AAAA,EAClB,GAEMC,IAAY,CAAgBC,GAAQC,MAA2B;AACnE,IAAID,EAAI,SAAS,6BACfT,EAAiB,CAACS,EAAI,MAAM,GAG1BA,EAAI,SAAS,qBACfT,EAAiB,EAAI,GAGvBJ,IAAQa,GAAKC,CAAU;AAAA,EACzB;AAEA,SAAAC,EAAU,MAAM;AACd,IAAKP,KACHD,EAAa,MAAM;AAAA,EAEvB,GAAG,CAACC,CAAwB,CAAC,GAG3B,gBAAAQ,EAAAC,GAAA,EACG,UAAA;AAAA,IAAAT,KAA4BL,KAC3B,gBAAAe,EAACC,GAAA,EAAW,WAAAb,GAAsB,UAAUI,GAAW;AAAA,KAGvD,MAAM;AACN,cAAQJ,GAAA;AAAA,QACN,KAAK;AACH,iBACE,gBAAAY;AAAA,YAACE;AAAA,YAAA;AAAA,cACE,GAAGlB;AAAA,cACJ,cAAc,CAACmB,MAASpB,IAAeoB,GAAM,MAAM;AAAA,cACnD,OAAO,CAACR,MAAQ;AACd,gBAAAD,EAAUC,GAAK,MAAM;AAAA,cACvB;AAAA,YAAA;AAAA,UAAA;AAAA,QAKN,KAAK;AACH,iBACE,gBAAAK;AAAA,YAACI;AAAA,YAAA;AAAA,cACE,GAAGpB;AAAA,cACJ,cAAc,CAACmB,MAASpB,IAAeoB,GAAM,SAAS;AAAA,cACtD,OAAO,CAACR,MAAQ;AACd,gBAAAD,EAAUC,GAAK,SAAS;AAAA,cAC1B;AAAA,YAAA;AAAA,UAAA;AAAA,QAKN,KAAK;AACH,iBACE,gBAAAK;AAAA,YAACK;AAAA,YAAA;AAAA,cACE,GAAGrB;AAAA,cACJ,cAAc,CAACmB,MAASpB,IAAeoB,GAAM,UAAU;AAAA,cACvD,OAAO,CAACR,MAAQ;AACd,gBAAAD,EAAUC,GAAK,UAAU;AAAA,cAC3B;AAAA,YAAA;AAAA,UAAA;AAAA,QAKN;AACE,iBAAO;AAAA,MAAA;AAAA,IAEb,GAAA;AAAA,EAAG,GACL;AAEJ;"}
@@ -1,9 +1,9 @@
1
- import { jsx as t, jsxs as y } from "react/jsx-runtime";
2
- import { useState as b, useEffect as p, useCallback as R } from "react";
3
- import { useTokenModal as A } from "../../hooks/useTokenModal.js";
4
- import { useTypedTranslation as F } from "../../localisation.js";
5
- import { WidgetDepositSkeleton as S } from "./WidgetDepositSkeleton.js";
6
- import { b as q, u as j, y as N, n as O, c as Q, p as U, o as K, S as P } from "../../config-Opy5ppbU.js";
1
+ import { jsx as t, jsxs as _ } from "react/jsx-runtime";
2
+ import { useState as y, useEffect as p, useCallback as B } from "react";
3
+ import { useTokenModal as R } from "../../hooks/useTokenModal.js";
4
+ import { useTypedTranslation as A } from "../../localisation.js";
5
+ import { WidgetDepositSkeleton as b } from "./WidgetDepositSkeleton.js";
6
+ import { b as F, u as q, y as j, n as N, c as O, p as Q, o as U, S as K } from "../../config-Bg5hUlJL.js";
7
7
  import "@tanstack/react-query";
8
8
  import "@headlessui/react";
9
9
  import "@material-symbols-svg/react-rounded/icons/chevron-left";
@@ -15,20 +15,20 @@ import { notReachable as r } from "../../utils/notReachable.js";
15
15
  import "use-debounce";
16
16
  import "@material-symbols-svg/react-rounded/icons/wand-shine";
17
17
  import "../../components/Input.js";
18
- import { Banner as z } from "../../components/Banner.js";
19
- import { isDebug as G } from "../../utils/checkers/isDebug.js";
18
+ import { Banner as P } from "../../components/Banner.js";
19
+ import { isDebug as z } from "../../utils/checkers/isDebug.js";
20
20
  import "viem";
21
21
  import "ethers";
22
22
  import "../../machine/machine.js";
23
23
  import { fireEvent as u } from "../../machine/events/utils/fireEvent.js";
24
- import { SuccessScreen as H } from "../../features/SuccessScreen/index.js";
25
- import { TokensModal as J } from "../../features/TokensModal.js";
24
+ import { SuccessScreen as G } from "../../features/SuccessScreen/index.js";
25
+ import { TokensModal as H } from "../../features/TokensModal.js";
26
26
  import "@material-symbols-svg/react-rounded/icons/arrow-downward";
27
27
  import "@material-symbols-svg/react-rounded/icons/progress-activity";
28
- import { ExternalDeposit as L } from "../../features/ExternalDeposit.js";
29
- import { DepositMethodSwitcher as V } from "../../features/DepositMethodSwitcher.js";
30
- import { WalletCompatibilityCheck as X } from "../../features/WalletCompatibilityCheck/index.js";
31
- import { BlockingError as Y } from "../../components/BlockingError.js";
28
+ import { ExternalDeposit as J } from "../../features/ExternalDeposit.js";
29
+ import { DepositMethodSwitcher as L } from "../../features/DepositMethodSwitcher.js";
30
+ import { WalletCompatibilityCheck as V } from "../../features/WalletCompatibilityCheck/index.js";
31
+ import { BlockingError as X } from "../../components/BlockingError.js";
32
32
  import "copy-text-to-clipboard";
33
33
  import "@material-symbols-svg/react-rounded/icons/content-copy";
34
34
  import "../../components/InputAmount.js";
@@ -48,30 +48,29 @@ import "@defuse-protocol/one-click-sdk-typescript";
48
48
  import "axios";
49
49
  import "../../network.js";
50
50
  import "viem/chains";
51
- import { useTokenInputPair as Z } from "../../hooks/useTokenInputPair.js";
52
- import { useIsCompatibilityCheckRequired as $ } from "../../hooks/useIsCompatibilityCheckRequired.js";
51
+ import { useTokenInputPair as Y } from "../../hooks/useTokenInputPair.js";
52
+ import { useIsCompatibilityCheckRequired as Z } from "../../hooks/useIsCompatibilityCheckRequired.js";
53
53
  import "browser-or-node";
54
- const $e = ({
54
+ const Ze = ({
55
55
  providers: m,
56
56
  onMsg: n,
57
- makeTransfer: T,
58
- isLoading: w
57
+ makeTransfer: S,
58
+ isLoading: T
59
59
  }) => {
60
- const { ctx: o } = q(), { t: i } = F(), { isDirectNearTokenWithdrawal: x } = j(), {
61
- chainsFilter: f,
62
- alchemyApiKey: C,
63
- refetchQuoteInterval: g,
64
- intentsAccountType: D,
65
- onWalletSignout: v
66
- } = N(), { onChangeAmount: E, onChangeToken: d } = Z(), { status: k, refetch: W } = O(), { tokenModalOpen: s, updateTokenModalState: a } = A({ onMsg: n }), h = $(), [I, c] = b(!1);
60
+ const { ctx: o } = F(), { t: i } = A(), { isDirectNearTokenWithdrawal: w } = q(), {
61
+ alchemyApiKey: x,
62
+ refetchQuoteInterval: C,
63
+ intentsAccountType: g,
64
+ onWalletSignout: D
65
+ } = j(), { onChangeAmount: E, onChangeToken: f } = Y(), { status: d, refetch: v } = N(), { tokenModalOpen: s, updateTokenModalState: a } = R({ onMsg: n }), k = Z(), [W, l] = y(!1);
67
66
  p(() => {
68
- h && c(!0);
69
- }, [h]);
70
- const [_, l] = b(), M = R(
67
+ k && l(!0);
68
+ }, [k]);
69
+ const [h, c] = y(), I = B(
71
70
  (e) => {
72
71
  switch (e.type) {
73
72
  case "on_successful_transfer":
74
- l(e.transferResult);
73
+ c(e.transferResult);
75
74
  break;
76
75
  case "on_transaction_received":
77
76
  break;
@@ -83,15 +82,15 @@ const $e = ({
83
82
  );
84
83
  p(() => (u("reset", { clearWalletAddress: !0 }), () => {
85
84
  u("depositTypeSet", { isExternal: !1 });
86
- }), []), Q({
87
- debug: G(),
85
+ }), []), O({
86
+ debug: z(),
88
87
  listenTo: [
89
88
  "checkWalletConnection",
90
89
  "setSourceTokenBalance",
91
90
  "setSourceTokenIntentsTarget",
92
91
  ["setDefaultSelectedTokens", { skipIntents: !0 }],
93
- ["makeQuote", { message: void 0, refetchQuoteInterval: g }],
94
- ["setBalancesUsingAlchemyExt", { alchemyApiKey: C }]
92
+ ["makeQuote", { message: void 0, refetchQuoteInterval: C }],
93
+ ["setBalancesUsingAlchemyExt", { alchemyApiKey: x }]
95
94
  ]
96
95
  }), p(() => {
97
96
  n?.({
@@ -99,23 +98,23 @@ const $e = ({
99
98
  isExternal: o.isDepositFromExternalWallet
100
99
  });
101
100
  }, [o.isDepositFromExternalWallet]);
102
- const B = () => {
101
+ const M = () => {
103
102
  u("reset", { clearWalletAddress: !1, keepSelectedTokens: !0 });
104
103
  };
105
- if (w || k !== "error" && !o.sourceToken)
106
- return /* @__PURE__ */ t(S, {});
107
- if (I)
104
+ if (T || d !== "error" && !o.sourceToken)
105
+ return /* @__PURE__ */ t(b, {});
106
+ if (W)
108
107
  return /* @__PURE__ */ t(
109
- X,
108
+ V,
110
109
  {
111
110
  providers: m,
112
111
  onMsg: (e) => {
113
112
  switch (e.type) {
114
113
  case "on_sign_out":
115
- v?.(D), c(!1);
114
+ D?.(g), l(!1);
116
115
  break;
117
116
  case "on_close":
118
- c(!1);
117
+ l(!1);
119
118
  break;
120
119
  default:
121
120
  r(e.type);
@@ -123,16 +122,16 @@ const $e = ({
123
122
  }
124
123
  }
125
124
  );
126
- if (o.state === "transfer_success" && _)
125
+ if (o.state === "transfer_success" && h)
127
126
  return /* @__PURE__ */ t(
128
- H,
127
+ G,
129
128
  {
130
- ..._,
129
+ ...h,
131
130
  title: i("transfer.success.deposit.title", "Deposit successful"),
132
131
  onMsg: (e) => {
133
132
  switch (e.type) {
134
133
  case "on_dismiss_success":
135
- l(void 0), B();
134
+ c(void 0), M();
136
135
  break;
137
136
  default:
138
137
  r(e.type);
@@ -140,28 +139,31 @@ const $e = ({
140
139
  }
141
140
  }
142
141
  );
143
- switch (k) {
142
+ switch (d) {
144
143
  case "error":
145
144
  return /* @__PURE__ */ t(
146
- Y,
145
+ X,
147
146
  {
148
147
  message: "Couldn't load tokens list.",
149
- onClickRetry: W
148
+ onClickRetry: v
150
149
  }
151
150
  );
152
151
  case "success":
153
152
  return s !== "none" ? /* @__PURE__ */ t(
154
- J,
153
+ H,
155
154
  {
156
155
  showBalances: !0,
157
156
  showChainsSelector: !0,
158
157
  variant: s,
159
158
  groupTokens: s === "source",
160
- chainsFilter: s === "source" ? f.source : f.target,
159
+ chainsFilter: s === "source" ? {
160
+ intents: "none",
161
+ external: o.isDepositFromExternalWallet ? "all" : "wallet-supported"
162
+ } : { intents: "all", external: "none" },
161
163
  onMsg: (e) => {
162
164
  switch (e.type) {
163
165
  case "on_select_token":
164
- d(s, e.token), a("none"), n?.({
166
+ f(s, e.token), a("none"), n?.({
165
167
  type: e.type,
166
168
  token: e.token,
167
169
  variant: s
@@ -175,16 +177,16 @@ const $e = ({
175
177
  }
176
178
  }
177
179
  }
178
- ) : /* @__PURE__ */ y("div", { className: "gap-sw-2xl flex flex-col", children: [
180
+ ) : /* @__PURE__ */ _("div", { className: "gap-sw-2xl flex flex-col", children: [
179
181
  /* @__PURE__ */ t(
180
- U.Source,
182
+ Q.Source,
181
183
  {
182
184
  showBalance: !o.isDepositFromExternalWallet,
183
185
  heading: i("tokenInput.heading.source.deposit", "Sell"),
184
186
  onMsg: (e) => {
185
187
  switch (e.type) {
186
188
  case "on_select_token":
187
- d("source", e.token);
189
+ f("source", e.token);
188
190
  break;
189
191
  case "on_change_amount":
190
192
  E("source", e.amount);
@@ -198,10 +200,10 @@ const $e = ({
198
200
  }
199
201
  }
200
202
  ),
201
- /* @__PURE__ */ t(V, { children: ({ isExternal: e }) => e ? /* @__PURE__ */ y("div", { className: "gap-sw-2xl flex flex-col justify-between", children: [
202
- /* @__PURE__ */ t(L, { onMsg: M }),
203
+ /* @__PURE__ */ t(L, { children: ({ isExternal: e }) => e ? /* @__PURE__ */ _("div", { className: "gap-sw-2xl flex flex-col justify-between", children: [
204
+ /* @__PURE__ */ t(J, { onMsg: I }),
203
205
  (o.state === "quote_success_internal" || o.state === "quote_success_external") && /* @__PURE__ */ t(
204
- z,
206
+ P,
205
207
  {
206
208
  multiline: !0,
207
209
  variant: "warn",
@@ -209,25 +211,25 @@ const $e = ({
209
211
  }
210
212
  )
211
213
  ] }) : null }),
212
- !x && /* @__PURE__ */ t(K, {}),
214
+ !w && /* @__PURE__ */ t(U, {}),
213
215
  /* @__PURE__ */ t(
214
- P,
216
+ K,
215
217
  {
216
218
  providers: m,
217
- makeTransfer: T,
219
+ makeTransfer: S,
218
220
  label: i("submit.active.deposit", "Deposit now"),
219
221
  onSuccess: (e) => {
220
- l(e), n?.({ type: "on_transfer_success" });
222
+ c(e), n?.({ type: "on_transfer_success" });
221
223
  }
222
224
  }
223
225
  )
224
226
  ] });
225
227
  case "pending":
226
228
  default:
227
- return /* @__PURE__ */ t(S, {});
229
+ return /* @__PURE__ */ t(b, {});
228
230
  }
229
231
  };
230
232
  export {
231
- $e as WidgetDepositContent
233
+ Ze as WidgetDepositContent
232
234
  };
233
235
  //# sourceMappingURL=WidgetDepositContent.js.map