@coinlist-co/react 0.9.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.
Files changed (34) hide show
  1. package/dist/{chunk-I5YTJ5SL.js → chunk-AQVCOWOV.js} +163 -69
  2. package/dist/chunk-AQVCOWOV.js.map +1 -0
  3. package/dist/{chunk-MKCOK3DF.js → chunk-TBU3EBNM.js} +2 -43
  4. package/dist/chunk-TBU3EBNM.js.map +1 -0
  5. package/dist/{chunk-Z2HAA2TI.js → chunk-UOHD7US2.js} +150 -63
  6. package/dist/chunk-UOHD7US2.js.map +1 -0
  7. package/dist/client/index.cjs +415 -292
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +131 -49
  10. package/dist/client/index.d.ts +131 -49
  11. package/dist/client/index.js +169 -76
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/{collections-BQbFJS3g.d.ts → collections-Bv1Oxzu_.d.ts} +1 -1
  14. package/dist/{collections-B84Vw55t.d.cts → collections-DDyxbOPZ.d.cts} +1 -1
  15. package/dist/{requirement-C2w45Q11.d.cts → requirement-oVZA1INj.d.cts} +271 -200
  16. package/dist/{requirement-C2w45Q11.d.ts → requirement-oVZA1INj.d.ts} +271 -200
  17. package/dist/server/index.cjs +135 -116
  18. package/dist/server/index.cjs.map +1 -1
  19. package/dist/server/index.d.cts +20 -27
  20. package/dist/server/index.d.ts +20 -27
  21. package/dist/server/index.js +10 -27
  22. package/dist/server/index.js.map +1 -1
  23. package/dist/shared/index.cjs +145 -75
  24. package/dist/shared/index.cjs.map +1 -1
  25. package/dist/shared/index.d.cts +4 -4
  26. package/dist/shared/index.d.ts +4 -4
  27. package/dist/shared/index.js +16 -92
  28. package/dist/shared/index.js.map +1 -1
  29. package/package.json +1 -1
  30. package/dist/chunk-AAER5LOL.js +0 -22
  31. package/dist/chunk-AAER5LOL.js.map +0 -1
  32. package/dist/chunk-I5YTJ5SL.js.map +0 -1
  33. package/dist/chunk-MKCOK3DF.js.map +0 -1
  34. package/dist/chunk-Z2HAA2TI.js.map +0 -1
@@ -505,11 +505,12 @@ var Offer = {
505
505
  fromDto: (dto) => ({
506
506
  id: OfferId(dto.id),
507
507
  slug: OfferSlug(dto.slug),
508
- tagline: notBlankStringOrNull(dto.tagline),
509
- bannerUrl: notBlankStringOrNull(dto.banner_url),
510
- logoUrl: notBlankStringOrNull(dto.logo_url),
508
+ type: dto.type,
509
+ tagline: dto.tagline,
510
+ bannerUrl: dto.banner_url,
511
+ logoUrl: dto.logo_url,
511
512
  startsAt: new Date(dto.starts_at),
512
- endsAt: new Date(dto.ends_at)
513
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null
513
514
  })
514
515
  };
515
516
 
