@steemit/steem-js 0.7.11 → 0.8.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.
Files changed (74) hide show
  1. package/README.md +22 -3
  2. package/circle.yml +1 -1
  3. package/config.json +1 -1
  4. package/dist/steem-tests.min.js +4097 -23
  5. package/dist/steem.min.js +2089 -18
  6. package/docker-webpack.config.js +44 -0
  7. package/lib/api/index.js +305 -412
  8. package/lib/api/methods.js +16 -1
  9. package/lib/api/rpc-auth.js +135 -0
  10. package/lib/api/transports/base.js +25 -66
  11. package/lib/api/transports/http.js +114 -129
  12. package/lib/api/transports/index.js +8 -15
  13. package/lib/api/transports/ws.js +107 -207
  14. package/lib/auth/ecc/index.js +9 -9
  15. package/lib/auth/ecc/src/address.js +48 -78
  16. package/lib/auth/ecc/src/aes.js +93 -129
  17. package/lib/auth/ecc/src/brain_key.js +7 -7
  18. package/lib/auth/ecc/src/ecdsa.js +7 -33
  19. package/lib/auth/ecc/src/ecsignature.js +4 -30
  20. package/lib/auth/ecc/src/enforce_types.js +1 -8
  21. package/lib/auth/ecc/src/hash.js +16 -25
  22. package/lib/auth/ecc/src/key_private.js +146 -199
  23. package/lib/auth/ecc/src/key_public.js +130 -202
  24. package/lib/auth/ecc/src/key_utils.js +64 -106
  25. package/lib/auth/ecc/src/signature.js +125 -177
  26. package/lib/auth/index.js +84 -97
  27. package/lib/auth/memo.js +90 -118
  28. package/lib/auth/serializer/index.js +12 -18
  29. package/lib/auth/serializer/src/ChainTypes.js +0 -3
  30. package/lib/auth/serializer/src/convert.js +29 -32
  31. package/lib/auth/serializer/src/error_with_cause.js +22 -37
  32. package/lib/auth/serializer/src/fast_parser.js +54 -74
  33. package/lib/auth/serializer/src/number_utils.js +30 -54
  34. package/lib/auth/serializer/src/object_id.js +37 -62
  35. package/lib/auth/serializer/src/operations.js +597 -689
  36. package/lib/auth/serializer/src/precision.js +55 -73
  37. package/lib/auth/serializer/src/serializer.js +158 -204
  38. package/lib/auth/serializer/src/template.js +13 -8
  39. package/lib/auth/serializer/src/types.js +949 -1102
  40. package/lib/auth/serializer/src/validation.js +268 -328
  41. package/lib/broadcast/helpers.js +61 -98
  42. package/lib/broadcast/index.js +61 -82
  43. package/lib/browser.js +15 -19
  44. package/lib/config.js +16 -38
  45. package/lib/formatter.js +89 -115
  46. package/lib/index.js +19 -17
  47. package/lib/utils.js +4 -9
  48. package/node-18.dockerfile +28 -0
  49. package/package.json +62 -38
  50. package/test/Crypto.js +16 -16
  51. package/test/KeyFormats.js +1 -1
  52. package/test/api.test.js +37 -0
  53. package/test/broadcast.test.js +14 -8
  54. package/test/comment.test.js +17 -3
  55. package/test/operations_test.js +1 -1
  56. package/test/promise-broadcast.test.js +86 -0
  57. package/test/reputation.test.js +68 -0
  58. package/test/smt.test.js +10 -10
  59. package/test-github-workflow.bat +19 -0
  60. package/test-github-workflow.sh +15 -0
  61. package/webpack/makeConfig.js +25 -17
  62. package/.circleci/config.yml +0 -23
  63. package/dist/statistics.html +0 -208
  64. package/dist/steem-tests.min.js.gz +0 -0
  65. package/dist/steem-tests.min.js.map +0 -1
  66. package/dist/steem.min.js.gz +0 -0
  67. package/dist/steem.min.js.map +0 -1
  68. package/lib/auth/ecc/README.md +0 -20
  69. package/lib/auth/ecc/package.json +0 -36
  70. package/lib/auth/serializer/README.md +0 -13
  71. package/lib/auth/serializer/package.json +0 -32
  72. package/node-4.dockerfile +0 -6
  73. package/node-6.dockerfile +0 -6
  74. package/yarn.lock +0 -3336
