@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.esm.js CHANGED
@@ -23746,46 +23746,107 @@ var URL_REGEXP = new RegExp('(http://www.|https://www.|http://|https://)?[a-z0-9
23746
23746
  var solidityImportRule = new RegExp('import( )+"(\\d+)"( )*;', 'gs');
23747
23747
  var pragmaSolidityRule = new RegExp('pragma( )+solidity( )*(\\^|>)\\d+.\\d+.\\d+;', 'gs');
23748
23748
 
23749
- function sendAsync(provider, method) {
23750
- var params = Array.prototype.slice.call(arguments).slice(2) || [];
23751
- return new Promise( /*#__PURE__*/function () {
23752
- var _ref = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ok, ko) {
23753
- return regeneratorRuntime.wrap(function _callee$(_context) {
23754
- while (1) {
23755
- switch (_context.prev = _context.next) {
23756
- case 0:
23757
- _context.prev = 0;
23758
- _context.next = 3;
23759
- return (provider.sendAsync || provider.send).call(provider, {
23760
- jsonrpc: '2.0',
23761
- method: method,
23762
- params: params,
23763
- id: new Date().getTime()
23764
- }, function (error, response) {
23765
- return error || response && response.error ? ko(error || response && response.error) : ok(response && response.result);
23766
- });
23749
+ var instrumentedProviders = {};
23767
23750
 
23768
- case 3:
23769
- _context.next = 8;
23751
+ function sendAsync(_x, _x2) {
23752
+ return _sendAsync.apply(this, arguments);
23753
+ }
23754
+
23755
+ function _sendAsync() {
23756
+ _sendAsync = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(inputProvider, method) {
23757
+ var provider,
23758
+ chainId,
23759
+ _ref,
23760
+ chainProvider,
23761
+ params,
23762
+ _args2 = arguments;
23763
+
23764
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
23765
+ while (1) {
23766
+ switch (_context2.prev = _context2.next) {
23767
+ case 0:
23768
+ provider = inputProvider;
23769
+
23770
+ if (!(method !== 'eth_chainId')) {
23771
+ _context2.next = 12;
23770
23772
  break;
23773
+ }
23771
23774
 
23772
- case 5:
23773
- _context.prev = 5;
23774
- _context.t0 = _context["catch"](0);
23775
- return _context.abrupt("return", ko(_context.t0));
23775
+ _context2.t0 = parseInt;
23776
+ _context2.t1 = provider.chainId;
23776
23777
 
23777
- case 8:
23778
- case "end":
23779
- return _context.stop();
23780
- }
23781
- }
23782
- }, _callee, null, [[0, 5]]);
23783
- }));
23778
+ if (_context2.t1) {
23779
+ _context2.next = 8;
23780
+ break;
23781
+ }
23784
23782
 
23785
- return function (_x, _x2) {
23786
- return _ref.apply(this, arguments);
23787
- };
23788
- }());
23783
+ _context2.next = 7;
23784
+ return sendAsync(provider, 'eth_chainId');
23785
+
23786
+ case 7:
23787
+ _context2.t1 = _context2.sent;
23788
+
23789
+ case 8:
23790
+ _context2.t2 = _context2.t1;
23791
+ chainId = provider.chainId = (0, _context2.t0)(_context2.t2);
23792
+ _ref = sendAsync.context || {
23793
+ chainProvider: {}
23794
+ }, chainProvider = _ref.chainProvider;
23795
+ provider = chainId !== 1 && chainProvider[chainId] ? instrumentedProviders[chainId] = instrumentedProviders[chainId] || new Web3.providers.HttpProvider(chainProvider[chainId]) : provider;
23796
+
23797
+ case 12:
23798
+ params = Array.prototype.slice.call(_args2).slice(2) || [];
23799
+ _context2.next = 15;
23800
+ return new Promise( /*#__PURE__*/function () {
23801
+ var _ref2 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ok, ko) {
23802
+ return regeneratorRuntime.wrap(function _callee$(_context) {
23803
+ while (1) {
23804
+ switch (_context.prev = _context.next) {
23805
+ case 0:
23806
+ _context.prev = 0;
23807
+ _context.next = 3;
23808
+ return (provider.sendAsync || provider.send).call(provider, {
23809
+ jsonrpc: '2.0',
23810
+ method: method,
23811
+ params: params,
23812
+ id: new Date().getTime()
23813
+ }, function (error, response) {
23814
+ return error || response && response.error ? ko(error || response && response.error) : ok(response && response.result);
23815
+ });
23816
+
23817
+ case 3:
23818
+ _context.next = 8;
23819
+ break;
23820
+
23821
+ case 5:
23822
+ _context.prev = 5;
23823
+ _context.t0 = _context["catch"](0);
23824
+ return _context.abrupt("return", ko(_context.t0));
23825
+
23826
+ case 8:
23827
+ case "end":
23828
+ return _context.stop();
23829
+ }
23830
+ }
23831
+ }, _callee, null, [[0, 5]]);
23832
+ }));
23833
+
23834
+ return function (_x3, _x4) {
23835
+ return _ref2.apply(this, arguments);
23836
+ };
23837
+ }());
23838
+
23839
+ case 15:
23840
+ return _context2.abrupt("return", _context2.sent);
23841
+
23842
+ case 16:
23843
+ case "end":
23844
+ return _context2.stop();
23845
+ }
23846
+ }
23847
+ }, _callee2);
23848
+ }));
23849
+ return _sendAsync.apply(this, arguments);
23789
23850
  }
23790
23851
 
23791
23852
  /**
@@ -48778,6 +48839,7 @@ var useWeb3 = function useWeb3() {
48778
48839
  };
48779
48840
  var Web3ContextProvider = function Web3ContextProvider(props) {
48780
48841
  var context = useEthosContext();
48842
+ sendAsync.context = sendAsync.context || context;
48781
48843
  var connectors = context.useWalletSettings.reduce(function (acc, connector) {
48782
48844
  return _objectSpread2(_objectSpread2({}, acc), _defineProperty({}, connector.id, _objectSpread2(_objectSpread2({}, connector.settings), {}, {
48783
48845
  buttonText: connector.buttonText
@@ -49038,6 +49100,11 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
49038
49100
  return globalContracts[index];
49039
49101
  };
49040
49102
 
49103
+ useEffect(function () {
49104
+ chainId && web3Instance && web3Instance.currentProvider && !web3Instance.currentProvider.chainId && (web3Instance.currentProvider.chainId = chainId);
49105
+ dualChainId && dualChainWeb3 && dualChainWeb3.currentProvider && !dualChainWeb3.currentProvider.chainId && (dualChainWeb3.currentProvider.chainId = dualChainId);
49106
+ }, [chainId, web3Instance, dualChainId, dualChainWeb3]);
49107
+
49041
49108
  window.setAccount = /*#__PURE__*/function () {
49042
49109
  var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(acc) {
49043
49110
  return regeneratorRuntime.wrap(function _callee3$(_context3) {