@steemit/steem-js 0.8.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +202 -105
  2. package/dist/api/index.d.ts +128 -0
  3. package/dist/api/methods.d.ts +9 -0
  4. package/dist/api/rpc-auth.d.ts +43 -0
  5. package/dist/api/transports/base.d.ts +13 -0
  6. package/dist/api/transports/http.d.ts +9 -0
  7. package/dist/api/transports/index.d.ts +9 -0
  8. package/dist/api/transports/types.d.ts +35 -0
  9. package/dist/api/transports/ws.d.ts +18 -0
  10. package/dist/auth/ecc/index.d.ts +9 -0
  11. package/dist/auth/ecc/src/address.d.ts +13 -0
  12. package/dist/auth/ecc/src/aes.d.ts +16 -0
  13. package/dist/auth/ecc/src/brain_key.d.ts +1 -0
  14. package/dist/auth/ecc/src/ecdsa.d.ts +28 -0
  15. package/dist/auth/ecc/src/ecsignature.d.ts +19 -0
  16. package/dist/auth/ecc/src/enforce_types.d.ts +5 -0
  17. package/dist/auth/ecc/src/hash.d.ts +25 -0
  18. package/dist/auth/ecc/src/index.d.ts +9 -0
  19. package/dist/auth/ecc/src/key_private.d.ts +38 -0
  20. package/dist/auth/ecc/src/key_public.d.ts +41 -0
  21. package/dist/auth/ecc/src/key_utils.d.ts +9 -0
  22. package/dist/auth/ecc/src/signature.d.ts +18 -0
  23. package/dist/auth/ecc.d.ts +3 -0
  24. package/dist/auth/index.d.ts +48 -0
  25. package/dist/auth/key_classes.d.ts +3 -0
  26. package/dist/auth/serializer.d.ts +19 -0
  27. package/dist/broadcast/helpers.d.ts +11 -0
  28. package/dist/broadcast/index.d.ts +43 -0
  29. package/dist/broadcast/operations.d.ts +6 -0
  30. package/dist/config.d.ts +25 -0
  31. package/dist/crypto/index.d.ts +25 -0
  32. package/dist/formatter/index.d.ts +92 -0
  33. package/dist/index.cjs +25848 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.ts +30 -0
  36. package/dist/index.js +25812 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/index.umd.js +57513 -0
  39. package/dist/index.umd.js.map +1 -0
  40. package/dist/memo/index.d.ts +11 -0
  41. package/dist/operations/index.d.ts +44 -0
  42. package/dist/serializer/convert.d.ts +12 -0
  43. package/dist/serializer/index.d.ts +11 -0
  44. package/dist/serializer/number_utils.d.ts +8 -0
  45. package/dist/serializer/precision.d.ts +5 -0
  46. package/dist/serializer/types.d.ts +36 -0
  47. package/dist/types/index.d.ts +131 -0
  48. package/dist/types.d.ts +34 -0
  49. package/dist/utils/index.d.ts +8 -0
  50. package/dist/utils.d.ts +2 -0
  51. package/package.json +68 -87
  52. package/.dockerignore +0 -12
  53. package/.editorconfig +0 -20
  54. package/.eslintrc +0 -27
  55. package/LICENSE +0 -21
  56. package/circle.yml +0 -3
  57. package/config.json +0 -10
  58. package/dist/steem-tests.min.js +0 -4097
  59. package/dist/steem.min.js +0 -2089
  60. package/docker-webpack.config.js +0 -44
  61. package/lib/api/index.js +0 -315
  62. package/lib/api/methods.js +0 -428
  63. package/lib/api/rpc-auth.js +0 -135
  64. package/lib/api/transports/base.js +0 -31
  65. package/lib/api/transports/http.js +0 -157
  66. package/lib/api/transports/index.js +0 -13
  67. package/lib/api/transports/ws.js +0 -128
  68. package/lib/auth/ecc/index.js +0 -13
  69. package/lib/auth/ecc/src/address.js +0 -54
  70. package/lib/auth/ecc/src/aes.js +0 -148
  71. package/lib/auth/ecc/src/brain_key.js +0 -13
  72. package/lib/auth/ecc/src/ecdsa.js +0 -193
  73. package/lib/auth/ecc/src/ecsignature.js +0 -102
  74. package/lib/auth/ecc/src/enforce_types.js +0 -42
  75. package/lib/auth/ecc/src/hash.js +0 -58
  76. package/lib/auth/ecc/src/key_private.js +0 -159
  77. package/lib/auth/ecc/src/key_public.js +0 -143
  78. package/lib/auth/ecc/src/key_utils.js +0 -70
  79. package/lib/auth/ecc/src/signature.js +0 -135
  80. package/lib/auth/index.js +0 -113
  81. package/lib/auth/memo.js +0 -119
  82. package/lib/auth/serializer/index.js +0 -15
  83. package/lib/auth/serializer/src/ChainTypes.js +0 -87
  84. package/lib/auth/serializer/src/convert.js +0 -34
  85. package/lib/auth/serializer/src/error_with_cause.js +0 -27
  86. package/lib/auth/serializer/src/fast_parser.js +0 -57
  87. package/lib/auth/serializer/src/number_utils.js +0 -43
  88. package/lib/auth/serializer/src/object_id.js +0 -43
  89. package/lib/auth/serializer/src/operations.js +0 -695
  90. package/lib/auth/serializer/src/precision.js +0 -77
  91. package/lib/auth/serializer/src/serializer.js +0 -165
  92. package/lib/auth/serializer/src/template.js +0 -22
  93. package/lib/auth/serializer/src/types.js +0 -1085
  94. package/lib/auth/serializer/src/validation.js +0 -300
  95. package/lib/broadcast/helpers.js +0 -140
  96. package/lib/broadcast/index.js +0 -106
  97. package/lib/broadcast/operations.js +0 -255
  98. package/lib/browser.js +0 -25
  99. package/lib/config.js +0 -23
  100. package/lib/formatter.js +0 -163
  101. package/lib/index.js +0 -21
  102. package/lib/utils.js +0 -50
  103. package/node-18.dockerfile +0 -28
  104. package/test/Crypto.js +0 -100
  105. package/test/KeyFormats.js +0 -105
  106. package/test/all_types.js +0 -115
  107. package/test/api.test.js +0 -363
  108. package/test/broadcast.test.js +0 -231
  109. package/test/browser/BrowserTests.js +0 -55
  110. package/test/comment.test.js +0 -83
  111. package/test/hf20-accounts.test.js +0 -76
  112. package/test/hf21-sps.test.js +0 -78
  113. package/test/memo.test.js +0 -37
  114. package/test/number_utils.js +0 -28
  115. package/test/operations_test.js +0 -39
  116. package/test/promise-broadcast.test.js +0 -86
  117. package/test/reputation.test.js +0 -68
  118. package/test/smt.test.js +0 -347
  119. package/test/test-post.json +0 -13
  120. package/test/test.html +0 -13
  121. package/test/test_helper.js +0 -19
  122. package/test/types_test.js +0 -139
  123. package/test-github-workflow.bat +0 -19
  124. package/test-github-workflow.sh +0 -15
  125. package/webpack/makeConfig.js +0 -113
  126. package/webpack.config.js +0 -2
