uniport-sdk 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/components/index.cjs +126 -39
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +126 -39
- package/dist/components/index.js.map +1 -1
- package/dist/core/index.cjs +52 -16
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +22 -3
- package/dist/core/index.d.ts +22 -3
- package/dist/core/index.js +51 -17
- package/dist/core/index.js.map +1 -1
- package/dist/{index-Dg_m2bK3.d.cts → index-B6_1AJAS.d.cts} +1 -1
- package/dist/{index-Dg_m2bK3.d.ts → index-B6_1AJAS.d.ts} +1 -1
- package/dist/index.cjs +122 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +121 -40
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ The SDK uses Uniport's hosted backend. No API key or backend URL is required for
|
|
|
33
33
|
|------|------|----------|-------------|
|
|
34
34
|
| `recipient` | `string` | Yes | Recipient wallet address on the destination chain |
|
|
35
35
|
| `destinationToken` | `string` | Yes | Destination token name from the supported token table |
|
|
36
|
-
| `amount` | `string` | No |
|
|
36
|
+
| `amount` | `string` | No | Exact destination amount. If omitted, the payer enters an input amount in the modal |
|
|
37
37
|
| `refundAddress` | `string` | No | Source-chain refund address to prefill in the modal |
|
|
38
38
|
| `label` | `string` | No | Button label |
|
|
39
39
|
| `variant` | `'default' \| 'compact' \| 'outline'` | No | Button style |
|
|
@@ -46,6 +46,8 @@ The SDK uses Uniport's hosted backend. No API key or backend URL is required for
|
|
|
46
46
|
|
|
47
47
|
If `refundAddress` is omitted, the payer can enter it inside the modal. The refund address is on the source chain the payer sends from.
|
|
48
48
|
|
|
49
|
+
When `amount` is supplied, the modal requests that exact destination amount and rounds the quoted input upward only when the increase is at most 0.25%. Rounded surplus and failed-swap refunds are credited to Uniport's configured Intents account. When `amount` is omitted, the payer enters an exact input amount and receives the quoted output.
|
|
50
|
+
|
|
49
51
|
**EVM source chains only:** if the payer leaves the refund address blank, it defaults to Uniport's own address (resolved from `uniport.eth`, with a hardcoded fallback if resolution fails) rather than blocking the payment. This exists because the underlying 1Click API currently requires an explicit refund address — it cannot yet auto-refund to the depositing wallet. On non-EVM chains (Sui, Solana, Bitcoin, etc.) a refund address is still required from the payer, since there is no Uniport-controlled address on those chains to fall back to.
|
|
50
52
|
|
|
51
53
|
## Supported Token Naming
|
|
@@ -245,11 +245,11 @@ var nearNEAR = createToken("near", "wNEAR", "nep141:wrap.near", 24, "wrap.near",
|
|
|
245
245
|
var nearUSDC = createToken("near", "USDC", "nep141:17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1", 6, "17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1");
|
|
246
246
|
var nearUSDT = createToken("near", "USDT", "nep141:usdt.tether-token.near", 6, "usdt.tether-token.near");
|
|
247
247
|
var CHAINS = {
|
|
248
|
-
|
|
249
|
-
id: "
|
|
250
|
-
name: "
|
|
251
|
-
icon: CHAIN_ICONS.
|
|
252
|
-
tokens: [
|
|
248
|
+
stellar: {
|
|
249
|
+
id: "stellar",
|
|
250
|
+
name: "Stellar",
|
|
251
|
+
icon: CHAIN_ICONS.stellar,
|
|
252
|
+
tokens: [stellarXLM, stellarUSDC]
|
|
253
253
|
},
|
|
254
254
|
eth: {
|
|
255
255
|
id: "eth",
|
|
@@ -269,11 +269,11 @@ var CHAINS = {
|
|
|
269
269
|
icon: CHAIN_ICONS.base,
|
|
270
270
|
tokens: [baseETH, baseUSDC, baseCbBTC, baseBRETT]
|
|
271
271
|
},
|
|
272
|
-
|
|
273
|
-
id: "
|
|
274
|
-
name: "
|
|
275
|
-
icon: CHAIN_ICONS.
|
|
276
|
-
tokens: [
|
|
272
|
+
sui: {
|
|
273
|
+
id: "sui",
|
|
274
|
+
name: "Sui",
|
|
275
|
+
icon: CHAIN_ICONS.sui,
|
|
276
|
+
tokens: [suiSUI, suiUSDC]
|
|
277
277
|
},
|
|
278
278
|
op: {
|
|
279
279
|
id: "op",
|
|
@@ -395,11 +395,11 @@ var CHAINS = {
|
|
|
395
395
|
icon: CHAIN_ICONS.monad,
|
|
396
396
|
tokens: []
|
|
397
397
|
},
|
|
398
|
-
|
|
399
|
-
id: "
|
|
400
|
-
name: "
|
|
401
|
-
icon: CHAIN_ICONS.
|
|
402
|
-
tokens: [
|
|
398
|
+
scroll: {
|
|
399
|
+
id: "scroll",
|
|
400
|
+
name: "Scroll",
|
|
401
|
+
icon: CHAIN_ICONS.scroll,
|
|
402
|
+
tokens: [scrollETH, scrollUSDT]
|
|
403
403
|
}
|
|
404
404
|
};
|
|
405
405
|
var ALL_TOKENS = Object.values(CHAINS).flatMap((chain) => chain.tokens);
|
|
@@ -489,6 +489,29 @@ function toSmallestUnits(amount, decimals) {
|
|
|
489
489
|
const paddedFraction = fraction.padEnd(decimals, "0").slice(0, decimals);
|
|
490
490
|
return `${whole}${paddedFraction}`.replace(/^0+/, "") || "0";
|
|
491
491
|
}
|
|
492
|
+
function fromSmallestUnits(amount, decimals) {
|
|
493
|
+
if (decimals === 0) return amount;
|
|
494
|
+
const padded = amount.padStart(decimals + 1, "0");
|
|
495
|
+
const whole = padded.slice(0, -decimals) || "0";
|
|
496
|
+
const fraction = padded.slice(-decimals).replace(/0+$/, "");
|
|
497
|
+
return fraction ? `${whole}.${fraction}` : whole;
|
|
498
|
+
}
|
|
499
|
+
var MAX_EXACT_OUTPUT_ROUNDING_BPS = 25;
|
|
500
|
+
function roundUpInputAmount(amount, decimals, maxIncreaseBps = MAX_EXACT_OUTPUT_ROUNDING_BPS) {
|
|
501
|
+
if (!/^[1-9]\d*$/.test(amount) || !Number.isInteger(decimals) || decimals < 0 || !Number.isInteger(maxIncreaseBps) || maxIncreaseBps < 0) {
|
|
502
|
+
return amount;
|
|
503
|
+
}
|
|
504
|
+
const value = BigInt(amount);
|
|
505
|
+
const maxBps = BigInt(maxIncreaseBps);
|
|
506
|
+
for (let displayDecimals = 0; displayDecimals <= decimals; displayDecimals++) {
|
|
507
|
+
const unit = 10n ** BigInt(decimals - displayDecimals);
|
|
508
|
+
const rounded = (value + unit - 1n) / unit * unit;
|
|
509
|
+
if ((rounded - value) * 10000n <= value * maxBps) {
|
|
510
|
+
return rounded.toString();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return amount;
|
|
514
|
+
}
|
|
492
515
|
function generateDeadline(hoursFromNow = 1) {
|
|
493
516
|
const deadline = new Date(Date.now() + hoursFromNow * 60 * 60 * 1e3);
|
|
494
517
|
return deadline.toISOString();
|
|
@@ -519,7 +542,10 @@ async function getQuote(options) {
|
|
|
519
542
|
referral = "uniport",
|
|
520
543
|
signal
|
|
521
544
|
} = options;
|
|
522
|
-
const amountInSmallestUnits = toSmallestUnits(
|
|
545
|
+
const amountInSmallestUnits = toSmallestUnits(
|
|
546
|
+
amount,
|
|
547
|
+
swapType === "EXACT_OUTPUT" ? destinationToken.decimals : originToken.decimals
|
|
548
|
+
);
|
|
523
549
|
const { backendUrl, requestTimeoutMs } = getUniportConfig();
|
|
524
550
|
const { signal: requestSignal, cleanup, didTimeout } = createTimeoutSignal(
|
|
525
551
|
requestTimeoutMs,
|
|
@@ -569,10 +595,24 @@ async function getQuote(options) {
|
|
|
569
595
|
}
|
|
570
596
|
const data = await response.json();
|
|
571
597
|
const quote = data.quote;
|
|
598
|
+
const paymentAmountIn = swapType === "EXACT_OUTPUT" ? roundUpInputAmount(quote.amountIn, originToken.decimals) : quote.amountIn;
|
|
599
|
+
const roundingRemainder = (BigInt(paymentAmountIn) - BigInt(quote.amountIn)).toString();
|
|
572
600
|
return {
|
|
573
601
|
depositAddress: quote.depositAddress || "",
|
|
574
602
|
memo: quote.depositMemo,
|
|
575
603
|
amountIn: quote.amountIn,
|
|
604
|
+
amountInFormatted: quote.amountInFormatted || fromSmallestUnits(quote.amountIn, originToken.decimals),
|
|
605
|
+
minAmountIn: quote.minAmountIn,
|
|
606
|
+
paymentAmountIn,
|
|
607
|
+
paymentAmountInFormatted: fromSmallestUnits(
|
|
608
|
+
paymentAmountIn,
|
|
609
|
+
originToken.decimals
|
|
610
|
+
),
|
|
611
|
+
roundingRemainder,
|
|
612
|
+
roundingRemainderFormatted: fromSmallestUnits(
|
|
613
|
+
roundingRemainder,
|
|
614
|
+
originToken.decimals
|
|
615
|
+
),
|
|
576
616
|
amountOut: quote.amountOut,
|
|
577
617
|
amountOutFormatted: quote.amountOutFormatted,
|
|
578
618
|
amountOutUsd: quote.amountOutUsd,
|
|
@@ -656,6 +696,13 @@ function getUniportDefaultRefundAddress() {
|
|
|
656
696
|
}
|
|
657
697
|
|
|
658
698
|
// src/hooks/useUniportPayment.ts
|
|
699
|
+
function normalizeError(error, fallback) {
|
|
700
|
+
if (error instanceof Error) return error;
|
|
701
|
+
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
702
|
+
return new Error(error.message);
|
|
703
|
+
}
|
|
704
|
+
return new Error(fallback);
|
|
705
|
+
}
|
|
659
706
|
function useUniportPayment(options) {
|
|
660
707
|
const {
|
|
661
708
|
recipient,
|
|
@@ -665,6 +712,7 @@ function useUniportPayment(options) {
|
|
|
665
712
|
onSuccess,
|
|
666
713
|
onError
|
|
667
714
|
} = options;
|
|
715
|
+
const swapType = initialAmount === void 0 ? "EXACT_INPUT" : "EXACT_OUTPUT";
|
|
668
716
|
const destToken = getToken(destinationToken);
|
|
669
717
|
if (!destToken) {
|
|
670
718
|
throw new Error(
|
|
@@ -684,6 +732,7 @@ function useUniportPayment(options) {
|
|
|
684
732
|
const [refundAddress, setRefundAddressState] = react.useState(
|
|
685
733
|
initialRefundAddress ?? ""
|
|
686
734
|
);
|
|
735
|
+
react.useEffect(() => setAmountState(initialAmount ?? ""), [initialAmount]);
|
|
687
736
|
const [evmDefaultRefundAddress, setEvmDefaultRefundAddress] = react.useState(
|
|
688
737
|
UNIPORT_FALLBACK_REFUND_ADDRESS
|
|
689
738
|
);
|
|
@@ -696,7 +745,7 @@ function useUniportPayment(options) {
|
|
|
696
745
|
cancelled = true;
|
|
697
746
|
};
|
|
698
747
|
}, []);
|
|
699
|
-
const effectiveRefundAddress = refundAddress.trim() || (selectedChain && isEvmChain(selectedChain.id) ? evmDefaultRefundAddress : "");
|
|
748
|
+
const effectiveRefundAddress = swapType === "EXACT_OUTPUT" ? "" : refundAddress.trim() || (selectedChain && isEvmChain(selectedChain.id) ? evmDefaultRefundAddress : "");
|
|
700
749
|
const pollingRef = react.useRef(null);
|
|
701
750
|
const lastStatusRef = react.useRef(null);
|
|
702
751
|
const previewDebounceRef = react.useRef(null);
|
|
@@ -714,7 +763,7 @@ function useUniportPayment(options) {
|
|
|
714
763
|
previewAbortRef.current.abort();
|
|
715
764
|
previewAbortRef.current = null;
|
|
716
765
|
}
|
|
717
|
-
if (!nextAmount || !nextSelectedToken || !nextRefundAddress) {
|
|
766
|
+
if (!nextAmount || !nextSelectedToken || swapType !== "EXACT_OUTPUT" && !nextRefundAddress) {
|
|
718
767
|
setIsLoadingPreview(false);
|
|
719
768
|
return;
|
|
720
769
|
}
|
|
@@ -729,6 +778,7 @@ function useUniportPayment(options) {
|
|
|
729
778
|
amount: nextAmount,
|
|
730
779
|
recipient,
|
|
731
780
|
refundTo: nextRefundAddress,
|
|
781
|
+
swapType,
|
|
732
782
|
dry: true,
|
|
733
783
|
signal: controller.signal
|
|
734
784
|
});
|
|
@@ -737,7 +787,10 @@ function useUniportPayment(options) {
|
|
|
737
787
|
if (err instanceof Error && err.name === "AbortError") {
|
|
738
788
|
return;
|
|
739
789
|
}
|
|
740
|
-
const previewFailure =
|
|
790
|
+
const previewFailure = normalizeError(
|
|
791
|
+
err,
|
|
792
|
+
"Failed to fetch estimate"
|
|
793
|
+
);
|
|
741
794
|
setPreviewError(previewFailure);
|
|
742
795
|
console.warn("Preview quote failed:", previewFailure);
|
|
743
796
|
} finally {
|
|
@@ -748,7 +801,7 @@ function useUniportPayment(options) {
|
|
|
748
801
|
}
|
|
749
802
|
}, 250);
|
|
750
803
|
},
|
|
751
|
-
[destToken, recipient]
|
|
804
|
+
[destToken, recipient, swapType]
|
|
752
805
|
);
|
|
753
806
|
const setAmount = react.useCallback(
|
|
754
807
|
(newAmount) => {
|
|
@@ -779,7 +832,7 @@ function useUniportPayment(options) {
|
|
|
779
832
|
schedulePreviewQuote(amount, effectiveRefundAddress, token);
|
|
780
833
|
}, [amount, effectiveRefundAddress, schedulePreviewQuote]);
|
|
781
834
|
const fetchQuote = react.useCallback(async () => {
|
|
782
|
-
if (!selectedToken || !amount || !effectiveRefundAddress) {
|
|
835
|
+
if (!selectedToken || !amount || swapType !== "EXACT_OUTPUT" && !effectiveRefundAddress) {
|
|
783
836
|
setError(new Error("Missing required fields"));
|
|
784
837
|
return;
|
|
785
838
|
}
|
|
@@ -792,12 +845,13 @@ function useUniportPayment(options) {
|
|
|
792
845
|
amount,
|
|
793
846
|
recipient,
|
|
794
847
|
refundTo: effectiveRefundAddress,
|
|
848
|
+
swapType,
|
|
795
849
|
dry: false
|
|
796
850
|
});
|
|
797
851
|
setQuote(result);
|
|
798
852
|
setPaymentState("awaiting_deposit");
|
|
799
853
|
} catch (err) {
|
|
800
|
-
const error2 = err
|
|
854
|
+
const error2 = normalizeError(err, "Failed to get quote");
|
|
801
855
|
setError(error2);
|
|
802
856
|
setPaymentState("error");
|
|
803
857
|
onError?.(error2);
|
|
@@ -808,6 +862,7 @@ function useUniportPayment(options) {
|
|
|
808
862
|
effectiveRefundAddress,
|
|
809
863
|
recipient,
|
|
810
864
|
destToken,
|
|
865
|
+
swapType,
|
|
811
866
|
onError
|
|
812
867
|
]);
|
|
813
868
|
const stopPolling = react.useCallback(() => {
|
|
@@ -917,7 +972,7 @@ function useUniportPayment(options) {
|
|
|
917
972
|
amount,
|
|
918
973
|
refundAddress,
|
|
919
974
|
effectiveRefundAddress,
|
|
920
|
-
isUsingDefaultRefundAddress: !refundAddress.trim() && !!effectiveRefundAddress,
|
|
975
|
+
isUsingDefaultRefundAddress: swapType !== "EXACT_OUTPUT" && !refundAddress.trim() && !!effectiveRefundAddress,
|
|
921
976
|
destinationToken: destToken,
|
|
922
977
|
chains,
|
|
923
978
|
tokens,
|
|
@@ -1124,6 +1179,9 @@ function formatPreviewError(error) {
|
|
|
1124
1179
|
return "Could not fetch estimate. Please try again.";
|
|
1125
1180
|
}
|
|
1126
1181
|
const normalized = error.message.toLowerCase();
|
|
1182
|
+
if (normalized.includes("trustline")) {
|
|
1183
|
+
return "This Stellar recipient must enable the selected asset before it can receive funds.";
|
|
1184
|
+
}
|
|
1127
1185
|
if (normalized.includes("recipient is not valid")) {
|
|
1128
1186
|
return "Recipient address does not match the selected destination chain.";
|
|
1129
1187
|
}
|
|
@@ -1231,8 +1289,9 @@ function UniportModal({
|
|
|
1231
1289
|
const isSuccess = paymentState === "success";
|
|
1232
1290
|
const isError = paymentState === "error";
|
|
1233
1291
|
const isQuoting = paymentState === "quoting";
|
|
1234
|
-
const
|
|
1235
|
-
const canPreviewEstimate = !!(payment.selectedToken && payment.amount && payment.effectiveRefundAddress);
|
|
1292
|
+
const isExactOutput = initialAmount !== void 0;
|
|
1293
|
+
const canPreviewEstimate = !!(payment.selectedToken && payment.amount && (isExactOutput || payment.effectiveRefundAddress));
|
|
1294
|
+
const canSubmit = !!(canPreviewEstimate && payment.previewQuote && !payment.previewError && !payment.isLoadingPreview);
|
|
1236
1295
|
const showBack = !isSuccess && !isError && (showQR || modalStep !== "chain");
|
|
1237
1296
|
const iconBtn = {
|
|
1238
1297
|
width: 36,
|
|
@@ -1453,9 +1512,9 @@ function UniportModal({
|
|
|
1453
1512
|
autoFocus: true
|
|
1454
1513
|
}
|
|
1455
1514
|
),
|
|
1456
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "14px", color: t.textMuted, marginTop: 8 }, children: tok?.symbol })
|
|
1515
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "14px", color: t.textMuted, marginTop: 8 }, children: isExactOutput ? payment.destinationToken.symbol : tok?.symbol })
|
|
1457
1516
|
] }),
|
|
1458
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "18px" }, children: [
|
|
1517
|
+
!isExactOutput && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "18px" }, children: [
|
|
1459
1518
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1460
1519
|
"label",
|
|
1461
1520
|
{
|
|
@@ -1542,22 +1601,21 @@ function UniportModal({
|
|
|
1542
1601
|
animation: `uniport-pulse 1s ease infinite ${delay}s`
|
|
1543
1602
|
} }, i)),
|
|
1544
1603
|
canPreviewEstimate && !payment.isLoadingPreview && payment.previewQuote && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: "15px", color: t.textSecondary }, children: [
|
|
1545
|
-
"You will receive",
|
|
1546
|
-
" ",
|
|
1604
|
+
isExactOutput ? "You will send " : "You will receive ",
|
|
1547
1605
|
/* @__PURE__ */ jsxRuntime.jsxs("strong", { style: { color: t.text }, children: [
|
|
1548
|
-
formatDisplayAmount(payment.previewQuote.amountOutFormatted),
|
|
1606
|
+
isExactOutput ? payment.previewQuote.paymentAmountInFormatted : formatDisplayAmount(payment.previewQuote.amountOutFormatted),
|
|
1549
1607
|
" ",
|
|
1550
|
-
payment.destinationToken.symbol
|
|
1608
|
+
isExactOutput ? tok?.symbol : payment.destinationToken.symbol
|
|
1551
1609
|
] }),
|
|
1552
1610
|
" ",
|
|
1553
1611
|
"on",
|
|
1554
1612
|
" ",
|
|
1555
|
-
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color: t.text }, children: formatChainLabel(payment.destinationToken.chain) })
|
|
1613
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color: t.text }, children: isExactOutput ? ch?.name : formatChainLabel(payment.destinationToken.chain) })
|
|
1556
1614
|
] }),
|
|
1557
1615
|
canPreviewEstimate && !payment.isLoadingPreview && payment.previewError && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "13px", color: t.error }, children: formatPreviewError(payment.previewError) }),
|
|
1558
1616
|
canPreviewEstimate && !payment.isLoadingPreview && !payment.previewQuote && !payment.previewError && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "13px", color: t.textMuted }, children: "Fetching estimate\u2026" })
|
|
1559
1617
|
] }),
|
|
1560
|
-
!!payment.amount && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...warningBox, marginBottom: "20px" }, children: [
|
|
1618
|
+
!!payment.amount && !isExactOutput && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...warningBox, marginBottom: "20px" }, children: [
|
|
1561
1619
|
/* @__PURE__ */ jsxRuntime.jsx(WarningTriangle, { color: t.warning }),
|
|
1562
1620
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: { margin: 0, fontSize: "13px", color: t.warningText, lineHeight: 1.55 }, children: [
|
|
1563
1621
|
"You must send",
|
|
@@ -1574,6 +1632,34 @@ function UniportModal({
|
|
|
1574
1632
|
". Sending a different amount or asset may result in loss of funds."
|
|
1575
1633
|
] })
|
|
1576
1634
|
] }),
|
|
1635
|
+
isExactOutput && payment.previewQuote && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...warningBox, marginBottom: "20px" }, children: [
|
|
1636
|
+
/* @__PURE__ */ jsxRuntime.jsx(WarningTriangle, { color: t.warning }),
|
|
1637
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: { margin: 0, fontSize: "13px", color: t.warningText, lineHeight: 1.55 }, children: [
|
|
1638
|
+
"To receive ",
|
|
1639
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { children: [
|
|
1640
|
+
"exactly ",
|
|
1641
|
+
payment.amount,
|
|
1642
|
+
" ",
|
|
1643
|
+
payment.destinationToken.symbol
|
|
1644
|
+
] }),
|
|
1645
|
+
", send ",
|
|
1646
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { children: [
|
|
1647
|
+
payment.previewQuote.paymentAmountInFormatted,
|
|
1648
|
+
" ",
|
|
1649
|
+
tok?.symbol
|
|
1650
|
+
] }),
|
|
1651
|
+
" on ",
|
|
1652
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: ch?.name }),
|
|
1653
|
+
".",
|
|
1654
|
+
payment.previewQuote.roundingRemainder !== "0" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1655
|
+
" The rounded surplus is ",
|
|
1656
|
+
payment.previewQuote.roundingRemainderFormatted,
|
|
1657
|
+
" ",
|
|
1658
|
+
tok?.symbol,
|
|
1659
|
+
"."
|
|
1660
|
+
] })
|
|
1661
|
+
] })
|
|
1662
|
+
] }),
|
|
1577
1663
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1578
1664
|
"button",
|
|
1579
1665
|
{
|
|
@@ -1586,7 +1672,7 @@ function UniportModal({
|
|
|
1586
1672
|
] }) : "Confirm Payment"
|
|
1587
1673
|
}
|
|
1588
1674
|
),
|
|
1589
|
-
!payment.effectiveRefundAddress && /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { textAlign: "center", fontSize: "12px", color: t.error, margin: "10px 0 0" }, children: [
|
|
1675
|
+
!isExactOutput && !payment.effectiveRefundAddress && /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { textAlign: "center", fontSize: "12px", color: t.error, margin: "10px 0 0" }, children: [
|
|
1590
1676
|
"Enter a refund address on ",
|
|
1591
1677
|
ch?.name || "the source chain",
|
|
1592
1678
|
" to continue."
|
|
@@ -1597,8 +1683,9 @@ function UniportModal({
|
|
|
1597
1683
|
const renderPaymentStep = () => {
|
|
1598
1684
|
const { quote } = payment;
|
|
1599
1685
|
const isProcessing = paymentState === "processing";
|
|
1686
|
+
const sendAmount = quote?.paymentAmountInFormatted || payment.amount;
|
|
1600
1687
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1601
|
-
renderHeader(`Send ${
|
|
1688
|
+
renderHeader(`Send ${sendAmount} ${payment.selectedToken?.symbol ?? ""} on ${payment.selectedChain?.name ?? ""}`),
|
|
1602
1689
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "4px 20px 24px" }, children: quote && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1603
1690
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1604
1691
|
background: "#ffffff",
|
|
@@ -1707,7 +1794,7 @@ function UniportModal({
|
|
|
1707
1794
|
"Only send",
|
|
1708
1795
|
" ",
|
|
1709
1796
|
/* @__PURE__ */ jsxRuntime.jsxs("strong", { children: [
|
|
1710
|
-
|
|
1797
|
+
sendAmount,
|
|
1711
1798
|
" ",
|
|
1712
1799
|
payment.selectedToken?.symbol
|
|
1713
1800
|
] }),
|
|
@@ -1728,7 +1815,7 @@ function UniportModal({
|
|
|
1728
1815
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: "10px" }, children: [
|
|
1729
1816
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "13px", color: t.textMuted }, children: "You'll receive" }),
|
|
1730
1817
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: "13px", fontWeight: 600, color: t.text }, children: [
|
|
1731
|
-
"\u2248",
|
|
1818
|
+
isExactOutput ? "" : "\u2248",
|
|
1732
1819
|
formatDisplayAmount(quote.amountOutFormatted),
|
|
1733
1820
|
" ",
|
|
1734
1821
|
payment.destinationToken.symbol
|
|
@@ -1818,11 +1905,11 @@ function UniportModal({
|
|
|
1818
1905
|
) }) }),
|
|
1819
1906
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { margin: "0 0 8px", fontSize: "20px", fontWeight: 700, color: t.text, letterSpacing: "-0.02em" }, children: "Payment sent!" }),
|
|
1820
1907
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: { margin: "0 0 24px", fontSize: "14px", color: t.textMuted, lineHeight: 1.6 }, children: [
|
|
1821
|
-
payment.amount,
|
|
1908
|
+
payment.quote?.paymentAmountInFormatted || payment.amount,
|
|
1822
1909
|
" ",
|
|
1823
1910
|
payment.selectedToken?.symbol,
|
|
1824
1911
|
" \u2192 ",
|
|
1825
|
-
"\u2248",
|
|
1912
|
+
isExactOutput ? "" : "\u2248",
|
|
1826
1913
|
formatDisplayAmount(payment.quote?.amountOutFormatted),
|
|
1827
1914
|
" ",
|
|
1828
1915
|
payment.destinationToken.symbol
|