@sereel/sdk 0.1.6 → 0.2.1
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 +20 -30
- package/dist/index.cjs +110 -161
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -21
- package/dist/index.d.ts +6 -21
- package/dist/index.js +110 -161
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,8 +76,8 @@ const client = createClient({
|
|
|
76
76
|
```ts
|
|
77
77
|
const { data, count } = await client.getAssets();
|
|
78
78
|
|
|
79
|
-
for (const
|
|
80
|
-
console.log(
|
|
79
|
+
for (const asset of data) {
|
|
80
|
+
console.log(asset.token_name, asset.issuer?.legal_name);
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
@@ -86,14 +86,17 @@ for (const record of data) {
|
|
|
86
86
|
### `client.getAssetByTokenAddress(tokenAddress)`
|
|
87
87
|
|
|
88
88
|
`GET /sdk/assets/{token_address}` — returns a single asset by its on-chain
|
|
89
|
-
token address.
|
|
89
|
+
token address. The response is a single `SdkSecurityDetails` object that
|
|
90
|
+
contains the token, issuer, primary book, and network details all in one
|
|
91
|
+
place.
|
|
90
92
|
|
|
91
93
|
```ts
|
|
92
94
|
const { data } = await client.getAssetByTokenAddress("0xabc…");
|
|
93
95
|
|
|
94
|
-
console.log(data.
|
|
95
|
-
console.log(data.
|
|
96
|
-
console.log(data.
|
|
96
|
+
console.log(data.token_name);
|
|
97
|
+
console.log(data.rule_engine?.name); // present if token has compliance rules
|
|
98
|
+
console.log(data.book?.status); // present if token has a book
|
|
99
|
+
console.log(data.network.name);
|
|
97
100
|
```
|
|
98
101
|
|
|
99
102
|
---
|
|
@@ -108,28 +111,20 @@ specific issuer. The `issuerId` is the `id` field from `SdkIssuerSummary`
|
|
|
108
111
|
const { data, count } = await client.getAssetsByIssuer("64f1a2b3c4d5e6f7a8b9c0d1");
|
|
109
112
|
|
|
110
113
|
console.log(`${count} tokens from this issuer`);
|
|
111
|
-
data.forEach(
|
|
114
|
+
data.forEach(asset => console.log(asset.token_symbol));
|
|
112
115
|
```
|
|
113
116
|
|
|
114
117
|
---
|
|
115
118
|
|
|
116
119
|
## Response shape
|
|
117
120
|
|
|
118
|
-
Every API method returns one or more `
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
interface SdkAssetRecord {
|
|
122
|
-
security: SdkSecurityDetails;
|
|
123
|
-
issuer: SdkIssuerSummary;
|
|
124
|
-
books: SdkBookSummary[];
|
|
125
|
-
network: NetworkDetails;
|
|
126
|
-
}
|
|
127
|
-
```
|
|
121
|
+
Every API method returns one or more `SdkSecurityDetails` objects.
|
|
128
122
|
|
|
129
123
|
### `SdkSecurityDetails`
|
|
130
124
|
|
|
131
|
-
Full token details
|
|
132
|
-
|
|
125
|
+
Full token details with issuer, book, and network flattened into a single
|
|
126
|
+
object. Internal and sensitive fields are intentionally excluded (`id`,
|
|
127
|
+
`org_id`, `deployment_txn_hash`, `token_program_id`, `engines` (raw),
|
|
133
128
|
`extra_information_attributes`, `allowlist_manager`, `iota_*` fields,
|
|
134
129
|
`individual_token_price`, `rule_engine_id`, `updated_at`).
|
|
135
130
|
|
|
@@ -144,15 +139,20 @@ interface SdkSecurityDetails {
|
|
|
144
139
|
admin: string; // token admin wallet address
|
|
145
140
|
icon_url: string | null;
|
|
146
141
|
prospectus: SdkTokenProspectus | null;
|
|
142
|
+
issuer: SdkIssuerSummary | null;
|
|
143
|
+
book: SdkBookSummary | null;
|
|
147
144
|
partners: SdkTokenPartner[] | null;
|
|
148
145
|
rule_engine: SdkRuleEngineSummary | null; // present when token has compliance rules
|
|
146
|
+
network: NetworkDetails;
|
|
149
147
|
created_at: string | null;
|
|
148
|
+
trex_claim_topics: number[] | null;
|
|
149
|
+
trex_issuers: string[] | null;
|
|
150
150
|
}
|
|
151
151
|
```
|
|
152
152
|
|
|
153
153
|
### `SdkRuleEngineSummary`
|
|
154
154
|
|
|
155
|
-
When a token has an associated compliance rule engine, it is
|
|
155
|
+
When a token has an associated compliance rule engine, it is included in the
|
|
156
156
|
security details. Only the name, address, and a slim view of each linked rule
|
|
157
157
|
are exposed.
|
|
158
158
|
|
|
@@ -212,10 +212,7 @@ interface SdkFundConfig {
|
|
|
212
212
|
min_redemption: string;
|
|
213
213
|
entry_fee_bps: string;
|
|
214
214
|
exit_fee_bps: string;
|
|
215
|
-
dealing_mode: number;
|
|
216
215
|
redemption_gate_bps: string;
|
|
217
|
-
protocol_subscription_fee_bps: string;
|
|
218
|
-
protocol_fee_recipient: string;
|
|
219
216
|
management_fee_bps_per_annum: string;
|
|
220
217
|
}
|
|
221
218
|
|
|
@@ -225,11 +222,8 @@ interface SdkBookSummary {
|
|
|
225
222
|
name: string | null;
|
|
226
223
|
book_type: string | null; // e.g. "open"
|
|
227
224
|
token_address: string;
|
|
228
|
-
fund_token: string; // alias for token_address
|
|
229
225
|
network_id: string;
|
|
230
226
|
settlement_token: string;
|
|
231
|
-
factory_address: string | null;
|
|
232
|
-
deployment_txn_hash: string | null;
|
|
233
227
|
order_book_address: string;
|
|
234
228
|
fund_address: string;
|
|
235
229
|
fund_id: string;
|
|
@@ -237,7 +231,6 @@ interface SdkBookSummary {
|
|
|
237
231
|
fund_config: SdkFundConfig;
|
|
238
232
|
status: IssuanceStatus;
|
|
239
233
|
created_at: string | null;
|
|
240
|
-
updated_at: string | null;
|
|
241
234
|
}
|
|
242
235
|
```
|
|
243
236
|
|
|
@@ -254,10 +247,7 @@ interface NetworkDetails {
|
|
|
254
247
|
native_currency: NativeCurrency;
|
|
255
248
|
rpc_endpoint: string;
|
|
256
249
|
explorer_urls: string[];
|
|
257
|
-
can_deploy_cmtat_token: boolean;
|
|
258
|
-
can_deploy_trex_token: boolean;
|
|
259
250
|
is_testnet: boolean;
|
|
260
|
-
is_supported: boolean;
|
|
261
251
|
}
|
|
262
252
|
```
|
|
263
253
|
|
package/dist/index.cjs
CHANGED
|
@@ -234,9 +234,6 @@ function isString(value) {
|
|
|
234
234
|
function isNullableString(value) {
|
|
235
235
|
return typeof value === "string" || value === null;
|
|
236
236
|
}
|
|
237
|
-
function isOptionalNullableString(value) {
|
|
238
|
-
return typeof value === "string" || value === null || value === void 0;
|
|
239
|
-
}
|
|
240
237
|
function isFiniteNumber(value) {
|
|
241
238
|
return typeof value === "number" && Number.isFinite(value);
|
|
242
239
|
}
|
|
@@ -325,79 +322,6 @@ function isRuleEngineSummary(value, ctx, path) {
|
|
|
325
322
|
}
|
|
326
323
|
return true;
|
|
327
324
|
}
|
|
328
|
-
function isSecurityDetails(value, ctx, path) {
|
|
329
|
-
const v = asRecord(value);
|
|
330
|
-
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
331
|
-
ctx.check(
|
|
332
|
-
isString(v.token_address),
|
|
333
|
-
`${path}.token_address`,
|
|
334
|
-
"string",
|
|
335
|
-
v.token_address
|
|
336
|
-
);
|
|
337
|
-
ctx.check(
|
|
338
|
-
isString(v.token_name),
|
|
339
|
-
`${path}.token_name`,
|
|
340
|
-
"string",
|
|
341
|
-
v.token_name
|
|
342
|
-
);
|
|
343
|
-
ctx.check(
|
|
344
|
-
isString(v.token_symbol),
|
|
345
|
-
`${path}.token_symbol`,
|
|
346
|
-
"string",
|
|
347
|
-
v.token_symbol
|
|
348
|
-
);
|
|
349
|
-
ctx.check(
|
|
350
|
-
isString(v.token_decimal),
|
|
351
|
-
`${path}.token_decimal`,
|
|
352
|
-
"string",
|
|
353
|
-
v.token_decimal
|
|
354
|
-
);
|
|
355
|
-
ctx.check(
|
|
356
|
-
isString(v.network_id),
|
|
357
|
-
`${path}.network_id`,
|
|
358
|
-
"string",
|
|
359
|
-
v.network_id
|
|
360
|
-
);
|
|
361
|
-
ctx.check(
|
|
362
|
-
isString(v.token_type),
|
|
363
|
-
`${path}.token_type`,
|
|
364
|
-
"string",
|
|
365
|
-
v.token_type
|
|
366
|
-
);
|
|
367
|
-
ctx.check(isString(v.admin), `${path}.admin`, "string", v.admin);
|
|
368
|
-
ctx.check(
|
|
369
|
-
isNullableString(v.icon_url),
|
|
370
|
-
`${path}.icon_url`,
|
|
371
|
-
"string | null",
|
|
372
|
-
v.icon_url
|
|
373
|
-
);
|
|
374
|
-
ctx.check(
|
|
375
|
-
isNullableString(v.created_at),
|
|
376
|
-
`${path}.created_at`,
|
|
377
|
-
"string | null",
|
|
378
|
-
v.created_at
|
|
379
|
-
);
|
|
380
|
-
if (v.prospectus !== null && v.prospectus !== void 0) {
|
|
381
|
-
isProspectus(v.prospectus, ctx, `${path}.prospectus`);
|
|
382
|
-
}
|
|
383
|
-
if (v.partners !== null && v.partners !== void 0) {
|
|
384
|
-
const partnersOk = ctx.check(
|
|
385
|
-
Array.isArray(v.partners),
|
|
386
|
-
`${path}.partners`,
|
|
387
|
-
"array",
|
|
388
|
-
v.partners
|
|
389
|
-
);
|
|
390
|
-
if (partnersOk) {
|
|
391
|
-
v.partners.forEach(
|
|
392
|
-
(partner, i) => isTokenPartner(partner, ctx, `${path}.partners[${i}]`)
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
if (v.rule_engine !== null && v.rule_engine !== void 0) {
|
|
397
|
-
isRuleEngineSummary(v.rule_engine, ctx, `${path}.rule_engine`);
|
|
398
|
-
}
|
|
399
|
-
return true;
|
|
400
|
-
}
|
|
401
325
|
function isIssuerSummary(value, ctx, path) {
|
|
402
326
|
const v = asRecord(value);
|
|
403
327
|
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
@@ -487,30 +411,12 @@ function isNetworkDetails(value, ctx, path) {
|
|
|
487
411
|
)
|
|
488
412
|
);
|
|
489
413
|
}
|
|
490
|
-
ctx.check(
|
|
491
|
-
isBoolean(v.can_deploy_cmtat_token),
|
|
492
|
-
`${path}.can_deploy_cmtat_token`,
|
|
493
|
-
"boolean",
|
|
494
|
-
v.can_deploy_cmtat_token
|
|
495
|
-
);
|
|
496
|
-
ctx.check(
|
|
497
|
-
isBoolean(v.can_deploy_trex_token),
|
|
498
|
-
`${path}.can_deploy_trex_token`,
|
|
499
|
-
"boolean",
|
|
500
|
-
v.can_deploy_trex_token
|
|
501
|
-
);
|
|
502
414
|
ctx.check(
|
|
503
415
|
isBoolean(v.is_testnet),
|
|
504
416
|
`${path}.is_testnet`,
|
|
505
417
|
"boolean",
|
|
506
418
|
v.is_testnet
|
|
507
419
|
);
|
|
508
|
-
ctx.check(
|
|
509
|
-
isBoolean(v.is_supported),
|
|
510
|
-
`${path}.is_supported`,
|
|
511
|
-
"boolean",
|
|
512
|
-
v.is_supported
|
|
513
|
-
);
|
|
514
420
|
return true;
|
|
515
421
|
}
|
|
516
422
|
function isFundConfig(value, ctx, path) {
|
|
@@ -546,30 +452,12 @@ function isFundConfig(value, ctx, path) {
|
|
|
546
452
|
"string",
|
|
547
453
|
v.exit_fee_bps
|
|
548
454
|
);
|
|
549
|
-
ctx.check(
|
|
550
|
-
isFiniteNumber(v.dealing_mode),
|
|
551
|
-
`${path}.dealing_mode`,
|
|
552
|
-
"finite number",
|
|
553
|
-
v.dealing_mode
|
|
554
|
-
);
|
|
555
455
|
ctx.check(
|
|
556
456
|
isString(v.redemption_gate_bps),
|
|
557
457
|
`${path}.redemption_gate_bps`,
|
|
558
458
|
"string",
|
|
559
459
|
v.redemption_gate_bps
|
|
560
460
|
);
|
|
561
|
-
ctx.check(
|
|
562
|
-
isOptionalNullableString(v.protocol_subscription_fee_bps),
|
|
563
|
-
`${path}.protocol_subscription_fee_bps`,
|
|
564
|
-
"string | null | undefined",
|
|
565
|
-
v.protocol_subscription_fee_bps
|
|
566
|
-
);
|
|
567
|
-
ctx.check(
|
|
568
|
-
isOptionalNullableString(v.protocol_fee_recipient),
|
|
569
|
-
`${path}.protocol_fee_recipient`,
|
|
570
|
-
"string | null | undefined",
|
|
571
|
-
v.protocol_fee_recipient
|
|
572
|
-
);
|
|
573
461
|
ctx.check(
|
|
574
462
|
isString(v.management_fee_bps_per_annum),
|
|
575
463
|
`${path}.management_fee_bps_per_annum`,
|
|
@@ -626,48 +514,18 @@ function isBookSummary(value, ctx, path) {
|
|
|
626
514
|
"string",
|
|
627
515
|
v.token_address
|
|
628
516
|
);
|
|
629
|
-
ctx.check(
|
|
630
|
-
isString(v.fund_token),
|
|
631
|
-
`${path}.fund_token`,
|
|
632
|
-
"string",
|
|
633
|
-
v.fund_token
|
|
634
|
-
);
|
|
635
517
|
ctx.check(
|
|
636
518
|
isString(v.network_id),
|
|
637
519
|
`${path}.network_id`,
|
|
638
520
|
"string",
|
|
639
521
|
v.network_id
|
|
640
522
|
);
|
|
641
|
-
ctx.check(
|
|
642
|
-
isOptionalNullableString(v.admin_wallet),
|
|
643
|
-
`${path}.admin_wallet`,
|
|
644
|
-
"string | null | undefined",
|
|
645
|
-
v.admin_wallet
|
|
646
|
-
);
|
|
647
|
-
ctx.check(
|
|
648
|
-
isOptionalNullableString(v.manager_wallet),
|
|
649
|
-
`${path}.manager_wallet`,
|
|
650
|
-
"string | null | undefined",
|
|
651
|
-
v.manager_wallet
|
|
652
|
-
);
|
|
653
523
|
ctx.check(
|
|
654
524
|
isString(v.settlement_token),
|
|
655
525
|
`${path}.settlement_token`,
|
|
656
526
|
"string",
|
|
657
527
|
v.settlement_token
|
|
658
528
|
);
|
|
659
|
-
ctx.check(
|
|
660
|
-
isNullableString(v.factory_address),
|
|
661
|
-
`${path}.factory_address`,
|
|
662
|
-
"string | null",
|
|
663
|
-
v.factory_address
|
|
664
|
-
);
|
|
665
|
-
ctx.check(
|
|
666
|
-
isNullableString(v.deployment_txn_hash),
|
|
667
|
-
`${path}.deployment_txn_hash`,
|
|
668
|
-
"string | null",
|
|
669
|
-
v.deployment_txn_hash
|
|
670
|
-
);
|
|
671
529
|
ctx.check(
|
|
672
530
|
isString(v.order_book_address),
|
|
673
531
|
`${path}.order_book_address`,
|
|
@@ -700,31 +558,122 @@ function isBookSummary(value, ctx, path) {
|
|
|
700
558
|
"string | null",
|
|
701
559
|
v.created_at
|
|
702
560
|
);
|
|
703
|
-
ctx.check(
|
|
704
|
-
isNullableString(v.updated_at),
|
|
705
|
-
`${path}.updated_at`,
|
|
706
|
-
"string | null",
|
|
707
|
-
v.updated_at
|
|
708
|
-
);
|
|
709
561
|
return true;
|
|
710
562
|
}
|
|
711
|
-
function
|
|
563
|
+
function isSecurityDetails(value, ctx, path) {
|
|
712
564
|
const v = asRecord(value);
|
|
713
565
|
if (!ctx.check(v !== void 0, path, "object", value)) return false;
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
566
|
+
ctx.check(
|
|
567
|
+
isString(v.token_address),
|
|
568
|
+
`${path}.token_address`,
|
|
569
|
+
"string",
|
|
570
|
+
v.token_address
|
|
571
|
+
);
|
|
572
|
+
ctx.check(
|
|
573
|
+
isString(v.token_name),
|
|
574
|
+
`${path}.token_name`,
|
|
575
|
+
"string",
|
|
576
|
+
v.token_name
|
|
577
|
+
);
|
|
578
|
+
ctx.check(
|
|
579
|
+
isString(v.token_symbol),
|
|
580
|
+
`${path}.token_symbol`,
|
|
581
|
+
"string",
|
|
582
|
+
v.token_symbol
|
|
721
583
|
);
|
|
722
|
-
|
|
723
|
-
v.
|
|
724
|
-
|
|
584
|
+
ctx.check(
|
|
585
|
+
isString(v.token_decimal),
|
|
586
|
+
`${path}.token_decimal`,
|
|
587
|
+
"string",
|
|
588
|
+
v.token_decimal
|
|
589
|
+
);
|
|
590
|
+
ctx.check(
|
|
591
|
+
isString(v.network_id),
|
|
592
|
+
`${path}.network_id`,
|
|
593
|
+
"string",
|
|
594
|
+
v.network_id
|
|
595
|
+
);
|
|
596
|
+
ctx.check(
|
|
597
|
+
isString(v.token_type),
|
|
598
|
+
`${path}.token_type`,
|
|
599
|
+
"string",
|
|
600
|
+
v.token_type
|
|
601
|
+
);
|
|
602
|
+
ctx.check(isString(v.admin), `${path}.admin`, "string", v.admin);
|
|
603
|
+
ctx.check(
|
|
604
|
+
isNullableString(v.icon_url),
|
|
605
|
+
`${path}.icon_url`,
|
|
606
|
+
"string | null",
|
|
607
|
+
v.icon_url
|
|
608
|
+
);
|
|
609
|
+
ctx.check(
|
|
610
|
+
isNullableString(v.created_at),
|
|
611
|
+
`${path}.created_at`,
|
|
612
|
+
"string | null",
|
|
613
|
+
v.created_at
|
|
614
|
+
);
|
|
615
|
+
if (v.prospectus !== null && v.prospectus !== void 0) {
|
|
616
|
+
isProspectus(v.prospectus, ctx, `${path}.prospectus`);
|
|
617
|
+
}
|
|
618
|
+
if (v.issuer !== null && v.issuer !== void 0) {
|
|
619
|
+
isIssuerSummary(v.issuer, ctx, `${path}.issuer`);
|
|
620
|
+
}
|
|
621
|
+
if (v.book !== null && v.book !== void 0) {
|
|
622
|
+
isBookSummary(v.book, ctx, `${path}.book`);
|
|
623
|
+
}
|
|
624
|
+
if (v.partners !== null && v.partners !== void 0) {
|
|
625
|
+
const partnersOk = ctx.check(
|
|
626
|
+
Array.isArray(v.partners),
|
|
627
|
+
`${path}.partners`,
|
|
628
|
+
"array",
|
|
629
|
+
v.partners
|
|
725
630
|
);
|
|
631
|
+
if (partnersOk) {
|
|
632
|
+
v.partners.forEach(
|
|
633
|
+
(partner, i) => isTokenPartner(partner, ctx, `${path}.partners[${i}]`)
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
if (v.rule_engine !== null && v.rule_engine !== void 0) {
|
|
638
|
+
isRuleEngineSummary(v.rule_engine, ctx, `${path}.rule_engine`);
|
|
726
639
|
}
|
|
727
640
|
isNetworkDetails(v.network, ctx, `${path}.network`);
|
|
641
|
+
if (v.trex_claim_topics !== null && v.trex_claim_topics !== void 0) {
|
|
642
|
+
const topicsOk = ctx.check(
|
|
643
|
+
Array.isArray(v.trex_claim_topics),
|
|
644
|
+
`${path}.trex_claim_topics`,
|
|
645
|
+
"number[]",
|
|
646
|
+
v.trex_claim_topics
|
|
647
|
+
);
|
|
648
|
+
if (topicsOk) {
|
|
649
|
+
v.trex_claim_topics.forEach(
|
|
650
|
+
(topic, i) => ctx.check(
|
|
651
|
+
isFiniteNumber(topic),
|
|
652
|
+
`${path}.trex_claim_topics[${i}]`,
|
|
653
|
+
"finite number",
|
|
654
|
+
topic
|
|
655
|
+
)
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if (v.trex_issuers !== null && v.trex_issuers !== void 0) {
|
|
660
|
+
const issuersOk = ctx.check(
|
|
661
|
+
Array.isArray(v.trex_issuers),
|
|
662
|
+
`${path}.trex_issuers`,
|
|
663
|
+
"string[]",
|
|
664
|
+
v.trex_issuers
|
|
665
|
+
);
|
|
666
|
+
if (issuersOk) {
|
|
667
|
+
v.trex_issuers.forEach(
|
|
668
|
+
(issuer, i) => ctx.check(
|
|
669
|
+
isString(issuer),
|
|
670
|
+
`${path}.trex_issuers[${i}]`,
|
|
671
|
+
"string",
|
|
672
|
+
issuer
|
|
673
|
+
)
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
728
677
|
return true;
|
|
729
678
|
}
|
|
730
679
|
function buildValidationError(value, failures) {
|
|
@@ -749,7 +698,7 @@ function validateSdkAssetsResponse(value) {
|
|
|
749
698
|
);
|
|
750
699
|
if (Array.isArray(value.data)) {
|
|
751
700
|
value.data.forEach(
|
|
752
|
-
(item, i) =>
|
|
701
|
+
(item, i) => isSecurityDetails(item, ctx, `<root>.data[${i}]`)
|
|
753
702
|
);
|
|
754
703
|
}
|
|
755
704
|
}
|
|
@@ -762,7 +711,7 @@ function validateSdkAssetResponse(value) {
|
|
|
762
711
|
const ctx = new ValidationContext();
|
|
763
712
|
ctx.check(isRecord(value), "<root>", "object", value);
|
|
764
713
|
if (isRecord(value)) {
|
|
765
|
-
|
|
714
|
+
isSecurityDetails(value.data, ctx, "<root>.data");
|
|
766
715
|
}
|
|
767
716
|
if (ctx.failures.length > 0) {
|
|
768
717
|
throw buildValidationError(value, ctx.failures);
|