@coinlist-co/react 0.10.0 → 0.10.1
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/dist/{chunk-GSSAB4K5.js → chunk-AQVCOWOV.js} +163 -69
- package/dist/chunk-AQVCOWOV.js.map +1 -0
- package/dist/{chunk-7BJ2HAG7.js → chunk-TBU3EBNM.js} +2 -2
- package/dist/{chunk-TUZKKFNW.js → chunk-UOHD7US2.js} +53 -34
- package/dist/chunk-UOHD7US2.js.map +1 -0
- package/dist/client/index.cjs +292 -295
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +5 -4
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-ZYLKp8JB.d.ts → collections-Bv1Oxzu_.d.ts} +1 -1
- package/dist/{collections-CJ24dOda.d.cts → collections-DDyxbOPZ.d.cts} +1 -1
- package/dist/{requirement-CDi5NJI8.d.cts → requirement-oVZA1INj.d.cts} +5 -1
- package/dist/{requirement-CDi5NJI8.d.ts → requirement-oVZA1INj.d.ts} +5 -1
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +3 -5
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +4 -4
- package/dist/shared/index.d.ts +4 -4
- package/dist/shared/index.js +12 -92
- package/dist/shared/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-AAER5LOL.js +0 -22
- package/dist/chunk-AAER5LOL.js.map +0 -1
- package/dist/chunk-GSSAB4K5.js.map +0 -1
- package/dist/chunk-TUZKKFNW.js.map +0 -1
- /package/dist/{chunk-7BJ2HAG7.js.map → chunk-TBU3EBNM.js.map} +0 -0
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
assertUint256,
|
|
10
10
|
generateSecureRandomBase64Url,
|
|
11
11
|
sha256
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-UOHD7US2.js";
|
|
13
13
|
|
|
14
14
|
// src/shared/core/blockchain/abis/erc20.ts
|
|
15
15
|
var ERC20_ABI = [
|
|
@@ -339,6 +339,58 @@ function applyBps(amount, bps) {
|
|
|
339
339
|
return assertUint256(amount * bps / BPS_DENOM);
|
|
340
340
|
}
|
|
341
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
|
+
|
|
342
394
|
// src/shared/core/blockchain/swap/math.ts
|
|
343
395
|
function computePrice({
|
|
344
396
|
inputTokenAmount,
|
|
@@ -357,65 +409,7 @@ function computeSlip(amount, slippage) {
|
|
|
357
409
|
return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });
|
|
358
410
|
}
|
|
359
411
|
|
|
360
|
-
// src/shared/core/blockchain/swap/status.ts
|
|
361
|
-
function isStopped(status) {
|
|
362
|
-
return (status.stopped & status.swapLevel) !== 0n;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// src/shared/core/blockchain/swap/swapped-event.ts
|
|
366
|
-
import { parseEventLogs } from "viem";
|
|
367
|
-
function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
368
|
-
try {
|
|
369
|
-
const [swapped] = parseEventLogs({
|
|
370
|
-
abi: SUPERSTATE_SWAP_ABI,
|
|
371
|
-
eventName: "Swapped",
|
|
372
|
-
logs: receipt.logs
|
|
373
|
-
});
|
|
374
|
-
if (!swapped) return null;
|
|
375
|
-
const raw = swapped.args.outputAmount;
|
|
376
|
-
if (raw < 0n || raw > MAX_UINT_256) return null;
|
|
377
|
-
return BlockchainAmount({ raw, decimals: outputDecimals });
|
|
378
|
-
} catch {
|
|
379
|
-
return null;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// src/shared/types/oauth.ts
|
|
384
|
-
var AuthorizationCode = (value) => value;
|
|
385
|
-
var CodeVerifier = (value) => value;
|
|
386
|
-
var CodeChallenge = (value) => value;
|
|
387
|
-
var PKCEState = (value) => value;
|
|
388
|
-
var RedirectUri = (value) => value;
|
|
389
|
-
var ClientId = (value) => value;
|
|
390
|
-
var ClientSecret = (value) => value;
|
|
391
|
-
|
|
392
|
-
// src/shared/pkce.ts
|
|
393
|
-
async function generatePKCEParams(config) {
|
|
394
|
-
const state = generateSecureRandomBase64Url(32);
|
|
395
|
-
const codeVerifier = generateSecureRandomBase64Url(32);
|
|
396
|
-
const codeChallengeRaw = await sha256(codeVerifier);
|
|
397
|
-
const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
|
|
398
|
-
return {
|
|
399
|
-
clientId: config.clientId,
|
|
400
|
-
responseType: "code",
|
|
401
|
-
redirectUri: config.redirectUri,
|
|
402
|
-
codeChallenge: CodeChallenge(codeChallenge),
|
|
403
|
-
codeChallengeMethod: "S256",
|
|
404
|
-
state: PKCEState(state),
|
|
405
|
-
codeVerifier: CodeVerifier(codeVerifier)
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// src/shared/types/blockchain/ui.ts
|
|
410
|
-
var FormattedAmountUi = (value) => value;
|
|
411
|
-
var FormattedPercentUi = (value) => value;
|
|
412
|
-
var TxExplorerUrl = (value) => value;
|
|
413
|
-
var ShortenedWalletAddress = (value) => value;
|
|
414
|
-
var FormattedAmountAssetUi = (value) => value;
|
|
415
|
-
var AssetIconUrl = (value) => value;
|
|
416
|
-
|
|
417
412
|
// src/shared/core/blockchain/formatters.ts
|
|
418
|
-
import { formatUnits } from "viem";
|
|
419
413
|
function shortenAddress(address) {
|
|
420
414
|
const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
|
|
421
415
|
return ShortenedWalletAddress(short);
|
|
@@ -513,6 +507,40 @@ function formattedPricePerShare(quote, locale) {
|
|
|
513
507
|
return formattedUsdPrice(computePrice(quote), locale);
|
|
514
508
|
}
|
|
515
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
|
+
|
|
516
544
|
// src/shared/core/blockchain/swap/constants.ts
|
|
517
545
|
var SUPERSTATE_TOS_URL = "https://superstate.com/terms";
|
|
518
546
|
var SWAP_POLL_INTERVAL_MS = 15e3;
|
|
@@ -543,6 +571,29 @@ var SwapQuote = {
|
|
|
543
571
|
})
|
|
544
572
|
};
|
|
545
573
|
|
|
574
|
+
// src/shared/core/blockchain/swap/status.ts
|
|
575
|
+
function isStopped(status) {
|
|
576
|
+
return (status.stopped & status.swapLevel) !== 0n;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// src/shared/core/blockchain/swap/swapped-event.ts
|
|
580
|
+
import { parseEventLogs } from "viem";
|
|
581
|
+
function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
582
|
+
try {
|
|
583
|
+
const [swapped] = parseEventLogs({
|
|
584
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
585
|
+
eventName: "Swapped",
|
|
586
|
+
logs: receipt.logs
|
|
587
|
+
});
|
|
588
|
+
if (!swapped) return null;
|
|
589
|
+
const raw = swapped.args.outputAmount;
|
|
590
|
+
if (raw < 0n || raw > MAX_UINT_256) return null;
|
|
591
|
+
return BlockchainAmount({ raw, decimals: outputDecimals });
|
|
592
|
+
} catch {
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
546
597
|
// src/shared/core/blockchain/token-registry.ts
|
|
547
598
|
var USDC_SYMBOL = StablecoinSymbol("USDC");
|
|
548
599
|
var USDC = {
|
|
@@ -595,6 +646,42 @@ var TOKEN_REGISTRY = {
|
|
|
595
646
|
}
|
|
596
647
|
};
|
|
597
648
|
|
|
649
|
+
// src/shared/types/oauth.ts
|
|
650
|
+
var AuthorizationCode = (value) => value;
|
|
651
|
+
var CodeVerifier = (value) => value;
|
|
652
|
+
var CodeChallenge = (value) => value;
|
|
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
|
+
}
|
|
674
|
+
|
|
675
|
+
// src/shared/types/user.ts
|
|
676
|
+
var UserId = (value) => value;
|
|
677
|
+
var UserEmail = (value) => value;
|
|
678
|
+
var User = {
|
|
679
|
+
fromDto: (dto) => ({
|
|
680
|
+
id: UserId(dto.id),
|
|
681
|
+
email: UserEmail(dto.email)
|
|
682
|
+
})
|
|
683
|
+
};
|
|
684
|
+
|
|
598
685
|
export {
|
|
599
686
|
ERC20_ABI,
|
|
600
687
|
SUPERSTATE_SWAP_ABI,
|
|
@@ -604,20 +691,15 @@ export {
|
|
|
604
691
|
computeSlip,
|
|
605
692
|
isStopped,
|
|
606
693
|
decodeSwappedOutputAmount,
|
|
607
|
-
AuthorizationCode,
|
|
608
|
-
CodeVerifier,
|
|
609
|
-
CodeChallenge,
|
|
610
|
-
PKCEState,
|
|
611
|
-
RedirectUri,
|
|
612
|
-
ClientId,
|
|
613
|
-
ClientSecret,
|
|
614
|
-
generatePKCEParams,
|
|
615
694
|
FormattedAmountUi,
|
|
616
695
|
FormattedPercentUi,
|
|
617
696
|
TxExplorerUrl,
|
|
618
697
|
ShortenedWalletAddress,
|
|
619
698
|
FormattedAmountAssetUi,
|
|
620
699
|
AssetIconUrl,
|
|
700
|
+
getChainId,
|
|
701
|
+
getNetworkName,
|
|
702
|
+
txExplorerUrl,
|
|
621
703
|
shortenAddress,
|
|
622
704
|
formatAmount,
|
|
623
705
|
formatRawAmount,
|
|
@@ -628,6 +710,7 @@ export {
|
|
|
628
710
|
NA_AMOUNT_ASSET_UI,
|
|
629
711
|
formattedUsdPrice,
|
|
630
712
|
formattedPricePerShare,
|
|
713
|
+
parseBlockchainAmount,
|
|
631
714
|
SUPERSTATE_TOS_URL,
|
|
632
715
|
SWAP_POLL_INTERVAL_MS,
|
|
633
716
|
DEFAULT_AMOUNT_TO_COMPUTE_PRICE,
|
|
@@ -639,6 +722,17 @@ export {
|
|
|
639
722
|
USDC,
|
|
640
723
|
USDT_SYMBOL,
|
|
641
724
|
USDT,
|
|
642
|
-
TOKEN_REGISTRY
|
|
725
|
+
TOKEN_REGISTRY,
|
|
726
|
+
AuthorizationCode,
|
|
727
|
+
CodeVerifier,
|
|
728
|
+
CodeChallenge,
|
|
729
|
+
PKCEState,
|
|
730
|
+
RedirectUri,
|
|
731
|
+
ClientId,
|
|
732
|
+
ClientSecret,
|
|
733
|
+
generatePKCEParams,
|
|
734
|
+
UserId,
|
|
735
|
+
UserEmail,
|
|
736
|
+
User
|
|
643
737
|
};
|
|
644
|
-
//# sourceMappingURL=chunk-
|
|
738
|
+
//# sourceMappingURL=chunk-AQVCOWOV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/core/blockchain/abis/erc20.ts","../src/shared/core/blockchain/abis/superstate-swap.ts","../src/shared/core/blockchain/bps.ts","../src/shared/types/blockchain/ui.ts","../src/shared/core/blockchain/chain.ts","../src/shared/core/blockchain/formatters.ts","../src/shared/core/blockchain/swap/math.ts","../src/shared/core/blockchain/math.ts","../src/shared/core/blockchain/swap/constants.ts","../src/shared/core/blockchain/swap/quote.ts","../src/shared/core/blockchain/swap/status.ts","../src/shared/core/blockchain/swap/swapped-event.ts","../src/shared/core/blockchain/token-registry.ts","../src/shared/types/oauth.ts","../src/shared/pkce.ts","../src/shared/types/user.ts"],"sourcesContent":["/**\n * Minimal ERC-20 ABI the SDK writes against (mirrors viem's `erc20Abi`). The\n * swap flow uses `approve`; `allowance`/`balanceOf`/`decimals`/`symbol`/`name`\n * are included so reads share a single SDK-owned ABI.\n */\nexport const ERC20_ABI = [\n {\n type: 'function',\n name: 'allowance',\n inputs: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n ],\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'approve',\n inputs: [\n { name: 'spender', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'balanceOf',\n inputs: [{ name: 'account', type: 'address' }],\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'decimals',\n inputs: [],\n outputs: [{ name: '', type: 'uint8' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'name',\n inputs: [],\n outputs: [{ name: '', type: 'string' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'symbol',\n inputs: [],\n outputs: [{ name: '', type: 'string' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'totalSupply',\n inputs: [],\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'transfer',\n inputs: [\n { name: 'recipient', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'transferFrom',\n inputs: [\n { name: 'sender', type: 'address' },\n { name: 'recipient', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'event',\n name: 'Approval',\n inputs: [\n { name: 'owner', type: 'address', indexed: true },\n { name: 'spender', type: 'address', indexed: true },\n { name: 'value', type: 'uint256', indexed: false },\n ],\n anonymous: false,\n },\n {\n type: 'event',\n name: 'Transfer',\n inputs: [\n { name: 'from', type: 'address', indexed: true },\n { name: 'to', type: 'address', indexed: true },\n { name: 'value', type: 'uint256', indexed: false },\n ],\n anonymous: false,\n },\n] as const;\n","export const SUPERSTATE_SWAP_ABI = [\n {\n type: 'function',\n name: 'authorized',\n inputs: [{ name: 'user', type: 'address', internalType: 'address' }],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'stopped',\n inputs: [],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'SWAP_LEVEL',\n inputs: [],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'preview',\n inputs: [\n { name: 'token', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [\n {\n name: '',\n type: 'tuple',\n internalType: 'struct Preview',\n components: [\n { name: 'input', type: 'uint256', internalType: 'uint256' },\n { name: 'fee', type: 'uint256', internalType: 'uint256' },\n { name: 'output', type: 'uint256', internalType: 'uint256' },\n ],\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'swap',\n inputs: [\n { name: 'token', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n { name: 'slip', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'tokenBalance',\n inputs: [{ name: 'token', type: 'address', internalType: 'address' }],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'outputToken',\n inputs: [],\n outputs: [{ name: '', type: 'address', internalType: 'address' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'outputTokenBalance',\n inputs: [],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'totals',\n inputs: [{ name: 'token', type: 'address', internalType: 'address' }],\n outputs: [\n {\n name: '',\n type: 'tuple',\n internalType: 'struct SwapTotal',\n components: [\n { name: 'inputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'feeSum', type: 'uint256', internalType: 'uint256' },\n { name: 'outputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'count', type: 'uint256', internalType: 'uint256' },\n ],\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'totals',\n inputs: [\n { name: 'user', type: 'address', internalType: 'address' },\n { name: 'token', type: 'address', internalType: 'address' },\n ],\n outputs: [\n {\n name: '',\n type: 'tuple',\n internalType: 'struct SwapTotal',\n components: [\n { name: 'inputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'feeSum', type: 'uint256', internalType: 'uint256' },\n { name: 'outputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'count', type: 'uint256', internalType: 'uint256' },\n ],\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'transfer',\n inputs: [\n { name: 'to', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'transfer',\n inputs: [\n { name: 'to', type: 'address', internalType: 'address' },\n { name: 'token', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'setBps',\n inputs: [{ name: 'points', type: 'uint256', internalType: 'uint256' }],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'event',\n name: 'Swapped',\n inputs: [\n { name: 'user', type: 'address', indexed: true, internalType: 'address' },\n {\n name: 'inputToken',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'outputToken',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'inputAmount',\n type: 'uint256',\n indexed: false,\n internalType: 'uint256',\n },\n {\n name: 'outputAmount',\n type: 'uint256',\n indexed: false,\n internalType: 'uint256',\n },\n ],\n anonymous: false,\n },\n {\n type: 'event',\n name: 'Transferred',\n inputs: [\n { name: 'to', type: 'address', indexed: true, internalType: 'address' },\n {\n name: 'token',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'amount',\n type: 'uint256',\n indexed: false,\n internalType: 'uint256',\n },\n ],\n anonymous: false,\n },\n {\n type: 'error',\n name: 'InvalidAddress',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InsufficientAmount',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InvalidAmount',\n inputs: [],\n },\n {\n type: 'error',\n name: 'SwapFailed',\n inputs: [\n { name: 'user', type: 'address', internalType: 'address' },\n { name: 'token', type: 'address', internalType: 'address' },\n ],\n },\n] as const;\n","import {\n assertUint256,\n Bps,\n type Uint256,\n} from '@/shared/types/blockchain/core';\n\n/** Basis-point denominator: 10_000 bps = 100%. */\nexport const BPS_DENOM: Bps = Bps(10_000n);\n\n/**\n * Applies a basis-point fraction to an amount, flooring the result.\n * `floor((amount × bps) / BPS_DENOM)`. The result is bounds-checked, so an\n * overflow (bps far above BPS_DENOM) or a negative product is rejected.\n */\nexport function applyBps(amount: Uint256, bps: Bps): Uint256 {\n return assertUint256((amount * bps) / BPS_DENOM);\n}\n","import type { Newtype } from '@/shared/types/newtype';\n\nexport type FormattedAmountUi = Newtype<string, 'FormattedAmountUi'>;\nexport const FormattedAmountUi = (value: string): FormattedAmountUi =>\n value as FormattedAmountUi;\n\nexport type FormattedPercentUi = Newtype<string, 'FormattedPercentUi'>;\nexport const FormattedPercentUi = (value: string): FormattedPercentUi =>\n value as FormattedPercentUi;\n\nexport type TxExplorerUrl = Newtype<string, 'TxExplorerUrl'>;\nexport const TxExplorerUrl = (value: string): TxExplorerUrl =>\n value as TxExplorerUrl;\n\n/**\n * A wallet address shortened for display (e.g. `0x1234…5678`). Keeps a\n * `0x${string}` base but drops the runtime `0x` narrowing.\n */\nexport type ShortenedWalletAddress = Newtype<\n `0x${string}`,\n 'ShortenedWalletAddress'\n>;\nexport const ShortenedWalletAddress = (value: string): ShortenedWalletAddress =>\n value as ShortenedWalletAddress;\n\nexport type FormattedAmountAssetUi = Newtype<string, 'FormattedAmountAssetUi'>;\nexport const FormattedAmountAssetUi = (value: string): FormattedAmountAssetUi =>\n value as FormattedAmountAssetUi;\n\nexport type AssetIconUrl = Newtype<string, 'AssetIconUrl'>;\nexport const AssetIconUrl = (value: string): AssetIconUrl =>\n value as AssetIconUrl;\n","import type { Hash } from 'viem';\nimport type { EthereumChain } from '@/shared/types/blockchain/core';\nimport { TxExplorerUrl } from '@/shared/types/blockchain/ui';\n\nexport function getChainId(chain: EthereumChain): number {\n switch (chain) {\n case 'ethereum_mainnet':\n return 1;\n case 'ethereum_sepolia':\n return 11155111;\n default: {\n const _exhaustive: never = chain;\n return _exhaustive;\n }\n }\n}\n\nexport function getNetworkName(chain: EthereumChain): string {\n switch (chain) {\n case 'ethereum_mainnet':\n return 'Ethereum';\n case 'ethereum_sepolia':\n return 'Ethereum Sepolia';\n default: {\n const _exhaustive: never = chain;\n return _exhaustive;\n }\n }\n}\n\nexport function txExplorerUrl(\n chain: EthereumChain,\n txHash: Hash\n): TxExplorerUrl {\n return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);\n}\n\nfunction explorerBaseUrl(chain: EthereumChain): string {\n switch (chain) {\n case 'ethereum_mainnet':\n return 'https://etherscan.io';\n case 'ethereum_sepolia':\n return 'https://sepolia.etherscan.io';\n default: {\n const _exhaustive: never = chain;\n return _exhaustive;\n }\n }\n}\n","import { formatUnits } from 'viem';\nimport { computePrice } from '@/shared/core/blockchain/swap/math';\nimport type { SwapQuote } from '@/shared/core/blockchain/swap/quote';\nimport type {\n AssetSymbol,\n BlockchainAmount,\n Bps,\n EvmWalletAddress,\n} from '@/shared/types/blockchain/core';\nimport { AssetDecimals } from '@/shared/types/blockchain/core';\nimport {\n FormattedAmountAssetUi,\n FormattedAmountUi,\n FormattedPercentUi,\n ShortenedWalletAddress,\n} from '@/shared/types/blockchain/ui';\n\nexport function shortenAddress(\n address: EvmWalletAddress\n): ShortenedWalletAddress {\n const short =\n address.length > 10\n ? `${address.slice(0, 6)}…${address.slice(-4)}`\n : address;\n return ShortenedWalletAddress(short);\n}\n\nexport type FormatAmountOptions = {\n maxFractionDigits?: AssetDecimals;\n};\n\nexport function formatAmount(\n amount: BlockchainAmount,\n locale: string,\n options?: FormatAmountOptions\n): FormattedAmountUi {\n const decimal = formatRawAmount(amount);\n let [integerPart, fractionPart = ''] = decimal.split('.');\n\n const maxFractionDigits = options?.maxFractionDigits;\n const minFractionDigits =\n maxFractionDigits !== undefined\n ? Math.min(maxFractionDigits, amount.decimals)\n : Math.min(2, amount.decimals);\n\n if (\n maxFractionDigits !== undefined &&\n fractionPart.length > maxFractionDigits\n ) {\n ({ integerPart, fractionPart } = roundFractionHalfUp(\n integerPart,\n fractionPart,\n maxFractionDigits\n ));\n }\n\n const fraction =\n minFractionDigits === 0 ? '' : fractionPart.padEnd(minFractionDigits, '0');\n\n const integerFormatted = BigInt(integerPart).toLocaleString(locale);\n if (minFractionDigits === 0 && fraction === '') {\n return FormattedAmountUi(integerFormatted);\n }\n\n const decimalSeparator =\n new Intl.NumberFormat(locale)\n .formatToParts(1.1)\n .find((p) => p.type === 'decimal')?.value ?? '.';\n\n return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);\n}\n\n/**\n * Rounds a decimal split into `integerPart`/`fractionPart` strings half-up to\n * `maxFractionDigits`, carrying into the integer part when needed (via BigInt,\n * so precision is preserved beyond `Number.MAX_SAFE_INTEGER`).\n *\n * Precondition: `integerPart` must be non-negative (guaranteed here because\n * `BlockchainAmount.raw` is a `Uint256`). A negative integer part would carry\n * in the wrong direction (toward +∞ instead of away from zero).\n */\nfunction roundFractionHalfUp(\n integerPart: string,\n fractionPart: string,\n maxFractionDigits: number\n): { integerPart: string; fractionPart: string } {\n if (fractionPart.length <= maxFractionDigits) {\n return { integerPart, fractionPart };\n }\n\n if (maxFractionDigits === 0) {\n const roundUp = fractionPart[0] >= '5';\n const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);\n return { integerPart: integer.toString(), fractionPart: '' };\n }\n\n const trimmed = fractionPart.slice(0, maxFractionDigits);\n if (fractionPart[maxFractionDigits] < '5') {\n return { integerPart, fractionPart: trimmed };\n }\n\n const digits = trimmed.split('').map((digit) => Number.parseInt(digit, 10));\n let carry = 1;\n for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {\n const sum = digits[i] + carry;\n if (sum === 10) {\n digits[i] = 0;\n carry = 1;\n } else {\n digits[i] = sum;\n carry = 0;\n }\n }\n\n return {\n integerPart:\n carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,\n fractionPart: digits.join(''),\n };\n}\n\nexport function formatRawAmount(amount: BlockchainAmount): string {\n return formatUnits(amount.raw, amount.decimals);\n}\n\n/**\n * Formats a {@link BlockchainAmount} using compact notation (e.g. `1.37B`,\n * `5M`). Compact notation only surfaces a couple of significant decimals, so\n * the bigint → number narrowing here is intentional and safe: full precision\n * is deliberately dropped in favour of a human-readable summary value.\n */\nexport function formatCompactAmount(\n amount: BlockchainAmount,\n locale: string\n): FormattedAmountUi {\n const value = Number(formatRawAmount(amount));\n const formatted = new Intl.NumberFormat(locale, {\n notation: 'compact',\n maximumFractionDigits: 2,\n }).format(value);\n return FormattedAmountUi(formatted);\n}\n\nexport function formatBpsAsPercent(\n bps: Bps,\n locale: string\n): FormattedPercentUi {\n const whole = bps / 100n;\n const fraction = bps % 100n;\n const wholeFormatted = whole.toLocaleString(locale);\n const decimalSeparator =\n new Intl.NumberFormat(locale)\n .formatToParts(1.1)\n .find((p) => p.type === 'decimal')?.value ?? '.';\n\n if (fraction === 0n) {\n return FormattedPercentUi(`${wholeFormatted}%`);\n }\n\n const fractionFormatted = fraction\n .toString()\n .padStart(2, '0')\n .replace(/0+$/, '');\n\n return FormattedPercentUi(\n `${wholeFormatted}${decimalSeparator}${fractionFormatted}%`\n );\n}\n\nexport function usdAmount(amount: FormattedAmountUi): FormattedAmountAssetUi {\n return FormattedAmountAssetUi(`$${amount}`);\n}\n\nexport function assetAmount(\n amount: FormattedAmountUi,\n symbol: AssetSymbol\n): FormattedAmountAssetUi {\n return FormattedAmountAssetUi(`${amount} ${symbol}`);\n}\n\n/** Placeholder shown when an amount is unavailable (e.g. a loading quote). */\nexport const NA_AMOUNT_ASSET_UI: FormattedAmountAssetUi =\n FormattedAmountAssetUi('-');\n\nconst USD_FRACTION_DIGITS = AssetDecimals(2);\n\n/**\n * Formats a USD amount capped at 2 fractional digits, falling back to the\n * {@link NA_AMOUNT_ASSET_UI} placeholder when the amount is absent.\n */\nexport function formattedUsdPrice(\n amount: BlockchainAmount | null,\n locale: string\n): FormattedAmountAssetUi {\n if (!amount) return NA_AMOUNT_ASSET_UI;\n return usdAmount(\n formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })\n );\n}\n\n/** Formats a quote's implied price per output token as a USD amount. */\nexport function formattedPricePerShare(\n quote: SwapQuote | null,\n locale: string\n): FormattedAmountAssetUi {\n if (!quote) return NA_AMOUNT_ASSET_UI;\n return formattedUsdPrice(computePrice(quote), locale);\n}\n","import { applyBps, BPS_DENOM } from '@/shared/core/blockchain/bps';\nimport type { SwapQuote } from '@/shared/core/blockchain/swap/quote';\nimport {\n assertUint256,\n BlockchainAmount,\n Bps,\n} from '@/shared/types/blockchain/core';\n\n/**\n * Price of 1 output token in USD, assuming the input token is a $1 stablecoin.\n *\n * `raw_price = inputTokenAmount.raw × 10^outputDecimals ÷ outputTokenAmount.raw`\n *\n * The multiplication happens before the division so we never lose precision to\n * integer truncation early. This mirrors standard fixed-point practice on-chain.\n * Returned decimals match the input token decimals (always the stablecoin's 6).\n */\nexport function computePrice({\n inputTokenAmount,\n outputTokenAmount,\n}: SwapQuote): BlockchainAmount | null {\n if (outputTokenAmount.raw === 0n) return null;\n\n const scale = 10n ** BigInt(outputTokenAmount.decimals);\n const raw = assertUint256(\n (inputTokenAmount.raw * scale) / outputTokenAmount.raw\n );\n\n return BlockchainAmount({ raw, decimals: inputTokenAmount.decimals });\n}\n\n/**\n * Applies slippage to an amount, returning the minimum acceptable amount:\n * `amount × (BPS_DENOM − slippage) / BPS_DENOM`. Throws when `slippage` exceeds\n * `BPS_DENOM` (the retained fraction would be negative).\n */\nexport function computeSlip(\n amount: BlockchainAmount,\n slippage: Bps\n): BlockchainAmount {\n const retained = Bps(assertUint256(BPS_DENOM - slippage));\n const slipRaw = applyBps(amount.raw, retained);\n return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });\n}\n","import { parseUnits } from 'viem';\nimport {\n type AssetDecimals,\n BlockchainAmount,\n} from '@/shared/types/blockchain/core';\n\n/** A typed, i18n-agnostic reason a raw amount string failed to parse. */\nexport type AmountParseErrorReason =\n | { type: 'empty' }\n | { type: 'negative' }\n | { type: 'invalid-format' }\n | { type: 'too-many-decimals'; maxDecimals: AssetDecimals };\n\nexport type AmountParseResult =\n | { valid: true; amount: BlockchainAmount }\n | { valid: false; reason: AmountParseErrorReason };\n\n/**\n * Parses a user-entered decimal string into a {@link BlockchainAmount} at the\n * given token decimals. Rejects scientific notation, negatives, malformed\n * input, and more fractional digits than the token supports — surfacing a\n * typed {@link AmountParseErrorReason} so callers own the display copy.\n */\nexport function parseBlockchainAmount(\n amount: string,\n decimals: AssetDecimals\n): AmountParseResult {\n const trimmed = amount.trim();\n if (trimmed === '') return { valid: false, reason: { type: 'empty' } };\n if (trimmed.startsWith('-')) {\n return { valid: false, reason: { type: 'negative' } };\n }\n // viem accepts \"1e18\" as scientific notation — reject it explicitly\n if (/[eE]/.test(trimmed)) {\n return { valid: false, reason: { type: 'invalid-format' } };\n }\n // reject bare decimal point or missing digits on either side\n if (!/^\\d+(\\.\\d+)?$/.test(trimmed)) {\n return { valid: false, reason: { type: 'invalid-format' } };\n }\n const [, fraction = ''] = trimmed.split('.');\n if (fraction.length > decimals) {\n return {\n valid: false,\n reason: { type: 'too-many-decimals', maxDecimals: decimals },\n };\n }\n try {\n return {\n valid: true,\n amount: BlockchainAmount({\n raw: parseUnits(trimmed, decimals),\n decimals,\n }),\n };\n } catch {\n return { valid: false, reason: { type: 'invalid-format' } };\n }\n}\n","import { Bps, EvmContractAddress } from '@/shared/types/blockchain/core';\n\nexport const SUPERSTATE_TOS_URL = 'https://superstate.com/terms';\n\n/** Poll interval for refreshing on-chain swap quotes and balances. */\nexport const SWAP_POLL_INTERVAL_MS = 15_000;\n\n/**\n * Notional input used to derive a display price-per-share when the user has\n * not yet entered an amount (1 USDC at 6 decimals).\n */\nexport const DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1_000_000n;\n\n/** Slippage tolerances offered in the review step, in basis points. */\nexport const SLIPPAGE_OPTIONS_BPS: Bps[] = [25n, 50n, 100n, 200n, 500n].map(\n (n) => Bps(n)\n);\n\n/** Default slippage tolerance (0.5%). */\nexport const DEFAULT_SLIPPAGE_BPS: Bps = Bps(50n);\n\n/**\n * The Superstate swap contract on Ethereum Sepolia. The mainnet address is not\n * yet finalized upstream, so it is intentionally not exported — callers pass\n * the contract address explicitly.\n */\nexport const SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: EvmContractAddress =\n EvmContractAddress('0x84f8e9a6C9Cc12fe911259372EfCa5582C4ae557');\n","import {\n type AssetDecimals,\n BlockchainAmount,\n} from '@/shared/types/blockchain/core';\nimport type { SwapPreview } from '@/shared/types/swap';\n\n/**\n * A read-only quote for a swap as domain amounts: how much goes in, the\n * protocol fee, and how much would come out. Derived from the raw\n * {@link SwapPreview} the swap contract returns.\n */\nexport type SwapQuote = {\n inputTokenAmount: BlockchainAmount;\n fee: BlockchainAmount;\n outputTokenAmount: BlockchainAmount;\n};\n\nexport const SwapQuote = {\n /**\n * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The\n * input and fee are denominated in the input token; the output in the output\n * token.\n */\n fromPreview: (\n preview: SwapPreview,\n inputDecimals: AssetDecimals,\n outputDecimals: AssetDecimals\n ): SwapQuote => ({\n inputTokenAmount: BlockchainAmount({\n raw: preview.inputAmount,\n decimals: inputDecimals,\n }),\n fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),\n outputTokenAmount: BlockchainAmount({\n raw: preview.outputAmount,\n decimals: outputDecimals,\n }),\n }),\n};\n","import type { SwapStatus } from '@/shared/types/swap';\n\n/**\n * Interprets the on-chain swap availability read from `stopped()` and\n * `SWAP_LEVEL()`.\n *\n * The contract tracks paused operations as a bitmask in `stopped`. The swap is\n * stopped when the SWAP_LEVEL flag is set:\n *\n * (stopped & SWAP_LEVEL) != 0 -> stopped (not active)\n */\nexport function isStopped(status: SwapStatus): boolean {\n return (status.stopped & status.swapLevel) !== 0n;\n}\n","import { parseEventLogs, type TransactionReceipt } from 'viem';\nimport { SUPERSTATE_SWAP_ABI } from '@/shared/core/blockchain/abis/superstate-swap';\nimport {\n type AssetDecimals,\n BlockchainAmount,\n MAX_UINT_256,\n} from '@/shared/types/blockchain/core';\n\n/**\n * Decodes the confirmed output amount from the `Swapped` event in a swap\n * transaction receipt.\n *\n * Returns `null` when the event is absent or the amount is not a valid uint256\n * so callers can fall back to the quote's expected output — the swap already\n * confirmed on-chain, so a missing/undecodable event should not fail the flow.\n */\nexport function decodeSwappedOutputAmount(\n receipt: TransactionReceipt,\n outputDecimals: AssetDecimals\n): BlockchainAmount | null {\n try {\n const [swapped] = parseEventLogs({\n abi: SUPERSTATE_SWAP_ABI,\n eventName: 'Swapped',\n logs: receipt.logs,\n });\n if (!swapped) return null;\n\n const raw = swapped.args.outputAmount;\n if (raw < 0n || raw > MAX_UINT_256) return null;\n return BlockchainAmount({ raw, decimals: outputDecimals });\n } catch {\n // Undecodable log (ABI mismatch / malformed) — fall back to the\n // quote. The swap already confirmed on-chain, so never fail here.\n return null;\n }\n}\n","import {\n AssetDecimals,\n type Erc20Asset,\n type EthereumChain,\n EvmContractAddress,\n type KnownAssetSymbol,\n StablecoinSymbol,\n} from '@/shared/types/blockchain/core';\n\nexport const USDC_SYMBOL: StablecoinSymbol = StablecoinSymbol('USDC');\nexport const USDC: Erc20Asset = {\n name: 'USD Coin',\n symbol: USDC_SYMBOL,\n decimals: AssetDecimals(6),\n};\n\nexport const USDT_SYMBOL: StablecoinSymbol = StablecoinSymbol('USDT');\nexport const USDT: Erc20Asset = {\n name: 'Tether USD',\n symbol: USDT_SYMBOL,\n decimals: AssetDecimals(6),\n};\n\n/** ERC-20 contract addresses for a supported stablecoin, keyed by chain. */\ntype TokenAddresses = Record<EthereumChain, EvmContractAddress>;\n\nconst USDC_ADDRESSES: TokenAddresses = {\n ethereum_mainnet: EvmContractAddress(\n '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'\n ),\n ethereum_sepolia: EvmContractAddress(\n '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238'\n ),\n};\n\nconst USDT_ADDRESSES: TokenAddresses = {\n ethereum_mainnet: EvmContractAddress(\n '0xdac17f958d2ee523a2206206994597c13d831ec7'\n ),\n ethereum_sepolia: EvmContractAddress(\n '0x7169D38820dfd117C3FA1f22a697dBA58d90BA06'\n ),\n};\n\n/** Lookups for the stablecoins the SDK's swap flows support out of the box. */\nexport const TOKEN_REGISTRY = {\n erc20: (symbol: KnownAssetSymbol): Erc20Asset => {\n switch (symbol) {\n case 'USDC':\n return USDC;\n case 'USDT':\n return USDT;\n default:\n throw new Error(`Unknown asset symbol: ${symbol}`);\n }\n },\n contractAddress: (\n symbol: KnownAssetSymbol,\n chain: EthereumChain\n ): EvmContractAddress => {\n switch (symbol) {\n case 'USDC':\n return USDC_ADDRESSES[chain];\n case 'USDT':\n return USDT_ADDRESSES[chain];\n default:\n throw new Error(`Unknown asset symbol: ${symbol}`);\n }\n },\n};\n","import type { Newtype } from '@/shared/types/newtype';\n\nexport type AuthorizationCode = Newtype<string, 'AuthorizationCode'>;\nexport const AuthorizationCode = (value: string): AuthorizationCode =>\n value as AuthorizationCode;\n\nexport type CodeVerifier = Newtype<string, 'CodeVerifier'>;\nexport const CodeVerifier = (value: string): CodeVerifier =>\n value as CodeVerifier;\n\nexport type CodeChallenge = Newtype<string, 'CodeChallenge'>;\nexport const CodeChallenge = (value: string): CodeChallenge =>\n value as CodeChallenge;\n\nexport type PKCEState = Newtype<string, 'PKCEState'>;\nexport const PKCEState = (value: string) => value as PKCEState;\n\nexport type RedirectUri = Newtype<string, 'RedirectUri'>;\nexport const RedirectUri = (value: string): RedirectUri => value as RedirectUri;\n\nexport type ClientId = Newtype<string, 'ClientId'>;\nexport const ClientId = (value: string): ClientId => value as ClientId;\n\nexport type ClientSecret = Newtype<string, 'ClientSecret'>;\nexport const ClientSecret = (value: string): ClientSecret =>\n value as ClientSecret;\n","import type {\n CodeChallenge as CodeChallengeType,\n CodeVerifier as CodeVerifierType,\n PKCEState as PKCEStateType,\n} from '@/shared/types/oauth';\nimport {\n type ClientId,\n CodeChallenge,\n CodeVerifier,\n PKCEState,\n type RedirectUri,\n} from '@/shared/types/oauth';\nimport {\n arrayBufferToBase64Url,\n generateSecureRandomBase64Url,\n sha256,\n} from '@/shared/utils';\n\nexport type PKCEParams = {\n clientId: ClientId;\n responseType: 'code';\n redirectUri: RedirectUri;\n codeChallenge: CodeChallengeType;\n codeChallengeMethod: 'S256';\n state: PKCEStateType;\n codeVerifier: CodeVerifierType;\n};\n\nexport type PKCEConfig = {\n clientId: ClientId;\n redirectUri: RedirectUri;\n};\n\n/**\n * Generates PKCE parameters for an OAuth2 authorization code flow.\n * Pure crypto — no React, no DOM beyond Web Crypto API. Safe to use\n * in server-side code and Next.js middleware.\n */\nexport async function generatePKCEParams(\n config: PKCEConfig\n): Promise<PKCEParams> {\n const state = generateSecureRandomBase64Url(32);\n const codeVerifier = generateSecureRandomBase64Url(32);\n const codeChallengeRaw = await sha256(codeVerifier);\n const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);\n\n return {\n clientId: config.clientId,\n responseType: 'code',\n redirectUri: config.redirectUri,\n codeChallenge: CodeChallenge(codeChallenge),\n codeChallengeMethod: 'S256',\n state: PKCEState(state),\n codeVerifier: CodeVerifier(codeVerifier),\n };\n}\n","import type { UserDto } from '@/shared/types/dto/user';\nimport type { Newtype } from '@/shared/types/newtype';\n\nexport type UserId = Newtype<string, 'UserId'>;\nexport const UserId = (value: string) => value as UserId;\nexport type UserEmail = Newtype<string, 'UserEmail'>;\nexport const UserEmail = (value: string) => value as UserEmail;\n\nexport type User = {\n id: UserId;\n email: UserEmail;\n};\n\nexport const User = {\n fromDto: (dto: UserDto): User => ({\n id: UserId(dto.id),\n email: UserEmail(dto.email),\n }),\n};\n"],"mappings":";;;;;;;;;;;;;;AAKO,IAAM,YAAY;AAAA,EACvB;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,MACN,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,MACjC,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,IACrC;AAAA,IACA,SAAS,CAAC,EAAE,MAAM,IAAI,MAAM,UAAU,CAAC;AAAA,IACvC,iBAAiB;AAAA,EACnB;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,MACN,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,MACnC,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,IACpC;AAAA,IACA,SAAS,CAAC,EAAE,MAAM,IAAI,MAAM,OAAO,CAAC;AAAA,IACpC,iBAAiB;AAAA,EACnB;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ,CAAC,EAAE,MAAM,WAAW,MAAM,UAAU,CAAC;AAAA,IAC7C,SAAS,CAAC,EAAE,MAAM,IAAI,MAAM,UAAU,CAAC;AAAA,IACvC,iBAAiB;AAAA,EACnB;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ,CAAC;AAAA,IACT,SAAS,CAAC,EAAE,MAAM,IAAI,MAAM,QAAQ,CAAC;AAAA,IACrC,iBAAiB;AAAA,EACnB;AAAA,EAC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qBAAqB;AAAA,IACrB,OAAO,UAAU,KAAK;AAAA,IACtB,cAAc,aAAa,YAAY;AAAA,EACzC;AACF;;;ACnDO,IAAM,SAAS,CAAC,UAAkB;AAElC,IAAM,YAAY,CAAC,UAAkB;AAOrC,IAAM,OAAO;AAAA,EAClB,SAAS,CAAC,SAAwB;AAAA,IAChC,IAAI,OAAO,IAAI,EAAE;AAAA,IACjB,OAAO,UAAU,IAAI,KAAK;AAAA,EAC5B;AACF;","names":[]}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
RequirementStatusInfo,
|
|
12
12
|
fetchAllPages,
|
|
13
13
|
getUUIDv4
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-UOHD7US2.js";
|
|
15
15
|
|
|
16
16
|
// src/shared/api/frontline/config.ts
|
|
17
17
|
var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
|
|
@@ -439,4 +439,4 @@ export {
|
|
|
439
439
|
fetchOfferRequirements,
|
|
440
440
|
fetchRequirementStatuses
|
|
441
441
|
};
|
|
442
|
-
//# sourceMappingURL=chunk-
|
|
442
|
+
//# sourceMappingURL=chunk-TBU3EBNM.js.map
|
|
@@ -565,6 +565,21 @@ var PaginationParams = {
|
|
|
565
565
|
}
|
|
566
566
|
};
|
|
567
567
|
|
|
568
|
+
// src/shared/core/erc20-namespace.ts
|
|
569
|
+
var Erc20NamespaceImpl = class {
|
|
570
|
+
constructor(ctx) {
|
|
571
|
+
this.ctx = ctx;
|
|
572
|
+
}
|
|
573
|
+
async getTokenAllowance(params) {
|
|
574
|
+
await this.ctx.ensureUserAuthenticated();
|
|
575
|
+
return getTokenAllowance(this.ctx.api, params);
|
|
576
|
+
}
|
|
577
|
+
async getTokenBalance(params) {
|
|
578
|
+
await this.ctx.ensureUserAuthenticated();
|
|
579
|
+
return getTokenBalance(this.ctx.api, params);
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
|
|
568
583
|
// src/shared/types/participation.ts
|
|
569
584
|
var ParticipationId = (value) => value;
|
|
570
585
|
var Blockchain = (value) => value;
|
|
@@ -677,6 +692,20 @@ var DocumentSubmission = {
|
|
|
677
692
|
})
|
|
678
693
|
};
|
|
679
694
|
|
|
695
|
+
// src/shared/types/errors.ts
|
|
696
|
+
var NotImplementedError = class extends Error {
|
|
697
|
+
constructor(message = "Not implemented yet") {
|
|
698
|
+
super(message);
|
|
699
|
+
this.name = "NotImplementedError";
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
var NotAuthenticatedError = class extends Error {
|
|
703
|
+
constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
|
|
704
|
+
super(message);
|
|
705
|
+
this.name = "NotAuthenticatedError";
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
|
|
680
709
|
// src/shared/types/kyc.ts
|
|
681
710
|
var KycToken = {
|
|
682
711
|
fromDto: (dto) => ({
|
|
@@ -684,6 +713,22 @@ var KycToken = {
|
|
|
684
713
|
})
|
|
685
714
|
};
|
|
686
715
|
|
|
716
|
+
// src/shared/types/oauth-session.ts
|
|
717
|
+
var ClientCredentialsOAuth = (value) => value;
|
|
718
|
+
var OAuthRefreshToken = (value) => value;
|
|
719
|
+
var OAuthSession = {
|
|
720
|
+
fromDto: (dto) => {
|
|
721
|
+
const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
|
|
722
|
+
return {
|
|
723
|
+
accessToken: {
|
|
724
|
+
value: dto.access_token,
|
|
725
|
+
expiresAt
|
|
726
|
+
},
|
|
727
|
+
...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
|
|
687
732
|
// src/shared/types/pii.ts
|
|
688
733
|
var Iso2CountryCode = (value) => value;
|
|
689
734
|
var PiiJurisdiction = {
|
|
@@ -733,35 +778,6 @@ var RequirementStatusInfo = {
|
|
|
733
778
|
)
|
|
734
779
|
};
|
|
735
780
|
|
|
736
|
-
// src/shared/core/erc20-namespace.ts
|
|
737
|
-
var Erc20NamespaceImpl = class {
|
|
738
|
-
constructor(ctx) {
|
|
739
|
-
this.ctx = ctx;
|
|
740
|
-
}
|
|
741
|
-
async getTokenAllowance(params) {
|
|
742
|
-
await this.ctx.ensureUserAuthenticated();
|
|
743
|
-
return getTokenAllowance(this.ctx.api, params);
|
|
744
|
-
}
|
|
745
|
-
async getTokenBalance(params) {
|
|
746
|
-
await this.ctx.ensureUserAuthenticated();
|
|
747
|
-
return getTokenBalance(this.ctx.api, params);
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
|
|
751
|
-
// src/shared/types/errors.ts
|
|
752
|
-
var NotImplementedError = class extends Error {
|
|
753
|
-
constructor(message = "Not implemented yet") {
|
|
754
|
-
super(message);
|
|
755
|
-
this.name = "NotImplementedError";
|
|
756
|
-
}
|
|
757
|
-
};
|
|
758
|
-
var NotAuthenticatedError = class extends Error {
|
|
759
|
-
constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
|
|
760
|
-
super(message);
|
|
761
|
-
this.name = "NotAuthenticatedError";
|
|
762
|
-
}
|
|
763
|
-
};
|
|
764
|
-
|
|
765
781
|
export {
|
|
766
782
|
sha256,
|
|
767
783
|
arrayBufferToBase64Url,
|
|
@@ -813,6 +829,7 @@ export {
|
|
|
813
829
|
fetchAllPages,
|
|
814
830
|
PaginatedResponse,
|
|
815
831
|
PaginationParams,
|
|
832
|
+
Erc20NamespaceImpl,
|
|
816
833
|
ParticipationId,
|
|
817
834
|
Blockchain,
|
|
818
835
|
WalletAddress,
|
|
@@ -821,16 +838,18 @@ export {
|
|
|
821
838
|
CreateParticipationParams,
|
|
822
839
|
TokenSaleNamespaceImpl,
|
|
823
840
|
DocumentSubmission,
|
|
841
|
+
NotImplementedError,
|
|
842
|
+
NotAuthenticatedError,
|
|
824
843
|
KycToken,
|
|
844
|
+
ClientCredentialsOAuth,
|
|
845
|
+
OAuthRefreshToken,
|
|
846
|
+
OAuthSession,
|
|
825
847
|
Iso2CountryCode,
|
|
826
848
|
PiiJurisdiction,
|
|
827
849
|
PiiAddress,
|
|
828
850
|
Pii,
|
|
829
851
|
RequirementId,
|
|
830
852
|
Requirement,
|
|
831
|
-
RequirementStatusInfo
|
|
832
|
-
Erc20NamespaceImpl,
|
|
833
|
-
NotImplementedError,
|
|
834
|
-
NotAuthenticatedError
|
|
853
|
+
RequirementStatusInfo
|
|
835
854
|
};
|
|
836
|
-
//# sourceMappingURL=chunk-
|
|
855
|
+
//# sourceMappingURL=chunk-UOHD7US2.js.map
|