@empereur-rouge/pms-sdk 0.3.4 → 0.3.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 +66 -4
- package/dist/index.cjs +26 -6
- package/dist/index.d.cts +31 -8
- package/dist/index.d.ts +31 -8
- package/dist/index.js +26 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -172,13 +172,17 @@ console.log(imported.address); // même adresse que ci-dessus
|
|
|
172
172
|
#### Méthodes de Lecture
|
|
173
173
|
|
|
174
174
|
```typescript
|
|
175
|
-
// Lister les ledgers actifs (avec block_count par ledger)
|
|
175
|
+
// Lister les ledgers actifs (avec block_count et symbol par ledger)
|
|
176
176
|
const ledgers: LedgerInfo[] = await client.listLedgers();
|
|
177
177
|
// Réponse:
|
|
178
178
|
// [
|
|
179
|
-
// { id: "main", network_id: "mainnet", prefix: "", protocol_version: 1, block_count: 12345 },
|
|
180
|
-
// { id: "gaming", network_id: "gaming-net", prefix: "gam_", protocol_version: 1, block_count: 678 }
|
|
179
|
+
// { id: "main", network_id: "mainnet", prefix: "", protocol_version: 1, block_count: 12345, symbol: "PMS" },
|
|
180
|
+
// { id: "gaming", network_id: "gaming-net", prefix: "gam_", protocol_version: 1, block_count: 678, symbol: "GAME" }
|
|
181
181
|
// ]
|
|
182
|
+
|
|
183
|
+
// Filtrer par préfixe de nom (starts_with, case-insensitive sur id, network_id ou symbol)
|
|
184
|
+
const gaming = await client.listLedgers({ search: "gam" });
|
|
185
|
+
// → [{ id: "gaming", ... }]
|
|
182
186
|
```
|
|
183
187
|
|
|
184
188
|
```typescript
|
|
@@ -266,7 +270,57 @@ const historyWithDecrypt = await client.getHistory(address, {
|
|
|
266
270
|
// Les items "EncryptedReward" déchiffrés apparaîtront comme des "Reward" standards
|
|
267
271
|
```
|
|
268
272
|
|
|
269
|
-
####
|
|
273
|
+
#### Activity API
|
|
274
|
+
|
|
275
|
+
L'Activity API classifie chaque transaction avec un type semantique (`fee_received`, `transfer_in`, `nft_mint`, `freeze`, etc.), une direction et un montant net. Elle remplace `/wallet/history` (deprecie).
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
// Toute l'activite d'un wallet
|
|
279
|
+
const activity = await client.getActivity("8eabc...");
|
|
280
|
+
// Reponse: { address, items: ActivityItem[], count, has_more, next_after_ts?, next_after_id? }
|
|
281
|
+
|
|
282
|
+
// Filtrer par type
|
|
283
|
+
const fees = await client.getActivity("8eabc...", {
|
|
284
|
+
type: ["fee_received", "reward"],
|
|
285
|
+
limit: 20,
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// Pagination
|
|
289
|
+
const page2 = await client.getActivity("8eabc...", {
|
|
290
|
+
after_ts: activity.next_after_ts,
|
|
291
|
+
after_id: activity.next_after_id,
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// Filtrer par asset
|
|
295
|
+
const edeniteActivity = await client.getActivity("8eabc...", {
|
|
296
|
+
asset_id: "edenite",
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// Avec dechiffrement des payloads chiffres (EncryptedReward, Encrypted)
|
|
300
|
+
// IMPORTANT: ne passer la cle privee que sur TLS
|
|
301
|
+
const decrypted = await client.getActivity("8eabc...", {
|
|
302
|
+
x25519_sk_hex: "votre_cle_privee_x25519_hex",
|
|
303
|
+
});
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Streaming temps reel (SSE)** :
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
const stop = client.streamActivity("8eabc...", {
|
|
310
|
+
type: ["transfer_in", "fee_received"],
|
|
311
|
+
x25519_sk_hex: "votre_cle_privee_x25519_hex", // Optionnel: dechiffrement en temps reel
|
|
312
|
+
onActivity: (item) => {
|
|
313
|
+
console.log(`${item.activity_type}: ${item.amount} (${item.direction})`);
|
|
314
|
+
},
|
|
315
|
+
onError: (err) => console.error("SSE error:", err),
|
|
316
|
+
onClose: () => console.log("Stream closed"),
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
// Plus tard: fermer la connexion
|
|
320
|
+
stop();
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
#### Methodes d'Ecriture (Transactions)
|
|
270
324
|
|
|
271
325
|
```typescript
|
|
272
326
|
// Envoyer des tokens
|
|
@@ -470,6 +524,14 @@ import type {
|
|
|
470
524
|
WalletHistoryResp,
|
|
471
525
|
HistoryItem,
|
|
472
526
|
|
|
527
|
+
// Activity
|
|
528
|
+
ActivityItem,
|
|
529
|
+
ActivityResp,
|
|
530
|
+
ActivityOptions,
|
|
531
|
+
StreamActivityOptions,
|
|
532
|
+
ActivityType,
|
|
533
|
+
ActivityDirection,
|
|
534
|
+
|
|
473
535
|
// Ledger
|
|
474
536
|
LedgerInfo,
|
|
475
537
|
} from "@empereur-rouge/pms-sdk";
|
package/dist/index.cjs
CHANGED
|
@@ -377,17 +377,26 @@ var PmsClient = class {
|
|
|
377
377
|
/**
|
|
378
378
|
* Liste tous les ledgers actifs avec leur nombre de blocs.
|
|
379
379
|
*
|
|
380
|
+
* @param options - Filtrage optionnel
|
|
381
|
+
* @returns Ledgers correspondants
|
|
382
|
+
*
|
|
380
383
|
* @example
|
|
381
384
|
* ```typescript
|
|
385
|
+
* // Tous les ledgers
|
|
382
386
|
* const ledgers = await client.listLedgers();
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
* }
|
|
387
|
+
*
|
|
388
|
+
* // Filtrer par préfixe de nom (starts_with, case-insensitive)
|
|
389
|
+
* const gaming = await client.listLedgers({ search: "gam" });
|
|
386
390
|
* ```
|
|
387
391
|
*/
|
|
388
|
-
async listLedgers() {
|
|
389
|
-
const
|
|
390
|
-
|
|
392
|
+
async listLedgers(options) {
|
|
393
|
+
const params = new URLSearchParams();
|
|
394
|
+
if (options?.search) {
|
|
395
|
+
params.set("search", options.search);
|
|
396
|
+
}
|
|
397
|
+
const qs = params.toString();
|
|
398
|
+
const path = `/v1/ledgers${qs ? `?${qs}` : ""}`;
|
|
399
|
+
return (await this.fetch(path)).ledgers ?? [];
|
|
391
400
|
}
|
|
392
401
|
/**
|
|
393
402
|
* Récupère un bloc par son ID.
|
|
@@ -668,6 +677,11 @@ var PmsClient = class {
|
|
|
668
677
|
* after_ts: activity.next_after_ts,
|
|
669
678
|
* after_id: activity.next_after_id,
|
|
670
679
|
* });
|
|
680
|
+
*
|
|
681
|
+
* // Avec déchiffrement des payloads chiffrés (TLS requis)
|
|
682
|
+
* const decrypted = await client.getActivity("8eabc...", {
|
|
683
|
+
* x25519_sk_hex: wallet.x25519PrivateKeyHex,
|
|
684
|
+
* });
|
|
671
685
|
* ```
|
|
672
686
|
*/
|
|
673
687
|
async getActivity(address, options) {
|
|
@@ -687,6 +701,9 @@ var PmsClient = class {
|
|
|
687
701
|
if (options?.asset_id !== void 0) {
|
|
688
702
|
params.set("asset_id", options.asset_id);
|
|
689
703
|
}
|
|
704
|
+
if (options?.x25519_sk_hex !== void 0) {
|
|
705
|
+
params.set("x25519_sk_hex", options.x25519_sk_hex);
|
|
706
|
+
}
|
|
690
707
|
const qs = params.toString();
|
|
691
708
|
const path = `/v1/wallet/${encodeURIComponent(address)}/activity${qs ? `?${qs}` : ""}`;
|
|
692
709
|
return this.fetch(path);
|
|
@@ -719,6 +736,9 @@ var PmsClient = class {
|
|
|
719
736
|
if (options.type && options.type.length > 0) {
|
|
720
737
|
params.set("type", options.type.join(","));
|
|
721
738
|
}
|
|
739
|
+
if (options.x25519_sk_hex !== void 0) {
|
|
740
|
+
params.set("x25519_sk_hex", options.x25519_sk_hex);
|
|
741
|
+
}
|
|
722
742
|
const qs = params.toString();
|
|
723
743
|
const path = `/v1/wallet/${encodeURIComponent(address)}/activity/stream${qs ? `?${qs}` : ""}`;
|
|
724
744
|
const url = `${this.config.nodeUrl}${path}`;
|
package/dist/index.d.cts
CHANGED
|
@@ -472,6 +472,8 @@ interface WalletResponse {
|
|
|
472
472
|
public_key_hex: string;
|
|
473
473
|
/** Clé publique X25519 (hex) */
|
|
474
474
|
x25519_pub_hex: string;
|
|
475
|
+
/** Clé secrète X25519 (hex, dérivée via HKDF depuis la clé ECDSA) */
|
|
476
|
+
x25519_sk_hex: string;
|
|
475
477
|
/** Mots mnémoniques (24 mots, absent si restauré depuis clé privée) */
|
|
476
478
|
mnemonic_words?: string[];
|
|
477
479
|
}
|
|
@@ -496,6 +498,13 @@ interface LedgerInfo {
|
|
|
496
498
|
protocol_version: number;
|
|
497
499
|
/** Nombre de blocs dans le DAG */
|
|
498
500
|
block_count: number;
|
|
501
|
+
/** Symbole du token natif (ex: "PMS") */
|
|
502
|
+
symbol: string;
|
|
503
|
+
}
|
|
504
|
+
/** Options pour listLedgers() */
|
|
505
|
+
interface ListLedgersOptions {
|
|
506
|
+
/** Filtre prefix (starts_with, case-insensitive) sur id, network_id ou symbol */
|
|
507
|
+
search?: string;
|
|
499
508
|
}
|
|
500
509
|
/** Configuration du client PMS */
|
|
501
510
|
interface PmsClientConfig {
|
|
@@ -550,11 +559,12 @@ interface WalletHistoryResp {
|
|
|
550
559
|
* - Minting: "mint"
|
|
551
560
|
* - NFT: "nft_mint", "nft_transfer_in", "nft_transfer_out", "nft_burn", "nft_use"
|
|
552
561
|
* - Bridge: "bridge_lock_in", "bridge_lock_out", "bridge_mint"
|
|
553
|
-
* - Compliance: "freeze", "unfreeze", "seized", "seize_received", "
|
|
562
|
+
* - Compliance: "freeze", "unfreeze", "seized", "seize_received", "reverse_received"
|
|
554
563
|
* - Token: "token_create"
|
|
555
564
|
* - Reward: "reward"
|
|
565
|
+
* - Encrypted: "encrypted" (payload chiffré sans clé de déchiffrement)
|
|
556
566
|
*/
|
|
557
|
-
type ActivityType = "transfer_in" | "transfer_out" | "transfer_self" | "fee_received" | "reward" | "mint" | "nft_mint" | "nft_transfer_in" | "nft_transfer_out" | "nft_burn" | "nft_use" | "bridge_lock_in" | "
|
|
567
|
+
type ActivityType = "transfer_in" | "transfer_out" | "transfer_self" | "fee_received" | "reward" | "mint" | "nft_mint" | "nft_transfer_in" | "nft_transfer_out" | "nft_burn" | "nft_use" | "bridge_lock_in" | "bridge_mint" | "freeze" | "unfreeze" | "seized" | "seize_received" | "reverse_received" | "token_create" | "encrypted";
|
|
558
568
|
/** Direction de l'activité */
|
|
559
569
|
type ActivityDirection = "in" | "out" | "info";
|
|
560
570
|
/** Élément d'activité classifié pour un wallet */
|
|
@@ -597,7 +607,7 @@ interface ActivityResp {
|
|
|
597
607
|
interface ActivityOptions {
|
|
598
608
|
/** Filtrer par type(s) d'activité (ex: ["fee_received", "transfer_in"]) */
|
|
599
609
|
type?: ActivityType[];
|
|
600
|
-
/** Nombre max d'éléments (défaut: 50, max:
|
|
610
|
+
/** Nombre max d'éléments (défaut: 50, max: 2000) */
|
|
601
611
|
limit?: number;
|
|
602
612
|
/** Cursor de pagination: timestamp */
|
|
603
613
|
after_ts?: number;
|
|
@@ -605,11 +615,15 @@ interface ActivityOptions {
|
|
|
605
615
|
after_id?: string;
|
|
606
616
|
/** Filtrer par asset ID */
|
|
607
617
|
asset_id?: string;
|
|
618
|
+
/** Clé privée X25519 (hex) pour déchiffrer les payloads chiffrés (EncryptedReward, Encrypted). Requiert TLS. */
|
|
619
|
+
x25519_sk_hex?: string;
|
|
608
620
|
}
|
|
609
621
|
/** Options pour streamActivity() */
|
|
610
622
|
interface StreamActivityOptions {
|
|
611
623
|
/** Filtrer par type(s) d'activité */
|
|
612
624
|
type?: ActivityType[];
|
|
625
|
+
/** Clé privée X25519 (hex) pour déchiffrer les payloads chiffrés en temps réel. Requiert TLS. */
|
|
626
|
+
x25519_sk_hex?: string;
|
|
613
627
|
/** Callback appelé pour chaque activité en temps réel */
|
|
614
628
|
onActivity: (item: ActivityItem) => void;
|
|
615
629
|
/** Callback appelé en cas d'erreur */
|
|
@@ -689,15 +703,19 @@ declare class PmsClient {
|
|
|
689
703
|
/**
|
|
690
704
|
* Liste tous les ledgers actifs avec leur nombre de blocs.
|
|
691
705
|
*
|
|
706
|
+
* @param options - Filtrage optionnel
|
|
707
|
+
* @returns Ledgers correspondants
|
|
708
|
+
*
|
|
692
709
|
* @example
|
|
693
710
|
* ```typescript
|
|
711
|
+
* // Tous les ledgers
|
|
694
712
|
* const ledgers = await client.listLedgers();
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
* }
|
|
713
|
+
*
|
|
714
|
+
* // Filtrer par préfixe de nom (starts_with, case-insensitive)
|
|
715
|
+
* const gaming = await client.listLedgers({ search: "gam" });
|
|
698
716
|
* ```
|
|
699
717
|
*/
|
|
700
|
-
listLedgers(): Promise<LedgerInfo[]>;
|
|
718
|
+
listLedgers(options?: ListLedgersOptions): Promise<LedgerInfo[]>;
|
|
701
719
|
/**
|
|
702
720
|
* Récupère un bloc par son ID.
|
|
703
721
|
*/
|
|
@@ -871,6 +889,11 @@ declare class PmsClient {
|
|
|
871
889
|
* after_ts: activity.next_after_ts,
|
|
872
890
|
* after_id: activity.next_after_id,
|
|
873
891
|
* });
|
|
892
|
+
*
|
|
893
|
+
* // Avec déchiffrement des payloads chiffrés (TLS requis)
|
|
894
|
+
* const decrypted = await client.getActivity("8eabc...", {
|
|
895
|
+
* x25519_sk_hex: wallet.x25519PrivateKeyHex,
|
|
896
|
+
* });
|
|
874
897
|
* ```
|
|
875
898
|
*/
|
|
876
899
|
getActivity(address: string, options?: ActivityOptions): Promise<ActivityResp>;
|
|
@@ -1070,4 +1093,4 @@ declare function formatAmount(sats: bigint): string;
|
|
|
1070
1093
|
*/
|
|
1071
1094
|
declare function decryptPayload(encrypted: EncryptedPayload, recipientPrivateKeyHex: string): string;
|
|
1072
1095
|
|
|
1073
|
-
export { type ActivityDirection, type ActivityItem, type ActivityOptions, type ActivityResp, type ActivityType, type BalanceInfo, type Block, type BurnNftResponse, type CoordinatorInfoResponse, type CubeAttributes, type HistoryItem, type LedgerInfo, type MintCubeResponse, type NftMetadata, type NftResponse, PmsClient, type PmsClientConfig, PmsWallet, type PrepareTxRequest, type PrepareTxResponse, type RuntimeConfig, type StreamActivityOptions, type SubmitResponse, type SupplyInfo, type TokenMetadata, type Utxo, type UtxoDetail, type WalletHistoryResp, type WalletResponse, decryptPayload, formatAmount, fromHex, isValidMnemonic, parseAmount, toHex };
|
|
1096
|
+
export { type ActivityDirection, type ActivityItem, type ActivityOptions, type ActivityResp, type ActivityType, type BalanceInfo, type Block, type BurnNftResponse, type CoordinatorInfoResponse, type CubeAttributes, type HistoryItem, type LedgerInfo, type ListLedgersOptions, type MintCubeResponse, type NftMetadata, type NftResponse, PmsClient, type PmsClientConfig, PmsWallet, type PrepareTxRequest, type PrepareTxResponse, type RuntimeConfig, type StreamActivityOptions, type SubmitResponse, type SupplyInfo, type TokenMetadata, type Utxo, type UtxoDetail, type WalletHistoryResp, type WalletResponse, decryptPayload, formatAmount, fromHex, isValidMnemonic, parseAmount, toHex };
|
package/dist/index.d.ts
CHANGED
|
@@ -472,6 +472,8 @@ interface WalletResponse {
|
|
|
472
472
|
public_key_hex: string;
|
|
473
473
|
/** Clé publique X25519 (hex) */
|
|
474
474
|
x25519_pub_hex: string;
|
|
475
|
+
/** Clé secrète X25519 (hex, dérivée via HKDF depuis la clé ECDSA) */
|
|
476
|
+
x25519_sk_hex: string;
|
|
475
477
|
/** Mots mnémoniques (24 mots, absent si restauré depuis clé privée) */
|
|
476
478
|
mnemonic_words?: string[];
|
|
477
479
|
}
|
|
@@ -496,6 +498,13 @@ interface LedgerInfo {
|
|
|
496
498
|
protocol_version: number;
|
|
497
499
|
/** Nombre de blocs dans le DAG */
|
|
498
500
|
block_count: number;
|
|
501
|
+
/** Symbole du token natif (ex: "PMS") */
|
|
502
|
+
symbol: string;
|
|
503
|
+
}
|
|
504
|
+
/** Options pour listLedgers() */
|
|
505
|
+
interface ListLedgersOptions {
|
|
506
|
+
/** Filtre prefix (starts_with, case-insensitive) sur id, network_id ou symbol */
|
|
507
|
+
search?: string;
|
|
499
508
|
}
|
|
500
509
|
/** Configuration du client PMS */
|
|
501
510
|
interface PmsClientConfig {
|
|
@@ -550,11 +559,12 @@ interface WalletHistoryResp {
|
|
|
550
559
|
* - Minting: "mint"
|
|
551
560
|
* - NFT: "nft_mint", "nft_transfer_in", "nft_transfer_out", "nft_burn", "nft_use"
|
|
552
561
|
* - Bridge: "bridge_lock_in", "bridge_lock_out", "bridge_mint"
|
|
553
|
-
* - Compliance: "freeze", "unfreeze", "seized", "seize_received", "
|
|
562
|
+
* - Compliance: "freeze", "unfreeze", "seized", "seize_received", "reverse_received"
|
|
554
563
|
* - Token: "token_create"
|
|
555
564
|
* - Reward: "reward"
|
|
565
|
+
* - Encrypted: "encrypted" (payload chiffré sans clé de déchiffrement)
|
|
556
566
|
*/
|
|
557
|
-
type ActivityType = "transfer_in" | "transfer_out" | "transfer_self" | "fee_received" | "reward" | "mint" | "nft_mint" | "nft_transfer_in" | "nft_transfer_out" | "nft_burn" | "nft_use" | "bridge_lock_in" | "
|
|
567
|
+
type ActivityType = "transfer_in" | "transfer_out" | "transfer_self" | "fee_received" | "reward" | "mint" | "nft_mint" | "nft_transfer_in" | "nft_transfer_out" | "nft_burn" | "nft_use" | "bridge_lock_in" | "bridge_mint" | "freeze" | "unfreeze" | "seized" | "seize_received" | "reverse_received" | "token_create" | "encrypted";
|
|
558
568
|
/** Direction de l'activité */
|
|
559
569
|
type ActivityDirection = "in" | "out" | "info";
|
|
560
570
|
/** Élément d'activité classifié pour un wallet */
|
|
@@ -597,7 +607,7 @@ interface ActivityResp {
|
|
|
597
607
|
interface ActivityOptions {
|
|
598
608
|
/** Filtrer par type(s) d'activité (ex: ["fee_received", "transfer_in"]) */
|
|
599
609
|
type?: ActivityType[];
|
|
600
|
-
/** Nombre max d'éléments (défaut: 50, max:
|
|
610
|
+
/** Nombre max d'éléments (défaut: 50, max: 2000) */
|
|
601
611
|
limit?: number;
|
|
602
612
|
/** Cursor de pagination: timestamp */
|
|
603
613
|
after_ts?: number;
|
|
@@ -605,11 +615,15 @@ interface ActivityOptions {
|
|
|
605
615
|
after_id?: string;
|
|
606
616
|
/** Filtrer par asset ID */
|
|
607
617
|
asset_id?: string;
|
|
618
|
+
/** Clé privée X25519 (hex) pour déchiffrer les payloads chiffrés (EncryptedReward, Encrypted). Requiert TLS. */
|
|
619
|
+
x25519_sk_hex?: string;
|
|
608
620
|
}
|
|
609
621
|
/** Options pour streamActivity() */
|
|
610
622
|
interface StreamActivityOptions {
|
|
611
623
|
/** Filtrer par type(s) d'activité */
|
|
612
624
|
type?: ActivityType[];
|
|
625
|
+
/** Clé privée X25519 (hex) pour déchiffrer les payloads chiffrés en temps réel. Requiert TLS. */
|
|
626
|
+
x25519_sk_hex?: string;
|
|
613
627
|
/** Callback appelé pour chaque activité en temps réel */
|
|
614
628
|
onActivity: (item: ActivityItem) => void;
|
|
615
629
|
/** Callback appelé en cas d'erreur */
|
|
@@ -689,15 +703,19 @@ declare class PmsClient {
|
|
|
689
703
|
/**
|
|
690
704
|
* Liste tous les ledgers actifs avec leur nombre de blocs.
|
|
691
705
|
*
|
|
706
|
+
* @param options - Filtrage optionnel
|
|
707
|
+
* @returns Ledgers correspondants
|
|
708
|
+
*
|
|
692
709
|
* @example
|
|
693
710
|
* ```typescript
|
|
711
|
+
* // Tous les ledgers
|
|
694
712
|
* const ledgers = await client.listLedgers();
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
* }
|
|
713
|
+
*
|
|
714
|
+
* // Filtrer par préfixe de nom (starts_with, case-insensitive)
|
|
715
|
+
* const gaming = await client.listLedgers({ search: "gam" });
|
|
698
716
|
* ```
|
|
699
717
|
*/
|
|
700
|
-
listLedgers(): Promise<LedgerInfo[]>;
|
|
718
|
+
listLedgers(options?: ListLedgersOptions): Promise<LedgerInfo[]>;
|
|
701
719
|
/**
|
|
702
720
|
* Récupère un bloc par son ID.
|
|
703
721
|
*/
|
|
@@ -871,6 +889,11 @@ declare class PmsClient {
|
|
|
871
889
|
* after_ts: activity.next_after_ts,
|
|
872
890
|
* after_id: activity.next_after_id,
|
|
873
891
|
* });
|
|
892
|
+
*
|
|
893
|
+
* // Avec déchiffrement des payloads chiffrés (TLS requis)
|
|
894
|
+
* const decrypted = await client.getActivity("8eabc...", {
|
|
895
|
+
* x25519_sk_hex: wallet.x25519PrivateKeyHex,
|
|
896
|
+
* });
|
|
874
897
|
* ```
|
|
875
898
|
*/
|
|
876
899
|
getActivity(address: string, options?: ActivityOptions): Promise<ActivityResp>;
|
|
@@ -1070,4 +1093,4 @@ declare function formatAmount(sats: bigint): string;
|
|
|
1070
1093
|
*/
|
|
1071
1094
|
declare function decryptPayload(encrypted: EncryptedPayload, recipientPrivateKeyHex: string): string;
|
|
1072
1095
|
|
|
1073
|
-
export { type ActivityDirection, type ActivityItem, type ActivityOptions, type ActivityResp, type ActivityType, type BalanceInfo, type Block, type BurnNftResponse, type CoordinatorInfoResponse, type CubeAttributes, type HistoryItem, type LedgerInfo, type MintCubeResponse, type NftMetadata, type NftResponse, PmsClient, type PmsClientConfig, PmsWallet, type PrepareTxRequest, type PrepareTxResponse, type RuntimeConfig, type StreamActivityOptions, type SubmitResponse, type SupplyInfo, type TokenMetadata, type Utxo, type UtxoDetail, type WalletHistoryResp, type WalletResponse, decryptPayload, formatAmount, fromHex, isValidMnemonic, parseAmount, toHex };
|
|
1096
|
+
export { type ActivityDirection, type ActivityItem, type ActivityOptions, type ActivityResp, type ActivityType, type BalanceInfo, type Block, type BurnNftResponse, type CoordinatorInfoResponse, type CubeAttributes, type HistoryItem, type LedgerInfo, type ListLedgersOptions, type MintCubeResponse, type NftMetadata, type NftResponse, PmsClient, type PmsClientConfig, PmsWallet, type PrepareTxRequest, type PrepareTxResponse, type RuntimeConfig, type StreamActivityOptions, type SubmitResponse, type SupplyInfo, type TokenMetadata, type Utxo, type UtxoDetail, type WalletHistoryResp, type WalletResponse, decryptPayload, formatAmount, fromHex, isValidMnemonic, parseAmount, toHex };
|
package/dist/index.js
CHANGED
|
@@ -344,17 +344,26 @@ var PmsClient = class {
|
|
|
344
344
|
/**
|
|
345
345
|
* Liste tous les ledgers actifs avec leur nombre de blocs.
|
|
346
346
|
*
|
|
347
|
+
* @param options - Filtrage optionnel
|
|
348
|
+
* @returns Ledgers correspondants
|
|
349
|
+
*
|
|
347
350
|
* @example
|
|
348
351
|
* ```typescript
|
|
352
|
+
* // Tous les ledgers
|
|
349
353
|
* const ledgers = await client.listLedgers();
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
* }
|
|
354
|
+
*
|
|
355
|
+
* // Filtrer par préfixe de nom (starts_with, case-insensitive)
|
|
356
|
+
* const gaming = await client.listLedgers({ search: "gam" });
|
|
353
357
|
* ```
|
|
354
358
|
*/
|
|
355
|
-
async listLedgers() {
|
|
356
|
-
const
|
|
357
|
-
|
|
359
|
+
async listLedgers(options) {
|
|
360
|
+
const params = new URLSearchParams();
|
|
361
|
+
if (options?.search) {
|
|
362
|
+
params.set("search", options.search);
|
|
363
|
+
}
|
|
364
|
+
const qs = params.toString();
|
|
365
|
+
const path = `/v1/ledgers${qs ? `?${qs}` : ""}`;
|
|
366
|
+
return (await this.fetch(path)).ledgers ?? [];
|
|
358
367
|
}
|
|
359
368
|
/**
|
|
360
369
|
* Récupère un bloc par son ID.
|
|
@@ -635,6 +644,11 @@ var PmsClient = class {
|
|
|
635
644
|
* after_ts: activity.next_after_ts,
|
|
636
645
|
* after_id: activity.next_after_id,
|
|
637
646
|
* });
|
|
647
|
+
*
|
|
648
|
+
* // Avec déchiffrement des payloads chiffrés (TLS requis)
|
|
649
|
+
* const decrypted = await client.getActivity("8eabc...", {
|
|
650
|
+
* x25519_sk_hex: wallet.x25519PrivateKeyHex,
|
|
651
|
+
* });
|
|
638
652
|
* ```
|
|
639
653
|
*/
|
|
640
654
|
async getActivity(address, options) {
|
|
@@ -654,6 +668,9 @@ var PmsClient = class {
|
|
|
654
668
|
if (options?.asset_id !== void 0) {
|
|
655
669
|
params.set("asset_id", options.asset_id);
|
|
656
670
|
}
|
|
671
|
+
if (options?.x25519_sk_hex !== void 0) {
|
|
672
|
+
params.set("x25519_sk_hex", options.x25519_sk_hex);
|
|
673
|
+
}
|
|
657
674
|
const qs = params.toString();
|
|
658
675
|
const path = `/v1/wallet/${encodeURIComponent(address)}/activity${qs ? `?${qs}` : ""}`;
|
|
659
676
|
return this.fetch(path);
|
|
@@ -686,6 +703,9 @@ var PmsClient = class {
|
|
|
686
703
|
if (options.type && options.type.length > 0) {
|
|
687
704
|
params.set("type", options.type.join(","));
|
|
688
705
|
}
|
|
706
|
+
if (options.x25519_sk_hex !== void 0) {
|
|
707
|
+
params.set("x25519_sk_hex", options.x25519_sk_hex);
|
|
708
|
+
}
|
|
689
709
|
const qs = params.toString();
|
|
690
710
|
const path = `/v1/wallet/${encodeURIComponent(address)}/activity/stream${qs ? `?${qs}` : ""}`;
|
|
691
711
|
const url = `${this.config.nodeUrl}${path}`;
|
package/package.json
CHANGED