@@ -1,12 +1,10 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  var _my;
4
4
  var _internal;
5
5
  var v = require('./validation');
6
6
  var BigInteger = require('bigi');
7
-
8
7
  module.exports = _my =
9
-
10
8
  // Result may be used for int64 types (like transfer amount). Asset's
11
9
  // precision is used to convert the number to a whole number with an implied
12
10
  // decimal place.
@@ -14,82 +12,66 @@ module.exports = _my =
14
12
  // "1.01" with a precision of 2 returns long 101
15
13
  // See http://cryptocoinjs.com/modules/misc/bigi/#example
16
14
  {
17
- to_bigint64: function to_bigint64(number_or_string, precision) {
18
- var error_info = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
19
-
20
- var long = _internal.to_long64(number_or_string, precision, error_info);
21
- return BigInteger(long.toString());
22
- },
23
-
24
-
25
- // 101 string or long with a precision of 2 returns "1.01"
26
- to_string64: function to_string64(number_or_string, precision) {
27
- var error_info = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
28
-
29
- v.required(number_or_string, error_info);
30
- v.number(precision, error_info);
31
- var number_long = v.to_long(number_or_string, error_info);
32
- var string64 = _internal.decimal_precision_string(number_long, precision, error_info);
33
- v.no_overflow64(string64, error_info);
34
- return string64;
35
- }
15
+ to_bigint64(number_or_string, precision, error_info = "") {
16
+ var long = _internal.to_long64(number_or_string, precision, error_info);
17
+ return BigInteger(long.toString());
18
+ },
19
+ // 101 string or long with a precision of 2 returns "1.01"
20
+ to_string64(number_or_string, precision, error_info = "") {
21
+ v.required(number_or_string, error_info);
22
+ v.number(precision, error_info);
23
+ var number_long = v.to_long(number_or_string, error_info);
24
+ var string64 = _internal.decimal_precision_string(number_long, precision, error_info);
25
+ v.no_overflow64(string64, error_info);
26
+ return string64;
27
+ }
36
28
  };
37
29
 
38
30
  // _internal is for low-level transaction code
39
31
  module.exports._internal = _internal =
40
-
41
32
  // Warning: Long operations may over-flow without detection
