@rougechain/sdk 0.8.1 → 0.8.3

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
@@ -64,6 +64,9 @@ const { balance } = await rc.getBalance(wallet.publicKey);
64
64
  | **Rollup** | `rc` | zk-STARK batch proofs, rollup status, submit transfers |
65
65
  | **Mail** | `rc.mail` | On-chain encrypted email (`@rouge.quant`) |
66
66
  | **Messenger** | `rc.messenger` | E2E encrypted messaging with self-destruct |
67
+ | **Address Resolution** | `rc` | O(1) rouge1↔pubkey resolution via on-chain index |
68
+ | **Push Notifications** | `rc` | PQC-signed push token registration (Expo) |
69
+ | **Token Freeze** | `rc` | Creator-only token freeze/pause |
67
70
 
68
71
  ## Wallet & Addresses
69
72
 
@@ -402,6 +405,39 @@ const signedTx = signTransaction(payload, wallet.privateKey, wallet.publicKey);
402
405
  const valid = verifyTransaction(signedTx); // true
403
406
  ```
404
407
 
408
+ ## Address Resolution
409
+
410
+ Resolve between compact `rouge1…` addresses and full hex public keys using the on-chain persistent index.
411
+
412
+ ```typescript
413
+ // rouge1… → public key
414
+ const { publicKey } = await rc.resolveAddress("rouge1q8f3x7k2m4...");
415
+
416
+ // public key → rouge1…
417
+ const { address } = await rc.resolveAddress(hexPubKey);
418
+
419
+ // Both return: { success, address, publicKey, balance }
420
+ ```
421
+
422
+ ## Push Notifications
423
+
424
+ Register Expo push tokens for real-time notifications. Requires PQC signature — only the wallet owner can register.
425
+
426
+ ```typescript
427
+ // Register (wallet signs the request with ML-DSA-65)
428
+ await rc.registerPushToken(wallet, expoPushToken);
429
+
430
+ // Unregister
431
+ await rc.unregisterPushToken(wallet);
432
+ ```
433
+
434
+ ## Nonce Management
435
+
436
+ ```typescript
437
+ // Get sequential nonce for an account
438
+ const { nonce, next_nonce } = await rc.getNonce(wallet.publicKey);
439
+ ```
440
+
405
441
  ## Environment Support
406
442
 
407
443
  | Environment | Notes |
package/dist/index.cjs CHANGED
@@ -274,6 +274,18 @@ function createSignedUnshield(wallet, nullifiers, amount, proof) {
274
274
  proof
275
275
  });
276
276
  }
277
+ function createSignedPushRegister(wallet, pushToken, platform = "expo") {
278
+ return buildAndSign(wallet, {
279
+ type: "push_register",
280
+ pushToken,
281
+ platform
282
+ });
283
+ }
284
+ function createSignedPushUnregister(wallet) {
285
+ return buildAndSign(wallet, {
286
+ type: "push_unregister"
287
+ });
288
+ }
277
289
  var COMMITMENT_DOMAIN = new TextEncoder().encode("ROUGECHAIN_COMMITMENT_V1");
278
290
  var NULLIFIER_DOMAIN = new TextEncoder().encode("ROUGECHAIN_NULLIFIER_V1");
279
291
  function generateRandomness() {
@@ -478,14 +490,16 @@ var RougeChain = class {
478
490
  async getNonce(publicKey) {
479
491
  return this.get(`/account/${encodeURIComponent(publicKey)}/nonce`);
480
492
  }
481
- // ===== Push Notifications =====
482
- /** Register an Expo push token for a wallet to receive notifications. */
483
- async registerPushToken(publicKey, pushToken, platform = "expo") {
484
- return this.post("/push/register", { publicKey, pushToken, platform });
493
+ // ===== Push Notifications (PQC-signed) =====
494
+ /** Register an Expo push token signed by wallet to prove ownership. */
495
+ async registerPushToken(wallet, pushToken, platform = "expo") {
496
+ const tx = createSignedPushRegister(wallet, pushToken, platform);
497
+ return this.submitTx("/push/register", tx);
485
498
  }
486
- /** Unregister push notifications for a wallet. */
487
- async unregisterPushToken(publicKey) {
488
- return this.post("/push/unregister", { publicKey });
499
+ /** Unregister push notifications signed by wallet to prove ownership. */
500
+ async unregisterPushToken(wallet) {
501
+ const tx = createSignedPushUnregister(wallet);
502
+ return this.submitTx("/push/unregister", tx);
489
503
  }
490
504
  // ===== Write operations =====
491
505
  async transfer(wallet, params) {
@@ -1003,16 +1017,17 @@ var MessengerClient = class {
1003
1017
  );
1004
1018
  return data.messages ?? [];
1005
1019
  }
1006
- async sendMessage(conversationId, sender, encryptedContent, opts = {}) {
1020
+ async sendMessage(conversationId, senderWalletId, encryptedContent, opts = {}) {
1007
1021
  try {
1008
1022
  const data = await this.rc.post("/messenger/messages", {
1009
- conversation_id: conversationId,
1010
- sender,
1011
- encrypted_content: encryptedContent,
1012
- media_type: opts.mediaType,
1013
- media_data: opts.mediaData,
1014
- self_destruct: opts.selfDestruct,
1015
- destruct_after_seconds: opts.destructAfterSeconds
1023
+ conversationId,
1024
+ senderWalletId,
1025
+ encryptedContent,
1026
+ signature: opts.signature ?? "",
1027
+ messageType: opts.messageType ?? "text",
1028
+ selfDestruct: opts.selfDestruct ?? false,
1029
+ destructAfterSeconds: opts.destructAfterSeconds,
1030
+ spoiler: opts.spoiler ?? false
1016
1031
  });
1017
1032
  return { success: data.success === true, error: data.error, data };
1018
1033
  } catch (e) {
@@ -1034,7 +1049,7 @@ var MessengerClient = class {
1034
1049
  async markRead(messageId) {
1035
1050
  try {
1036
1051
  const data = await this.rc.post("/messenger/messages/read", {
1037
- message_id: messageId
1052
+ messageId
1038
1053
  });
1039
1054
  return { success: data.success === true, error: data.error };
1040
1055
  } catch (e) {