@aurora-is-near/intents-swap-widget 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{config-CNXFAxSY.js → config-BhnkBtE4.js} +250 -247
- package/dist/config-BhnkBtE4.js.map +1 -0
- package/dist/config.d.ts +14 -6
- 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.d.ts +2 -1
- package/dist/features/ChainsDropdown/index.js +55 -50
- package/dist/features/ChainsDropdown/index.js.map +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.d.ts +2 -1
- package/dist/features/TokensList/TokensList.js +39 -37
- package/dist/features/TokensList/TokensList.js.map +1 -1
- package/dist/features/TokensList/index.d.ts +2 -1
- package/dist/features/TokensModal.d.ts +2 -1
- package/dist/features/TokensModal.js +61 -44
- package/dist/features/TokensModal.js.map +1 -1
- package/dist/features/WalletCompatibilityCheck/index.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useChains.d.ts +1 -1
- package/dist/hooks/useChains.js +21 -18
- package/dist/hooks/useChains.js.map +1 -1
- package/dist/hooks/useCompatibilityCheck.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.d.ts +1 -2
- package/dist/hooks/useTokens.js +1 -1
- package/dist/hooks/useTokensFiltered.d.ts +2 -1
- package/dist/hooks/useTokensFiltered.js +30 -22
- package/dist/hooks/useTokensFiltered.js.map +1 -1
- package/dist/hooks/useTokensIntentsUnique.js +1 -1
- package/dist/index.js +1 -1
- package/dist/machine/effects/index.js +1 -1
- package/dist/machine/effects/useAlchemyBalanceEffect.js +1 -1
- package/dist/machine/effects/useBalancesUpdateEffect.js +1 -1
- package/dist/machine/effects/useMakeQuoteEffect.js +1 -1
- package/dist/machine/effects/useSelectedTokensEffect.js +1 -1
- package/dist/machine/effects/useSetTokenBalanceEffect.js +1 -1
- package/dist/machine/effects/useSetTokenIntentsTargetEffect.js +1 -1
- package/dist/machine/effects/useWalletConnEffect.js +1 -1
- package/dist/machine/events/index.js +1 -1
- package/dist/machine/events/tokenSelect.js +1 -1
- package/dist/machine/events/validateInputAndMoveTo.js +1 -1
- package/dist/machine/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/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.js +2 -1
- package/dist/widgets/WidgetDeposit.js.map +1 -1
- package/dist/widgets/WidgetSwap.js +15 -14
- package/dist/widgets/WidgetSwap.js.map +1 -1
- package/dist/widgets/WidgetWithdraw.js +15 -14
- package/dist/widgets/WidgetWithdraw.js.map +1 -1
- package/package.json +2 -1
- package/src/config.tsx +9 -7
- package/src/features/ChainsDropdown/index.tsx +35 -22
- package/src/features/TokensList/TokensList.tsx +3 -0
- package/src/features/TokensModal.tsx +12 -1
- package/src/hooks/useChains.ts +31 -5
- package/src/hooks/useTokens.ts +24 -9
- package/src/hooks/useTokensFiltered.ts +17 -7
- package/src/widgets/WidgetDeposit.tsx +1 -0
- package/src/widgets/WidgetSwap.tsx +1 -0
- package/src/widgets/WidgetWithdraw.tsx +1 -0
- package/dist/config-CNXFAxSY.js.map +0 -1
|
@@ -2,13 +2,13 @@ import { jsx as q } from "react/jsx-runtime";
|
|
|
2
2
|
import Te from "i18next";
|
|
3
3
|
import { deepClone as R } from "valtio/utils";
|
|
4
4
|
import { useSnapshot as Q, snapshot as $, proxy as ne } from "valtio";
|
|
5
|
-
import { useMemo as C, useEffect as h, useRef as O, createContext as
|
|
6
|
-
import { useQuery as se, useInfiniteQuery as ge, useQueryClient as Ae, QueryClient as he, QueryClientProvider as
|
|
7
|
-
import { I18nextProvider as
|
|
5
|
+
import { useMemo as C, 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 we } from "@tanstack/react-query";
|
|
7
|
+
import { I18nextProvider as ye } from "react-i18next";
|
|
8
8
|
import { CHAINS_LIST as Se, DEFAULT_CHAIN_ICON as be, DRY_QUOTE_ADDRESSES as J, CHAIN_POA_MAP as _e, 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 Ce } from "derive-valtio";
|
|
11
|
-
import { machine as x, moveTo as
|
|
11
|
+
import { machine as x, moveTo as y } from "./machine/machine.js";
|
|
12
12
|
import { guardStates as S } from "./machine/guards/index.js";
|
|
13
13
|
import { getUsdTradeDelta as De } from "./machine/computed/getUsdTradeDelta.js";
|
|
14
14
|
import { getIsDirectTransfer as qe } from "./machine/computed/getIsDirectTransfer.js";
|
|
@@ -16,11 +16,11 @@ import { getIsDirectNonNearWithdrawal as Oe } from "./machine/computed/getIsDire
|
|
|
16
16
|
import { getIsNearToIntentsSameAssetTransfer as xe } from "./machine/computed/getIsNearToIntentsSameAssetTransfer.js";
|
|
17
17
|
import { getIsDirectNearDeposit as Be } from "./machine/computed/getIsDirectNearDeposit.js";
|
|
18
18
|
import "ethers";
|
|
19
|
-
import
|
|
19
|
+
import Le from "lodash.once";
|
|
20
20
|
import { logger as b } from "./logger.js";
|
|
21
|
-
import { fireEvent as
|
|
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
|
-
import { isQuoteIdle as
|
|
23
|
+
import { isQuoteIdle as Ue } from "./machine/subscriptions/checkers/isQuoteIdle.js";
|
|
24
24
|
import { isInputChanged as Qe } from "./machine/subscriptions/checkers/isInputChanged.js";
|
|
25
25
|
import { isErrorChanged as Pe } from "./machine/subscriptions/checkers/isErrorChanged.js";
|
|
26
26
|
import { isOnlyErrorChanged as We } from "./machine/subscriptions/checkers/isOnlyErrorChanged.js";
|
|
@@ -42,8 +42,8 @@ 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
|
|
46
|
-
import { TOKENS_DATA as G, NATIVE_NEAR_DUMB_ASSET_ID as
|
|
45
|
+
import { OneClickService as nt, QuoteRequest as w } from "@defuse-protocol/one-click-sdk-typescript";
|
|
46
|
+
import { TOKENS_DATA as G, NATIVE_NEAR_DUMB_ASSET_ID as L, 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";
|
|
@@ -52,9 +52,9 @@ import { isAlchemySupportedChain as at } from "./ext/alchemy/types.js";
|
|
|
52
52
|
import { getIntentsAccountId as K } from "./utils/intents/getIntentsAccountId.js";
|
|
53
53
|
import { getIntentsBalances as it } from "./utils/intents/getIntentsBalance.js";
|
|
54
54
|
import { getTokenBalanceKey as ct } from "./utils/intents/getTokenBalanceKey.js";
|
|
55
|
-
import { snakeCase as
|
|
56
|
-
import { CanceledError as
|
|
57
|
-
import { oneClickApi as F, bridgeApi as
|
|
55
|
+
import { snakeCase as lt } from "change-case";
|
|
56
|
+
import { CanceledError as le, AxiosError as de } from "axios";
|
|
57
|
+
import { oneClickApi as F, 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";
|
|
@@ -74,7 +74,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
74
74
|
}, Xn = (e) => {
|
|
75
75
|
const t = Q(N);
|
|
76
76
|
if (!S(t.context, [e]))
|
|
77
|
-
throw new
|
|
77
|
+
throw new U(
|
|
78
78
|
`[WIDGET] Attempt to access snapshot for ${e} state while context does not match`
|
|
79
79
|
);
|
|
80
80
|
return t.context;
|
|
@@ -82,26 +82,26 @@ const N = x.getStore(), pt = Ce({
|
|
|
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 y(o ? "input_valid_dry" : "initial_dry");
|
|
86
86
|
}
|
|
87
|
-
n && re(e) ?
|
|
88
|
-
},
|
|
87
|
+
n && re(e) ? y("input_valid_external") : s && ae(e) ? y("input_valid_internal") : y("initial_wallet");
|
|
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);
|
|
91
|
-
},
|
|
91
|
+
}, kt = ({ debug: e }) => {
|
|
92
92
|
x.onContextChange((t, s) => {
|
|
93
93
|
const n = s;
|
|
94
94
|
if (e && b.debug("[WIDGET] Context changed", n), e && t.error && Pe(n) && b.debug(`[WIDGET] Error set to ${t.error.code}`), We(n) || Ge(t, n, e))
|
|
95
95
|
return;
|
|
96
96
|
if (Me(t, n)) {
|
|
97
|
-
|
|
97
|
+
d("reset", null), y("initial_dry");
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
const { isChanged: o, isDry:
|
|
100
|
+
const { isChanged: o, isDry: r } = Qe(t, n);
|
|
101
101
|
if (o) {
|
|
102
102
|
if (Re(t)) {
|
|
103
|
-
const u =
|
|
104
|
-
|
|
103
|
+
const u = r ? "initial_dry" : "initial_wallet";
|
|
104
|
+
y(u, {
|
|
105
105
|
onMoved: () => {
|
|
106
106
|
e && b.debug(
|
|
107
107
|
`[WIDGET] Inputs changed. State moved to ${u}`
|
|
@@ -109,7 +109,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
Ue(t) || (t.quote = void 0, t.quoteStatus = "idle", t.transferStatus = { status: "idle" }), Ve(t) && (t.sendAddress = void 0), It(t, n) && (t.sendAddress = t.walletAddress), ue(t);
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
}, gt = ({ debug: e }) => {
|
|
@@ -142,143 +142,148 @@ const N = x.getStore(), pt = Ce({
|
|
|
142
142
|
default:
|
|
143
143
|
ie(s, { throwError: !1 });
|
|
144
144
|
}
|
|
145
|
-
},
|
|
145
|
+
}, g = (e, t) => {
|
|
146
146
|
x.on(e, (s, n) => t(s, n));
|
|
147
147
|
}, ht = () => {
|
|
148
|
-
|
|
149
|
-
},
|
|
148
|
+
g("quoteSetStatus", Ze), g("walletAddressSet", Ye), g("transferSetStatus", tt), g("tokenSelectRotate", M), 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
|
+
}, wt = (e) => {
|
|
150
150
|
const t = e.symbol.toLowerCase();
|
|
151
151
|
return G[t]?.icon ?? "";
|
|
152
|
-
}, Y = (e) => Se[e].icon ?? be,
|
|
153
|
-
const {
|
|
154
|
-
|
|
152
|
+
}, Y = (e) => Se[e].icon ?? be, yt = (e) => `${e.blockchain?.charAt(0).toUpperCase()}${e.blockchain?.slice(1)}`, St = (e) => G[e.symbol]?.name ?? e.symbol, P = (e) => {
|
|
153
|
+
const {
|
|
154
|
+
showIntentTokens: t,
|
|
155
|
+
allowedTokensList: s,
|
|
156
|
+
allowedSourceTokensList: n,
|
|
157
|
+
allowedTargetTokensList: o,
|
|
158
|
+
filterTokens: r
|
|
159
|
+
} = v(), u = se({
|
|
155
160
|
queryKey: ["tokens"],
|
|
156
161
|
queryFn: async () => await nt.getTokens()
|
|
157
|
-
}),
|
|
158
|
-
if (!
|
|
162
|
+
}), i = C(() => {
|
|
163
|
+
if (!u.data)
|
|
159
164
|
return [];
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
return !st(
|
|
163
|
-
...
|
|
164
|
-
blockchain:
|
|
165
|
+
const c = u.data.map((a) => {
|
|
166
|
+
const T = a.blockchain.toLowerCase();
|
|
167
|
+
return !st(T) || s && !s.includes(a.assetId) || e === "source" && n && !n.includes(a.assetId) || e === "target" && o && !o.includes(a.assetId) ? null : {
|
|
168
|
+
...a,
|
|
169
|
+
blockchain: T,
|
|
165
170
|
isIntent: !1,
|
|
166
|
-
icon:
|
|
167
|
-
name: St(
|
|
168
|
-
chainIcon: Y(
|
|
169
|
-
chainName:
|
|
170
|
-
contractAddress:
|
|
171
|
+
icon: wt(a),
|
|
172
|
+
name: St(a),
|
|
173
|
+
chainIcon: Y(T),
|
|
174
|
+
chainName: yt(a),
|
|
175
|
+
contractAddress: a.contractAddress
|
|
171
176
|
};
|
|
172
|
-
}).filter((
|
|
173
|
-
(
|
|
174
|
-
),
|
|
175
|
-
return
|
|
177
|
+
}).filter((a) => !!a).filter(r ?? (() => !0)), m = c.filter(
|
|
178
|
+
(a) => a.symbol.toLowerCase() !== "wnear"
|
|
179
|
+
), l = c.find((a) => a.symbol.toLowerCase() === "wnear");
|
|
180
|
+
return m.push({
|
|
176
181
|
name: "NEAR",
|
|
177
182
|
symbol: "NEAR",
|
|
178
183
|
chainName: "Near",
|
|
179
184
|
blockchain: "near",
|
|
180
|
-
assetId:
|
|
185
|
+
assetId: L,
|
|
181
186
|
chainIcon: Y("near"),
|
|
182
187
|
icon: G.near?.icon ?? "",
|
|
183
|
-
price:
|
|
184
|
-
contractAddress:
|
|
188
|
+
price: l?.price ?? 0,
|
|
189
|
+
contractAddress: l?.contractAddress,
|
|
185
190
|
isIntent: !1,
|
|
186
191
|
decimals: 24
|
|
187
192
|
}), t ? [
|
|
188
|
-
...
|
|
193
|
+
...m,
|
|
189
194
|
// add intents tokens to the full list
|
|
190
|
-
...
|
|
191
|
-
(
|
|
195
|
+
...c.map(
|
|
196
|
+
(a) => a.symbol.toLowerCase() === "wnear" ? { ...a, symbol: "NEAR", name: "NEAR", isIntent: !0 } : { ...a, isIntent: !0 }
|
|
192
197
|
)
|
|
193
|
-
] :
|
|
194
|
-
}, [
|
|
198
|
+
] : m;
|
|
199
|
+
}, [u.data, t, r]);
|
|
195
200
|
return {
|
|
196
|
-
...
|
|
197
|
-
tokens:
|
|
201
|
+
...u,
|
|
202
|
+
tokens: i
|
|
198
203
|
};
|
|
199
204
|
}, ee = 3, fe = ({
|
|
200
205
|
walletAddress: e,
|
|
201
206
|
alchemyApiKey: t,
|
|
202
207
|
...s
|
|
203
208
|
}) => {
|
|
204
|
-
const { ctx: n } = _(), { tokens: o } = P(), { walletSupportedChains:
|
|
209
|
+
const { ctx: n } = _(), { tokens: o } = P(), { walletSupportedChains: r } = v(), { setWalletBalance: u } = ce(n.walletAddress), i = s.isEnabled && !!e && r.length > 0, c = ge({
|
|
205
210
|
initialPageParam: null,
|
|
206
|
-
enabled:
|
|
211
|
+
enabled: i && !!e && !!t,
|
|
207
212
|
queryKey: ["walletTokensBalance", e],
|
|
208
|
-
queryFn: async ({ pageParam:
|
|
209
|
-
pageParam:
|
|
213
|
+
queryFn: async ({ pageParam: l }) => rt({ alchemyApiKey: t })({
|
|
214
|
+
pageParam: l ? `${l}` : null,
|
|
210
215
|
walletAddress: e,
|
|
211
|
-
walletSupportedChains:
|
|
216
|
+
walletSupportedChains: r
|
|
212
217
|
}),
|
|
213
|
-
getNextPageParam: (
|
|
214
|
-
if (
|
|
215
|
-
return
|
|
218
|
+
getNextPageParam: (l, a) => {
|
|
219
|
+
if (l.pageKey && !(a.length >= ee))
|
|
220
|
+
return l.pageKey;
|
|
216
221
|
}
|
|
217
222
|
});
|
|
218
223
|
h(() => {
|
|
219
|
-
|
|
220
|
-
}, [
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
224
|
+
i && c.data && c.hasNextPage && c.data.pages.length < ee && !c.isFetchingNextPage && c.fetchNextPage();
|
|
225
|
+
}, [i, c]);
|
|
226
|
+
const m = C(() => {
|
|
227
|
+
if (!c.data?.pages)
|
|
223
228
|
return {};
|
|
224
|
-
const
|
|
229
|
+
const l = ot(
|
|
225
230
|
o,
|
|
226
|
-
|
|
231
|
+
c.data.pages.flatMap((a) => a.data)
|
|
227
232
|
);
|
|
228
|
-
return o.forEach((
|
|
229
|
-
at(
|
|
230
|
-
}),
|
|
231
|
-
}, [
|
|
233
|
+
return o.forEach((a) => {
|
|
234
|
+
at(a.blockchain) && !(a.assetId in l) && (l[a.assetId] = "0");
|
|
235
|
+
}), l;
|
|
236
|
+
}, [c.data, o]);
|
|
232
237
|
return h(() => {
|
|
233
|
-
S(n, ["initial_wallet"]) && (u(n.walletAddress,
|
|
234
|
-
}, [
|
|
235
|
-
status:
|
|
236
|
-
refetch:
|
|
237
|
-
balances:
|
|
238
|
+
S(n, ["initial_wallet"]) && (u(n.walletAddress, m), n.sourceToken && Object.keys(m).includes(n.sourceToken.assetId) && d("tokenSetBalance", m[n.sourceToken.assetId]));
|
|
239
|
+
}, [m]), {
|
|
240
|
+
status: c.status,
|
|
241
|
+
refetch: c.refetch,
|
|
242
|
+
balances: m
|
|
238
243
|
};
|
|
239
244
|
}, H = () => {
|
|
240
|
-
const { walletAddress: e, intentsAccountType: t } = v(), { tokens: s } = P(), n = s.filter((
|
|
245
|
+
const { walletAddress: e, intentsAccountType: t } = v(), { tokens: s } = P(), n = s.filter((i) => i.isIntent).map((i) => i.assetId), o = K({
|
|
241
246
|
walletAddress: e ?? "",
|
|
242
247
|
addressType: t
|
|
243
|
-
}),
|
|
248
|
+
}), r = se({
|
|
244
249
|
enabled: !!e && !!o && s.length > 0,
|
|
245
250
|
queryKey: ["intentsBalances", o],
|
|
246
251
|
queryFn: async () => o ? await it(o, n) : {}
|
|
247
252
|
}), u = C(() => {
|
|
248
|
-
switch (
|
|
253
|
+
switch (r.status) {
|
|
249
254
|
case "error":
|
|
250
|
-
return b.error("Unable to load intents balances:",
|
|
255
|
+
return b.error("Unable to load intents balances:", r.error), {};
|
|
251
256
|
case "success":
|
|
252
257
|
return Object.fromEntries(
|
|
253
|
-
Object.entries(
|
|
254
|
-
`intent-${
|
|
255
|
-
|
|
258
|
+
Object.entries(r.data).map(([i, c]) => [
|
|
259
|
+
`intent-${i}`,
|
|
260
|
+
c
|
|
256
261
|
])
|
|
257
262
|
);
|
|
258
263
|
case "pending":
|
|
259
264
|
return {};
|
|
260
265
|
default:
|
|
261
|
-
return ie(
|
|
266
|
+
return ie(r, { throwError: !1 }), {};
|
|
262
267
|
}
|
|
263
|
-
}, [
|
|
268
|
+
}, [r]) ?? {};
|
|
264
269
|
return {
|
|
265
|
-
...
|
|
270
|
+
...r,
|
|
266
271
|
intentBalances: u
|
|
267
272
|
};
|
|
268
273
|
}, bt = ({
|
|
269
274
|
isEnabled: e,
|
|
270
275
|
alchemyApiKey: t
|
|
271
276
|
}) => {
|
|
272
|
-
const { ctx: s } = _(), n = Ae(), { refetch: o } = H(), { refetch:
|
|
277
|
+
const { ctx: s } = _(), n = Ae(), { refetch: o } = H(), { refetch: r } = fe({
|
|
273
278
|
isEnabled: e,
|
|
274
279
|
walletAddress: s.walletAddress,
|
|
275
280
|
alchemyApiKey: t ?? ""
|
|
276
281
|
});
|
|
277
282
|
h(() => {
|
|
278
283
|
const u = S(s, ["transfer_success"]);
|
|
279
|
-
!e || !u || (async () => (await o(), t && (await new Promise((
|
|
280
|
-
setTimeout(
|
|
281
|
-
}), await
|
|
284
|
+
!e || !u || (async () => (await o(), t && (await new Promise((i) => {
|
|
285
|
+
setTimeout(i, 1e4);
|
|
286
|
+
}), await r()), await n.invalidateQueries({ queryKey: ["tokenBalance"] })))();
|
|
282
287
|
}, [s.state, e, t]);
|
|
283
288
|
}, _t = () => {
|
|
284
289
|
const { walletAddress: e } = v(), { intentBalances: t } = H(), { walletBalance: s } = ce(e);
|
|
@@ -292,11 +297,11 @@ const N = x.getStore(), pt = Ce({
|
|
|
292
297
|
if (!e)
|
|
293
298
|
return;
|
|
294
299
|
if (!t.sourceToken || !t.walletAddress) {
|
|
295
|
-
|
|
300
|
+
d("tokenSetBalance", void 0);
|
|
296
301
|
return;
|
|
297
302
|
}
|
|
298
303
|
const n = ct(t.sourceToken);
|
|
299
|
-
|
|
304
|
+
d("tokenSetBalance", s[n]);
|
|
300
305
|
}, [s, t.sourceToken]);
|
|
301
306
|
}, te = {
|
|
302
307
|
// cbBTC (eth)
|
|
@@ -321,35 +326,35 @@ const N = x.getStore(), pt = Ce({
|
|
|
321
326
|
if (!e)
|
|
322
327
|
return;
|
|
323
328
|
if (!t.sourceToken) {
|
|
324
|
-
|
|
329
|
+
d("tokenSelect", { variant: "target", token: void 0 });
|
|
325
330
|
return;
|
|
326
331
|
}
|
|
327
332
|
const { sourceToken: n } = t;
|
|
328
333
|
if (t.sourceToken.assetId in te) {
|
|
329
|
-
const
|
|
330
|
-
(
|
|
334
|
+
const i = s.find(
|
|
335
|
+
(c) => c.isIntent && c.assetId === te[n.assetId]
|
|
331
336
|
);
|
|
332
|
-
|
|
337
|
+
d("tokenSelect", {
|
|
333
338
|
variant: "target",
|
|
334
|
-
token:
|
|
339
|
+
token: i
|
|
335
340
|
});
|
|
336
341
|
return;
|
|
337
342
|
}
|
|
338
343
|
const o = s.find(
|
|
339
|
-
(
|
|
344
|
+
(i) => i.isIntent && i.symbol === n.symbol && i.blockchain === "near"
|
|
340
345
|
);
|
|
341
346
|
if (o) {
|
|
342
|
-
|
|
347
|
+
d("tokenSelect", { variant: "target", token: o });
|
|
343
348
|
return;
|
|
344
349
|
}
|
|
345
|
-
const
|
|
346
|
-
(
|
|
350
|
+
const r = s.find(
|
|
351
|
+
(i) => i.isIntent && i.assetId === n.assetId
|
|
347
352
|
), u = s.find(
|
|
348
|
-
(
|
|
353
|
+
(i) => i.isIntent && i.symbol === "USDC" && i.blockchain === "near"
|
|
349
354
|
);
|
|
350
|
-
|
|
355
|
+
d("tokenSelect", {
|
|
351
356
|
variant: "target",
|
|
352
|
-
token:
|
|
357
|
+
token: r ?? u
|
|
353
358
|
});
|
|
354
359
|
}, [s, t.sourceToken]);
|
|
355
360
|
}, Nt = ({ isEnabled: e }) => {
|
|
@@ -357,41 +362,41 @@ const N = x.getStore(), pt = Ce({
|
|
|
357
362
|
h(() => {
|
|
358
363
|
if (!e)
|
|
359
364
|
return;
|
|
360
|
-
|
|
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"));
|
|
361
366
|
}, [e, t, s, n]);
|
|
362
367
|
}, Ct = () => {
|
|
363
|
-
const { ctx: e } = _(), { intentsAccountType: t, oneClickApiQuoteProxyUrl: s, appName: n } = v(), o = !e.walletAddress,
|
|
368
|
+
const { ctx: e } = _(), { intentsAccountType: t, oneClickApiQuoteProxyUrl: s, appName: n } = v(), o = !e.walletAddress, r = K({
|
|
364
369
|
addressType: t,
|
|
365
370
|
walletAddress: o ? J[t] : e.walletAddress ?? ""
|
|
366
|
-
}), u = O(null),
|
|
371
|
+
}), u = O(null), i = O(new AbortController()), c = C(() => async (a) => F.post(
|
|
367
372
|
s,
|
|
368
|
-
|
|
373
|
+
a,
|
|
369
374
|
{
|
|
370
|
-
signal:
|
|
375
|
+
signal: i.current.signal
|
|
371
376
|
}
|
|
372
|
-
), [s, F]),
|
|
377
|
+
), [s, F]), m = o ? J[t] : e.walletAddress ?? "";
|
|
373
378
|
return {
|
|
374
|
-
make: async ({ message:
|
|
379
|
+
make: async ({ message: a, quoteType: T = "exact_in" } = {}) => {
|
|
375
380
|
if (!S(e, [
|
|
376
381
|
"input_valid_dry",
|
|
377
382
|
"input_valid_external",
|
|
378
383
|
"input_valid_internal"
|
|
379
384
|
])) {
|
|
380
385
|
const p = `Unable to run quote in current state ${e.state}`;
|
|
381
|
-
throw b.error(`[WIDGET] ${p}`), new
|
|
386
|
+
throw b.error(`[WIDGET] ${p}`), new A({
|
|
382
387
|
code: "QUOTE_INVALID_INITIAL",
|
|
383
388
|
meta: { isDry: o, message: p }
|
|
384
389
|
});
|
|
385
390
|
}
|
|
386
|
-
if (!
|
|
391
|
+
if (!r) {
|
|
387
392
|
const p = "No corresponding intents account to run a quote";
|
|
388
|
-
throw b.error(`[WIDGET] ${p}`), new
|
|
393
|
+
throw b.error(`[WIDGET] ${p}`), new A({
|
|
389
394
|
code: "QUOTE_INVALID_INITIAL",
|
|
390
395
|
meta: { isDry: o, message: p }
|
|
391
396
|
});
|
|
392
397
|
}
|
|
393
|
-
u.current && (
|
|
394
|
-
let
|
|
398
|
+
u.current && (i.current.abort("Abort previous quote (auto)"), i.current = new AbortController());
|
|
399
|
+
let I;
|
|
395
400
|
const k = {
|
|
396
401
|
// Settings
|
|
397
402
|
dry: o,
|
|
@@ -399,53 +404,53 @@ const N = x.getStore(), pt = Ce({
|
|
|
399
404
|
// 1%
|
|
400
405
|
deadline: new Date(Date.now() + 3600 * 1e3).toISOString(),
|
|
401
406
|
// 1 hour
|
|
402
|
-
swapType:
|
|
407
|
+
swapType: T === "exact_out" ? w.swapType.EXACT_OUTPUT : w.swapType.EXACT_INPUT,
|
|
403
408
|
// Target
|
|
404
|
-
destinationAsset: e.targetToken.assetId ===
|
|
409
|
+
destinationAsset: e.targetToken.assetId === L ? V : e.targetToken.assetId,
|
|
405
410
|
// Source
|
|
406
|
-
originAsset: e.sourceToken.assetId ===
|
|
407
|
-
amount:
|
|
411
|
+
originAsset: e.sourceToken.assetId === L ? V : e.sourceToken.assetId,
|
|
412
|
+
amount: T === "exact_out" ? e.targetTokenAmount : e.sourceTokenAmount
|
|
408
413
|
};
|
|
409
|
-
|
|
414
|
+
a && (k.customRecipientMsg = a), n && (k.referral = lt(n));
|
|
410
415
|
try {
|
|
411
|
-
e.sourceToken.isIntent && e.targetToken.isIntent && (u.current =
|
|
416
|
+
e.sourceToken.isIntent && e.targetToken.isIntent && (u.current = c({
|
|
412
417
|
...k,
|
|
413
|
-
recipient:
|
|
414
|
-
recipientType:
|
|
415
|
-
depositType:
|
|
418
|
+
recipient: r,
|
|
419
|
+
recipientType: w.recipientType.INTENTS,
|
|
420
|
+
depositType: w.depositType.INTENTS,
|
|
416
421
|
// Refund
|
|
417
|
-
refundTo:
|
|
418
|
-
refundType:
|
|
419
|
-
}),
|
|
422
|
+
refundTo: r,
|
|
423
|
+
refundType: w.refundType.INTENTS
|
|
424
|
+
}), I = (await u.current).data), u.current = c({
|
|
420
425
|
...k,
|
|
421
|
-
recipient: !e.targetToken.isIntent && e.sendAddress ? e.sendAddress :
|
|
422
|
-
recipientType: e.targetToken.isIntent ?
|
|
423
|
-
depositType: e.sourceToken.isIntent ?
|
|
426
|
+
recipient: !e.targetToken.isIntent && e.sendAddress ? e.sendAddress : r,
|
|
427
|
+
recipientType: e.targetToken.isIntent ? w.recipientType.INTENTS : w.recipientType.DESTINATION_CHAIN,
|
|
428
|
+
depositType: e.sourceToken.isIntent ? w.depositType.INTENTS : w.depositType.ORIGIN_CHAIN,
|
|
424
429
|
// Refund
|
|
425
|
-
refundTo: e.sourceToken.isIntent ?
|
|
426
|
-
refundType: e.sourceToken.isIntent ?
|
|
427
|
-
}),
|
|
430
|
+
refundTo: e.sourceToken.isIntent ? r : m,
|
|
431
|
+
refundType: e.sourceToken.isIntent ? w.refundType.INTENTS : w.refundType.ORIGIN_CHAIN
|
|
432
|
+
}), I = (await u.current).data;
|
|
428
433
|
} catch (p) {
|
|
429
|
-
if (p instanceof
|
|
434
|
+
if (p instanceof le)
|
|
430
435
|
return;
|
|
431
|
-
if (p instanceof
|
|
436
|
+
if (p instanceof de) {
|
|
432
437
|
const E = p.response?.data.message || p.message;
|
|
433
438
|
if (E.includes("Amount is too low")) {
|
|
434
439
|
const X = E.match(/\d+/), Z = X ? X[0] : void 0;
|
|
435
|
-
throw new
|
|
440
|
+
throw new A({
|
|
436
441
|
code: "QUOTE_AMOUNT_IS_TOO_LOW",
|
|
437
442
|
meta: {
|
|
438
443
|
minAmount: (Z && B(Z, e.sourceToken.decimals)) ?? "0"
|
|
439
444
|
}
|
|
440
445
|
});
|
|
441
446
|
}
|
|
442
|
-
throw E.includes("recipient is not valid") ? new
|
|
447
|
+
throw E.includes("recipient is not valid") ? new A({
|
|
443
448
|
code: "TOKEN_IS_NOT_SUPPORTED"
|
|
444
|
-
}) : E.includes("Failed to get a deposit address") ? new
|
|
449
|
+
}) : E.includes("Failed to get a deposit address") ? new A({
|
|
445
450
|
code: "QUOTE_NO_ONE_TIME_ADDRESS"
|
|
446
451
|
}) : p;
|
|
447
452
|
}
|
|
448
|
-
throw new
|
|
453
|
+
throw new A({
|
|
449
454
|
code: "QUOTE_FAILED",
|
|
450
455
|
meta: {
|
|
451
456
|
// @ts-expect-error In case error has a message
|
|
@@ -457,33 +462,33 @@ const N = x.getStore(), pt = Ce({
|
|
|
457
462
|
if (o)
|
|
458
463
|
f = {
|
|
459
464
|
dry: !0,
|
|
460
|
-
...
|
|
465
|
+
...I.quote,
|
|
461
466
|
deadline: void 0,
|
|
462
467
|
depositAddress: void 0
|
|
463
468
|
};
|
|
464
|
-
else if (
|
|
469
|
+
else if (I.quote.deadline && I.quote.depositAddress)
|
|
465
470
|
f = {
|
|
466
471
|
dry: !1,
|
|
467
|
-
...
|
|
468
|
-
deadline:
|
|
469
|
-
depositAddress:
|
|
472
|
+
...I.quote,
|
|
473
|
+
deadline: I.quote.deadline,
|
|
474
|
+
depositAddress: I.quote.depositAddress
|
|
470
475
|
};
|
|
471
476
|
else
|
|
472
|
-
throw new
|
|
477
|
+
throw new A({
|
|
473
478
|
code: "QUOTE_INVALID",
|
|
474
479
|
meta: { isDry: o }
|
|
475
480
|
});
|
|
476
481
|
return f;
|
|
477
482
|
},
|
|
478
483
|
cancel: () => {
|
|
479
|
-
|
|
484
|
+
i.current.abort("Abort quote manually"), i.current = new AbortController();
|
|
480
485
|
}
|
|
481
486
|
};
|
|
482
487
|
}, Dt = () => {
|
|
483
488
|
const { ctx: e } = _(), { intentsAccountType: t, oneClickApiQuoteProxyUrl: s } = v(), n = K({
|
|
484
489
|
addressType: t,
|
|
485
490
|
walletAddress: e.walletAddress ?? ""
|
|
486
|
-
}), o = O(null),
|
|
491
|
+
}), o = O(null), r = O(new AbortController()), u = C(() => async (c) => dt.post(
|
|
487
492
|
"",
|
|
488
493
|
{
|
|
489
494
|
id: 1,
|
|
@@ -491,13 +496,13 @@ const N = x.getStore(), pt = Ce({
|
|
|
491
496
|
method: "deposit_address",
|
|
492
497
|
params: [
|
|
493
498
|
{
|
|
494
|
-
account_id:
|
|
495
|
-
chain:
|
|
499
|
+
account_id: c.accountId,
|
|
500
|
+
chain: c.chain
|
|
496
501
|
}
|
|
497
502
|
]
|
|
498
503
|
},
|
|
499
504
|
{
|
|
500
|
-
signal:
|
|
505
|
+
signal: r.current.signal
|
|
501
506
|
}
|
|
502
507
|
), [s, F]);
|
|
503
508
|
return {
|
|
@@ -507,14 +512,14 @@ const N = x.getStore(), pt = Ce({
|
|
|
507
512
|
"input_valid_external",
|
|
508
513
|
"input_valid_internal"
|
|
509
514
|
])) {
|
|
510
|
-
const
|
|
511
|
-
throw b.error(`[WIDGET] ${
|
|
515
|
+
const l = `Unable to run quote in current state ${e.state}`;
|
|
516
|
+
throw b.error(`[WIDGET] ${l}`), new A({
|
|
512
517
|
code: "QUOTE_INVALID_INITIAL",
|
|
513
|
-
meta: { isDry: !1, message:
|
|
518
|
+
meta: { isDry: !1, message: l }
|
|
514
519
|
});
|
|
515
520
|
}
|
|
516
521
|
if (e.sourceToken.assetId !== e.targetToken.assetId)
|
|
517
|
-
throw new
|
|
522
|
+
throw new A({
|
|
518
523
|
code: "QUOTE_INVALID_INITIAL",
|
|
519
524
|
meta: {
|
|
520
525
|
isDry: !1,
|
|
@@ -522,7 +527,7 @@ const N = x.getStore(), pt = Ce({
|
|
|
522
527
|
}
|
|
523
528
|
});
|
|
524
529
|
if (e.sourceToken.isIntent)
|
|
525
|
-
throw new
|
|
530
|
+
throw new A({
|
|
526
531
|
code: "QUOTE_INVALID_INITIAL",
|
|
527
532
|
meta: {
|
|
528
533
|
isDry: !1,
|
|
@@ -530,22 +535,22 @@ const N = x.getStore(), pt = Ce({
|
|
|
530
535
|
}
|
|
531
536
|
});
|
|
532
537
|
if (!n) {
|
|
533
|
-
const
|
|
534
|
-
throw b.error(`[WIDGET] ${
|
|
538
|
+
const l = "No corresponding intents account to run a quote";
|
|
539
|
+
throw b.error(`[WIDGET] ${l}`), new A({
|
|
535
540
|
code: "QUOTE_INVALID_INITIAL",
|
|
536
|
-
meta: { isDry: !1, message:
|
|
541
|
+
meta: { isDry: !1, message: l }
|
|
537
542
|
});
|
|
538
543
|
}
|
|
539
|
-
o.current && (
|
|
540
|
-
const
|
|
541
|
-
if (!
|
|
542
|
-
throw new
|
|
544
|
+
o.current && (r.current.abort("Abort previous quote (auto)"), r.current = new AbortController());
|
|
545
|
+
const m = _e[e.targetToken.blockchain];
|
|
546
|
+
if (!m)
|
|
547
|
+
throw new A({
|
|
543
548
|
code: "QUOTE_INVALID_INITIAL",
|
|
544
549
|
meta: { isDry: !1, message: "Chain is not supported by POA" }
|
|
545
550
|
});
|
|
546
551
|
try {
|
|
547
552
|
return o.current = u({
|
|
548
|
-
chain:
|
|
553
|
+
chain: m,
|
|
549
554
|
accountId: n
|
|
550
555
|
}), {
|
|
551
556
|
depositAddress: (await o.current).data.result.address,
|
|
@@ -566,22 +571,22 @@ const N = x.getStore(), pt = Ce({
|
|
|
566
571
|
timeEstimate: 0,
|
|
567
572
|
dry: !1
|
|
568
573
|
};
|
|
569
|
-
} catch (
|
|
570
|
-
if (
|
|
574
|
+
} catch (l) {
|
|
575
|
+
if (l instanceof le)
|
|
571
576
|
return;
|
|
572
|
-
if (b.error(
|
|
573
|
-
const
|
|
574
|
-
throw new
|
|
577
|
+
if (b.error(l), l instanceof de) {
|
|
578
|
+
const a = l.response?.data.message || l.message;
|
|
579
|
+
throw new A({
|
|
575
580
|
code: "QUOTE_FAILED",
|
|
576
581
|
meta: {
|
|
577
|
-
message:
|
|
582
|
+
message: a ?? "Failed to fetch quote. Please try again."
|
|
578
583
|
}
|
|
579
584
|
});
|
|
580
585
|
}
|
|
581
586
|
}
|
|
582
587
|
},
|
|
583
588
|
cancel: () => {
|
|
584
|
-
|
|
589
|
+
r.current.abort("Abort quote manually"), r.current = new AbortController();
|
|
585
590
|
}
|
|
586
591
|
};
|
|
587
592
|
}, qt = ({
|
|
@@ -591,51 +596,51 @@ const N = x.getStore(), pt = Ce({
|
|
|
591
596
|
}) => {
|
|
592
597
|
const { ctx: n } = _(), {
|
|
593
598
|
isDirectTransfer: o,
|
|
594
|
-
isDirectNonNearWithdrawal:
|
|
599
|
+
isDirectNonNearWithdrawal: r,
|
|
595
600
|
isNearToIntentsSameAssetTransfer: u,
|
|
596
|
-
isDirectNearDeposit:
|
|
597
|
-
} = Tt(),
|
|
598
|
-
|
|
601
|
+
isDirectNearDeposit: i
|
|
602
|
+
} = Tt(), c = !n.walletAddress, m = e && !o && !r && !u && !i, { make: l, cancel: a } = Ct(), { make: T, cancel: D } = Dt(), I = () => {
|
|
603
|
+
a(), D();
|
|
599
604
|
};
|
|
600
605
|
h(() => {
|
|
601
606
|
const k = S(n, ["input_valid_dry"]), f = S(n, ["input_valid_external"]), p = S(n, ["input_valid_internal"]);
|
|
602
|
-
(
|
|
603
|
-
}, [
|
|
604
|
-
if (!
|
|
607
|
+
(c && !k || !c && n.targetToken?.isIntent && !p || !c && !n.targetToken?.isIntent && !f) && I();
|
|
608
|
+
}, [I, c, n]), h(() => {
|
|
609
|
+
if (!m || n.sourceToken?.assetId === L && n.targetToken?.assetId === V)
|
|
605
610
|
return;
|
|
606
|
-
const k =
|
|
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;
|
|
607
612
|
(async () => {
|
|
608
613
|
try {
|
|
609
614
|
if (k && n.quoteStatus === "idle") {
|
|
610
|
-
|
|
615
|
+
d("quoteSetStatus", "pending");
|
|
611
616
|
let f;
|
|
612
|
-
if (n.sourceToken?.assetId === n.targetToken?.assetId ? f = await
|
|
617
|
+
if (n.sourceToken?.assetId === n.targetToken?.assetId ? f = await T() : f = await l({ message: t, quoteType: s }), !f)
|
|
613
618
|
return;
|
|
614
|
-
if (
|
|
619
|
+
if (d("quoteSetStatus", "success"), d("quoteSet", f), d("errorSet", null), d("tokenSetAmount", {
|
|
615
620
|
variant: "target",
|
|
616
621
|
amount: f.amountOut
|
|
617
622
|
}), n.state === "input_valid_dry") {
|
|
618
|
-
|
|
623
|
+
y("quote_success_dry");
|
|
619
624
|
return;
|
|
620
625
|
}
|
|
621
|
-
n.targetToken?.isIntent ?
|
|
626
|
+
n.targetToken?.isIntent ? y("quote_success_internal") : y("quote_success_external");
|
|
622
627
|
}
|
|
623
628
|
} catch (f) {
|
|
624
|
-
if (f instanceof
|
|
629
|
+
if (f instanceof A) {
|
|
625
630
|
if (f.data.code === "QUOTE_INVALID_INITIAL") {
|
|
626
|
-
|
|
631
|
+
d("quoteSetStatus", "idle"), d("quoteSet", void 0), d("errorSet", null);
|
|
627
632
|
return;
|
|
628
633
|
}
|
|
629
|
-
|
|
634
|
+
d("quoteSetStatus", "error"), d("quoteSet", void 0), d("errorSet", f.data), ue(n);
|
|
630
635
|
return;
|
|
631
636
|
}
|
|
632
|
-
|
|
637
|
+
d("quoteSetStatus", "error"), d("quoteSet", void 0), d("errorSet", {
|
|
633
638
|
code: "QUOTE_FAILED",
|
|
634
639
|
meta: { message: "Unknown error" }
|
|
635
640
|
});
|
|
636
641
|
}
|
|
637
642
|
})();
|
|
638
|
-
}, [n,
|
|
643
|
+
}, [n, m, c, l]);
|
|
639
644
|
}, W = {
|
|
640
645
|
sol: "sol",
|
|
641
646
|
evm: "eth",
|
|
@@ -645,21 +650,21 @@ const N = x.getStore(), pt = Ce({
|
|
|
645
650
|
skipIntents: t = !1,
|
|
646
651
|
target: s = "none"
|
|
647
652
|
}) => {
|
|
648
|
-
const { tokens: n } = P(), { ctx: o, state:
|
|
649
|
-
walletSupportedChains:
|
|
650
|
-
chainsFilter:
|
|
651
|
-
walletAddress:
|
|
652
|
-
intentsAccountType:
|
|
653
|
-
} = v(),
|
|
653
|
+
const { tokens: n } = P(), { ctx: o, state: r } = _(), { intentBalances: u } = H(), {
|
|
654
|
+
walletSupportedChains: i,
|
|
655
|
+
chainsFilter: c,
|
|
656
|
+
walletAddress: m,
|
|
657
|
+
intentsAccountType: l
|
|
658
|
+
} = v(), a = mt({
|
|
654
659
|
tokens: n,
|
|
655
|
-
walletSupportedChains:
|
|
660
|
+
walletSupportedChains: i,
|
|
656
661
|
balances: u,
|
|
657
662
|
across: "intents"
|
|
658
|
-
}), [
|
|
663
|
+
}), [T, D] = C(() => !m && !t ? [
|
|
659
664
|
{ token: ft({ tokens: n }), status: "loaded" },
|
|
660
665
|
{ token: void 0, status: "loaded" }
|
|
661
|
-
] :
|
|
662
|
-
{ token:
|
|
666
|
+
] : c.source.intents !== "none" && !t ? a ? [
|
|
667
|
+
{ token: a, status: "loaded" },
|
|
663
668
|
{ token: void 0, status: "loaded" }
|
|
664
669
|
] : [
|
|
665
670
|
{ token: void 0, status: "loading" },
|
|
@@ -667,64 +672,64 @@ const N = x.getStore(), pt = Ce({
|
|
|
667
672
|
] : [
|
|
668
673
|
{ token: ut({
|
|
669
674
|
tokens: n,
|
|
670
|
-
walletSupportedChains:
|
|
675
|
+
walletSupportedChains: i
|
|
671
676
|
}), status: "loaded" },
|
|
672
677
|
{ token: void 0, status: "loaded" }
|
|
673
678
|
], [
|
|
674
679
|
n,
|
|
675
680
|
t,
|
|
676
|
-
|
|
677
|
-
d,
|
|
681
|
+
c,
|
|
678
682
|
m,
|
|
679
|
-
|
|
680
|
-
|
|
683
|
+
a,
|
|
684
|
+
i,
|
|
685
|
+
r
|
|
681
686
|
]);
|
|
682
687
|
return h(() => {
|
|
683
688
|
if (!e)
|
|
684
689
|
return;
|
|
685
|
-
if (S(o, ["initial_dry", "initial_wallet"]) && (
|
|
690
|
+
if (S(o, ["initial_dry", "initial_wallet"]) && (T.status === "loaded" && !o.sourceToken && d("tokenSelect", {
|
|
686
691
|
variant: "source",
|
|
687
|
-
token:
|
|
688
|
-
}), D.status === "loaded" &&
|
|
692
|
+
token: T.token
|
|
693
|
+
}), D.status === "loaded" && T.status === "loaded" && !o.targetToken)) {
|
|
689
694
|
let k = D.token;
|
|
690
|
-
s === "same-asset" && (
|
|
691
|
-
(f) => !f.isIntent && f.symbol === o.sourceToken?.symbol && f.blockchain === W[
|
|
695
|
+
s === "same-asset" && (T.token?.isIntent ? k = n.find(
|
|
696
|
+
(f) => !f.isIntent && f.symbol === o.sourceToken?.symbol && f.blockchain === W[l]
|
|
692
697
|
) : k = n.find(
|
|
693
698
|
(f) => f.isIntent && f.symbol === o.sourceToken?.symbol
|
|
694
|
-
)),
|
|
699
|
+
)), d("tokenSelect", {
|
|
695
700
|
variant: "target",
|
|
696
701
|
token: k
|
|
697
702
|
});
|
|
698
703
|
}
|
|
699
|
-
}, [o,
|
|
700
|
-
const
|
|
701
|
-
if (!e || !
|
|
704
|
+
}, [o, T, D, e]), h(() => {
|
|
705
|
+
const I = S(o, ["initial_dry", "initial_wallet"]);
|
|
706
|
+
if (!e || !I)
|
|
702
707
|
return;
|
|
703
708
|
const k = n.find(
|
|
704
709
|
(p) => p.isIntent && p.symbol === "AURORA" && p.blockchain === "near"
|
|
705
710
|
), f = setTimeout(() => {
|
|
706
|
-
if (!
|
|
707
|
-
if (!t &&
|
|
708
|
-
|
|
711
|
+
if (!T.token)
|
|
712
|
+
if (!t && a)
|
|
713
|
+
d("tokenSelect", {
|
|
709
714
|
variant: "source",
|
|
710
|
-
token:
|
|
715
|
+
token: a
|
|
711
716
|
});
|
|
712
|
-
else if (
|
|
717
|
+
else if (i.length) {
|
|
713
718
|
const p = n.find(
|
|
714
|
-
(E) => !E.isIntent && E.blockchain === W[
|
|
719
|
+
(E) => !E.isIntent && E.blockchain === W[l] && E.symbol.toLowerCase() === Ee[W[l]]?.toLowerCase()
|
|
715
720
|
) ?? k;
|
|
716
|
-
|
|
721
|
+
d("tokenSelect", {
|
|
717
722
|
variant: "source",
|
|
718
723
|
token: p
|
|
719
724
|
});
|
|
720
725
|
} else
|
|
721
|
-
|
|
726
|
+
d("tokenSelect", {
|
|
722
727
|
variant: "source",
|
|
723
728
|
token: k
|
|
724
729
|
});
|
|
725
730
|
}, 3e3);
|
|
726
731
|
return () => clearTimeout(f);
|
|
727
|
-
}, [n,
|
|
732
|
+
}, [n, T, t]), { source: o.sourceToken, target: o.targetToken };
|
|
728
733
|
}, xt = ({
|
|
729
734
|
isEnabled: e,
|
|
730
735
|
alchemyApiKey: t
|
|
@@ -735,18 +740,18 @@ const N = x.getStore(), pt = Ce({
|
|
|
735
740
|
walletAddress: s.walletAddress,
|
|
736
741
|
alchemyApiKey: t ?? ""
|
|
737
742
|
});
|
|
738
|
-
}, Bt =
|
|
739
|
-
e && b.debug("[WIDGET] Debug mode is enabled"), ht(), gt({ debug: e }),
|
|
743
|
+
}, Bt = Le(({ debug: e }) => {
|
|
744
|
+
e && b.debug("[WIDGET] Debug mode is enabled"), ht(), gt({ debug: e }), kt({ debug: e });
|
|
740
745
|
}), Zn = ({ listenTo: e, debug: t = !1 }) => {
|
|
741
746
|
h(() => {
|
|
742
747
|
Bt({ debug: t });
|
|
743
748
|
}, [t]);
|
|
744
749
|
const s = e.find(
|
|
745
|
-
(
|
|
750
|
+
(r) => Array.isArray(r) && r[0] === "setBalancesUsingAlchemyExt"
|
|
746
751
|
), n = e.find(
|
|
747
|
-
(
|
|
752
|
+
(r) => Array.isArray(r) && r[0] === "setDefaultSelectedTokens"
|
|
748
753
|
), o = e.find(
|
|
749
|
-
(
|
|
754
|
+
(r) => Array.isArray(r) && r[0] === "makeQuote"
|
|
750
755
|
);
|
|
751
756
|
xt({
|
|
752
757
|
isEnabled: !!s,
|
|
@@ -769,21 +774,21 @@ const N = x.getStore(), pt = Ce({
|
|
|
769
774
|
isEnabled: e.includes("updateBalances"),
|
|
770
775
|
alchemyApiKey: s?.[1].alchemyApiKey
|
|
771
776
|
});
|
|
772
|
-
},
|
|
773
|
-
class
|
|
777
|
+
}, Lt = x.getStore();
|
|
778
|
+
class U extends Error {
|
|
774
779
|
context;
|
|
775
780
|
_is_widget_error = !0;
|
|
776
781
|
constructor(t, s) {
|
|
777
|
-
super(t), this.name = "WidgetError", this.cause = s?.cause, this.context = $(
|
|
782
|
+
super(t), this.name = "WidgetError", this.cause = s?.cause, this.context = $(Lt).context;
|
|
778
783
|
}
|
|
779
784
|
}
|
|
780
|
-
class me extends
|
|
785
|
+
class me extends U {
|
|
781
786
|
data;
|
|
782
787
|
constructor(t) {
|
|
783
788
|
super(t.code), this.data = t, this.name = "MachineError";
|
|
784
789
|
}
|
|
785
790
|
}
|
|
786
|
-
class
|
|
791
|
+
class A extends me {
|
|
787
792
|
constructor(t) {
|
|
788
793
|
super(t), this.name = "QuoteError";
|
|
789
794
|
}
|
|
@@ -793,10 +798,10 @@ class Jn extends me {
|
|
|
793
798
|
super(t), this.name = "TransferError";
|
|
794
799
|
}
|
|
795
800
|
}
|
|
796
|
-
const Yn = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e && !!e._is_widget_error,
|
|
797
|
-
if (t instanceof
|
|
801
|
+
const Yn = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e && !!e._is_widget_error, Ut = (e) => null, Qt = (e) => (t) => {
|
|
802
|
+
if (t instanceof U)
|
|
798
803
|
throw t;
|
|
799
|
-
const s = new
|
|
804
|
+
const s = new U(
|
|
800
805
|
t instanceof Error ? t.message : "Unknown error",
|
|
801
806
|
{ cause: t }
|
|
802
807
|
);
|
|
@@ -806,7 +811,7 @@ const Yn = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e
|
|
|
806
811
|
return /* @__PURE__ */ q(
|
|
807
812
|
Ne,
|
|
808
813
|
{
|
|
809
|
-
FallbackComponent:
|
|
814
|
+
FallbackComponent: Ut,
|
|
810
815
|
onError: Qt(t),
|
|
811
816
|
children: e
|
|
812
817
|
}
|
|
@@ -856,12 +861,12 @@ const Yn = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e
|
|
|
856
861
|
source: { external: "wallet-supported", intents: "with-balance" },
|
|
857
862
|
target: { external: "all", intents: "all" }
|
|
858
863
|
}
|
|
859
|
-
}, pe =
|
|
864
|
+
}, pe = Ie({
|
|
860
865
|
config: j
|
|
861
866
|
}), z = ne({
|
|
862
867
|
config: j
|
|
863
868
|
}), v = () => {
|
|
864
|
-
const e =
|
|
869
|
+
const e = ke(pe);
|
|
865
870
|
return Q(e).config;
|
|
866
871
|
}, Mt = (e) => {
|
|
867
872
|
z.config = R(e);
|
|
@@ -874,9 +879,7 @@ const Yn = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e
|
|
|
874
879
|
return h(() => {
|
|
875
880
|
const o = R(t);
|
|
876
881
|
Object.assign(n.current.config, o), Mt(o);
|
|
877
|
-
}, [t]),
|
|
878
|
-
$e(s ?? {});
|
|
879
|
-
}, [s]), Fe("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: /* @__PURE__ */ q("div", { className: "sw", children: e }) }) }) }) });
|
|
882
|
+
}, [t]), $e(s ?? {}), Fe("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 }) }) }) }) });
|
|
880
883
|
};
|
|
881
884
|
export {
|
|
882
885
|
j as A,
|
|
@@ -885,9 +888,9 @@ export {
|
|
|
885
888
|
es as D,
|
|
886
889
|
Pt as E,
|
|
887
890
|
me as M,
|
|
888
|
-
|
|
891
|
+
A as Q,
|
|
889
892
|
Jn as T,
|
|
890
|
-
|
|
893
|
+
U as W,
|
|
891
894
|
Xn as a,
|
|
892
895
|
_ as b,
|
|
893
896
|
Zn as c,
|
|
@@ -898,8 +901,8 @@ export {
|
|
|
898
901
|
fe as h,
|
|
899
902
|
Yn as i,
|
|
900
903
|
v as j,
|
|
901
|
-
|
|
902
|
-
|
|
904
|
+
It as k,
|
|
905
|
+
kt as l,
|
|
903
906
|
gt as m,
|
|
904
907
|
ht as n,
|
|
905
908
|
bt as o,
|
|
@@ -915,4 +918,4 @@ export {
|
|
|
915
918
|
Ot as y,
|
|
916
919
|
xt as z
|
|
917
920
|
};
|
|
918
|
-
//# sourceMappingURL=config-
|
|
921
|
+
//# sourceMappingURL=config-BhnkBtE4.js.map
|