@coinlist-co/react 0.10.1 → 0.11.1-rc.22d81d4
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 +32 -0
- package/dist/chunk-AQIHCFW4.js +279 -0
- package/dist/chunk-AQIHCFW4.js.map +1 -0
- package/dist/{chunk-AQVCOWOV.js → chunk-PRG3EDQJ.js} +216 -317
- package/dist/chunk-PRG3EDQJ.js.map +1 -0
- package/dist/chunk-ZVB6KWZ2.js +2206 -0
- package/dist/chunk-ZVB6KWZ2.js.map +1 -0
- package/dist/client/index.cjs +11285 -3319
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +4243 -881
- package/dist/client/index.d.ts +4243 -881
- package/dist/client/index.js +9103 -2389
- package/dist/client/index.js.map +1 -1
- package/dist/collections-DrJFEDHl.d.cts +116 -0
- package/dist/collections-pLtrj6fw.d.ts +116 -0
- package/dist/config-C6vlghJY.d.cts +2617 -0
- package/dist/config-C6vlghJY.d.ts +2617 -0
- package/dist/server/index.cjs +1588 -514
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +266 -162
- package/dist/server/index.d.ts +266 -162
- package/dist/server/index.js +235 -169
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +2203 -937
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +256 -132
- package/dist/shared/index.d.ts +256 -132
- package/dist/shared/index.js +102 -28
- package/package.json +12 -8
- package/dist/chunk-AQVCOWOV.js.map +0 -1
- package/dist/chunk-TBU3EBNM.js +0 -442
- package/dist/chunk-TBU3EBNM.js.map +0 -1
- package/dist/chunk-UOHD7US2.js +0 -855
- package/dist/chunk-UOHD7US2.js.map +0 -1
- package/dist/collections-Bv1Oxzu_.d.ts +0 -28
- package/dist/collections-DDyxbOPZ.d.cts +0 -28
- package/dist/requirement-oVZA1INj.d.cts +0 -1040
- package/dist/requirement-oVZA1INj.d.ts +0 -1040
|
@@ -2,16 +2,57 @@ import {
|
|
|
2
2
|
AssetDecimals,
|
|
3
3
|
BlockchainAmount,
|
|
4
4
|
Bps,
|
|
5
|
+
DecimalString,
|
|
5
6
|
EvmContractAddress,
|
|
7
|
+
InvariantError,
|
|
6
8
|
MAX_UINT_256,
|
|
9
|
+
NA_AMOUNT_ASSET_UI,
|
|
7
10
|
StablecoinSymbol,
|
|
11
|
+
ValidationError,
|
|
8
12
|
arrayBufferToBase64Url,
|
|
9
13
|
assertUint256,
|
|
14
|
+
fetchOfferDetails,
|
|
15
|
+
fetchOffers,
|
|
16
|
+
fetchOffersPage,
|
|
17
|
+
formattedUsdPrice,
|
|
10
18
|
generateSecureRandomBase64Url,
|
|
19
|
+
internalLogger,
|
|
11
20
|
sha256
|
|
12
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-ZVB6KWZ2.js";
|
|
22
|
+
|
|
23
|
+
// src/shared/types/oauth.ts
|
|
24
|
+
var AuthorizationCode = (value) => value;
|
|
25
|
+
var CodeVerifier = (value) => value;
|
|
26
|
+
var CodeChallenge = (value) => value;
|
|
27
|
+
var PKCEState = (value) => value;
|
|
28
|
+
var RedirectUri = (value) => value;
|
|
29
|
+
var ClientId = (value) => value;
|
|
30
|
+
var ClientSecret = (value) => value;
|
|
31
|
+
|
|
32
|
+
// src/shared/core/auth/pkce.ts
|
|
33
|
+
async function generatePKCEParams(config) {
|
|
34
|
+
const state = generateSecureRandomBase64Url(32);
|
|
35
|
+
const codeVerifier = generateSecureRandomBase64Url(32);
|
|
36
|
+
const codeChallengeRaw = await sha256(codeVerifier);
|
|
37
|
+
const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
|
|
38
|
+
return {
|
|
39
|
+
clientId: config.clientId,
|
|
40
|
+
responseType: "code",
|
|
41
|
+
redirectUri: config.redirectUri,
|
|
42
|
+
codeChallenge: CodeChallenge(codeChallenge),
|
|
43
|
+
codeChallengeMethod: "S256",
|
|
44
|
+
state: PKCEState(state),
|
|
45
|
+
codeVerifier: CodeVerifier(codeVerifier)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
13
48
|
|
|
14
|
-
// src/shared/core/blockchain/
|
|
49
|
+
// src/shared/core/blockchain/bps.ts
|
|
50
|
+
var BPS_DENOM = Bps(10000n);
|
|
51
|
+
function applyBps(amount, bps) {
|
|
52
|
+
return assertUint256(amount * bps / BPS_DENOM);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/shared/core/blockchain/erc20/abi.ts
|
|
15
56
|
var ERC20_ABI = [
|
|
16
57
|
{
|
|
17
58
|
type: "function",
|
|
@@ -111,7 +152,98 @@ var ERC20_ABI = [
|
|
|
111
152
|
}
|
|
112
153
|
];
|
|
113
154
|
|
|
114
|
-
// src/shared/core/blockchain/
|
|
155
|
+
// src/shared/core/blockchain/token-registry.ts
|
|
156
|
+
var USDC_SYMBOL = StablecoinSymbol("USDC");
|
|
157
|
+
var USDC = {
|
|
158
|
+
name: "USD Coin",
|
|
159
|
+
symbol: USDC_SYMBOL,
|
|
160
|
+
decimals: AssetDecimals(6)
|
|
161
|
+
};
|
|
162
|
+
var USDT_SYMBOL = StablecoinSymbol("USDT");
|
|
163
|
+
var USDT = {
|
|
164
|
+
name: "Tether USD",
|
|
165
|
+
symbol: USDT_SYMBOL,
|
|
166
|
+
decimals: AssetDecimals(6)
|
|
167
|
+
};
|
|
168
|
+
var USDC_ADDRESSES = {
|
|
169
|
+
ethereum_mainnet: EvmContractAddress(
|
|
170
|
+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
|
171
|
+
),
|
|
172
|
+
ethereum_sepolia: EvmContractAddress(
|
|
173
|
+
"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
|
|
174
|
+
)
|
|
175
|
+
};
|
|
176
|
+
var USDT_ADDRESSES = {
|
|
177
|
+
ethereum_mainnet: EvmContractAddress(
|
|
178
|
+
"0xdac17f958d2ee523a2206206994597c13d831ec7"
|
|
179
|
+
),
|
|
180
|
+
ethereum_sepolia: EvmContractAddress(
|
|
181
|
+
"0x7169D38820dfd117C3FA1f22a697dBA58d90BA06"
|
|
182
|
+
)
|
|
183
|
+
};
|
|
184
|
+
var TOKEN_REGISTRY = {
|
|
185
|
+
erc20: (symbol) => {
|
|
186
|
+
switch (symbol) {
|
|
187
|
+
case "USDC":
|
|
188
|
+
return USDC;
|
|
189
|
+
case "USDT":
|
|
190
|
+
return USDT;
|
|
191
|
+
default:
|
|
192
|
+
throw new InvariantError(`Unknown asset symbol: ${symbol}`);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
contractAddress: (symbol, chain) => {
|
|
196
|
+
switch (symbol) {
|
|
197
|
+
case "USDC":
|
|
198
|
+
return USDC_ADDRESSES[chain];
|
|
199
|
+
case "USDT":
|
|
200
|
+
return USDT_ADDRESSES[chain];
|
|
201
|
+
default:
|
|
202
|
+
throw new InvariantError(`Unknown asset symbol: ${symbol}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/shared/core/checkout/ondo/constants.ts
|
|
208
|
+
var ONDO_SWAP_CONTRACT_ADDRESSES = {
|
|
209
|
+
ethereum_sepolia: EvmContractAddress(
|
|
210
|
+
"0xFF9c5Ade32d9B4102469Bd5F3817CB0061b25feC"
|
|
211
|
+
)
|
|
212
|
+
};
|
|
213
|
+
function ondoSwapContractAddress(chain) {
|
|
214
|
+
return ONDO_SWAP_CONTRACT_ADDRESSES[chain] ?? null;
|
|
215
|
+
}
|
|
216
|
+
var ONDO_POLL_INTERVAL_MS = 15e3;
|
|
217
|
+
var ONDO_QUOTE_EXPIRY_THRESHOLD_MS = 5e3;
|
|
218
|
+
var DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE = DecimalString("1000");
|
|
219
|
+
var ONDO_SUPPORTED_INPUT_ASSETS = [
|
|
220
|
+
USDC_SYMBOL
|
|
221
|
+
];
|
|
222
|
+
|
|
223
|
+
// src/shared/core/checkout/ondo/math.ts
|
|
224
|
+
function computeOndoPrice(transaction) {
|
|
225
|
+
const { notionalValue, receiveOutputAmount } = transaction;
|
|
226
|
+
if (receiveOutputAmount.raw <= 0n) {
|
|
227
|
+
throw new ValidationError(
|
|
228
|
+
"Ondo price: receiveOutputAmount must be greater than zero"
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
const scaled = notionalValue.raw * 10n ** BigInt(receiveOutputAmount.decimals);
|
|
232
|
+
const raw = scaled / receiveOutputAmount.raw;
|
|
233
|
+
return BlockchainAmount({
|
|
234
|
+
raw: assertPriceFits(raw),
|
|
235
|
+
decimals: notionalValue.decimals
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function assertPriceFits(raw) {
|
|
239
|
+
try {
|
|
240
|
+
return assertUint256(raw);
|
|
241
|
+
} catch {
|
|
242
|
+
throw new ValidationError(`Ondo price: out of uint256 bounds (${raw})`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// src/shared/core/checkout/superstate/blockchain/abi.ts
|
|
115
247
|
var SUPERSTATE_SWAP_ABI = [
|
|
116
248
|
{
|
|
117
249
|
type: "function",
|
|
@@ -333,65 +465,7 @@ var SUPERSTATE_SWAP_ABI = [
|
|
|
333
465
|
}
|
|
334
466
|
];
|
|
335
467
|
|
|
336
|
-
// src/shared/core/blockchain/
|
|
337
|
-
var BPS_DENOM = Bps(10000n);
|
|
338
|
-
function applyBps(amount, bps) {
|
|
339
|
-
return assertUint256(amount * bps / BPS_DENOM);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// src/shared/types/blockchain/ui.ts
|
|
343
|
-
var FormattedAmountUi = (value) => value;
|
|
344
|
-
var FormattedPercentUi = (value) => value;
|
|
345
|
-
var TxExplorerUrl = (value) => value;
|
|
346
|
-
var ShortenedWalletAddress = (value) => value;
|
|
347
|
-
var FormattedAmountAssetUi = (value) => value;
|
|
348
|
-
var AssetIconUrl = (value) => value;
|
|
349
|
-
|
|
350
|
-
// src/shared/core/blockchain/chain.ts
|
|
351
|
-
function getChainId(chain) {
|
|
352
|
-
switch (chain) {
|
|
353
|
-
case "ethereum_mainnet":
|
|
354
|
-
return 1;
|
|
355
|
-
case "ethereum_sepolia":
|
|
356
|
-
return 11155111;
|
|
357
|
-
default: {
|
|
358
|
-
const _exhaustive = chain;
|
|
359
|
-
return _exhaustive;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
function getNetworkName(chain) {
|
|
364
|
-
switch (chain) {
|
|
365
|
-
case "ethereum_mainnet":
|
|
366
|
-
return "Ethereum";
|
|
367
|
-
case "ethereum_sepolia":
|
|
368
|
-
return "Ethereum Sepolia";
|
|
369
|
-
default: {
|
|
370
|
-
const _exhaustive = chain;
|
|
371
|
-
return _exhaustive;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
function txExplorerUrl(chain, txHash) {
|
|
376
|
-
return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
|
|
377
|
-
}
|
|
378
|
-
function explorerBaseUrl(chain) {
|
|
379
|
-
switch (chain) {
|
|
380
|
-
case "ethereum_mainnet":
|
|
381
|
-
return "https://etherscan.io";
|
|
382
|
-
case "ethereum_sepolia":
|
|
383
|
-
return "https://sepolia.etherscan.io";
|
|
384
|
-
default: {
|
|
385
|
-
const _exhaustive = chain;
|
|
386
|
-
return _exhaustive;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// src/shared/core/blockchain/formatters.ts
|
|
392
|
-
import { formatUnits } from "viem";
|
|
393
|
-
|
|
394
|
-
// src/shared/core/blockchain/swap/math.ts
|
|
468
|
+
// src/shared/core/checkout/superstate/blockchain/math.ts
|
|
395
469
|
function computePrice({
|
|
396
470
|
inputTokenAmount,
|
|
397
471
|
outputTokenAmount
|
|
@@ -409,149 +483,7 @@ function computeSlip(amount, slippage) {
|
|
|
409
483
|
return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });
|
|
410
484
|
}
|
|
411
485
|
|
|
412
|
-
// src/shared/core/blockchain/
|
|
413
|
-
function shortenAddress(address) {
|
|
414
|
-
const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
|
|
415
|
-
return ShortenedWalletAddress(short);
|
|
416
|
-
}
|
|
417
|
-
function formatAmount(amount, locale, options) {
|
|
418
|
-
const decimal = formatRawAmount(amount);
|
|
419
|
-
let [integerPart, fractionPart = ""] = decimal.split(".");
|
|
420
|
-
const maxFractionDigits = options?.maxFractionDigits;
|
|
421
|
-
const minFractionDigits = maxFractionDigits !== void 0 ? Math.min(maxFractionDigits, amount.decimals) : Math.min(2, amount.decimals);
|
|
422
|
-
if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
|
|
423
|
-
({ integerPart, fractionPart } = roundFractionHalfUp(
|
|
424
|
-
integerPart,
|
|
425
|
-
fractionPart,
|
|
426
|
-
maxFractionDigits
|
|
427
|
-
));
|
|
428
|
-
}
|
|
429
|
-
const fraction = minFractionDigits === 0 ? "" : fractionPart.padEnd(minFractionDigits, "0");
|
|
430
|
-
const integerFormatted = BigInt(integerPart).toLocaleString(locale);
|
|
431
|
-
if (minFractionDigits === 0 && fraction === "") {
|
|
432
|
-
return FormattedAmountUi(integerFormatted);
|
|
433
|
-
}
|
|
434
|
-
const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
|
|
435
|
-
return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);
|
|
436
|
-
}
|
|
437
|
-
function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
|
|
438
|
-
if (fractionPart.length <= maxFractionDigits) {
|
|
439
|
-
return { integerPart, fractionPart };
|
|
440
|
-
}
|
|
441
|
-
if (maxFractionDigits === 0) {
|
|
442
|
-
const roundUp = fractionPart[0] >= "5";
|
|
443
|
-
const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);
|
|
444
|
-
return { integerPart: integer.toString(), fractionPart: "" };
|
|
445
|
-
}
|
|
446
|
-
const trimmed = fractionPart.slice(0, maxFractionDigits);
|
|
447
|
-
if (fractionPart[maxFractionDigits] < "5") {
|
|
448
|
-
return { integerPart, fractionPart: trimmed };
|
|
449
|
-
}
|
|
450
|
-
const digits = trimmed.split("").map((digit) => Number.parseInt(digit, 10));
|
|
451
|
-
let carry = 1;
|
|
452
|
-
for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {
|
|
453
|
-
const sum = digits[i] + carry;
|
|
454
|
-
if (sum === 10) {
|
|
455
|
-
digits[i] = 0;
|
|
456
|
-
carry = 1;
|
|
457
|
-
} else {
|
|
458
|
-
digits[i] = sum;
|
|
459
|
-
carry = 0;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
return {
|
|
463
|
-
integerPart: carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,
|
|
464
|
-
fractionPart: digits.join("")
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
function formatRawAmount(amount) {
|
|
468
|
-
return formatUnits(amount.raw, amount.decimals);
|
|
469
|
-
}
|
|
470
|
-
function formatCompactAmount(amount, locale) {
|
|
471
|
-
const value = Number(formatRawAmount(amount));
|
|
472
|
-
const formatted = new Intl.NumberFormat(locale, {
|
|
473
|
-
notation: "compact",
|
|
474
|
-
maximumFractionDigits: 2
|
|
475
|
-
}).format(value);
|
|
476
|
-
return FormattedAmountUi(formatted);
|
|
477
|
-
}
|
|
478
|
-
function formatBpsAsPercent(bps, locale) {
|
|
479
|
-
const whole = bps / 100n;
|
|
480
|
-
const fraction = bps % 100n;
|
|
481
|
-
const wholeFormatted = whole.toLocaleString(locale);
|
|
482
|
-
const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
|
|
483
|
-
if (fraction === 0n) {
|
|
484
|
-
return FormattedPercentUi(`${wholeFormatted}%`);
|
|
485
|
-
}
|
|
486
|
-
const fractionFormatted = fraction.toString().padStart(2, "0").replace(/0+$/, "");
|
|
487
|
-
return FormattedPercentUi(
|
|
488
|
-
`${wholeFormatted}${decimalSeparator}${fractionFormatted}%`
|
|
489
|
-
);
|
|
490
|
-
}
|
|
491
|
-
function usdAmount(amount) {
|
|
492
|
-
return FormattedAmountAssetUi(`$${amount}`);
|
|
493
|
-
}
|
|
494
|
-
function assetAmount(amount, symbol) {
|
|
495
|
-
return FormattedAmountAssetUi(`${amount} ${symbol}`);
|
|
496
|
-
}
|
|
497
|
-
var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
|
|
498
|
-
var USD_FRACTION_DIGITS = AssetDecimals(2);
|
|
499
|
-
function formattedUsdPrice(amount, locale) {
|
|
500
|
-
if (!amount) return NA_AMOUNT_ASSET_UI;
|
|
501
|
-
return usdAmount(
|
|
502
|
-
formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
function formattedPricePerShare(quote, locale) {
|
|
506
|
-
if (!quote) return NA_AMOUNT_ASSET_UI;
|
|
507
|
-
return formattedUsdPrice(computePrice(quote), locale);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// src/shared/core/blockchain/math.ts
|
|
511
|
-
import { parseUnits } from "viem";
|
|
512
|
-
function parseBlockchainAmount(amount, decimals) {
|
|
513
|
-
const trimmed = amount.trim();
|
|
514
|
-
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
515
|
-
if (trimmed.startsWith("-")) {
|
|
516
|
-
return { valid: false, reason: { type: "negative" } };
|
|
517
|
-
}
|
|
518
|
-
if (/[eE]/.test(trimmed)) {
|
|
519
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
520
|
-
}
|
|
521
|
-
if (!/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
522
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
523
|
-
}
|
|
524
|
-
const [, fraction = ""] = trimmed.split(".");
|
|
525
|
-
if (fraction.length > decimals) {
|
|
526
|
-
return {
|
|
527
|
-
valid: false,
|
|
528
|
-
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
try {
|
|
532
|
-
return {
|
|
533
|
-
valid: true,
|
|
534
|
-
amount: BlockchainAmount({
|
|
535
|
-
raw: parseUnits(trimmed, decimals),
|
|
536
|
-
decimals
|
|
537
|
-
})
|
|
538
|
-
};
|
|
539
|
-
} catch {
|
|
540
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// src/shared/core/blockchain/swap/constants.ts
|
|
545
|
-
var SUPERSTATE_TOS_URL = "https://superstate.com/terms";
|
|
546
|
-
var SWAP_POLL_INTERVAL_MS = 15e3;
|
|
547
|
-
var DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
|
|
548
|
-
var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
|
|
549
|
-
(n) => Bps(n)
|
|
550
|
-
);
|
|
551
|
-
var DEFAULT_SLIPPAGE_BPS = Bps(50n);
|
|
552
|
-
var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("0x84f8e9a6C9Cc12fe911259372EfCa5582C4ae557");
|
|
553
|
-
|
|
554
|
-
// src/shared/core/blockchain/swap/quote.ts
|
|
486
|
+
// src/shared/core/checkout/superstate/blockchain/quote.ts
|
|
555
487
|
var SwapQuote = {
|
|
556
488
|
/**
|
|
557
489
|
* Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
|
|
@@ -571,12 +503,12 @@ var SwapQuote = {
|
|
|
571
503
|
})
|
|
572
504
|
};
|
|
573
505
|
|
|
574
|
-
// src/shared/core/blockchain/
|
|
506
|
+
// src/shared/core/checkout/superstate/blockchain/status.ts
|
|
575
507
|
function isStopped(status) {
|
|
576
508
|
return (status.stopped & status.swapLevel) !== 0n;
|
|
577
509
|
}
|
|
578
510
|
|
|
579
|
-
// src/shared/core/blockchain/
|
|
511
|
+
// src/shared/core/checkout/superstate/blockchain/swapped-event.ts
|
|
580
512
|
import { parseEventLogs } from "viem";
|
|
581
513
|
function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
582
514
|
try {
|
|
@@ -594,83 +526,59 @@ function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
|
594
526
|
}
|
|
595
527
|
}
|
|
596
528
|
|
|
597
|
-
// src/shared/core/
|
|
598
|
-
var
|
|
599
|
-
var
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
var
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
};
|
|
610
|
-
var USDC_ADDRESSES = {
|
|
611
|
-
ethereum_mainnet: EvmContractAddress(
|
|
612
|
-
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
|
613
|
-
),
|
|
614
|
-
ethereum_sepolia: EvmContractAddress(
|
|
615
|
-
"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
|
|
616
|
-
)
|
|
617
|
-
};
|
|
618
|
-
var USDT_ADDRESSES = {
|
|
619
|
-
ethereum_mainnet: EvmContractAddress(
|
|
620
|
-
"0xdac17f958d2ee523a2206206994597c13d831ec7"
|
|
621
|
-
),
|
|
622
|
-
ethereum_sepolia: EvmContractAddress(
|
|
623
|
-
"0x7169D38820dfd117C3FA1f22a697dBA58d90BA06"
|
|
624
|
-
)
|
|
529
|
+
// src/shared/core/checkout/superstate/constants.ts
|
|
530
|
+
var SUPERSTATE_ISSUER_NAME = "Superstate";
|
|
531
|
+
var SUPERSTATE_SUPPORTED_INPUT_ASSETS = [USDC_SYMBOL];
|
|
532
|
+
var SWAP_POLL_INTERVAL_MS = 15e3;
|
|
533
|
+
var DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
|
|
534
|
+
var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
|
|
535
|
+
(n) => Bps(n)
|
|
536
|
+
);
|
|
537
|
+
var DEFAULT_SLIPPAGE_BPS = Bps(50n);
|
|
538
|
+
var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("0x84f8e9a6C9Cc12fe911259372EfCa5582C4ae557");
|
|
539
|
+
var SUPERSTATE_SWAP_CONTRACT_ADDRESSES = {
|
|
540
|
+
ethereum_sepolia: SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA
|
|
625
541
|
};
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
542
|
+
function superstateSwapContractAddress(chain) {
|
|
543
|
+
return SUPERSTATE_SWAP_CONTRACT_ADDRESSES[chain] ?? null;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// src/shared/core/checkout/superstate/formatters.ts
|
|
547
|
+
function formattedPricePerShare(quote, locale) {
|
|
548
|
+
if (!quote) return NA_AMOUNT_ASSET_UI;
|
|
549
|
+
return formattedUsdPrice(computePrice(quote), locale);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// src/shared/core/offers/offers-namespace.ts
|
|
553
|
+
var OffersNamespaceImpl = class {
|
|
554
|
+
constructor(ctx) {
|
|
555
|
+
this.ctx = ctx;
|
|
556
|
+
this.log = internalLogger(ctx.logger, "OFFERS");
|
|
557
|
+
}
|
|
558
|
+
async list() {
|
|
559
|
+
return this.log.wrap("list", void 0, async () => {
|
|
560
|
+
await this.ctx.ensureUserAuthenticated();
|
|
561
|
+
return fetchOffers(this.ctx.api, void 0);
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
async listPage(params) {
|
|
565
|
+
return this.log.wrap("listPage", params, async () => {
|
|
566
|
+
await this.ctx.ensureUserAuthenticated();
|
|
567
|
+
return fetchOffersPage(this.ctx.api, params, void 0);
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
async get(id) {
|
|
571
|
+
return this.log.wrap("get", id, async () => {
|
|
572
|
+
await this.ctx.ensureUserAuthenticated();
|
|
573
|
+
return fetchOfferDetails(this.ctx.api, id, void 0);
|
|
574
|
+
});
|
|
646
575
|
}
|
|
647
576
|
};
|
|
648
577
|
|
|
649
|
-
// src/shared/types/
|
|
650
|
-
var
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
var PKCEState = (value) => value;
|
|
654
|
-
var RedirectUri = (value) => value;
|
|
655
|
-
var ClientId = (value) => value;
|
|
656
|
-
var ClientSecret = (value) => value;
|
|
657
|
-
|
|
658
|
-
// src/shared/pkce.ts
|
|
659
|
-
async function generatePKCEParams(config) {
|
|
660
|
-
const state = generateSecureRandomBase64Url(32);
|
|
661
|
-
const codeVerifier = generateSecureRandomBase64Url(32);
|
|
662
|
-
const codeChallengeRaw = await sha256(codeVerifier);
|
|
663
|
-
const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
|
|
664
|
-
return {
|
|
665
|
-
clientId: config.clientId,
|
|
666
|
-
responseType: "code",
|
|
667
|
-
redirectUri: config.redirectUri,
|
|
668
|
-
codeChallenge: CodeChallenge(codeChallenge),
|
|
669
|
-
codeChallengeMethod: "S256",
|
|
670
|
-
state: PKCEState(state),
|
|
671
|
-
codeVerifier: CodeVerifier(codeVerifier)
|
|
672
|
-
};
|
|
673
|
-
}
|
|
578
|
+
// src/shared/types/blockchain/wallet-error.ts
|
|
579
|
+
var RedactedWalletError = {
|
|
580
|
+
fromWalletError: (error) => error.type === "unknown" ? { type: "unknown" } : error
|
|
581
|
+
};
|
|
674
582
|
|
|
675
583
|
// src/shared/types/user.ts
|
|
676
584
|
var UserId = (value) => value;
|
|
@@ -683,56 +591,47 @@ var User = {
|
|
|
683
591
|
};
|
|
684
592
|
|
|
685
593
|
export {
|
|
594
|
+
AuthorizationCode,
|
|
595
|
+
CodeVerifier,
|
|
596
|
+
CodeChallenge,
|
|
597
|
+
PKCEState,
|
|
598
|
+
RedirectUri,
|
|
599
|
+
ClientId,
|
|
600
|
+
ClientSecret,
|
|
601
|
+
generatePKCEParams,
|
|
686
602
|
ERC20_ABI,
|
|
687
|
-
SUPERSTATE_SWAP_ABI,
|
|
688
603
|
BPS_DENOM,
|
|
689
604
|
applyBps,
|
|
605
|
+
USDC_SYMBOL,
|
|
606
|
+
USDC,
|
|
607
|
+
USDT_SYMBOL,
|
|
608
|
+
USDT,
|
|
609
|
+
TOKEN_REGISTRY,
|
|
610
|
+
ondoSwapContractAddress,
|
|
611
|
+
ONDO_POLL_INTERVAL_MS,
|
|
612
|
+
ONDO_QUOTE_EXPIRY_THRESHOLD_MS,
|
|
613
|
+
DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE,
|
|
614
|
+
ONDO_SUPPORTED_INPUT_ASSETS,
|
|
615
|
+
computeOndoPrice,
|
|
616
|
+
SUPERSTATE_SWAP_ABI,
|
|
690
617
|
computePrice,
|
|
691
618
|
computeSlip,
|
|
619
|
+
SwapQuote,
|
|
692
620
|
isStopped,
|
|
693
621
|
decodeSwappedOutputAmount,
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
TxExplorerUrl,
|
|
697
|
-
ShortenedWalletAddress,
|
|
698
|
-
FormattedAmountAssetUi,
|
|
699
|
-
AssetIconUrl,
|
|
700
|
-
getChainId,
|
|
701
|
-
getNetworkName,
|
|
702
|
-
txExplorerUrl,
|
|
703
|
-
shortenAddress,
|
|
704
|
-
formatAmount,
|
|
705
|
-
formatRawAmount,
|
|
706
|
-
formatCompactAmount,
|
|
707
|
-
formatBpsAsPercent,
|
|
708
|
-
usdAmount,
|
|
709
|
-
assetAmount,
|
|
710
|
-
NA_AMOUNT_ASSET_UI,
|
|
711
|
-
formattedUsdPrice,
|
|
712
|
-
formattedPricePerShare,
|
|
713
|
-
parseBlockchainAmount,
|
|
714
|
-
SUPERSTATE_TOS_URL,
|
|
622
|
+
SUPERSTATE_ISSUER_NAME,
|
|
623
|
+
SUPERSTATE_SUPPORTED_INPUT_ASSETS,
|
|
715
624
|
SWAP_POLL_INTERVAL_MS,
|
|
716
625
|
DEFAULT_AMOUNT_TO_COMPUTE_PRICE,
|
|
717
626
|
SLIPPAGE_OPTIONS_BPS,
|
|
718
627
|
DEFAULT_SLIPPAGE_BPS,
|
|
719
628
|
SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
USDT,
|
|
725
|
-
TOKEN_REGISTRY,
|
|
726
|
-
AuthorizationCode,
|
|
727
|
-
CodeVerifier,
|
|
728
|
-
CodeChallenge,
|
|
729
|
-
PKCEState,
|
|
730
|
-
RedirectUri,
|
|
731
|
-
ClientId,
|
|
732
|
-
ClientSecret,
|
|
733
|
-
generatePKCEParams,
|
|
629
|
+
superstateSwapContractAddress,
|
|
630
|
+
formattedPricePerShare,
|
|
631
|
+
OffersNamespaceImpl,
|
|
632
|
+
RedactedWalletError,
|
|
734
633
|
UserId,
|
|
735
634
|
UserEmail,
|
|
736
635
|
User
|
|
737
636
|
};
|
|
738
|
-
//# sourceMappingURL=chunk-
|
|
637
|
+
//# sourceMappingURL=chunk-PRG3EDQJ.js.map
|