@rougechain/sdk 0.8.2 → 0.8.4

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/dist/index.js CHANGED
@@ -466,6 +466,19 @@ var RougeChain = class {
466
466
  async getFinality() {
467
467
  return this.get("/finality");
468
468
  }
469
+ // ===== EIP-1559 Fee Info =====
470
+ /** Get current EIP-1559 fee information including base fee and suggestions. */
471
+ async getFeeInfo() {
472
+ return this.get("/fee");
473
+ }
474
+ // ===== BFT Finality Proofs =====
475
+ /**
476
+ * Get a BFT finality proof for a specific block height.
477
+ * Returns the aggregated precommit votes that prove ≥2/3 validator stake agreed.
478
+ */
479
+ async getFinalityProof(height) {
480
+ return this.get(`/finality/${height}`);
481
+ }
469
482
  // ===== Peers =====
470
483
  async getPeers() {
471
484
  const data = await this.get("/peers");
@@ -551,6 +564,39 @@ var RougeChain = class {
551
564
  const tx = createSignedTokenMetadataClaim(wallet, tokenSymbol);
552
565
  return this.submitTx("/v2/token/metadata/claim", tx);
553
566
  }
567
+ /**
568
+ * Mint additional tokens for a mintable token (creator only).
569
+ * The token must have been created with `mintable: true`.
570
+ */
571
+ async mintTokens(wallet, params) {
572
+ return this.post("/v2/token/mint", {
573
+ public_key: wallet.publicKey,
574
+ symbol: params.symbol,
575
+ amount: params.amount,
576
+ fee: params.fee ?? 1,
577
+ signature: ""
578
+ // Will be signed server-side via PQC verification
579
+ });
580
+ }
581
+ // ===== WebSocket =====
582
+ /**
583
+ * Connect to the node's WebSocket and optionally subscribe to specific topics.
584
+ * Topics: "blocks", "transactions", "stats", "account:<pubkey>", "token:<symbol>"
585
+ *
586
+ * @example
587
+ * const ws = client.connectWebSocket(["blocks", "account:abc123"]);
588
+ * ws.onmessage = (e) => console.log(JSON.parse(e.data));
589
+ */
590
+ connectWebSocket(topics) {
591
+ const wsUrl = this.baseUrl.replace(/^http/, "ws") + "/ws";
592
+ const ws = new WebSocket(wsUrl);
593
+ if (topics && topics.length > 0) {
594
+ ws.addEventListener("open", () => {
595
+ ws.send(JSON.stringify({ subscribe: topics }));
596
+ });
597
+ }
598
+ return ws;
599
+ }
554
600
  // ===== Rollup =====
555
601
  /** Get the current rollup accumulator status. */
556
602
  async getRollupStatus() {
@@ -911,6 +957,56 @@ var MailClient = class {
911
957
  constructor(rc) {
912
958
  this.rc = rc;
913
959
  }
960
+ // --- Name Registry ---
961
+ async registerName(name, walletId) {
962
+ try {
963
+ const data = await this.rc.post("/names/register", {
964
+ name,
965
+ walletId
966
+ });
967
+ return { success: data.success === true, error: data.error, data };
968
+ } catch (e) {
969
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
970
+ }
971
+ }
972
+ async resolveName(name) {
973
+ try {
974
+ const data = await this.rc.get(
975
+ `/names/resolve/${encodeURIComponent(name.toLowerCase())}`
976
+ );
977
+ if (!data.success) return null;
978
+ return { entry: data.entry, wallet: data.wallet };
979
+ } catch {
980
+ return null;
981
+ }
982
+ }
983
+ async reverseLookup(walletId) {
984
+ try {
985
+ const data = await this.rc.get(
986
+ `/names/reverse/${encodeURIComponent(walletId)}`
987
+ );
988
+ return data.name || null;
989
+ } catch {
990
+ return null;
991
+ }
992
+ }
993
+ async releaseName(name, walletId) {
994
+ try {
995
+ const res = await this.rc.fetchFn(
996
+ `${this.rc.baseUrl}/names/release`,
997
+ {
998
+ method: "DELETE",
999
+ headers: { ...this.rc.headers, "Content-Type": "application/json" },
1000
+ body: JSON.stringify({ name, walletId })
1001
+ }
1002
+ );
1003
+ const data = await res.json();
1004
+ return { success: data.success === true, error: data.error };
1005
+ } catch (e) {
1006
+ return { success: false, error: e instanceof Error ? e.message : String(e) };
1007
+ }
1008
+ }
1009
+ // --- Mail ---
914
1010
  async send(params) {
915
1011
  try {
916
1012
  const data = await this.rc.post("/mail/send", params);
@@ -1015,16 +1111,17 @@ var MessengerClient = class {
1015
1111
  );
1016
1112
  return data.messages ?? [];
1017
1113
  }
1018
- async sendMessage(conversationId, sender, encryptedContent, opts = {}) {
1114
+ async sendMessage(conversationId, senderWalletId, encryptedContent, opts = {}) {
1019
1115
  try {
1020
1116
  const data = await this.rc.post("/messenger/messages", {
1021
- conversation_id: conversationId,
1022
- sender,
1023
- encrypted_content: encryptedContent,
1024
- media_type: opts.mediaType,
1025
- media_data: opts.mediaData,
1026
- self_destruct: opts.selfDestruct,
1027
- destruct_after_seconds: opts.destructAfterSeconds
1117
+ conversationId,
1118
+ senderWalletId,
1119
+ encryptedContent,
1120
+ signature: opts.signature ?? "",
1121
+ messageType: opts.messageType ?? "text",
1122
+ selfDestruct: opts.selfDestruct ?? false,
1123
+ destructAfterSeconds: opts.destructAfterSeconds,
1124
+ spoiler: opts.spoiler ?? false
1028
1125
  });
1029
1126
  return { success: data.success === true, error: data.error, data };
1030
1127
  } catch (e) {
@@ -1046,7 +1143,7 @@ var MessengerClient = class {
1046
1143
  async markRead(messageId) {
1047
1144
  try {
1048
1145
  const data = await this.rc.post("/messenger/messages/read", {
1049
- message_id: messageId
1146
+ messageId
1050
1147
  });
1051
1148
  return { success: data.success === true, error: data.error };
1052
1149
  } catch (e) {
@@ -1110,6 +1207,33 @@ var ShieldedClient = class {
1110
1207
  );
1111
1208
  return this.rc.submitTx("/v2/shielded/unshield", tx);
1112
1209
  }
1210
+ // ─── WASM Smart Contracts ──────────────────────────────────────────
1211
+ /** Deploy a WASM smart contract */
1212
+ async deployContract(params) {
1213
+ return this.rc.post("/v2/contract/deploy", params);
1214
+ }
1215
+ /** Call a WASM smart contract method (mutating) */
1216
+ async callContract(params) {
1217
+ return this.rc.post("/v2/contract/call", params);
1218
+ }
1219
+ /** Get contract metadata */
1220
+ async getContract(addr) {
1221
+ return this.rc.get(`/contract/${addr}`);
1222
+ }
1223
+ /** Read contract storage. Omit key for full state dump. */
1224
+ async getContractState(addr, key) {
1225
+ const q = key ? `?key=${encodeURIComponent(key)}` : "";
1226
+ return this.rc.get(`/contract/${addr}/state${q}`);
1227
+ }
1228
+ /** Get contract events */
1229
+ async getContractEvents(addr, limit) {
1230
+ const q = limit ? `?limit=${limit}` : "";
1231
+ return this.rc.get(`/contract/${addr}/events${q}`);
1232
+ }
1233
+ /** List all deployed contracts */
1234
+ async listContracts() {
1235
+ return this.rc.get("/contracts");
1236
+ }
1113
1237
  };
1114
1238
 
1115
1239
  // src/address.ts
@@ -1266,9 +1390,9 @@ var Wallet = class _Wallet {
1266
1390
  /**
1267
1391
  * Generate a new ML-DSA-65 keypair with a BIP-39 mnemonic.
1268
1392
  * The mnemonic is stored on the wallet for backup/recovery.
1269
- * @param strength 128 = 12 words (default), 256 = 24 words
1393
+ * @param strength 256 = 24 words (default, post-quantum safe), 128 = 12 words
1270
1394
  */
1271
- static generate(strength = 128) {
1395
+ static generate(strength = 256) {
1272
1396
  const mnemonic = generateMnemonic(strength);
1273
1397
  const { publicKey, secretKey } = keypairFromMnemonic(mnemonic);
1274
1398
  return new _Wallet(publicKey, secretKey, mnemonic);