@@ -551,16 +552,17 @@ var OfferDetail = {
551
552
  return {
552
553
  id: OfferId(dto.id),
553
554
  slug: OfferSlug(dto.slug),
555
+ type: dto.type,
554
556
  name: dto.name,
555
557
  asset: Asset.fromDto(dto.asset),
556
558
  fundingAssets: dto.funding_assets.map(Asset.fromDto),
557
559
  about: notBlankStringOrNull(dto.about),
558
- tagline: notBlankStringOrNull(dto.tagline),
559
- bannerUrl: notBlankStringOrNull(dto.banner_url),
560
- logoUrl: notBlankStringOrNull(dto.logo_url),
561
- category: notBlankStringOrNull(dto.category),
560
+ tagline: dto.tagline,
561
+ bannerUrl: dto.banner_url,
562
+ logoUrl: dto.logo_url,
563
+ category: dto.category,
562
564
  startsAt: new Date(dto.starts_at),
563
- endsAt: new Date(dto.ends_at),
565
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
564
566
  faqs: dto.faqs.map(FaqItem.fromDto),
565
567
  links: dto.links.map(Link.fromDto),
566
568
  milestones: dto.milestones.map(Milestone.fromDto),
@@ -636,87 +638,6 @@ async function fetchOfferDetails(api, id, clientCreds) {
636
638
  return OfferDetail.fromDto(dto);
637
639
  }
638
640
 
639
- // src/shared/types/participation.ts
640
- var ParticipationId = (value) => value;
641
- var Blockchain = (value) => value;
642
- var WalletAddress = (value) => value;
643
- var ParticipationsPaginationParams = {
644
- toQueryParams: (params) => {
645
- const queryParams = PaginationParams.toQueryParams(params);
646
- if (params.offerId) {
647
- queryParams["filters[0][field]"] = "offer_id";
648
- queryParams["filters[0][op]"] = "==";
649
- queryParams["filters[0][value]"] = params.offerId;
650
- }
651
- return queryParams;
652
- }
653
- };
654
- var Participation = {
655
- /** Maps API DTO shape into the SDK participation domain model. */
656
- fromDto: (dto) => {
657
- const walletAddress = notBlankStringOrNull(dto.wallet_address);
658
- return {
659
- id: ParticipationId(dto.id),
660
- offerId: OfferId(dto.offer_id),
661
- offerOptionId: OfferOptionId(dto.offer_option_id),
662
- status: dto.status,
663
- amount: dto.amount,
664
- displayAmount: dto.amount_string,
665
- asset: Asset.fromDto(dto.asset),
666
- chain: Blockchain(dto.chain),
667
- insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
668
- updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
669
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
670
- };
671
- }
672
- };
673
- var CreateParticipationParams = {
674
- /** Maps participation creation params into API DTO payload. */
675
- toDto: (params) => ({
676
- offer_id: params.offerId,
677
- offer_option_id: params.offerOptionId,
678
- chain: params.chain,
679
- wallet_address: params.walletAddress,
680
- amount: params.amount,
681
- asset_id: params.assetId,
682
- approval_transaction_hash: params.approvalTransactionHash
683
- })
684
- };
685
-
686
- // src/shared/api/frontline/participations.ts
687
- async function fetchParticipations(api, offerId) {
688
- return fetchAllPages(
689
- (params) => fetchParticipationsPage(api, params),
690
- { offerId }
691
- );
692
- }
693
- async function fetchParticipationsPage(api, params) {
694
- const pageDto = await api.send({
695
- method: "GET",
696
- url: "/v1/participations",
697
- queryParams: ParticipationsPaginationParams.toQueryParams(params),
698
- attributes: Attributes.protected()
699
- });
700
- return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
701
- }
702
- async function fetchParticipation(api, id) {
703
- const dto = await api.send({
704
- method: "GET",
705
- url: `/v1/participations/${id}`,
706
- attributes: Attributes.protected()
707
- });
708
- return Participation.fromDto(dto);
709
- }
710
- async function createParticipation(api, params) {
711
- const dto = await api.send({
712
- method: "POST",
713
- url: "/v1/participations",
714
- body: CreateParticipationParams.toDto(params),
715
- attributes: Attributes.protected()
716
- });
717
- return Participation.fromDto(dto);
718
- }
719
-
720
641
  // src/shared/types/pii.ts
721
642
  var Iso2CountryCode = (value) => value;
722
643
  var PiiJurisdiction = {
@@ -1084,6 +1005,21 @@ function toErc20Asset(dto) {
1084
1005
  };
1085
1006
  }
1086
1007
 
1008
+ // src/shared/core/erc20-namespace.ts
1009
+ var Erc20NamespaceImpl = class {
1010
+ constructor(ctx) {
1011
+ this.ctx = ctx;
1012
+ }
1013
+ async getTokenAllowance(params) {
1014
+ await this.ctx.ensureUserAuthenticated();
1015
+ return getTokenAllowance(this.ctx.api, params);
1016
+ }
1017
+ async getTokenBalance(params) {
1018
+ await this.ctx.ensureUserAuthenticated();
1019
+ return getTokenBalance(this.ctx.api, params);
1020
+ }
1021
+ };
1022
+
1087
1023
  // src/shared/core/swap-namespace.ts
1088
1024
  var SwapNamespaceImpl = class {
1089
1025
  constructor(ctx) {
@@ -1101,14 +1037,6 @@ var SwapNamespaceImpl = class {
1101
1037
  await this.ctx.ensureUserAuthenticated();
1102
1038
  return getSwapStatus(this.ctx.api, params);
1103
1039
  }
1104
- async getTokenAllowance(params) {
1105
- await this.ctx.ensureUserAuthenticated();
1106
- return getTokenAllowance(this.ctx.api, params);
1107
- }
1108
- async getTokenBalance(params) {
1109
- await this.ctx.ensureUserAuthenticated();
1110
- return getTokenBalance(this.ctx.api, params);
1111
- }
1112
1040
  async getOutputToken(params) {
1113
1041
  await this.ctx.ensureUserAuthenticated();
1114
1042
  return getSwapOutputToken(this.ctx.api, params);
@@ -1123,6 +1051,110 @@ var SwapNamespaceImpl = class {
1123
1051
  }
1124
1052
  };
1125
1053
 
1054
+ // src/shared/types/participation.ts
1055
+ var ParticipationId = (value) => value;
1056
+ var Blockchain = (value) => value;
1057
+ var WalletAddress = (value) => value;
1058
+ var ParticipationsPaginationParams = {
1059
+ toQueryParams: (params) => {
1060
+ const queryParams = PaginationParams.toQueryParams(params);
1061
+ if (params.offerId) {
1062
+ queryParams["filters[0][field]"] = "offer_id";
1063
+ queryParams["filters[0][op]"] = "==";
1064
+ queryParams["filters[0][value]"] = params.offerId;
1065
+ }
1066
+ return queryParams;
1067
+ }
1068
+ };
1069
+ var Participation = {
1070
+ /** Maps API DTO shape into the SDK participation domain model. */
1071
+ fromDto: (dto) => {
1072
+ const walletAddress = notBlankStringOrNull(dto.wallet_address);
1073
+ return {
1074
+ id: ParticipationId(dto.id),
1075
+ offerId: OfferId(dto.offer_id),
1076
+ offerOptionId: OfferOptionId(dto.offer_option_id),
1077
+ status: dto.status,
1078
+ amount: dto.amount,
1079
+ displayAmount: dto.amount_string,
1080
+ asset: Asset.fromDto(dto.asset),
1081
+ chain: Blockchain(dto.chain),
1082
+ insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
1083
+ updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
1084
+ walletAddress: walletAddress ? WalletAddress(walletAddress) : null
1085
+ };
1086
+ }
1087
+ };
1088
+ var CreateParticipationParams = {
1089
+ /** Maps participation creation params into API DTO payload. */
1090
+ toDto: (params) => ({
1091
+ offer_id: params.offerId,
1092
+ offer_option_id: params.offerOptionId,
1093
+ chain: params.chain,
1094
+ wallet_address: params.walletAddress,
1095
+ amount: params.amount,
1096
+ asset_id: params.assetId,
1097
+ approval_transaction_hash: params.approvalTransactionHash
1098
+ })
1099
+ };
1100
+
1101
+ // src/shared/api/frontline/participations.ts
1102
+ async function fetchParticipations(api, offerId) {
1103
+ return fetchAllPages(
1104
+ (params) => fetchParticipationsPage(api, params),
1105
+ { offerId }
1106
+ );
1107
+ }
1108
+ async function fetchParticipationsPage(api, params) {
1109
+ const pageDto = await api.send({
1110
+ method: "GET",
1111
+ url: "/v1/participations",
1112
+ queryParams: ParticipationsPaginationParams.toQueryParams(params),
1113
+ attributes: Attributes.protected()
1114
+ });
1115
+ return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
1116
+ }
1117
+ async function fetchParticipation(api, id) {
1118
+ const dto = await api.send({
1119
+ method: "GET",
1120
+ url: `/v1/participations/${id}`,
1121
+ attributes: Attributes.protected()
1122
+ });
1123
+ return Participation.fromDto(dto);
1124
+ }
1125
+ async function createParticipation(api, params) {
1126
+ const dto = await api.send({
1127
+ method: "POST",
1128
+ url: "/v1/participations",
1129
+ body: CreateParticipationParams.toDto(params),
1130
+ attributes: Attributes.protected()
1131
+ });
1132
+ return Participation.fromDto(dto);
1133
+ }
1134
+
1135
+ // src/shared/core/token-sale-namespace.ts
1136
+ var TokenSaleNamespaceImpl = class {
1137
+ constructor(ctx) {
1138
+ this.ctx = ctx;
1139
+ }
1140
+ async fetchParticipations(offerId) {
1141
+ await this.ctx.ensureUserAuthenticated();
1142
+ return fetchParticipations(this.ctx.api, offerId);
1143
+ }
1144
+ async fetchParticipationsPage(params) {
1145
+ await this.ctx.ensureUserAuthenticated();
1146
+ return fetchParticipationsPage(this.ctx.api, params);
1147
+ }
1148
+ async fetchParticipation(id) {
1149
+ await this.ctx.ensureUserAuthenticated();
1150
+ return fetchParticipation(this.ctx.api, id);
1151
+ }
1152
+ async createParticipation(params) {
1153
+ await this.ctx.ensureUserAuthenticated();
1154
+ return createParticipation(this.ctx.api, params);
1155
+ }
1156
+ };
1157
+
1126
1158
  // src/shared/types/errors.ts
1127
1159
  var NotAuthenticatedError = class extends Error {
1128
1160
  constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
@@ -1166,10 +1198,13 @@ var CoinListServerImpl = class {
1166
1198
  // than re-sending with the same expired token and wasting a round-trip.
1167
1199
  (refresh) => refresh && !this._config.sessionStore.setSession ? Promise.resolve(null) : this.accessToken()
1168
1200
  );
1169
- this.swap = new SwapNamespaceImpl({
1201
+ const ctx = {
1170
1202
  api: this.api,
1171
1203
  ensureUserAuthenticated: () => this.ensureUserAuthenticated()
1172
- });
1204
+ };
1205
+ this.erc20 = new Erc20NamespaceImpl(ctx);
1206
+ this.tokenSale = new TokenSaleNamespaceImpl(ctx);
1207
+ this.swap = new SwapNamespaceImpl(ctx);
1173
1208
  }
1174
1209
  async completeOAuth(code, codeVerifier) {
1175
1210
  const sessionStore = this._config.sessionStore;
@@ -1290,22 +1325,6 @@ var CoinListServerImpl = class {
1290
1325
  await this.ensureAuthenticated(clientCreds);
1291
1326
  return fetchOfferDetails(this.api, id, clientCreds);
1292
1327
  }
1293
- async fetchParticipations(offerId) {
1294
- await this.ensureUserAuthenticated();
1295
- return fetchParticipations(this.api, offerId);
1296
- }
1297
- async fetchParticipationsPage(params) {
1298
- await this.ensureUserAuthenticated();
1299
- return fetchParticipationsPage(this.api, params);
1300
- }
1301
- async fetchParticipation(id) {
1302
- await this.ensureUserAuthenticated();
1303
- return fetchParticipation(this.api, id);
1304
- }
1305
- async createParticipation(params) {
1306
- await this.ensureUserAuthenticated();
1307
- return createParticipation(this.api, params);
1308
- }
1309
1328
  async createWalletOwnershipChallenge(params) {
1310
1329
  await this.ensureUserAuthenticated();
1311
1330
  return createWalletOwnershipChallenge(this.api, params);