@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,413 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = [{
7
- "api": "database_api",
8
- "method": "set_subscribe_callback",
9
- "params": ["callback", "clearFilter"]
10
- }, {
11
- "api": "database_api",
12
- "method": "set_pending_transaction_callback",
13
- "params": ["cb"]
14
- }, {
15
- "api": "database_api",
16
- "method": "set_block_applied_callback",
17
- "params": ["cb"]
18
- }, {
19
- "api": "database_api",
20
- "method": "cancel_all_subscriptions"
21
- }, {
22
- "api": "database_api",
23
- "method": "get_trending_tags",
24
- "params": ["afterTag", "limit"]
25
- }, {
26
- "api": "database_api",
27
- "method": "get_tags_used_by_author",
28
- "params": ["author"]
29
- }, {
30
- "api": "database_api",
31
- "method": "get_post_discussions_by_payout",
32
- "params": ["query"]
33
- }, {
34
- "api": "database_api",
35
- "method": "get_comment_discussions_by_payout",
36
- "params": ["query"]
37
- }, {
38
- "api": "database_api",
39
- "method": "get_discussions_by_trending",
40
- "params": ["query"]
41
- }, {
42
- "api": "database_api",
43
- "method": "get_discussions_by_trending30",
44
- "params": ["query"]
45
- }, {
46
- "api": "database_api",
47
- "method": "get_discussions_by_created",
48
- "params": ["query"]
49
- }, {
50
- "api": "database_api",
51
- "method": "get_discussions_by_active",
52
- "params": ["query"]
53
- }, {
54
- "api": "database_api",
55
- "method": "get_discussions_by_cashout",
56
- "params": ["query"]
57
- }, {
58
- "api": "database_api",
59
- "method": "get_discussions_by_payout",
60
- "params": ["query"]
61
- }, {
62
- "api": "database_api",
63
- "method": "get_discussions_by_votes",
64
- "params": ["query"]
65
- }, {
66
- "api": "database_api",
67
- "method": "get_discussions_by_children",
68
- "params": ["query"]
69
- }, {
70
- "api": "database_api",
71
- "method": "get_discussions_by_hot",
72
- "params": ["query"]
73
- }, {
74
- "api": "database_api",
75
- "method": "get_discussions_by_feed",
76
- "params": ["query"]
77
- }, {
78
- "api": "database_api",
79
- "method": "get_discussions_by_blog",
80
- "params": ["query"]
81
- }, {
82
- "api": "database_api",
83
- "method": "get_discussions_by_comments",
84
- "params": ["query"]
85
- }, {
86
- "api": "database_api",
87
- "method": "get_discussions_by_promoted",
88
- "params": ["query"]
89
- }, {
90
- "api": "database_api",
91
- "method": "get_block_header",
92
- "params": ["blockNum"]
93
- }, {
94
- "api": "database_api",
95
- "method": "get_block",
96
- "params": ["blockNum"]
97
- }, {
98
- "api": "database_api",
99
- "method": "get_ops_in_block",
100
- "params": ["blockNum", "onlyVirtual"]
101
- }, {
102
- "api": "database_api",
103
- "method": "get_state",
104
- "params": ["path"]
105
- }, {
106
- "api": "database_api",
107
- "method": "get_trending_categories",
108
- "params": ["after", "limit"]
109
- }, {
110
- "api": "database_api",
111
- "method": "get_best_categories",
112
- "params": ["after", "limit"]
113
- }, {
114
- "api": "database_api",
115
- "method": "get_active_categories",
116
- "params": ["after", "limit"]
117
- }, {
118
- "api": "database_api",
119
- "method": "get_recent_categories",
120
- "params": ["after", "limit"]
121
- }, {
122
- "api": "database_api",
123
- "method": "get_config"
124
- }, {
125
- "api": "database_api",
126
- "method": "get_dynamic_global_properties"
127
- }, {
128
- "api": "database_api",
129
- "method": "get_chain_properties"
130
- }, {
131
- "api": "database_api",
132
- "method": "get_feed_history"
133
- }, {
134
- "api": "database_api",
135
- "method": "get_current_median_history_price"
136
- }, {
137
- "api": "database_api",
138
- "method": "get_witness_schedule"
139
- }, {
140
- "api": "database_api",
141
- "method": "get_hardfork_version"
142
- }, {
143
- "api": "database_api",
144
- "method": "get_next_scheduled_hardfork"
145
- }, {
146
- "api": "account_by_key_api",
147
- "method": "get_key_references",
148
- "params": ["key"]
149
- }, {
150
- "api": "database_api",
151
- "method": "get_accounts",
152
- "params": ["names"]
153
- }, {
154
- "api": "database_api",
155
- "method": "get_account_references",
156
- "params": ["accountId"]
157
- }, {
158
- "api": "database_api",
159
- "method": "lookup_account_names",
160
- "params": ["accountNames"]
161
- }, {
162
- "api": "database_api",
163
- "method": "lookup_accounts",
164
- "params": ["lowerBoundName", "limit"]
165
- }, {
166
- "api": "database_api",
167
- "method": "get_account_count"
168
- }, {
169
- "api": "database_api",
170
- "method": "get_conversion_requests",
171
- "params": ["accountName"]
172
- }, {
173
- "api": "database_api",
174
- "method": "get_account_history",
175
- "params": ["account", "from", "limit"]
176
- }, {
177
- "api": "database_api",
178
- "method": "get_owner_history",
179
- "params": ["account"]
180
- }, {
181
- "api": "database_api",
182
- "method": "get_recovery_request",
183
- "params": ["account"]
184
- }, {
185
- "api": "database_api",
186
- "method": "get_escrow",
187
- "params": ["from", "escrowId"]
188
- }, {
189
- "api": "database_api",
190
- "method": "get_withdraw_routes",
191
- "params": ["account", "withdrawRouteType"]
192
- }, {
193
- "api": "database_api",
194
- "method": "get_account_bandwidth",
195
- "params": ["account", "bandwidthType"]
196
- }, {
197
- "api": "database_api",
198
- "method": "get_savings_withdraw_from",
199
- "params": ["account"]
200
- }, {
201
- "api": "database_api",
202
- "method": "get_savings_withdraw_to",
203
- "params": ["account"]
204
- }, {
205
- "api": "database_api",
206
- "method": "get_order_book",
207
- "params": ["limit"]
208
- }, {
209
- "api": "database_api",
210
- "method": "get_open_orders",
211
- "params": ["owner"]
212
- }, {
213
- "api": "database_api",
214
- "method": "get_liquidity_queue",
215
- "params": ["startAccount", "limit"]
216
- }, {
217
- "api": "database_api",
218
- "method": "get_transaction_hex",
219
- "params": ["trx"]
220
- }, {
221
- "api": "database_api",
222
- "method": "get_transaction",
223
- "params": ["trxId"]
224
- }, {
225
- "api": "database_api",
226
- "method": "get_required_signatures",
227
- "params": ["trx", "availableKeys"]
228
- }, {
229
- "api": "database_api",
230
- "method": "get_potential_signatures",
231
- "params": ["trx"]
232
- }, {
233
- "api": "database_api",
234
- "method": "verify_authority",
235
- "params": ["trx"]
236
- }, {
237
- "api": "database_api",
238
- "method": "verify_account_authority",
239
- "params": ["nameOrId", "signers"]
240
- }, {
241
- "api": "database_api",
242
- "method": "get_active_votes",
243
- "params": ["author", "permlink"]
244
- }, {
245
- "api": "database_api",
246
- "method": "get_account_votes",
247
- "params": ["voter"]
248
- }, {
249
- "api": "database_api",
250
- "method": "get_content",
251
- "params": ["author", "permlink"]
252
- }, {
253
- "api": "database_api",
254
- "method": "get_content_replies",
255
- "params": ["author", "permlink"]
256
- }, {
257
- "api": "database_api",
258
- "method": "get_discussions_by_author_before_date",
259
- "params": ["author", "startPermlink", "beforeDate", "limit"]
260
- }, {
261
- "api": "database_api",
262
- "method": "get_replies_by_last_update",
263
- "params": ["startAuthor", "startPermlink", "limit"]
264
- }, {
265
- "api": "database_api",
266
- "method": "get_witnesses",
267
- "params": ["witnessIds"]
268
- }, {
269
- "api": "database_api",
270
- "method": "get_witness_by_account",
271
- "params": ["accountName"]
272
- }, {
273
- "api": "database_api",
274
- "method": "get_witnesses_by_vote",
275
- "params": ["from", "limit"]
276
- }, {
277
- "api": "database_api",
278
- "method": "lookup_witness_accounts",
279
- "params": ["lowerBoundName", "limit"]
280
- }, {
281
- "api": "database_api",
282
- "method": "get_witness_count"
283
- }, {
284
- "api": "database_api",
285
- "method": "get_active_witnesses"
286
- }, {
287
- "api": "database_api",
288
- "method": "get_miner_queue"
289
- }, {
290
- "api": "database_api",
291
- "method": "get_reward_fund",
292
- "params": ["name"]
293
- }, {
294
- "api": "database_api",
295
- "method": "get_vesting_delegations",
296
- "params": ["account", "from", "limit"]
297
- }, {
298
- "api": "login_api",
299
- "method": "login",
300
- "params": ["username", "password"]
301
- }, {
302
- "api": "login_api",
303
- "method": "get_api_by_name",
304
- "params": ["database_api"]
305
- }, {
306
- "api": "login_api",
307
- "method": "get_version"
308
- }, {
309
- "api": "follow_api",
310
- "method": "get_followers",
311
- "params": ["following", "startFollower", "followType", "limit"]
312
- }, {
313
- "api": "follow_api",
314
- "method": "get_following",
315
- "params": ["follower", "startFollowing", "followType", "limit"]
316
- }, {
317
- "api": "follow_api",
318
- "method": "get_follow_count",
319
- "params": ["account"]
320
- }, {
321
- "api": "follow_api",
322
- "method": "get_feed_entries",
323
- "params": ["account", "entryId", "limit"]
324
- }, {
325
- "api": "follow_api",
326
- "method": "get_feed",
327
- "params": ["account", "entryId", "limit"]
328
- }, {
329
- "api": "follow_api",
330
- "method": "get_blog_entries",
331
- "params": ["account", "entryId", "limit"]
332
- }, {
333
- "api": "follow_api",
334
- "method": "get_blog",
335
- "params": ["account", "entryId", "limit"]
336
- }, {
337
- "api": "follow_api",
338
- "method": "get_account_reputations",
339
- "params": ["lowerBoundName", "limit"]
340
- }, {
341
- "api": "follow_api",
342
- "method": "get_reblogged_by",
343
- "params": ["author", "permlink"]
344
- }, {
345
- "api": "follow_api",
346
- "method": "get_blog_authors",
347
- "params": ["blogAccount"]
348
- }, {
349
- "api": "network_broadcast_api",
350
- "method": "broadcast_transaction",
351
- "params": ["trx"]
352
- }, {
353
- "api": "network_broadcast_api",
354
- "method": "broadcast_transaction_with_callback",
355
- "params": ["confirmationCallback", "trx"]
356
- }, {
357
- "api": "network_broadcast_api",
358
- "method": "broadcast_transaction_synchronous",
359
- "params": ["trx"]
360
- }, {
361
- "api": "network_broadcast_api",
362
- "method": "broadcast_block",
363
- "params": ["b"]
364
- }, {
365
- "api": "network_broadcast_api",
366
- "method": "set_max_block_age",
367
- "params": ["maxBlockAge"]
368
- }, {
369
- "api": "market_history_api",
370
- "method": "get_ticker",
371
- "params": []
372
- }, {
373
- "api": "market_history_api",
374
- "method": "get_volume",
375
- "params": []
376
- }, {
377
- "api": "market_history_api",
378
- "method": "get_order_book",
379
- "method_name": "getMarketOrderBook",
380
- "params": ["limit"]
381
- }, {
382
- "api": "market_history_api",
383
- "method": "get_trade_history",
384
- "params": ["start", "end", "limit"]
385
- }, {
386
- "api": "market_history_api",
387
- "method": "get_recent_trades",
388
- "params": ["limit"]
389
- }, {
390
- "api": "market_history_api",
391
- "method": "get_market_history",
392
- "params": ["bucket_seconds", "start", "end"]
393
- }, {
394
- "api": "market_history_api",
395
- "method": "get_market_history_buckets",
396
- "params": []
397
- }, {
398
- "api": "condenser_api",
399
- "method": "find_proposals",
400
- "params": ["id_set"]
401
- }, {
402
- "api": "condenser_api",
403
- "method": "list_proposals",
404
- "params": ["start", "limit", "order_by", "order_direction", "status"]
405
- }, {
406
- "api": "condenser_api",
407
- "method": "list_proposal_votes",
408
- "params": ["start", "limit", "order_by", "order_direction", "status"]
409
- }, {
410
- "api": "condenser_api",
411
- "method": "get_nai_pool",
412
- "params": []
413
- }];
@@ -1,72 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- var _bluebird = require('bluebird');
10
-
11
- var _bluebird2 = _interopRequireDefault(_bluebird);
12
-
13
- var _events = require('events');
14
-
15
- var _events2 = _interopRequireDefault(_events);
16
-
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
19
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
-
21
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
22
-
23
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
24
-
25
- var Transport = function (_EventEmitter) {
26
- _inherits(Transport, _EventEmitter);
27
-
28
- function Transport() {
29
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
30
-
31
- _classCallCheck(this, Transport);
32
-
33
- var _this = _possibleConstructorReturn(this, (Transport.__proto__ || Object.getPrototypeOf(Transport)).call(this, options));
34
-
35
- _this.options = options;
36
- _this.id = 0;
37
- return _this;
38
- }
39
-
40
- _createClass(Transport, [{
41
- key: 'setOptions',
42
- value: function setOptions(options) {
43
- Object.assign(this.options, options);
44
- this.stop();
45
- }
46
- }, {
47
- key: 'listenTo',
48
- value: function listenTo(target, eventName, callback) {
49
- if (target.addEventListener) target.addEventListener(eventName, callback);else target.on(eventName, callback);
50
-
51
- return function () {
52
- if (target.removeEventListener) target.removeEventListener(eventName, callback);else target.removeListener(eventName, callback);
53
- };
54
- }
55
- }, {
56
- key: 'send',
57
- value: function send() {}
58
- }, {
59
- key: 'start',
60
- value: function start() {}
61
- }, {
62
- key: 'stop',
63
- value: function stop() {}
64
- }]);
65
-
66
- return Transport;
67
- }(_events2.default);
68
-
69
- exports.default = Transport;
70
-
71
-
72
- _bluebird2.default.promisifyAll(Transport.prototype);
@@ -1,172 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- exports.jsonRpc = jsonRpc;
10
-
11
- var _crossFetch = require('cross-fetch');
12
-
13
- var _crossFetch2 = _interopRequireDefault(_crossFetch);
14
-
15
- var _debug = require('debug');
16
-
17
- var _debug2 = _interopRequireDefault(_debug);
18
-
19
- var _retry = require('retry');
20
-
21
- var _retry2 = _interopRequireDefault(_retry);
22
-
23
- var _base = require('./base');
24
-
25
- var _base2 = _interopRequireDefault(_base);
26
-
27
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
30
-
31
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
32
-
33
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
34
-
35
- var debug = (0, _debug2.default)('steem:http');
36
-
37
- var RPCError = function (_Error) {
38
- _inherits(RPCError, _Error);
39
-
40
- function RPCError(rpcError) {
41
- _classCallCheck(this, RPCError);
42
-
43
- var _this = _possibleConstructorReturn(this, (RPCError.__proto__ || Object.getPrototypeOf(RPCError)).call(this, rpcError.message));
44
-
45
- _this.name = 'RPCError';
46
- _this.code = rpcError.code;
47
- _this.data = rpcError.data;
48
- return _this;
49
- }
50
-
51
- return RPCError;
52
- }(Error);
53
-
54
- /**
55
- * Makes a JSON-RPC request using `fetch` or a user-provided `fetchMethod`.
56
- *
57
- * @param {string} uri - The URI to the JSON-RPC endpoint.
58
- * @param {string} options.method - The remote JSON-RPC method to call.
59
- * @param {string} options.id - ID for the request, for matching to a response.
60
- * @param {*} options.params - The params for the remote method.
61
- * @param {function} [options.fetchMethod=fetch] - A function with the same
62
- * signature as `fetch`, which can be used to make the network request, or for
63
- * stubbing in tests.
64
- */
65
-
66
-
67
- function jsonRpc(uri, _ref) {
68
- var method = _ref.method,
69
- id = _ref.id,
70
- params = _ref.params,
71
- _ref$fetchMethod = _ref.fetchMethod,
72
- fetchMethod = _ref$fetchMethod === undefined ? _crossFetch2.default : _ref$fetchMethod;
73
-
74
- var payload = { id: id, jsonrpc: '2.0', method: method, params: params };
75
- return fetchMethod(uri, {
76
- body: JSON.stringify(payload),
77
- method: 'post',
78
- mode: 'cors',
79
- headers: {
80
- Accept: 'application/json, text/plain, */*',
81
- 'Content-Type': 'application/json'
82
- }
83
- }).then(function (res) {
84
- if (!res.ok) {
85
- throw new Error('HTTP ' + res.status + ': ' + res.statusText);
86
- }
87
- return res.json();
88
- }).then(function (rpcRes) {
89
- if (rpcRes.id !== id) {
90
- throw new Error('Invalid response id: ' + rpcRes.id);
91
- }
92
- if (rpcRes.error) {
93
- throw new RPCError(rpcRes.error);
94
- }
95
- return rpcRes.result;
96
- });
97
- }
98
-
99
- var HttpTransport = function (_Transport) {
100
- _inherits(HttpTransport, _Transport);
101
-
102
- function HttpTransport() {
103
- _classCallCheck(this, HttpTransport);
104
-
105
- return _possibleConstructorReturn(this, (HttpTransport.__proto__ || Object.getPrototypeOf(HttpTransport)).apply(this, arguments));
106
- }
107
-
108
- _createClass(HttpTransport, [{
109
- key: 'send',
110
- value: function send(api, data, callback) {
111
- var _this3 = this;
112
-
113
- if (this.options.useAppbaseApi) {
114
- api = 'condenser_api';
115
- }
116
- debug('Steem::send', api, data);
117
- var id = data.id || this.id++;
118
- var params = [api, data.method, data.params];
119
- var retriable = this.retriable(api, data);
120
- var fetchMethod = this.options.fetchMethod;
121
- if (retriable) {
122
- retriable.attempt(function (currentAttempt) {
123
- jsonRpc(_this3.options.uri, { method: 'call', id: id, params: params, fetchMethod: fetchMethod }).then(function (res) {
124
- callback(null, res);
125
- }, function (err) {
126
- if (retriable.retry(err)) {
127
- return;
128
- }
129
- callback(retriable.mainError());
130
- });
131
- });
132
- } else {
133
- jsonRpc(this.options.uri, { method: 'call', id: id, params: params, fetchMethod: fetchMethod }).then(function (res) {
134
- callback(null, res);
135
- }, function (err) {
136
- callback(err);
137
- });
138
- }
139
- }
140
- }, {
141
- key: 'retriable',
142
-
143
-
144
- // An object which can be used to track retries.
145
- value: function retriable(api, data) {
146
- if (this.nonRetriableOperations.some(function (o) {
147
- return o === data.method;
148
- })) {
149
- // Do not retry if the operation is non-retriable.
150
- return null;
151
- } else if (Object(this.options.retry) === this.options.retry) {
152
- // If `this.options.retry` is a map of options, pass those to operation.
153
- return _retry2.default.operation(this.options.retry);
154
- } else if (this.options.retry) {
155
- // If `this.options.retry` is `true`, use default options.
156
- return _retry2.default.operation();
157
- } else {
158
- // Otherwise, don't retry.
159
- return null;
160
- }
161
- }
162
- }, {
163
- key: 'nonRetriableOperations',
164
- get: function get() {
165
- return this.options.nonRetriableOperations || ['broadcast_transaction', 'broadcast_transaction_with_callback', 'broadcast_transaction_synchronous', 'broadcast_block'];
166
- }
167
- }]);
168
-
169
- return HttpTransport;
170
- }(_base2.default);
171
-
172
- exports.default = HttpTransport;
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _http = require('./http');
8
-
9
- var _http2 = _interopRequireDefault(_http);
10
-
11
- var _ws = require('./ws');
12
-
13
- var _ws2 = _interopRequireDefault(_ws);
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
- exports.default = {
18
- http: _http2.default,
19
- ws: _ws2.default
20
- };