@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,225 +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:', () => {
12
- it('exists', () => {
13
- should.exist(steem.broadcast);
14
- });
15
-
16
- it('has generated methods', () => {
17
- should.exist(steem.broadcast.vote);
18
- should.exist(steem.broadcast.voteWith);
19
- should.exist(steem.broadcast.comment);
20
- should.exist(steem.broadcast.transfer);
21
- });
22
-
23
- it('has backing methods', () => {
24
- should.exist(steem.broadcast.send);
25
- });
26
-
27
- it('has promise methods', () => {
28
- should.exist(steem.broadcast.sendAsync);
29
- should.exist(steem.broadcast.voteAsync);
30
- should.exist(steem.broadcast.transferAsync);
31
- });
32
-
33
- describe('patching transaction with default global properties', () => {
34
- it('works', async () => {
35
- const tx = await steem.broadcast._prepareTransaction({
36
- extensions: [],
37
- operations: [['vote', {
38
- voter: 'yamadapc',
39
- author: 'yamadapc',
40
- permlink: 'test-1-2-3-4-5-6-7-9',
41
- }]],
42
- });
43
-
44
- tx.should.have.properties([
45
- 'expiration',
46
- 'ref_block_num',
47
- 'ref_block_prefix',
48
- 'extensions',
49
- 'operations',
50
- ]);
51
- });
52
- });
53
-
54
- describe('no blocks on chain', () => {
55
- it('works', async () => {
56
- const newAccountName = username + '-' + Math.floor(Math.random() * 10000);
57
- const keys = steem.auth.generateKeys(
58
- username, password, ['posting', 'active', 'owner', 'memo']);
59
-
60
- const oldGetDynamicGlobalProperties = steem.api.getDynamicGlobalPropertiesAsync;
61
- steem.api.getDynamicGlobalPropertiesAsync = () => Promise.resolve({
62
- time: '2019-04-14T21:30:56',
63
- last_irreversible_block_num: 32047459,
64
- });
65
-
66
- // If the block returned is `null`, then no blocks are on the chain yet.
67
- const oldGetBlockAsync = steem.api.getBlockAsync;
68
- steem.api.getBlockAsync = () => Promise.resolve(null);
69
-
70
- try {
71
- const tx = await steem.broadcast._prepareTransaction({
72
- extensions: [],
73
- operations: [[
74
- 'account_create',
75
- {
76
- fee: '0.000 STEEM',
77
- creator: username,
78
- new_account_name: newAccountName,
79
- owner: {
80
- weight_threshold: 1,
81
- account_auths: [],
82
- key_auths: [[keys.owner, 1]],
83
- },
84
- active: {
85
- weight_threshold: 1,
86
- account_auths: [],
87
- key_auths: [[keys.active, 1]],
88
- },
89
- posting: {
90
- weight_threshold: 1,
91
- account_auths: [],
92
- key_auths: [[keys.posting, 1]],
93
- },
94
- memo_key: keys.memo,
95
- json_metadata: '',
96
- extensions: [],
97
- }
98
- ]],
99
- });
100
-
101
- tx.should.have.properties([
102
- 'expiration',
103
- 'ref_block_num',
104
- 'ref_block_prefix',
105
- 'extensions',
106
- 'operations',
107
- ]);
108
- } finally {
109
- steem.api.getDynamicGlobalPropertiesAsync = oldGetDynamicGlobalProperties;
110
- steem.api.getBlockAsync = oldGetBlockAsync;
111
- }
112
- });
113
- });
114
-
115
- describe('downvoting', () => {
116
- it('works', async () => {
117
- const tx = await steem.broadcast.voteAsync(
118
- postingWif,
119
- username,
120
- 'yamadapc',
121
- 'test-1-2-3-4-5-6-7-9',
122
- -1000
123
- );
124
- tx.should.have.properties([
125
- 'expiration',
126
- 'ref_block_num',
127
- 'ref_block_prefix',
128
- 'extensions',
129
- 'operations',
130
- 'signatures',
131
- ]);
132
- });
133
- });
134
-
135
- describe('voting', () => {
136
- beforeEach(() => {
137
- return Promise.delay(2000);
138
- });
139
-
140
- it('works', async () => {
141
- const tx = await steem.broadcast.voteAsync(
142
- postingWif,
143
- username,
144
- 'yamadapc',
145
- 'test-1-2-3-4-5-6-7-9',
146
- 10000
147
- );
148
-
149
- tx.should.have.properties([
150
- 'expiration',
151
- 'ref_block_num',
152
- 'ref_block_prefix',
153
- 'extensions',
154
- 'operations',
155
- 'signatures',
156
- ]);
157
- });
158
-
159
- it('works with callbacks', (done) => {
160
- steem.broadcast.vote(
161
- postingWif,
162
- username,
163
- 'yamadapc',
164
- 'test-1-2-3-4-5-6-7-9',
165
- 5000,
166
- (err, tx) => {
167
- if (err) return done(err);
168
- tx.should.have.properties([
169
- 'expiration',
170
- 'ref_block_num',
171
- 'ref_block_prefix',
172
- 'extensions',
173
- 'operations',
174
- 'signatures',
175
- ]);
176
- done();
177
- }
178
- );
179
- });
180
- });
181
-
182
- describe('customJson', () => {
183
- before(() => {
184
- return Promise.delay(2000);
185
- });
186
-
187
- it('works', async () => {
188
- const tx = await steem.broadcast.customJsonAsync(
189
- postingWif,
190
- [],
191
- [username],
192
- 'follow',
193
- JSON.stringify([
194
- 'follow',
195
- {
196
- follower: username,
197
- following: 'fabien',
198
- what: ['blog'],
199
- },
200
- ])
201
- );
202
-
203
- tx.should.have.properties([
204
- 'expiration',
205
- 'ref_block_num',
206
- 'ref_block_prefix',
207
- 'extensions',
208
- 'operations',
209
- 'signatures',
210
- ]);
211
- });
212
- });
213
-
214
- describe('writeOperations', () => {
215
- it('receives a properly formatted error response', () => {
216
- const wif = steem.auth.toWif('username', 'password', 'posting');
217
- return steem.broadcast.voteAsync(wif, 'voter', 'author', 'permlink', 0).
218
- then(() => {
219
- throw new Error('writeOperation should have failed but it didn\'t');
220
- }, (e) => {
221
- should.exist(e.message);
222
- });
223
- });
224
- });
225
- });
@@ -1,55 +0,0 @@
1
- import assert from 'assert'
2
- import {PrivateKey, PublicKey} from 'shared/ecc'
3
- import {encode, decode} from 'shared/chain/memo'
4
- import {serverApiRecordEvent} from 'app/utils/ServerApiClient'
5
-
6
- export const browserTests = {}
7
-
8
- export default function runTests() {
9
- let rpt = ''
10
- let pass = true
11
- function it(name, fn) {
12
- console.log('Testing', name)
13
- rpt += 'Testing ' + name + '\n'
14
- try {
15
- fn()
16
- } catch(error) {
17
- console.error(error)
18
- pass = false
19
- rpt += error.stack + '\n\n'
20
- serverApiRecordEvent('client_error', error)
21
- }
22
- }
23
-
24
- let private_key, public_key, encodedMemo
25
- const wif = '5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw'
26
- const pubkey = 'STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA'
27
-
28
- it('create private key', () => {
29
- private_key = PrivateKey.fromSeed('1')
30
- assert.equal(private_key.toWif(), wif)
31
- })
32
- it('supports WIF format', () => {
33
- assert(PrivateKey.fromWif(wif))
34
- })
35
- it('finds public from private key', () => {
36
- public_key = private_key.toPublicKey()
37
- // substring match ignore prefix
38
- assert.equal(public_key.toString(), pubkey, 'Public key did not match')
39
- })
40
- it('parses public key', () => {
41
- assert(PublicKey.fromString(public_key.toString()))
42
- })
43
- it('encrypts memo', () => {
44
- encodedMemo = encode(private_key, public_key, '#memo')
45
- assert(encodedMemo)
46
- })
47
- it('decripts memo', () => {
48
- const dec = decode(private_key, encodedMemo)
49
- if(dec !== '#memo') {
50
- console.error('Decoded memo did not match (memo encryption is unavailable)')
51
- browserTests.memo_encryption = false
52
- }
53
- })
54
- if(!pass) return rpt
55
- }
@@ -1,69 +0,0 @@
1
- import Promise from 'bluebird';
2
- import should from 'should';
3
- import steem from '../src';
4
- import pkg from '../package.json';
5
-
6
- const username = process.env.STEEM_USERNAME || 'guest123';
7
- const password = process.env.STEEM_PASSWORD;
8
- const postingWif = password
9
- ? steem.auth.toWif(username, password, 'posting')
10
- : '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg';
11
-
12
- describe('steem.broadcast:', () => {
13
-
14
- describe('comment with options', () => {
15
- before(() => {
16
- return Promise.delay(2000);
17
- });
18
-
19
- it('works', async () => {
20
- const permlink = steem.formatter.commentPermlink('siol', 'test');
21
- const operations = [
22
- ['comment',
23
- {
24
- parent_author: 'siol',
25
- parent_permlink: 'test',
26
- author: username,
27
- permlink,
28
- title: 'Test',
29
- body: `This is a test using Steem.js v${pkg.version}.`,
30
- json_metadata : JSON.stringify({
31
- tags: ['test'],
32
- app: `steemjs/${pkg.version}`
33
- })
34
- }
35
- ],
36
- ['comment_options', {
37
- author: username,
38
- permlink,
39
- max_accepted_payout: '1000000.000 SBD',
40
- percent_steem_dollars: 10000,
41
- allow_votes: true,
42
- allow_curation_rewards: true,
43
- extensions: [
44
- [0, {
45
- beneficiaries: [
46
- { account: 'good-karma', weight: 2000 },
47
- { account: 'null', weight: 5000 }
48
- ]
49
- }]
50
- ]
51
- }]
52
- ];
53
-
54
- const tx = await steem.broadcast.sendAsync(
55
- { operations, extensions: [] },
56
- { posting: postingWif }
57
- );
58
-
59
- tx.should.have.properties([
60
- 'expiration',
61
- 'ref_block_num',
62
- 'ref_block_prefix',
63
- 'extensions',
64
- 'operations',
65
- 'signatures',
66
- ]);
67
- });
68
- });
69
- });
@@ -1,76 +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 activeWif = steem.auth.toWif(username, password, 'active');
8
-
9
- describe('steem.hf20-accounts:', () => {
10
- it('has generated methods', () => {
11
- should.exist(steem.broadcast.claimAccount);
12
- should.exist(steem.broadcast.createClaimedAccount);
13
- });
14
-
15
- it('has promise methods', () => {
16
- should.exist(steem.broadcast.claimAccountAsync);
17
- should.exist(steem.broadcast.createClaimedAccountAsync);
18
- });
19
-
20
-
21
- describe('claimAccount', () => {
22
-
23
- /* Skip these tests. Steem-js test infrastructure not set up for testing active auths
24
- Blocked by Steem issue #3546
25
- it('signs and verifies auth', function(done) {
26
- let tx = {
27
- 'operations': [[
28
- 'claim_account', {
29
- 'creator': username,
30
- 'fee': '0.000 STEEM'}]]
31
- }
32
-
33
- steem.api.callAsync('condenser_api.get_version', []).then((result) => {
34
- if(result['blockchain_version'] < '0.22.0') return done();
35
-
36
- steem.broadcast._prepareTransaction(tx).then(function(tx){
37
- tx = steem.auth.signTransaction(tx, [activeWif]);
38
- steem.api.verifyAuthorityAsync(tx).then(
39
- (result) => {result.should.equal(true); done();},
40
- (err) => {done(err);}
41
- );
42
- });
43
- });
44
-
45
- });
46
-
47
- it('claims and creates account', function(done) {
48
- this.skip(); // (!) need test account with enough RC
49
-
50
- steem.api.callAsync('condenser_api.get_version', []).then((result) => {
51
- if(result['blockchain_version'] < '0.22.0') return done();
52
-
53
- steem.broadcast.claimAccountAsync(activeWif, username, '0.000 STEEM', []).then((result) => {
54
- let newAccountName = username + '-' + Math.floor(Math.random() * 10000);
55
- let keys = steem.auth.generateKeys(
56
- username, password, ['posting', 'active', 'owner', 'memo']);
57
-
58
- steem.broadcast.createClaimedAccountAsync(
59
- activeWif,
60
- username,
61
- newAccountName,
62
- keys['owner'],
63
- keys['active'],
64
- keys['posting'],
65
- keys['memo'],
66
- {}, []
67
- ).then((result) => {
68
- should.exist(result);
69
- done();
70
- }, (err) => {done(err)});
71
- }, (err) => {done(err)});
72
- });
73
- });
74
- */
75
- });
76
- });
@@ -1,78 +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.hf21-accounts:', () => {
11
- it('has generated methods', () => {
12
- should.exist(steem.broadcast.createProposal);
13
- should.exist(steem.broadcast.updateProposalVotes);
14
- should.exist(steem.broadcast.removeProposal);
15
- });
16
-
17
- it('has promise methods', () => {
18
- should.exist(steem.broadcast.createProposalAsync);
19
- should.exist(steem.broadcast.updateProposalVotesAsync);
20
- should.exist(steem.broadcast.removeProposalAsync);
21
- });
22
-
23
- describe('create proposal ops', () => {
24
- /* Skip these tests. Steem-js test infrastructure not set up for testing active auths
25
- Blocked by Steem issue #3546
26
- it('signs and verifies create_proposal', function(done) {
27
- let permlink = 'test';
28
-
29
- let tx = {
30
- 'operations': [[
31
- 'create_proposal', {
32
- 'creator': username,
33
- 'receiver': username,
34
- 'start_date': '2019-09-01T00:00:00',
35
- 'end_date': '2019-10-01T00:00:00',
36
- 'daily_pay': '1.000 SBD',
37
- 'subject': 'testing',
38
- 'permlink': permlink
39
- }]]
40
- }
41
-
42
- steem.api.callAsync('condenser_api.get_version', []).then((result) => {
43
- if(result['blockchain_version'] < '0.22.0') return done();
44
- result.should.have.property('blockchain_version');
45
-
46
- steem.broadcast._prepareTransaction(tx).then(function(tx){
47
- tx = steem.auth.signTransaction(tx, [activeWif]);
48
- steem.api.verifyAuthorityAsync(tx).then(
49
- (result) => {result.should.equal(true); done();},
50
- (err) => {done(err);}
51
- );
52
- });
53
- });
54
- })
55
-
56
- it('signs and verifies update_proposal_votes', function(done) {
57
- let tx = {
58
- 'operations': [[
59
- 'update_proposal_votes', {
60
- 'voter': username,
61
- 'proposal_ids': [7],
62
- 'approve': true
63
- }]]
64
- }
65
-
66
- return done();
67
-
68
- steem.broadcast._prepareTransaction(tx).then(function(tx){
69
- tx = steem.auth.signTransaction(tx, [activeWif]);
70
- steem.api.verifyAuthorityAsync(tx).then(
71
- (result) => {result.should.equal(true); done();},
72
- (err) => {done(err);}
73
- );
74
- });
75
- })
76
- */
77
- });
78
- });
package/test/memo.test.js DELETED
@@ -1,37 +0,0 @@
1
- import assert from 'assert'
2
- import {encode, decode} from '../src/auth/memo';
3
- import {PrivateKey} from '../src/auth/ecc';
4
-
5
-
6
- const private_key = PrivateKey.fromSeed("")
7
- const public_key = private_key.toPublicKey()
8
-
9
- describe('steem.auth: memo', ()=> {
10
- it('plain text', () => {
11
- const plaintext1 = encode(null/*private_key*/, null/*public_key*/, 'memo')
12
- assert.equal(plaintext1, 'memo')
13
-
14
- const plaintext2 = decode(null/*private_key*/, plaintext1)
15
- assert.equal(plaintext2, 'memo')
16
- })
17
- it('encryption obj params', () => {
18
- const cypertext = encode(private_key, public_key, '#memo')
19
- const plaintext = decode(private_key, cypertext)
20
- assert.equal(plaintext, '#memo')
21
- })
22
- it('encryption string params', () => {
23
- const cypertext = encode(private_key.toWif(), public_key.toPublicKeyString(), '#memo2')
24
- const plaintext = decode(private_key.toWif(), cypertext)
25
- assert.equal(plaintext, '#memo2')
26
- })
27
- it('known encryption', () => {
28
- const base58 = '#HU6pdQ4Hh8cFrDVooekRPVZu4BdrhAe9RxrWrei2CwfAApAPdM4PT5mSV9cV3tTuWKotYQF6suyM4JHFBZz4pcwyezPzuZ2na7uwhRcLqFoqCam1VU3eCLjVNqcgUNbH3'
29
- const nonce = '1462976530069648'
30
- const text = '#爱'
31
-
32
- const cypertext = encode(private_key, public_key, text, nonce)
33
- assert.equal(cypertext, base58)
34
- const plaintext = decode(private_key, cypertext)
35
- assert.equal(plaintext, text)
36
- })
37
- })
@@ -1,28 +0,0 @@
1
- import assert from "assert"
2
- import { toImpliedDecimal, fromImpliedDecimal } from "../src/auth/serializer/src/number_utils"
3
-
4
- describe("steem.auth: Number utils", () => {
5
-
6
-
7
- it("to implied decimal", ()=> {
8
- assert.equal("1", toImpliedDecimal(1, 0))
9
- assert.equal("10", toImpliedDecimal(1, 1))
10
- assert.equal("100", toImpliedDecimal(1, 2))
11
- assert.equal("10", toImpliedDecimal(".1", 2))
12
- assert.equal("10", toImpliedDecimal("0.1", 2))
13
- assert.equal("10", toImpliedDecimal("00.1", 2))
14
- assert.equal("10", toImpliedDecimal("00.10", 2))
15
- assert.throws(()=> toImpliedDecimal("00.100", 2))
16
- assert.throws(()=> toImpliedDecimal(9007199254740991 + 1, 1))
17
- })
18
-
19
- it("from implied decimal", ()=> {
20
- assert.equal("1", fromImpliedDecimal(1, 0))
21
- assert.equal("0.1", fromImpliedDecimal(1, 1))
22
- assert.equal("0.01", fromImpliedDecimal(1, 2))
23
- // must have suffixing zeros
24
- assert.equal("0.100", fromImpliedDecimal(100, 3))
25
- })
26
-
27
-
28
- })
@@ -1,39 +0,0 @@
1
- var assert = require('assert');
2
- var types = require('../src/auth/serializer/src/types');
3
- var ops = require('../src/auth/serializer/src/operations');
4
-
5
- describe("steem.auth: operation test", ()=> {
6
-
7
- it("templates", ()=> {
8
- for(let op in ops) {
9
- switch(op) {
10
- case "operation" : continue
11
- }
12
- template(ops[op])
13
- }
14
- })
15
-
16
- it("account_create", ()=> {
17
- let tx = {"ref_block_num": 19297,"ref_block_prefix": 1608085982,"expiration": "2016-03-23T22:41:21","operations": [ ["account_create",{"fee": "0.000 STEEM","creator": "initminer","new_account_name": "scott","owner": {"weight_threshold": 1,"account_auths": [],"key_auths": [ ["STM7DTS62msowgpAZJBNRMStMUt5bfRA4hc9j5wjwU4vKhi3KFkKb",1 ]]},"active": {"weight_threshold": 1,"account_auths": [],"key_auths": [ ["STM8k1f8fvHxLrCTqMdRUJcK2rCE3y7SQBb8PremyadWvVWMeedZy",1 ]]},"posting": {"weight_threshold": 1,"account_auths": [],"key_auths": [ ["STM6DgpKJqoVGg7o6J1jdiP45xxbgoUg5VGzs96YBxX42NZu2bZea",1 ]]},"memo_key": "STM6ppNVEFmvBW4jEkzxXnGKuKuwYjMUrhz2WX1kHeGSchGdWJEDQ","json_metadata": ""} ]],"extensions": [], "signatures": []}
18
-
19
- let tx_hex = "614bde71d95f911bf3560109000000000000000003535445454d000009696e69746d696e65720573636f74740100000000010332757668fa45c2bc21447a2ff1dc2bbed9d9dda1616fd7b700255bd28e9d674a010001000000000103fb8900a262d51b908846be54fcf04b3a80d12ee749b9446f976b58b220ba4eed010001000000000102af4963d0f034043f4b4b0c99220e6a4b5d8b9cc71e5cd7d110f7602f3a0a11d1010002ff0de11ef55b998daf88047f1a00a60ed5dffb0c23c3279f8bd42a733845c5da000000"
20
-
21
- // 03 53 54 45 45 4d 0000
22
- assert.equal("STEEM", new Buffer("535445454d", "hex").toString())
23
- let tx_object1 = ops.signed_transaction.fromObject(tx)
24
- let tx_object2 = ops.signed_transaction.fromHex(tx_hex)
25
- assert.deepEqual(tx, ops.signed_transaction.toObject(tx_object1))
26
- assert.deepEqual(tx, ops.signed_transaction.toObject(tx_object2))
27
- assert.deepEqual(tx_hex, ops.signed_transaction.toHex(tx_object1))
28
- assert.deepEqual(tx_hex, ops.signed_transaction.toHex(tx_object2))
29
- })
30
-
31
- })
32
-
33
- function template(op) {
34
-
35
- assert(op.toObject({}, {use_default: true}))
36
- assert(op.toObject({}, {use_default: true, annotate: true}))
37
-
38
-
39
- }