@ethereansos/interfaces-core 0.4.120 → 0.4.123

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.
package/dist/index.cjs.js CHANGED
@@ -23758,46 +23758,107 @@ 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
- function sendAsync(provider, method) {
23762
- var params = Array.prototype.slice.call(arguments).slice(2) || [];
23763
- return new Promise( /*#__PURE__*/function () {
23764
- var _ref = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ok, ko) {
23765
- return regeneratorRuntime.wrap(function _callee$(_context) {
23766
- while (1) {
23767
- switch (_context.prev = _context.next) {
23768
- case 0:
23769
- _context.prev = 0;
23770
- _context.next = 3;
23771
- return (provider.sendAsync || provider.send).call(provider, {
23772
- jsonrpc: '2.0',
23773
- method: method,
23774
- params: params,
23775
- id: new Date().getTime()
23776
- }, function (error, response) {
23777
- return error || response && response.error ? ko(error || response && response.error) : ok(response && response.result);
23778
- });
23761
+ var instrumentedProviders = {};
23779
23762
 
23780
- case 3:
23781
- _context.next = 8;
23763
+ function sendAsync(_x, _x2) {
23764
+ return _sendAsync.apply(this, arguments);
23765
+ }
23766
+
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;
23775
+
23776
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
23777
+ while (1) {
23778
+ switch (_context2.prev = _context2.next) {
23779
+ case 0:
23780
+ provider = inputProvider;
23781
+
23782
+ if (!(method !== 'eth_chainId')) {
23783
+ _context2.next = 12;
23782
23784
  break;
23785
+ }
23783
23786
 
23784
- case 5:
23785
- _context.prev = 5;
23786
- _context.t0 = _context["catch"](0);
23787
- return _context.abrupt("return", ko(_context.t0));
23787
+ _context2.t0 = parseInt;
23788
+ _context2.t1 = provider.chainId;
23788
23789
 
23789
- case 8:
23790
- case "end":
23791
- return _context.stop();
23792
- }
23793
- }
23794
- }, _callee, null, [[0, 5]]);
23795
- }));
23790
+ if (_context2.t1) {
23791
+ _context2.next = 8;
23792
+ break;
23793
+ }
23796
23794
 
23797
- return function (_x, _x2) {
23798
- return _ref.apply(this, arguments);
23799
- };
23800
- }());
23795
+ _context2.next = 7;
23796
+ return sendAsync(provider, 'eth_chainId');
23797
+
23798
+ case 7:
23799
+ _context2.t1 = _context2.sent;
23800
+
23801
+ case 8:
23802
+ _context2.t2 = _context2.t1;
23803
+ chainId = provider.chainId = (0, _context2.t0)(_context2.t2);
23804
+ _ref = sendAsync.context || {
23805
+ chainProvider: {}
23806
+ }, chainProvider = _ref.chainProvider;
23807
+ provider = chainId !== 1 && chainProvider[chainId] ? instrumentedProviders[chainId] = instrumentedProviders[chainId] || new Web3__default["default"].providers.HttpProvider(chainProvider[chainId]) : provider;
23808
+
23809
+ case 12:
23810
+ params = Array.prototype.slice.call(_args2).slice(2) || [];
23811
+ _context2.next = 15;
23812
+ return new Promise( /*#__PURE__*/function () {
23813
+ var _ref2 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ok, ko) {
23814
+ return regeneratorRuntime.wrap(function _callee$(_context) {
23815
+ while (1) {
23816
+ switch (_context.prev = _context.next) {
23817
+ case 0:
23818
+ _context.prev = 0;
23819
+ _context.next = 3;
23820
+ return (provider.sendAsync || provider.send).call(provider, {
23821
+ jsonrpc: '2.0',
23822
+ method: method,
23823
+ params: params,
23824
+ id: new Date().getTime()
23825
+ }, function (error, response) {
23826
+ return error || response && response.error ? ko(error || response && response.error) : ok(response && response.result);
23827
+ });
23828
+
23829
+ case 3:
23830
+ _context.next = 8;
23831
+ break;
23832
+
23833
+ case 5:
23834
+ _context.prev = 5;
23835
+ _context.t0 = _context["catch"](0);
23836
+ return _context.abrupt("return", ko(_context.t0));
23837
+
23838
+ case 8:
23839
+ case "end":
23840
+ return _context.stop();
23841
+ }
23842
+ }
23843
+ }, _callee, null, [[0, 5]]);
23844
+ }));
23845
+
23846
+ return function (_x3, _x4) {
23847
+ return _ref2.apply(this, arguments);
23848
+ };
23849
+ }());
23850
+
23851
+ case 15:
23852
+ return _context2.abrupt("return", _context2.sent);
23853
+
23854
+ case 16:
23855
+ case "end":
23856
+ return _context2.stop();
23857
+ }
23858
+ }
23859
+ }, _callee2);
23860
+ }));
23861
+ return _sendAsync.apply(this, arguments);
23801
23862
  }
23802
23863
 
23803
23864
  /**
@@ -48790,6 +48851,7 @@ var useWeb3 = function useWeb3() {
48790
48851
  };
48791
48852
  var Web3ContextProvider = function Web3ContextProvider(props) {
48792
48853
  var context = useEthosContext();
48854
+ sendAsync.context = sendAsync.context || context;
48793
48855
  var connectors = context.useWalletSettings.reduce(function (acc, connector) {
48794
48856
  return _objectSpread2(_objectSpread2({}, acc), _defineProperty({}, connector.id, _objectSpread2(_objectSpread2({}, connector.settings), {}, {
48795
48857
  buttonText: connector.buttonText
@@ -49050,6 +49112,11 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
49050
49112
  return globalContracts[index];
49051
49113
  };
49052
49114
 
49115
+ React.useEffect(function () {
49116
+ chainId && web3Instance && web3Instance.currentProvider && !web3Instance.currentProvider.chainId && (web3Instance.currentProvider.chainId = chainId);
49117
+ dualChainId && dualChainWeb3 && dualChainWeb3.currentProvider && !dualChainWeb3.currentProvider.chainId && (dualChainWeb3.currentProvider.chainId = dualChainId);
49118
+ }, [chainId, web3Instance, dualChainId, dualChainWeb3]);
49119
+
49053
49120
  window.setAccount = /*#__PURE__*/function () {
49054
49121
  var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(acc) {
49055
49122
  return regeneratorRuntime.wrap(function _callee3$(_context3) {