@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.
@@ -26425,7 +26425,7 @@ function serializeCommentOptions(bb, data) {
26425
26425
  bb.writeUint16(dataObj.percent_steem_dollars ?? 0);
26426
26426
  serializeBool(bb, dataObj.allow_votes);
26427
26427
  serializeBool(bb, dataObj.allow_curation_rewards);
26428
- serializeExtensions(bb, dataObj.extensions);
26428
+ serializeCommentOptionsExtensions(bb, dataObj.extensions);
26429
26429
  }
26430
26430
  /**
26431
26431
  * Serialize custom_json operation
@@ -26502,7 +26502,7 @@ function serializeAuthority(bb, auth) {
26502
26502
  *
26503
26503
  * Format: int64 amount (little-endian) + uint8 precision + 7-byte symbol (UTF-8, null-padded).
26504
26504
  *
26505
- * This helper is reused across all operations中涉及资产字段的地方,例如:
26505
+ * This helper is reused for asset fields across all operations, e.g.
26506
26506
  * - amount / vesting_shares / reward_* / *_pays
26507
26507
  */
26508
26508
  function serializeAsset(bb, amount) {
@@ -26522,7 +26522,7 @@ function serializeAsset(bb, amount) {
26522
26522
  }
26523
26523
  /**
26524
26524
  * Write a string using ByteBuffer's writeVString method.
26525
- * 所有字符串字段统一通过该 helper 序列化,避免直接到处调用 ByteBuffer API
26525
+ * All string fields are serialized through this helper to avoid calling ByteBuffer API directly everywhere.
26526
26526
  */
26527
26527
  function writeString(bb, str) {
26528
26528
  bb.writeVString(str);
@@ -26530,8 +26530,8 @@ function writeString(bb, str) {
26530
26530
  /**
26531
26531
  * Serialize a time_point_sec-style field.
26532
26532
  *
26533
- * 接受 ISO 字符串 / Date / 秒级数字,最终写入 uint32(自 epoch 起的秒数)。
26534
- * 常用于 proposal start/endescrow_deadline 等字段。
26533
+ * Accepts ISO string / Date / seconds number; writes uint32 (seconds since epoch).
26534
+ * Used for proposal start/end, escrow_deadline, and similar fields.
26535
26535
  */
26536
26536
  function serializeTimePointSec(bb, value) {
26537
26537
  let seconds;
@@ -26544,7 +26544,7 @@ function serializeTimePointSec(bb, value) {
26544
26544
  seconds = Math.floor(value.getTime() / 1000);
26545
26545
  }
26546
26546
  else if (typeof value === 'number') {
26547
- // 这里假定已是秒级时间戳
26547
+ // Assume value is already in seconds
26548
26548
  seconds = value;
26549
26549
  }
26550
26550
  else {
@@ -26554,29 +26554,61 @@ function serializeTimePointSec(bb, value) {
26554
26554
  }
26555
26555
  /**
26556
26556
  * Serialize a generic bool flag as uint8(0/1).
26557
- * 后续在多处 optional / approve / decline 字段可统一复用。
26557
+ * Reused for optional / approve / decline and similar fields.
26558
26558
  */
26559
26559
  function serializeBool(bb, value) {
26560
26560
  bb.writeUint8(value ? 1 : 0);
26561
26561
  }
26562
26562
  /**
26563
- * Serialize a future_extensions / extensions 风格字段。
26563
+ * Serialize comment_options extensions (flat_set<comment_options_extension>).
26564
+ * Used only for comment_options operation. Supports tag 0 (comment_payout_beneficiaries).
26565
+ * Beneficiaries are sorted alphabetically by account name before encoding to satisfy Steem protocol.
26566
+ * Other extension tags are skipped; only tag 0 is serialized.
26567
+ */
26568
+ function serializeCommentOptionsExtensions(bb, extensions) {
26569
+ if (!Array.isArray(extensions) || extensions.length === 0) {
26570
+ bb.writeVarint32(0);
26571
+ return;
26572
+ }
26573
+ // Only serialize tag 0 (comment_payout_beneficiaries); skip unknown tags
26574
+ const supported = extensions.filter((ext) => {
26575
+ const tag = Array.isArray(ext) && ext.length >= 1 ? Number(ext[0]) : -1;
26576
+ return tag === 0;
26577
+ });
26578
+ bb.writeVarint32(supported.length);
26579
+ for (const ext of supported) {
26580
+ const tag = ext[0];
26581
+ const value = ext[1];
26582
+ bb.writeVarint32(tag);
26583
+ if (tag === 0) {
26584
+ const beneficiaries = Array.isArray(value?.beneficiaries) ? value.beneficiaries.slice() : [];
26585
+ beneficiaries.sort((a, b) => String(a.account).localeCompare(String(b.account)));
26586
+ bb.writeVarint32(beneficiaries.length);
26587
+ for (const b of beneficiaries) {
26588
+ writeString(bb, String(b.account ?? ''));
26589
+ bb.writeUint16(Number(b.weight) & 0xffff);
26590
+ }
26591
+ }
26592
+ }
26593
+ }
26594
+ /**
26595
+ * Serialize a future_extensions / extensions-style field.
26564
26596
  *
26565
- * 目前大多数链上交易中 extensions 仍为空集合,协议格式是:
26597
+ * For most on-chain transactions extensions are still an empty set. Protocol format:
26566
26598
  * - varint32 length
26567
- * - 后续按约定序列化各元素(当前实现仅支持空或简单 JSON 字符串)
26599
+ * - then each element serialized per convention (current implementation supports empty only).
26568
26600
  *
26569
- * 为兼容现有使用场景,这里暂时只写入长度,忽略实际内容;当需要支持
26570
- * 具体 extension 类型时,可以在保持签名兼容性的前提下扩展实现。
26601
+ * To stay compatible with existing usage, we only write length 0 and ignore content here;
26602
+ * when supporting specific extension types, extend this after verification.
26571
26603
  */
26572
26604
  function serializeExtensions(bb, extensions) {
26573
26605
  if (!Array.isArray(extensions) || extensions.length === 0) {
26574
26606
  bb.writeVarint32(0);
26575
26607
  return;
26576
26608
  }
26577
- // 协议上 extensions future_extensions,目前主网基本为 0
26578
- // 为避免序列化出与 C++ 节点不兼容的数据,这里保守起见仍写入 0
26579
- // 如果未来需要支持非空 extensions,可在测试验证后放开以下逻辑:
26609
+ // Protocol-wise extensions are future_extensions; on mainnet they are typically 0.
26610
+ // To avoid serializing data incompatible with C++ nodes, we still write 0 conservatively.
26611
+ // To support non-empty extensions in the future, enable the logic below after tests:
26580
26612
  //
26581
26613
  // bb.writeVarint32(extensions.length);
26582
26614
  // for (const ext of extensions) {
@@ -29652,7 +29684,7 @@ const steem = {
29652
29684
  memo,
29653
29685
  operations,
29654
29686
  utils: utils$3,
29655
- version: '1.0.14',
29687
+ version: '1.0.15',
29656
29688
  config: {
29657
29689
  set: (options) => {
29658
29690
  // If nodes is provided, extract the first node as url for API