@@ -1,86 +0,0 @@
1
- import Promise from 'bluebird';
2
- import should from 'should';
3
- import steem from '../src';
4
-
5
- const username = process.env.STEEM_USERNAME || 'guest123';
6
- const password = process.env.STEEM_PASSWORD;
7
- const postingWif = password
8
- ? steem.auth.toWif(username, password, 'posting')
9
- : '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg';
10
-
11
- describe('steem.broadcast: Promise Support', () => {
12
- it('should support Promises without Async suffix', function() {
13
- this.timeout(10000);
14
- const votePromise = steem.broadcast.vote(
15
- postingWif,
16
- username,
17
- 'yamadapc',
18
- 'test-1-2-3-4-5-6-7-9',
19
- 1000
20
- );
21
-
22
- should(votePromise).be.an.instanceof(Promise);
23
-
24
- return votePromise.then(tx => {
25
- tx.should.have.properties([
26
- 'expiration',
27
- 'ref_block_num',
28
- 'ref_block_prefix',
29
- 'extensions',
30
- 'operations',
31
- 'signatures',
32
- ]);
33
- });
34
- });
35
-
36
- it('should still support callbacks', function(done) {
37
- this.timeout(10000);
38
- steem.broadcast.vote(
39
- postingWif,
40
- username,
41
- 'yamadapc',
42
- 'test-1-2-3-4-5-6-7-9',
43
- 1000,
44
- (err, tx) => {
45
- if (err) return done(err);
46
- tx.should.have.properties([
47
- 'expiration',
48
- 'ref_block_num',
49
- 'ref_block_prefix',
50
- 'extensions',
51
- 'operations',
52
- 'signatures',
53
- ]);
54
- done();
55
- }
56
- );
57
- });
58
-
59
- it('should support direct Promise on send method', function() {
60
- this.timeout(10000);
61
- const operations = [['vote', {
62
- voter: username,
63
- author: 'yamadapc',
64
- permlink: 'test-1-2-3-4-5-6-7-9',
65
- weight: 1000,
66
- }]];
67
-
68
- const sendPromise = steem.broadcast.send(
69
- { operations, extensions: [] },
70
- { posting: postingWif }
71
- );
72
-
73
- should(sendPromise).be.an.instanceof(Promise);
74
-
75
- return sendPromise.then(tx => {
76
- tx.should.have.properties([
77
- 'expiration',
78
- 'ref_block_num',
79
- 'ref_block_prefix',
80
- 'extensions',
81
- 'operations',
82
- 'signatures',
83
- ]);
84
- });
85
- });
86
- });
@@ -1,68 +0,0 @@
1
- import assert from 'assert';
2
- import steem from '../src';
3
-
4
- describe('steem.format.reputation', ()=> {
5
- const reputation = steem.formatter.reputation;
6
- it('rep 0 => 25', () => {
7
- assert.equal(reputation(0), 25);
8
- });
9
- it('rep 95832978796820 => 69', () => {
10
- assert.equal(reputation(95832978796820), 69);
11
- });
12
- it('rep 10004392664120 => 61', () => {
13
- assert.equal(reputation(10004392664120), 61);
14
- });
15
- it('rep 30999525306309 => 65', () => {
16
- assert.equal(reputation(30999525306309), 65);
17
- });
18
- it('rep -37765258368568 => -16', () => {
19
- assert.equal(reputation(-37765258368568), -16);
20
- });
21
- it('rep 334486135407077 => 74', () => {
22
- assert.equal(reputation(334486135407077), 74);
23
- });
24
- it('rep null => null', () => {
25
- assert.equal(reputation(null), null);
26
- });
27
- it('rep undefined => undefined', () => {
28
- assert.equal(reputation(undefined), undefined);
29
- });
30
- it('rep -1234123412342234 => -29', () => {
31
- assert.equal(reputation(-1234123412342234), -29);
32
- });
33
- it('rep -22233344455 => 12', () => {
34
- assert.equal(reputation(-22233344455), 12);
35
- });
36
-
37
- // with decimal places
38
- it('rep 0 => 25', () => {
39
- assert.equal(reputation(0, 1), 25);
40
- });
41
- it('rep 95832978796820 => 69.83', () => {
42
- assert.equal(reputation(95832978796820, 2), 69.83);
43
- });
44
- it('rep 10004392664120 => 61.002', () => {
45
- assert.equal(reputation(10004392664120, 3), 61.002);
46
- });
47
- it('rep 30999525306309 => 65.4222', () => {
48
- assert.equal(reputation(30999525306309, 4), 65.4222);
49
- });
50
- it('rep -37765258368568 => -16.19383', () => {
51
- assert.equal(reputation(-37765258368568, 5), -16.19383);
52
- });
53
- it('rep 334486135407077 => 74.719403', () => {
54
- assert.equal(reputation(334486135407077, 6), 74.719403);
55
- });
56
- it('rep null => null', () => {
57
- assert.equal(reputation(null, 7), null);
58
- });
59
- it('rep undefined => undefined', () => {
60
- assert.equal(reputation(undefined, 8), undefined);
61
- });
62
- it('rep -1234123412342234 => -29.822227322', () => {
63
- assert.equal(reputation(-1234123412342234, 9), -29.822227322);
64
- });
65
- it('rep -22233344455 => 12.8769568338', () => {
66
- assert.equal(reputation(-22233344455, 10), 12.8769568338);
67
- });
68
- })
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.24.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.24.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.24.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.24.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.24.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.24.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.24.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.24.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.24.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.24.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
- });
@@ -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>
@@ -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
- }
@@ -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); };