@steemit/steem-js 1.0.12 → 1.0.13
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/browser.esm.js +873 -4
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs +873 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +873 -4
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +873 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22154,9 +22154,45 @@ function getOperationTypeIndex(opType) {
|
|
|
22154
22154
|
'account_witness_proxy': 13,
|
|
22155
22155
|
'pow': 14,
|
|
22156
22156
|
'custom': 15,
|
|
22157
|
+
'report_over_production': 16,
|
|
22157
22158
|
'delete_comment': 17,
|
|
22158
22159
|
'custom_json': 18,
|
|
22159
22160
|
'comment_options': 19,
|
|
22161
|
+
'set_withdraw_vesting_route': 20,
|
|
22162
|
+
'limit_order_create2': 21,
|
|
22163
|
+
'claim_account': 22,
|
|
22164
|
+
'create_claimed_account': 23,
|
|
22165
|
+
'request_account_recovery': 24,
|
|
22166
|
+
'recover_account': 25,
|
|
22167
|
+
'change_recovery_account': 26,
|
|
22168
|
+
'escrow_transfer': 27,
|
|
22169
|
+
'escrow_dispute': 28,
|
|
22170
|
+
'escrow_release': 29,
|
|
22171
|
+
'pow2': 30,
|
|
22172
|
+
'escrow_approve': 31,
|
|
22173
|
+
'transfer_to_savings': 32,
|
|
22174
|
+
'transfer_from_savings': 33,
|
|
22175
|
+
'cancel_transfer_from_savings': 34,
|
|
22176
|
+
'custom_binary': 35,
|
|
22177
|
+
'decline_voting_rights': 36,
|
|
22178
|
+
'reset_account': 37,
|
|
22179
|
+
'set_reset_account': 38,
|
|
22180
|
+
'claim_reward_balance': 39,
|
|
22181
|
+
'delegate_vesting_shares': 40,
|
|
22182
|
+
'account_create_with_delegation': 41,
|
|
22183
|
+
'witness_set_properties': 42,
|
|
22184
|
+
'account_update2': 43,
|
|
22185
|
+
'create_proposal': 44,
|
|
22186
|
+
'update_proposal_votes': 45,
|
|
22187
|
+
'remove_proposal': 46,
|
|
22188
|
+
'claim_reward_balance2': 47,
|
|
22189
|
+
'fill_convert_request': 48,
|
|
22190
|
+
'comment_reward': 49,
|
|
22191
|
+
'liquidity_reward': 50,
|
|
22192
|
+
'interest': 51,
|
|
22193
|
+
'fill_vesting_withdraw': 52,
|
|
22194
|
+
'fill_order': 53,
|
|
22195
|
+
'fill_transfer_from_savings': 54,
|
|
22160
22196
|
};
|
|
22161
22197
|
const index = opMap[opType];
|
|
22162
22198
|
if (index === undefined) {
|
|
@@ -22181,6 +22217,135 @@ function serializeOperationData(bb, opType, opData) {
|
|
|
22181
22217
|
case 'account_create':
|
|
22182
22218
|
serializeAccountCreate(bb, opData);
|
|
22183
22219
|
break;
|
|
22220
|
+
case 'account_update':
|
|
22221
|
+
serializeAccountUpdate(bb, opData);
|
|
22222
|
+
break;
|
|
22223
|
+
case 'account_create_with_delegation':
|
|
22224
|
+
serializeAccountCreateWithDelegation(bb, opData);
|
|
22225
|
+
break;
|
|
22226
|
+
case 'create_claimed_account':
|
|
22227
|
+
serializeCreateClaimedAccount(bb, opData);
|
|
22228
|
+
break;
|
|
22229
|
+
case 'account_update2':
|
|
22230
|
+
serializeAccountUpdate2(bb, opData);
|
|
22231
|
+
break;
|
|
22232
|
+
case 'request_account_recovery':
|
|
22233
|
+
serializeRequestAccountRecovery(bb, opData);
|
|
22234
|
+
break;
|
|
22235
|
+
case 'recover_account':
|
|
22236
|
+
serializeRecoverAccount(bb, opData);
|
|
22237
|
+
break;
|
|
22238
|
+
case 'change_recovery_account':
|
|
22239
|
+
serializeChangeRecoveryAccount(bb, opData);
|
|
22240
|
+
break;
|
|
22241
|
+
case 'reset_account':
|
|
22242
|
+
serializeResetAccount(bb, opData);
|
|
22243
|
+
break;
|
|
22244
|
+
case 'set_reset_account':
|
|
22245
|
+
serializeSetResetAccount(bb, opData);
|
|
22246
|
+
break;
|
|
22247
|
+
case 'decline_voting_rights':
|
|
22248
|
+
serializeDeclineVotingRights(bb, opData);
|
|
22249
|
+
break;
|
|
22250
|
+
case 'transfer_to_vesting':
|
|
22251
|
+
serializeTransferToVesting(bb, opData);
|
|
22252
|
+
break;
|
|
22253
|
+
case 'withdraw_vesting':
|
|
22254
|
+
serializeWithdrawVesting(bb, opData);
|
|
22255
|
+
break;
|
|
22256
|
+
case 'set_withdraw_vesting_route':
|
|
22257
|
+
serializeSetWithdrawVestingRoute(bb, opData);
|
|
22258
|
+
break;
|
|
22259
|
+
case 'transfer_to_savings':
|
|
22260
|
+
serializeTransferToSavings(bb, opData);
|
|
22261
|
+
break;
|
|
22262
|
+
case 'transfer_from_savings':
|
|
22263
|
+
serializeTransferFromSavings(bb, opData);
|
|
22264
|
+
break;
|
|
22265
|
+
case 'cancel_transfer_from_savings':
|
|
22266
|
+
serializeCancelTransferFromSavings(bb, opData);
|
|
22267
|
+
break;
|
|
22268
|
+
case 'limit_order_create':
|
|
22269
|
+
serializeLimitOrderCreate(bb, opData);
|
|
22270
|
+
break;
|
|
22271
|
+
case 'limit_order_create2':
|
|
22272
|
+
serializeLimitOrderCreate2(bb, opData);
|
|
22273
|
+
break;
|
|
22274
|
+
case 'limit_order_cancel':
|
|
22275
|
+
serializeLimitOrderCancel(bb, opData);
|
|
22276
|
+
break;
|
|
22277
|
+
case 'feed_publish':
|
|
22278
|
+
serializeFeedPublish(bb, opData);
|
|
22279
|
+
break;
|
|
22280
|
+
case 'convert':
|
|
22281
|
+
serializeConvert(bb, opData);
|
|
22282
|
+
break;
|
|
22283
|
+
case 'fill_order':
|
|
22284
|
+
serializeFillOrder(bb, opData);
|
|
22285
|
+
break;
|
|
22286
|
+
case 'escrow_transfer':
|
|
22287
|
+
serializeEscrowTransfer(bb, opData);
|
|
22288
|
+
break;
|
|
22289
|
+
case 'escrow_dispute':
|
|
22290
|
+
serializeEscrowDispute(bb, opData);
|
|
22291
|
+
break;
|
|
22292
|
+
case 'escrow_release':
|
|
22293
|
+
serializeEscrowRelease(bb, opData);
|
|
22294
|
+
break;
|
|
22295
|
+
case 'escrow_approve':
|
|
22296
|
+
serializeEscrowApprove(bb, opData);
|
|
22297
|
+
break;
|
|
22298
|
+
case 'claim_reward_balance':
|
|
22299
|
+
serializeClaimRewardBalance(bb, opData);
|
|
22300
|
+
break;
|
|
22301
|
+
case 'claim_reward_balance2':
|
|
22302
|
+
serializeClaimRewardBalance2(bb, opData);
|
|
22303
|
+
break;
|
|
22304
|
+
case 'comment_reward':
|
|
22305
|
+
serializeCommentReward(bb, opData);
|
|
22306
|
+
break;
|
|
22307
|
+
case 'liquidity_reward':
|
|
22308
|
+
serializeLiquidityReward(bb, opData);
|
|
22309
|
+
break;
|
|
22310
|
+
case 'interest':
|
|
22311
|
+
serializeInterest(bb, opData);
|
|
22312
|
+
break;
|
|
22313
|
+
case 'fill_vesting_withdraw':
|
|
22314
|
+
serializeFillVestingWithdraw(bb, opData);
|
|
22315
|
+
break;
|
|
22316
|
+
case 'fill_convert_request':
|
|
22317
|
+
serializeFillConvertRequest(bb, opData);
|
|
22318
|
+
break;
|
|
22319
|
+
case 'fill_transfer_from_savings':
|
|
22320
|
+
serializeFillTransferFromSavings(bb, opData);
|
|
22321
|
+
break;
|
|
22322
|
+
case 'pow':
|
|
22323
|
+
serializePow(bb, opData);
|
|
22324
|
+
break;
|
|
22325
|
+
case 'pow2':
|
|
22326
|
+
serializePow2(bb, opData);
|
|
22327
|
+
break;
|
|
22328
|
+
case 'witness_update':
|
|
22329
|
+
serializeWitnessUpdate(bb, opData);
|
|
22330
|
+
break;
|
|
22331
|
+
case 'witness_set_properties':
|
|
22332
|
+
serializeWitnessSetProperties(bb, opData);
|
|
22333
|
+
break;
|
|
22334
|
+
case 'account_witness_vote':
|
|
22335
|
+
serializeAccountWitnessVote(bb, opData);
|
|
22336
|
+
break;
|
|
22337
|
+
case 'account_witness_proxy':
|
|
22338
|
+
serializeAccountWitnessProxy(bb, opData);
|
|
22339
|
+
break;
|
|
22340
|
+
case 'custom':
|
|
22341
|
+
serializeCustom(bb, opData);
|
|
22342
|
+
break;
|
|
22343
|
+
case 'custom_binary':
|
|
22344
|
+
serializeCustomBinary(bb, opData);
|
|
22345
|
+
break;
|
|
22346
|
+
case 'comment_options':
|
|
22347
|
+
serializeCommentOptions(bb, opData);
|
|
22348
|
+
break;
|
|
22184
22349
|
case 'custom_json':
|
|
22185
22350
|
serializeCustomJson(bb, opData);
|
|
22186
22351
|
break;
|
|
@@ -22250,6 +22415,647 @@ function serializeAccountCreate(bb, data) {
|
|
|
22250
22415
|
}
|
|
22251
22416
|
writeString(bb, String(dataObj.json_metadata || ''));
|
|
22252
22417
|
}
|
|
22418
|
+
/**
|
|
22419
|
+
* Serialize account_update operation.
|
|
22420
|
+
* Format: account, optional owner (1 byte + authority?), optional active, optional posting, memo_key, json_metadata.
|
|
22421
|
+
*/
|
|
22422
|
+
function serializeAccountUpdate(bb, data) {
|
|
22423
|
+
const dataObj = data;
|
|
22424
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22425
|
+
// Optional authorities: 0 = not present, 1 = present then serialize authority
|
|
22426
|
+
if (dataObj.owner != null && dataObj.owner !== '') {
|
|
22427
|
+
bb.writeUint8(1);
|
|
22428
|
+
serializeAuthority(bb, typeof dataObj.owner === 'object' ? dataObj.owner : { weight_threshold: 1, account_auths: [], key_auths: [] });
|
|
22429
|
+
}
|
|
22430
|
+
else {
|
|
22431
|
+
bb.writeUint8(0);
|
|
22432
|
+
}
|
|
22433
|
+
if (dataObj.active != null && dataObj.active !== '') {
|
|
22434
|
+
bb.writeUint8(1);
|
|
22435
|
+
serializeAuthority(bb, typeof dataObj.active === 'object' ? dataObj.active : { weight_threshold: 1, account_auths: [], key_auths: [] });
|
|
22436
|
+
}
|
|
22437
|
+
else {
|
|
22438
|
+
bb.writeUint8(0);
|
|
22439
|
+
}
|
|
22440
|
+
if (dataObj.posting != null && dataObj.posting !== '') {
|
|
22441
|
+
bb.writeUint8(1);
|
|
22442
|
+
serializeAuthority(bb, typeof dataObj.posting === 'object' ? dataObj.posting : { weight_threshold: 1, account_auths: [], key_auths: [] });
|
|
22443
|
+
}
|
|
22444
|
+
else {
|
|
22445
|
+
bb.writeUint8(0);
|
|
22446
|
+
}
|
|
22447
|
+
// memo_key (public key, required)
|
|
22448
|
+
if (typeof dataObj.memo_key === 'string') {
|
|
22449
|
+
const pubKey = PublicKey.fromStringOrThrow(dataObj.memo_key);
|
|
22450
|
+
bb.append(pubKey.toBuffer());
|
|
22451
|
+
}
|
|
22452
|
+
else if (Buffer.isBuffer(dataObj.memo_key)) {
|
|
22453
|
+
bb.append(dataObj.memo_key);
|
|
22454
|
+
}
|
|
22455
|
+
else if (dataObj.memo_key && typeof dataObj.memo_key.toBuffer === 'function') {
|
|
22456
|
+
bb.append(dataObj.memo_key.toBuffer());
|
|
22457
|
+
}
|
|
22458
|
+
else {
|
|
22459
|
+
throw new Error('Invalid memo_key format');
|
|
22460
|
+
}
|
|
22461
|
+
writeString(bb, typeof dataObj.json_metadata === 'string'
|
|
22462
|
+
? dataObj.json_metadata
|
|
22463
|
+
: dataObj.json_metadata != null
|
|
22464
|
+
? JSON.stringify(dataObj.json_metadata)
|
|
22465
|
+
: '');
|
|
22466
|
+
}
|
|
22467
|
+
/**
|
|
22468
|
+
* Serialize account_create_with_delegation operation.
|
|
22469
|
+
* Fields (see FC_REFLECT): fee, delegation, creator, new_account_name,
|
|
22470
|
+
* owner, active, posting, memo_key, json_metadata, extensions.
|
|
22471
|
+
*/
|
|
22472
|
+
function serializeAccountCreateWithDelegation(bb, data) {
|
|
22473
|
+
const dataObj = data;
|
|
22474
|
+
serializeAsset(bb, String(dataObj.fee || '0.000 STEEM'));
|
|
22475
|
+
serializeAsset(bb, String(dataObj.delegation || '0.000 VESTS'));
|
|
22476
|
+
writeString(bb, String(dataObj.creator || ''));
|
|
22477
|
+
writeString(bb, String(dataObj.new_account_name || ''));
|
|
22478
|
+
serializeAuthority(bb, dataObj.owner);
|
|
22479
|
+
serializeAuthority(bb, dataObj.active);
|
|
22480
|
+
serializeAuthority(bb, dataObj.posting);
|
|
22481
|
+
const memoKey = String(dataObj.memo_key || '');
|
|
22482
|
+
const pubKey = PublicKey.fromStringOrThrow(memoKey);
|
|
22483
|
+
bb.append(pubKey.toBuffer());
|
|
22484
|
+
writeString(bb, String(dataObj.json_metadata || ''));
|
|
22485
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22486
|
+
}
|
|
22487
|
+
/**
|
|
22488
|
+
* Serialize create_claimed_account operation.
|
|
22489
|
+
* Fields: creator, new_account_name, owner, active, posting,
|
|
22490
|
+
* memo_key, json_metadata, extensions.
|
|
22491
|
+
*/
|
|
22492
|
+
function serializeCreateClaimedAccount(bb, data) {
|
|
22493
|
+
const dataObj = data;
|
|
22494
|
+
writeString(bb, String(dataObj.creator || ''));
|
|
22495
|
+
writeString(bb, String(dataObj.new_account_name || ''));
|
|
22496
|
+
serializeAuthority(bb, dataObj.owner);
|
|
22497
|
+
serializeAuthority(bb, dataObj.active);
|
|
22498
|
+
serializeAuthority(bb, dataObj.posting);
|
|
22499
|
+
const memoKey = String(dataObj.memo_key || '');
|
|
22500
|
+
const pubKey = PublicKey.fromStringOrThrow(memoKey);
|
|
22501
|
+
bb.append(pubKey.toBuffer());
|
|
22502
|
+
writeString(bb, String(dataObj.json_metadata || ''));
|
|
22503
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22504
|
+
}
|
|
22505
|
+
/**
|
|
22506
|
+
* Serialize account_update2 operation.
|
|
22507
|
+
* Fields: account, owner, active, posting, memo_key,
|
|
22508
|
+
* json_metadata, posting_json_metadata, extensions.
|
|
22509
|
+
*/
|
|
22510
|
+
function serializeAccountUpdate2(bb, data) {
|
|
22511
|
+
const dataObj = data;
|
|
22512
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22513
|
+
serializeAuthority(bb, dataObj.owner);
|
|
22514
|
+
serializeAuthority(bb, dataObj.active);
|
|
22515
|
+
serializeAuthority(bb, dataObj.posting);
|
|
22516
|
+
const memoKey = String(dataObj.memo_key || '');
|
|
22517
|
+
const pubKey = PublicKey.fromStringOrThrow(memoKey);
|
|
22518
|
+
bb.append(pubKey.toBuffer());
|
|
22519
|
+
writeString(bb, String(dataObj.json_metadata || ''));
|
|
22520
|
+
writeString(bb, String(dataObj.posting_json_metadata || ''));
|
|
22521
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22522
|
+
}
|
|
22523
|
+
/**
|
|
22524
|
+
* Serialize request_account_recovery operation.
|
|
22525
|
+
* Fields: recovery_account, account_to_recover, new_owner_authority, extensions.
|
|
22526
|
+
*/
|
|
22527
|
+
function serializeRequestAccountRecovery(bb, data) {
|
|
22528
|
+
const dataObj = data;
|
|
22529
|
+
writeString(bb, String(dataObj.recovery_account || ''));
|
|
22530
|
+
writeString(bb, String(dataObj.account_to_recover || ''));
|
|
22531
|
+
serializeAuthority(bb, dataObj.new_owner_authority);
|
|
22532
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22533
|
+
}
|
|
22534
|
+
/**
|
|
22535
|
+
* Serialize recover_account operation.
|
|
22536
|
+
* Fields: account_to_recover, new_owner_authority, recent_owner_authority, extensions.
|
|
22537
|
+
*/
|
|
22538
|
+
function serializeRecoverAccount(bb, data) {
|
|
22539
|
+
const dataObj = data;
|
|
22540
|
+
writeString(bb, String(dataObj.account_to_recover || ''));
|
|
22541
|
+
serializeAuthority(bb, dataObj.new_owner_authority);
|
|
22542
|
+
serializeAuthority(bb, dataObj.recent_owner_authority);
|
|
22543
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22544
|
+
}
|
|
22545
|
+
/**
|
|
22546
|
+
* Serialize change_recovery_account operation.
|
|
22547
|
+
* Fields: account_to_recover, new_recovery_account, extensions.
|
|
22548
|
+
*/
|
|
22549
|
+
function serializeChangeRecoveryAccount(bb, data) {
|
|
22550
|
+
const dataObj = data;
|
|
22551
|
+
writeString(bb, String(dataObj.account_to_recover || ''));
|
|
22552
|
+
writeString(bb, String(dataObj.new_recovery_account || ''));
|
|
22553
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22554
|
+
}
|
|
22555
|
+
/**
|
|
22556
|
+
* Serialize reset_account operation.
|
|
22557
|
+
* Fields: reset_account, account_to_reset, new_owner_authority.
|
|
22558
|
+
*/
|
|
22559
|
+
function serializeResetAccount(bb, data) {
|
|
22560
|
+
const dataObj = data;
|
|
22561
|
+
writeString(bb, String(dataObj.reset_account || ''));
|
|
22562
|
+
writeString(bb, String(dataObj.account_to_reset || ''));
|
|
22563
|
+
serializeAuthority(bb, dataObj.new_owner_authority);
|
|
22564
|
+
}
|
|
22565
|
+
/**
|
|
22566
|
+
* Serialize set_reset_account operation.
|
|
22567
|
+
* Fields: account, reset_account.
|
|
22568
|
+
*/
|
|
22569
|
+
function serializeSetResetAccount(bb, data) {
|
|
22570
|
+
const dataObj = data;
|
|
22571
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22572
|
+
writeString(bb, String(dataObj.reset_account || ''));
|
|
22573
|
+
}
|
|
22574
|
+
/**
|
|
22575
|
+
* Serialize decline_voting_rights operation.
|
|
22576
|
+
* Fields: account, decline.
|
|
22577
|
+
*/
|
|
22578
|
+
function serializeDeclineVotingRights(bb, data) {
|
|
22579
|
+
const dataObj = data;
|
|
22580
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22581
|
+
serializeBool(bb, dataObj.decline);
|
|
22582
|
+
}
|
|
22583
|
+
/**
|
|
22584
|
+
* Serialize transfer_to_vesting operation.
|
|
22585
|
+
* Fields: from, to, amount.
|
|
22586
|
+
*/
|
|
22587
|
+
function serializeTransferToVesting(bb, data) {
|
|
22588
|
+
const dataObj = data;
|
|
22589
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22590
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22591
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
22592
|
+
}
|
|
22593
|
+
/**
|
|
22594
|
+
* Serialize withdraw_vesting operation.
|
|
22595
|
+
* Fields: account, vesting_shares.
|
|
22596
|
+
*/
|
|
22597
|
+
function serializeWithdrawVesting(bb, data) {
|
|
22598
|
+
const dataObj = data;
|
|
22599
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22600
|
+
serializeAsset(bb, String(dataObj.vesting_shares || '0.000 VESTS'));
|
|
22601
|
+
}
|
|
22602
|
+
/**
|
|
22603
|
+
* Serialize set_withdraw_vesting_route operation.
|
|
22604
|
+
* Fields: from_account, to_account, percent, auto_vest.
|
|
22605
|
+
*/
|
|
22606
|
+
function serializeSetWithdrawVestingRoute(bb, data) {
|
|
22607
|
+
const dataObj = data;
|
|
22608
|
+
writeString(bb, String(dataObj.from_account || ''));
|
|
22609
|
+
writeString(bb, String(dataObj.to_account || ''));
|
|
22610
|
+
// percent is uint16
|
|
22611
|
+
bb.writeUint16(dataObj.percent ?? 0);
|
|
22612
|
+
serializeBool(bb, dataObj.auto_vest);
|
|
22613
|
+
}
|
|
22614
|
+
/**
|
|
22615
|
+
* Serialize transfer_to_savings operation.
|
|
22616
|
+
* Fields: from, to, amount, memo.
|
|
22617
|
+
*/
|
|
22618
|
+
function serializeTransferToSavings(bb, data) {
|
|
22619
|
+
const dataObj = data;
|
|
22620
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22621
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22622
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
22623
|
+
writeString(bb, String(dataObj.memo || ''));
|
|
22624
|
+
}
|
|
22625
|
+
/**
|
|
22626
|
+
* Serialize transfer_from_savings operation.
|
|
22627
|
+
* Fields: from, request_id, to, amount, memo.
|
|
22628
|
+
*/
|
|
22629
|
+
function serializeTransferFromSavings(bb, data) {
|
|
22630
|
+
const dataObj = data;
|
|
22631
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22632
|
+
bb.writeUint32(dataObj.request_id ?? dataObj.requestID ?? 0);
|
|
22633
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22634
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
22635
|
+
writeString(bb, String(dataObj.memo || ''));
|
|
22636
|
+
}
|
|
22637
|
+
/**
|
|
22638
|
+
* Serialize cancel_transfer_from_savings operation.
|
|
22639
|
+
* Fields: from, request_id.
|
|
22640
|
+
*/
|
|
22641
|
+
function serializeCancelTransferFromSavings(bb, data) {
|
|
22642
|
+
const dataObj = data;
|
|
22643
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22644
|
+
bb.writeUint32(dataObj.request_id ?? dataObj.requestID ?? 0);
|
|
22645
|
+
}
|
|
22646
|
+
/**
|
|
22647
|
+
* Serialize limit_order_create operation.
|
|
22648
|
+
* Fields: owner, orderid, amount_to_sell, min_to_receive, fill_or_kill, expiration.
|
|
22649
|
+
*/
|
|
22650
|
+
function serializeLimitOrderCreate(bb, data) {
|
|
22651
|
+
const dataObj = data;
|
|
22652
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22653
|
+
bb.writeUint32(dataObj.orderid ?? 0);
|
|
22654
|
+
serializeAsset(bb, String(dataObj.amount_to_sell || '0.000 STEEM'));
|
|
22655
|
+
serializeAsset(bb, String(dataObj.min_to_receive || '0.000 STEEM'));
|
|
22656
|
+
serializeBool(bb, dataObj.fill_or_kill);
|
|
22657
|
+
serializeTimePointSec(bb, dataObj.expiration);
|
|
22658
|
+
}
|
|
22659
|
+
/**
|
|
22660
|
+
* Serialize limit_order_create2 operation.
|
|
22661
|
+
* Fields: owner, orderid, amount_to_sell, exchange_rate{base, quote}, fill_or_kill, expiration.
|
|
22662
|
+
*/
|
|
22663
|
+
function serializeLimitOrderCreate2(bb, data) {
|
|
22664
|
+
const dataObj = data;
|
|
22665
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22666
|
+
bb.writeUint32(dataObj.orderid ?? 0);
|
|
22667
|
+
serializeAsset(bb, String(dataObj.amount_to_sell || '0.000 STEEM'));
|
|
22668
|
+
const rate = (dataObj.exchange_rate ?? dataObj.exchangeRate);
|
|
22669
|
+
const base = rate?.base ?? '0.000 STEEM';
|
|
22670
|
+
const quote = rate?.quote ?? '0.000 SBD';
|
|
22671
|
+
serializeAsset(bb, String(base));
|
|
22672
|
+
serializeAsset(bb, String(quote));
|
|
22673
|
+
serializeBool(bb, dataObj.fill_or_kill);
|
|
22674
|
+
serializeTimePointSec(bb, dataObj.expiration);
|
|
22675
|
+
}
|
|
22676
|
+
/**
|
|
22677
|
+
* Serialize limit_order_cancel operation.
|
|
22678
|
+
* Fields: owner, orderid.
|
|
22679
|
+
*/
|
|
22680
|
+
function serializeLimitOrderCancel(bb, data) {
|
|
22681
|
+
const dataObj = data;
|
|
22682
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22683
|
+
bb.writeUint32(dataObj.orderid ?? 0);
|
|
22684
|
+
}
|
|
22685
|
+
/**
|
|
22686
|
+
* Serialize feed_publish operation.
|
|
22687
|
+
* Fields: publisher, exchange_rate{base, quote}.
|
|
22688
|
+
*/
|
|
22689
|
+
function serializeFeedPublish(bb, data) {
|
|
22690
|
+
const dataObj = data;
|
|
22691
|
+
writeString(bb, String(dataObj.publisher || ''));
|
|
22692
|
+
const rate = (dataObj.exchange_rate ?? dataObj.exchangeRate);
|
|
22693
|
+
const base = rate?.base ?? '0.000 STEEM';
|
|
22694
|
+
const quote = rate?.quote ?? '0.000 SBD';
|
|
22695
|
+
serializeAsset(bb, String(base));
|
|
22696
|
+
serializeAsset(bb, String(quote));
|
|
22697
|
+
}
|
|
22698
|
+
/**
|
|
22699
|
+
* Serialize convert operation.
|
|
22700
|
+
* Fields: owner, requestid, amount.
|
|
22701
|
+
*/
|
|
22702
|
+
function serializeConvert(bb, data) {
|
|
22703
|
+
const dataObj = data;
|
|
22704
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22705
|
+
bb.writeUint32(dataObj.requestid ?? dataObj.request_id ?? 0);
|
|
22706
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
22707
|
+
}
|
|
22708
|
+
/**
|
|
22709
|
+
* Serialize fill_order operation (virtual).
|
|
22710
|
+
* Fields: current_owner, current_orderid, current_pays,
|
|
22711
|
+
* open_owner, open_orderid, open_pays.
|
|
22712
|
+
*/
|
|
22713
|
+
function serializeFillOrder(bb, data) {
|
|
22714
|
+
const dataObj = data;
|
|
22715
|
+
writeString(bb, String(dataObj.current_owner || ''));
|
|
22716
|
+
bb.writeUint32(dataObj.current_orderid ?? 0);
|
|
22717
|
+
serializeAsset(bb, String(dataObj.current_pays || '0.000 STEEM'));
|
|
22718
|
+
writeString(bb, String(dataObj.open_owner || ''));
|
|
22719
|
+
bb.writeUint32(dataObj.open_orderid ?? 0);
|
|
22720
|
+
serializeAsset(bb, String(dataObj.open_pays || '0.000 STEEM'));
|
|
22721
|
+
}
|
|
22722
|
+
/**
|
|
22723
|
+
* Serialize escrow_transfer operation.
|
|
22724
|
+
* Fields: from, to, sbd_amount, steem_amount, escrow_id, agent,
|
|
22725
|
+
* fee, json_meta, ratification_deadline, escrow_expiration.
|
|
22726
|
+
*/
|
|
22727
|
+
function serializeEscrowTransfer(bb, data) {
|
|
22728
|
+
const dataObj = data;
|
|
22729
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22730
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22731
|
+
serializeAsset(bb, String(dataObj.sbd_amount || '0.000 SBD'));
|
|
22732
|
+
serializeAsset(bb, String(dataObj.steem_amount || '0.000 STEEM'));
|
|
22733
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
22734
|
+
writeString(bb, String(dataObj.agent || ''));
|
|
22735
|
+
serializeAsset(bb, String(dataObj.fee || '0.000 STEEM'));
|
|
22736
|
+
writeString(bb, String(dataObj.json_meta || ''));
|
|
22737
|
+
serializeTimePointSec(bb, dataObj.ratification_deadline);
|
|
22738
|
+
serializeTimePointSec(bb, dataObj.escrow_expiration);
|
|
22739
|
+
}
|
|
22740
|
+
/**
|
|
22741
|
+
* Serialize escrow_dispute operation.
|
|
22742
|
+
* Fields: from, to, who, escrow_id.
|
|
22743
|
+
*/
|
|
22744
|
+
function serializeEscrowDispute(bb, data) {
|
|
22745
|
+
const dataObj = data;
|
|
22746
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22747
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22748
|
+
writeString(bb, String(dataObj.who || ''));
|
|
22749
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
22750
|
+
}
|
|
22751
|
+
/**
|
|
22752
|
+
* Serialize escrow_release operation.
|
|
22753
|
+
* Fields: from, to, who, escrow_id, sbd_amount, steem_amount.
|
|
22754
|
+
*/
|
|
22755
|
+
function serializeEscrowRelease(bb, data) {
|
|
22756
|
+
const dataObj = data;
|
|
22757
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22758
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22759
|
+
writeString(bb, String(dataObj.who || ''));
|
|
22760
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
22761
|
+
serializeAsset(bb, String(dataObj.sbd_amount || '0.000 SBD'));
|
|
22762
|
+
serializeAsset(bb, String(dataObj.steem_amount || '0.000 STEEM'));
|
|
22763
|
+
}
|
|
22764
|
+
/**
|
|
22765
|
+
* Serialize escrow_approve operation.
|
|
22766
|
+
* Fields: from, to, agent, who, escrow_id, approve.
|
|
22767
|
+
*/
|
|
22768
|
+
function serializeEscrowApprove(bb, data) {
|
|
22769
|
+
const dataObj = data;
|
|
22770
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22771
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22772
|
+
writeString(bb, String(dataObj.agent || ''));
|
|
22773
|
+
writeString(bb, String(dataObj.who || ''));
|
|
22774
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
22775
|
+
serializeBool(bb, dataObj.approve);
|
|
22776
|
+
}
|
|
22777
|
+
/**
|
|
22778
|
+
* Serialize claim_reward_balance operation.
|
|
22779
|
+
* Fields: account, reward_steem, reward_sbd, reward_vests.
|
|
22780
|
+
*/
|
|
22781
|
+
function serializeClaimRewardBalance(bb, data) {
|
|
22782
|
+
const dataObj = data;
|
|
22783
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22784
|
+
serializeAsset(bb, String(dataObj.reward_steem || '0.000 STEEM'));
|
|
22785
|
+
serializeAsset(bb, String(dataObj.reward_sbd || '0.000 SBD'));
|
|
22786
|
+
serializeAsset(bb, String(dataObj.reward_vests || '0.000000 VESTS'));
|
|
22787
|
+
}
|
|
22788
|
+
/**
|
|
22789
|
+
* Serialize claim_reward_balance2 operation.
|
|
22790
|
+
* Fields: account, extensions, reward_tokens (array of asset strings).
|
|
22791
|
+
*/
|
|
22792
|
+
function serializeClaimRewardBalance2(bb, data) {
|
|
22793
|
+
const dataObj = data;
|
|
22794
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22795
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22796
|
+
const tokens = Array.isArray(dataObj.reward_tokens) ? dataObj.reward_tokens : [];
|
|
22797
|
+
bb.writeVarint32(tokens.length);
|
|
22798
|
+
for (const tok of tokens) {
|
|
22799
|
+
serializeAsset(bb, typeof tok === 'string' ? tok : String(tok));
|
|
22800
|
+
}
|
|
22801
|
+
}
|
|
22802
|
+
/**
|
|
22803
|
+
* Serialize comment_reward operation.
|
|
22804
|
+
* Fields: author, permlink, payout.
|
|
22805
|
+
*/
|
|
22806
|
+
function serializeCommentReward(bb, data) {
|
|
22807
|
+
const dataObj = data;
|
|
22808
|
+
writeString(bb, String(dataObj.author || ''));
|
|
22809
|
+
writeString(bb, String(dataObj.permlink || ''));
|
|
22810
|
+
serializeAsset(bb, String(dataObj.payout || '0.000 STEEM'));
|
|
22811
|
+
}
|
|
22812
|
+
/**
|
|
22813
|
+
* Serialize liquidity_reward operation.
|
|
22814
|
+
* Fields: owner, payout.
|
|
22815
|
+
*/
|
|
22816
|
+
function serializeLiquidityReward(bb, data) {
|
|
22817
|
+
const dataObj = data;
|
|
22818
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22819
|
+
serializeAsset(bb, String(dataObj.payout || '0.000 STEEM'));
|
|
22820
|
+
}
|
|
22821
|
+
/**
|
|
22822
|
+
* Serialize interest operation.
|
|
22823
|
+
* Fields: owner, interest.
|
|
22824
|
+
*/
|
|
22825
|
+
function serializeInterest(bb, data) {
|
|
22826
|
+
const dataObj = data;
|
|
22827
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22828
|
+
serializeAsset(bb, String(dataObj.interest || '0.000 STEEM'));
|
|
22829
|
+
}
|
|
22830
|
+
/**
|
|
22831
|
+
* Serialize fill_vesting_withdraw operation.
|
|
22832
|
+
* Fields: from_account, to_account, withdrawn, deposited.
|
|
22833
|
+
*/
|
|
22834
|
+
function serializeFillVestingWithdraw(bb, data) {
|
|
22835
|
+
const dataObj = data;
|
|
22836
|
+
writeString(bb, String(dataObj.from_account || ''));
|
|
22837
|
+
writeString(bb, String(dataObj.to_account || ''));
|
|
22838
|
+
serializeAsset(bb, String(dataObj.withdrawn || '0.000000 VESTS'));
|
|
22839
|
+
serializeAsset(bb, String(dataObj.deposited || '0.000 STEEM'));
|
|
22840
|
+
}
|
|
22841
|
+
/**
|
|
22842
|
+
* Serialize fill_convert_request operation.
|
|
22843
|
+
* Fields: owner, requestid, amount_in, amount_out.
|
|
22844
|
+
*/
|
|
22845
|
+
function serializeFillConvertRequest(bb, data) {
|
|
22846
|
+
const dataObj = data;
|
|
22847
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22848
|
+
bb.writeUint32(dataObj.requestid ?? 0);
|
|
22849
|
+
serializeAsset(bb, String(dataObj.amount_in || '0.000 STEEM'));
|
|
22850
|
+
serializeAsset(bb, String(dataObj.amount_out || '0.000 STEEM'));
|
|
22851
|
+
}
|
|
22852
|
+
/**
|
|
22853
|
+
* Serialize fill_transfer_from_savings operation.
|
|
22854
|
+
* Fields: from, to, amount, request_id, memo.
|
|
22855
|
+
*/
|
|
22856
|
+
function serializeFillTransferFromSavings(bb, data) {
|
|
22857
|
+
const dataObj = data;
|
|
22858
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22859
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22860
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
22861
|
+
bb.writeUint32(dataObj.request_id ?? 0);
|
|
22862
|
+
writeString(bb, String(dataObj.memo || ''));
|
|
22863
|
+
}
|
|
22864
|
+
/**
|
|
22865
|
+
* Serialize ChainProperties (used in pow, witness_update).
|
|
22866
|
+
* Fields: account_creation_fee (asset string), maximum_block_size (uint32), sbd_interest_rate (uint16).
|
|
22867
|
+
*/
|
|
22868
|
+
function serializeChainProperties(bb, props) {
|
|
22869
|
+
const p = props || {};
|
|
22870
|
+
const fee = p.account_creation_fee;
|
|
22871
|
+
if (typeof fee === 'string' && fee.split(' ').length >= 2) {
|
|
22872
|
+
serializeAsset(bb, fee);
|
|
22873
|
+
}
|
|
22874
|
+
else {
|
|
22875
|
+
serializeAsset(bb, '0.000 STEEM');
|
|
22876
|
+
}
|
|
22877
|
+
bb.writeUint32(p.maximum_block_size ?? 0);
|
|
22878
|
+
bb.writeUint16(p.sbd_interest_rate ?? 0);
|
|
22879
|
+
}
|
|
22880
|
+
/**
|
|
22881
|
+
* Serialize POW inner struct (worker, input, signature, work).
|
|
22882
|
+
*/
|
|
22883
|
+
function serializePOWInner(bb, work) {
|
|
22884
|
+
const w = work || {};
|
|
22885
|
+
writeString(bb, String(w.worker || ''));
|
|
22886
|
+
writeString(bb, String(w.input || ''));
|
|
22887
|
+
writeString(bb, String(w.signature || ''));
|
|
22888
|
+
writeString(bb, String(w.work || ''));
|
|
22889
|
+
}
|
|
22890
|
+
/**
|
|
22891
|
+
* Serialize pow operation.
|
|
22892
|
+
* Fields: worker_account, block_id, nonce (optional), work (POW), props (ChainProperties).
|
|
22893
|
+
*/
|
|
22894
|
+
function serializePow(bb, data) {
|
|
22895
|
+
const dataObj = data;
|
|
22896
|
+
writeString(bb, String(dataObj.worker_account || ''));
|
|
22897
|
+
writeString(bb, String(dataObj.block_id || ''));
|
|
22898
|
+
const nonce = dataObj.nonce;
|
|
22899
|
+
if (nonce !== undefined && nonce !== null) {
|
|
22900
|
+
bb.writeUint8(1);
|
|
22901
|
+
bb.writeUint64(Number(nonce));
|
|
22902
|
+
}
|
|
22903
|
+
else {
|
|
22904
|
+
bb.writeUint8(0);
|
|
22905
|
+
}
|
|
22906
|
+
serializePOWInner(bb, dataObj.work);
|
|
22907
|
+
serializeChainProperties(bb, dataObj.props);
|
|
22908
|
+
}
|
|
22909
|
+
/**
|
|
22910
|
+
* Serialize pow2 operation.
|
|
22911
|
+
* Fields: input, pow_summary (opaque bytes; if string treated as hex).
|
|
22912
|
+
*/
|
|
22913
|
+
function serializePow2(bb, data) {
|
|
22914
|
+
const dataObj = data;
|
|
22915
|
+
writeString(bb, String(dataObj.input || ''));
|
|
22916
|
+
const summary = dataObj.pow_summary;
|
|
22917
|
+
let bytes;
|
|
22918
|
+
if (typeof summary === 'string') {
|
|
22919
|
+
const hex = summary.startsWith('0x') ? summary.slice(2) : summary;
|
|
22920
|
+
bytes = Buffer.from(hex, 'hex');
|
|
22921
|
+
}
|
|
22922
|
+
else if (Buffer.isBuffer(summary)) {
|
|
22923
|
+
bytes = summary;
|
|
22924
|
+
}
|
|
22925
|
+
else {
|
|
22926
|
+
bytes = Buffer.alloc(0);
|
|
22927
|
+
}
|
|
22928
|
+
bb.writeVarint32(bytes.length);
|
|
22929
|
+
bb.append(bytes);
|
|
22930
|
+
}
|
|
22931
|
+
/**
|
|
22932
|
+
* Serialize witness_update operation.
|
|
22933
|
+
* Fields: owner, url, block_signing_key, props (ChainProperties), fee.
|
|
22934
|
+
*/
|
|
22935
|
+
function serializeWitnessUpdate(bb, data) {
|
|
22936
|
+
const dataObj = data;
|
|
22937
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22938
|
+
writeString(bb, String(dataObj.url || ''));
|
|
22939
|
+
const key = dataObj.block_signing_key;
|
|
22940
|
+
if (typeof key === 'string') {
|
|
22941
|
+
const pubKey = PublicKey.fromStringOrThrow(key);
|
|
22942
|
+
bb.append(pubKey.toBuffer());
|
|
22943
|
+
}
|
|
22944
|
+
else if (Buffer.isBuffer(key)) {
|
|
22945
|
+
bb.append(key);
|
|
22946
|
+
}
|
|
22947
|
+
else if (key && typeof key.toBuffer === 'function') {
|
|
22948
|
+
bb.append(key.toBuffer());
|
|
22949
|
+
}
|
|
22950
|
+
else {
|
|
22951
|
+
bb.append(Buffer.alloc(33));
|
|
22952
|
+
}
|
|
22953
|
+
serializeChainProperties(bb, dataObj.props);
|
|
22954
|
+
serializeAsset(bb, String(dataObj.fee || '0.000 STEEM'));
|
|
22955
|
+
}
|
|
22956
|
+
/**
|
|
22957
|
+
* Serialize witness_set_properties operation.
|
|
22958
|
+
* Fields: owner, props (map string -> bytes), extensions.
|
|
22959
|
+
*/
|
|
22960
|
+
function serializeWitnessSetProperties(bb, data) {
|
|
22961
|
+
const dataObj = data;
|
|
22962
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22963
|
+
const props = dataObj.props;
|
|
22964
|
+
const keys = props ? Object.keys(props).sort() : [];
|
|
22965
|
+
bb.writeVarint32(keys.length);
|
|
22966
|
+
for (const k of keys) {
|
|
22967
|
+
writeString(bb, k);
|
|
22968
|
+
const v = props[k];
|
|
22969
|
+
const buf = typeof v === 'string' ? Buffer.from(v, 'utf8') : Buffer.isBuffer(v) ? v : Buffer.alloc(0);
|
|
22970
|
+
bb.writeVarint32(buf.length);
|
|
22971
|
+
bb.append(buf);
|
|
22972
|
+
}
|
|
22973
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22974
|
+
}
|
|
22975
|
+
/**
|
|
22976
|
+
* Serialize account_witness_vote operation.
|
|
22977
|
+
* Fields: account, witness, approve.
|
|
22978
|
+
*/
|
|
22979
|
+
function serializeAccountWitnessVote(bb, data) {
|
|
22980
|
+
const dataObj = data;
|
|
22981
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22982
|
+
writeString(bb, String(dataObj.witness || ''));
|
|
22983
|
+
serializeBool(bb, dataObj.approve);
|
|
22984
|
+
}
|
|
22985
|
+
/**
|
|
22986
|
+
* Serialize account_witness_proxy operation.
|
|
22987
|
+
* Fields: account, proxy.
|
|
22988
|
+
*/
|
|
22989
|
+
function serializeAccountWitnessProxy(bb, data) {
|
|
22990
|
+
const dataObj = data;
|
|
22991
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22992
|
+
writeString(bb, String(dataObj.proxy || ''));
|
|
22993
|
+
}
|
|
22994
|
+
/**
|
|
22995
|
+
* Serialize custom operation (required_auths, id, data).
|
|
22996
|
+
* id is uint16 in protocol; data is bytes.
|
|
22997
|
+
*/
|
|
22998
|
+
function serializeCustom(bb, data) {
|
|
22999
|
+
const dataObj = data;
|
|
23000
|
+
const requiredAuths = Array.isArray(dataObj.required_auths)
|
|
23001
|
+
? dataObj.required_auths.slice().sort()
|
|
23002
|
+
: [];
|
|
23003
|
+
bb.writeVarint32(requiredAuths.length);
|
|
23004
|
+
for (const account of requiredAuths) {
|
|
23005
|
+
writeString(bb, String(account));
|
|
23006
|
+
}
|
|
23007
|
+
bb.writeUint16(dataObj.id ?? 0);
|
|
23008
|
+
const dataBytes = dataObj.data;
|
|
23009
|
+
let buf;
|
|
23010
|
+
if (typeof dataBytes === 'string') {
|
|
23011
|
+
const hex = dataBytes.startsWith('0x') ? dataBytes.slice(2) : dataBytes;
|
|
23012
|
+
buf = Buffer.from(hex, 'hex');
|
|
23013
|
+
}
|
|
23014
|
+
else if (Buffer.isBuffer(dataBytes)) {
|
|
23015
|
+
buf = dataBytes;
|
|
23016
|
+
}
|
|
23017
|
+
else {
|
|
23018
|
+
buf = Buffer.alloc(0);
|
|
23019
|
+
}
|
|
23020
|
+
bb.writeVarint32(buf.length);
|
|
23021
|
+
bb.append(buf);
|
|
23022
|
+
}
|
|
23023
|
+
/**
|
|
23024
|
+
* Serialize custom_binary operation.
|
|
23025
|
+
* Fields: id (string), data (bytes).
|
|
23026
|
+
*/
|
|
23027
|
+
function serializeCustomBinary(bb, data) {
|
|
23028
|
+
const dataObj = data;
|
|
23029
|
+
writeString(bb, String(dataObj.id || ''));
|
|
23030
|
+
const dataBytes = dataObj.data;
|
|
23031
|
+
let buf;
|
|
23032
|
+
if (typeof dataBytes === 'string') {
|
|
23033
|
+
const hex = dataBytes.startsWith('0x') ? dataBytes.slice(2) : dataBytes;
|
|
23034
|
+
buf = Buffer.from(hex, 'hex');
|
|
23035
|
+
}
|
|
23036
|
+
else if (Buffer.isBuffer(dataBytes)) {
|
|
23037
|
+
buf = dataBytes;
|
|
23038
|
+
}
|
|
23039
|
+
else {
|
|
23040
|
+
buf = Buffer.alloc(0);
|
|
23041
|
+
}
|
|
23042
|
+
bb.writeVarint32(buf.length);
|
|
23043
|
+
bb.append(buf);
|
|
23044
|
+
}
|
|
23045
|
+
/**
|
|
23046
|
+
* Serialize comment_options operation.
|
|
23047
|
+
* Fields: author, permlink, max_accepted_payout, percent_steem_dollars, allow_votes, allow_curation_rewards, extensions.
|
|
23048
|
+
*/
|
|
23049
|
+
function serializeCommentOptions(bb, data) {
|
|
23050
|
+
const dataObj = data;
|
|
23051
|
+
writeString(bb, String(dataObj.author || ''));
|
|
23052
|
+
writeString(bb, String(dataObj.permlink || ''));
|
|
23053
|
+
serializeAsset(bb, String(dataObj.max_accepted_payout || '1000000.000 SBD'));
|
|
23054
|
+
bb.writeUint16(dataObj.percent_steem_dollars ?? 0);
|
|
23055
|
+
serializeBool(bb, dataObj.allow_votes);
|
|
23056
|
+
serializeBool(bb, dataObj.allow_curation_rewards);
|
|
23057
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
23058
|
+
}
|
|
22253
23059
|
/**
|
|
22254
23060
|
* Serialize custom_json operation
|
|
22255
23061
|
*/
|
|
@@ -22321,7 +23127,12 @@ function serializeAuthority(bb, auth) {
|
|
|
22321
23127
|
}
|
|
22322
23128
|
}
|
|
22323
23129
|
/**
|
|
22324
|
-
* Serialize asset (
|
|
23130
|
+
* Serialize asset (STEEM/SBD/VESTS style string) to binary.
|
|
23131
|
+
*
|
|
23132
|
+
* Format: int64 amount (little-endian) + uint8 precision + 7-byte symbol (UTF-8, null-padded).
|
|
23133
|
+
*
|
|
23134
|
+
* This helper is reused across all operations中涉及资产字段的地方,例如:
|
|
23135
|
+
* - amount / vesting_shares / reward_* / *_pays
|
|
22325
23136
|
*/
|
|
22326
23137
|
function serializeAsset(bb, amount) {
|
|
22327
23138
|
const parts = amount.split(' ');
|
|
@@ -22330,7 +23141,6 @@ function serializeAsset(bb, amount) {
|
|
|
22330
23141
|
const [intPart, decPart = ''] = valueStr.split('.');
|
|
22331
23142
|
const precision = decPart.length;
|
|
22332
23143
|
const amountValue = parseInt(intPart + decPart.padEnd(precision, '0'), 10) || 0;
|
|
22333
|
-
// ByteBuffer can accept number directly for small values
|
|
22334
23144
|
bb.writeInt64(amountValue);
|
|
22335
23145
|
bb.writeUint8(precision);
|
|
22336
23146
|
const symbolBytes = Buffer.from(symbol, 'utf8');
|
|
@@ -22340,11 +23150,70 @@ function serializeAsset(bb, amount) {
|
|
|
22340
23150
|
}
|
|
22341
23151
|
}
|
|
22342
23152
|
/**
|
|
22343
|
-
* Write a string using ByteBuffer's writeVString method
|
|
23153
|
+
* Write a string using ByteBuffer's writeVString method.
|
|
23154
|
+
* 所有字符串字段统一通过该 helper 序列化,避免直接到处调用 ByteBuffer API。
|
|
22344
23155
|
*/
|
|
22345
23156
|
function writeString(bb, str) {
|
|
22346
23157
|
bb.writeVString(str);
|
|
22347
23158
|
}
|
|
23159
|
+
/**
|
|
23160
|
+
* Serialize a time_point_sec-style field.
|
|
23161
|
+
*
|
|
23162
|
+
* 接受 ISO 字符串 / Date / 秒级数字,最终写入 uint32(自 epoch 起的秒数)。
|
|
23163
|
+
* 常用于 proposal start/end、escrow_deadline 等字段。
|
|
23164
|
+
*/
|
|
23165
|
+
function serializeTimePointSec(bb, value) {
|
|
23166
|
+
let seconds;
|
|
23167
|
+
if (typeof value === 'string') {
|
|
23168
|
+
const iso = value.endsWith('Z') ? value : `${value}Z`;
|
|
23169
|
+
const d = new Date(iso);
|
|
23170
|
+
seconds = Math.floor(d.getTime() / 1000);
|
|
23171
|
+
}
|
|
23172
|
+
else if (value instanceof Date) {
|
|
23173
|
+
seconds = Math.floor(value.getTime() / 1000);
|
|
23174
|
+
}
|
|
23175
|
+
else if (typeof value === 'number') {
|
|
23176
|
+
// 这里假定已是秒级时间戳
|
|
23177
|
+
seconds = value;
|
|
23178
|
+
}
|
|
23179
|
+
else {
|
|
23180
|
+
seconds = 0;
|
|
23181
|
+
}
|
|
23182
|
+
bb.writeUint32(seconds);
|
|
23183
|
+
}
|
|
23184
|
+
/**
|
|
23185
|
+
* Serialize a generic bool flag as uint8(0/1).
|
|
23186
|
+
* 后续在多处 optional / approve / decline 字段可统一复用。
|
|
23187
|
+
*/
|
|
23188
|
+
function serializeBool(bb, value) {
|
|
23189
|
+
bb.writeUint8(value ? 1 : 0);
|
|
23190
|
+
}
|
|
23191
|
+
/**
|
|
23192
|
+
* Serialize a future_extensions / extensions 风格字段。
|
|
23193
|
+
*
|
|
23194
|
+
* 目前大多数链上交易中 extensions 仍为空集合,协议格式是:
|
|
23195
|
+
* - varint32 length
|
|
23196
|
+
* - 后续按约定序列化各元素(当前实现仅支持空或简单 JSON 字符串)
|
|
23197
|
+
*
|
|
23198
|
+
* 为兼容现有使用场景,这里暂时只写入长度,忽略实际内容;当需要支持
|
|
23199
|
+
* 具体 extension 类型时,可以在保持签名兼容性的前提下扩展实现。
|
|
23200
|
+
*/
|
|
23201
|
+
function serializeExtensions(bb, extensions) {
|
|
23202
|
+
if (!Array.isArray(extensions) || extensions.length === 0) {
|
|
23203
|
+
bb.writeVarint32(0);
|
|
23204
|
+
return;
|
|
23205
|
+
}
|
|
23206
|
+
// 协议上 extensions 是 future_extensions,目前主网基本为 0。
|
|
23207
|
+
// 为避免序列化出与 C++ 节点不兼容的数据,这里保守起见仍写入 0。
|
|
23208
|
+
// 如果未来需要支持非空 extensions,可在测试验证后放开以下逻辑:
|
|
23209
|
+
//
|
|
23210
|
+
// bb.writeVarint32(extensions.length);
|
|
23211
|
+
// for (const ext of extensions) {
|
|
23212
|
+
// const json = JSON.stringify(ext ?? null);
|
|
23213
|
+
// writeString(bb, json);
|
|
23214
|
+
// }
|
|
23215
|
+
bb.writeVarint32(0);
|
|
23216
|
+
}
|
|
22348
23217
|
|
|
22349
23218
|
class Serializer {
|
|
22350
23219
|
static fromBuffer(buffer) {
|
|
@@ -25817,7 +26686,7 @@ const steem = {
|
|
|
25817
26686
|
operations,
|
|
25818
26687
|
serializer,
|
|
25819
26688
|
utils: utils$3,
|
|
25820
|
-
version: '1.0.
|
|
26689
|
+
version: '1.0.13',
|
|
25821
26690
|
config: {
|
|
25822
26691
|
set: (options) => {
|
|
25823
26692
|
// If nodes is provided, extract the first node as url for API
|