@aurora-is-near/intents-swap-widget 2.6.0 → 2.6.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/components/InputAmount.d.ts +2 -2
- package/dist/{config-DN8VJllh.js → config-Dq9mlDST.js} +101 -103
- package/dist/{config-DN8VJllh.js.map → config-Dq9mlDST.js.map} +1 -1
- package/dist/config.d.ts +6 -31
- package/dist/config.js +4 -6
- package/dist/errors.js +1 -1
- package/dist/ext/alchemy/index.d.ts +1 -1
- package/dist/ext/alchemy/index.js +1 -1
- package/dist/ext/index.js +1 -1
- package/dist/features/BalanceRpcLoader/index.js +4 -4
- package/dist/features/BalanceRpcLoader/useTokenBalanceRpc.js +3 -3
- package/dist/features/ChainsDropdown/index.js +9 -9
- 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 +5 -5
- 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 +7 -7
- 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/TokenInput/utils/getPercentageDeltaColor.d.ts +1 -1
- package/dist/features/TokensList/TokenItem.js +4 -4
- package/dist/features/TokensList/TokensList.js +10 -10
- package/dist/features/TokensModal.js +4 -4
- package/dist/features/WalletCompatibilityCheck/index.js +7 -7
- 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 +2 -2
- 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.d.ts +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.d.ts +1 -0
- package/dist/index.js +109 -108
- 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/types/config.d.ts +25 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/utils/intents/signers/near.js +1 -1
- package/dist/utils/intents/signers/privy.js +1 -1
- package/dist/utils/near/getNearNep141StorageBalance.js +4 -4
- package/dist/widgets/WidgetDeposit.js +5 -5
- package/dist/widgets/WidgetSwap.js +7 -7
- package/dist/widgets/WidgetWithdraw.js +5 -5
- package/package.json +1 -1
- package/src/config.tsx +9 -44
- package/src/index.ts +2 -0
- package/src/machine/effects/useSelectedTokensEffect.ts +1 -1
- package/src/types/config.ts +37 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { InputElement } from 'imask';
|
|
2
2
|
import { IMaskMixinProps } from 'react-imask';
|
|
3
3
|
import { Props as InputProps } from './Input';
|
|
4
|
-
export declare const MaskedInputAmount: import('react').ForwardRefExoticComponent<(IMaskMixinProps<InputElement> & Omit<InputProps, "
|
|
4
|
+
export declare const MaskedInputAmount: import('react').ForwardRefExoticComponent<(IMaskMixinProps<InputElement> & Omit<InputProps, "children" | "className"> & {
|
|
5
5
|
rawValue: string;
|
|
6
|
-
}) & import('react').RefAttributes<import('react').ComponentType<IMaskMixinProps<InputElement> & Omit<InputProps, "
|
|
6
|
+
}) & import('react').RefAttributes<import('react').ComponentType<IMaskMixinProps<InputElement> & Omit<InputProps, "children" | "className"> & {
|
|
7
7
|
rawValue: string;
|
|
8
8
|
}>>>;
|
|
9
9
|
export declare const InputAmount: ({ value, setValue, ...props }: Omit<InputProps, "value"> & {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { jsx as q } from "react/jsx-runtime";
|
|
2
2
|
import Te from "i18next";
|
|
3
3
|
import { deepClone as M } from "valtio/utils";
|
|
4
|
-
import { useSnapshot as P, snapshot as
|
|
5
|
-
import { useMemo as
|
|
4
|
+
import { useSnapshot as P, snapshot as $, proxy as ne } from "valtio";
|
|
5
|
+
import { useMemo as D, useEffect as h, useRef as O, createContext as Ie, useContext as ke } from "react";
|
|
6
6
|
import { useQuery as se, useInfiniteQuery as ge, useQueryClient as Ae, QueryClient as he, QueryClientProvider as we } from "@tanstack/react-query";
|
|
7
7
|
import { I18nextProvider as ye } from "react-i18next";
|
|
8
|
-
import { CHAINS_LIST as Se, DEFAULT_CHAIN_ICON as
|
|
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
|
-
import { derive as
|
|
11
|
-
import { machine as
|
|
10
|
+
import { derive as De } from "derive-valtio";
|
|
11
|
+
import { machine as L, moveTo as y } from "./machine/machine.js";
|
|
12
12
|
import { guardStates as S } from "./machine/guards/index.js";
|
|
13
|
-
import { getUsdTradeDelta as
|
|
13
|
+
import { getUsdTradeDelta as Ce } from "./machine/computed/getUsdTradeDelta.js";
|
|
14
14
|
import { getIsDirectTransfer as qe } from "./machine/computed/getIsDirectTransfer.js";
|
|
15
15
|
import { getIsDirectNonNearWithdrawal as Oe } from "./machine/computed/getIsDirectNonNearWithdrawal.js";
|
|
16
|
-
import { getIsNearToIntentsSameAssetTransfer as
|
|
16
|
+
import { getIsNearToIntentsSameAssetTransfer as Le } from "./machine/computed/getIsNearToIntentsSameAssetTransfer.js";
|
|
17
17
|
import { getIsDirectNearDeposit as Be } from "./machine/computed/getIsDirectNearDeposit.js";
|
|
18
18
|
import "ethers";
|
|
19
|
-
import
|
|
20
|
-
import { logger as
|
|
19
|
+
import xe from "lodash.once";
|
|
20
|
+
import { logger as _ } from "./logger.js";
|
|
21
21
|
import { fireEvent as d } from "./machine/events/utils/fireEvent.js";
|
|
22
22
|
import { validateDryInputs as oe, validateExternalInputs as re, validateInternalInputs as ae } from "./machine/events/validateInputs.js";
|
|
23
23
|
import { isQuoteIdle as Ue } from "./machine/subscriptions/checkers/isQuoteIdle.js";
|
|
@@ -26,12 +26,12 @@ import { isErrorChanged as Pe } from "./machine/subscriptions/checkers/isErrorCh
|
|
|
26
26
|
import { isOnlyErrorChanged as We } from "./machine/subscriptions/checkers/isOnlyErrorChanged.js";
|
|
27
27
|
import { isValidInitialState as Re } from "./machine/subscriptions/checkers/isValidInitialState.js";
|
|
28
28
|
import { isWalletDisconnected as Me } from "./machine/subscriptions/checkers/isWalletDisconnected.js";
|
|
29
|
-
import { isSendAddressForbidden as
|
|
30
|
-
import { useAddClassToPortal as
|
|
31
|
-
import { initLocalisation as
|
|
32
|
-
import { isAmountChangedFromQuote as
|
|
29
|
+
import { isSendAddressForbidden as Fe } from "./machine/subscriptions/checkers/isSendAddressForbidden.js";
|
|
30
|
+
import { useAddClassToPortal as Ve } from "./hooks/useAddClassToPortal.js";
|
|
31
|
+
import { initLocalisation as Ge } from "./localisation.js";
|
|
32
|
+
import { isAmountChangedFromQuote as $e } from "./machine/subscriptions/checkers/isAmountChangedFromQuote.js";
|
|
33
33
|
import { reset as Ke } from "./machine/events/reset.js";
|
|
34
|
-
import { tokenSelectRotate as
|
|
34
|
+
import { tokenSelectRotate as F } from "./machine/events/tokenSelectRotate.js";
|
|
35
35
|
import { errorSet as He } from "./machine/events/errorSet.js";
|
|
36
36
|
import { quoteSet as je } from "./machine/events/quoteSet.js";
|
|
37
37
|
import { addressSet as ze } from "./machine/events/addressSet.js";
|
|
@@ -43,7 +43,7 @@ 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
45
|
import { OneClickService as nt, QuoteRequest as w } from "@defuse-protocol/one-click-sdk-typescript";
|
|
46
|
-
import { TOKENS_DATA as K, NATIVE_NEAR_DUMB_ASSET_ID as
|
|
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";
|
|
49
49
|
import { parse as ot } from "./ext/alchemy/parse.js";
|
|
@@ -54,18 +54,18 @@ import { getIntentsBalances as it } from "./utils/intents/getIntentsBalance.js";
|
|
|
54
54
|
import { getTokenBalanceKey as ct } from "./utils/intents/getTokenBalanceKey.js";
|
|
55
55
|
import { snakeCase as lt } from "change-case";
|
|
56
56
|
import { CanceledError as le, AxiosError as de } from "axios";
|
|
57
|
-
import { oneClickApi as
|
|
57
|
+
import { oneClickApi as G, bridgeApi as dt } from "./network.js";
|
|
58
58
|
import { formatBigToHuman as B } from "./utils/formatters/formatBigToHuman.js";
|
|
59
59
|
import { getMainTokenByChain as ut } from "./utils/tokens/getMainTokenByChain.js";
|
|
60
60
|
import { getDefaultIntentsToken as ft } from "./utils/tokens/getDefaultIntentsToken.js";
|
|
61
61
|
import { getTokenWithHighBalance as mt } from "./utils/tokens/getTokenWithHighBalance.js";
|
|
62
|
-
const N =
|
|
63
|
-
usdTradeDelta: (e) =>
|
|
62
|
+
const N = L.getStore(), pt = De({
|
|
63
|
+
usdTradeDelta: (e) => Ce(e(N.context)),
|
|
64
64
|
isDirectTransfer: (e) => qe(e(N.context)),
|
|
65
|
-
isNearToIntentsSameAssetTransfer: (e) =>
|
|
65
|
+
isNearToIntentsSameAssetTransfer: (e) => Le(e(N.context)),
|
|
66
66
|
isDirectNearDeposit: (e) => Be(e(N.context)),
|
|
67
67
|
isDirectNonNearWithdrawal: (e) => Oe(e(N.context))
|
|
68
|
-
}), Tt = () => P(pt),
|
|
68
|
+
}), Tt = () => P(pt), b = () => {
|
|
69
69
|
const e = P(N);
|
|
70
70
|
return {
|
|
71
71
|
state: e.state,
|
|
@@ -86,12 +86,12 @@ const N = x.getStore(), pt = Ce({
|
|
|
86
86
|
}
|
|
87
87
|
n && re(e) ? y("input_valid_external") : s && ae(e) ? y("input_valid_internal") : y("initial_wallet");
|
|
88
88
|
}, It = (e, t) => {
|
|
89
|
-
const { config: s } =
|
|
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);
|
|
91
91
|
}, kt = ({ debug: e }) => {
|
|
92
|
-
|
|
92
|
+
L.onContextChange((t, s) => {
|
|
93
93
|
const n = s;
|
|
94
|
-
if (e &&
|
|
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
97
|
d("reset", null), y("initial_dry");
|
|
@@ -103,27 +103,27 @@ const N = x.getStore(), pt = Ce({
|
|
|
103
103
|
const u = r ? "initial_dry" : "initial_wallet";
|
|
104
104
|
y(u, {
|
|
105
105
|
onMoved: () => {
|
|
106
|
-
e &&
|
|
106
|
+
e && _.debug(
|
|
107
107
|
`[WIDGET] Inputs changed. State moved to ${u}`
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
Ue(t) || (t.quote = void 0, t.quoteStatus = "idle", t.transferStatus = { status: "idle" }),
|
|
112
|
+
Ue(t) || (t.quote = void 0, t.quoteStatus = "idle", t.transferStatus = { status: "idle" }), Fe(t) && (t.sendAddress = void 0), It(t, n) && (t.sendAddress = t.walletAddress), ue(t);
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
}, gt = ({ debug: e }) => {
|
|
116
|
-
|
|
117
|
-
e &&
|
|
116
|
+
L.onTransition((t, s) => {
|
|
117
|
+
e && _.debug(`===> [WIDGET] State moved from ${t} to ${s}`);
|
|
118
118
|
});
|
|
119
119
|
}, At = (e, t) => {
|
|
120
|
-
const { variant: s, token: n } = t, { config: o } =
|
|
120
|
+
const { variant: s, token: n } = t, { config: o } = $(z);
|
|
121
121
|
switch (s) {
|
|
122
122
|
case "source":
|
|
123
123
|
if (n && n.assetId === e.targetToken?.assetId && n.isIntent === e.targetToken.isIntent && o.enableAutoTokensSwitching) {
|
|
124
124
|
if (!e.sourceToken)
|
|
125
125
|
return;
|
|
126
|
-
|
|
126
|
+
F(e);
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
if (n && !e.sourceToken && n.assetId === e.targetToken?.assetId && n.isIntent === e.targetToken.isIntent && o.enableAutoTokensSwitching)
|
|
@@ -134,7 +134,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
134
134
|
if (n && n.assetId === e.sourceToken?.assetId && n.isIntent === e.sourceToken.isIntent && o.enableAutoTokensSwitching) {
|
|
135
135
|
if (!e.targetToken)
|
|
136
136
|
return;
|
|
137
|
-
|
|
137
|
+
F(e);
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
e.targetToken = n;
|
|
@@ -143,13 +143,13 @@ const N = x.getStore(), pt = Ce({
|
|
|
143
143
|
ie(s, { throwError: !1 });
|
|
144
144
|
}
|
|
145
145
|
}, g = (e, t) => {
|
|
146
|
-
|
|
146
|
+
L.on(e, (s, n) => t(s, n));
|
|
147
147
|
}, ht = () => {
|
|
148
|
-
g("quoteSetStatus", Ze), g("walletAddressSet", Ye), g("transferSetStatus", tt), g("tokenSelectRotate",
|
|
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
|
}, wt = (e) => {
|
|
150
150
|
const t = e.symbol.toLowerCase();
|
|
151
151
|
return K[t]?.icon ?? "";
|
|
152
|
-
}, Y = (e) => Se[e].icon ??
|
|
152
|
+
}, Y = (e) => Se[e].icon ?? _e, yt = (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,
|
|
@@ -159,7 +159,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
159
159
|
} = v(), u = se({
|
|
160
160
|
queryKey: ["tokens"],
|
|
161
161
|
queryFn: async () => await nt.getTokens()
|
|
162
|
-
}), i =
|
|
162
|
+
}), i = D(() => {
|
|
163
163
|
if (!u.data)
|
|
164
164
|
return [];
|
|
165
165
|
const c = u.data.map((a) => {
|
|
@@ -182,7 +182,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
182
182
|
symbol: "NEAR",
|
|
183
183
|
chainName: "Near",
|
|
184
184
|
blockchain: "near",
|
|
185
|
-
assetId:
|
|
185
|
+
assetId: x,
|
|
186
186
|
chainIcon: Y("near"),
|
|
187
187
|
icon: K.near?.icon ?? "",
|
|
188
188
|
price: l?.price ?? 0,
|
|
@@ -206,7 +206,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
206
206
|
alchemyApiKey: t,
|
|
207
207
|
...s
|
|
208
208
|
}) => {
|
|
209
|
-
const { ctx: n } =
|
|
209
|
+
const { ctx: n } = b(), { tokens: o } = W(), { walletSupportedChains: r } = v(), { setWalletBalance: u } = ce(n.walletAddress), i = s.isEnabled && !!e && r.length > 0, c = ge({
|
|
210
210
|
initialPageParam: null,
|
|
211
211
|
enabled: i && !!e && !!t,
|
|
212
212
|
queryKey: ["walletTokensBalance", e],
|
|
@@ -223,7 +223,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
223
223
|
h(() => {
|
|
224
224
|
i && c.data && c.hasNextPage && c.data.pages.length < ee && !c.isFetchingNextPage && c.fetchNextPage();
|
|
225
225
|
}, [i, c]);
|
|
226
|
-
const m =
|
|
226
|
+
const m = D(() => {
|
|
227
227
|
if (!c.data?.pages)
|
|
228
228
|
return {};
|
|
229
229
|
const l = ot(
|
|
@@ -249,10 +249,10 @@ const N = x.getStore(), pt = Ce({
|
|
|
249
249
|
enabled: !!e && !!o && s.length > 0,
|
|
250
250
|
queryKey: ["intentsBalances", o],
|
|
251
251
|
queryFn: async () => o ? await it(o, n) : {}
|
|
252
|
-
}), u =
|
|
252
|
+
}), u = D(() => {
|
|
253
253
|
switch (r.status) {
|
|
254
254
|
case "error":
|
|
255
|
-
return
|
|
255
|
+
return _.error("Unable to load intents balances:", r.error), {};
|
|
256
256
|
case "success":
|
|
257
257
|
return Object.fromEntries(
|
|
258
258
|
Object.entries(r.data).map(([i, c]) => [
|
|
@@ -270,11 +270,11 @@ const N = x.getStore(), pt = Ce({
|
|
|
270
270
|
...r,
|
|
271
271
|
intentBalances: u
|
|
272
272
|
};
|
|
273
|
-
},
|
|
273
|
+
}, _t = ({
|
|
274
274
|
isEnabled: e,
|
|
275
275
|
alchemyApiKey: t
|
|
276
276
|
}) => {
|
|
277
|
-
const { ctx: s } =
|
|
277
|
+
const { ctx: s } = b(), n = Ae(), { refetch: o } = j(), { refetch: r } = fe({
|
|
278
278
|
isEnabled: e,
|
|
279
279
|
walletAddress: s.walletAddress,
|
|
280
280
|
alchemyApiKey: t ?? ""
|
|
@@ -285,14 +285,14 @@ const N = x.getStore(), pt = Ce({
|
|
|
285
285
|
setTimeout(i, 1e4);
|
|
286
286
|
}), await r()), await n.invalidateQueries({ queryKey: ["tokenBalance"] })))();
|
|
287
287
|
}, [s.state, e, t]);
|
|
288
|
-
},
|
|
288
|
+
}, bt = () => {
|
|
289
289
|
const { walletAddress: e } = v(), { intentBalances: t } = j(), { walletBalance: s } = ce(e);
|
|
290
|
-
return { mergedBalance:
|
|
290
|
+
return { mergedBalance: D(
|
|
291
291
|
() => ({ ...s, ...t }),
|
|
292
292
|
[s, t]
|
|
293
293
|
) };
|
|
294
294
|
}, Et = ({ isEnabled: e }) => {
|
|
295
|
-
const { ctx: t } =
|
|
295
|
+
const { ctx: t } = b(), { mergedBalance: s } = bt();
|
|
296
296
|
h(() => {
|
|
297
297
|
if (!e)
|
|
298
298
|
return;
|
|
@@ -321,7 +321,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
321
321
|
}, vt = ({
|
|
322
322
|
isEnabled: e
|
|
323
323
|
}) => {
|
|
324
|
-
const { ctx: t } =
|
|
324
|
+
const { ctx: t } = b(), { tokens: s } = W();
|
|
325
325
|
h(() => {
|
|
326
326
|
if (!e)
|
|
327
327
|
return;
|
|
@@ -358,23 +358,23 @@ const N = x.getStore(), pt = Ce({
|
|
|
358
358
|
});
|
|
359
359
|
}, [s, t.sourceToken]);
|
|
360
360
|
}, Nt = ({ isEnabled: e }) => {
|
|
361
|
-
const { walletAddress: t } = v(), { ctx: s, state: n } =
|
|
361
|
+
const { walletAddress: t } = v(), { ctx: s, state: n } = b();
|
|
362
362
|
h(() => {
|
|
363
363
|
if (!e)
|
|
364
364
|
return;
|
|
365
365
|
d("walletAddressSet", t ?? void 0), S(s, ["initial_dry", "initial_wallet"]) && (n === "initial_wallet" && !t ? y("initial_dry") : n === "initial_dry" && t && y("initial_wallet"));
|
|
366
366
|
}, [e, t, s, n]);
|
|
367
|
-
},
|
|
368
|
-
const { ctx: e } =
|
|
367
|
+
}, Dt = () => {
|
|
368
|
+
const { ctx: e } = b(), { intentsAccountType: t, oneClickApiQuoteProxyUrl: s, appName: n } = v(), o = !e.walletAddress, r = H({
|
|
369
369
|
addressType: t,
|
|
370
370
|
walletAddress: o ? J[t] : e.walletAddress ?? ""
|
|
371
|
-
}), u = O(null), i = O(new AbortController()), c =
|
|
371
|
+
}), u = O(null), i = O(new AbortController()), c = D(() => async (a) => G.post(
|
|
372
372
|
s,
|
|
373
373
|
a,
|
|
374
374
|
{
|
|
375
375
|
signal: i.current.signal
|
|
376
376
|
}
|
|
377
|
-
), [s,
|
|
377
|
+
), [s, G]), m = o ? J[t] : e.walletAddress ?? "";
|
|
378
378
|
return {
|
|
379
379
|
make: async ({ message: a, quoteType: T = "exact_in" } = {}) => {
|
|
380
380
|
if (!S(e, [
|
|
@@ -383,14 +383,14 @@ const N = x.getStore(), pt = Ce({
|
|
|
383
383
|
"input_valid_internal"
|
|
384
384
|
])) {
|
|
385
385
|
const p = `Unable to run quote in current state ${e.state}`;
|
|
386
|
-
throw
|
|
386
|
+
throw _.error(`[WIDGET] ${p}`), new A({
|
|
387
387
|
code: "QUOTE_INVALID_INITIAL",
|
|
388
388
|
meta: { isDry: o, message: p }
|
|
389
389
|
});
|
|
390
390
|
}
|
|
391
391
|
if (!r) {
|
|
392
392
|
const p = "No corresponding intents account to run a quote";
|
|
393
|
-
throw
|
|
393
|
+
throw _.error(`[WIDGET] ${p}`), new A({
|
|
394
394
|
code: "QUOTE_INVALID_INITIAL",
|
|
395
395
|
meta: { isDry: o, message: p }
|
|
396
396
|
});
|
|
@@ -406,9 +406,9 @@ const N = x.getStore(), pt = Ce({
|
|
|
406
406
|
// 1 hour
|
|
407
407
|
swapType: T === "exact_out" ? w.swapType.EXACT_OUTPUT : w.swapType.EXACT_INPUT,
|
|
408
408
|
// Target
|
|
409
|
-
destinationAsset: e.targetToken.assetId ===
|
|
409
|
+
destinationAsset: e.targetToken.assetId === x ? V : e.targetToken.assetId,
|
|
410
410
|
// Source
|
|
411
|
-
originAsset: e.sourceToken.assetId ===
|
|
411
|
+
originAsset: e.sourceToken.assetId === x ? V : e.sourceToken.assetId,
|
|
412
412
|
amount: T === "exact_out" ? e.targetTokenAmount : e.sourceTokenAmount
|
|
413
413
|
};
|
|
414
414
|
a && (k.customRecipientMsg = a), n && (k.referral = lt(n));
|
|
@@ -484,11 +484,11 @@ const N = x.getStore(), pt = Ce({
|
|
|
484
484
|
i.current.abort("Abort quote manually"), i.current = new AbortController();
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
|
-
},
|
|
488
|
-
const { ctx: e } =
|
|
487
|
+
}, Ct = () => {
|
|
488
|
+
const { ctx: e } = b(), { intentsAccountType: t, oneClickApiQuoteProxyUrl: s } = v(), n = H({
|
|
489
489
|
addressType: t,
|
|
490
490
|
walletAddress: e.walletAddress ?? ""
|
|
491
|
-
}), o = O(null), r = O(new AbortController()), u =
|
|
491
|
+
}), o = O(null), r = O(new AbortController()), u = D(() => async (c) => dt.post(
|
|
492
492
|
"",
|
|
493
493
|
{
|
|
494
494
|
id: 1,
|
|
@@ -504,7 +504,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
504
504
|
{
|
|
505
505
|
signal: r.current.signal
|
|
506
506
|
}
|
|
507
|
-
), [s,
|
|
507
|
+
), [s, G]);
|
|
508
508
|
return {
|
|
509
509
|
make: async () => {
|
|
510
510
|
if (!S(e, [
|
|
@@ -513,7 +513,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
513
513
|
"input_valid_internal"
|
|
514
514
|
])) {
|
|
515
515
|
const l = `Unable to run quote in current state ${e.state}`;
|
|
516
|
-
throw
|
|
516
|
+
throw _.error(`[WIDGET] ${l}`), new A({
|
|
517
517
|
code: "QUOTE_INVALID_INITIAL",
|
|
518
518
|
meta: { isDry: !1, message: l }
|
|
519
519
|
});
|
|
@@ -536,13 +536,13 @@ const N = x.getStore(), pt = Ce({
|
|
|
536
536
|
});
|
|
537
537
|
if (!n) {
|
|
538
538
|
const l = "No corresponding intents account to run a quote";
|
|
539
|
-
throw
|
|
539
|
+
throw _.error(`[WIDGET] ${l}`), new A({
|
|
540
540
|
code: "QUOTE_INVALID_INITIAL",
|
|
541
541
|
meta: { isDry: !1, message: l }
|
|
542
542
|
});
|
|
543
543
|
}
|
|
544
544
|
o.current && (r.current.abort("Abort previous quote (auto)"), r.current = new AbortController());
|
|
545
|
-
const m =
|
|
545
|
+
const m = be[e.targetToken.blockchain];
|
|
546
546
|
if (!m)
|
|
547
547
|
throw new A({
|
|
548
548
|
code: "QUOTE_INVALID_INITIAL",
|
|
@@ -574,7 +574,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
574
574
|
} catch (l) {
|
|
575
575
|
if (l instanceof le)
|
|
576
576
|
return;
|
|
577
|
-
if (
|
|
577
|
+
if (_.error(l), l instanceof de) {
|
|
578
578
|
const a = l.response?.data.message || l.message;
|
|
579
579
|
throw new A({
|
|
580
580
|
code: "QUOTE_FAILED",
|
|
@@ -594,19 +594,19 @@ const N = x.getStore(), pt = Ce({
|
|
|
594
594
|
message: t,
|
|
595
595
|
type: s = "exact_in"
|
|
596
596
|
}) => {
|
|
597
|
-
const { ctx: n } =
|
|
597
|
+
const { ctx: n } = b(), {
|
|
598
598
|
isDirectTransfer: o,
|
|
599
599
|
isDirectNonNearWithdrawal: r,
|
|
600
600
|
isNearToIntentsSameAssetTransfer: u,
|
|
601
601
|
isDirectNearDeposit: i
|
|
602
|
-
} = Tt(), c = !n.walletAddress, m = e && !o && !r && !u && !i, { make: l, cancel: a } =
|
|
603
|
-
a(),
|
|
602
|
+
} = Tt(), c = !n.walletAddress, m = e && !o && !r && !u && !i, { make: l, cancel: a } = Dt(), { make: T, cancel: C } = Ct(), I = () => {
|
|
603
|
+
a(), C();
|
|
604
604
|
};
|
|
605
605
|
h(() => {
|
|
606
606
|
const k = S(n, ["input_valid_dry"]), f = S(n, ["input_valid_external"]), p = S(n, ["input_valid_internal"]);
|
|
607
607
|
(c && !k || !c && n.targetToken?.isIntent && !p || !c && !n.targetToken?.isIntent && !f) && I();
|
|
608
608
|
}, [I, c, n]), h(() => {
|
|
609
|
-
if (!m || n.sourceToken?.assetId ===
|
|
609
|
+
if (!m || n.sourceToken?.assetId === x && n.targetToken?.assetId === V)
|
|
610
610
|
return;
|
|
611
611
|
const k = c ? n.state === "input_valid_dry" : n.state === "input_valid_external" && !n.targetToken?.isIntent || n.state === "input_valid_internal" && n.targetToken?.isIntent;
|
|
612
612
|
(async () => {
|
|
@@ -650,7 +650,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
650
650
|
skipIntents: t = !1,
|
|
651
651
|
target: s = "none"
|
|
652
652
|
}) => {
|
|
653
|
-
const { tokens: n } = W(), { ctx: o, state: r } =
|
|
653
|
+
const { tokens: n } = W(), { ctx: o, state: r } = b(), { intentBalances: u } = j(), {
|
|
654
654
|
walletSupportedChains: i,
|
|
655
655
|
chainsFilter: c,
|
|
656
656
|
walletAddress: m,
|
|
@@ -660,7 +660,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
660
660
|
walletSupportedChains: i,
|
|
661
661
|
balances: u,
|
|
662
662
|
across: "intents"
|
|
663
|
-
}), [T,
|
|
663
|
+
}), [T, C] = D(() => !m && !t ? [
|
|
664
664
|
{ token: ft({ tokens: n }), status: "loaded" },
|
|
665
665
|
{ token: void 0, status: "loaded" }
|
|
666
666
|
] : c.source.intents !== "none" && !t ? a ? [
|
|
@@ -690,8 +690,8 @@ const N = x.getStore(), pt = Ce({
|
|
|
690
690
|
if (S(o, ["initial_dry", "initial_wallet"]) && (T.status === "loaded" && !o.sourceToken && d("tokenSelect", {
|
|
691
691
|
variant: "source",
|
|
692
692
|
token: T.token
|
|
693
|
-
}),
|
|
694
|
-
let k =
|
|
693
|
+
}), C.status === "loaded" && T.status === "loaded" && !o.targetToken)) {
|
|
694
|
+
let k = C.token;
|
|
695
695
|
s === "same-asset" && (T.token?.isIntent ? k = n.find(
|
|
696
696
|
(f) => !f.isIntent && f.symbol === o.sourceToken?.symbol && f.blockchain === R[l]
|
|
697
697
|
) : k = n.find(
|
|
@@ -701,7 +701,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
701
701
|
token: k
|
|
702
702
|
});
|
|
703
703
|
}
|
|
704
|
-
}, [o, T,
|
|
704
|
+
}, [o, T, C, e]), h(() => {
|
|
705
705
|
const I = S(o, ["initial_dry", "initial_wallet"]);
|
|
706
706
|
if (!e || !I)
|
|
707
707
|
return;
|
|
@@ -730,18 +730,18 @@ const N = x.getStore(), pt = Ce({
|
|
|
730
730
|
}, 3e3);
|
|
731
731
|
return () => clearTimeout(f);
|
|
732
732
|
}, [n, T, t]), { source: o.sourceToken, target: o.targetToken };
|
|
733
|
-
},
|
|
733
|
+
}, Lt = ({
|
|
734
734
|
isEnabled: e,
|
|
735
735
|
alchemyApiKey: t
|
|
736
736
|
}) => {
|
|
737
|
-
const { ctx: s } =
|
|
737
|
+
const { ctx: s } = b();
|
|
738
738
|
fe({
|
|
739
739
|
isEnabled: e,
|
|
740
740
|
walletAddress: s.walletAddress,
|
|
741
741
|
alchemyApiKey: t ?? ""
|
|
742
742
|
});
|
|
743
|
-
}, Bt =
|
|
744
|
-
e &&
|
|
743
|
+
}, Bt = xe(({ debug: e }) => {
|
|
744
|
+
e && _.debug("[WIDGET] Debug mode is enabled"), ht(), gt({ debug: e }), kt({ debug: e });
|
|
745
745
|
}), Zn = ({ listenTo: e, debug: t = !1 }) => {
|
|
746
746
|
h(() => {
|
|
747
747
|
Bt({ debug: t });
|
|
@@ -753,7 +753,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
753
753
|
), o = e.find(
|
|
754
754
|
(r) => Array.isArray(r) && r[0] === "makeQuote"
|
|
755
755
|
);
|
|
756
|
-
|
|
756
|
+
Lt({
|
|
757
757
|
isEnabled: !!s,
|
|
758
758
|
alchemyApiKey: s?.[1].alchemyApiKey
|
|
759
759
|
}), Ot({
|
|
@@ -770,16 +770,16 @@ const N = x.getStore(), pt = Ce({
|
|
|
770
770
|
isEnabled: e.includes("setSourceTokenBalance")
|
|
771
771
|
}), vt({
|
|
772
772
|
isEnabled: e.includes("setSourceTokenIntentsTarget")
|
|
773
|
-
}),
|
|
773
|
+
}), _t({
|
|
774
774
|
isEnabled: e.includes("updateBalances"),
|
|
775
775
|
alchemyApiKey: s?.[1].alchemyApiKey
|
|
776
776
|
});
|
|
777
|
-
},
|
|
777
|
+
}, xt = L.getStore();
|
|
778
778
|
class U extends Error {
|
|
779
779
|
context;
|
|
780
780
|
_is_widget_error = !0;
|
|
781
781
|
constructor(t, s) {
|
|
782
|
-
super(t), this.name = "WidgetError", this.cause = s?.cause, this.context =
|
|
782
|
+
super(t), this.name = "WidgetError", this.cause = s?.cause, this.context = $(xt).context;
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
785
|
class me extends U {
|
|
@@ -807,7 +807,7 @@ const Yn = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e
|
|
|
807
807
|
);
|
|
808
808
|
throw s.context = e, s;
|
|
809
809
|
}, Pt = ({ children: e }) => {
|
|
810
|
-
const { ctx: t } =
|
|
810
|
+
const { ctx: t } = b();
|
|
811
811
|
return /* @__PURE__ */ q(
|
|
812
812
|
Ne,
|
|
813
813
|
{
|
|
@@ -889,43 +889,41 @@ 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]),
|
|
892
|
+
}, [t]), Ge(s ?? {}), Ve("headlessui-portal-root", "sw"), /* @__PURE__ */ q(we, { client: Wt, children: /* @__PURE__ */ q(ye, { i18n: Te, children: /* @__PURE__ */ q(pe.Provider, { value: n.current, children: /* @__PURE__ */ q(Pt, { children: /* @__PURE__ */ q("div", { className: "sw", children: e }) }) }) }) });
|
|
893
893
|
};
|
|
894
894
|
export {
|
|
895
|
-
|
|
895
|
+
Lt as A,
|
|
896
896
|
z as B,
|
|
897
|
-
Mt as C,
|
|
898
|
-
es as D,
|
|
899
897
|
Pt as E,
|
|
900
898
|
me as M,
|
|
901
899
|
A as Q,
|
|
902
900
|
Jn as T,
|
|
903
|
-
|
|
901
|
+
es as W,
|
|
904
902
|
Xn as a,
|
|
905
|
-
|
|
903
|
+
b,
|
|
906
904
|
Zn as c,
|
|
907
905
|
j as d,
|
|
908
|
-
|
|
909
|
-
|
|
906
|
+
Dt as e,
|
|
907
|
+
bt as f,
|
|
910
908
|
W as g,
|
|
911
909
|
fe as h,
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
910
|
+
U as i,
|
|
911
|
+
Yn as j,
|
|
912
|
+
v as k,
|
|
913
|
+
It as l,
|
|
914
|
+
kt as m,
|
|
915
|
+
gt as n,
|
|
916
|
+
ht as o,
|
|
917
|
+
_t as p,
|
|
918
|
+
Et as q,
|
|
921
919
|
Bt as r,
|
|
922
|
-
|
|
920
|
+
vt as s,
|
|
923
921
|
At as t,
|
|
924
922
|
Tt as u,
|
|
925
923
|
ue as v,
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
924
|
+
Nt as w,
|
|
925
|
+
Ct as x,
|
|
926
|
+
qt as y,
|
|
927
|
+
Ot as z
|
|
930
928
|
};
|
|
931
|
-
//# sourceMappingURL=config-
|
|
929
|
+
//# sourceMappingURL=config-Dq9mlDST.js.map
|