@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.
- 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.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 +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,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,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const api = require("./api");
|
|
4
|
-
const auth = require("./auth");
|
|
5
|
-
const memo = require("./auth/memo");
|
|
6
|
-
const broadcast = require("./broadcast");
|
|
7
|
-
const config = require("./config");
|
|
8
|
-
const formatter = require("./formatter")(api);
|
|
9
|
-
const utils = require("./utils");
|
|
10
|
-
const steem = {
|
|
11
|
-
api,
|
|
12
|
-
auth,
|
|
13
|
-
memo,
|
|
14
|
-
broadcast,
|
|
15
|
-
config,
|
|
16
|
-
formatter,
|
|
17
|
-
utils
|
|
18
|
-
};
|
|
19
|
-
if (typeof window !== "undefined") {
|
|
20
|
-
window.steem = steem;
|
|
21
|
-
}
|
|
22
|
-
if (typeof global !== "undefined") {
|
|
23
|
-
global.steem = steem;
|
|
24
|
-
}
|
|
25
|
-
exports = module.exports = steem;
|
package/lib/config.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _each = _interopRequireDefault(require("lodash/each"));
|
|
4
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
5
|
-
const defaultConfig = require('../config.json');
|
|
6
|
-
class Config {
|
|
7
|
-
constructor(c) {
|
|
8
|
-
(0, _each.default)(c, (value, key) => {
|
|
9
|
-
this[key] = value;
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
get(k) {
|
|
13
|
-
return this[k];
|
|
14
|
-
}
|
|
15
|
-
set(k, v) {
|
|
16
|
-
this[k] = v;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
module.exports = new Config(defaultConfig);
|
|
20
|
-
if (typeof module.exports.Config !== 'undefined') {
|
|
21
|
-
throw new Error("default config.json file may not contain a property 'Config'");
|
|
22
|
-
}
|
|
23
|
-
module.exports.Config = Config;
|
package/lib/formatter.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _get = _interopRequireDefault(require("lodash/get"));
|
|
4
|
-
var _ecc = require("./auth/ecc");
|
|
5
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
-
module.exports = steemAPI => {
|
|
7
|
-
function numberWithCommas(x) {
|
|
8
|
-
return x.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
9
|
-
}
|
|
10
|
-
function vestingSteem(account, gprops) {
|
|
11
|
-
const vests = parseFloat(account.vesting_shares.split(" ")[0]);
|
|
12
|
-
const total_vests = parseFloat(gprops.total_vesting_shares.split(" ")[0]);
|
|
13
|
-
const total_vest_steem = parseFloat(gprops.total_vesting_fund_steem.split(" ")[0]);
|
|
14
|
-
const vesting_steemf = total_vest_steem * (vests / total_vests);
|
|
15
|
-
return vesting_steemf;
|
|
16
|
-
}
|
|
17
|
-
function processOrders(open_orders, assetPrecision) {
|
|
18
|
-
const sbdOrders = !open_orders ? 0 : open_orders.reduce((o, order) => {
|
|
19
|
-
if (order.sell_price.base.indexOf("SBD") !== -1) {
|
|
20
|
-
o += order.for_sale;
|
|
21
|
-
}
|
|
22
|
-
return o;
|
|
23
|
-
}, 0) / assetPrecision;
|
|
24
|
-
const steemOrders = !open_orders ? 0 : open_orders.reduce((o, order) => {
|
|
25
|
-
if (order.sell_price.base.indexOf("STEEM") !== -1) {
|
|
26
|
-
o += order.for_sale;
|
|
27
|
-
}
|
|
28
|
-
return o;
|
|
29
|
-
}, 0) / assetPrecision;
|
|
30
|
-
return {
|
|
31
|
-
steemOrders,
|
|
32
|
-
sbdOrders
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function calculateSaving(savings_withdraws) {
|
|
36
|
-
let savings_pending = 0;
|
|
37
|
-
let savings_sbd_pending = 0;
|
|
38
|
-
savings_withdraws.forEach(withdraw => {
|
|
39
|
-
const [amount, asset] = withdraw.amount.split(" ");
|
|
40
|
-
if (asset === "STEEM") savings_pending += parseFloat(amount);else {
|
|
41
|
-
if (asset === "SBD") savings_sbd_pending += parseFloat(amount);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
savings_pending,
|
|
46
|
-
savings_sbd_pending
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function pricePerSteem(feed_price) {
|
|
50
|
-
let price_per_steem = undefined;
|
|
51
|
-
const {
|
|
52
|
-
base,
|
|
53
|
-
quote
|
|
54
|
-
} = feed_price;
|
|
55
|
-
if (/ SBD$/.test(base) && / STEEM$/.test(quote)) {
|
|
56
|
-
price_per_steem = parseFloat(base.split(" ")[0]) / parseFloat(quote.split(" ")[0]);
|
|
57
|
-
}
|
|
58
|
-
return price_per_steem;
|
|
59
|
-
}
|
|
60
|
-
function estimateAccountValue(account, {
|
|
61
|
-
gprops,
|
|
62
|
-
feed_price,
|
|
63
|
-
open_orders,
|
|
64
|
-
savings_withdraws,
|
|
65
|
-
vesting_steem
|
|
66
|
-
} = {}) {
|
|
67
|
-
const promises = [];
|
|
68
|
-
const username = account.name;
|
|
69
|
-
const assetPrecision = 1000;
|
|
70
|
-
let orders, savings;
|
|
71
|
-
if (!vesting_steem || !feed_price) {
|
|
72
|
-
if (!gprops || !feed_price) {
|
|
73
|
-
promises.push(steemAPI.getStateAsync(`/@${username}`).then(data => {
|
|
74
|
-
gprops = data.props;
|
|
75
|
-
feed_price = data.feed_price;
|
|
76
|
-
vesting_steem = vestingSteem(account, gprops);
|
|
77
|
-
}));
|
|
78
|
-
} else {
|
|
79
|
-
vesting_steem = vestingSteem(account, gprops);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (!open_orders) {
|
|
83
|
-
promises.push(steemAPI.getOpenOrdersAsync(username).then(open_orders => {
|
|
84
|
-
orders = processOrders(open_orders, assetPrecision);
|
|
85
|
-
}));
|
|
86
|
-
} else {
|
|
87
|
-
orders = processOrders(open_orders, assetPrecision);
|
|
88
|
-
}
|
|
89
|
-
if (!savings_withdraws) {
|
|
90
|
-
promises.push(steemAPI.getSavingsWithdrawFromAsync(username).then(savings_withdraws => {
|
|
91
|
-
savings = calculateSaving(savings_withdraws);
|
|
92
|
-
}));
|
|
93
|
-
} else {
|
|
94
|
-
savings = calculateSaving(savings_withdraws);
|
|
95
|
-
}
|
|
96
|
-
return Promise.all(promises).then(() => {
|
|
97
|
-
let price_per_steem = pricePerSteem(feed_price);
|
|
98
|
-
const savings_balance = account.savings_balance;
|
|
99
|
-
const savings_sbd_balance = account.savings_sbd_balance;
|
|
100
|
-
const balance_steem = parseFloat(account.balance.split(" ")[0]);
|
|
101
|
-
const saving_balance_steem = parseFloat(savings_balance.split(" ")[0]);
|
|
102
|
-
const sbd_balance = parseFloat(account.sbd_balance);
|
|
103
|
-
const sbd_balance_savings = parseFloat(savings_sbd_balance.split(" ")[0]);
|
|
104
|
-
let conversionValue = 0;
|
|
105
|
-
const currentTime = new Date().getTime();
|
|
106
|
-
(account.other_history || []).reduce((out, item) => {
|
|
107
|
-
if ((0, _get.default)(item, [1, "op", 0], "") !== "convert") return out;
|
|
108
|
-
const timestamp = new Date((0, _get.default)(item, [1, "timestamp"])).getTime();
|
|
109
|
-
const finishTime = timestamp + 86400000 * 3.5; // add 3.5day conversion delay
|
|
110
|
-
if (finishTime < currentTime) return out;
|
|
111
|
-
const amount = parseFloat((0, _get.default)(item, [1, "op", 1, "amount"]).replace(" SBD", ""));
|
|
112
|
-
conversionValue += amount;
|
|
113
|
-
}, []);
|
|
114
|
-
const total_sbd = sbd_balance + sbd_balance_savings + savings.savings_sbd_pending + orders.sbdOrders + conversionValue;
|
|
115
|
-
const total_steem = vesting_steem + balance_steem + saving_balance_steem + savings.savings_pending + orders.steemOrders;
|
|
116
|
-
return (total_steem * price_per_steem + total_sbd).toFixed(2);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
function createSuggestedPassword() {
|
|
120
|
-
const PASSWORD_LENGTH = 32;
|
|
121
|
-
const privateKey = _ecc.key_utils.get_random_key();
|
|
122
|
-
return privateKey.toWif().substring(3, 3 + PASSWORD_LENGTH);
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
reputation: function (reputation, decimal_places = 0) {
|
|
126
|
-
if (reputation == 0) return 25;
|
|
127
|
-
if (!reputation) return reputation;
|
|
128
|
-
let neg = reputation < 0;
|
|
129
|
-
let rep = String(reputation);
|
|
130
|
-
rep = neg ? rep.substring(1) : rep;
|
|
131
|
-
let v = Math.log10((rep > 0 ? rep : -rep) - 10) - 9;
|
|
132
|
-
v = neg ? -v : v;
|
|
133
|
-
v = v * 9 + 25;
|
|
134
|
-
if (decimal_places > 0) {
|
|
135
|
-
return +(Math.round(v + "e+" + decimal_places) + "e-" + decimal_places);
|
|
136
|
-
}
|
|
137
|
-
return parseInt(v);
|
|
138
|
-
},
|
|
139
|
-
vestToSteem: function (vestingShares, totalVestingShares, totalVestingFundSteem) {
|
|
140
|
-
return parseFloat(totalVestingFundSteem) * (parseFloat(vestingShares) / parseFloat(totalVestingShares));
|
|
141
|
-
},
|
|
142
|
-
commentPermlink: function (parentAuthor, parentPermlink) {
|
|
143
|
-
const timeStr = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, "").toLowerCase();
|
|
144
|
-
parentPermlink = parentPermlink.replace(/(-\d{8}t\d{9}z)/g, "");
|
|
145
|
-
let permLink = "re-" + parentAuthor + "-" + parentPermlink + "-" + timeStr;
|
|
146
|
-
if (permLink.length > 255) {
|
|
147
|
-
// pay respect to STEEMIT_MAX_PERMLINK_LENGTH
|
|
148
|
-
permLink.substr(permLink.length - 255, permLink.length);
|
|
149
|
-
}
|
|
150
|
-
// permlinks must be lower case and not contain anything but
|
|
151
|
-
// alphanumeric characters plus dashes
|
|
152
|
-
return permLink.toLowerCase().replace(/[^a-z0-9-]+/g, "");
|
|
153
|
-
},
|
|
154
|
-
amount: function (amount, asset) {
|
|
155
|
-
return amount.toFixed(3) + " " + asset;
|
|
156
|
-
},
|
|
157
|
-
numberWithCommas,
|
|
158
|
-
vestingSteem,
|
|
159
|
-
estimateAccountValue,
|
|
160
|
-
createSuggestedPassword,
|
|
161
|
-
pricePerSteem
|
|
162
|
-
};
|
|
163
|
-
};
|
package/lib/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const api = require('./api');
|
|
4
|
-
const auth = require('./auth');
|
|
5
|
-
const broadcast = require('./broadcast');
|
|
6
|
-
const formatter = require('./formatter')(api);
|
|
7
|
-
const memo = require('./auth/memo');
|
|
8
|
-
const config = require('./config');
|
|
9
|
-
const utils = require('./utils');
|
|
10
|
-
module.exports = {
|
|
11
|
-
api,
|
|
12
|
-
auth,
|
|
13
|
-
broadcast,
|
|
14
|
-
formatter,
|
|
15
|
-
memo,
|
|
16
|
-
config,
|
|
17
|
-
utils
|
|
18
|
-
};
|
|
19
|
-
process.on('warning', warning => {
|
|
20
|
-
console.log('warning_stack: ', warning.stack);
|
|
21
|
-
});
|
package/lib/utils.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.camelCase = camelCase;
|
|
7
|
-
exports.validateAccountName = validateAccountName;
|
|
8
|
-
const snakeCaseRe = /_([a-z])/g;
|
|
9
|
-
function camelCase(str) {
|
|
10
|
-
return str.replace(snakeCaseRe, function (_m, l) {
|
|
11
|
-
return l.toUpperCase();
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function validateAccountName(value) {
|
|
15
|
-
let i, label, len, suffix;
|
|
16
|
-
suffix = "Account name should ";
|
|
17
|
-
if (!value) {
|
|
18
|
-
return suffix + "not be empty.";
|
|
19
|
-
}
|
|
20
|
-
const length = value.length;
|
|
21
|
-
if (length < 3) {
|
|
22
|
-
return suffix + "be longer.";
|
|
23
|
-
}
|
|
24
|
-
if (length > 16) {
|
|
25
|
-
return suffix + "be shorter.";
|
|
26
|
-
}
|
|
27
|
-
if (/\./.test(value)) {
|
|
28
|
-
suffix = "Each account segment should ";
|
|
29
|
-
}
|
|
30
|
-
const ref = value.split(".");
|
|
31
|
-
for (i = 0, len = ref.length; i < len; i++) {
|
|
32
|
-
label = ref[i];
|
|
33
|
-
if (!/^[a-z]/.test(label)) {
|
|
34
|
-
return suffix + "start with a letter.";
|
|
35
|
-
}
|
|
36
|
-
if (!/^[a-z0-9-]*$/.test(label)) {
|
|
37
|
-
return suffix + "have only letters, digits, or dashes.";
|
|
38
|
-
}
|
|
39
|
-
if (/--/.test(label)) {
|
|
40
|
-
return suffix + "have only one dash in a row.";
|
|
41
|
-
}
|
|
42
|
-
if (!/[a-z0-9]$/.test(label)) {
|
|
43
|
-
return suffix + "end with a letter or digit.";
|
|
44
|
-
}
|
|
45
|
-
if (!(label.length >= 3)) {
|
|
46
|
-
return suffix + "be longer";
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
package/node-18.dockerfile
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
FROM node:18
|
|
2
|
-
# Copy just package files first for better caching
|
|
3
|
-
COPY package*.json /steemjs/
|
|
4
|
-
WORKDIR /steemjs
|
|
5
|
-
|
|
6
|
-
# Install dependencies with --ignore-scripts to skip the build
|
|
7
|
-
RUN npm install --ignore-scripts || \
|
|
8
|
-
(echo "NPM install failed with default options, trying alternative approach" && \
|
|
9
|
-
npm cache clean --force && \
|
|
10
|
-
NODE_ENV=development npm install --no-package-lock --ignore-scripts)
|
|
11
|
-
|
|
12
|
-
# Now copy the rest of the application
|
|
13
|
-
COPY . /steemjs
|
|
14
|
-
|
|
15
|
-
# Build the Node.js version only (babel transformation)
|
|
16
|
-
RUN npm run build-node
|
|
17
|
-
|
|
18
|
-
# Debug environment
|
|
19
|
-
RUN echo "Node version: $(node -v)" && \
|
|
20
|
-
echo "NPM version: $(npm -v)" && \
|
|
21
|
-
ls -la test
|
|
22
|
-
|
|
23
|
-
# Run tests with the module aliases
|
|
24
|
-
RUN NODE_ENV=test BABEL_ENV=test npm test || \
|
|
25
|
-
echo "Some tests may have failed, but continuing build"
|
|
26
|
-
|
|
27
|
-
# Image build is considered successful even if tests fail
|
|
28
|
-
RUN echo "Build completed successfully!"
|
package/test/Crypto.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import config from "../src/config"
|
|
2
|
-
import { Aes, PrivateKey, PublicKey, Signature } from "../src/auth/ecc"
|
|
3
|
-
import assert from "assert"
|
|
4
|
-
|
|
5
|
-
var secureRandom = require('secure-random');
|
|
6
|
-
var hash = require('../src/auth/ecc/src/hash');
|
|
7
|
-
var key = require('../src/auth/ecc/src/key_utils');
|
|
8
|
-
|
|
9
|
-
describe("steem.auth: Crypto", function() {
|
|
10
|
-
|
|
11
|
-
/*it "Computes public key", ->
|
|
12
|
-
private_key = PrivateKey.fromHex decrypted_key.substring 0, 64
|
|
13
|
-
public_key = private_key.toPublicKey()
|
|
14
|
-
console.log public_key.toHex());*/
|
|
15
|
-
|
|
16
|
-
it("sign", function() {
|
|
17
|
-
this.timeout(10000);
|
|
18
|
-
var private_key = PrivateKey.fromSeed("1");
|
|
19
|
-
return (() => {
|
|
20
|
-
var result = [];
|
|
21
|
-
for (var i = 0; i < 10; i++) {
|
|
22
|
-
result.push(Signature.signBuffer((new Buffer.alloc(i)), private_key));
|
|
23
|
-
}
|
|
24
|
-
return result;
|
|
25
|
-
})();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
describe("steem.auth: derives", ()=> {
|
|
31
|
-
|
|
32
|
-
let prefix = config.get("address_prefix")
|
|
33
|
-
let one_time_private = PrivateKey.fromHex("8fdfdde486f696fd7c6313325e14d3ff0c34b6e2c390d1944cbfe150f4457168")
|
|
34
|
-
let to_public = PublicKey.fromStringOrThrow(prefix + "7vbxtK1WaZqXsiCHPcjVFBewVj8HFRd5Z5XZDpN6Pvb2dZcMqK")
|
|
35
|
-
let secret = one_time_private.get_shared_secret( to_public )
|
|
36
|
-
let child = hash.sha256( secret )
|
|
37
|
-
|
|
38
|
-
// Check everything above with `wdump((child));` from the witness_node:
|
|
39
|
-
assert.equal(child.toString('hex'), "1f296fa48172d9af63ef3fb6da8e369e6cc33c1fb7c164207a3549b39e8ef698")
|
|
40
|
-
|
|
41
|
-
let nonce = hash.sha256( one_time_private.toBuffer() )
|
|
42
|
-
assert.equal(nonce.toString('hex'), "462f6c19ece033b5a3dba09f1e1d7935a5302e4d1eac0a84489cdc8339233fbf")
|
|
43
|
-
|
|
44
|
-
it("child from public", ()=> assert.equal(
|
|
45
|
-
to_public.child(child).toString(),
|
|
46
|
-
"STM6XA72XARQCain961PCJnXiKYdEMrndNGago2PV5bcUiVyzJ6iL",
|
|
47
|
-
"derive child public key"
|
|
48
|
-
))
|
|
49
|
-
|
|
50
|
-
// child = hash.sha256( one_time_private.get_secret( to_public ))
|
|
51
|
-
it("child from private", ()=> assert.equal(
|
|
52
|
-
PrivateKey.fromSeed("alice-brain-key").child(child).toPublicKey().toString(),
|
|
53
|
-
"STM6XA72XARQCain961PCJnXiKYdEMrndNGago2PV5bcUiVyzJ6iL",
|
|
54
|
-
"derive child from private key"
|
|
55
|
-
))
|
|
56
|
-
|
|
57
|
-
// "many keys" works, not really needed
|
|
58
|
-
// it("many keys", function() {
|
|
59
|
-
//
|
|
60
|
-
// this.timeout(10 * 1000)
|
|
61
|
-
//
|
|
62
|
-
// for (var i = 0; i < 10; i++) {
|
|
63
|
-
// let privkey1 = key.get_random_key()
|
|
64
|
-
// let privkey2 = key.get_random_key()
|
|
65
|
-
//
|
|
66
|
-
// let secret1 = one_time_private.get_shared_secret( privkey1.toPublicKey() )
|
|
67
|
-
// let child1 = hash.sha256( secret1 )
|
|
68
|
-
//
|
|
69
|
-
// let secret2 = privkey2.get_shared_secret( privkey2.toPublicKey() )
|
|
70
|
-
// let child2 = hash.sha256( secret2 )
|
|
71
|
-
//
|
|
72
|
-
// it("child from public", ()=> assert.equal(
|
|
73
|
-
// privkey1.toPublicKey().child(child1).toString(),
|
|
74
|
-
// privkey2.toPublicKey().child(child2).toString(),
|
|
75
|
-
// "derive child public key"
|
|
76
|
-
// ))
|
|
77
|
-
//
|
|
78
|
-
// it("child from private", ()=> assert.equal(
|
|
79
|
-
// privkey1.child(child1).toString(),
|
|
80
|
-
// privkey2.child(child2).toString(),
|
|
81
|
-
// "derive child private key"
|
|
82
|
-
// ))
|
|
83
|
-
// }
|
|
84
|
-
//
|
|
85
|
-
// })
|
|
86
|
-
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
var min_time_elapsed = function(f){
|
|
90
|
-
var start_t = Date.now();
|
|
91
|
-
var ret = f();
|
|
92
|
-
var elapsed = Date.now() - start_t;
|
|
93
|
-
assert.equal(
|
|
94
|
-
// repeat operations may take less time
|
|
95
|
-
elapsed >= 250 * 0.8, true,
|
|
96
|
-
`minimum time requirement was not met, instead only ${elapsed/1000.0} elapsed`
|
|
97
|
-
);
|
|
98
|
-
return ret;
|
|
99
|
-
};
|
|
100
|
-
|