@rougechain/sdk 0.8.3 → 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/README.md +87 -2
- package/dist/index.cjs +125 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +125 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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);
|
|
@@ -1111,6 +1207,33 @@ var ShieldedClient = class {
|
|
|
1111
1207
|
);
|
|
1112
1208
|
return this.rc.submitTx("/v2/shielded/unshield", tx);
|
|
1113
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
|
+
}
|
|
1114
1237
|
};
|
|
1115
1238
|
|
|
1116
1239
|
// src/address.ts
|
|
@@ -1267,9 +1390,9 @@ var Wallet = class _Wallet {
|
|
|
1267
1390
|
/**
|
|
1268
1391
|
* Generate a new ML-DSA-65 keypair with a BIP-39 mnemonic.
|
|
1269
1392
|
* The mnemonic is stored on the wallet for backup/recovery.
|
|
1270
|
-
* @param strength
|
|
1393
|
+
* @param strength 256 = 24 words (default, post-quantum safe), 128 = 12 words
|
|
1271
1394
|
*/
|
|
1272
|
-
static generate(strength =
|
|
1395
|
+
static generate(strength = 256) {
|
|
1273
1396
|
const mnemonic = generateMnemonic(strength);
|
|
1274
1397
|
const { publicKey, secretKey } = keypairFromMnemonic(mnemonic);
|
|
1275
1398
|
return new _Wallet(publicKey, secretKey, mnemonic);
|