@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
package/test/smt.test.js
DELETED
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
import assert from 'assert'
|
|
2
|
-
import Promise from 'bluebird';
|
|
3
|
-
import should from 'should';
|
|
4
|
-
import steem from '../src';
|
|
5
|
-
|
|
6
|
-
const username = process.env.STEEM_USERNAME || 'guest123';
|
|
7
|
-
const password = process.env.STEEM_PASSWORD;
|
|
8
|
-
const activeWif = steem.auth.toWif(username, password, 'active');
|
|
9
|
-
|
|
10
|
-
describe('steem.smt:', () => {
|
|
11
|
-
|
|
12
|
-
describe('smt creation ops', () => {
|
|
13
|
-
it('signs and verifies smt_create', function(done) {
|
|
14
|
-
let url = steem.config.get('uri');
|
|
15
|
-
steem.api.setOptions({ url: url, useAppbaseApi: true });
|
|
16
|
-
|
|
17
|
-
let tx = {
|
|
18
|
-
'operations': [[
|
|
19
|
-
'smt_create', {
|
|
20
|
-
'control_account': username,
|
|
21
|
-
'symbol': {'nai':'@@631672482','precision':3},
|
|
22
|
-
'smt_creation_fee': {'amount':'10000','precision':3,'nai':'@@000000013'},
|
|
23
|
-
'precision': 3,
|
|
24
|
-
}]]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
steem.api.callAsync('condenser_api.get_version', []).then((result) => {
|
|
28
|
-
if(result['blockchain_version'] < '0.23.0') return done(); /* SKIP AS THIS WILL ONLY PASS ON A TESTNET CURRENTLY */
|
|
29
|
-
result.should.have.property('blockchain_version');
|
|
30
|
-
|
|
31
|
-
steem.broadcast._prepareTransaction(tx).then(function(tx){
|
|
32
|
-
tx = steem.auth.signTransaction(tx, [activeWif]);
|
|
33
|
-
steem.api.verifyAuthorityAsync(tx).then(
|
|
34
|
-
(result) => {result.should.equal(true); done();},
|
|
35
|
-
(err) => {done(err);}
|
|
36
|
-
);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('signs and verifies smt_setup', function(done) {
|
|
42
|
-
let tx = {
|
|
43
|
-
'operations': [[
|
|
44
|
-
'smt_setup', {
|
|
45
|
-
'control_account' : username,
|
|
46
|
-
'symbol' : {'nai':'@@631672482','precision':3},
|
|
47
|
-
'max_supply' : '1000000000000000',
|
|
48
|
-
'contribution_begin_time' : '2020-12-21T00:00:00',
|
|
49
|
-
'contribution_end_time' : '2021-12-21T00:00:00',
|
|
50
|
-
'launch_time' : '2021-12-22T00:00:00',
|
|
51
|
-
'steem_units_min' : 0,
|
|
52
|
-
'min_unit_ratio' : 50,
|
|
53
|
-
'max_unit_ratio' : 100,
|
|
54
|
-
'extensions':[]
|
|
55
|
-
}
|
|
56
|
-
]]
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
steem.api.callAsync('condenser_api.get_version', []).then((result) => {
|
|
60
|
-
if(result['blockchain_version'] < '0.23.0') return done(); /* SKIP AS THIS WILL ONLY PASS ON A TESTNET CURRENTLY */
|
|
61
|
-
result.should.have.property('blockchain_version');
|
|
62
|
-
|
|
63
|
-
steem.broadcast._prepareTransaction(tx).then(function(tx){
|
|
64
|
-
tx = steem.auth.signTransaction(tx, [activeWif]);
|
|
65
|
-
steem.api.verifyAuthorityAsync(tx).then(
|
|
66
|
-
(result) => {result.should.equal(true); done();},
|
|
67
|
-
(err) => {done(err);}
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
it('signs and verifies smt_setup_ico_tier', function(done) {
|
|
74
|
-
let tx = {
|
|
75
|
-
'operations': [[
|
|
76
|
-
'smt_setup_ico_tier', {
|
|
77
|
-
'control_account' : username,
|
|
78
|
-
'symbol' : {'nai':'@@631672482','precision':3},
|
|
79
|
-
'steem_units_cap' : 10000,
|
|
80
|
-
'generation_policy' : [
|
|
81
|
-
0,
|
|
82
|
-
{
|
|
83
|
-
'generation_unit' : {
|
|
84
|
-
'steem_unit' : [
|
|
85
|
-
['$!alice.vesting',2],
|
|
86
|
-
['$market_maker',2],
|
|
87
|
-
['alice',2]
|
|
88
|
-
],
|
|
89
|
-
'token_unit' : [
|
|
90
|
-
['$!alice.vesting',2],
|
|
91
|
-
['$from',2],
|
|
92
|
-
['$from.vesting',2],
|
|
93
|
-
['$market_maker',2],
|
|
94
|
-
['$rewards',2],
|
|
95
|
-
['alice',2]
|
|
96
|
-
]
|
|
97
|
-
},
|
|
98
|
-
'extensions':[]
|
|
99
|
-
}
|
|
100
|
-
],
|
|
101
|
-
'remove' : false,
|
|
102
|
-
'extensions':[]
|
|
103
|
-
}]]
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
steem.api.callAsync('condenser_api.get_version', []).then((result) => {
|
|
107
|
-
if(result['blockchain_version'] < '0.23.0') return done(); /* SKIP AS THIS WILL ONLY PASS ON A TESTNET CURRENTLY */
|
|
108
|
-
result.should.have.property('blockchain_version');
|
|
109
|
-
|
|
110
|
-
steem.broadcast._prepareTransaction(tx).then(function(tx){
|
|
111
|
-
tx = steem.auth.signTransaction(tx, [activeWif]);
|
|
112
|
-
steem.api.verifyAuthorityAsync(tx).then(
|
|
113
|
-
(result) => {result.should.equal(true); done();},
|
|
114
|
-
(err) => {done(err);}
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
it('signs and verifies smt_setup_emissions', function(done) {
|
|
121
|
-
let tx = {
|
|
122
|
-
'operations': [[
|
|
123
|
-
'smt_setup_emissions', {
|
|
124
|
-
'control_account' : username,
|
|
125
|
-
'symbol' : {'nai':'@@631672482','precision':3},
|
|
126
|
-
'schedule_time' : '2019-10-16T19:47:05',
|
|
127
|
-
'emissions_unit' : {
|
|
128
|
-
'token_unit' : [
|
|
129
|
-
['$market_maker',1],
|
|
130
|
-
['$rewards',1],
|
|
131
|
-
['$vesting',1]
|
|
132
|
-
]
|
|
133
|
-
},
|
|
134
|
-
'interval_seconds' : 21600,
|
|
135
|
-
'emission_count' : 1,
|
|
136
|
-
'lep_time' : '1970-01-01T00:00:00',
|
|
137
|
-
'rep_time' : '1970-01-01T00:00:00',
|
|
138
|
-
'lep_abs_amount' : 0,
|
|
139
|
-
'rep_abs_amount': 0,
|
|
140
|
-
'lep_rel_amount_numerator' : 1,
|
|
141
|
-
'rep_rel_amount_numerator' : 0,
|
|
142
|
-
'rel_amount_denom_bits' : 0,
|
|
143
|
-
'remove' : false,
|
|
144
|
-
'floor_emissions' : false,
|
|
145
|
-
'extensions':[]
|
|
146
|
-
}]]
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
steem.api.callAsync('condenser_api.get_version', []).then((result) => {
|
|
150
|
-
if(result['blockchain_version'] < '0.23.0') return done(); /* SKIP AS THIS WILL ONLY PASS ON A TESTNET CURRENTLY */
|
|
151
|
-
result.should.have.property('blockchain_version');
|
|
152
|
-
|
|
153
|
-
steem.broadcast._prepareTransaction(tx).then(function(tx){
|
|
154
|
-
tx = steem.auth.signTransaction(tx, [activeWif]);
|
|
155
|
-
steem.api.verifyAuthorityAsync(tx).then(
|
|
156
|
-
(result) => {result.should.equal(true); done();},
|
|
157
|
-
(err) => {done(err);}
|
|
158
|
-
);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
it('signs and verifies smt_set_setup_parameters', function(done) {
|
|
164
|
-
let tx = {
|
|
165
|
-
'operations': [[
|
|
166
|
-
'smt_set_setup_parameters', {
|
|
167
|
-
'control_account' : username,
|
|
168
|
-
'symbol' : {'nai':'@@631672482','precision':3},
|
|
169
|
-
'setup_parameters' : [[
|
|
170
|
-
0, {
|
|
171
|
-
'value':false
|
|
172
|
-
}]],
|
|
173
|
-
'extensions':[]
|
|
174
|
-
}]]
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
steem.api.callAsync('condenser_api.get_version', []).then((result) => {
|
|
178
|
-
if(result['blockchain_version'] < '0.23.0') return done(); /* SKIP AS THIS WILL ONLY PASS ON A TESTNET CURRENTLY */
|
|
179
|
-
result.should.have.property('blockchain_version');
|
|
180
|
-
|
|
181
|
-
steem.broadcast._prepareTransaction(tx).then(function(tx){
|
|
182
|
-
tx = steem.auth.signTransaction(tx, [activeWif]);
|
|
183
|
-
steem.api.verifyAuthorityAsync(tx).then(
|
|
184
|
-
(result) => {result.should.equal(true); done();},
|
|
185
|
-
(err) => {done(err);}
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
it('signs and verifies smt_set_runtime_parameters', function(done) {
|
|
192
|
-
let tx = {
|
|
193
|
-
'operations': [[
|
|
194
|
-
'smt_set_runtime_parameters', {
|
|
195
|
-
'control_account' : username,
|
|
196
|
-
'symbol' : {'nai':'@@631672482','precision':3},
|
|
197
|
-
'runtime_parameters' : [[
|
|
198
|
-
1, {
|
|
199
|
-
'vote_regeneration_period_seconds' : 604800,
|
|
200
|
-
'votes_per_regeneration_period' : 6999
|
|
201
|
-
}]],
|
|
202
|
-
'extensions':[]
|
|
203
|
-
}]]
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
steem.api.callAsync('condenser_api.get_version', []).then((result) => {
|
|
207
|
-
if(result['blockchain_version'] < '0.23.0') return done(); /* SKIP AS THIS WILL ONLY PASS ON A TESTNET CURRENTLY */
|
|
208
|
-
result.should.have.property('blockchain_version');
|
|
209
|
-
|
|
210
|
-
steem.broadcast._prepareTransaction(tx).then(function(tx){
|
|
211
|
-
tx = steem.auth.signTransaction(tx, [activeWif]);
|
|
212
|
-
steem.api.verifyAuthorityAsync(tx).then(
|
|
213
|
-
(result) => {result.should.equal(true); done();},
|
|
214
|
-
(err) => {done(err);}
|
|
215
|
-
);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
it('signs and verifies smt_contribute', function(done) {
|
|
221
|
-
let tx = {
|
|
222
|
-
'operations': [[
|
|
223
|
-
'smt_contribute', {
|
|
224
|
-
'contributor' : username,
|
|
225
|
-
'symbol' : {'nai':'@@631672482','precision':3},
|
|
226
|
-
'contribution_id' : 1,
|
|
227
|
-
'contribution': {'amount':'1000','precision':3,'nai':'@@000000013'},
|
|
228
|
-
'extensions':[]
|
|
229
|
-
}]]
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
steem.api.callAsync('condenser_api.get_version', []).then((result) => {
|
|
233
|
-
if(result['blockchain_version'] < '0.23.0') return done(); /* SKIP AS THIS WILL ONLY PASS ON A TESTNET CURRENTLY */
|
|
234
|
-
result.should.have.property('blockchain_version');
|
|
235
|
-
|
|
236
|
-
steem.broadcast._prepareTransaction(tx).then(function(tx){
|
|
237
|
-
tx = steem.auth.signTransaction(tx, [activeWif]);
|
|
238
|
-
steem.api.verifyAuthorityAsync(tx).then(
|
|
239
|
-
(result) => {result.should.equal(true); done();},
|
|
240
|
-
(err) => {done(err);}
|
|
241
|
-
);
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
})
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
describe('smt extended ops', () => {
|
|
248
|
-
let permlink = 'test';
|
|
249
|
-
|
|
250
|
-
it('signs and verifies claim_rewards_balance2', function(done) {
|
|
251
|
-
let tx = {
|
|
252
|
-
'operations': [[
|
|
253
|
-
'claim_reward_balance2', {
|
|
254
|
-
'account' : username,
|
|
255
|
-
'reward_tokens' : [
|
|
256
|
-
{'amount':'1000','precision':3,'nai':'@@000000013'},
|
|
257
|
-
{'amount':'1000','precision':3,'nai':'@@000000021'},
|
|
258
|
-
{'amount':'1000000','precision':6,'nai':'@@000000037'},
|
|
259
|
-
{'amount':'1','precision':1,'nai':'@@631672482'},
|
|
260
|
-
{'amount':'1','precision':0,'nai':'@@642246725'},
|
|
261
|
-
{'amount':'1','precision':1,'nai':'@@678264426'}
|
|
262
|
-
],
|
|
263
|
-
'extensions':[]
|
|
264
|
-
}]]
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
steem.api.callAsync('condenser_api.get_version', []).then((result) => {
|
|
268
|
-
if(result['blockchain_version'] < '0.23.0') return done(); /* SKIP AS THIS WILL ONLY PASS ON A TESTNET CURRENTLY */
|
|
269
|
-
result.should.have.property('blockchain_version');
|
|
270
|
-
|
|
271
|
-
steem.broadcast._prepareTransaction(tx).then(function(tx){
|
|
272
|
-
tx = steem.auth.signTransaction(tx, [activeWif]);
|
|
273
|
-
steem.api.verifyAuthorityAsync(tx).then(
|
|
274
|
-
(result) => {result.should.equal(true); done();},
|
|
275
|
-
(err) => {done(err);}
|
|
276
|
-
);
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
it('signs and verifies comment_options', function(done) {
|
|
282
|
-
let tx = {
|
|
283
|
-
'operations': [[
|
|
284
|
-
'comment_options', {
|
|
285
|
-
'author' : username,
|
|
286
|
-
'permlink' : permlink,
|
|
287
|
-
'max_accepted_payout' : '1000000.000 TESTS',
|
|
288
|
-
'percent_steem_dollars' : 10000,
|
|
289
|
-
'allow_votes' : true,
|
|
290
|
-
'allow_curation_rewards' : true,
|
|
291
|
-
'extensions' : [[
|
|
292
|
-
1, {
|
|
293
|
-
'votable_assets':[[
|
|
294
|
-
{'nai':'@@631672482','precision':3}, {
|
|
295
|
-
'max_accepted_payout' : 10,
|
|
296
|
-
'allow_curation_rewards' : true,
|
|
297
|
-
'beneficiaries' : {
|
|
298
|
-
'beneficiaries' : [
|
|
299
|
-
{ 'account' : 'alice', 'weight' : 100 },
|
|
300
|
-
{ 'account': 'bob' , 'weight' : 100 }
|
|
301
|
-
]}}]]}]]}]]
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
steem.api.callAsync('condenser_api.get_version', []).then((result) => {
|
|
305
|
-
if(result['blockchain_version'] < '0.23.0') return done(); /* SKIP AS THIS WILL ONLY PASS ON A TESTNET CURRENTLY */
|
|
306
|
-
result.should.have.property('blockchain_version');
|
|
307
|
-
|
|
308
|
-
steem.broadcast._prepareTransaction(tx).then(function(tx){
|
|
309
|
-
tx = steem.auth.signTransaction(tx, [activeWif]);
|
|
310
|
-
steem.api.verifyAuthorityAsync(tx).then(
|
|
311
|
-
(result) => {result.should.equal(true); done();},
|
|
312
|
-
(err) => {done(err);}
|
|
313
|
-
);
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
it('signs and verifies vote2', function(done) {
|
|
319
|
-
let tx = {
|
|
320
|
-
'operations': [[
|
|
321
|
-
'vote2', {
|
|
322
|
-
'voter' : username,
|
|
323
|
-
'author' : username,
|
|
324
|
-
'permlink' : permlink,
|
|
325
|
-
'rshares': [
|
|
326
|
-
[{'nai':'@@631672482','precision':3},2000000000],
|
|
327
|
-
[{'nai':'@@000000013','precision':3},81502331182]
|
|
328
|
-
],
|
|
329
|
-
'extensions':[]
|
|
330
|
-
}]]
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
steem.api.callAsync('condenser_api.get_version', []).then((result) => {
|
|
334
|
-
if(result['blockchain_version'] < '0.23.0') return done(); /* SKIP AS THIS WILL ONLY PASS ON A TESTNET CURRENTLY */
|
|
335
|
-
result.should.have.property('blockchain_version');
|
|
336
|
-
|
|
337
|
-
steem.broadcast._prepareTransaction(tx).then(function(tx){
|
|
338
|
-
tx = steem.auth.signTransaction(tx, [activeWif]);
|
|
339
|
-
steem.api.verifyAuthorityAsync(tx).then(
|
|
340
|
-
(result) => {result.should.equal(true); done();},
|
|
341
|
-
(err) => {done(err);}
|
|
342
|
-
);
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
})
|
|
346
|
-
});
|
|
347
|
-
});
|
package/test/test-post.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"author": "yamadapc",
|
|
3
|
-
"permlink": "test-1-2-3-4-5-6-7-9",
|
|
4
|
-
"category": "test",
|
|
5
|
-
"parent_author": "",
|
|
6
|
-
"parent_permlink": "test",
|
|
7
|
-
"title": "test-1-2-3-4-5-6-7-9",
|
|
8
|
-
"body": "<script>alert('hello world')</script>",
|
|
9
|
-
"allow_replies": true,
|
|
10
|
-
"allow_votes": true,
|
|
11
|
-
"allow_curation_rewards": true,
|
|
12
|
-
"url": "/test/@yamadapc/test-1-2-3-4-5-6-7-9"
|
|
13
|
-
}
|
package/test/test.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<link href="../node_modules/mocha/mocha.css" rel="stylesheet" />
|
|
2
|
-
|
|
3
|
-
<div id="mocha"></div>
|
|
4
|
-
|
|
5
|
-
<script src="../node_modules/mocha/mocha.js"></script>
|
|
6
|
-
<script>mocha.setup('bdd')</script>
|
|
7
|
-
<script src="../dist/steem-tests.min.js"></script>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<script>
|
|
11
|
-
mocha.checkLeaks();
|
|
12
|
-
mocha.run();
|
|
13
|
-
</script>
|
package/test/test_helper.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var assert = require('assert');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
|
|
5
|
-
error(message_substring, f){
|
|
6
|
-
var fail = false;
|
|
7
|
-
try {
|
|
8
|
-
f();
|
|
9
|
-
fail = true;
|
|
10
|
-
} catch (e) {
|
|
11
|
-
if (e.toString().indexOf(message_substring) === -1) {
|
|
12
|
-
throw new Error("expecting " + message_substring);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
if (fail) {
|
|
16
|
-
throw new Error("expecting " + message_substring);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
package/test/types_test.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
var Convert = require('../src/auth/serializer/src/convert');
|
|
2
|
-
var Long = require('bytebuffer').Long;
|
|
3
|
-
|
|
4
|
-
var assert = require('assert');
|
|
5
|
-
var type = require('../src/auth/serializer/src/types');
|
|
6
|
-
var p = require('../src/auth/serializer/src/precision');
|
|
7
|
-
var th = require('./test_helper');
|
|
8
|
-
|
|
9
|
-
describe("steem.auth: types", function() {
|
|
10
|
-
|
|
11
|
-
it("vote_id",function() {
|
|
12
|
-
var toHex=function(id){
|
|
13
|
-
var vote = type.vote_id.fromObject(id);
|
|
14
|
-
return Convert(type.vote_id).toHex(vote);
|
|
15
|
-
};
|
|
16
|
-
assert.equal("ff000000", toHex("255:0"));
|
|
17
|
-
assert.equal("00ffffff", toHex("0:"+0xffffff));
|
|
18
|
-
var out_of_range=function(id){
|
|
19
|
-
try {
|
|
20
|
-
toHex(id);
|
|
21
|
-
return assert(false, 'should have been out of range');
|
|
22
|
-
} catch (e) {
|
|
23
|
-
return assert(e.message.indexOf('out of range') !== -1);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
out_of_range("0:"+(0xffffff+1));
|
|
27
|
-
out_of_range("256:0");
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("set sort", function() {
|
|
32
|
-
var bool_set = type.set(type.bool);
|
|
33
|
-
// Note, 1,0 sorts to 0,1
|
|
34
|
-
assert.equal("020001", Convert(bool_set).toHex([1,0]));
|
|
35
|
-
th.error("duplicate (set)", function() { return Convert(bool_set).toHex([1,1]); });
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("string sort", function() {
|
|
40
|
-
var setType = type.set(type.string);
|
|
41
|
-
var set = setType.fromObject(["a","z","m"])
|
|
42
|
-
var setObj = setType.toObject(set)
|
|
43
|
-
assert.deepEqual(["a","m","z"], setObj, "not sorted")
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("map sort", function() {
|
|
47
|
-
var bool_map = type.map(type.bool, type.bool);
|
|
48
|
-
// 1,1 0,0 sorts to 0,0 1,1
|
|
49
|
-
assert.equal("0200000101", Convert(bool_map).toHex([[1,1],[0,0]]));
|
|
50
|
-
th.error("duplicate (map)", function() { return Convert(bool_map).toHex([[1,1],[1,1]]); });
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it("public_key sort", function() {
|
|
54
|
-
let mapType = type.map(type.public_key, type.uint16)
|
|
55
|
-
let map = mapType.fromObject([//not sorted
|
|
56
|
-
["STM8me6d9PqzTgcoHxx6b4rnvWVTqz11kafidRAZwfacJkcJtfd75",0],
|
|
57
|
-
["STM56ankGHKf6qUsQe7vPsXTSEqST6Dt1ff73aV3YQbedzRua8NLQ",0],
|
|
58
|
-
])
|
|
59
|
-
let mapObject = mapType.toObject(map)
|
|
60
|
-
assert.deepEqual(mapObject, [ // sorted (uppercase comes first)
|
|
61
|
-
["STM56ankGHKf6qUsQe7vPsXTSEqST6Dt1ff73aV3YQbedzRua8NLQ",0],
|
|
62
|
-
["STM8me6d9PqzTgcoHxx6b4rnvWVTqz11kafidRAZwfacJkcJtfd75",0],
|
|
63
|
-
])
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it("type_id sort", function() {
|
|
67
|
-
// map (protocol_id_type "account"), (uint16)
|
|
68
|
-
let t = type.map(type.protocol_id_type("account"), type.uint16);
|
|
69
|
-
assert.deepEqual( t.fromObject([[1,1],[0,0]]), [[0,0],[1,1]], 'did not sort' )
|
|
70
|
-
assert.deepEqual( t.fromObject([[0,0],[1,1]]), [[0,0],[1,1]], 'did not sort' )
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("precision number strings", function() {
|
|
74
|
-
var check=function(input_string, precision, output_string){
|
|
75
|
-
return assert.equal(
|
|
76
|
-
output_string,
|
|
77
|
-
p._internal.decimal_precision_string(
|
|
78
|
-
input_string,
|
|
79
|
-
precision
|
|
80
|
-
)
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
check(
|
|
85
|
-
"12345678901234567890123456789012345678901234567890.12345",5,
|
|
86
|
-
"1234567890123456789012345678901234567890123456789012345"
|
|
87
|
-
);
|
|
88
|
-
check("", 0, "0");
|
|
89
|
-
check("0", 0, "0");
|
|
90
|
-
check("-0", 0, "0");
|
|
91
|
-
check("-00", 0, "0");
|
|
92
|
-
check("-0.0", 0, "0");
|
|
93
|
-
check("-", 0, "0");
|
|
94
|
-
check("1", 0, "1");
|
|
95
|
-
check("11", 0, "11");
|
|
96
|
-
|
|
97
|
-
overflow(function(){ return check(".1", 0, ""); });
|
|
98
|
-
overflow(function(){ return check("-.1", 0, ""); });
|
|
99
|
-
overflow(function(){ return check("0.1", 0, ""); });
|
|
100
|
-
overflow(function(){ return check("1.1", 0, ""); });
|
|
101
|
-
overflow(function(){ return check("1.11", 1, ""); });
|
|
102
|
-
|
|
103
|
-
check("", 1, "00");
|
|
104
|
-
check("1", 1, "10");
|
|
105
|
-
check("1.1", 1, "11");
|
|
106
|
-
check("-1", 1, "-10");
|
|
107
|
-
check("-1.1", 1, "-11");
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
return it("precision number long", function() {
|
|
112
|
-
var _precision;
|
|
113
|
-
assert.equal(
|
|
114
|
-
Long.MAX_VALUE.toString(),
|
|
115
|
-
p.to_bigint64(
|
|
116
|
-
Long.MAX_VALUE.toString(), _precision = 0
|
|
117
|
-
).toString(),
|
|
118
|
-
"to_bigint64 MAX_VALUE mismatch"
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
// Long.MAX_VALUE.toString() == 9223372036854775807
|
|
122
|
-
// Long.MAX_VALUE.toString() +1 9223372036854775808
|
|
123
|
-
overflow(function(){ return p.to_bigint64(
|
|
124
|
-
'9223372036854775808', _precision = 0
|
|
125
|
-
);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
assert.equal("0", p.to_string64(Long.ZERO, 0));
|
|
129
|
-
assert.equal("00", p.to_string64(Long.ZERO, 1));
|
|
130
|
-
|
|
131
|
-
overflow(function(){ return p.to_bigint64(
|
|
132
|
-
'92233720368547758075', _precision = 1
|
|
133
|
-
);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
var overflow = function(f){ return th.error("overflow", f); };
|
package/webpack/makeConfig.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const Visualizer = require('webpack-visualizer-plugin');
|
|
3
|
-
const _ = require('lodash');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const webpack = require('webpack');
|
|
6
|
-
|
|
7
|
-
const DEFAULTS = {
|
|
8
|
-
isDevelopment: process.env.NODE_ENV !== 'production',
|
|
9
|
-
baseDir: path.join(__dirname, '..'),
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function makePlugins(options) {
|
|
13
|
-
const isDevelopment = options.isDevelopment;
|
|
14
|
-
|
|
15
|
-
let plugins = [
|
|
16
|
-
new Visualizer({
|
|
17
|
-
filename: './statistics.html'
|
|
18
|
-
}),
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
if (!isDevelopment) {
|
|
22
|
-
plugins = plugins.concat([
|
|
23
|
-
new webpack.optimize.DedupePlugin(),
|
|
24
|
-
new webpack.optimize.UglifyJsPlugin({
|
|
25
|
-
output: {
|
|
26
|
-
comments: false,
|
|
27
|
-
},
|
|
28
|
-
minimize: true,
|
|
29
|
-
compress: {
|
|
30
|
-
warnings: false,
|
|
31
|
-
}
|
|
32
|
-
}),
|
|
33
|
-
new webpack.optimize.AggressiveMergingPlugin(),
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return plugins;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function makeStyleLoaders(options) {
|
|
41
|
-
if (options.isDevelopment) {
|
|
42
|
-
return [
|
|
43
|
-
{
|
|
44
|
-
test: /\.s[ac]ss$/,
|
|
45
|
-
loaders: [
|
|
46
|
-
'style',
|
|
47
|
-
'css?sourceMap',
|
|
48
|
-
'autoprefixer-loader?browsers=last 2 version',
|
|
49
|
-
'sass?sourceMap&sourceMapContents',
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return [
|
|
56
|
-
{
|
|
57
|
-
test: /\.s[ac]ss$/,
|
|
58
|
-
loader: ExtractTextPlugin.extract(
|
|
59
|
-
'style-loader',
|
|
60
|
-
'css!autoprefixer-loader?browsers=last 2 version!sass'
|
|
61
|
-
),
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function makeConfig(options) {
|
|
67
|
-
if (!options) options = {};
|
|
68
|
-
_.defaults(options, DEFAULTS);
|
|
69
|
-
|
|
70
|
-
const isDevelopment = options.isDevelopment;
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
devtool: isDevelopment ? 'cheap-eval-source-map' : 'source-map',
|
|
74
|
-
entry: {
|
|
75
|
-
steem: path.join(options.baseDir, 'src/browser.js'),
|
|
76
|
-
'steem-tests': path.join(options.baseDir, 'test/api.test.js'),
|
|
77
|
-
},
|
|
78
|
-
output: {
|
|
79
|
-
path: path.join(options.baseDir, 'dist'),
|
|
80
|
-
filename: '[name].min.js',
|
|
81
|
-
},
|
|
82
|
-
plugins: makePlugins(options),
|
|
83
|
-
module: {
|
|
84
|
-
loaders: [
|
|
85
|
-
{
|
|
86
|
-
test: /\.js?$/,
|
|
87
|
-
loader: 'babel',
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
test: /\.json?$/,
|
|
91
|
-
loader: 'json',
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (!module.parent) {
|
|
99
|
-
console.log(makeConfig({
|
|
100
|
-
isDevelopment: process.env.NODE_ENV !== 'production',
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
exports = module.exports = makeConfig;
|
|
105
|
-
exports.DEFAULTS = DEFAULTS;
|
package/webpack.config.js
DELETED