@coinlist-co/react 0.12.1-rc.df659d8 → 0.12.1-rc.e183ffd
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-I5EHOV7V.js → chunk-DCW7NQXH.js} +2 -2
- package/dist/{chunk-VSYGGTI6.js → chunk-MOE5S6CE.js} +186 -106
- package/dist/chunk-MOE5S6CE.js.map +1 -0
- package/dist/{chunk-3EOK47CQ.js → chunk-ONLH57LF.js} +2 -2
- package/dist/client/index.cjs +177 -88
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +31 -25
- package/dist/client/index.d.ts +31 -25
- package/dist/client/index.js +31 -20
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-UYVlXbEh.d.cts → collections-Biy3pQQL.d.cts} +1 -1
- package/dist/{collections-C6b-rJpx.d.ts → collections-JfNDG8Tc.d.ts} +1 -1
- package/dist/server/index.cjs +149 -71
- 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 +2 -2
- package/dist/{tokens-namespace-C-BxcYMj.d.cts → tokens-namespace-CIWBtgt2.d.cts} +171 -46
- package/dist/{tokens-namespace-C-BxcYMj.d.ts → tokens-namespace-CIWBtgt2.d.ts} +171 -46
- package/dist/universal/index.cjs +153 -71
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +4 -4
- package/dist/universal/index.d.ts +4 -4
- package/dist/universal/index.js +6 -2
- package/package.json +1 -1
- package/dist/chunk-VSYGGTI6.js.map +0 -1
- /package/dist/{chunk-I5EHOV7V.js.map → chunk-DCW7NQXH.js.map} +0 -0
- /package/dist/{chunk-3EOK47CQ.js.map → chunk-ONLH57LF.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aI as ClientId, bw as RedirectUri, aJ as CodeChallenge, bk as PKCEState, C as CodeVerifier, q as EvmWalletAddress, a as EthereumChain, bN as Tx, B as BlockchainAmount, bG as SwapPreview, a0 as AssetDecimals, aA as Newtype } from './tokens-namespace-CIWBtgt2.cjs';
|
|
2
2
|
import { Hex, Abi, Hash, TransactionReceipt } from 'viem';
|
|
3
3
|
|
|
4
4
|
type PKCEParams = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aI as ClientId, bw as RedirectUri, aJ as CodeChallenge, bk as PKCEState, C as CodeVerifier, q as EvmWalletAddress, a as EthereumChain, bN as Tx, B as BlockchainAmount, bG as SwapPreview, a0 as AssetDecimals, aA as Newtype } from './tokens-namespace-CIWBtgt2.js';
|
|
2
2
|
import { Hex, Abi, Hash, TransactionReceipt } from 'viem';
|
|
3
3
|
|
|
4
4
|
type PKCEParams = {
|
package/dist/server/index.cjs
CHANGED
|
@@ -935,6 +935,40 @@ async function fetchAllPages(fetchPage, baseParams) {
|
|
|
935
935
|
return items;
|
|
936
936
|
}
|
|
937
937
|
|
|
938
|
+
// src/universal/core/shared/utils/wire.ts
|
|
939
|
+
function unknownTypeError(dto, model) {
|
|
940
|
+
const type = dto.type;
|
|
941
|
+
throw new ValidationError(
|
|
942
|
+
`${model}.type: unknown type ${JSON.stringify(type)}`
|
|
943
|
+
);
|
|
944
|
+
}
|
|
945
|
+
function requiredString(value, field) {
|
|
946
|
+
const text = notBlankStringOrNull(value);
|
|
947
|
+
if (text === null) {
|
|
948
|
+
throw new ValidationError(
|
|
949
|
+
`${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
return text;
|
|
953
|
+
}
|
|
954
|
+
function requiredDate(value, field) {
|
|
955
|
+
const date = typeof value === "string" ? new Date(value) : null;
|
|
956
|
+
if (date === null || Number.isNaN(date.getTime())) {
|
|
957
|
+
throw new ValidationError(
|
|
958
|
+
`${field}: expected a date, got ${JSON.stringify(value)}`
|
|
959
|
+
);
|
|
960
|
+
}
|
|
961
|
+
return date;
|
|
962
|
+
}
|
|
963
|
+
function requiredArray(value, field) {
|
|
964
|
+
if (!Array.isArray(value)) {
|
|
965
|
+
throw new ValidationError(
|
|
966
|
+
`${field}: expected an array, got ${typeof value}`
|
|
967
|
+
);
|
|
968
|
+
}
|
|
969
|
+
return value;
|
|
970
|
+
}
|
|
971
|
+
|
|
938
972
|
// src/universal/types/blockchain/core.ts
|
|
939
973
|
var ETHEREUM_CHAINS = {
|
|
940
974
|
ethereum_mainnet: true,
|
|
@@ -1026,25 +1060,69 @@ var AssetSymbol = (value) => value;
|
|
|
1026
1060
|
// src/universal/types/offer.ts
|
|
1027
1061
|
var OfferId = (value) => value;
|
|
1028
1062
|
var OfferSlug = (value) => value;
|
|
1063
|
+
var OFFER_TYPES = {
|
|
1064
|
+
"coinlist::token_sale": true,
|
|
1065
|
+
"superstate::swap": true,
|
|
1066
|
+
"ondo::swap": true
|
|
1067
|
+
};
|
|
1068
|
+
var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
|
|
1069
|
+
var OfferEditorial = {
|
|
1070
|
+
/**
|
|
1071
|
+
* `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
|
|
1072
|
+
* the same three checks name the payload that failed them.
|
|
1073
|
+
*/
|
|
1074
|
+
fromDto: (dto, model) => ({
|
|
1075
|
+
tagline: requiredString(dto.tagline, `${model}.tagline`),
|
|
1076
|
+
bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
|
|
1077
|
+
startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
|
|
1078
|
+
})
|
|
1079
|
+
};
|
|
1029
1080
|
var Offer = {
|
|
1030
1081
|
fromDto: (dto) => {
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
`Offer.tokens: expected an array, got ${typeof dto.tokens}`
|
|
1034
|
-
);
|
|
1035
|
-
}
|
|
1036
|
-
return {
|
|
1082
|
+
const tokens = requiredArray(dto.tokens, "Offer.tokens");
|
|
1083
|
+
const base2 = {
|
|
1037
1084
|
id: OfferId(dto.id),
|
|
1038
1085
|
slug: OfferSlug(dto.slug),
|
|
1039
|
-
type: dto.type,
|
|
1040
|
-
tagline: dto.tagline,
|
|
1041
|
-
bannerUrl: dto.banner_url,
|
|
1042
|
-
logoUrl: dto.logo_url,
|
|
1043
|
-
startsAt: new Date(dto.starts_at),
|
|
1044
1086
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
1045
|
-
tokens: OfferToken.listFromDto(
|
|
1087
|
+
tokens: OfferToken.listFromDto(tokens)
|
|
1046
1088
|
};
|
|
1047
|
-
|
|
1089
|
+
switch (dto.type) {
|
|
1090
|
+
case "coinlist::token_sale":
|
|
1091
|
+
return {
|
|
1092
|
+
...base2,
|
|
1093
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
1094
|
+
type: dto.type,
|
|
1095
|
+
logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
|
|
1096
|
+
};
|
|
1097
|
+
case "superstate::swap":
|
|
1098
|
+
return {
|
|
1099
|
+
...base2,
|
|
1100
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
1101
|
+
type: dto.type,
|
|
1102
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
1103
|
+
};
|
|
1104
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
1105
|
+
// on the wire: copying them would hand every consumer a `startsAt` that
|
|
1106
|
+
// is 1970 for one variant and a date for the others.
|
|
1107
|
+
case "ondo::swap":
|
|
1108
|
+
return {
|
|
1109
|
+
...base2,
|
|
1110
|
+
type: dto.type,
|
|
1111
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
1112
|
+
};
|
|
1113
|
+
default:
|
|
1114
|
+
return unknownTypeError(dto, "Offer");
|
|
1115
|
+
}
|
|
1116
|
+
},
|
|
1117
|
+
/**
|
|
1118
|
+
* Maps a page of offers, dropping every offer whose `type` this SDK does not
|
|
1119
|
+
* name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
|
|
1120
|
+
* would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
|
|
1121
|
+
* reject the whole page, so one offer of an unknown type would blank the
|
|
1122
|
+
* grid for every offer beside it. A single offer fetched by id still
|
|
1123
|
+
* throws, because there is nothing beside it to keep.
|
|
1124
|
+
*/
|
|
1125
|
+
listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
|
|
1048
1126
|
};
|
|
1049
1127
|
var OfferToken = {
|
|
1050
1128
|
fromDto: (dto) => ({
|
|
@@ -1093,76 +1171,69 @@ var OfferSwapContract = {
|
|
|
1093
1171
|
};
|
|
1094
1172
|
var OfferDetail = {
|
|
1095
1173
|
fromDto: (dto) => {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
if (!Array.isArray(dto.terms)) {
|
|
1107
|
-
throw new ValidationError(
|
|
1108
|
-
`OfferDetail.terms: expected an array, got ${typeof dto.terms}`
|
|
1109
|
-
);
|
|
1110
|
-
}
|
|
1111
|
-
if (!Array.isArray(dto.links)) {
|
|
1112
|
-
throw new ValidationError(
|
|
1113
|
-
`OfferDetail.links: expected an array, got ${typeof dto.links}`
|
|
1114
|
-
);
|
|
1115
|
-
}
|
|
1116
|
-
if (!Array.isArray(dto.faqs)) {
|
|
1117
|
-
throw new ValidationError(
|
|
1118
|
-
`OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
|
|
1119
|
-
);
|
|
1120
|
-
}
|
|
1121
|
-
if (!Array.isArray(dto.milestones)) {
|
|
1122
|
-
throw new ValidationError(
|
|
1123
|
-
`OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
|
|
1124
|
-
);
|
|
1125
|
-
}
|
|
1126
|
-
if (!Array.isArray(dto.tokens)) {
|
|
1127
|
-
throw new ValidationError(
|
|
1128
|
-
`OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
|
|
1129
|
-
);
|
|
1130
|
-
}
|
|
1131
|
-
const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
|
|
1132
|
-
if (!Array.isArray(swapContracts)) {
|
|
1133
|
-
throw new ValidationError(
|
|
1134
|
-
`OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
|
|
1135
|
-
);
|
|
1136
|
-
}
|
|
1174
|
+
const fundingAssets = requiredArray(
|
|
1175
|
+
dto.funding_assets,
|
|
1176
|
+
"OfferDetail.funding_assets"
|
|
1177
|
+
);
|
|
1178
|
+
const options = requiredArray(dto.options, "OfferDetail.options");
|
|
1179
|
+
const terms = requiredArray(dto.terms, "OfferDetail.terms");
|
|
1180
|
+
const links = requiredArray(dto.links, "OfferDetail.links");
|
|
1181
|
+
const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
|
|
1182
|
+
const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
|
|
1183
|
+
const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
|
|
1137
1184
|
const isin = notBlankStringOrNull(dto.isin);
|
|
1138
1185
|
const ticker = notBlankStringOrNull(dto.ticker);
|
|
1139
|
-
|
|
1186
|
+
const base2 = {
|
|
1140
1187
|
id: OfferId(dto.id),
|
|
1141
1188
|
slug: OfferSlug(dto.slug),
|
|
1142
|
-
type: dto.type,
|
|
1143
1189
|
name: dto.name,
|
|
1144
1190
|
asset: Asset.fromDto(dto.asset),
|
|
1145
|
-
fundingAssets:
|
|
1146
|
-
tokens: OfferToken.listFromDto(
|
|
1147
|
-
swapContracts: swapContracts.map(OfferSwapContract.fromDto),
|
|
1191
|
+
fundingAssets: fundingAssets.map(Asset.fromDto),
|
|
1192
|
+
tokens: OfferToken.listFromDto(tokens),
|
|
1148
1193
|
about: notBlankStringOrNull(dto.about),
|
|
1149
|
-
tagline: dto.tagline,
|
|
1150
|
-
bannerUrl: dto.banner_url,
|
|
1151
|
-
logoUrl: dto.logo_url,
|
|
1152
1194
|
category: dto.category,
|
|
1153
1195
|
issuer: notBlankStringOrNull(dto.issuer),
|
|
1154
1196
|
isin: isin === null ? null : Isin(isin),
|
|
1155
1197
|
ticker: ticker === null ? null : Ticker(ticker),
|
|
1156
1198
|
instrumentType: notBlankStringOrNull(dto.instrument_type),
|
|
1157
1199
|
listingVenue: notBlankStringOrNull(dto.listing_venue),
|
|
1158
|
-
startsAt: new Date(dto.starts_at),
|
|
1159
1200
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
1160
|
-
faqs:
|
|
1161
|
-
links:
|
|
1162
|
-
milestones:
|
|
1163
|
-
options:
|
|
1164
|
-
terms:
|
|
1201
|
+
faqs: faqs.map(FaqItem.fromDto),
|
|
1202
|
+
links: links.map(Link.fromDto),
|
|
1203
|
+
milestones: milestones.map(Milestone.fromDto),
|
|
1204
|
+
options: options.map(OfferOption.fromDto),
|
|
1205
|
+
terms: terms.map(TermItem.fromDto)
|
|
1165
1206
|
};
|
|
1207
|
+
switch (dto.type) {
|
|
1208
|
+
case "coinlist::token_sale":
|
|
1209
|
+
return {
|
|
1210
|
+
...base2,
|
|
1211
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
1212
|
+
type: dto.type,
|
|
1213
|
+
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
|
|
1214
|
+
};
|
|
1215
|
+
case "superstate::swap":
|
|
1216
|
+
return {
|
|
1217
|
+
...base2,
|
|
1218
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
1219
|
+
type: dto.type,
|
|
1220
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
1221
|
+
};
|
|
1222
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
1223
|
+
// on the wire, as in `Offer.fromDto`.
|
|
1224
|
+
case "ondo::swap":
|
|
1225
|
+
return {
|
|
1226
|
+
...base2,
|
|
1227
|
+
type: dto.type,
|
|
1228
|
+
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
1229
|
+
swapContracts: requiredArray(
|
|
1230
|
+
dto.swap_contracts,
|
|
1231
|
+
"OfferDetail.swap_contracts"
|
|
1232
|
+
).map(OfferSwapContract.fromDto)
|
|
1233
|
+
};
|
|
1234
|
+
default:
|
|
1235
|
+
return unknownTypeError(dto, "OfferDetail");
|
|
1236
|
+
}
|
|
1166
1237
|
}
|
|
1167
1238
|
};
|
|
1168
1239
|
var OfferOption = {
|
|
@@ -1206,8 +1277,15 @@ var Milestone = {
|
|
|
1206
1277
|
// src/universal/types/pagination.ts
|
|
1207
1278
|
var Cursor = (value) => value;
|
|
1208
1279
|
var PaginatedResponse = {
|
|
1209
|
-
fromDto: (dto, itemMapper) => (
|
|
1210
|
-
|
|
1280
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
1281
|
+
/**
|
|
1282
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
1283
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1284
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
1285
|
+
* page holds, not where the next page starts.
|
|
1286
|
+
*/
|
|
1287
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
1288
|
+
data: pageMapper(dto.data),
|
|
1211
1289
|
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
1212
1290
|
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
1213
1291
|
})
|
|
@@ -1243,7 +1321,7 @@ async function fetchOffersPage(api, params, clientCreds) {
|
|
|
1243
1321
|
Attributes.clientCredentials(clientCreds)
|
|
1244
1322
|
)
|
|
1245
1323
|
});
|
|
1246
|
-
return PaginatedResponse.
|
|
1324
|
+
return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
|
|
1247
1325
|
}
|
|
1248
1326
|
async function fetchOfferDetails(api, id, clientCreds) {
|
|
1249
1327
|
const dto = await api.send({
|