@aurora-is-near/intents-swap-widget 2.6.5 → 2.7.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/README.md +14 -0
- package/dist/components/Icon.js +36 -33
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/SkeletonBox.d.ts +3 -0
- package/dist/components/SkeletonBox.js +12 -0
- package/dist/components/SkeletonBox.js.map +1 -0
- package/dist/components/WidgetContainer.d.ts +2 -0
- package/dist/components/WidgetContainer.js +6 -0
- package/dist/components/WidgetContainer.js.map +1 -0
- package/dist/{config-Dq9mlDST.js → config-haLfG4Cu.js} +24 -24
- package/dist/{config-Dq9mlDST.js.map → config-haLfG4Cu.js.map} +1 -1
- 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/index.js +1 -1
- package/dist/features/BalanceRpcLoader/useTokenBalanceRpc.js +1 -1
- package/dist/features/ChainsDropdown/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/SwapDirectionSwitcher.js +1 -1
- package/dist/features/SwapQuote/SwapQuote.js +1 -1
- package/dist/features/TokenInput/TokenInput.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/useTokenInputBalance.js +1 -1
- package/dist/features/TokensList/TokenItem.js +1 -1
- package/dist/features/TokensList/TokensList.js +1 -1
- package/dist/features/TokensModal.js +1 -1
- package/dist/features/WalletCompatibilityCheck/index.js +1 -1
- package/dist/hooks/index.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.js +1 -1
- package/dist/hooks/useIntentsBalance.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/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 +4 -4
- 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/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/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/{WidgetDeposit.d.ts → WidgetDeposit/WidgetDepositContent.d.ts} +4 -4
- package/dist/widgets/{WidgetDeposit.js → WidgetDeposit/WidgetDepositContent.js} +39 -39
- package/dist/widgets/WidgetDeposit/WidgetDepositContent.js.map +1 -0
- package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.d.ts +1 -0
- package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +10 -0
- package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js.map +1 -0
- package/dist/widgets/WidgetDeposit/index.d.ts +3 -0
- package/dist/widgets/WidgetDeposit/index.js +8 -0
- package/dist/widgets/WidgetDeposit/index.js.map +1 -0
- package/dist/widgets/{WidgetSwap.d.ts → WidgetSwap/WidgetSwapContent.d.ts} +4 -4
- package/dist/widgets/{WidgetSwap.js → WidgetSwap/WidgetSwapContent.js} +34 -34
- package/dist/widgets/WidgetSwap/WidgetSwapContent.js.map +1 -0
- package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.d.ts +1 -0
- package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +13 -0
- package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js.map +1 -0
- package/dist/widgets/WidgetSwap/index.d.ts +3 -0
- package/dist/widgets/WidgetSwap/index.js +8 -0
- package/dist/widgets/WidgetSwap/index.js.map +1 -0
- package/dist/widgets/{WidgetWithdraw.d.ts → WidgetWithdraw/WidgetWithdrawContent.d.ts} +4 -4
- package/dist/widgets/{WidgetWithdraw.js → WidgetWithdraw/WidgetWithdrawContent.js} +33 -33
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js.map +1 -0
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.d.ts +1 -0
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +11 -0
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js.map +1 -0
- package/dist/widgets/WidgetWithdraw/index.d.ts +3 -0
- package/dist/widgets/WidgetWithdraw/index.js +8 -0
- package/dist/widgets/WidgetWithdraw/index.js.map +1 -0
- package/dist/widgets/index.js +3 -3
- package/package.json +1 -1
- package/src/components/Icon.tsx +5 -2
- package/src/components/SkeletonBox.tsx +7 -0
- package/src/components/WidgetContainer.tsx +9 -0
- package/src/config.tsx +1 -3
- package/src/widgets/{WidgetDeposit.tsx → WidgetDeposit/WidgetDepositContent.tsx} +9 -9
- package/src/widgets/WidgetDeposit/WidgetDepositSkeleton.tsx +8 -0
- package/src/widgets/WidgetDeposit/index.tsx +10 -0
- package/src/widgets/{WidgetSwap.tsx → WidgetSwap/WidgetSwapContent.tsx} +9 -9
- package/src/widgets/WidgetSwap/WidgetSwapSkeleton.tsx +13 -0
- package/src/widgets/WidgetSwap/index.tsx +10 -0
- package/src/widgets/{WidgetWithdraw.tsx → WidgetWithdraw/WidgetWithdrawContent.tsx} +9 -9
- package/src/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.tsx +9 -0
- package/src/widgets/WidgetWithdraw/index.tsx +10 -0
- package/dist/widgets/WidgetDeposit.js.map +0 -1
- package/dist/widgets/WidgetSkeleton.d.ts +0 -5
- package/dist/widgets/WidgetSkeleton.js +0 -24
- package/dist/widgets/WidgetSkeleton.js.map +0 -1
- package/dist/widgets/WidgetSwap.js.map +0 -1
- package/dist/widgets/WidgetWithdraw.js.map +0 -1
- package/src/widgets/WidgetSkeleton.tsx +0 -34
package/README.md
CHANGED
|
@@ -42,6 +42,20 @@ _Types_ submodule exports domain types such as `Token`, `Chain`, `Quote` etc.
|
|
|
42
42
|
|
|
43
43
|
_Ext_ submodule contains various extensions that can be used with the widget but are completely optional. For example, it includes an Alchemy API integration that allows you to easily get token balances. Essentially, these are pre-written pieces of custom code.
|
|
44
44
|
|
|
45
|
+
## Styling
|
|
46
|
+
|
|
47
|
+
If you are importing one of our pre-built widget components (e.g. `WidgetSwap`)
|
|
48
|
+
then you don't need to do anything to apply the widget styles.
|
|
49
|
+
|
|
50
|
+
If you are rolling your own using our components you will need to add the `sw`
|
|
51
|
+
class to some wrapping element, for example:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
<div className="sw">
|
|
55
|
+
{/* Your custom widget */}
|
|
56
|
+
</div>
|
|
57
|
+
```
|
|
58
|
+
|
|
45
59
|
## Theming
|
|
46
60
|
|
|
47
61
|
This package uses Tailwind, but your app doesn't have to. It exposes CSS variables to control styling. Each variable and its corresponding Tailwind token uses the `sw-` prefix to avoid conflicts with your app's theme and variables.
|
package/dist/components/Icon.js
CHANGED
|
@@ -1,62 +1,65 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { cn as
|
|
4
|
-
const
|
|
5
|
-
radius:
|
|
2
|
+
import { useState as f } from "react";
|
|
3
|
+
import { cn as c } from "../utils/cn.js";
|
|
4
|
+
const n = ({
|
|
5
|
+
radius: o = 9999,
|
|
6
6
|
variant: t,
|
|
7
|
-
children:
|
|
7
|
+
children: s,
|
|
8
8
|
isLoaded: e,
|
|
9
|
-
noLoadedBg:
|
|
10
|
-
size:
|
|
9
|
+
noLoadedBg: a,
|
|
10
|
+
size: l = 28
|
|
11
11
|
}) => /* @__PURE__ */ r(
|
|
12
12
|
"div",
|
|
13
13
|
{
|
|
14
|
-
style: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
style: {
|
|
15
|
+
width: `${l}px`,
|
|
16
|
+
height: `${l}px`,
|
|
17
|
+
borderRadius: `${o}px`
|
|
18
|
+
},
|
|
19
|
+
className: c("flex items-center justify-center overflow-hidden", {
|
|
20
|
+
"bg-sw-gray-500": t === "dark" && (e && !a || !e),
|
|
21
|
+
"bg-sw-gray-200": t === "light" && (e && !a || !e)
|
|
19
22
|
}),
|
|
20
|
-
children:
|
|
23
|
+
children: s
|
|
21
24
|
}
|
|
22
25
|
), x = ({
|
|
23
|
-
variant:
|
|
26
|
+
variant: o,
|
|
24
27
|
icon: t,
|
|
25
|
-
label:
|
|
28
|
+
label: s,
|
|
26
29
|
radius: e = 9999,
|
|
27
|
-
noLoadedBg:
|
|
28
|
-
size:
|
|
30
|
+
noLoadedBg: a = !1,
|
|
31
|
+
size: l = 28
|
|
29
32
|
}) => {
|
|
30
|
-
const [
|
|
31
|
-
return typeof t == "string" &&
|
|
32
|
-
|
|
33
|
+
const [p, i] = f("loading");
|
|
34
|
+
return typeof t == "string" && p === "failed" ? /* @__PURE__ */ r(
|
|
35
|
+
n,
|
|
33
36
|
{
|
|
34
|
-
size:
|
|
37
|
+
size: l,
|
|
35
38
|
radius: e,
|
|
36
|
-
variant:
|
|
37
|
-
noLoadedBg:
|
|
39
|
+
variant: o,
|
|
40
|
+
noLoadedBg: a,
|
|
38
41
|
isLoaded: !1,
|
|
39
|
-
children: /* @__PURE__ */ r("span", { className: "text-sw-label-m text-sw-gray-100", children:
|
|
42
|
+
children: /* @__PURE__ */ r("span", { className: "text-sw-label-m text-sw-gray-100", children: s.charAt(0).toUpperCase() })
|
|
40
43
|
}
|
|
41
44
|
) : /* @__PURE__ */ r(
|
|
42
|
-
|
|
45
|
+
n,
|
|
43
46
|
{
|
|
44
|
-
size:
|
|
47
|
+
size: l,
|
|
45
48
|
radius: e,
|
|
46
|
-
variant:
|
|
47
|
-
noLoadedBg:
|
|
48
|
-
isLoaded: typeof t != "string" ||
|
|
49
|
+
variant: o,
|
|
50
|
+
noLoadedBg: a,
|
|
51
|
+
isLoaded: typeof t != "string" || p === "loaded",
|
|
49
52
|
children: /* @__PURE__ */ r(() => t ? typeof t == "string" ? /* @__PURE__ */ r(
|
|
50
53
|
"img",
|
|
51
54
|
{
|
|
52
55
|
width: 28,
|
|
53
56
|
height: 28,
|
|
54
57
|
src: t,
|
|
55
|
-
alt:
|
|
56
|
-
onLoad: () =>
|
|
57
|
-
onError: () =>
|
|
58
|
+
alt: s,
|
|
59
|
+
onLoad: () => i("loaded"),
|
|
60
|
+
onError: () => i("failed")
|
|
58
61
|
}
|
|
59
|
-
) : t : /* @__PURE__ */ r("span", { className: "text-sw-label-m text-sw-gray-100", children:
|
|
62
|
+
) : t : /* @__PURE__ */ r("span", { className: "text-sw-label-m text-sw-gray-100", children: s?.charAt(0).toUpperCase() }), {})
|
|
60
63
|
}
|
|
61
64
|
);
|
|
62
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.js","sources":["../../src/components/Icon.tsx"],"sourcesContent":["import { useState } from 'react';\nimport type { PropsWithChildren } from 'react';\n\nimport { cn } from '@/utils/cn';\n\ntype Variant = 'light' | 'dark';\ntype State = 'loading' | 'loaded' | 'failed';\n\ntype Props = {\n radius?: number;\n size?: number;\n label: string;\n variant: Variant;\n noLoadedBg?: boolean;\n icon: React.ReactElement | string | undefined;\n};\n\nconst Wrapper = ({\n radius = 9999,\n variant,\n children,\n isLoaded,\n noLoadedBg,\n size = 28,\n}: PropsWithChildren<{\n radius?: number;\n variant: Variant;\n size: number;\n noLoadedBg: boolean;\n isLoaded: boolean;\n}>) => (\n <div\n style={{
|
|
1
|
+
{"version":3,"file":"Icon.js","sources":["../../src/components/Icon.tsx"],"sourcesContent":["import { useState } from 'react';\nimport type { PropsWithChildren } from 'react';\n\nimport { cn } from '@/utils/cn';\n\ntype Variant = 'light' | 'dark';\ntype State = 'loading' | 'loaded' | 'failed';\n\ntype Props = {\n radius?: number;\n size?: number;\n label: string;\n variant: Variant;\n noLoadedBg?: boolean;\n icon: React.ReactElement | string | undefined;\n};\n\nconst Wrapper = ({\n radius = 9999,\n variant,\n children,\n isLoaded,\n noLoadedBg,\n size = 28,\n}: PropsWithChildren<{\n radius?: number;\n variant: Variant;\n size: number;\n noLoadedBg: boolean;\n isLoaded: boolean;\n}>) => (\n <div\n style={{\n width: `${size}px`,\n height: `${size}px`,\n borderRadius: `${radius}px`,\n }}\n className={cn('flex items-center justify-center overflow-hidden', {\n 'bg-sw-gray-500':\n variant === 'dark' && ((isLoaded && !noLoadedBg) || !isLoaded),\n 'bg-sw-gray-200':\n variant === 'light' && ((isLoaded && !noLoadedBg) || !isLoaded),\n })}>\n {children}\n </div>\n);\n\nexport const Icon = ({\n variant,\n icon,\n label,\n radius = 9999,\n noLoadedBg = false,\n size = 28,\n}: Props) => {\n const [imageState, setImageState] = useState<State>('loading');\n\n if (typeof icon === 'string' && imageState === 'failed') {\n return (\n <Wrapper\n size={size}\n radius={radius}\n variant={variant}\n noLoadedBg={noLoadedBg}\n isLoaded={false}>\n <span className=\"text-sw-label-m text-sw-gray-100\">\n {label.charAt(0).toUpperCase()}\n </span>\n </Wrapper>\n );\n }\n\n const Ico = () => {\n if (!icon) {\n return (\n <span className=\"text-sw-label-m text-sw-gray-100\">\n {label?.charAt(0).toUpperCase()}\n </span>\n );\n }\n\n if (typeof icon === 'string') {\n return (\n <img\n width={28}\n height={28}\n src={icon}\n alt={label}\n onLoad={() => setImageState('loaded')}\n onError={() => setImageState('failed')}\n />\n );\n }\n\n return icon;\n };\n\n return (\n <Wrapper\n size={size}\n radius={radius}\n variant={variant}\n noLoadedBg={noLoadedBg}\n isLoaded={typeof icon !== 'string' || imageState === 'loaded'}>\n <Ico />\n </Wrapper>\n );\n};\n"],"names":["Wrapper","radius","variant","children","isLoaded","noLoadedBg","size","jsx","cn","Icon","icon","label","imageState","setImageState","useState"],"mappings":";;;AAiBA,MAAMA,IAAU,CAAC;AAAA,EACf,QAAAC,IAAS;AAAA,EACT,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AACT,MAOE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,OAAO;AAAA,MACL,OAAO,GAAGD,CAAI;AAAA,MACd,QAAQ,GAAGA,CAAI;AAAA,MACf,cAAc,GAAGL,CAAM;AAAA,IAAA;AAAA,IAEzB,WAAWO,EAAG,oDAAoD;AAAA,MAChE,kBACEN,MAAY,WAAYE,KAAY,CAACC,KAAe,CAACD;AAAA,MACvD,kBACEF,MAAY,YAAaE,KAAY,CAACC,KAAe,CAACD;AAAA,IAAA,CACzD;AAAA,IACA,UAAAD;AAAA,EAAA;AACH,GAGWM,IAAO,CAAC;AAAA,EACnB,SAAAP;AAAA,EACA,MAAAQ;AAAA,EACA,OAAAC;AAAA,EACA,QAAAV,IAAS;AAAA,EACT,YAAAI,IAAa;AAAA,EACb,MAAAC,IAAO;AACT,MAAa;AACX,QAAM,CAACM,GAAYC,CAAa,IAAIC,EAAgB,SAAS;AAE7D,SAAI,OAAOJ,KAAS,YAAYE,MAAe,WAE3C,gBAAAL;AAAA,IAACP;AAAA,IAAA;AAAA,MACC,MAAAM;AAAA,MACA,QAAAL;AAAA,MACA,SAAAC;AAAA,MACA,YAAAG;AAAA,MACA,UAAU;AAAA,MACV,UAAA,gBAAAE,EAAC,UAAK,WAAU,oCACb,YAAM,OAAO,CAAC,EAAE,YAAA,EAAY,CAC/B;AAAA,IAAA;AAAA,EAAA,IA+BJ,gBAAAA;AAAA,IAACP;AAAA,IAAA;AAAA,MACC,MAAAM;AAAA,MACA,QAAAL;AAAA,MACA,SAAAC;AAAA,MACA,YAAAG;AAAA,MACA,UAAU,OAAOK,KAAS,YAAYE,MAAe;AAAA,MACrD,4BAhCQ,MACLF,IAQD,OAAOA,KAAS,WAEhB,gBAAAH;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,KAAKG;AAAA,UACL,KAAKC;AAAA,UACL,QAAQ,MAAME,EAAc,QAAQ;AAAA,UACpC,SAAS,MAAMA,EAAc,QAAQ;AAAA,QAAA;AAAA,MAAA,IAKpCH,IAnBH,gBAAAH,EAAC,UAAK,WAAU,oCACb,aAAO,OAAO,CAAC,EAAE,YAAA,EAAY,CAChC,GA2BD,CAAA,CAAI;AAAA,IAAA;AAAA,EAAA;AAGX;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { cn as r } from "../utils/cn.js";
|
|
3
|
+
const t = ({ className: o }) => /* @__PURE__ */ e(
|
|
4
|
+
"div",
|
|
5
|
+
{
|
|
6
|
+
className: r("animate-pulse rounded-sw-lg bg-sw-gray-800", o)
|
|
7
|
+
}
|
|
8
|
+
);
|
|
9
|
+
export {
|
|
10
|
+
t as SkeletonBox
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=SkeletonBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkeletonBox.js","sources":["../../src/components/SkeletonBox.tsx"],"sourcesContent":["import { cn } from '@/utils/cn';\n\nexport const SkeletonBox = ({ className }: { className: string }) => (\n <div\n className={cn('animate-pulse rounded-sw-lg bg-sw-gray-800', className)}\n />\n);\n"],"names":["SkeletonBox","className","jsx","cn"],"mappings":";;AAEO,MAAMA,IAAc,CAAC,EAAE,WAAAC,EAAA,MAC5B,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC,EAAG,8CAA8CF,CAAS;AAAA,EAAA;AACvE;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
const s = ({ children: e }) => /* @__PURE__ */ t("div", { className: "sw w-full h-full flex justify-center items-center", children: e });
|
|
3
|
+
export {
|
|
4
|
+
s as WidgetContainer
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=WidgetContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WidgetContainer.js","sources":["../../src/components/WidgetContainer.tsx"],"sourcesContent":["import { PropsWithChildren } from 'react';\n\nexport const WidgetContainer = ({ children }: PropsWithChildren) => {\n return (\n <div className=\"sw w-full h-full flex justify-center items-center\">\n {children}\n </div>\n );\n};\n"],"names":["WidgetContainer","children","jsx"],"mappings":";AAEO,MAAMA,IAAkB,CAAC,EAAE,UAAAC,QAE9B,gBAAAC,EAAC,OAAA,EAAI,WAAU,qDACZ,UAAAD,EAAA,CACH;"}
|
|
@@ -3,12 +3,12 @@ import Te from "i18next";
|
|
|
3
3
|
import { deepClone as M } from "valtio/utils";
|
|
4
4
|
import { useSnapshot as P, snapshot as $, proxy as ne } from "valtio";
|
|
5
5
|
import { useMemo as D, useEffect as h, useRef as O, createContext as Ie, useContext as ke } from "react";
|
|
6
|
-
import { useQuery as se, useInfiniteQuery as ge, useQueryClient as Ae, QueryClient as he, QueryClientProvider as
|
|
7
|
-
import { I18nextProvider as
|
|
6
|
+
import { useQuery as se, useInfiniteQuery as ge, useQueryClient as Ae, QueryClient as he, QueryClientProvider as ye } from "@tanstack/react-query";
|
|
7
|
+
import { I18nextProvider as we } from "react-i18next";
|
|
8
8
|
import { CHAINS_LIST as Se, DEFAULT_CHAIN_ICON as _e, DRY_QUOTE_ADDRESSES as J, CHAIN_POA_MAP as be, CHAIN_BASE_TOKENS as Ee, EVM_CHAINS as ve } from "./constants/chains.js";
|
|
9
9
|
import { ErrorBoundary as Ne } from "react-error-boundary";
|
|
10
10
|
import { derive as De } from "derive-valtio";
|
|
11
|
-
import { machine as L, moveTo as
|
|
11
|
+
import { machine as L, moveTo as w } from "./machine/machine.js";
|
|
12
12
|
import { guardStates as S } from "./machine/guards/index.js";
|
|
13
13
|
import { getUsdTradeDelta as Ce } from "./machine/computed/getUsdTradeDelta.js";
|
|
14
14
|
import { getIsDirectTransfer as qe } from "./machine/computed/getIsDirectTransfer.js";
|
|
@@ -42,7 +42,7 @@ import { depositTypeSet as Je } from "./machine/events/depositTypeSet.js";
|
|
|
42
42
|
import { walletAddressSet as Ye } from "./machine/events/walletAddressSet.js";
|
|
43
43
|
import { tokenSetBalance as et } from "./machine/events/tokenSetBalance.js";
|
|
44
44
|
import { transferSetStatus as tt } from "./machine/events/transferSetStatus.js";
|
|
45
|
-
import { OneClickService as nt, QuoteRequest as
|
|
45
|
+
import { OneClickService as nt, QuoteRequest as y } from "@defuse-protocol/one-click-sdk-typescript";
|
|
46
46
|
import { TOKENS_DATA as K, NATIVE_NEAR_DUMB_ASSET_ID as x, WNEAR_ASSET_ID as V } from "./constants/tokens.js";
|
|
47
47
|
import { isValidChain as st } from "./utils/checkers/isValidChain.js";
|
|
48
48
|
import { useWalletBalance as ce } from "./hooks/useWalletBalance.js";
|
|
@@ -82,9 +82,9 @@ const N = L.getStore(), pt = De({
|
|
|
82
82
|
const t = !e.walletAddress, s = !t && e.targetToken?.isIntent === !0, n = !t && e.targetToken?.isIntent === !1;
|
|
83
83
|
if (t) {
|
|
84
84
|
const o = oe(e);
|
|
85
|
-
return
|
|
85
|
+
return w(o ? "input_valid_dry" : "initial_dry");
|
|
86
86
|
}
|
|
87
|
-
n && re(e) ?
|
|
87
|
+
n && re(e) ? w("input_valid_external") : s && ae(e) ? w("input_valid_internal") : w("initial_wallet");
|
|
88
88
|
}, It = (e, t) => {
|
|
89
89
|
const { config: s } = $(z);
|
|
90
90
|
return e.targetToken && !e.sendAddress && !!e.walletAddress && !e.targetToken.isIntent && !t.find((n) => n?.key === "sendAddress") && s.walletSupportedChains.includes(e.targetToken.blockchain);
|
|
@@ -94,14 +94,14 @@ const N = L.getStore(), pt = De({
|
|
|
94
94
|
if (e && _.debug("[WIDGET] Context changed", n), e && t.error && Pe(n) && _.debug(`[WIDGET] Error set to ${t.error.code}`), We(n) || $e(t, n, e))
|
|
95
95
|
return;
|
|
96
96
|
if (Me(t, n)) {
|
|
97
|
-
d("reset", null),
|
|
97
|
+
d("reset", null), w("initial_dry");
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
const { isChanged: o, isDry: r } = Qe(t, n);
|
|
101
101
|
if (o) {
|
|
102
102
|
if (Re(t)) {
|
|
103
103
|
const u = r ? "initial_dry" : "initial_wallet";
|
|
104
|
-
|
|
104
|
+
w(u, {
|
|
105
105
|
onMoved: () => {
|
|
106
106
|
e && _.debug(
|
|
107
107
|
`[WIDGET] Inputs changed. State moved to ${u}`
|
|
@@ -146,10 +146,10 @@ const N = L.getStore(), pt = De({
|
|
|
146
146
|
L.on(e, (s, n) => t(s, n));
|
|
147
147
|
}, ht = () => {
|
|
148
148
|
g("quoteSetStatus", Ze), g("walletAddressSet", Ye), g("transferSetStatus", tt), g("tokenSelectRotate", F), g("tokenSetBalance", et), g("tokenSetAmount", Xe), g("depositTypeSet", Je), g("tokenSelect", At), g("addressSet", ze), g("errorSet", He), g("quoteSet", je), g("reset", Ke), g("validateDryInputs", oe), g("validateExternalInputs", re), g("validateInternalInputs", ae);
|
|
149
|
-
},
|
|
149
|
+
}, yt = (e) => {
|
|
150
150
|
const t = e.symbol.toLowerCase();
|
|
151
151
|
return K[t]?.icon ?? "";
|
|
152
|
-
}, Y = (e) => Se[e].icon ?? _e,
|
|
152
|
+
}, Y = (e) => Se[e].icon ?? _e, wt = (e) => `${e.blockchain?.charAt(0).toUpperCase()}${e.blockchain?.slice(1)}`, St = (e) => K[e.symbol]?.name ?? e.symbol, W = (e) => {
|
|
153
153
|
const {
|
|
154
154
|
showIntentTokens: t,
|
|
155
155
|
allowedTokensList: s,
|
|
@@ -168,10 +168,10 @@ const N = L.getStore(), pt = De({
|
|
|
168
168
|
...a,
|
|
169
169
|
blockchain: T,
|
|
170
170
|
isIntent: !1,
|
|
171
|
-
icon:
|
|
171
|
+
icon: yt(a),
|
|
172
172
|
name: St(a),
|
|
173
173
|
chainIcon: Y(T),
|
|
174
|
-
chainName:
|
|
174
|
+
chainName: wt(a),
|
|
175
175
|
contractAddress: a.contractAddress
|
|
176
176
|
};
|
|
177
177
|
}).filter((a) => !!a).filter(r ?? (() => !0)), m = c.filter(
|
|
@@ -362,7 +362,7 @@ const N = L.getStore(), pt = De({
|
|
|
362
362
|
h(() => {
|
|
363
363
|
if (!e)
|
|
364
364
|
return;
|
|
365
|
-
d("walletAddressSet", t ?? void 0), S(s, ["initial_dry", "initial_wallet"]) && (n === "initial_wallet" && !t ?
|
|
365
|
+
d("walletAddressSet", t ?? void 0), S(s, ["initial_dry", "initial_wallet"]) && (n === "initial_wallet" && !t ? w("initial_dry") : n === "initial_dry" && t && w("initial_wallet"));
|
|
366
366
|
}, [e, t, s, n]);
|
|
367
367
|
}, Dt = () => {
|
|
368
368
|
const { ctx: e } = b(), { intentsAccountType: t, oneClickApiQuoteProxyUrl: s, appName: n } = v(), o = !e.walletAddress, r = H({
|
|
@@ -404,7 +404,7 @@ const N = L.getStore(), pt = De({
|
|
|
404
404
|
// 1%
|
|
405
405
|
deadline: new Date(Date.now() + 3600 * 1e3).toISOString(),
|
|
406
406
|
// 1 hour
|
|
407
|
-
swapType: T === "exact_out" ?
|
|
407
|
+
swapType: T === "exact_out" ? y.swapType.EXACT_OUTPUT : y.swapType.EXACT_INPUT,
|
|
408
408
|
// Target
|
|
409
409
|
destinationAsset: e.targetToken.assetId === x ? V : e.targetToken.assetId,
|
|
410
410
|
// Source
|
|
@@ -416,19 +416,19 @@ const N = L.getStore(), pt = De({
|
|
|
416
416
|
e.sourceToken.isIntent && e.targetToken.isIntent && (u.current = c({
|
|
417
417
|
...k,
|
|
418
418
|
recipient: r,
|
|
419
|
-
recipientType:
|
|
420
|
-
depositType:
|
|
419
|
+
recipientType: y.recipientType.INTENTS,
|
|
420
|
+
depositType: y.depositType.INTENTS,
|
|
421
421
|
// Refund
|
|
422
422
|
refundTo: r,
|
|
423
|
-
refundType:
|
|
423
|
+
refundType: y.refundType.INTENTS
|
|
424
424
|
}), I = (await u.current).data), u.current = c({
|
|
425
425
|
...k,
|
|
426
426
|
recipient: !e.targetToken.isIntent && e.sendAddress ? e.sendAddress : r,
|
|
427
|
-
recipientType: e.targetToken.isIntent ?
|
|
428
|
-
depositType: e.sourceToken.isIntent ?
|
|
427
|
+
recipientType: e.targetToken.isIntent ? y.recipientType.INTENTS : y.recipientType.DESTINATION_CHAIN,
|
|
428
|
+
depositType: e.sourceToken.isIntent ? y.depositType.INTENTS : y.depositType.ORIGIN_CHAIN,
|
|
429
429
|
// Refund
|
|
430
430
|
refundTo: e.sourceToken.isIntent ? r : m,
|
|
431
|
-
refundType: e.sourceToken.isIntent ?
|
|
431
|
+
refundType: e.sourceToken.isIntent ? y.refundType.INTENTS : y.refundType.ORIGIN_CHAIN
|
|
432
432
|
}), I = (await u.current).data;
|
|
433
433
|
} catch (p) {
|
|
434
434
|
if (p instanceof le)
|
|
@@ -620,10 +620,10 @@ const N = L.getStore(), pt = De({
|
|
|
620
620
|
variant: "target",
|
|
621
621
|
amount: f.amountOut
|
|
622
622
|
}), n.state === "input_valid_dry") {
|
|
623
|
-
|
|
623
|
+
w("quote_success_dry");
|
|
624
624
|
return;
|
|
625
625
|
}
|
|
626
|
-
n.targetToken?.isIntent ?
|
|
626
|
+
n.targetToken?.isIntent ? w("quote_success_internal") : w("quote_success_external");
|
|
627
627
|
}
|
|
628
628
|
} catch (f) {
|
|
629
629
|
if (f instanceof A) {
|
|
@@ -889,7 +889,7 @@ const Yn = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e
|
|
|
889
889
|
...t
|
|
890
890
|
});
|
|
891
891
|
Object.assign(n.current.config, o), Mt(o);
|
|
892
|
-
}, [t]), Ge(s ?? {}), Ve("headlessui-portal-root", "sw"), /* @__PURE__ */ q(
|
|
892
|
+
}, [t]), Ge(s ?? {}), Ve("headlessui-portal-root", "sw"), /* @__PURE__ */ q(ye, { client: Wt, children: /* @__PURE__ */ q(we, { i18n: Te, children: /* @__PURE__ */ q(pe.Provider, { value: n.current, children: /* @__PURE__ */ q(Pt, { children: e }) }) }) });
|
|
893
893
|
};
|
|
894
894
|
export {
|
|
895
895
|
Lt as A,
|
|
@@ -926,4 +926,4 @@ export {
|
|
|
926
926
|
qt as y,
|
|
927
927
|
Ot as z
|
|
928
928
|
};
|
|
929
|
-
//# sourceMappingURL=config-
|
|
929
|
+
//# sourceMappingURL=config-haLfG4Cu.js.map
|