@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.
Files changed (132) hide show
  1. package/README.md +203 -87
  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 +72 -67
  52. package/.circleci/config.yml +0 -23
  53. package/.dockerignore +0 -12
  54. package/.editorconfig +0 -20
  55. package/.eslintrc +0 -27
  56. package/LICENSE +0 -21
  57. package/circle.yml +0 -3
  58. package/config.json +0 -10
  59. package/dist/statistics.html +0 -208
  60. package/dist/steem-tests.min.js +0 -23
  61. package/dist/steem-tests.min.js.gz +0 -0
  62. package/dist/steem-tests.min.js.map +0 -1
  63. package/dist/steem.min.js +0 -18
  64. package/dist/steem.min.js.gz +0 -0
  65. package/dist/steem.min.js.map +0 -1
  66. package/lib/api/index.js +0 -422
  67. package/lib/api/methods.js +0 -413
  68. package/lib/api/transports/base.js +0 -72
  69. package/lib/api/transports/http.js +0 -172
  70. package/lib/api/transports/index.js +0 -20
  71. package/lib/api/transports/ws.js +0 -228
  72. package/lib/auth/ecc/README.md +0 -20
  73. package/lib/auth/ecc/index.js +0 -13
  74. package/lib/auth/ecc/package.json +0 -36
  75. package/lib/auth/ecc/src/address.js +0 -84
  76. package/lib/auth/ecc/src/aes.js +0 -184
  77. package/lib/auth/ecc/src/brain_key.js +0 -13
  78. package/lib/auth/ecc/src/ecdsa.js +0 -219
  79. package/lib/auth/ecc/src/ecsignature.js +0 -128
  80. package/lib/auth/ecc/src/enforce_types.js +0 -49
  81. package/lib/auth/ecc/src/hash.js +0 -67
  82. package/lib/auth/ecc/src/key_private.js +0 -212
  83. package/lib/auth/ecc/src/key_public.js +0 -215
  84. package/lib/auth/ecc/src/key_utils.js +0 -112
  85. package/lib/auth/ecc/src/signature.js +0 -187
  86. package/lib/auth/index.js +0 -126
  87. package/lib/auth/memo.js +0 -147
  88. package/lib/auth/serializer/README.md +0 -13
  89. package/lib/auth/serializer/index.js +0 -21
  90. package/lib/auth/serializer/package.json +0 -32
  91. package/lib/auth/serializer/src/ChainTypes.js +0 -90
  92. package/lib/auth/serializer/src/convert.js +0 -37
  93. package/lib/auth/serializer/src/error_with_cause.js +0 -42
  94. package/lib/auth/serializer/src/fast_parser.js +0 -77
  95. package/lib/auth/serializer/src/number_utils.js +0 -67
  96. package/lib/auth/serializer/src/object_id.js +0 -68
  97. package/lib/auth/serializer/src/operations.js +0 -787
  98. package/lib/auth/serializer/src/precision.js +0 -95
  99. package/lib/auth/serializer/src/serializer.js +0 -211
  100. package/lib/auth/serializer/src/template.js +0 -17
  101. package/lib/auth/serializer/src/types.js +0 -1238
  102. package/lib/auth/serializer/src/validation.js +0 -360
  103. package/lib/broadcast/helpers.js +0 -177
  104. package/lib/broadcast/index.js +0 -127
  105. package/lib/broadcast/operations.js +0 -255
  106. package/lib/browser.js +0 -29
  107. package/lib/config.js +0 -45
  108. package/lib/formatter.js +0 -189
  109. package/lib/index.js +0 -19
  110. package/lib/utils.js +0 -55
  111. package/node-4.dockerfile +0 -6
  112. package/node-6.dockerfile +0 -6
  113. package/test/Crypto.js +0 -100
  114. package/test/KeyFormats.js +0 -105
  115. package/test/all_types.js +0 -115
  116. package/test/api.test.js +0 -326
  117. package/test/broadcast.test.js +0 -225
  118. package/test/browser/BrowserTests.js +0 -55
  119. package/test/comment.test.js +0 -69
  120. package/test/hf20-accounts.test.js +0 -76
  121. package/test/hf21-sps.test.js +0 -78
  122. package/test/memo.test.js +0 -37
  123. package/test/number_utils.js +0 -28
  124. package/test/operations_test.js +0 -39
  125. package/test/smt.test.js +0 -347
  126. package/test/test-post.json +0 -13
  127. package/test/test.html +0 -13
  128. package/test/test_helper.js +0 -19
  129. package/test/types_test.js +0 -139
  130. package/webpack/makeConfig.js +0 -105
  131. package/webpack.config.js +0 -2
  132. package/yarn.lock +0 -3336
