@trustware/sdk-staging 1.1.17-staging.6 → 1.1.18-staging.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/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/core.cjs +36 -5
- package/dist/core.cjs.map +1 -1
- package/dist/core.mjs +36 -5
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +358 -489
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +358 -489
- package/dist/index.mjs.map +1 -1
- package/dist/smart-account.cjs +1 -1
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.mjs +1 -1
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +1 -1
- package/dist/wallet.mjs +1 -1
- package/dist/widget.cjs +358 -489
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +358 -489
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -633,7 +633,7 @@ var init_constants = __esm({
|
|
|
633
633
|
"src/constants.ts"() {
|
|
634
634
|
"use strict";
|
|
635
635
|
SDK_NAME = "@trustware/sdk";
|
|
636
|
-
SDK_VERSION = "1.1.
|
|
636
|
+
SDK_VERSION = "1.1.18-staging.1";
|
|
637
637
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
638
638
|
GTM_ID = "GTM-TZDGNCXB";
|
|
639
639
|
API_PREFIX = "/api";
|
|
@@ -4960,6 +4960,32 @@ var init_routeError = __esm({
|
|
|
4960
4960
|
}
|
|
4961
4961
|
});
|
|
4962
4962
|
|
|
4963
|
+
// src/core/routeApprovals.ts
|
|
4964
|
+
function approvalAmountWei(approval, stepIndex) {
|
|
4965
|
+
const { amount } = approval;
|
|
4966
|
+
if (amount === void 0 || amount === "") {
|
|
4967
|
+
throw new Error(
|
|
4968
|
+
`Route approval ${stepIndex} (spender ${String(approval.spender)}) has no amount.`
|
|
4969
|
+
);
|
|
4970
|
+
}
|
|
4971
|
+
if (!DECIMAL_INTEGER.test(amount)) {
|
|
4972
|
+
throw new Error(
|
|
4973
|
+
`Route approval ${stepIndex} (spender ${String(approval.spender)}) has an invalid amount "${amount}".`
|
|
4974
|
+
);
|
|
4975
|
+
}
|
|
4976
|
+
return BigInt(amount);
|
|
4977
|
+
}
|
|
4978
|
+
function assertValidRouteApprovals(approvals) {
|
|
4979
|
+
(approvals ?? []).forEach(approvalAmountWei);
|
|
4980
|
+
}
|
|
4981
|
+
var DECIMAL_INTEGER;
|
|
4982
|
+
var init_routeApprovals = __esm({
|
|
4983
|
+
"src/core/routeApprovals.ts"() {
|
|
4984
|
+
"use strict";
|
|
4985
|
+
DECIMAL_INTEGER = /^\d+$/;
|
|
4986
|
+
}
|
|
4987
|
+
});
|
|
4988
|
+
|
|
4963
4989
|
// src/core/routeValue.ts
|
|
4964
4990
|
function parseUsd(value) {
|
|
4965
4991
|
if (value == null) return null;
|
|
@@ -5120,6 +5146,7 @@ async function buildRoute(body, signal) {
|
|
|
5120
5146
|
if (!txReq?.data) {
|
|
5121
5147
|
throw new Error("Invalid route: missing transaction data");
|
|
5122
5148
|
}
|
|
5149
|
+
assertValidRouteApprovals(route?.execution?.approvals);
|
|
5123
5150
|
assertRouteDeliversValue(route);
|
|
5124
5151
|
return { intentId, txReq, actions, finalExchangeRate, route, sponsorship };
|
|
5125
5152
|
}
|
|
@@ -5240,6 +5267,7 @@ var init_routes = __esm({
|
|
|
5240
5267
|
"use strict";
|
|
5241
5268
|
init_http();
|
|
5242
5269
|
init_routeError();
|
|
5270
|
+
init_routeApprovals();
|
|
5243
5271
|
init_routeValue();
|
|
5244
5272
|
init_store();
|
|
5245
5273
|
init_address();
|
|
@@ -6382,11 +6410,13 @@ async function ensureApprovals(w, approvals, fallbackChainId, intentId, routeAmo
|
|
|
6382
6410
|
for (const [stepIndex, approval] of approvals.entries()) {
|
|
6383
6411
|
const spender = approval.spender;
|
|
6384
6412
|
const tokenAddress = approval.tokenAddress;
|
|
6385
|
-
|
|
6386
|
-
if (!spender || !tokenAddress || !amount) continue;
|
|
6413
|
+
if (!spender || !tokenAddress) continue;
|
|
6387
6414
|
const chainId = approval.chainId || String(fallbackChainId ?? "");
|
|
6388
6415
|
if (!chainId) continue;
|
|
6389
|
-
const amountWei = requiredApprovalAmount(
|
|
6416
|
+
const amountWei = requiredApprovalAmount(
|
|
6417
|
+
approvalAmountWei(approval, stepIndex),
|
|
6418
|
+
routeAmountWei
|
|
6419
|
+
);
|
|
6390
6420
|
let currentAllowance = 0n;
|
|
6391
6421
|
try {
|
|
6392
6422
|
const { allowance } = await getEVMAllowance({
|
|
@@ -6472,7 +6502,6 @@ async function sendRouteTransactionReporting(b, fallbackChainId, options, onAcce
|
|
|
6472
6502
|
)}).`
|
|
6473
6503
|
);
|
|
6474
6504
|
}
|
|
6475
|
-
await ensureWalletOnChain(w, target);
|
|
6476
6505
|
if (!validatedSponsorship && !options?.approvalsEnsured) {
|
|
6477
6506
|
await ensureApprovals(
|
|
6478
6507
|
w,
|
|
@@ -6482,6 +6511,7 @@ async function sendRouteTransactionReporting(b, fallbackChainId, options, onAcce
|
|
|
6482
6511
|
BigInt(b.route?.estimate?.fromAmount ?? "0")
|
|
6483
6512
|
);
|
|
6484
6513
|
}
|
|
6514
|
+
await ensureWalletOnChain(w, target);
|
|
6485
6515
|
if (w.type === "eip1193") {
|
|
6486
6516
|
const from = await w.getAddress();
|
|
6487
6517
|
const hexValue = value ? `0x${value.toString(16)}` : "0x0";
|
|
@@ -6648,6 +6678,7 @@ var import_viem2, erc20ApproveAbi, NOT_FOUND_GRACE_MS, UNLIMITED_APPROVAL_FLOOR;
|
|
|
6648
6678
|
var init_tx = __esm({
|
|
6649
6679
|
"src/core/tx.ts"() {
|
|
6650
6680
|
"use strict";
|
|
6681
|
+
init_routeApprovals();
|
|
6651
6682
|
init_routeValue();
|
|
6652
6683
|
init_wallets();
|
|
6653
6684
|
init_routes();
|
|
@@ -9948,11 +9979,7 @@ function mapRouteFacts(facts) {
|
|
|
9948
9979
|
return INVALID_ADDRESS;
|
|
9949
9980
|
}
|
|
9950
9981
|
if (!facts.allDeclined) {
|
|
9951
|
-
return
|
|
9952
|
-
category: "route_error",
|
|
9953
|
-
title: "Route Unavailable",
|
|
9954
|
-
message: "A routing provider did not respond. Please try again in a moment."
|
|
9955
|
-
};
|
|
9982
|
+
return ROUTING_BUSY;
|
|
9956
9983
|
}
|
|
9957
9984
|
const has = (code) => facts.codes.includes(code);
|
|
9958
9985
|
if (has(RouteDeclineCode.FeesExceedOutput)) {
|
|
@@ -9972,12 +9999,8 @@ function mapRouteFacts(facts) {
|
|
|
9972
9999
|
message: minimum ? `This route needs at least ${minimum}. Try a larger amount.` : "This amount is below the minimum for this route. Try a larger amount."
|
|
9973
10000
|
};
|
|
9974
10001
|
}
|
|
9975
|
-
if (
|
|
9976
|
-
return
|
|
9977
|
-
category: "route_error",
|
|
9978
|
-
title: "Insufficient Liquidity",
|
|
9979
|
-
message: "Not enough liquidity for this swap. Try a smaller amount or different token."
|
|
9980
|
-
};
|
|
10002
|
+
if (facts.codes.every((code) => code === RouteDeclineCode.InsufficientLiquidity)) {
|
|
10003
|
+
return INSUFFICIENT_LIQUIDITY;
|
|
9981
10004
|
}
|
|
9982
10005
|
if (facts.codes.every((code) => code === RouteDeclineCode.DestinationCallFailed)) {
|
|
9983
10006
|
return DESTINATION_CALL_FAILED;
|
|
@@ -10029,11 +10052,7 @@ function classifyError(raw, msg) {
|
|
|
10029
10052
|
};
|
|
10030
10053
|
}
|
|
10031
10054
|
if (bm.includes("liquidity") || bm.includes("slippage") || bm.includes("price impact")) {
|
|
10032
|
-
return
|
|
10033
|
-
category: "route_error",
|
|
10034
|
-
title: "Insufficient Liquidity",
|
|
10035
|
-
message: "Not enough liquidity for this swap. Try a smaller amount or different token."
|
|
10036
|
-
};
|
|
10055
|
+
return INSUFFICIENT_LIQUIDITY;
|
|
10037
10056
|
}
|
|
10038
10057
|
if (bm.includes("insufficient funds") || bm.includes("insufficient balance")) {
|
|
10039
10058
|
return {
|
|
@@ -10069,12 +10088,8 @@ function classifyError(raw, msg) {
|
|
|
10069
10088
|
message: "Could not get a quote right now. Please try again."
|
|
10070
10089
|
};
|
|
10071
10090
|
}
|
|
10072
|
-
if (lower.includes("
|
|
10073
|
-
return
|
|
10074
|
-
category: "route_error",
|
|
10075
|
-
title: "Insufficient Liquidity",
|
|
10076
|
-
message: "Not enough liquidity for this swap. Try a smaller amount or different token."
|
|
10077
|
-
};
|
|
10091
|
+
if (lower.includes("enough liquidity") || lower.includes("insufficient liquidity") || lower.includes("price impact too high")) {
|
|
10092
|
+
return INSUFFICIENT_LIQUIDITY;
|
|
10078
10093
|
}
|
|
10079
10094
|
if (lower.includes("destination contract call")) {
|
|
10080
10095
|
return DESTINATION_CALL_FAILED;
|
|
@@ -10082,6 +10097,9 @@ function classifyError(raw, msg) {
|
|
|
10082
10097
|
if (lower.includes("invalid address") || lower.includes("address is not valid")) {
|
|
10083
10098
|
return INVALID_ADDRESS;
|
|
10084
10099
|
}
|
|
10100
|
+
if (lower.includes("routing is busy")) {
|
|
10101
|
+
return ROUTING_BUSY;
|
|
10102
|
+
}
|
|
10085
10103
|
if (lower.includes("did not respond") || lower.includes("routing provider")) {
|
|
10086
10104
|
return {
|
|
10087
10105
|
category: "route_error",
|
|
@@ -10160,7 +10178,7 @@ function classifyError(raw, msg) {
|
|
|
10160
10178
|
message: "An unexpected error occurred. Please try again."
|
|
10161
10179
|
};
|
|
10162
10180
|
}
|
|
10163
|
-
var SELF_MAPPED, INVALID_ADDRESS, DESTINATION_CALL_FAILED;
|
|
10181
|
+
var SELF_MAPPED, INVALID_ADDRESS, DESTINATION_CALL_FAILED, INSUFFICIENT_LIQUIDITY, ROUTING_BUSY;
|
|
10164
10182
|
var init_mapError = __esm({
|
|
10165
10183
|
"src/widget/lib/mapError.ts"() {
|
|
10166
10184
|
"use strict";
|
|
@@ -10181,6 +10199,16 @@ var init_mapError = __esm({
|
|
|
10181
10199
|
title: "Destination Call Failed",
|
|
10182
10200
|
message: "The destination contract call could not be simulated. Check the call data and target."
|
|
10183
10201
|
};
|
|
10202
|
+
INSUFFICIENT_LIQUIDITY = {
|
|
10203
|
+
category: "route_error",
|
|
10204
|
+
title: "Insufficient Liquidity",
|
|
10205
|
+
message: "There isn't enough liquidity to route this swap right now. Try a different token or network, or a smaller amount."
|
|
10206
|
+
};
|
|
10207
|
+
ROUTING_BUSY = {
|
|
10208
|
+
category: "route_error",
|
|
10209
|
+
title: "Route Unavailable",
|
|
10210
|
+
message: "Routing is busy right now. Please wait a moment and try again."
|
|
10211
|
+
};
|
|
10184
10212
|
}
|
|
10185
10213
|
});
|
|
10186
10214
|
|
|
@@ -20092,6 +20120,37 @@ var init_SuccessSummaryCard = __esm({
|
|
|
20092
20120
|
}
|
|
20093
20121
|
});
|
|
20094
20122
|
|
|
20123
|
+
// src/widget/helpers/plannedApprovals.ts
|
|
20124
|
+
function plannedErc20Approvals(approvals, route) {
|
|
20125
|
+
return (approvals ?? []).flatMap((approval, stepIndex) => {
|
|
20126
|
+
const token = approval.tokenAddress ?? route.fromTokenAddress;
|
|
20127
|
+
const spender = approval.spender;
|
|
20128
|
+
if (!isEvmAddress2(token) || !isEvmAddress2(spender)) return [];
|
|
20129
|
+
return [
|
|
20130
|
+
{
|
|
20131
|
+
stepIndex,
|
|
20132
|
+
chainId: approval.chainId || route.chainId,
|
|
20133
|
+
token,
|
|
20134
|
+
spender,
|
|
20135
|
+
// A planned 0 is the reset-to-zero step USDT-style tokens need
|
|
20136
|
+
// before an existing allowance can change; it is kept as 0.
|
|
20137
|
+
amountWei: requiredApprovalAmount(
|
|
20138
|
+
approvalAmountWei(approval, stepIndex),
|
|
20139
|
+
route.amountWei
|
|
20140
|
+
)
|
|
20141
|
+
}
|
|
20142
|
+
];
|
|
20143
|
+
});
|
|
20144
|
+
}
|
|
20145
|
+
var init_plannedApprovals = __esm({
|
|
20146
|
+
"src/widget/helpers/plannedApprovals.ts"() {
|
|
20147
|
+
"use strict";
|
|
20148
|
+
init_routeApprovals();
|
|
20149
|
+
init_tx();
|
|
20150
|
+
init_chainHelpers();
|
|
20151
|
+
}
|
|
20152
|
+
});
|
|
20153
|
+
|
|
20095
20154
|
// src/widget/lib/routeChange.ts
|
|
20096
20155
|
function describeRouteChange(change) {
|
|
20097
20156
|
switch (change.kind) {
|
|
@@ -33389,9 +33448,6 @@ var init_smart_account2 = __esm({
|
|
|
33389
33448
|
});
|
|
33390
33449
|
|
|
33391
33450
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
33392
|
-
function sleep3(ms) {
|
|
33393
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
33394
|
-
}
|
|
33395
33451
|
function useTransactionActionModel({
|
|
33396
33452
|
actionErrorMessage,
|
|
33397
33453
|
amountWei,
|
|
@@ -33429,92 +33485,72 @@ function useTransactionActionModel({
|
|
|
33429
33485
|
selectedChain?.id,
|
|
33430
33486
|
selectedChain?.networkIdentifier
|
|
33431
33487
|
]);
|
|
33432
|
-
const selectedTokenOnBackendChain = (0, import_react38.useMemo)(() => {
|
|
33433
|
-
if (!backendChainId2) return false;
|
|
33434
|
-
const target = normalizeChainKey(backendChainId2);
|
|
33435
|
-
return [
|
|
33436
|
-
selectedChain?.chainId,
|
|
33437
|
-
selectedChain?.id,
|
|
33438
|
-
selectedChain?.networkIdentifier
|
|
33439
|
-
].some((c) => {
|
|
33440
|
-
const k = normalizeChainKey(c ?? null);
|
|
33441
|
-
return k !== "" && k === target;
|
|
33442
|
-
});
|
|
33443
|
-
}, [
|
|
33444
|
-
backendChainId2,
|
|
33445
|
-
selectedChain?.chainId,
|
|
33446
|
-
selectedChain?.id,
|
|
33447
|
-
selectedChain?.networkIdentifier
|
|
33448
|
-
]);
|
|
33449
33488
|
const isNativeSelected = (0, import_react38.useMemo)(() => {
|
|
33450
33489
|
const address = selectedToken?.address;
|
|
33451
33490
|
return !address || isNativeTokenAddress(address, chainType);
|
|
33452
33491
|
}, [chainType, selectedToken?.address]);
|
|
33453
|
-
const
|
|
33454
|
-
|
|
33455
|
-
|
|
33456
|
-
|
|
33457
|
-
|
|
33458
|
-
|
|
33492
|
+
const requiredApprovals = (0, import_react38.useMemo)(
|
|
33493
|
+
() => isEvm && !isNativeSelected && !routeResult?.sponsorship ? plannedErc20Approvals(routeResult?.route?.execution?.approvals, {
|
|
33494
|
+
fromTokenAddress: selectedToken?.address,
|
|
33495
|
+
chainId: backendChainId2 ?? "",
|
|
33496
|
+
amountWei
|
|
33497
|
+
}) : [],
|
|
33498
|
+
[
|
|
33499
|
+
amountWei,
|
|
33500
|
+
backendChainId2,
|
|
33501
|
+
isEvm,
|
|
33502
|
+
isNativeSelected,
|
|
33503
|
+
routeResult?.route?.execution?.approvals,
|
|
33504
|
+
routeResult?.sponsorship,
|
|
33505
|
+
selectedToken?.address
|
|
33506
|
+
]
|
|
33507
|
+
);
|
|
33508
|
+
const [unmetApprovals, setUnmetApprovals] = (0, import_react38.useState)(
|
|
33509
|
+
[]
|
|
33510
|
+
);
|
|
33459
33511
|
const [isReadingAllowance, setIsReadingAllowance] = (0, import_react38.useState)(false);
|
|
33460
33512
|
const [isApproving, setIsApproving] = (0, import_react38.useState)(false);
|
|
33461
33513
|
const [gasReservationWei, setGasReservationWei] = (0, import_react38.useState)(0n);
|
|
33514
|
+
const findUnmetApprovals = (0, import_react38.useCallback)(async () => {
|
|
33515
|
+
if (!walletAddress) return [];
|
|
33516
|
+
const met = await Promise.all(
|
|
33517
|
+
requiredApprovals.map(async (approval) => {
|
|
33518
|
+
try {
|
|
33519
|
+
const { allowance } = await getEVMAllowance({
|
|
33520
|
+
chainId: approval.chainId,
|
|
33521
|
+
tokenAddress: approval.token,
|
|
33522
|
+
ownerAddress: walletAddress,
|
|
33523
|
+
spenderAddress: approval.spender
|
|
33524
|
+
});
|
|
33525
|
+
return approvalSatisfied(
|
|
33526
|
+
BigInt(allowance || "0"),
|
|
33527
|
+
approval.amountWei
|
|
33528
|
+
);
|
|
33529
|
+
} catch {
|
|
33530
|
+
return false;
|
|
33531
|
+
}
|
|
33532
|
+
})
|
|
33533
|
+
);
|
|
33534
|
+
return requiredApprovals.filter((_, index) => !met[index]);
|
|
33535
|
+
}, [requiredApprovals, walletAddress]);
|
|
33462
33536
|
const readAllowance = (0, import_react38.useCallback)(async () => {
|
|
33463
|
-
if (
|
|
33464
|
-
|
|
33465
|
-
setAllowanceWei(0n);
|
|
33537
|
+
if (requiredApprovals.length === 0) {
|
|
33538
|
+
setUnmetApprovals([]);
|
|
33466
33539
|
return;
|
|
33467
33540
|
}
|
|
33541
|
+
setIsReadingAllowance(true);
|
|
33468
33542
|
try {
|
|
33469
|
-
|
|
33470
|
-
const result = await getEVMAllowance({
|
|
33471
|
-
chainId: backendChainId2,
|
|
33472
|
-
tokenAddress: selectedToken.address,
|
|
33473
|
-
ownerAddress: walletAddress,
|
|
33474
|
-
spenderAddress: spender
|
|
33475
|
-
});
|
|
33476
|
-
setAllowanceWei(BigInt(result.allowance || "0"));
|
|
33477
|
-
} catch {
|
|
33478
|
-
setAllowanceWei(0n);
|
|
33543
|
+
setUnmetApprovals(await findUnmetApprovals());
|
|
33479
33544
|
} finally {
|
|
33480
33545
|
setIsReadingAllowance(false);
|
|
33481
33546
|
}
|
|
33482
|
-
}, [
|
|
33483
|
-
backendChainId2,
|
|
33484
|
-
isEvm,
|
|
33485
|
-
isNativeSelected,
|
|
33486
|
-
routeResult?.sponsorship,
|
|
33487
|
-
selectedTokenOnBackendChain,
|
|
33488
|
-
selectedToken?.address,
|
|
33489
|
-
spender,
|
|
33490
|
-
walletAddress
|
|
33491
|
-
]);
|
|
33547
|
+
}, [findUnmetApprovals, requiredApprovals.length]);
|
|
33492
33548
|
(0, import_react38.useEffect)(() => {
|
|
33493
33549
|
void readAllowance();
|
|
33494
33550
|
}, [readAllowance]);
|
|
33495
|
-
const needsApproval =
|
|
33496
|
-
!!walletAddress && !!spender && amountWei > 0n && allowanceWei < amountWei;
|
|
33497
|
-
const waitForApprovalConfirmation2 = (0, import_react38.useCallback)(
|
|
33498
|
-
async (chainId, txHash) => {
|
|
33499
|
-
const timeoutMs = 12e4;
|
|
33500
|
-
const intervalMs = 2e3;
|
|
33501
|
-
const started = Date.now();
|
|
33502
|
-
while (Date.now() - started < timeoutMs) {
|
|
33503
|
-
const status = await getEVMTxStatus({ chainId, txHash });
|
|
33504
|
-
if (status.status === "success") {
|
|
33505
|
-
return;
|
|
33506
|
-
}
|
|
33507
|
-
if (status.status === "reverted") {
|
|
33508
|
-
throw new Error("Approval transaction reverted");
|
|
33509
|
-
}
|
|
33510
|
-
await sleep3(intervalMs);
|
|
33511
|
-
}
|
|
33512
|
-
throw new Error("Timed out waiting for approval confirmation");
|
|
33513
|
-
},
|
|
33514
|
-
[]
|
|
33515
|
-
);
|
|
33551
|
+
const needsApproval = !!walletAddress && amountWei > 0n && unmetApprovals.length > 0;
|
|
33516
33552
|
const handleApproveExact = (0, import_react38.useCallback)(async () => {
|
|
33517
|
-
if (isApproving || amountWei <= 0n || !walletAddress ||
|
|
33553
|
+
if (isApproving || amountWei <= 0n || !walletAddress || unmetApprovals.length === 0) {
|
|
33518
33554
|
return;
|
|
33519
33555
|
}
|
|
33520
33556
|
const wallet = Trustware.getWallet();
|
|
@@ -33530,80 +33566,57 @@ function useTransactionActionModel({
|
|
|
33530
33566
|
});
|
|
33531
33567
|
setIsApproving(true);
|
|
33532
33568
|
try {
|
|
33533
|
-
const
|
|
33534
|
-
|
|
33535
|
-
|
|
33536
|
-
|
|
33537
|
-
|
|
33538
|
-
|
|
33539
|
-
|
|
33540
|
-
});
|
|
33541
|
-
if (Number.isFinite(targetChain)) {
|
|
33542
|
-
const current = await wallet.getChainId();
|
|
33543
|
-
if (current !== targetChain) {
|
|
33544
|
-
try {
|
|
33545
|
-
await wallet.switchChain(targetChain);
|
|
33546
|
-
} catch {
|
|
33547
|
-
}
|
|
33548
|
-
}
|
|
33549
|
-
}
|
|
33550
|
-
const data = (0, import_viem42.encodeFunctionData)({
|
|
33551
|
-
abi: import_viem42.erc20Abi,
|
|
33552
|
-
functionName: "approve",
|
|
33553
|
-
args: [spender, amountWei]
|
|
33554
|
-
});
|
|
33555
|
-
let hash;
|
|
33556
|
-
if (wallet.type === "eip1193") {
|
|
33557
|
-
const from = await wallet.getAddress();
|
|
33558
|
-
const params = {
|
|
33559
|
-
from,
|
|
33560
|
-
to: selectedToken.address,
|
|
33561
|
-
data,
|
|
33562
|
-
value: "0x0"
|
|
33563
|
-
};
|
|
33564
|
-
if (Number.isFinite(targetChain)) {
|
|
33565
|
-
params.chainId = `0x${targetChain.toString(16)}`;
|
|
33566
|
-
}
|
|
33567
|
-
hash = await wallet.request({
|
|
33568
|
-
method: "eth_sendTransaction",
|
|
33569
|
-
params: [params]
|
|
33569
|
+
for (const approval of unmetApprovals) {
|
|
33570
|
+
const approvalChain = Number(approval.chainId);
|
|
33571
|
+
await ensureWalletOnChain(wallet, approvalChain);
|
|
33572
|
+
const data = (0, import_viem42.encodeFunctionData)({
|
|
33573
|
+
abi: import_viem42.erc20Abi,
|
|
33574
|
+
functionName: "approve",
|
|
33575
|
+
args: [approval.spender, approval.amountWei]
|
|
33570
33576
|
});
|
|
33571
|
-
|
|
33572
|
-
|
|
33573
|
-
|
|
33574
|
-
|
|
33575
|
-
|
|
33576
|
-
|
|
33577
|
-
|
|
33578
|
-
|
|
33579
|
-
|
|
33580
|
-
|
|
33581
|
-
|
|
33582
|
-
|
|
33583
|
-
|
|
33584
|
-
|
|
33577
|
+
let hash;
|
|
33578
|
+
if (wallet.type === "eip1193") {
|
|
33579
|
+
const from = await wallet.getAddress();
|
|
33580
|
+
hash = await wallet.request({
|
|
33581
|
+
method: "eth_sendTransaction",
|
|
33582
|
+
params: [
|
|
33583
|
+
{
|
|
33584
|
+
from,
|
|
33585
|
+
to: approval.token,
|
|
33586
|
+
data,
|
|
33587
|
+
value: "0x0",
|
|
33588
|
+
chainId: `0x${approvalChain.toString(16)}`
|
|
33589
|
+
}
|
|
33590
|
+
]
|
|
33591
|
+
});
|
|
33592
|
+
} else {
|
|
33593
|
+
const response = await wallet.sendTransaction({
|
|
33594
|
+
to: approval.token,
|
|
33595
|
+
data,
|
|
33596
|
+
value: 0n,
|
|
33597
|
+
chainId: approvalChain
|
|
33598
|
+
});
|
|
33599
|
+
hash = response.hash;
|
|
33600
|
+
}
|
|
33601
|
+
await waitForApprovalConfirmation(approval.chainId, hash);
|
|
33585
33602
|
}
|
|
33603
|
+
await readAllowance();
|
|
33586
33604
|
} catch {
|
|
33587
33605
|
} finally {
|
|
33588
33606
|
setIsApproving(false);
|
|
33589
33607
|
}
|
|
33590
33608
|
}, [
|
|
33591
33609
|
amountWei,
|
|
33592
|
-
backendChainId2,
|
|
33593
33610
|
destinationConfig?.routes.toChain,
|
|
33594
33611
|
destinationConfig?.routes.toToken,
|
|
33595
33612
|
isApproving,
|
|
33596
33613
|
readAllowance,
|
|
33597
|
-
routeResult?.txReq?.chainId,
|
|
33598
33614
|
selectedChain?.axelarChainName,
|
|
33599
33615
|
selectedChain?.chainId,
|
|
33600
|
-
selectedChain?.id,
|
|
33601
33616
|
selectedChain?.networkName,
|
|
33602
|
-
selectedToken?.address,
|
|
33603
33617
|
selectedToken?.symbol,
|
|
33604
|
-
spender,
|
|
33605
33618
|
trackEvent,
|
|
33606
|
-
|
|
33619
|
+
unmetApprovals,
|
|
33607
33620
|
walletAddress
|
|
33608
33621
|
]);
|
|
33609
33622
|
const getCachedFeeData = (0, import_react38.useCallback)(async () => {
|
|
@@ -33790,32 +33803,13 @@ function useTransactionActionModel({
|
|
|
33790
33803
|
const handleSwipeConfirm = (0, import_react38.useCallback)(async () => {
|
|
33791
33804
|
if (needsApproval) {
|
|
33792
33805
|
await handleApproveExact();
|
|
33793
|
-
if (
|
|
33794
|
-
return;
|
|
33795
|
-
}
|
|
33796
|
-
const freshAllowance = await getEVMAllowance({
|
|
33797
|
-
chainId: backendChainId2,
|
|
33798
|
-
tokenAddress: selectedToken.address,
|
|
33799
|
-
ownerAddress: walletAddress,
|
|
33800
|
-
spenderAddress: spender
|
|
33801
|
-
}).then((r) => BigInt(r.allowance || "0")).catch(() => 0n);
|
|
33802
|
-
if (freshAllowance >= amountWei) {
|
|
33806
|
+
if ((await findUnmetApprovals()).length === 0) {
|
|
33803
33807
|
await handleConfirm();
|
|
33804
33808
|
}
|
|
33805
33809
|
return;
|
|
33806
33810
|
}
|
|
33807
33811
|
await handleConfirm();
|
|
33808
|
-
}, [
|
|
33809
|
-
amountWei,
|
|
33810
|
-
backendChainId2,
|
|
33811
|
-
handleApproveExact,
|
|
33812
|
-
handleConfirm,
|
|
33813
|
-
needsApproval,
|
|
33814
|
-
selectedTokenOnBackendChain,
|
|
33815
|
-
selectedToken?.address,
|
|
33816
|
-
spender,
|
|
33817
|
-
walletAddress
|
|
33818
|
-
]);
|
|
33812
|
+
}, [findUnmetApprovals, handleApproveExact, handleConfirm, needsApproval]);
|
|
33819
33813
|
const isWalletConnected = walletStatus === "connected";
|
|
33820
33814
|
const canSwipe = parsedAmount > 0 && !!selectedToken && isWalletConnected && !isLoadingRoute && !isSubmitting && !!routeResult && !actionErrorMessage && !isApproving && !isReadingAllowance;
|
|
33821
33815
|
const swipeResetKey = (0, import_react38.useMemo)(() => {
|
|
@@ -33862,9 +33856,11 @@ var init_useTransactionActionModel = __esm({
|
|
|
33862
33856
|
import_viem42 = require("viem");
|
|
33863
33857
|
init_core2();
|
|
33864
33858
|
init_sdkRpc();
|
|
33859
|
+
init_tx();
|
|
33865
33860
|
init_hooks2();
|
|
33866
33861
|
init_chains();
|
|
33867
33862
|
init_utils();
|
|
33863
|
+
init_plannedApprovals();
|
|
33868
33864
|
init_hooks();
|
|
33869
33865
|
init_routeChange();
|
|
33870
33866
|
}
|
|
@@ -35305,33 +35301,15 @@ function useSwapExecution(fromChain) {
|
|
|
35305
35301
|
const chainIdStr = String(txReq?.chainId ?? fromChain?.chainId ?? "");
|
|
35306
35302
|
const amountWei = BigInt(routeResult.route?.estimate?.fromAmount ?? "0");
|
|
35307
35303
|
const plannedApprovals = routeResult.route?.execution?.approvals ?? [];
|
|
35308
|
-
|
|
35309
|
-
|
|
35310
|
-
|
|
35311
|
-
|
|
35312
|
-
|
|
35313
|
-
|
|
35314
|
-
|
|
35315
|
-
|
|
35316
|
-
|
|
35317
|
-
chainId: a.chainId || chainIdStr,
|
|
35318
|
-
token,
|
|
35319
|
-
spender: a.spender,
|
|
35320
|
-
required
|
|
35321
|
-
}
|
|
35322
|
-
];
|
|
35323
|
-
}) : (() => {
|
|
35324
|
-
const spender = txReq?.to ?? txReq?.target;
|
|
35325
|
-
if (!spender) return [];
|
|
35326
|
-
return [
|
|
35327
|
-
{
|
|
35328
|
-
chainId: chainIdStr,
|
|
35329
|
-
token: fromTokenAddress,
|
|
35330
|
-
spender,
|
|
35331
|
-
required: amountWei
|
|
35332
|
-
}
|
|
35333
|
-
];
|
|
35334
|
-
})();
|
|
35304
|
+
if (plannedApprovals.length === 0) {
|
|
35305
|
+
setState((p) => ({ ...p, allowanceStatus: "sufficient" }));
|
|
35306
|
+
return;
|
|
35307
|
+
}
|
|
35308
|
+
const toCheck = plannedErc20Approvals(plannedApprovals, {
|
|
35309
|
+
fromTokenAddress,
|
|
35310
|
+
chainId: chainIdStr,
|
|
35311
|
+
amountWei
|
|
35312
|
+
});
|
|
35335
35313
|
if (toCheck.length === 0 || !chainIdStr || amountWei === 0n) {
|
|
35336
35314
|
setState((p) => ({ ...p, allowanceStatus: "unknown" }));
|
|
35337
35315
|
return;
|
|
@@ -35346,7 +35324,7 @@ function useSwapExecution(fromChain) {
|
|
|
35346
35324
|
ownerAddress: walletAddress,
|
|
35347
35325
|
spenderAddress: c.spender
|
|
35348
35326
|
});
|
|
35349
|
-
return approvalSatisfied(BigInt(allowance || "0"), c.
|
|
35327
|
+
return approvalSatisfied(BigInt(allowance || "0"), c.amountWei);
|
|
35350
35328
|
})
|
|
35351
35329
|
);
|
|
35352
35330
|
setState((p) => ({
|
|
@@ -35401,7 +35379,6 @@ function useSwapExecution(fromChain) {
|
|
|
35401
35379
|
const txReq = routeResult.txReq;
|
|
35402
35380
|
const numericChainId = Number(txReq.chainId ?? fromChain?.chainId) || void 0;
|
|
35403
35381
|
const chainIdStr = String(txReq.chainId ?? fromChain?.chainId ?? "");
|
|
35404
|
-
const spender = txReq.to ?? txReq.target;
|
|
35405
35382
|
const chainType = normalizeChainType(fromChain);
|
|
35406
35383
|
const isNative = !fromTokenAddress || isNativeTokenAddress(fromTokenAddress, chainType);
|
|
35407
35384
|
const fromAmountWei = BigInt(
|
|
@@ -35481,34 +35458,12 @@ function useSwapExecution(fromChain) {
|
|
|
35481
35458
|
const acceptance = { tracking: false };
|
|
35482
35459
|
try {
|
|
35483
35460
|
const plannedApprovals = routeResult.route?.execution?.approvals ?? [];
|
|
35484
|
-
const requiredApprovals = plannedApprovals
|
|
35485
|
-
|
|
35486
|
-
|
|
35487
|
-
|
|
35488
|
-
|
|
35489
|
-
|
|
35490
|
-
BigInt(a.amount || "0"),
|
|
35491
|
-
fromAmountWei
|
|
35492
|
-
);
|
|
35493
|
-
return [
|
|
35494
|
-
{
|
|
35495
|
-
stepIndex: index,
|
|
35496
|
-
token,
|
|
35497
|
-
spender: approvalSpender,
|
|
35498
|
-
amountWei,
|
|
35499
|
-
chainId: a.chainId || chainIdStr
|
|
35500
|
-
}
|
|
35501
|
-
];
|
|
35502
|
-
}) : spender && fromTokenAddress ? [
|
|
35503
|
-
{
|
|
35504
|
-
stepIndex: null,
|
|
35505
|
-
token: fromTokenAddress,
|
|
35506
|
-
spender,
|
|
35507
|
-
amountWei: fromAmountWei,
|
|
35508
|
-
chainId: chainIdStr
|
|
35509
|
-
}
|
|
35510
|
-
] : [];
|
|
35511
|
-
const coversEveryPlannedApproval = plannedApprovals.length === 0 || requiredApprovals.length === plannedApprovals.length;
|
|
35461
|
+
const requiredApprovals = plannedErc20Approvals(plannedApprovals, {
|
|
35462
|
+
fromTokenAddress,
|
|
35463
|
+
chainId: chainIdStr,
|
|
35464
|
+
amountWei: fromAmountWei
|
|
35465
|
+
});
|
|
35466
|
+
const coversEveryPlannedApproval = requiredApprovals.length === plannedApprovals.length;
|
|
35512
35467
|
const ownsApprovals = coversEveryPlannedApproval && needsErc20Approval(fromTokenAddress, chainType) && !!walletAddress && !!chainIdStr;
|
|
35513
35468
|
const activeAddress = ownsApprovals ? await requireActiveAddress(wallet, walletAddress) : void 0;
|
|
35514
35469
|
for (const required of requiredApprovals) {
|
|
@@ -35570,14 +35525,12 @@ function useSwapExecution(fromChain) {
|
|
|
35570
35525
|
});
|
|
35571
35526
|
approvalHash = response.hash;
|
|
35572
35527
|
}
|
|
35573
|
-
|
|
35574
|
-
|
|
35575
|
-
|
|
35576
|
-
|
|
35577
|
-
|
|
35578
|
-
|
|
35579
|
-
});
|
|
35580
|
-
}
|
|
35528
|
+
void submitStepReceipt(
|
|
35529
|
+
routeResult.intentId,
|
|
35530
|
+
required.stepIndex,
|
|
35531
|
+
approvalHash
|
|
35532
|
+
).catch(() => {
|
|
35533
|
+
});
|
|
35581
35534
|
await waitForApprovalConfirmation(required.chainId, approvalHash);
|
|
35582
35535
|
setState((p) => ({
|
|
35583
35536
|
...p,
|
|
@@ -35696,6 +35649,7 @@ var init_useSwapExecution = __esm({
|
|
|
35696
35649
|
init_tx();
|
|
35697
35650
|
init_sdkRpc();
|
|
35698
35651
|
init_chainHelpers();
|
|
35652
|
+
init_plannedApprovals();
|
|
35699
35653
|
init_chains();
|
|
35700
35654
|
SA_COOLDOWN_MS = 3e4;
|
|
35701
35655
|
}
|
|
@@ -37947,6 +37901,26 @@ var init_currency = __esm({
|
|
|
37947
37901
|
}
|
|
37948
37902
|
});
|
|
37949
37903
|
|
|
37904
|
+
// src/modes/swap/amountFormat.ts
|
|
37905
|
+
function fmtAmount(n, maxFractionDigits = 6) {
|
|
37906
|
+
if (!isFinite(n) || n === 0) return "0";
|
|
37907
|
+
if (Math.abs(n) < 10 ** -maxFractionDigits) {
|
|
37908
|
+
return n.toLocaleString(void 0, {
|
|
37909
|
+
maximumSignificantDigits: SMALL_AMOUNT_SIGNIFICANT_DIGITS
|
|
37910
|
+
});
|
|
37911
|
+
}
|
|
37912
|
+
return n.toLocaleString(void 0, {
|
|
37913
|
+
maximumFractionDigits: maxFractionDigits
|
|
37914
|
+
});
|
|
37915
|
+
}
|
|
37916
|
+
var SMALL_AMOUNT_SIGNIFICANT_DIGITS;
|
|
37917
|
+
var init_amountFormat = __esm({
|
|
37918
|
+
"src/modes/swap/amountFormat.ts"() {
|
|
37919
|
+
"use strict";
|
|
37920
|
+
SMALL_AMOUNT_SIGNIFICANT_DIGITS = 2;
|
|
37921
|
+
}
|
|
37922
|
+
});
|
|
37923
|
+
|
|
37950
37924
|
// src/widget/lib/quoteCountdown.ts
|
|
37951
37925
|
function quoteCountdown(elapsedMs, intervalMs) {
|
|
37952
37926
|
if (!Number.isFinite(intervalMs) || intervalMs <= 0) {
|
|
@@ -39265,10 +39239,6 @@ var init_components2 = __esm({
|
|
|
39265
39239
|
});
|
|
39266
39240
|
|
|
39267
39241
|
// src/modes/swap/SwapMode.tsx
|
|
39268
|
-
function fmtAmount(n, max = 6) {
|
|
39269
|
-
if (!isFinite(n) || n === 0) return "0";
|
|
39270
|
-
return n.toLocaleString(void 0, { maximumFractionDigits: max });
|
|
39271
|
-
}
|
|
39272
39242
|
function buildExplorerUrl(hash, chain, backendUrl) {
|
|
39273
39243
|
if (backendUrl) return backendUrl;
|
|
39274
39244
|
const base2 = chain?.blockExplorerUrls?.[0];
|
|
@@ -41005,249 +40975,34 @@ function SwapMode({
|
|
|
41005
40975
|
}
|
|
41006
40976
|
),
|
|
41007
40977
|
completedStr && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(SuccessReceiptRow, { label: "Completed", value: completedStr }),
|
|
41008
|
-
txHash && ((
|
|
41009
|
-
|
|
41010
|
-
|
|
41011
|
-
|
|
41012
|
-
|
|
41013
|
-
|
|
41014
|
-
|
|
41015
|
-
|
|
41016
|
-
|
|
41017
|
-
|
|
41018
|
-
|
|
41019
|
-
|
|
41020
|
-
|
|
41021
|
-
|
|
41022
|
-
|
|
41023
|
-
|
|
41024
|
-
|
|
41025
|
-
|
|
41026
|
-
|
|
41027
|
-
|
|
41028
|
-
|
|
41029
|
-
|
|
41030
|
-
|
|
41031
|
-
|
|
41032
|
-
|
|
41033
|
-
|
|
41034
|
-
|
|
41035
|
-
|
|
41036
|
-
{
|
|
41037
|
-
href: srcUrl,
|
|
41038
|
-
target: "_blank",
|
|
41039
|
-
rel: "noopener noreferrer",
|
|
41040
|
-
style: {
|
|
41041
|
-
display: "inline-flex",
|
|
41042
|
-
alignItems: "center",
|
|
41043
|
-
gap: "0.25rem",
|
|
41044
|
-
color: colors.foreground,
|
|
41045
|
-
fontWeight: fontWeight.medium,
|
|
41046
|
-
textDecorationLine: "underline",
|
|
41047
|
-
textDecorationStyle: "dotted",
|
|
41048
|
-
textUnderlineOffset: "4px"
|
|
41049
|
-
},
|
|
41050
|
-
children: [
|
|
41051
|
-
txHash.slice(0, 6),
|
|
41052
|
-
"\u2026",
|
|
41053
|
-
txHash.slice(-4),
|
|
41054
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
41055
|
-
"svg",
|
|
41056
|
-
{
|
|
41057
|
-
style: { width: "0.75rem", height: "0.75rem" },
|
|
41058
|
-
viewBox: "0 0 24 24",
|
|
41059
|
-
fill: "none",
|
|
41060
|
-
stroke: "currentColor",
|
|
41061
|
-
strokeWidth: 2,
|
|
41062
|
-
strokeLinecap: "round",
|
|
41063
|
-
strokeLinejoin: "round",
|
|
41064
|
-
children: [
|
|
41065
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
|
|
41066
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("polyline", { points: "15 3 21 3 21 9" }),
|
|
41067
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
|
|
41068
|
-
]
|
|
41069
|
-
}
|
|
41070
|
-
)
|
|
41071
|
-
]
|
|
41072
|
-
}
|
|
41073
|
-
),
|
|
41074
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
41075
|
-
"button",
|
|
41076
|
-
{
|
|
41077
|
-
onClick: () => handleCopyHash(txHash),
|
|
41078
|
-
title: "Copy full hash",
|
|
41079
|
-
style: {
|
|
41080
|
-
display: "inline-flex",
|
|
41081
|
-
alignItems: "center",
|
|
41082
|
-
gap: "0.2rem",
|
|
41083
|
-
fontSize: fontSize.xs,
|
|
41084
|
-
color: isCopied ? colors.green[500] : colors.mutedForeground,
|
|
41085
|
-
backgroundColor: "transparent",
|
|
41086
|
-
border: 0,
|
|
41087
|
-
cursor: "pointer",
|
|
41088
|
-
fontFamily: "inherit",
|
|
41089
|
-
padding: 0,
|
|
41090
|
-
transition: "color 0.15s"
|
|
41091
|
-
},
|
|
41092
|
-
children: isCopied ? "Copied!" : /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
41093
|
-
"svg",
|
|
41094
|
-
{
|
|
41095
|
-
style: {
|
|
41096
|
-
width: "0.875rem",
|
|
41097
|
-
height: "0.875rem"
|
|
41098
|
-
},
|
|
41099
|
-
viewBox: "0 0 24 24",
|
|
41100
|
-
fill: "none",
|
|
41101
|
-
stroke: "currentColor",
|
|
41102
|
-
strokeWidth: 2,
|
|
41103
|
-
strokeLinecap: "round",
|
|
41104
|
-
strokeLinejoin: "round",
|
|
41105
|
-
children: [
|
|
41106
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
41107
|
-
"rect",
|
|
41108
|
-
{
|
|
41109
|
-
x: "9",
|
|
41110
|
-
y: "9",
|
|
41111
|
-
width: "13",
|
|
41112
|
-
height: "13",
|
|
41113
|
-
rx: "2",
|
|
41114
|
-
ry: "2"
|
|
41115
|
-
}
|
|
41116
|
-
),
|
|
41117
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
41118
|
-
]
|
|
41119
|
-
}
|
|
41120
|
-
)
|
|
41121
|
-
}
|
|
41122
|
-
)
|
|
41123
|
-
]
|
|
41124
|
-
}
|
|
41125
|
-
)
|
|
41126
|
-
]
|
|
41127
|
-
}
|
|
41128
|
-
);
|
|
41129
|
-
})(),
|
|
41130
|
-
destTxHash && (() => {
|
|
41131
|
-
const destUrl = buildExplorerUrl(
|
|
41132
|
-
destTxHash,
|
|
41133
|
-
toChain,
|
|
41134
|
-
toChainTxUrl
|
|
41135
|
-
);
|
|
41136
|
-
const isCopied = copiedHash === destTxHash;
|
|
41137
|
-
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
41138
|
-
"div",
|
|
41139
|
-
{
|
|
41140
|
-
style: {
|
|
41141
|
-
display: "flex",
|
|
41142
|
-
alignItems: "center",
|
|
41143
|
-
justifyContent: "space-between"
|
|
41144
|
-
},
|
|
41145
|
-
children: [
|
|
41146
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { style: { color: colors.mutedForeground }, children: "Destination tx" }),
|
|
41147
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
41148
|
-
"div",
|
|
41149
|
-
{
|
|
41150
|
-
style: {
|
|
41151
|
-
display: "inline-flex",
|
|
41152
|
-
alignItems: "center",
|
|
41153
|
-
gap: spacing[2]
|
|
41154
|
-
},
|
|
41155
|
-
children: [
|
|
41156
|
-
destUrl && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
41157
|
-
"a",
|
|
41158
|
-
{
|
|
41159
|
-
href: destUrl,
|
|
41160
|
-
target: "_blank",
|
|
41161
|
-
rel: "noopener noreferrer",
|
|
41162
|
-
style: {
|
|
41163
|
-
display: "inline-flex",
|
|
41164
|
-
alignItems: "center",
|
|
41165
|
-
gap: "0.25rem",
|
|
41166
|
-
color: colors.foreground,
|
|
41167
|
-
fontWeight: fontWeight.medium,
|
|
41168
|
-
textDecorationLine: "underline",
|
|
41169
|
-
textDecorationStyle: "dotted",
|
|
41170
|
-
textUnderlineOffset: "4px"
|
|
41171
|
-
},
|
|
41172
|
-
children: [
|
|
41173
|
-
destTxHash.slice(0, 6),
|
|
41174
|
-
"\u2026",
|
|
41175
|
-
destTxHash.slice(-4),
|
|
41176
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
41177
|
-
"svg",
|
|
41178
|
-
{
|
|
41179
|
-
style: { width: "0.75rem", height: "0.75rem" },
|
|
41180
|
-
viewBox: "0 0 24 24",
|
|
41181
|
-
fill: "none",
|
|
41182
|
-
stroke: "currentColor",
|
|
41183
|
-
strokeWidth: 2,
|
|
41184
|
-
strokeLinecap: "round",
|
|
41185
|
-
strokeLinejoin: "round",
|
|
41186
|
-
children: [
|
|
41187
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
|
|
41188
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("polyline", { points: "15 3 21 3 21 9" }),
|
|
41189
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
|
|
41190
|
-
]
|
|
41191
|
-
}
|
|
41192
|
-
)
|
|
41193
|
-
]
|
|
41194
|
-
}
|
|
41195
|
-
),
|
|
41196
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
41197
|
-
"button",
|
|
41198
|
-
{
|
|
41199
|
-
onClick: () => handleCopyHash(destTxHash),
|
|
41200
|
-
title: "Copy full hash",
|
|
41201
|
-
style: {
|
|
41202
|
-
display: "inline-flex",
|
|
41203
|
-
alignItems: "center",
|
|
41204
|
-
fontSize: fontSize.xs,
|
|
41205
|
-
color: isCopied ? colors.green[500] : colors.mutedForeground,
|
|
41206
|
-
backgroundColor: "transparent",
|
|
41207
|
-
border: 0,
|
|
41208
|
-
cursor: "pointer",
|
|
41209
|
-
fontFamily: "inherit",
|
|
41210
|
-
padding: 0,
|
|
41211
|
-
transition: "color 0.15s"
|
|
41212
|
-
},
|
|
41213
|
-
children: isCopied ? "Copied!" : /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
41214
|
-
"svg",
|
|
41215
|
-
{
|
|
41216
|
-
style: {
|
|
41217
|
-
width: "0.875rem",
|
|
41218
|
-
height: "0.875rem"
|
|
41219
|
-
},
|
|
41220
|
-
viewBox: "0 0 24 24",
|
|
41221
|
-
fill: "none",
|
|
41222
|
-
stroke: "currentColor",
|
|
41223
|
-
strokeWidth: 2,
|
|
41224
|
-
strokeLinecap: "round",
|
|
41225
|
-
strokeLinejoin: "round",
|
|
41226
|
-
children: [
|
|
41227
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
41228
|
-
"rect",
|
|
41229
|
-
{
|
|
41230
|
-
x: "9",
|
|
41231
|
-
y: "9",
|
|
41232
|
-
width: "13",
|
|
41233
|
-
height: "13",
|
|
41234
|
-
rx: "2",
|
|
41235
|
-
ry: "2"
|
|
41236
|
-
}
|
|
41237
|
-
),
|
|
41238
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
41239
|
-
]
|
|
41240
|
-
}
|
|
41241
|
-
)
|
|
41242
|
-
}
|
|
41243
|
-
)
|
|
41244
|
-
]
|
|
41245
|
-
}
|
|
41246
|
-
)
|
|
41247
|
-
]
|
|
41248
|
-
}
|
|
41249
|
-
);
|
|
41250
|
-
})()
|
|
40978
|
+
txHash && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
40979
|
+
SuccessTxHashRow,
|
|
40980
|
+
{
|
|
40981
|
+
label: destTxHash ? "Source tx" : "Transaction",
|
|
40982
|
+
hash: txHash,
|
|
40983
|
+
explorerUrl: buildExplorerUrl(
|
|
40984
|
+
txHash,
|
|
40985
|
+
fromChain,
|
|
40986
|
+
fromChainTxUrl
|
|
40987
|
+
),
|
|
40988
|
+
isCopied: copiedHash === txHash,
|
|
40989
|
+
onCopy: handleCopyHash
|
|
40990
|
+
}
|
|
40991
|
+
),
|
|
40992
|
+
destTxHash && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
40993
|
+
SuccessTxHashRow,
|
|
40994
|
+
{
|
|
40995
|
+
label: "Destination tx",
|
|
40996
|
+
hash: destTxHash,
|
|
40997
|
+
explorerUrl: buildExplorerUrl(
|
|
40998
|
+
destTxHash,
|
|
40999
|
+
toChain,
|
|
41000
|
+
toChainTxUrl
|
|
41001
|
+
),
|
|
41002
|
+
isCopied: copiedHash === destTxHash,
|
|
41003
|
+
onCopy: handleCopyHash
|
|
41004
|
+
}
|
|
41005
|
+
)
|
|
41251
41006
|
]
|
|
41252
41007
|
}
|
|
41253
41008
|
)
|
|
@@ -43596,6 +43351,119 @@ function SuccessReceiptRow({
|
|
|
43596
43351
|
}
|
|
43597
43352
|
);
|
|
43598
43353
|
}
|
|
43354
|
+
function SuccessTxHashRow({
|
|
43355
|
+
label,
|
|
43356
|
+
hash,
|
|
43357
|
+
explorerUrl,
|
|
43358
|
+
isCopied,
|
|
43359
|
+
onCopy
|
|
43360
|
+
}) {
|
|
43361
|
+
const shortHash = `${hash.slice(0, 6)}\u2026${hash.slice(-4)}`;
|
|
43362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
43363
|
+
"div",
|
|
43364
|
+
{
|
|
43365
|
+
style: {
|
|
43366
|
+
display: "flex",
|
|
43367
|
+
alignItems: "center",
|
|
43368
|
+
justifyContent: "space-between"
|
|
43369
|
+
},
|
|
43370
|
+
children: [
|
|
43371
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { style: { color: colors.mutedForeground }, children: label }),
|
|
43372
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
43373
|
+
"div",
|
|
43374
|
+
{
|
|
43375
|
+
style: {
|
|
43376
|
+
display: "inline-flex",
|
|
43377
|
+
alignItems: "center",
|
|
43378
|
+
gap: spacing[2]
|
|
43379
|
+
},
|
|
43380
|
+
children: [
|
|
43381
|
+
explorerUrl ? /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
43382
|
+
"a",
|
|
43383
|
+
{
|
|
43384
|
+
href: explorerUrl,
|
|
43385
|
+
target: "_blank",
|
|
43386
|
+
rel: "noopener noreferrer",
|
|
43387
|
+
style: {
|
|
43388
|
+
display: "inline-flex",
|
|
43389
|
+
alignItems: "center",
|
|
43390
|
+
gap: "0.25rem",
|
|
43391
|
+
color: colors.foreground,
|
|
43392
|
+
fontWeight: fontWeight.medium,
|
|
43393
|
+
textDecorationLine: "underline",
|
|
43394
|
+
textDecorationStyle: "dotted",
|
|
43395
|
+
textUnderlineOffset: "4px"
|
|
43396
|
+
},
|
|
43397
|
+
children: [
|
|
43398
|
+
shortHash,
|
|
43399
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
43400
|
+
"svg",
|
|
43401
|
+
{
|
|
43402
|
+
style: { width: "0.75rem", height: "0.75rem" },
|
|
43403
|
+
viewBox: "0 0 24 24",
|
|
43404
|
+
fill: "none",
|
|
43405
|
+
stroke: "currentColor",
|
|
43406
|
+
strokeWidth: 2,
|
|
43407
|
+
strokeLinecap: "round",
|
|
43408
|
+
strokeLinejoin: "round",
|
|
43409
|
+
children: [
|
|
43410
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
|
|
43411
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("polyline", { points: "15 3 21 3 21 9" }),
|
|
43412
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
|
|
43413
|
+
]
|
|
43414
|
+
}
|
|
43415
|
+
)
|
|
43416
|
+
]
|
|
43417
|
+
}
|
|
43418
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
43419
|
+
"span",
|
|
43420
|
+
{
|
|
43421
|
+
style: { color: colors.foreground, fontWeight: fontWeight.medium },
|
|
43422
|
+
children: shortHash
|
|
43423
|
+
}
|
|
43424
|
+
),
|
|
43425
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
43426
|
+
"button",
|
|
43427
|
+
{
|
|
43428
|
+
onClick: () => onCopy(hash),
|
|
43429
|
+
title: "Copy full hash",
|
|
43430
|
+
style: {
|
|
43431
|
+
display: "inline-flex",
|
|
43432
|
+
alignItems: "center",
|
|
43433
|
+
fontSize: fontSize.xs,
|
|
43434
|
+
color: isCopied ? colors.green[500] : colors.mutedForeground,
|
|
43435
|
+
backgroundColor: "transparent",
|
|
43436
|
+
border: 0,
|
|
43437
|
+
cursor: "pointer",
|
|
43438
|
+
fontFamily: "inherit",
|
|
43439
|
+
padding: 0,
|
|
43440
|
+
transition: "color 0.15s"
|
|
43441
|
+
},
|
|
43442
|
+
children: isCopied ? "Copied!" : /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
43443
|
+
"svg",
|
|
43444
|
+
{
|
|
43445
|
+
style: { width: "0.875rem", height: "0.875rem" },
|
|
43446
|
+
viewBox: "0 0 24 24",
|
|
43447
|
+
fill: "none",
|
|
43448
|
+
stroke: "currentColor",
|
|
43449
|
+
strokeWidth: 2,
|
|
43450
|
+
strokeLinecap: "round",
|
|
43451
|
+
strokeLinejoin: "round",
|
|
43452
|
+
children: [
|
|
43453
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
|
|
43454
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
43455
|
+
]
|
|
43456
|
+
}
|
|
43457
|
+
)
|
|
43458
|
+
}
|
|
43459
|
+
)
|
|
43460
|
+
]
|
|
43461
|
+
}
|
|
43462
|
+
)
|
|
43463
|
+
]
|
|
43464
|
+
}
|
|
43465
|
+
);
|
|
43466
|
+
}
|
|
43599
43467
|
function ProcessingStepNode({
|
|
43600
43468
|
active,
|
|
43601
43469
|
done,
|
|
@@ -43752,6 +43620,7 @@ var init_SwapMode = __esm({
|
|
|
43752
43620
|
init_SwapTokenSelect();
|
|
43753
43621
|
init_VaultDiscovery();
|
|
43754
43622
|
init_currency();
|
|
43623
|
+
init_amountFormat();
|
|
43755
43624
|
init_quoteCountdown();
|
|
43756
43625
|
init_components2();
|
|
43757
43626
|
import_jsx_runtime57 = require("react/jsx-runtime");
|