@steemit/steem-js 0.8.0 → 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.
Files changed (126) hide show
  1. package/README.md +202 -105
  2. package/dist/api/index.d.ts +128 -0
  3. package/dist/api/methods.d.ts +9 -0
  4. package/dist/api/rpc-auth.d.ts +43 -0
  5. package/dist/api/transports/base.d.ts +13 -0
  6. package/dist/api/transports/http.d.ts +9 -0
  7. package/dist/api/transports/index.d.ts +9 -0
  8. package/dist/api/transports/types.d.ts +35 -0
  9. package/dist/api/transports/ws.d.ts +18 -0
  10. package/dist/auth/ecc/index.d.ts +9 -0
  11. package/dist/auth/ecc/src/address.d.ts +13 -0
  12. package/dist/auth/ecc/src/aes.d.ts +16 -0
  13. package/dist/auth/ecc/src/brain_key.d.ts +1 -0
  14. package/dist/auth/ecc/src/ecdsa.d.ts +28 -0
  15. package/dist/auth/ecc/src/ecsignature.d.ts +19 -0
  16. package/dist/auth/ecc/src/enforce_types.d.ts +5 -0
  17. package/dist/auth/ecc/src/hash.d.ts +25 -0
  18. package/dist/auth/ecc/src/index.d.ts +9 -0
  19. package/dist/auth/ecc/src/key_private.d.ts +38 -0
  20. package/dist/auth/ecc/src/key_public.d.ts +41 -0
  21. package/dist/auth/ecc/src/key_utils.d.ts +9 -0
  22. package/dist/auth/ecc/src/signature.d.ts +18 -0
  23. package/dist/auth/ecc.d.ts +3 -0
  24. package/dist/auth/index.d.ts +48 -0
  25. package/dist/auth/key_classes.d.ts +3 -0
  26. package/dist/auth/serializer.d.ts +19 -0
  27. package/dist/broadcast/helpers.d.ts +11 -0
  28. package/dist/broadcast/index.d.ts +43 -0
  29. package/dist/broadcast/operations.d.ts +6 -0
  30. package/dist/config.d.ts +25 -0
  31. package/dist/crypto/index.d.ts +25 -0
  32. package/dist/formatter/index.d.ts +92 -0
  33. package/dist/index.cjs +25848 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.ts +30 -0
  36. package/dist/index.js +25812 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/index.umd.js +57513 -0
  39. package/dist/index.umd.js.map +1 -0
  40. package/dist/memo/index.d.ts +11 -0
  41. package/dist/operations/index.d.ts +44 -0
  42. package/dist/serializer/convert.d.ts +12 -0
  43. package/dist/serializer/index.d.ts +11 -0
  44. package/dist/serializer/number_utils.d.ts +8 -0
  45. package/dist/serializer/precision.d.ts +5 -0
  46. package/dist/serializer/types.d.ts +36 -0
  47. package/dist/types/index.d.ts +131 -0
  48. package/dist/types.d.ts +34 -0
  49. package/dist/utils/index.d.ts +8 -0
  50. package/dist/utils.d.ts +2 -0
  51. package/package.json +68 -87
  52. package/.dockerignore +0 -12
  53. package/.editorconfig +0 -20
  54. package/.eslintrc +0 -27
  55. package/LICENSE +0 -21
  56. package/circle.yml +0 -3
  57. package/config.json +0 -10
  58. package/dist/steem-tests.min.js +0 -4097
  59. package/dist/steem.min.js +0 -2089
  60. package/docker-webpack.config.js +0 -44
  61. package/lib/api/index.js +0 -315
  62. package/lib/api/methods.js +0 -428
  63. package/lib/api/rpc-auth.js +0 -135
  64. package/lib/api/transports/base.js +0 -31
  65. package/lib/api/transports/http.js +0 -157
  66. package/lib/api/transports/index.js +0 -13
  67. package/lib/api/transports/ws.js +0 -128
  68. package/lib/auth/ecc/index.js +0 -13
  69. package/lib/auth/ecc/src/address.js +0 -54
  70. package/lib/auth/ecc/src/aes.js +0 -148
  71. package/lib/auth/ecc/src/brain_key.js +0 -13
  72. package/lib/auth/ecc/src/ecdsa.js +0 -193
  73. package/lib/auth/ecc/src/ecsignature.js +0 -102
  74. package/lib/auth/ecc/src/enforce_types.js +0 -42
  75. package/lib/auth/ecc/src/hash.js +0 -58
  76. package/lib/auth/ecc/src/key_private.js +0 -159
  77. package/lib/auth/ecc/src/key_public.js +0 -143
  78. package/lib/auth/ecc/src/key_utils.js +0 -70
  79. package/lib/auth/ecc/src/signature.js +0 -135
  80. package/lib/auth/index.js +0 -113
  81. package/lib/auth/memo.js +0 -119
  82. package/lib/auth/serializer/index.js +0 -15
  83. package/lib/auth/serializer/src/ChainTypes.js +0 -87
  84. package/lib/auth/serializer/src/convert.js +0 -34
  85. package/lib/auth/serializer/src/error_with_cause.js +0 -27
  86. package/lib/auth/serializer/src/fast_parser.js +0 -57
  87. package/lib/auth/serializer/src/number_utils.js +0 -43
  88. package/lib/auth/serializer/src/object_id.js +0 -43
  89. package/lib/auth/serializer/src/operations.js +0 -695
  90. package/lib/auth/serializer/src/precision.js +0 -77
  91. package/lib/auth/serializer/src/serializer.js +0 -165
  92. package/lib/auth/serializer/src/template.js +0 -22
  93. package/lib/auth/serializer/src/types.js +0 -1085
  94. package/lib/auth/serializer/src/validation.js +0 -300
  95. package/lib/broadcast/helpers.js +0 -140
  96. package/lib/broadcast/index.js +0 -106
  97. package/lib/broadcast/operations.js +0 -255
  98. package/lib/browser.js +0 -25
  99. package/lib/config.js +0 -23
  100. package/lib/formatter.js +0 -163
  101. package/lib/index.js +0 -21
  102. package/lib/utils.js +0 -50
  103. package/node-18.dockerfile +0 -28
  104. package/test/Crypto.js +0 -100
  105. package/test/KeyFormats.js +0 -105
  106. package/test/all_types.js +0 -115
  107. package/test/api.test.js +0 -363
  108. package/test/broadcast.test.js +0 -231
  109. package/test/browser/BrowserTests.js +0 -55
  110. package/test/comment.test.js +0 -83
  111. package/test/hf20-accounts.test.js +0 -76
  112. package/test/hf21-sps.test.js +0 -78
  113. package/test/memo.test.js +0 -37
  114. package/test/number_utils.js +0 -28
  115. package/test/operations_test.js +0 -39
  116. package/test/promise-broadcast.test.js +0 -86
  117. package/test/reputation.test.js +0 -68
  118. package/test/smt.test.js +0 -347
  119. package/test/test-post.json +0 -13
  120. package/test/test.html +0 -13
  121. package/test/test_helper.js +0 -19
  122. package/test/types_test.js +0 -139
  123. package/test-github-workflow.bat +0 -19
  124. package/test-github-workflow.sh +0 -15
  125. package/webpack/makeConfig.js +0 -113
  126. package/webpack.config.js +0 -2
