@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
|
@@ -1216,16 +1216,51 @@ type InternalDebugEvent = {
|
|
|
1216
1216
|
* handling it becomes a compile error.
|
|
1217
1217
|
*/
|
|
1218
1218
|
type OfferTypeDto = 'coinlist::token_sale' | 'superstate::swap' | 'ondo::swap';
|
|
1219
|
-
|
|
1219
|
+
/**
|
|
1220
|
+
* One variant per {@link OfferTypeDto}, mirroring frontline#1365, which keys
|
|
1221
|
+
* `GET /v1/offers` on `type`. Read `type` first: it decides which of the
|
|
1222
|
+
* fields below mean anything.
|
|
1223
|
+
*/
|
|
1224
|
+
type OfferDto = CoinListTokenSaleOfferDto | SuperstateSwapOfferDto | OndoSwapOfferDto;
|
|
1225
|
+
type OfferBaseDto = {
|
|
1220
1226
|
id: string;
|
|
1221
1227
|
slug: string;
|
|
1222
|
-
|
|
1228
|
+
ends_at: string | null;
|
|
1229
|
+
tokens: OfferTokenDto[];
|
|
1230
|
+
};
|
|
1231
|
+
/**
|
|
1232
|
+
* A curated sale window and the hand-authored copy that goes with it. Required
|
|
1233
|
+
* on every variant that runs such a campaign, which is every one but Ondo.
|
|
1234
|
+
*/
|
|
1235
|
+
type OfferEditorialDto = {
|
|
1223
1236
|
tagline: string;
|
|
1224
1237
|
banner_url: string;
|
|
1225
|
-
logo_url: string;
|
|
1226
1238
|
starts_at: string;
|
|
1227
|
-
|
|
1228
|
-
|
|
1239
|
+
};
|
|
1240
|
+
/**
|
|
1241
|
+
* What an Ondo swap sends in place of {@link OfferEditorialDto}. It trades
|
|
1242
|
+
* continuously and runs no campaign, so the keys arrive as `null` and carry
|
|
1243
|
+
* nothing. Declared so a fixture can describe the real payload; no `fromDto`
|
|
1244
|
+
* reads them.
|
|
1245
|
+
*/
|
|
1246
|
+
type OfferNoEditorialDto = {
|
|
1247
|
+
tagline: null;
|
|
1248
|
+
banner_url: null;
|
|
1249
|
+
starts_at: null;
|
|
1250
|
+
};
|
|
1251
|
+
type CoinListTokenSaleOfferDto = OfferBaseDto & OfferEditorialDto & {
|
|
1252
|
+
type: 'coinlist::token_sale';
|
|
1253
|
+
logo_url: string;
|
|
1254
|
+
};
|
|
1255
|
+
type SuperstateSwapOfferDto = OfferBaseDto & OfferEditorialDto & {
|
|
1256
|
+
type: 'superstate::swap';
|
|
1257
|
+
/** Publishing a swap does not require anyone to upload artwork for it. */
|
|
1258
|
+
logo_url: string | null;
|
|
1259
|
+
};
|
|
1260
|
+
type OndoSwapOfferDto = OfferBaseDto & OfferNoEditorialDto & {
|
|
1261
|
+
type: 'ondo::swap';
|
|
1262
|
+
/** Publishing a swap does not require anyone to upload artwork for it. */
|
|
1263
|
+
logo_url: string | null;
|
|
1229
1264
|
};
|
|
1230
1265
|
type OfferTokenDto = {
|
|
1231
1266
|
role: 'funding' | 'distribution' | 'swap';
|
|
@@ -1238,19 +1273,62 @@ declare const OfferId: (value: string) => OfferId;
|
|
|
1238
1273
|
type OfferSlug = Newtype<string, 'OfferSlug'>;
|
|
1239
1274
|
declare const OfferSlug: (value: string) => OfferSlug;
|
|
1240
1275
|
type OfferType = OfferTypeDto;
|
|
1241
|
-
|
|
1276
|
+
declare const isOfferType: (value: string) => value is OfferType;
|
|
1277
|
+
type OfferBase = {
|
|
1242
1278
|
id: OfferId;
|
|
1243
1279
|
slug: OfferSlug;
|
|
1244
|
-
|
|
1280
|
+
endsAt: Date | null;
|
|
1281
|
+
tokens: OfferToken[];
|
|
1282
|
+
};
|
|
1283
|
+
type CoinListTokenSaleOffer = OfferBase & OfferEditorial & {
|
|
1284
|
+
type: 'coinlist::token_sale';
|
|
1285
|
+
logoUrl: string;
|
|
1286
|
+
};
|
|
1287
|
+
type SuperstateSwapOffer = OfferBase & OfferEditorial & {
|
|
1288
|
+
type: 'superstate::swap';
|
|
1289
|
+
/** Null when nobody has uploaded artwork: a swap publishes without it. */
|
|
1290
|
+
logoUrl: string | null;
|
|
1291
|
+
};
|
|
1292
|
+
type OndoSwapOffer = OfferBase & {
|
|
1293
|
+
type: 'ondo::swap';
|
|
1294
|
+
/** Null when nobody has uploaded artwork: a swap publishes without it. */
|
|
1295
|
+
logoUrl: string | null;
|
|
1296
|
+
};
|
|
1297
|
+
/**
|
|
1298
|
+
* A curated sale window and the hand-authored copy that goes with it. Every
|
|
1299
|
+
* variant that runs such a campaign carries all three, validated; an Ondo swap
|
|
1300
|
+
* trades continuously, runs none, and carries none.
|
|
1301
|
+
*/
|
|
1302
|
+
type OfferEditorial = {
|
|
1245
1303
|
tagline: string;
|
|
1246
1304
|
bannerUrl: string;
|
|
1247
|
-
logoUrl: string;
|
|
1248
1305
|
startsAt: Date;
|
|
1249
|
-
endsAt: Date | null;
|
|
1250
|
-
tokens: OfferToken[];
|
|
1251
1306
|
};
|
|
1307
|
+
declare const OfferEditorial: {
|
|
1308
|
+
/**
|
|
1309
|
+
* `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
|
|
1310
|
+
* the same three checks name the payload that failed them.
|
|
1311
|
+
*/
|
|
1312
|
+
fromDto: (dto: OfferEditorialDto, model: string) => OfferEditorial;
|
|
1313
|
+
};
|
|
1314
|
+
/**
|
|
1315
|
+
* An offer as `GET /v1/offers` lists it: a union on {@link OfferType}, each
|
|
1316
|
+
* variant carrying only the fields that mean something for it. Narrow on
|
|
1317
|
+
* `type` before reading anything beyond {@link OfferBase} - an Ondo swap has
|
|
1318
|
+
* no `startsAt` to read, and the compiler says so.
|
|
1319
|
+
*/
|
|
1320
|
+
type Offer = CoinListTokenSaleOffer | SuperstateSwapOffer | OndoSwapOffer;
|
|
1252
1321
|
declare const Offer: {
|
|
1253
1322
|
fromDto: (dto: OfferDto) => Offer;
|
|
1323
|
+
/**
|
|
1324
|
+
* Maps a page of offers, dropping every offer whose `type` this SDK does not
|
|
1325
|
+
* name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
|
|
1326
|
+
* would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
|
|
1327
|
+
* reject the whole page, so one offer of an unknown type would blank the
|
|
1328
|
+
* grid for every offer beside it. A single offer fetched by id still
|
|
1329
|
+
* throws, because there is nothing beside it to keep.
|
|
1330
|
+
*/
|
|
1331
|
+
listFromDto: (dtos: OfferDto[]) => Offer[];
|
|
1254
1332
|
};
|
|
1255
1333
|
type TokenRole = 'funding' | 'distribution' | 'swap';
|
|
1256
1334
|
type OfferToken = {
|
|
@@ -1295,6 +1373,13 @@ interface PaginatedResponse<T> {
|
|
|
1295
1373
|
}
|
|
1296
1374
|
declare const PaginatedResponse: {
|
|
1297
1375
|
fromDto: <A, B>(dto: PaginatedResponseDto<A>, itemMapper: (item: A) => B) => PaginatedResponse<B>;
|
|
1376
|
+
/**
|
|
1377
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
1378
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1379
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
1380
|
+
* page holds, not where the next page starts.
|
|
1381
|
+
*/
|
|
1382
|
+
fromDtoPage: <A, B>(dto: PaginatedResponseDto<A>, pageMapper: (items: A[]) => B[]) => PaginatedResponse<B>;
|
|
1298
1383
|
};
|
|
1299
1384
|
/**
|
|
1300
1385
|
* Cursor-based pagination input used when requesting paginated API resources.
|
|
@@ -1356,12 +1441,41 @@ type CreateParticipationDto = {
|
|
|
1356
1441
|
approval_transaction_hash: string | null | undefined;
|
|
1357
1442
|
};
|
|
1358
1443
|
|
|
1359
|
-
|
|
1444
|
+
/**
|
|
1445
|
+
* One variant per `OfferTypeDto`, the same split as `OfferDto` with what
|
|
1446
|
+
* `GET /v1/offers/:id` adds on top. Read `type` first.
|
|
1447
|
+
*/
|
|
1448
|
+
type OfferDetailDto = CoinListTokenSaleOfferDetailDto | SuperstateSwapOfferDetailDto | OndoSwapOfferDetailDto;
|
|
1449
|
+
type CoinListTokenSaleOfferDetailDto = OfferDetailBaseDto & OfferEditorialDto & OfferDetailNoSwapContractsDto & {
|
|
1450
|
+
type: 'coinlist::token_sale';
|
|
1451
|
+
logo_url: string;
|
|
1452
|
+
};
|
|
1453
|
+
type SuperstateSwapOfferDetailDto = OfferDetailBaseDto & OfferEditorialDto & OfferDetailNoSwapContractsDto & {
|
|
1454
|
+
type: 'superstate::swap';
|
|
1455
|
+
logo_url: string | null;
|
|
1456
|
+
};
|
|
1457
|
+
type OndoSwapOfferDetailDto = OfferDetailBaseDto & OfferNoEditorialDto & {
|
|
1458
|
+
type: 'ondo::swap';
|
|
1459
|
+
logo_url: string | null;
|
|
1460
|
+
/**
|
|
1461
|
+
* Every chain this offer swaps on, with the contract each settles
|
|
1462
|
+
* through. `[]` is an answer - "swaps nowhere" - and a missing key is not.
|
|
1463
|
+
*/
|
|
1464
|
+
swap_contracts: OfferDetailSwapContractDto[];
|
|
1465
|
+
};
|
|
1466
|
+
/**
|
|
1467
|
+
* An offer that does not settle through a CoinList swap contract sends `[]`
|
|
1468
|
+
* or no key at all, and either way there is nothing to read. Declared so a
|
|
1469
|
+
* fixture can describe the real payload.
|
|
1470
|
+
*/
|
|
1471
|
+
type OfferDetailNoSwapContractsDto = {
|
|
1472
|
+
swap_contracts?: OfferDetailSwapContractDto[];
|
|
1473
|
+
};
|
|
1474
|
+
type OfferDetailBaseDto = {
|
|
1360
1475
|
asset: AssetDto;
|
|
1361
1476
|
faqs: OfferDetailFaqDto[];
|
|
1362
1477
|
funding_assets: AssetDto[];
|
|
1363
1478
|
tokens: OfferTokenDto[];
|
|
1364
|
-
swap_contracts?: OfferDetailSwapContractDto[];
|
|
1365
1479
|
id: string;
|
|
1366
1480
|
links: OfferDetailLinkDto[];
|
|
1367
1481
|
milestones: OfferDetailMilestoneDto[];
|
|
@@ -1369,15 +1483,10 @@ type OfferDetailDto = {
|
|
|
1369
1483
|
object: 'offer_details';
|
|
1370
1484
|
options: OfferDetailOptionDto[];
|
|
1371
1485
|
slug: string;
|
|
1372
|
-
type: OfferTypeDto;
|
|
1373
1486
|
terms: OfferDetailTermDto[];
|
|
1374
1487
|
about: string | null | undefined;
|
|
1375
|
-
banner_url: string;
|
|
1376
1488
|
category: string;
|
|
1377
1489
|
ends_at: string | null;
|
|
1378
|
-
logo_url: string;
|
|
1379
|
-
starts_at: string;
|
|
1380
|
-
tagline: string;
|
|
1381
1490
|
/** Issuer of the *token*, not of the security it tracks. Ondo offers only. */
|
|
1382
1491
|
issuer: string | null;
|
|
1383
1492
|
/** ISO 6166 id of the underlying security. Null when the supplier has none. */
|
|
@@ -1438,42 +1547,33 @@ type Isin = Newtype<string, 'Isin'>;
|
|
|
1438
1547
|
declare const Isin: (value: string) => Isin;
|
|
1439
1548
|
type OrderBookSide = 'buy' | 'sell';
|
|
1440
1549
|
|
|
1441
|
-
type
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
declare const OfferOptionSlug: (value: string) => OfferOptionSlug;
|
|
1445
|
-
/**
|
|
1446
|
-
* A chain an offer can be swapped on, with the CoinList contract the swap
|
|
1447
|
-
* settles through - the spender to approve before any quote exists.
|
|
1448
|
-
*
|
|
1449
|
-
* Carries no role, unlike {@link OfferToken}: there is one swap contract per
|
|
1450
|
-
* chain and it serves every Ondo asset on it, so which token is being traded
|
|
1451
|
-
* does not change the answer.
|
|
1452
|
-
*/
|
|
1453
|
-
type OfferSwapContract = {
|
|
1454
|
-
chain: Chain;
|
|
1455
|
-
address: EvmContractAddress;
|
|
1550
|
+
type CoinListTokenSaleOfferDetail = OfferDetailBase & OfferEditorial & {
|
|
1551
|
+
type: 'coinlist::token_sale';
|
|
1552
|
+
logoUrl: string;
|
|
1456
1553
|
};
|
|
1457
|
-
|
|
1458
|
-
|
|
1554
|
+
type SuperstateSwapOfferDetail = OfferDetailBase & OfferEditorial & {
|
|
1555
|
+
type: 'superstate::swap';
|
|
1556
|
+
/** Null when nobody has uploaded artwork: a swap publishes without it. */
|
|
1557
|
+
logoUrl: string | null;
|
|
1459
1558
|
};
|
|
1460
|
-
type
|
|
1559
|
+
type OndoSwapOfferDetail = OfferDetailBase & {
|
|
1560
|
+
type: 'ondo::swap';
|
|
1561
|
+
/** Null when nobody has uploaded artwork: a swap publishes without it. */
|
|
1562
|
+
logoUrl: string | null;
|
|
1563
|
+
/**
|
|
1564
|
+
* Every chain this offer can be swapped on, with the CoinList contract each
|
|
1565
|
+
* settles through. Empty means it cannot be swapped anywhere.
|
|
1566
|
+
*/
|
|
1567
|
+
swapContracts: OfferSwapContract[];
|
|
1568
|
+
};
|
|
1569
|
+
type OfferDetailBase = {
|
|
1461
1570
|
id: OfferId;
|
|
1462
1571
|
slug: OfferSlug;
|
|
1463
|
-
type: OfferType;
|
|
1464
1572
|
name: string;
|
|
1465
1573
|
asset: Asset;
|
|
1466
1574
|
fundingAssets: Asset[];
|
|
1467
1575
|
tokens: OfferToken[];
|
|
1468
|
-
/**
|
|
1469
|
-
* Every chain this offer can be swapped on, with the CoinList contract each
|
|
1470
|
-
* settles through. Empty means it cannot be swapped anywhere.
|
|
1471
|
-
*/
|
|
1472
|
-
swapContracts: OfferSwapContract[];
|
|
1473
1576
|
about: string | null;
|
|
1474
|
-
tagline: string;
|
|
1475
|
-
bannerUrl: string;
|
|
1476
|
-
logoUrl: string;
|
|
1477
1577
|
category: string;
|
|
1478
1578
|
/**
|
|
1479
1579
|
* The legal issuer of the *token*, e.g. `'Ondo Global Markets'`. The issuer
|
|
@@ -1517,7 +1617,6 @@ type OfferDetail = {
|
|
|
1517
1617
|
* the offer tokenizes a security.
|
|
1518
1618
|
*/
|
|
1519
1619
|
listingVenue: string | null;
|
|
1520
|
-
startsAt: Date;
|
|
1521
1620
|
endsAt: Date | null;
|
|
1522
1621
|
faqs: FaqItem[];
|
|
1523
1622
|
links: Link[];
|
|
@@ -1525,6 +1624,32 @@ type OfferDetail = {
|
|
|
1525
1624
|
options: OfferOption[];
|
|
1526
1625
|
terms: TermItem[];
|
|
1527
1626
|
};
|
|
1627
|
+
type OfferOptionId = Newtype<string, 'OfferOptionId'>;
|
|
1628
|
+
declare const OfferOptionId: (value: string) => OfferOptionId;
|
|
1629
|
+
type OfferOptionSlug = Newtype<string, 'OfferOptionSlug'>;
|
|
1630
|
+
declare const OfferOptionSlug: (value: string) => OfferOptionSlug;
|
|
1631
|
+
/**
|
|
1632
|
+
* A chain an offer can be swapped on, with the CoinList contract the swap
|
|
1633
|
+
* settles through - the spender to approve before any quote exists.
|
|
1634
|
+
*
|
|
1635
|
+
* Carries no role, unlike {@link OfferToken}: there is one swap contract per
|
|
1636
|
+
* chain and it serves every Ondo asset on it, so which token is being traded
|
|
1637
|
+
* does not change the answer.
|
|
1638
|
+
*/
|
|
1639
|
+
type OfferSwapContract = {
|
|
1640
|
+
chain: Chain;
|
|
1641
|
+
address: EvmContractAddress;
|
|
1642
|
+
};
|
|
1643
|
+
declare const OfferSwapContract: {
|
|
1644
|
+
fromDto: (dto: OfferDetailSwapContractDto) => OfferSwapContract;
|
|
1645
|
+
};
|
|
1646
|
+
/**
|
|
1647
|
+
* An offer as `GET /v1/offers/:id` serves it: the same union on `type` as
|
|
1648
|
+
* {@link Offer}, each variant carrying only the fields that mean something
|
|
1649
|
+
* for it. Narrow on `type` before reading anything beyond
|
|
1650
|
+
* {@link OfferDetailBase}.
|
|
1651
|
+
*/
|
|
1652
|
+
type OfferDetail = CoinListTokenSaleOfferDetail | SuperstateSwapOfferDetail | OndoSwapOfferDetail;
|
|
1528
1653
|
declare const OfferDetail: {
|
|
1529
1654
|
fromDto: (dto: OfferDetailDto) => OfferDetail;
|
|
1530
1655
|
};
|
|
@@ -3173,4 +3298,4 @@ declare class TokensNamespaceImpl implements TokensNamespace {
|
|
|
3173
3298
|
list(chain?: EthereumChain): Promise<TokenMetadata[]>;
|
|
3174
3299
|
}
|
|
3175
3300
|
|
|
3176
|
-
export {
|
|
3301
|
+
export { OndoTradingStatus as $, AuthorizationCode as A, BlockchainAmount as B, CodeVerifier as C, TokenMetadata as D, type Erc20Namespace as E, type OfferType as F, type OndoSwapOfferDetail as G, type CoinListTokenSaleOfferDetail as H, type SuperstateSwapOfferDetail as I, Offer as J, RequirementStatusInfo as K, type Logger as L, type RequirementType as M, type RequirementStatusValue as N, OfferId as O, Participation as P, OfferOptionAddress as Q, type RequirementsNamespace as R, type SuperstateSwapNamespace as S, type TokensNamespace as T, type UniversalNamespaceContext as U, RequirementId as V, type WalletError as W, type KycLevelName as X, DocumentSubmission as Y, type WalletChallengeType as Z, type PinoLoggerOptions as _, EthereumChain as a, type GetTokenBalanceParams as a$, AssetDecimals as a0, type BuildOndoBuyParams as a1, type BuildOndoSellParams as a2, OndoQuote as a3, type OndoQuoteSize as a4, type TokenIdentifier as a5, OfferOptionAddressId as a6, TokenLogo as a7, type DebugEvent as a8, type FrontlineEventId as a9, type Newtype as aA, type AllowWalletParams as aB, AllowWalletResponse as aC, Asset as aD, AssetCode as aE, Blockchain as aF, type BuildOndoSwapParamsCore as aG, Chain as aH, ClientId as aI, CodeChallenge as aJ, type CoinListTokenSaleOffer as aK, ConnectExternalWalletParams as aL, type CreateKycTokenParams as aM, CreateParticipationParams as aN, CreateWalletOwnershipChallengeParams as aO, Cursor as aP, type DocumentFormType as aQ, type DocumentSubmissionStatus as aR, type DocumentType as aS, ETHEREUM_CHAINS as aT, Erc20NamespaceImpl as aU, FaqItem as aV, type GetOndoQuoteParams as aW, type GetOndoTradingStatusParams as aX, type GetSwapAuthorizationParams as aY, type GetSwapPreviewParams as aZ, type GetTokenAllowanceParams as a_, HttpError as aa, type HttpResponse as ab, KycToken as ac, type LogBinding as ad, type LogBindings as ae, type LogCause as af, type LogLevel as ag, type LogScope as ah, type LogValue as ai, type ProductionLogLevel as aj, RedactedWalletError as ak, type RequestId as al, type RpcFailureReason as am, type SafeEvent as an, type SafeFields as ao, type UnredactedFields as ap, OAuthSession as aq, ClientCredentialsOAuth as ar, ClientSecret as as, type Sender as at, PaginationParams as au, PaginatedResponse as av, DecimalString as aw, SwapStatus as ax, type Uint256 as ay, KnownAssetSymbol as az, EvmContractAddress as b, HexEncodedTransactionData as b0, Isin as b1, Iso2CountryCode as b2, Link as b3, type ListOptionAddressesParams as b4, MAX_ASSET_DECIMALS as b5, MAX_UINT_256 as b6, Milestone as b7, OAuthRefreshToken as b8, type OfferBase as b9, SOLANA_CHAINS as bA, STABLE_DECIMALS as bB, SolanaChain as bC, type SubmitDocumentParams as bD, type SuperstateSwapOffer as bE, type SwapContractRef as bF, SwapPreview as bG, TermItem as bH, Ticker as bI, type TokenLogoImage as bJ, TokenLogoUrl as bK, type TokenRole as bL, TokensNamespaceImpl as bM, type Tx as bN, WalletAddress as bO, WalletOwnershipChallenge as bP, type WalletProtocol as bQ, WalletsNamespaceImpl as bR, apiErrorCode as bS, assertUint256 as bT, isChain as bU, isOfferType as bV, parseUint256 as bW, type OfferDetailBase as ba, OfferEditorial as bb, OfferOption as bc, OfferOptionSlug as bd, OfferSlug as be, OfferToken as bf, OffersNamespaceImpl as bg, type OndoQuoteDuration as bh, type OndoSellOutcome as bi, type OndoSwapOffer as bj, PKCEState as bk, type PaginatedResponseDto as bl, ParticipationId as bm, type ParticipationStatus as bn, ParticipationsPaginationParams as bo, PauseFlags as bp, Pii as bq, PiiAddress as br, PiiJurisdiction as bs, type PiiKind as bt, type QueryParamValue as bu, type QueryParamValues as bv, RedirectUri as bw, type RemoveOptionAddressParams as bx, type RequirementActionNeededReason as by, type RpcConfig as bz, type CoinListTokenSaleNamespace as c, OfferOptionId as d, AssetId as e, CoinListTokenSaleNamespaceImpl as f, type OndoNamespace as g, AssetSymbol as h, OfferSwapContract as i, OndoBuyTransaction as j, OndoSellTransaction as k, type OndoSwapTransactionCore as l, type OrderBookSide as m, OndoNamespaceImpl as n, type WalletsNamespace as o, Bps as p, EvmWalletAddress as q, SuperstateSwapNamespaceImpl as r, Requirement as s, RequirementsNamespaceImpl as t, type Config as u, type OAuthAccessToken as v, type OffersNamespace as w, StablecoinSymbol as x, type Erc20Asset as y, OfferDetail as z };
|
package/dist/universal/index.cjs
CHANGED
|
@@ -82,6 +82,7 @@ __export(universal_exports, {
|
|
|
82
82
|
ONDO_SUPPORTED_INPUT_ASSETS: () => ONDO_SUPPORTED_INPUT_ASSETS,
|
|
83
83
|
Offer: () => Offer,
|
|
84
84
|
OfferDetail: () => OfferDetail,
|
|
85
|
+
OfferEditorial: () => OfferEditorial,
|
|
85
86
|
OfferId: () => OfferId,
|
|
86
87
|
OfferOption: () => OfferOption,
|
|
87
88
|
OfferOptionAddress: () => OfferOptionAddress,
|
|
@@ -170,6 +171,7 @@ __export(universal_exports, {
|
|
|
170
171
|
getChainId: () => getChainId,
|
|
171
172
|
getNetworkName: () => getNetworkName,
|
|
172
173
|
isChain: () => isChain,
|
|
174
|
+
isOfferType: () => isOfferType,
|
|
173
175
|
isSwapAvailable: () => isSwapAvailable,
|
|
174
176
|
parseBlockchainAmount: () => parseBlockchainAmount,
|
|
175
177
|
parseUint256: () => parseUint256,
|
|
@@ -428,8 +430,15 @@ async function generatePKCEParams(config) {
|
|
|
428
430
|
// src/universal/types/pagination.ts
|
|
429
431
|
var Cursor = (value) => value;
|
|
430
432
|
var PaginatedResponse = {
|
|
431
|
-
fromDto: (dto, itemMapper) => (
|
|
432
|
-
|
|
433
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
434
|
+
/**
|
|
435
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
436
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
437
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
438
|
+
* page holds, not where the next page starts.
|
|
439
|
+
*/
|
|
440
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
441
|
+
data: pageMapper(dto.data),
|
|
433
442
|
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
434
443
|
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
435
444
|
})
|
|
@@ -494,6 +503,40 @@ var MathError = class extends Error {
|
|
|
494
503
|
}
|
|
495
504
|
};
|
|
496
505
|
|
|
506
|
+
// src/universal/core/shared/utils/wire.ts
|
|
507
|
+
function unknownTypeError(dto, model) {
|
|
508
|
+
const type = dto.type;
|
|
509
|
+
throw new ValidationError(
|
|
510
|
+
`${model}.type: unknown type ${JSON.stringify(type)}`
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
function requiredString(value, field) {
|
|
514
|
+
const text = notBlankStringOrNull(value);
|
|
515
|
+
if (text === null) {
|
|
516
|
+
throw new ValidationError(
|
|
517
|
+
`${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
return text;
|
|
521
|
+
}
|
|
522
|
+
function requiredDate(value, field) {
|
|
523
|
+
const date = typeof value === "string" ? new Date(value) : null;
|
|
524
|
+
if (date === null || Number.isNaN(date.getTime())) {
|
|
525
|
+
throw new ValidationError(
|
|
526
|
+
`${field}: expected a date, got ${JSON.stringify(value)}`
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
return date;
|
|
530
|
+
}
|
|
531
|
+
function requiredArray(value, field) {
|
|
532
|
+
if (!Array.isArray(value)) {
|
|
533
|
+
throw new ValidationError(
|
|
534
|
+
`${field}: expected an array, got ${typeof value}`
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
return value;
|
|
538
|
+
}
|
|
539
|
+
|
|
497
540
|
// src/universal/types/blockchain/core.ts
|
|
498
541
|
var ETHEREUM_CHAINS = {
|
|
499
542
|
ethereum_mainnet: true,
|
|
@@ -594,25 +637,69 @@ var Bps = (value) => value;
|
|
|
594
637
|
// src/universal/types/offer.ts
|
|
595
638
|
var OfferId = (value) => value;
|
|
596
639
|
var OfferSlug = (value) => value;
|
|
640
|
+
var OFFER_TYPES = {
|
|
641
|
+
"coinlist::token_sale": true,
|
|
642
|
+
"superstate::swap": true,
|
|
643
|
+
"ondo::swap": true
|
|
644
|
+
};
|
|
645
|
+
var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
|
|
646
|
+
var OfferEditorial = {
|
|
647
|
+
/**
|
|
648
|
+
* `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
|
|
649
|
+
* the same three checks name the payload that failed them.
|
|
650
|
+
*/
|
|
651
|
+
fromDto: (dto, model) => ({
|
|
652
|
+
tagline: requiredString(dto.tagline, `${model}.tagline`),
|
|
653
|
+
bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
|
|
654
|
+
startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
|
|
655
|
+
})
|
|
656
|
+
};
|
|
597
657
|
var Offer = {
|
|
598
658
|
fromDto: (dto) => {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
`Offer.tokens: expected an array, got ${typeof dto.tokens}`
|
|
602
|
-
);
|
|
603
|
-
}
|
|
604
|
-
return {
|
|
659
|
+
const tokens = requiredArray(dto.tokens, "Offer.tokens");
|
|
660
|
+
const base2 = {
|
|
605
661
|
id: OfferId(dto.id),
|
|
606
662
|
slug: OfferSlug(dto.slug),
|
|
607
|
-
type: dto.type,
|
|
608
|
-
tagline: dto.tagline,
|
|
609
|
-
bannerUrl: dto.banner_url,
|
|
610
|
-
logoUrl: dto.logo_url,
|
|
611
|
-
startsAt: new Date(dto.starts_at),
|
|
612
663
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
613
|
-
tokens: OfferToken.listFromDto(
|
|
664
|
+
tokens: OfferToken.listFromDto(tokens)
|
|
614
665
|
};
|
|
615
|
-
|
|
666
|
+
switch (dto.type) {
|
|
667
|
+
case "coinlist::token_sale":
|
|
668
|
+
return {
|
|
669
|
+
...base2,
|
|
670
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
671
|
+
type: dto.type,
|
|
672
|
+
logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
|
|
673
|
+
};
|
|
674
|
+
case "superstate::swap":
|
|
675
|
+
return {
|
|
676
|
+
...base2,
|
|
677
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
678
|
+
type: dto.type,
|
|
679
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
680
|
+
};
|
|
681
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
682
|
+
// on the wire: copying them would hand every consumer a `startsAt` that
|
|
683
|
+
// is 1970 for one variant and a date for the others.
|
|
684
|
+
case "ondo::swap":
|
|
685
|
+
return {
|
|
686
|
+
...base2,
|
|
687
|
+
type: dto.type,
|
|
688
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
689
|
+
};
|
|
690
|
+
default:
|
|
691
|
+
return unknownTypeError(dto, "Offer");
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
/**
|
|
695
|
+
* Maps a page of offers, dropping every offer whose `type` this SDK does not
|
|
696
|
+
* name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
|
|
697
|
+
* would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
|
|
698
|
+
* reject the whole page, so one offer of an unknown type would blank the
|
|
699
|
+
* grid for every offer beside it. A single offer fetched by id still
|
|
700
|
+
* throws, because there is nothing beside it to keep.
|
|
701
|
+
*/
|
|
702
|
+
listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
|
|
616
703
|
};
|
|
617
704
|
var OfferToken = {
|
|
618
705
|
fromDto: (dto) => ({
|
|
@@ -649,76 +736,69 @@ var OfferSwapContract = {
|
|
|
649
736
|
};
|
|
650
737
|
var OfferDetail = {
|
|
651
738
|
fromDto: (dto) => {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
if (!Array.isArray(dto.terms)) {
|
|
663
|
-
throw new ValidationError(
|
|
664
|
-
`OfferDetail.terms: expected an array, got ${typeof dto.terms}`
|
|
665
|
-
);
|
|
666
|
-
}
|
|
667
|
-
if (!Array.isArray(dto.links)) {
|
|
668
|
-
throw new ValidationError(
|
|
669
|
-
`OfferDetail.links: expected an array, got ${typeof dto.links}`
|
|
670
|
-
);
|
|
671
|
-
}
|
|
672
|
-
if (!Array.isArray(dto.faqs)) {
|
|
673
|
-
throw new ValidationError(
|
|
674
|
-
`OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
|
|
675
|
-
);
|
|
676
|
-
}
|
|
677
|
-
if (!Array.isArray(dto.milestones)) {
|
|
678
|
-
throw new ValidationError(
|
|
679
|
-
`OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
if (!Array.isArray(dto.tokens)) {
|
|
683
|
-
throw new ValidationError(
|
|
684
|
-
`OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
|
|
685
|
-
);
|
|
686
|
-
}
|
|
687
|
-
const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
|
|
688
|
-
if (!Array.isArray(swapContracts)) {
|
|
689
|
-
throw new ValidationError(
|
|
690
|
-
`OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
|
|
691
|
-
);
|
|
692
|
-
}
|
|
739
|
+
const fundingAssets = requiredArray(
|
|
740
|
+
dto.funding_assets,
|
|
741
|
+
"OfferDetail.funding_assets"
|
|
742
|
+
);
|
|
743
|
+
const options = requiredArray(dto.options, "OfferDetail.options");
|
|
744
|
+
const terms = requiredArray(dto.terms, "OfferDetail.terms");
|
|
745
|
+
const links = requiredArray(dto.links, "OfferDetail.links");
|
|
746
|
+
const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
|
|
747
|
+
const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
|
|
748
|
+
const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
|
|
693
749
|
const isin = notBlankStringOrNull(dto.isin);
|
|
694
750
|
const ticker = notBlankStringOrNull(dto.ticker);
|
|
695
|
-
|
|
751
|
+
const base2 = {
|
|
696
752
|
id: OfferId(dto.id),
|
|
697
753
|
slug: OfferSlug(dto.slug),
|
|
698
|
-
type: dto.type,
|
|
699
754
|
name: dto.name,
|
|
700
755
|
asset: Asset.fromDto(dto.asset),
|
|
701
|
-
fundingAssets:
|
|
702
|
-
tokens: OfferToken.listFromDto(
|
|
703
|
-
swapContracts: swapContracts.map(OfferSwapContract.fromDto),
|
|
756
|
+
fundingAssets: fundingAssets.map(Asset.fromDto),
|
|
757
|
+
tokens: OfferToken.listFromDto(tokens),
|
|
704
758
|
about: notBlankStringOrNull(dto.about),
|
|
705
|
-
tagline: dto.tagline,
|
|
706
|
-
bannerUrl: dto.banner_url,
|
|
707
|
-
logoUrl: dto.logo_url,
|
|
708
759
|
category: dto.category,
|
|
709
760
|
issuer: notBlankStringOrNull(dto.issuer),
|
|
710
761
|
isin: isin === null ? null : Isin(isin),
|
|
711
762
|
ticker: ticker === null ? null : Ticker(ticker),
|
|
712
763
|
instrumentType: notBlankStringOrNull(dto.instrument_type),
|
|
713
764
|
listingVenue: notBlankStringOrNull(dto.listing_venue),
|
|
714
|
-
startsAt: new Date(dto.starts_at),
|
|
715
765
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
716
|
-
faqs:
|
|
717
|
-
links:
|
|
718
|
-
milestones:
|
|
719
|
-
options:
|
|
720
|
-
terms:
|
|
766
|
+
faqs: faqs.map(FaqItem.fromDto),
|
|
767
|
+
links: links.map(Link.fromDto),
|
|
768
|
+
milestones: milestones.map(Milestone.fromDto),
|
|
769
|
+
options: options.map(OfferOption.fromDto),
|
|
770
|
+
terms: terms.map(TermItem.fromDto)
|
|
721
771
|
};
|
|
772
|
+
switch (dto.type) {
|
|
773
|
+
case "coinlist::token_sale":
|
|
774
|
+
return {
|
|
775
|
+
...base2,
|
|
776
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
777
|
+
type: dto.type,
|
|
778
|
+
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
|
|
779
|
+
};
|
|
780
|
+
case "superstate::swap":
|
|
781
|
+
return {
|
|
782
|
+
...base2,
|
|
783
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
784
|
+
type: dto.type,
|
|
785
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
786
|
+
};
|
|
787
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
788
|
+
// on the wire, as in `Offer.fromDto`.
|
|
789
|
+
case "ondo::swap":
|
|
790
|
+
return {
|
|
791
|
+
...base2,
|
|
792
|
+
type: dto.type,
|
|
793
|
+
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
794
|
+
swapContracts: requiredArray(
|
|
795
|
+
dto.swap_contracts,
|
|
796
|
+
"OfferDetail.swap_contracts"
|
|
797
|
+
).map(OfferSwapContract.fromDto)
|
|
798
|
+
};
|
|
799
|
+
default:
|
|
800
|
+
return unknownTypeError(dto, "OfferDetail");
|
|
801
|
+
}
|
|
722
802
|
}
|
|
723
803
|
};
|
|
724
804
|
var OfferOption = {
|
|
@@ -2930,7 +3010,7 @@ async function fetchOffersPage(api, params, clientCreds) {
|
|
|
2930
3010
|
Attributes.clientCredentials(clientCreds)
|
|
2931
3011
|
)
|
|
2932
3012
|
});
|
|
2933
|
-
return PaginatedResponse.
|
|
3013
|
+
return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
|
|
2934
3014
|
}
|
|
2935
3015
|
async function fetchOfferDetails(api, id, clientCreds) {
|
|
2936
3016
|
const dto = await api.send({
|
|
@@ -3790,6 +3870,7 @@ var User = {
|
|
|
3790
3870
|
ONDO_SUPPORTED_INPUT_ASSETS,
|
|
3791
3871
|
Offer,
|
|
3792
3872
|
OfferDetail,
|
|
3873
|
+
OfferEditorial,
|
|
3793
3874
|
OfferId,
|
|
3794
3875
|
OfferOption,
|
|
3795
3876
|
OfferOptionAddress,
|
|
@@ -3878,6 +3959,7 @@ var User = {
|
|
|
3878
3959
|
getChainId,
|
|
3879
3960
|
getNetworkName,
|
|
3880
3961
|
isChain,
|
|
3962
|
+
isOfferType,
|
|
3881
3963
|
isSwapAvailable,
|
|
3882
3964
|
parseBlockchainAmount,
|
|
3883
3965
|
parseUint256,
|