@coinlist-co/react 0.11.0 → 0.11.1-rc.8cfcd2a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-B2HCVPCQ.js → chunk-5KYO7OOX.js} +26 -11
- package/dist/chunk-5KYO7OOX.js.map +1 -0
- package/dist/chunk-AQIHCFW4.js +279 -0
- package/dist/chunk-AQIHCFW4.js.map +1 -0
- package/dist/{chunk-UIIXXLA7.js → chunk-ZVB6KWZ2.js} +484 -141
- package/dist/chunk-ZVB6KWZ2.js.map +1 -0
- package/dist/client/index.cjs +1308 -462
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +216 -211
- package/dist/client/index.d.ts +216 -211
- package/dist/client/index.js +464 -108
- package/dist/client/index.js.map +1 -1
- package/dist/collections-DrJFEDHl.d.cts +116 -0
- package/dist/collections-pLtrj6fw.d.ts +116 -0
- package/dist/{config-B5mwS_2l.d.cts → config-C6vlghJY.d.cts} +713 -22
- package/dist/{config-B5mwS_2l.d.ts → config-C6vlghJY.d.ts} +713 -22
- package/dist/server/index.cjs +766 -209
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +80 -3
- package/dist/server/index.d.ts +80 -3
- package/dist/server/index.js +120 -51
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +487 -124
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +18 -5
- package/dist/shared/index.d.ts +18 -5
- package/dist/shared/index.js +8 -2
- package/package.json +3 -2
- package/dist/chunk-B2HCVPCQ.js.map +0 -1
- package/dist/chunk-KDGNDAHA.js +0 -146
- package/dist/chunk-KDGNDAHA.js.map +0 -1
- package/dist/chunk-UIIXXLA7.js.map +0 -1
- package/dist/collections-BhDkYmzV.d.cts +0 -65
- package/dist/collections-CZhHoQHr.d.ts +0 -65
|
@@ -25,6 +25,8 @@ var retryAttempt = (attempt) => ({
|
|
|
25
25
|
var renewAttempted = (value) => ({
|
|
26
26
|
renewAttempted: value
|
|
27
27
|
});
|
|
28
|
+
var requestId = (id) => ({ requestId: id });
|
|
29
|
+
var getRequestId = (attrs) => attrs?.requestId ?? null;
|
|
28
30
|
var isProtected = (attrs) => attrs?.protected === true;
|
|
29
31
|
var needUserAgent = (attrs) => attrs?.userAgent === true;
|
|
30
32
|
var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
|
|
@@ -46,7 +48,9 @@ var Attributes = {
|
|
|
46
48
|
renewAttempted,
|
|
47
49
|
wasRenewAttempted,
|
|
48
50
|
clientCredentials,
|
|
49
|
-
getClientCredentials
|
|
51
|
+
getClientCredentials,
|
|
52
|
+
requestId,
|
|
53
|
+
getRequestId
|
|
50
54
|
};
|
|
51
55
|
|
|
52
56
|
// src/shared/api/http.ts
|
|
@@ -56,6 +60,16 @@ var HttpError = class extends Error {
|
|
|
56
60
|
this.name = "HttpError";
|
|
57
61
|
this.response = response;
|
|
58
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Correlates this failure with the `[HTTP]` log lines for the same request,
|
|
65
|
+
* which carry the method, the URL, the duration and every retry. `null` when
|
|
66
|
+
* the response did not come from an {@link HttpClient}.
|
|
67
|
+
*
|
|
68
|
+
* Worth quoting in a bug report: it is what makes a log excerpt readable.
|
|
69
|
+
*/
|
|
70
|
+
get requestId() {
|
|
71
|
+
return this.response.requestId ?? null;
|
|
72
|
+
}
|
|
59
73
|
};
|
|
60
74
|
function apiErrorCode(error) {
|
|
61
75
|
if (!(error instanceof HttpError)) return null;
|
|
@@ -163,22 +177,6 @@ var Request = {
|
|
|
163
177
|
concatAttributes
|
|
164
178
|
};
|
|
165
179
|
|
|
166
|
-
// src/shared/api/pagination.ts
|
|
167
|
-
async function fetchAllPages(fetchPage, baseParams) {
|
|
168
|
-
const items = [];
|
|
169
|
-
let cursor = null;
|
|
170
|
-
do {
|
|
171
|
-
const params = {
|
|
172
|
-
...baseParams ?? {},
|
|
173
|
-
after: cursor ?? void 0
|
|
174
|
-
};
|
|
175
|
-
const page = await fetchPage(params);
|
|
176
|
-
items.push(...page.data);
|
|
177
|
-
cursor = page.startingAfter;
|
|
178
|
-
} while (cursor);
|
|
179
|
-
return items;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
180
|
// src/shared/types/errors.ts
|
|
183
181
|
var NotImplementedError = class extends Error {
|
|
184
182
|
constructor(message = "Not implemented yet") {
|
|
@@ -198,6 +196,28 @@ var ValidationError = class extends Error {
|
|
|
198
196
|
this.name = "ValidationError";
|
|
199
197
|
}
|
|
200
198
|
};
|
|
199
|
+
var InvariantError = class extends Error {
|
|
200
|
+
constructor(message) {
|
|
201
|
+
super(message);
|
|
202
|
+
this.name = "InvariantError";
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// src/shared/api/pagination.ts
|
|
207
|
+
async function fetchAllPages(fetchPage, baseParams) {
|
|
208
|
+
const items = [];
|
|
209
|
+
let cursor = null;
|
|
210
|
+
do {
|
|
211
|
+
const params = {
|
|
212
|
+
...baseParams ?? {},
|
|
213
|
+
after: cursor ?? void 0
|
|
214
|
+
};
|
|
215
|
+
const page = await fetchPage(params);
|
|
216
|
+
items.push(...page.data);
|
|
217
|
+
cursor = page.startingAfter;
|
|
218
|
+
} while (cursor);
|
|
219
|
+
return items;
|
|
220
|
+
}
|
|
201
221
|
|
|
202
222
|
// src/shared/types/blockchain/core.ts
|
|
203
223
|
var ETHEREUM_CHAINS = {
|
|
@@ -245,11 +265,14 @@ var STABLE_DECIMALS = AssetDecimals(6);
|
|
|
245
265
|
var DecimalString = (value) => value;
|
|
246
266
|
var MAX_UINT_256 = 2n ** 256n - 1n;
|
|
247
267
|
var assertUint256 = (value) => {
|
|
248
|
-
if (value
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
return value;
|
|
268
|
+
if (isUint256(value)) return value;
|
|
269
|
+
throw new InvariantError(`Value out of uint256 bounds: ${value}`);
|
|
252
270
|
};
|
|
271
|
+
var parseUint256 = (value, label) => {
|
|
272
|
+
if (isUint256(value)) return value;
|
|
273
|
+
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
274
|
+
};
|
|
275
|
+
var isUint256 = (value) => value >= 0n && value <= MAX_UINT_256;
|
|
253
276
|
var BlockchainAmount = Object.assign(
|
|
254
277
|
(value) => value,
|
|
255
278
|
{
|
|
@@ -259,13 +282,13 @@ var BlockchainAmount = Object.assign(
|
|
|
259
282
|
);
|
|
260
283
|
function combineAmounts(a, b, op) {
|
|
261
284
|
if (a.decimals !== b.decimals) {
|
|
262
|
-
throw new
|
|
285
|
+
throw new InvariantError(
|
|
263
286
|
`Cannot combine BlockchainAmounts with different decimals: ${a.decimals} vs ${b.decimals}`
|
|
264
287
|
);
|
|
265
288
|
}
|
|
266
289
|
const raw = op(a.raw, b.raw);
|
|
267
290
|
if (raw < 0n || raw > MAX_UINT_256) {
|
|
268
|
-
throw new
|
|
291
|
+
throw new InvariantError(`BlockchainAmount out of uint256 bounds: ${raw}`);
|
|
269
292
|
}
|
|
270
293
|
return BlockchainAmount({ raw, decimals: a.decimals });
|
|
271
294
|
}
|
|
@@ -334,25 +357,31 @@ var SwapAuthorization = {
|
|
|
334
357
|
};
|
|
335
358
|
var SwapPreview = {
|
|
336
359
|
fromDto: (dto) => ({
|
|
337
|
-
inputAmount:
|
|
338
|
-
|
|
339
|
-
|
|
360
|
+
inputAmount: parseUint256(
|
|
361
|
+
BigInt(dto.pay_input_amount),
|
|
362
|
+
"SwapPreview.pay_input_amount"
|
|
363
|
+
),
|
|
364
|
+
fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
|
|
365
|
+
outputAmount: parseUint256(
|
|
366
|
+
BigInt(dto.receive_output_amount),
|
|
367
|
+
"SwapPreview.receive_output_amount"
|
|
368
|
+
)
|
|
340
369
|
})
|
|
341
370
|
};
|
|
342
371
|
var SwapStatus = {
|
|
343
372
|
fromDto: (dto) => ({
|
|
344
|
-
stopped:
|
|
345
|
-
swapLevel:
|
|
373
|
+
stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
|
|
374
|
+
swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
|
|
346
375
|
})
|
|
347
376
|
};
|
|
348
377
|
var TokenAllowance = {
|
|
349
378
|
fromDto: (dto) => ({
|
|
350
|
-
allowance:
|
|
379
|
+
allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
|
|
351
380
|
})
|
|
352
381
|
};
|
|
353
382
|
var TokenBalance = {
|
|
354
383
|
fromDto: (dto) => ({
|
|
355
|
-
balance:
|
|
384
|
+
balance: parseUint256(BigInt(dto.balance), "TokenBalance.balance")
|
|
356
385
|
})
|
|
357
386
|
};
|
|
358
387
|
var AllowWalletResponse = {
|
|
@@ -477,18 +506,169 @@ function toErc20Asset(dto) {
|
|
|
477
506
|
};
|
|
478
507
|
}
|
|
479
508
|
|
|
509
|
+
// src/shared/core/observability/log-cause.ts
|
|
510
|
+
function classifyLogCause(error) {
|
|
511
|
+
if (error instanceof HttpError) {
|
|
512
|
+
return httpCause(error);
|
|
513
|
+
}
|
|
514
|
+
if (error instanceof ValidationError) {
|
|
515
|
+
return { type: "validation", message: error.message };
|
|
516
|
+
}
|
|
517
|
+
if (error instanceof InvariantError) {
|
|
518
|
+
return { type: "invariant", message: error.message };
|
|
519
|
+
}
|
|
520
|
+
if (error instanceof NotAuthenticatedError) {
|
|
521
|
+
return { type: "not-authenticated" };
|
|
522
|
+
}
|
|
523
|
+
if (error instanceof NotImplementedError) {
|
|
524
|
+
return { type: "not-implemented" };
|
|
525
|
+
}
|
|
526
|
+
return { type: "generic-error", name: errorName(error) };
|
|
527
|
+
}
|
|
528
|
+
function describeErrorUnredacted(error) {
|
|
529
|
+
if (error instanceof HttpError) {
|
|
530
|
+
return describeHttpErrorRedacted(error);
|
|
531
|
+
}
|
|
532
|
+
if (error instanceof Error) {
|
|
533
|
+
return `${error.name}: ${error.message}`;
|
|
534
|
+
}
|
|
535
|
+
return `thrown non-error: ${stringifyUnredacted(error)}`;
|
|
536
|
+
}
|
|
537
|
+
function stringifyUnredacted(value) {
|
|
538
|
+
if (value === void 0) return "";
|
|
539
|
+
try {
|
|
540
|
+
return JSON.stringify(
|
|
541
|
+
value,
|
|
542
|
+
(_key, item) => typeof item === "bigint" ? `${item}` : item
|
|
543
|
+
) ?? String(value);
|
|
544
|
+
} catch (_) {
|
|
545
|
+
return "<unserializable>";
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function describeHttpErrorRedacted(error) {
|
|
549
|
+
const code = apiErrorCode(error);
|
|
550
|
+
const status = error.response.status;
|
|
551
|
+
return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
|
|
552
|
+
}
|
|
553
|
+
function errorName(error) {
|
|
554
|
+
return error instanceof Error ? error.name : `non-error ${typeof error}`;
|
|
555
|
+
}
|
|
556
|
+
function httpCause(error) {
|
|
557
|
+
return {
|
|
558
|
+
type: "http",
|
|
559
|
+
requestId: error.requestId,
|
|
560
|
+
status: error.response.status,
|
|
561
|
+
code: apiErrorCode(error),
|
|
562
|
+
eventId: apiErrorEventId(error)
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
function apiErrorEventId(error) {
|
|
566
|
+
const body = error.response.body;
|
|
567
|
+
if (typeof body !== "object" || body === null) return null;
|
|
568
|
+
const eventId = body.event_id;
|
|
569
|
+
return typeof eventId === "string" ? eventId : null;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// src/shared/core/observability/internal-logger.ts
|
|
573
|
+
function internalLogger(logger, scope) {
|
|
574
|
+
return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
|
|
575
|
+
}
|
|
576
|
+
var LEVEL_RANK = {
|
|
577
|
+
none: 0,
|
|
578
|
+
error: 1,
|
|
579
|
+
warn: 2,
|
|
580
|
+
info: 3,
|
|
581
|
+
debug: 4
|
|
582
|
+
};
|
|
583
|
+
function scopedLogger(logger, scope, bindings) {
|
|
584
|
+
const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
|
|
585
|
+
const safe = (event) => ({
|
|
586
|
+
msg: event.msg,
|
|
587
|
+
scope,
|
|
588
|
+
bindings,
|
|
589
|
+
fields: event.fields ?? {},
|
|
590
|
+
...event.cause === void 0 ? {} : { cause: event.cause }
|
|
591
|
+
});
|
|
592
|
+
const unredacted = (event) => ({
|
|
593
|
+
msg: event.msg,
|
|
594
|
+
scope,
|
|
595
|
+
bindings,
|
|
596
|
+
fields: event.fields ?? {}
|
|
597
|
+
});
|
|
598
|
+
const self = {
|
|
599
|
+
child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
|
|
600
|
+
debug: (event) => {
|
|
601
|
+
if (admits("debug")) logger.debug(() => unredacted(event()));
|
|
602
|
+
},
|
|
603
|
+
info: (event) => {
|
|
604
|
+
if (admits("info")) logger.info(() => safe(event()));
|
|
605
|
+
},
|
|
606
|
+
warn: (event) => {
|
|
607
|
+
if (admits("warn")) logger.warn(() => safe(event()));
|
|
608
|
+
},
|
|
609
|
+
error: (event) => {
|
|
610
|
+
if (admits("error")) logger.error(() => safe(event()));
|
|
611
|
+
},
|
|
612
|
+
failure: (event, error) => {
|
|
613
|
+
if (admits("debug"))
|
|
614
|
+
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
615
|
+
if (admits("error")) logger.error(() => safe(classified(event(), error)));
|
|
616
|
+
},
|
|
617
|
+
warning: (event, error) => {
|
|
618
|
+
if (admits("debug"))
|
|
619
|
+
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
620
|
+
if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
|
|
621
|
+
},
|
|
622
|
+
wrap: async (op, params, run) => {
|
|
623
|
+
const opLog = self.child({ op });
|
|
624
|
+
opLog.debug(() => ({ msg: "call", fields: { params } }));
|
|
625
|
+
try {
|
|
626
|
+
return await run();
|
|
627
|
+
} catch (error) {
|
|
628
|
+
opLog.failure(() => ({ msg: "call failed" }), error);
|
|
629
|
+
throw error;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
return self;
|
|
634
|
+
}
|
|
635
|
+
function verbatim(event, error) {
|
|
636
|
+
return {
|
|
637
|
+
msg: event.msg,
|
|
638
|
+
fields: { ...event.fields, error: describeErrorUnredacted(error) }
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function classified(event, error) {
|
|
642
|
+
return { ...event, cause: event.cause ?? classifyLogCause(error) };
|
|
643
|
+
}
|
|
644
|
+
var noopInternalLogger = {
|
|
645
|
+
child: () => noopInternalLogger,
|
|
646
|
+
debug: () => void 0,
|
|
647
|
+
info: () => void 0,
|
|
648
|
+
warn: () => void 0,
|
|
649
|
+
error: () => void 0,
|
|
650
|
+
failure: () => void 0,
|
|
651
|
+
warning: () => void 0,
|
|
652
|
+
wrap: (_op, _params, run) => run()
|
|
653
|
+
};
|
|
654
|
+
|
|
480
655
|
// src/shared/core/blockchain/erc20/erc20-namespace.ts
|
|
481
656
|
var Erc20NamespaceImpl = class {
|
|
482
657
|
constructor(ctx) {
|
|
483
658
|
this.ctx = ctx;
|
|
659
|
+
this.log = internalLogger(ctx.logger, "ERC20");
|
|
484
660
|
}
|
|
485
661
|
async getAllowance(params) {
|
|
486
|
-
|
|
487
|
-
|
|
662
|
+
return this.log.wrap("getAllowance", params, async () => {
|
|
663
|
+
await this.ctx.ensureUserAuthenticated();
|
|
664
|
+
return getTokenAllowance(this.ctx.api, params);
|
|
665
|
+
});
|
|
488
666
|
}
|
|
489
667
|
async getBalance(params) {
|
|
490
|
-
|
|
491
|
-
|
|
668
|
+
return this.log.wrap("getBalance", params, async () => {
|
|
669
|
+
await this.ctx.ensureUserAuthenticated();
|
|
670
|
+
return getTokenBalance(this.ctx.api, params);
|
|
671
|
+
});
|
|
492
672
|
}
|
|
493
673
|
};
|
|
494
674
|
|
|
@@ -684,15 +864,30 @@ var Asset = {
|
|
|
684
864
|
var OfferId = (value) => value;
|
|
685
865
|
var OfferSlug = (value) => value;
|
|
686
866
|
var Offer = {
|
|
867
|
+
fromDto: (dto) => {
|
|
868
|
+
if (!Array.isArray(dto.tokens)) {
|
|
869
|
+
throw new ValidationError(
|
|
870
|
+
`Offer.tokens: expected an array, got ${typeof dto.tokens}`
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
return {
|
|
874
|
+
id: OfferId(dto.id),
|
|
875
|
+
slug: OfferSlug(dto.slug),
|
|
876
|
+
type: dto.type,
|
|
877
|
+
tagline: dto.tagline,
|
|
878
|
+
bannerUrl: dto.banner_url,
|
|
879
|
+
logoUrl: dto.logo_url,
|
|
880
|
+
startsAt: new Date(dto.starts_at),
|
|
881
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
882
|
+
tokens: dto.tokens.map(OfferToken.fromDto)
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
var OfferToken = {
|
|
687
887
|
fromDto: (dto) => ({
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
tagline: dto.tagline,
|
|
692
|
-
bannerUrl: dto.banner_url,
|
|
693
|
-
logoUrl: dto.logo_url,
|
|
694
|
-
startsAt: new Date(dto.starts_at),
|
|
695
|
-
endsAt: dto.ends_at ? new Date(dto.ends_at) : null
|
|
888
|
+
role: dto.role,
|
|
889
|
+
chain: Chain(dto.chain),
|
|
890
|
+
address: EvmContractAddress(dto.address)
|
|
696
891
|
})
|
|
697
892
|
};
|
|
698
893
|
|
|
@@ -752,25 +947,39 @@ var OfferOptionSlug = (value) => value;
|
|
|
752
947
|
var OfferDetail = {
|
|
753
948
|
fromDto: (dto) => {
|
|
754
949
|
if (!Array.isArray(dto.funding_assets)) {
|
|
755
|
-
throw new
|
|
950
|
+
throw new ValidationError(
|
|
951
|
+
`OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
|
|
952
|
+
);
|
|
756
953
|
}
|
|
757
954
|
if (!Array.isArray(dto.options)) {
|
|
758
|
-
throw new
|
|
955
|
+
throw new ValidationError(
|
|
956
|
+
`OfferDetail.options: expected an array, got ${typeof dto.options}`
|
|
957
|
+
);
|
|
759
958
|
}
|
|
760
959
|
if (!Array.isArray(dto.terms)) {
|
|
761
|
-
throw new
|
|
960
|
+
throw new ValidationError(
|
|
961
|
+
`OfferDetail.terms: expected an array, got ${typeof dto.terms}`
|
|
962
|
+
);
|
|
762
963
|
}
|
|
763
964
|
if (!Array.isArray(dto.links)) {
|
|
764
|
-
throw new
|
|
965
|
+
throw new ValidationError(
|
|
966
|
+
`OfferDetail.links: expected an array, got ${typeof dto.links}`
|
|
967
|
+
);
|
|
765
968
|
}
|
|
766
969
|
if (!Array.isArray(dto.faqs)) {
|
|
767
|
-
throw new
|
|
970
|
+
throw new ValidationError(
|
|
971
|
+
`OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
|
|
972
|
+
);
|
|
768
973
|
}
|
|
769
974
|
if (!Array.isArray(dto.milestones)) {
|
|
770
|
-
throw new
|
|
975
|
+
throw new ValidationError(
|
|
976
|
+
`OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
|
|
977
|
+
);
|
|
771
978
|
}
|
|
772
979
|
if (!Array.isArray(dto.tokens)) {
|
|
773
|
-
throw new
|
|
980
|
+
throw new ValidationError(
|
|
981
|
+
`OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
|
|
982
|
+
);
|
|
774
983
|
}
|
|
775
984
|
return {
|
|
776
985
|
id: OfferId(dto.id),
|
|
@@ -832,13 +1041,6 @@ var Milestone = {
|
|
|
832
1041
|
status: dto.status
|
|
833
1042
|
})
|
|
834
1043
|
};
|
|
835
|
-
var OfferToken = {
|
|
836
|
-
fromDto: (dto) => ({
|
|
837
|
-
role: dto.role,
|
|
838
|
-
chain: Chain(dto.chain),
|
|
839
|
-
address: EvmContractAddress(dto.address)
|
|
840
|
-
})
|
|
841
|
-
};
|
|
842
1044
|
|
|
843
1045
|
// src/shared/types/providers/coin-list/token-sale.ts
|
|
844
1046
|
var ParticipationId = (value) => value;
|
|
@@ -925,22 +1127,31 @@ async function createParticipation(api, params) {
|
|
|
925
1127
|
var CoinListTokenSaleNamespaceImpl = class {
|
|
926
1128
|
constructor(ctx) {
|
|
927
1129
|
this.ctx = ctx;
|
|
1130
|
+
this.log = internalLogger(ctx.logger, "TOKEN_SALE");
|
|
928
1131
|
}
|
|
929
1132
|
async list(offerId) {
|
|
930
|
-
|
|
931
|
-
|
|
1133
|
+
return this.log.wrap("list", offerId, async () => {
|
|
1134
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1135
|
+
return fetchParticipations(this.ctx.api, offerId);
|
|
1136
|
+
});
|
|
932
1137
|
}
|
|
933
1138
|
async listPage(params) {
|
|
934
|
-
|
|
935
|
-
|
|
1139
|
+
return this.log.wrap("listPage", params, async () => {
|
|
1140
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1141
|
+
return fetchParticipationsPage(this.ctx.api, params);
|
|
1142
|
+
});
|
|
936
1143
|
}
|
|
937
1144
|
async get(id) {
|
|
938
|
-
|
|
939
|
-
|
|
1145
|
+
return this.log.wrap("get", id, async () => {
|
|
1146
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1147
|
+
return fetchParticipation(this.ctx.api, id);
|
|
1148
|
+
});
|
|
940
1149
|
}
|
|
941
1150
|
async createParticipation(params) {
|
|
942
|
-
|
|
943
|
-
|
|
1151
|
+
return this.log.wrap("createParticipation", params, async () => {
|
|
1152
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1153
|
+
return createParticipation(this.ctx.api, params);
|
|
1154
|
+
});
|
|
944
1155
|
}
|
|
945
1156
|
};
|
|
946
1157
|
|
|
@@ -1107,18 +1318,25 @@ function sizeParam(params) {
|
|
|
1107
1318
|
var OndoNamespaceImpl = class {
|
|
1108
1319
|
constructor(ctx) {
|
|
1109
1320
|
this.ctx = ctx;
|
|
1321
|
+
this.log = internalLogger(ctx.logger, "ONDO");
|
|
1110
1322
|
}
|
|
1111
1323
|
async getTradingStatus(params) {
|
|
1112
|
-
|
|
1113
|
-
|
|
1324
|
+
return this.log.wrap("getTradingStatus", params, async () => {
|
|
1325
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1326
|
+
return getOndoTradingStatus(this.ctx.api, params);
|
|
1327
|
+
});
|
|
1114
1328
|
}
|
|
1115
1329
|
async getQuote(params) {
|
|
1116
|
-
|
|
1117
|
-
|
|
1330
|
+
return this.log.wrap("getQuote", params, async () => {
|
|
1331
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1332
|
+
return getOndoQuote(this.ctx.api, params);
|
|
1333
|
+
});
|
|
1118
1334
|
}
|
|
1119
1335
|
async buildSwapTransaction(params) {
|
|
1120
|
-
|
|
1121
|
-
|
|
1336
|
+
return this.log.wrap("buildSwapTransaction", params, async () => {
|
|
1337
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1338
|
+
return buildOndoSwapTransaction(this.ctx.api, params);
|
|
1339
|
+
});
|
|
1122
1340
|
}
|
|
1123
1341
|
};
|
|
1124
1342
|
|
|
@@ -1126,26 +1344,37 @@ var OndoNamespaceImpl = class {
|
|
|
1126
1344
|
var SuperstateSwapNamespaceImpl = class {
|
|
1127
1345
|
constructor(ctx) {
|
|
1128
1346
|
this.ctx = ctx;
|
|
1347
|
+
this.log = internalLogger(ctx.logger, "SUPERSTATE");
|
|
1129
1348
|
}
|
|
1130
1349
|
async getAuthorization(params) {
|
|
1131
|
-
|
|
1132
|
-
|
|
1350
|
+
return this.log.wrap("getAuthorization", params, async () => {
|
|
1351
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1352
|
+
return getSwapAuthorization(this.ctx.api, params);
|
|
1353
|
+
});
|
|
1133
1354
|
}
|
|
1134
1355
|
async getPreview(params) {
|
|
1135
|
-
|
|
1136
|
-
|
|
1356
|
+
return this.log.wrap("getPreview", params, async () => {
|
|
1357
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1358
|
+
return getSwapPreview(this.ctx.api, params);
|
|
1359
|
+
});
|
|
1137
1360
|
}
|
|
1138
1361
|
async getStatus(params) {
|
|
1139
|
-
|
|
1140
|
-
|
|
1362
|
+
return this.log.wrap("getStatus", params, async () => {
|
|
1363
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1364
|
+
return getSwapStatus(this.ctx.api, params);
|
|
1365
|
+
});
|
|
1141
1366
|
}
|
|
1142
1367
|
async getOutputToken(params) {
|
|
1143
|
-
|
|
1144
|
-
|
|
1368
|
+
return this.log.wrap("getOutputToken", params, async () => {
|
|
1369
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1370
|
+
return getSwapOutputToken(this.ctx.api, params);
|
|
1371
|
+
});
|
|
1145
1372
|
}
|
|
1146
1373
|
async allowWallet(params) {
|
|
1147
|
-
|
|
1148
|
-
|
|
1374
|
+
return this.log.wrap("allowWallet", params, async () => {
|
|
1375
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1376
|
+
return allowWallet(this.ctx.api, params);
|
|
1377
|
+
});
|
|
1149
1378
|
}
|
|
1150
1379
|
};
|
|
1151
1380
|
|
|
@@ -1278,38 +1507,49 @@ async function fetchRequirementStatuses(api, offerId) {
|
|
|
1278
1507
|
var RequirementsNamespaceImpl = class {
|
|
1279
1508
|
constructor(ctx) {
|
|
1280
1509
|
this.ctx = ctx;
|
|
1510
|
+
this.log = internalLogger(ctx.logger, "REQUIREMENTS");
|
|
1281
1511
|
}
|
|
1282
1512
|
async forOffer(offerId) {
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1513
|
+
return this.log.wrap("forOffer", offerId, async () => {
|
|
1514
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1515
|
+
return fetchOfferRequirements(
|
|
1516
|
+
this.ctx.api,
|
|
1517
|
+
offerId,
|
|
1518
|
+
void 0
|
|
1519
|
+
);
|
|
1520
|
+
});
|
|
1289
1521
|
}
|
|
1290
1522
|
async statuses(offerId) {
|
|
1291
|
-
|
|
1292
|
-
|
|
1523
|
+
return this.log.wrap("statuses", offerId, async () => {
|
|
1524
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1525
|
+
return fetchRequirementStatuses(this.ctx.api, offerId);
|
|
1526
|
+
});
|
|
1293
1527
|
}
|
|
1294
1528
|
async createKycToken(params) {
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1529
|
+
return this.log.wrap("createKycToken", params, async () => {
|
|
1530
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1531
|
+
return createKycToken(
|
|
1532
|
+
this.ctx.api,
|
|
1533
|
+
params?.levelName,
|
|
1534
|
+
params?.reset
|
|
1535
|
+
);
|
|
1536
|
+
});
|
|
1301
1537
|
}
|
|
1302
1538
|
async getPii() {
|
|
1303
|
-
|
|
1304
|
-
|
|
1539
|
+
return this.log.wrap("getPii", void 0, async () => {
|
|
1540
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1541
|
+
return fetchPii(this.ctx.api);
|
|
1542
|
+
});
|
|
1305
1543
|
}
|
|
1306
1544
|
async submitDocument(params) {
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1545
|
+
return this.log.wrap("submitDocument", params, async () => {
|
|
1546
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1547
|
+
return submitDocument(
|
|
1548
|
+
this.ctx.api,
|
|
1549
|
+
params.documentType,
|
|
1550
|
+
params.fields
|
|
1551
|
+
);
|
|
1552
|
+
});
|
|
1313
1553
|
}
|
|
1314
1554
|
};
|
|
1315
1555
|
|
|
@@ -1389,17 +1629,16 @@ var COINLIST_BASE_URL = "https://coinlist.co";
|
|
|
1389
1629
|
var OAUTH_PAGE_PATH = "/oauth/authorize";
|
|
1390
1630
|
var SUPPORT_NEW_TICKET_URL = "https://support.coinlist.co/support/tickets/new";
|
|
1391
1631
|
var VERIFY_IDENTITY_PATH = "/verify-identity";
|
|
1392
|
-
var VERIFY_IDENTITY_VERIFIED_PATH = "/verify-identity/identity_verified";
|
|
1393
|
-
var VERIFY_IDENTITY_PROOF_OF_ADDRESS_PATH = "/verify-identity/proof_of_address";
|
|
1394
|
-
var VERIFY_IDENTITY_SOURCE_OF_FUNDS_PATH = "/verify-identity/source_of_funds";
|
|
1395
1632
|
var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
|
|
1396
1633
|
var WALLET_PATH = "/wallet";
|
|
1397
1634
|
|
|
1398
1635
|
// src/shared/api/http-client.ts
|
|
1399
1636
|
var HttpClient = class {
|
|
1400
|
-
constructor(config, middleware = {}) {
|
|
1637
|
+
constructor(config, middleware = {}, logger = null, options = {}) {
|
|
1401
1638
|
this.config = config;
|
|
1402
1639
|
this.middleware = middleware;
|
|
1640
|
+
this.log = internalLogger(logger, "HTTP");
|
|
1641
|
+
this.makeRequestId = options.makeRequestId ?? defaultMakeRequestId;
|
|
1403
1642
|
}
|
|
1404
1643
|
async send(request) {
|
|
1405
1644
|
return this.runRequestWithAfterMiddleware(request);
|
|
@@ -1435,7 +1674,13 @@ var HttpClient = class {
|
|
|
1435
1674
|
return {
|
|
1436
1675
|
...request,
|
|
1437
1676
|
url,
|
|
1438
|
-
headers
|
|
1677
|
+
headers,
|
|
1678
|
+
// Only when absent: a retry or a post-renewal re-send arrives with the
|
|
1679
|
+
// first attempt's id already on it, and keeping it is the whole point.
|
|
1680
|
+
attributes: Attributes.getRequestId(request.attributes) === null ? Attributes.concat(
|
|
1681
|
+
request.attributes ?? Attributes.empty,
|
|
1682
|
+
Attributes.requestId(this.makeRequestId())
|
|
1683
|
+
) : request.attributes
|
|
1439
1684
|
};
|
|
1440
1685
|
}
|
|
1441
1686
|
/**
|
|
@@ -1459,14 +1704,93 @@ var HttpClient = class {
|
|
|
1459
1704
|
}
|
|
1460
1705
|
return request;
|
|
1461
1706
|
}
|
|
1462
|
-
|
|
1463
|
-
|
|
1707
|
+
/**
|
|
1708
|
+
* One physical attempt, logged as one line.
|
|
1709
|
+
*
|
|
1710
|
+
* A non-2xx is a `warn` rather than an `error` because the wire does not
|
|
1711
|
+
* know whether it is a failure: the retry middleware may turn a 503 into a
|
|
1712
|
+
* success, and the token registry reads a 404 as "not listed". The namespace
|
|
1713
|
+
* above decides, and logs the `error` when it does.
|
|
1714
|
+
*/
|
|
1715
|
+
async executeRequest(request) {
|
|
1716
|
+
const requestId2 = Attributes.getRequestId(request.attributes);
|
|
1717
|
+
const log = requestId2 === null ? this.log : this.log.child({ requestId: requestId2 });
|
|
1718
|
+
const attempt = Attributes.getRetryAttempt(request.attributes) + 1;
|
|
1719
|
+
const startedAt = Date.now();
|
|
1720
|
+
log.debug(() => ({
|
|
1721
|
+
msg: "request sent",
|
|
1722
|
+
fields: describeRequestUnredacted(request)
|
|
1723
|
+
}));
|
|
1724
|
+
try {
|
|
1725
|
+
const response = await makeRequest(request);
|
|
1726
|
+
const elapsed = Date.now() - startedAt;
|
|
1727
|
+
const outcome = () => ({
|
|
1728
|
+
msg: "request completed",
|
|
1729
|
+
fields: {
|
|
1730
|
+
...identifyRequest(request),
|
|
1731
|
+
"http.response.status_code": response.status,
|
|
1732
|
+
duration_ms: elapsed,
|
|
1733
|
+
attempt
|
|
1734
|
+
}
|
|
1735
|
+
});
|
|
1736
|
+
if (response.status >= 200 && response.status < 300) {
|
|
1737
|
+
log.info(outcome);
|
|
1738
|
+
} else {
|
|
1739
|
+
log.warn(outcome);
|
|
1740
|
+
}
|
|
1741
|
+
log.debug(() => ({
|
|
1742
|
+
msg: "response received",
|
|
1743
|
+
fields: { body: response.body }
|
|
1744
|
+
}));
|
|
1745
|
+
return requestId2 === null ? response : { ...response, requestId: requestId2 };
|
|
1746
|
+
} catch (error) {
|
|
1747
|
+
const elapsed = Date.now() - startedAt;
|
|
1748
|
+
log.warning(
|
|
1749
|
+
() => ({
|
|
1750
|
+
msg: "request threw",
|
|
1751
|
+
fields: {
|
|
1752
|
+
...identifyRequest(request),
|
|
1753
|
+
duration_ms: elapsed,
|
|
1754
|
+
attempt
|
|
1755
|
+
}
|
|
1756
|
+
}),
|
|
1757
|
+
error
|
|
1758
|
+
);
|
|
1759
|
+
throw error;
|
|
1760
|
+
}
|
|
1464
1761
|
}
|
|
1465
1762
|
};
|
|
1763
|
+
function identifyRequest(request) {
|
|
1764
|
+
const { host, path } = splitUrl(request.url);
|
|
1765
|
+
return {
|
|
1766
|
+
"http.request.method": request.method,
|
|
1767
|
+
"server.address": host,
|
|
1768
|
+
"url.path": path
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
function splitUrl(url) {
|
|
1772
|
+
try {
|
|
1773
|
+
const parsed = new URL(url);
|
|
1774
|
+
return { host: parsed.host, path: parsed.pathname };
|
|
1775
|
+
} catch (_) {
|
|
1776
|
+
return { host: null, path: url };
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
function defaultMakeRequestId() {
|
|
1780
|
+
return Math.random().toString(36).slice(2, 10).padEnd(8, "0");
|
|
1781
|
+
}
|
|
1782
|
+
function describeRequestUnredacted(request) {
|
|
1783
|
+
return {
|
|
1784
|
+
"http.request.method": request.method,
|
|
1785
|
+
"url.full": buildUrlWithQueryParams(request.url, request.queryParams),
|
|
1786
|
+
headers: request.headers,
|
|
1787
|
+
...request.method === "POST" ? { body: request.body } : {}
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1466
1790
|
|
|
1467
1791
|
// src/shared/api/nabu/tokens.ts
|
|
1468
|
-
function createNabuApiClient(baseUrl) {
|
|
1469
|
-
return new HttpClient({ baseUrl });
|
|
1792
|
+
function createNabuApiClient(baseUrl, logger = null) {
|
|
1793
|
+
return new HttpClient({ baseUrl }, {}, logger);
|
|
1470
1794
|
}
|
|
1471
1795
|
async function fetchTokenMetadata(client, token) {
|
|
1472
1796
|
const address = checksummed(token.address);
|
|
@@ -1539,14 +1863,23 @@ var TokensNamespaceImpl = class {
|
|
|
1539
1863
|
* registry is unauthenticated and on its own host, so the frontline sender
|
|
1540
1864
|
* and the auth check would both be dead weight here.
|
|
1541
1865
|
*/
|
|
1542
|
-
constructor(baseUrl) {
|
|
1543
|
-
this.api = createNabuApiClient(baseUrl);
|
|
1866
|
+
constructor(baseUrl, logger = null) {
|
|
1867
|
+
this.api = createNabuApiClient(baseUrl, logger);
|
|
1868
|
+
this.log = internalLogger(logger, "TOKENS");
|
|
1544
1869
|
}
|
|
1545
1870
|
get(token) {
|
|
1546
|
-
return
|
|
1871
|
+
return this.log.wrap(
|
|
1872
|
+
"get",
|
|
1873
|
+
token,
|
|
1874
|
+
() => fetchTokenMetadata(this.api, token)
|
|
1875
|
+
);
|
|
1547
1876
|
}
|
|
1548
1877
|
list(chain) {
|
|
1549
|
-
return
|
|
1878
|
+
return this.log.wrap(
|
|
1879
|
+
"list",
|
|
1880
|
+
chain,
|
|
1881
|
+
() => fetchTokensMetadata(this.api, chain)
|
|
1882
|
+
);
|
|
1550
1883
|
}
|
|
1551
1884
|
};
|
|
1552
1885
|
|
|
@@ -1652,33 +1985,42 @@ async function removeOptionAddress(api, offerId, addressId) {
|
|
|
1652
1985
|
var WalletsNamespaceImpl = class {
|
|
1653
1986
|
constructor(ctx) {
|
|
1654
1987
|
this.ctx = ctx;
|
|
1988
|
+
this.log = internalLogger(ctx.logger, "WALLETS");
|
|
1655
1989
|
}
|
|
1656
1990
|
async createOwnershipChallenge(params) {
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1991
|
+
return this.log.wrap("createOwnershipChallenge", params, async () => {
|
|
1992
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1993
|
+
return createWalletOwnershipChallenge(
|
|
1994
|
+
this.ctx.api,
|
|
1995
|
+
params
|
|
1996
|
+
);
|
|
1997
|
+
});
|
|
1662
1998
|
}
|
|
1663
1999
|
async connectExternal(params) {
|
|
1664
|
-
|
|
1665
|
-
|
|
2000
|
+
return this.log.wrap("connectExternal", params, async () => {
|
|
2001
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2002
|
+
return connectExternalWallet(this.ctx.api, params);
|
|
2003
|
+
});
|
|
1666
2004
|
}
|
|
1667
2005
|
async list(params) {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
2006
|
+
return this.log.wrap("list", params, async () => {
|
|
2007
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2008
|
+
return listOptionAddresses(
|
|
2009
|
+
this.ctx.api,
|
|
2010
|
+
params.offerId,
|
|
2011
|
+
params.offerOptionId
|
|
2012
|
+
);
|
|
2013
|
+
});
|
|
1674
2014
|
}
|
|
1675
2015
|
async remove(params) {
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
2016
|
+
return this.log.wrap("remove", params, async () => {
|
|
2017
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2018
|
+
return removeOptionAddress(
|
|
2019
|
+
this.ctx.api,
|
|
2020
|
+
params.offerId,
|
|
2021
|
+
params.addressId
|
|
2022
|
+
);
|
|
2023
|
+
});
|
|
1682
2024
|
}
|
|
1683
2025
|
};
|
|
1684
2026
|
|
|
@@ -1740,20 +2082,20 @@ export {
|
|
|
1740
2082
|
OAUTH_PAGE_PATH,
|
|
1741
2083
|
SUPPORT_NEW_TICKET_URL,
|
|
1742
2084
|
VERIFY_IDENTITY_PATH,
|
|
1743
|
-
VERIFY_IDENTITY_VERIFIED_PATH,
|
|
1744
|
-
VERIFY_IDENTITY_PROOF_OF_ADDRESS_PATH,
|
|
1745
|
-
VERIFY_IDENTITY_SOURCE_OF_FUNDS_PATH,
|
|
1746
2085
|
VERIFY_IDENTITY_ACCREDITATION_PATH,
|
|
1747
2086
|
WALLET_PATH,
|
|
1748
2087
|
Attributes,
|
|
1749
2088
|
HttpError,
|
|
1750
2089
|
apiErrorCode,
|
|
1751
2090
|
Request,
|
|
1752
|
-
HttpClient,
|
|
1753
|
-
fetchAllPages,
|
|
1754
2091
|
NotImplementedError,
|
|
1755
2092
|
NotAuthenticatedError,
|
|
1756
2093
|
ValidationError,
|
|
2094
|
+
InvariantError,
|
|
2095
|
+
describeErrorUnredacted,
|
|
2096
|
+
internalLogger,
|
|
2097
|
+
HttpClient,
|
|
2098
|
+
fetchAllPages,
|
|
1757
2099
|
ETHEREUM_CHAINS,
|
|
1758
2100
|
EthereumChain,
|
|
1759
2101
|
SOLANA_CHAINS,
|
|
@@ -1768,6 +2110,7 @@ export {
|
|
|
1768
2110
|
DecimalString,
|
|
1769
2111
|
MAX_UINT_256,
|
|
1770
2112
|
assertUint256,
|
|
2113
|
+
parseUint256,
|
|
1771
2114
|
BlockchainAmount,
|
|
1772
2115
|
AssetSymbol,
|
|
1773
2116
|
StablecoinSymbol,
|
|
@@ -1810,6 +2153,7 @@ export {
|
|
|
1810
2153
|
OfferId,
|
|
1811
2154
|
OfferSlug,
|
|
1812
2155
|
Offer,
|
|
2156
|
+
OfferToken,
|
|
1813
2157
|
OfferOptionId,
|
|
1814
2158
|
OfferOptionSlug,
|
|
1815
2159
|
OfferDetail,
|
|
@@ -1818,7 +2162,6 @@ export {
|
|
|
1818
2162
|
Link,
|
|
1819
2163
|
TermItem,
|
|
1820
2164
|
Milestone,
|
|
1821
|
-
OfferToken,
|
|
1822
2165
|
ParticipationId,
|
|
1823
2166
|
Blockchain,
|
|
1824
2167
|
WalletAddress,
|
|
@@ -1860,4 +2203,4 @@ export {
|
|
|
1860
2203
|
OAuthRefreshToken,
|
|
1861
2204
|
OAuthSession
|
|
1862
2205
|
};
|
|
1863
|
-
//# sourceMappingURL=chunk-
|
|
2206
|
+
//# sourceMappingURL=chunk-ZVB6KWZ2.js.map
|