@sereel/sdk 0.1.4 → 0.1.6
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 +33 -24
- package/dist/index.cjs +536 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -11
- package/dist/index.d.ts +25 -11
- package/dist/index.js +533 -45
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,12 +13,18 @@ var SereelSdkError = class extends Error {
|
|
|
13
13
|
};
|
|
14
14
|
var InvalidConfigurationError = class extends SereelSdkError {
|
|
15
15
|
};
|
|
16
|
+
var NetworkError = class extends SereelSdkError {
|
|
17
|
+
};
|
|
16
18
|
var HttpError = class extends SereelSdkError {
|
|
17
19
|
};
|
|
18
20
|
var UnauthorizedError = class extends HttpError {
|
|
19
21
|
};
|
|
22
|
+
var ForbiddenError = class extends HttpError {
|
|
23
|
+
};
|
|
20
24
|
var NotFoundError = class extends HttpError {
|
|
21
25
|
};
|
|
26
|
+
var RateLimitError = class extends HttpError {
|
|
27
|
+
};
|
|
22
28
|
var ServerError = class extends HttpError {
|
|
23
29
|
};
|
|
24
30
|
var TimeoutError = class extends SereelSdkError {
|
|
@@ -123,14 +129,30 @@ function toHttpError(status, body) {
|
|
|
123
129
|
if (status === 401) {
|
|
124
130
|
return new UnauthorizedError(message, options);
|
|
125
131
|
}
|
|
132
|
+
if (status === 403) {
|
|
133
|
+
return new ForbiddenError(message, options);
|
|
134
|
+
}
|
|
126
135
|
if (status === 404) {
|
|
127
136
|
return new NotFoundError(message, options);
|
|
128
137
|
}
|
|
138
|
+
if (status === 429) {
|
|
139
|
+
return new RateLimitError(message, options);
|
|
140
|
+
}
|
|
129
141
|
if (status >= 500) {
|
|
130
142
|
return new ServerError(message, options);
|
|
131
143
|
}
|
|
132
144
|
return new HttpError(message, options);
|
|
133
145
|
}
|
|
146
|
+
function isAbortError(error) {
|
|
147
|
+
return error instanceof Error && (error.name === "AbortError" || error.constructor.name === "AbortError");
|
|
148
|
+
}
|
|
149
|
+
function wrapNetworkError(error) {
|
|
150
|
+
if (error instanceof NetworkError) {
|
|
151
|
+
return error;
|
|
152
|
+
}
|
|
153
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : "Network request failed.";
|
|
154
|
+
return new NetworkError(message, { cause: error });
|
|
155
|
+
}
|
|
134
156
|
async function requestJson(config, path, validate) {
|
|
135
157
|
const { signal, cleanup } = createTimeoutSignal(config.timeoutMs);
|
|
136
158
|
try {
|
|
@@ -148,16 +170,16 @@ async function requestJson(config, path, validate) {
|
|
|
148
170
|
}
|
|
149
171
|
return validate(body);
|
|
150
172
|
} catch (error) {
|
|
151
|
-
if (error instanceof HttpError || error instanceof MalformedResponseError) {
|
|
173
|
+
if (error instanceof HttpError || error instanceof MalformedResponseError || error instanceof NetworkError) {
|
|
152
174
|
throw error;
|
|
153
175
|
}
|
|
154
|
-
if (error
|
|
176
|
+
if (isAbortError(error)) {
|
|
155
177
|
throw new TimeoutError(
|
|
156
178
|
`Request timed out after ${config.timeoutMs}ms.`,
|
|
157
179
|
{ cause: error }
|
|
158
180
|
);
|
|
159
181
|
}
|
|
160
|
-
throw error;
|
|
182
|
+
throw wrapNetworkError(error);
|
|
161
183
|
} finally {
|
|
162
184
|
cleanup();
|
|
163
185
|
}
|
|
@@ -173,75 +195,538 @@ function isString(value) {
|
|
|
173
195
|
function isNullableString(value) {
|
|
174
196
|
return typeof value === "string" || value === null;
|
|
175
197
|
}
|
|
198
|
+
function isOptionalNullableString(value) {
|
|
199
|
+
return typeof value === "string" || value === null || value === void 0;
|
|
200
|
+
}
|
|
176
201
|
function isFiniteNumber(value) {
|
|
177
202
|
return typeof value === "number" && Number.isFinite(value);
|
|
178
203
|
}
|
|
179
204
|
function isBoolean(value) {
|
|
180
205
|
return typeof value === "boolean";
|
|
181
206
|
}
|
|
182
|
-
|
|
183
|
-
|
|
207
|
+
var ValidationContext = class {
|
|
208
|
+
failures = [];
|
|
209
|
+
check(condition, path, expected, received) {
|
|
210
|
+
if (!condition) {
|
|
211
|
+
this.failures.push({ path, expected, received });
|
|
212
|
+
}
|
|
213
|
+
return condition;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
function asRecord(value) {
|
|
217
|
+
return isRecord(value) ? value : void 0;
|
|
184
218
|
}
|
|
185
|
-
function
|
|
186
|
-
|
|
219
|
+
function isProspectus(value, ctx, path) {
|
|
220
|
+
const v = asRecord(value);
|
|
221
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
222
|
+
ctx.check(isString(v.name), `${path}.name`, "string", v.name);
|
|
223
|
+
ctx.check(isString(v.url), `${path}.url`, "string", v.url);
|
|
224
|
+
return true;
|
|
187
225
|
}
|
|
188
|
-
function
|
|
189
|
-
|
|
226
|
+
function isTokenPartner(value, ctx, path) {
|
|
227
|
+
const v = asRecord(value);
|
|
228
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
229
|
+
ctx.check(
|
|
230
|
+
isString(v.partner_name),
|
|
231
|
+
`${path}.partner_name`,
|
|
232
|
+
"string",
|
|
233
|
+
v.partner_name
|
|
234
|
+
);
|
|
235
|
+
ctx.check(
|
|
236
|
+
isString(v.partner_logo),
|
|
237
|
+
`${path}.partner_logo`,
|
|
238
|
+
"string",
|
|
239
|
+
v.partner_logo
|
|
240
|
+
);
|
|
241
|
+
ctx.check(
|
|
242
|
+
isString(v.partner_role),
|
|
243
|
+
`${path}.partner_role`,
|
|
244
|
+
"string",
|
|
245
|
+
v.partner_role
|
|
246
|
+
);
|
|
247
|
+
return true;
|
|
190
248
|
}
|
|
191
|
-
function
|
|
192
|
-
|
|
249
|
+
function isRuleSummary(value, ctx, path) {
|
|
250
|
+
const v = asRecord(value);
|
|
251
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
252
|
+
ctx.check(
|
|
253
|
+
isString(v.rule_address),
|
|
254
|
+
`${path}.rule_address`,
|
|
255
|
+
"string",
|
|
256
|
+
v.rule_address
|
|
257
|
+
);
|
|
258
|
+
ctx.check(
|
|
259
|
+
isString(v.rule_type),
|
|
260
|
+
`${path}.rule_type`,
|
|
261
|
+
"string",
|
|
262
|
+
v.rule_type
|
|
263
|
+
);
|
|
264
|
+
return true;
|
|
193
265
|
}
|
|
194
|
-
function
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
266
|
+
function isRuleEngineSummary(value, ctx, path) {
|
|
267
|
+
const v = asRecord(value);
|
|
268
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
269
|
+
ctx.check(isString(v.name), `${path}.name`, "string", v.name);
|
|
270
|
+
ctx.check(
|
|
271
|
+
isString(v.rule_engine_address),
|
|
272
|
+
`${path}.rule_engine_address`,
|
|
273
|
+
"string",
|
|
274
|
+
v.rule_engine_address
|
|
275
|
+
);
|
|
276
|
+
const rulesOk = ctx.check(
|
|
277
|
+
Array.isArray(v.rules),
|
|
278
|
+
`${path}.rules`,
|
|
279
|
+
"array",
|
|
280
|
+
v.rules
|
|
281
|
+
);
|
|
282
|
+
if (rulesOk) {
|
|
283
|
+
v.rules.forEach(
|
|
284
|
+
(rule, i) => isRuleSummary(rule, ctx, `${path}.rules[${i}]`)
|
|
285
|
+
);
|
|
202
286
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
function isSecurityDetails(value, ctx, path) {
|
|
290
|
+
const v = asRecord(value);
|
|
291
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
292
|
+
ctx.check(
|
|
293
|
+
isString(v.token_address),
|
|
294
|
+
`${path}.token_address`,
|
|
295
|
+
"string",
|
|
296
|
+
v.token_address
|
|
297
|
+
);
|
|
298
|
+
ctx.check(
|
|
299
|
+
isString(v.token_name),
|
|
300
|
+
`${path}.token_name`,
|
|
301
|
+
"string",
|
|
302
|
+
v.token_name
|
|
303
|
+
);
|
|
304
|
+
ctx.check(
|
|
305
|
+
isString(v.token_symbol),
|
|
306
|
+
`${path}.token_symbol`,
|
|
307
|
+
"string",
|
|
308
|
+
v.token_symbol
|
|
309
|
+
);
|
|
310
|
+
ctx.check(
|
|
311
|
+
isString(v.token_decimal),
|
|
312
|
+
`${path}.token_decimal`,
|
|
313
|
+
"string",
|
|
314
|
+
v.token_decimal
|
|
315
|
+
);
|
|
316
|
+
ctx.check(
|
|
317
|
+
isString(v.network_id),
|
|
318
|
+
`${path}.network_id`,
|
|
319
|
+
"string",
|
|
320
|
+
v.network_id
|
|
321
|
+
);
|
|
322
|
+
ctx.check(
|
|
323
|
+
isString(v.token_type),
|
|
324
|
+
`${path}.token_type`,
|
|
325
|
+
"string",
|
|
326
|
+
v.token_type
|
|
327
|
+
);
|
|
328
|
+
ctx.check(isString(v.admin), `${path}.admin`, "string", v.admin);
|
|
329
|
+
ctx.check(
|
|
330
|
+
isNullableString(v.icon_url),
|
|
331
|
+
`${path}.icon_url`,
|
|
332
|
+
"string | null",
|
|
333
|
+
v.icon_url
|
|
334
|
+
);
|
|
335
|
+
ctx.check(
|
|
336
|
+
isNullableString(v.created_at),
|
|
337
|
+
`${path}.created_at`,
|
|
338
|
+
"string | null",
|
|
339
|
+
v.created_at
|
|
340
|
+
);
|
|
341
|
+
if (v.prospectus !== null && v.prospectus !== void 0) {
|
|
342
|
+
isProspectus(v.prospectus, ctx, `${path}.prospectus`);
|
|
343
|
+
}
|
|
344
|
+
if (v.partners !== null && v.partners !== void 0) {
|
|
345
|
+
const partnersOk = ctx.check(
|
|
346
|
+
Array.isArray(v.partners),
|
|
347
|
+
`${path}.partners`,
|
|
348
|
+
"array",
|
|
349
|
+
v.partners
|
|
350
|
+
);
|
|
351
|
+
if (partnersOk) {
|
|
352
|
+
v.partners.forEach(
|
|
353
|
+
(partner, i) => isTokenPartner(partner, ctx, `${path}.partners[${i}]`)
|
|
354
|
+
);
|
|
355
|
+
}
|
|
206
356
|
}
|
|
207
|
-
if (
|
|
208
|
-
|
|
357
|
+
if (v.rule_engine !== null && v.rule_engine !== void 0) {
|
|
358
|
+
isRuleEngineSummary(v.rule_engine, ctx, `${path}.rule_engine`);
|
|
209
359
|
}
|
|
210
360
|
return true;
|
|
211
361
|
}
|
|
212
|
-
function isIssuerSummary(value) {
|
|
213
|
-
|
|
362
|
+
function isIssuerSummary(value, ctx, path) {
|
|
363
|
+
const v = asRecord(value);
|
|
364
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
365
|
+
ctx.check(isString(v.id), `${path}.id`, "string", v.id);
|
|
366
|
+
ctx.check(
|
|
367
|
+
isString(v.legal_name),
|
|
368
|
+
`${path}.legal_name`,
|
|
369
|
+
"string",
|
|
370
|
+
v.legal_name
|
|
371
|
+
);
|
|
372
|
+
ctx.check(
|
|
373
|
+
isNullableString(v.display_name),
|
|
374
|
+
`${path}.display_name`,
|
|
375
|
+
"string | null",
|
|
376
|
+
v.display_name
|
|
377
|
+
);
|
|
378
|
+
ctx.check(
|
|
379
|
+
isString(v.jurisdiction),
|
|
380
|
+
`${path}.jurisdiction`,
|
|
381
|
+
"string",
|
|
382
|
+
v.jurisdiction
|
|
383
|
+
);
|
|
384
|
+
ctx.check(
|
|
385
|
+
isNullableString(v.website),
|
|
386
|
+
`${path}.website`,
|
|
387
|
+
"string | null",
|
|
388
|
+
v.website
|
|
389
|
+
);
|
|
390
|
+
ctx.check(
|
|
391
|
+
isNullableString(v.logo_url),
|
|
392
|
+
`${path}.logo_url`,
|
|
393
|
+
"string | null",
|
|
394
|
+
v.logo_url
|
|
395
|
+
);
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
function isNativeCurrency(value, ctx, path) {
|
|
399
|
+
const v = asRecord(value);
|
|
400
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
401
|
+
ctx.check(isString(v.symbol), `${path}.symbol`, "string", v.symbol);
|
|
402
|
+
ctx.check(isString(v.name), `${path}.name`, "string", v.name);
|
|
403
|
+
ctx.check(
|
|
404
|
+
isFiniteNumber(v.decimals),
|
|
405
|
+
`${path}.decimals`,
|
|
406
|
+
"finite number",
|
|
407
|
+
v.decimals
|
|
408
|
+
);
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
function isNetworkDetails(value, ctx, path) {
|
|
412
|
+
const v = asRecord(value);
|
|
413
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
414
|
+
ctx.check(
|
|
415
|
+
isString(v.network_id),
|
|
416
|
+
`${path}.network_id`,
|
|
417
|
+
"string",
|
|
418
|
+
v.network_id
|
|
419
|
+
);
|
|
420
|
+
ctx.check(isString(v.name), `${path}.name`, "string", v.name);
|
|
421
|
+
ctx.check(isString(v.family), `${path}.family`, "string", v.family);
|
|
422
|
+
ctx.check(
|
|
423
|
+
isFiniteNumber(v.chain_id) || v.chain_id === null,
|
|
424
|
+
`${path}.chain_id`,
|
|
425
|
+
"number | null",
|
|
426
|
+
v.chain_id
|
|
427
|
+
);
|
|
428
|
+
isNativeCurrency(v.native_currency, ctx, `${path}.native_currency`);
|
|
429
|
+
ctx.check(
|
|
430
|
+
isString(v.rpc_endpoint),
|
|
431
|
+
`${path}.rpc_endpoint`,
|
|
432
|
+
"string",
|
|
433
|
+
v.rpc_endpoint
|
|
434
|
+
);
|
|
435
|
+
const explorerOk = ctx.check(
|
|
436
|
+
Array.isArray(v.explorer_urls),
|
|
437
|
+
`${path}.explorer_urls`,
|
|
438
|
+
"string[]",
|
|
439
|
+
v.explorer_urls
|
|
440
|
+
);
|
|
441
|
+
if (explorerOk) {
|
|
442
|
+
v.explorer_urls.forEach(
|
|
443
|
+
(url, i) => ctx.check(
|
|
444
|
+
isString(url),
|
|
445
|
+
`${path}.explorer_urls[${i}]`,
|
|
446
|
+
"string",
|
|
447
|
+
url
|
|
448
|
+
)
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
ctx.check(
|
|
452
|
+
isBoolean(v.can_deploy_cmtat_token),
|
|
453
|
+
`${path}.can_deploy_cmtat_token`,
|
|
454
|
+
"boolean",
|
|
455
|
+
v.can_deploy_cmtat_token
|
|
456
|
+
);
|
|
457
|
+
ctx.check(
|
|
458
|
+
isBoolean(v.can_deploy_trex_token),
|
|
459
|
+
`${path}.can_deploy_trex_token`,
|
|
460
|
+
"boolean",
|
|
461
|
+
v.can_deploy_trex_token
|
|
462
|
+
);
|
|
463
|
+
ctx.check(
|
|
464
|
+
isBoolean(v.is_testnet),
|
|
465
|
+
`${path}.is_testnet`,
|
|
466
|
+
"boolean",
|
|
467
|
+
v.is_testnet
|
|
468
|
+
);
|
|
469
|
+
ctx.check(
|
|
470
|
+
isBoolean(v.is_supported),
|
|
471
|
+
`${path}.is_supported`,
|
|
472
|
+
"boolean",
|
|
473
|
+
v.is_supported
|
|
474
|
+
);
|
|
475
|
+
return true;
|
|
214
476
|
}
|
|
215
|
-
function
|
|
216
|
-
|
|
477
|
+
function isFundConfig(value, ctx, path) {
|
|
478
|
+
const v = asRecord(value);
|
|
479
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
480
|
+
ctx.check(
|
|
481
|
+
isString(v.nav_staleness_threshold),
|
|
482
|
+
`${path}.nav_staleness_threshold`,
|
|
483
|
+
"string",
|
|
484
|
+
v.nav_staleness_threshold
|
|
485
|
+
);
|
|
486
|
+
ctx.check(
|
|
487
|
+
isString(v.min_subscription),
|
|
488
|
+
`${path}.min_subscription`,
|
|
489
|
+
"string",
|
|
490
|
+
v.min_subscription
|
|
491
|
+
);
|
|
492
|
+
ctx.check(
|
|
493
|
+
isString(v.min_redemption),
|
|
494
|
+
`${path}.min_redemption`,
|
|
495
|
+
"string",
|
|
496
|
+
v.min_redemption
|
|
497
|
+
);
|
|
498
|
+
ctx.check(
|
|
499
|
+
isString(v.entry_fee_bps),
|
|
500
|
+
`${path}.entry_fee_bps`,
|
|
501
|
+
"string",
|
|
502
|
+
v.entry_fee_bps
|
|
503
|
+
);
|
|
504
|
+
ctx.check(
|
|
505
|
+
isString(v.exit_fee_bps),
|
|
506
|
+
`${path}.exit_fee_bps`,
|
|
507
|
+
"string",
|
|
508
|
+
v.exit_fee_bps
|
|
509
|
+
);
|
|
510
|
+
ctx.check(
|
|
511
|
+
isFiniteNumber(v.dealing_mode),
|
|
512
|
+
`${path}.dealing_mode`,
|
|
513
|
+
"finite number",
|
|
514
|
+
v.dealing_mode
|
|
515
|
+
);
|
|
516
|
+
ctx.check(
|
|
517
|
+
isString(v.redemption_gate_bps),
|
|
518
|
+
`${path}.redemption_gate_bps`,
|
|
519
|
+
"string",
|
|
520
|
+
v.redemption_gate_bps
|
|
521
|
+
);
|
|
522
|
+
ctx.check(
|
|
523
|
+
isOptionalNullableString(v.protocol_subscription_fee_bps),
|
|
524
|
+
`${path}.protocol_subscription_fee_bps`,
|
|
525
|
+
"string | null | undefined",
|
|
526
|
+
v.protocol_subscription_fee_bps
|
|
527
|
+
);
|
|
528
|
+
ctx.check(
|
|
529
|
+
isOptionalNullableString(v.protocol_fee_recipient),
|
|
530
|
+
`${path}.protocol_fee_recipient`,
|
|
531
|
+
"string | null | undefined",
|
|
532
|
+
v.protocol_fee_recipient
|
|
533
|
+
);
|
|
534
|
+
ctx.check(
|
|
535
|
+
isString(v.management_fee_bps_per_annum),
|
|
536
|
+
`${path}.management_fee_bps_per_annum`,
|
|
537
|
+
"string",
|
|
538
|
+
v.management_fee_bps_per_annum
|
|
539
|
+
);
|
|
540
|
+
return true;
|
|
217
541
|
}
|
|
218
|
-
|
|
219
|
-
|
|
542
|
+
var ISSUANCE_STATUSES = /* @__PURE__ */ new Set([
|
|
543
|
+
"OPEN",
|
|
544
|
+
"CLOSED",
|
|
545
|
+
"FINALIZED",
|
|
546
|
+
"SETTLED",
|
|
547
|
+
"CANCELLED"
|
|
548
|
+
]);
|
|
549
|
+
function isIssuanceStatus(value, ctx, path) {
|
|
550
|
+
return ctx.check(
|
|
551
|
+
isString(value) && ISSUANCE_STATUSES.has(value),
|
|
552
|
+
path,
|
|
553
|
+
`one of ${[...ISSUANCE_STATUSES].join(", ")}`,
|
|
554
|
+
value
|
|
555
|
+
);
|
|
220
556
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
557
|
+
function isBookSummary(value, ctx, path) {
|
|
558
|
+
const v = asRecord(value);
|
|
559
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
560
|
+
ctx.check(
|
|
561
|
+
isString(v.id) || v.id === null,
|
|
562
|
+
`${path}.id`,
|
|
563
|
+
"string | null",
|
|
564
|
+
v.id
|
|
565
|
+
);
|
|
566
|
+
ctx.check(
|
|
567
|
+
isString(v.organization_id),
|
|
568
|
+
`${path}.organization_id`,
|
|
569
|
+
"string",
|
|
570
|
+
v.organization_id
|
|
571
|
+
);
|
|
572
|
+
ctx.check(
|
|
573
|
+
isNullableString(v.name),
|
|
574
|
+
`${path}.name`,
|
|
575
|
+
"string | null",
|
|
576
|
+
v.name
|
|
577
|
+
);
|
|
578
|
+
ctx.check(
|
|
579
|
+
isNullableString(v.book_type),
|
|
580
|
+
`${path}.book_type`,
|
|
581
|
+
"string | null",
|
|
582
|
+
v.book_type
|
|
583
|
+
);
|
|
584
|
+
ctx.check(
|
|
585
|
+
isString(v.token_address),
|
|
586
|
+
`${path}.token_address`,
|
|
587
|
+
"string",
|
|
588
|
+
v.token_address
|
|
589
|
+
);
|
|
590
|
+
ctx.check(
|
|
591
|
+
isString(v.fund_token),
|
|
592
|
+
`${path}.fund_token`,
|
|
593
|
+
"string",
|
|
594
|
+
v.fund_token
|
|
595
|
+
);
|
|
596
|
+
ctx.check(
|
|
597
|
+
isString(v.network_id),
|
|
598
|
+
`${path}.network_id`,
|
|
599
|
+
"string",
|
|
600
|
+
v.network_id
|
|
601
|
+
);
|
|
602
|
+
ctx.check(
|
|
603
|
+
isOptionalNullableString(v.admin_wallet),
|
|
604
|
+
`${path}.admin_wallet`,
|
|
605
|
+
"string | null | undefined",
|
|
606
|
+
v.admin_wallet
|
|
607
|
+
);
|
|
608
|
+
ctx.check(
|
|
609
|
+
isOptionalNullableString(v.manager_wallet),
|
|
610
|
+
`${path}.manager_wallet`,
|
|
611
|
+
"string | null | undefined",
|
|
612
|
+
v.manager_wallet
|
|
613
|
+
);
|
|
614
|
+
ctx.check(
|
|
615
|
+
isString(v.settlement_token),
|
|
616
|
+
`${path}.settlement_token`,
|
|
617
|
+
"string",
|
|
618
|
+
v.settlement_token
|
|
619
|
+
);
|
|
620
|
+
ctx.check(
|
|
621
|
+
isNullableString(v.factory_address),
|
|
622
|
+
`${path}.factory_address`,
|
|
623
|
+
"string | null",
|
|
624
|
+
v.factory_address
|
|
625
|
+
);
|
|
626
|
+
ctx.check(
|
|
627
|
+
isNullableString(v.deployment_txn_hash),
|
|
628
|
+
`${path}.deployment_txn_hash`,
|
|
629
|
+
"string | null",
|
|
630
|
+
v.deployment_txn_hash
|
|
631
|
+
);
|
|
632
|
+
ctx.check(
|
|
633
|
+
isString(v.order_book_address),
|
|
634
|
+
`${path}.order_book_address`,
|
|
635
|
+
"string",
|
|
636
|
+
v.order_book_address
|
|
637
|
+
);
|
|
638
|
+
ctx.check(
|
|
639
|
+
isString(v.fund_address),
|
|
640
|
+
`${path}.fund_address`,
|
|
641
|
+
"string",
|
|
642
|
+
v.fund_address
|
|
643
|
+
);
|
|
644
|
+
ctx.check(
|
|
645
|
+
isString(v.fund_id),
|
|
646
|
+
`${path}.fund_id`,
|
|
647
|
+
"string",
|
|
648
|
+
v.fund_id
|
|
649
|
+
);
|
|
650
|
+
ctx.check(
|
|
651
|
+
isString(v.initial_nav),
|
|
652
|
+
`${path}.initial_nav`,
|
|
653
|
+
"string",
|
|
654
|
+
v.initial_nav
|
|
655
|
+
);
|
|
656
|
+
isFundConfig(v.fund_config, ctx, `${path}.fund_config`);
|
|
657
|
+
isIssuanceStatus(v.status, ctx, `${path}.status`);
|
|
658
|
+
ctx.check(
|
|
659
|
+
isNullableString(v.created_at),
|
|
660
|
+
`${path}.created_at`,
|
|
661
|
+
"string | null",
|
|
662
|
+
v.created_at
|
|
663
|
+
);
|
|
664
|
+
ctx.check(
|
|
665
|
+
isNullableString(v.updated_at),
|
|
666
|
+
`${path}.updated_at`,
|
|
667
|
+
"string | null",
|
|
668
|
+
v.updated_at
|
|
669
|
+
);
|
|
670
|
+
return true;
|
|
223
671
|
}
|
|
224
|
-
function
|
|
225
|
-
|
|
672
|
+
function isAssetRecord(value, ctx, path) {
|
|
673
|
+
const v = asRecord(value);
|
|
674
|
+
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
675
|
+
isSecurityDetails(v.security, ctx, `${path}.security`);
|
|
676
|
+
isIssuerSummary(v.issuer, ctx, `${path}.issuer`);
|
|
677
|
+
const booksOk = ctx.check(
|
|
678
|
+
Array.isArray(v.books),
|
|
679
|
+
`${path}.books`,
|
|
680
|
+
"array",
|
|
681
|
+
v.books
|
|
682
|
+
);
|
|
683
|
+
if (booksOk) {
|
|
684
|
+
v.books.forEach(
|
|
685
|
+
(book, i) => isBookSummary(book, ctx, `${path}.books[${i}]`)
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
isNetworkDetails(v.network, ctx, `${path}.network`);
|
|
689
|
+
return true;
|
|
226
690
|
}
|
|
227
|
-
function
|
|
228
|
-
|
|
691
|
+
function buildValidationError(value, failures) {
|
|
692
|
+
const summary = failures.slice(0, 5).map(
|
|
693
|
+
(f) => `${f.path}: expected ${f.expected}, got ${JSON.stringify(f.received)}`
|
|
694
|
+
).join("; ");
|
|
695
|
+
const message = failures.length > 5 ? `Received an invalid SDK response shape (${failures.length} issues). First 5: ${summary}` : `Received an invalid SDK response shape. ${summary}`;
|
|
696
|
+
return new MalformedResponseError(message, {
|
|
697
|
+
details: { failures: failures.slice(0, 20), value }
|
|
698
|
+
});
|
|
229
699
|
}
|
|
230
700
|
function validateSdkAssetsResponse(value) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
701
|
+
const ctx = new ValidationContext();
|
|
702
|
+
ctx.check(isRecord(value), "<root>", "object", value);
|
|
703
|
+
if (isRecord(value)) {
|
|
704
|
+
ctx.check(Array.isArray(value.data), "<root>.data", "array", value.data);
|
|
705
|
+
ctx.check(
|
|
706
|
+
isFiniteNumber(value.count),
|
|
707
|
+
"<root>.count",
|
|
708
|
+
"finite number",
|
|
709
|
+
value.count
|
|
235
710
|
);
|
|
711
|
+
if (Array.isArray(value.data)) {
|
|
712
|
+
value.data.forEach(
|
|
713
|
+
(item, i) => isAssetRecord(item, ctx, `<root>.data[${i}]`)
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
if (ctx.failures.length > 0) {
|
|
718
|
+
throw buildValidationError(value, ctx.failures);
|
|
236
719
|
}
|
|
237
720
|
return value;
|
|
238
721
|
}
|
|
239
722
|
function validateSdkAssetResponse(value) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
723
|
+
const ctx = new ValidationContext();
|
|
724
|
+
ctx.check(isRecord(value), "<root>", "object", value);
|
|
725
|
+
if (isRecord(value)) {
|
|
726
|
+
isAssetRecord(value.data, ctx, "<root>.data");
|
|
727
|
+
}
|
|
728
|
+
if (ctx.failures.length > 0) {
|
|
729
|
+
throw buildValidationError(value, ctx.failures);
|
|
245
730
|
}
|
|
246
731
|
return value;
|
|
247
732
|
}
|
|
@@ -281,10 +766,13 @@ function createClient(config) {
|
|
|
281
766
|
}
|
|
282
767
|
export {
|
|
283
768
|
ENVIRONMENT_BASE_URLS,
|
|
769
|
+
ForbiddenError,
|
|
284
770
|
HttpError,
|
|
285
771
|
InvalidConfigurationError,
|
|
286
772
|
MalformedResponseError,
|
|
773
|
+
NetworkError,
|
|
287
774
|
NotFoundError,
|
|
775
|
+
RateLimitError,
|
|
288
776
|
SereelSdkError,
|
|
289
777
|
ServerError,
|
|
290
778
|
TimeoutError,
|