@empereur-rouge/pms-sdk 0.3.3 → 0.3.5

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 CHANGED
@@ -171,6 +171,20 @@ console.log(imported.address); // même adresse que ci-dessus
171
171
 
172
172
  #### Méthodes de Lecture
173
173
 
174
+ ```typescript
175
+ // Lister les ledgers actifs (avec block_count et symbol par ledger)
176
+ const ledgers: LedgerInfo[] = await client.listLedgers();
177
+ // Réponse:
178
+ // [
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
+ // ]
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", ... }]
186
+ ```
187
+
174
188
  ```typescript
175
189
  // Récupérer les tips du DAG (blocs les plus récents)
176
190
  const tips: string[] = await client.getTips();
@@ -256,7 +270,57 @@ const historyWithDecrypt = await client.getHistory(address, {
256
270
  // Les items "EncryptedReward" déchiffrés apparaîtront comme des "Reward" standards
257
271
  ```
258
272
 
259
- #### Méthodes d'Écriture (Transactions)
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)
260
324
 
261
325
  ```typescript
262
326
  // Envoyer des tokens
@@ -455,10 +519,21 @@ import type {
455
519
  // Blocs & Transactions (lecture)
456
520
  Block,
457
521
  Utxo,
458
-
522
+
459
523
  // Historique
460
524
  WalletHistoryResp,
461
525
  HistoryItem,
526
+
527
+ // Activity
528
+ ActivityItem,
529
+ ActivityResp,
530
+ ActivityOptions,
531
+ StreamActivityOptions,
532
+ ActivityType,
533
+ ActivityDirection,
534
+
535
+ // Ledger
536
+ LedgerInfo,
462
537
  } from "@empereur-rouge/pms-sdk";
463
538
 
464
539
  // Types bas niveau (API avancée)
package/dist/index.cjs CHANGED
@@ -374,6 +374,30 @@ var PmsClient = class {
374
374
  async getCoordinatorInfo() {
375
375
  return this.fetch("/v1/coordinator/info");
376
376
  }
377
+ /**
378
+ * Liste tous les ledgers actifs avec leur nombre de blocs.
379
+ *
380
+ * @param options - Filtrage optionnel
381
+ * @returns Ledgers correspondants
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * // Tous les ledgers
386
+ * const ledgers = await client.listLedgers();
387
+ *
388
+ * // Filtrer par préfixe de nom (starts_with, case-insensitive)
389
+ * const gaming = await client.listLedgers({ search: "gam" });
390
+ * ```
391
+ */
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 ?? [];
400
+ }
377
401
  /**
378
402
  * Récupère un bloc par son ID.
379
403
  */
