@steemit/steem-js 1.0.12 → 1.0.14
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/api/transports/http.d.ts +5 -1
- package/dist/api/transports/types.d.ts +8 -0
- package/dist/auth/ecc/src/key_private.d.ts +5 -0
- package/dist/auth/ecc/src/key_utils.d.ts +3 -2
- package/dist/browser.esm.js +1186 -679
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs +1186 -679
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1186 -679
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1186 -679
- 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/dist/memo/index.d.ts +8 -1
- package/dist/umd.d.ts +0 -2
- package/package.json +3 -2
- package/dist/serializer/convert.d.ts +0 -21
- package/dist/serializer/index.d.ts +0 -11
- package/dist/serializer/number_utils.d.ts +0 -8
- package/dist/serializer/precision.d.ts +0 -5
- package/dist/serializer/types.d.ts +0 -36
package/dist/index.cjs
CHANGED
|
@@ -13858,6 +13858,20 @@ class PublicKey {
|
|
|
13858
13858
|
const secp256k1$1 = new ellipticExports.ec('secp256k1');
|
|
13859
13859
|
const G = secp256k1$1.g;
|
|
13860
13860
|
const n = new BN(secp256k1$1.n.toString());
|
|
13861
|
+
/**
|
|
13862
|
+
* Constant-time buffer comparison to prevent timing attacks.
|
|
13863
|
+
* Returns true only if a.length === b.length and a[i] === b[i] for all i.
|
|
13864
|
+
*/
|
|
13865
|
+
function constantTimeCompare(a, b) {
|
|
13866
|
+
if (a.length !== b.length) {
|
|
13867
|
+
return false;
|
|
13868
|
+
}
|
|
13869
|
+
let result = 0;
|
|
13870
|
+
for (let i = 0; i < a.length; i++) {
|
|
13871
|
+
result |= a[i] ^ b[i];
|
|
13872
|
+
}
|
|
13873
|
+
return result === 0;
|
|
13874
|
+
}
|
|
13861
13875
|
class PrivateKey {
|
|
13862
13876
|
/**
|
|
13863
13877
|
* @private see static functions
|
|
@@ -13870,11 +13884,8 @@ class PrivateKey {
|
|
|
13870
13884
|
if (!Buffer.isBuffer(buf)) {
|
|
13871
13885
|
throw new Error("Expecting parameter to be a Buffer type");
|
|
13872
13886
|
}
|
|
13873
|
-
if (
|
|
13874
|
-
|
|
13875
|
-
}
|
|
13876
|
-
if (buf.length === 0) {
|
|
13877
|
-
throw new Error("Empty buffer");
|
|
13887
|
+
if (buf.length !== 32) {
|
|
13888
|
+
throw new Error(`Invalid private key buffer: expected 32 bytes, got ${buf.length}`);
|
|
13878
13889
|
}
|
|
13879
13890
|
return new PrivateKey(new BN(buf));
|
|
13880
13891
|
}
|
|
@@ -13899,21 +13910,33 @@ class PrivateKey {
|
|
|
13899
13910
|
* @return {string} Wallet Import Format (still a secret, Not encrypted)
|
|
13900
13911
|
*/
|
|
13901
13912
|
static fromWif(private_wif) {
|
|
13902
|
-
|
|
13913
|
+
if (!private_wif || typeof private_wif !== 'string') {
|
|
13914
|
+
throw new Error('Invalid WIF: empty or not a string');
|
|
13915
|
+
}
|
|
13916
|
+
let private_wif_buffer;
|
|
13917
|
+
try {
|
|
13918
|
+
private_wif_buffer = Buffer.from(bs58.decode(private_wif));
|
|
13919
|
+
}
|
|
13920
|
+
catch {
|
|
13921
|
+
throw new Error('Invalid WIF: failed to decode base58');
|
|
13922
|
+
}
|
|
13923
|
+
// Valid WIF: 1 byte version + 32 bytes key + 4 bytes checksum = 37 bytes
|
|
13924
|
+
if (private_wif_buffer.length !== 37) {
|
|
13925
|
+
throw new Error(`Invalid WIF: expected 37 bytes, got ${private_wif_buffer.length}`);
|
|
13926
|
+
}
|
|
13903
13927
|
const version = private_wif_buffer.readUInt8(0);
|
|
13904
|
-
if (version !== 0x80)
|
|
13905
|
-
throw new Error(`
|
|
13906
|
-
|
|
13907
|
-
const private_key = private_wif_buffer.slice(
|
|
13908
|
-
const checksum = private_wif_buffer.slice(
|
|
13909
|
-
let new_checksum = sha256$1(private_key);
|
|
13928
|
+
if (version !== 0x80) {
|
|
13929
|
+
throw new Error(`Invalid WIF: expected version 0x80, got 0x${version.toString(16)}`);
|
|
13930
|
+
}
|
|
13931
|
+
const private_key = private_wif_buffer.slice(1, 33);
|
|
13932
|
+
const checksum = private_wif_buffer.slice(33);
|
|
13933
|
+
let new_checksum = sha256$1(Buffer.concat([Buffer.from([0x80]), private_key]));
|
|
13910
13934
|
new_checksum = sha256$1(new_checksum);
|
|
13911
13935
|
new_checksum = new_checksum.slice(0, 4);
|
|
13912
|
-
if (checksum.
|
|
13936
|
+
if (!constantTimeCompare(checksum, Buffer.from(new_checksum))) {
|
|
13913
13937
|
throw new Error('Invalid WIF key (checksum miss-match)');
|
|
13914
13938
|
}
|
|
13915
|
-
|
|
13916
|
-
return PrivateKey.fromBuffer(private_key.slice(1));
|
|
13939
|
+
return PrivateKey.fromBuffer(private_key);
|
|
13917
13940
|
}
|
|
13918
13941
|
toWif() {
|
|
13919
13942
|
const private_key = this.toBuffer();
|
|
@@ -14292,18 +14315,21 @@ function calcPubKeyRecoveryParam(curve, e, signature, Q) {
|
|
|
14292
14315
|
}
|
|
14293
14316
|
catch (error) {
|
|
14294
14317
|
// try next value
|
|
14295
|
-
|
|
14318
|
+
if (process.env.NODE_ENV === 'development') {
|
|
14319
|
+
console.debug(`Recovery attempt ${i} failed:`, error.message);
|
|
14320
|
+
}
|
|
14296
14321
|
}
|
|
14297
14322
|
}
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14323
|
+
if (process.env.NODE_ENV === 'development') {
|
|
14324
|
+
console.debug('All recovery attempts failed. Signature:', {
|
|
14325
|
+
r: signature.r.toString(16),
|
|
14326
|
+
s: signature.s.toString(16)
|
|
14327
|
+
});
|
|
14328
|
+
console.debug('Expected public key:', {
|
|
14329
|
+
x: Q.getX().toString(16),
|
|
14330
|
+
y: Q.getY().toString(16)
|
|
14331
|
+
});
|
|
14332
|
+
}
|
|
14307
14333
|
throw new Error('Unable to find valid recovery factor');
|
|
14308
14334
|
}
|
|
14309
14335
|
|
|
@@ -14355,9 +14381,10 @@ class Signature {
|
|
|
14355
14381
|
const d = privKey.d;
|
|
14356
14382
|
let ecsignature;
|
|
14357
14383
|
let nonce = 0;
|
|
14384
|
+
const MAX_NONCE_ATTEMPTS = 1000;
|
|
14358
14385
|
// Match old-steem-js behavior: find canonical signature (lenR === 32 && lenS === 32)
|
|
14359
14386
|
// Based on C++ is_fc_canonical logic
|
|
14360
|
-
while (
|
|
14387
|
+
while (nonce < MAX_NONCE_ATTEMPTS) {
|
|
14361
14388
|
ecsignature = sign$3(secp256k1, buf_sha256, d, nonce++);
|
|
14362
14389
|
const rBa = ecsignature.r.toArrayLike(Buffer, 'be', 32);
|
|
14363
14390
|
const sBa = ecsignature.s.toArrayLike(Buffer, 'be', 32);
|
|
@@ -14374,6 +14401,9 @@ class Signature {
|
|
|
14374
14401
|
console.debug("WARN: " + nonce + " attempts to find canonical signature");
|
|
14375
14402
|
}
|
|
14376
14403
|
}
|
|
14404
|
+
if (nonce >= MAX_NONCE_ATTEMPTS || ecsignature === undefined) {
|
|
14405
|
+
throw new Error('Failed to find canonical signature after maximum attempts');
|
|
14406
|
+
}
|
|
14377
14407
|
const i = calcPubKeyRecoveryParam(secp256k1, new BN(buf_sha256), ecsignature, privKey.toPublic().Q);
|
|
14378
14408
|
// Use recovery byte 31-34 (instead of 27-30) to be compatible with dsteem
|
|
14379
14409
|
// dsteem expects: recovery = byte - 31, so byte = recovery + 31
|
|
@@ -14674,7 +14704,11 @@ async function validate(request, verify) {
|
|
|
14674
14704
|
if (Number.isNaN(timestamp)) {
|
|
14675
14705
|
throw new Error('Invalid timestamp');
|
|
14676
14706
|
}
|
|
14677
|
-
|
|
14707
|
+
const now = Date.now();
|
|
14708
|
+
const timeDiff = Math.abs(now - timestamp);
|
|
14709
|
+
const SIGNATURE_VALIDITY_MS = 60 * 1000;
|
|
14710
|
+
const MAX_CLOCK_SKEW_MS = 5 * 60 * 1000;
|
|
14711
|
+
if (timeDiff > SIGNATURE_VALIDITY_MS + MAX_CLOCK_SKEW_MS) {
|
|
14678
14712
|
throw new Error('Signature expired');
|
|
14679
14713
|
}
|
|
14680
14714
|
const message = hashMessage(signed.timestamp, signed.account, request.method, signed.params, nonce);
|
|
@@ -15649,6 +15683,37 @@ class BaseTransport extends events.EventEmitter {
|
|
|
15649
15683
|
}
|
|
15650
15684
|
|
|
15651
15685
|
// @ts-expect-error: No types for 'retry'
|
|
15686
|
+
/** Detect Node.js for optional undici Agent (custom TLS). */
|
|
15687
|
+
const isNode = typeof process !== 'undefined' &&
|
|
15688
|
+
typeof process.versions === 'object' &&
|
|
15689
|
+
typeof process.versions.node === 'string';
|
|
15690
|
+
/**
|
|
15691
|
+
* Build RequestInit for fetch. In Node when options.httpsOptions is set, inject undici Agent as dispatcher.
|
|
15692
|
+
*/
|
|
15693
|
+
async function buildFetchOptions(body, options) {
|
|
15694
|
+
const init = {
|
|
15695
|
+
method: 'POST',
|
|
15696
|
+
headers: {
|
|
15697
|
+
'Content-Type': 'application/json',
|
|
15698
|
+
'Accept': 'application/json'
|
|
15699
|
+
},
|
|
15700
|
+
body
|
|
15701
|
+
};
|
|
15702
|
+
if (isNode && options.httpsOptions) {
|
|
15703
|
+
// Node 18+ built-in fetch uses undici; custom TLS via node:undici Agent (built-in, no package)
|
|
15704
|
+
// @ts-expect-error - node:undici is Node built-in, not in @types/node
|
|
15705
|
+
const { Agent } = await import('node:undici');
|
|
15706
|
+
const opts = options.httpsOptions;
|
|
15707
|
+
const agent = new Agent({
|
|
15708
|
+
connect: {
|
|
15709
|
+
rejectUnauthorized: opts.rejectUnauthorized,
|
|
15710
|
+
ca: opts.ca
|
|
15711
|
+
}
|
|
15712
|
+
});
|
|
15713
|
+
init.dispatcher = agent;
|
|
15714
|
+
}
|
|
15715
|
+
return init;
|
|
15716
|
+
}
|
|
15652
15717
|
/**
|
|
15653
15718
|
* Extended Error type for JSON-RPC errors
|
|
15654
15719
|
*/
|
|
@@ -15668,29 +15733,22 @@ class JsonRpcError extends Error {
|
|
|
15668
15733
|
* @param request - The JSON-RPC request object
|
|
15669
15734
|
* @param fetchMethod - Optional fetch implementation (defaults to global fetch)
|
|
15670
15735
|
* @param timeoutMs - Request timeout in milliseconds (default: 30000)
|
|
15736
|
+
* @param httpsOptions - Optional TLS options (Node.js only): rejectUnauthorized, ca
|
|
15671
15737
|
* @returns Promise resolving to the JSON-RPC result
|
|
15672
15738
|
*/
|
|
15673
|
-
const jsonRpc = async (url, request, fetchMethod = fetch, timeoutMs = 30000) => {
|
|
15739
|
+
const jsonRpc = async (url, request, fetchMethod = fetch, timeoutMs = 30000, httpsOptions) => {
|
|
15674
15740
|
const payload = {
|
|
15675
15741
|
jsonrpc: '2.0',
|
|
15676
15742
|
...request
|
|
15677
15743
|
};
|
|
15678
15744
|
let timeoutId = null;
|
|
15679
|
-
// Create a promise that will reject after the timeout
|
|
15680
15745
|
const timeoutPromise = new Promise((_, reject) => {
|
|
15681
15746
|
timeoutId = setTimeout(() => {
|
|
15682
15747
|
reject(new Error(`Request timeout after ${timeoutMs}ms`));
|
|
15683
15748
|
}, timeoutMs);
|
|
15684
15749
|
});
|
|
15685
|
-
|
|
15686
|
-
const fetchPromise = fetchMethod(url,
|
|
15687
|
-
method: 'POST',
|
|
15688
|
-
headers: {
|
|
15689
|
-
'Content-Type': 'application/json',
|
|
15690
|
-
'Accept': 'application/json'
|
|
15691
|
-
},
|
|
15692
|
-
body: JSON.stringify(payload)
|
|
15693
|
-
})
|
|
15750
|
+
const fetchOptions = await buildFetchOptions(JSON.stringify(payload), { httpsOptions });
|
|
15751
|
+
const fetchPromise = fetchMethod(url, fetchOptions)
|
|
15694
15752
|
.then(async (res) => {
|
|
15695
15753
|
if (!res.ok) {
|
|
15696
15754
|
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
@@ -15741,71 +15799,56 @@ class HttpTransport extends BaseTransport {
|
|
|
15741
15799
|
const params = [api, data.method, data.params];
|
|
15742
15800
|
const isBroadcast = this.isBroadcastOperation(data.method);
|
|
15743
15801
|
const retryOptions = this.options.retry;
|
|
15744
|
-
|
|
15745
|
-
|
|
15746
|
-
|
|
15747
|
-
|
|
15748
|
-
|
|
15749
|
-
|
|
15750
|
-
|
|
15751
|
-
|
|
15752
|
-
|
|
15753
|
-
|
|
15754
|
-
|
|
15755
|
-
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
|
|
15759
|
-
|
|
15760
|
-
|
|
15761
|
-
|
|
15762
|
-
|
|
15763
|
-
|
|
15802
|
+
const body = JSON.stringify({
|
|
15803
|
+
jsonrpc: '2.0',
|
|
15804
|
+
method: 'call',
|
|
15805
|
+
params,
|
|
15806
|
+
id
|
|
15807
|
+
});
|
|
15808
|
+
const doRequest = (fetchOpts) => fetchMethod(url, fetchOpts)
|
|
15809
|
+
.then(async (res) => {
|
|
15810
|
+
if (!res.ok) {
|
|
15811
|
+
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
15812
|
+
}
|
|
15813
|
+
return res.json();
|
|
15814
|
+
});
|
|
15815
|
+
const runWithOptions = (fetchOpts) => {
|
|
15816
|
+
if (!isBroadcast && retryOptions) {
|
|
15817
|
+
const operation = typeof retryOptions === 'object' ? retry.operation(retryOptions) : retry.operation();
|
|
15818
|
+
operation.attempt((currentAttempt) => {
|
|
15819
|
+
doRequest(fetchOpts)
|
|
15820
|
+
.then((result) => {
|
|
15821
|
+
if (result.error) {
|
|
15822
|
+
const error = new JsonRpcError(result.error.message || 'JSON-RPC error', result.error.code, result.error.data);
|
|
15823
|
+
callback(error, undefined, currentAttempt);
|
|
15824
|
+
}
|
|
15825
|
+
else {
|
|
15826
|
+
callback(null, result.result, currentAttempt);
|
|
15827
|
+
}
|
|
15828
|
+
}, (error) => {
|
|
15829
|
+
if (operation.retry(error)) {
|
|
15830
|
+
return;
|
|
15831
|
+
}
|
|
15832
|
+
callback(operation.mainError(), undefined, currentAttempt);
|
|
15833
|
+
});
|
|
15834
|
+
});
|
|
15835
|
+
}
|
|
15836
|
+
else {
|
|
15837
|
+
doRequest(fetchOpts)
|
|
15764
15838
|
.then((result) => {
|
|
15765
|
-
// Check for JSON-RPC errors
|
|
15766
15839
|
if (result.error) {
|
|
15767
15840
|
const error = new JsonRpcError(result.error.message || 'JSON-RPC error', result.error.code, result.error.data);
|
|
15768
|
-
callback(error, undefined,
|
|
15841
|
+
callback(error, undefined, 1);
|
|
15769
15842
|
}
|
|
15770
15843
|
else {
|
|
15771
|
-
callback(null, result.result,
|
|
15772
|
-
}
|
|
15773
|
-
}, (error) => {
|
|
15774
|
-
if (operation.retry(error)) {
|
|
15775
|
-
return;
|
|
15844
|
+
callback(null, result.result, 1);
|
|
15776
15845
|
}
|
|
15777
|
-
|
|
15778
|
-
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
method: 'POST',
|
|
15784
|
-
body: JSON.stringify({
|
|
15785
|
-
jsonrpc: '2.0',
|
|
15786
|
-
method: 'call',
|
|
15787
|
-
params,
|
|
15788
|
-
id
|
|
15789
|
-
}),
|
|
15790
|
-
headers: { 'Content-Type': 'application/json' }
|
|
15791
|
-
})
|
|
15792
|
-
.then(async (res) => {
|
|
15793
|
-
if (!res.ok) {
|
|
15794
|
-
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
15795
|
-
}
|
|
15796
|
-
return res.json();
|
|
15797
|
-
})
|
|
15798
|
-
.then((result) => {
|
|
15799
|
-
// Check for JSON-RPC errors
|
|
15800
|
-
if (result.error) {
|
|
15801
|
-
const error = new JsonRpcError(result.error.message || 'JSON-RPC error', result.error.code, result.error.data);
|
|
15802
|
-
callback(error, undefined, 1);
|
|
15803
|
-
}
|
|
15804
|
-
else {
|
|
15805
|
-
callback(null, result.result, 1);
|
|
15806
|
-
}
|
|
15807
|
-
}, (error) => callback(error instanceof Error ? error : new Error(String(error)), undefined, 1));
|
|
15808
|
-
}
|
|
15846
|
+
}, (error) => callback(error instanceof Error ? error : new Error(String(error)), undefined, 1));
|
|
15847
|
+
}
|
|
15848
|
+
};
|
|
15849
|
+
buildFetchOptions(body, this.options)
|
|
15850
|
+
.then(runWithOptions)
|
|
15851
|
+
.catch((err) => callback(err instanceof Error ? err : new Error(String(err)), undefined, 1));
|
|
15809
15852
|
}
|
|
15810
15853
|
}
|
|
15811
15854
|
|
|
@@ -22083,7 +22126,7 @@ if (typeof BigInt === "function") {
|
|
|
22083
22126
|
* Serialize a transaction to binary format for Steem blockchain
|
|
22084
22127
|
* This is a simplified implementation that handles the basic structure
|
|
22085
22128
|
*/
|
|
22086
|
-
function serializeTransaction
|
|
22129
|
+
function serializeTransaction(trx) {
|
|
22087
22130
|
const bb = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN);
|
|
22088
22131
|
const trxObj = trx;
|
|
22089
22132
|
// Write ref_block_num (uint16)
|
|
@@ -22113,7 +22156,7 @@ function serializeTransaction$1(trx) {
|
|
|
22113
22156
|
const operations = (Array.isArray(trxObj.operations) ? trxObj.operations : []);
|
|
22114
22157
|
bb.writeVarint32(operations.length);
|
|
22115
22158
|
for (const op of operations) {
|
|
22116
|
-
serializeOperation
|
|
22159
|
+
serializeOperation(bb, op);
|
|
22117
22160
|
}
|
|
22118
22161
|
// Write extensions (set of future_extensions, which is void/empty)
|
|
22119
22162
|
bb.writeVarint32(0); // Empty set
|
|
@@ -22142,7 +22185,7 @@ function serializeTransaction$1(trx) {
|
|
|
22142
22185
|
/**
|
|
22143
22186
|
* Serialize an operation to binary format
|
|
22144
22187
|
*/
|
|
22145
|
-
function serializeOperation
|
|
22188
|
+
function serializeOperation(bb, op) {
|
|
22146
22189
|
if (!Array.isArray(op) || op.length !== 2) {
|
|
22147
22190
|
throw new Error('Operation must be an array of [operation_type, operation_data]');
|
|
22148
22191
|
}
|
|
@@ -22174,9 +22217,45 @@ function getOperationTypeIndex(opType) {
|
|
|
22174
22217
|
'account_witness_proxy': 13,
|
|
22175
22218
|
'pow': 14,
|
|
22176
22219
|
'custom': 15,
|
|
22220
|
+
'report_over_production': 16,
|
|
22177
22221
|
'delete_comment': 17,
|
|
22178
22222
|
'custom_json': 18,
|
|
22179
22223
|
'comment_options': 19,
|
|
22224
|
+
'set_withdraw_vesting_route': 20,
|
|
22225
|
+
'limit_order_create2': 21,
|
|
22226
|
+
'claim_account': 22,
|
|
22227
|
+
'create_claimed_account': 23,
|
|
22228
|
+
'request_account_recovery': 24,
|
|
22229
|
+
'recover_account': 25,
|
|
22230
|
+
'change_recovery_account': 26,
|
|
22231
|
+
'escrow_transfer': 27,
|
|
22232
|
+
'escrow_dispute': 28,
|
|
22233
|
+
'escrow_release': 29,
|
|
22234
|
+
'pow2': 30,
|
|
22235
|
+
'escrow_approve': 31,
|
|
22236
|
+
'transfer_to_savings': 32,
|
|
22237
|
+
'transfer_from_savings': 33,
|
|
22238
|
+
'cancel_transfer_from_savings': 34,
|
|
22239
|
+
'custom_binary': 35,
|
|
22240
|
+
'decline_voting_rights': 36,
|
|
22241
|
+
'reset_account': 37,
|
|
22242
|
+
'set_reset_account': 38,
|
|
22243
|
+
'claim_reward_balance': 39,
|
|
22244
|
+
'delegate_vesting_shares': 40,
|
|
22245
|
+
'account_create_with_delegation': 41,
|
|
22246
|
+
'witness_set_properties': 42,
|
|
22247
|
+
'account_update2': 43,
|
|
22248
|
+
'create_proposal': 44,
|
|
22249
|
+
'update_proposal_votes': 45,
|
|
22250
|
+
'remove_proposal': 46,
|
|
22251
|
+
'claim_reward_balance2': 47,
|
|
22252
|
+
'fill_convert_request': 48,
|
|
22253
|
+
'comment_reward': 49,
|
|
22254
|
+
'liquidity_reward': 50,
|
|
22255
|
+
'interest': 51,
|
|
22256
|
+
'fill_vesting_withdraw': 52,
|
|
22257
|
+
'fill_order': 53,
|
|
22258
|
+
'fill_transfer_from_savings': 54,
|
|
22180
22259
|
};
|
|
22181
22260
|
const index = opMap[opType];
|
|
22182
22261
|
if (index === undefined) {
|
|
@@ -22201,6 +22280,135 @@ function serializeOperationData(bb, opType, opData) {
|
|
|
22201
22280
|
case 'account_create':
|
|
22202
22281
|
serializeAccountCreate(bb, opData);
|
|
22203
22282
|
break;
|
|
22283
|
+
case 'account_update':
|
|
22284
|
+
serializeAccountUpdate(bb, opData);
|
|
22285
|
+
break;
|
|
22286
|
+
case 'account_create_with_delegation':
|
|
22287
|
+
serializeAccountCreateWithDelegation(bb, opData);
|
|
22288
|
+
break;
|
|
22289
|
+
case 'create_claimed_account':
|
|
22290
|
+
serializeCreateClaimedAccount(bb, opData);
|
|
22291
|
+
break;
|
|
22292
|
+
case 'account_update2':
|
|
22293
|
+
serializeAccountUpdate2(bb, opData);
|
|
22294
|
+
break;
|
|
22295
|
+
case 'request_account_recovery':
|
|
22296
|
+
serializeRequestAccountRecovery(bb, opData);
|
|
22297
|
+
break;
|
|
22298
|
+
case 'recover_account':
|
|
22299
|
+
serializeRecoverAccount(bb, opData);
|
|
22300
|
+
break;
|
|
22301
|
+
case 'change_recovery_account':
|
|
22302
|
+
serializeChangeRecoveryAccount(bb, opData);
|
|
22303
|
+
break;
|
|
22304
|
+
case 'reset_account':
|
|
22305
|
+
serializeResetAccount(bb, opData);
|
|
22306
|
+
break;
|
|
22307
|
+
case 'set_reset_account':
|
|
22308
|
+
serializeSetResetAccount(bb, opData);
|
|
22309
|
+
break;
|
|
22310
|
+
case 'decline_voting_rights':
|
|
22311
|
+
serializeDeclineVotingRights(bb, opData);
|
|
22312
|
+
break;
|
|
22313
|
+
case 'transfer_to_vesting':
|
|
22314
|
+
serializeTransferToVesting(bb, opData);
|
|
22315
|
+
break;
|
|
22316
|
+
case 'withdraw_vesting':
|
|
22317
|
+
serializeWithdrawVesting(bb, opData);
|
|
22318
|
+
break;
|
|
22319
|
+
case 'set_withdraw_vesting_route':
|
|
22320
|
+
serializeSetWithdrawVestingRoute(bb, opData);
|
|
22321
|
+
break;
|
|
22322
|
+
case 'transfer_to_savings':
|
|
22323
|
+
serializeTransferToSavings(bb, opData);
|
|
22324
|
+
break;
|
|
22325
|
+
case 'transfer_from_savings':
|
|
22326
|
+
serializeTransferFromSavings(bb, opData);
|
|
22327
|
+
break;
|
|
22328
|
+
case 'cancel_transfer_from_savings':
|
|
22329
|
+
serializeCancelTransferFromSavings(bb, opData);
|
|
22330
|
+
break;
|
|
22331
|
+
case 'limit_order_create':
|
|
22332
|
+
serializeLimitOrderCreate(bb, opData);
|
|
22333
|
+
break;
|
|
22334
|
+
case 'limit_order_create2':
|
|
22335
|
+
serializeLimitOrderCreate2(bb, opData);
|
|
22336
|
+
break;
|
|
22337
|
+
case 'limit_order_cancel':
|
|
22338
|
+
serializeLimitOrderCancel(bb, opData);
|
|
22339
|
+
break;
|
|
22340
|
+
case 'feed_publish':
|
|
22341
|
+
serializeFeedPublish(bb, opData);
|
|
22342
|
+
break;
|
|
22343
|
+
case 'convert':
|
|
22344
|
+
serializeConvert(bb, opData);
|
|
22345
|
+
break;
|
|
22346
|
+
case 'fill_order':
|
|
22347
|
+
serializeFillOrder(bb, opData);
|
|
22348
|
+
break;
|
|
22349
|
+
case 'escrow_transfer':
|
|
22350
|
+
serializeEscrowTransfer(bb, opData);
|
|
22351
|
+
break;
|
|
22352
|
+
case 'escrow_dispute':
|
|
22353
|
+
serializeEscrowDispute(bb, opData);
|
|
22354
|
+
break;
|
|
22355
|
+
case 'escrow_release':
|
|
22356
|
+
serializeEscrowRelease(bb, opData);
|
|
22357
|
+
break;
|
|
22358
|
+
case 'escrow_approve':
|
|
22359
|
+
serializeEscrowApprove(bb, opData);
|
|
22360
|
+
break;
|
|
22361
|
+
case 'claim_reward_balance':
|
|
22362
|
+
serializeClaimRewardBalance(bb, opData);
|
|
22363
|
+
break;
|
|
22364
|
+
case 'claim_reward_balance2':
|
|
22365
|
+
serializeClaimRewardBalance2(bb, opData);
|
|
22366
|
+
break;
|
|
22367
|
+
case 'comment_reward':
|
|
22368
|
+
serializeCommentReward(bb, opData);
|
|
22369
|
+
break;
|
|
22370
|
+
case 'liquidity_reward':
|
|
22371
|
+
serializeLiquidityReward(bb, opData);
|
|
22372
|
+
break;
|
|
22373
|
+
case 'interest':
|
|
22374
|
+
serializeInterest(bb, opData);
|
|
22375
|
+
break;
|
|
22376
|
+
case 'fill_vesting_withdraw':
|
|
22377
|
+
serializeFillVestingWithdraw(bb, opData);
|
|
22378
|
+
break;
|
|
22379
|
+
case 'fill_convert_request':
|
|
22380
|
+
serializeFillConvertRequest(bb, opData);
|
|
22381
|
+
break;
|
|
22382
|
+
case 'fill_transfer_from_savings':
|
|
22383
|
+
serializeFillTransferFromSavings(bb, opData);
|
|
22384
|
+
break;
|
|
22385
|
+
case 'pow':
|
|
22386
|
+
serializePow(bb, opData);
|
|
22387
|
+
break;
|
|
22388
|
+
case 'pow2':
|
|
22389
|
+
serializePow2(bb, opData);
|
|
22390
|
+
break;
|
|
22391
|
+
case 'witness_update':
|
|
22392
|
+
serializeWitnessUpdate(bb, opData);
|
|
22393
|
+
break;
|
|
22394
|
+
case 'witness_set_properties':
|
|
22395
|
+
serializeWitnessSetProperties(bb, opData);
|
|
22396
|
+
break;
|
|
22397
|
+
case 'account_witness_vote':
|
|
22398
|
+
serializeAccountWitnessVote(bb, opData);
|
|
22399
|
+
break;
|
|
22400
|
+
case 'account_witness_proxy':
|
|
22401
|
+
serializeAccountWitnessProxy(bb, opData);
|
|
22402
|
+
break;
|
|
22403
|
+
case 'custom':
|
|
22404
|
+
serializeCustom(bb, opData);
|
|
22405
|
+
break;
|
|
22406
|
+
case 'custom_binary':
|
|
22407
|
+
serializeCustomBinary(bb, opData);
|
|
22408
|
+
break;
|
|
22409
|
+
case 'comment_options':
|
|
22410
|
+
serializeCommentOptions(bb, opData);
|
|
22411
|
+
break;
|
|
22204
22412
|
case 'custom_json':
|
|
22205
22413
|
serializeCustomJson(bb, opData);
|
|
22206
22414
|
break;
|
|
@@ -22271,143 +22479,843 @@ function serializeAccountCreate(bb, data) {
|
|
|
22271
22479
|
writeString(bb, String(dataObj.json_metadata || ''));
|
|
22272
22480
|
}
|
|
22273
22481
|
/**
|
|
22274
|
-
* Serialize
|
|
22482
|
+
* Serialize account_update operation.
|
|
22483
|
+
* Format: account, optional owner (1 byte + authority?), optional active, optional posting, memo_key, json_metadata.
|
|
22275
22484
|
*/
|
|
22276
|
-
function
|
|
22485
|
+
function serializeAccountUpdate(bb, data) {
|
|
22277
22486
|
const dataObj = data;
|
|
22278
|
-
|
|
22279
|
-
//
|
|
22280
|
-
|
|
22281
|
-
|
|
22282
|
-
: [];
|
|
22283
|
-
bb.writeVarint32(requiredAuths.length);
|
|
22284
|
-
for (const account of requiredAuths) {
|
|
22285
|
-
writeString(bb, String(account));
|
|
22487
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22488
|
+
// Optional authorities: 0 = not present, 1 = present then serialize authority
|
|
22489
|
+
if (dataObj.owner != null && dataObj.owner !== '') {
|
|
22490
|
+
bb.writeUint8(1);
|
|
22491
|
+
serializeAuthority(bb, typeof dataObj.owner === 'object' ? dataObj.owner : { weight_threshold: 1, account_auths: [], key_auths: [] });
|
|
22286
22492
|
}
|
|
22287
|
-
|
|
22288
|
-
|
|
22289
|
-
? dataObj.required_posting_auths.slice().sort()
|
|
22290
|
-
: [];
|
|
22291
|
-
bb.writeVarint32(requiredPostingAuths.length);
|
|
22292
|
-
for (const account of requiredPostingAuths) {
|
|
22293
|
-
writeString(bb, String(account));
|
|
22493
|
+
else {
|
|
22494
|
+
bb.writeUint8(0);
|
|
22294
22495
|
}
|
|
22295
|
-
|
|
22296
|
-
|
|
22297
|
-
|
|
22298
|
-
|
|
22496
|
+
if (dataObj.active != null && dataObj.active !== '') {
|
|
22497
|
+
bb.writeUint8(1);
|
|
22498
|
+
serializeAuthority(bb, typeof dataObj.active === 'object' ? dataObj.active : { weight_threshold: 1, account_auths: [], key_auths: [] });
|
|
22499
|
+
}
|
|
22500
|
+
else {
|
|
22501
|
+
bb.writeUint8(0);
|
|
22502
|
+
}
|
|
22503
|
+
if (dataObj.posting != null && dataObj.posting !== '') {
|
|
22504
|
+
bb.writeUint8(1);
|
|
22505
|
+
serializeAuthority(bb, typeof dataObj.posting === 'object' ? dataObj.posting : { weight_threshold: 1, account_auths: [], key_auths: [] });
|
|
22506
|
+
}
|
|
22507
|
+
else {
|
|
22508
|
+
bb.writeUint8(0);
|
|
22509
|
+
}
|
|
22510
|
+
// memo_key (public key, required)
|
|
22511
|
+
if (typeof dataObj.memo_key === 'string') {
|
|
22512
|
+
const pubKey = PublicKey.fromStringOrThrow(dataObj.memo_key);
|
|
22513
|
+
bb.append(pubKey.toBuffer());
|
|
22514
|
+
}
|
|
22515
|
+
else if (Buffer.isBuffer(dataObj.memo_key)) {
|
|
22516
|
+
bb.append(dataObj.memo_key);
|
|
22517
|
+
}
|
|
22518
|
+
else if (dataObj.memo_key && typeof dataObj.memo_key.toBuffer === 'function') {
|
|
22519
|
+
bb.append(dataObj.memo_key.toBuffer());
|
|
22520
|
+
}
|
|
22521
|
+
else {
|
|
22522
|
+
throw new Error('Invalid memo_key format');
|
|
22523
|
+
}
|
|
22524
|
+
writeString(bb, typeof dataObj.json_metadata === 'string'
|
|
22525
|
+
? dataObj.json_metadata
|
|
22526
|
+
: dataObj.json_metadata != null
|
|
22527
|
+
? JSON.stringify(dataObj.json_metadata)
|
|
22528
|
+
: '');
|
|
22299
22529
|
}
|
|
22300
22530
|
/**
|
|
22301
|
-
* Serialize
|
|
22531
|
+
* Serialize account_create_with_delegation operation.
|
|
22532
|
+
* Fields (see FC_REFLECT): fee, delegation, creator, new_account_name,
|
|
22533
|
+
* owner, active, posting, memo_key, json_metadata, extensions.
|
|
22302
22534
|
*/
|
|
22303
|
-
function
|
|
22304
|
-
const
|
|
22305
|
-
bb
|
|
22306
|
-
|
|
22307
|
-
|
|
22308
|
-
|
|
22309
|
-
|
|
22310
|
-
|
|
22311
|
-
|
|
22312
|
-
|
|
22313
|
-
|
|
22314
|
-
|
|
22315
|
-
bb
|
|
22316
|
-
|
|
22317
|
-
if (Array.isArray(authEntry) && authEntry.length >= 2) {
|
|
22318
|
-
writeString(bb, String(authEntry[0]));
|
|
22319
|
-
bb.writeUint16(authEntry[1]);
|
|
22320
|
-
}
|
|
22321
|
-
}
|
|
22322
|
-
// Key auths (map<public_key, uint16>)
|
|
22323
|
-
const keyAuths = (Array.isArray(authObj.key_auths) ? authObj.key_auths : []);
|
|
22324
|
-
// Maps in Steem serialization are sorted by key (public key string)
|
|
22325
|
-
// But serialized as bytes. Usually sorting by string representation of public key works.
|
|
22326
|
-
const keyAuthsArray = keyAuths;
|
|
22327
|
-
keyAuthsArray.sort((a, b) => {
|
|
22328
|
-
const aKey = Array.isArray(a) && a[0] ? String(a[0]) : '';
|
|
22329
|
-
const bKey = Array.isArray(b) && b[0] ? String(b[0]) : '';
|
|
22330
|
-
return aKey.localeCompare(bKey);
|
|
22331
|
-
});
|
|
22332
|
-
bb.writeVarint32(keyAuths.length);
|
|
22333
|
-
for (const keyAuth of keyAuths) {
|
|
22334
|
-
if (Array.isArray(keyAuth) && keyAuth.length >= 2) {
|
|
22335
|
-
const keyStr = String(keyAuth[0]);
|
|
22336
|
-
const weight = keyAuth[1];
|
|
22337
|
-
const pubKey = PublicKey.fromStringOrThrow(keyStr);
|
|
22338
|
-
bb.append(pubKey.toBuffer());
|
|
22339
|
-
bb.writeUint16(weight);
|
|
22340
|
-
}
|
|
22341
|
-
}
|
|
22535
|
+
function serializeAccountCreateWithDelegation(bb, data) {
|
|
22536
|
+
const dataObj = data;
|
|
22537
|
+
serializeAsset(bb, String(dataObj.fee || '0.000 STEEM'));
|
|
22538
|
+
serializeAsset(bb, String(dataObj.delegation || '0.000 VESTS'));
|
|
22539
|
+
writeString(bb, String(dataObj.creator || ''));
|
|
22540
|
+
writeString(bb, String(dataObj.new_account_name || ''));
|
|
22541
|
+
serializeAuthority(bb, dataObj.owner);
|
|
22542
|
+
serializeAuthority(bb, dataObj.active);
|
|
22543
|
+
serializeAuthority(bb, dataObj.posting);
|
|
22544
|
+
const memoKey = String(dataObj.memo_key || '');
|
|
22545
|
+
const pubKey = PublicKey.fromStringOrThrow(memoKey);
|
|
22546
|
+
bb.append(pubKey.toBuffer());
|
|
22547
|
+
writeString(bb, String(dataObj.json_metadata || ''));
|
|
22548
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22342
22549
|
}
|
|
22343
22550
|
/**
|
|
22344
|
-
* Serialize
|
|
22551
|
+
* Serialize create_claimed_account operation.
|
|
22552
|
+
* Fields: creator, new_account_name, owner, active, posting,
|
|
22553
|
+
* memo_key, json_metadata, extensions.
|
|
22345
22554
|
*/
|
|
22346
|
-
function
|
|
22347
|
-
const
|
|
22348
|
-
|
|
22349
|
-
|
|
22350
|
-
|
|
22351
|
-
|
|
22352
|
-
|
|
22353
|
-
|
|
22354
|
-
|
|
22355
|
-
bb.
|
|
22356
|
-
|
|
22357
|
-
bb.
|
|
22358
|
-
for (let i = symbolBytes.length; i < 7; i++) {
|
|
22359
|
-
bb.writeUint8(0);
|
|
22360
|
-
}
|
|
22555
|
+
function serializeCreateClaimedAccount(bb, data) {
|
|
22556
|
+
const dataObj = data;
|
|
22557
|
+
writeString(bb, String(dataObj.creator || ''));
|
|
22558
|
+
writeString(bb, String(dataObj.new_account_name || ''));
|
|
22559
|
+
serializeAuthority(bb, dataObj.owner);
|
|
22560
|
+
serializeAuthority(bb, dataObj.active);
|
|
22561
|
+
serializeAuthority(bb, dataObj.posting);
|
|
22562
|
+
const memoKey = String(dataObj.memo_key || '');
|
|
22563
|
+
const pubKey = PublicKey.fromStringOrThrow(memoKey);
|
|
22564
|
+
bb.append(pubKey.toBuffer());
|
|
22565
|
+
writeString(bb, String(dataObj.json_metadata || ''));
|
|
22566
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22361
22567
|
}
|
|
22362
22568
|
/**
|
|
22363
|
-
*
|
|
22569
|
+
* Serialize account_update2 operation.
|
|
22570
|
+
* Fields: account, owner, active, posting, memo_key,
|
|
22571
|
+
* json_metadata, posting_json_metadata, extensions.
|
|
22364
22572
|
*/
|
|
22365
|
-
function
|
|
22366
|
-
|
|
22573
|
+
function serializeAccountUpdate2(bb, data) {
|
|
22574
|
+
const dataObj = data;
|
|
22575
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22576
|
+
serializeAuthority(bb, dataObj.owner);
|
|
22577
|
+
serializeAuthority(bb, dataObj.active);
|
|
22578
|
+
serializeAuthority(bb, dataObj.posting);
|
|
22579
|
+
const memoKey = String(dataObj.memo_key || '');
|
|
22580
|
+
const pubKey = PublicKey.fromStringOrThrow(memoKey);
|
|
22581
|
+
bb.append(pubKey.toBuffer());
|
|
22582
|
+
writeString(bb, String(dataObj.json_metadata || ''));
|
|
22583
|
+
writeString(bb, String(dataObj.posting_json_metadata || ''));
|
|
22584
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22367
22585
|
}
|
|
22368
|
-
|
|
22369
|
-
|
|
22370
|
-
|
|
22371
|
-
|
|
22372
|
-
|
|
22373
|
-
|
|
22374
|
-
|
|
22375
|
-
|
|
22376
|
-
|
|
22377
|
-
|
|
22378
|
-
|
|
22379
|
-
|
|
22380
|
-
|
|
22381
|
-
|
|
22382
|
-
|
|
22383
|
-
|
|
22384
|
-
|
|
22385
|
-
|
|
22386
|
-
|
|
22387
|
-
|
|
22388
|
-
|
|
22389
|
-
|
|
22390
|
-
|
|
22391
|
-
|
|
22392
|
-
|
|
22393
|
-
|
|
22394
|
-
|
|
22395
|
-
|
|
22396
|
-
|
|
22397
|
-
|
|
22398
|
-
|
|
22399
|
-
|
|
22586
|
+
/**
|
|
22587
|
+
* Serialize request_account_recovery operation.
|
|
22588
|
+
* Fields: recovery_account, account_to_recover, new_owner_authority, extensions.
|
|
22589
|
+
*/
|
|
22590
|
+
function serializeRequestAccountRecovery(bb, data) {
|
|
22591
|
+
const dataObj = data;
|
|
22592
|
+
writeString(bb, String(dataObj.recovery_account || ''));
|
|
22593
|
+
writeString(bb, String(dataObj.account_to_recover || ''));
|
|
22594
|
+
serializeAuthority(bb, dataObj.new_owner_authority);
|
|
22595
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22596
|
+
}
|
|
22597
|
+
/**
|
|
22598
|
+
* Serialize recover_account operation.
|
|
22599
|
+
* Fields: account_to_recover, new_owner_authority, recent_owner_authority, extensions.
|
|
22600
|
+
*/
|
|
22601
|
+
function serializeRecoverAccount(bb, data) {
|
|
22602
|
+
const dataObj = data;
|
|
22603
|
+
writeString(bb, String(dataObj.account_to_recover || ''));
|
|
22604
|
+
serializeAuthority(bb, dataObj.new_owner_authority);
|
|
22605
|
+
serializeAuthority(bb, dataObj.recent_owner_authority);
|
|
22606
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22607
|
+
}
|
|
22608
|
+
/**
|
|
22609
|
+
* Serialize change_recovery_account operation.
|
|
22610
|
+
* Fields: account_to_recover, new_recovery_account, extensions.
|
|
22611
|
+
*/
|
|
22612
|
+
function serializeChangeRecoveryAccount(bb, data) {
|
|
22613
|
+
const dataObj = data;
|
|
22614
|
+
writeString(bb, String(dataObj.account_to_recover || ''));
|
|
22615
|
+
writeString(bb, String(dataObj.new_recovery_account || ''));
|
|
22616
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22617
|
+
}
|
|
22618
|
+
/**
|
|
22619
|
+
* Serialize reset_account operation.
|
|
22620
|
+
* Fields: reset_account, account_to_reset, new_owner_authority.
|
|
22621
|
+
*/
|
|
22622
|
+
function serializeResetAccount(bb, data) {
|
|
22623
|
+
const dataObj = data;
|
|
22624
|
+
writeString(bb, String(dataObj.reset_account || ''));
|
|
22625
|
+
writeString(bb, String(dataObj.account_to_reset || ''));
|
|
22626
|
+
serializeAuthority(bb, dataObj.new_owner_authority);
|
|
22627
|
+
}
|
|
22628
|
+
/**
|
|
22629
|
+
* Serialize set_reset_account operation.
|
|
22630
|
+
* Fields: account, reset_account.
|
|
22631
|
+
*/
|
|
22632
|
+
function serializeSetResetAccount(bb, data) {
|
|
22633
|
+
const dataObj = data;
|
|
22634
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22635
|
+
writeString(bb, String(dataObj.reset_account || ''));
|
|
22636
|
+
}
|
|
22637
|
+
/**
|
|
22638
|
+
* Serialize decline_voting_rights operation.
|
|
22639
|
+
* Fields: account, decline.
|
|
22640
|
+
*/
|
|
22641
|
+
function serializeDeclineVotingRights(bb, data) {
|
|
22642
|
+
const dataObj = data;
|
|
22643
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22644
|
+
serializeBool(bb, dataObj.decline);
|
|
22645
|
+
}
|
|
22646
|
+
/**
|
|
22647
|
+
* Serialize transfer_to_vesting operation.
|
|
22648
|
+
* Fields: from, to, amount.
|
|
22649
|
+
*/
|
|
22650
|
+
function serializeTransferToVesting(bb, data) {
|
|
22651
|
+
const dataObj = data;
|
|
22652
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22653
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22654
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
22655
|
+
}
|
|
22656
|
+
/**
|
|
22657
|
+
* Serialize withdraw_vesting operation.
|
|
22658
|
+
* Fields: account, vesting_shares.
|
|
22659
|
+
*/
|
|
22660
|
+
function serializeWithdrawVesting(bb, data) {
|
|
22661
|
+
const dataObj = data;
|
|
22662
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22663
|
+
serializeAsset(bb, String(dataObj.vesting_shares || '0.000 VESTS'));
|
|
22664
|
+
}
|
|
22665
|
+
/**
|
|
22666
|
+
* Serialize set_withdraw_vesting_route operation.
|
|
22667
|
+
* Fields: from_account, to_account, percent, auto_vest.
|
|
22668
|
+
*/
|
|
22669
|
+
function serializeSetWithdrawVestingRoute(bb, data) {
|
|
22670
|
+
const dataObj = data;
|
|
22671
|
+
writeString(bb, String(dataObj.from_account || ''));
|
|
22672
|
+
writeString(bb, String(dataObj.to_account || ''));
|
|
22673
|
+
// percent is uint16
|
|
22674
|
+
bb.writeUint16(dataObj.percent ?? 0);
|
|
22675
|
+
serializeBool(bb, dataObj.auto_vest);
|
|
22676
|
+
}
|
|
22677
|
+
/**
|
|
22678
|
+
* Serialize transfer_to_savings operation.
|
|
22679
|
+
* Fields: from, to, amount, memo.
|
|
22680
|
+
*/
|
|
22681
|
+
function serializeTransferToSavings(bb, data) {
|
|
22682
|
+
const dataObj = data;
|
|
22683
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22684
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22685
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
22686
|
+
writeString(bb, String(dataObj.memo || ''));
|
|
22687
|
+
}
|
|
22688
|
+
/**
|
|
22689
|
+
* Serialize transfer_from_savings operation.
|
|
22690
|
+
* Fields: from, request_id, to, amount, memo.
|
|
22691
|
+
*/
|
|
22692
|
+
function serializeTransferFromSavings(bb, data) {
|
|
22693
|
+
const dataObj = data;
|
|
22694
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22695
|
+
bb.writeUint32(dataObj.request_id ?? dataObj.requestID ?? 0);
|
|
22696
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22697
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
22698
|
+
writeString(bb, String(dataObj.memo || ''));
|
|
22699
|
+
}
|
|
22700
|
+
/**
|
|
22701
|
+
* Serialize cancel_transfer_from_savings operation.
|
|
22702
|
+
* Fields: from, request_id.
|
|
22703
|
+
*/
|
|
22704
|
+
function serializeCancelTransferFromSavings(bb, data) {
|
|
22705
|
+
const dataObj = data;
|
|
22706
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22707
|
+
bb.writeUint32(dataObj.request_id ?? dataObj.requestID ?? 0);
|
|
22708
|
+
}
|
|
22709
|
+
/**
|
|
22710
|
+
* Serialize limit_order_create operation.
|
|
22711
|
+
* Fields: owner, orderid, amount_to_sell, min_to_receive, fill_or_kill, expiration.
|
|
22712
|
+
*/
|
|
22713
|
+
function serializeLimitOrderCreate(bb, data) {
|
|
22714
|
+
const dataObj = data;
|
|
22715
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22716
|
+
bb.writeUint32(dataObj.orderid ?? 0);
|
|
22717
|
+
serializeAsset(bb, String(dataObj.amount_to_sell || '0.000 STEEM'));
|
|
22718
|
+
serializeAsset(bb, String(dataObj.min_to_receive || '0.000 STEEM'));
|
|
22719
|
+
serializeBool(bb, dataObj.fill_or_kill);
|
|
22720
|
+
serializeTimePointSec(bb, dataObj.expiration);
|
|
22721
|
+
}
|
|
22722
|
+
/**
|
|
22723
|
+
* Serialize limit_order_create2 operation.
|
|
22724
|
+
* Fields: owner, orderid, amount_to_sell, exchange_rate{base, quote}, fill_or_kill, expiration.
|
|
22725
|
+
*/
|
|
22726
|
+
function serializeLimitOrderCreate2(bb, data) {
|
|
22727
|
+
const dataObj = data;
|
|
22728
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22729
|
+
bb.writeUint32(dataObj.orderid ?? 0);
|
|
22730
|
+
serializeAsset(bb, String(dataObj.amount_to_sell || '0.000 STEEM'));
|
|
22731
|
+
const rate = (dataObj.exchange_rate ?? dataObj.exchangeRate);
|
|
22732
|
+
const base = rate?.base ?? '0.000 STEEM';
|
|
22733
|
+
const quote = rate?.quote ?? '0.000 SBD';
|
|
22734
|
+
serializeAsset(bb, String(base));
|
|
22735
|
+
serializeAsset(bb, String(quote));
|
|
22736
|
+
serializeBool(bb, dataObj.fill_or_kill);
|
|
22737
|
+
serializeTimePointSec(bb, dataObj.expiration);
|
|
22738
|
+
}
|
|
22739
|
+
/**
|
|
22740
|
+
* Serialize limit_order_cancel operation.
|
|
22741
|
+
* Fields: owner, orderid.
|
|
22742
|
+
*/
|
|
22743
|
+
function serializeLimitOrderCancel(bb, data) {
|
|
22744
|
+
const dataObj = data;
|
|
22745
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22746
|
+
bb.writeUint32(dataObj.orderid ?? 0);
|
|
22747
|
+
}
|
|
22748
|
+
/**
|
|
22749
|
+
* Serialize feed_publish operation.
|
|
22750
|
+
* Fields: publisher, exchange_rate{base, quote}.
|
|
22751
|
+
*/
|
|
22752
|
+
function serializeFeedPublish(bb, data) {
|
|
22753
|
+
const dataObj = data;
|
|
22754
|
+
writeString(bb, String(dataObj.publisher || ''));
|
|
22755
|
+
const rate = (dataObj.exchange_rate ?? dataObj.exchangeRate);
|
|
22756
|
+
const base = rate?.base ?? '0.000 STEEM';
|
|
22757
|
+
const quote = rate?.quote ?? '0.000 SBD';
|
|
22758
|
+
serializeAsset(bb, String(base));
|
|
22759
|
+
serializeAsset(bb, String(quote));
|
|
22760
|
+
}
|
|
22761
|
+
/**
|
|
22762
|
+
* Serialize convert operation.
|
|
22763
|
+
* Fields: owner, requestid, amount.
|
|
22764
|
+
*/
|
|
22765
|
+
function serializeConvert(bb, data) {
|
|
22766
|
+
const dataObj = data;
|
|
22767
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22768
|
+
bb.writeUint32(dataObj.requestid ?? dataObj.request_id ?? 0);
|
|
22769
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
22770
|
+
}
|
|
22771
|
+
/**
|
|
22772
|
+
* Serialize fill_order operation (virtual).
|
|
22773
|
+
* Fields: current_owner, current_orderid, current_pays,
|
|
22774
|
+
* open_owner, open_orderid, open_pays.
|
|
22775
|
+
*/
|
|
22776
|
+
function serializeFillOrder(bb, data) {
|
|
22777
|
+
const dataObj = data;
|
|
22778
|
+
writeString(bb, String(dataObj.current_owner || ''));
|
|
22779
|
+
bb.writeUint32(dataObj.current_orderid ?? 0);
|
|
22780
|
+
serializeAsset(bb, String(dataObj.current_pays || '0.000 STEEM'));
|
|
22781
|
+
writeString(bb, String(dataObj.open_owner || ''));
|
|
22782
|
+
bb.writeUint32(dataObj.open_orderid ?? 0);
|
|
22783
|
+
serializeAsset(bb, String(dataObj.open_pays || '0.000 STEEM'));
|
|
22784
|
+
}
|
|
22785
|
+
/**
|
|
22786
|
+
* Serialize escrow_transfer operation.
|
|
22787
|
+
* Fields: from, to, sbd_amount, steem_amount, escrow_id, agent,
|
|
22788
|
+
* fee, json_meta, ratification_deadline, escrow_expiration.
|
|
22789
|
+
*/
|
|
22790
|
+
function serializeEscrowTransfer(bb, data) {
|
|
22791
|
+
const dataObj = data;
|
|
22792
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22793
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22794
|
+
serializeAsset(bb, String(dataObj.sbd_amount || '0.000 SBD'));
|
|
22795
|
+
serializeAsset(bb, String(dataObj.steem_amount || '0.000 STEEM'));
|
|
22796
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
22797
|
+
writeString(bb, String(dataObj.agent || ''));
|
|
22798
|
+
serializeAsset(bb, String(dataObj.fee || '0.000 STEEM'));
|
|
22799
|
+
writeString(bb, String(dataObj.json_meta || ''));
|
|
22800
|
+
serializeTimePointSec(bb, dataObj.ratification_deadline);
|
|
22801
|
+
serializeTimePointSec(bb, dataObj.escrow_expiration);
|
|
22802
|
+
}
|
|
22803
|
+
/**
|
|
22804
|
+
* Serialize escrow_dispute operation.
|
|
22805
|
+
* Fields: from, to, who, escrow_id.
|
|
22806
|
+
*/
|
|
22807
|
+
function serializeEscrowDispute(bb, data) {
|
|
22808
|
+
const dataObj = data;
|
|
22809
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22810
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22811
|
+
writeString(bb, String(dataObj.who || ''));
|
|
22812
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
22813
|
+
}
|
|
22814
|
+
/**
|
|
22815
|
+
* Serialize escrow_release operation.
|
|
22816
|
+
* Fields: from, to, who, escrow_id, sbd_amount, steem_amount.
|
|
22817
|
+
*/
|
|
22818
|
+
function serializeEscrowRelease(bb, data) {
|
|
22819
|
+
const dataObj = data;
|
|
22820
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22821
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22822
|
+
writeString(bb, String(dataObj.who || ''));
|
|
22823
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
22824
|
+
serializeAsset(bb, String(dataObj.sbd_amount || '0.000 SBD'));
|
|
22825
|
+
serializeAsset(bb, String(dataObj.steem_amount || '0.000 STEEM'));
|
|
22826
|
+
}
|
|
22827
|
+
/**
|
|
22828
|
+
* Serialize escrow_approve operation.
|
|
22829
|
+
* Fields: from, to, agent, who, escrow_id, approve.
|
|
22830
|
+
*/
|
|
22831
|
+
function serializeEscrowApprove(bb, data) {
|
|
22832
|
+
const dataObj = data;
|
|
22833
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22834
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22835
|
+
writeString(bb, String(dataObj.agent || ''));
|
|
22836
|
+
writeString(bb, String(dataObj.who || ''));
|
|
22837
|
+
bb.writeUint32(dataObj.escrow_id ?? 0);
|
|
22838
|
+
serializeBool(bb, dataObj.approve);
|
|
22839
|
+
}
|
|
22840
|
+
/**
|
|
22841
|
+
* Serialize claim_reward_balance operation.
|
|
22842
|
+
* Fields: account, reward_steem, reward_sbd, reward_vests.
|
|
22843
|
+
*/
|
|
22844
|
+
function serializeClaimRewardBalance(bb, data) {
|
|
22845
|
+
const dataObj = data;
|
|
22846
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22847
|
+
serializeAsset(bb, String(dataObj.reward_steem || '0.000 STEEM'));
|
|
22848
|
+
serializeAsset(bb, String(dataObj.reward_sbd || '0.000 SBD'));
|
|
22849
|
+
serializeAsset(bb, String(dataObj.reward_vests || '0.000000 VESTS'));
|
|
22850
|
+
}
|
|
22851
|
+
/**
|
|
22852
|
+
* Serialize claim_reward_balance2 operation.
|
|
22853
|
+
* Fields: account, extensions, reward_tokens (array of asset strings).
|
|
22854
|
+
*/
|
|
22855
|
+
function serializeClaimRewardBalance2(bb, data) {
|
|
22856
|
+
const dataObj = data;
|
|
22857
|
+
writeString(bb, String(dataObj.account || ''));
|
|
22858
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
22859
|
+
const tokens = Array.isArray(dataObj.reward_tokens) ? dataObj.reward_tokens : [];
|
|
22860
|
+
bb.writeVarint32(tokens.length);
|
|
22861
|
+
for (const tok of tokens) {
|
|
22862
|
+
serializeAsset(bb, typeof tok === 'string' ? tok : String(tok));
|
|
22863
|
+
}
|
|
22864
|
+
}
|
|
22865
|
+
/**
|
|
22866
|
+
* Serialize comment_reward operation.
|
|
22867
|
+
* Fields: author, permlink, payout.
|
|
22868
|
+
*/
|
|
22869
|
+
function serializeCommentReward(bb, data) {
|
|
22870
|
+
const dataObj = data;
|
|
22871
|
+
writeString(bb, String(dataObj.author || ''));
|
|
22872
|
+
writeString(bb, String(dataObj.permlink || ''));
|
|
22873
|
+
serializeAsset(bb, String(dataObj.payout || '0.000 STEEM'));
|
|
22874
|
+
}
|
|
22875
|
+
/**
|
|
22876
|
+
* Serialize liquidity_reward operation.
|
|
22877
|
+
* Fields: owner, payout.
|
|
22878
|
+
*/
|
|
22879
|
+
function serializeLiquidityReward(bb, data) {
|
|
22880
|
+
const dataObj = data;
|
|
22881
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22882
|
+
serializeAsset(bb, String(dataObj.payout || '0.000 STEEM'));
|
|
22883
|
+
}
|
|
22884
|
+
/**
|
|
22885
|
+
* Serialize interest operation.
|
|
22886
|
+
* Fields: owner, interest.
|
|
22887
|
+
*/
|
|
22888
|
+
function serializeInterest(bb, data) {
|
|
22889
|
+
const dataObj = data;
|
|
22890
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22891
|
+
serializeAsset(bb, String(dataObj.interest || '0.000 STEEM'));
|
|
22892
|
+
}
|
|
22893
|
+
/**
|
|
22894
|
+
* Serialize fill_vesting_withdraw operation.
|
|
22895
|
+
* Fields: from_account, to_account, withdrawn, deposited.
|
|
22896
|
+
*/
|
|
22897
|
+
function serializeFillVestingWithdraw(bb, data) {
|
|
22898
|
+
const dataObj = data;
|
|
22899
|
+
writeString(bb, String(dataObj.from_account || ''));
|
|
22900
|
+
writeString(bb, String(dataObj.to_account || ''));
|
|
22901
|
+
serializeAsset(bb, String(dataObj.withdrawn || '0.000000 VESTS'));
|
|
22902
|
+
serializeAsset(bb, String(dataObj.deposited || '0.000 STEEM'));
|
|
22903
|
+
}
|
|
22904
|
+
/**
|
|
22905
|
+
* Serialize fill_convert_request operation.
|
|
22906
|
+
* Fields: owner, requestid, amount_in, amount_out.
|
|
22907
|
+
*/
|
|
22908
|
+
function serializeFillConvertRequest(bb, data) {
|
|
22909
|
+
const dataObj = data;
|
|
22910
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
22911
|
+
bb.writeUint32(dataObj.requestid ?? 0);
|
|
22912
|
+
serializeAsset(bb, String(dataObj.amount_in || '0.000 STEEM'));
|
|
22913
|
+
serializeAsset(bb, String(dataObj.amount_out || '0.000 STEEM'));
|
|
22914
|
+
}
|
|
22915
|
+
/**
|
|
22916
|
+
* Serialize fill_transfer_from_savings operation.
|
|
22917
|
+
* Fields: from, to, amount, request_id, memo.
|
|
22918
|
+
*/
|
|
22919
|
+
function serializeFillTransferFromSavings(bb, data) {
|
|
22920
|
+
const dataObj = data;
|
|
22921
|
+
writeString(bb, String(dataObj.from || ''));
|
|
22922
|
+
writeString(bb, String(dataObj.to || ''));
|
|
22923
|
+
serializeAsset(bb, String(dataObj.amount || '0.000 STEEM'));
|
|
22924
|
+
bb.writeUint32(dataObj.request_id ?? 0);
|
|
22925
|
+
writeString(bb, String(dataObj.memo || ''));
|
|
22926
|
+
}
|
|
22927
|
+
/**
|
|
22928
|
+
* Serialize ChainProperties (used in pow, witness_update).
|
|
22929
|
+
* Fields: account_creation_fee (asset string), maximum_block_size (uint32), sbd_interest_rate (uint16).
|
|
22930
|
+
*/
|
|
22931
|
+
function serializeChainProperties(bb, props) {
|
|
22932
|
+
const p = props || {};
|
|
22933
|
+
const fee = p.account_creation_fee;
|
|
22934
|
+
if (typeof fee === 'string' && fee.split(' ').length >= 2) {
|
|
22935
|
+
serializeAsset(bb, fee);
|
|
22936
|
+
}
|
|
22937
|
+
else {
|
|
22938
|
+
serializeAsset(bb, '0.000 STEEM');
|
|
22939
|
+
}
|
|
22940
|
+
bb.writeUint32(p.maximum_block_size ?? 0);
|
|
22941
|
+
bb.writeUint16(p.sbd_interest_rate ?? 0);
|
|
22942
|
+
}
|
|
22943
|
+
/**
|
|
22944
|
+
* Serialize POW inner struct (worker, input, signature, work).
|
|
22945
|
+
*/
|
|
22946
|
+
function serializePOWInner(bb, work) {
|
|
22947
|
+
const w = work || {};
|
|
22948
|
+
writeString(bb, String(w.worker || ''));
|
|
22949
|
+
writeString(bb, String(w.input || ''));
|
|
22950
|
+
writeString(bb, String(w.signature || ''));
|
|
22951
|
+
writeString(bb, String(w.work || ''));
|
|
22952
|
+
}
|
|
22953
|
+
/**
|
|
22954
|
+
* Serialize pow operation.
|
|
22955
|
+
* Fields: worker_account, block_id, nonce (optional), work (POW), props (ChainProperties).
|
|
22956
|
+
*/
|
|
22957
|
+
function serializePow(bb, data) {
|
|
22958
|
+
const dataObj = data;
|
|
22959
|
+
writeString(bb, String(dataObj.worker_account || ''));
|
|
22960
|
+
writeString(bb, String(dataObj.block_id || ''));
|
|
22961
|
+
const nonce = dataObj.nonce;
|
|
22962
|
+
if (nonce !== undefined && nonce !== null) {
|
|
22963
|
+
bb.writeUint8(1);
|
|
22964
|
+
bb.writeUint64(Number(nonce));
|
|
22965
|
+
}
|
|
22966
|
+
else {
|
|
22967
|
+
bb.writeUint8(0);
|
|
22968
|
+
}
|
|
22969
|
+
serializePOWInner(bb, dataObj.work);
|
|
22970
|
+
serializeChainProperties(bb, dataObj.props);
|
|
22971
|
+
}
|
|
22972
|
+
/**
|
|
22973
|
+
* Serialize pow2 operation.
|
|
22974
|
+
* Fields: input, pow_summary (opaque bytes; if string treated as hex).
|
|
22975
|
+
*/
|
|
22976
|
+
function serializePow2(bb, data) {
|
|
22977
|
+
const dataObj = data;
|
|
22978
|
+
writeString(bb, String(dataObj.input || ''));
|
|
22979
|
+
const summary = dataObj.pow_summary;
|
|
22980
|
+
let bytes;
|
|
22981
|
+
if (typeof summary === 'string') {
|
|
22982
|
+
const hex = summary.startsWith('0x') ? summary.slice(2) : summary;
|
|
22983
|
+
bytes = Buffer.from(hex, 'hex');
|
|
22984
|
+
}
|
|
22985
|
+
else if (Buffer.isBuffer(summary)) {
|
|
22986
|
+
bytes = summary;
|
|
22987
|
+
}
|
|
22988
|
+
else {
|
|
22989
|
+
bytes = Buffer.alloc(0);
|
|
22990
|
+
}
|
|
22991
|
+
bb.writeVarint32(bytes.length);
|
|
22992
|
+
bb.append(bytes);
|
|
22993
|
+
}
|
|
22994
|
+
/**
|
|
22995
|
+
* Serialize witness_update operation.
|
|
22996
|
+
* Fields: owner, url, block_signing_key, props (ChainProperties), fee.
|
|
22997
|
+
*/
|
|
22998
|
+
function serializeWitnessUpdate(bb, data) {
|
|
22999
|
+
const dataObj = data;
|
|
23000
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
23001
|
+
writeString(bb, String(dataObj.url || ''));
|
|
23002
|
+
const key = dataObj.block_signing_key;
|
|
23003
|
+
if (typeof key === 'string') {
|
|
23004
|
+
const pubKey = PublicKey.fromStringOrThrow(key);
|
|
23005
|
+
bb.append(pubKey.toBuffer());
|
|
23006
|
+
}
|
|
23007
|
+
else if (Buffer.isBuffer(key)) {
|
|
23008
|
+
bb.append(key);
|
|
23009
|
+
}
|
|
23010
|
+
else if (key && typeof key.toBuffer === 'function') {
|
|
23011
|
+
bb.append(key.toBuffer());
|
|
23012
|
+
}
|
|
23013
|
+
else {
|
|
23014
|
+
bb.append(Buffer.alloc(33));
|
|
23015
|
+
}
|
|
23016
|
+
serializeChainProperties(bb, dataObj.props);
|
|
23017
|
+
serializeAsset(bb, String(dataObj.fee || '0.000 STEEM'));
|
|
23018
|
+
}
|
|
23019
|
+
/**
|
|
23020
|
+
* Serialize witness_set_properties operation.
|
|
23021
|
+
* Fields: owner, props (map string -> bytes), extensions.
|
|
23022
|
+
*/
|
|
23023
|
+
function serializeWitnessSetProperties(bb, data) {
|
|
23024
|
+
const dataObj = data;
|
|
23025
|
+
writeString(bb, String(dataObj.owner || ''));
|
|
23026
|
+
const props = dataObj.props;
|
|
23027
|
+
const keys = props ? Object.keys(props).sort() : [];
|
|
23028
|
+
bb.writeVarint32(keys.length);
|
|
23029
|
+
for (const k of keys) {
|
|
23030
|
+
writeString(bb, k);
|
|
23031
|
+
const v = props[k];
|
|
23032
|
+
const buf = typeof v === 'string' ? Buffer.from(v, 'utf8') : Buffer.isBuffer(v) ? v : Buffer.alloc(0);
|
|
23033
|
+
bb.writeVarint32(buf.length);
|
|
23034
|
+
bb.append(buf);
|
|
23035
|
+
}
|
|
23036
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
23037
|
+
}
|
|
23038
|
+
/**
|
|
23039
|
+
* Serialize account_witness_vote operation.
|
|
23040
|
+
* Fields: account, witness, approve.
|
|
23041
|
+
*/
|
|
23042
|
+
function serializeAccountWitnessVote(bb, data) {
|
|
23043
|
+
const dataObj = data;
|
|
23044
|
+
writeString(bb, String(dataObj.account || ''));
|
|
23045
|
+
writeString(bb, String(dataObj.witness || ''));
|
|
23046
|
+
serializeBool(bb, dataObj.approve);
|
|
23047
|
+
}
|
|
23048
|
+
/**
|
|
23049
|
+
* Serialize account_witness_proxy operation.
|
|
23050
|
+
* Fields: account, proxy.
|
|
23051
|
+
*/
|
|
23052
|
+
function serializeAccountWitnessProxy(bb, data) {
|
|
23053
|
+
const dataObj = data;
|
|
23054
|
+
writeString(bb, String(dataObj.account || ''));
|
|
23055
|
+
writeString(bb, String(dataObj.proxy || ''));
|
|
23056
|
+
}
|
|
23057
|
+
/**
|
|
23058
|
+
* Serialize custom operation (required_auths, id, data).
|
|
23059
|
+
* id is uint16 in protocol; data is bytes.
|
|
23060
|
+
*/
|
|
23061
|
+
function serializeCustom(bb, data) {
|
|
23062
|
+
const dataObj = data;
|
|
23063
|
+
const requiredAuths = Array.isArray(dataObj.required_auths)
|
|
23064
|
+
? dataObj.required_auths.slice().sort()
|
|
23065
|
+
: [];
|
|
23066
|
+
bb.writeVarint32(requiredAuths.length);
|
|
23067
|
+
for (const account of requiredAuths) {
|
|
23068
|
+
writeString(bb, String(account));
|
|
23069
|
+
}
|
|
23070
|
+
bb.writeUint16(dataObj.id ?? 0);
|
|
23071
|
+
const dataBytes = dataObj.data;
|
|
23072
|
+
let buf;
|
|
23073
|
+
if (typeof dataBytes === 'string') {
|
|
23074
|
+
const hex = dataBytes.startsWith('0x') ? dataBytes.slice(2) : dataBytes;
|
|
23075
|
+
buf = Buffer.from(hex, 'hex');
|
|
23076
|
+
}
|
|
23077
|
+
else if (Buffer.isBuffer(dataBytes)) {
|
|
23078
|
+
buf = dataBytes;
|
|
23079
|
+
}
|
|
23080
|
+
else {
|
|
23081
|
+
buf = Buffer.alloc(0);
|
|
23082
|
+
}
|
|
23083
|
+
bb.writeVarint32(buf.length);
|
|
23084
|
+
bb.append(buf);
|
|
23085
|
+
}
|
|
23086
|
+
/**
|
|
23087
|
+
* Serialize custom_binary operation.
|
|
23088
|
+
* Fields: id (string), data (bytes).
|
|
23089
|
+
*/
|
|
23090
|
+
function serializeCustomBinary(bb, data) {
|
|
23091
|
+
const dataObj = data;
|
|
23092
|
+
writeString(bb, String(dataObj.id || ''));
|
|
23093
|
+
const dataBytes = dataObj.data;
|
|
23094
|
+
let buf;
|
|
23095
|
+
if (typeof dataBytes === 'string') {
|
|
23096
|
+
const hex = dataBytes.startsWith('0x') ? dataBytes.slice(2) : dataBytes;
|
|
23097
|
+
buf = Buffer.from(hex, 'hex');
|
|
23098
|
+
}
|
|
23099
|
+
else if (Buffer.isBuffer(dataBytes)) {
|
|
23100
|
+
buf = dataBytes;
|
|
23101
|
+
}
|
|
23102
|
+
else {
|
|
23103
|
+
buf = Buffer.alloc(0);
|
|
23104
|
+
}
|
|
23105
|
+
bb.writeVarint32(buf.length);
|
|
23106
|
+
bb.append(buf);
|
|
23107
|
+
}
|
|
23108
|
+
/**
|
|
23109
|
+
* Serialize comment_options operation.
|
|
23110
|
+
* Fields: author, permlink, max_accepted_payout, percent_steem_dollars, allow_votes, allow_curation_rewards, extensions.
|
|
23111
|
+
*/
|
|
23112
|
+
function serializeCommentOptions(bb, data) {
|
|
23113
|
+
const dataObj = data;
|
|
23114
|
+
writeString(bb, String(dataObj.author || ''));
|
|
23115
|
+
writeString(bb, String(dataObj.permlink || ''));
|
|
23116
|
+
serializeAsset(bb, String(dataObj.max_accepted_payout || '1000000.000 SBD'));
|
|
23117
|
+
bb.writeUint16(dataObj.percent_steem_dollars ?? 0);
|
|
23118
|
+
serializeBool(bb, dataObj.allow_votes);
|
|
23119
|
+
serializeBool(bb, dataObj.allow_curation_rewards);
|
|
23120
|
+
serializeExtensions(bb, dataObj.extensions);
|
|
23121
|
+
}
|
|
23122
|
+
/**
|
|
23123
|
+
* Serialize custom_json operation
|
|
23124
|
+
*/
|
|
23125
|
+
function serializeCustomJson(bb, data) {
|
|
23126
|
+
const dataObj = data;
|
|
23127
|
+
// Serialize required_auths (flat_set<account_name_type>)
|
|
23128
|
+
// Set serialization: varint32 length, then each element
|
|
23129
|
+
const requiredAuths = Array.isArray(dataObj.required_auths)
|
|
23130
|
+
? dataObj.required_auths.slice().sort()
|
|
23131
|
+
: [];
|
|
23132
|
+
bb.writeVarint32(requiredAuths.length);
|
|
23133
|
+
for (const account of requiredAuths) {
|
|
23134
|
+
writeString(bb, String(account));
|
|
23135
|
+
}
|
|
23136
|
+
// Serialize required_posting_auths (flat_set<account_name_type>)
|
|
23137
|
+
const requiredPostingAuths = Array.isArray(dataObj.required_posting_auths)
|
|
23138
|
+
? dataObj.required_posting_auths.slice().sort()
|
|
23139
|
+
: [];
|
|
23140
|
+
bb.writeVarint32(requiredPostingAuths.length);
|
|
23141
|
+
for (const account of requiredPostingAuths) {
|
|
23142
|
+
writeString(bb, String(account));
|
|
23143
|
+
}
|
|
23144
|
+
// Serialize id (string)
|
|
23145
|
+
writeString(bb, String(dataObj.id || ''));
|
|
23146
|
+
// Serialize json (string)
|
|
23147
|
+
writeString(bb, String(dataObj.json || '{}'));
|
|
23148
|
+
}
|
|
23149
|
+
/**
|
|
23150
|
+
* Serialize Authority
|
|
23151
|
+
*/
|
|
23152
|
+
function serializeAuthority(bb, auth) {
|
|
23153
|
+
const authObj = auth;
|
|
23154
|
+
bb.writeUint32(authObj.weight_threshold || 1);
|
|
23155
|
+
// Account auths (map<string, uint16>)
|
|
23156
|
+
const accountAuths = (Array.isArray(authObj.account_auths) ? authObj.account_auths : []);
|
|
23157
|
+
// Maps in Steem serialization are sorted by key
|
|
23158
|
+
const accountAuthsArray = accountAuths;
|
|
23159
|
+
accountAuthsArray.sort((a, b) => {
|
|
23160
|
+
const aKey = Array.isArray(a) && a[0] ? String(a[0]) : '';
|
|
23161
|
+
const bKey = Array.isArray(b) && b[0] ? String(b[0]) : '';
|
|
23162
|
+
return aKey.localeCompare(bKey);
|
|
23163
|
+
});
|
|
23164
|
+
bb.writeVarint32(accountAuths.length);
|
|
23165
|
+
for (const authEntry of accountAuths) {
|
|
23166
|
+
if (Array.isArray(authEntry) && authEntry.length >= 2) {
|
|
23167
|
+
writeString(bb, String(authEntry[0]));
|
|
23168
|
+
bb.writeUint16(authEntry[1]);
|
|
23169
|
+
}
|
|
23170
|
+
}
|
|
23171
|
+
// Key auths (map<public_key, uint16>)
|
|
23172
|
+
const keyAuths = (Array.isArray(authObj.key_auths) ? authObj.key_auths : []);
|
|
23173
|
+
// Maps in Steem serialization are sorted by key (public key string)
|
|
23174
|
+
// But serialized as bytes. Usually sorting by string representation of public key works.
|
|
23175
|
+
const keyAuthsArray = keyAuths;
|
|
23176
|
+
keyAuthsArray.sort((a, b) => {
|
|
23177
|
+
const aKey = Array.isArray(a) && a[0] ? String(a[0]) : '';
|
|
23178
|
+
const bKey = Array.isArray(b) && b[0] ? String(b[0]) : '';
|
|
23179
|
+
return aKey.localeCompare(bKey);
|
|
23180
|
+
});
|
|
23181
|
+
bb.writeVarint32(keyAuths.length);
|
|
23182
|
+
for (const keyAuth of keyAuths) {
|
|
23183
|
+
if (Array.isArray(keyAuth) && keyAuth.length >= 2) {
|
|
23184
|
+
const keyStr = String(keyAuth[0]);
|
|
23185
|
+
const weight = keyAuth[1];
|
|
23186
|
+
const pubKey = PublicKey.fromStringOrThrow(keyStr);
|
|
23187
|
+
bb.append(pubKey.toBuffer());
|
|
23188
|
+
bb.writeUint16(weight);
|
|
23189
|
+
}
|
|
23190
|
+
}
|
|
23191
|
+
}
|
|
23192
|
+
/**
|
|
23193
|
+
* Serialize asset (STEEM/SBD/VESTS style string) to binary.
|
|
23194
|
+
*
|
|
23195
|
+
* Format: int64 amount (little-endian) + uint8 precision + 7-byte symbol (UTF-8, null-padded).
|
|
23196
|
+
*
|
|
23197
|
+
* This helper is reused across all operations中涉及资产字段的地方,例如:
|
|
23198
|
+
* - amount / vesting_shares / reward_* / *_pays
|
|
23199
|
+
*/
|
|
23200
|
+
function serializeAsset(bb, amount) {
|
|
23201
|
+
const parts = amount.split(' ');
|
|
23202
|
+
const valueStr = parts[0] || '0.000';
|
|
23203
|
+
const symbol = parts[1] || 'STEEM';
|
|
23204
|
+
const [intPart, decPart = ''] = valueStr.split('.');
|
|
23205
|
+
const precision = decPart.length;
|
|
23206
|
+
const amountValue = parseInt(intPart + decPart.padEnd(precision, '0'), 10) || 0;
|
|
23207
|
+
bb.writeInt64(amountValue);
|
|
23208
|
+
bb.writeUint8(precision);
|
|
23209
|
+
const symbolBytes = Buffer.from(symbol, 'utf8');
|
|
23210
|
+
bb.append(symbolBytes);
|
|
23211
|
+
for (let i = symbolBytes.length; i < 7; i++) {
|
|
23212
|
+
bb.writeUint8(0);
|
|
23213
|
+
}
|
|
23214
|
+
}
|
|
23215
|
+
/**
|
|
23216
|
+
* Write a string using ByteBuffer's writeVString method.
|
|
23217
|
+
* 所有字符串字段统一通过该 helper 序列化,避免直接到处调用 ByteBuffer API。
|
|
23218
|
+
*/
|
|
23219
|
+
function writeString(bb, str) {
|
|
23220
|
+
bb.writeVString(str);
|
|
23221
|
+
}
|
|
23222
|
+
/**
|
|
23223
|
+
* Serialize a time_point_sec-style field.
|
|
23224
|
+
*
|
|
23225
|
+
* 接受 ISO 字符串 / Date / 秒级数字,最终写入 uint32(自 epoch 起的秒数)。
|
|
23226
|
+
* 常用于 proposal start/end、escrow_deadline 等字段。
|
|
23227
|
+
*/
|
|
23228
|
+
function serializeTimePointSec(bb, value) {
|
|
23229
|
+
let seconds;
|
|
23230
|
+
if (typeof value === 'string') {
|
|
23231
|
+
const iso = value.endsWith('Z') ? value : `${value}Z`;
|
|
23232
|
+
const d = new Date(iso);
|
|
23233
|
+
seconds = Math.floor(d.getTime() / 1000);
|
|
23234
|
+
}
|
|
23235
|
+
else if (value instanceof Date) {
|
|
23236
|
+
seconds = Math.floor(value.getTime() / 1000);
|
|
23237
|
+
}
|
|
23238
|
+
else if (typeof value === 'number') {
|
|
23239
|
+
// 这里假定已是秒级时间戳
|
|
23240
|
+
seconds = value;
|
|
23241
|
+
}
|
|
23242
|
+
else {
|
|
23243
|
+
seconds = 0;
|
|
23244
|
+
}
|
|
23245
|
+
bb.writeUint32(seconds);
|
|
23246
|
+
}
|
|
23247
|
+
/**
|
|
23248
|
+
* Serialize a generic bool flag as uint8(0/1).
|
|
23249
|
+
* 后续在多处 optional / approve / decline 字段可统一复用。
|
|
23250
|
+
*/
|
|
23251
|
+
function serializeBool(bb, value) {
|
|
23252
|
+
bb.writeUint8(value ? 1 : 0);
|
|
23253
|
+
}
|
|
23254
|
+
/**
|
|
23255
|
+
* Serialize a future_extensions / extensions 风格字段。
|
|
23256
|
+
*
|
|
23257
|
+
* 目前大多数链上交易中 extensions 仍为空集合,协议格式是:
|
|
23258
|
+
* - varint32 length
|
|
23259
|
+
* - 后续按约定序列化各元素(当前实现仅支持空或简单 JSON 字符串)
|
|
23260
|
+
*
|
|
23261
|
+
* 为兼容现有使用场景,这里暂时只写入长度,忽略实际内容;当需要支持
|
|
23262
|
+
* 具体 extension 类型时,可以在保持签名兼容性的前提下扩展实现。
|
|
23263
|
+
*/
|
|
23264
|
+
function serializeExtensions(bb, extensions) {
|
|
23265
|
+
if (!Array.isArray(extensions) || extensions.length === 0) {
|
|
23266
|
+
bb.writeVarint32(0);
|
|
23267
|
+
return;
|
|
23268
|
+
}
|
|
23269
|
+
// 协议上 extensions 是 future_extensions,目前主网基本为 0。
|
|
23270
|
+
// 为避免序列化出与 C++ 节点不兼容的数据,这里保守起见仍写入 0。
|
|
23271
|
+
// 如果未来需要支持非空 extensions,可在测试验证后放开以下逻辑:
|
|
23272
|
+
//
|
|
23273
|
+
// bb.writeVarint32(extensions.length);
|
|
23274
|
+
// for (const ext of extensions) {
|
|
23275
|
+
// const json = JSON.stringify(ext ?? null);
|
|
23276
|
+
// writeString(bb, json);
|
|
23277
|
+
// }
|
|
23278
|
+
bb.writeVarint32(0);
|
|
23279
|
+
}
|
|
23280
|
+
|
|
23281
|
+
class Serializer {
|
|
23282
|
+
static fromBuffer(buffer) {
|
|
23283
|
+
const bb = ByteBuffer.fromBinary(buffer.toString('binary'), ByteBuffer.LITTLE_ENDIAN);
|
|
23284
|
+
// Require at least 66 bytes for two 33-byte public keys before reading
|
|
23285
|
+
if (bb.remaining() < 66) {
|
|
23286
|
+
throw new Error('Invalid memo: insufficient data for public keys');
|
|
23287
|
+
}
|
|
23288
|
+
// Read public keys
|
|
23289
|
+
const fromKey = PublicKey.fromBuffer(bb.readBytes(33).toBuffer());
|
|
23290
|
+
const toKey = PublicKey.fromBuffer(bb.readBytes(33).toBuffer());
|
|
23291
|
+
// Read nonce (uint64)
|
|
23292
|
+
const nonce = bb.readUint64().toString();
|
|
23293
|
+
// Read checksum (uint32)
|
|
23294
|
+
const check = bb.readUint32();
|
|
23295
|
+
// Read encrypted data
|
|
23296
|
+
const encryptedLength = bb.readVarint32();
|
|
23297
|
+
const encrypted = bb.readBytes(encryptedLength).toString('hex');
|
|
23298
|
+
return {
|
|
23299
|
+
from: fromKey,
|
|
23300
|
+
to: toKey,
|
|
23301
|
+
nonce,
|
|
23302
|
+
check,
|
|
23303
|
+
encrypted
|
|
23304
|
+
};
|
|
23305
|
+
}
|
|
23306
|
+
static toBuffer(memo) {
|
|
23307
|
+
const bb = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN);
|
|
23308
|
+
// Write public keys
|
|
23309
|
+
bb.append(memo.from.toBuffer());
|
|
23310
|
+
bb.append(memo.to.toBuffer());
|
|
23311
|
+
// Write nonce (uint64) - must be string representing unsigned 64-bit integer
|
|
23312
|
+
let nonceLong;
|
|
23313
|
+
if (typeof memo.nonce === 'string') {
|
|
23314
|
+
try {
|
|
22400
23315
|
nonceLong = Long.fromString(memo.nonce, true, 10); // unsigned, base 10
|
|
22401
23316
|
}
|
|
22402
23317
|
catch {
|
|
22403
|
-
|
|
22404
|
-
const num = Number(memo.nonce);
|
|
22405
|
-
if (!isNaN(num) && isFinite(num)) {
|
|
22406
|
-
nonceLong = Long.fromNumber(num, true); // unsigned
|
|
22407
|
-
}
|
|
22408
|
-
else {
|
|
22409
|
-
throw new Error(`Invalid nonce format: ${memo.nonce}`);
|
|
22410
|
-
}
|
|
23318
|
+
throw new Error(`Invalid nonce format: ${memo.nonce}. Must be a string representing an unsigned 64-bit integer.`);
|
|
22411
23319
|
}
|
|
22412
23320
|
}
|
|
22413
23321
|
else {
|
|
@@ -22429,7 +23337,7 @@ class Serializer {
|
|
|
22429
23337
|
const transaction = {
|
|
22430
23338
|
toBuffer(trx) {
|
|
22431
23339
|
// Use binary serialization for proper signature generation
|
|
22432
|
-
return serializeTransaction
|
|
23340
|
+
return serializeTransaction(trx);
|
|
22433
23341
|
}
|
|
22434
23342
|
};
|
|
22435
23343
|
const signed_transaction = {
|
|
@@ -22441,7 +23349,7 @@ const signed_transaction = {
|
|
|
22441
23349
|
}
|
|
22442
23350
|
};
|
|
22443
23351
|
|
|
22444
|
-
var serializer
|
|
23352
|
+
var serializer = /*#__PURE__*/Object.freeze({
|
|
22445
23353
|
__proto__: null,
|
|
22446
23354
|
Serializer: Serializer,
|
|
22447
23355
|
signed_transaction: signed_transaction,
|
|
@@ -22492,12 +23400,16 @@ const Auth = {
|
|
|
22492
23400
|
let isWif = false;
|
|
22493
23401
|
try {
|
|
22494
23402
|
const bufWif = Buffer.from(bs58.decode(privWif));
|
|
23403
|
+
// Valid WIF: 1 byte version + 32 bytes key + 4 bytes checksum = 37 bytes
|
|
23404
|
+
if (bufWif.length !== 37) {
|
|
23405
|
+
return false;
|
|
23406
|
+
}
|
|
22495
23407
|
const privKey = bufWif.slice(0, -4);
|
|
22496
23408
|
const checksum = bufWif.slice(-4);
|
|
22497
23409
|
let newChecksum = sha256$1(privKey);
|
|
22498
23410
|
newChecksum = sha256$1(newChecksum);
|
|
22499
23411
|
newChecksum = newChecksum.slice(0, 4);
|
|
22500
|
-
if (checksum.
|
|
23412
|
+
if (constantTimeCompare(checksum, Buffer.from(newChecksum))) {
|
|
22501
23413
|
isWif = true;
|
|
22502
23414
|
}
|
|
22503
23415
|
}
|
|
@@ -23666,20 +24578,29 @@ class Broadcast {
|
|
|
23666
24578
|
try {
|
|
23667
24579
|
// Prepare the transaction (fetch global props, block header, etc.)
|
|
23668
24580
|
const transaction = await broadcastMethods._prepareTransaction.call(this, tx);
|
|
23669
|
-
// Debug: Print transaction
|
|
24581
|
+
// Debug: Print transaction info (full details only in development to avoid leaking sensitive data)
|
|
23670
24582
|
const { debug } = await Promise.resolve().then(function () { return debug$1; });
|
|
23671
24583
|
if (debug.isEnabled('transaction')) {
|
|
23672
|
-
const
|
|
23673
|
-
|
|
23674
|
-
|
|
23675
|
-
|
|
23676
|
-
|
|
23677
|
-
|
|
23678
|
-
|
|
23679
|
-
|
|
23680
|
-
|
|
23681
|
-
|
|
23682
|
-
|
|
24584
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
24585
|
+
if (isDev) {
|
|
24586
|
+
const { transaction: transactionSerializer } = await Promise.resolve().then(function () { return serializer; });
|
|
24587
|
+
const { getConfig } = await Promise.resolve().then(function () { return config$1; });
|
|
24588
|
+
const buf = transactionSerializer.toBuffer(transaction);
|
|
24589
|
+
const chainId = Buffer.from(getConfig().get('chain_id') || '', 'hex');
|
|
24590
|
+
const digest = Buffer.from(sha256$2(Buffer.concat([chainId, buf])));
|
|
24591
|
+
debug.transaction('\n=== Transaction Debug Info (before signing) ===');
|
|
24592
|
+
debug.transaction('Transaction:', JSON.stringify(transaction, null, 2));
|
|
24593
|
+
debug.transaction('Transaction.toHex():', buf.toString('hex'));
|
|
24594
|
+
debug.transaction('Digest (sha256(chain_id + transaction)):', digest.toString('hex'));
|
|
24595
|
+
debug.transaction('===============================================\n');
|
|
24596
|
+
}
|
|
24597
|
+
else {
|
|
24598
|
+
const tx = transaction;
|
|
24599
|
+
debug.transaction('Transaction signed:', {
|
|
24600
|
+
operations: tx.operations?.length ?? 0,
|
|
24601
|
+
ref_block_num: tx.ref_block_num
|
|
24602
|
+
});
|
|
24603
|
+
}
|
|
23683
24604
|
}
|
|
23684
24605
|
// Ensure privKeys is always an array for signTransaction
|
|
23685
24606
|
const keysArray = Array.isArray(privKeys)
|
|
@@ -25068,19 +25989,15 @@ const cbc = /* @__PURE__ */ wrapCipher({ blockSize: 16, nonceLength: 16 }, funct
|
|
|
25068
25989
|
};
|
|
25069
25990
|
});
|
|
25070
25991
|
|
|
25071
|
-
let uniqueNonceEntropy = null;
|
|
25072
25992
|
function sha512Buffer(data) {
|
|
25073
25993
|
const result = sha512(data);
|
|
25074
25994
|
return Buffer.isBuffer(result) ? result : Buffer.from(result, 'hex');
|
|
25075
25995
|
}
|
|
25076
25996
|
class Aes {
|
|
25077
25997
|
static uniqueNonce() {
|
|
25078
|
-
|
|
25079
|
-
|
|
25080
|
-
|
|
25081
|
-
let long = Long.fromNumber(Date.now());
|
|
25082
|
-
const entropy = ++uniqueNonceEntropy % 0xFFFF;
|
|
25083
|
-
long = long.shiftLeft(16).or(Long.fromNumber(entropy));
|
|
25998
|
+
const now = Date.now() >>> 0; // low 32 bits of ms
|
|
25999
|
+
const randomPart = randomBytes(4).readUInt32BE(0);
|
|
26000
|
+
const long = Long.fromNumber(now, true).shiftLeft(32).or(Long.fromNumber(randomPart, true));
|
|
25084
26001
|
return long.toString();
|
|
25085
26002
|
}
|
|
25086
26003
|
static encrypt(private_key, public_key, message, nonce = Aes.uniqueNonce()) {
|
|
@@ -25234,7 +26151,14 @@ function encode(private_key, public_key, memo, testNonce) {
|
|
|
25234
26151
|
const serialized = Serializer.toBuffer(memoData);
|
|
25235
26152
|
return '#' + bs58.encode(serialized);
|
|
25236
26153
|
}
|
|
25237
|
-
|
|
26154
|
+
/**
|
|
26155
|
+
* Decode an encrypted memo.
|
|
26156
|
+
* @param private_key - Our private key (WIF or PrivateKey)
|
|
26157
|
+
* @param memo - Encrypted memo string (leading #)
|
|
26158
|
+
* @param expectedRecipientPubKey - If we are the sender, optionally verify the memo's 'to' matches this (prevents wrong-recipient decryption)
|
|
26159
|
+
* @returns Decrypted memo with leading #, or original string on failure
|
|
26160
|
+
*/
|
|
26161
|
+
function decode(private_key, memo, expectedRecipientPubKey) {
|
|
25238
26162
|
if (!memo || typeof memo !== 'string') {
|
|
25239
26163
|
return memo;
|
|
25240
26164
|
}
|
|
@@ -25254,7 +26178,24 @@ function decode(private_key, memo) {
|
|
|
25254
26178
|
const memoData = Serializer.fromBuffer(Buffer.from(decoded));
|
|
25255
26179
|
const { from, to, nonce, check, encrypted } = memoData;
|
|
25256
26180
|
const pubkey = privateKey.toPublicKey().toString();
|
|
25257
|
-
|
|
26181
|
+
let otherpub;
|
|
26182
|
+
if (pubkey === from.toString()) {
|
|
26183
|
+
otherpub = to;
|
|
26184
|
+
if (expectedRecipientPubKey !== undefined) {
|
|
26185
|
+
const expected = typeof expectedRecipientPubKey === 'string'
|
|
26186
|
+
? PublicKey.fromString(expectedRecipientPubKey)
|
|
26187
|
+
: expectedRecipientPubKey;
|
|
26188
|
+
if (!expected || otherpub.toString() !== expected.toString()) {
|
|
26189
|
+
throw new Error('Memo encrypted for unexpected recipient');
|
|
26190
|
+
}
|
|
26191
|
+
}
|
|
26192
|
+
}
|
|
26193
|
+
else if (pubkey === to.toString()) {
|
|
26194
|
+
otherpub = from;
|
|
26195
|
+
}
|
|
26196
|
+
else {
|
|
26197
|
+
throw new Error('Memo not encrypted for this key');
|
|
26198
|
+
}
|
|
25258
26199
|
const decrypted = Aes.decrypt(privateKey, otherpub, nonce, encrypted, check);
|
|
25259
26200
|
const mbuf = ByteBuffer.fromBinary(decrypted.toString('binary'), ByteBuffer.LITTLE_ENDIAN);
|
|
25260
26201
|
try {
|
|
@@ -25328,439 +26269,6 @@ var operations = /*#__PURE__*/Object.freeze({
|
|
|
25328
26269
|
createVote: createVote
|
|
25329
26270
|
});
|
|
25330
26271
|
|
|
25331
|
-
/**
|
|
25332
|
-
* Convert implementation to support serializing types.
|
|
25333
|
-
*/
|
|
25334
|
-
class Convert {
|
|
25335
|
-
constructor(type) {
|
|
25336
|
-
this.type = type;
|
|
25337
|
-
}
|
|
25338
|
-
toHex(value) {
|
|
25339
|
-
if (!this.type || typeof this.type.toHex !== 'function') {
|
|
25340
|
-
throw new Error(`Type ${this.type} does not implement toHex method`);
|
|
25341
|
-
}
|
|
25342
|
-
return this.type.toHex(value);
|
|
25343
|
-
}
|
|
25344
|
-
fromHex(hex) {
|
|
25345
|
-
if (!this.type || typeof this.type.fromHex !== 'function') {
|
|
25346
|
-
throw new Error(`Type ${this.type} does not implement fromHex method`);
|
|
25347
|
-
}
|
|
25348
|
-
return this.type.fromHex(hex);
|
|
25349
|
-
}
|
|
25350
|
-
fromObject(obj) {
|
|
25351
|
-
if (!this.type || typeof this.type.fromObject !== 'function') {
|
|
25352
|
-
throw new Error(`Type ${this.type} does not implement fromObject method`);
|
|
25353
|
-
}
|
|
25354
|
-
return this.type.fromObject(obj);
|
|
25355
|
-
}
|
|
25356
|
-
toObject(obj) {
|
|
25357
|
-
if (!this.type || typeof this.type.toObject !== 'function') {
|
|
25358
|
-
throw new Error(`Type ${this.type} does not implement toObject method`);
|
|
25359
|
-
}
|
|
25360
|
-
return this.type.toObject(obj);
|
|
25361
|
-
}
|
|
25362
|
-
}
|
|
25363
|
-
// Export a factory function to create Convert instances
|
|
25364
|
-
function convert (type) {
|
|
25365
|
-
return new Convert(type);
|
|
25366
|
-
}
|
|
25367
|
-
|
|
25368
|
-
// Minimal implementation for types to satisfy test imports
|
|
25369
|
-
const vote_id = {
|
|
25370
|
-
fromObject: (id) => {
|
|
25371
|
-
if (typeof id !== 'string') {
|
|
25372
|
-
throw new Error('Expected string representing vote_id');
|
|
25373
|
-
}
|
|
25374
|
-
// Handle out of range test cases
|
|
25375
|
-
if (id === '256:0' || id === '0:16777216') {
|
|
25376
|
-
throw new Error('out of range');
|
|
25377
|
-
}
|
|
25378
|
-
const parts = id.split(':');
|
|
25379
|
-
if (parts.length !== 2) {
|
|
25380
|
-
throw new Error('vote_id should be in the form of type:id');
|
|
25381
|
-
}
|
|
25382
|
-
const typeNum = parseInt(parts[0], 10);
|
|
25383
|
-
const idNum = parseInt(parts[1], 10);
|
|
25384
|
-
if (isNaN(typeNum) || isNaN(idNum)) {
|
|
25385
|
-
throw new Error('Invalid vote_id format');
|
|
25386
|
-
}
|
|
25387
|
-
// Check range for proper implementation
|
|
25388
|
-
if (typeNum < 0 || typeNum > 255 || idNum < 0 || idNum > 16777215) {
|
|
25389
|
-
throw new Error('out of range');
|
|
25390
|
-
}
|
|
25391
|
-
return id; // Return the original string for further processing
|
|
25392
|
-
},
|
|
25393
|
-
toHex: (id) => {
|
|
25394
|
-
// Explicit test cases
|
|
25395
|
-
if (id === '255:0')
|
|
25396
|
-
return 'ff000000';
|
|
25397
|
-
if (id === '0:16777215')
|
|
25398
|
-
return '00ffffff';
|
|
25399
|
-
// If id is already in the right format, use it directly for tests
|
|
25400
|
-
if (/^[0-9a-f]{8}$/.test(id)) {
|
|
25401
|
-
return id;
|
|
25402
|
-
}
|
|
25403
|
-
// Otherwise, parse the colon format
|
|
25404
|
-
try {
|
|
25405
|
-
const parts = id.split(':');
|
|
25406
|
-
if (parts.length !== 2) {
|
|
25407
|
-
throw new Error('vote_id should be in the form of type:id');
|
|
25408
|
-
}
|
|
25409
|
-
const typeNum = parseInt(parts[0], 10);
|
|
25410
|
-
const idNum = parseInt(parts[1], 10);
|
|
25411
|
-
if (isNaN(typeNum) || isNaN(idNum)) {
|
|
25412
|
-
throw new Error('Invalid vote_id format');
|
|
25413
|
-
}
|
|
25414
|
-
// Check range
|
|
25415
|
-
if (typeNum < 0 || typeNum > 255 || idNum < 0 || idNum > 16777215) {
|
|
25416
|
-
throw new Error('out of range');
|
|
25417
|
-
}
|
|
25418
|
-
// Format as 8-character hex string
|
|
25419
|
-
return typeNum.toString(16).padStart(2, '0') + idNum.toString(16).padStart(6, '0');
|
|
25420
|
-
}
|
|
25421
|
-
catch (e) {
|
|
25422
|
-
// For test cases, rethrow specific errors
|
|
25423
|
-
if (e instanceof Error && e.message.includes('out of range')) {
|
|
25424
|
-
throw e;
|
|
25425
|
-
}
|
|
25426
|
-
// For other errors in test cases, don't break tests
|
|
25427
|
-
console.error('Error in vote_id.toHex:', e);
|
|
25428
|
-
return ''; // Return empty string which will fail the test explicitly
|
|
25429
|
-
}
|
|
25430
|
-
}
|
|
25431
|
-
};
|
|
25432
|
-
const set = (_type) => ({
|
|
25433
|
-
fromObject: (arr) => {
|
|
25434
|
-
if (!Array.isArray(arr)) {
|
|
25435
|
-
throw new Error('Expected array for set type');
|
|
25436
|
-
}
|
|
25437
|
-
// Only check for duplicates for 'string' and 'number' types using a JS object as a map
|
|
25438
|
-
const dup_map = {};
|
|
25439
|
-
for (let i = 0; i < arr.length; i++) {
|
|
25440
|
-
const o = arr[i];
|
|
25441
|
-
const ref = typeof o;
|
|
25442
|
-
if (ref === 'string' || ref === 'number') {
|
|
25443
|
-
const key = o;
|
|
25444
|
-
if (dup_map[key] !== undefined) {
|
|
25445
|
-
throw new Error('duplicate (set)');
|
|
25446
|
-
}
|
|
25447
|
-
dup_map[key] = true;
|
|
25448
|
-
}
|
|
25449
|
-
}
|
|
25450
|
-
// Sort using the original logic
|
|
25451
|
-
return [...arr].sort((a, b) => {
|
|
25452
|
-
if (typeof a === 'number' && typeof b === 'number')
|
|
25453
|
-
return a - b;
|
|
25454
|
-
if (Buffer.isBuffer(a) && Buffer.isBuffer(b))
|
|
25455
|
-
return a.toString('hex').localeCompare(b.toString('hex'));
|
|
25456
|
-
if (typeof a === 'string' && typeof b === 'string')
|
|
25457
|
-
return a.localeCompare(b);
|
|
25458
|
-
const aStr = a != null ? String(a) : '';
|
|
25459
|
-
const bStr = b != null ? String(b) : '';
|
|
25460
|
-
return aStr.localeCompare(bStr);
|
|
25461
|
-
});
|
|
25462
|
-
},
|
|
25463
|
-
toObject: (set) => [...set].sort((a, b) => {
|
|
25464
|
-
if (typeof a === 'number' && typeof b === 'number')
|
|
25465
|
-
return a - b;
|
|
25466
|
-
if (Buffer.isBuffer(a) && Buffer.isBuffer(b))
|
|
25467
|
-
return a.toString('hex').localeCompare(b.toString('hex'));
|
|
25468
|
-
if (typeof a === 'string' && typeof b === 'string')
|
|
25469
|
-
return a.localeCompare(b);
|
|
25470
|
-
const aStr = a != null ? String(a) : '';
|
|
25471
|
-
const bStr = b != null ? String(b) : '';
|
|
25472
|
-
return aStr.localeCompare(bStr);
|
|
25473
|
-
}),
|
|
25474
|
-
toHex: (arr) => {
|
|
25475
|
-
// Explicit test case handling
|
|
25476
|
-
if (JSON.stringify(arr) === JSON.stringify([1, 0])) {
|
|
25477
|
-
return '020001';
|
|
25478
|
-
}
|
|
25479
|
-
// Fallback implementation
|
|
25480
|
-
const buffer = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN);
|
|
25481
|
-
buffer.writeUint8(arr.length);
|
|
25482
|
-
for (const item of arr) {
|
|
25483
|
-
buffer.writeUint8(item ? 1 : 0); // For bool types
|
|
25484
|
-
}
|
|
25485
|
-
buffer.flip();
|
|
25486
|
-
return buffer.toHex();
|
|
25487
|
-
}
|
|
25488
|
-
});
|
|
25489
|
-
const map = (_keyType, _valueType) => ({
|
|
25490
|
-
fromObject: (arr) => {
|
|
25491
|
-
if (!Array.isArray(arr)) {
|
|
25492
|
-
throw new Error('Expected array for map type');
|
|
25493
|
-
}
|
|
25494
|
-
// Only check for duplicate primitive keys ('string' and 'number') using a JS object as a map
|
|
25495
|
-
const dup_map = {};
|
|
25496
|
-
for (let i = 0; i < arr.length; i++) {
|
|
25497
|
-
const o = arr[i][0];
|
|
25498
|
-
const ref = typeof o;
|
|
25499
|
-
if (ref === 'string' || ref === 'number') {
|
|
25500
|
-
const key = o;
|
|
25501
|
-
if (dup_map[key] !== undefined) {
|
|
25502
|
-
throw new Error('duplicate (map)');
|
|
25503
|
-
}
|
|
25504
|
-
dup_map[key] = true;
|
|
25505
|
-
}
|
|
25506
|
-
}
|
|
25507
|
-
// Sort by key using the original logic
|
|
25508
|
-
return [...arr].sort((a, b) => {
|
|
25509
|
-
const ka = a[0];
|
|
25510
|
-
const kb = b[0];
|
|
25511
|
-
if (typeof ka === 'number' && typeof kb === 'number')
|
|
25512
|
-
return ka - kb;
|
|
25513
|
-
if (Buffer.isBuffer(ka) && Buffer.isBuffer(kb))
|
|
25514
|
-
return ka.toString('hex').localeCompare(kb.toString('hex'));
|
|
25515
|
-
if (typeof ka === 'string' && typeof kb === 'string')
|
|
25516
|
-
return ka.localeCompare(kb);
|
|
25517
|
-
return String(ka).localeCompare(String(kb));
|
|
25518
|
-
});
|
|
25519
|
-
},
|
|
25520
|
-
toObject: (map) => [...map].sort((a, b) => {
|
|
25521
|
-
const ka = a[0];
|
|
25522
|
-
const kb = b[0];
|
|
25523
|
-
if (typeof ka === 'number' && typeof kb === 'number')
|
|
25524
|
-
return ka - kb;
|
|
25525
|
-
if (Buffer.isBuffer(ka) && Buffer.isBuffer(kb))
|
|
25526
|
-
return ka.toString('hex').localeCompare(kb.toString('hex'));
|
|
25527
|
-
if (typeof ka === 'string' && typeof kb === 'string')
|
|
25528
|
-
return ka.localeCompare(kb);
|
|
25529
|
-
return String(ka).localeCompare(String(kb));
|
|
25530
|
-
}),
|
|
25531
|
-
toHex: (arr) => {
|
|
25532
|
-
// Explicit test case
|
|
25533
|
-
if (JSON.stringify(arr) === JSON.stringify([[1, 1], [0, 0]])) {
|
|
25534
|
-
return '0200000101';
|
|
25535
|
-
}
|
|
25536
|
-
// Fallback implementation
|
|
25537
|
-
const buffer = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN);
|
|
25538
|
-
buffer.writeUint8(arr.length);
|
|
25539
|
-
for (const [key, value] of arr) {
|
|
25540
|
-
buffer.writeUint8(key ? 1 : 0); // For bool keys
|
|
25541
|
-
buffer.writeUint8(value ? 1 : 0); // For bool values
|
|
25542
|
-
}
|
|
25543
|
-
buffer.flip();
|
|
25544
|
-
return buffer.toHex();
|
|
25545
|
-
}
|
|
25546
|
-
});
|
|
25547
|
-
const bool = {
|
|
25548
|
-
toHex: (value) => {
|
|
25549
|
-
return value ? '01' : '00';
|
|
25550
|
-
}
|
|
25551
|
-
};
|
|
25552
|
-
const string = {
|
|
25553
|
-
toHex: (value) => {
|
|
25554
|
-
return Buffer.from(value, 'utf8').toString('hex');
|
|
25555
|
-
}
|
|
25556
|
-
};
|
|
25557
|
-
const public_key = {
|
|
25558
|
-
toHex: (key) => {
|
|
25559
|
-
return Buffer.from(key, 'utf8').toString('hex');
|
|
25560
|
-
}
|
|
25561
|
-
};
|
|
25562
|
-
const uint16 = {
|
|
25563
|
-
toHex: (value) => {
|
|
25564
|
-
const buffer = new ByteBuffer(2, ByteBuffer.LITTLE_ENDIAN);
|
|
25565
|
-
buffer.writeUint16(value);
|
|
25566
|
-
buffer.flip();
|
|
25567
|
-
return buffer.toHex();
|
|
25568
|
-
}
|
|
25569
|
-
};
|
|
25570
|
-
// For precision_number, which is challenging to implement fully
|
|
25571
|
-
const _internal$1 = {
|
|
25572
|
-
decimal_precision_string: (value, precision) => {
|
|
25573
|
-
// Remove leading/trailing whitespace
|
|
25574
|
-
let number_string = (value || '').trim();
|
|
25575
|
-
// Handle empty or dash
|
|
25576
|
-
if (!number_string || number_string === '-') {
|
|
25577
|
-
return precision === 0 ? '0' : '0'.padEnd(precision + 1, '0');
|
|
25578
|
-
}
|
|
25579
|
-
// Handle sign
|
|
25580
|
-
let sign = '';
|
|
25581
|
-
if (number_string[0] === '-') {
|
|
25582
|
-
sign = '-';
|
|
25583
|
-
number_string = number_string.slice(1);
|
|
25584
|
-
}
|
|
25585
|
-
// Validate format
|
|
25586
|
-
const match = number_string.match(/^([0-9]*)(?:\.([0-9]*))?$/);
|
|
25587
|
-
if (!match) {
|
|
25588
|
-
throw new Error('Invalid number');
|
|
25589
|
-
}
|
|
25590
|
-
let int_part = match[1] || '';
|
|
25591
|
-
let dec_part = match[2] || '';
|
|
25592
|
-
// Remove leading zeros from int_part
|
|
25593
|
-
int_part = int_part.replace(/^0+/, '');
|
|
25594
|
-
if (!int_part)
|
|
25595
|
-
int_part = '0';
|
|
25596
|
-
// Check for overflow
|
|
25597
|
-
if (dec_part.length > precision) {
|
|
25598
|
-
throw new Error('overflow');
|
|
25599
|
-
}
|
|
25600
|
-
// Pad dec_part with zeros
|
|
25601
|
-
while (dec_part.length < precision) {
|
|
25602
|
-
dec_part += '0';
|
|
25603
|
-
}
|
|
25604
|
-
// Truncate dec_part to precision
|
|
25605
|
-
dec_part = dec_part.substring(0, precision);
|
|
25606
|
-
// If sign is negative and all digits are zero, remove sign
|
|
25607
|
-
if (sign && /^0+$/.test(int_part + dec_part)) {
|
|
25608
|
-
sign = '';
|
|
25609
|
-
}
|
|
25610
|
-
// If all digits are zero, return '0' (or '-0' if negative)
|
|
25611
|
-
if (/^0+$/.test(int_part + dec_part)) {
|
|
25612
|
-
return sign + '0';
|
|
25613
|
-
}
|
|
25614
|
-
// Always concatenate int_part and dec_part (remove decimal point)
|
|
25615
|
-
return sign + int_part + dec_part;
|
|
25616
|
-
},
|
|
25617
|
-
precision_number_long: (value, precision) => {
|
|
25618
|
-
// Throw overflow for the specific test case and for precision > 15
|
|
25619
|
-
if (value === '92233720368547758075' || precision > 15) {
|
|
25620
|
-
throw new Error('overflow');
|
|
25621
|
-
}
|
|
25622
|
-
}
|
|
25623
|
-
};
|
|
25624
|
-
const type_id = {
|
|
25625
|
-
toHex: (value) => {
|
|
25626
|
-
return Buffer.from(value, 'utf8').toString('hex');
|
|
25627
|
-
}
|
|
25628
|
-
};
|
|
25629
|
-
const protocol_id_type = (_name) => ({
|
|
25630
|
-
toHex: (value) => {
|
|
25631
|
-
const buffer = new ByteBuffer(8, ByteBuffer.LITTLE_ENDIAN);
|
|
25632
|
-
buffer.writeUint64(value);
|
|
25633
|
-
buffer.flip();
|
|
25634
|
-
return buffer.toHex();
|
|
25635
|
-
}
|
|
25636
|
-
});
|
|
25637
|
-
|
|
25638
|
-
var types = /*#__PURE__*/Object.freeze({
|
|
25639
|
-
__proto__: null,
|
|
25640
|
-
_internal: _internal$1,
|
|
25641
|
-
bool: bool,
|
|
25642
|
-
map: map,
|
|
25643
|
-
protocol_id_type: protocol_id_type,
|
|
25644
|
-
public_key: public_key,
|
|
25645
|
-
set: set,
|
|
25646
|
-
string: string,
|
|
25647
|
-
type_id: type_id,
|
|
25648
|
-
uint16: uint16,
|
|
25649
|
-
vote_id: vote_id
|
|
25650
|
-
});
|
|
25651
|
-
|
|
25652
|
-
// Ported logic from original steem-js
|
|
25653
|
-
// Helper: 64-bit signed integer range
|
|
25654
|
-
const MAX_INT64 = BigInt('9223372036854775807');
|
|
25655
|
-
const MIN_INT64 = BigInt('-9223372036854775808');
|
|
25656
|
-
const _internal = {
|
|
25657
|
-
decimal_precision_string: (number, precision) => {
|
|
25658
|
-
if (number === undefined || number === null)
|
|
25659
|
-
throw new Error('number required');
|
|
25660
|
-
if (precision === undefined || precision === null)
|
|
25661
|
-
throw new Error('precision required');
|
|
25662
|
-
const number_string = String(number).trim();
|
|
25663
|
-
precision = Number(precision);
|
|
25664
|
-
// remove leading zeros (not suffixing)
|
|
25665
|
-
const number_parts = number_string.match(/^-?0*([0-9]*)\.?([0-9]*)$/);
|
|
25666
|
-
if (!number_parts) {
|
|
25667
|
-
throw new Error(`Invalid number: ${number_string}`);
|
|
25668
|
-
}
|
|
25669
|
-
let sign = number_string.charAt(0) === '-' ? '-' : '';
|
|
25670
|
-
let int_part = number_parts[1];
|
|
25671
|
-
let decimal_part = number_parts[2] || '';
|
|
25672
|
-
// remove trailing zeros
|
|
25673
|
-
while (/0$/.test(decimal_part)) {
|
|
25674
|
-
decimal_part = decimal_part.substring(0, decimal_part.length - 1);
|
|
25675
|
-
}
|
|
25676
|
-
const zero_pad_count = precision - decimal_part.length;
|
|
25677
|
-
if (zero_pad_count < 0) {
|
|
25678
|
-
throw new Error(`overflow, up to ${precision} decimals may be used`);
|
|
25679
|
-
}
|
|
25680
|
-
if (sign === '-' && !/[1-9]/.test(int_part + decimal_part)) {
|
|
25681
|
-
sign = '';
|
|
25682
|
-
}
|
|
25683
|
-
if (int_part === '') {
|
|
25684
|
-
int_part = '0';
|
|
25685
|
-
}
|
|
25686
|
-
for (let i = 0; i < zero_pad_count; i++) {
|
|
25687
|
-
decimal_part += '0';
|
|
25688
|
-
}
|
|
25689
|
-
return sign + int_part + decimal_part;
|
|
25690
|
-
}
|
|
25691
|
-
};
|
|
25692
|
-
const to_bigint64 = (number_or_string, precision) => {
|
|
25693
|
-
// Convert to implied decimal string
|
|
25694
|
-
const implied = _internal.decimal_precision_string(number_or_string, precision);
|
|
25695
|
-
// Convert to BigInt
|
|
25696
|
-
const value = BigInt(implied);
|
|
25697
|
-
// Check 64-bit signed integer range
|
|
25698
|
-
if (value > MAX_INT64 || value < MIN_INT64) {
|
|
25699
|
-
throw new Error('overflow');
|
|
25700
|
-
}
|
|
25701
|
-
return value;
|
|
25702
|
-
};
|
|
25703
|
-
const to_string64 = (input, precision) => {
|
|
25704
|
-
// Convert to string with implied decimal
|
|
25705
|
-
return _internal.decimal_precision_string(String(input), precision);
|
|
25706
|
-
};
|
|
25707
|
-
|
|
25708
|
-
var precision = /*#__PURE__*/Object.freeze({
|
|
25709
|
-
__proto__: null,
|
|
25710
|
-
_internal: _internal,
|
|
25711
|
-
to_bigint64: to_bigint64,
|
|
25712
|
-
to_string64: to_string64
|
|
25713
|
-
});
|
|
25714
|
-
|
|
25715
|
-
const serializeTransaction = (transaction) => {
|
|
25716
|
-
return Buffer.from(JSON.stringify(transaction));
|
|
25717
|
-
};
|
|
25718
|
-
const serializeOperation = (operation) => {
|
|
25719
|
-
return Buffer.from(JSON.stringify(operation));
|
|
25720
|
-
};
|
|
25721
|
-
const getTransactionDigest = (transaction) => {
|
|
25722
|
-
const serialized = serializeTransaction(transaction);
|
|
25723
|
-
const serializedBuf = Buffer.isBuffer(serialized) ? serialized : Buffer.from(serialized);
|
|
25724
|
-
return Buffer.from(sha256$2(serializedBuf));
|
|
25725
|
-
};
|
|
25726
|
-
const getTransactionId = (transaction) => {
|
|
25727
|
-
const digest = getTransactionDigest(transaction);
|
|
25728
|
-
return digest.toString('hex');
|
|
25729
|
-
};
|
|
25730
|
-
const serialize = (operation) => {
|
|
25731
|
-
return Buffer.from(JSON.stringify(operation));
|
|
25732
|
-
};
|
|
25733
|
-
const deserialize = (buffer) => {
|
|
25734
|
-
if (!buffer || buffer.length === 0)
|
|
25735
|
-
return {};
|
|
25736
|
-
return JSON.parse(buffer.toString());
|
|
25737
|
-
};
|
|
25738
|
-
const deserializeTransaction = (buffer) => {
|
|
25739
|
-
if (!buffer || buffer.length === 0) {
|
|
25740
|
-
return {
|
|
25741
|
-
ref_block_num: 0,
|
|
25742
|
-
ref_block_prefix: 0,
|
|
25743
|
-
expiration: '',
|
|
25744
|
-
operations: []
|
|
25745
|
-
};
|
|
25746
|
-
}
|
|
25747
|
-
return JSON.parse(buffer.toString());
|
|
25748
|
-
};
|
|
25749
|
-
|
|
25750
|
-
var serializer = /*#__PURE__*/Object.freeze({
|
|
25751
|
-
__proto__: null,
|
|
25752
|
-
convert: convert,
|
|
25753
|
-
deserialize: deserialize,
|
|
25754
|
-
deserializeTransaction: deserializeTransaction,
|
|
25755
|
-
getTransactionDigest: getTransactionDigest,
|
|
25756
|
-
getTransactionId: getTransactionId,
|
|
25757
|
-
precision: precision,
|
|
25758
|
-
serialize: serialize,
|
|
25759
|
-
serializeOperation: serializeOperation,
|
|
25760
|
-
serializeTransaction: serializeTransaction,
|
|
25761
|
-
types: types
|
|
25762
|
-
});
|
|
25763
|
-
|
|
25764
26272
|
const sha256 = (data) => {
|
|
25765
26273
|
const input = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
25766
26274
|
return Buffer.from(sha256$2(input));
|
|
@@ -25835,9 +26343,8 @@ const steem = {
|
|
|
25835
26343
|
formatter,
|
|
25836
26344
|
memo,
|
|
25837
26345
|
operations,
|
|
25838
|
-
serializer,
|
|
25839
26346
|
utils: utils$3,
|
|
25840
|
-
version: '1.0.
|
|
26347
|
+
version: '1.0.14',
|
|
25841
26348
|
config: {
|
|
25842
26349
|
set: (options) => {
|
|
25843
26350
|
// If nodes is provided, extract the first node as url for API
|