@@ -1,77 +0,0 @@
1
- "use strict";
2
-
3
- var _my;
4
- var _internal;
5
- var v = require('./validation');
6
- var BigInteger = require('bigi');
7
- module.exports = _my =
8
- // Result may be used for int64 types (like transfer amount). Asset's
9
- // precision is used to convert the number to a whole number with an implied
10
- // decimal place.
11
-
12
- // "1.01" with a precision of 2 returns long 101
13
- // See http://cryptocoinjs.com/modules/misc/bigi/#example
14
- {
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
- }
28
- };
29
-
30
- // _internal is for low-level transaction code
31
- module.exports._internal = _internal =
32
- // Warning: Long operations may over-flow without detection
33
- {
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
- }
57
-
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";
74
- }
75
- return sign + int_part + decimal_part;
76
- }
77
- };
@@ -1,165 +0,0 @@
1
- "use strict";
2
-
3
- var ByteBuffer = require('bytebuffer');
4
- var EC = require('./error_with_cause');
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());
33
- }
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;
42
- }
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());
115
- }
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
- }
165
- module.exports = Serializer;
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- /** Console print any transaction object with zero default values. */
4
- module.exports = function template(op) {
5
- var object = op.toObject(void 0, {
6
- use_default: true,
7
- annotate: true
8
- });
9
-
10
- // visual (with descriptions)
11
- console.error(JSON.stringify(object, null, 4));
12
-
13
- // usable in a copy-paste
14
-
15
- object = op.toObject(void 0, {
16
- use_default: true,
17
- annotate: false
18
- });
19
-
20
- // copy-paste one-lineer
21
- console.error(JSON.stringify(object));
22
- };