@@ -653,6 +677,11 @@ var PmsClient = class {
653
677
  * after_ts: activity.next_after_ts,
654
678
  * after_id: activity.next_after_id,
655
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
+ * });
656
685
  * ```
657
686
  */
658
687
  async getActivity(address, options) {
@@ -672,6 +701,9 @@ var PmsClient = class {
672
701
  if (options?.asset_id !== void 0) {
673
702
  params.set("asset_id", options.asset_id);
674
703
  }
704
+ if (options?.x25519_sk_hex !== void 0) {
705
+ params.set("x25519_sk_hex", options.x25519_sk_hex);
706
+ }
675
707
  const qs = params.toString();
676
708
  const path = `/v1/wallet/${encodeURIComponent(address)}/activity${qs ? `?${qs}` : ""}`;
677
709
  return this.fetch(path);
@@ -704,6 +736,9 @@ var PmsClient = class {
704
736
  if (options.type && options.type.length > 0) {
705
737
  params.set("type", options.type.join(","));
706
738
  }
739
+ if (options.x25519_sk_hex !== void 0) {
740
+ params.set("x25519_sk_hex", options.x25519_sk_hex);
741
+ }
707
742
  const qs = params.toString();
708
743
  const path = `/v1/wallet/${encodeURIComponent(address)}/activity/stream${qs ? `?${qs}` : ""}`;
709
744
  const url = `${this.config.nodeUrl}${path}`;
package/dist/index.d.cts CHANGED
@@ -484,6 +484,26 @@ interface BalanceInfo {
484
484
  /** Liste des UTXOs */
485
485
  utxos: Utxo[];
486
486
  }
487
+ /** Info sur un ledger actif */
488
+ interface LedgerInfo {
489
+ /** Identifiant unique du ledger */
490
+ id: string;
491
+ /** Network ID du ledger */
492
+ network_id: string;
493
+ /** Préfixe de stockage */
494
+ prefix: string;
495
+ /** Version du protocole */
496
+ protocol_version: number;
497
+ /** Nombre de blocs dans le DAG */
498
+ block_count: number;
499
+ /** Symbole du token natif (ex: "PMS") */
500
+ symbol: string;
501
+ }
502
+ /** Options pour listLedgers() */
503
+ interface ListLedgersOptions {
504
+ /** Filtre prefix (starts_with, case-insensitive) sur id, network_id ou symbol */
505
+ search?: string;
506
+ }
487
507
  /** Configuration du client PMS */
488
508
  interface PmsClientConfig {
489
509
  /** URL du nœud principal (ex: "https://node.pms.network") */
@@ -592,11 +612,15 @@ interface ActivityOptions {
592
612
  after_id?: string;
593
613
  /** Filtrer par asset ID */
594
614
  asset_id?: string;
615
+ /** Clé privée X25519 (hex) pour déchiffrer les payloads chiffrés (EncryptedReward, Encrypted). Requiert TLS. */
616
+ x25519_sk_hex?: string;
595
617
  }
596
618
  /** Options pour streamActivity() */
597
619
  interface StreamActivityOptions {
598
620
  /** Filtrer par type(s) d'activité */
599
621
  type?: ActivityType[];
622
+ /** Clé privée X25519 (hex) pour déchiffrer les payloads chiffrés en temps réel. Requiert TLS. */
623
+ x25519_sk_hex?: string;
600
624
  /** Callback appelé pour chaque activité en temps réel */
601
625
  onActivity: (item: ActivityItem) => void;
602
626
  /** Callback appelé en cas d'erreur */
@@ -673,6 +697,22 @@ declare class PmsClient {
673
697
  * Récupère les informations publiques du coordinateur (clés).
674
698
  */
675
699
  getCoordinatorInfo(): Promise<CoordinatorInfoResponse>;
700
+ /**
701
+ * Liste tous les ledgers actifs avec leur nombre de blocs.
702
+ *
703
+ * @param options - Filtrage optionnel
704
+ * @returns Ledgers correspondants
705
+ *
706
+ * @example
707
+ * ```typescript
708
+ * // Tous les ledgers
709
+ * const ledgers = await client.listLedgers();
710
+ *
711
+ * // Filtrer par préfixe de nom (starts_with, case-insensitive)
712
+ * const gaming = await client.listLedgers({ search: "gam" });
713
+ * ```
714
+ */
715
+ listLedgers(options?: ListLedgersOptions): Promise<LedgerInfo[]>;
676
716
  /**
677
717
  * Récupère un bloc par son ID.
678
718
  */
@@ -846,6 +886,11 @@ declare class PmsClient {
846
886
  * after_ts: activity.next_after_ts,
847
887
  * after_id: activity.next_after_id,
848
888
  * });
889
+ *
890
+ * // Avec déchiffrement des payloads chiffrés (TLS requis)
891
+ * const decrypted = await client.getActivity("8eabc...", {
892
+ * x25519_sk_hex: wallet.x25519PrivateKeyHex,
893
+ * });
849
894
  * ```
850
895
  */
851
896
  getActivity(address: string, options?: ActivityOptions): Promise<ActivityResp>;
@@ -1045,4 +1090,4 @@ declare function formatAmount(sats: bigint): string;
1045
1090
  */
1046
1091
  declare function decryptPayload(encrypted: EncryptedPayload, recipientPrivateKeyHex: string): string;
1047
1092
 
1048
- export { type ActivityDirection, type ActivityItem, type ActivityOptions, type ActivityResp, type ActivityType, type BalanceInfo, type Block, type BurnNftResponse, type CoordinatorInfoResponse, type CubeAttributes, type HistoryItem, 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 };
1093
+ 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
@@ -484,6 +484,26 @@ interface BalanceInfo {
484
484
  /** Liste des UTXOs */
485
485
  utxos: Utxo[];
486
486
  }
487
+ /** Info sur un ledger actif */
488
+ interface LedgerInfo {
489
+ /** Identifiant unique du ledger */
490
+ id: string;
491
+ /** Network ID du ledger */
492
+ network_id: string;
493
+ /** Préfixe de stockage */
494
+ prefix: string;
495
+ /** Version du protocole */
496
+ protocol_version: number;
497
+ /** Nombre de blocs dans le DAG */
498
+ block_count: number;
499
+ /** Symbole du token natif (ex: "PMS") */
500
+ symbol: string;
501
+ }
502
+ /** Options pour listLedgers() */
503
+ interface ListLedgersOptions {
504
+ /** Filtre prefix (starts_with, case-insensitive) sur id, network_id ou symbol */
505
+ search?: string;
506
+ }
487
507
  /** Configuration du client PMS */