42
33
  {
43
- to_long64: function to_long64(number_or_string, precision) {
44
- var error_info = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
45
-
46
- v.required(number_or_string, "number_or_string " + error_info);
47
- v.required(precision, "precision " + error_info);
48
- return v.to_long(_internal.decimal_precision_string(number_or_string, precision, error_info));
49
- },
50
- decimal_precision_string: function decimal_precision_string(number, precision) {
51
- var error_info = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
52
-
53
- v.required(number, "number " + error_info);
54
- v.required(precision, "precision " + error_info);
55
-
56
- var number_string = v.to_string(number);
57
- number_string = number_string.trim();
58
- precision = v.to_number(precision);
59
-
60
- // remove leading zeros (not suffixing)
61
- var number_parts = number_string.match(/^-?0*([0-9]*)\.?([0-9]*)$/);
62
- if (!number_parts) {
63
- throw new Error('Invalid number: ' + number_string + ' ' + error_info);
64
- }
65
-
66
- var sign = number_string.charAt(0) === '-' ? '-' : '';
67
- var int_part = number_parts[1];
68
- var decimal_part = number_parts[2];
69
- if (!decimal_part) {
70
- decimal_part = "";
71
- }
72
-
73
- // remove trailing zeros
74
- while (/0$/.test(decimal_part)) {
75
- decimal_part = decimal_part.substring(0, decimal_part.length - 1);
76
- }
77
-
78
- var zero_pad_count = precision - decimal_part.length;
79
- if (zero_pad_count < 0) {
80
- throw new Error('overflow, up to ' + precision + ' decimals may be used ' + error_info);
81
- }
82
-
83
- if (sign === "-" && !/[1-9]/.test(int_part + decimal_part)) {
84
- sign = "";
85
- }
86
- if (int_part === "") {
87
- int_part = "0";
88
- }
89
- for (var i = 0; 0 < zero_pad_count ? i < zero_pad_count : i > zero_pad_count; 0 < zero_pad_count ? i++ : i++) {
90
- decimal_part += "0";
91
- }
34
+ to_long64(number_or_string, precision, error_info = "") {
35
+ v.required(number_or_string, "number_or_string " + error_info);
36
+ v.required(precision, "precision " + error_info);
37
+ return v.to_long(_internal.decimal_precision_string(number_or_string, precision, error_info));
38
+ },
39
+ decimal_precision_string(number, precision, error_info = "") {
40
+ v.required(number, "number " + error_info);
41
+ v.required(precision, "precision " + error_info);
42
+ var number_string = v.to_string(number);
43
+ number_string = number_string.trim();
44
+ precision = v.to_number(precision);
45
+
46
+ // remove leading zeros (not suffixing)
47
+ var number_parts = number_string.match(/^-?0*([0-9]*)\.?([0-9]*)$/);
48
+ if (!number_parts) {
49
+ throw new Error(`Invalid number: ${number_string} ${error_info}`);
50
+ }
51
+ var sign = number_string.charAt(0) === '-' ? '-' : '';
52
+ var int_part = number_parts[1];
53
+ var decimal_part = number_parts[2];
54
+ if (!decimal_part) {
55
+ decimal_part = "";
56
+ }
92
57
 
93
- return sign + int_part + decimal_part;
58
+ // remove trailing zeros
59
+ while (/0$/.test(decimal_part)) {
60
+ decimal_part = decimal_part.substring(0, decimal_part.length - 1);
61
+ }
62
+ var zero_pad_count = precision - decimal_part.length;
63
+ if (zero_pad_count < 0) {
64
+ throw new Error(`overflow, up to ${precision} decimals may be used ${error_info}`);
65
+ }
66
+ if (sign === "-" && !/[1-9]/.test(int_part + decimal_part)) {
67
+ sign = "";
68
+ }
69
+ if (int_part === "") {
70
+ int_part = "0";
71
+ }
72
+ for (var i = 0; 0 < zero_pad_count ? i < zero_pad_count : i > zero_pad_count; 0 < zero_pad_count ? i++ : i++) {
73
+ decimal_part += "0";
94
74
  }
75
+ return sign + int_part + decimal_part;
76
+ }
95
77
  };
@@ -1,211 +1,165 @@
1
- 'use strict';
2
-
3
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4
-
5
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1
+ "use strict";
6
2
 
7
3
  var ByteBuffer = require('bytebuffer');
8
4
  var EC = require('./error_with_cause');
9
-
10
- var HEX_DUMP = process.env.npm_config__graphene_serializer_hex_dump;
11
-
12
- var Serializer = function () {
13
- function Serializer(operation_name, types) {
14
- _classCallCheck(this, Serializer);
15
-
16
- this.operation_name = operation_name;
17
- this.types = types;
18
- if (this.types) this.keys = Object.keys(this.types);
19
-
20
- Serializer.printDebug = true;
21
- }
22
-
23
- _createClass(Serializer, [{
24
- key: 'fromByteBuffer',
25
- value: function fromByteBuffer(b) {
26
- var object = {};
27
- var field = null;
28
- try {
29
- var iterable = this.keys;
30
- for (var i = 0, field; i < iterable.length; i++) {
31
- field = iterable[i];
32
- var type = this.types[field];
33
- try {
34
- if (HEX_DUMP) {
35
- if (type.operation_name) {
36
- console.error(type.operation_name);
37
- } else {
38
- var o1 = b.offset;
39
- type.fromByteBuffer(b);
40
- var o2 = b.offset;
41
- b.offset = o1;
42
- //b.reset()
43
- var _b = b.copy(o1, o2);
44
- console.error(this.operation_name + '.' + field + '\t', _b.toHex());
45
- }
46
- }
47
- object[field] = type.fromByteBuffer(b);
48
- } catch (e) {
49
- if (Serializer.printDebug) {
50
- console.error('Error reading ' + this.operation_name + '.' + field + ' in data:');
51
- b.printDebug();
52
- }
53
- throw e;
54
- }
55
- }
56
- } catch (error) {
57
- EC.throw(this.operation_name + '.' + field, error);
58
- }
59
-
60
- return object;
61
- }
62
- }, {
63
- key: 'appendByteBuffer',
64
- value: function appendByteBuffer(b, object) {
65
- var field = null;
66
- try {
67
- var iterable = this.keys;
68
- for (var i = 0, field; i < iterable.length; i++) {
69
- field = iterable[i];
70
- var type = this.types[field];
71
- type.appendByteBuffer(b, object[field]);
72
- }
73
- } catch (error) {
74
- try {
75
- EC.throw(this.operation_name + '.' + field + " = " + JSON.stringify(object[field]), error);
76
- } catch (e) {
77
- // circular ref
78
- EC.throw(this.operation_name + '.' + field + " = " + object[field], error);
79
- }
80
- }
81
- return;
82
- }
83
- }, {
84
- key: 'fromObject',
85
- value: function fromObject(serialized_object) {
86
- var result = {};
87
- var field = null;
88
- try {
89
- var iterable = this.keys;
90
- for (var i = 0, field; i < iterable.length; i++) {
91
- field = iterable[i];
92
- var type = this.types[field];
93
- var value = serialized_object[field];
94
- //DEBUG value = value.resolve if value.resolve
95
- //DEBUG console.log('... value',field,value)
96
- var object = type.fromObject(value);
97
- result[field] = object;
98
- }
99
- } catch (error) {
100
- EC.throw(this.operation_name + '.' + field, error);
101
- }
102
-
103
- return result;
104
- }
105
-
106
- /**
107
- @arg {boolean} [debug.use_default = false] - more template friendly
108
- @arg {boolean} [debug.annotate = false] - add user-friendly information
109
- */
110
-
111
- }, {
112
- key: 'toObject',
113
- value: function toObject() {
114
- var serialized_object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
115
- var debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { use_default: false, annotate: false };
116
-
117
- var result = {};
118
- var field = null;
119
- try {
120
- if (!this.types) return result;
121
-
122
- var iterable = this.keys;
123
- for (var i = 0, field; i < iterable.length; i++) {
124
- field = iterable[i];
125
- var type = this.types[field];
126
- var object = type.toObject(typeof serialized_object !== "undefined" && serialized_object !== null ? serialized_object[field] : undefined, debug);
127
- result[field] = object;
128
- if (HEX_DUMP) {
129
- var b = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN);
130
- var has_value = typeof serialized_object !== "undefined" && serialized_object !== null;
131
- if (has_value) {
132
- var value = serialized_object[field];
133
- if (value) type.appendByteBuffer(b, value);
134
- }
135
- b = b.copy(0, b.offset);
136
- console.error(this.operation_name + '.' + field, b.toHex());
137
- }
138
- }
139
- } catch (error) {
140
- EC.throw(this.operation_name + '.' + field, error);
141
- }
142
-
143
- return result;
144
- }
145
-
146
- /** Sort by the first element in a operation */
147
-
148
- }, {
149
- key: 'compare',
150
- value: function compare(a, b) {
151
-
152
- var first_key = this.keys[0];
153
- var first_type = this.types[first_key];
154
-
155
- var valA = a[first_key];
156
- var valB = b[first_key];
157
-
158
- if (first_type.compare) return first_type.compare(valA, valB);
159
-
160
- if (typeof valA === "number" && typeof valB === "number") return valA - valB;
161
-
162
- var encoding = void 0;
163
- if (Buffer.isBuffer(valA) && Buffer.isBuffer(valB)) {
164
- // A binary string compare does not work. If localeCompare is well supported that could replace HEX. Performanance is very good so comparing HEX works.
165
- encoding = "hex";
5
+ const HEX_DUMP = process.env.npm_config__graphene_serializer_hex_dump;
6
+ class Serializer {
7
+ constructor(operation_name, types) {
8
+ this.operation_name = operation_name;
9
+ this.types = types;
10
+ if (this.types) this.keys = Object.keys(this.types);
11
+ Serializer.printDebug = true;
12
+ }
13
+ fromByteBuffer(b) {
14
+ var object = {};
15
+ var field = null;
16
+ try {
17
+ var iterable = this.keys;
18
+ for (var i = 0, field; i < iterable.length; i++) {
19
+ field = iterable[i];
20
+ var type = this.types[field];
21
+ try {
22
+ if (HEX_DUMP) {
23
+ if (type.operation_name) {
24
+ console.error(type.operation_name);
25
+ } else {
26
+ var o1 = b.offset;
27
+ type.fromByteBuffer(b);
28
+ var o2 = b.offset;
29
+ b.offset = o1;
30
+ //b.reset()
31
+ var _b = b.copy(o1, o2);
32
+ console.error(`${this.operation_name}.${field}\t`, _b.toHex());
166
33
  }
167
-
168
- var strA = valA.toString(encoding);
169
- var strB = valB.toString(encoding);
170
- return strA > strB ? 1 : strA < strB ? -1 : 0;
171
- }
172
-
173
- // <helper_functions>
174
-
175
- }, {
176
- key: 'fromHex',
177
- value: function fromHex(hex) {
178
- var b = ByteBuffer.fromHex(hex, ByteBuffer.LITTLE_ENDIAN);
179
- return this.fromByteBuffer(b);
180
- }
181
- }, {
182
- key: 'fromBuffer',
183
- value: function fromBuffer(buffer) {
184
- var b = ByteBuffer.fromBinary(buffer.toString("binary"), ByteBuffer.LITTLE_ENDIAN);
185
- return this.fromByteBuffer(b);
186
- }
187
- }, {
188
- key: 'toHex',
189
- value: function toHex(object) {
190
- // return this.toBuffer(object).toString("hex")
191
- var b = this.toByteBuffer(object);
192
- return b.toHex();
34
+ }
35
+ object[field] = type.fromByteBuffer(b);
36
+ } catch (e) {
37
+ if (Serializer.printDebug) {
38
+ console.error(`Error reading ${this.operation_name}.${field} in data:`);
39
+ b.printDebug();
40
+ }
41
+ throw e;
193
42
  }
194
- }, {
195
- key: 'toByteBuffer',
196
- value: function toByteBuffer(object) {
197
- var b = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN);
198
- this.appendByteBuffer(b, object);
199
- return b.copy(0, b.offset);
200
- }
201
- }, {
202
- key: 'toBuffer',
203
- value: function toBuffer(object) {
204
- return new Buffer(this.toByteBuffer(object).toBinary(), 'binary');
43
+ }
44
+ } catch (error) {
45
+ EC.throw(this.operation_name + '.' + field, error);
46
+ }
47
+ return object;
48
+ }
49
+ appendByteBuffer(b, object) {
50
+ var field = null;
51
+ try {
52
+ var iterable = this.keys;
53
+ for (var i = 0, field; i < iterable.length; i++) {
54
+ field = iterable[i];
55
+ var type = this.types[field];
56
+ type.appendByteBuffer(b, object[field]);
57
+ }
58
+ } catch (error) {
59
+ try {
60
+ EC.throw(this.operation_name + '.' + field + " = " + JSON.stringify(object[field]), error);
61
+ } catch (e) {
62
+ // circular ref
63
+ EC.throw(this.operation_name + '.' + field + " = " + object[field], error);
64
+ }
65
+ }
66
+ return;
67
+ }
68
+ fromObject(serialized_object) {
69
+ var result = {};
70
+ var field = null;
71
+ try {
72
+ var iterable = this.keys;
73
+ for (var i = 0, field; i < iterable.length; i++) {
74
+ field = iterable[i];
75
+ var type = this.types[field];
76
+ var value = serialized_object[field];
77
+ //DEBUG value = value.resolve if value.resolve
78
+ //DEBUG console.log('... value',field,value)
79
+ var object = type.fromObject(value);
80
+ result[field] = object;
81
+ }
82
+ } catch (error) {
83
+ EC.throw(this.operation_name + '.' + field, error);
84
+ }
85
+ return result;
86
+ }
87
+
88
+ /**
89
+ @arg {boolean} [debug.use_default = false] - more template friendly
90
+ @arg {boolean} [debug.annotate = false] - add user-friendly information
91
+ */
92
+ toObject(serialized_object = {}, debug = {
93
+ use_default: false,
94
+ annotate: false
95
+ }) {
96
+ var result = {};
97
+ var field = null;
98
+ try {
99
+ if (!this.types) return result;
100
+ var iterable = this.keys;
101
+ for (var i = 0, field; i < iterable.length; i++) {
102
+ field = iterable[i];
103
+ var type = this.types[field];
104
+ var object = type.toObject(typeof serialized_object !== "undefined" && serialized_object !== null ? serialized_object[field] : undefined, debug);
105
+ result[field] = object;
106
+ if (HEX_DUMP) {
107
+ var b = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN);
108
+ let has_value = typeof serialized_object !== "undefined" && serialized_object !== null;
109
+ if (has_value) {
110
+ let value = serialized_object[field];
111
+ if (value) type.appendByteBuffer(b, value);
112
+ }
113
+ b = b.copy(0, b.offset);
114
+ console.error(this.operation_name + '.' + field, b.toHex());
205
115
  }
206
- }]);
207
-
208
- return Serializer;
209
- }();
210
-
116
+ }
117
+ } catch (error) {
118
+ EC.throw(this.operation_name + '.' + field, error);
119
+ }
120
+ return result;
121
+ }
122
+
123
+ /** Sort by the first element in a operation */
124
+ compare(a, b) {
125
+ let first_key = this.keys[0];
126
+ let first_type = this.types[first_key];
127
+ let valA = a[first_key];
128
+ let valB = b[first_key];
129
+ if (first_type.compare) return first_type.compare(valA, valB);
130
+ if (typeof valA === "number" && typeof valB === "number") return valA - valB;
131
+ let encoding;
132
+ if (Buffer.isBuffer(valA) && Buffer.isBuffer(valB)) {
133
+ // A binary string compare does not work. If localeCompare is well supported that could replace HEX. Performanance is very good so comparing HEX works.
134
+ encoding = "hex";
135
+ }
136
+ let strA = valA.toString(encoding);
137
+ let strB = valB.toString(encoding);
138
+ return strA > strB ? 1 : strA < strB ? -1 : 0;
139
+ }
140
+
141
+ // <helper_functions>
142
+
143
+ fromHex(hex) {
144
+ var b = ByteBuffer.fromHex(hex, ByteBuffer.LITTLE_ENDIAN);
145
+ return this.fromByteBuffer(b);
146
+ }
147
+ fromBuffer(buffer) {
148
+ var b = ByteBuffer.fromBinary(buffer.toString("binary"), ByteBuffer.LITTLE_ENDIAN);
149
+ return this.fromByteBuffer(b);
150
+ }
151
+ toHex(object) {
152
+ // return this.toBuffer(object).toString("hex")
153
+ var b = this.toByteBuffer(object);
154
+ return b.toHex();
155
+ }
156
+ toByteBuffer(object) {
157
+ var b = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN);
158
+ this.appendByteBuffer(b, object);
159
+ return b.copy(0, b.offset);
160
+ }
161
+ toBuffer(object) {
162
+ return new Buffer.from(this.toByteBuffer(object).toBinary(), 'binary');
163
+ }
164
+ }
211
165
  module.exports = Serializer;
@@ -2,16 +2,21 @@
2
2
 
3
3
  /** Console print any transaction object with zero default values. */
4
4
  module.exports = function template(op) {
5
+ var object = op.toObject(void 0, {
6
+ use_default: true,
7
+ annotate: true
8
+ });
5
9
 
6
- var object = op.toObject(void 0, { use_default: true, annotate: true });
10
+ // visual (with descriptions)
11
+ console.error(JSON.stringify(object, null, 4));
7
12
 
8
- // visual (with descriptions)
9
- console.error(JSON.stringify(object, null, 4));
13
+ // usable in a copy-paste
10
14
 
11
- // usable in a copy-paste
15
+ object = op.toObject(void 0, {
16
+ use_default: true,
17
+ annotate: false
18
+ });
12
19
 
13
- object = op.toObject(void 0, { use_default: true, annotate: false });
14
-
15
- // copy-paste one-lineer
16
- console.error(JSON.stringify(object));
20
+ // copy-paste one-lineer
21
+ console.error(JSON.stringify(object));
17
22
  };