@aioha/tx-digest 1.0.1 → 2.0.0
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/helpers/ByteBuffer.js +1 -220
- package/helpers/serializer.js +86 -100
- package/index.js +4 -3
- package/package.json +1 -1
- package/helpers/Asset.js +0 -69
package/helpers/ByteBuffer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>
|
|
3
|
-
* Backing buffer: ArrayBuffer
|
|
3
|
+
* Backing buffer: ArrayBuffer
|
|
4
4
|
* Released under the Apache License, Version 2.0
|
|
5
5
|
* see: https://github.com/dcodeIO/bytebuffer.js for details
|
|
6
6
|
* modified by @xmcl/bytebuffer
|
|
@@ -158,29 +158,6 @@ export class ByteBuffer {
|
|
|
158
158
|
this.noAssert = noAssert
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
/**
|
|
162
|
-
* Gets the accessor type.
|
|
163
|
-
* @returns {Function} `Buffer` under node.js, `Uint8Array` respectively `DataView` in the browser (classes)
|
|
164
|
-
* @expose
|
|
165
|
-
*/
|
|
166
|
-
static accessor = function () {
|
|
167
|
-
return DataView
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Allocates a new ByteBuffer backed by a buffer of the specified capacity.
|
|
172
|
-
* @param {number=} capacity Initial capacity. Defaults to {@link ByteBuffer.DEFAULT_CAPACITY}.
|
|
173
|
-
* @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
|
|
174
|
-
* {@link ByteBuffer.DEFAULT_ENDIAN}.
|
|
175
|
-
* @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
|
|
176
|
-
* {@link ByteBuffer.DEFAULT_NOASSERT}.
|
|
177
|
-
* @returns {!ByteBuffer}
|
|
178
|
-
* @expose
|
|
179
|
-
*/
|
|
180
|
-
static allocate = function (capacity, littleEndian, noAssert) {
|
|
181
|
-
return new ByteBuffer(capacity, littleEndian, noAssert)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
161
|
/**
|
|
185
162
|
* Gets the backing buffer type.
|
|
186
163
|
* @returns {Function} `Buffer` under node.js, `ArrayBuffer` in the browser (classes)
|
|
@@ -513,64 +490,6 @@ export class ByteBuffer {
|
|
|
513
490
|
|
|
514
491
|
// types/ints/int32
|
|
515
492
|
|
|
516
|
-
/**
|
|
517
|
-
* Writes a 32bit signed integer.
|
|
518
|
-
* @param {number} value Value to write
|
|
519
|
-
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
|
|
520
|
-
* @expose
|
|
521
|
-
*/
|
|
522
|
-
writeInt32(value, offset) {
|
|
523
|
-
const relative = typeof offset === 'undefined'
|
|
524
|
-
|
|
525
|
-
if (relative) {
|
|
526
|
-
offset = this.offset
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
if (!this.noAssert) {
|
|
530
|
-
if (typeof value !== 'number' || value % 1 !== 0) {
|
|
531
|
-
throw TypeError('Illegal value: ' + value + ' (not an integer)')
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
value |= 0
|
|
535
|
-
|
|
536
|
-
if (typeof offset !== 'number' || offset % 1 !== 0) {
|
|
537
|
-
throw TypeError('Illegal offset: ' + offset + ' (not an integer)')
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
offset >>>= 0
|
|
541
|
-
|
|
542
|
-
if (offset < 0 || offset + 0 > this.buffer.byteLength) {
|
|
543
|
-
throw RangeError('Illegal offset: 0 <= ' + offset + ' (+0) <= ' + this.buffer.byteLength)
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
offset += 4
|
|
548
|
-
|
|
549
|
-
let capacity4 = this.buffer.byteLength
|
|
550
|
-
|
|
551
|
-
if (offset > capacity4) {
|
|
552
|
-
this.resize((capacity4 *= 2) > offset ? capacity4 : offset)
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
offset -= 4
|
|
556
|
-
|
|
557
|
-
this.view.setInt32(offset, value, this.littleEndian)
|
|
558
|
-
|
|
559
|
-
if (relative) {
|
|
560
|
-
this.offset += 4
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
return this
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Writes a 32bit signed integer. This is an alias of {@link ByteBuffer#writeInt32}.
|
|
568
|
-
* @param {number} value Value to write
|
|
569
|
-
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
|
|
570
|
-
* @expose
|
|
571
|
-
*/
|
|
572
|
-
writeInt = this.writeInt32
|
|
573
|
-
|
|
574
493
|
/**
|
|
575
494
|
* Writes a 32bit unsigned integer.
|
|
576
495
|
* @param {number} value Value to write
|
|
@@ -739,22 +658,6 @@ export class ByteBuffer {
|
|
|
739
658
|
return bb
|
|
740
659
|
}
|
|
741
660
|
|
|
742
|
-
/**
|
|
743
|
-
* Makes sure that this ByteBuffer is backed by a {@link ByteBuffer#buffer} of at least the specified capacity. If the
|
|
744
|
-
* current capacity is exceeded, it will be doubled. If double the current capacity is less than the required capacity,
|
|
745
|
-
* the required capacity will be used instead.
|
|
746
|
-
* @param {number} capacity Required capacity
|
|
747
|
-
* @returns {!ByteBuffer} this
|
|
748
|
-
* @expose
|
|
749
|
-
*/
|
|
750
|
-
ensureCapacity(capacity) {
|
|
751
|
-
let current = this.buffer.byteLength
|
|
752
|
-
if (current < capacity) {
|
|
753
|
-
return this.resize((current *= 2) > capacity ? current : capacity)
|
|
754
|
-
}
|
|
755
|
-
return this
|
|
756
|
-
}
|
|
757
|
-
|
|
758
661
|
/**
|
|
759
662
|
* Makes this ByteBuffer ready for a new sequence of write or relative read operations. Sets `limit = offset` and
|
|
760
663
|
* `offset = 0`. Make sure always to flip a ByteBuffer when all relative read or write operations are complete.
|
|
@@ -767,30 +670,6 @@ export class ByteBuffer {
|
|
|
767
670
|
return this
|
|
768
671
|
}
|
|
769
672
|
|
|
770
|
-
/**
|
|
771
|
-
* Switches (to) little endian byte order.
|
|
772
|
-
* @param {boolean=} littleEndian Defaults to `true`, otherwise uses big endian
|
|
773
|
-
* @returns {!ByteBuffer} this
|
|
774
|
-
* @expose
|
|
775
|
-
*/
|
|
776
|
-
LE(littleEndian) {
|
|
777
|
-
this.littleEndian = typeof littleEndian !== 'undefined' ? !!littleEndian : true
|
|
778
|
-
|
|
779
|
-
return this
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Switches (to) big endian byte order.
|
|
784
|
-
* @param {boolean=} bigEndian Defaults to `true`, otherwise uses little endian
|
|
785
|
-
* @returns {!ByteBuffer} this
|
|
786
|
-
* @expose
|
|
787
|
-
*/
|
|
788
|
-
BE(bigEndian) {
|
|
789
|
-
this.littleEndian = typeof bigEndian !== 'undefined' ? !bigEndian : false
|
|
790
|
-
|
|
791
|
-
return this
|
|
792
|
-
}
|
|
793
|
-
|
|
794
673
|
/**
|
|
795
674
|
* Resizes this ByteBuffer to be backed by a buffer of at least the given capacity. Will do nothing if already that
|
|
796
675
|
* large or larger.
|
|
@@ -1143,105 +1022,7 @@ export class ByteBuffer {
|
|
|
1143
1022
|
}
|
|
1144
1023
|
return offset - start
|
|
1145
1024
|
}
|
|
1146
|
-
|
|
1147
|
-
readUTF8String(length, metrics, offset) {
|
|
1148
|
-
if (typeof metrics === 'number') {
|
|
1149
|
-
offset = metrics
|
|
1150
|
-
metrics = undefined
|
|
1151
|
-
}
|
|
1152
|
-
const relative = typeof offset === 'undefined'
|
|
1153
|
-
if (relative) offset = this.offset
|
|
1154
|
-
if (typeof metrics === 'undefined') metrics = ByteBuffer.METRICS_CHARS
|
|
1155
|
-
if (!this.noAssert) {
|
|
1156
|
-
if (typeof length !== 'number' || length % 1 !== 0) {
|
|
1157
|
-
throw TypeError('Illegal length: ' + length + ' (not an integer)')
|
|
1158
|
-
}
|
|
1159
|
-
length |= 0
|
|
1160
|
-
if (typeof offset !== 'number' || offset % 1 !== 0) {
|
|
1161
|
-
throw TypeError('Illegal offset: ' + offset + ' (not an integer)')
|
|
1162
|
-
}
|
|
1163
|
-
offset >>>= 0
|
|
1164
|
-
if (offset < 0 || offset + 0 > this.buffer.byteLength) {
|
|
1165
|
-
throw RangeError('Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength)
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
let i = 0
|
|
1169
|
-
const start = offset
|
|
1170
|
-
let sd
|
|
1171
|
-
if (metrics === ByteBuffer.METRICS_CHARS) {
|
|
1172
|
-
// The same for node and the browser
|
|
1173
|
-
sd = stringDestination()
|
|
1174
|
-
utfx.decodeUTF8(
|
|
1175
|
-
function () {
|
|
1176
|
-
return i < length && offset < this.limit ? this.view.getUint8(offset++) : null
|
|
1177
|
-
}.bind(this),
|
|
1178
|
-
function (cp) {
|
|
1179
|
-
++i
|
|
1180
|
-
utfx.UTF8toUTF16(cp, sd)
|
|
1181
|
-
}
|
|
1182
|
-
)
|
|
1183
|
-
if (i !== length) {
|
|
1184
|
-
throw RangeError('Illegal range: Truncated data, ' + i + ' == ' + length)
|
|
1185
|
-
}
|
|
1186
|
-
if (relative) {
|
|
1187
|
-
this.offset = offset
|
|
1188
|
-
return sd()
|
|
1189
|
-
} else {
|
|
1190
|
-
return {
|
|
1191
|
-
string: sd(),
|
|
1192
|
-
length: offset - start
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
} else if (metrics === ByteBuffer.METRICS_BYTES) {
|
|
1196
|
-
if (!this.noAssert) {
|
|
1197
|
-
if (typeof offset !== 'number' || offset % 1 !== 0) {
|
|
1198
|
-
throw TypeError('Illegal offset: ' + offset + ' (not an integer)')
|
|
1199
|
-
}
|
|
1200
|
-
offset >>>= 0
|
|
1201
|
-
if (offset < 0 || offset + length > this.buffer.byteLength) {
|
|
1202
|
-
throw RangeError('Illegal offset: 0 <= ' + offset + ' (+' + length + ') <= ' + this.buffer.byteLength)
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
const k = offset + length
|
|
1206
|
-
utfx.decodeUTF8toUTF16(
|
|
1207
|
-
function () {
|
|
1208
|
-
return offset < k ? this.view.getUint8(offset++) : null
|
|
1209
|
-
}.bind(this),
|
|
1210
|
-
(sd = stringDestination()),
|
|
1211
|
-
this.noAssert
|
|
1212
|
-
)
|
|
1213
|
-
if (offset !== k) {
|
|
1214
|
-
throw RangeError('Illegal range: Truncated data, ' + offset + ' == ' + k)
|
|
1215
|
-
}
|
|
1216
|
-
if (relative) {
|
|
1217
|
-
this.offset = offset
|
|
1218
|
-
return sd()
|
|
1219
|
-
} else {
|
|
1220
|
-
return {
|
|
1221
|
-
string: sd(),
|
|
1222
|
-
length: offset - start
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
} else {
|
|
1226
|
-
throw TypeError('Unsupported metrics: ' + metrics)
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
function stringDestination() {
|
|
1231
|
-
const cs = []
|
|
1232
|
-
const ps = []
|
|
1233
|
-
return function () {
|
|
1234
|
-
if (arguments.length === 0) {
|
|
1235
|
-
return ps.join('') + stringFromCharCode.apply(String, cs)
|
|
1236
|
-
}
|
|
1237
|
-
if (cs.length + arguments.length > 1024) {
|
|
1238
|
-
ps.push(stringFromCharCode.apply(String, cs))
|
|
1239
|
-
cs.length = 0
|
|
1240
|
-
}
|
|
1241
|
-
Array.prototype.push.apply(cs, arguments)
|
|
1242
|
-
}
|
|
1243
1025
|
}
|
|
1244
|
-
const stringFromCharCode = String.fromCharCode
|
|
1245
1026
|
|
|
1246
1027
|
function stringSource(s) {
|
|
1247
1028
|
let i = 0
|
package/helpers/serializer.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import { PublicKey } from './PublicKey.js'
|
|
2
|
-
import { Asset } from './Asset.js'
|
|
3
2
|
import { HexBuffer } from './HexBuffer.js'
|
|
4
3
|
|
|
4
|
+
const Extensions = {
|
|
5
|
+
comment_payout_beneficiaries: 0,
|
|
6
|
+
update_proposal_end_date: 1
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const NaiUint32 = (nai) => {
|
|
10
|
+
switch (nai) {
|
|
11
|
+
case '@@000000021': // HIVE
|
|
12
|
+
return 3200000035 // ((99999999+2) << 5) | 3
|
|
13
|
+
case '@@000000013': // HBD
|
|
14
|
+
return 3200000003 // ((99999999+1) << 5) | 3
|
|
15
|
+
case '@@000000037': // VESTS
|
|
16
|
+
return 3200000070 // ((99999999+3) << 5) | 6
|
|
17
|
+
default:
|
|
18
|
+
throw new Error('Invalid NAI')
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
5
22
|
const VoidSerializer = () => {
|
|
6
23
|
throw new Error('Void can not be serialized')
|
|
7
24
|
}
|
|
@@ -9,17 +26,17 @@ const StringSerializer = (buffer, data) => {
|
|
|
9
26
|
buffer.writeVString(data)
|
|
10
27
|
}
|
|
11
28
|
|
|
12
|
-
const Int8Serializer = (buffer, data) => {
|
|
13
|
-
|
|
14
|
-
}
|
|
29
|
+
// const Int8Serializer = (buffer, data) => {
|
|
30
|
+
// buffer.writeInt8(data)
|
|
31
|
+
// }
|
|
15
32
|
|
|
16
33
|
const Int16Serializer = (buffer, data) => {
|
|
17
34
|
buffer.writeInt16(data)
|
|
18
35
|
}
|
|
19
36
|
|
|
20
|
-
const Int32Serializer = (buffer, data) => {
|
|
21
|
-
|
|
22
|
-
}
|
|
37
|
+
// const Int32Serializer = (buffer, data) => {
|
|
38
|
+
// buffer.writeInt32(data)
|
|
39
|
+
// }
|
|
23
40
|
|
|
24
41
|
const Int64Serializer = (buffer, data) => {
|
|
25
42
|
buffer.writeInt64(data)
|
|
@@ -45,36 +62,10 @@ const BooleanSerializer = (buffer, data) => {
|
|
|
45
62
|
buffer.writeByte(data ? 1 : 0)
|
|
46
63
|
}
|
|
47
64
|
|
|
48
|
-
const
|
|
65
|
+
const ExtensionSerializer = (itemSerializer) => {
|
|
49
66
|
return (buffer, data) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// id was/is supposed to be 0 or integer here but seems to have been changed in e.g. comment_options
|
|
53
|
-
// extensions: [
|
|
54
|
-
// [
|
|
55
|
-
// "comment_payout_beneficiaries",
|
|
56
|
-
// {
|
|
57
|
-
// "beneficiaries": [
|
|
58
|
-
// {
|
|
59
|
-
// "account": "vimm",
|
|
60
|
-
// "weight": 1000
|
|
61
|
-
// }
|
|
62
|
-
// ]
|
|
63
|
-
// }
|
|
64
|
-
// ]
|
|
65
|
-
// ]
|
|
66
|
-
// "comment_payout_beneficiaries" was 0 and at some point it got changed
|
|
67
|
-
// It should still be serialized as a 0 or an integer
|
|
68
|
-
// Now the question is, always 0? will need an example transaction to prove otherwise
|
|
69
|
-
if (typeof id === 'string') {
|
|
70
|
-
if (id === 'update_proposal_end_date') {
|
|
71
|
-
id = 1
|
|
72
|
-
} else {
|
|
73
|
-
id = 0
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
buffer.writeVarint32(id)
|
|
77
|
-
itemSerializers[id](buffer, item)
|
|
67
|
+
buffer.writeVarint32(Extensions[data.type])
|
|
68
|
+
itemSerializer(buffer, data.value)
|
|
78
69
|
}
|
|
79
70
|
}
|
|
80
71
|
|
|
@@ -84,13 +75,8 @@ const StaticVariantSerializer = (itemSerializers) => {
|
|
|
84
75
|
* Should not be a problem in real-word usage.
|
|
85
76
|
*/
|
|
86
77
|
const AssetSerializer = (buffer, data) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
buffer.writeInt64(Math.round(asset.amount * Math.pow(10, precision)))
|
|
90
|
-
buffer.writeUint8(precision)
|
|
91
|
-
for (let i = 0; i < 7; i++) {
|
|
92
|
-
buffer.writeUint8(asset.symbol.charCodeAt(i) || 0)
|
|
93
|
-
}
|
|
78
|
+
buffer.writeInt64(data.amount)
|
|
79
|
+
buffer.writeUint32(NaiUint32(data.nai))
|
|
94
80
|
}
|
|
95
81
|
|
|
96
82
|
const DateSerializer = (buffer, data) => {
|
|
@@ -206,7 +192,7 @@ const OperationDataSerializer = (operationId, definitions) => {
|
|
|
206
192
|
|
|
207
193
|
const OperationSerializers = {}
|
|
208
194
|
|
|
209
|
-
OperationSerializers.
|
|
195
|
+
OperationSerializers.account_create_operation = OperationDataSerializer(9, [
|
|
210
196
|
['fee', AssetSerializer],
|
|
211
197
|
['creator', StringSerializer],
|
|
212
198
|
['new_account_name', StringSerializer],
|
|
@@ -217,7 +203,7 @@ OperationSerializers.account_create = OperationDataSerializer(9, [
|
|
|
217
203
|
['json_metadata', StringSerializer]
|
|
218
204
|
])
|
|
219
205
|
|
|
220
|
-
OperationSerializers.
|
|
206
|
+
OperationSerializers.account_create_with_delegation_operation = OperationDataSerializer(41, [
|
|
221
207
|
['fee', AssetSerializer],
|
|
222
208
|
['delegation', AssetSerializer],
|
|
223
209
|
['creator', StringSerializer],
|
|
@@ -230,7 +216,7 @@ OperationSerializers.account_create_with_delegation = OperationDataSerializer(41
|
|
|
230
216
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
231
217
|
])
|
|
232
218
|
|
|
233
|
-
OperationSerializers.
|
|
219
|
+
OperationSerializers.account_update_operation = OperationDataSerializer(10, [
|
|
234
220
|
['account', StringSerializer],
|
|
235
221
|
['owner', OptionalSerializer(AuthoritySerializer)],
|
|
236
222
|
['active', OptionalSerializer(AuthoritySerializer)],
|
|
@@ -239,42 +225,42 @@ OperationSerializers.account_update = OperationDataSerializer(10, [
|
|
|
239
225
|
['json_metadata', StringSerializer]
|
|
240
226
|
])
|
|
241
227
|
|
|
242
|
-
OperationSerializers.
|
|
228
|
+
OperationSerializers.account_witness_proxy_operation = OperationDataSerializer(13, [
|
|
243
229
|
['account', StringSerializer],
|
|
244
230
|
['proxy', StringSerializer]
|
|
245
231
|
])
|
|
246
232
|
|
|
247
|
-
OperationSerializers.
|
|
233
|
+
OperationSerializers.account_witness_vote_operation = OperationDataSerializer(12, [
|
|
248
234
|
['account', StringSerializer],
|
|
249
235
|
['witness', StringSerializer],
|
|
250
236
|
['approve', BooleanSerializer]
|
|
251
237
|
])
|
|
252
238
|
|
|
253
|
-
OperationSerializers.
|
|
239
|
+
OperationSerializers.cancel_transfer_from_savings_operation = OperationDataSerializer(34, [
|
|
254
240
|
['from', StringSerializer],
|
|
255
241
|
['request_id', UInt32Serializer]
|
|
256
242
|
])
|
|
257
243
|
|
|
258
|
-
OperationSerializers.
|
|
244
|
+
OperationSerializers.change_recovery_account_operation = OperationDataSerializer(26, [
|
|
259
245
|
['account_to_recover', StringSerializer],
|
|
260
246
|
['new_recovery_account', StringSerializer],
|
|
261
247
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
262
248
|
])
|
|
263
249
|
|
|
264
|
-
OperationSerializers.
|
|
250
|
+
OperationSerializers.claim_account_operation = OperationDataSerializer(22, [
|
|
265
251
|
['creator', StringSerializer],
|
|
266
252
|
['fee', AssetSerializer],
|
|
267
253
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
268
254
|
])
|
|
269
255
|
|
|
270
|
-
OperationSerializers.
|
|
256
|
+
OperationSerializers.claim_reward_balance_operation = OperationDataSerializer(39, [
|
|
271
257
|
['account', StringSerializer],
|
|
272
258
|
['reward_hive', AssetSerializer],
|
|
273
259
|
['reward_hbd', AssetSerializer],
|
|
274
260
|
['reward_vests', AssetSerializer]
|
|
275
261
|
])
|
|
276
262
|
|
|
277
|
-
OperationSerializers.
|
|
263
|
+
OperationSerializers.comment_operation = OperationDataSerializer(1, [
|
|
278
264
|
['parent_author', StringSerializer],
|
|
279
265
|
['parent_permlink', StringSerializer],
|
|
280
266
|
['author', StringSerializer],
|
|
@@ -284,7 +270,7 @@ OperationSerializers.comment = OperationDataSerializer(1, [
|
|
|
284
270
|
['json_metadata', StringSerializer]
|
|
285
271
|
])
|
|
286
272
|
|
|
287
|
-
OperationSerializers.
|
|
273
|
+
OperationSerializers.comment_options_operation = OperationDataSerializer(19, [
|
|
288
274
|
['author', StringSerializer],
|
|
289
275
|
['permlink', StringSerializer],
|
|
290
276
|
['max_accepted_payout', AssetSerializer],
|
|
@@ -293,17 +279,17 @@ OperationSerializers.comment_options = OperationDataSerializer(19, [
|
|
|
293
279
|
['allow_curation_rewards', BooleanSerializer],
|
|
294
280
|
[
|
|
295
281
|
'extensions',
|
|
296
|
-
ArraySerializer(
|
|
282
|
+
ArraySerializer(ExtensionSerializer(ObjectSerializer([['beneficiaries', ArraySerializer(BeneficiarySerializer)]])))
|
|
297
283
|
]
|
|
298
284
|
])
|
|
299
285
|
|
|
300
|
-
OperationSerializers.
|
|
286
|
+
OperationSerializers.convert_operation = OperationDataSerializer(8, [
|
|
301
287
|
['owner', StringSerializer],
|
|
302
288
|
['requestid', UInt32Serializer],
|
|
303
289
|
['amount', AssetSerializer]
|
|
304
290
|
])
|
|
305
291
|
|
|
306
|
-
OperationSerializers.
|
|
292
|
+
OperationSerializers.create_claimed_account_operation = OperationDataSerializer(23, [
|
|
307
293
|
['creator', StringSerializer],
|
|
308
294
|
['new_account_name', StringSerializer],
|
|
309
295
|
['owner', AuthoritySerializer],
|
|
@@ -314,13 +300,13 @@ OperationSerializers.create_claimed_account = OperationDataSerializer(23, [
|
|
|
314
300
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
315
301
|
])
|
|
316
302
|
|
|
317
|
-
OperationSerializers.
|
|
303
|
+
OperationSerializers.custom_operation = OperationDataSerializer(15, [
|
|
318
304
|
['required_auths', ArraySerializer(StringSerializer)],
|
|
319
305
|
['id', UInt16Serializer],
|
|
320
306
|
['data', VariableBinarySerializer]
|
|
321
307
|
])
|
|
322
308
|
|
|
323
|
-
OperationSerializers.
|
|
309
|
+
OperationSerializers.custom_binary_operation = OperationDataSerializer(35, [
|
|
324
310
|
['required_owner_auths', ArraySerializer(StringSerializer)],
|
|
325
311
|
['required_active_auths', ArraySerializer(StringSerializer)],
|
|
326
312
|
['required_posting_auths', ArraySerializer(StringSerializer)],
|
|
@@ -329,30 +315,30 @@ OperationSerializers.custom_binary = OperationDataSerializer(35, [
|
|
|
329
315
|
['data', VariableBinarySerializer]
|
|
330
316
|
])
|
|
331
317
|
|
|
332
|
-
OperationSerializers.
|
|
318
|
+
OperationSerializers.custom_json_operation = OperationDataSerializer(18, [
|
|
333
319
|
['required_auths', ArraySerializer(StringSerializer)],
|
|
334
320
|
['required_posting_auths', ArraySerializer(StringSerializer)],
|
|
335
321
|
['id', StringSerializer],
|
|
336
322
|
['json', StringSerializer]
|
|
337
323
|
])
|
|
338
324
|
|
|
339
|
-
OperationSerializers.
|
|
325
|
+
OperationSerializers.decline_voting_rights_operation = OperationDataSerializer(36, [
|
|
340
326
|
['account', StringSerializer],
|
|
341
327
|
['decline', BooleanSerializer]
|
|
342
328
|
])
|
|
343
329
|
|
|
344
|
-
OperationSerializers.
|
|
330
|
+
OperationSerializers.delegate_vesting_shares_operation = OperationDataSerializer(40, [
|
|
345
331
|
['delegator', StringSerializer],
|
|
346
332
|
['delegatee', StringSerializer],
|
|
347
333
|
['vesting_shares', AssetSerializer]
|
|
348
334
|
])
|
|
349
335
|
|
|
350
|
-
OperationSerializers.
|
|
336
|
+
OperationSerializers.delete_comment_operation = OperationDataSerializer(17, [
|
|
351
337
|
['author', StringSerializer],
|
|
352
338
|
['permlink', StringSerializer]
|
|
353
339
|
])
|
|
354
340
|
|
|
355
|
-
OperationSerializers.
|
|
341
|
+
OperationSerializers.escrow_approve_operation = OperationDataSerializer(31, [
|
|
356
342
|
['from', StringSerializer],
|
|
357
343
|
['to', StringSerializer],
|
|
358
344
|
['agent', StringSerializer],
|
|
@@ -361,7 +347,7 @@ OperationSerializers.escrow_approve = OperationDataSerializer(31, [
|
|
|
361
347
|
['approve', BooleanSerializer]
|
|
362
348
|
])
|
|
363
349
|
|
|
364
|
-
OperationSerializers.
|
|
350
|
+
OperationSerializers.escrow_dispute_operation = OperationDataSerializer(28, [
|
|
365
351
|
['from', StringSerializer],
|
|
366
352
|
['to', StringSerializer],
|
|
367
353
|
['agent', StringSerializer],
|
|
@@ -369,7 +355,7 @@ OperationSerializers.escrow_dispute = OperationDataSerializer(28, [
|
|
|
369
355
|
['escrow_id', UInt32Serializer]
|
|
370
356
|
])
|
|
371
357
|
|
|
372
|
-
OperationSerializers.
|
|
358
|
+
OperationSerializers.escrow_release_operation = OperationDataSerializer(29, [
|
|
373
359
|
['from', StringSerializer],
|
|
374
360
|
['to', StringSerializer],
|
|
375
361
|
['agent', StringSerializer],
|
|
@@ -380,7 +366,7 @@ OperationSerializers.escrow_release = OperationDataSerializer(29, [
|
|
|
380
366
|
['hive_amount', AssetSerializer]
|
|
381
367
|
])
|
|
382
368
|
|
|
383
|
-
OperationSerializers.
|
|
369
|
+
OperationSerializers.escrow_transfer_operation = OperationDataSerializer(27, [
|
|
384
370
|
['from', StringSerializer],
|
|
385
371
|
['to', StringSerializer],
|
|
386
372
|
['agent', StringSerializer],
|
|
@@ -393,17 +379,17 @@ OperationSerializers.escrow_transfer = OperationDataSerializer(27, [
|
|
|
393
379
|
['json_meta', StringSerializer]
|
|
394
380
|
])
|
|
395
381
|
|
|
396
|
-
OperationSerializers.
|
|
382
|
+
OperationSerializers.feed_publish_operation = OperationDataSerializer(7, [
|
|
397
383
|
['publisher', StringSerializer],
|
|
398
384
|
['exchange_rate', PriceSerializer]
|
|
399
385
|
])
|
|
400
386
|
|
|
401
|
-
OperationSerializers.
|
|
387
|
+
OperationSerializers.limit_order_cancel_operation = OperationDataSerializer(6, [
|
|
402
388
|
['owner', StringSerializer],
|
|
403
389
|
['orderid', UInt32Serializer]
|
|
404
390
|
])
|
|
405
391
|
|
|
406
|
-
OperationSerializers.
|
|
392
|
+
OperationSerializers.limit_order_create_operation = OperationDataSerializer(5, [
|
|
407
393
|
['owner', StringSerializer],
|
|
408
394
|
['orderid', UInt32Serializer],
|
|
409
395
|
['amount_to_sell', AssetSerializer],
|
|
@@ -412,7 +398,7 @@ OperationSerializers.limit_order_create = OperationDataSerializer(5, [
|
|
|
412
398
|
['expiration', DateSerializer]
|
|
413
399
|
])
|
|
414
400
|
|
|
415
|
-
OperationSerializers.
|
|
401
|
+
OperationSerializers.limit_order_create2_operation = OperationDataSerializer(21, [
|
|
416
402
|
['owner', StringSerializer],
|
|
417
403
|
['orderid', UInt32Serializer],
|
|
418
404
|
['amount_to_sell', AssetSerializer],
|
|
@@ -421,53 +407,53 @@ OperationSerializers.limit_order_create2 = OperationDataSerializer(21, [
|
|
|
421
407
|
['expiration', DateSerializer]
|
|
422
408
|
])
|
|
423
409
|
|
|
424
|
-
OperationSerializers.
|
|
410
|
+
OperationSerializers.recover_account_operation = OperationDataSerializer(25, [
|
|
425
411
|
['account_to_recover', StringSerializer],
|
|
426
412
|
['new_owner_authority', AuthoritySerializer],
|
|
427
413
|
['recent_owner_authority', AuthoritySerializer],
|
|
428
414
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
429
415
|
])
|
|
430
416
|
|
|
431
|
-
OperationSerializers.
|
|
417
|
+
OperationSerializers.report_over_production_operation = OperationDataSerializer(16, [
|
|
432
418
|
['reporter', StringSerializer],
|
|
433
419
|
['first_block', SignedBlockHeaderSerializer],
|
|
434
420
|
['second_block', SignedBlockHeaderSerializer]
|
|
435
421
|
])
|
|
436
422
|
|
|
437
|
-
OperationSerializers.
|
|
423
|
+
OperationSerializers.request_account_recovery_operation = OperationDataSerializer(24, [
|
|
438
424
|
['recovery_account', StringSerializer],
|
|
439
425
|
['account_to_recover', StringSerializer],
|
|
440
426
|
['new_owner_authority', AuthoritySerializer],
|
|
441
427
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
442
428
|
])
|
|
443
429
|
|
|
444
|
-
OperationSerializers.
|
|
430
|
+
OperationSerializers.reset_account_operation = OperationDataSerializer(37, [
|
|
445
431
|
['reset_account', StringSerializer],
|
|
446
432
|
['account_to_reset', StringSerializer],
|
|
447
433
|
['new_owner_authority', AuthoritySerializer]
|
|
448
434
|
])
|
|
449
435
|
|
|
450
|
-
OperationSerializers.
|
|
436
|
+
OperationSerializers.set_reset_account_operation = OperationDataSerializer(38, [
|
|
451
437
|
['account', StringSerializer],
|
|
452
438
|
['current_reset_account', StringSerializer],
|
|
453
439
|
['reset_account', StringSerializer]
|
|
454
440
|
])
|
|
455
441
|
|
|
456
|
-
OperationSerializers.
|
|
442
|
+
OperationSerializers.set_withdraw_vesting_route_operation = OperationDataSerializer(20, [
|
|
457
443
|
['from_account', StringSerializer],
|
|
458
444
|
['to_account', StringSerializer],
|
|
459
445
|
['percent', UInt16Serializer],
|
|
460
446
|
['auto_vest', BooleanSerializer]
|
|
461
447
|
])
|
|
462
448
|
|
|
463
|
-
OperationSerializers.
|
|
449
|
+
OperationSerializers.transfer_operation = OperationDataSerializer(2, [
|
|
464
450
|
['from', StringSerializer],
|
|
465
451
|
['to', StringSerializer],
|
|
466
452
|
['amount', AssetSerializer],
|
|
467
453
|
['memo', StringSerializer]
|
|
468
454
|
])
|
|
469
455
|
|
|
470
|
-
OperationSerializers.
|
|
456
|
+
OperationSerializers.transfer_from_savings_operation = OperationDataSerializer(33, [
|
|
471
457
|
['from', StringSerializer],
|
|
472
458
|
['request_id', UInt32Serializer],
|
|
473
459
|
['to', StringSerializer],
|
|
@@ -475,32 +461,32 @@ OperationSerializers.transfer_from_savings = OperationDataSerializer(33, [
|
|
|
475
461
|
['memo', StringSerializer]
|
|
476
462
|
])
|
|
477
463
|
|
|
478
|
-
OperationSerializers.
|
|
464
|
+
OperationSerializers.transfer_to_savings_operation = OperationDataSerializer(32, [
|
|
479
465
|
['from', StringSerializer],
|
|
480
466
|
['to', StringSerializer],
|
|
481
467
|
['amount', AssetSerializer],
|
|
482
468
|
['memo', StringSerializer]
|
|
483
469
|
])
|
|
484
470
|
|
|
485
|
-
OperationSerializers.
|
|
471
|
+
OperationSerializers.transfer_to_vesting_operation = OperationDataSerializer(3, [
|
|
486
472
|
['from', StringSerializer],
|
|
487
473
|
['to', StringSerializer],
|
|
488
474
|
['amount', AssetSerializer]
|
|
489
475
|
])
|
|
490
476
|
|
|
491
|
-
OperationSerializers.
|
|
477
|
+
OperationSerializers.vote_operation = OperationDataSerializer(0, [
|
|
492
478
|
['voter', StringSerializer],
|
|
493
479
|
['author', StringSerializer],
|
|
494
480
|
['permlink', StringSerializer],
|
|
495
481
|
['weight', Int16Serializer]
|
|
496
482
|
])
|
|
497
483
|
|
|
498
|
-
OperationSerializers.
|
|
484
|
+
OperationSerializers.withdraw_vesting_operation = OperationDataSerializer(4, [
|
|
499
485
|
['account', StringSerializer],
|
|
500
486
|
['vesting_shares', AssetSerializer]
|
|
501
487
|
])
|
|
502
488
|
|
|
503
|
-
OperationSerializers.
|
|
489
|
+
OperationSerializers.witness_update_operation = OperationDataSerializer(11, [
|
|
504
490
|
['owner', StringSerializer],
|
|
505
491
|
['url', StringSerializer],
|
|
506
492
|
['block_signing_key', PublicKeySerializer],
|
|
@@ -508,13 +494,13 @@ OperationSerializers.witness_update = OperationDataSerializer(11, [
|
|
|
508
494
|
['fee', AssetSerializer]
|
|
509
495
|
])
|
|
510
496
|
|
|
511
|
-
OperationSerializers.
|
|
497
|
+
OperationSerializers.witness_set_properties_operation = OperationDataSerializer(42, [
|
|
512
498
|
['owner', StringSerializer],
|
|
513
499
|
['props', FlatMapSerializer(StringSerializer, VariableBinarySerializer)],
|
|
514
500
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
515
501
|
])
|
|
516
502
|
|
|
517
|
-
OperationSerializers.
|
|
503
|
+
OperationSerializers.account_update2_operation = OperationDataSerializer(43, [
|
|
518
504
|
['account', StringSerializer],
|
|
519
505
|
['owner', OptionalSerializer(AuthoritySerializer)],
|
|
520
506
|
['active', OptionalSerializer(AuthoritySerializer)],
|
|
@@ -525,7 +511,7 @@ OperationSerializers.account_update2 = OperationDataSerializer(43, [
|
|
|
525
511
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
526
512
|
])
|
|
527
513
|
|
|
528
|
-
OperationSerializers.
|
|
514
|
+
OperationSerializers.create_proposal_operation = OperationDataSerializer(44, [
|
|
529
515
|
['creator', StringSerializer],
|
|
530
516
|
['receiver', StringSerializer],
|
|
531
517
|
['start_date', DateSerializer],
|
|
@@ -536,14 +522,14 @@ OperationSerializers.create_proposal = OperationDataSerializer(44, [
|
|
|
536
522
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
537
523
|
])
|
|
538
524
|
|
|
539
|
-
OperationSerializers.
|
|
525
|
+
OperationSerializers.update_proposal_votes_operation = OperationDataSerializer(45, [
|
|
540
526
|
['voter', StringSerializer],
|
|
541
527
|
['proposal_ids', ArraySerializer(Int64Serializer)],
|
|
542
528
|
['approve', BooleanSerializer],
|
|
543
529
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
544
530
|
])
|
|
545
531
|
|
|
546
|
-
OperationSerializers.
|
|
532
|
+
OperationSerializers.remove_proposal_operation = OperationDataSerializer(46, [
|
|
547
533
|
['proposal_owner', StringSerializer],
|
|
548
534
|
['proposal_ids', ArraySerializer(Int64Serializer)],
|
|
549
535
|
['extensions', ArraySerializer(VoidSerializer)]
|
|
@@ -551,22 +537,22 @@ OperationSerializers.remove_proposal = OperationDataSerializer(46, [
|
|
|
551
537
|
|
|
552
538
|
const ProposalUpdateSerializer = ObjectSerializer([['end_date', DateSerializer]])
|
|
553
539
|
|
|
554
|
-
OperationSerializers.
|
|
540
|
+
OperationSerializers.update_proposal_operation = OperationDataSerializer(47, [
|
|
555
541
|
['proposal_id', UInt64Serializer],
|
|
556
542
|
['creator', StringSerializer],
|
|
557
543
|
['daily_pay', AssetSerializer],
|
|
558
544
|
['subject', StringSerializer],
|
|
559
545
|
['permlink', StringSerializer],
|
|
560
|
-
['extensions', ArraySerializer(
|
|
546
|
+
['extensions', ArraySerializer(ExtensionSerializer(ProposalUpdateSerializer))]
|
|
561
547
|
])
|
|
562
548
|
|
|
563
|
-
OperationSerializers.
|
|
549
|
+
OperationSerializers.collateralized_convert_operation = OperationDataSerializer(48, [
|
|
564
550
|
['owner', StringSerializer],
|
|
565
551
|
['requestid', UInt32Serializer],
|
|
566
552
|
['amount', AssetSerializer]
|
|
567
553
|
])
|
|
568
554
|
|
|
569
|
-
OperationSerializers.
|
|
555
|
+
OperationSerializers.recurrent_transfer_operation = OperationDataSerializer(49, [
|
|
570
556
|
['from', StringSerializer],
|
|
571
557
|
['to', StringSerializer],
|
|
572
558
|
['amount', AssetSerializer],
|
|
@@ -577,14 +563,14 @@ OperationSerializers.recurrent_transfer = OperationDataSerializer(49, [
|
|
|
577
563
|
])
|
|
578
564
|
|
|
579
565
|
const OperationSerializer = (buffer, operation) => {
|
|
580
|
-
const serializer = OperationSerializers[operation
|
|
566
|
+
const serializer = OperationSerializers[operation.type]
|
|
581
567
|
if (!serializer) {
|
|
582
|
-
throw new Error(`No serializer for operation: ${operation
|
|
568
|
+
throw new Error(`No serializer for operation: ${operation.type}`)
|
|
583
569
|
}
|
|
584
570
|
try {
|
|
585
|
-
serializer(buffer, operation
|
|
571
|
+
serializer(buffer, operation.value)
|
|
586
572
|
} catch (error) {
|
|
587
|
-
error.message = `${operation
|
|
573
|
+
error.message = `${operation.type}: ${error.message}`
|
|
588
574
|
throw error
|
|
589
575
|
}
|
|
590
576
|
}
|
|
@@ -614,16 +600,16 @@ export const Serializer = {
|
|
|
614
600
|
Date: DateSerializer,
|
|
615
601
|
FlatMap: FlatMapSerializer,
|
|
616
602
|
Int16: Int16Serializer,
|
|
617
|
-
Int32: Int32Serializer,
|
|
603
|
+
// Int32: Int32Serializer,
|
|
618
604
|
Int64: Int64Serializer,
|
|
619
|
-
Int8: Int8Serializer,
|
|
605
|
+
// Int8: Int8Serializer,
|
|
620
606
|
Memo: EncryptedMemoSerializer,
|
|
621
607
|
Object: ObjectSerializer,
|
|
622
608
|
Operation: OperationSerializer,
|
|
623
609
|
Optional: OptionalSerializer,
|
|
624
610
|
Price: PriceSerializer,
|
|
625
611
|
PublicKey: PublicKeySerializer,
|
|
626
|
-
|
|
612
|
+
Extension: ExtensionSerializer,
|
|
627
613
|
String: StringSerializer,
|
|
628
614
|
Transaction: TransactionSerializer,
|
|
629
615
|
UInt16: UInt16Serializer,
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ByteBuffer } from './helpers/ByteBuffer.js'
|
|
2
2
|
import { Serializer } from './helpers/serializer.js'
|
|
3
3
|
import { hexToUint8Array, uint8ArrayToHex } from './helpers/uint8Array.js'
|
|
4
|
-
// import { sha256 } from '@noble/hashes/
|
|
4
|
+
// import { sha256 } from '@noble/hashes/sha2'
|
|
5
5
|
|
|
6
6
|
export const sha256 = async (message) => {
|
|
7
7
|
const hashBuffer = await window.crypto.subtle.digest('SHA-256', message)
|
|
@@ -20,7 +20,8 @@ export const transactionDigest = async (transaction, chainId = CHAIN_ID) => {
|
|
|
20
20
|
}
|
|
21
21
|
buffer.flip()
|
|
22
22
|
const transactionData = new Uint8Array(buffer.toBuffer())
|
|
23
|
+
const bin = new Uint8Array([...chainId, ...transactionData])
|
|
23
24
|
const txId = uint8ArrayToHex(await sha256(transactionData)).slice(0, 40)
|
|
24
|
-
const digest = await sha256(
|
|
25
|
-
return { digest, txId }
|
|
25
|
+
const digest = await sha256(bin)
|
|
26
|
+
return { digest, txId, bin }
|
|
26
27
|
}
|
package/package.json
CHANGED
package/helpers/Asset.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/** Class representing a hive asset,
|
|
2
|
-
* e.g. `1.000 HIVE` or `12.112233 VESTS`. */
|
|
3
|
-
export class Asset {
|
|
4
|
-
/** Create a new Asset instance from a string, e.g. `42.000 HIVE`. */
|
|
5
|
-
static fromString(string, expectedSymbol = null) {
|
|
6
|
-
const [amountString, symbol] = string.split(' ')
|
|
7
|
-
if (['STEEM', 'VESTS', 'SBD', 'TESTS', 'TBD', 'HIVE', 'HBD'].indexOf(symbol) === -1) {
|
|
8
|
-
throw new Error(`Invalid asset symbol: ${symbol}`)
|
|
9
|
-
}
|
|
10
|
-
if (expectedSymbol && symbol !== expectedSymbol) {
|
|
11
|
-
throw new Error(`Invalid asset, expected symbol: ${expectedSymbol} got: ${symbol}`)
|
|
12
|
-
}
|
|
13
|
-
const amount = Number.parseFloat(amountString)
|
|
14
|
-
if (!Number.isFinite(amount)) {
|
|
15
|
-
throw new Error(`Invalid asset amount: ${amountString}`)
|
|
16
|
-
}
|
|
17
|
-
return new Asset(amount, symbol)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Convenience to create new Asset.
|
|
22
|
-
* @param symbol Symbol to use when created from number. Will also be used to validate
|
|
23
|
-
* the asset, throws if the passed value has a different symbol than this.
|
|
24
|
-
*/
|
|
25
|
-
static from(value, symbol = null) {
|
|
26
|
-
if (value instanceof Asset) {
|
|
27
|
-
if (symbol && value.symbol !== symbol) {
|
|
28
|
-
throw new Error(`Invalid asset, expected symbol: ${symbol} got: ${value.symbol}`)
|
|
29
|
-
}
|
|
30
|
-
return value
|
|
31
|
-
} else if (typeof value === 'number' && Number.isFinite(value)) {
|
|
32
|
-
return new Asset(value, symbol || 'STEEM')
|
|
33
|
-
} else if (typeof value === 'string') {
|
|
34
|
-
return Asset.fromString(value, symbol)
|
|
35
|
-
} else {
|
|
36
|
-
throw new Error(`Invalid asset '${String(value)}'`)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// We convert HIVE & HBD strings to STEEM & SBD because the serialization should be based on STEEM & SBD
|
|
41
|
-
constructor(amount, symbol) {
|
|
42
|
-
this.amount = amount
|
|
43
|
-
this.symbol = symbol === 'HIVE' ? 'STEEM' : symbol === 'HBD' ? 'SBD' : symbol
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Return asset precision. */
|
|
47
|
-
getPrecision() {
|
|
48
|
-
switch (this.symbol) {
|
|
49
|
-
case 'TESTS':
|
|
50
|
-
case 'TBD':
|
|
51
|
-
case 'STEEM':
|
|
52
|
-
case 'SBD':
|
|
53
|
-
case 'HBD':
|
|
54
|
-
case 'HIVE':
|
|
55
|
-
return 3
|
|
56
|
-
case 'VESTS':
|
|
57
|
-
return 6
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Return a string representation of this asset, e.g. `42.000 HIVE`. */
|
|
62
|
-
toString() {
|
|
63
|
-
return `${this.amount.toFixed(this.getPrecision())} ${this.symbol}`
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
toJSON() {
|
|
67
|
-
return this.toString()
|
|
68
|
-
}
|
|
69
|
-
}
|