@steemit/steem-js 1.0.14 → 1.0.15

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
@@ -23097,7 +23097,7 @@ function serializeCommentOptions(bb, data) {
23097
23097
  bb.writeUint16(dataObj.percent_steem_dollars ?? 0);
23098
23098
  serializeBool(bb, dataObj.allow_votes);
23099
23099
  serializeBool(bb, dataObj.allow_curation_rewards);
23100
- serializeExtensions(bb, dataObj.extensions);
23100
+ serializeCommentOptionsExtensions(bb, dataObj.extensions);
23101
23101
  }
23102
23102
  /**
23103
23103
  * Serialize custom_json operation
@@ -23174,7 +23174,7 @@ function serializeAuthority(bb, auth) {
23174
23174
  *
23175
23175
  * Format: int64 amount (little-endian) + uint8 precision + 7-byte symbol (UTF-8, null-padded).
23176
23176
  *
23177
- * This helper is reused across all operations中涉及资产字段的地方,例如:
23177
+ * This helper is reused for asset fields across all operations, e.g.
23178
23178
  * - amount / vesting_shares / reward_* / *_pays
23179
23179
  */
23180
23180
  function serializeAsset(bb, amount) {
@@ -23194,7 +23194,7 @@ function serializeAsset(bb, amount) {
23194
23194
  }
23195
23195
  /**
23196
23196
  * Write a string using ByteBuffer's writeVString method.
23197
- * 所有字符串字段统一通过该 helper 序列化,避免直接到处调用 ByteBuffer API
23197
+ * All string fields are serialized through this helper to avoid calling ByteBuffer API directly everywhere.
23198
23198
  */
23199
23199
  function writeString(bb, str) {
23200
23200
  bb.writeVString(str);
@@ -23202,8 +23202,8 @@ function writeString(bb, str) {
23202
23202
  /**
23203
23203
  * Serialize a time_point_sec-style field.
23204
23204
  *
23205
- * 接受 ISO 字符串 / Date / 秒级数字,最终写入 uint32(自 epoch 起的秒数)。
23206
- * 常用于 proposal start/endescrow_deadline 等字段。
23205
+ * Accepts ISO string / Date / seconds number; writes uint32 (seconds since epoch).
23206
+ * Used for proposal start/end, escrow_deadline, and similar fields.
23207
23207
  */
23208
23208
  function serializeTimePointSec(bb, value) {
23209
23209
  let seconds;
@@ -23216,7 +23216,7 @@ function serializeTimePointSec(bb, value) {
23216
23216
  seconds = Math.floor(value.getTime() / 1000);
23217
23217
  }
23218
23218
  else if (typeof value === 'number') {
23219
- // 这里假定已是秒级时间戳
23219
+ // Assume value is already in seconds
23220
23220
  seconds = value;
23221
23221
  }
23222
23222
  else {
@@ -23226,29 +23226,61 @@ function serializeTimePointSec(bb, value) {
23226
23226
  }
23227
23227
  /**
23228
23228
  * Serialize a generic bool flag as uint8(0/1).
23229
- * 后续在多处 optional / approve / decline 字段可统一复用。
23229
+ * Reused for optional / approve / decline and similar fields.
23230
23230
  */
23231
23231
  function serializeBool(bb, value) {
23232
23232
  bb.writeUint8(value ? 1 : 0);
23233
23233
  }
23234
23234
  /**
23235
- * Serialize a future_extensions / extensions 风格字段。
23235
+ * Serialize comment_options extensions (flat_set<comment_options_extension>).
23236
+ * Used only for comment_options operation. Supports tag 0 (comment_payout_beneficiaries).
23237
+ * Beneficiaries are sorted alphabetically by account name before encoding to satisfy Steem protocol.
23238
+ * Other extension tags are skipped; only tag 0 is serialized.
23239
+ */
23240
+ function serializeCommentOptionsExtensions(bb, extensions) {
23241
+ if (!Array.isArray(extensions) || extensions.length === 0) {
23242
+ bb.writeVarint32(0);
23243
+ return;
23244
+ }
23245
+ // Only serialize tag 0 (comment_payout_beneficiaries); skip unknown tags
23246
+ const supported = extensions.filter((ext) => {
23247
+ const tag = Array.isArray(ext) && ext.length >= 1 ? Number(ext[0]) : -1;
23248
+ return tag === 0;
23249
+ });
23250
+ bb.writeVarint32(supported.length);
23251
+ for (const ext of supported) {
23252
+ const tag = ext[0];
23253
+ const value = ext[1];
23254
+ bb.writeVarint32(tag);
23255
+ if (tag === 0) {
23256
+ const beneficiaries = Array.isArray(value?.beneficiaries) ? value.beneficiaries.slice() : [];
23257
+ beneficiaries.sort((a, b) => String(a.account).localeCompare(String(b.account)));
23258
+ bb.writeVarint32(beneficiaries.length);
23259
+ for (const b of beneficiaries) {
23260
+ writeString(bb, String(b.account ?? ''));
23261
+ bb.writeUint16(Number(b.weight) & 0xffff);
23262
+ }
23263
+ }
23264
+ }
23265
+ }
23266
+ /**
23267
+ * Serialize a future_extensions / extensions-style field.
23236
23268
  *
23237
- * 目前大多数链上交易中 extensions 仍为空集合,协议格式是:
23269
+ * For most on-chain transactions extensions are still an empty set. Protocol format:
23238
23270
  * - varint32 length
23239
- * - 后续按约定序列化各元素(当前实现仅支持空或简单 JSON 字符串)
23271
+ * - then each element serialized per convention (current implementation supports empty only).
23240
23272
  *
23241
- * 为兼容现有使用场景,这里暂时只写入长度,忽略实际内容;当需要支持
23242
- * 具体 extension 类型时,可以在保持签名兼容性的前提下扩展实现。
23273
+ * To stay compatible with existing usage, we only write length 0 and ignore content here;
23274
+ * when supporting specific extension types, extend this after verification.
23243
23275
  */
23244
23276
  function serializeExtensions(bb, extensions) {
23245
23277
  if (!Array.isArray(extensions) || extensions.length === 0) {
23246
23278
  bb.writeVarint32(0);
23247
23279
  return;
23248
23280
  }
23249
- // 协议上 extensions future_extensions,目前主网基本为 0
23250
- // 为避免序列化出与 C++ 节点不兼容的数据,这里保守起见仍写入 0
23251
- // 如果未来需要支持非空 extensions,可在测试验证后放开以下逻辑:
23281
+ // Protocol-wise extensions are future_extensions; on mainnet they are typically 0.
23282
+ // To avoid serializing data incompatible with C++ nodes, we still write 0 conservatively.
23283
+ // To support non-empty extensions in the future, enable the logic below after tests:
23252
23284
  //
23253
23285
  // bb.writeVarint32(extensions.length);
23254
23286
  // for (const ext of extensions) {
@@ -26324,7 +26356,7 @@ const steem = {
26324
26356
  memo,
26325
26357
  operations,
26326
26358
  utils: utils$3,
26327
- version: '1.0.14',
26359
+ version: '1.0.15',
26328
26360
  config: {
26329
26361
  set: (options) => {
26330
26362
  // If nodes is provided, extract the first node as url for API