@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.umd.js CHANGED
@@ -26111,7 +26111,7 @@
26111
26111
  bb.writeUint16(dataObj.percent_steem_dollars ?? 0);
26112
26112
  serializeBool(bb, dataObj.allow_votes);
26113
26113
  serializeBool(bb, dataObj.allow_curation_rewards);
26114
- serializeExtensions(bb, dataObj.extensions);
26114
+ serializeCommentOptionsExtensions(bb, dataObj.extensions);
26115
26115
  }
26116
26116
  /**
26117
26117
  * Serialize custom_json operation
@@ -26188,7 +26188,7 @@
26188
26188
  *
26189
26189
  * Format: int64 amount (little-endian) + uint8 precision + 7-byte symbol (UTF-8, null-padded).
26190
26190
  *
26191
- * This helper is reused across all operations中涉及资产字段的地方,例如:
26191
+ * This helper is reused for asset fields across all operations, e.g.
26192
26192
  * - amount / vesting_shares / reward_* / *_pays
26193
26193
  */
26194
26194
  function serializeAsset(bb, amount) {
@@ -26208,7 +26208,7 @@
26208
26208
  }
26209
26209
  /**
26210
26210
  * Write a string using ByteBuffer's writeVString method.
26211
- * 所有字符串字段统一通过该 helper 序列化,避免直接到处调用 ByteBuffer API
26211
+ * All string fields are serialized through this helper to avoid calling ByteBuffer API directly everywhere.
26212
26212
  */
26213
26213
  function writeString(bb, str) {
26214
26214
  bb.writeVString(str);
@@ -26216,8 +26216,8 @@
26216
26216
  /**
26217
26217
  * Serialize a time_point_sec-style field.
26218
26218
  *
26219
- * 接受 ISO 字符串 / Date / 秒级数字,最终写入 uint32(自 epoch 起的秒数)。
26220
- * 常用于 proposal start/endescrow_deadline 等字段。
26219
+ * Accepts ISO string / Date / seconds number; writes uint32 (seconds since epoch).
26220
+ * Used for proposal start/end, escrow_deadline, and similar fields.
26221
26221
  */
26222
26222
  function serializeTimePointSec(bb, value) {
26223
26223
  let seconds;
@@ -26230,7 +26230,7 @@
26230
26230
  seconds = Math.floor(value.getTime() / 1000);
26231
26231
  }
26232
26232
  else if (typeof value === 'number') {
26233
- // 这里假定已是秒级时间戳
26233
+ // Assume value is already in seconds
26234
26234
  seconds = value;
26235
26235
  }
26236
26236
  else {
@@ -26240,29 +26240,61 @@
26240
26240
  }
26241
26241
  /**
26242
26242
  * Serialize a generic bool flag as uint8(0/1).
26243
- * 后续在多处 optional / approve / decline 字段可统一复用。
26243
+ * Reused for optional / approve / decline and similar fields.
26244
26244
  */
26245
26245
  function serializeBool(bb, value) {
26246
26246
  bb.writeUint8(value ? 1 : 0);
26247
26247
  }
26248
26248
  /**
26249
- * Serialize a future_extensions / extensions 风格字段。
26249
+ * Serialize comment_options extensions (flat_set<comment_options_extension>).
26250
+ * Used only for comment_options operation. Supports tag 0 (comment_payout_beneficiaries).
26251
+ * Beneficiaries are sorted alphabetically by account name before encoding to satisfy Steem protocol.
26252
+ * Other extension tags are skipped; only tag 0 is serialized.
26253
+ */
26254
+ function serializeCommentOptionsExtensions(bb, extensions) {
26255
+ if (!Array.isArray(extensions) || extensions.length === 0) {
26256
+ bb.writeVarint32(0);
26257
+ return;
26258
+ }
26259
+ // Only serialize tag 0 (comment_payout_beneficiaries); skip unknown tags
26260
+ const supported = extensions.filter((ext) => {
26261
+ const tag = Array.isArray(ext) && ext.length >= 1 ? Number(ext[0]) : -1;
26262
+ return tag === 0;
26263
+ });
26264
+ bb.writeVarint32(supported.length);
26265
+ for (const ext of supported) {
26266
+ const tag = ext[0];
26267
+ const value = ext[1];
26268
+ bb.writeVarint32(tag);
26269
+ if (tag === 0) {
26270
+ const beneficiaries = Array.isArray(value?.beneficiaries) ? value.beneficiaries.slice() : [];
26271
+ beneficiaries.sort((a, b) => String(a.account).localeCompare(String(b.account)));
26272
+ bb.writeVarint32(beneficiaries.length);
26273
+ for (const b of beneficiaries) {
26274
+ writeString(bb, String(b.account ?? ''));
26275
+ bb.writeUint16(Number(b.weight) & 0xffff);
26276
+ }
26277
+ }
26278
+ }
26279
+ }
26280
+ /**
26281
+ * Serialize a future_extensions / extensions-style field.
26250
26282
  *
26251
- * 目前大多数链上交易中 extensions 仍为空集合,协议格式是:
26283
+ * For most on-chain transactions extensions are still an empty set. Protocol format:
26252
26284
  * - varint32 length
26253
- * - 后续按约定序列化各元素(当前实现仅支持空或简单 JSON 字符串)
26285
+ * - then each element serialized per convention (current implementation supports empty only).
26254
26286
  *
26255
- * 为兼容现有使用场景,这里暂时只写入长度,忽略实际内容;当需要支持
26256
- * 具体 extension 类型时,可以在保持签名兼容性的前提下扩展实现。
26287
+ * To stay compatible with existing usage, we only write length 0 and ignore content here;
26288
+ * when supporting specific extension types, extend this after verification.
26257
26289
  */
26258
26290
  function serializeExtensions(bb, extensions) {
26259
26291
  if (!Array.isArray(extensions) || extensions.length === 0) {
26260
26292
  bb.writeVarint32(0);
26261
26293
  return;
26262
26294
  }
26263
- // 协议上 extensions future_extensions,目前主网基本为 0
26264
- // 为避免序列化出与 C++ 节点不兼容的数据,这里保守起见仍写入 0
26265
- // 如果未来需要支持非空 extensions,可在测试验证后放开以下逻辑:
26295
+ // Protocol-wise extensions are future_extensions; on mainnet they are typically 0.
26296
+ // To avoid serializing data incompatible with C++ nodes, we still write 0 conservatively.
26297
+ // To support non-empty extensions in the future, enable the logic below after tests:
26266
26298
  //
26267
26299
  // bb.writeVarint32(extensions.length);
26268
26300
  // for (const ext of extensions) {
@@ -29351,7 +29383,7 @@
29351
29383
  operations,
29352
29384
  utils: utils$n,
29353
29385
  ...crypto$1,
29354
- version: '1.0.14',
29386
+ version: '1.0.15',
29355
29387
  config: {
29356
29388
  set: (options) => {
29357
29389
  // If nodes is provided, extract the first node as url for API