UNPKG

79.9 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
7var _classCallCheck = _interopDefault(require('@babel/runtime/helpers/classCallCheck'));
8var _createClass = _interopDefault(require('@babel/runtime/helpers/createClass'));
9var EventEmitter = _interopDefault(require('eventemitter3'));
10var confluxWebCoreSubscriptions = require('conflux-web-core-subscriptions');
11var _possibleConstructorReturn = _interopDefault(require('@babel/runtime/helpers/possibleConstructorReturn'));
12var _getPrototypeOf = _interopDefault(require('@babel/runtime/helpers/getPrototypeOf'));
13var _inherits = _interopDefault(require('@babel/runtime/helpers/inherits'));
14var isFunction = _interopDefault(require('lodash/isFunction'));
15var _toConsumableArray = _interopDefault(require('@babel/runtime/helpers/toConsumableArray'));
16var _regeneratorRuntime = _interopDefault(require('@babel/runtime/regenerator'));
17var _asyncToGenerator = _interopDefault(require('@babel/runtime/helpers/asyncToGenerator'));
18var isString = _interopDefault(require('lodash/isString'));
19var cloneDeep = _interopDefault(require('lodash/cloneDeep'));
20var rxjs = require('rxjs');
21var _get = _interopDefault(require('@babel/runtime/helpers/get'));
22
23var PromiEvent = function () {
24 function PromiEvent() {
25 var _this = this;
26 _classCallCheck(this, PromiEvent);
27 this.promise = new Promise(function (resolve, reject) {
28 _this.resolve = resolve;
29 _this.reject = reject;
30 });
31 this.eventEmitter = new EventEmitter();
32 return new Proxy(this, {
33 get: this.proxyHandler
34 });
35 }
36 _createClass(PromiEvent, [{
37 key: "proxyHandler",
38 value: function proxyHandler(target, name) {
39 if (name === 'resolve' || name === 'reject') {
40 return target[name];
41 }
42 if (name === 'then') {
43 return target.promise.then.bind(target.promise);
44 }
45 if (name === 'catch') {
46 return target.promise["catch"].bind(target.promise);
47 }
48 if (target.eventEmitter[name]) {
49 return target.eventEmitter[name];
50 }
51 }
52 }]);
53 return PromiEvent;
54}();
55
56var AbstractMethod = function () {
57 function AbstractMethod(rpcMethod, parametersAmount, utils, formatters, moduleInstance) {
58 _classCallCheck(this, AbstractMethod);
59 this.utils = utils;
60 this.formatters = formatters;
61 this.moduleInstance = moduleInstance;
62 this._arguments = {
63 parameters: []
64 };
65 this._rpcMethod = rpcMethod;
66 this._parametersAmount = parametersAmount;
67 }
68 _createClass(AbstractMethod, [{
69 key: "beforeExecution",
70 value: function beforeExecution(moduleInstance) {}
71 }, {
72 key: "afterExecution",
73 value: function afterExecution(response) {
74 return response;
75 }
76 }, {
77 key: "execute",
78 value: function () {
79 var _execute = _asyncToGenerator( _regeneratorRuntime.mark(function _callee() {
80 var response;
81 return _regeneratorRuntime.wrap(function _callee$(_context) {
82 while (1) {
83 switch (_context.prev = _context.next) {
84 case 0:
85 this.beforeExecution(this.moduleInstance);
86 if (!(this.parameters.length !== this.parametersAmount)) {
87 _context.next = 3;
88 break;
89 }
90 throw new Error("Invalid Arguments length: expected: ".concat(this.parametersAmount, ", given: ").concat(this.parameters.length));
91 case 3:
92 _context.prev = 3;
93 _context.next = 6;
94 return this.moduleInstance.currentProvider.send(this.rpcMethod, this.parameters);
95 case 6:
96 response = _context.sent;
97 if (response) {
98 response = this.afterExecution(response);
99 }
100 if (this.callback) {
101 this.callback(false, response);
102 }
103 return _context.abrupt("return", response);
104 case 12:
105 _context.prev = 12;
106 _context.t0 = _context["catch"](3);
107 if (this.callback) {
108 this.callback(_context.t0, null);
109 }
110 throw _context.t0;
111 case 16:
112 case "end":
113 return _context.stop();
114 }
115 }
116 }, _callee, this, [[3, 12]]);
117 }));
118 function execute() {
119 return _execute.apply(this, arguments);
120 }
121 return execute;
122 }()
123 }, {
124 key: "setArguments",
125 value: function setArguments(methodArguments) {
126 var parameters = cloneDeep(_toConsumableArray(methodArguments));
127 var callback = null;
128 if (parameters.length > this.parametersAmount) {
129 if (!isFunction(parameters[parameters.length - 1])) {
130 throw new TypeError("The latest parameter should be a function otherwise it can't be used as callback");
131 }
132 callback = parameters.pop();
133 }
134 this._arguments = {
135 callback: callback,
136 parameters: parameters
137 };
138 }
139 }, {
140 key: "getArguments",
141 value: function getArguments() {
142 return this._arguments;
143 }
144 }, {
145 key: "isHash",
146 value: function isHash(parameter) {
147 return isString(parameter) && parameter.startsWith('0x');
148 }
149 }, {
150 key: "rpcMethod",
151 set: function set(value) {
152 this._rpcMethod = value;
153 }
154 ,
155 get: function get() {
156 return this._rpcMethod;
157 }
158 }, {
159 key: "parametersAmount",
160 set: function set(value) {
161 this._parametersAmount = value;
162 }
163 ,
164 get: function get() {
165 return this._parametersAmount;
166 }
167 }, {
168 key: "parameters",
169 get: function get() {
170 return this._arguments.parameters;
171 }
172 ,
173 set: function set(value) {
174 this._arguments.parameters = value;
175 }
176 }, {
177 key: "callback",
178 get: function get() {
179 return this._arguments.callback;
180 }
181 ,
182 set: function set(value) {
183 this._arguments.callback = value;
184 }
185 }]);
186 return AbstractMethod;
187}();
188
189function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
190function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
191var AbstractGetBlockMethod = function (_AbstractMethod) {
192 _inherits(AbstractGetBlockMethod, _AbstractMethod);
193 var _super = _createSuper(AbstractGetBlockMethod);
194 function AbstractGetBlockMethod(rpcMethod, utils, formatters, moduleInstance) {
195 _classCallCheck(this, AbstractGetBlockMethod);
196 return _super.call(this, rpcMethod, 2, utils, formatters, moduleInstance);
197 }
198 _createClass(AbstractGetBlockMethod, [{
199 key: "beforeExecution",
200 value: function beforeExecution(moduleInstance) {
201 this.parameters[0] = this.formatters.inputBlockAddressFormatter(this.parameters[0]);
202 if (isFunction(this.parameters[1])) {
203 this.callback = this.parameters[1];
204 this.parameters[1] = false;
205 } else {
206 this.parameters[1] = !!this.parameters[1];
207 }
208 }
209 }, {
210 key: "afterExecution",
211 value: function afterExecution(response) {
212 return this.formatters.outputBlockFormatter(response);
213 }
214 }]);
215 return AbstractGetBlockMethod;
216}(AbstractMethod);
217
218function _createSuper$1(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$1()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
219function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
220var GetBlockByNumberMethod = function (_AbstractGetBlockMeth) {
221 _inherits(GetBlockByNumberMethod, _AbstractGetBlockMeth);
222 var _super = _createSuper$1(GetBlockByNumberMethod);
223 function GetBlockByNumberMethod(utils, formatters, moduleInstance) {
224 _classCallCheck(this, GetBlockByNumberMethod);
225 return _super.call(this, 'cfx_getBlockByEpochNumber', utils, formatters, moduleInstance);
226 }
227 return GetBlockByNumberMethod;
228}(AbstractGetBlockMethod);
229
230function _createSuper$2(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$2()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
231function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
232var GetTransactionReceiptMethod = function (_AbstractMethod) {
233 _inherits(GetTransactionReceiptMethod, _AbstractMethod);
234 var _super = _createSuper$2(GetTransactionReceiptMethod);
235 function GetTransactionReceiptMethod(utils, formatters, moduleInstance) {
236 _classCallCheck(this, GetTransactionReceiptMethod);
237 return _super.call(this, 'cfx_getTransactionReceipt', 1, utils, formatters, moduleInstance);
238 }
239 _createClass(GetTransactionReceiptMethod, [{
240 key: "afterExecution",
241 value: function afterExecution(response) {
242 if (response !== null) {
243 return this.formatters.outputTransactionReceiptFormatter(response);
244 }
245 return response;
246 }
247 }]);
248 return GetTransactionReceiptMethod;
249}(AbstractMethod);
250
251var TransactionObserver = function () {
252 function TransactionObserver(provider, timeout, blockConfirmations, getTransactionReceiptMethod, getBlockByNumberMethod, newHeadsSubscription) {
253 _classCallCheck(this, TransactionObserver);
254 this.provider = provider;
255 this.timeout = timeout;
256 this.blockConfirmations = blockConfirmations;
257 this.getTransactionReceiptMethod = getTransactionReceiptMethod;
258 this.getBlockByNumberMethod = getBlockByNumberMethod;
259 this.newHeadsSubscription = newHeadsSubscription;
260 this.blockNumbers = [];
261 this.lastBlock = false;
262 this.confirmations = 0;
263 this.confirmationChecks = 0;
264 this.interval = false;
265 }
266 _createClass(TransactionObserver, [{
267 key: "observe",
268 value: function observe(transactionHash) {
269 var _this = this;
270 return rxjs.Observable.create(function (observer) {
271 if (_this.provider.supportsSubscriptions()) {
272 _this.startSocketObserver(transactionHash, observer);
273 } else {
274 _this.startHttpObserver(transactionHash, observer);
275 }
276 });
277 }
278 }, {
279 key: "startSocketObserver",
280 value: function startSocketObserver(transactionHash, observer) {
281 var _this2 = this;
282 this.newHeadsSubscription.subscribe( function () {
283 var _ref = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(error, newHead) {
284 var receipt;
285 return _regeneratorRuntime.wrap(function _callee$(_context) {
286 while (1) {
287 switch (_context.prev = _context.next) {
288 case 0:
289 _context.prev = 0;
290 if (!observer.closed) {
291 _context.next = 5;
292 break;
293 }
294 _context.next = 4;
295 return _this2.newHeadsSubscription.unsubscribe();
296 case 4:
297 return _context.abrupt("return");
298 case 5:
299 if (!error) {
300 _context.next = 7;
301 break;
302 }
303 throw error;
304 case 7:
305 _this2.getTransactionReceiptMethod.parameters = [transactionHash];
306 _context.next = 10;
307 return _this2.getTransactionReceiptMethod.execute();
308 case 10:
309 receipt = _context.sent;
310 if (_this2.blockNumbers.includes(newHead.number)) {
311 _context.next = 25;
312 break;
313 }
314 if (!receipt) {
315 _context.next = 19;
316 break;
317 }
318 _this2.confirmations++;
319 _this2.emitNext(receipt, observer);
320 if (!_this2.isConfirmed()) {
321 _context.next = 19;
322 break;
323 }
324 _context.next = 18;
325 return _this2.newHeadsSubscription.unsubscribe();
326 case 18:
327 observer.complete();
328 case 19:
329 _this2.blockNumbers.push(newHead.number);
330 _this2.confirmationChecks++;
331 if (!_this2.isTimeoutTimeExceeded()) {
332 _context.next = 25;
333 break;
334 }
335 _context.next = 24;
336 return _this2.newHeadsSubscription.unsubscribe();
337 case 24:
338 _this2.emitError(new Error('Timeout exceeded during the transaction confirmation process. Be aware the transaction could still get confirmed!'), receipt, observer);
339 case 25:
340 _context.next = 30;
341 break;
342 case 27:
343 _context.prev = 27;
344 _context.t0 = _context["catch"](0);
345 _this2.emitError(_context.t0, false, observer);
346 case 30:
347 case "end":
348 return _context.stop();
349 }
350 }
351 }, _callee, null, [[0, 27]]);
352 }));
353 return function (_x, _x2) {
354 return _ref.apply(this, arguments);
355 };
356 }());
357 }
358 }, {
359 key: "startHttpObserver",
360 value: function startHttpObserver(transactionHash, observer) {
361 var _this3 = this;
362 var interval = setInterval( _asyncToGenerator( _regeneratorRuntime.mark(function _callee2() {
363 var receipt, block;
364 return _regeneratorRuntime.wrap(function _callee2$(_context2) {
365 while (1) {
366 switch (_context2.prev = _context2.next) {
367 case 0:
368 _context2.prev = 0;
369 if (!observer.closed) {
370 _context2.next = 4;
371 break;
372 }
373 clearInterval(interval);
374 return _context2.abrupt("return");
375 case 4:
376 _this3.getTransactionReceiptMethod.parameters = [transactionHash];
377 _context2.next = 7;
378 return _this3.getTransactionReceiptMethod.execute();
379 case 7:
380 receipt = _context2.sent;
381 if (!receipt) {
382 _context2.next = 22;
383 break;
384 }
385 if (!_this3.lastBlock) {
386 _context2.next = 16;
387 break;
388 }
389 _context2.next = 12;
390 return _this3.getBlockByNumber(_this3.increaseBlockNumber(_this3.lastBlock.number));
391 case 12:
392 block = _context2.sent;
393 if (block && _this3.isValidConfirmation(block)) {
394 _this3.lastBlock = block;
395 _this3.confirmations++;
396 _this3.emitNext(receipt, observer);
397 }
398 _context2.next = 21;
399 break;
400 case 16:
401 _context2.next = 18;
402 return _this3.getBlockByNumber(receipt.blockNumber);
403 case 18:
404 _this3.lastBlock = _context2.sent;
405 _this3.confirmations++;
406 _this3.emitNext(receipt, observer);
407 case 21:
408 if (_this3.isConfirmed()) {
409 clearInterval(interval);
410 observer.complete();
411 }
412 case 22:
413 _this3.confirmationChecks++;
414 if (_this3.isTimeoutTimeExceeded()) {
415 clearInterval(interval);
416 _this3.emitError(new Error('Timeout exceeded during the transaction confirmation process. Be aware the transaction could still get confirmed!'), receipt, observer);
417 }
418 _context2.next = 30;
419 break;
420 case 26:
421 _context2.prev = 26;
422 _context2.t0 = _context2["catch"](0);
423 clearInterval(interval);
424 _this3.emitError(_context2.t0, false, observer);
425 case 30:
426 case "end":
427 return _context2.stop();
428 }
429 }
430 }, _callee2, null, [[0, 26]]);
431 })), 1000);
432 }
433 }, {
434 key: "emitNext",
435 value: function emitNext(receipt, observer) {
436 observer.next({
437 receipt: receipt,
438 confirmations: this.confirmations
439 });
440 }
441 }, {
442 key: "emitError",
443 value: function emitError(error, receipt, observer) {
444 observer.error({
445 error: error,
446 receipt: receipt,
447 confirmations: this.confirmations,
448 confirmationChecks: this.confirmationChecks
449 });
450 }
451 }, {
452 key: "getBlockByNumber",
453 value: function getBlockByNumber(blockNumber) {
454 this.getBlockByNumberMethod.parameters = [blockNumber];
455 return this.getBlockByNumberMethod.execute();
456 }
457 }, {
458 key: "isConfirmed",
459 value: function isConfirmed() {
460 return this.confirmations === this.blockConfirmations;
461 }
462 }, {
463 key: "isValidConfirmation",
464 value: function isValidConfirmation(block) {
465 return this.lastBlock.hash === block.parentHash && this.lastBlock.number !== block.number;
466 }
467 }, {
468 key: "isTimeoutTimeExceeded",
469 value: function isTimeoutTimeExceeded() {
470 return this.confirmationChecks === this.timeout;
471 }
472 }, {
473 key: "increaseBlockNumber",
474 value: function increaseBlockNumber(blockNumber) {
475 return '0x' + (parseInt(blockNumber, 16) + 1).toString(16);
476 }
477 }]);
478 return TransactionObserver;
479}();
480
481function _createSuper$3(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$3()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
482function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
483var GetTransactionCountMethod = function (_AbstractMethod) {
484 _inherits(GetTransactionCountMethod, _AbstractMethod);
485 var _super = _createSuper$3(GetTransactionCountMethod);
486 function GetTransactionCountMethod(utils, formatters, moduleInstance) {
487 _classCallCheck(this, GetTransactionCountMethod);
488 return _super.call(this, 'cfx_getTransactionCount', 2, utils, formatters, moduleInstance);
489 }
490 _createClass(GetTransactionCountMethod, [{
491 key: "beforeExecution",
492 value: function beforeExecution(moduleInstance) {
493 this.parameters[0] = this.formatters.inputAddressFormatter(this.parameters[0]);
494 if (isFunction(this.parameters[1])) {
495 this.callback = this.parameters[1];
496 this.parameters[1] = moduleInstance.defaultEpoch;
497 }
498 this.parameters[1] = this.formatters.inputDefaultEpochNumberFormatter(this.parameters[1], moduleInstance);
499 }
500 }, {
501 key: "afterExecution",
502 value: function afterExecution(response) {
503 return this.utils.hexToNumber(response);
504 }
505 }]);
506 return GetTransactionCountMethod;
507}(AbstractMethod);
508
509function _createSuper$4(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$4()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
510function _isNativeReflectConstruct$4() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
511var ChainIdMethod = function (_AbstractMethod) {
512 _inherits(ChainIdMethod, _AbstractMethod);
513 var _super = _createSuper$4(ChainIdMethod);
514 function ChainIdMethod(utils, formatters, moduleInstance) {
515 _classCallCheck(this, ChainIdMethod);
516 return _super.call(this, 'eth_chainId', 0, utils, formatters, moduleInstance);
517 }
518 _createClass(ChainIdMethod, [{
519 key: "afterExecution",
520 value: function afterExecution(response) {
521 return this.utils.hexToNumber(response);
522 }
523 }]);
524 return ChainIdMethod;
525}(AbstractMethod);
526
527var AbstractMethodFactory = function () {
528 function AbstractMethodFactory(utils, formatters) {
529 _classCallCheck(this, AbstractMethodFactory);
530 this.utils = utils;
531 this.formatters = formatters;
532 this._methods = null;
533 }
534 _createClass(AbstractMethodFactory, [{
535 key: "hasMethod",
536 value: function hasMethod(name) {
537 return typeof this.methods[name] !== 'undefined';
538 }
539 }, {
540 key: "createMethod",
541 value: function createMethod(name, moduleInstance) {
542 var method = this.methods[name];
543 if (method.Type === 'observed-transaction-method') {
544 return new method(this.utils, this.formatters, moduleInstance, this.createTransactionObserver(moduleInstance));
545 }
546 if (method.Type === 'cfx-send-transaction-method') {
547 return new method(this.utils, this.formatters, moduleInstance, this.createTransactionObserver(moduleInstance), new ChainIdMethod(this.utils, this.formatters, moduleInstance), new GetTransactionCountMethod(this.utils, this.formatters, moduleInstance));
548 }
549 return new method(this.utils, this.formatters, moduleInstance);
550 }
551 }, {
552 key: "getTimeout",
553 value: function getTimeout(moduleInstance) {
554 var timeout = moduleInstance.transactionBlockTimeout;
555 if (!moduleInstance.currentProvider.supportsSubscriptions()) {
556 timeout = moduleInstance.transactionPollingTimeout;
557 }
558 return timeout;
559 }
560 }, {
561 key: "createTransactionObserver",
562 value: function createTransactionObserver(moduleInstance) {
563 return new TransactionObserver(moduleInstance.currentProvider, this.getTimeout(moduleInstance), moduleInstance.transactionConfirmationBlocks, new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance), new GetBlockByNumberMethod(this.utils, this.formatters, moduleInstance), new confluxWebCoreSubscriptions.NewHeadsSubscription(this.utils, this.formatters, moduleInstance));
564 }
565 }, {
566 key: "methods",
567 get: function get() {
568 if (this._methods) {
569 return this._methods;
570 }
571 throw new Error('No methods defined for MethodFactory!');
572 }
573 ,
574 set: function set(value) {
575 this._methods = value;
576 }
577 }]);
578 return AbstractMethodFactory;
579}();
580
581var MethodProxy =
582function MethodProxy(target, methodFactory) {
583 _classCallCheck(this, MethodProxy);
584 return new Proxy(target, {
585 get: function get(target, name) {
586 if (methodFactory.hasMethod(name)) {
587 var RpcMethod = function RpcMethod() {
588 method.setArguments(arguments);
589 return method.execute();
590 };
591 if (typeof target[name] !== 'undefined') {
592 throw new TypeError("Duplicated method ".concat(name, ". This method is defined as RPC call and as Object method."));
593 }
594 var method = methodFactory.createMethod(name, target);
595 RpcMethod.method = method;
596 RpcMethod.request = function () {
597 method.setArguments(arguments);
598 return method;
599 };
600 return RpcMethod;
601 }
602 return target[name];
603 }
604 });
605};
606
607function _createSuper$5(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$5()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
608function _isNativeReflectConstruct$5() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
609var GetProtocolVersionMethod = function (_AbstractMethod) {
610 _inherits(GetProtocolVersionMethod, _AbstractMethod);
611 var _super = _createSuper$5(GetProtocolVersionMethod);
612 function GetProtocolVersionMethod(utils, formatters, moduleInstance) {
613 _classCallCheck(this, GetProtocolVersionMethod);
614 return _super.call(this, 'eth_protocolVersion', 0, utils, formatters, moduleInstance);
615 }
616 _createClass(GetProtocolVersionMethod, [{
617 key: "afterExecution",
618 value: function afterExecution(response) {
619 return this.utils.hexToNumber(response);
620 }
621 }]);
622 return GetProtocolVersionMethod;
623}(AbstractMethod);
624
625function _createSuper$6(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$6()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
626function _isNativeReflectConstruct$6() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
627var VersionMethod = function (_AbstractMethod) {
628 _inherits(VersionMethod, _AbstractMethod);
629 var _super = _createSuper$6(VersionMethod);
630 function VersionMethod(utils, formatters, moduleInstance) {
631 _classCallCheck(this, VersionMethod);
632 return _super.call(this, 'net_version', 0, utils, formatters, moduleInstance);
633 }
634 _createClass(VersionMethod, [{
635 key: "afterExecution",
636 value: function afterExecution(response) {
637 return this.utils.hexToNumber(response);
638 }
639 }]);
640 return VersionMethod;
641}(AbstractMethod);
642
643function _createSuper$7(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$7()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
644function _isNativeReflectConstruct$7() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
645var ListeningMethod = function (_AbstractMethod) {
646 _inherits(ListeningMethod, _AbstractMethod);
647 var _super = _createSuper$7(ListeningMethod);
648 function ListeningMethod(utils, formatters, moduleInstance) {
649 _classCallCheck(this, ListeningMethod);
650 return _super.call(this, 'net_listening', 0, utils, formatters, moduleInstance);
651 }
652 return ListeningMethod;
653}(AbstractMethod);
654
655function _createSuper$8(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$8()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
656function _isNativeReflectConstruct$8() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
657var PeerCountMethod = function (_AbstractMethod) {
658 _inherits(PeerCountMethod, _AbstractMethod);
659 var _super = _createSuper$8(PeerCountMethod);
660 function PeerCountMethod(utils, formatters, moduleInstance) {
661 _classCallCheck(this, PeerCountMethod);
662 return _super.call(this, 'net_peerCount', 0, utils, formatters, moduleInstance);
663 }
664 _createClass(PeerCountMethod, [{
665 key: "afterExecution",
666 value: function afterExecution(response) {
667 return this.utils.hexToNumber(response);
668 }
669 }]);
670 return PeerCountMethod;
671}(AbstractMethod);
672
673function _createSuper$9(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$9()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
674function _isNativeReflectConstruct$9() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
675var GetNodeInfoMethod = function (_AbstractMethod) {
676 _inherits(GetNodeInfoMethod, _AbstractMethod);
677 var _super = _createSuper$9(GetNodeInfoMethod);
678 function GetNodeInfoMethod(utils, formatters, moduleInstance) {
679 _classCallCheck(this, GetNodeInfoMethod);
680 return _super.call(this, 'confluxWeb_clientVersion', 0, utils, formatters, moduleInstance);
681 }
682 return GetNodeInfoMethod;
683}(AbstractMethod);
684
685function _createSuper$a(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$a()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
686function _isNativeReflectConstruct$a() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
687var GetCoinbaseMethod = function (_AbstractMethod) {
688 _inherits(GetCoinbaseMethod, _AbstractMethod);
689 var _super = _createSuper$a(GetCoinbaseMethod);
690 function GetCoinbaseMethod(utils, formatters, moduleInstance) {
691 _classCallCheck(this, GetCoinbaseMethod);
692 return _super.call(this, 'eth_coinbase', 0, utils, formatters, moduleInstance);
693 }
694 return GetCoinbaseMethod;
695}(AbstractMethod);
696
697function _createSuper$b(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$b()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
698function _isNativeReflectConstruct$b() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
699var IsMiningMethod = function (_AbstractMethod) {
700 _inherits(IsMiningMethod, _AbstractMethod);
701 var _super = _createSuper$b(IsMiningMethod);
702 function IsMiningMethod(utils, formatters, moduleInstance) {
703 _classCallCheck(this, IsMiningMethod);
704 return _super.call(this, 'eth_mining', 0, utils, formatters, moduleInstance);
705 }
706 return IsMiningMethod;
707}(AbstractMethod);
708
709function _createSuper$c(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$c()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
710function _isNativeReflectConstruct$c() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
711var GetHashrateMethod = function (_AbstractMethod) {
712 _inherits(GetHashrateMethod, _AbstractMethod);
713 var _super = _createSuper$c(GetHashrateMethod);
714 function GetHashrateMethod(utils, formatters, moduleInstance) {
715 _classCallCheck(this, GetHashrateMethod);
716 return _super.call(this, 'eth_hashrate', 0, utils, formatters, moduleInstance);
717 }
718 _createClass(GetHashrateMethod, [{
719 key: "afterExecution",
720 value: function afterExecution(response) {
721 return this.utils.hexToNumber(response);
722 }
723 }]);
724 return GetHashrateMethod;
725}(AbstractMethod);
726
727function _createSuper$d(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$d()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
728function _isNativeReflectConstruct$d() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
729var IsSyncingMethod = function (_AbstractMethod) {
730 _inherits(IsSyncingMethod, _AbstractMethod);
731 var _super = _createSuper$d(IsSyncingMethod);
732 function IsSyncingMethod(utils, formatters, moduleInstance) {
733 _classCallCheck(this, IsSyncingMethod);
734 return _super.call(this, 'eth_syncing', 0, utils, formatters, moduleInstance);
735 }
736 _createClass(IsSyncingMethod, [{
737 key: "afterExecution",
738 value: function afterExecution(response) {
739 if (typeof response !== 'boolean') {
740 return this.formatters.outputSyncingFormatter(response);
741 }
742 return response;
743 }
744 }]);
745 return IsSyncingMethod;
746}(AbstractMethod);
747
748function _createSuper$e(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$e()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
749function _isNativeReflectConstruct$e() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
750var GetGasPriceMethod = function (_AbstractMethod) {
751 _inherits(GetGasPriceMethod, _AbstractMethod);
752 var _super = _createSuper$e(GetGasPriceMethod);
753 function GetGasPriceMethod(utils, formatters, moduleInstance) {
754 _classCallCheck(this, GetGasPriceMethod);
755 return _super.call(this, 'cfx_gasPrice', 0, utils, formatters, moduleInstance);
756 }
757 _createClass(GetGasPriceMethod, [{
758 key: "afterExecution",
759 value: function afterExecution(response) {
760 return this.formatters.outputBigNumberFormatter(response);
761 }
762 }]);
763 return GetGasPriceMethod;
764}(AbstractMethod);
765
766function _createSuper$f(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$f()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
767function _isNativeReflectConstruct$f() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
768var SubmitWorkMethod = function (_AbstractMethod) {
769 _inherits(SubmitWorkMethod, _AbstractMethod);
770 var _super = _createSuper$f(SubmitWorkMethod);
771 function SubmitWorkMethod(utils, formatters, moduleInstance) {
772 _classCallCheck(this, SubmitWorkMethod);
773 return _super.call(this, 'eth_submitWork', 3, utils, formatters, moduleInstance);
774 }
775 return SubmitWorkMethod;
776}(AbstractMethod);
777
778function _createSuper$g(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$g()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
779function _isNativeReflectConstruct$g() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
780var GetWorkMethod = function (_AbstractMethod) {
781 _inherits(GetWorkMethod, _AbstractMethod);
782 var _super = _createSuper$g(GetWorkMethod);
783 function GetWorkMethod(utils, formatters, moduleInstance) {
784 _classCallCheck(this, GetWorkMethod);
785 return _super.call(this, 'eth_getWork', 0, utils, formatters, moduleInstance);
786 }
787 return GetWorkMethod;
788}(AbstractMethod);
789
790function _createSuper$h(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$h()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
791function _isNativeReflectConstruct$h() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
792var GetAccountsMethod = function (_AbstractMethod) {
793 _inherits(GetAccountsMethod, _AbstractMethod);
794 var _super = _createSuper$h(GetAccountsMethod);
795 function GetAccountsMethod(utils, formatters, moduleInstance) {
796 _classCallCheck(this, GetAccountsMethod);
797 return _super.call(this, 'cfx_accounts', 0, utils, formatters, moduleInstance);
798 }
799 _createClass(GetAccountsMethod, [{
800 key: "afterExecution",
801 value: function afterExecution(response) {
802 var _this = this;
803 return response.map(function (responseItem) {
804 return _this.utils.toChecksumAddress(responseItem);
805 });
806 }
807 }]);
808 return GetAccountsMethod;
809}(AbstractMethod);
810
811function _createSuper$i(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$i()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
812function _isNativeReflectConstruct$i() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
813var GetBalanceMethod = function (_AbstractMethod) {
814 _inherits(GetBalanceMethod, _AbstractMethod);
815 var _super = _createSuper$i(GetBalanceMethod);
816 function GetBalanceMethod(utils, formatters, moduleInstance) {
817 _classCallCheck(this, GetBalanceMethod);
818 return _super.call(this, 'cfx_getBalance', 2, utils, formatters, moduleInstance);
819 }
820 _createClass(GetBalanceMethod, [{
821 key: "beforeExecution",
822 value: function beforeExecution(moduleInstance) {
823 this.parameters[0] = this.formatters.inputAddressFormatter(this.parameters[0]);
824 if (isFunction(this.parameters[1])) {
825 this.callback = this.parameters[1];
826 this.parameters[1] = moduleInstance.defaultEpoch;
827 }
828 this.parameters[1] = this.formatters.inputDefaultEpochNumberFormatter(this.parameters[1], moduleInstance);
829 }
830 }, {
831 key: "afterExecution",
832 value: function afterExecution(response) {
833 return this.formatters.outputBigNumberFormatter(response);
834 }
835 }]);
836 return GetBalanceMethod;
837}(AbstractMethod);
838
839function _createSuper$j(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$j()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
840function _isNativeReflectConstruct$j() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
841var RequestAccountsMethod = function (_AbstractMethod) {
842 _inherits(RequestAccountsMethod, _AbstractMethod);
843 var _super = _createSuper$j(RequestAccountsMethod);
844 function RequestAccountsMethod(utils, formatters, moduleInstance) {
845 _classCallCheck(this, RequestAccountsMethod);
846 return _super.call(this, 'eth_requestAccounts', 0, utils, formatters, moduleInstance);
847 }
848 return RequestAccountsMethod;
849}(AbstractMethod);
850
851function _createSuper$k(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$k()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
852function _isNativeReflectConstruct$k() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
853var AbstractGetBlockTransactionCountMethod = function (_AbstractMethod) {
854 _inherits(AbstractGetBlockTransactionCountMethod, _AbstractMethod);
855 var _super = _createSuper$k(AbstractGetBlockTransactionCountMethod);
856 function AbstractGetBlockTransactionCountMethod(rpcMethod, utils, formatters, moduleInstance) {
857 _classCallCheck(this, AbstractGetBlockTransactionCountMethod);
858 return _super.call(this, rpcMethod, 1, utils, formatters, moduleInstance);
859 }
860 _createClass(AbstractGetBlockTransactionCountMethod, [{
861 key: "beforeExecution",
862 value: function beforeExecution(moduleInstance) {
863 this.parameters[0] = this.formatters.inputBlockAddressFormatter(this.parameters[0]);
864 }
865 }, {
866 key: "afterExecution",
867 value: function afterExecution(response) {
868 return this.utils.hexToNumber(response);
869 }
870 }]);
871 return AbstractGetBlockTransactionCountMethod;
872}(AbstractMethod);
873
874function _createSuper$l(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$l()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
875function _isNativeReflectConstruct$l() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
876var GetBlockByHashMethod = function (_AbstractGetBlockMeth) {
877 _inherits(GetBlockByHashMethod, _AbstractGetBlockMeth);
878 var _super = _createSuper$l(GetBlockByHashMethod);
879 function GetBlockByHashMethod(utils, formatters, moduleInstance) {
880 _classCallCheck(this, GetBlockByHashMethod);
881 return _super.call(this, 'cfx_getBlockByHash', utils, formatters, moduleInstance);
882 }
883 return GetBlockByHashMethod;
884}(AbstractGetBlockMethod);
885
886function _createSuper$m(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$m()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
887function _isNativeReflectConstruct$m() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
888var GetBlockTransactionCountByHashMethod = function (_AbstractGetBlockTran) {
889 _inherits(GetBlockTransactionCountByHashMethod, _AbstractGetBlockTran);
890 var _super = _createSuper$m(GetBlockTransactionCountByHashMethod);
891 function GetBlockTransactionCountByHashMethod(utils, formatters, moduleInstance) {
892 _classCallCheck(this, GetBlockTransactionCountByHashMethod);
893 return _super.call(this, 'cfx_getBlockTransactionCountByHash', utils, formatters, moduleInstance);
894 }
895 return GetBlockTransactionCountByHashMethod;
896}(AbstractGetBlockTransactionCountMethod);
897
898function _createSuper$n(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$n()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
899function _isNativeReflectConstruct$n() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
900var GetBlockTransactionCountByNumberMethod = function (_AbstractGetBlockTran) {
901 _inherits(GetBlockTransactionCountByNumberMethod, _AbstractGetBlockTran);
902 var _super = _createSuper$n(GetBlockTransactionCountByNumberMethod);
903 function GetBlockTransactionCountByNumberMethod(utils, formatters, moduleInstance) {
904 _classCallCheck(this, GetBlockTransactionCountByNumberMethod);
905 return _super.call(this, 'cfx_getBlockTransactionCountByNumber', utils, formatters, moduleInstance);
906 }
907 return GetBlockTransactionCountByNumberMethod;
908}(AbstractGetBlockTransactionCountMethod);
909
910function _createSuper$o(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$o()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
911function _isNativeReflectConstruct$o() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
912var AbstractGetTransactionFromBlockMethod = function (_AbstractMethod) {
913 _inherits(AbstractGetTransactionFromBlockMethod, _AbstractMethod);
914 var _super = _createSuper$o(AbstractGetTransactionFromBlockMethod);
915 function AbstractGetTransactionFromBlockMethod(rpcMethod, utils, formatters, moduleInstance) {
916 _classCallCheck(this, AbstractGetTransactionFromBlockMethod);
917 return _super.call(this, rpcMethod, 2, utils, formatters, moduleInstance);
918 }
919 _createClass(AbstractGetTransactionFromBlockMethod, [{
920 key: "beforeExecution",
921 value: function beforeExecution(moduleInstance) {
922 this.parameters[0] = this.formatters.inputBlockAddressFormatter(this.parameters[0]);
923 this.parameters[1] = this.utils.numberToHex(this.parameters[1]);
924 }
925 }, {
926 key: "afterExecution",
927 value: function afterExecution(response) {
928 return this.formatters.outputTransactionFormatter(response);
929 }
930 }]);
931 return AbstractGetTransactionFromBlockMethod;
932}(AbstractMethod);
933
934function _createSuper$p(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$p()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
935function _isNativeReflectConstruct$p() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
936var AbstractObservedTransactionMethod = function (_AbstractMethod) {
937 _inherits(AbstractObservedTransactionMethod, _AbstractMethod);
938 var _super = _createSuper$p(AbstractObservedTransactionMethod);
939 function AbstractObservedTransactionMethod(rpcMethod, parametersAmount, utils, formatters, moduleInstance, transactionObserver) {
940 var _this;
941 _classCallCheck(this, AbstractObservedTransactionMethod);
942 _this = _super.call(this, rpcMethod, parametersAmount, utils, formatters, moduleInstance);
943 _this.transactionObserver = transactionObserver;
944 _this.promiEvent = new PromiEvent();
945 return _this;
946 }
947 _createClass(AbstractObservedTransactionMethod, [{
948 key: "execute",
949 value: function execute() {
950 var _this2 = this;
951 this.beforeExecution(this.moduleInstance);
952 this.moduleInstance.currentProvider.send(this.rpcMethod, this.parameters).then(function (transactionHash) {
953 if (_this2.callback) {
954 _this2.promiEvent.resolve(_this2.callback(false, transactionHash));
955 return;
956 }
957 _this2.promiEvent.resolve(transactionHash);
958 })["catch"](function (error) {
959 if (_this2.callback) {
960 _this2.callback(error, null);
961 return;
962 }
963 _this2.handleError(error, false, 0);
964 });
965 return this.promiEvent;
966 }
967 }, {
968 key: "handleError",
969 value: function handleError(error, receipt, confirmations) {
970 if (this.promiEvent.listenerCount('error') > 0) {
971 this.promiEvent.emit('error', error, receipt, confirmations);
972 this.promiEvent.removeAllListeners();
973 return;
974 }
975 this.promiEvent.reject(error);
976 }
977 }], [{
978 key: "Type",
979 get: function get() {
980 return 'observed-transaction-method';
981 }
982 }]);
983 return AbstractObservedTransactionMethod;
984}(AbstractMethod);
985
986function _createSuper$q(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$q()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
987function _isNativeReflectConstruct$q() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
988var SendTransactionMethod = function (_AbstractObservedTran) {
989 _inherits(SendTransactionMethod, _AbstractObservedTran);
990 var _super = _createSuper$q(SendTransactionMethod);
991 function SendTransactionMethod(utils, formatters, moduleInstance, transactionObserver) {
992 _classCallCheck(this, SendTransactionMethod);
993 return _super.call(this, 'cfx_sendTransaction', 1, utils, formatters, moduleInstance, transactionObserver);
994 }
995 _createClass(SendTransactionMethod, [{
996 key: "beforeExecution",
997 value: function beforeExecution(moduleInstance) {
998 this.parameters[0] = this.formatters.inputTransactionFormatter(this.parameters[0], moduleInstance);
999 }
1000 }]);
1001 return SendTransactionMethod;
1002}(AbstractObservedTransactionMethod);
1003
1004function _createSuper$r(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$r()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1005function _isNativeReflectConstruct$r() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1006var CfxSendTransactionMethod = function (_SendTransactionMetho) {
1007 _inherits(CfxSendTransactionMethod, _SendTransactionMetho);
1008 var _super = _createSuper$r(CfxSendTransactionMethod);
1009 function CfxSendTransactionMethod(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod) {
1010 var _this;
1011 _classCallCheck(this, CfxSendTransactionMethod);
1012 _this = _super.call(this, utils, formatters, moduleInstance, transactionObserver);
1013 _this.chainIdMethod = chainIdMethod;
1014 _this.getTransactionCountMethod = getTransactionCountMethod;
1015 return _this;
1016 }
1017 _createClass(CfxSendTransactionMethod, [{
1018 key: "beforeExecution",
1019 value: function beforeExecution(moduleInstance) {
1020 if (this.rpcMethod !== 'cfx_sendRawTransaction') {
1021 _get(_getPrototypeOf(CfxSendTransactionMethod.prototype), "beforeExecution", this).call(this, moduleInstance);
1022 }
1023 }
1024 }, {
1025 key: "execute",
1026 value: function execute() {
1027 var _this2 = this;
1028 if (!this.parameters[0].gas && this.moduleInstance.defaultGas) {
1029 this.parameters[0]['gas'] = this.moduleInstance.defaultGas;
1030 }
1031 if (!this.parameters[0].gasPrice && this.parameters[0].gasPrice !== 0) {
1032 if (!this.moduleInstance.defaultGasPrice) {
1033 this.moduleInstance.currentProvider.send('cfx_gasPrice', []).then(function (gasPrice) {
1034 _this2.parameters[0].gasPrice = gasPrice;
1035 _this2.execute();
1036 })["catch"](function (error) {
1037 _this2.handleError(error, false, 0);
1038 });
1039 return this.promiEvent;
1040 }
1041 this.parameters[0]['gasPrice'] = this.moduleInstance.defaultGasPrice;
1042 }
1043 if (this.hasAccounts() && this.isDefaultSigner()) {
1044 if (this.moduleInstance.accounts.wallet[this.parameters[0].from]) {
1045 this.sendRawTransaction(this.moduleInstance.accounts.wallet[this.parameters[0].from].privateKey)["catch"](function (error) {
1046 _this2.handleError(error, false, 0);
1047 });
1048 return this.promiEvent;
1049 }
1050 }
1051 if (this.hasCustomSigner()) {
1052 this.sendRawTransaction()["catch"](function (error) {
1053 _this2.handleError(error, false, 0);
1054 });
1055 return this.promiEvent;
1056 }
1057 return _get(_getPrototypeOf(CfxSendTransactionMethod.prototype), "execute", this).call(this);
1058 }
1059 }, {
1060 key: "sendRawTransaction",
1061 value: function () {
1062 var _sendRawTransaction = _asyncToGenerator( _regeneratorRuntime.mark(function _callee() {
1063 var privateKey,
1064 transaction,
1065 response,
1066 _args = arguments;
1067 return _regeneratorRuntime.wrap(function _callee$(_context) {
1068 while (1) {
1069 switch (_context.prev = _context.next) {
1070 case 0:
1071 privateKey = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
1072 this.beforeExecution(this.moduleInstance);
1073 if (!(!this.parameters[0].nonce && this.parameters[0].nonce !== 0)) {
1074 _context.next = 7;
1075 break;
1076 }
1077 this.getTransactionCountMethod.parameters = [this.parameters[0].from, 'latest_state'];
1078 _context.next = 6;
1079 return this.getTransactionCountMethod.execute();
1080 case 6:
1081 this.parameters[0].nonce = _context.sent;
1082 case 7:
1083 if (!this.parameters[0].storageLimit) {
1084 this.parameters[0]['storageLimit'] = 100000000;
1085 }
1086 if (!this.parameters[0].chainId) {
1087 this.parameters[0]['chainId'] = 0;
1088 }
1089 if (this.parameters[0].epochHeight) {
1090 _context.next = 13;
1091 break;
1092 }
1093 _context.next = 12;
1094 return this.moduleInstance.currentProvider.send('cfx_epochNumber', []);
1095 case 12:
1096 this.parameters[0].epochHeight = _context.sent;
1097 case 13:
1098 transaction = this.parameters[0];
1099 transaction.to = transaction.to || '0x';
1100 transaction.data = transaction.data || '0x';
1101 transaction.value = transaction.value || '0x';
1102 delete transaction.from;
1103 _context.next = 20;
1104 return this.moduleInstance.transactionSigner.sign(transaction, privateKey);
1105 case 20:
1106 response = _context.sent;
1107 this.parameters = [response.rawTransaction];
1108 this.rpcMethod = 'cfx_sendRawTransaction';
1109 return _context.abrupt("return", _get(_getPrototypeOf(CfxSendTransactionMethod.prototype), "execute", this).call(this));
1110 case 24:
1111 case "end":
1112 return _context.stop();
1113 }
1114 }
1115 }, _callee, this);
1116 }));
1117 function sendRawTransaction() {
1118 return _sendRawTransaction.apply(this, arguments);
1119 }
1120 return sendRawTransaction;
1121 }()
1122 }, {
1123 key: "isDefaultSigner",
1124 value: function isDefaultSigner() {
1125 return this.moduleInstance.transactionSigner.type === 'TransactionSigner';
1126 }
1127 }, {
1128 key: "hasAccounts",
1129 value: function hasAccounts() {
1130 return this.moduleInstance.accounts && this.moduleInstance.accounts.wallet.accountsIndex > 0;
1131 }
1132 }, {
1133 key: "hasCustomSigner",
1134 value: function hasCustomSigner() {
1135 return this.moduleInstance.transactionSigner.type !== 'TransactionSigner';
1136 }
1137 }], [{
1138 key: "Type",
1139 get: function get() {
1140 return 'cfx-send-transaction-method';
1141 }
1142 }]);
1143 return CfxSendTransactionMethod;
1144}(SendTransactionMethod);
1145
1146function _createSuper$s(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$s()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1147function _isNativeReflectConstruct$s() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1148var GetTransactionMethod = function (_AbstractMethod) {
1149 _inherits(GetTransactionMethod, _AbstractMethod);
1150 var _super = _createSuper$s(GetTransactionMethod);
1151 function GetTransactionMethod(utils, formatters, moduleInstance) {
1152 _classCallCheck(this, GetTransactionMethod);
1153 return _super.call(this, 'cfx_getTransactionByHash', 1, utils, formatters, moduleInstance);
1154 }
1155 _createClass(GetTransactionMethod, [{
1156 key: "afterExecution",
1157 value: function afterExecution(response) {
1158 return this.formatters.outputTransactionFormatter(response);
1159 }
1160 }]);
1161 return GetTransactionMethod;
1162}(AbstractMethod);
1163
1164function _createSuper$t(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$t()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1165function _isNativeReflectConstruct$t() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1166var GetTransactionByBlockHashAndIndexMethod = function (_AbstractGetTransacti) {
1167 _inherits(GetTransactionByBlockHashAndIndexMethod, _AbstractGetTransacti);
1168 var _super = _createSuper$t(GetTransactionByBlockHashAndIndexMethod);
1169 function GetTransactionByBlockHashAndIndexMethod(utils, formatters, moduleInstance) {
1170 _classCallCheck(this, GetTransactionByBlockHashAndIndexMethod);
1171 return _super.call(this, 'cfx_getTransactionByBlockHashAndIndex', utils, formatters, moduleInstance);
1172 }
1173 return GetTransactionByBlockHashAndIndexMethod;
1174}(AbstractGetTransactionFromBlockMethod);
1175
1176function _createSuper$u(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$u()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1177function _isNativeReflectConstruct$u() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1178var GetTransactionByBlockAddressAndIndexMethod = function (_AbstractGetTransacti) {
1179 _inherits(GetTransactionByBlockAddressAndIndexMethod, _AbstractGetTransacti);
1180 var _super = _createSuper$u(GetTransactionByBlockAddressAndIndexMethod);
1181 function GetTransactionByBlockAddressAndIndexMethod(utils, formatters, moduleInstance) {
1182 _classCallCheck(this, GetTransactionByBlockAddressAndIndexMethod);
1183 return _super.call(this, 'cfx_getTransactionByBlockAddressAndIndex', utils, formatters, moduleInstance);
1184 }
1185 return GetTransactionByBlockAddressAndIndexMethod;
1186}(AbstractGetTransactionFromBlockMethod);
1187
1188function _createSuper$v(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$v()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1189function _isNativeReflectConstruct$v() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1190var SendRawTransactionMethod = function (_AbstractObservedTran) {
1191 _inherits(SendRawTransactionMethod, _AbstractObservedTran);
1192 var _super = _createSuper$v(SendRawTransactionMethod);
1193 function SendRawTransactionMethod(utils, formatters, moduleInstance, transactionObserver) {
1194 _classCallCheck(this, SendRawTransactionMethod);
1195 return _super.call(this, 'cfx_sendRawTransaction', 1, utils, formatters, moduleInstance, transactionObserver);
1196 }
1197 return SendRawTransactionMethod;
1198}(AbstractObservedTransactionMethod);
1199
1200function _createSuper$w(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$w()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1201function _isNativeReflectConstruct$w() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1202var SignTransactionMethod = function (_AbstractMethod) {
1203 _inherits(SignTransactionMethod, _AbstractMethod);
1204 var _super = _createSuper$w(SignTransactionMethod);
1205 function SignTransactionMethod(utils, formatters, moduleInstance) {
1206 _classCallCheck(this, SignTransactionMethod);
1207 return _super.call(this, 'cfx_signTransaction', 1, utils, formatters, moduleInstance);
1208 }
1209 _createClass(SignTransactionMethod, [{
1210 key: "beforeExecution",
1211 value: function beforeExecution(moduleInstance) {
1212 this.parameters[0] = this.formatters.inputTransactionFormatter(this.parameters[0], moduleInstance);
1213 }
1214 }]);
1215 return SignTransactionMethod;
1216}(AbstractMethod);
1217
1218function _createSuper$x(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$x()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1219function _isNativeReflectConstruct$x() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1220var GetCodeMethod = function (_AbstractMethod) {
1221 _inherits(GetCodeMethod, _AbstractMethod);
1222 var _super = _createSuper$x(GetCodeMethod);
1223 function GetCodeMethod(utils, formatters, moduleInstance) {
1224 _classCallCheck(this, GetCodeMethod);
1225 return _super.call(this, 'cfx_getCode', 2, utils, formatters, moduleInstance);
1226 }
1227 _createClass(GetCodeMethod, [{
1228 key: "beforeExecution",
1229 value: function beforeExecution(moduleInstance) {
1230 this.parameters[0] = this.formatters.inputAddressFormatter(this.parameters[0]);
1231 if (isFunction(this.parameters[1])) {
1232 this.callback = this.parameters[1];
1233 this.parameters[1] = moduleInstance.defaultEpoch;
1234 }
1235 this.parameters[1] = this.formatters.inputDefaultEpochNumberFormatter(this.parameters[1], moduleInstance);
1236 }
1237 }]);
1238 return GetCodeMethod;
1239}(AbstractMethod);
1240
1241function _createSuper$y(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$y()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1242function _isNativeReflectConstruct$y() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1243var SignMethod = function (_AbstractMethod) {
1244 _inherits(SignMethod, _AbstractMethod);
1245 var _super = _createSuper$y(SignMethod);
1246 function SignMethod(utils, formatters, moduleInstance) {
1247 _classCallCheck(this, SignMethod);
1248 return _super.call(this, 'cfx_sign', 2, utils, formatters, moduleInstance);
1249 }
1250 _createClass(SignMethod, [{
1251 key: "beforeExecution",
1252 value: function beforeExecution(moduleInstance) {
1253 this.parameters[0] = this.formatters.inputSignFormatter(this.parameters[0]);
1254 this.parameters[1] = this.formatters.inputAddressFormatter(this.parameters[1]);
1255 this.parameters.reverse();
1256 }
1257 }]);
1258 return SignMethod;
1259}(AbstractMethod);
1260
1261function _createSuper$z(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$z()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1262function _isNativeReflectConstruct$z() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1263var CallMethod = function (_AbstractMethod) {
1264 _inherits(CallMethod, _AbstractMethod);
1265 var _super = _createSuper$z(CallMethod);
1266 function CallMethod(utils, formatters, moduleInstance) {
1267 _classCallCheck(this, CallMethod);
1268 return _super.call(this, 'cfx_call', 2, utils, formatters, moduleInstance);
1269 }
1270 _createClass(CallMethod, [{
1271 key: "beforeExecution",
1272 value: function beforeExecution(moduleInstance) {
1273 this.parameters[0] = this.formatters.inputCallFormatter(this.parameters[0], moduleInstance);
1274 if (isFunction(this.parameters[1])) {
1275 this.callback = this.parameters[1];
1276 this.parameters[1] = moduleInstance.defaultEpoch;
1277 }
1278 this.parameters[1] = this.formatters.inputDefaultEpochNumberFormatter(this.parameters[1], moduleInstance);
1279 }
1280 }]);
1281 return CallMethod;
1282}(AbstractMethod);
1283
1284function _createSuper$A(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$A()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1285function _isNativeReflectConstruct$A() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1286var GetStorageAtMethod = function (_AbstractMethod) {
1287 _inherits(GetStorageAtMethod, _AbstractMethod);
1288 var _super = _createSuper$A(GetStorageAtMethod);
1289 function GetStorageAtMethod(utils, formatters, moduleInstance) {
1290 _classCallCheck(this, GetStorageAtMethod);
1291 return _super.call(this, 'eth_getStorageAt', 3, utils, formatters, moduleInstance);
1292 }
1293 _createClass(GetStorageAtMethod, [{
1294 key: "beforeExecution",
1295 value: function beforeExecution(moduleInstance) {
1296 this.parameters[0] = this.formatters.inputAddressFormatter(this.parameters[0]);
1297 this.parameters[1] = this.utils.numberToHex(this.parameters[1]);
1298 if (isFunction(this.parameters[2])) {
1299 this.callback = this.parameters[2];
1300 this.parameters[2] = moduleInstance.defaultEpoch;
1301 }
1302 this.parameters[2] = this.formatters.inputDefaultEpochNumberFormatter(this.parameters[2], moduleInstance);
1303 }
1304 }]);
1305 return GetStorageAtMethod;
1306}(AbstractMethod);
1307
1308function _createSuper$B(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$B()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1309function _isNativeReflectConstruct$B() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1310var EstimateGasMethod = function (_AbstractMethod) {
1311 _inherits(EstimateGasMethod, _AbstractMethod);
1312 var _super = _createSuper$B(EstimateGasMethod);
1313 function EstimateGasMethod(utils, formatters, moduleInstance) {
1314 _classCallCheck(this, EstimateGasMethod);
1315 return _super.call(this, 'cfx_estimateGas', 1, utils, formatters, moduleInstance);
1316 }
1317 _createClass(EstimateGasMethod, [{
1318 key: "beforeExecution",
1319 value: function beforeExecution(moduleInstance) {
1320 this.parameters[0] = this.formatters.inputCallFormatter(this.parameters[0], moduleInstance);
1321 }
1322 }, {
1323 key: "afterExecution",
1324 value: function afterExecution(response) {
1325 return this.utils.hexToNumber(response);
1326 }
1327 }]);
1328 return EstimateGasMethod;
1329}(AbstractMethod);
1330
1331function _createSuper$C(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$C()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1332function _isNativeReflectConstruct$C() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1333var GetPastLogsMethod = function (_AbstractMethod) {
1334 _inherits(GetPastLogsMethod, _AbstractMethod);
1335 var _super = _createSuper$C(GetPastLogsMethod);
1336 function GetPastLogsMethod(utils, formatters, moduleInstance) {
1337 _classCallCheck(this, GetPastLogsMethod);
1338 return _super.call(this, 'cfx_getLogs', 1, utils, formatters, moduleInstance);
1339 }
1340 _createClass(GetPastLogsMethod, [{
1341 key: "beforeExecution",
1342 value: function beforeExecution(moduleInstance) {
1343 this.parameters[0] = this.formatters.inputLogFormatter(this.parameters[0]);
1344 }
1345 }, {
1346 key: "afterExecution",
1347 value: function afterExecution(response) {
1348 var _this = this;
1349 return response.map(function (responseItem) {
1350 return _this.formatters.outputLogFormatter(responseItem);
1351 });
1352 }
1353 }]);
1354 return GetPastLogsMethod;
1355}(AbstractMethod);
1356
1357function _createSuper$D(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct$D()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1358function _isNativeReflectConstruct$D() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1359var GetEpochNumberMethod = function (_AbstractMethod) {
1360 _inherits(GetEpochNumberMethod, _AbstractMethod);
1361 var _super = _createSuper$D(GetEpochNumberMethod);
1362 function GetEpochNumberMethod(utils, formatters, moduleInstance) {
1363 _classCallCheck(this, GetEpochNumberMethod);
1364 return _super.call(this, 'cfx_epochNumber', 1, utils, formatters, moduleInstance);
1365 }
1366 _createClass(GetEpochNumberMethod, [{
1367 key: "beforeExecution",
1368 value: function beforeExecution(moduleInstance) {
1369 if (this.parameters[0] === undefined) {
1370 this.parameters[0] = 'latest_mined';
1371 }
1372 if (!this.formatters.isPredefinedEpochNumber(this.parameters[0])) {
1373 throw new Error('The epoch field must be predefined epoch number.');
1374 }
1375 }
1376 }, {
1377 key: "afterExecution",
1378 value: function afterExecution(response) {
1379 return this.utils.hexToNumber(response);
1380 }
1381 }]);
1382 return GetEpochNumberMethod;
1383}(AbstractMethod);
1384
1385exports.AbstractGetBlockMethod = AbstractGetBlockMethod;
1386exports.AbstractGetBlockTransactionCountMethod = AbstractGetBlockTransactionCountMethod;
1387exports.AbstractGetTransactionFromBlockMethod = AbstractGetTransactionFromBlockMethod;
1388exports.AbstractMethod = AbstractMethod;
1389exports.AbstractMethodFactory = AbstractMethodFactory;
1390exports.AbstractObservedTransactionMethod = AbstractObservedTransactionMethod;
1391exports.CallMethod = CallMethod;
1392exports.CfxSendTransactionMethod = CfxSendTransactionMethod;
1393exports.ChainIdMethod = ChainIdMethod;
1394exports.EstimateGasMethod = EstimateGasMethod;
1395exports.GetAccountsMethod = GetAccountsMethod;
1396exports.GetBalanceMethod = GetBalanceMethod;
1397exports.GetBlockByHashMethod = GetBlockByHashMethod;
1398exports.GetBlockByNumberMethod = GetBlockByNumberMethod;
1399exports.GetBlockTransactionCountByHashMethod = GetBlockTransactionCountByHashMethod;
1400exports.GetBlockTransactionCountByNumberMethod = GetBlockTransactionCountByNumberMethod;
1401exports.GetCodeMethod = GetCodeMethod;
1402exports.GetCoinbaseMethod = GetCoinbaseMethod;
1403exports.GetEpochNumberMethod = GetEpochNumberMethod;
1404exports.GetGasPriceMethod = GetGasPriceMethod;
1405exports.GetHashrateMethod = GetHashrateMethod;
1406exports.GetNodeInfoMethod = GetNodeInfoMethod;
1407exports.GetPastLogsMethod = GetPastLogsMethod;
1408exports.GetProtocolVersionMethod = GetProtocolVersionMethod;
1409exports.GetStorageAtMethod = GetStorageAtMethod;
1410exports.GetTransactionByBlockAddressAndIndexMethod = GetTransactionByBlockAddressAndIndexMethod;
1411exports.GetTransactionByBlockHashAndIndexMethod = GetTransactionByBlockHashAndIndexMethod;
1412exports.GetTransactionCountMethod = GetTransactionCountMethod;
1413exports.GetTransactionMethod = GetTransactionMethod;
1414exports.GetTransactionReceiptMethod = GetTransactionReceiptMethod;
1415exports.GetWorkMethod = GetWorkMethod;
1416exports.IsMiningMethod = IsMiningMethod;
1417exports.IsSyncingMethod = IsSyncingMethod;
1418exports.ListeningMethod = ListeningMethod;
1419exports.MethodProxy = MethodProxy;
1420exports.PeerCountMethod = PeerCountMethod;
1421exports.PromiEvent = PromiEvent;
1422exports.RequestAccountsMethod = RequestAccountsMethod;
1423exports.SendRawTransactionMethod = SendRawTransactionMethod;
1424exports.SendTransactionMethod = SendTransactionMethod;
1425exports.SignMethod = SignMethod;
1426exports.SignTransactionMethod = SignTransactionMethod;
1427exports.SubmitWorkMethod = SubmitWorkMethod;
1428exports.TransactionObserver = TransactionObserver;
1429exports.VersionMethod = VersionMethod;