@coinlist-co/react 0.9.0 → 0.10.0
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-MKCOK3DF.js → chunk-7BJ2HAG7.js} +2 -43
- package/dist/chunk-7BJ2HAG7.js.map +1 -0
- package/dist/{chunk-I5YTJ5SL.js → chunk-GSSAB4K5.js} +2 -2
- package/dist/{chunk-Z2HAA2TI.js → chunk-TUZKKFNW.js} +114 -46
- package/dist/chunk-TUZKKFNW.js.map +1 -0
- package/dist/client/index.cjs +281 -155
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +131 -49
- package/dist/client/index.d.ts +131 -49
- package/dist/client/index.js +168 -76
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-B84Vw55t.d.cts → collections-CJ24dOda.d.cts} +1 -1
- package/dist/{collections-BQbFJS3g.d.ts → collections-ZYLKp8JB.d.ts} +1 -1
- package/dist/{requirement-C2w45Q11.d.ts → requirement-CDi5NJI8.d.cts} +267 -200
- package/dist/{requirement-C2w45Q11.d.cts → requirement-CDi5NJI8.d.ts} +267 -200
- package/dist/server/index.cjs +135 -116
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +20 -27
- package/dist/server/index.d.ts +20 -27
- package/dist/server/index.js +9 -24
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +145 -75
- 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 +6 -2
- package/dist/shared/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-MKCOK3DF.js.map +0 -1
- package/dist/chunk-Z2HAA2TI.js.map +0 -1
- /package/dist/{chunk-I5YTJ5SL.js.map → chunk-GSSAB4K5.js.map} +0 -0
package/dist/client/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ var client_exports = {};
|
|
|
32
32
|
__export(client_exports, {
|
|
33
33
|
ChecklistStatus: () => ChecklistStatus,
|
|
34
34
|
ClientSwapNamespaceImpl: () => ClientSwapNamespaceImpl,
|
|
35
|
+
ClientTokenSaleNamespaceImpl: () => ClientTokenSaleNamespaceImpl,
|
|
35
36
|
CoinListClientInitializationError: () => CoinListClientInitializationError,
|
|
36
37
|
CoinListContext: () => CoinListContext,
|
|
37
38
|
CoinListContextProvider: () => CoinListContextProvider,
|
|
@@ -58,6 +59,7 @@ __export(client_exports, {
|
|
|
58
59
|
connectExternalWalletFlow: () => connectExternalWalletFlow,
|
|
59
60
|
createCoinListClient: () => createCoinListClient,
|
|
60
61
|
executeSwap: () => executeSwap,
|
|
62
|
+
executeTokenSale: () => executeTokenSale,
|
|
61
63
|
useCoinList: () => useCoinList,
|
|
62
64
|
useCompleteOAuth: () => useCompleteOAuth,
|
|
63
65
|
useConnectWallet: () => useConnectWallet,
|
|
@@ -655,6 +657,50 @@ var ERC20_ABI = [
|
|
|
655
657
|
}
|
|
656
658
|
];
|
|
657
659
|
|
|
660
|
+
// src/client/core/blockchain/erc20-approval.ts
|
|
661
|
+
async function submitErc20Approval(args) {
|
|
662
|
+
const {
|
|
663
|
+
wallet,
|
|
664
|
+
tokenAddress,
|
|
665
|
+
spender,
|
|
666
|
+
chain,
|
|
667
|
+
value,
|
|
668
|
+
pending,
|
|
669
|
+
confirming,
|
|
670
|
+
emit
|
|
671
|
+
} = args;
|
|
672
|
+
emit(pending);
|
|
673
|
+
let hash;
|
|
674
|
+
try {
|
|
675
|
+
hash = await wallet.writeContract({
|
|
676
|
+
abi: ERC20_ABI,
|
|
677
|
+
address: tokenAddress,
|
|
678
|
+
functionName: "approve",
|
|
679
|
+
args: [spender, value],
|
|
680
|
+
chain
|
|
681
|
+
});
|
|
682
|
+
} catch (error) {
|
|
683
|
+
return {
|
|
684
|
+
type: "error",
|
|
685
|
+
error: { step: "approval", cause: classifyWalletError(error) }
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
emit(confirming);
|
|
689
|
+
let receipt;
|
|
690
|
+
try {
|
|
691
|
+
receipt = await wallet.awaitTx(hash, chain);
|
|
692
|
+
} catch (error) {
|
|
693
|
+
return {
|
|
694
|
+
type: "error",
|
|
695
|
+
error: { step: "approval", cause: classifyWalletError(error, { hash }) }
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
if (receipt.status !== "success") {
|
|
699
|
+
return { type: "error", error: { step: "approval-reverted" } };
|
|
700
|
+
}
|
|
701
|
+
return { type: "ok", txHash: hash };
|
|
702
|
+
}
|
|
703
|
+
|
|
658
704
|
// src/shared/core/blockchain/abis/superstate-swap.ts
|
|
659
705
|
var SUPERSTATE_SWAP_ABI = [
|
|
660
706
|
{
|
|
@@ -963,6 +1009,7 @@ function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
|
963
1009
|
async function executeSwap(params) {
|
|
964
1010
|
const {
|
|
965
1011
|
swap,
|
|
1012
|
+
erc20,
|
|
966
1013
|
wallet,
|
|
967
1014
|
contractAddress,
|
|
968
1015
|
chain,
|
|
@@ -990,7 +1037,7 @@ async function executeSwap(params) {
|
|
|
990
1037
|
emit("checking-allowance");
|
|
991
1038
|
let allowance;
|
|
992
1039
|
try {
|
|
993
|
-
allowance = await
|
|
1040
|
+
allowance = await erc20.getTokenAllowance({
|
|
994
1041
|
tokenAddress: inputTokenAddress,
|
|
995
1042
|
owner: wallet.address,
|
|
996
1043
|
spender: contractAddress,
|
|
@@ -1001,7 +1048,7 @@ async function executeSwap(params) {
|
|
|
1001
1048
|
}
|
|
1002
1049
|
if (allowance.allowance < inputAmount) {
|
|
1003
1050
|
if (allowance.allowance > 0n) {
|
|
1004
|
-
const reset = await
|
|
1051
|
+
const reset = await submitErc20Approval({
|
|
1005
1052
|
wallet,
|
|
1006
1053
|
tokenAddress: inputTokenAddress,
|
|
1007
1054
|
spender: contractAddress,
|
|
@@ -1013,7 +1060,7 @@ async function executeSwap(params) {
|
|
|
1013
1060
|
});
|
|
1014
1061
|
if (reset.type === "error") return { type: "error", error: reset.error };
|
|
1015
1062
|
}
|
|
1016
|
-
const approve = await
|
|
1063
|
+
const approve = await submitErc20Approval({
|
|
1017
1064
|
wallet,
|
|
1018
1065
|
tokenAddress: inputTokenAddress,
|
|
1019
1066
|
spender: contractAddress,
|
|
@@ -1070,48 +1117,6 @@ async function executeSwap(params) {
|
|
|
1070
1117
|
recipientAddress: wallet.address
|
|
1071
1118
|
};
|
|
1072
1119
|
}
|
|
1073
|
-
async function submitApproval(args) {
|
|
1074
|
-
const {
|
|
1075
|
-
wallet,
|
|
1076
|
-
tokenAddress,
|
|
1077
|
-
spender,
|
|
1078
|
-
chain,
|
|
1079
|
-
value,
|
|
1080
|
-
pending,
|
|
1081
|
-
confirming,
|
|
1082
|
-
emit
|
|
1083
|
-
} = args;
|
|
1084
|
-
emit(pending);
|
|
1085
|
-
let hash;
|
|
1086
|
-
try {
|
|
1087
|
-
hash = await wallet.writeContract({
|
|
1088
|
-
abi: ERC20_ABI,
|
|
1089
|
-
address: tokenAddress,
|
|
1090
|
-
functionName: "approve",
|
|
1091
|
-
args: [spender, value],
|
|
1092
|
-
chain
|
|
1093
|
-
});
|
|
1094
|
-
} catch (error) {
|
|
1095
|
-
return {
|
|
1096
|
-
type: "error",
|
|
1097
|
-
error: { step: "approval", cause: classifyWalletError(error) }
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
emit(confirming);
|
|
1101
|
-
let receipt;
|
|
1102
|
-
try {
|
|
1103
|
-
receipt = await wallet.awaitTx(hash, chain);
|
|
1104
|
-
} catch (error) {
|
|
1105
|
-
return {
|
|
1106
|
-
type: "error",
|
|
1107
|
-
error: { step: "approval", cause: classifyWalletError(error, { hash }) }
|
|
1108
|
-
};
|
|
1109
|
-
}
|
|
1110
|
-
if (receipt.status !== "success") {
|
|
1111
|
-
return { type: "error", error: { step: "approval-reverted" } };
|
|
1112
|
-
}
|
|
1113
|
-
return { type: "ok" };
|
|
1114
|
-
}
|
|
1115
1120
|
async function authorizeWallet(params) {
|
|
1116
1121
|
const { swap, wallet, offerId, contractAddress, chain, onProgress } = params;
|
|
1117
1122
|
const emit = (phase) => onProgress?.(phase);
|
|
@@ -1376,11 +1381,12 @@ var Offer = {
|
|
|
1376
1381
|
fromDto: (dto) => ({
|
|
1377
1382
|
id: OfferId(dto.id),
|
|
1378
1383
|
slug: OfferSlug(dto.slug),
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1384
|
+
type: dto.type,
|
|
1385
|
+
tagline: dto.tagline,
|
|
1386
|
+
bannerUrl: dto.banner_url,
|
|
1387
|
+
logoUrl: dto.logo_url,
|
|
1382
1388
|
startsAt: new Date(dto.starts_at),
|
|
1383
|
-
endsAt: new Date(dto.ends_at)
|
|
1389
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null
|
|
1384
1390
|
})
|
|
1385
1391
|
};
|
|
1386
1392
|
|
|
@@ -1410,16 +1416,17 @@ var OfferDetail = {
|
|
|
1410
1416
|
return {
|
|
1411
1417
|
id: OfferId(dto.id),
|
|
1412
1418
|
slug: OfferSlug(dto.slug),
|
|
1419
|
+
type: dto.type,
|
|
1413
1420
|
name: dto.name,
|
|
1414
1421
|
asset: Asset.fromDto(dto.asset),
|
|
1415
1422
|
fundingAssets: dto.funding_assets.map(Asset.fromDto),
|
|
1416
1423
|
about: notBlankStringOrNull(dto.about),
|
|
1417
|
-
tagline:
|
|
1418
|
-
bannerUrl:
|
|
1419
|
-
logoUrl:
|
|
1420
|
-
category:
|
|
1424
|
+
tagline: dto.tagline,
|
|
1425
|
+
bannerUrl: dto.banner_url,
|
|
1426
|
+
logoUrl: dto.logo_url,
|
|
1427
|
+
category: dto.category,
|
|
1421
1428
|
startsAt: new Date(dto.starts_at),
|
|
1422
|
-
endsAt: new Date(dto.ends_at),
|
|
1429
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
1423
1430
|
faqs: dto.faqs.map(FaqItem.fromDto),
|
|
1424
1431
|
links: dto.links.map(Link.fromDto),
|
|
1425
1432
|
milestones: dto.milestones.map(Milestone.fromDto),
|
|
@@ -1581,14 +1588,6 @@ var SwapNamespaceImpl = class {
|
|
|
1581
1588
|
await this.ctx.ensureUserAuthenticated();
|
|
1582
1589
|
return getSwapStatus(this.ctx.api, params);
|
|
1583
1590
|
}
|
|
1584
|
-
async getTokenAllowance(params) {
|
|
1585
|
-
await this.ctx.ensureUserAuthenticated();
|
|
1586
|
-
return getTokenAllowance(this.ctx.api, params);
|
|
1587
|
-
}
|
|
1588
|
-
async getTokenBalance(params) {
|
|
1589
|
-
await this.ctx.ensureUserAuthenticated();
|
|
1590
|
-
return getTokenBalance(this.ctx.api, params);
|
|
1591
|
-
}
|
|
1592
1591
|
async getOutputToken(params) {
|
|
1593
1592
|
await this.ctx.ensureUserAuthenticated();
|
|
1594
1593
|
return getSwapOutputToken(this.ctx.api, params);
|
|
@@ -1605,54 +1604,18 @@ var SwapNamespaceImpl = class {
|
|
|
1605
1604
|
|
|
1606
1605
|
// src/client/core/client-swap-namespace.ts
|
|
1607
1606
|
var ClientSwapNamespaceImpl = class extends SwapNamespaceImpl {
|
|
1607
|
+
constructor(ctx, erc20) {
|
|
1608
|
+
super(ctx);
|
|
1609
|
+
this.erc20 = erc20;
|
|
1610
|
+
}
|
|
1608
1611
|
executeSwap(params) {
|
|
1609
|
-
return executeSwap({ ...params, swap: this });
|
|
1612
|
+
return executeSwap({ ...params, swap: this, erc20: this.erc20 });
|
|
1610
1613
|
}
|
|
1611
1614
|
authorizeWallet(params) {
|
|
1612
1615
|
return authorizeWallet({ ...params, swap: this });
|
|
1613
1616
|
}
|
|
1614
1617
|
};
|
|
1615
1618
|
|
|
1616
|
-
// src/shared/types/document-submission.ts
|
|
1617
|
-
var DocumentSubmission = {
|
|
1618
|
-
fromDto: (dto) => ({
|
|
1619
|
-
status: dto.status,
|
|
1620
|
-
formType: dto.form_type
|
|
1621
|
-
})
|
|
1622
|
-
};
|
|
1623
|
-
|
|
1624
|
-
// src/shared/api/frontline/documents.ts
|
|
1625
|
-
async function submitDocument(api, documentType, fields) {
|
|
1626
|
-
const dto = await api.send({
|
|
1627
|
-
method: "POST",
|
|
1628
|
-
url: `/v1/documents/${documentType}/submission`,
|
|
1629
|
-
body: fields,
|
|
1630
|
-
attributes: Attributes.protected()
|
|
1631
|
-
});
|
|
1632
|
-
return DocumentSubmission.fromDto(dto);
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
// src/shared/types/kyc.ts
|
|
1636
|
-
var KycToken = {
|
|
1637
|
-
fromDto: (dto) => ({
|
|
1638
|
-
token: dto.token
|
|
1639
|
-
})
|
|
1640
|
-
};
|
|
1641
|
-
|
|
1642
|
-
// src/shared/api/frontline/kyc.ts
|
|
1643
|
-
async function createKycToken(api, levelName, reset) {
|
|
1644
|
-
const dto = await api.send({
|
|
1645
|
-
method: "POST",
|
|
1646
|
-
url: "/v1/kyc-token",
|
|
1647
|
-
body: {
|
|
1648
|
-
...levelName === void 0 ? {} : { level_name: levelName },
|
|
1649
|
-
...reset === void 0 ? {} : { reset }
|
|
1650
|
-
},
|
|
1651
|
-
attributes: Attributes.protected()
|
|
1652
|
-
});
|
|
1653
|
-
return KycToken.fromDto(dto);
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
1619
|
// src/shared/api/pagination.ts
|
|
1657
1620
|
var Cursor = (value) => value;
|
|
1658
1621
|
async function fetchAllPages(fetchPage, baseParams) {
|
|
@@ -1692,35 +1655,6 @@ var PaginationParams = {
|
|
|
1692
1655
|
}
|
|
1693
1656
|
};
|
|
1694
1657
|
|
|
1695
|
-
// src/shared/api/frontline/offers.ts
|
|
1696
|
-
async function fetchOffers(api, clientCreds) {
|
|
1697
|
-
return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
|
|
1698
|
-
}
|
|
1699
|
-
async function fetchOffersPage(api, params, clientCreds) {
|
|
1700
|
-
const queryParams = PaginationParams.toQueryParams(params);
|
|
1701
|
-
const pageDto = await api.send({
|
|
1702
|
-
method: "GET",
|
|
1703
|
-
url: "/v1/offers",
|
|
1704
|
-
queryParams,
|
|
1705
|
-
attributes: Attributes.concat(
|
|
1706
|
-
Attributes.protected(),
|
|
1707
|
-
Attributes.clientCredentials(clientCreds)
|
|
1708
|
-
)
|
|
1709
|
-
});
|
|
1710
|
-
return PaginatedResponse.fromDto(pageDto, Offer.fromDto);
|
|
1711
|
-
}
|
|
1712
|
-
async function fetchOfferDetails(api, id, clientCreds) {
|
|
1713
|
-
const dto = await api.send({
|
|
1714
|
-
method: "GET",
|
|
1715
|
-
url: `/v1/offers/${id}`,
|
|
1716
|
-
attributes: Attributes.concat(
|
|
1717
|
-
Attributes.protected(),
|
|
1718
|
-
Attributes.clientCredentials(clientCreds)
|
|
1719
|
-
)
|
|
1720
|
-
});
|
|
1721
|
-
return OfferDetail.fromDto(dto);
|
|
1722
|
-
}
|
|
1723
|
-
|
|
1724
1658
|
// src/shared/types/participation.ts
|
|
1725
1659
|
var ParticipationId = (value) => value;
|
|
1726
1660
|
var Blockchain = (value) => value;
|
|
@@ -1768,6 +1702,85 @@ var CreateParticipationParams = {
|
|
|
1768
1702
|
})
|
|
1769
1703
|
};
|
|
1770
1704
|
|
|
1705
|
+
// src/client/core/blockchain/token-sale-flow.ts
|
|
1706
|
+
async function executeTokenSale(params) {
|
|
1707
|
+
const {
|
|
1708
|
+
erc20,
|
|
1709
|
+
tokenSale,
|
|
1710
|
+
wallet,
|
|
1711
|
+
offerId,
|
|
1712
|
+
offerOptionId,
|
|
1713
|
+
assetId,
|
|
1714
|
+
paymentTokenAddress,
|
|
1715
|
+
fundingContractAddress,
|
|
1716
|
+
chain,
|
|
1717
|
+
amount,
|
|
1718
|
+
onProgress
|
|
1719
|
+
} = params;
|
|
1720
|
+
const emit = (phase) => onProgress?.(phase);
|
|
1721
|
+
emit("checking-allowance");
|
|
1722
|
+
let currentAllowance;
|
|
1723
|
+
try {
|
|
1724
|
+
const allowance = await erc20.getTokenAllowance({
|
|
1725
|
+
tokenAddress: paymentTokenAddress,
|
|
1726
|
+
owner: wallet.address,
|
|
1727
|
+
spender: fundingContractAddress,
|
|
1728
|
+
chain
|
|
1729
|
+
});
|
|
1730
|
+
currentAllowance = allowance.allowance;
|
|
1731
|
+
} catch {
|
|
1732
|
+
return { type: "error", error: { step: "allowance-check" } };
|
|
1733
|
+
}
|
|
1734
|
+
if (currentAllowance > 0n) {
|
|
1735
|
+
const reset = await submitErc20Approval({
|
|
1736
|
+
wallet,
|
|
1737
|
+
tokenAddress: paymentTokenAddress,
|
|
1738
|
+
spender: fundingContractAddress,
|
|
1739
|
+
chain,
|
|
1740
|
+
value: 0n,
|
|
1741
|
+
pending: "resetting-allowance",
|
|
1742
|
+
confirming: "confirming-allowance-reset",
|
|
1743
|
+
emit
|
|
1744
|
+
});
|
|
1745
|
+
if (reset.type === "error") {
|
|
1746
|
+
return {
|
|
1747
|
+
type: "error",
|
|
1748
|
+
error: reset.error.step === "approval-reverted" ? { step: "allowance-reset-reverted" } : { step: "allowance-reset", cause: reset.error.cause }
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
const approve = await submitErc20Approval({
|
|
1753
|
+
wallet,
|
|
1754
|
+
tokenAddress: paymentTokenAddress,
|
|
1755
|
+
spender: fundingContractAddress,
|
|
1756
|
+
chain,
|
|
1757
|
+
value: amount.raw,
|
|
1758
|
+
pending: "approving",
|
|
1759
|
+
confirming: "confirming-approval",
|
|
1760
|
+
emit
|
|
1761
|
+
});
|
|
1762
|
+
if (approve.type === "error") {
|
|
1763
|
+
return { type: "error", error: approve.error };
|
|
1764
|
+
}
|
|
1765
|
+
const approvalTxHash = approve.txHash;
|
|
1766
|
+
emit("recording-participation");
|
|
1767
|
+
let participation;
|
|
1768
|
+
try {
|
|
1769
|
+
participation = await tokenSale.createParticipation({
|
|
1770
|
+
offerId,
|
|
1771
|
+
offerOptionId,
|
|
1772
|
+
chain: Blockchain(chain),
|
|
1773
|
+
walletAddress: WalletAddress(wallet.address),
|
|
1774
|
+
amount: amount.raw.toString(),
|
|
1775
|
+
assetId,
|
|
1776
|
+
approvalTransactionHash: approvalTxHash
|
|
1777
|
+
});
|
|
1778
|
+
} catch {
|
|
1779
|
+
return { type: "error", error: { step: "participation", approvalTxHash } };
|
|
1780
|
+
}
|
|
1781
|
+
return { type: "success", participation, approvalTxHash };
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1771
1784
|
// src/shared/api/frontline/participations.ts
|
|
1772
1785
|
async function fetchParticipations(api, offerId) {
|
|
1773
1786
|
return fetchAllPages(
|
|
@@ -1802,6 +1815,109 @@ async function createParticipation(api, params) {
|
|
|
1802
1815
|
return Participation.fromDto(dto);
|
|
1803
1816
|
}
|
|
1804
1817
|
|
|
1818
|
+
// src/shared/core/token-sale-namespace.ts
|
|
1819
|
+
var TokenSaleNamespaceImpl = class {
|
|
1820
|
+
constructor(ctx) {
|
|
1821
|
+
this.ctx = ctx;
|
|
1822
|
+
}
|
|
1823
|
+
async fetchParticipations(offerId) {
|
|
1824
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1825
|
+
return fetchParticipations(this.ctx.api, offerId);
|
|
1826
|
+
}
|
|
1827
|
+
async fetchParticipationsPage(params) {
|
|
1828
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1829
|
+
return fetchParticipationsPage(this.ctx.api, params);
|
|
1830
|
+
}
|
|
1831
|
+
async fetchParticipation(id) {
|
|
1832
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1833
|
+
return fetchParticipation(this.ctx.api, id);
|
|
1834
|
+
}
|
|
1835
|
+
async createParticipation(params) {
|
|
1836
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1837
|
+
return createParticipation(this.ctx.api, params);
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1841
|
+
// src/client/core/client-token-sale-namespace.ts
|
|
1842
|
+
var ClientTokenSaleNamespaceImpl = class extends TokenSaleNamespaceImpl {
|
|
1843
|
+
constructor(ctx, erc20) {
|
|
1844
|
+
super(ctx);
|
|
1845
|
+
this.erc20 = erc20;
|
|
1846
|
+
}
|
|
1847
|
+
executeTokenSale(params) {
|
|
1848
|
+
return executeTokenSale({ ...params, erc20: this.erc20, tokenSale: this });
|
|
1849
|
+
}
|
|
1850
|
+
};
|
|
1851
|
+
|
|
1852
|
+
// src/shared/types/document-submission.ts
|
|
1853
|
+
var DocumentSubmission = {
|
|
1854
|
+
fromDto: (dto) => ({
|
|
1855
|
+
status: dto.status,
|
|
1856
|
+
formType: dto.form_type
|
|
1857
|
+
})
|
|
1858
|
+
};
|
|
1859
|
+
|
|
1860
|
+
// src/shared/api/frontline/documents.ts
|
|
1861
|
+
async function submitDocument(api, documentType, fields) {
|
|
1862
|
+
const dto = await api.send({
|
|
1863
|
+
method: "POST",
|
|
1864
|
+
url: `/v1/documents/${documentType}/submission`,
|
|
1865
|
+
body: fields,
|
|
1866
|
+
attributes: Attributes.protected()
|
|
1867
|
+
});
|
|
1868
|
+
return DocumentSubmission.fromDto(dto);
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
// src/shared/types/kyc.ts
|
|
1872
|
+
var KycToken = {
|
|
1873
|
+
fromDto: (dto) => ({
|
|
1874
|
+
token: dto.token
|
|
1875
|
+
})
|
|
1876
|
+
};
|
|
1877
|
+
|
|
1878
|
+
// src/shared/api/frontline/kyc.ts
|
|
1879
|
+
async function createKycToken(api, levelName, reset) {
|
|
1880
|
+
const dto = await api.send({
|
|
1881
|
+
method: "POST",
|
|
1882
|
+
url: "/v1/kyc-token",
|
|
1883
|
+
body: {
|
|
1884
|
+
...levelName === void 0 ? {} : { level_name: levelName },
|
|
1885
|
+
...reset === void 0 ? {} : { reset }
|
|
1886
|
+
},
|
|
1887
|
+
attributes: Attributes.protected()
|
|
1888
|
+
});
|
|
1889
|
+
return KycToken.fromDto(dto);
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
// src/shared/api/frontline/offers.ts
|
|
1893
|
+
async function fetchOffers(api, clientCreds) {
|
|
1894
|
+
return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
|
|
1895
|
+
}
|
|
1896
|
+
async function fetchOffersPage(api, params, clientCreds) {
|
|
1897
|
+
const queryParams = PaginationParams.toQueryParams(params);
|
|
1898
|
+
const pageDto = await api.send({
|
|
1899
|
+
method: "GET",
|
|
1900
|
+
url: "/v1/offers",
|
|
1901
|
+
queryParams,
|
|
1902
|
+
attributes: Attributes.concat(
|
|
1903
|
+
Attributes.protected(),
|
|
1904
|
+
Attributes.clientCredentials(clientCreds)
|
|
1905
|
+
)
|
|
1906
|
+
});
|
|
1907
|
+
return PaginatedResponse.fromDto(pageDto, Offer.fromDto);
|
|
1908
|
+
}
|
|
1909
|
+
async function fetchOfferDetails(api, id, clientCreds) {
|
|
1910
|
+
const dto = await api.send({
|
|
1911
|
+
method: "GET",
|
|
1912
|
+
url: `/v1/offers/${id}`,
|
|
1913
|
+
attributes: Attributes.concat(
|
|
1914
|
+
Attributes.protected(),
|
|
1915
|
+
Attributes.clientCredentials(clientCreds)
|
|
1916
|
+
)
|
|
1917
|
+
});
|
|
1918
|
+
return OfferDetail.fromDto(dto);
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1805
1921
|
// src/shared/types/pii.ts
|
|
1806
1922
|
var Iso2CountryCode = (value) => value;
|
|
1807
1923
|
var PiiJurisdiction = {
|
|
@@ -1887,6 +2003,21 @@ async function fetchRequirementStatuses(api, offerId) {
|
|
|
1887
2003
|
return RequirementStatusInfo.fromStatusesDto(response);
|
|
1888
2004
|
}
|
|
1889
2005
|
|
|
2006
|
+
// src/shared/core/erc20-namespace.ts
|
|
2007
|
+
var Erc20NamespaceImpl = class {
|
|
2008
|
+
constructor(ctx) {
|
|
2009
|
+
this.ctx = ctx;
|
|
2010
|
+
}
|
|
2011
|
+
async getTokenAllowance(params) {
|
|
2012
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2013
|
+
return getTokenAllowance(this.ctx.api, params);
|
|
2014
|
+
}
|
|
2015
|
+
async getTokenBalance(params) {
|
|
2016
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2017
|
+
return getTokenBalance(this.ctx.api, params);
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
2020
|
+
|
|
1890
2021
|
// src/shared/types/oauth.ts
|
|
1891
2022
|
var AuthorizationCode = (value) => value;
|
|
1892
2023
|
var CodeVerifier = (value) => value;
|
|
@@ -1933,10 +2064,13 @@ var CoinListClientImpl = class {
|
|
|
1933
2064
|
},
|
|
1934
2065
|
this.fetchAccessToken.bind(this)
|
|
1935
2066
|
);
|
|
1936
|
-
|
|
2067
|
+
const ctx = {
|
|
1937
2068
|
api: this.api,
|
|
1938
2069
|
ensureUserAuthenticated: async () => this.ensureAuthenticated()
|
|
1939
|
-
}
|
|
2070
|
+
};
|
|
2071
|
+
this.erc20 = new Erc20NamespaceImpl(ctx);
|
|
2072
|
+
this.tokenSale = new ClientTokenSaleNamespaceImpl(ctx, this.erc20);
|
|
2073
|
+
this.swap = new ClientSwapNamespaceImpl(ctx, this.erc20);
|
|
1940
2074
|
}
|
|
1941
2075
|
async init() {
|
|
1942
2076
|
await this.fetchAccessToken(true);
|
|
@@ -2018,22 +2152,6 @@ var CoinListClientImpl = class {
|
|
|
2018
2152
|
this.ensureAuthenticated();
|
|
2019
2153
|
return fetchOfferDetails(this.api, id, void 0);
|
|
2020
2154
|
}
|
|
2021
|
-
async fetchParticipations(offerId) {
|
|
2022
|
-
this.ensureAuthenticated();
|
|
2023
|
-
return fetchParticipations(this.api, offerId);
|
|
2024
|
-
}
|
|
2025
|
-
async fetchParticipationsPage(params) {
|
|
2026
|
-
this.ensureAuthenticated();
|
|
2027
|
-
return fetchParticipationsPage(this.api, params);
|
|
2028
|
-
}
|
|
2029
|
-
async fetchParticipation(id) {
|
|
2030
|
-
this.ensureAuthenticated();
|
|
2031
|
-
return fetchParticipation(this.api, id);
|
|
2032
|
-
}
|
|
2033
|
-
async createParticipation(params) {
|
|
2034
|
-
this.ensureAuthenticated();
|
|
2035
|
-
return createParticipation(this.api, params);
|
|
2036
|
-
}
|
|
2037
2155
|
async createWalletOwnershipChallenge(params) {
|
|
2038
2156
|
this.ensureAuthenticated();
|
|
2039
2157
|
return createWalletOwnershipChallenge(this.api, params);
|
|
@@ -2636,7 +2754,7 @@ var OfferCardUi = {
|
|
|
2636
2754
|
bannerUrl: offer.bannerUrl,
|
|
2637
2755
|
logoUrl: offer.logoUrl,
|
|
2638
2756
|
formattedStartsAt: monthYearFormatter.format(offer.startsAt),
|
|
2639
|
-
formattedEndsAt: monthYearFormatter.format(offer.endsAt)
|
|
2757
|
+
formattedEndsAt: offer.endsAt ? monthYearFormatter.format(offer.endsAt) : null
|
|
2640
2758
|
})
|
|
2641
2759
|
};
|
|
2642
2760
|
function OfferCard({
|
|
@@ -2687,7 +2805,7 @@ function OfferCard({
|
|
|
2687
2805
|
),
|
|
2688
2806
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: cn(typeClasses.label, "clcosdk:text-text-primary"), children: offer.formattedStartsAt })
|
|
2689
2807
|
] }),
|
|
2690
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-1", children: [
|
|
2808
|
+
offer.formattedEndsAt && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-1", children: [
|
|
2691
2809
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2692
2810
|
"span",
|
|
2693
2811
|
{
|
|
@@ -2695,7 +2813,13 @@ function OfferCard({
|
|
|
2695
2813
|
children: "Ends"
|
|
2696
2814
|
}
|
|
2697
2815
|
),
|
|
2698
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2816
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2817
|
+
"span",
|
|
2818
|
+
{
|
|
2819
|
+
className: cn(typeClasses.label, "clcosdk:text-text-primary"),
|
|
2820
|
+
children: offer.formattedEndsAt
|
|
2821
|
+
}
|
|
2822
|
+
)
|
|
2699
2823
|
] })
|
|
2700
2824
|
] })
|
|
2701
2825
|
] });
|
|
@@ -4774,7 +4898,7 @@ function useSwapTokenBalances(options) {
|
|
|
4774
4898
|
}
|
|
4775
4899
|
const results = await Promise.allSettled(
|
|
4776
4900
|
symbols.map(
|
|
4777
|
-
(symbol) => coinlist.
|
|
4901
|
+
(symbol) => coinlist.erc20.getTokenBalance({
|
|
4778
4902
|
tokenAddress: TOKEN_REGISTRY.contractAddress(symbol, chain),
|
|
4779
4903
|
owner: address,
|
|
4780
4904
|
chain
|
|
@@ -4926,7 +5050,7 @@ function useParticipations(offerId, options = {}) {
|
|
|
4926
5050
|
};
|
|
4927
5051
|
}
|
|
4928
5052
|
setParticipationsState(LOADING_STATE8);
|
|
4929
|
-
coinlist.fetchParticipations(offerId).then((participations) => {
|
|
5053
|
+
coinlist.tokenSale.fetchParticipations(offerId).then((participations) => {
|
|
4930
5054
|
if (!isCancelled) {
|
|
4931
5055
|
setParticipationsState({ type: "CONTENT", participations });
|
|
4932
5056
|
}
|
|
@@ -4946,6 +5070,7 @@ function useParticipations(offerId, options = {}) {
|
|
|
4946
5070
|
0 && (module.exports = {
|
|
4947
5071
|
ChecklistStatus,
|
|
4948
5072
|
ClientSwapNamespaceImpl,
|
|
5073
|
+
ClientTokenSaleNamespaceImpl,
|
|
4949
5074
|
CoinListClientInitializationError,
|
|
4950
5075
|
CoinListContext,
|
|
4951
5076
|
CoinListContextProvider,
|
|
@@ -4972,6 +5097,7 @@ function useParticipations(offerId, options = {}) {
|
|
|
4972
5097
|
connectExternalWalletFlow,
|
|
4973
5098
|
createCoinListClient,
|
|
4974
5099
|
executeSwap,
|
|
5100
|
+
executeTokenSale,
|
|
4975
5101
|
useCoinList,
|
|
4976
5102
|
useCompleteOAuth,
|
|
4977
5103
|
useConnectWallet,
|