@coinlist-co/react 0.12.1 → 0.12.2-rc.0ff2d03
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/README.md +10 -0
- package/dist/chunk-MJ6YXZWH.js +22 -0
- package/dist/chunk-MJ6YXZWH.js.map +1 -0
- package/dist/{chunk-VH34YC3Q.js → chunk-PWGUKS4Q.js} +199 -186
- package/dist/chunk-PWGUKS4Q.js.map +1 -0
- package/dist/{chunk-DCW7NQXH.js → chunk-QTBEDN7C.js} +52 -19
- package/dist/chunk-QTBEDN7C.js.map +1 -0
- package/dist/{chunk-MOE5S6CE.js → chunk-SVPFFLIT.js} +1314 -796
- package/dist/chunk-SVPFFLIT.js.map +1 -0
- package/dist/client/index.d.ts +3332 -4554
- package/dist/client/index.js +7374 -4387
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.d.ts +69 -71
- package/dist/server/index.js +327 -67
- package/dist/server/index.js.map +1 -1
- package/dist/{tokens-namespace-CIWBtgt2.d.cts → time-BDzqB806.d.ts} +1901 -2491
- package/dist/{token-registry-snapshot-CqI6dXM_.d.cts → token-registry-snapshot-cvLsnMo_.d.ts} +74 -42
- package/dist/universal/index.d.ts +100 -1001
- package/dist/universal/index.js +52 -36
- package/package.json +18 -14
- package/dist/chunk-DCW7NQXH.js.map +0 -1
- package/dist/chunk-MOE5S6CE.js.map +0 -1
- package/dist/chunk-VH34YC3Q.js.map +0 -1
- package/dist/client/index.cjs +0 -16840
- package/dist/client/index.cjs.map +0 -1
- package/dist/client/index.d.cts +0 -6592
- package/dist/server/index.cjs +0 -3878
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.cts +0 -354
- package/dist/token-registry-snapshot-BNBNuDu1.d.ts +0 -179
- package/dist/tokens-namespace-CIWBtgt2.d.ts +0 -3301
- package/dist/universal/index.cjs +0 -4028
- package/dist/universal/index.cjs.map +0 -1
- package/dist/universal/index.d.cts +0 -1276
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
// src/universal/api/internal-access-token-source.ts
|
|
2
|
+
var SentWith = {
|
|
3
|
+
userToken: (token) => ({
|
|
4
|
+
type: "user-token",
|
|
5
|
+
token
|
|
6
|
+
}),
|
|
7
|
+
noUserToken: { type: "no-user-token" }
|
|
8
|
+
};
|
|
9
|
+
var TokenTrigger = {
|
|
10
|
+
beforeRequest: { type: "before-request" },
|
|
11
|
+
after401: (rejected) => ({
|
|
12
|
+
type: "after-401",
|
|
13
|
+
rejected
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
function isRejectedToken(token, rejected) {
|
|
17
|
+
switch (rejected.type) {
|
|
18
|
+
case "user-token":
|
|
19
|
+
return rejected.token.value === token.value;
|
|
20
|
+
case "no-user-token":
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
1
25
|
// src/universal/api/http-attributes.ts
|
|
2
26
|
var empty = {};
|
|
3
27
|
var concat = (left, right) => ({
|
|
@@ -25,6 +49,10 @@ var retryAttempt = (attempt) => ({
|
|
|
25
49
|
var renewAttempted = (value) => ({
|
|
26
50
|
renewAttempted: value
|
|
27
51
|
});
|
|
52
|
+
var notRetryable = () => ({ retryable: false });
|
|
53
|
+
var sentWith = (token) => ({
|
|
54
|
+
sentWith: token
|
|
55
|
+
});
|
|
28
56
|
var requestId = (id) => ({ requestId: id });
|
|
29
57
|
var getRequestId = (attrs) => attrs?.requestId ?? null;
|
|
30
58
|
var isProtected = (attrs) => attrs?.protected === true;
|
|
@@ -32,6 +60,8 @@ var needUserAgent = (attrs) => attrs?.userAgent === true;
|
|
|
32
60
|
var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
|
|
33
61
|
var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
|
|
34
62
|
var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
|
|
63
|
+
var isRetryable = (attrs) => attrs?.retryable !== false;
|
|
64
|
+
var getSentWith = (attrs) => attrs?.sentWith === void 0 ? SentWith.noUserToken : SentWith.userToken(attrs.sentWith);
|
|
35
65
|
var getClientCredentials = (attrs) => attrs?.clientCredentials;
|
|
36
66
|
var Attributes = {
|
|
37
67
|
empty,
|
|
@@ -47,6 +77,10 @@ var Attributes = {
|
|
|
47
77
|
getRetryAttempt,
|
|
48
78
|
renewAttempted,
|
|
49
79
|
wasRenewAttempted,
|
|
80
|
+
notRetryable,
|
|
81
|
+
isRetryable,
|
|
82
|
+
sentWith,
|
|
83
|
+
getSentWith,
|
|
50
84
|
clientCredentials,
|
|
51
85
|
getClientCredentials,
|
|
52
86
|
requestId,
|
|
@@ -209,165 +243,53 @@ var MathError = class extends Error {
|
|
|
209
243
|
}
|
|
210
244
|
};
|
|
211
245
|
|
|
212
|
-
// src/universal/
|
|
213
|
-
var
|
|
214
|
-
|
|
215
|
-
type: "function",
|
|
216
|
-
name: "allowance",
|
|
217
|
-
inputs: [
|
|
218
|
-
{ name: "owner", type: "address" },
|
|
219
|
-
{ name: "spender", type: "address" }
|
|
220
|
-
],
|
|
221
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
222
|
-
stateMutability: "view"
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
type: "function",
|
|
226
|
-
name: "approve",
|
|
227
|
-
inputs: [
|
|
228
|
-
{ name: "spender", type: "address" },
|
|
229
|
-
{ name: "amount", type: "uint256" }
|
|
230
|
-
],
|
|
231
|
-
outputs: [{ name: "", type: "bool" }],
|
|
232
|
-
stateMutability: "nonpayable"
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
type: "function",
|
|
236
|
-
name: "balanceOf",
|
|
237
|
-
inputs: [{ name: "account", type: "address" }],
|
|
238
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
239
|
-
stateMutability: "view"
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
type: "function",
|
|
243
|
-
name: "decimals",
|
|
244
|
-
inputs: [],
|
|
245
|
-
outputs: [{ name: "", type: "uint8" }],
|
|
246
|
-
stateMutability: "view"
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
type: "function",
|
|
250
|
-
name: "name",
|
|
251
|
-
inputs: [],
|
|
252
|
-
outputs: [{ name: "", type: "string" }],
|
|
253
|
-
stateMutability: "view"
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
type: "function",
|
|
257
|
-
name: "symbol",
|
|
258
|
-
inputs: [],
|
|
259
|
-
outputs: [{ name: "", type: "string" }],
|
|
260
|
-
stateMutability: "view"
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
type: "function",
|
|
264
|
-
name: "totalSupply",
|
|
265
|
-
inputs: [],
|
|
266
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
267
|
-
stateMutability: "view"
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
type: "function",
|
|
271
|
-
name: "transfer",
|
|
272
|
-
inputs: [
|
|
273
|
-
{ name: "recipient", type: "address" },
|
|
274
|
-
{ name: "amount", type: "uint256" }
|
|
275
|
-
],
|
|
276
|
-
outputs: [{ name: "", type: "bool" }],
|
|
277
|
-
stateMutability: "nonpayable"
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
type: "function",
|
|
281
|
-
name: "transferFrom",
|
|
282
|
-
inputs: [
|
|
283
|
-
{ name: "sender", type: "address" },
|
|
284
|
-
{ name: "recipient", type: "address" },
|
|
285
|
-
{ name: "amount", type: "uint256" }
|
|
286
|
-
],
|
|
287
|
-
outputs: [{ name: "", type: "bool" }],
|
|
288
|
-
stateMutability: "nonpayable"
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
type: "event",
|
|
292
|
-
name: "Approval",
|
|
293
|
-
inputs: [
|
|
294
|
-
{ name: "owner", type: "address", indexed: true },
|
|
295
|
-
{ name: "spender", type: "address", indexed: true },
|
|
296
|
-
{ name: "value", type: "uint256", indexed: false }
|
|
297
|
-
],
|
|
298
|
-
anonymous: false
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
type: "event",
|
|
302
|
-
name: "Transfer",
|
|
303
|
-
inputs: [
|
|
304
|
-
{ name: "from", type: "address", indexed: true },
|
|
305
|
-
{ name: "to", type: "address", indexed: true },
|
|
306
|
-
{ name: "value", type: "uint256", indexed: false }
|
|
307
|
-
],
|
|
308
|
-
anonymous: false
|
|
309
|
-
}
|
|
310
|
-
];
|
|
311
|
-
|
|
312
|
-
// src/universal/api/pagination.ts
|
|
313
|
-
async function fetchAllPages(fetchPage, baseParams) {
|
|
314
|
-
const items = [];
|
|
315
|
-
let cursor = null;
|
|
316
|
-
do {
|
|
317
|
-
const params = {
|
|
318
|
-
...baseParams ?? {},
|
|
319
|
-
after: cursor ?? void 0
|
|
320
|
-
};
|
|
321
|
-
const page = await fetchPage(params);
|
|
322
|
-
items.push(...page.data);
|
|
323
|
-
cursor = page.startingAfter;
|
|
324
|
-
} while (cursor);
|
|
325
|
-
return items;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// src/universal/types/pagination.ts
|
|
329
|
-
var Cursor = (value) => value;
|
|
330
|
-
var PaginatedResponse = {
|
|
331
|
-
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
246
|
+
// src/universal/types/time.ts
|
|
247
|
+
var MAX_EPOCH_MILLIS = 864e13;
|
|
248
|
+
var EpochMillis = {
|
|
332
249
|
/**
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
* cursors are the wire's either way: dropping an item changes what the
|
|
336
|
-
* page holds, not where the next page starts.
|
|
250
|
+
* @throws {@link ValidationError} unless `value` is an integer a `Date` can
|
|
251
|
+
* represent: at most {@link MAX_EPOCH_MILLIS} either side of the epoch.
|
|
337
252
|
*/
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
};
|
|
344
|
-
var PaginationParams = {
|
|
345
|
-
toQueryParams: (params) => {
|
|
346
|
-
const queryParams = {};
|
|
347
|
-
if (params.after) {
|
|
348
|
-
queryParams.starting_after = params.after;
|
|
349
|
-
}
|
|
350
|
-
if (params.before) {
|
|
351
|
-
queryParams.starting_before = params.before;
|
|
352
|
-
}
|
|
353
|
-
if (params.limit) {
|
|
354
|
-
queryParams.limit = params.limit;
|
|
253
|
+
of: (value) => {
|
|
254
|
+
if (!Number.isInteger(value) || Math.abs(value) > MAX_EPOCH_MILLIS) {
|
|
255
|
+
throw new ValidationError(
|
|
256
|
+
`EpochMillis must be an integer within \xB1${MAX_EPOCH_MILLIS}, got ${value}`
|
|
257
|
+
);
|
|
355
258
|
}
|
|
356
|
-
return
|
|
357
|
-
}
|
|
259
|
+
return value;
|
|
260
|
+
},
|
|
261
|
+
/** The wall clock. Code that needs the time takes a `TimeEff` instead. */
|
|
262
|
+
now: () => EpochMillis.of(Date.now()),
|
|
263
|
+
/** @throws {@link ValidationError} for an invalid `Date`. */
|
|
264
|
+
fromDate: (date) => EpochMillis.of(date.getTime()),
|
|
265
|
+
/** How long after `from` the instant `to` is; negative if it is before. */
|
|
266
|
+
elapsed: (from, to) => Millis.of(to - from),
|
|
267
|
+
plus: (at, duration) => EpochMillis.of(at + duration)
|
|
358
268
|
};
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
var
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
269
|
+
var Millis = {
|
|
270
|
+
of: (value) => value
|
|
271
|
+
};
|
|
272
|
+
var Seconds = {
|
|
273
|
+
/**
|
|
274
|
+
* @throws {@link ValidationError} unless `value` is a non-negative integer.
|
|
275
|
+
*/
|
|
276
|
+
of: (value) => {
|
|
277
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
278
|
+
throw new ValidationError(
|
|
279
|
+
`Seconds must be a non-negative integer, got ${value}`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
return value;
|
|
283
|
+
},
|
|
284
|
+
toMillis: (value) => Millis.of(value * 1e3)
|
|
370
285
|
};
|
|
286
|
+
function isExpired({
|
|
287
|
+
expiresAt,
|
|
288
|
+
now,
|
|
289
|
+
buffer = Millis.of(0)
|
|
290
|
+
}) {
|
|
291
|
+
return now >= expiresAt - buffer;
|
|
292
|
+
}
|
|
371
293
|
|
|
372
294
|
// src/universal/types/blockchain/core.ts
|
|
373
295
|
var ETHEREUM_CHAINS = {
|
|
@@ -431,8 +353,18 @@ var BlockchainAmount = Object.assign(
|
|
|
431
353
|
{
|
|
432
354
|
add: (a, b) => combineAmounts(a, b, (x, y) => x + y),
|
|
433
355
|
sub: (a, b) => combineAmounts(a, b, (x, y) => x - y),
|
|
434
|
-
|
|
435
|
-
|
|
356
|
+
/**
|
|
357
|
+
* `a * b`, in `a`'s decimals - a price times a quantity. Multiplies before
|
|
358
|
+
* it rescales, then truncates towards zero. The exact inverse of `div`.
|
|
359
|
+
*/
|
|
360
|
+
mul: (a, b) => multiplyAmounts(a, b),
|
|
361
|
+
/**
|
|
362
|
+
* `a / b`, in `a`'s decimals - a price, a ratio. Rescales before it
|
|
363
|
+
* divides, then truncates towards zero.
|
|
364
|
+
*
|
|
365
|
+
* @throws MathError when `b` is zero.
|
|
366
|
+
*/
|
|
367
|
+
div: (a, b) => divideAmounts(a, b)
|
|
436
368
|
}
|
|
437
369
|
);
|
|
438
370
|
function multiplyAmounts(a, b) {
|
|
@@ -466,6 +398,66 @@ var StablecoinSymbol = (value) => value;
|
|
|
466
398
|
var KnownAssetSymbol = StablecoinSymbol;
|
|
467
399
|
var Bps = (value) => value;
|
|
468
400
|
|
|
401
|
+
// src/universal/core/shared/blockchain/math.ts
|
|
402
|
+
import { parseUnits } from "viem";
|
|
403
|
+
function blockchainAmountFromRawOrThrow({
|
|
404
|
+
label,
|
|
405
|
+
raw,
|
|
406
|
+
decimals
|
|
407
|
+
}) {
|
|
408
|
+
const trimmed = raw.trim();
|
|
409
|
+
if (trimmed === "") {
|
|
410
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
411
|
+
}
|
|
412
|
+
let value;
|
|
413
|
+
try {
|
|
414
|
+
value = BigInt(trimmed);
|
|
415
|
+
} catch {
|
|
416
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
417
|
+
}
|
|
418
|
+
try {
|
|
419
|
+
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
420
|
+
} catch {
|
|
421
|
+
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function parseBlockchainAmount(amount, decimals) {
|
|
425
|
+
const trimmed = amount.trim();
|
|
426
|
+
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
427
|
+
if (trimmed.startsWith("-")) {
|
|
428
|
+
return { valid: false, reason: { type: "negative" } };
|
|
429
|
+
}
|
|
430
|
+
if (/[eE]/.test(trimmed)) {
|
|
431
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
432
|
+
}
|
|
433
|
+
if (trimmed === ".") {
|
|
434
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
435
|
+
}
|
|
436
|
+
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
437
|
+
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
438
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
439
|
+
}
|
|
440
|
+
const [, fraction = ""] = normalised.split(".");
|
|
441
|
+
if (fraction.length > decimals) {
|
|
442
|
+
return {
|
|
443
|
+
valid: false,
|
|
444
|
+
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
try {
|
|
448
|
+
const raw = parseUnits(normalised, decimals);
|
|
449
|
+
if (raw > MAX_UINT_256) {
|
|
450
|
+
return { valid: false, reason: { type: "overflow" } };
|
|
451
|
+
}
|
|
452
|
+
return {
|
|
453
|
+
valid: true,
|
|
454
|
+
amount: BlockchainAmount({ raw, decimals })
|
|
455
|
+
};
|
|
456
|
+
} catch {
|
|
457
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
469
461
|
// src/universal/core/shared/utils/crypto.ts
|
|
470
462
|
async function sha256(data) {
|
|
471
463
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
@@ -541,6 +533,12 @@ function requiredDate(value, field) {
|
|
|
541
533
|
}
|
|
542
534
|
return date;
|
|
543
535
|
}
|
|
536
|
+
function dateOrNull(value, field) {
|
|
537
|
+
return value === null ? null : requiredDate(value, field);
|
|
538
|
+
}
|
|
539
|
+
function decimalOrNull(value) {
|
|
540
|
+
return value === null ? null : DecimalString(value);
|
|
541
|
+
}
|
|
544
542
|
function requiredArray(value, field) {
|
|
545
543
|
if (!Array.isArray(value)) {
|
|
546
544
|
throw new ValidationError(
|
|
@@ -550,290 +548,271 @@ function requiredArray(value, field) {
|
|
|
550
548
|
return value;
|
|
551
549
|
}
|
|
552
550
|
|
|
553
|
-
// src/universal/types/
|
|
554
|
-
var
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
551
|
+
// src/universal/types/providers/centrifuge/centrifuge.ts
|
|
552
|
+
var CentrifugeVaultStatus = {
|
|
553
|
+
fromDto: (dto) => ({
|
|
554
|
+
chain: EthereumChain(dto.chain),
|
|
555
|
+
symbol: AssetSymbol(dto.symbol),
|
|
556
|
+
vaultAddress: EvmContractAddress(dto.vault_address),
|
|
557
|
+
linked: dto.linked,
|
|
558
|
+
permissioned: dto.permissioned,
|
|
559
|
+
membershipValidUntil: dateOrNull(
|
|
560
|
+
dto.membership_valid_until,
|
|
561
|
+
"CentrifugeVaultStatus.membership_valid_until"
|
|
562
|
+
),
|
|
563
|
+
halted: dto.halted,
|
|
564
|
+
priceUpdatedAt: dateOrNull(
|
|
565
|
+
dto.price_updated_at,
|
|
566
|
+
"CentrifugeVaultStatus.price_updated_at"
|
|
567
|
+
),
|
|
568
|
+
orderability: parseOrderability(
|
|
569
|
+
dto.can_order,
|
|
570
|
+
dto.reasons,
|
|
571
|
+
"CentrifugeVaultStatus"
|
|
572
|
+
),
|
|
573
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
|
|
571
574
|
})
|
|
572
575
|
};
|
|
573
|
-
var
|
|
576
|
+
var CentrifugeVaultBuyTransaction = {
|
|
574
577
|
fromDto: (dto) => {
|
|
575
|
-
const
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
return {
|
|
585
|
-
...base2,
|
|
586
|
-
...OfferEditorial.fromDto(dto, "Offer"),
|
|
587
|
-
type: dto.type,
|
|
588
|
-
logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
|
|
589
|
-
};
|
|
590
|
-
case "superstate::swap":
|
|
591
|
-
return {
|
|
592
|
-
...base2,
|
|
593
|
-
...OfferEditorial.fromDto(dto, "Offer"),
|
|
594
|
-
type: dto.type,
|
|
595
|
-
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
596
|
-
};
|
|
597
|
-
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
598
|
-
// on the wire: copying them would hand every consumer a `startsAt` that
|
|
599
|
-
// is 1970 for one variant and a date for the others.
|
|
600
|
-
case "ondo::swap":
|
|
601
|
-
return {
|
|
602
|
-
...base2,
|
|
603
|
-
type: dto.type,
|
|
604
|
-
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
605
|
-
};
|
|
606
|
-
default:
|
|
607
|
-
return unknownTypeError(dto, "Offer");
|
|
578
|
+
const spendInputAmount = blockchainAmountFromRawOrThrow({
|
|
579
|
+
label: "spend_input_amount",
|
|
580
|
+
raw: dto.spend_input_amount,
|
|
581
|
+
decimals: AssetDecimals(dto.spend_input_decimals)
|
|
582
|
+
});
|
|
583
|
+
if (spendInputAmount.raw <= 0n) {
|
|
584
|
+
throw new ValidationError(
|
|
585
|
+
`spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
|
|
586
|
+
);
|
|
608
587
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
* reject the whole page, so one offer of an unknown type would blank the
|
|
615
|
-
* grid for every offer beside it. A single offer fetched by id still
|
|
616
|
-
* throws, because there is nothing beside it to keep.
|
|
617
|
-
*/
|
|
618
|
-
listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
|
|
619
|
-
};
|
|
620
|
-
var OfferToken = {
|
|
621
|
-
fromDto: (dto) => ({
|
|
622
|
-
role: dto.role,
|
|
623
|
-
chain: Chain(dto.chain),
|
|
624
|
-
address: EvmContractAddress(dto.address)
|
|
625
|
-
}),
|
|
626
|
-
/**
|
|
627
|
-
* Maps an offer's token list, dropping every token on a chain this SDK does
|
|
628
|
-
* not name. Frontline's chain registry runs ahead of {@link Chain}, and a
|
|
629
|
-
* plain `.map` would throw out of `Offer.fromDto` and, through
|
|
630
|
-
* `PaginatedResponse.fromDto`, reject the whole offers page - which is how
|
|
631
|
-
* one Base token blanked production's offers list. Dropping costs that
|
|
632
|
-
* token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
|
|
633
|
-
* so nobody could have looked it up anyway.
|
|
634
|
-
*
|
|
635
|
-
* Same shape as `TokenMetadata.fromRegistryDto`.
|
|
636
|
-
*/
|
|
637
|
-
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
|
|
588
|
+
return {
|
|
589
|
+
...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
|
|
590
|
+
spendInputAmount
|
|
591
|
+
};
|
|
592
|
+
}
|
|
638
593
|
};
|
|
639
|
-
|
|
640
|
-
// src/universal/types/trading.ts
|
|
641
|
-
var Ticker = (value) => value;
|
|
642
|
-
var Isin = (value) => value;
|
|
643
|
-
|
|
644
|
-
// src/universal/types/offer-detail.ts
|
|
645
|
-
var OfferOptionId = (value) => value;
|
|
646
|
-
var OfferOptionSlug = (value) => value;
|
|
647
|
-
var OfferSwapContract = {
|
|
594
|
+
var CentrifugeVaultClaimTransaction = {
|
|
648
595
|
fromDto: (dto) => ({
|
|
649
|
-
|
|
650
|
-
|
|
596
|
+
...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
|
|
597
|
+
claimableShares: blockchainAmountFromRawOrThrow({
|
|
598
|
+
label: "claimable_shares",
|
|
599
|
+
raw: dto.claimable_shares,
|
|
600
|
+
decimals: AssetDecimals(dto.share_decimals)
|
|
601
|
+
})
|
|
651
602
|
})
|
|
652
603
|
};
|
|
653
|
-
var
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
|
|
665
|
-
const isin = notBlankStringOrNull(dto.isin);
|
|
666
|
-
const ticker = notBlankStringOrNull(dto.ticker);
|
|
667
|
-
const base2 = {
|
|
668
|
-
id: OfferId(dto.id),
|
|
669
|
-
slug: OfferSlug(dto.slug),
|
|
670
|
-
name: dto.name,
|
|
671
|
-
asset: Asset.fromDto(dto.asset),
|
|
672
|
-
fundingAssets: fundingAssets.map(Asset.fromDto),
|
|
673
|
-
tokens: OfferToken.listFromDto(tokens),
|
|
674
|
-
about: notBlankStringOrNull(dto.about),
|
|
675
|
-
category: dto.category,
|
|
676
|
-
issuer: notBlankStringOrNull(dto.issuer),
|
|
677
|
-
isin: isin === null ? null : Isin(isin),
|
|
678
|
-
ticker: ticker === null ? null : Ticker(ticker),
|
|
679
|
-
instrumentType: notBlankStringOrNull(dto.instrument_type),
|
|
680
|
-
listingVenue: notBlankStringOrNull(dto.listing_venue),
|
|
681
|
-
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
682
|
-
faqs: faqs.map(FaqItem.fromDto),
|
|
683
|
-
links: links.map(Link.fromDto),
|
|
684
|
-
milestones: milestones.map(Milestone.fromDto),
|
|
685
|
-
options: options.map(OfferOption.fromDto),
|
|
686
|
-
terms: terms.map(TermItem.fromDto)
|
|
604
|
+
var CentrifugeAssets = (amount) => amount;
|
|
605
|
+
var CentrifugeShares = (amount) => amount;
|
|
606
|
+
var CentrifugeDepositPosition = {
|
|
607
|
+
fromContract: (raw, context) => {
|
|
608
|
+
const assets = (label, value) => CentrifugeAssets(contractAmount(label, value, context.assetDecimals));
|
|
609
|
+
return {
|
|
610
|
+
chain: context.chain,
|
|
611
|
+
proxy: context.proxy,
|
|
612
|
+
walletAddress: context.walletAddress,
|
|
613
|
+
pending: assets("pendingDepositRequest", raw.pendingDepositRequest),
|
|
614
|
+
claimable: assets("claimableDepositRequest", raw.claimableDepositRequest)
|
|
687
615
|
};
|
|
688
|
-
switch (dto.type) {
|
|
689
|
-
case "coinlist::token_sale":
|
|
690
|
-
return {
|
|
691
|
-
...base2,
|
|
692
|
-
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
693
|
-
type: dto.type,
|
|
694
|
-
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
|
|
695
|
-
};
|
|
696
|
-
case "superstate::swap":
|
|
697
|
-
return {
|
|
698
|
-
...base2,
|
|
699
|
-
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
700
|
-
type: dto.type,
|
|
701
|
-
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
702
|
-
};
|
|
703
|
-
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
704
|
-
// on the wire, as in `Offer.fromDto`.
|
|
705
|
-
case "ondo::swap":
|
|
706
|
-
return {
|
|
707
|
-
...base2,
|
|
708
|
-
type: dto.type,
|
|
709
|
-
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
710
|
-
swapContracts: requiredArray(
|
|
711
|
-
dto.swap_contracts,
|
|
712
|
-
"OfferDetail.swap_contracts"
|
|
713
|
-
).map(OfferSwapContract.fromDto)
|
|
714
|
-
};
|
|
715
|
-
default:
|
|
716
|
-
return unknownTypeError(dto, "OfferDetail");
|
|
717
|
-
}
|
|
718
616
|
}
|
|
719
617
|
};
|
|
720
|
-
var
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
731
|
-
};
|
|
732
|
-
var FaqItem = {
|
|
733
|
-
fromDto: (dto) => ({
|
|
734
|
-
question: notBlankStringOrNull(dto.question),
|
|
735
|
-
answer: notBlankStringOrNull(dto.answer)
|
|
736
|
-
})
|
|
618
|
+
var CentrifugeRedeemPosition = {
|
|
619
|
+
fromContract: (raw, context) => {
|
|
620
|
+
const shares = (label, value) => CentrifugeShares(contractAmount(label, value, context.shareDecimals));
|
|
621
|
+
return {
|
|
622
|
+
chain: context.chain,
|
|
623
|
+
proxy: context.proxy,
|
|
624
|
+
walletAddress: context.walletAddress,
|
|
625
|
+
pending: shares("pendingRedeemRequest", raw.pendingRedeemRequest),
|
|
626
|
+
claimable: shares("claimableRedeemRequest", raw.claimableRedeemRequest)
|
|
627
|
+
};
|
|
628
|
+
}
|
|
737
629
|
};
|
|
738
|
-
var
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
url: notBlankStringOrNull(dto.url)
|
|
742
|
-
})
|
|
630
|
+
var CentrifugeVaultLeg = {
|
|
631
|
+
/** Whether the leg has anything queued or anything ready to claim. */
|
|
632
|
+
isActive: (leg) => leg.position.pending.raw > 0n || leg.position.claimable.raw > 0n
|
|
743
633
|
};
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
634
|
+
function contractAmount(label, value, decimals) {
|
|
635
|
+
return BlockchainAmount({ raw: parseUint256(value, label), decimals });
|
|
636
|
+
}
|
|
637
|
+
var CentrifugeVaultLegId = {
|
|
638
|
+
/** Addresses compare case-insensitively: a host may pass either case. */
|
|
639
|
+
of: (leg) => [
|
|
640
|
+
leg.direction,
|
|
641
|
+
leg.position.chain,
|
|
642
|
+
leg.position.walletAddress.toLowerCase()
|
|
643
|
+
].join(":")
|
|
749
644
|
};
|
|
750
|
-
var
|
|
645
|
+
var CentrifugeVaultClaimProceedsTransaction = {
|
|
751
646
|
fromDto: (dto) => ({
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
647
|
+
...parseTransactionCore(dto, "CentrifugeVaultClaimProceedsTransaction"),
|
|
648
|
+
claimableAssets: blockchainAmountFromRawOrThrow({
|
|
649
|
+
label: "claimable_assets",
|
|
650
|
+
raw: dto.claimable_assets,
|
|
651
|
+
decimals: AssetDecimals(dto.asset_decimals)
|
|
652
|
+
})
|
|
755
653
|
})
|
|
756
654
|
};
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
const queryParams = PaginationParams.toQueryParams(params);
|
|
765
|
-
if (params.offerId) {
|
|
766
|
-
queryParams["filters[0][field]"] = "offer_id";
|
|
767
|
-
queryParams["filters[0][op]"] = "==";
|
|
768
|
-
queryParams["filters[0][value]"] = params.offerId;
|
|
655
|
+
function parseOrderability(canOrder, reasons, model) {
|
|
656
|
+
const [first, ...rest] = reasons;
|
|
657
|
+
if (canOrder) {
|
|
658
|
+
if (first !== void 0) {
|
|
659
|
+
throw new ValidationError(
|
|
660
|
+
`${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
|
|
661
|
+
);
|
|
769
662
|
}
|
|
770
|
-
return
|
|
663
|
+
return { type: "orderable" };
|
|
771
664
|
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
const walletAddress = notBlankStringOrNull(dto.wallet_address);
|
|
777
|
-
return {
|
|
778
|
-
id: ParticipationId(dto.id),
|
|
779
|
-
offerId: OfferId(dto.offer_id),
|
|
780
|
-
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
781
|
-
status: dto.status,
|
|
782
|
-
amount: dto.amount,
|
|
783
|
-
displayAmount: dto.amount_string,
|
|
784
|
-
asset: Asset.fromDto(dto.asset),
|
|
785
|
-
chain: Blockchain(dto.chain),
|
|
786
|
-
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
787
|
-
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
788
|
-
walletAddress: walletAddress ? WalletAddress(walletAddress) : null
|
|
789
|
-
};
|
|
665
|
+
if (first === void 0) {
|
|
666
|
+
throw new ValidationError(
|
|
667
|
+
`${model}.reasons: expected at least one when can_order is false`
|
|
668
|
+
);
|
|
790
669
|
}
|
|
791
|
-
};
|
|
792
|
-
var CreateParticipationParams = {
|
|
793
|
-
/** Maps participation creation params into API DTO payload. */
|
|
794
|
-
toDto: (params) => ({
|
|
795
|
-
offer_id: params.offerId,
|
|
796
|
-
offer_option_id: params.offerOptionId,
|
|
797
|
-
chain: params.chain,
|
|
798
|
-
wallet_address: params.walletAddress,
|
|
799
|
-
amount: params.amount,
|
|
800
|
-
asset_id: params.assetId,
|
|
801
|
-
approval_transaction_hash: params.approvalTransactionHash
|
|
802
|
-
})
|
|
803
|
-
};
|
|
804
|
-
|
|
805
|
-
// src/universal/api/frontline/providers/coin-list/token-sale.ts
|
|
806
|
-
async function fetchParticipations(api, offerId) {
|
|
807
|
-
return fetchAllPages(
|
|
808
|
-
(params) => fetchParticipationsPage(api, params),
|
|
809
|
-
{ offerId }
|
|
810
|
-
);
|
|
670
|
+
return { type: "blocked", reasons: [first, ...rest] };
|
|
811
671
|
}
|
|
812
|
-
|
|
813
|
-
|
|
672
|
+
function parseTransactionCore(dto, model) {
|
|
673
|
+
return {
|
|
674
|
+
tx: {
|
|
675
|
+
to: EvmContractAddress(dto.to),
|
|
676
|
+
data: HexEncodedTransactionData(dto.data)
|
|
677
|
+
},
|
|
678
|
+
expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// src/universal/api/frontline/providers/centrifuge/centrifuge.ts
|
|
683
|
+
async function getCentrifugeVaultStatus(api, params) {
|
|
684
|
+
const dto = await api.send({
|
|
814
685
|
method: "GET",
|
|
815
|
-
url: "/v1/
|
|
816
|
-
queryParams:
|
|
686
|
+
url: "/v1/centrifuge/vault/status",
|
|
687
|
+
queryParams: {
|
|
688
|
+
symbol: params.symbol,
|
|
689
|
+
chain: params.chain
|
|
690
|
+
},
|
|
817
691
|
attributes: Attributes.protected()
|
|
818
692
|
});
|
|
819
|
-
return
|
|
693
|
+
return CentrifugeVaultStatus.fromDto(dto);
|
|
820
694
|
}
|
|
821
|
-
async function
|
|
695
|
+
async function buildCentrifugeVaultBuy(api, params) {
|
|
822
696
|
const dto = await api.send({
|
|
823
|
-
method: "
|
|
824
|
-
url:
|
|
697
|
+
method: "POST",
|
|
698
|
+
url: "/v1/centrifuge/vault/invest",
|
|
699
|
+
body: {
|
|
700
|
+
...walletFields(params),
|
|
701
|
+
amount: params.amount.raw.toString()
|
|
702
|
+
},
|
|
825
703
|
attributes: Attributes.protected()
|
|
826
704
|
});
|
|
827
|
-
|
|
705
|
+
if (dto.spend_input_decimals !== params.amount.decimals) {
|
|
706
|
+
throw new ValidationError(
|
|
707
|
+
`spend_input_decimals: the request was priced in ${dto.spend_input_decimals} decimals but the deposit was sized in ${params.amount.decimals}`
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
return CentrifugeVaultBuyTransaction.fromDto(dto);
|
|
828
711
|
}
|
|
829
|
-
async function
|
|
712
|
+
async function createCentrifugeVaultClaim(api, params) {
|
|
830
713
|
const dto = await api.send({
|
|
831
714
|
method: "POST",
|
|
832
|
-
url: "/v1/
|
|
833
|
-
body:
|
|
715
|
+
url: "/v1/centrifuge/vault/claim",
|
|
716
|
+
body: walletFields(params),
|
|
834
717
|
attributes: Attributes.protected()
|
|
835
718
|
});
|
|
836
|
-
return
|
|
719
|
+
return CentrifugeVaultClaimTransaction.fromDto(dto);
|
|
720
|
+
}
|
|
721
|
+
async function createCentrifugeVaultClaimProceeds(api, params) {
|
|
722
|
+
const dto = await api.send({
|
|
723
|
+
method: "POST",
|
|
724
|
+
url: "/v1/centrifuge/vault/claim-proceeds",
|
|
725
|
+
body: walletFields(params),
|
|
726
|
+
attributes: Attributes.protected()
|
|
727
|
+
});
|
|
728
|
+
return CentrifugeVaultClaimProceedsTransaction.fromDto(dto);
|
|
729
|
+
}
|
|
730
|
+
function walletFields(params) {
|
|
731
|
+
return {
|
|
732
|
+
symbol: params.symbol,
|
|
733
|
+
chain: params.chain,
|
|
734
|
+
wallet_address: params.walletAddress
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// src/universal/core/providers/checkout/centrifuge/blockchain/abi.ts
|
|
739
|
+
var CENTRIFUGE_PROXY_ABI = [
|
|
740
|
+
{
|
|
741
|
+
type: "function",
|
|
742
|
+
name: "pendingDepositRequest",
|
|
743
|
+
inputs: [{ name: "investor", type: "address" }],
|
|
744
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
745
|
+
stateMutability: "view"
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
type: "function",
|
|
749
|
+
name: "claimableDepositRequest",
|
|
750
|
+
inputs: [{ name: "investor", type: "address" }],
|
|
751
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
752
|
+
stateMutability: "view"
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
type: "function",
|
|
756
|
+
name: "pendingRedeemRequest",
|
|
757
|
+
inputs: [{ name: "investor", type: "address" }],
|
|
758
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
759
|
+
stateMutability: "view"
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
type: "function",
|
|
763
|
+
name: "claimableRedeemRequest",
|
|
764
|
+
inputs: [{ name: "investor", type: "address" }],
|
|
765
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
766
|
+
stateMutability: "view"
|
|
767
|
+
}
|
|
768
|
+
];
|
|
769
|
+
|
|
770
|
+
// src/universal/api/rpc/providers/centrifuge/position.ts
|
|
771
|
+
async function readCentrifugeDepositPosition(clients, params) {
|
|
772
|
+
const client = clients(params.vault.chain);
|
|
773
|
+
const proxy = proxyOf(params);
|
|
774
|
+
const wallet = params.walletAddress;
|
|
775
|
+
const [pendingDepositRequest, claimableDepositRequest] = await client.multicall({
|
|
776
|
+
allowFailure: false,
|
|
777
|
+
contracts: [
|
|
778
|
+
{ ...proxy, functionName: "pendingDepositRequest", args: [wallet] },
|
|
779
|
+
{ ...proxy, functionName: "claimableDepositRequest", args: [wallet] }
|
|
780
|
+
]
|
|
781
|
+
});
|
|
782
|
+
return CentrifugeDepositPosition.fromContract(
|
|
783
|
+
{ pendingDepositRequest, claimableDepositRequest },
|
|
784
|
+
contextOf(params)
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
async function readCentrifugeRedeemPosition(clients, params) {
|
|
788
|
+
const client = clients(params.vault.chain);
|
|
789
|
+
const proxy = proxyOf(params);
|
|
790
|
+
const wallet = params.walletAddress;
|
|
791
|
+
const [pendingRedeemRequest, claimableRedeemRequest] = await client.multicall(
|
|
792
|
+
{
|
|
793
|
+
allowFailure: false,
|
|
794
|
+
contracts: [
|
|
795
|
+
{ ...proxy, functionName: "pendingRedeemRequest", args: [wallet] },
|
|
796
|
+
{ ...proxy, functionName: "claimableRedeemRequest", args: [wallet] }
|
|
797
|
+
]
|
|
798
|
+
}
|
|
799
|
+
);
|
|
800
|
+
return CentrifugeRedeemPosition.fromContract(
|
|
801
|
+
{ pendingRedeemRequest, claimableRedeemRequest },
|
|
802
|
+
contextOf(params)
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
function proxyOf(params) {
|
|
806
|
+
return { address: params.vault.proxy, abi: CENTRIFUGE_PROXY_ABI };
|
|
807
|
+
}
|
|
808
|
+
function contextOf(params) {
|
|
809
|
+
return {
|
|
810
|
+
chain: params.vault.chain,
|
|
811
|
+
proxy: params.vault.proxy,
|
|
812
|
+
walletAddress: params.walletAddress,
|
|
813
|
+
assetDecimals: params.vault.funding.decimals,
|
|
814
|
+
shareDecimals: params.vault.share.decimals
|
|
815
|
+
};
|
|
837
816
|
}
|
|
838
817
|
|
|
839
818
|
// src/universal/core/shared/observability/log-cause.ts
|
|
@@ -1019,34 +998,48 @@ var noopInternalLogger = {
|
|
|
1019
998
|
wrap: (_op, _params, run) => run()
|
|
1020
999
|
};
|
|
1021
1000
|
|
|
1022
|
-
// src/universal/core/checkout/
|
|
1023
|
-
var
|
|
1001
|
+
// src/universal/core/providers/checkout/centrifuge/centrifuge-namespace.ts
|
|
1002
|
+
var CentrifugeNamespaceImpl = class {
|
|
1024
1003
|
constructor(ctx) {
|
|
1025
1004
|
this.ctx = ctx;
|
|
1026
|
-
this.log = internalLogger(ctx.logger, "
|
|
1005
|
+
this.log = internalLogger(ctx.logger, "CENTRIFUGE");
|
|
1027
1006
|
}
|
|
1028
|
-
async
|
|
1029
|
-
return this.log.wrap("
|
|
1007
|
+
async getVaultStatus(params) {
|
|
1008
|
+
return this.log.wrap("getVaultStatus", params, async () => {
|
|
1030
1009
|
await this.ctx.ensureUserAuthenticated();
|
|
1031
|
-
return
|
|
1010
|
+
return getCentrifugeVaultStatus(this.ctx.api, params);
|
|
1032
1011
|
});
|
|
1033
1012
|
}
|
|
1034
|
-
async
|
|
1035
|
-
return this.log.wrap(
|
|
1013
|
+
async readDepositPosition(params) {
|
|
1014
|
+
return this.log.wrap(
|
|
1015
|
+
"readDepositPosition",
|
|
1016
|
+
params,
|
|
1017
|
+
() => readCentrifugeDepositPosition(this.ctx.rpc, params)
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
async readRedeemPosition(params) {
|
|
1021
|
+
return this.log.wrap(
|
|
1022
|
+
"readRedeemPosition",
|
|
1023
|
+
params,
|
|
1024
|
+
() => readCentrifugeRedeemPosition(this.ctx.rpc, params)
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
async createClaim(params) {
|
|
1028
|
+
return this.log.wrap("createClaim", params, async () => {
|
|
1036
1029
|
await this.ctx.ensureUserAuthenticated();
|
|
1037
|
-
return
|
|
1030
|
+
return createCentrifugeVaultClaim(this.ctx.api, params);
|
|
1038
1031
|
});
|
|
1039
1032
|
}
|
|
1040
|
-
async
|
|
1041
|
-
return this.log.wrap("
|
|
1033
|
+
async createClaimProceeds(params) {
|
|
1034
|
+
return this.log.wrap("createClaimProceeds", params, async () => {
|
|
1042
1035
|
await this.ctx.ensureUserAuthenticated();
|
|
1043
|
-
return
|
|
1036
|
+
return createCentrifugeVaultClaimProceeds(this.ctx.api, params);
|
|
1044
1037
|
});
|
|
1045
1038
|
}
|
|
1046
|
-
async
|
|
1047
|
-
return this.log.wrap("
|
|
1039
|
+
async buildBuyTransaction(params) {
|
|
1040
|
+
return this.log.wrap("buildBuyTransaction", params, async () => {
|
|
1048
1041
|
await this.ctx.ensureUserAuthenticated();
|
|
1049
|
-
return
|
|
1042
|
+
return buildCentrifugeVaultBuy(this.ctx.api, params);
|
|
1050
1043
|
});
|
|
1051
1044
|
}
|
|
1052
1045
|
};
|
|
@@ -1069,7 +1062,11 @@ function formatAmount(amount, locale, options) {
|
|
|
1069
1062
|
const decimal = formatRawAmount(amount);
|
|
1070
1063
|
let [integerPart, fractionPart = ""] = decimal.split(".");
|
|
1071
1064
|
const maxFractionDigits = options?.maxFractionDigits;
|
|
1072
|
-
const minFractionDigits =
|
|
1065
|
+
const minFractionDigits = Math.min(
|
|
1066
|
+
options?.minFractionDigits ?? (maxFractionDigits !== void 0 ? maxFractionDigits : 2),
|
|
1067
|
+
maxFractionDigits ?? amount.decimals,
|
|
1068
|
+
amount.decimals
|
|
1069
|
+
);
|
|
1073
1070
|
if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
|
|
1074
1071
|
({ integerPart, fractionPart } = roundFractionHalfUp(
|
|
1075
1072
|
integerPart,
|
|
@@ -1077,7 +1074,8 @@ function formatAmount(amount, locale, options) {
|
|
|
1077
1074
|
maxFractionDigits
|
|
1078
1075
|
));
|
|
1079
1076
|
}
|
|
1080
|
-
const
|
|
1077
|
+
const trimmed = fractionPart.replace(/0+$/, "");
|
|
1078
|
+
const fraction = trimmed.padEnd(minFractionDigits, "0");
|
|
1081
1079
|
const integerFormatted = BigInt(integerPart).toLocaleString(locale);
|
|
1082
1080
|
if (minFractionDigits === 0 && fraction === "") {
|
|
1083
1081
|
return FormattedAmountUi(integerFormatted);
|
|
@@ -1146,6 +1144,14 @@ function assetAmount(amount, symbol) {
|
|
|
1146
1144
|
return FormattedAmountAssetUi(`${amount} ${symbol}`);
|
|
1147
1145
|
}
|
|
1148
1146
|
var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
|
|
1147
|
+
var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
|
|
1148
|
+
var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
|
|
1149
|
+
function formatShareAmount(amount, locale) {
|
|
1150
|
+
return formatAmount(amount, locale, {
|
|
1151
|
+
maxFractionDigits: SHARE_MAX_FRACTION_DIGITS,
|
|
1152
|
+
minFractionDigits: SHARE_MIN_FRACTION_DIGITS
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1149
1155
|
var USD_FRACTION_DIGITS = AssetDecimals(2);
|
|
1150
1156
|
function formattedUsdPrice(amount, locale) {
|
|
1151
1157
|
if (!amount) return NA_AMOUNT_ASSET_UI;
|
|
@@ -1154,6 +1160,435 @@ function formattedUsdPrice(amount, locale) {
|
|
|
1154
1160
|
);
|
|
1155
1161
|
}
|
|
1156
1162
|
|
|
1163
|
+
// src/universal/types/asset.ts
|
|
1164
|
+
var AssetId = (value) => value;
|
|
1165
|
+
var AssetCode = (value) => value;
|
|
1166
|
+
var Asset = {
|
|
1167
|
+
fromDto: (dto) => ({
|
|
1168
|
+
id: AssetId(dto.id),
|
|
1169
|
+
code: AssetCode(dto.code),
|
|
1170
|
+
name: dto.name,
|
|
1171
|
+
fractionalDigits: dto.fractional_digits
|
|
1172
|
+
})
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1175
|
+
// src/universal/types/offer.ts
|
|
1176
|
+
var OfferId = (value) => value;
|
|
1177
|
+
var OfferSlug = (value) => value;
|
|
1178
|
+
var OFFER_TYPES = {
|
|
1179
|
+
"coinlist::token_sale": true,
|
|
1180
|
+
"superstate::swap": true,
|
|
1181
|
+
"ondo::swap": true,
|
|
1182
|
+
"centrifuge::vault": true
|
|
1183
|
+
};
|
|
1184
|
+
var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
|
|
1185
|
+
var OfferEditorial = {
|
|
1186
|
+
/**
|
|
1187
|
+
* `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
|
|
1188
|
+
* the same three checks name the payload that failed them.
|
|
1189
|
+
*/
|
|
1190
|
+
fromDto: (dto, model) => ({
|
|
1191
|
+
tagline: requiredString(dto.tagline, `${model}.tagline`),
|
|
1192
|
+
bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
|
|
1193
|
+
startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
|
|
1194
|
+
})
|
|
1195
|
+
};
|
|
1196
|
+
var Offer = {
|
|
1197
|
+
fromDto: (dto) => {
|
|
1198
|
+
const tokens = requiredArray(dto.tokens, "Offer.tokens");
|
|
1199
|
+
const base2 = {
|
|
1200
|
+
id: OfferId(dto.id),
|
|
1201
|
+
slug: OfferSlug(dto.slug),
|
|
1202
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
1203
|
+
tokens: OfferToken.listFromDto(tokens)
|
|
1204
|
+
};
|
|
1205
|
+
switch (dto.type) {
|
|
1206
|
+
case "coinlist::token_sale":
|
|
1207
|
+
return {
|
|
1208
|
+
...base2,
|
|
1209
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
1210
|
+
type: dto.type,
|
|
1211
|
+
logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
|
|
1212
|
+
};
|
|
1213
|
+
case "superstate::swap":
|
|
1214
|
+
return {
|
|
1215
|
+
...base2,
|
|
1216
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
1217
|
+
type: dto.type,
|
|
1218
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
1219
|
+
};
|
|
1220
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
1221
|
+
// on the wire: copying them would hand every consumer a `startsAt` that
|
|
1222
|
+
// is 1970 for one variant and a date for the others.
|
|
1223
|
+
case "ondo::swap":
|
|
1224
|
+
case "centrifuge::vault":
|
|
1225
|
+
return {
|
|
1226
|
+
...base2,
|
|
1227
|
+
type: dto.type,
|
|
1228
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
1229
|
+
};
|
|
1230
|
+
default:
|
|
1231
|
+
return unknownTypeError(dto, "Offer");
|
|
1232
|
+
}
|
|
1233
|
+
},
|
|
1234
|
+
/**
|
|
1235
|
+
* Maps a page of offers, dropping every offer whose `type` this SDK does not
|
|
1236
|
+
* name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
|
|
1237
|
+
* would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
|
|
1238
|
+
* reject the whole page, so one offer of an unknown type would blank the
|
|
1239
|
+
* grid for every offer beside it. A single offer fetched by id still
|
|
1240
|
+
* throws, because there is nothing beside it to keep.
|
|
1241
|
+
*/
|
|
1242
|
+
listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
|
|
1243
|
+
};
|
|
1244
|
+
var OfferToken = {
|
|
1245
|
+
fromDto: (dto) => ({
|
|
1246
|
+
role: dto.role,
|
|
1247
|
+
chain: Chain(dto.chain),
|
|
1248
|
+
address: EvmContractAddress(dto.address)
|
|
1249
|
+
}),
|
|
1250
|
+
/**
|
|
1251
|
+
* Maps an offer's token list, dropping every token on a chain this SDK does
|
|
1252
|
+
* not name. Frontline's chain registry runs ahead of {@link Chain}, and a
|
|
1253
|
+
* plain `.map` would throw out of `Offer.fromDto` and, through
|
|
1254
|
+
* `PaginatedResponse.fromDto`, reject the whole offers page - which is how
|
|
1255
|
+
* one Base token blanked production's offers list. Dropping costs that
|
|
1256
|
+
* token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
|
|
1257
|
+
* so nobody could have looked it up anyway.
|
|
1258
|
+
*
|
|
1259
|
+
* Same shape as `TokenMetadata.fromRegistryDto`.
|
|
1260
|
+
*/
|
|
1261
|
+
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
// src/universal/types/trading.ts
|
|
1265
|
+
var Ticker = (value) => value;
|
|
1266
|
+
var Isin = (value) => value;
|
|
1267
|
+
|
|
1268
|
+
// src/universal/types/offer-detail.ts
|
|
1269
|
+
var AsyncOfferDetail = {
|
|
1270
|
+
/**
|
|
1271
|
+
* Narrows an offer fetched generically, e.g. on an offer page, to one with
|
|
1272
|
+
* something to claim.
|
|
1273
|
+
*
|
|
1274
|
+
* An exhaustive `switch` rather than a list of async types, so a new offer
|
|
1275
|
+
* type is a compile error here until someone decides whether it settles
|
|
1276
|
+
* later.
|
|
1277
|
+
*/
|
|
1278
|
+
is: (offer) => {
|
|
1279
|
+
switch (offer.type) {
|
|
1280
|
+
case "centrifuge::vault":
|
|
1281
|
+
return true;
|
|
1282
|
+
case "ondo::swap":
|
|
1283
|
+
case "superstate::swap":
|
|
1284
|
+
case "coinlist::token_sale":
|
|
1285
|
+
return false;
|
|
1286
|
+
default: {
|
|
1287
|
+
const exhaustive = offer;
|
|
1288
|
+
return exhaustive;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
var OfferOptionId = (value) => value;
|
|
1294
|
+
var OfferOptionSlug = (value) => value;
|
|
1295
|
+
var OfferSwapContract = {
|
|
1296
|
+
fromDto: (dto) => ({
|
|
1297
|
+
chain: Chain(dto.chain),
|
|
1298
|
+
address: EvmContractAddress(dto.address)
|
|
1299
|
+
})
|
|
1300
|
+
};
|
|
1301
|
+
var OfferVaultContract = {
|
|
1302
|
+
fromDto: (dto) => ({
|
|
1303
|
+
chain: Chain(dto.chain),
|
|
1304
|
+
address: EvmContractAddress(dto.address)
|
|
1305
|
+
}),
|
|
1306
|
+
/**
|
|
1307
|
+
* Drops every proxy on a chain this SDK does not name, as
|
|
1308
|
+
* `OfferToken.listFromDto` does: frontline publishes the full offer-token
|
|
1309
|
+
* chain list, which runs ahead of {@link Chain}, and one unmodelled chain
|
|
1310
|
+
* should not throw away the proxies the SDK can use.
|
|
1311
|
+
*/
|
|
1312
|
+
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
|
|
1313
|
+
};
|
|
1314
|
+
var OfferDetail = {
|
|
1315
|
+
fromDto: (dto) => {
|
|
1316
|
+
const fundingAssets = requiredArray(
|
|
1317
|
+
dto.funding_assets,
|
|
1318
|
+
"OfferDetail.funding_assets"
|
|
1319
|
+
);
|
|
1320
|
+
const options = requiredArray(dto.options, "OfferDetail.options");
|
|
1321
|
+
const terms = requiredArray(dto.terms, "OfferDetail.terms");
|
|
1322
|
+
const links = requiredArray(dto.links, "OfferDetail.links");
|
|
1323
|
+
const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
|
|
1324
|
+
const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
|
|
1325
|
+
const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
|
|
1326
|
+
const isin = notBlankStringOrNull(dto.isin);
|
|
1327
|
+
const ticker = notBlankStringOrNull(dto.ticker);
|
|
1328
|
+
const base2 = {
|
|
1329
|
+
id: OfferId(dto.id),
|
|
1330
|
+
slug: OfferSlug(dto.slug),
|
|
1331
|
+
name: dto.name,
|
|
1332
|
+
asset: Asset.fromDto(dto.asset),
|
|
1333
|
+
fundingAssets: fundingAssets.map(Asset.fromDto),
|
|
1334
|
+
tokens: OfferToken.listFromDto(tokens),
|
|
1335
|
+
about: notBlankStringOrNull(dto.about),
|
|
1336
|
+
category: dto.category,
|
|
1337
|
+
issuer: notBlankStringOrNull(dto.issuer),
|
|
1338
|
+
isin: isin === null ? null : Isin(isin),
|
|
1339
|
+
ticker: ticker === null ? null : Ticker(ticker),
|
|
1340
|
+
instrumentType: notBlankStringOrNull(dto.instrument_type),
|
|
1341
|
+
listingVenue: notBlankStringOrNull(dto.listing_venue),
|
|
1342
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
1343
|
+
faqs: faqs.map(FaqItem.fromDto),
|
|
1344
|
+
links: links.map(Link.fromDto),
|
|
1345
|
+
milestones: milestones.map(Milestone.fromDto),
|
|
1346
|
+
options: options.map(OfferOption.fromDto),
|
|
1347
|
+
terms: terms.map(TermItem.fromDto)
|
|
1348
|
+
};
|
|
1349
|
+
switch (dto.type) {
|
|
1350
|
+
case "coinlist::token_sale":
|
|
1351
|
+
return {
|
|
1352
|
+
...base2,
|
|
1353
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
1354
|
+
type: dto.type,
|
|
1355
|
+
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
|
|
1356
|
+
};
|
|
1357
|
+
case "superstate::swap":
|
|
1358
|
+
return {
|
|
1359
|
+
...base2,
|
|
1360
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
1361
|
+
type: dto.type,
|
|
1362
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
1363
|
+
};
|
|
1364
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
1365
|
+
// on the wire, as in `Offer.fromDto`.
|
|
1366
|
+
case "ondo::swap":
|
|
1367
|
+
return {
|
|
1368
|
+
...base2,
|
|
1369
|
+
type: dto.type,
|
|
1370
|
+
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
1371
|
+
swapContracts: requiredArray(
|
|
1372
|
+
dto.swap_contracts,
|
|
1373
|
+
"OfferDetail.swap_contracts"
|
|
1374
|
+
).map(OfferSwapContract.fromDto)
|
|
1375
|
+
};
|
|
1376
|
+
// No editorial, as for Ondo. `[]` is fine and a missing key is not, for
|
|
1377
|
+
// the same reason as `swap_contracts`: this is the spender a user
|
|
1378
|
+
// approves.
|
|
1379
|
+
case "centrifuge::vault":
|
|
1380
|
+
return {
|
|
1381
|
+
...base2,
|
|
1382
|
+
type: dto.type,
|
|
1383
|
+
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
1384
|
+
vaultContracts: OfferVaultContract.listFromDto(
|
|
1385
|
+
requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
|
|
1386
|
+
)
|
|
1387
|
+
};
|
|
1388
|
+
default:
|
|
1389
|
+
return unknownTypeError(dto, "OfferDetail");
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
var OfferOption = {
|
|
1394
|
+
fromDto: (dto) => ({
|
|
1395
|
+
id: OfferOptionId(dto.id),
|
|
1396
|
+
slug: OfferOptionSlug(dto.slug),
|
|
1397
|
+
bidIncrement: dto.bid_increment,
|
|
1398
|
+
floorPriceUsd: dto.floor_price_usd,
|
|
1399
|
+
minimumPurchaseUsd: dto.minimum_purchase_usd,
|
|
1400
|
+
priceUsd: dto.price_usd,
|
|
1401
|
+
saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
|
|
1402
|
+
totalTokenSupply: dto.total_token_supply
|
|
1403
|
+
})
|
|
1404
|
+
};
|
|
1405
|
+
var FaqItem = {
|
|
1406
|
+
fromDto: (dto) => ({
|
|
1407
|
+
question: notBlankStringOrNull(dto.question),
|
|
1408
|
+
answer: notBlankStringOrNull(dto.answer)
|
|
1409
|
+
})
|
|
1410
|
+
};
|
|
1411
|
+
var Link = {
|
|
1412
|
+
fromDto: (dto) => ({
|
|
1413
|
+
label: notBlankStringOrNull(dto.label),
|
|
1414
|
+
url: notBlankStringOrNull(dto.url)
|
|
1415
|
+
})
|
|
1416
|
+
};
|
|
1417
|
+
var TermItem = {
|
|
1418
|
+
fromDto: (dto) => ({
|
|
1419
|
+
key: notBlankStringOrNull(dto.key),
|
|
1420
|
+
value: notBlankStringOrNull(dto.value)
|
|
1421
|
+
})
|
|
1422
|
+
};
|
|
1423
|
+
var Milestone = {
|
|
1424
|
+
fromDto: (dto) => ({
|
|
1425
|
+
name: notBlankStringOrNull(dto.name),
|
|
1426
|
+
schedule: notBlankStringOrNull(dto.schedule),
|
|
1427
|
+
status: dto.status
|
|
1428
|
+
})
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
// src/universal/types/pagination.ts
|
|
1432
|
+
var Cursor = (value) => value;
|
|
1433
|
+
var PaginatedResponse = {
|
|
1434
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
1435
|
+
/**
|
|
1436
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
1437
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1438
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
1439
|
+
* page holds, not where the next page starts.
|
|
1440
|
+
*/
|
|
1441
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
1442
|
+
data: pageMapper(dto.data),
|
|
1443
|
+
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
1444
|
+
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
1445
|
+
})
|
|
1446
|
+
};
|
|
1447
|
+
var PaginationParams = {
|
|
1448
|
+
toQueryParams: (params) => {
|
|
1449
|
+
const queryParams = {};
|
|
1450
|
+
if (params.after) {
|
|
1451
|
+
queryParams.starting_after = params.after;
|
|
1452
|
+
}
|
|
1453
|
+
if (params.before) {
|
|
1454
|
+
queryParams.starting_before = params.before;
|
|
1455
|
+
}
|
|
1456
|
+
if (params.limit) {
|
|
1457
|
+
queryParams.limit = params.limit;
|
|
1458
|
+
}
|
|
1459
|
+
return queryParams;
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
// src/universal/types/providers/coin-list/token-sale.ts
|
|
1464
|
+
var ParticipationId = (value) => value;
|
|
1465
|
+
var Blockchain = (value) => value;
|
|
1466
|
+
var WalletAddress = (value) => value;
|
|
1467
|
+
var ParticipationsPaginationParams = {
|
|
1468
|
+
toQueryParams: (params) => {
|
|
1469
|
+
const queryParams = PaginationParams.toQueryParams(params);
|
|
1470
|
+
if (params.offerId) {
|
|
1471
|
+
queryParams["filters[0][field]"] = "offer_id";
|
|
1472
|
+
queryParams["filters[0][op]"] = "==";
|
|
1473
|
+
queryParams["filters[0][value]"] = params.offerId;
|
|
1474
|
+
}
|
|
1475
|
+
return queryParams;
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
var Participation = {
|
|
1479
|
+
/** Maps API DTO shape into the SDK participation domain model. */
|
|
1480
|
+
fromDto: (dto) => {
|
|
1481
|
+
const walletAddress = notBlankStringOrNull(dto.wallet_address);
|
|
1482
|
+
return {
|
|
1483
|
+
id: ParticipationId(dto.id),
|
|
1484
|
+
offerId: OfferId(dto.offer_id),
|
|
1485
|
+
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
1486
|
+
status: dto.status,
|
|
1487
|
+
amount: dto.amount,
|
|
1488
|
+
displayAmount: dto.amount_string,
|
|
1489
|
+
asset: Asset.fromDto(dto.asset),
|
|
1490
|
+
chain: Blockchain(dto.chain),
|
|
1491
|
+
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
1492
|
+
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
1493
|
+
walletAddress: walletAddress ? WalletAddress(walletAddress) : null
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
var CreateParticipationParams = {
|
|
1498
|
+
/** Maps participation creation params into API DTO payload. */
|
|
1499
|
+
toDto: (params) => ({
|
|
1500
|
+
offer_id: params.offerId,
|
|
1501
|
+
offer_option_id: params.offerOptionId,
|
|
1502
|
+
chain: params.chain,
|
|
1503
|
+
wallet_address: params.walletAddress,
|
|
1504
|
+
amount: params.amount,
|
|
1505
|
+
asset_id: params.assetId,
|
|
1506
|
+
approval_transaction_hash: params.approvalTransactionHash
|
|
1507
|
+
})
|
|
1508
|
+
};
|
|
1509
|
+
|
|
1510
|
+
// src/universal/api/pagination.ts
|
|
1511
|
+
async function fetchAllPages(fetchPage, baseParams) {
|
|
1512
|
+
const items = [];
|
|
1513
|
+
let cursor = null;
|
|
1514
|
+
do {
|
|
1515
|
+
const params = {
|
|
1516
|
+
...baseParams ?? {},
|
|
1517
|
+
after: cursor ?? void 0
|
|
1518
|
+
};
|
|
1519
|
+
const page = await fetchPage(params);
|
|
1520
|
+
items.push(...page.data);
|
|
1521
|
+
cursor = page.startingAfter;
|
|
1522
|
+
} while (cursor);
|
|
1523
|
+
return items;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
// src/universal/api/frontline/providers/coin-list/token-sale.ts
|
|
1527
|
+
async function fetchParticipations(api, offerId) {
|
|
1528
|
+
return fetchAllPages(
|
|
1529
|
+
(params) => fetchParticipationsPage(api, params),
|
|
1530
|
+
{ offerId }
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
async function fetchParticipationsPage(api, params) {
|
|
1534
|
+
const pageDto = await api.send({
|
|
1535
|
+
method: "GET",
|
|
1536
|
+
url: "/v1/participations",
|
|
1537
|
+
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
1538
|
+
attributes: Attributes.protected()
|
|
1539
|
+
});
|
|
1540
|
+
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
1541
|
+
}
|
|
1542
|
+
async function fetchParticipation(api, id) {
|
|
1543
|
+
const dto = await api.send({
|
|
1544
|
+
method: "GET",
|
|
1545
|
+
url: `/v1/participations/${id}`,
|
|
1546
|
+
attributes: Attributes.protected()
|
|
1547
|
+
});
|
|
1548
|
+
return Participation.fromDto(dto);
|
|
1549
|
+
}
|
|
1550
|
+
async function createParticipation(api, params) {
|
|
1551
|
+
const dto = await api.send({
|
|
1552
|
+
method: "POST",
|
|
1553
|
+
url: "/v1/participations",
|
|
1554
|
+
body: CreateParticipationParams.toDto(params),
|
|
1555
|
+
attributes: Attributes.protected()
|
|
1556
|
+
});
|
|
1557
|
+
return Participation.fromDto(dto);
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
// src/universal/core/providers/checkout/coin-list/token-sale-namespace.ts
|
|
1561
|
+
var CoinListTokenSaleNamespaceImpl = class {
|
|
1562
|
+
constructor(ctx) {
|
|
1563
|
+
this.ctx = ctx;
|
|
1564
|
+
this.log = internalLogger(ctx.logger, "TOKEN_SALE");
|
|
1565
|
+
}
|
|
1566
|
+
async list(offerId) {
|
|
1567
|
+
return this.log.wrap("list", offerId, async () => {
|
|
1568
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1569
|
+
return fetchParticipations(this.ctx.api, offerId);
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
async listPage(params) {
|
|
1573
|
+
return this.log.wrap("listPage", params, async () => {
|
|
1574
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1575
|
+
return fetchParticipationsPage(this.ctx.api, params);
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
async get(id) {
|
|
1579
|
+
return this.log.wrap("get", id, async () => {
|
|
1580
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1581
|
+
return fetchParticipation(this.ctx.api, id);
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
async createParticipation(params) {
|
|
1585
|
+
return this.log.wrap("createParticipation", params, async () => {
|
|
1586
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1587
|
+
return createParticipation(this.ctx.api, params);
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
|
|
1157
1592
|
// src/universal/core/shared/blockchain/chain.ts
|
|
1158
1593
|
import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
|
|
1159
1594
|
var VIEM_CHAINS = {
|
|
@@ -1212,66 +1647,6 @@ function explorerBaseUrl(chain) {
|
|
|
1212
1647
|
}
|
|
1213
1648
|
}
|
|
1214
1649
|
|
|
1215
|
-
// src/universal/core/shared/blockchain/math.ts
|
|
1216
|
-
import { parseUnits } from "viem";
|
|
1217
|
-
function blockchainAmountFromRawOrThrow({
|
|
1218
|
-
label,
|
|
1219
|
-
raw,
|
|
1220
|
-
decimals
|
|
1221
|
-
}) {
|
|
1222
|
-
const trimmed = raw.trim();
|
|
1223
|
-
if (trimmed === "") {
|
|
1224
|
-
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
1225
|
-
}
|
|
1226
|
-
let value;
|
|
1227
|
-
try {
|
|
1228
|
-
value = BigInt(trimmed);
|
|
1229
|
-
} catch {
|
|
1230
|
-
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
1231
|
-
}
|
|
1232
|
-
try {
|
|
1233
|
-
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
1234
|
-
} catch {
|
|
1235
|
-
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
function parseBlockchainAmount(amount, decimals) {
|
|
1239
|
-
const trimmed = amount.trim();
|
|
1240
|
-
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
1241
|
-
if (trimmed.startsWith("-")) {
|
|
1242
|
-
return { valid: false, reason: { type: "negative" } };
|
|
1243
|
-
}
|
|
1244
|
-
if (/[eE]/.test(trimmed)) {
|
|
1245
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1246
|
-
}
|
|
1247
|
-
if (trimmed === ".") {
|
|
1248
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1249
|
-
}
|
|
1250
|
-
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
1251
|
-
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
1252
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1253
|
-
}
|
|
1254
|
-
const [, fraction = ""] = normalised.split(".");
|
|
1255
|
-
if (fraction.length > decimals) {
|
|
1256
|
-
return {
|
|
1257
|
-
valid: false,
|
|
1258
|
-
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
1259
|
-
};
|
|
1260
|
-
}
|
|
1261
|
-
try {
|
|
1262
|
-
const raw = parseUnits(normalised, decimals);
|
|
1263
|
-
if (raw > MAX_UINT_256) {
|
|
1264
|
-
return { valid: false, reason: { type: "overflow" } };
|
|
1265
|
-
}
|
|
1266
|
-
return {
|
|
1267
|
-
valid: true,
|
|
1268
|
-
amount: BlockchainAmount({ raw, decimals })
|
|
1269
|
-
};
|
|
1270
|
-
} catch {
|
|
1271
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
1650
|
// src/universal/types/providers/ondo/ondo.ts
|
|
1276
1651
|
var OndoTradingStatus = {
|
|
1277
1652
|
fromDto: (dto) => {
|
|
@@ -1287,7 +1662,6 @@ var OndoTradingStatus = {
|
|
|
1287
1662
|
};
|
|
1288
1663
|
}
|
|
1289
1664
|
};
|
|
1290
|
-
var decimalOrNull = (value) => value === null ? null : DecimalString(value);
|
|
1291
1665
|
var OndoQuote = {
|
|
1292
1666
|
fromDto: (dto) => {
|
|
1293
1667
|
const assetDecimals = AssetDecimals(dto.asset_decimals);
|
|
@@ -1533,7 +1907,7 @@ function sizeParam(params) {
|
|
|
1533
1907
|
return { notional_value: notionalValue };
|
|
1534
1908
|
}
|
|
1535
1909
|
|
|
1536
|
-
// src/universal/core/checkout/ondo/ondo-namespace.ts
|
|
1910
|
+
// src/universal/core/providers/checkout/ondo/ondo-namespace.ts
|
|
1537
1911
|
var OndoNamespaceImpl = class {
|
|
1538
1912
|
constructor(ctx) {
|
|
1539
1913
|
this.ctx = ctx;
|
|
@@ -1565,7 +1939,102 @@ var OndoNamespaceImpl = class {
|
|
|
1565
1939
|
}
|
|
1566
1940
|
};
|
|
1567
1941
|
|
|
1568
|
-
// src/universal/
|
|
1942
|
+
// src/universal/types/providers/superstate/swap.ts
|
|
1943
|
+
var SwapPreview = {
|
|
1944
|
+
/** Maps the contract's `Preview { input, fee, output }` struct. */
|
|
1945
|
+
fromContract: (preview) => ({
|
|
1946
|
+
inputAmount: parseUint256(preview.input, "SwapPreview.input"),
|
|
1947
|
+
fee: parseUint256(preview.fee, "SwapPreview.fee"),
|
|
1948
|
+
outputAmount: parseUint256(preview.output, "SwapPreview.output")
|
|
1949
|
+
})
|
|
1950
|
+
};
|
|
1951
|
+
var PauseFlags = (value) => value;
|
|
1952
|
+
var SwapStatus = {
|
|
1953
|
+
/**
|
|
1954
|
+
* Maps the contract's `Status { uint32 flags; State state }` struct, where
|
|
1955
|
+
* `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
|
|
1956
|
+
*
|
|
1957
|
+
* `flags` is carried onto the `paused` arm only. On the other two the
|
|
1958
|
+
* contract sets it to a self-identifying marker rather than to information -
|
|
1959
|
+
* so repeating it would invite a caller to read meaning into a constant.
|
|
1960
|
+
*
|
|
1961
|
+
* @throws ValidationError on a `state` outside the enum. A contract that has
|
|
1962
|
+
* grown a fourth state is one the SDK does not model, and guessing `active`
|
|
1963
|
+
* would let a halted swap read as a live one.
|
|
1964
|
+
*/
|
|
1965
|
+
fromContract: (status) => {
|
|
1966
|
+
switch (status.state) {
|
|
1967
|
+
case 0:
|
|
1968
|
+
return { state: "active" };
|
|
1969
|
+
case 1:
|
|
1970
|
+
return { state: "paused", pausedLevels: PauseFlags(status.flags) };
|
|
1971
|
+
case 2:
|
|
1972
|
+
return { state: "stopped" };
|
|
1973
|
+
default:
|
|
1974
|
+
throw new ValidationError(
|
|
1975
|
+
`SwapStatus.state: unknown contract state (${status.state})`
|
|
1976
|
+
);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
var AllowWalletResponse = {
|
|
1981
|
+
fromDto: (dto) => {
|
|
1982
|
+
switch (dto.action) {
|
|
1983
|
+
case "broadcast_transaction":
|
|
1984
|
+
return {
|
|
1985
|
+
action: "broadcast_transaction",
|
|
1986
|
+
to: EvmContractAddress(dto.to),
|
|
1987
|
+
data: HexEncodedTransactionData(dto.data)
|
|
1988
|
+
};
|
|
1989
|
+
case "none":
|
|
1990
|
+
return {
|
|
1991
|
+
action: "none",
|
|
1992
|
+
alreadyAllowed: dto.already_allowed
|
|
1993
|
+
};
|
|
1994
|
+
default: {
|
|
1995
|
+
const _exhaustive = dto;
|
|
1996
|
+
return _exhaustive;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
2001
|
+
|
|
2002
|
+
// src/universal/core/providers/checkout/superstate/blockchain/quote.ts
|
|
2003
|
+
var SwapQuote = {
|
|
2004
|
+
/**
|
|
2005
|
+
* Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
|
|
2006
|
+
* input and fee are denominated in the input token; the output in the output
|
|
2007
|
+
* token.
|
|
2008
|
+
*/
|
|
2009
|
+
fromPreview: (preview, inputDecimals, outputDecimals) => ({
|
|
2010
|
+
inputTokenAmount: BlockchainAmount({
|
|
2011
|
+
raw: preview.inputAmount,
|
|
2012
|
+
decimals: inputDecimals
|
|
2013
|
+
}),
|
|
2014
|
+
fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
|
|
2015
|
+
outputTokenAmount: BlockchainAmount({
|
|
2016
|
+
raw: preview.outputAmount,
|
|
2017
|
+
decimals: outputDecimals
|
|
2018
|
+
})
|
|
2019
|
+
})
|
|
2020
|
+
};
|
|
2021
|
+
|
|
2022
|
+
// src/universal/api/frontline/providers/superstate/swap.ts
|
|
2023
|
+
async function allowWallet(api, params) {
|
|
2024
|
+
const dto = await api.send({
|
|
2025
|
+
method: "POST",
|
|
2026
|
+
url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
|
|
2027
|
+
body: {
|
|
2028
|
+
wallet_address: params.walletAddress,
|
|
2029
|
+
chain: params.chain,
|
|
2030
|
+
signature: params.signature
|
|
2031
|
+
},
|
|
2032
|
+
attributes: Attributes.protected()
|
|
2033
|
+
});
|
|
2034
|
+
return AllowWalletResponse.fromDto(dto);
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
// src/universal/core/providers/checkout/superstate/blockchain/abi.ts
|
|
1569
2038
|
var SUPERSTATE_SWAP_ABI = [
|
|
1570
2039
|
{
|
|
1571
2040
|
type: "function",
|
|
@@ -2418,100 +2887,125 @@ var SUPERSTATE_SWAP_ABI = [
|
|
|
2418
2887
|
type: "error",
|
|
2419
2888
|
name: "SwapFailed",
|
|
2420
2889
|
inputs: [
|
|
2421
|
-
{
|
|
2422
|
-
name: "user",
|
|
2423
|
-
type: "address",
|
|
2424
|
-
internalType: "address"
|
|
2425
|
-
},
|
|
2426
|
-
{
|
|
2427
|
-
name: "token",
|
|
2428
|
-
type: "address",
|
|
2429
|
-
internalType: "address"
|
|
2430
|
-
}
|
|
2431
|
-
]
|
|
2890
|
+
{
|
|
2891
|
+
name: "user",
|
|
2892
|
+
type: "address",
|
|
2893
|
+
internalType: "address"
|
|
2894
|
+
},
|
|
2895
|
+
{
|
|
2896
|
+
name: "token",
|
|
2897
|
+
type: "address",
|
|
2898
|
+
internalType: "address"
|
|
2899
|
+
}
|
|
2900
|
+
]
|
|
2901
|
+
},
|
|
2902
|
+
{
|
|
2903
|
+
type: "error",
|
|
2904
|
+
name: "Unauthorized",
|
|
2905
|
+
inputs: []
|
|
2906
|
+
}
|
|
2907
|
+
];
|
|
2908
|
+
|
|
2909
|
+
// src/universal/core/shared/blockchain/erc20/abi.ts
|
|
2910
|
+
var ERC20_ABI = [
|
|
2911
|
+
{
|
|
2912
|
+
type: "function",
|
|
2913
|
+
name: "allowance",
|
|
2914
|
+
inputs: [
|
|
2915
|
+
{ name: "owner", type: "address" },
|
|
2916
|
+
{ name: "spender", type: "address" }
|
|
2917
|
+
],
|
|
2918
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2919
|
+
stateMutability: "view"
|
|
2920
|
+
},
|
|
2921
|
+
{
|
|
2922
|
+
type: "function",
|
|
2923
|
+
name: "approve",
|
|
2924
|
+
inputs: [
|
|
2925
|
+
{ name: "spender", type: "address" },
|
|
2926
|
+
{ name: "amount", type: "uint256" }
|
|
2927
|
+
],
|
|
2928
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2929
|
+
stateMutability: "nonpayable"
|
|
2930
|
+
},
|
|
2931
|
+
{
|
|
2932
|
+
type: "function",
|
|
2933
|
+
name: "balanceOf",
|
|
2934
|
+
inputs: [{ name: "account", type: "address" }],
|
|
2935
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2936
|
+
stateMutability: "view"
|
|
2937
|
+
},
|
|
2938
|
+
{
|
|
2939
|
+
type: "function",
|
|
2940
|
+
name: "decimals",
|
|
2941
|
+
inputs: [],
|
|
2942
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
2943
|
+
stateMutability: "view"
|
|
2944
|
+
},
|
|
2945
|
+
{
|
|
2946
|
+
type: "function",
|
|
2947
|
+
name: "name",
|
|
2948
|
+
inputs: [],
|
|
2949
|
+
outputs: [{ name: "", type: "string" }],
|
|
2950
|
+
stateMutability: "view"
|
|
2951
|
+
},
|
|
2952
|
+
{
|
|
2953
|
+
type: "function",
|
|
2954
|
+
name: "symbol",
|
|
2955
|
+
inputs: [],
|
|
2956
|
+
outputs: [{ name: "", type: "string" }],
|
|
2957
|
+
stateMutability: "view"
|
|
2958
|
+
},
|
|
2959
|
+
{
|
|
2960
|
+
type: "function",
|
|
2961
|
+
name: "totalSupply",
|
|
2962
|
+
inputs: [],
|
|
2963
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2964
|
+
stateMutability: "view"
|
|
2965
|
+
},
|
|
2966
|
+
{
|
|
2967
|
+
type: "function",
|
|
2968
|
+
name: "transfer",
|
|
2969
|
+
inputs: [
|
|
2970
|
+
{ name: "recipient", type: "address" },
|
|
2971
|
+
{ name: "amount", type: "uint256" }
|
|
2972
|
+
],
|
|
2973
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2974
|
+
stateMutability: "nonpayable"
|
|
2975
|
+
},
|
|
2976
|
+
{
|
|
2977
|
+
type: "function",
|
|
2978
|
+
name: "transferFrom",
|
|
2979
|
+
inputs: [
|
|
2980
|
+
{ name: "sender", type: "address" },
|
|
2981
|
+
{ name: "recipient", type: "address" },
|
|
2982
|
+
{ name: "amount", type: "uint256" }
|
|
2983
|
+
],
|
|
2984
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2985
|
+
stateMutability: "nonpayable"
|
|
2986
|
+
},
|
|
2987
|
+
{
|
|
2988
|
+
type: "event",
|
|
2989
|
+
name: "Approval",
|
|
2990
|
+
inputs: [
|
|
2991
|
+
{ name: "owner", type: "address", indexed: true },
|
|
2992
|
+
{ name: "spender", type: "address", indexed: true },
|
|
2993
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
2994
|
+
],
|
|
2995
|
+
anonymous: false
|
|
2432
2996
|
},
|
|
2433
2997
|
{
|
|
2434
|
-
type: "
|
|
2435
|
-
name: "
|
|
2436
|
-
inputs: [
|
|
2998
|
+
type: "event",
|
|
2999
|
+
name: "Transfer",
|
|
3000
|
+
inputs: [
|
|
3001
|
+
{ name: "from", type: "address", indexed: true },
|
|
3002
|
+
{ name: "to", type: "address", indexed: true },
|
|
3003
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
3004
|
+
],
|
|
3005
|
+
anonymous: false
|
|
2437
3006
|
}
|
|
2438
3007
|
];
|
|
2439
3008
|
|
|
2440
|
-
// src/universal/types/providers/superstate/swap.ts
|
|
2441
|
-
var SwapPreview = {
|
|
2442
|
-
/** Maps the contract's `Preview { input, fee, output }` struct. */
|
|
2443
|
-
fromContract: (preview) => ({
|
|
2444
|
-
inputAmount: parseUint256(preview.input, "SwapPreview.input"),
|
|
2445
|
-
fee: parseUint256(preview.fee, "SwapPreview.fee"),
|
|
2446
|
-
outputAmount: parseUint256(preview.output, "SwapPreview.output")
|
|
2447
|
-
})
|
|
2448
|
-
};
|
|
2449
|
-
var PauseFlags = (value) => value;
|
|
2450
|
-
var SwapStatus = {
|
|
2451
|
-
/**
|
|
2452
|
-
* Maps the contract's `Status { uint32 flags; State state }` struct, where
|
|
2453
|
-
* `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
|
|
2454
|
-
*
|
|
2455
|
-
* `flags` is carried onto the `paused` arm only. On the other two the
|
|
2456
|
-
* contract sets it to a self-identifying marker rather than to information -
|
|
2457
|
-
* so repeating it would invite a caller to read meaning into a constant.
|
|
2458
|
-
*
|
|
2459
|
-
* @throws ValidationError on a `state` outside the enum. A contract that has
|
|
2460
|
-
* grown a fourth state is one the SDK does not model, and guessing `active`
|
|
2461
|
-
* would let a halted swap read as a live one.
|
|
2462
|
-
*/
|
|
2463
|
-
fromContract: (status) => {
|
|
2464
|
-
switch (status.state) {
|
|
2465
|
-
case 0:
|
|
2466
|
-
return { state: "active" };
|
|
2467
|
-
case 1:
|
|
2468
|
-
return { state: "paused", pausedLevels: PauseFlags(status.flags) };
|
|
2469
|
-
case 2:
|
|
2470
|
-
return { state: "stopped" };
|
|
2471
|
-
default:
|
|
2472
|
-
throw new ValidationError(
|
|
2473
|
-
`SwapStatus.state: unknown contract state (${status.state})`
|
|
2474
|
-
);
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
};
|
|
2478
|
-
var AllowWalletResponse = {
|
|
2479
|
-
fromDto: (dto) => {
|
|
2480
|
-
switch (dto.action) {
|
|
2481
|
-
case "broadcast_transaction":
|
|
2482
|
-
return {
|
|
2483
|
-
action: "broadcast_transaction",
|
|
2484
|
-
to: EvmContractAddress(dto.to),
|
|
2485
|
-
data: HexEncodedTransactionData(dto.data)
|
|
2486
|
-
};
|
|
2487
|
-
case "none":
|
|
2488
|
-
return {
|
|
2489
|
-
action: "none",
|
|
2490
|
-
alreadyAllowed: dto.already_allowed
|
|
2491
|
-
};
|
|
2492
|
-
default: {
|
|
2493
|
-
const _exhaustive = dto;
|
|
2494
|
-
return _exhaustive;
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
};
|
|
2499
|
-
|
|
2500
|
-
// src/universal/api/frontline/providers/superstate/swap.ts
|
|
2501
|
-
async function allowWallet(api, params) {
|
|
2502
|
-
const dto = await api.send({
|
|
2503
|
-
method: "POST",
|
|
2504
|
-
url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
|
|
2505
|
-
body: {
|
|
2506
|
-
wallet_address: params.walletAddress,
|
|
2507
|
-
chain: params.chain,
|
|
2508
|
-
signature: params.signature
|
|
2509
|
-
},
|
|
2510
|
-
attributes: Attributes.protected()
|
|
2511
|
-
});
|
|
2512
|
-
return AllowWalletResponse.fromDto(dto);
|
|
2513
|
-
}
|
|
2514
|
-
|
|
2515
3009
|
// src/universal/api/rpc/providers/superstate/swap.ts
|
|
2516
3010
|
async function getSwapAuthorization(clients, params) {
|
|
2517
3011
|
return clients(params.chain).readContract({
|
|
@@ -2561,7 +3055,7 @@ async function getSwapOutputToken(clients, params) {
|
|
|
2561
3055
|
};
|
|
2562
3056
|
}
|
|
2563
3057
|
|
|
2564
|
-
// src/universal/core/checkout/superstate/swap-namespace.ts
|
|
3058
|
+
// src/universal/core/providers/checkout/superstate/swap-namespace.ts
|
|
2565
3059
|
var SuperstateSwapNamespaceImpl = class {
|
|
2566
3060
|
constructor(ctx) {
|
|
2567
3061
|
this.ctx = ctx;
|
|
@@ -2581,6 +3075,20 @@ var SuperstateSwapNamespaceImpl = class {
|
|
|
2581
3075
|
async () => getSwapPreview(this.ctx.rpc, params)
|
|
2582
3076
|
);
|
|
2583
3077
|
}
|
|
3078
|
+
async getQuote(params) {
|
|
3079
|
+
return this.log.wrap("getQuote", params, async () => {
|
|
3080
|
+
const { amount, outputTokenDecimals, ...ref } = params;
|
|
3081
|
+
const preview = await getSwapPreview(this.ctx.rpc, {
|
|
3082
|
+
...ref,
|
|
3083
|
+
amount: amount.raw
|
|
3084
|
+
});
|
|
3085
|
+
return SwapQuote.fromPreview(
|
|
3086
|
+
preview,
|
|
3087
|
+
amount.decimals,
|
|
3088
|
+
outputTokenDecimals
|
|
3089
|
+
);
|
|
3090
|
+
});
|
|
3091
|
+
}
|
|
2584
3092
|
async getStatus(params) {
|
|
2585
3093
|
return this.log.wrap(
|
|
2586
3094
|
"getStatus",
|
|
@@ -2732,47 +3240,188 @@ async function fetchRequirementStatuses(api, offerId) {
|
|
|
2732
3240
|
var RequirementsNamespaceImpl = class {
|
|
2733
3241
|
constructor(ctx) {
|
|
2734
3242
|
this.ctx = ctx;
|
|
2735
|
-
this.log = internalLogger(ctx.logger, "REQUIREMENTS");
|
|
3243
|
+
this.log = internalLogger(ctx.logger, "REQUIREMENTS");
|
|
3244
|
+
}
|
|
3245
|
+
async forOffer(offerId) {
|
|
3246
|
+
return this.log.wrap("forOffer", offerId, async () => {
|
|
3247
|
+
await this.ctx.ensureUserAuthenticated();
|
|
3248
|
+
return fetchOfferRequirements(
|
|
3249
|
+
this.ctx.api,
|
|
3250
|
+
offerId,
|
|
3251
|
+
void 0
|
|
3252
|
+
);
|
|
3253
|
+
});
|
|
3254
|
+
}
|
|
3255
|
+
async statuses(offerId) {
|
|
3256
|
+
return this.log.wrap("statuses", offerId, async () => {
|
|
3257
|
+
await this.ctx.ensureUserAuthenticated();
|
|
3258
|
+
return fetchRequirementStatuses(this.ctx.api, offerId);
|
|
3259
|
+
});
|
|
3260
|
+
}
|
|
3261
|
+
async createKycToken(params) {
|
|
3262
|
+
return this.log.wrap("createKycToken", params, async () => {
|
|
3263
|
+
await this.ctx.ensureUserAuthenticated();
|
|
3264
|
+
return createKycToken(
|
|
3265
|
+
this.ctx.api,
|
|
3266
|
+
params?.levelName,
|
|
3267
|
+
params?.reset
|
|
3268
|
+
);
|
|
3269
|
+
});
|
|
3270
|
+
}
|
|
3271
|
+
async getPii() {
|
|
3272
|
+
return this.log.wrap("getPii", void 0, async () => {
|
|
3273
|
+
await this.ctx.ensureUserAuthenticated();
|
|
3274
|
+
return fetchPii(this.ctx.api);
|
|
3275
|
+
});
|
|
3276
|
+
}
|
|
3277
|
+
async submitDocument(params) {
|
|
3278
|
+
return this.log.wrap("submitDocument", params, async () => {
|
|
3279
|
+
await this.ctx.ensureUserAuthenticated();
|
|
3280
|
+
return submitDocument(
|
|
3281
|
+
this.ctx.api,
|
|
3282
|
+
params.documentType,
|
|
3283
|
+
params.fields
|
|
3284
|
+
);
|
|
3285
|
+
});
|
|
3286
|
+
}
|
|
3287
|
+
};
|
|
3288
|
+
|
|
3289
|
+
// src/universal/types/offer-option-address.ts
|
|
3290
|
+
var OfferOptionAddressId = (value) => value;
|
|
3291
|
+
var OfferOptionAddress = {
|
|
3292
|
+
/** Maps the API DTO into the SDK offer-option-address domain model. */
|
|
3293
|
+
fromDto: (dto) => ({
|
|
3294
|
+
id: OfferOptionAddressId(dto.id),
|
|
3295
|
+
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
3296
|
+
address: EvmWalletAddress(dto.address),
|
|
3297
|
+
protocol: dto.protocol,
|
|
3298
|
+
createdAt: new Date(dto.created_at)
|
|
3299
|
+
})
|
|
3300
|
+
};
|
|
3301
|
+
var ConnectExternalWalletParams = {
|
|
3302
|
+
/** Maps connect-wallet params into the API DTO payload. */
|
|
3303
|
+
toDto: (params) => ({
|
|
3304
|
+
offer_option_id: params.offerOptionId,
|
|
3305
|
+
wallet_address: params.walletAddress,
|
|
3306
|
+
chain: params.chain,
|
|
3307
|
+
signature: params.signature
|
|
3308
|
+
})
|
|
3309
|
+
};
|
|
3310
|
+
|
|
3311
|
+
// src/universal/types/wallet-ownership-challenge.ts
|
|
3312
|
+
var WalletOwnershipChallenge = {
|
|
3313
|
+
/** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
|
|
3314
|
+
fromDto: (dto) => ({
|
|
3315
|
+
message: dto.message,
|
|
3316
|
+
expiresAt: new Date(dto.expires_at)
|
|
3317
|
+
})
|
|
3318
|
+
};
|
|
3319
|
+
var CreateWalletOwnershipChallengeParams = {
|
|
3320
|
+
/**
|
|
3321
|
+
* Maps challenge-request params into the API DTO payload. The discriminated
|
|
3322
|
+
* union guarantees SIWE fields are present exactly when `challengeType` is
|
|
3323
|
+
* `siwe`, so the mapping narrows on the discriminant.
|
|
3324
|
+
*/
|
|
3325
|
+
toDto: (params) => {
|
|
3326
|
+
switch (params.challengeType) {
|
|
3327
|
+
case "plain":
|
|
3328
|
+
return {
|
|
3329
|
+
wallet_address: params.walletAddress,
|
|
3330
|
+
chain: params.chain,
|
|
3331
|
+
challenge_type: "plain"
|
|
3332
|
+
};
|
|
3333
|
+
case "siwe":
|
|
3334
|
+
return {
|
|
3335
|
+
wallet_address: params.walletAddress,
|
|
3336
|
+
chain: params.chain,
|
|
3337
|
+
challenge_type: "siwe",
|
|
3338
|
+
domain: params.domain,
|
|
3339
|
+
uri: params.uri,
|
|
3340
|
+
statement: params.statement
|
|
3341
|
+
};
|
|
3342
|
+
default: {
|
|
3343
|
+
const _exhaustive = params;
|
|
3344
|
+
return _exhaustive;
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
};
|
|
3349
|
+
|
|
3350
|
+
// src/universal/api/frontline/wallet-connect.ts
|
|
3351
|
+
async function createWalletOwnershipChallenge(api, params) {
|
|
3352
|
+
const dto = await api.send({
|
|
3353
|
+
method: "POST",
|
|
3354
|
+
url: "/v1/wallet-ownership",
|
|
3355
|
+
body: CreateWalletOwnershipChallengeParams.toDto(params),
|
|
3356
|
+
attributes: Attributes.protected()
|
|
3357
|
+
});
|
|
3358
|
+
return WalletOwnershipChallenge.fromDto(dto);
|
|
3359
|
+
}
|
|
3360
|
+
async function connectExternalWallet(api, params) {
|
|
3361
|
+
const dto = await api.send({
|
|
3362
|
+
method: "POST",
|
|
3363
|
+
url: `/v1/offers/${params.offerId}/addresses`,
|
|
3364
|
+
body: ConnectExternalWalletParams.toDto(params),
|
|
3365
|
+
attributes: Attributes.protected()
|
|
3366
|
+
});
|
|
3367
|
+
return OfferOptionAddress.fromDto(dto);
|
|
3368
|
+
}
|
|
3369
|
+
async function listOptionAddresses(api, offerId, offerOptionId) {
|
|
3370
|
+
const { data } = await api.send({
|
|
3371
|
+
method: "GET",
|
|
3372
|
+
url: `/v1/offers/${offerId}/addresses`,
|
|
3373
|
+
queryParams: { offer_option_id: offerOptionId },
|
|
3374
|
+
attributes: Attributes.protected()
|
|
3375
|
+
});
|
|
3376
|
+
return data.map(OfferOptionAddress.fromDto);
|
|
3377
|
+
}
|
|
3378
|
+
async function removeOptionAddress(api, offerId, addressId) {
|
|
3379
|
+
const dto = await api.send({
|
|
3380
|
+
method: "DELETE",
|
|
3381
|
+
url: `/v1/offers/${offerId}/addresses/${addressId}`,
|
|
3382
|
+
attributes: Attributes.protected()
|
|
3383
|
+
});
|
|
3384
|
+
return OfferOptionAddress.fromDto(dto);
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
// src/universal/core/wallets/wallets-namespace.ts
|
|
3388
|
+
var WalletsNamespaceImpl = class {
|
|
3389
|
+
constructor(ctx) {
|
|
3390
|
+
this.ctx = ctx;
|
|
3391
|
+
this.log = internalLogger(ctx.logger, "WALLETS");
|
|
2736
3392
|
}
|
|
2737
|
-
async
|
|
2738
|
-
return this.log.wrap("
|
|
3393
|
+
async createOwnershipChallenge(params) {
|
|
3394
|
+
return this.log.wrap("createOwnershipChallenge", params, async () => {
|
|
2739
3395
|
await this.ctx.ensureUserAuthenticated();
|
|
2740
|
-
return
|
|
3396
|
+
return createWalletOwnershipChallenge(
|
|
2741
3397
|
this.ctx.api,
|
|
2742
|
-
|
|
2743
|
-
void 0
|
|
3398
|
+
params
|
|
2744
3399
|
);
|
|
2745
3400
|
});
|
|
2746
3401
|
}
|
|
2747
|
-
async
|
|
2748
|
-
return this.log.wrap("
|
|
3402
|
+
async connectExternal(params) {
|
|
3403
|
+
return this.log.wrap("connectExternal", params, async () => {
|
|
2749
3404
|
await this.ctx.ensureUserAuthenticated();
|
|
2750
|
-
return
|
|
3405
|
+
return connectExternalWallet(this.ctx.api, params);
|
|
2751
3406
|
});
|
|
2752
3407
|
}
|
|
2753
|
-
async
|
|
2754
|
-
return this.log.wrap("
|
|
3408
|
+
async list(params) {
|
|
3409
|
+
return this.log.wrap("list", params, async () => {
|
|
2755
3410
|
await this.ctx.ensureUserAuthenticated();
|
|
2756
|
-
return
|
|
3411
|
+
return listOptionAddresses(
|
|
2757
3412
|
this.ctx.api,
|
|
2758
|
-
params
|
|
2759
|
-
params
|
|
3413
|
+
params.offerId,
|
|
3414
|
+
params.offerOptionId
|
|
2760
3415
|
);
|
|
2761
3416
|
});
|
|
2762
3417
|
}
|
|
2763
|
-
async
|
|
2764
|
-
return this.log.wrap("
|
|
2765
|
-
await this.ctx.ensureUserAuthenticated();
|
|
2766
|
-
return fetchPii(this.ctx.api);
|
|
2767
|
-
});
|
|
2768
|
-
}
|
|
2769
|
-
async submitDocument(params) {
|
|
2770
|
-
return this.log.wrap("submitDocument", params, async () => {
|
|
3418
|
+
async remove(params) {
|
|
3419
|
+
return this.log.wrap("remove", params, async () => {
|
|
2771
3420
|
await this.ctx.ensureUserAuthenticated();
|
|
2772
|
-
return
|
|
3421
|
+
return removeOptionAddress(
|
|
2773
3422
|
this.ctx.api,
|
|
2774
|
-
params.
|
|
2775
|
-
params.
|
|
3423
|
+
params.offerId,
|
|
3424
|
+
params.addressId
|
|
2776
3425
|
);
|
|
2777
3426
|
});
|
|
2778
3427
|
}
|
|
@@ -2944,11 +3593,18 @@ var HttpClient = class {
|
|
|
2944
3593
|
);
|
|
2945
3594
|
let response = await this.executeRequest(preparedRequest);
|
|
2946
3595
|
for (const middleware of this.middleware.afterRequest ?? []) {
|
|
3596
|
+
let retried = false;
|
|
2947
3597
|
response = await middleware({
|
|
2948
3598
|
request: preparedRequest,
|
|
2949
3599
|
response,
|
|
2950
|
-
retry: (nextRequest = preparedRequest) =>
|
|
3600
|
+
retry: (nextRequest = preparedRequest) => {
|
|
3601
|
+
retried = true;
|
|
3602
|
+
return this.runRequestWithAfterMiddleware(nextRequest);
|
|
3603
|
+
}
|
|
2951
3604
|
});
|
|
3605
|
+
if (retried) {
|
|
3606
|
+
return response;
|
|
3607
|
+
}
|
|
2952
3608
|
}
|
|
2953
3609
|
return response;
|
|
2954
3610
|
}
|
|
@@ -3193,163 +3849,6 @@ var TokensNamespaceImpl = class {
|
|
|
3193
3849
|
}
|
|
3194
3850
|
};
|
|
3195
3851
|
|
|
3196
|
-
// src/universal/types/offer-option-address.ts
|
|
3197
|
-
var OfferOptionAddressId = (value) => value;
|
|
3198
|
-
var OfferOptionAddress = {
|
|
3199
|
-
/** Maps the API DTO into the SDK offer-option-address domain model. */
|
|
3200
|
-
fromDto: (dto) => ({
|
|
3201
|
-
id: OfferOptionAddressId(dto.id),
|
|
3202
|
-
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
3203
|
-
address: EvmWalletAddress(dto.address),
|
|
3204
|
-
protocol: dto.protocol,
|
|
3205
|
-
createdAt: new Date(dto.created_at)
|
|
3206
|
-
})
|
|
3207
|
-
};
|
|
3208
|
-
var ConnectExternalWalletParams = {
|
|
3209
|
-
/** Maps connect-wallet params into the API DTO payload. */
|
|
3210
|
-
toDto: (params) => ({
|
|
3211
|
-
offer_option_id: params.offerOptionId,
|
|
3212
|
-
wallet_address: params.walletAddress,
|
|
3213
|
-
chain: params.chain,
|
|
3214
|
-
signature: params.signature
|
|
3215
|
-
})
|
|
3216
|
-
};
|
|
3217
|
-
|
|
3218
|
-
// src/universal/types/wallet-ownership-challenge.ts
|
|
3219
|
-
var WalletOwnershipChallenge = {
|
|
3220
|
-
/** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
|
|
3221
|
-
fromDto: (dto) => ({
|
|
3222
|
-
message: dto.message,
|
|
3223
|
-
expiresAt: new Date(dto.expires_at)
|
|
3224
|
-
})
|
|
3225
|
-
};
|
|
3226
|
-
var CreateWalletOwnershipChallengeParams = {
|
|
3227
|
-
/**
|
|
3228
|
-
* Maps challenge-request params into the API DTO payload. The discriminated
|
|
3229
|
-
* union guarantees SIWE fields are present exactly when `challengeType` is
|
|
3230
|
-
* `siwe`, so the mapping narrows on the discriminant.
|
|
3231
|
-
*/
|
|
3232
|
-
toDto: (params) => {
|
|
3233
|
-
switch (params.challengeType) {
|
|
3234
|
-
case "plain":
|
|
3235
|
-
return {
|
|
3236
|
-
wallet_address: params.walletAddress,
|
|
3237
|
-
chain: params.chain,
|
|
3238
|
-
challenge_type: "plain"
|
|
3239
|
-
};
|
|
3240
|
-
case "siwe":
|
|
3241
|
-
return {
|
|
3242
|
-
wallet_address: params.walletAddress,
|
|
3243
|
-
chain: params.chain,
|
|
3244
|
-
challenge_type: "siwe",
|
|
3245
|
-
domain: params.domain,
|
|
3246
|
-
uri: params.uri,
|
|
3247
|
-
statement: params.statement
|
|
3248
|
-
};
|
|
3249
|
-
default: {
|
|
3250
|
-
const _exhaustive = params;
|
|
3251
|
-
return _exhaustive;
|
|
3252
|
-
}
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
};
|
|
3256
|
-
|
|
3257
|
-
// src/universal/api/frontline/wallet-connect.ts
|
|
3258
|
-
async function createWalletOwnershipChallenge(api, params) {
|
|
3259
|
-
const dto = await api.send({
|
|
3260
|
-
method: "POST",
|
|
3261
|
-
url: "/v1/wallet-ownership",
|
|
3262
|
-
body: CreateWalletOwnershipChallengeParams.toDto(params),
|
|
3263
|
-
attributes: Attributes.protected()
|
|
3264
|
-
});
|
|
3265
|
-
return WalletOwnershipChallenge.fromDto(dto);
|
|
3266
|
-
}
|
|
3267
|
-
async function connectExternalWallet(api, params) {
|
|
3268
|
-
const dto = await api.send({
|
|
3269
|
-
method: "POST",
|
|
3270
|
-
url: `/v1/offers/${params.offerId}/addresses`,
|
|
3271
|
-
body: ConnectExternalWalletParams.toDto(params),
|
|
3272
|
-
attributes: Attributes.protected()
|
|
3273
|
-
});
|
|
3274
|
-
return OfferOptionAddress.fromDto(dto);
|
|
3275
|
-
}
|
|
3276
|
-
async function listOptionAddresses(api, offerId, offerOptionId) {
|
|
3277
|
-
const { data } = await api.send({
|
|
3278
|
-
method: "GET",
|
|
3279
|
-
url: `/v1/offers/${offerId}/addresses`,
|
|
3280
|
-
queryParams: { offer_option_id: offerOptionId },
|
|
3281
|
-
attributes: Attributes.protected()
|
|
3282
|
-
});
|
|
3283
|
-
return data.map(OfferOptionAddress.fromDto);
|
|
3284
|
-
}
|
|
3285
|
-
async function removeOptionAddress(api, offerId, addressId) {
|
|
3286
|
-
const dto = await api.send({
|
|
3287
|
-
method: "DELETE",
|
|
3288
|
-
url: `/v1/offers/${offerId}/addresses/${addressId}`,
|
|
3289
|
-
attributes: Attributes.protected()
|
|
3290
|
-
});
|
|
3291
|
-
return OfferOptionAddress.fromDto(dto);
|
|
3292
|
-
}
|
|
3293
|
-
|
|
3294
|
-
// src/universal/core/wallets/wallets-namespace.ts
|
|
3295
|
-
var WalletsNamespaceImpl = class {
|
|
3296
|
-
constructor(ctx) {
|
|
3297
|
-
this.ctx = ctx;
|
|
3298
|
-
this.log = internalLogger(ctx.logger, "WALLETS");
|
|
3299
|
-
}
|
|
3300
|
-
async createOwnershipChallenge(params) {
|
|
3301
|
-
return this.log.wrap("createOwnershipChallenge", params, async () => {
|
|
3302
|
-
await this.ctx.ensureUserAuthenticated();
|
|
3303
|
-
return createWalletOwnershipChallenge(
|
|
3304
|
-
this.ctx.api,
|
|
3305
|
-
params
|
|
3306
|
-
);
|
|
3307
|
-
});
|
|
3308
|
-
}
|
|
3309
|
-
async connectExternal(params) {
|
|
3310
|
-
return this.log.wrap("connectExternal", params, async () => {
|
|
3311
|
-
await this.ctx.ensureUserAuthenticated();
|
|
3312
|
-
return connectExternalWallet(this.ctx.api, params);
|
|
3313
|
-
});
|
|
3314
|
-
}
|
|
3315
|
-
async list(params) {
|
|
3316
|
-
return this.log.wrap("list", params, async () => {
|
|
3317
|
-
await this.ctx.ensureUserAuthenticated();
|
|
3318
|
-
return listOptionAddresses(
|
|
3319
|
-
this.ctx.api,
|
|
3320
|
-
params.offerId,
|
|
3321
|
-
params.offerOptionId
|
|
3322
|
-
);
|
|
3323
|
-
});
|
|
3324
|
-
}
|
|
3325
|
-
async remove(params) {
|
|
3326
|
-
return this.log.wrap("remove", params, async () => {
|
|
3327
|
-
await this.ctx.ensureUserAuthenticated();
|
|
3328
|
-
return removeOptionAddress(
|
|
3329
|
-
this.ctx.api,
|
|
3330
|
-
params.offerId,
|
|
3331
|
-
params.addressId
|
|
3332
|
-
);
|
|
3333
|
-
});
|
|
3334
|
-
}
|
|
3335
|
-
};
|
|
3336
|
-
|
|
3337
|
-
// src/universal/types/oauth-session.ts
|
|
3338
|
-
var ClientCredentialsOAuth = (value) => value;
|
|
3339
|
-
var OAuthRefreshToken = (value) => value;
|
|
3340
|
-
var OAuthSession = {
|
|
3341
|
-
fromDto: (dto) => {
|
|
3342
|
-
const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
|
|
3343
|
-
return {
|
|
3344
|
-
accessToken: {
|
|
3345
|
-
value: dto.access_token,
|
|
3346
|
-
expiresAt
|
|
3347
|
-
},
|
|
3348
|
-
...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
|
|
3349
|
-
};
|
|
3350
|
-
}
|
|
3351
|
-
};
|
|
3352
|
-
|
|
3353
3852
|
// src/universal/api/frontline/offers.ts
|
|
3354
3853
|
async function fetchOffers(api, clientCreds) {
|
|
3355
3854
|
return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
|
|
@@ -3394,6 +3893,9 @@ export {
|
|
|
3394
3893
|
VERIFY_IDENTITY_PATH,
|
|
3395
3894
|
VERIFY_IDENTITY_ACCREDITATION_PATH,
|
|
3396
3895
|
WALLET_PATH,
|
|
3896
|
+
SentWith,
|
|
3897
|
+
TokenTrigger,
|
|
3898
|
+
isRejectedToken,
|
|
3397
3899
|
Attributes,
|
|
3398
3900
|
HttpError,
|
|
3399
3901
|
apiErrorCode,
|
|
@@ -3403,17 +3905,15 @@ export {
|
|
|
3403
3905
|
ValidationError,
|
|
3404
3906
|
InvariantError,
|
|
3405
3907
|
MathError,
|
|
3908
|
+
classifyLogCause,
|
|
3406
3909
|
describeErrorUnredacted,
|
|
3407
3910
|
internalLogger,
|
|
3408
3911
|
HttpClient,
|
|
3912
|
+
EpochMillis,
|
|
3913
|
+
Millis,
|
|
3914
|
+
Seconds,
|
|
3915
|
+
isExpired,
|
|
3409
3916
|
ERC20_ABI,
|
|
3410
|
-
fetchAllPages,
|
|
3411
|
-
Cursor,
|
|
3412
|
-
PaginatedResponse,
|
|
3413
|
-
PaginationParams,
|
|
3414
|
-
AssetId,
|
|
3415
|
-
AssetCode,
|
|
3416
|
-
Asset,
|
|
3417
3917
|
ETHEREUM_CHAINS,
|
|
3418
3918
|
EthereumChain,
|
|
3419
3919
|
SOLANA_CHAINS,
|
|
@@ -3435,6 +3935,38 @@ export {
|
|
|
3435
3935
|
StablecoinSymbol,
|
|
3436
3936
|
KnownAssetSymbol,
|
|
3437
3937
|
Bps,
|
|
3938
|
+
blockchainAmountFromRawOrThrow,
|
|
3939
|
+
parseBlockchainAmount,
|
|
3940
|
+
CentrifugeVaultStatus,
|
|
3941
|
+
CentrifugeVaultBuyTransaction,
|
|
3942
|
+
CentrifugeVaultClaimTransaction,
|
|
3943
|
+
CentrifugeAssets,
|
|
3944
|
+
CentrifugeShares,
|
|
3945
|
+
CentrifugeDepositPosition,
|
|
3946
|
+
CentrifugeRedeemPosition,
|
|
3947
|
+
CentrifugeVaultLeg,
|
|
3948
|
+
CentrifugeVaultLegId,
|
|
3949
|
+
CentrifugeVaultClaimProceedsTransaction,
|
|
3950
|
+
CentrifugeNamespaceImpl,
|
|
3951
|
+
FormattedAmountUi,
|
|
3952
|
+
FormattedPercentUi,
|
|
3953
|
+
TxExplorerUrl,
|
|
3954
|
+
ShortenedWalletAddress,
|
|
3955
|
+
FormattedAmountAssetUi,
|
|
3956
|
+
AssetIconUrl,
|
|
3957
|
+
shortenAddress,
|
|
3958
|
+
formatAmount,
|
|
3959
|
+
formatRawAmount,
|
|
3960
|
+
formatCompactAmount,
|
|
3961
|
+
formatBpsAsPercent,
|
|
3962
|
+
usdAmount,
|
|
3963
|
+
assetAmount,
|
|
3964
|
+
NA_AMOUNT_ASSET_UI,
|
|
3965
|
+
formatShareAmount,
|
|
3966
|
+
formattedUsdPrice,
|
|
3967
|
+
AssetId,
|
|
3968
|
+
AssetCode,
|
|
3969
|
+
Asset,
|
|
3438
3970
|
OfferId,
|
|
3439
3971
|
OfferSlug,
|
|
3440
3972
|
isOfferType,
|
|
@@ -3443,15 +3975,20 @@ export {
|
|
|
3443
3975
|
OfferToken,
|
|
3444
3976
|
Ticker,
|
|
3445
3977
|
Isin,
|
|
3978
|
+
AsyncOfferDetail,
|
|
3446
3979
|
OfferOptionId,
|
|
3447
3980
|
OfferOptionSlug,
|
|
3448
3981
|
OfferSwapContract,
|
|
3982
|
+
OfferVaultContract,
|
|
3449
3983
|
OfferDetail,
|
|
3450
3984
|
OfferOption,
|
|
3451
3985
|
FaqItem,
|
|
3452
3986
|
Link,
|
|
3453
3987
|
TermItem,
|
|
3454
3988
|
Milestone,
|
|
3989
|
+
Cursor,
|
|
3990
|
+
PaginatedResponse,
|
|
3991
|
+
PaginationParams,
|
|
3455
3992
|
ParticipationId,
|
|
3456
3993
|
Blockchain,
|
|
3457
3994
|
WalletAddress,
|
|
@@ -3459,28 +3996,11 @@ export {
|
|
|
3459
3996
|
Participation,
|
|
3460
3997
|
CreateParticipationParams,
|
|
3461
3998
|
CoinListTokenSaleNamespaceImpl,
|
|
3462
|
-
FormattedAmountUi,
|
|
3463
|
-
FormattedPercentUi,
|
|
3464
|
-
TxExplorerUrl,
|
|
3465
|
-
ShortenedWalletAddress,
|
|
3466
|
-
FormattedAmountAssetUi,
|
|
3467
|
-
AssetIconUrl,
|
|
3468
|
-
shortenAddress,
|
|
3469
|
-
formatAmount,
|
|
3470
|
-
formatRawAmount,
|
|
3471
|
-
formatCompactAmount,
|
|
3472
|
-
formatBpsAsPercent,
|
|
3473
|
-
usdAmount,
|
|
3474
|
-
assetAmount,
|
|
3475
|
-
NA_AMOUNT_ASSET_UI,
|
|
3476
|
-
formattedUsdPrice,
|
|
3477
3999
|
viemChain,
|
|
3478
4000
|
getChainId,
|
|
3479
4001
|
chainFromId,
|
|
3480
4002
|
getNetworkName,
|
|
3481
4003
|
txExplorerUrl,
|
|
3482
|
-
blockchainAmountFromRawOrThrow,
|
|
3483
|
-
parseBlockchainAmount,
|
|
3484
4004
|
OndoTradingStatus,
|
|
3485
4005
|
OndoQuote,
|
|
3486
4006
|
OndoBuyTransaction,
|
|
@@ -3491,10 +4011,8 @@ export {
|
|
|
3491
4011
|
PauseFlags,
|
|
3492
4012
|
SwapStatus,
|
|
3493
4013
|
AllowWalletResponse,
|
|
4014
|
+
SwapQuote,
|
|
3494
4015
|
SuperstateSwapNamespaceImpl,
|
|
3495
|
-
fetchOffers,
|
|
3496
|
-
fetchOffersPage,
|
|
3497
|
-
fetchOfferDetails,
|
|
3498
4016
|
DocumentSubmission,
|
|
3499
4017
|
KycToken,
|
|
3500
4018
|
Iso2CountryCode,
|
|
@@ -3506,19 +4024,19 @@ export {
|
|
|
3506
4024
|
RequirementStatusInfo,
|
|
3507
4025
|
fetchOfferRequirements,
|
|
3508
4026
|
RequirementsNamespaceImpl,
|
|
3509
|
-
Erc20NamespaceImpl,
|
|
3510
|
-
TokenLogoUrl,
|
|
3511
|
-
TokenLogo,
|
|
3512
|
-
TokenMetadata,
|
|
3513
|
-
TokensNamespaceImpl,
|
|
3514
4027
|
OfferOptionAddressId,
|
|
3515
4028
|
OfferOptionAddress,
|
|
3516
4029
|
ConnectExternalWalletParams,
|
|
3517
4030
|
WalletOwnershipChallenge,
|
|
3518
4031
|
CreateWalletOwnershipChallengeParams,
|
|
3519
4032
|
WalletsNamespaceImpl,
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
4033
|
+
fetchOffers,
|
|
4034
|
+
fetchOffersPage,
|
|
4035
|
+
fetchOfferDetails,
|
|
4036
|
+
Erc20NamespaceImpl,
|
|
4037
|
+
TokenLogoUrl,
|
|
4038
|
+
TokenLogo,
|
|
4039
|
+
TokenMetadata,
|
|
4040
|
+
TokensNamespaceImpl
|
|
3523
4041
|
};
|
|
3524
|
-
//# sourceMappingURL=chunk-
|
|
4042
|
+
//# sourceMappingURL=chunk-SVPFFLIT.js.map
|