@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/browser.esm.js
CHANGED
|
@@ -25483,9 +25483,45 @@ function getOperationTypeIndex(opType) {
|
|
|
25483
25483
|
'account_witness_proxy': 13,
|
|
25484
25484
|
'pow': 14,
|
|
25485
25485
|
'custom': 15,
|
|
25486
|
+
'report_over_production': 16,
|
|
25486
25487
|
'delete_comment': 17,
|
|
25487
25488
|
'custom_json': 18,
|
|
25488
25489
|
'comment_options': 19,
|
|
25490
|
+
'set_withdraw_vesting_route': 20,
|
|
25491
|
+
'limit_order_create2': 21,
|
|
25492
|
+
'claim_account': 22,
|
|
25493
|
+
'create_claimed_account': 23,
|
|
25494
|
+
'request_account_recovery': 24,
|
|
25495
|
+
'recover_account': 25,
|
|
25496
|
+
'change_recovery_account': 26,
|
|
25497
|
+
'escrow_transfer': 27,
|
|
25498
|
+
'escrow_dispute': 28,
|
|
25499
|
+
'escrow_release': 29,
|
|
25500
|
+
'pow2': 30,
|
|
25501
|
+
'escrow_approve': 31,
|
|
25502
|
+
'transfer_to_savings': 32,
|
|
25503
|
+
'transfer_from_savings': 33,
|
|
25504
|
+
'cancel_transfer_from_savings': 34,
|
|
25505
|
+
'custom_binary': 35,
|
|
25506
|
+
'decline_voting_rights': 36,
|
|
25507
|
+
'reset_account': 37,
|
|
25508
|
+
'set_reset_account': 38,
|
|
25509
|
+
'claim_reward_balance': 39,
|
|
25510
|
+
'delegate_vesting_shares': 40,
|
|
25511
|
+
'account_create_with_delegation': 41,
|
|
25512
|
+
'witness_set_properties': 42,
|
|
25513
|
+
'account_update2': 43,
|
|
25514
|
+
'create_proposal': 44,
|
|
25515
|
+
'update_proposal_votes': 45,
|
|
25516
|
+
'remove_proposal': 46,
|
|
25517
|
+
'claim_reward_balance2': 47,
|
|
25518
|
+
'fill_convert_request': 48,
|
|
25519
|
+
'comment_reward': 49,
|
|
25520
|
+
'liquidity_reward': 50,
|
|
25521
|
+
'interest': 51,
|
|
25522
|
+
'fill_vesting_withdraw': 52,
|
|
25523
|
+
'fill_order': 53,
|
|
25524
|
+
'fill_transfer_from_savings': 54,
|
|
25489
25525
|
};
|
|
25490
25526
|
const index = opMap[opType];
|
|
25491
25527
|
if (index === undefined) {
|
|
@@ -25510,6 +25546,135 @@ function serializeOperationData(bb, opType, opData) {
|
|
|
25510
25546
|
case 'account_create':
|
|
25511
25547
|
serializeAccountCreate(bb, opData);
|
|
25512
25548
|
break;
|
|
25549
|
+
case 'account_update':
|
|
25550
|
+
serializeAccountUpdate(bb, opData);
|
|
25551
|
+
break;
|
|
25552
|
+
case 'account_create_with_delegation':
|
|
25553
|
+
serializeAccountCreateWithDelegation(bb, opData);
|
|
25554
|
+
break;
|
|
25555
|
+
case 'create_claimed_account':
|
|
25556
|
+
serializeCreateClaimedAccount(bb, opData);
|
|
25557
|
+
break;
|
|
25558
|
+
case 'account_update2':
|
|
25559
|
+
serializeAccountUpdate2(bb, opData);
|
|
25560
|
+
break;
|
|
25561
|
+
case 'request_account_recovery':
|
|
25562
|
+
serializeRequestAccountRecovery(bb, opData);
|
|
25563
|
+
break;
|
|
25564
|
+
case 'recover_account':
|
|
25565
|
+
serializeRecoverAccount(bb, opData);
|
|
25566
|
+
break;
|
|
25567
|
+
case 'change_recovery_account':
|
|
25568
|
+
serializeChangeRecoveryAccount(bb, opData);
|
|
25569
|
+
break;
|
|
25570
|
+
case 'reset_account':
|
|
25571
|
+
serializeResetAccount(bb, opData);
|
|
25572
|
+
break;
|
|
25573
|
+
case 'set_reset_account':
|
|
25574
|
+
serializeSetResetAccount(bb, opData);
|
|
25575
|
+
break;
|
|
25576
|
+
case 'decline_voting_rights':
|
|
25577
|
+
serializeDeclineVotingRights(bb, opData);
|
|
25578
|
+
break;
|
|
25579
|
+
case 'transfer_to_vesting':
|
|
25580
|
+
serializeTransferToVesting(bb, opData);
|
|
25581
|
+
break;
|
|
25582
|
+
case 'withdraw_vesting':
|
|
25583
|
+
serializeWithdrawVesting(bb, opData);
|
|
25584
|
+
break;
|
|
25585
|
+
case 'set_withdraw_vesting_route':
|
|
25586
|
+
serializeSetWithdrawVestingRoute(bb, opData);
|
|
25587
|
+
break;
|
|
25588
|
+
case 'transfer_to_savings':
|
|
25589
|
+
serializeTransferToSavings(bb, opData);
|
|
25590
|
+
break;
|
|
25591
|
+
case 'transfer_from_savings':
|
|
25592
|
+
serializeTransferFromSavings(bb, opData);
|
|
25593
|
+
break;
|
|
25594
|
+
case 'cancel_transfer_from_savings':
|
|
25595
|
+
serializeCancelTransferFromSavings(bb, opData);
|
|
25596
|
+
break;
|
|
25597
|
+
case 'limit_order_create':
|
|
25598
|
+
serializeLimitOrderCreate(bb, opData);
|
|
25599
|
+
break;
|
|
25600
|
+
case 'limit_order_create2':
|
|
25601
|
+
serializeLimitOrderCreate2(bb, opData);
|
|
25602
|
+
break;
|
|
25603
|
+
case 'limit_order_cancel':
|
|
25604
|
+
serializeLimitOrderCancel(bb, opData);
|
|
25605
|
+
break;
|
|
25606
|
+
case 'feed_publish':
|
|
25607
|
+
serializeFeedPublish(bb, opData);
|
|
25608
|
+
break;
|
|
25609
|
+
case 'convert':
|
|
25610
|
+
serializeConvert(bb, opData);
|
|
25611
|
+
break;
|
|
25612
|
+
case 'fill_order':
|
|
25613
|
+
serializeFillOrder(bb, opData);
|
|
25614
|
+
break;
|
|
25615
|
+
case 'escrow_transfer':
|
|
25616
|
+
serializeEscrowTransfer(bb, opData);
|
|
25617
|
+
break;
|
|
25618
|
+
case 'escrow_dispute':
|
|
25619
|
+
serializeEscrowDispute(bb, opData);
|
|
25620
|
+
break;
|
|
25621
|
+
case 'escrow_release':
|
|
25622
|
+
serializeEscrowRelease(bb, opData);
|
|
25623
|
+
break;
|
|
25624
|
+
case 'escrow_approve':
|
|
25625
|
+
serializeEscrowApprove(bb, opData);
|
|
25626
|
+
break;
|
|
25627
|
+
case 'claim_reward_balance':
|
|
25628
|
+
serializeClaimRewardBalance(bb, opData);
|
|
25629
|
+
break;
|
|
25630
|
+
case 'claim_reward_balance2':
|
|
25631
|
+
serializeClaimRewardBalance2(bb, opData);
|
|
25632
|
+
break;
|
|
25633
|
+
case 'comment_reward':
|
|
25634
|
+
serializeCommentReward(bb, opData);
|
|
25635
|
+
break;
|
|
25636
|
+
case 'liquidity_reward':
|
|
25637
|
+
serializeLiquidityReward(bb, opData);
|
|
25638
|
+
break;
|
|
25639
|
+
case 'interest':
|
|
25640
|
+
serializeInterest(bb, opData);
|
|
25641
|
+
break;
|
|
25642
|
+
case 'fill_vesting_withdraw':
|
|
25643
|
+
serializeFillVestingWithdraw(bb, opData);
|
|
25644
|
+
break;
|
|
25645
|
+
case 'fill_convert_request':
|
|
25646
|
+
serializeFillConvertRequest(bb, opData);
|
|
25647
|
+
break;
|
|
25648
|
+
case 'fill_transfer_from_savings':
|
|
25649
|
+
serializeFillTransferFromSavings(bb, opData);
|
|
25650
|
+
break;
|
|
25651
|
+
case 'pow':
|
|
25652
|
+
serializePow(bb, opData);
|
|
25653
|
+
break;
|
|
25654
|
+
case 'pow2':
|
|
25655
|
+
serializePow2(bb, opData);
|
|
25656
|
+
break;
|
|
25657
|
+
case 'witness_update':
|
|
25658
|
+
serializeWitnessUpdate(bb, opData);
|
|
25659
|
+
break;
|
|
25660
|
+
case 'witness_set_properties':
|
|
25661
|
+
serializeWitnessSetProperties(bb, opData);
|
|
25662
|
+
break;
|
|
25663
|
+
case 'account_witness_vote':
|
|
25664
|
+
serializeAccountWitnessVote(bb, opData);
|
|
25665
|
+
break;
|
|
25666
|
+
case 'account_witness_proxy':
|
|
25667
|
+
serializeAccountWitnessProxy(bb, opData);
|
|
25668
|
+
break;
|
|
25669
|
+
case 'custom':
|
|
25670
|
+
serializeCustom(bb, opData);
|
|
25671
|
+
break;
|
|
25672
|
+
case 'custom_binary':
|
|
25673
|
+
serializeCustomBinary(bb, opData);
|
|
25674
|
+
break;
|
|
25675
|
+
case 'comment_options':
|
|
25676
|
+
serializeCommentOptions(bb, opData);
|
|
25677
|
+
break;
|
|
25513
25678
|
case 'custom_json':
|
|
25514
25679
|
serializeCustomJson(bb, opData);
|
|
25515
25680
|
break;
|
|
@@ -25579,6 +25744,647 @@ function serializeAccountCreate(bb, data) {
|
|
|
25579
25744
|
}
|
|
25580
25745
|
writeString(bb, String(dataObj.json_metadata || ''));
|
|
25581
25746
|
}
|
|
25747
|
+
/**
|
|
25748
|
+
* Serialize account_update operation.
|
|
25749
|
+
* Format: account, optional owner (1 byte + authority?), optional active, optional posting, memo_key, json_metadata.
|
|
25750
|
+
*/
|
|
25751
|
+
function serializeAccountUpdate(bb, data) {
|
|
25752
|
+
const dataObj = data;
|
|
25753
|
+
writeString(bb, String(dataObj.account || ''));
|
|
25754
|
+
// Optional authorities: 0 = not present, 1 = present then serialize authority
|
|
25755
|
+
if (dataObj.owner != null && dataObj.owner !== '') {
|
|
25756
|
+
bb.writeUint8(1);
|
|
25757
|
+
serializeAuthority(bb, typeof dataObj.owner === 'object' ? dataObj.owner : { weight_threshold: 1, account_auths: [], key_auths: [] });
|
|
25758
|
+
}
|
|
25759
|
+
else {
|
|
25760
|
+
bb.writeUint8(0);
|
|
25761
|
+
}
|
|
25762
|
+
if (dataObj.active != null && dataObj.active !== '') {
|
|
25763
|
+
bb.writeUint8(1);
|
|
25764
|
+
serializeAuthority(bb, typeof dataObj.active === 'object' ? dataObj.active : { weight_threshold: 1, account_auths: [], key_auths: [] });
|
|
25765
|
+
}
|
|
25766
|
+
else {
|
|
25767
|
+
bb.writeUint8(0);
|
|
25768
|
+
}
|
|
25769
|
+
if (dataObj.posting != null && dataObj.posting !== '') {
|
|
25770
|
+
bb.writeUint8(1);
|
|
25771
|
+
serializeAuthority(bb, typeof dataObj.posting === 'object' ? dataObj.posting : { weight_threshold: 1, account_auths: [], key_auths: [] });
|
|
25772
|
+
}
|
|
25773
|
+
else {
|
|
25774
|
+
bb.writeUint8(0);
|
|
25775
|
+
}
|
|
25776
|
+
// memo_key (public key, required)
|
|
25777
|
+
if (typeof dataObj.memo_key === 'string') {
|
|
25778
|
+
const pubKey = PublicKey.fromStringOrThrow(dataObj.memo_key);
|
|
25779
|
+
bb.append(pubKey.toBuffer());
|
|
25780
|
+
}
|
|
25781
|
+
else if (bufferExports.Buffer.isBuffer(dataObj.memo_key)) {
|
|
25782
|
+
bb.append(dataObj.memo_key);
|
|
25783
|
+
}
|
|
25784
|
+
else if (dataObj.memo_key && typeof dataObj.memo_key.toBuffer === 'function') {
|
|
25785
|
+
bb.append(dataObj.memo_key.toBuffer());
|
|
25786
|
+
}
|
|
25787
|
+
else {
|
|
25788
|
+
throw new Error('Invalid memo_key format');
|
|
25789
|
+
}
|
|
25790
|
+
writeString(bb, typeof dataObj.json_metadata === 'string'
|
|
25791
|
+
? dataObj.json_metadata
|
|
25792
|
+
: dataObj.json_metadata != null
|
|
25793
|
+
? JSON.stringify(dataObj.json_metadata)
|
|
25794
|
+
: '');
|
|
25795
|
+
}
|
|
25796
|
+
/**
|
|
25797
|
+
* Serialize account_create_with_delegation operation.
|
|
25798
|
+
* Fields (see FC_REFLECT): fee, delegation, creator, new_account_name,
|
|
25799
|
+
* owner, active, posting, memo_key, json_metadata, extensions.
|
|
25800
|
+
*/
|
|
25801
|
+
function serializeAccountCreateWithDelegation(bb, data) {
|
|
25802
|
+
const dataObj = data;
|
|
25803
|
+
serializeAsset(bb, String(dataObj.fee || '0.000 STEEM'));
|
|
25804
|
+
serializeAsset(bb, String(dataObj.delegation || '0.000 VESTS'));
|
|
25805
|
+
writeString(bb, String(dataObj.creator || ''));
|
|
25806
|
+
writeString(bb, String(dataObj.new_account_name || ''));
|
|
25807
|
+
serializeAuthority(bb, dataObj.owner);
|
|
25808
|
+
serializeAuthority(bb, dataObj.active);
|
|
25809
|
+
serializeAuthority(bb, dataObj.posting);
|
|
25810
|
+
const memoKey = String(dataObj.memo_key || '');
|
|
25811
|
+
const pubKey = PublicKey.fromStringOrThrow(memoKey);
|
|
25812
|
+
bb.append(pubKey.toBuffer());
|
|
25813
|
+
writeString(bb, String(dataObj.json_metadata || ''));
|
|
25814
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
25815
|
+
}
|
|
25816
|
+
/**
|
|
25817
|
+
* Serialize create_claimed_account operation.
|
|
25818
|
+
* Fields: creator, new_account_name, owner, active, posting,
|
|
25819
|
+
* memo_key, json_metadata, extensions.
|
|
25820
|
+
*/
|
|
25821
|
+
function serializeCreateClaimedAccount(bb, data) {
|
|
25822
|
+
const dataObj = data;
|
|
25823
|
+
writeString(bb, String(dataObj.creator || ''));
|
|
25824
|
+
writeString(bb, String(dataObj.new_account_name || ''));
|
|
25825
|
+
serializeAuthority(bb, dataObj.owner);
|
|
25826
|
+
serializeAuthority(bb, dataObj.active);
|
|
25827
|
+
serializeAuthority(bb, dataObj.posting);
|
|
25828
|
+
const memoKey = String(dataObj.memo_key || '');
|
|
25829
|
+
const pubKey = PublicKey.fromStringOrThrow(memoKey);
|
|
25830
|
+
bb.append(pubKey.toBuffer());
|
|
25831
|
+
writeString(bb, String(dataObj.json_metadata || ''));
|
|
25832
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
25833
|
+
}
|
|
25834
|
+
/**
|
|
25835
|
+
* Serialize account_update2 operation.
|
|
25836
|
+
* Fields: account, owner, active, posting, memo_key,
|
|
25837
|
+
* json_metadata, posting_json_metadata, extensions.
|
|
25838
|
+
*/
|
|
25839
|
+
function serializeAccountUpdate2(bb, data) {
|
|
25840
|
+
const dataObj = data;
|
|
25841
|
+
writeString(bb, String(dataObj.account || ''));
|
|
25842
|
+
serializeAuthority(bb, dataObj.owner);
|
|
25843
|
+
serializeAuthority(bb, dataObj.active);
|
|
25844
|
+
serializeAuthority(bb, dataObj.posting);
|
|
25845
|
+
const memoKey = String(dataObj.memo_key || '');
|
|
25846
|
+
const pubKey = PublicKey.fromStringOrThrow(memoKey);
|
|
25847
|
+
bb.append(pubKey.toBuffer());
|
|
25848
|
+
writeString(bb, String(dataObj.json_metadata || ''));
|
|
25849
|
+
writeString(bb, String(dataObj.posting_json_metadata || ''));
|
|
25850
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
25851
|
+
}
|
|
25852
|
+
/**
|
|
25853
|
+
* Serialize request_account_recovery operation.
|
|
25854
|
+
* Fields: recovery_account, account_to_recover, new_owner_authority, extensions.
|
|
25855
|
+
*/
|
|
25856
|
+
function serializeRequestAccountRecovery(bb, data) {
|
|
25857
|
+
const dataObj = data;
|
|
25858
|
+
writeString(bb, String(dataObj.recovery_account || ''));
|
|
25859
|
+
writeString(bb, String(dataObj.account_to_recover || ''));
|
|
25860
|
+
serializeAuthority(bb, dataObj.new_owner_authority);
|
|
25861
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
25862
|
+
}
|
|
25863
|
+
/**
|
|
25864
|
+
* Serialize recover_account operation.
|
|
25865
|
+
* Fields: account_to_recover, new_owner_authority, recent_owner_authority, extensions.
|
|
25866
|
+
*/
|
|
25867
|
+
function serializeRecoverAccount(bb, data) {
|
|
25868
|
+
const dataObj = data;
|
|
25869
|
+
writeString(bb, String(dataObj.account_to_recover || ''));
|
|
25870
|
+
serializeAuthority(bb, dataObj.new_owner_authority);
|
|
25871
|
+
serializeAuthority(bb, dataObj.recent_owner_authority);
|
|
25872
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
25873
|
+
}
|
|
25874
|
+
/**
|
|
25875
|
+
* Serialize change_recovery_account operation.
|
|
25876
|
+
* Fields: account_to_recover, new_recovery_account, extensions.
|
|
25877
|
+
*/
|
|
25878
|
+
function serializeChangeRecoveryAccount(bb, data) {
|
|
25879
|
+
const dataObj = data;
|
|
25880
|
+
writeString(bb, String(dataObj.account_to_recover || ''));
|
|
25881
|
+
writeString(bb, String(dataObj.new_recovery_account || ''));
|
|
25882
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
25883
|
+
}
|
|
25884
|
+
/**
|
|
25885
|
+
* Serialize reset_account operation.
|
|
25886
|
+
* Fields: reset_account, account_to_reset, new_owner_authority.
|
|
25887
|
+
*/
|
|
25888
|
+
function serializeResetAccount(bb, data) {
|
|
25889
|
+
const dataObj = data;
|
|
25890
|
+
writeString(bb, String(dataObj.reset_account || ''));
|
|
25891
|
+
writeString(bb, String(dataObj.account_to_reset || ''));
|
|
25892
|
+
serializeAuthority(bb, dataObj.new_owner_authority);
|
|
25893
|
+
}
|
|
25894
|
+
/**
|
|
25895
|
+
* Serialize set_reset_account operation.
|
|
25896
|
+
* Fields: account, reset_account.
|
|
25897
|
+
*/
|
|
25898
|
+
function serializeSetResetAccount(bb, data) {
|
|
25899
|
+
const dataObj = data;
|
|
25900
|
+
writeString(bb, String(dataObj.account || ''));
|
|
25901
|
+
writeString(bb, String(dataObj.reset_account || ''));
|
|
25902
|
+
}
|
|
25903
|
+
/**
|
|
25904
|
+
* Serialize decline_voting_rights operation.
|
|
25905
|
+
* Fields: account, decline.
|
|
25906
|
+
*/
|
|
25907
|
+
function serializeDeclineVotingRights(bb, data) {
|
|
25908
|
+
const dataObj = data;
|
|
25909
|
+
writeString(bb, String(dataObj.account || ''));
|
|
25910
|
+
serializeBool(bb, dataObj.decline);
|
|
25911
|
+
}
|
|
25912
|
+
/**
|
|
25913
|
+
* Serialize transfer_to_vesting operation.
|
|
25914
|
+
* Fields: from, to, amount.
|
|
25915
|
+
*/
|
|
25916
|
+
function serializeTransferToVesting(bb, data) {
|
|
25917
|
+
const dataObj = data;
|
|
25918
|
+
writeString(bb, String(dataObj.from || ''));
|
|
25919
|
+
writeString(bb, String(dataObj.to || ''));
|
|
25920
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
25921
|
+
}
|
|
25922
|
+
/**
|
|
25923
|
+
* Serialize withdraw_vesting operation.
|
|
25924
|
+
* Fields: account, vesting_shares.
|
|
25925
|
+
*/
|
|
25926
|
+
function serializeWithdrawVesting(bb, data) {
|
|
25927
|
+
const dataObj = data;
|
|
25928
|
+
writeString(bb, String(dataObj.account || ''));
|
|
25929
|
+
serializeAsset(bb, String(dataObj.vesting_shares || '0.000 VESTS'));
|
|
25930
|
+
}
|
|
25931
|
+
/**
|
|
25932
|
+
* Serialize set_withdraw_vesting_route operation.
|
|
25933
|
+
* Fields: from_account, to_account, percent, auto_vest.
|
|
25934
|
+
*/
|
|
25935
|
+
function serializeSetWithdrawVestingRoute(bb, data) {
|
|
25936
|
+
const dataObj = data;
|
|
25937
|
+
writeString(bb, String(dataObj.from_account || ''));
|
|
25938
|
+
writeString(bb, String(dataObj.to_account || ''));
|
|
25939
|
+
// percent is uint16
|
|
25940
|
+
bb.writeUint16(dataObj.percent ?? 0);
|
|
25941
|
+
serializeBool(bb, dataObj.auto_vest);
|
|
25942
|
+
}
|
|
25943
|
+
/**
|
|
25944
|
+
* Serialize transfer_to_savings operation.
|
|
25945
|
+
* Fields: from, to, amount, memo.
|
|
25946
|
+
*/
|
|
25947
|
+
function serializeTransferToSavings(bb, data) {
|
|
25948
|
+
const dataObj = data;
|
|
25949
|
+
writeString(bb, String(dataObj.from || ''));
|
|
25950
|
+
writeString(bb, String(dataObj.to || ''));
|
|
25951
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
25952
|
+
writeString(bb, String(dataObj.memo || ''));
|
|
25953
|
+
}
|
|
25954
|
+
/**
|
|
25955
|
+
* Serialize transfer_from_savings operation.
|
|
25956
|
+
* Fields: from, request_id, to, amount, memo.
|
|
25957
|
+
*/
|
|
25958
|
+
function serializeTransferFromSavings(bb, data) {
|
|
25959
|
+
const dataObj = data;
|
|
25960
|
+
writeString(bb, String(dataObj.from || ''));
|
|
25961
|
+
bb.writeUint32(dataObj.request_id ?? dataObj.requestID ?? 0);
|
|
25962
|
+
writeString(bb, String(dataObj.to || ''));
|
|
25963
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
25964
|
+
writeString(bb, String(dataObj.memo || ''));
|
|
25965
|
+
}
|
|
25966
|
+
/**
|
|
25967
|
+
* Serialize cancel_transfer_from_savings operation.
|
|
25968
|
+
* Fields: from, request_id.
|
|
25969
|
+
*/
|
|
25970
|
+
function serializeCancelTransferFromSavings(bb, data) {
|
|
25971
|
+
const dataObj = data;
|
|
25972
|
+
writeString(bb, String(dataObj.from || ''));
|
|
25973
|
+
bb.writeUint32(dataObj.request_id ?? dataObj.requestID ?? 0);
|
|
25974
|
+
}
|
|
25975
|
+
/**
|
|
25976
|
+
* Serialize limit_order_create operation.
|
|
25977
|
+
* Fields: owner, orderid, amount_to_sell, min_to_receive, fill_or_kill, expiration.
|
|
25978
|
+
*/
|
|
25979
|
+
function serializeLimitOrderCreate(bb, data) {
|
|
25980
|
+
const dataObj = data;
|
|
25981
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
25982
|
+
bb.writeUint32(dataObj.orderid ?? 0);
|
|
25983
|
+
serializeAsset(bb, String(dataObj.amount_to_sell || '0.000 STEEM'));
|
|
25984
|
+
serializeAsset(bb, String(dataObj.min_to_receive || '0.000 STEEM'));
|
|
25985
|
+
serializeBool(bb, dataObj.fill_or_kill);
|
|
25986
|
+
serializeTimePointSec(bb, dataObj.expiration);
|
|
25987
|
+
}
|
|
25988
|
+
/**
|
|
25989
|
+
* Serialize limit_order_create2 operation.
|
|
25990
|
+
* Fields: owner, orderid, amount_to_sell, exchange_rate{base, quote}, fill_or_kill, expiration.
|
|
25991
|
+
*/
|
|
25992
|
+
function serializeLimitOrderCreate2(bb, data) {
|
|
25993
|
+
const dataObj = data;
|
|
25994
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
25995
|
+
bb.writeUint32(dataObj.orderid ?? 0);
|
|
25996
|
+
serializeAsset(bb, String(dataObj.amount_to_sell || '0.000 STEEM'));
|
|
25997
|
+
const rate = (dataObj.exchange_rate ?? dataObj.exchangeRate);
|
|
25998
|
+
const base = rate?.base ?? '0.000 STEEM';
|
|
25999
|
+
const quote = rate?.quote ?? '0.000 SBD';
|
|
26000
|
+
serializeAsset(bb, String(base));
|
|
26001
|
+
serializeAsset(bb, String(quote));
|
|
26002
|
+
serializeBool(bb, dataObj.fill_or_kill);
|
|
26003
|
+
serializeTimePointSec(bb, dataObj.expiration);
|
|
26004
|
+
}
|
|
26005
|
+
/**
|
|
26006
|
+
* Serialize limit_order_cancel operation.
|
|
26007
|
+
* Fields: owner, orderid.
|
|
26008
|
+
*/
|
|
26009
|
+
function serializeLimitOrderCancel(bb, data) {
|
|
26010
|
+
const dataObj = data;
|
|
26011
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
26012
|
+
bb.writeUint32(dataObj.orderid ?? 0);
|
|
26013
|
+
}
|
|
26014
|
+
/**
|
|
26015
|
+
* Serialize feed_publish operation.
|
|
26016
|
+
* Fields: publisher, exchange_rate{base, quote}.
|
|
26017
|
+
*/
|
|
26018
|
+
function serializeFeedPublish(bb, data) {
|
|
26019
|
+
const dataObj = data;
|
|
26020
|
+
writeString(bb, String(dataObj.publisher || ''));
|
|
26021
|
+
const rate = (dataObj.exchange_rate ?? dataObj.exchangeRate);
|
|
26022
|
+
const base = rate?.base ?? '0.000 STEEM';
|
|
26023
|
+
const quote = rate?.quote ?? '0.000 SBD';
|
|
26024
|
+
serializeAsset(bb, String(base));
|
|
26025
|
+
serializeAsset(bb, String(quote));
|
|
26026
|
+
}
|
|
26027
|
+
/**
|
|
26028
|
+
* Serialize convert operation.
|
|
26029
|
+
* Fields: owner, requestid, amount.
|
|
26030
|
+
*/
|
|
26031
|
+
function serializeConvert(bb, data) {
|
|
26032
|
+
const dataObj = data;
|
|
26033
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
26034
|
+
bb.writeUint32(dataObj.requestid ?? dataObj.request_id ?? 0);
|
|
26035
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
26036
|
+
}
|
|
26037
|
+
/**
|
|
26038
|
+
* Serialize fill_order operation (virtual).
|
|
26039
|
+
* Fields: current_owner, current_orderid, current_pays,
|
|
26040
|
+
* open_owner, open_orderid, open_pays.
|
|
26041
|
+
*/
|
|
26042
|
+
function serializeFillOrder(bb, data) {
|
|
26043
|
+
const dataObj = data;
|
|
26044
|
+
writeString(bb, String(dataObj.current_owner || ''));
|
|
26045
|
+
bb.writeUint32(dataObj.current_orderid ?? 0);
|
|
26046
|
+
serializeAsset(bb, String(dataObj.current_pays || '0.000 STEEM'));
|
|
26047
|
+
writeString(bb, String(dataObj.open_owner || ''));
|
|
26048
|
+
bb.writeUint32(dataObj.open_orderid ?? 0);
|
|
26049
|
+
serializeAsset(bb, String(dataObj.open_pays || '0.000 STEEM'));
|
|
26050
|
+
}
|
|
26051
|
+
/**
|
|
26052
|
+
* Serialize escrow_transfer operation.
|
|
26053
|
+
* Fields: from, to, sbd_amount, steem_amount, escrow_id, agent,
|
|
26054
|
+
* fee, json_meta, ratification_deadline, escrow_expiration.
|
|
26055
|
+
*/
|
|
26056
|
+
function serializeEscrowTransfer(bb, data) {
|
|
26057
|
+
const dataObj = data;
|
|
26058
|
+
writeString(bb, String(dataObj.from || ''));
|
|
26059
|
+
writeString(bb, String(dataObj.to || ''));
|
|
26060
|
+
serializeAsset(bb, String(dataObj.sbd_amount || '0.000 SBD'));
|
|
26061
|
+
serializeAsset(bb, String(dataObj.steem_amount || '0.000 STEEM'));
|
|
26062
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
26063
|
+
writeString(bb, String(dataObj.agent || ''));
|
|
26064
|
+
serializeAsset(bb, String(dataObj.fee || '0.000 STEEM'));
|
|
26065
|
+
writeString(bb, String(dataObj.json_meta || ''));
|
|
26066
|
+
serializeTimePointSec(bb, dataObj.ratification_deadline);
|
|
26067
|
+
serializeTimePointSec(bb, dataObj.escrow_expiration);
|
|
26068
|
+
}
|
|
26069
|
+
/**
|
|
26070
|
+
* Serialize escrow_dispute operation.
|
|
26071
|
+
* Fields: from, to, who, escrow_id.
|
|
26072
|
+
*/
|
|
26073
|
+
function serializeEscrowDispute(bb, data) {
|
|
26074
|
+
const dataObj = data;
|
|
26075
|
+
writeString(bb, String(dataObj.from || ''));
|
|
26076
|
+
writeString(bb, String(dataObj.to || ''));
|
|
26077
|
+
writeString(bb, String(dataObj.who || ''));
|
|
26078
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
26079
|
+
}
|
|
26080
|
+
/**
|
|
26081
|
+
* Serialize escrow_release operation.
|
|
26082
|
+
* Fields: from, to, who, escrow_id, sbd_amount, steem_amount.
|
|
26083
|
+
*/
|
|
26084
|
+
function serializeEscrowRelease(bb, data) {
|
|
26085
|
+
const dataObj = data;
|
|
26086
|
+
writeString(bb, String(dataObj.from || ''));
|
|
26087
|
+
writeString(bb, String(dataObj.to || ''));
|
|
26088
|
+
writeString(bb, String(dataObj.who || ''));
|
|
26089
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
26090
|
+
serializeAsset(bb, String(dataObj.sbd_amount || '0.000 SBD'));
|
|
26091
|
+
serializeAsset(bb, String(dataObj.steem_amount || '0.000 STEEM'));
|
|
26092
|
+
}
|
|
26093
|
+
/**
|
|
26094
|
+
* Serialize escrow_approve operation.
|
|
26095
|
+
* Fields: from, to, agent, who, escrow_id, approve.
|
|
26096
|
+
*/
|
|
26097
|
+
function serializeEscrowApprove(bb, data) {
|
|
26098
|
+
const dataObj = data;
|
|
26099
|
+
writeString(bb, String(dataObj.from || ''));
|
|
26100
|
+
writeString(bb, String(dataObj.to || ''));
|
|
26101
|
+
writeString(bb, String(dataObj.agent || ''));
|
|
26102
|
+
writeString(bb, String(dataObj.who || ''));
|
|
26103
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
26104
|
+
serializeBool(bb, dataObj.approve);
|
|
26105
|
+
}
|
|
26106
|
+
/**
|
|
26107
|
+
* Serialize claim_reward_balance operation.
|
|
26108
|
+
* Fields: account, reward_steem, reward_sbd, reward_vests.
|
|
26109
|
+
*/
|
|
26110
|
+
function serializeClaimRewardBalance(bb, data) {
|
|
26111
|
+
const dataObj = data;
|
|
26112
|
+
writeString(bb, String(dataObj.account || ''));
|
|
26113
|
+
serializeAsset(bb, String(dataObj.reward_steem || '0.000 STEEM'));
|
|
26114
|
+
serializeAsset(bb, String(dataObj.reward_sbd || '0.000 SBD'));
|
|
26115
|
+
serializeAsset(bb, String(dataObj.reward_vests || '0.000000 VESTS'));
|
|
26116
|
+
}
|
|
26117
|
+
/**
|
|
26118
|
+
* Serialize claim_reward_balance2 operation.
|
|
26119
|
+
* Fields: account, extensions, reward_tokens (array of asset strings).
|
|
26120
|
+
*/
|
|
26121
|
+
function serializeClaimRewardBalance2(bb, data) {
|
|
26122
|
+
const dataObj = data;
|
|
26123
|
+
writeString(bb, String(dataObj.account || ''));
|
|
26124
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
26125
|
+
const tokens = Array.isArray(dataObj.reward_tokens) ? dataObj.reward_tokens : [];
|
|
26126
|
+
bb.writeVarint32(tokens.length);
|
|
26127
|
+
for (const tok of tokens) {
|
|
26128
|
+
serializeAsset(bb, typeof tok === 'string' ? tok : String(tok));
|
|
26129
|
+
}
|
|
26130
|
+
}
|
|
26131
|
+
/**
|
|
26132
|
+
* Serialize comment_reward operation.
|
|
26133
|
+
* Fields: author, permlink, payout.
|
|
26134
|
+
*/
|
|
26135
|
+
function serializeCommentReward(bb, data) {
|
|
26136
|
+
const dataObj = data;
|
|
26137
|
+
writeString(bb, String(dataObj.author || ''));
|
|
26138
|
+
writeString(bb, String(dataObj.permlink || ''));
|
|
26139
|
+
serializeAsset(bb, String(dataObj.payout || '0.000 STEEM'));
|
|
26140
|
+
}
|
|
26141
|
+
/**
|
|
26142
|
+
* Serialize liquidity_reward operation.
|
|
26143
|
+
* Fields: owner, payout.
|
|
26144
|
+
*/
|
|
26145
|
+
function serializeLiquidityReward(bb, data) {
|
|
26146
|
+
const dataObj = data;
|
|
26147
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
26148
|
+
serializeAsset(bb, String(dataObj.payout || '0.000 STEEM'));
|
|
26149
|
+
}
|
|
26150
|
+
/**
|
|
26151
|
+
* Serialize interest operation.
|
|
26152
|
+
* Fields: owner, interest.
|
|
26153
|
+
*/
|
|
26154
|
+
function serializeInterest(bb, data) {
|
|
26155
|
+
const dataObj = data;
|
|
26156
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
26157
|
+
serializeAsset(bb, String(dataObj.interest || '0.000 STEEM'));
|
|
26158
|
+
}
|
|
26159
|
+
/**
|
|
26160
|
+
* Serialize fill_vesting_withdraw operation.
|
|
26161
|
+
* Fields: from_account, to_account, withdrawn, deposited.
|
|
26162
|
+
*/
|
|
26163
|
+
function serializeFillVestingWithdraw(bb, data) {
|
|
26164
|
+
const dataObj = data;
|
|
26165
|
+
writeString(bb, String(dataObj.from_account || ''));
|
|
26166
|
+
writeString(bb, String(dataObj.to_account || ''));
|
|
26167
|
+
serializeAsset(bb, String(dataObj.withdrawn || '0.000000 VESTS'));
|
|
26168
|
+
serializeAsset(bb, String(dataObj.deposited || '0.000 STEEM'));
|
|
26169
|
+
}
|
|
26170
|
+
/**
|
|
26171
|
+
* Serialize fill_convert_request operation.
|
|
26172
|
+
* Fields: owner, requestid, amount_in, amount_out.
|
|
26173
|
+
*/
|
|
26174
|
+
function serializeFillConvertRequest(bb, data) {
|
|
26175
|
+
const dataObj = data;
|
|
26176
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
26177
|
+
bb.writeUint32(dataObj.requestid ?? 0);
|
|
26178
|
+
serializeAsset(bb, String(dataObj.amount_in || '0.000 STEEM'));
|
|
26179
|
+
serializeAsset(bb, String(dataObj.amount_out || '0.000 STEEM'));
|
|
26180
|
+
}
|
|
26181
|
+
/**
|
|
26182
|
+
* Serialize fill_transfer_from_savings operation.
|
|
26183
|
+
* Fields: from, to, amount, request_id, memo.
|
|
26184
|
+
*/
|
|
26185
|
+
function serializeFillTransferFromSavings(bb, data) {
|
|
26186
|
+
const dataObj = data;
|
|
26187
|
+
writeString(bb, String(dataObj.from || ''));
|
|
26188
|
+
writeString(bb, String(dataObj.to || ''));
|
|
26189
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
26190
|
+
bb.writeUint32(dataObj.request_id ?? 0);
|
|
26191
|
+
writeString(bb, String(dataObj.memo || ''));
|
|
26192
|
+
}
|
|
26193
|
+
/**
|
|
26194
|
+
* Serialize ChainProperties (used in pow, witness_update).
|
|
26195
|
+
* Fields: account_creation_fee (asset string), maximum_block_size (uint32), sbd_interest_rate (uint16).
|
|
26196
|
+
*/
|
|
26197
|
+
function serializeChainProperties(bb, props) {
|
|
26198
|
+
const p = props || {};
|
|
26199
|
+
const fee = p.account_creation_fee;
|
|
26200
|
+
if (typeof fee === 'string' && fee.split(' ').length >= 2) {
|
|
26201
|
+
serializeAsset(bb, fee);
|
|
26202
|
+
}
|
|
26203
|
+
else {
|
|
26204
|
+
serializeAsset(bb, '0.000 STEEM');
|
|
26205
|
+
}
|
|
26206
|
+
bb.writeUint32(p.maximum_block_size ?? 0);
|
|
26207
|
+
bb.writeUint16(p.sbd_interest_rate ?? 0);
|
|
26208
|
+
}
|
|
26209
|
+
/**
|
|
26210
|
+
* Serialize POW inner struct (worker, input, signature, work).
|
|
26211
|
+
*/
|
|
26212
|
+
function serializePOWInner(bb, work) {
|
|
26213
|
+
const w = work || {};
|
|
26214
|
+
writeString(bb, String(w.worker || ''));
|
|
26215
|
+
writeString(bb, String(w.input || ''));
|
|
26216
|
+
writeString(bb, String(w.signature || ''));
|
|
26217
|
+
writeString(bb, String(w.work || ''));
|
|
26218
|
+
}
|
|
26219
|
+
/**
|
|
26220
|
+
* Serialize pow operation.
|
|
26221
|
+
* Fields: worker_account, block_id, nonce (optional), work (POW), props (ChainProperties).
|
|
26222
|
+
*/
|
|
26223
|
+
function serializePow(bb, data) {
|
|
26224
|
+
const dataObj = data;
|
|
26225
|
+
writeString(bb, String(dataObj.worker_account || ''));
|
|
26226
|
+
writeString(bb, String(dataObj.block_id || ''));
|
|
26227
|
+
const nonce = dataObj.nonce;
|
|
26228
|
+
if (nonce !== undefined && nonce !== null) {
|
|
26229
|
+
bb.writeUint8(1);
|
|
26230
|
+
bb.writeUint64(Number(nonce));
|
|
26231
|
+
}
|
|
26232
|
+
else {
|
|
26233
|
+
bb.writeUint8(0);
|
|
26234
|
+
}
|
|
26235
|
+
serializePOWInner(bb, dataObj.work);
|
|
26236
|
+
serializeChainProperties(bb, dataObj.props);
|
|
26237
|
+
}
|
|
26238
|
+
/**
|
|
26239
|
+
* Serialize pow2 operation.
|
|
26240
|
+
* Fields: input, pow_summary (opaque bytes; if string treated as hex).
|
|
26241
|
+
*/
|
|
26242
|
+
function serializePow2(bb, data) {
|
|
26243
|
+
const dataObj = data;
|
|
26244
|
+
writeString(bb, String(dataObj.input || ''));
|
|
26245
|
+
const summary = dataObj.pow_summary;
|
|
26246
|
+
let bytes;
|
|
26247
|
+
if (typeof summary === 'string') {
|
|
26248
|
+
const hex = summary.startsWith('0x') ? summary.slice(2) : summary;
|
|
26249
|
+
bytes = bufferExports.Buffer.from(hex, 'hex');
|
|
26250
|
+
}
|
|
26251
|
+
else if (bufferExports.Buffer.isBuffer(summary)) {
|
|
26252
|
+
bytes = summary;
|
|
26253
|
+
}
|
|
26254
|
+
else {
|
|
26255
|
+
bytes = bufferExports.Buffer.alloc(0);
|
|
26256
|
+
}
|
|
26257
|
+
bb.writeVarint32(bytes.length);
|
|
26258
|
+
bb.append(bytes);
|
|
26259
|
+
}
|
|
26260
|
+
/**
|
|
26261
|
+
* Serialize witness_update operation.
|
|
26262
|
+
* Fields: owner, url, block_signing_key, props (ChainProperties), fee.
|
|
26263
|
+
*/
|
|
26264
|
+
function serializeWitnessUpdate(bb, data) {
|
|
26265
|
+
const dataObj = data;
|
|
26266
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
26267
|
+
writeString(bb, String(dataObj.url || ''));
|
|
26268
|
+
const key = dataObj.block_signing_key;
|
|
26269
|
+
if (typeof key === 'string') {
|
|
26270
|
+
const pubKey = PublicKey.fromStringOrThrow(key);
|
|
26271
|
+
bb.append(pubKey.toBuffer());
|
|
26272
|
+
}
|
|
26273
|
+
else if (bufferExports.Buffer.isBuffer(key)) {
|
|
26274
|
+
bb.append(key);
|
|
26275
|
+
}
|
|
26276
|
+
else if (key && typeof key.toBuffer === 'function') {
|
|
26277
|
+
bb.append(key.toBuffer());
|
|
26278
|
+
}
|
|
26279
|
+
else {
|
|
26280
|
+
bb.append(bufferExports.Buffer.alloc(33));
|
|
26281
|
+
}
|
|
26282
|
+
serializeChainProperties(bb, dataObj.props);
|
|
26283
|
+
serializeAsset(bb, String(dataObj.fee || '0.000 STEEM'));
|
|
26284
|
+
}
|
|
26285
|
+
/**
|
|
26286
|
+
* Serialize witness_set_properties operation.
|
|
26287
|
+
* Fields: owner, props (map string -> bytes), extensions.
|
|
26288
|
+
*/
|
|
26289
|
+
function serializeWitnessSetProperties(bb, data) {
|
|
26290
|
+
const dataObj = data;
|
|
26291
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
26292
|
+
const props = dataObj.props;
|
|
26293
|
+
const keys = props ? Object.keys(props).sort() : [];
|
|
26294
|
+
bb.writeVarint32(keys.length);
|
|
26295
|
+
for (const k of keys) {
|
|
26296
|
+
writeString(bb, k);
|
|
26297
|
+
const v = props[k];
|
|
26298
|
+
const buf = typeof v === 'string' ? bufferExports.Buffer.from(v, 'utf8') : bufferExports.Buffer.isBuffer(v) ? v : bufferExports.Buffer.alloc(0);
|
|
26299
|
+
bb.writeVarint32(buf.length);
|
|
26300
|
+
bb.append(buf);
|
|
26301
|
+
}
|
|
26302
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
26303
|
+
}
|
|
26304
|
+
/**
|
|
26305
|
+
* Serialize account_witness_vote operation.
|
|
26306
|
+
* Fields: account, witness, approve.
|
|
26307
|
+
*/
|
|
26308
|
+
function serializeAccountWitnessVote(bb, data) {
|
|
26309
|
+
const dataObj = data;
|
|
26310
|
+
writeString(bb, String(dataObj.account || ''));
|
|
26311
|
+
writeString(bb, String(dataObj.witness || ''));
|
|
26312
|
+
serializeBool(bb, dataObj.approve);
|
|
26313
|
+
}
|
|
26314
|
+
/**
|
|
26315
|
+
* Serialize account_witness_proxy operation.
|
|
26316
|
+
* Fields: account, proxy.
|
|
26317
|
+
*/
|
|
26318
|
+
function serializeAccountWitnessProxy(bb, data) {
|
|
26319
|
+
const dataObj = data;
|
|
26320
|
+
writeString(bb, String(dataObj.account || ''));
|
|
26321
|
+
writeString(bb, String(dataObj.proxy || ''));
|
|
26322
|
+
}
|
|
26323
|
+
/**
|
|
26324
|
+
* Serialize custom operation (required_auths, id, data).
|
|
26325
|
+
* id is uint16 in protocol; data is bytes.
|
|
26326
|
+
*/
|
|
26327
|
+
function serializeCustom(bb, data) {
|
|
26328
|
+
const dataObj = data;
|
|
26329
|
+
const requiredAuths = Array.isArray(dataObj.required_auths)
|
|
26330
|
+
? dataObj.required_auths.slice().sort()
|
|
26331
|
+
: [];
|
|
26332
|
+
bb.writeVarint32(requiredAuths.length);
|
|
26333
|
+
for (const account of requiredAuths) {
|
|
26334
|
+
writeString(bb, String(account));
|
|
26335
|
+
}
|
|
26336
|
+
bb.writeUint16(dataObj.id ?? 0);
|
|
26337
|
+
const dataBytes = dataObj.data;
|
|
26338
|
+
let buf;
|
|
26339
|
+
if (typeof dataBytes === 'string') {
|
|
26340
|
+
const hex = dataBytes.startsWith('0x') ? dataBytes.slice(2) : dataBytes;
|
|
26341
|
+
buf = bufferExports.Buffer.from(hex, 'hex');
|
|
26342
|
+
}
|
|
26343
|
+
else if (bufferExports.Buffer.isBuffer(dataBytes)) {
|
|
26344
|
+
buf = dataBytes;
|
|
26345
|
+
}
|
|
26346
|
+
else {
|
|
26347
|
+
buf = bufferExports.Buffer.alloc(0);
|
|
26348
|
+
}
|
|
26349
|
+
bb.writeVarint32(buf.length);
|
|
26350
|
+
bb.append(buf);
|
|
26351
|
+
}
|
|
26352
|
+
/**
|
|
26353
|
+
* Serialize custom_binary operation.
|
|
26354
|
+
* Fields: id (string), data (bytes).
|
|
26355
|
+
*/
|
|
26356
|
+
function serializeCustomBinary(bb, data) {
|
|
26357
|
+
const dataObj = data;
|
|
26358
|
+
writeString(bb, String(dataObj.id || ''));
|
|
26359
|
+
const dataBytes = dataObj.data;
|
|
26360
|
+
let buf;
|
|
26361
|
+
if (typeof dataBytes === 'string') {
|
|
26362
|
+
const hex = dataBytes.startsWith('0x') ? dataBytes.slice(2) : dataBytes;
|
|
26363
|
+
buf = bufferExports.Buffer.from(hex, 'hex');
|
|
26364
|
+
}
|
|
26365
|
+
else if (bufferExports.Buffer.isBuffer(dataBytes)) {
|
|
26366
|
+
buf = dataBytes;
|
|
26367
|
+
}
|
|
26368
|
+
else {
|
|
26369
|
+
buf = bufferExports.Buffer.alloc(0);
|
|
26370
|
+
}
|
|
26371
|
+
bb.writeVarint32(buf.length);
|
|
26372
|
+
bb.append(buf);
|
|
26373
|
+
}
|
|
26374
|
+
/**
|
|
26375
|
+
* Serialize comment_options operation.
|
|
26376
|
+
* Fields: author, permlink, max_accepted_payout, percent_steem_dollars, allow_votes, allow_curation_rewards, extensions.
|
|
26377
|
+
*/
|
|
26378
|
+
function serializeCommentOptions(bb, data) {
|
|
26379
|
+
const dataObj = data;
|
|
26380
|
+
writeString(bb, String(dataObj.author || ''));
|
|
26381
|
+
writeString(bb, String(dataObj.permlink || ''));
|
|
26382
|
+
serializeAsset(bb, String(dataObj.max_accepted_payout || '1000000.000 SBD'));
|
|
26383
|
+
bb.writeUint16(dataObj.percent_steem_dollars ?? 0);
|
|
26384
|
+
serializeBool(bb, dataObj.allow_votes);
|
|
26385
|
+
serializeBool(bb, dataObj.allow_curation_rewards);
|
|
26386
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
26387
|
+
}
|
|
25582
26388
|
/**
|
|
25583
26389
|
* Serialize custom_json operation
|
|
25584
26390
|
*/
|
|
@@ -25650,7 +26456,12 @@ function serializeAuthority(bb, auth) {
|
|
|
25650
26456
|
}
|
|
25651
26457
|
}
|
|
25652
26458
|
/**
|
|
25653
|
-
* Serialize asset (
|
|
26459
|
+
* Serialize asset (STEEM/SBD/VESTS style string) to binary.
|
|
26460
|
+
*
|
|
26461
|
+
* Format: int64 amount (little-endian) + uint8 precision + 7-byte symbol (UTF-8, null-padded).
|
|
26462
|
+
*
|
|
26463
|
+
* This helper is reused across all operations中涉及资产字段的地方,例如:
|
|
26464
|
+
* - amount / vesting_shares / reward_* / *_pays
|
|
25654
26465
|
*/
|
|
25655
26466
|
function serializeAsset(bb, amount) {
|
|
25656
26467
|
const parts = amount.split(' ');
|
|
@@ -25659,7 +26470,6 @@ function serializeAsset(bb, amount) {
|
|
|
25659
26470
|
const [intPart, decPart = ''] = valueStr.split('.');
|
|
25660
26471
|
const precision = decPart.length;
|
|
25661
26472
|
const amountValue = parseInt(intPart + decPart.padEnd(precision, '0'), 10) || 0;
|
|
25662
|
-
// ByteBuffer can accept number directly for small values
|
|
25663
26473
|
bb.writeInt64(amountValue);
|
|
25664
26474
|
bb.writeUint8(precision);
|
|
25665
26475
|
const symbolBytes = bufferExports.Buffer.from(symbol, 'utf8');
|
|
@@ -25669,11 +26479,70 @@ function serializeAsset(bb, amount) {
|
|
|
25669
26479
|
}
|
|
25670
26480
|
}
|
|
25671
26481
|
/**
|
|
25672
|
-
* Write a string using ByteBuffer's writeVString method
|
|
26482
|
+
* Write a string using ByteBuffer's writeVString method.
|
|
26483
|
+
* 所有字符串字段统一通过该 helper 序列化,避免直接到处调用 ByteBuffer API。
|
|
25673
26484
|
*/
|
|
25674
26485
|
function writeString(bb, str) {
|
|
25675
26486
|
bb.writeVString(str);
|
|
25676
26487
|
}
|
|
26488
|
+
/**
|
|
26489
|
+
* Serialize a time_point_sec-style field.
|
|
26490
|
+
*
|
|
26491
|
+
* 接受 ISO 字符串 / Date / 秒级数字,最终写入 uint32(自 epoch 起的秒数)。
|
|
26492
|
+
* 常用于 proposal start/end、escrow_deadline 等字段。
|
|
26493
|
+
*/
|
|
26494
|
+
function serializeTimePointSec(bb, value) {
|
|
26495
|
+
let seconds;
|
|
26496
|
+
if (typeof value === 'string') {
|
|
26497
|
+
const iso = value.endsWith('Z') ? value : `${value}Z`;
|
|
26498
|
+
const d = new Date(iso);
|
|
26499
|
+
seconds = Math.floor(d.getTime() / 1000);
|
|
26500
|
+
}
|
|
26501
|
+
else if (value instanceof Date) {
|
|
26502
|
+
seconds = Math.floor(value.getTime() / 1000);
|
|
26503
|
+
}
|
|
26504
|
+
else if (typeof value === 'number') {
|
|
26505
|
+
// 这里假定已是秒级时间戳
|
|
26506
|
+
seconds = value;
|
|
26507
|
+
}
|
|
26508
|
+
else {
|
|
26509
|
+
seconds = 0;
|
|
26510
|
+
}
|
|
26511
|
+
bb.writeUint32(seconds);
|
|
26512
|
+
}
|
|
26513
|
+
/**
|
|
26514
|
+
* Serialize a generic bool flag as uint8(0/1).
|
|
26515
|
+
* 后续在多处 optional / approve / decline 字段可统一复用。
|
|
26516
|
+
*/
|
|
26517
|
+
function serializeBool(bb, value) {
|
|
26518
|
+
bb.writeUint8(value ? 1 : 0);
|
|
26519
|
+
}
|
|
26520
|
+
/**
|
|
26521
|
+
* Serialize a future_extensions / extensions 风格字段。
|
|
26522
|
+
*
|
|
26523
|
+
* 目前大多数链上交易中 extensions 仍为空集合,协议格式是:
|
|
26524
|
+
* - varint32 length
|
|
26525
|
+
* - 后续按约定序列化各元素(当前实现仅支持空或简单 JSON 字符串)
|
|
26526
|
+
*
|
|
26527
|
+
* 为兼容现有使用场景,这里暂时只写入长度,忽略实际内容;当需要支持
|
|
26528
|
+
* 具体 extension 类型时,可以在保持签名兼容性的前提下扩展实现。
|
|
26529
|
+
*/
|
|
26530
|
+
function serializeExtensions(bb, extensions) {
|
|
26531
|
+
if (!Array.isArray(extensions) || extensions.length === 0) {
|
|
26532
|
+
bb.writeVarint32(0);
|
|
26533
|
+
return;
|
|
26534
|
+
}
|
|
26535
|
+
// 协议上 extensions 是 future_extensions,目前主网基本为 0。
|
|
26536
|
+
// 为避免序列化出与 C++ 节点不兼容的数据,这里保守起见仍写入 0。
|
|
26537
|
+
// 如果未来需要支持非空 extensions,可在测试验证后放开以下逻辑:
|
|
26538
|
+
//
|
|
26539
|
+
// bb.writeVarint32(extensions.length);
|
|
26540
|
+
// for (const ext of extensions) {
|
|
26541
|
+
// const json = JSON.stringify(ext ?? null);
|
|
26542
|
+
// writeString(bb, json);
|
|
26543
|
+
// }
|
|
26544
|
+
bb.writeVarint32(0);
|
|
26545
|
+
}
|
|
25677
26546
|
|
|
25678
26547
|
class Serializer {
|
|
25679
26548
|
static fromBuffer(buffer) {
|
|
@@ -29145,7 +30014,7 @@ const steem = {
|
|
|
29145
30014
|
operations,
|
|
29146
30015
|
serializer,
|
|
29147
30016
|
utils: utils$3,
|
|
29148
|
-
version: '1.0.
|
|
30017
|
+
version: '1.0.13',
|
|
29149
30018
|
config: {
|
|
29150
30019
|
set: (options) => {
|
|
29151
30020
|
// If nodes is provided, extract the first node as url for API
|