488
508
  interface PmsClientConfig {
489
509
  /** URL du nœud principal (ex: "https://node.pms.network") */
@@ -592,11 +612,15 @@ interface ActivityOptions {
592
612
  after_id?: string;
593
613
  /** Filtrer par asset ID */
594
614
  asset_id?: string;
615
+ /** Clé privée X25519 (hex) pour déchiffrer les payloads chiffrés (EncryptedReward, Encrypted). Requiert TLS. */
616
+ x25519_sk_hex?: string;
595
617
  }
596
618
  /** Options pour streamActivity() */
597
619
  interface StreamActivityOptions {
598
620
  /** Filtrer par type(s) d'activité */
599
621
  type?: ActivityType[];
622
+ /** Clé privée X25519 (hex) pour déchiffrer les payloads chiffrés en temps réel. Requiert TLS. */
623
+ x25519_sk_hex?: string;
600
624
  /** Callback appelé pour chaque activité en temps réel */
601
625
  onActivity: (item: ActivityItem) => void;
602
626
  /** Callback appelé en cas d'erreur */
@@ -673,6 +697,22 @@ declare class PmsClient {
673
697
  * Récupère les informations publiques du coordinateur (clés).
674
698
  */
675
699
  getCoordinatorInfo(): Promise<CoordinatorInfoResponse>;
700
+ /**
701
+ * Liste tous les ledgers actifs avec leur nombre de blocs.
702
+ *
703
+ * @param options - Filtrage optionnel
704
+ * @returns Ledgers correspondants
705
+ *
706
+ * @example
707
+ * ```typescript
708
+ * // Tous les ledgers
709
+ * const ledgers = await client.listLedgers();
710
+ *
711
+ * // Filtrer par préfixe de nom (starts_with, case-insensitive)
712
+ * const gaming = await client.listLedgers({ search: "gam" });
713
+ * ```
714
+ */
715
+ listLedgers(options?: ListLedgersOptions): Promise<LedgerInfo[]>;
676
716
  /**
677
717
  * Récupère un bloc par son ID.
678
718
  */
@@ -846,6 +886,11 @@ declare class PmsClient {
846
886
  * after_ts: activity.next_after_ts,
847
887
  * after_id: activity.next_after_id,
848
888
  * });
889
+ *
890
+ * // Avec déchiffrement des payloads chiffrés (TLS requis)
891
+ * const decrypted = await client.getActivity("8eabc...", {
892
+ * x25519_sk_hex: wallet.x25519PrivateKeyHex,
893
+ * });
849
894
  * ```
850
895
  */
851
896
  getActivity(address: string, options?: ActivityOptions): Promise<ActivityResp>;
@@ -1045,4 +1090,4 @@ declare function formatAmount(sats: bigint): string;
1045
1090
  */
1046
1091
  declare function decryptPayload(encrypted: EncryptedPayload, recipientPrivateKeyHex: string): string;
1047
1092
 
1048
- export { type ActivityDirection, type ActivityItem, type ActivityOptions, type ActivityResp, type ActivityType, type BalanceInfo, type Block, type BurnNftResponse, type CoordinatorInfoResponse, type CubeAttributes, type HistoryItem, 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 };
1093
+ 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
@@ -341,6 +341,30 @@ var PmsClient = class {
341
341
  async getCoordinatorInfo() {
342
342
  return this.fetch("/v1/coordinator/info");
343
343
  }
344
+ /**
345
+ * Liste tous les ledgers actifs avec leur nombre de blocs.
346
+ *
347
+ * @param options - Filtrage optionnel
348
+ * @returns Ledgers correspondants
349
+ *
350
+ * @example
351
+ * ```typescript
352
+ * // Tous les ledgers
353
+ * const ledgers = await client.listLedgers();
354
+ *
355
+ * // Filtrer par préfixe de nom (starts_with, case-insensitive)
356
+ * const gaming = await client.listLedgers({ search: "gam" });
357
+ * ```
358
+ */
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 ?? [];
367
+ }
344
368
  /**
345
369
  * Récupère un bloc par son ID.
346
370
  */
@@ -620,6 +644,11 @@ var PmsClient = class {
620
644
  * after_ts: activity.next_after_ts,
621
645
  * after_id: activity.next_after_id,
622
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
+ * });
623
652
  * ```
624
653
  */
625
654
  async getActivity(address, options) {
@@ -639,6 +668,9 @@ var PmsClient = class {
639
668
  if (options?.asset_id !== void 0) {
640
669
  params.set("asset_id", options.asset_id);
641
670
  }
671
+ if (options?.x25519_sk_hex !== void 0) {
672
+ params.set("x25519_sk_hex", options.x25519_sk_hex);
673
+ }
642
674
  const qs = params.toString();
643
675
  const path = `/v1/wallet/${encodeURIComponent(address)}/activity${qs ? `?${qs}` : ""}`;
644
676
  return this.fetch(path);
@@ -671,6 +703,9 @@ var PmsClient = class {
671
703
  if (options.type && options.type.length > 0) {
672
704
  params.set("type", options.type.join(","));
673
705
  }
706
+ if (options.x25519_sk_hex !== void 0) {
707
+ params.set("x25519_sk_hex", options.x25519_sk_hex);
708
+ }
674
709
  const qs = params.toString();
675
710
  const path = `/v1/wallet/${encodeURIComponent(address)}/activity/stream${qs ? `?${qs}` : ""}`;
676
711
  const url = `${this.config.nodeUrl}${path}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empereur-rouge/pms-sdk",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "TypeScript SDK for PMS (Planetary Monetary System) — wallet management, transactions, NFTs, and DAG interactions",
5
5
  "author": "empereur-rouge",
6
6
  "license": "MIT",