@@ -1,255 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = [{
4
- "roles": ["posting", "active", "owner"],
5
- "operation": "vote",
6
- "params": ["voter", "author", "permlink", "weight"]
7
- }, {
8
- "roles": ["posting", "active", "owner"],
9
- "operation": "comment",
10
- "params": ["parent_author", "parent_permlink", "author", "permlink", "title", "body", "json_metadata"]
11
- }, {
12
- "roles": ["active", "owner"],
13
- "operation": "transfer",
14
- "params": ["from", "to", "amount", "memo"]
15
- }, {
16
- "roles": ["active", "owner"],
17
- "operation": "transfer_to_vesting",
18
- "params": ["from", "to", "amount"]
19
- }, {
20
- "roles": ["active", "owner"],
21
- "operation": "withdraw_vesting",
22
- "params": ["account", "vesting_shares"]
23
- }, {
24
- "roles": ["active", "owner"],
25
- "operation": "limit_order_create",
26
- "params": ["owner", "orderid", "amount_to_sell", "min_to_receive", "fill_or_kill", "expiration"]
27
- }, {
28
- "roles": ["active", "owner"],
29
- "operation": "limit_order_cancel",
30
- "params": ["owner", "orderid"]
31
- }, {
32
- "roles": ["active", "owner"],
33
- "operation": "price",
34
- "params": ["base", "quote"]
35
- }, {
36
- "roles": ["active", "owner"],
37
- "operation": "feed_publish",
38
- "params": ["publisher", "exchange_rate"]
39
- }, {
40
- "roles": ["active", "owner"],
41
- "operation": "convert",
42
- "params": ["owner", "requestid", "amount"]
43
- }, {
44
- "roles": ["active", "owner"],
45
- "operation": "account_create",
46
- "params": ["fee", "creator", "new_account_name", "owner", "active", "posting", "memo_key", "json_metadata"]
47
- }, {
48
- "roles": ["active", "owner"],
49
- "operation": "account_update",
50
- "params": ["account", "owner", "active", "posting", "memo_key", "json_metadata"]
51
- }, {
52
- "roles": ["active", "owner"],
53
- "operation": "witness_update",
54
- "params": ["owner", "url", "block_signing_key", "props", "fee"]
55
- }, {
56
- "roles": ["active", "owner"],
57
- "operation": "account_witness_vote",
58
- "params": ["account", "witness", "approve"]
59
- }, {
60
- "roles": ["active", "owner"],
61
- "operation": "account_witness_proxy",
62
- "params": ["account", "proxy"]
63
- }, {
64
- "roles": ["active", "owner"],
65
- "operation": "pow",
66
- "params": ["worker", "input", "signature", "work"]
67
- }, {
68
- "roles": ["active", "owner"],
69
- "operation": "custom",
70
- "params": ["required_auths", "id", "data"]
71
- }, {
72
- "roles": ["posting", "active", "owner"],
73
- "operation": "delete_comment",
74
- "params": ["author", "permlink"]
75
- }, {
76
- "roles": ["posting", "active", "owner"],
77
- "operation": "custom_json",
78
- "params": ["required_auths", "required_posting_auths", "id", "json"]
79
- }, {
80
- "roles": ["posting", "active", "owner"],
81
- "operation": "comment_options",
82
- "params": ["author", "permlink", "max_accepted_payout", "percent_steem_dollars", "allow_votes", "allow_curation_rewards", "extensions"]
83
- }, {
84
- "roles": ["active", "owner"],
85
- "operation": "set_withdraw_vesting_route",
86
- "params": ["from_account", "to_account", "percent", "auto_vest"]
87
- }, {
88
- "roles": ["active", "owner"],
89
- "operation": "limit_order_create2",
90
- "params": ["owner", "orderid", "amount_to_sell", "exchange_rate", "fill_or_kill", "expiration"]
91
- }, {
92
- "roles": ["active", "owner"],
93
- "operation": "claim_account",
94
- "params": ["creator", "fee", "extensions"]
95
- }, {
96
- "roles": ["active", "owner"],
97
- "operation": "create_claimed_account",
98
- "params": ["creator", "new_account_name", "owner", "active", "posting", "memo_key", "json_metadata", "extensions"]
99
- }, {
100
- "roles": ["active", "owner"],
101
- "operation": "request_account_recovery",
102
- "params": ["recovery_account", "account_to_recover", "new_owner_authority", "extensions"]
103
- }, {
104
- "roles": ["owner"],
105
- "operation": "recover_account",
106
- "params": ["account_to_recover", "new_owner_authority", "recent_owner_authority", "extensions"]
107
- }, {
108
- "roles": ["owner"],
109
- "operation": "change_recovery_account",
110
- "params": ["account_to_recover", "new_recovery_account", "extensions"]
111
- }, {
112
- "roles": ["active", "owner"],
113
- "operation": "escrow_transfer",
114
- "params": ["from", "to", "agent", "escrow_id", "sbd_amount", "steem_amount", "fee", "ratification_deadline", "escrow_expiration", "json_meta"]
115
- }, {
116
- "roles": ["active", "owner"],
117
- "operation": "escrow_dispute",
118
- "params": ["from", "to", "agent", "who", "escrow_id"]
119
- }, {
120
- "roles": ["active", "owner"],
121
- "operation": "escrow_release",
122
- "params": ["from", "to", "agent", "who", "receiver", "escrow_id", "sbd_amount", "steem_amount"]
123
- }, {
124
- "roles": ["active", "owner"],
125
- "operation": "pow2",
126
- "params": ["input", "pow_summary"]
127
- }, {
128
- "roles": ["active", "owner"],
129
- "operation": "escrow_approve",
130
- "params": ["from", "to", "agent", "who", "escrow_id", "approve"]
131
- }, {
132
- "roles": ["active", "owner"],
133
- "operation": "transfer_to_savings",
134
- "params": ["from", "to", "amount", "memo"]
135
- }, {
136
- "roles": ["active", "owner"],
137
- "operation": "transfer_from_savings",
138
- "params": ["from", "request_id", "to", "amount", "memo"]
139
- }, {
140
- "roles": ["active", "owner"],
141
- "operation": "cancel_transfer_from_savings",
142
- "params": ["from", "request_id"]
143
- }, {
144
- "roles": ["posting", "active", "owner"],
145
- "operation": "custom_binary",
146
- "params": ["id", "data"]
147
- }, {
148
- "roles": ["owner"],
149
- "operation": "decline_voting_rights",
150
- "params": ["account", "decline"]
151
- }, {
152
- "roles": ["active", "owner"],
153
- "operation": "reset_account",
154
- "params": ["reset_account", "account_to_reset", "new_owner_authority"]
155
- }, {
156
- "roles": ["owner", "posting"],
157
- "operation": "set_reset_account",
158
- "params": ["account", "current_reset_account", "reset_account"]
159
- }, {
160
- "roles": ["posting", "active", "owner"],
161
- "operation": "claim_reward_balance",
162
- "params": ["account", "reward_steem", "reward_sbd", "reward_vests"]
163
- }, {
164
- "roles": ["active", "owner"],
165
- "operation": "delegate_vesting_shares",
166
- "params": ["delegator", "delegatee", "vesting_shares"]
167
- }, {
168
- "roles": ["active", "owner"],
169
- "operation": "account_create_with_delegation",
170
- "params": ["fee", "delegation", "creator", "new_account_name", "owner", "active", "posting", "memo_key", "json_metadata", "extensions"]
171
- }, {
172
- "roles": ["active", "owner"],
173
- "operation": "witness_set_properties",
174
- "params": ["owner", "props", "extensions"]
175
- }, {
176
- "roles": ["posting", "active", "owner"],
177
- "operation": "account_update2",
178
- "params": ["account", "owner", "active", "posting", "memo_key", "json_metadata", "posting_json_metadata", "extensions"]
179
- }, {
180
- "roles": ["active", "owner"],
181
- "operation": "create_proposal",
182
- "params": ["creator", "receiver", "start_date", "end_date", "daily_pay", "subject", "permlink", "extensions"]
183
- }, {
184
- "roles": ["active", "owner"],
185
- "operation": "update_proposal_votes",
186
- "params": ["voter", "proposal_ids", "approve", "extensions"]
187
- }, {
188
- "roles": ["active", "owner"],
189
- "operation": "remove_proposal",
190
- "params": ["proposal_owner", "proposal_ids", "extensions"]
191
- }, {
192
- "roles": ["posting", "active", "owner"],
193
- "operation": "claim_reward_balance2",
194
- "params": ["account", "reward_tokens", "extensions"]
195
- }, {
196
- "roles": ["posting", "active", "owner"],
197
- "operation": "vote2",
198
- "params": ["voter", "author", "permlink", "rshares", "extensions"]
199
- }, {
200
- "roles": ["active", "owner"],
201
- "operation": "smt_create",
202
- "params": ["control_account", "symbol", "smt_creation_fee", "precision", "extensions"]
203
- }, {
204
- "roles": ["active", "owner"],
205
- "operation": "smt_setup",
206
- "params": ["control_account", "symbol", "max_supply", "contribution_begin_time", "contribution_end_time", "launch_time", "steem_units_min", "min_unit_ratio", "max_unit_ratio", "extensions"]
207
- }, {
208
- "roles": ["active", "owner"],
209
- "operation": "smt_setup_emissions",
210
- "params": ["control_account", "symbol", "schedule_time", "emissions_unit", "interval_seconds", "interval_coount", "lep_time", "rep_time", "lep_abs_amount", "rep_abs_amount", "lep_rel_amount_numerator", "rep_rel_amount_numerator", "rel_amount_denom_bits", "remove", "floor_emissions", "extensions"]
211
- }, {
212
- "roles": ["active", "owner"],
213
- "operation": "smt_setup_ico_tier",
214
- "params": ["control_account", "symbol", "steem_units_cap", "generation_policy", "remove", "extensions"]
215
- }, {
216
- "roles": ["active", "owner"],
217
- "operation": "smt_set_setup_parameters",
218
- "params": ["control_account", "symbol", "setup_parameters", "extensions"]
219
- }, {
220
- "roles": ["active", "owner"],
221
- "operation": "smt_set_runtime_parameters",
222
- "params": ["control_account", "symbol", "runtime_parameters", "extensions"]
223
- }, {
224
- "roles": ["active", "owner"],
225
- "operation": "smt_contribute",
226
- "params": ["contributor", "symbol", "contribution_id", "contribution", "extensions"]
227
- }, {
228
- "roles": ["active", "owner"],
229
- "operation": "fill_convert_request",
230
- "params": ["owner", "requestid", "amount_in", "amount_out"]
231
- }, {
232
- "roles": ["posting", "active", "owner"],
233
- "operation": "comment_reward",
234
- "params": ["author", "permlink", "payout"]
235
- }, {
236
- "roles": ["active", "owner"],
237
- "operation": "liquidity_reward",
238
- "params": ["owner", "payout"]
239
- }, {
240
- "roles": ["active", "owner"],
241
- "operation": "interest",
242
- "params": ["owner", "interest"]
243
- }, {
244
- "roles": ["active", "owner"],
245
- "operation": "fill_vesting_withdraw",
246
- "params": ["from_account", "to_account", "withdrawn", "deposited"]
247
- }, {
248
- "roles": ["posting", "active", "owner"],
249
- "operation": "fill_order",
250
- "params": ["current_owner", "current_orderid", "current_pays", "open_owner", "open_orderid", "open_pays"]
251
- }, {
252
- "roles": ["posting", "active", "owner"],
253
- "operation": "fill_transfer_from_savings",
254
- "params": ["from", "to", "amount", "request_id", "memo"]
255
- }];
package/lib/browser.js DELETED
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- var api = require("./api");
4
- var auth = require("./auth");
5
- var memo = require("./auth/memo");
6
- var broadcast = require("./broadcast");
7
- var config = require("./config");
8
- var formatter = require("./formatter")(api);
9
- var utils = require("./utils");
10
-
11
- var steem = {
12
- api: api,
13
- auth: auth,
14
- memo: memo,
15
- broadcast: broadcast,
16
- config: config,
17
- formatter: formatter,
18
- utils: utils
19
- };
20
-
21
- if (typeof window !== "undefined") {
22
- window.steem = steem;
23
- }
24
-
25
- if (typeof global !== "undefined") {
26
- global.steem = steem;
27
- }
28
-
29
- exports = module.exports = steem;
package/lib/config.js DELETED
@@ -1,45 +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
- var _each = require('lodash/each');
6
-
7
- var _each2 = _interopRequireDefault(_each);
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
-
13
- var defaultConfig = require('../config.json');
14
-
15
- var Config = function () {
16
- function Config(c) {
17
- var _this = this;
18
-
19
- _classCallCheck(this, Config);
20
-
21
- (0, _each2.default)(c, function (value, key) {
22
- _this[key] = value;
23
- });
24
- }
25
-
26
- _createClass(Config, [{
27
- key: 'get',
28
- value: function get(k) {
29
- return this[k];
30
- }
31
- }, {
32
- key: 'set',
33
- value: function set(k, v) {
34
- this[k] = v;
35
- }
36
- }]);
37
-
38
- return Config;
39
- }();
40
-
41
- module.exports = new Config(defaultConfig);
42
- if (typeof module.exports.Config !== 'undefined') {
43
- throw new Error("default config.json file may not contain a property 'Config'");
44
- }
45
- module.exports.Config = Config;
package/lib/formatter.js DELETED
@@ -1,189 +0,0 @@
1
- "use strict";
2
-
3
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
4
-
5
- var _get = require("lodash/get");
6
-
7
- var _get2 = _interopRequireDefault(_get);
8
-
9
- var _ecc = require("./auth/ecc");
10
-
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
13
- module.exports = function (steemAPI) {
14
- function numberWithCommas(x) {
15
- return x.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
16
- }
17
-
18
- function vestingSteem(account, gprops) {
19
- var vests = parseFloat(account.vesting_shares.split(" ")[0]);
20
- var total_vests = parseFloat(gprops.total_vesting_shares.split(" ")[0]);
21
- var total_vest_steem = parseFloat(gprops.total_vesting_fund_steem.split(" ")[0]);
22
- var vesting_steemf = total_vest_steem * (vests / total_vests);
23
- return vesting_steemf;
24
- }
25
-
26
- function processOrders(open_orders, assetPrecision) {
27
- var sbdOrders = !open_orders ? 0 : open_orders.reduce(function (o, order) {
28
- if (order.sell_price.base.indexOf("SBD") !== -1) {
29
- o += order.for_sale;
30
- }
31
- return o;
32
- }, 0) / assetPrecision;
33
-
34
- var steemOrders = !open_orders ? 0 : open_orders.reduce(function (o, order) {
35
- if (order.sell_price.base.indexOf("STEEM") !== -1) {
36
- o += order.for_sale;
37
- }
38
- return o;
39
- }, 0) / assetPrecision;
40
-
41
- return { steemOrders: steemOrders, sbdOrders: sbdOrders };
42
- }
43
-
44
- function calculateSaving(savings_withdraws) {
45
- var savings_pending = 0;
46
- var savings_sbd_pending = 0;
47
- savings_withdraws.forEach(function (withdraw) {
48
- var _withdraw$amount$spli = withdraw.amount.split(" "),
49
- _withdraw$amount$spli2 = _slicedToArray(_withdraw$amount$spli, 2),
50
- amount = _withdraw$amount$spli2[0],
51
- asset = _withdraw$amount$spli2[1];
52
-
53
- if (asset === "STEEM") savings_pending += parseFloat(amount);else {
54
- if (asset === "SBD") savings_sbd_pending += parseFloat(amount);
55
- }
56
- });
57
- return { savings_pending: savings_pending, savings_sbd_pending: savings_sbd_pending };
58
- }
59
-
60
- function pricePerSteem(feed_price) {
61
- var price_per_steem = undefined;
62
- var base = feed_price.base,
63
- quote = feed_price.quote;
64
-
65
- if (/ SBD$/.test(base) && / STEEM$/.test(quote)) {
66
- price_per_steem = parseFloat(base.split(" ")[0]) / parseFloat(quote.split(" ")[0]);
67
- }
68
- return price_per_steem;
69
- }
70
-
71
- function estimateAccountValue(account) {
72
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
73
- gprops = _ref.gprops,
74
- feed_price = _ref.feed_price,
75
- open_orders = _ref.open_orders,
76
- savings_withdraws = _ref.savings_withdraws,
77
- vesting_steem = _ref.vesting_steem;
78
-
79
- var promises = [];
80
- var username = account.name;
81
- var assetPrecision = 1000;
82
- var orders = void 0,
83
- savings = void 0;
84
-
85
- if (!vesting_steem || !feed_price) {
86
- if (!gprops || !feed_price) {
87
- promises.push(steemAPI.getStateAsync("/@" + username).then(function (data) {
88
- gprops = data.props;
89
- feed_price = data.feed_price;
90
- vesting_steem = vestingSteem(account, gprops);
91
- }));
92
- } else {
93
- vesting_steem = vestingSteem(account, gprops);
94
- }
95
- }
96
-
97
- if (!open_orders) {
98
- promises.push(steemAPI.getOpenOrdersAsync(username).then(function (open_orders) {
99
- orders = processOrders(open_orders, assetPrecision);
100
- }));
101
- } else {
102
- orders = processOrders(open_orders, assetPrecision);
103
- }
104
-
105
- if (!savings_withdraws) {
106
- promises.push(steemAPI.getSavingsWithdrawFromAsync(username).then(function (savings_withdraws) {
107
- savings = calculateSaving(savings_withdraws);
108
- }));
109
- } else {
110
- savings = calculateSaving(savings_withdraws);
111
- }
112
-
113
- return Promise.all(promises).then(function () {
114
- var price_per_steem = pricePerSteem(feed_price);
115
-
116
- var savings_balance = account.savings_balance;
117
- var savings_sbd_balance = account.savings_sbd_balance;
118
- var balance_steem = parseFloat(account.balance.split(" ")[0]);
119
- var saving_balance_steem = parseFloat(savings_balance.split(" ")[0]);
120
- var sbd_balance = parseFloat(account.sbd_balance);
121
- var sbd_balance_savings = parseFloat(savings_sbd_balance.split(" ")[0]);
122
-
123
- var conversionValue = 0;
124
- var currentTime = new Date().getTime();
125
- (account.other_history || []).reduce(function (out, item) {
126
- if ((0, _get2.default)(item, [1, "op", 0], "") !== "convert") return out;
127
-
128
- var timestamp = new Date((0, _get2.default)(item, [1, "timestamp"])).getTime();
129
- var finishTime = timestamp + 86400000 * 3.5; // add 3.5day conversion delay
130
- if (finishTime < currentTime) return out;
131
-
132
- var amount = parseFloat((0, _get2.default)(item, [1, "op", 1, "amount"]).replace(" SBD", ""));
133
- conversionValue += amount;
134
- }, []);
135
-
136
- var total_sbd = sbd_balance + sbd_balance_savings + savings.savings_sbd_pending + orders.sbdOrders + conversionValue;
137
-
138
- var total_steem = vesting_steem + balance_steem + saving_balance_steem + savings.savings_pending + orders.steemOrders;
139
-
140
- return (total_steem * price_per_steem + total_sbd).toFixed(2);
141
- });
142
- }
143
-
144
- function createSuggestedPassword() {
145
- var PASSWORD_LENGTH = 32;
146
- var privateKey = _ecc.key_utils.get_random_key();
147
- return privateKey.toWif().substring(3, 3 + PASSWORD_LENGTH);
148
- }
149
-
150
- return {
151
- reputation: function reputation(_reputation) {
152
- if (_reputation == null) return _reputation;
153
- _reputation = parseInt(_reputation);
154
- var rep = String(_reputation);
155
- var neg = rep.charAt(0) === "-";
156
- rep = neg ? rep.substring(1) : rep;
157
- var str = rep;
158
- var leadingDigits = parseInt(str.substring(0, 4));
159
- var log = Math.log(leadingDigits) / Math.log(10);
160
- var n = str.length - 1;
161
- var out = n + (log - parseInt(log));
162
- if (isNaN(out)) out = 0;
163
- out = Math.max(out - 9, 0);
164
- out = (neg ? -1 : 1) * out;
165
- out = out * 9 + 25;
166
- out = parseInt(out);
167
- return out;
168
- },
169
-
170
- vestToSteem: function vestToSteem(vestingShares, totalVestingShares, totalVestingFundSteem) {
171
- return parseFloat(totalVestingFundSteem) * (parseFloat(vestingShares) / parseFloat(totalVestingShares));
172
- },
173
-
174
- commentPermlink: function commentPermlink(parentAuthor, parentPermlink) {
175
- var timeStr = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, "").toLowerCase();
176
- parentPermlink = parentPermlink.replace(/(-\d{8}t\d{9}z)/g, "");
177
- return "re-" + parentAuthor + "-" + parentPermlink + "-" + timeStr;
178
- },
179
-
180
- amount: function amount(_amount, asset) {
181
- return _amount.toFixed(3) + " " + asset;
182
- },
183
- numberWithCommas: numberWithCommas,
184
- vestingSteem: vestingSteem,
185
- estimateAccountValue: estimateAccountValue,
186
- createSuggestedPassword: createSuggestedPassword,
187
- pricePerSteem: pricePerSteem
188
- };
189
- };
package/lib/index.js DELETED
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var api = require('./api');
4
- var auth = require('./auth');
5
- var broadcast = require('./broadcast');
6
- var formatter = require('./formatter')(api);
7
- var memo = require('./auth/memo');
8
- var config = require('./config');
9
- var utils = require('./utils');
10
-
11
- module.exports = {
12
- api: api,
13
- auth: auth,
14
- broadcast: broadcast,
15
- formatter: formatter,
16
- memo: memo,
17
- config: config,
18
- utils: utils
19
- };
package/lib/utils.js DELETED
@@ -1,55 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.camelCase = camelCase;
7
- exports.validateAccountName = validateAccountName;
8
- var snakeCaseRe = /_([a-z])/g;
9
- function camelCase(str) {
10
- return str.replace(snakeCaseRe, function (_m, l) {
11
- return l.toUpperCase();
12
- });
13
- }
14
-
15
- function validateAccountName(value) {
16
- var i = void 0,
17
- label = void 0,
18
- len = void 0,
19
- suffix = void 0;
20
-
21
- suffix = "Account name should ";
22
- if (!value) {
23
- return suffix + "not be empty.";
24
- }
25
- var length = value.length;
26
- if (length < 3) {
27
- return suffix + "be longer.";
28
- }
29
- if (length > 16) {
30
- return suffix + "be shorter.";
31
- }
32
- if (/\./.test(value)) {
33
- suffix = "Each account segment should ";
34
- }
35
- var ref = value.split(".");
36
- for (i = 0, len = ref.length; i < len; i++) {
37
- label = ref[i];
38
- if (!/^[a-z]/.test(label)) {
39
- return suffix + "start with a letter.";
40
- }
41
- if (!/^[a-z0-9-]*$/.test(label)) {
42
- return suffix + "have only letters, digits, or dashes.";
43
- }
44
- if (/--/.test(label)) {
45
- return suffix + "have only one dash in a row.";
46
- }
47
- if (!/[a-z0-9]$/.test(label)) {
48
- return suffix + "end with a letter or digit.";
49
- }
50
- if (!(label.length >= 3)) {
51
- return suffix + "be longer";
52
- }
53
- }
54
- return null;
55
- }
package/node-4.dockerfile DELETED
@@ -1,6 +0,0 @@
1
- FROM node:4
2
- ADD ./package.json /steemjs/package.json
3
- WORKDIR /steemjs
4
- RUN npm install
5
- ADD . /steemjs
6
- RUN npm test
package/node-6.dockerfile DELETED
@@ -1,6 +0,0 @@
1
- FROM node:6
2
- ADD ./package.json /steemjs/package.json
3
- WORKDIR /steemjs
4
- RUN npm install
5
- ADD . /steemjs
6
- RUN npm test