@steemit/steem-js 0.7.11 → 1.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/README.md +203 -87
- package/dist/api/index.d.ts +128 -0
- package/dist/api/methods.d.ts +9 -0
- package/dist/api/rpc-auth.d.ts +43 -0
- package/dist/api/transports/base.d.ts +13 -0
- package/dist/api/transports/http.d.ts +9 -0
- package/dist/api/transports/index.d.ts +9 -0
- package/dist/api/transports/types.d.ts +35 -0
- package/dist/api/transports/ws.d.ts +18 -0
- package/dist/auth/ecc/index.d.ts +9 -0
- package/dist/auth/ecc/src/address.d.ts +13 -0
- package/dist/auth/ecc/src/aes.d.ts +16 -0
- package/dist/auth/ecc/src/brain_key.d.ts +1 -0
- package/dist/auth/ecc/src/ecdsa.d.ts +28 -0
- package/dist/auth/ecc/src/ecsignature.d.ts +19 -0
- package/dist/auth/ecc/src/enforce_types.d.ts +5 -0
- package/dist/auth/ecc/src/hash.d.ts +25 -0
- package/dist/auth/ecc/src/index.d.ts +9 -0
- package/dist/auth/ecc/src/key_private.d.ts +38 -0
- package/dist/auth/ecc/src/key_public.d.ts +41 -0
- package/dist/auth/ecc/src/key_utils.d.ts +9 -0
- package/dist/auth/ecc/src/signature.d.ts +18 -0
- package/dist/auth/ecc.d.ts +3 -0
- package/dist/auth/index.d.ts +48 -0
- package/dist/auth/key_classes.d.ts +3 -0
- package/dist/auth/serializer.d.ts +19 -0
- package/dist/broadcast/helpers.d.ts +11 -0
- package/dist/broadcast/index.d.ts +43 -0
- package/dist/broadcast/operations.d.ts +6 -0
- package/dist/config.d.ts +25 -0
- package/dist/crypto/index.d.ts +25 -0
- package/dist/formatter/index.d.ts +92 -0
- package/dist/index.cjs +25848 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +25812 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +57513 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/memo/index.d.ts +11 -0
- package/dist/operations/index.d.ts +44 -0
- package/dist/serializer/convert.d.ts +12 -0
- package/dist/serializer/index.d.ts +11 -0
- package/dist/serializer/number_utils.d.ts +8 -0
- package/dist/serializer/precision.d.ts +5 -0
- package/dist/serializer/types.d.ts +36 -0
- package/dist/types/index.d.ts +131 -0
- package/dist/types.d.ts +34 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils.d.ts +2 -0
- package/package.json +72 -67
- package/.circleci/config.yml +0 -23
- package/.dockerignore +0 -12
- package/.editorconfig +0 -20
- package/.eslintrc +0 -27
- package/LICENSE +0 -21
- package/circle.yml +0 -3
- package/config.json +0 -10
- package/dist/statistics.html +0 -208
- package/dist/steem-tests.min.js +0 -23
- package/dist/steem-tests.min.js.gz +0 -0
- package/dist/steem-tests.min.js.map +0 -1
- package/dist/steem.min.js +0 -18
- package/dist/steem.min.js.gz +0 -0
- package/dist/steem.min.js.map +0 -1
- package/lib/api/index.js +0 -422
- package/lib/api/methods.js +0 -413
- package/lib/api/transports/base.js +0 -72
- package/lib/api/transports/http.js +0 -172
- package/lib/api/transports/index.js +0 -20
- package/lib/api/transports/ws.js +0 -228
- package/lib/auth/ecc/README.md +0 -20
- package/lib/auth/ecc/index.js +0 -13
- package/lib/auth/ecc/package.json +0 -36
- package/lib/auth/ecc/src/address.js +0 -84
- package/lib/auth/ecc/src/aes.js +0 -184
- package/lib/auth/ecc/src/brain_key.js +0 -13
- package/lib/auth/ecc/src/ecdsa.js +0 -219
- package/lib/auth/ecc/src/ecsignature.js +0 -128
- package/lib/auth/ecc/src/enforce_types.js +0 -49
- package/lib/auth/ecc/src/hash.js +0 -67
- package/lib/auth/ecc/src/key_private.js +0 -212
- package/lib/auth/ecc/src/key_public.js +0 -215
- package/lib/auth/ecc/src/key_utils.js +0 -112
- package/lib/auth/ecc/src/signature.js +0 -187
- package/lib/auth/index.js +0 -126
- package/lib/auth/memo.js +0 -147
- package/lib/auth/serializer/README.md +0 -13
- package/lib/auth/serializer/index.js +0 -21
- package/lib/auth/serializer/package.json +0 -32
- package/lib/auth/serializer/src/ChainTypes.js +0 -90
- package/lib/auth/serializer/src/convert.js +0 -37
- package/lib/auth/serializer/src/error_with_cause.js +0 -42
- package/lib/auth/serializer/src/fast_parser.js +0 -77
- package/lib/auth/serializer/src/number_utils.js +0 -67
- package/lib/auth/serializer/src/object_id.js +0 -68
- package/lib/auth/serializer/src/operations.js +0 -787
- package/lib/auth/serializer/src/precision.js +0 -95
- package/lib/auth/serializer/src/serializer.js +0 -211
- package/lib/auth/serializer/src/template.js +0 -17
- package/lib/auth/serializer/src/types.js +0 -1238
- package/lib/auth/serializer/src/validation.js +0 -360
- package/lib/broadcast/helpers.js +0 -177
- package/lib/broadcast/index.js +0 -127
- package/lib/broadcast/operations.js +0 -255
- package/lib/browser.js +0 -29
- package/lib/config.js +0 -45
- package/lib/formatter.js +0 -189
- package/lib/index.js +0 -19
- package/lib/utils.js +0 -55
- package/node-4.dockerfile +0 -6
- package/node-6.dockerfile +0 -6
- package/test/Crypto.js +0 -100
- package/test/KeyFormats.js +0 -105
- package/test/all_types.js +0 -115
- package/test/api.test.js +0 -326
- package/test/broadcast.test.js +0 -225
- package/test/browser/BrowserTests.js +0 -55
- package/test/comment.test.js +0 -69
- package/test/hf20-accounts.test.js +0 -76
- package/test/hf21-sps.test.js +0 -78
- package/test/memo.test.js +0 -37
- package/test/number_utils.js +0 -28
- package/test/operations_test.js +0 -39
- package/test/smt.test.js +0 -347
- package/test/test-post.json +0 -13
- package/test/test.html +0 -13
- package/test/test_helper.js +0 -19
- package/test/types_test.js +0 -139
- package/webpack/makeConfig.js +0 -105
- package/webpack.config.js +0 -2
- package/yarn.lock +0 -3336
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _my;
|
|
4
|
-
var _internal;
|
|
5
|
-
var v = require('./validation');
|
|
6
|
-
var BigInteger = require('bigi');
|
|
7
|
-
|
|
8
|
-
module.exports = _my =
|
|
9
|
-
|
|
10
|
-
// Result may be used for int64 types (like transfer amount). Asset's
|
|
11
|
-
// precision is used to convert the number to a whole number with an implied
|
|
12
|
-
// decimal place.
|
|
13
|
-
|
|
14
|
-
// "1.01" with a precision of 2 returns long 101
|
|
15
|
-
// See http://cryptocoinjs.com/modules/misc/bigi/#example
|
|
16
|
-
{
|
|
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
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// _internal is for low-level transaction code
|
|
39
|
-
module.exports._internal = _internal =
|
|
40
|
-
|
|
41
|
-
// Warning: Long operations may over-flow without detection
|
|
42
|
-
{
|
|
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
|
-
}
|
|
92
|
-
|
|
93
|
-
return sign + int_part + decimal_part;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
@@ -1,211 +0,0 @@
|
|
|
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"); } }
|
|
6
|
-
|
|
7
|
-
var ByteBuffer = require('bytebuffer');
|
|
8
|
-
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";
|
|
166
|
-
}
|
|
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();
|
|
193
|
-
}
|
|
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');
|
|
205
|
-
}
|
|
206
|
-
}]);
|
|
207
|
-
|
|
208
|
-
return Serializer;
|
|
209
|
-
}();
|
|
210
|
-
|
|
211
|
-
module.exports = Serializer;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/** Console print any transaction object with zero default values. */
|
|
4
|
-
module.exports = function template(op) {
|
|
5
|
-
|
|
6
|
-
var object = op.toObject(void 0, { use_default: true, annotate: true });
|
|
7
|
-
|
|
8
|
-
// visual (with descriptions)
|
|
9
|
-
console.error(JSON.stringify(object, null, 4));
|
|
10
|
-
|
|
11
|
-
// usable in a copy-paste
|
|
12
|
-
|
|
13
|
-
object = op.toObject(void 0, { use_default: true, annotate: false });
|
|
14
|
-
|
|
15
|
-
// copy-paste one-lineer
|
|
16
|
-
console.error(JSON.stringify(object));
|
|
17
|
-
};
|