@steemit/steem-js 0.8.0 → 1.0.1
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 +202 -105
- 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/transaction.d.ts +5 -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 +27 -0
- package/dist/crypto/index.d.ts +25 -0
- package/dist/formatter/index.d.ts +92 -0
- package/dist/index.cjs +26436 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +26400 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +58121 -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/debug.d.ts +36 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils.d.ts +2 -0
- package/package.json +68 -87
- 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/steem-tests.min.js +0 -4097
- package/dist/steem.min.js +0 -2089
- package/docker-webpack.config.js +0 -44
- package/lib/api/index.js +0 -315
- package/lib/api/methods.js +0 -428
- package/lib/api/rpc-auth.js +0 -135
- package/lib/api/transports/base.js +0 -31
- package/lib/api/transports/http.js +0 -157
- package/lib/api/transports/index.js +0 -13
- package/lib/api/transports/ws.js +0 -128
- package/lib/auth/ecc/index.js +0 -13
- package/lib/auth/ecc/src/address.js +0 -54
- package/lib/auth/ecc/src/aes.js +0 -148
- package/lib/auth/ecc/src/brain_key.js +0 -13
- package/lib/auth/ecc/src/ecdsa.js +0 -193
- package/lib/auth/ecc/src/ecsignature.js +0 -102
- package/lib/auth/ecc/src/enforce_types.js +0 -42
- package/lib/auth/ecc/src/hash.js +0 -58
- package/lib/auth/ecc/src/key_private.js +0 -159
- package/lib/auth/ecc/src/key_public.js +0 -143
- package/lib/auth/ecc/src/key_utils.js +0 -70
- package/lib/auth/ecc/src/signature.js +0 -135
- package/lib/auth/index.js +0 -113
- package/lib/auth/memo.js +0 -119
- package/lib/auth/serializer/index.js +0 -15
- package/lib/auth/serializer/src/ChainTypes.js +0 -87
- package/lib/auth/serializer/src/convert.js +0 -34
- package/lib/auth/serializer/src/error_with_cause.js +0 -27
- package/lib/auth/serializer/src/fast_parser.js +0 -57
- package/lib/auth/serializer/src/number_utils.js +0 -43
- package/lib/auth/serializer/src/object_id.js +0 -43
- package/lib/auth/serializer/src/operations.js +0 -695
- package/lib/auth/serializer/src/precision.js +0 -77
- package/lib/auth/serializer/src/serializer.js +0 -165
- package/lib/auth/serializer/src/template.js +0 -22
- package/lib/auth/serializer/src/types.js +0 -1085
- package/lib/auth/serializer/src/validation.js +0 -300
- package/lib/broadcast/helpers.js +0 -140
- package/lib/broadcast/index.js +0 -106
- package/lib/broadcast/operations.js +0 -255
- package/lib/browser.js +0 -25
- package/lib/config.js +0 -23
- package/lib/formatter.js +0 -163
- package/lib/index.js +0 -21
- package/lib/utils.js +0 -50
- package/node-18.dockerfile +0 -28
- 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 -363
- package/test/broadcast.test.js +0 -231
- package/test/browser/BrowserTests.js +0 -55
- package/test/comment.test.js +0 -83
- 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/promise-broadcast.test.js +0 -86
- package/test/reputation.test.js +0 -68
- 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/test-github-workflow.bat +0 -19
- package/test-github-workflow.sh +0 -15
- package/webpack/makeConfig.js +0 -113
- package/webpack.config.js +0 -2
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const assert = require("assert");
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
Convert 12.34 with a precision of 3 into 12340
|
|
7
|
-
|
|
8
|
-
@arg {number|string} number - Use strings for large numbers. This may contain one decimal but no sign
|
|
9
|
-
@arg {number} precision - number of implied decimal places (usually causes right zero padding)
|
|
10
|
-
@return {string} -
|
|
11
|
-
*/
|
|
12
|
-
function toImpliedDecimal(number, precision) {
|
|
13
|
-
if (typeof number === "number") {
|
|
14
|
-
assert(number <= 9007199254740991, "overflow");
|
|
15
|
-
number = "" + number;
|
|
16
|
-
} else if (number.toString) number = number.toString();
|
|
17
|
-
assert(typeof number === "string", "number should be an actual number or string: " + typeof number);
|
|
18
|
-
number = number.trim();
|
|
19
|
-
assert(/^[0-9]*\.?[0-9]*$/.test(number), "Invalid decimal number " + number);
|
|
20
|
-
let [whole = "", decimal = ""] = number.split(".");
|
|
21
|
-
let padding = precision - decimal.length;
|
|
22
|
-
assert(padding >= 0, "Too many decimal digits in " + number + " to create an implied decimal of " + precision);
|
|
23
|
-
for (let i = 0; i < padding; i++) decimal += "0";
|
|
24
|
-
while (whole.charAt(0) === "0") whole = whole.substring(1);
|
|
25
|
-
return whole + decimal;
|
|
26
|
-
}
|
|
27
|
-
function fromImpliedDecimal(number, precision) {
|
|
28
|
-
if (typeof number === "number") {
|
|
29
|
-
assert(number <= 9007199254740991, "overflow");
|
|
30
|
-
number = "" + number;
|
|
31
|
-
} else if (number.toString) number = number.toString();
|
|
32
|
-
while (number.length < precision + 1)
|
|
33
|
-
// 0.123
|
|
34
|
-
number = "0" + number;
|
|
35
|
-
|
|
36
|
-
// 44000 => 44.000
|
|
37
|
-
let dec_string = number.substring(number.length - precision);
|
|
38
|
-
return number.substring(0, number.length - precision) + (dec_string ? "." + dec_string : "");
|
|
39
|
-
}
|
|
40
|
-
module.exports = {
|
|
41
|
-
toImpliedDecimal,
|
|
42
|
-
fromImpliedDecimal
|
|
43
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var Long = require('bytebuffer').Long;
|
|
4
|
-
var v = require('./validation');
|
|
5
|
-
var DB_MAX_INSTANCE_ID = Long.fromNumber(Math.pow(2, 48) - 1);
|
|
6
|
-
class ObjectId {
|
|
7
|
-
constructor(space, type, instance) {
|
|
8
|
-
this.space = space;
|
|
9
|
-
this.type = type;
|
|
10
|
-
this.instance = instance;
|
|
11
|
-
var instance_string = this.instance.toString();
|
|
12
|
-
var object_id = `${this.space}.${this.type}.${instance_string}`;
|
|
13
|
-
if (!v.is_digits(instance_string)) {
|
|
14
|
-
throw new `Invalid object id ${object_id}`();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
static fromString(value) {
|
|
18
|
-
if (value.space !== undefined && value.type !== undefined && value.instance !== undefined) {
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
var params = v.require_match(/^([0-9]+)\.([0-9]+)\.([0-9]+)$/, v.required(value, "object_id"), "object_id");
|
|
22
|
-
return new ObjectId(parseInt(params[1]), parseInt(params[2]), Long.fromString(params[3]));
|
|
23
|
-
}
|
|
24
|
-
static fromLong(long) {
|
|
25
|
-
var space = long.shiftRight(56).toInt();
|
|
26
|
-
var type = long.shiftRight(48).toInt() & 0x00ff;
|
|
27
|
-
var instance = long.and(DB_MAX_INSTANCE_ID);
|
|
28
|
-
return new ObjectId(space, type, instance);
|
|
29
|
-
}
|
|
30
|
-
static fromByteBuffer(b) {
|
|
31
|
-
return ObjectId.fromLong(b.readUint64());
|
|
32
|
-
}
|
|
33
|
-
toLong() {
|
|
34
|
-
return Long.fromNumber(this.space).shiftLeft(56).or(Long.fromNumber(this.type).shiftLeft(48).or(this.instance));
|
|
35
|
-
}
|
|
36
|
-
appendByteBuffer(b) {
|
|
37
|
-
return b.writeUint64(this.toLong());
|
|
38
|
-
}
|
|
39
|
-
toString() {
|
|
40
|
-
return `${this.space}.${this.type}.${this.instance.toString()}`;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
module.exports = ObjectId;
|