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