uniport-sdk 0.0.7 → 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 +111 -24
- 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 +111 -24
- package/dist/components/index.js.map +1 -1
- package/dist/core/index.cjs +37 -1
- 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 +36 -2
- 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 +107 -24
- 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 +106 -25
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QuoteResult, StatusResult, Chain, Token } from './core/index.cjs';
|
|
2
|
-
export { ALL_TOKENS, CHAINS, CHAINS_REQUIRING_MEMO, CHAIN_ICONS, ChainId, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, EVM_CHAINS, EnsResolution, ExecutionStatus, QuoteOptions, ResolvedUniportConfig, SwapType, TOKEN_ICONS, UNIPORT_ENS_NAME, UNIPORT_FALLBACK_REFUND_ADDRESS, UniportApiErrorBody, UniportConfig, UniportError, UniportErrorCode, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, configureUniport, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, formatDisplayAmount, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, needsMemoDeposit, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, scrollETH, scrollUSDT, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, stellarUSDC, stellarXLM, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC } from './core/index.cjs';
|
|
3
|
-
import { P as PaymentState } from './index-
|
|
4
|
-
export { U as UniportButton, a as UniportButtonProps, b as UniportModal, c as UniportModalProps } from './index-
|
|
2
|
+
export { ALL_TOKENS, CHAINS, CHAINS_REQUIRING_MEMO, CHAIN_ICONS, ChainId, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, EVM_CHAINS, EnsResolution, ExecutionStatus, MAX_EXACT_OUTPUT_ROUNDING_BPS, QuoteOptions, ResolvedUniportConfig, SwapType, TOKEN_ICONS, UNIPORT_ENS_NAME, UNIPORT_FALLBACK_REFUND_ADDRESS, UniportApiErrorBody, UniportConfig, UniportError, UniportErrorCode, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, configureUniport, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, formatDisplayAmount, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, needsMemoDeposit, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, roundUpInputAmount, scrollETH, scrollUSDT, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, stellarUSDC, stellarXLM, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC } from './core/index.cjs';
|
|
3
|
+
import { P as PaymentState } from './index-B6_1AJAS.cjs';
|
|
4
|
+
export { U as UniportButton, a as UniportButtonProps, b as UniportModal, c as UniportModalProps } from './index-B6_1AJAS.cjs';
|
|
5
5
|
import 'react/jsx-runtime';
|
|
6
6
|
import 'react';
|
|
7
7
|
|
|
@@ -15,6 +15,7 @@ interface UseUniportPaymentOptions {
|
|
|
15
15
|
recipient: string;
|
|
16
16
|
refundAddress?: string;
|
|
17
17
|
destinationToken: string;
|
|
18
|
+
/** Exact destination amount; omit to let the payer enter an input amount. */
|
|
18
19
|
amount?: string;
|
|
19
20
|
onSuccess?: (result: {
|
|
20
21
|
txHash: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QuoteResult, StatusResult, Chain, Token } from './core/index.js';
|
|
2
|
-
export { ALL_TOKENS, CHAINS, CHAINS_REQUIRING_MEMO, CHAIN_ICONS, ChainId, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, EVM_CHAINS, EnsResolution, ExecutionStatus, QuoteOptions, ResolvedUniportConfig, SwapType, TOKEN_ICONS, UNIPORT_ENS_NAME, UNIPORT_FALLBACK_REFUND_ADDRESS, UniportApiErrorBody, UniportConfig, UniportError, UniportErrorCode, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, configureUniport, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, formatDisplayAmount, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, needsMemoDeposit, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, scrollETH, scrollUSDT, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, stellarUSDC, stellarXLM, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC } from './core/index.js';
|
|
3
|
-
import { P as PaymentState } from './index-
|
|
4
|
-
export { U as UniportButton, a as UniportButtonProps, b as UniportModal, c as UniportModalProps } from './index-
|
|
2
|
+
export { ALL_TOKENS, CHAINS, CHAINS_REQUIRING_MEMO, CHAIN_ICONS, ChainId, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, EVM_CHAINS, EnsResolution, ExecutionStatus, MAX_EXACT_OUTPUT_ROUNDING_BPS, QuoteOptions, ResolvedUniportConfig, SwapType, TOKEN_ICONS, UNIPORT_ENS_NAME, UNIPORT_FALLBACK_REFUND_ADDRESS, UniportApiErrorBody, UniportConfig, UniportError, UniportErrorCode, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, configureUniport, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, formatDisplayAmount, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, needsMemoDeposit, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, roundUpInputAmount, scrollETH, scrollUSDT, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, stellarUSDC, stellarXLM, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC } from './core/index.js';
|
|
3
|
+
import { P as PaymentState } from './index-B6_1AJAS.js';
|
|
4
|
+
export { U as UniportButton, a as UniportButtonProps, b as UniportModal, c as UniportModalProps } from './index-B6_1AJAS.js';
|
|
5
5
|
import 'react/jsx-runtime';
|
|
6
6
|
import 'react';
|
|
7
7
|
|
|
@@ -15,6 +15,7 @@ interface UseUniportPaymentOptions {
|
|
|
15
15
|
recipient: string;
|
|
16
16
|
refundAddress?: string;
|
|
17
17
|
destinationToken: string;
|
|
18
|
+
/** Exact destination amount; omit to let the payer enter an input amount. */
|
|
18
19
|
amount?: string;
|
|
19
20
|
onSuccess?: (result: {
|
|
20
21
|
txHash: string;
|
package/dist/index.js
CHANGED
|
@@ -498,11 +498,28 @@ function toSmallestUnits(amount, decimals) {
|
|
|
498
498
|
return `${whole}${paddedFraction}`.replace(/^0+/, "") || "0";
|
|
499
499
|
}
|
|
500
500
|
function fromSmallestUnits(amount, decimals) {
|
|
501
|
+
if (decimals === 0) return amount;
|
|
501
502
|
const padded = amount.padStart(decimals + 1, "0");
|
|
502
503
|
const whole = padded.slice(0, -decimals) || "0";
|
|
503
504
|
const fraction = padded.slice(-decimals).replace(/0+$/, "");
|
|
504
505
|
return fraction ? `${whole}.${fraction}` : whole;
|
|
505
506
|
}
|
|
507
|
+
var MAX_EXACT_OUTPUT_ROUNDING_BPS = 25;
|
|
508
|
+
function roundUpInputAmount(amount, decimals, maxIncreaseBps = MAX_EXACT_OUTPUT_ROUNDING_BPS) {
|
|
509
|
+
if (!/^[1-9]\d*$/.test(amount) || !Number.isInteger(decimals) || decimals < 0 || !Number.isInteger(maxIncreaseBps) || maxIncreaseBps < 0) {
|
|
510
|
+
return amount;
|
|
511
|
+
}
|
|
512
|
+
const value = BigInt(amount);
|
|
513
|
+
const maxBps = BigInt(maxIncreaseBps);
|
|
514
|
+
for (let displayDecimals = 0; displayDecimals <= decimals; displayDecimals++) {
|
|
515
|
+
const unit = 10n ** BigInt(decimals - displayDecimals);
|
|
516
|
+
const rounded = (value + unit - 1n) / unit * unit;
|
|
517
|
+
if ((rounded - value) * 10000n <= value * maxBps) {
|
|
518
|
+
return rounded.toString();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return amount;
|
|
522
|
+
}
|
|
506
523
|
function generateDeadline(hoursFromNow = 1) {
|
|
507
524
|
const deadline = new Date(Date.now() + hoursFromNow * 60 * 60 * 1e3);
|
|
508
525
|
return deadline.toISOString();
|
|
@@ -533,7 +550,10 @@ async function getQuote(options) {
|
|
|
533
550
|
referral = "uniport",
|
|
534
551
|
signal
|
|
535
552
|
} = options;
|
|
536
|
-
const amountInSmallestUnits = toSmallestUnits(
|
|
553
|
+
const amountInSmallestUnits = toSmallestUnits(
|
|
554
|
+
amount,
|
|
555
|
+
swapType === "EXACT_OUTPUT" ? destinationToken.decimals : originToken.decimals
|
|
556
|
+
);
|
|
537
557
|
const { backendUrl, requestTimeoutMs } = getUniportConfig();
|
|
538
558
|
const { signal: requestSignal, cleanup, didTimeout } = createTimeoutSignal(
|
|
539
559
|
requestTimeoutMs,
|
|
@@ -583,10 +603,24 @@ async function getQuote(options) {
|
|
|
583
603
|
}
|
|
584
604
|
const data = await response.json();
|
|
585
605
|
const quote = data.quote;
|
|
606
|
+
const paymentAmountIn = swapType === "EXACT_OUTPUT" ? roundUpInputAmount(quote.amountIn, originToken.decimals) : quote.amountIn;
|
|
607
|
+
const roundingRemainder = (BigInt(paymentAmountIn) - BigInt(quote.amountIn)).toString();
|
|
586
608
|
return {
|
|
587
609
|
depositAddress: quote.depositAddress || "",
|
|
588
610
|
memo: quote.depositMemo,
|
|
589
611
|
amountIn: quote.amountIn,
|
|
612
|
+
amountInFormatted: quote.amountInFormatted || fromSmallestUnits(quote.amountIn, originToken.decimals),
|
|
613
|
+
minAmountIn: quote.minAmountIn,
|
|
614
|
+
paymentAmountIn,
|
|
615
|
+
paymentAmountInFormatted: fromSmallestUnits(
|
|
616
|
+
paymentAmountIn,
|
|
617
|
+
originToken.decimals
|
|
618
|
+
),
|
|
619
|
+
roundingRemainder,
|
|
620
|
+
roundingRemainderFormatted: fromSmallestUnits(
|
|
621
|
+
roundingRemainder,
|
|
622
|
+
originToken.decimals
|
|
623
|
+
),
|
|
590
624
|
amountOut: quote.amountOut,
|
|
591
625
|
amountOutFormatted: quote.amountOutFormatted,
|
|
592
626
|
amountOutUsd: quote.amountOutUsd,
|
|
@@ -724,6 +758,13 @@ function getUniportDefaultRefundAddress() {
|
|
|
724
758
|
}
|
|
725
759
|
return uniportRefundAddressPromise;
|
|
726
760
|
}
|
|
761
|
+
function normalizeError(error, fallback) {
|
|
762
|
+
if (error instanceof Error) return error;
|
|
763
|
+
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
764
|
+
return new Error(error.message);
|
|
765
|
+
}
|
|
766
|
+
return new Error(fallback);
|
|
767
|
+
}
|
|
727
768
|
function useUniportPayment(options) {
|
|
728
769
|
const {
|
|
729
770
|
recipient,
|
|
@@ -733,6 +774,7 @@ function useUniportPayment(options) {
|
|
|
733
774
|
onSuccess,
|
|
734
775
|
onError
|
|
735
776
|
} = options;
|
|
777
|
+
const swapType = initialAmount === void 0 ? "EXACT_INPUT" : "EXACT_OUTPUT";
|
|
736
778
|
const destToken = getToken(destinationToken);
|
|
737
779
|
if (!destToken) {
|
|
738
780
|
throw new Error(
|
|
@@ -752,6 +794,7 @@ function useUniportPayment(options) {
|
|
|
752
794
|
const [refundAddress, setRefundAddressState] = useState(
|
|
753
795
|
initialRefundAddress ?? ""
|
|
754
796
|
);
|
|
797
|
+
useEffect(() => setAmountState(initialAmount ?? ""), [initialAmount]);
|
|
755
798
|
const [evmDefaultRefundAddress, setEvmDefaultRefundAddress] = useState(
|
|
756
799
|
UNIPORT_FALLBACK_REFUND_ADDRESS
|
|
757
800
|
);
|
|
@@ -764,7 +807,7 @@ function useUniportPayment(options) {
|
|
|
764
807
|
cancelled = true;
|
|
765
808
|
};
|
|
766
809
|
}, []);
|
|
767
|
-
const effectiveRefundAddress = refundAddress.trim() || (selectedChain && isEvmChain(selectedChain.id) ? evmDefaultRefundAddress : "");
|
|
810
|
+
const effectiveRefundAddress = swapType === "EXACT_OUTPUT" ? "" : refundAddress.trim() || (selectedChain && isEvmChain(selectedChain.id) ? evmDefaultRefundAddress : "");
|
|
768
811
|
const pollingRef = useRef(null);
|
|
769
812
|
const lastStatusRef = useRef(null);
|
|
770
813
|
const previewDebounceRef = useRef(null);
|
|
@@ -782,7 +825,7 @@ function useUniportPayment(options) {
|
|
|
782
825
|
previewAbortRef.current.abort();
|
|
783
826
|
previewAbortRef.current = null;
|
|
784
827
|
}
|
|
785
|
-
if (!nextAmount || !nextSelectedToken || !nextRefundAddress) {
|
|
828
|
+
if (!nextAmount || !nextSelectedToken || swapType !== "EXACT_OUTPUT" && !nextRefundAddress) {
|
|
786
829
|
setIsLoadingPreview(false);
|
|
787
830
|
return;
|
|
788
831
|
}
|
|
@@ -797,6 +840,7 @@ function useUniportPayment(options) {
|
|
|
797
840
|
amount: nextAmount,
|
|
798
841
|
recipient,
|
|
799
842
|
refundTo: nextRefundAddress,
|
|
843
|
+
swapType,
|
|
800
844
|
dry: true,
|
|
801
845
|
signal: controller.signal
|
|
802
846
|
});
|
|
@@ -805,7 +849,10 @@ function useUniportPayment(options) {
|
|
|
805
849
|
if (err instanceof Error && err.name === "AbortError") {
|
|
806
850
|
return;
|
|
807
851
|
}
|
|
808
|
-
const previewFailure =
|
|
852
|
+
const previewFailure = normalizeError(
|
|
853
|
+
err,
|
|
854
|
+
"Failed to fetch estimate"
|
|
855
|
+
);
|
|
809
856
|
setPreviewError(previewFailure);
|
|
810
857
|
console.warn("Preview quote failed:", previewFailure);
|
|
811
858
|
} finally {
|
|
@@ -816,7 +863,7 @@ function useUniportPayment(options) {
|
|
|
816
863
|
}
|
|
817
864
|
}, 250);
|
|
818
865
|
},
|
|
819
|
-
[destToken, recipient]
|
|
866
|
+
[destToken, recipient, swapType]
|
|
820
867
|
);
|
|
821
868
|
const setAmount = useCallback(
|
|
822
869
|
(newAmount) => {
|
|
@@ -847,7 +894,7 @@ function useUniportPayment(options) {
|
|
|
847
894
|
schedulePreviewQuote(amount, effectiveRefundAddress, token);
|
|
848
895
|
}, [amount, effectiveRefundAddress, schedulePreviewQuote]);
|
|
849
896
|
const fetchQuote = useCallback(async () => {
|
|
850
|
-
if (!selectedToken || !amount || !effectiveRefundAddress) {
|
|
897
|
+
if (!selectedToken || !amount || swapType !== "EXACT_OUTPUT" && !effectiveRefundAddress) {
|
|
851
898
|
setError(new Error("Missing required fields"));
|
|
852
899
|
return;
|
|
853
900
|
}
|
|
@@ -860,12 +907,13 @@ function useUniportPayment(options) {
|
|
|
860
907
|
amount,
|
|
861
908
|
recipient,
|
|
862
909
|
refundTo: effectiveRefundAddress,
|
|
910
|
+
swapType,
|
|
863
911
|
dry: false
|
|
864
912
|
});
|
|
865
913
|
setQuote(result);
|
|
866
914
|
setPaymentState("awaiting_deposit");
|
|
867
915
|
} catch (err) {
|
|
868
|
-
const error2 = err
|
|
916
|
+
const error2 = normalizeError(err, "Failed to get quote");
|
|
869
917
|
setError(error2);
|
|
870
918
|
setPaymentState("error");
|
|
871
919
|
onError?.(error2);
|
|
@@ -876,6 +924,7 @@ function useUniportPayment(options) {
|
|
|
876
924
|
effectiveRefundAddress,
|
|
877
925
|
recipient,
|
|
878
926
|
destToken,
|
|
927
|
+
swapType,
|
|
879
928
|
onError
|
|
880
929
|
]);
|
|
881
930
|
const stopPolling = useCallback(() => {
|
|
@@ -985,7 +1034,7 @@ function useUniportPayment(options) {
|
|
|
985
1034
|
amount,
|
|
986
1035
|
refundAddress,
|
|
987
1036
|
effectiveRefundAddress,
|
|
988
|
-
isUsingDefaultRefundAddress: !refundAddress.trim() && !!effectiveRefundAddress,
|
|
1037
|
+
isUsingDefaultRefundAddress: swapType !== "EXACT_OUTPUT" && !refundAddress.trim() && !!effectiveRefundAddress,
|
|
989
1038
|
destinationToken: destToken,
|
|
990
1039
|
chains,
|
|
991
1040
|
tokens,
|
|
@@ -1192,6 +1241,9 @@ function formatPreviewError(error) {
|
|
|
1192
1241
|
return "Could not fetch estimate. Please try again.";
|
|
1193
1242
|
}
|
|
1194
1243
|
const normalized = error.message.toLowerCase();
|
|
1244
|
+
if (normalized.includes("trustline")) {
|
|
1245
|
+
return "This Stellar recipient must enable the selected asset before it can receive funds.";
|
|
1246
|
+
}
|
|
1195
1247
|
if (normalized.includes("recipient is not valid")) {
|
|
1196
1248
|
return "Recipient address does not match the selected destination chain.";
|
|
1197
1249
|
}
|
|
@@ -1299,8 +1351,9 @@ function UniportModal({
|
|
|
1299
1351
|
const isSuccess = paymentState === "success";
|
|
1300
1352
|
const isError = paymentState === "error";
|
|
1301
1353
|
const isQuoting = paymentState === "quoting";
|
|
1302
|
-
const
|
|
1303
|
-
const canPreviewEstimate = !!(payment.selectedToken && payment.amount && payment.effectiveRefundAddress);
|
|
1354
|
+
const isExactOutput = initialAmount !== void 0;
|
|
1355
|
+
const canPreviewEstimate = !!(payment.selectedToken && payment.amount && (isExactOutput || payment.effectiveRefundAddress));
|
|
1356
|
+
const canSubmit = !!(canPreviewEstimate && payment.previewQuote && !payment.previewError && !payment.isLoadingPreview);
|
|
1304
1357
|
const showBack = !isSuccess && !isError && (showQR || modalStep !== "chain");
|
|
1305
1358
|
const iconBtn = {
|
|
1306
1359
|
width: 36,
|
|
@@ -1521,9 +1574,9 @@ function UniportModal({
|
|
|
1521
1574
|
autoFocus: true
|
|
1522
1575
|
}
|
|
1523
1576
|
),
|
|
1524
|
-
/* @__PURE__ */ jsx("div", { style: { fontSize: "14px", color: t.textMuted, marginTop: 8 }, children: tok?.symbol })
|
|
1577
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: "14px", color: t.textMuted, marginTop: 8 }, children: isExactOutput ? payment.destinationToken.symbol : tok?.symbol })
|
|
1525
1578
|
] }),
|
|
1526
|
-
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "18px" }, children: [
|
|
1579
|
+
!isExactOutput && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "18px" }, children: [
|
|
1527
1580
|
/* @__PURE__ */ jsxs(
|
|
1528
1581
|
"label",
|
|
1529
1582
|
{
|
|
@@ -1610,22 +1663,21 @@ function UniportModal({
|
|
|
1610
1663
|
animation: `uniport-pulse 1s ease infinite ${delay}s`
|
|
1611
1664
|
} }, i)),
|
|
1612
1665
|
canPreviewEstimate && !payment.isLoadingPreview && payment.previewQuote && /* @__PURE__ */ jsxs("span", { style: { fontSize: "15px", color: t.textSecondary }, children: [
|
|
1613
|
-
"You will receive",
|
|
1614
|
-
" ",
|
|
1666
|
+
isExactOutput ? "You will send " : "You will receive ",
|
|
1615
1667
|
/* @__PURE__ */ jsxs("strong", { style: { color: t.text }, children: [
|
|
1616
|
-
formatDisplayAmount(payment.previewQuote.amountOutFormatted),
|
|
1668
|
+
isExactOutput ? payment.previewQuote.paymentAmountInFormatted : formatDisplayAmount(payment.previewQuote.amountOutFormatted),
|
|
1617
1669
|
" ",
|
|
1618
|
-
payment.destinationToken.symbol
|
|
1670
|
+
isExactOutput ? tok?.symbol : payment.destinationToken.symbol
|
|
1619
1671
|
] }),
|
|
1620
1672
|
" ",
|
|
1621
1673
|
"on",
|
|
1622
1674
|
" ",
|
|
1623
|
-
/* @__PURE__ */ jsx("strong", { style: { color: t.text }, children: formatChainLabel(payment.destinationToken.chain) })
|
|
1675
|
+
/* @__PURE__ */ jsx("strong", { style: { color: t.text }, children: isExactOutput ? ch?.name : formatChainLabel(payment.destinationToken.chain) })
|
|
1624
1676
|
] }),
|
|
1625
1677
|
canPreviewEstimate && !payment.isLoadingPreview && payment.previewError && /* @__PURE__ */ jsx("span", { style: { fontSize: "13px", color: t.error }, children: formatPreviewError(payment.previewError) }),
|
|
1626
1678
|
canPreviewEstimate && !payment.isLoadingPreview && !payment.previewQuote && !payment.previewError && /* @__PURE__ */ jsx("span", { style: { fontSize: "13px", color: t.textMuted }, children: "Fetching estimate\u2026" })
|
|
1627
1679
|
] }),
|
|
1628
|
-
!!payment.amount && /* @__PURE__ */ jsxs("div", { style: { ...warningBox, marginBottom: "20px" }, children: [
|
|
1680
|
+
!!payment.amount && !isExactOutput && /* @__PURE__ */ jsxs("div", { style: { ...warningBox, marginBottom: "20px" }, children: [
|
|
1629
1681
|
/* @__PURE__ */ jsx(WarningTriangle, { color: t.warning }),
|
|
1630
1682
|
/* @__PURE__ */ jsxs("p", { style: { margin: 0, fontSize: "13px", color: t.warningText, lineHeight: 1.55 }, children: [
|
|
1631
1683
|
"You must send",
|
|
@@ -1642,6 +1694,34 @@ function UniportModal({
|
|
|
1642
1694
|
". Sending a different amount or asset may result in loss of funds."
|
|
1643
1695
|
] })
|
|
1644
1696
|
] }),
|
|
1697
|
+
isExactOutput && payment.previewQuote && /* @__PURE__ */ jsxs("div", { style: { ...warningBox, marginBottom: "20px" }, children: [
|
|
1698
|
+
/* @__PURE__ */ jsx(WarningTriangle, { color: t.warning }),
|
|
1699
|
+
/* @__PURE__ */ jsxs("p", { style: { margin: 0, fontSize: "13px", color: t.warningText, lineHeight: 1.55 }, children: [
|
|
1700
|
+
"To receive ",
|
|
1701
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
1702
|
+
"exactly ",
|
|
1703
|
+
payment.amount,
|
|
1704
|
+
" ",
|
|
1705
|
+
payment.destinationToken.symbol
|
|
1706
|
+
] }),
|
|
1707
|
+
", send ",
|
|
1708
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
1709
|
+
payment.previewQuote.paymentAmountInFormatted,
|
|
1710
|
+
" ",
|
|
1711
|
+
tok?.symbol
|
|
1712
|
+
] }),
|
|
1713
|
+
" on ",
|
|
1714
|
+
/* @__PURE__ */ jsx("strong", { children: ch?.name }),
|
|
1715
|
+
".",
|
|
1716
|
+
payment.previewQuote.roundingRemainder !== "0" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1717
|
+
" The rounded surplus is ",
|
|
1718
|
+
payment.previewQuote.roundingRemainderFormatted,
|
|
1719
|
+
" ",
|
|
1720
|
+
tok?.symbol,
|
|
1721
|
+
"."
|
|
1722
|
+
] })
|
|
1723
|
+
] })
|
|
1724
|
+
] }),
|
|
1645
1725
|
/* @__PURE__ */ jsx(
|
|
1646
1726
|
"button",
|
|
1647
1727
|
{
|
|
@@ -1654,7 +1734,7 @@ function UniportModal({
|
|
|
1654
1734
|
] }) : "Confirm Payment"
|
|
1655
1735
|
}
|
|
1656
1736
|
),
|
|
1657
|
-
!payment.effectiveRefundAddress && /* @__PURE__ */ jsxs("p", { style: { textAlign: "center", fontSize: "12px", color: t.error, margin: "10px 0 0" }, children: [
|
|
1737
|
+
!isExactOutput && !payment.effectiveRefundAddress && /* @__PURE__ */ jsxs("p", { style: { textAlign: "center", fontSize: "12px", color: t.error, margin: "10px 0 0" }, children: [
|
|
1658
1738
|
"Enter a refund address on ",
|
|
1659
1739
|
ch?.name || "the source chain",
|
|
1660
1740
|
" to continue."
|
|
@@ -1665,8 +1745,9 @@ function UniportModal({
|
|
|
1665
1745
|
const renderPaymentStep = () => {
|
|
1666
1746
|
const { quote } = payment;
|
|
1667
1747
|
const isProcessing = paymentState === "processing";
|
|
1748
|
+
const sendAmount = quote?.paymentAmountInFormatted || payment.amount;
|
|
1668
1749
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1669
|
-
renderHeader(`Send ${
|
|
1750
|
+
renderHeader(`Send ${sendAmount} ${payment.selectedToken?.symbol ?? ""} on ${payment.selectedChain?.name ?? ""}`),
|
|
1670
1751
|
/* @__PURE__ */ jsx("div", { style: { padding: "4px 20px 24px" }, children: quote && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1671
1752
|
/* @__PURE__ */ jsx("div", { style: {
|
|
1672
1753
|
background: "#ffffff",
|
|
@@ -1775,7 +1856,7 @@ function UniportModal({
|
|
|
1775
1856
|
"Only send",
|
|
1776
1857
|
" ",
|
|
1777
1858
|
/* @__PURE__ */ jsxs("strong", { children: [
|
|
1778
|
-
|
|
1859
|
+
sendAmount,
|
|
1779
1860
|
" ",
|
|
1780
1861
|
payment.selectedToken?.symbol
|
|
1781
1862
|
] }),
|
|
@@ -1796,7 +1877,7 @@ function UniportModal({
|
|
|
1796
1877
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: "10px" }, children: [
|
|
1797
1878
|
/* @__PURE__ */ jsx("span", { style: { fontSize: "13px", color: t.textMuted }, children: "You'll receive" }),
|
|
1798
1879
|
/* @__PURE__ */ jsxs("span", { style: { fontSize: "13px", fontWeight: 600, color: t.text }, children: [
|
|
1799
|
-
"\u2248",
|
|
1880
|
+
isExactOutput ? "" : "\u2248",
|
|
1800
1881
|
formatDisplayAmount(quote.amountOutFormatted),
|
|
1801
1882
|
" ",
|
|
1802
1883
|
payment.destinationToken.symbol
|
|
@@ -1886,11 +1967,11 @@ function UniportModal({
|
|
|
1886
1967
|
) }) }),
|
|
1887
1968
|
/* @__PURE__ */ jsx("h2", { style: { margin: "0 0 8px", fontSize: "20px", fontWeight: 700, color: t.text, letterSpacing: "-0.02em" }, children: "Payment sent!" }),
|
|
1888
1969
|
/* @__PURE__ */ jsxs("p", { style: { margin: "0 0 24px", fontSize: "14px", color: t.textMuted, lineHeight: 1.6 }, children: [
|
|
1889
|
-
payment.amount,
|
|
1970
|
+
payment.quote?.paymentAmountInFormatted || payment.amount,
|
|
1890
1971
|
" ",
|
|
1891
1972
|
payment.selectedToken?.symbol,
|
|
1892
1973
|
" \u2192 ",
|
|
1893
|
-
"\u2248",
|
|
1974
|
+
isExactOutput ? "" : "\u2248",
|
|
1894
1975
|
formatDisplayAmount(payment.quote?.amountOutFormatted),
|
|
1895
1976
|
" ",
|
|
1896
1977
|
payment.destinationToken.symbol
|
|
@@ -2238,6 +2319,6 @@ function UniportIcon() {
|
|
|
2238
2319
|
);
|
|
2239
2320
|
}
|
|
2240
2321
|
|
|
2241
|
-
export { ALL_TOKENS, CHAINS, CHAINS_REQUIRING_MEMO, CHAIN_ICONS, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, EVM_CHAINS, TOKEN_ICONS, UNIPORT_ENS_NAME, UNIPORT_FALLBACK_REFUND_ADDRESS, UniportButton, UniportError, UniportModal, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, configureUniport, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, formatDisplayAmount, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, needsMemoDeposit, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, scrollETH, scrollUSDT, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, stellarUSDC, stellarXLM, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, useUniportPayment, zcashZEC };
|
|
2322
|
+
export { ALL_TOKENS, CHAINS, CHAINS_REQUIRING_MEMO, CHAIN_ICONS, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, EVM_CHAINS, MAX_EXACT_OUTPUT_ROUNDING_BPS, TOKEN_ICONS, UNIPORT_ENS_NAME, UNIPORT_FALLBACK_REFUND_ADDRESS, UniportButton, UniportError, UniportModal, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, configureUniport, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, formatDisplayAmount, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, needsMemoDeposit, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, roundUpInputAmount, scrollETH, scrollUSDT, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, stellarUSDC, stellarXLM, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, useUniportPayment, zcashZEC };
|
|
2242
2323
|
//# sourceMappingURL=index.js.map
|
|
2243
2324
|
//# sourceMappingURL=index.js.map
|