uniport-sdk 0.0.3 → 0.0.5
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 +5 -0
- package/dist/components/index.cjs +237 -94
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +237 -94
- package/dist/components/index.js.map +1 -1
- package/dist/core/index.cjs +95 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +38 -1
- package/dist/core/index.d.ts +38 -1
- package/dist/core/index.js +89 -1
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +247 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +242 -96
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QuoteResult, StatusResult, Chain, Token } from './core/index.cjs';
|
|
2
|
-
export { ALL_TOKENS, CHAINS, CHAIN_ICONS, ChainId, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, ExecutionStatus, QuoteOptions, ResolvedUniportConfig, SwapType, TOKEN_ICONS, 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, fromSmallestUnits, generateDeadline, getExecutionStatus, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, rippleXRP, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC } from './core/index.cjs';
|
|
2
|
+
export { ALL_TOKENS, CHAINS, 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, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC } from './core/index.cjs';
|
|
3
3
|
import { P as PaymentState } from './index-Dg_m2bK3.cjs';
|
|
4
4
|
export { U as UniportButton, a as UniportButtonProps, b as UniportModal, c as UniportModalProps } from './index-Dg_m2bK3.cjs';
|
|
5
5
|
import 'react/jsx-runtime';
|
|
@@ -34,6 +34,10 @@ interface UseUniportPaymentReturn {
|
|
|
34
34
|
selectedToken: Token | null;
|
|
35
35
|
amount: string;
|
|
36
36
|
refundAddress: string;
|
|
37
|
+
/** refundAddress if provided, otherwise the resolved default (EVM only). May be empty on non-EVM chains. */
|
|
38
|
+
effectiveRefundAddress: string;
|
|
39
|
+
/** True when effectiveRefundAddress is the Uniport default rather than user input. */
|
|
40
|
+
isUsingDefaultRefundAddress: boolean;
|
|
37
41
|
destinationToken: Token;
|
|
38
42
|
chains: Chain[];
|
|
39
43
|
tokens: Token[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QuoteResult, StatusResult, Chain, Token } from './core/index.js';
|
|
2
|
-
export { ALL_TOKENS, CHAINS, CHAIN_ICONS, ChainId, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, ExecutionStatus, QuoteOptions, ResolvedUniportConfig, SwapType, TOKEN_ICONS, 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, fromSmallestUnits, generateDeadline, getExecutionStatus, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, rippleXRP, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC } from './core/index.js';
|
|
2
|
+
export { ALL_TOKENS, CHAINS, 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, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC } from './core/index.js';
|
|
3
3
|
import { P as PaymentState } from './index-Dg_m2bK3.js';
|
|
4
4
|
export { U as UniportButton, a as UniportButtonProps, b as UniportModal, c as UniportModalProps } from './index-Dg_m2bK3.js';
|
|
5
5
|
import 'react/jsx-runtime';
|
|
@@ -34,6 +34,10 @@ interface UseUniportPaymentReturn {
|
|
|
34
34
|
selectedToken: Token | null;
|
|
35
35
|
amount: string;
|
|
36
36
|
refundAddress: string;
|
|
37
|
+
/** refundAddress if provided, otherwise the resolved default (EVM only). May be empty on non-EVM chains. */
|
|
38
|
+
effectiveRefundAddress: string;
|
|
39
|
+
/** True when effectiveRefundAddress is the Uniport default rather than user input. */
|
|
40
|
+
isUsingDefaultRefundAddress: boolean;
|
|
37
41
|
destinationToken: Token;
|
|
38
42
|
chains: Chain[];
|
|
39
43
|
tokens: Token[];
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useRef, useCallback
|
|
1
|
+
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import { QRCodeSVG } from 'qrcode.react';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -81,6 +81,51 @@ var CHAIN_ICONS = {
|
|
|
81
81
|
xrp: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png",
|
|
82
82
|
zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png"
|
|
83
83
|
};
|
|
84
|
+
var EVM_CHAINS = [
|
|
85
|
+
"eth",
|
|
86
|
+
"arb",
|
|
87
|
+
"base",
|
|
88
|
+
"op",
|
|
89
|
+
"pol",
|
|
90
|
+
"avax",
|
|
91
|
+
"bsc",
|
|
92
|
+
"gnosis",
|
|
93
|
+
"bera",
|
|
94
|
+
"monad"
|
|
95
|
+
];
|
|
96
|
+
function isEvmChain(chain) {
|
|
97
|
+
return EVM_CHAINS.includes(chain);
|
|
98
|
+
}
|
|
99
|
+
var EXPLORER_TX_URLS = {
|
|
100
|
+
eth: (h) => `https://etherscan.io/tx/${h}`,
|
|
101
|
+
arb: (h) => `https://arbiscan.io/tx/${h}`,
|
|
102
|
+
base: (h) => `https://basescan.org/tx/${h}`,
|
|
103
|
+
op: (h) => `https://optimistic.etherscan.io/tx/${h}`,
|
|
104
|
+
pol: (h) => `https://polygonscan.com/tx/${h}`,
|
|
105
|
+
avax: (h) => `https://snowtrace.io/tx/${h}`,
|
|
106
|
+
bsc: (h) => `https://bscscan.com/tx/${h}`,
|
|
107
|
+
gnosis: (h) => `https://gnosisscan.io/tx/${h}`,
|
|
108
|
+
bera: (h) => `https://berascan.com/tx/${h}`,
|
|
109
|
+
monad: (h) => `https://monadvision.com/tx/${h}`,
|
|
110
|
+
sui: (h) => `https://suivision.xyz/txblock/${h}`,
|
|
111
|
+
sol: (h) => `https://solscan.io/tx/${h}`,
|
|
112
|
+
btc: (h) => `https://mempool.space/tx/${h}`,
|
|
113
|
+
near: (h) => `https://nearblocks.io/txns/${h}`,
|
|
114
|
+
ton: (h) => `https://tonviewer.com/transaction/${h}`,
|
|
115
|
+
tron: (h) => `https://tronscan.org/#/transaction/${h}`,
|
|
116
|
+
stellar: (h) => `https://stellar.expert/explorer/public/tx/${h}`,
|
|
117
|
+
cardano: (h) => `https://cardanoscan.io/transaction/${h}`,
|
|
118
|
+
aptos: (h) => `https://explorer.aptoslabs.com/txn/${h}?network=mainnet`,
|
|
119
|
+
starknet: (h) => `https://voyager.online/tx/${h}`,
|
|
120
|
+
doge: (h) => `https://dogechain.info/tx/${h}`,
|
|
121
|
+
ltc: (h) => `https://litecoinspace.org/tx/${h}`,
|
|
122
|
+
bch: (h) => `https://blockchair.com/bitcoin-cash/transaction/${h}`,
|
|
123
|
+
xrp: (h) => `https://xrpscan.com/tx/${h}`,
|
|
124
|
+
zec: (h) => `https://blockchair.com/zcash/transaction/${h}`
|
|
125
|
+
};
|
|
126
|
+
function getExplorerTxUrl(chain, hash) {
|
|
127
|
+
return EXPLORER_TX_URLS[chain]?.(hash);
|
|
128
|
+
}
|
|
84
129
|
function createToken(chain, symbol, assetId, decimals, contractAddress, options) {
|
|
85
130
|
const normalizedSymbol = symbol.replace("$", "").replace(" ", "");
|
|
86
131
|
const canonicalPrefix = TOKEN_NAME_PREFIXES[chain] || chain;
|
|
@@ -607,6 +652,49 @@ async function pollExecutionStatus(depositAddress, options) {
|
|
|
607
652
|
}
|
|
608
653
|
throw new Error(`Timeout waiting for swap completion after ${timeout}ms`);
|
|
609
654
|
}
|
|
655
|
+
|
|
656
|
+
// src/core/ens.ts
|
|
657
|
+
var ENSIDEAS_BASE_URL = "https://api.ensideas.com/ens/resolve";
|
|
658
|
+
var UNIPORT_ENS_NAME = "uniport.eth";
|
|
659
|
+
var UNIPORT_FALLBACK_REFUND_ADDRESS = "0x2f43A54f931b95053c3DDa5f4637065AA0c3c494";
|
|
660
|
+
async function resolveEnsName(name, options) {
|
|
661
|
+
const controller = new AbortController();
|
|
662
|
+
const timeoutId = setTimeout(
|
|
663
|
+
() => controller.abort(),
|
|
664
|
+
options?.timeoutMs ?? 1e4
|
|
665
|
+
);
|
|
666
|
+
options?.signal?.addEventListener("abort", () => controller.abort(), {
|
|
667
|
+
once: true
|
|
668
|
+
});
|
|
669
|
+
try {
|
|
670
|
+
const response = await fetch(
|
|
671
|
+
`${ENSIDEAS_BASE_URL}/${encodeURIComponent(name)}`,
|
|
672
|
+
{ signal: controller.signal }
|
|
673
|
+
);
|
|
674
|
+
if (!response.ok) return null;
|
|
675
|
+
const data = await response.json();
|
|
676
|
+
if (!data.address) return null;
|
|
677
|
+
return {
|
|
678
|
+
address: data.address,
|
|
679
|
+
name: data.name ?? name,
|
|
680
|
+
displayName: data.displayName ?? name,
|
|
681
|
+
avatar: data.avatar ?? null
|
|
682
|
+
};
|
|
683
|
+
} catch {
|
|
684
|
+
return null;
|
|
685
|
+
} finally {
|
|
686
|
+
clearTimeout(timeoutId);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
var uniportRefundAddressPromise = null;
|
|
690
|
+
function getUniportDefaultRefundAddress() {
|
|
691
|
+
if (!uniportRefundAddressPromise) {
|
|
692
|
+
uniportRefundAddressPromise = resolveEnsName(UNIPORT_ENS_NAME).then(
|
|
693
|
+
(result) => result?.address ?? UNIPORT_FALLBACK_REFUND_ADDRESS
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
return uniportRefundAddressPromise;
|
|
697
|
+
}
|
|
610
698
|
function useUniportPayment(options) {
|
|
611
699
|
const {
|
|
612
700
|
recipient,
|
|
@@ -635,6 +723,19 @@ function useUniportPayment(options) {
|
|
|
635
723
|
const [refundAddress, setRefundAddressState] = useState(
|
|
636
724
|
initialRefundAddress ?? ""
|
|
637
725
|
);
|
|
726
|
+
const [evmDefaultRefundAddress, setEvmDefaultRefundAddress] = useState(
|
|
727
|
+
UNIPORT_FALLBACK_REFUND_ADDRESS
|
|
728
|
+
);
|
|
729
|
+
useEffect(() => {
|
|
730
|
+
let cancelled = false;
|
|
731
|
+
getUniportDefaultRefundAddress().then((address) => {
|
|
732
|
+
if (!cancelled) setEvmDefaultRefundAddress(address);
|
|
733
|
+
});
|
|
734
|
+
return () => {
|
|
735
|
+
cancelled = true;
|
|
736
|
+
};
|
|
737
|
+
}, []);
|
|
738
|
+
const effectiveRefundAddress = refundAddress.trim() || (selectedChain && isEvmChain(selectedChain.id) ? evmDefaultRefundAddress : "");
|
|
638
739
|
const pollingRef = useRef(null);
|
|
639
740
|
const lastStatusRef = useRef(null);
|
|
640
741
|
const previewDebounceRef = useRef(null);
|
|
@@ -691,31 +792,33 @@ function useUniportPayment(options) {
|
|
|
691
792
|
const setAmount = useCallback(
|
|
692
793
|
(newAmount) => {
|
|
693
794
|
setAmountState(newAmount);
|
|
694
|
-
schedulePreviewQuote(newAmount,
|
|
795
|
+
schedulePreviewQuote(newAmount, effectiveRefundAddress, selectedToken);
|
|
695
796
|
},
|
|
696
|
-
[
|
|
797
|
+
[effectiveRefundAddress, schedulePreviewQuote, selectedToken]
|
|
697
798
|
);
|
|
698
799
|
const setRefundAddress = useCallback(
|
|
699
800
|
(newRefundAddress) => {
|
|
700
801
|
setRefundAddressState(newRefundAddress);
|
|
701
|
-
|
|
802
|
+
const nextEffective = newRefundAddress.trim() || (selectedChain && isEvmChain(selectedChain.id) ? evmDefaultRefundAddress : "");
|
|
803
|
+
schedulePreviewQuote(amount, nextEffective, selectedToken);
|
|
702
804
|
},
|
|
703
|
-
[amount, schedulePreviewQuote, selectedToken]
|
|
805
|
+
[amount, evmDefaultRefundAddress, schedulePreviewQuote, selectedChain, selectedToken]
|
|
704
806
|
);
|
|
705
807
|
const handleChainSelect = useCallback((chain) => {
|
|
706
808
|
const nextToken = chain.tokens[0] || null;
|
|
707
809
|
setSelectedChain(chain);
|
|
708
810
|
setSelectedToken(nextToken);
|
|
709
811
|
setPaymentState("selecting");
|
|
710
|
-
|
|
711
|
-
|
|
812
|
+
const nextEffective = refundAddress.trim() || (isEvmChain(chain.id) ? evmDefaultRefundAddress : "");
|
|
813
|
+
schedulePreviewQuote(amount, nextEffective, nextToken);
|
|
814
|
+
}, [amount, evmDefaultRefundAddress, refundAddress, schedulePreviewQuote]);
|
|
712
815
|
const handleTokenSelect = useCallback((token) => {
|
|
713
816
|
setSelectedToken(token);
|
|
714
817
|
setPaymentState("selecting");
|
|
715
|
-
schedulePreviewQuote(amount,
|
|
716
|
-
}, [amount,
|
|
818
|
+
schedulePreviewQuote(amount, effectiveRefundAddress, token);
|
|
819
|
+
}, [amount, effectiveRefundAddress, schedulePreviewQuote]);
|
|
717
820
|
const fetchQuote = useCallback(async () => {
|
|
718
|
-
if (!selectedToken || !amount || !
|
|
821
|
+
if (!selectedToken || !amount || !effectiveRefundAddress) {
|
|
719
822
|
setError(new Error("Missing required fields"));
|
|
720
823
|
return;
|
|
721
824
|
}
|
|
@@ -727,7 +830,7 @@ function useUniportPayment(options) {
|
|
|
727
830
|
destinationToken: destToken,
|
|
728
831
|
amount,
|
|
729
832
|
recipient,
|
|
730
|
-
refundTo:
|
|
833
|
+
refundTo: effectiveRefundAddress,
|
|
731
834
|
dry: false
|
|
732
835
|
});
|
|
733
836
|
setQuote(result);
|
|
@@ -741,7 +844,7 @@ function useUniportPayment(options) {
|
|
|
741
844
|
}, [
|
|
742
845
|
selectedToken,
|
|
743
846
|
amount,
|
|
744
|
-
|
|
847
|
+
effectiveRefundAddress,
|
|
745
848
|
recipient,
|
|
746
849
|
destToken,
|
|
747
850
|
onError
|
|
@@ -852,6 +955,8 @@ function useUniportPayment(options) {
|
|
|
852
955
|
selectedToken,
|
|
853
956
|
amount,
|
|
854
957
|
refundAddress,
|
|
958
|
+
effectiveRefundAddress,
|
|
959
|
+
isUsingDefaultRefundAddress: !refundAddress.trim() && !!effectiveRefundAddress,
|
|
855
960
|
destinationToken: destToken,
|
|
856
961
|
chains,
|
|
857
962
|
tokens,
|
|
@@ -1167,8 +1272,8 @@ function UniportModal({
|
|
|
1167
1272
|
const isSuccess = paymentState === "success";
|
|
1168
1273
|
const isError = paymentState === "error";
|
|
1169
1274
|
const isQuoting = paymentState === "quoting";
|
|
1170
|
-
const canSubmit = !!(payment.selectedToken && payment.amount && payment.
|
|
1171
|
-
const canPreviewEstimate = !!(payment.selectedToken && payment.amount && payment.
|
|
1275
|
+
const canSubmit = !!(payment.selectedToken && payment.amount && payment.effectiveRefundAddress);
|
|
1276
|
+
const canPreviewEstimate = !!(payment.selectedToken && payment.amount && payment.effectiveRefundAddress);
|
|
1172
1277
|
const showBack = !isSuccess && !isError && (showQR || modalStep !== "chain");
|
|
1173
1278
|
const iconBtn = {
|
|
1174
1279
|
width: 36,
|
|
@@ -1404,7 +1509,8 @@ function UniportModal({
|
|
|
1404
1509
|
},
|
|
1405
1510
|
children: [
|
|
1406
1511
|
"Refund address on ",
|
|
1407
|
-
ch?.name || "the source chain"
|
|
1512
|
+
ch?.name || "the source chain",
|
|
1513
|
+
ch && isEvmChain(ch.id) && /* @__PURE__ */ jsx("span", { style: { fontWeight: 400, color: t.textMuted }, children: " (optional)" })
|
|
1408
1514
|
]
|
|
1409
1515
|
}
|
|
1410
1516
|
),
|
|
@@ -1414,7 +1520,7 @@ function UniportModal({
|
|
|
1414
1520
|
type: "text",
|
|
1415
1521
|
value: payment.refundAddress,
|
|
1416
1522
|
onChange: (e) => payment.setRefundAddress(e.target.value),
|
|
1417
|
-
placeholder: `Enter a ${ch?.name || "source chain"} refund address`,
|
|
1523
|
+
placeholder: ch && isEvmChain(ch.id) ? `Optional \u2014 defaults to ${UNIPORT_ENS_NAME}` : `Enter a ${ch?.name || "source chain"} refund address`,
|
|
1418
1524
|
spellCheck: false,
|
|
1419
1525
|
autoCapitalize: "off",
|
|
1420
1526
|
autoCorrect: "off",
|
|
@@ -1440,7 +1546,7 @@ function UniportModal({
|
|
|
1440
1546
|
color: t.textMuted,
|
|
1441
1547
|
lineHeight: 1.5
|
|
1442
1548
|
},
|
|
1443
|
-
children: "Used only if the swap fails. This address must live on the chain the payer is sending from."
|
|
1549
|
+
children: payment.isUsingDefaultRefundAddress ? `Used only if the swap fails. You can enter your own address, or leave blank to use Uniport's default (${UNIPORT_ENS_NAME}).` : "Used only if the swap fails. This address must live on the chain the payer is sending from."
|
|
1444
1550
|
}
|
|
1445
1551
|
)
|
|
1446
1552
|
] }),
|
|
@@ -1505,7 +1611,7 @@ function UniportModal({
|
|
|
1505
1611
|
] }) : "Confirm Payment"
|
|
1506
1612
|
}
|
|
1507
1613
|
),
|
|
1508
|
-
!payment.
|
|
1614
|
+
!payment.effectiveRefundAddress && /* @__PURE__ */ jsxs("p", { style: { textAlign: "center", fontSize: "12px", color: t.error, margin: "10px 0 0" }, children: [
|
|
1509
1615
|
"Enter a refund address on ",
|
|
1510
1616
|
ch?.name || "the source chain",
|
|
1511
1617
|
" to continue."
|
|
@@ -1631,6 +1737,25 @@ function UniportModal({
|
|
|
1631
1737
|
] }) })
|
|
1632
1738
|
] });
|
|
1633
1739
|
};
|
|
1740
|
+
const renderTxHash = (hash, url) => url ? /* @__PURE__ */ jsxs(
|
|
1741
|
+
"a",
|
|
1742
|
+
{
|
|
1743
|
+
href: url,
|
|
1744
|
+
target: "_blank",
|
|
1745
|
+
rel: "noopener noreferrer",
|
|
1746
|
+
style: { color: t.accent, fontSize: "12px", fontFamily: "monospace", textDecoration: "none" },
|
|
1747
|
+
children: [
|
|
1748
|
+
hash.slice(0, 12),
|
|
1749
|
+
"\u2026",
|
|
1750
|
+
hash.slice(-8),
|
|
1751
|
+
" \u2197"
|
|
1752
|
+
]
|
|
1753
|
+
}
|
|
1754
|
+
) : /* @__PURE__ */ jsxs("span", { style: { color: t.textSecondary, fontSize: "12px", fontFamily: "monospace" }, children: [
|
|
1755
|
+
hash.slice(0, 12),
|
|
1756
|
+
"\u2026",
|
|
1757
|
+
hash.slice(-8)
|
|
1758
|
+
] });
|
|
1634
1759
|
const renderSuccessStep = () => /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
1635
1760
|
/* @__PURE__ */ jsx(
|
|
1636
1761
|
"button",
|
|
@@ -1701,29 +1826,14 @@ function UniportModal({
|
|
|
1701
1826
|
"Source TX \xB7 ",
|
|
1702
1827
|
payment.selectedChain?.name
|
|
1703
1828
|
] }),
|
|
1704
|
-
|
|
1705
|
-
"a",
|
|
1706
|
-
{
|
|
1707
|
-
href: `https://etherscan.io/tx/${hash}`,
|
|
1708
|
-
target: "_blank",
|
|
1709
|
-
rel: "noopener noreferrer",
|
|
1710
|
-
style: { color: t.accent, fontSize: "12px", fontFamily: "monospace", textDecoration: "none" },
|
|
1711
|
-
children: [
|
|
1712
|
-
hash.slice(0, 12),
|
|
1713
|
-
"\u2026",
|
|
1714
|
-
hash.slice(-8),
|
|
1715
|
-
" \u2197"
|
|
1716
|
-
]
|
|
1717
|
-
}
|
|
1718
|
-
)
|
|
1829
|
+
renderTxHash(hash, payment.selectedChain ? getExplorerTxUrl(payment.selectedChain.id, hash) : void 0)
|
|
1719
1830
|
] }, `o${i}`)),
|
|
1720
1831
|
payment.status?.destinationTxHashes?.map((hash, i) => /* @__PURE__ */ jsxs("div", { children: [
|
|
1721
|
-
/* @__PURE__ */
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
] })
|
|
1832
|
+
/* @__PURE__ */ jsxs("p", { style: { color: t.textMuted, fontSize: "11px", margin: "0 0 3px", textTransform: "uppercase", letterSpacing: "0.05em" }, children: [
|
|
1833
|
+
"Destination TX \xB7 ",
|
|
1834
|
+
CHAINS[payment.destinationToken.chain].name
|
|
1835
|
+
] }),
|
|
1836
|
+
renderTxHash(hash, getExplorerTxUrl(payment.destinationToken.chain, hash))
|
|
1727
1837
|
] }, `d${i}`)),
|
|
1728
1838
|
!payment.status?.originTxHashes?.length && !payment.status?.destinationTxHashes?.length && /* @__PURE__ */ jsx("p", { style: { color: t.textMuted, fontSize: "13px", margin: 0 }, children: "Loading transaction details\u2026" })
|
|
1729
1839
|
] }),
|
|
@@ -1839,62 +1949,101 @@ function UniportModal({
|
|
|
1839
1949
|
portalRoot
|
|
1840
1950
|
);
|
|
1841
1951
|
}
|
|
1952
|
+
var sharedButtonStyle = {
|
|
1953
|
+
display: "inline-flex",
|
|
1954
|
+
alignItems: "center",
|
|
1955
|
+
justifyContent: "center",
|
|
1956
|
+
cursor: "pointer",
|
|
1957
|
+
transition: "all 0.2s ease",
|
|
1958
|
+
fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
1959
|
+
};
|
|
1842
1960
|
var buttonStyles = {
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
alignItems: "center",
|
|
1880
|
-
justifyContent: "center",
|
|
1881
|
-
gap: "8px",
|
|
1882
|
-
padding: "12px 24px",
|
|
1883
|
-
fontSize: "14px",
|
|
1884
|
-
fontWeight: 500,
|
|
1885
|
-
color: "#4F46E5",
|
|
1886
|
-
background: "transparent",
|
|
1887
|
-
border: "2px solid #4F46E5",
|
|
1888
|
-
borderRadius: "12px",
|
|
1889
|
-
cursor: "pointer",
|
|
1890
|
-
transition: "all 0.2s ease",
|
|
1891
|
-
fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
1961
|
+
light: {
|
|
1962
|
+
default: {
|
|
1963
|
+
...sharedButtonStyle,
|
|
1964
|
+
gap: "8px",
|
|
1965
|
+
padding: "12px 24px",
|
|
1966
|
+
fontSize: "14px",
|
|
1967
|
+
fontWeight: 600,
|
|
1968
|
+
color: "#ffffff",
|
|
1969
|
+
background: "#1c1c1e",
|
|
1970
|
+
border: "1px solid #1c1c1e",
|
|
1971
|
+
borderRadius: "12px",
|
|
1972
|
+
boxShadow: "0 8px 24px rgba(28, 28, 30, 0.18)"
|
|
1973
|
+
},
|
|
1974
|
+
compact: {
|
|
1975
|
+
...sharedButtonStyle,
|
|
1976
|
+
gap: "6px",
|
|
1977
|
+
padding: "8px 16px",
|
|
1978
|
+
fontSize: "13px",
|
|
1979
|
+
fontWeight: 600,
|
|
1980
|
+
color: "#ffffff",
|
|
1981
|
+
background: "#1c1c1e",
|
|
1982
|
+
border: "1px solid #1c1c1e",
|
|
1983
|
+
borderRadius: "8px",
|
|
1984
|
+
boxShadow: "0 6px 18px rgba(28, 28, 30, 0.16)"
|
|
1985
|
+
},
|
|
1986
|
+
outline: {
|
|
1987
|
+
...sharedButtonStyle,
|
|
1988
|
+
gap: "8px",
|
|
1989
|
+
padding: "12px 24px",
|
|
1990
|
+
fontSize: "14px",
|
|
1991
|
+
fontWeight: 600,
|
|
1992
|
+
color: "#1c1c1e",
|
|
1993
|
+
background: "transparent",
|
|
1994
|
+
border: "1px solid #1c1c1e",
|
|
1995
|
+
borderRadius: "12px"
|
|
1996
|
+
}
|
|
1892
1997
|
},
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1998
|
+
dark: {
|
|
1999
|
+
default: {
|
|
2000
|
+
...sharedButtonStyle,
|
|
2001
|
+
gap: "8px",
|
|
2002
|
+
padding: "12px 24px",
|
|
2003
|
+
fontSize: "14px",
|
|
2004
|
+
fontWeight: 600,
|
|
2005
|
+
color: "#111113",
|
|
2006
|
+
background: "#ffffff",
|
|
2007
|
+
border: "1px solid rgba(255, 255, 255, 0.9)",
|
|
2008
|
+
borderRadius: "12px",
|
|
2009
|
+
boxShadow: "0 8px 24px rgba(0, 0, 0, 0.32)"
|
|
2010
|
+
},
|
|
2011
|
+
compact: {
|
|
2012
|
+
...sharedButtonStyle,
|
|
2013
|
+
gap: "6px",
|
|
2014
|
+
padding: "8px 16px",
|
|
2015
|
+
fontSize: "13px",
|
|
2016
|
+
fontWeight: 600,
|
|
2017
|
+
color: "#111113",
|
|
2018
|
+
background: "#ffffff",
|
|
2019
|
+
border: "1px solid rgba(255, 255, 255, 0.9)",
|
|
2020
|
+
borderRadius: "8px",
|
|
2021
|
+
boxShadow: "0 6px 18px rgba(0, 0, 0, 0.28)"
|
|
2022
|
+
},
|
|
2023
|
+
outline: {
|
|
2024
|
+
...sharedButtonStyle,
|
|
2025
|
+
gap: "8px",
|
|
2026
|
+
padding: "12px 24px",
|
|
2027
|
+
fontSize: "14px",
|
|
2028
|
+
fontWeight: 600,
|
|
2029
|
+
color: "#ffffff",
|
|
2030
|
+
background: "transparent",
|
|
2031
|
+
border: "1px solid rgba(255, 255, 255, 0.72)",
|
|
2032
|
+
borderRadius: "12px"
|
|
2033
|
+
}
|
|
1896
2034
|
}
|
|
1897
2035
|
};
|
|
2036
|
+
var disabledButtonStyle = {
|
|
2037
|
+
opacity: 0.5,
|
|
2038
|
+
cursor: "not-allowed",
|
|
2039
|
+
boxShadow: "none"
|
|
2040
|
+
};
|
|
2041
|
+
function getButtonStyle(variant, theme, disabled) {
|
|
2042
|
+
return {
|
|
2043
|
+
...buttonStyles[theme][variant],
|
|
2044
|
+
...disabled ? disabledButtonStyle : {}
|
|
2045
|
+
};
|
|
2046
|
+
}
|
|
1898
2047
|
function UniportButton({
|
|
1899
2048
|
recipient,
|
|
1900
2049
|
refundAddress,
|
|
@@ -1920,10 +2069,7 @@ function UniportButton({
|
|
|
1920
2069
|
setIsOpen(false);
|
|
1921
2070
|
onOpenChange?.(false);
|
|
1922
2071
|
};
|
|
1923
|
-
const style =
|
|
1924
|
-
...buttonStyles[variant],
|
|
1925
|
-
...disabled ? buttonStyles.disabled : {}
|
|
1926
|
-
};
|
|
2072
|
+
const style = getButtonStyle(variant, theme, disabled);
|
|
1927
2073
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1928
2074
|
/* @__PURE__ */ jsxs(
|
|
1929
2075
|
"button",
|
|
@@ -2000,6 +2146,6 @@ function UniportIcon() {
|
|
|
2000
2146
|
);
|
|
2001
2147
|
}
|
|
2002
2148
|
|
|
2003
|
-
export { ALL_TOKENS, CHAINS, CHAIN_ICONS, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, TOKEN_ICONS, 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, fromSmallestUnits, generateDeadline, getExecutionStatus, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, rippleXRP, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, useUniportPayment, zcashZEC };
|
|
2149
|
+
export { ALL_TOKENS, CHAINS, 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, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, useUniportPayment, zcashZEC };
|
|
2004
2150
|
//# sourceMappingURL=index.js.map
|
|
2005
2151
|
//# sourceMappingURL=index.js.map
|