uniport-sdk 0.0.4 → 0.0.6
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 +39 -0
- package/dist/components/index.cjs +447 -248
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +447 -248
- package/dist/components/index.js.map +1 -1
- package/dist/core/index.cjs +133 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +67 -1
- package/dist/core/index.d.ts +67 -1
- package/dist/core/index.js +120 -3
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +273 -57
- 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 +261 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,197 +11,6 @@ var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
|
11
11
|
|
|
12
12
|
// src/components/UniportButton.tsx
|
|
13
13
|
|
|
14
|
-
// src/core/config.ts
|
|
15
|
-
var DEFAULT_HOSTED_BACKEND_URL = "https://uniport-backend-production.up.railway.app";
|
|
16
|
-
var DEFAULT_REQUEST_TIMEOUT_MS = 2e4;
|
|
17
|
-
function normalizeBackendUrl(url) {
|
|
18
|
-
return url.replace(/\/+$/, "");
|
|
19
|
-
}
|
|
20
|
-
function getUniportConfig() {
|
|
21
|
-
const backendUrl = DEFAULT_HOSTED_BACKEND_URL;
|
|
22
|
-
return {
|
|
23
|
-
backendUrl: normalizeBackendUrl(backendUrl),
|
|
24
|
-
requestTimeoutMs: DEFAULT_REQUEST_TIMEOUT_MS
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/core/intents.ts
|
|
29
|
-
var UniportError = class extends Error {
|
|
30
|
-
constructor(params) {
|
|
31
|
-
super(params.message);
|
|
32
|
-
this.name = "UniportError";
|
|
33
|
-
this.code = params.code;
|
|
34
|
-
this.details = params.details;
|
|
35
|
-
this.status = params.status;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
function isAbortError(error) {
|
|
39
|
-
return error instanceof Error && error.name === "AbortError";
|
|
40
|
-
}
|
|
41
|
-
function extractDetailMessage(details) {
|
|
42
|
-
if (typeof details === "string" && details.trim()) {
|
|
43
|
-
return details;
|
|
44
|
-
}
|
|
45
|
-
if (Array.isArray(details)) {
|
|
46
|
-
const firstString = details.find(
|
|
47
|
-
(detail) => typeof detail === "string" && detail.trim().length > 0
|
|
48
|
-
);
|
|
49
|
-
return firstString;
|
|
50
|
-
}
|
|
51
|
-
if (typeof details === "object" && details !== null && "message" in details && typeof details.message === "string") {
|
|
52
|
-
const message = details.message.trim();
|
|
53
|
-
return message || void 0;
|
|
54
|
-
}
|
|
55
|
-
return void 0;
|
|
56
|
-
}
|
|
57
|
-
function toUniportError(body, fallback) {
|
|
58
|
-
const detailMessage = extractDetailMessage(body.details);
|
|
59
|
-
return new UniportError({
|
|
60
|
-
code: body.code || fallback.code,
|
|
61
|
-
message: detailMessage || body.message || fallback.message,
|
|
62
|
-
details: body.details,
|
|
63
|
-
status: fallback.status
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function createTimeoutSignal(timeoutMs, externalSignal) {
|
|
67
|
-
const controller = new AbortController();
|
|
68
|
-
let timedOut = false;
|
|
69
|
-
const timeoutId = setTimeout(() => {
|
|
70
|
-
timedOut = true;
|
|
71
|
-
controller.abort();
|
|
72
|
-
}, timeoutMs);
|
|
73
|
-
const abortFromExternal = () => controller.abort();
|
|
74
|
-
externalSignal?.addEventListener("abort", abortFromExternal, {
|
|
75
|
-
once: true
|
|
76
|
-
});
|
|
77
|
-
return {
|
|
78
|
-
signal: controller.signal,
|
|
79
|
-
didTimeout: () => timedOut,
|
|
80
|
-
cleanup: () => {
|
|
81
|
-
clearTimeout(timeoutId);
|
|
82
|
-
externalSignal?.removeEventListener("abort", abortFromExternal);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function toSmallestUnits(amount, decimals) {
|
|
87
|
-
const [whole, fraction = ""] = amount.split(".");
|
|
88
|
-
const paddedFraction = fraction.padEnd(decimals, "0").slice(0, decimals);
|
|
89
|
-
return `${whole}${paddedFraction}`.replace(/^0+/, "") || "0";
|
|
90
|
-
}
|
|
91
|
-
function generateDeadline(hoursFromNow = 1) {
|
|
92
|
-
const deadline = new Date(Date.now() + hoursFromNow * 60 * 60 * 1e3);
|
|
93
|
-
return deadline.toISOString();
|
|
94
|
-
}
|
|
95
|
-
async function getQuote(options) {
|
|
96
|
-
const {
|
|
97
|
-
originToken,
|
|
98
|
-
destinationToken,
|
|
99
|
-
amount,
|
|
100
|
-
recipient,
|
|
101
|
-
refundTo,
|
|
102
|
-
slippageTolerance = 100,
|
|
103
|
-
// 1% default
|
|
104
|
-
swapType = "EXACT_INPUT",
|
|
105
|
-
deadline,
|
|
106
|
-
dry = false,
|
|
107
|
-
referral = "uniport",
|
|
108
|
-
signal
|
|
109
|
-
} = options;
|
|
110
|
-
const amountInSmallestUnits = toSmallestUnits(amount, originToken.decimals);
|
|
111
|
-
const { backendUrl, requestTimeoutMs } = getUniportConfig();
|
|
112
|
-
const { signal: requestSignal, cleanup, didTimeout } = createTimeoutSignal(
|
|
113
|
-
requestTimeoutMs,
|
|
114
|
-
signal
|
|
115
|
-
);
|
|
116
|
-
let response;
|
|
117
|
-
try {
|
|
118
|
-
response = await fetch(`${backendUrl}/api/quote`, {
|
|
119
|
-
method: "POST",
|
|
120
|
-
headers: { "Content-Type": "application/json" },
|
|
121
|
-
signal: requestSignal,
|
|
122
|
-
body: JSON.stringify({
|
|
123
|
-
dry,
|
|
124
|
-
swapType,
|
|
125
|
-
slippageTolerance,
|
|
126
|
-
originAsset: originToken.assetId,
|
|
127
|
-
destinationAsset: destinationToken.assetId,
|
|
128
|
-
amount: amountInSmallestUnits,
|
|
129
|
-
refundTo,
|
|
130
|
-
recipient,
|
|
131
|
-
deadline: deadline?.toISOString() || generateDeadline(1),
|
|
132
|
-
referral
|
|
133
|
-
})
|
|
134
|
-
});
|
|
135
|
-
} catch (error) {
|
|
136
|
-
cleanup();
|
|
137
|
-
if (isAbortError(error)) {
|
|
138
|
-
if (signal?.aborted && !didTimeout()) {
|
|
139
|
-
throw error;
|
|
140
|
-
}
|
|
141
|
-
throw new UniportError({
|
|
142
|
-
code: "REQUEST_TIMEOUT",
|
|
143
|
-
message: "Quote request timed out"
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
throw error;
|
|
147
|
-
}
|
|
148
|
-
cleanup();
|
|
149
|
-
if (!response.ok) {
|
|
150
|
-
const errorBody = await response.json().catch(() => ({}));
|
|
151
|
-
throw toUniportError(errorBody, {
|
|
152
|
-
code: "QUOTE_FAILED",
|
|
153
|
-
message: "Quote failed.",
|
|
154
|
-
status: response.status
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
const data = await response.json();
|
|
158
|
-
const quote = data.quote;
|
|
159
|
-
return {
|
|
160
|
-
depositAddress: quote.depositAddress || "",
|
|
161
|
-
memo: quote.depositMemo,
|
|
162
|
-
amountIn: quote.amountIn,
|
|
163
|
-
amountOut: quote.amountOut,
|
|
164
|
-
amountOutFormatted: quote.amountOutFormatted,
|
|
165
|
-
amountOutUsd: quote.amountOutUsd,
|
|
166
|
-
deadline: quote.deadline,
|
|
167
|
-
timeWhenInactive: quote.timeWhenInactive,
|
|
168
|
-
correlationId: data.correlationId
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
async function getExecutionStatus(depositAddress, memo) {
|
|
172
|
-
const { backendUrl, requestTimeoutMs } = getUniportConfig();
|
|
173
|
-
const url = new URL(
|
|
174
|
-
`${backendUrl}/api/status/${encodeURIComponent(depositAddress)}`
|
|
175
|
-
);
|
|
176
|
-
if (memo) {
|
|
177
|
-
url.searchParams.set("memo", memo);
|
|
178
|
-
}
|
|
179
|
-
const { signal, cleanup } = createTimeoutSignal(requestTimeoutMs);
|
|
180
|
-
let response;
|
|
181
|
-
try {
|
|
182
|
-
response = await fetch(url.toString(), { signal });
|
|
183
|
-
} catch (error) {
|
|
184
|
-
cleanup();
|
|
185
|
-
if (isAbortError(error)) {
|
|
186
|
-
throw new UniportError({
|
|
187
|
-
code: "REQUEST_TIMEOUT",
|
|
188
|
-
message: "Status check timed out"
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
throw error;
|
|
192
|
-
}
|
|
193
|
-
cleanup();
|
|
194
|
-
if (!response.ok) {
|
|
195
|
-
const errorBody = await response.json().catch(() => ({}));
|
|
196
|
-
throw toUniportError(errorBody, {
|
|
197
|
-
code: "STATUS_CHECK_FAILED",
|
|
198
|
-
message: "Status check failed.",
|
|
199
|
-
status: response.status
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
return await response.json();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
14
|
// src/core/tokens.ts
|
|
206
15
|
var TOKEN_ICONS = {
|
|
207
16
|
// Stablecoins
|
|
@@ -278,8 +87,60 @@ var CHAIN_ICONS = {
|
|
|
278
87
|
ltc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/litecoin/info/logo.png",
|
|
279
88
|
bch: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png",
|
|
280
89
|
xrp: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png",
|
|
281
|
-
zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png"
|
|
90
|
+
zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png",
|
|
91
|
+
scroll: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/scroll/info/logo.png"
|
|
282
92
|
};
|
|
93
|
+
var EVM_CHAINS = [
|
|
94
|
+
"eth",
|
|
95
|
+
"arb",
|
|
96
|
+
"base",
|
|
97
|
+
"op",
|
|
98
|
+
"pol",
|
|
99
|
+
"avax",
|
|
100
|
+
"bsc",
|
|
101
|
+
"gnosis",
|
|
102
|
+
"bera",
|
|
103
|
+
"monad",
|
|
104
|
+
"scroll"
|
|
105
|
+
];
|
|
106
|
+
function isEvmChain(chain) {
|
|
107
|
+
return EVM_CHAINS.includes(chain);
|
|
108
|
+
}
|
|
109
|
+
var CHAINS_REQUIRING_MEMO = ["stellar"];
|
|
110
|
+
function needsMemoDeposit(chain) {
|
|
111
|
+
return CHAINS_REQUIRING_MEMO.includes(chain);
|
|
112
|
+
}
|
|
113
|
+
var EXPLORER_TX_URLS = {
|
|
114
|
+
eth: (h) => `https://etherscan.io/tx/${h}`,
|
|
115
|
+
arb: (h) => `https://arbiscan.io/tx/${h}`,
|
|
116
|
+
base: (h) => `https://basescan.org/tx/${h}`,
|
|
117
|
+
op: (h) => `https://optimistic.etherscan.io/tx/${h}`,
|
|
118
|
+
pol: (h) => `https://polygonscan.com/tx/${h}`,
|
|
119
|
+
avax: (h) => `https://snowtrace.io/tx/${h}`,
|
|
120
|
+
bsc: (h) => `https://bscscan.com/tx/${h}`,
|
|
121
|
+
gnosis: (h) => `https://gnosisscan.io/tx/${h}`,
|
|
122
|
+
bera: (h) => `https://berascan.com/tx/${h}`,
|
|
123
|
+
monad: (h) => `https://monadvision.com/tx/${h}`,
|
|
124
|
+
sui: (h) => `https://suivision.xyz/txblock/${h}`,
|
|
125
|
+
sol: (h) => `https://solscan.io/tx/${h}`,
|
|
126
|
+
btc: (h) => `https://mempool.space/tx/${h}`,
|
|
127
|
+
near: (h) => `https://nearblocks.io/txns/${h}`,
|
|
128
|
+
ton: (h) => `https://tonviewer.com/transaction/${h}`,
|
|
129
|
+
tron: (h) => `https://tronscan.org/#/transaction/${h}`,
|
|
130
|
+
stellar: (h) => `https://stellar.expert/explorer/public/tx/${h}`,
|
|
131
|
+
cardano: (h) => `https://cardanoscan.io/transaction/${h}`,
|
|
132
|
+
aptos: (h) => `https://explorer.aptoslabs.com/txn/${h}?network=mainnet`,
|
|
133
|
+
starknet: (h) => `https://voyager.online/tx/${h}`,
|
|
134
|
+
doge: (h) => `https://dogechain.info/tx/${h}`,
|
|
135
|
+
ltc: (h) => `https://litecoinspace.org/tx/${h}`,
|
|
136
|
+
bch: (h) => `https://blockchair.com/bitcoin-cash/transaction/${h}`,
|
|
137
|
+
xrp: (h) => `https://xrpscan.com/tx/${h}`,
|
|
138
|
+
zec: (h) => `https://blockchair.com/zcash/transaction/${h}`,
|
|
139
|
+
scroll: (h) => `https://scrollscan.com/tx/${h}`
|
|
140
|
+
};
|
|
141
|
+
function getExplorerTxUrl(chain, hash) {
|
|
142
|
+
return EXPLORER_TX_URLS[chain]?.(hash);
|
|
143
|
+
}
|
|
283
144
|
function createToken(chain, symbol, assetId, decimals, contractAddress, options) {
|
|
284
145
|
const normalizedSymbol = symbol.replace("$", "").replace(" ", "");
|
|
285
146
|
const canonicalPrefix = TOKEN_NAME_PREFIXES[chain] || chain;
|
|
@@ -340,6 +201,8 @@ var baseETH = createToken("base", "ETH", "nep141:base.omft.near", 18);
|
|
|
340
201
|
var baseUSDC = createToken("base", "USDC", "nep141:base-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913.omft.near", 6, "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913");
|
|
341
202
|
var baseCbBTC = createToken("base", "cbBTC", "nep141:base-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near", 8, "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf", { name: "baseCbBTC" });
|
|
342
203
|
var baseBRETT = createToken("base", "BRETT", "nep141:base-0x532f27101965dd16442e59d40670faf5ebb142e4.omft.near", 18, "0x532f27101965dd16442e59d40670faf5ebb142e4");
|
|
204
|
+
var scrollETH = createToken("scroll", "ETH", "nep245:v2_1.omni.hot.tg:534352_11111111111111111111", 18);
|
|
205
|
+
var scrollUSDT = createToken("scroll", "USDT", "nep245:v2_1.omni.hot.tg:534352_4RG3Q2wFsMQmd45m5m89RjsLfupA", 6, "0xf55bec9cafdbe8730f096aa55dad6d22d44099df");
|
|
343
206
|
var optimismETH = createToken("op", "ETH", "nep245:v2_1.omni.hot.tg:10_11111111111111111111", 18);
|
|
344
207
|
var optimismUSDC = createToken("op", "USDC", "nep245:v2_1.omni.hot.tg:10_A2ewyUyDp6qsue1jqZsGypkCxRJ", 6, "0x0b2c639c533813f4aa9d7837caf62653d097ff85");
|
|
345
208
|
var optimismUSDT = createToken("op", "USDT", "nep245:v2_1.omni.hot.tg:10_359RPSJVdTxwTJT9TyGssr2rFoWo", 6, "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58");
|
|
@@ -373,6 +236,8 @@ var aptosAPT = createToken("aptos", "APT", "nep141:aptos.omft.near", 8);
|
|
|
373
236
|
var starknetSTRK = createToken("starknet", "STRK", "nep141:starknet.omft.near", 18);
|
|
374
237
|
var berachainBERA = createToken("bera", "BERA", "nep141:bera.omft.near", 18);
|
|
375
238
|
var zcashZEC = createToken("zec", "ZEC", "nep141:zec.omft.near", 8);
|
|
239
|
+
var stellarXLM = createToken("stellar", "XLM", "nep245:v2_1.omni.hot.tg:1100_111bzQBB5v7AhLyPMDwS8uJgQV24KaAPXtwyVWu2KXbbfQU6NXRCz", 7);
|
|
240
|
+
var stellarUSDC = createToken("stellar", "USDC", "nep245:v2_1.omni.hot.tg:1100_111bzQBB65GxAPAVoxqmMcgYo5oS3txhqs1Uh1cgahKQUeTUq1TJu", 7, "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN");
|
|
376
241
|
var nearNEAR = createToken("near", "wNEAR", "nep141:wrap.near", 24, "wrap.near", {
|
|
377
242
|
name: "nearNEAR",
|
|
378
243
|
aliases: ["nearwNEAR"]
|
|
@@ -404,6 +269,12 @@ var CHAINS = {
|
|
|
404
269
|
icon: CHAIN_ICONS.base,
|
|
405
270
|
tokens: [baseETH, baseUSDC, baseCbBTC, baseBRETT]
|
|
406
271
|
},
|
|
272
|
+
scroll: {
|
|
273
|
+
id: "scroll",
|
|
274
|
+
name: "Scroll",
|
|
275
|
+
icon: CHAIN_ICONS.scroll,
|
|
276
|
+
tokens: [scrollETH, scrollUSDT]
|
|
277
|
+
},
|
|
407
278
|
op: {
|
|
408
279
|
id: "op",
|
|
409
280
|
name: "Optimism",
|
|
@@ -528,7 +399,7 @@ var CHAINS = {
|
|
|
528
399
|
id: "stellar",
|
|
529
400
|
name: "Stellar",
|
|
530
401
|
icon: CHAIN_ICONS.stellar,
|
|
531
|
-
tokens: []
|
|
402
|
+
tokens: [stellarXLM, stellarUSDC]
|
|
532
403
|
}
|
|
533
404
|
};
|
|
534
405
|
var ALL_TOKENS = Object.values(CHAINS).flatMap((chain) => chain.tokens);
|
|
@@ -541,6 +412,249 @@ function getSupportedChains() {
|
|
|
541
412
|
return Object.values(CHAINS).filter((c) => c.tokens.length > 0);
|
|
542
413
|
}
|
|
543
414
|
|
|
415
|
+
// src/core/config.ts
|
|
416
|
+
var DEFAULT_HOSTED_BACKEND_URL = "https://uniport-backend-production.up.railway.app";
|
|
417
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 2e4;
|
|
418
|
+
function normalizeBackendUrl(url) {
|
|
419
|
+
return url.replace(/\/+$/, "");
|
|
420
|
+
}
|
|
421
|
+
function getUniportConfig() {
|
|
422
|
+
const backendUrl = DEFAULT_HOSTED_BACKEND_URL;
|
|
423
|
+
return {
|
|
424
|
+
backendUrl: normalizeBackendUrl(backendUrl),
|
|
425
|
+
requestTimeoutMs: DEFAULT_REQUEST_TIMEOUT_MS
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// src/core/intents.ts
|
|
430
|
+
var UniportError = class extends Error {
|
|
431
|
+
constructor(params) {
|
|
432
|
+
super(params.message);
|
|
433
|
+
this.name = "UniportError";
|
|
434
|
+
this.code = params.code;
|
|
435
|
+
this.details = params.details;
|
|
436
|
+
this.status = params.status;
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
function isAbortError(error) {
|
|
440
|
+
return error instanceof Error && error.name === "AbortError";
|
|
441
|
+
}
|
|
442
|
+
function extractDetailMessage(details) {
|
|
443
|
+
if (typeof details === "string" && details.trim()) {
|
|
444
|
+
return details;
|
|
445
|
+
}
|
|
446
|
+
if (Array.isArray(details)) {
|
|
447
|
+
const firstString = details.find(
|
|
448
|
+
(detail) => typeof detail === "string" && detail.trim().length > 0
|
|
449
|
+
);
|
|
450
|
+
return firstString;
|
|
451
|
+
}
|
|
452
|
+
if (typeof details === "object" && details !== null && "message" in details && typeof details.message === "string") {
|
|
453
|
+
const message = details.message.trim();
|
|
454
|
+
return message || void 0;
|
|
455
|
+
}
|
|
456
|
+
return void 0;
|
|
457
|
+
}
|
|
458
|
+
function toUniportError(body, fallback) {
|
|
459
|
+
const detailMessage = extractDetailMessage(body.details);
|
|
460
|
+
return new UniportError({
|
|
461
|
+
code: body.code || fallback.code,
|
|
462
|
+
message: detailMessage || body.message || fallback.message,
|
|
463
|
+
details: body.details,
|
|
464
|
+
status: fallback.status
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function createTimeoutSignal(timeoutMs, externalSignal) {
|
|
468
|
+
const controller = new AbortController();
|
|
469
|
+
let timedOut = false;
|
|
470
|
+
const timeoutId = setTimeout(() => {
|
|
471
|
+
timedOut = true;
|
|
472
|
+
controller.abort();
|
|
473
|
+
}, timeoutMs);
|
|
474
|
+
const abortFromExternal = () => controller.abort();
|
|
475
|
+
externalSignal?.addEventListener("abort", abortFromExternal, {
|
|
476
|
+
once: true
|
|
477
|
+
});
|
|
478
|
+
return {
|
|
479
|
+
signal: controller.signal,
|
|
480
|
+
didTimeout: () => timedOut,
|
|
481
|
+
cleanup: () => {
|
|
482
|
+
clearTimeout(timeoutId);
|
|
483
|
+
externalSignal?.removeEventListener("abort", abortFromExternal);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function toSmallestUnits(amount, decimals) {
|
|
488
|
+
const [whole, fraction = ""] = amount.split(".");
|
|
489
|
+
const paddedFraction = fraction.padEnd(decimals, "0").slice(0, decimals);
|
|
490
|
+
return `${whole}${paddedFraction}`.replace(/^0+/, "") || "0";
|
|
491
|
+
}
|
|
492
|
+
function generateDeadline(hoursFromNow = 1) {
|
|
493
|
+
const deadline = new Date(Date.now() + hoursFromNow * 60 * 60 * 1e3);
|
|
494
|
+
return deadline.toISOString();
|
|
495
|
+
}
|
|
496
|
+
function formatDisplayAmount(amount, significantDigits = 6) {
|
|
497
|
+
if (!amount) return amount ?? "";
|
|
498
|
+
const num = Number(amount);
|
|
499
|
+
if (!Number.isFinite(num) || num === 0) return amount;
|
|
500
|
+
const abs = Math.abs(num);
|
|
501
|
+
if (abs < 1e-6 || abs >= 1e21) return amount;
|
|
502
|
+
return new Intl.NumberFormat("en-US", {
|
|
503
|
+
maximumSignificantDigits: significantDigits,
|
|
504
|
+
useGrouping: false
|
|
505
|
+
}).format(num);
|
|
506
|
+
}
|
|
507
|
+
async function getQuote(options) {
|
|
508
|
+
const {
|
|
509
|
+
originToken,
|
|
510
|
+
destinationToken,
|
|
511
|
+
amount,
|
|
512
|
+
recipient,
|
|
513
|
+
refundTo,
|
|
514
|
+
slippageTolerance = 100,
|
|
515
|
+
// 1% default
|
|
516
|
+
swapType = "EXACT_INPUT",
|
|
517
|
+
deadline,
|
|
518
|
+
dry = false,
|
|
519
|
+
referral = "uniport",
|
|
520
|
+
signal
|
|
521
|
+
} = options;
|
|
522
|
+
const amountInSmallestUnits = toSmallestUnits(amount, originToken.decimals);
|
|
523
|
+
const { backendUrl, requestTimeoutMs } = getUniportConfig();
|
|
524
|
+
const { signal: requestSignal, cleanup, didTimeout } = createTimeoutSignal(
|
|
525
|
+
requestTimeoutMs,
|
|
526
|
+
signal
|
|
527
|
+
);
|
|
528
|
+
let response;
|
|
529
|
+
try {
|
|
530
|
+
response = await fetch(`${backendUrl}/api/quote`, {
|
|
531
|
+
method: "POST",
|
|
532
|
+
headers: { "Content-Type": "application/json" },
|
|
533
|
+
signal: requestSignal,
|
|
534
|
+
body: JSON.stringify({
|
|
535
|
+
dry,
|
|
536
|
+
swapType,
|
|
537
|
+
slippageTolerance,
|
|
538
|
+
depositMode: needsMemoDeposit(originToken.chain) ? "MEMO" : void 0,
|
|
539
|
+
originAsset: originToken.assetId,
|
|
540
|
+
destinationAsset: destinationToken.assetId,
|
|
541
|
+
amount: amountInSmallestUnits,
|
|
542
|
+
refundTo,
|
|
543
|
+
recipient,
|
|
544
|
+
deadline: deadline?.toISOString() || generateDeadline(1),
|
|
545
|
+
referral
|
|
546
|
+
})
|
|
547
|
+
});
|
|
548
|
+
} catch (error) {
|
|
549
|
+
cleanup();
|
|
550
|
+
if (isAbortError(error)) {
|
|
551
|
+
if (signal?.aborted && !didTimeout()) {
|
|
552
|
+
throw error;
|
|
553
|
+
}
|
|
554
|
+
throw new UniportError({
|
|
555
|
+
code: "REQUEST_TIMEOUT",
|
|
556
|
+
message: "Quote request timed out"
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
throw error;
|
|
560
|
+
}
|
|
561
|
+
cleanup();
|
|
562
|
+
if (!response.ok) {
|
|
563
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
564
|
+
throw toUniportError(errorBody, {
|
|
565
|
+
code: "QUOTE_FAILED",
|
|
566
|
+
message: "Quote failed.",
|
|
567
|
+
status: response.status
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
const data = await response.json();
|
|
571
|
+
const quote = data.quote;
|
|
572
|
+
return {
|
|
573
|
+
depositAddress: quote.depositAddress || "",
|
|
574
|
+
memo: quote.depositMemo,
|
|
575
|
+
amountIn: quote.amountIn,
|
|
576
|
+
amountOut: quote.amountOut,
|
|
577
|
+
amountOutFormatted: quote.amountOutFormatted,
|
|
578
|
+
amountOutUsd: quote.amountOutUsd,
|
|
579
|
+
deadline: quote.deadline,
|
|
580
|
+
timeWhenInactive: quote.timeWhenInactive,
|
|
581
|
+
correlationId: data.correlationId
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
async function getExecutionStatus(depositAddress, memo) {
|
|
585
|
+
const { backendUrl, requestTimeoutMs } = getUniportConfig();
|
|
586
|
+
const url = new URL(
|
|
587
|
+
`${backendUrl}/api/status/${encodeURIComponent(depositAddress)}`
|
|
588
|
+
);
|
|
589
|
+
if (memo) {
|
|
590
|
+
url.searchParams.set("memo", memo);
|
|
591
|
+
}
|
|
592
|
+
const { signal, cleanup } = createTimeoutSignal(requestTimeoutMs);
|
|
593
|
+
let response;
|
|
594
|
+
try {
|
|
595
|
+
response = await fetch(url.toString(), { signal });
|
|
596
|
+
} catch (error) {
|
|
597
|
+
cleanup();
|
|
598
|
+
if (isAbortError(error)) {
|
|
599
|
+
throw new UniportError({
|
|
600
|
+
code: "REQUEST_TIMEOUT",
|
|
601
|
+
message: "Status check timed out"
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
throw error;
|
|
605
|
+
}
|
|
606
|
+
cleanup();
|
|
607
|
+
if (!response.ok) {
|
|
608
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
609
|
+
throw toUniportError(errorBody, {
|
|
610
|
+
code: "STATUS_CHECK_FAILED",
|
|
611
|
+
message: "Status check failed.",
|
|
612
|
+
status: response.status
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
return await response.json();
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// src/core/ens.ts
|
|
619
|
+
var ENSIDEAS_BASE_URL = "https://api.ensideas.com/ens/resolve";
|
|
620
|
+
var UNIPORT_ENS_NAME = "uniport.eth";
|
|
621
|
+
var UNIPORT_FALLBACK_REFUND_ADDRESS = "0x2f43A54f931b95053c3DDa5f4637065AA0c3c494";
|
|
622
|
+
async function resolveEnsName(name, options) {
|
|
623
|
+
const controller = new AbortController();
|
|
624
|
+
const timeoutId = setTimeout(
|
|
625
|
+
() => controller.abort(),
|
|
626
|
+
1e4
|
|
627
|
+
);
|
|
628
|
+
try {
|
|
629
|
+
const response = await fetch(
|
|
630
|
+
`${ENSIDEAS_BASE_URL}/${encodeURIComponent(name)}`,
|
|
631
|
+
{ signal: controller.signal }
|
|
632
|
+
);
|
|
633
|
+
if (!response.ok) return null;
|
|
634
|
+
const data = await response.json();
|
|
635
|
+
if (!data.address) return null;
|
|
636
|
+
return {
|
|
637
|
+
address: data.address,
|
|
638
|
+
name: data.name ?? name,
|
|
639
|
+
displayName: data.displayName ?? name,
|
|
640
|
+
avatar: data.avatar ?? null
|
|
641
|
+
};
|
|
642
|
+
} catch {
|
|
643
|
+
return null;
|
|
644
|
+
} finally {
|
|
645
|
+
clearTimeout(timeoutId);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
var uniportRefundAddressPromise = null;
|
|
649
|
+
function getUniportDefaultRefundAddress() {
|
|
650
|
+
if (!uniportRefundAddressPromise) {
|
|
651
|
+
uniportRefundAddressPromise = resolveEnsName(UNIPORT_ENS_NAME).then(
|
|
652
|
+
(result) => result?.address ?? UNIPORT_FALLBACK_REFUND_ADDRESS
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
return uniportRefundAddressPromise;
|
|
656
|
+
}
|
|
657
|
+
|
|
544
658
|
// src/hooks/useUniportPayment.ts
|
|
545
659
|
function useUniportPayment(options) {
|
|
546
660
|
const {
|
|
@@ -570,6 +684,19 @@ function useUniportPayment(options) {
|
|
|
570
684
|
const [refundAddress, setRefundAddressState] = react.useState(
|
|
571
685
|
initialRefundAddress ?? ""
|
|
572
686
|
);
|
|
687
|
+
const [evmDefaultRefundAddress, setEvmDefaultRefundAddress] = react.useState(
|
|
688
|
+
UNIPORT_FALLBACK_REFUND_ADDRESS
|
|
689
|
+
);
|
|
690
|
+
react.useEffect(() => {
|
|
691
|
+
let cancelled = false;
|
|
692
|
+
getUniportDefaultRefundAddress().then((address) => {
|
|
693
|
+
if (!cancelled) setEvmDefaultRefundAddress(address);
|
|
694
|
+
});
|
|
695
|
+
return () => {
|
|
696
|
+
cancelled = true;
|
|
697
|
+
};
|
|
698
|
+
}, []);
|
|
699
|
+
const effectiveRefundAddress = refundAddress.trim() || (selectedChain && isEvmChain(selectedChain.id) ? evmDefaultRefundAddress : "");
|
|
573
700
|
const pollingRef = react.useRef(null);
|
|
574
701
|
const lastStatusRef = react.useRef(null);
|
|
575
702
|
const previewDebounceRef = react.useRef(null);
|
|
@@ -626,31 +753,33 @@ function useUniportPayment(options) {
|
|
|
626
753
|
const setAmount = react.useCallback(
|
|
627
754
|
(newAmount) => {
|
|
628
755
|
setAmountState(newAmount);
|
|
629
|
-
schedulePreviewQuote(newAmount,
|
|
756
|
+
schedulePreviewQuote(newAmount, effectiveRefundAddress, selectedToken);
|
|
630
757
|
},
|
|
631
|
-
[
|
|
758
|
+
[effectiveRefundAddress, schedulePreviewQuote, selectedToken]
|
|
632
759
|
);
|
|
633
760
|
const setRefundAddress = react.useCallback(
|
|
634
761
|
(newRefundAddress) => {
|
|
635
762
|
setRefundAddressState(newRefundAddress);
|
|
636
|
-
|
|
763
|
+
const nextEffective = newRefundAddress.trim() || (selectedChain && isEvmChain(selectedChain.id) ? evmDefaultRefundAddress : "");
|
|
764
|
+
schedulePreviewQuote(amount, nextEffective, selectedToken);
|
|
637
765
|
},
|
|
638
|
-
[amount, schedulePreviewQuote, selectedToken]
|
|
766
|
+
[amount, evmDefaultRefundAddress, schedulePreviewQuote, selectedChain, selectedToken]
|
|
639
767
|
);
|
|
640
768
|
const handleChainSelect = react.useCallback((chain) => {
|
|
641
769
|
const nextToken = chain.tokens[0] || null;
|
|
642
770
|
setSelectedChain(chain);
|
|
643
771
|
setSelectedToken(nextToken);
|
|
644
772
|
setPaymentState("selecting");
|
|
645
|
-
|
|
646
|
-
|
|
773
|
+
const nextEffective = refundAddress.trim() || (isEvmChain(chain.id) ? evmDefaultRefundAddress : "");
|
|
774
|
+
schedulePreviewQuote(amount, nextEffective, nextToken);
|
|
775
|
+
}, [amount, evmDefaultRefundAddress, refundAddress, schedulePreviewQuote]);
|
|
647
776
|
const handleTokenSelect = react.useCallback((token) => {
|
|
648
777
|
setSelectedToken(token);
|
|
649
778
|
setPaymentState("selecting");
|
|
650
|
-
schedulePreviewQuote(amount,
|
|
651
|
-
}, [amount,
|
|
779
|
+
schedulePreviewQuote(amount, effectiveRefundAddress, token);
|
|
780
|
+
}, [amount, effectiveRefundAddress, schedulePreviewQuote]);
|
|
652
781
|
const fetchQuote = react.useCallback(async () => {
|
|
653
|
-
if (!selectedToken || !amount || !
|
|
782
|
+
if (!selectedToken || !amount || !effectiveRefundAddress) {
|
|
654
783
|
setError(new Error("Missing required fields"));
|
|
655
784
|
return;
|
|
656
785
|
}
|
|
@@ -662,7 +791,7 @@ function useUniportPayment(options) {
|
|
|
662
791
|
destinationToken: destToken,
|
|
663
792
|
amount,
|
|
664
793
|
recipient,
|
|
665
|
-
refundTo:
|
|
794
|
+
refundTo: effectiveRefundAddress,
|
|
666
795
|
dry: false
|
|
667
796
|
});
|
|
668
797
|
setQuote(result);
|
|
@@ -676,7 +805,7 @@ function useUniportPayment(options) {
|
|
|
676
805
|
}, [
|
|
677
806
|
selectedToken,
|
|
678
807
|
amount,
|
|
679
|
-
|
|
808
|
+
effectiveRefundAddress,
|
|
680
809
|
recipient,
|
|
681
810
|
destToken,
|
|
682
811
|
onError
|
|
@@ -787,6 +916,8 @@ function useUniportPayment(options) {
|
|
|
787
916
|
selectedToken,
|
|
788
917
|
amount,
|
|
789
918
|
refundAddress,
|
|
919
|
+
effectiveRefundAddress,
|
|
920
|
+
isUsingDefaultRefundAddress: !refundAddress.trim() && !!effectiveRefundAddress,
|
|
790
921
|
destinationToken: destToken,
|
|
791
922
|
chains,
|
|
792
923
|
tokens,
|
|
@@ -1055,7 +1186,7 @@ function UniportModal({
|
|
|
1055
1186
|
onError
|
|
1056
1187
|
});
|
|
1057
1188
|
const [modalStep, setModalStep] = react.useState("chain");
|
|
1058
|
-
const [
|
|
1189
|
+
const [copiedField, setCopiedField] = react.useState(null);
|
|
1059
1190
|
const [showReceipt, setShowReceipt] = react.useState(false);
|
|
1060
1191
|
const [portalRoot, setPortalRoot] = react.useState(null);
|
|
1061
1192
|
react.useEffect(() => {
|
|
@@ -1087,13 +1218,11 @@ function UniportModal({
|
|
|
1087
1218
|
};
|
|
1088
1219
|
}
|
|
1089
1220
|
}, [open, handleClose]);
|
|
1090
|
-
const handleCopy = react.useCallback(async () => {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
1096
|
-
}
|
|
1221
|
+
const handleCopy = react.useCallback(async (field, text) => {
|
|
1222
|
+
const ok = await payment.copyToClipboard(text);
|
|
1223
|
+
if (ok) {
|
|
1224
|
+
setCopiedField(field);
|
|
1225
|
+
setTimeout(() => setCopiedField(null), 2e3);
|
|
1097
1226
|
}
|
|
1098
1227
|
}, [payment]);
|
|
1099
1228
|
if (!open || !portalRoot) return null;
|
|
@@ -1102,8 +1231,8 @@ function UniportModal({
|
|
|
1102
1231
|
const isSuccess = paymentState === "success";
|
|
1103
1232
|
const isError = paymentState === "error";
|
|
1104
1233
|
const isQuoting = paymentState === "quoting";
|
|
1105
|
-
const canSubmit = !!(payment.selectedToken && payment.amount && payment.
|
|
1106
|
-
const canPreviewEstimate = !!(payment.selectedToken && payment.amount && payment.
|
|
1234
|
+
const canSubmit = !!(payment.selectedToken && payment.amount && payment.effectiveRefundAddress);
|
|
1235
|
+
const canPreviewEstimate = !!(payment.selectedToken && payment.amount && payment.effectiveRefundAddress);
|
|
1107
1236
|
const showBack = !isSuccess && !isError && (showQR || modalStep !== "chain");
|
|
1108
1237
|
const iconBtn = {
|
|
1109
1238
|
width: 36,
|
|
@@ -1339,7 +1468,8 @@ function UniportModal({
|
|
|
1339
1468
|
},
|
|
1340
1469
|
children: [
|
|
1341
1470
|
"Refund address on ",
|
|
1342
|
-
ch?.name || "the source chain"
|
|
1471
|
+
ch?.name || "the source chain",
|
|
1472
|
+
ch && isEvmChain(ch.id) && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 400, color: t.textMuted }, children: " (optional)" })
|
|
1343
1473
|
]
|
|
1344
1474
|
}
|
|
1345
1475
|
),
|
|
@@ -1349,7 +1479,7 @@ function UniportModal({
|
|
|
1349
1479
|
type: "text",
|
|
1350
1480
|
value: payment.refundAddress,
|
|
1351
1481
|
onChange: (e) => payment.setRefundAddress(e.target.value),
|
|
1352
|
-
placeholder: `Enter a ${ch?.name || "source chain"} refund address`,
|
|
1482
|
+
placeholder: ch && isEvmChain(ch.id) ? `Optional \u2014 defaults to ${UNIPORT_ENS_NAME}` : `Enter a ${ch?.name || "source chain"} refund address`,
|
|
1353
1483
|
spellCheck: false,
|
|
1354
1484
|
autoCapitalize: "off",
|
|
1355
1485
|
autoCorrect: "off",
|
|
@@ -1375,7 +1505,23 @@ function UniportModal({
|
|
|
1375
1505
|
color: t.textMuted,
|
|
1376
1506
|
lineHeight: 1.5
|
|
1377
1507
|
},
|
|
1378
|
-
children: "Used only if the swap fails. This address must live on the chain the payer is sending from."
|
|
1508
|
+
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."
|
|
1509
|
+
}
|
|
1510
|
+
),
|
|
1511
|
+
ch?.id === "stellar" && tok?.symbol !== "XLM" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1512
|
+
"p",
|
|
1513
|
+
{
|
|
1514
|
+
style: {
|
|
1515
|
+
margin: "6px 0 0",
|
|
1516
|
+
fontSize: "12px",
|
|
1517
|
+
color: t.warning,
|
|
1518
|
+
lineHeight: 1.5
|
|
1519
|
+
},
|
|
1520
|
+
children: [
|
|
1521
|
+
"This refund address must already have a trustline for ",
|
|
1522
|
+
tok?.symbol,
|
|
1523
|
+
" on Stellar, or a refund cannot be delivered to it."
|
|
1524
|
+
]
|
|
1379
1525
|
}
|
|
1380
1526
|
)
|
|
1381
1527
|
] }),
|
|
@@ -1399,7 +1545,7 @@ function UniportModal({
|
|
|
1399
1545
|
"You will receive",
|
|
1400
1546
|
" ",
|
|
1401
1547
|
/* @__PURE__ */ jsxRuntime.jsxs("strong", { style: { color: t.text }, children: [
|
|
1402
|
-
payment.previewQuote.amountOutFormatted,
|
|
1548
|
+
formatDisplayAmount(payment.previewQuote.amountOutFormatted),
|
|
1403
1549
|
" ",
|
|
1404
1550
|
payment.destinationToken.symbol
|
|
1405
1551
|
] }),
|
|
@@ -1440,7 +1586,7 @@ function UniportModal({
|
|
|
1440
1586
|
] }) : "Confirm Payment"
|
|
1441
1587
|
}
|
|
1442
1588
|
),
|
|
1443
|
-
!payment.
|
|
1589
|
+
!payment.effectiveRefundAddress && /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { textAlign: "center", fontSize: "12px", color: t.error, margin: "10px 0 0" }, children: [
|
|
1444
1590
|
"Enter a refund address on ",
|
|
1445
1591
|
ch?.name || "the source chain",
|
|
1446
1592
|
" to continue."
|
|
@@ -1480,7 +1626,7 @@ function UniportModal({
|
|
|
1480
1626
|
padding: "11px 13px",
|
|
1481
1627
|
background: t.inputBg,
|
|
1482
1628
|
borderRadius: "10px",
|
|
1483
|
-
marginBottom: "14px",
|
|
1629
|
+
marginBottom: quote.memo ? "10px" : "14px",
|
|
1484
1630
|
border: `1px solid ${t.border}`
|
|
1485
1631
|
}, children: [
|
|
1486
1632
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: {
|
|
@@ -1494,22 +1640,64 @@ function UniportModal({
|
|
|
1494
1640
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1495
1641
|
"button",
|
|
1496
1642
|
{
|
|
1497
|
-
onClick: handleCopy,
|
|
1643
|
+
onClick: () => handleCopy("address", quote.depositAddress),
|
|
1498
1644
|
title: "Copy address",
|
|
1499
1645
|
style: {
|
|
1500
1646
|
flexShrink: 0,
|
|
1501
1647
|
width: 34,
|
|
1502
1648
|
height: 34,
|
|
1503
1649
|
borderRadius: "8px",
|
|
1504
|
-
background:
|
|
1505
|
-
border: `1px solid ${
|
|
1650
|
+
background: copiedField === "address" ? `${t.success}18` : t.iconBtnBg,
|
|
1651
|
+
border: `1px solid ${copiedField === "address" ? t.success + "44" : t.border}`,
|
|
1506
1652
|
cursor: "pointer",
|
|
1507
1653
|
display: "flex",
|
|
1508
1654
|
alignItems: "center",
|
|
1509
1655
|
justifyContent: "center",
|
|
1510
1656
|
transition: "all 0.2s"
|
|
1511
1657
|
},
|
|
1512
|
-
children:
|
|
1658
|
+
children: copiedField === "address" ? /* @__PURE__ */ jsxRuntime.jsx(CheckMark, { color: t.success }) : /* @__PURE__ */ jsxRuntime.jsx(CopyIcon, { color: t.textMuted })
|
|
1659
|
+
}
|
|
1660
|
+
)
|
|
1661
|
+
] }),
|
|
1662
|
+
quote.memo && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1663
|
+
display: "flex",
|
|
1664
|
+
alignItems: "center",
|
|
1665
|
+
gap: "10px",
|
|
1666
|
+
padding: "11px 13px",
|
|
1667
|
+
background: `${t.warning}0f`,
|
|
1668
|
+
borderRadius: "10px",
|
|
1669
|
+
marginBottom: "14px",
|
|
1670
|
+
border: `1px solid ${t.warning}44`
|
|
1671
|
+
}, children: [
|
|
1672
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1 }, children: [
|
|
1673
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "0 0 3px", fontSize: "11px", color: t.warning, fontWeight: 600, textTransform: "uppercase", letterSpacing: "0.05em" }, children: "Memo required" }),
|
|
1674
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: {
|
|
1675
|
+
fontSize: "13px",
|
|
1676
|
+
color: t.text,
|
|
1677
|
+
fontFamily: "monospace",
|
|
1678
|
+
wordBreak: "break-all",
|
|
1679
|
+
lineHeight: 1.4
|
|
1680
|
+
}, children: quote.memo })
|
|
1681
|
+
] }),
|
|
1682
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1683
|
+
"button",
|
|
1684
|
+
{
|
|
1685
|
+
onClick: () => handleCopy("memo", quote.memo),
|
|
1686
|
+
title: "Copy memo",
|
|
1687
|
+
style: {
|
|
1688
|
+
flexShrink: 0,
|
|
1689
|
+
width: 34,
|
|
1690
|
+
height: 34,
|
|
1691
|
+
borderRadius: "8px",
|
|
1692
|
+
background: copiedField === "memo" ? `${t.success}18` : t.iconBtnBg,
|
|
1693
|
+
border: `1px solid ${copiedField === "memo" ? t.success + "44" : t.border}`,
|
|
1694
|
+
cursor: "pointer",
|
|
1695
|
+
display: "flex",
|
|
1696
|
+
alignItems: "center",
|
|
1697
|
+
justifyContent: "center",
|
|
1698
|
+
transition: "all 0.2s"
|
|
1699
|
+
},
|
|
1700
|
+
children: copiedField === "memo" ? /* @__PURE__ */ jsxRuntime.jsx(CheckMark, { color: t.success }) : /* @__PURE__ */ jsxRuntime.jsx(CopyIcon, { color: t.textMuted })
|
|
1513
1701
|
}
|
|
1514
1702
|
)
|
|
1515
1703
|
] }),
|
|
@@ -1526,7 +1714,14 @@ function UniportModal({
|
|
|
1526
1714
|
" ",
|
|
1527
1715
|
"on ",
|
|
1528
1716
|
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: payment.selectedChain?.name }),
|
|
1529
|
-
" to this address
|
|
1717
|
+
" to this address",
|
|
1718
|
+
quote.memo && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1719
|
+
" ",
|
|
1720
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "with the memo above" })
|
|
1721
|
+
] }),
|
|
1722
|
+
". Other assets may be permanently lost",
|
|
1723
|
+
quote.memo && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: ", and omitting the memo may make your deposit unrecoverable" }),
|
|
1724
|
+
"."
|
|
1530
1725
|
] })
|
|
1531
1726
|
] }),
|
|
1532
1727
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { borderTop: `1px solid ${t.border}`, paddingTop: "12px" }, children: [
|
|
@@ -1534,7 +1729,7 @@ function UniportModal({
|
|
|
1534
1729
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "13px", color: t.textMuted }, children: "You'll receive" }),
|
|
1535
1730
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: "13px", fontWeight: 600, color: t.text }, children: [
|
|
1536
1731
|
"\u2248",
|
|
1537
|
-
quote.amountOutFormatted,
|
|
1732
|
+
formatDisplayAmount(quote.amountOutFormatted),
|
|
1538
1733
|
" ",
|
|
1539
1734
|
payment.destinationToken.symbol
|
|
1540
1735
|
] })
|
|
@@ -1566,6 +1761,25 @@ function UniportModal({
|
|
|
1566
1761
|
] }) })
|
|
1567
1762
|
] });
|
|
1568
1763
|
};
|
|
1764
|
+
const renderTxHash = (hash, url) => url ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1765
|
+
"a",
|
|
1766
|
+
{
|
|
1767
|
+
href: url,
|
|
1768
|
+
target: "_blank",
|
|
1769
|
+
rel: "noopener noreferrer",
|
|
1770
|
+
style: { color: t.accent, fontSize: "12px", fontFamily: "monospace", textDecoration: "none" },
|
|
1771
|
+
children: [
|
|
1772
|
+
hash.slice(0, 12),
|
|
1773
|
+
"\u2026",
|
|
1774
|
+
hash.slice(-8),
|
|
1775
|
+
" \u2197"
|
|
1776
|
+
]
|
|
1777
|
+
}
|
|
1778
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { color: t.textSecondary, fontSize: "12px", fontFamily: "monospace" }, children: [
|
|
1779
|
+
hash.slice(0, 12),
|
|
1780
|
+
"\u2026",
|
|
1781
|
+
hash.slice(-8)
|
|
1782
|
+
] });
|
|
1569
1783
|
const renderSuccessStep = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative" }, children: [
|
|
1570
1784
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1571
1785
|
"button",
|
|
@@ -1609,7 +1823,7 @@ function UniportModal({
|
|
|
1609
1823
|
payment.selectedToken?.symbol,
|
|
1610
1824
|
" \u2192 ",
|
|
1611
1825
|
"\u2248",
|
|
1612
|
-
payment.quote?.amountOutFormatted,
|
|
1826
|
+
formatDisplayAmount(payment.quote?.amountOutFormatted),
|
|
1613
1827
|
" ",
|
|
1614
1828
|
payment.destinationToken.symbol
|
|
1615
1829
|
] }),
|
|
@@ -1636,29 +1850,14 @@ function UniportModal({
|
|
|
1636
1850
|
"Source TX \xB7 ",
|
|
1637
1851
|
payment.selectedChain?.name
|
|
1638
1852
|
] }),
|
|
1639
|
-
|
|
1640
|
-
"a",
|
|
1641
|
-
{
|
|
1642
|
-
href: `https://etherscan.io/tx/${hash}`,
|
|
1643
|
-
target: "_blank",
|
|
1644
|
-
rel: "noopener noreferrer",
|
|
1645
|
-
style: { color: t.accent, fontSize: "12px", fontFamily: "monospace", textDecoration: "none" },
|
|
1646
|
-
children: [
|
|
1647
|
-
hash.slice(0, 12),
|
|
1648
|
-
"\u2026",
|
|
1649
|
-
hash.slice(-8),
|
|
1650
|
-
" \u2197"
|
|
1651
|
-
]
|
|
1652
|
-
}
|
|
1653
|
-
)
|
|
1853
|
+
renderTxHash(hash, payment.selectedChain ? getExplorerTxUrl(payment.selectedChain.id, hash) : void 0)
|
|
1654
1854
|
] }, `o${i}`)),
|
|
1655
1855
|
payment.status?.destinationTxHashes?.map((hash, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1656
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
] })
|
|
1856
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: { color: t.textMuted, fontSize: "11px", margin: "0 0 3px", textTransform: "uppercase", letterSpacing: "0.05em" }, children: [
|
|
1857
|
+
"Destination TX \xB7 ",
|
|
1858
|
+
CHAINS[payment.destinationToken.chain].name
|
|
1859
|
+
] }),
|
|
1860
|
+
renderTxHash(hash, getExplorerTxUrl(payment.destinationToken.chain, hash))
|
|
1662
1861
|
] }, `d${i}`)),
|
|
1663
1862
|
!payment.status?.originTxHashes?.length && !payment.status?.destinationTxHashes?.length && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: t.textMuted, fontSize: "13px", margin: 0 }, children: "Loading transaction details\u2026" })
|
|
1664
1863
|
] }),
|