@ethereansos/interfaces-core 0.4.125 → 0.4.128

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs.js CHANGED
@@ -23758,53 +23758,96 @@ var URL_REGEXP = new RegExp('(http://www.|https://www.|http://|https://)?[a-z0-9
23758
23758
  var solidityImportRule = new RegExp('import( )+"(\\d+)"( )*;', 'gs');
23759
23759
  var pragmaSolidityRule = new RegExp('pragma( )+solidity( )*(\\^|>)\\d+.\\d+.\\d+;', 'gs');
23760
23760
 
23761
- var instrumentedProviders = {};
23761
+ var instrumentedProviders = [];
23762
+ var instrumentableMethods = ['eth_call', 'eth_getLogs'];
23762
23763
 
23763
- function sendAsync(_x, _x2) {
23764
- return _sendAsync.apply(this, arguments);
23764
+ function instrumentProvider(_x, _x2) {
23765
+ return _instrumentProvider.apply(this, arguments);
23765
23766
  }
23766
23767
 
23767
- function _sendAsync() {
23768
- _sendAsync = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(inputProvider, method) {
23769
- var provider,
23770
- chainId,
23771
- _ref,
23772
- chainProvider,
23773
- params,
23774
- _args2 = arguments;
23768
+ function _instrumentProvider() {
23769
+ _instrumentProvider = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(provider, method) {
23770
+ var entry, chainId, _ref, chainProvider;
23775
23771
 
23776
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
23772
+ return regeneratorRuntime.wrap(function _callee$(_context) {
23777
23773
  while (1) {
23778
- switch (_context2.prev = _context2.next) {
23774
+ switch (_context.prev = _context.next) {
23779
23775
  case 0:
23780
- provider = inputProvider;
23776
+ if (!(instrumentableMethods.indexOf(method) === -1)) {
23777
+ _context.next = 2;
23778
+ break;
23779
+ }
23781
23780
 
23782
- if (!(method !== 'eth_chainId')) {
23783
- _context2.next = 7;
23781
+ return _context.abrupt("return");
23782
+
23783
+ case 2:
23784
+ entry = instrumentedProviders.filter(function (it) {
23785
+ return it.provider === provider;
23786
+ })[0];
23787
+
23788
+ if (!entry) {
23789
+ _context.next = 5;
23784
23790
  break;
23785
23791
  }
23786
23792
 
23787
- _context2.next = 4;
23793
+ return _context.abrupt("return", entry.instrumentedProvider);
23794
+
23795
+ case 5:
23796
+ _context.t0 = parseInt;
23797
+ _context.next = 8;
23788
23798
  return sendAsync(provider, 'eth_chainId');
23789
23799
 
23790
- case 4:
23791
- chainId = _context2.sent;
23800
+ case 8:
23801
+ _context.t1 = _context.sent;
23802
+ chainId = (0, _context.t0)(_context.t1);
23803
+ instrumentedProviders.push(entry = {
23804
+ chainId: chainId,
23805
+ provider: provider,
23806
+ instrumentedProvider: provider
23807
+ });
23792
23808
  _ref = sendAsync.context || {
23793
23809
  chainProvider: {}
23794
23810
  }, chainProvider = _ref.chainProvider;
23795
- provider = chainId !== 1 && chainProvider[chainId] ? instrumentedProviders[chainId] = instrumentedProviders[chainId] || new Web3__default["default"].providers.HttpProvider(chainProvider[chainId]) : provider;
23811
+ return _context.abrupt("return", entry.instrumentedProvider = chainId !== 1 && chainProvider[chainId] ? new Web3__default["default"].providers.HttpProvider(chainProvider[chainId]) : provider);
23796
23812
 
23797
- case 7:
23798
- params = Array.prototype.slice.call(_args2).slice(2) || [];
23799
- _context2.next = 10;
23813
+ case 13:
23814
+ case "end":
23815
+ return _context.stop();
23816
+ }
23817
+ }
23818
+ }, _callee);
23819
+ }));
23820
+ return _instrumentProvider.apply(this, arguments);
23821
+ }
23822
+
23823
+ function sendAsync(_x3, _x4) {
23824
+ return _sendAsync.apply(this, arguments);
23825
+ }
23826
+
23827
+ function _sendAsync() {
23828
+ _sendAsync = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(inputProvider, method) {
23829
+ var provider,
23830
+ params,
23831
+ _args3 = arguments;
23832
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
23833
+ while (1) {
23834
+ switch (_context3.prev = _context3.next) {
23835
+ case 0:
23836
+ _context3.next = 2;
23837
+ return instrumentProvider(inputProvider);
23838
+
23839
+ case 2:
23840
+ provider = _context3.sent;
23841
+ params = Array.prototype.slice.call(_args3).slice(2) || [];
23842
+ _context3.next = 6;
23800
23843
  return new Promise( /*#__PURE__*/function () {
23801
- var _ref2 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ok, ko) {
23802
- return regeneratorRuntime.wrap(function _callee$(_context) {
23844
+ var _ref2 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(ok, ko) {
23845
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
23803
23846
  while (1) {
23804
- switch (_context.prev = _context.next) {
23847
+ switch (_context2.prev = _context2.next) {
23805
23848
  case 0:
23806
- _context.prev = 0;
23807
- _context.next = 3;
23849
+ _context2.prev = 0;
23850
+ _context2.next = 3;
23808
23851
  return (provider.sendAsync || provider.send).call(provider, {
23809
23852
  jsonrpc: '2.0',
23810
23853
  method: method,
@@ -23815,36 +23858,36 @@ function _sendAsync() {
23815
23858
  });
23816
23859
 
23817
23860
  case 3:
23818
- _context.next = 8;
23861
+ _context2.next = 8;
23819
23862
  break;
23820
23863
 
23821
23864
  case 5:
23822
- _context.prev = 5;
23823
- _context.t0 = _context["catch"](0);
23824
- return _context.abrupt("return", ko(_context.t0));
23865
+ _context2.prev = 5;
23866
+ _context2.t0 = _context2["catch"](0);
23867
+ return _context2.abrupt("return", ko(_context2.t0));
23825
23868
 
23826
23869
  case 8:
23827
23870
  case "end":
23828
- return _context.stop();
23871
+ return _context2.stop();
23829
23872
  }
23830
23873
  }
23831
- }, _callee, null, [[0, 5]]);
23874
+ }, _callee2, null, [[0, 5]]);
23832
23875
  }));
23833
23876
 
23834
- return function (_x3, _x4) {
23877
+ return function (_x5, _x6) {
23835
23878
  return _ref2.apply(this, arguments);
23836
23879
  };
23837
23880
  }());
23838
23881
 
23839
- case 10:
23840
- return _context2.abrupt("return", _context2.sent);
23882
+ case 6:
23883
+ return _context3.abrupt("return", _context3.sent);
23841
23884
 
23842
- case 11:
23885
+ case 7:
23843
23886
  case "end":
23844
- return _context2.stop();
23887
+ return _context3.stop();
23845
23888
  }
23846
23889
  }
23847
- }, _callee2);
23890
+ }, _callee3);
23848
23891
  }));
23849
23892
  return _sendAsync.apply(this, arguments);
23850
23893
  }