@rougechain/sdk 1.0.0 → 1.1.0
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.cjs +118 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +118 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -361,6 +361,7 @@ var RougeChain = class {
|
|
|
361
361
|
this.mail = new MailClient(this);
|
|
362
362
|
this.messenger = new MessengerClient(this);
|
|
363
363
|
this.shielded = new ShieldedClient(this);
|
|
364
|
+
this.social = new SocialClient(this);
|
|
364
365
|
}
|
|
365
366
|
// ===== Internal helpers =====
|
|
366
367
|
/** @internal */
|
|
@@ -992,14 +993,29 @@ var MailClient = class {
|
|
|
992
993
|
}
|
|
993
994
|
// --- Mail (signed) ---
|
|
994
995
|
async send(wallet, params) {
|
|
996
|
+
const sigPayload = params.encrypted_subject + "|" + params.encrypted_body + (params.encrypted_attachment ? "|" + params.encrypted_attachment : "");
|
|
997
|
+
let contentSig = params.content_signature || "";
|
|
998
|
+
if (!contentSig && wallet.privateKey) {
|
|
999
|
+
try {
|
|
1000
|
+
const { ml_dsa65: ml_dsa654 } = await import('@noble/post-quantum/ml-dsa.js');
|
|
1001
|
+
const privKey = typeof wallet.privateKey === "string" ? hexToBytes(wallet.privateKey) : wallet.privateKey;
|
|
1002
|
+
const sigBytes = ml_dsa654.sign(
|
|
1003
|
+
new TextEncoder().encode(sigPayload),
|
|
1004
|
+
privKey
|
|
1005
|
+
);
|
|
1006
|
+
contentSig = bytesToHex(sigBytes);
|
|
1007
|
+
} catch {
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
995
1010
|
const signed = signRequest(wallet, {
|
|
996
1011
|
fromWalletId: params.from,
|
|
997
1012
|
toWalletIds: [params.to],
|
|
998
1013
|
subjectEncrypted: params.encrypted_subject,
|
|
999
1014
|
bodyEncrypted: params.encrypted_body,
|
|
1000
|
-
|
|
1015
|
+
attachmentEncrypted: params.encrypted_attachment,
|
|
1016
|
+
contentSignature: contentSig,
|
|
1001
1017
|
replyToId: params.reply_to_id,
|
|
1002
|
-
hasAttachment:
|
|
1018
|
+
hasAttachment: !!params.encrypted_attachment
|
|
1003
1019
|
});
|
|
1004
1020
|
return this.rc.submitTx("/v2/mail/send", signed);
|
|
1005
1021
|
}
|
|
@@ -1211,6 +1227,106 @@ var ShieldedClient = class {
|
|
|
1211
1227
|
return this.rc.get("/contracts");
|
|
1212
1228
|
}
|
|
1213
1229
|
};
|
|
1230
|
+
var SocialClient = class {
|
|
1231
|
+
constructor(rc) {
|
|
1232
|
+
this.rc = rc;
|
|
1233
|
+
}
|
|
1234
|
+
async recordPlay(wallet, trackId) {
|
|
1235
|
+
const signed = signRequest(wallet, { trackId });
|
|
1236
|
+
return this.rc.submitTx("/v2/social/play", signed);
|
|
1237
|
+
}
|
|
1238
|
+
async toggleLike(wallet, trackId) {
|
|
1239
|
+
const signed = signRequest(wallet, { trackId });
|
|
1240
|
+
return this.rc.submitTx("/v2/social/like", signed);
|
|
1241
|
+
}
|
|
1242
|
+
async postComment(wallet, trackId, body) {
|
|
1243
|
+
const signed = signRequest(wallet, { trackId, body });
|
|
1244
|
+
return this.rc.submitTx("/v2/social/comment", signed);
|
|
1245
|
+
}
|
|
1246
|
+
async deleteComment(wallet, commentId) {
|
|
1247
|
+
const signed = signRequest(wallet, { commentId });
|
|
1248
|
+
return this.rc.submitTx("/v2/social/comment/delete", signed);
|
|
1249
|
+
}
|
|
1250
|
+
async toggleFollow(wallet, artistPubkey) {
|
|
1251
|
+
const signed = signRequest(wallet, { artistPubkey });
|
|
1252
|
+
return this.rc.submitTx("/v2/social/follow", signed);
|
|
1253
|
+
}
|
|
1254
|
+
async getTrackStats(trackId, viewerPubkey) {
|
|
1255
|
+
const q = viewerPubkey ? `?viewer=${encodeURIComponent(viewerPubkey)}` : "";
|
|
1256
|
+
return this.rc.get(`/social/track/${encodeURIComponent(trackId)}/stats${q}`);
|
|
1257
|
+
}
|
|
1258
|
+
async getComments(trackId, limit = 50, offset = 0) {
|
|
1259
|
+
const data = await this.rc.get(
|
|
1260
|
+
`/social/track/${encodeURIComponent(trackId)}/comments?limit=${limit}&offset=${offset}`
|
|
1261
|
+
);
|
|
1262
|
+
return data.comments ?? [];
|
|
1263
|
+
}
|
|
1264
|
+
async getArtistStats(pubkey, viewerPubkey) {
|
|
1265
|
+
const q = viewerPubkey ? `?viewer=${encodeURIComponent(viewerPubkey)}` : "";
|
|
1266
|
+
return this.rc.get(`/social/artist/${encodeURIComponent(pubkey)}/stats${q}`);
|
|
1267
|
+
}
|
|
1268
|
+
async getUserLikes(pubkey) {
|
|
1269
|
+
const data = await this.rc.get(`/social/user/${encodeURIComponent(pubkey)}/likes`);
|
|
1270
|
+
return data.trackIds ?? [];
|
|
1271
|
+
}
|
|
1272
|
+
async getUserFollowing(pubkey) {
|
|
1273
|
+
const data = await this.rc.get(`/social/user/${encodeURIComponent(pubkey)}/following`);
|
|
1274
|
+
return data.artists ?? [];
|
|
1275
|
+
}
|
|
1276
|
+
// ── Posts ──────────────────────────────────────────────
|
|
1277
|
+
async createPost(wallet, body, replyToId) {
|
|
1278
|
+
const payload = { body };
|
|
1279
|
+
if (replyToId) payload.replyToId = replyToId;
|
|
1280
|
+
const signed = signRequest(wallet, payload);
|
|
1281
|
+
return this.rc.submitTx("/v2/social/post", signed);
|
|
1282
|
+
}
|
|
1283
|
+
async deletePost(wallet, postId) {
|
|
1284
|
+
const signed = signRequest(wallet, { postId });
|
|
1285
|
+
return this.rc.submitTx("/v2/social/post/delete", signed);
|
|
1286
|
+
}
|
|
1287
|
+
async toggleRepost(wallet, postId) {
|
|
1288
|
+
const signed = signRequest(wallet, { postId });
|
|
1289
|
+
return this.rc.submitTx("/v2/social/repost", signed);
|
|
1290
|
+
}
|
|
1291
|
+
async getPost(postId, viewerPubkey) {
|
|
1292
|
+
const q = viewerPubkey ? `?viewer=${encodeURIComponent(viewerPubkey)}` : "";
|
|
1293
|
+
try {
|
|
1294
|
+
return await this.rc.get(`/social/post/${encodeURIComponent(postId)}${q}`);
|
|
1295
|
+
} catch {
|
|
1296
|
+
return null;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
async getPostStats(postId, viewerPubkey) {
|
|
1300
|
+
const q = viewerPubkey ? `?viewer=${encodeURIComponent(viewerPubkey)}` : "";
|
|
1301
|
+
return this.rc.get(`/social/post/${encodeURIComponent(postId)}/stats${q}`);
|
|
1302
|
+
}
|
|
1303
|
+
async getPostReplies(postId, limit = 50, offset = 0) {
|
|
1304
|
+
const data = await this.rc.get(
|
|
1305
|
+
`/social/post/${encodeURIComponent(postId)}/replies?limit=${limit}&offset=${offset}`
|
|
1306
|
+
);
|
|
1307
|
+
return data.replies ?? [];
|
|
1308
|
+
}
|
|
1309
|
+
async getUserPosts(pubkey, limit = 50, offset = 0) {
|
|
1310
|
+
return this.rc.get(
|
|
1311
|
+
`/social/user/${encodeURIComponent(pubkey)}/posts?limit=${limit}&offset=${offset}`
|
|
1312
|
+
);
|
|
1313
|
+
}
|
|
1314
|
+
async getGlobalTimeline(limit = 50, offset = 0) {
|
|
1315
|
+
const data = await this.rc.get(
|
|
1316
|
+
`/social/timeline?limit=${limit}&offset=${offset}`
|
|
1317
|
+
);
|
|
1318
|
+
return data.posts ?? [];
|
|
1319
|
+
}
|
|
1320
|
+
async getFollowingFeed(wallet, limit = 50, offset = 0) {
|
|
1321
|
+
const signed = signRequest(wallet, { limit, offset });
|
|
1322
|
+
try {
|
|
1323
|
+
const data = await this.rc.submitTx("/v2/social/feed", signed);
|
|
1324
|
+
return data.posts ?? [];
|
|
1325
|
+
} catch {
|
|
1326
|
+
return [];
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1214
1330
|
|
|
1215
1331
|
// src/address.ts
|
|
1216
1332
|
var CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|