@ethereansos/interfaces-core 0.4.72 → 0.4.73

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
@@ -42670,7 +42670,8 @@ var useEthosContext = function useEthosContext() {
42670
42670
  };
42671
42671
 
42672
42672
  var Web3Context = /*#__PURE__*/React.createContext('web3');
42673
- var BLOCK_INTERVAL = 15;
42673
+ var DEFAULT_BLOCK_INTERVAL = 15;
42674
+ var DEFAULT_BLOCK_INTERVAL_TIMEOUT = 40000;
42674
42675
  var web3States = {
42675
42676
  NOT_CONNECTED: NOT_CONNECTED,
42676
42677
  CONNECTED: CONNECTED,
@@ -42692,7 +42693,11 @@ var Web3ContextProvider = function Web3ContextProvider(props) {
42692
42693
  };
42693
42694
 
42694
42695
  var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42695
- var children = _ref.children;
42696
+ var children = _ref.children,
42697
+ blockInterval = _ref.blockInterval,
42698
+ blockIntervalTimeout = _ref.blockIntervalTimeout;
42699
+ var realBlockInterval = blockInterval || DEFAULT_BLOCK_INTERVAL;
42700
+ var realBlockIntervalTimeout = blockIntervalTimeout || DEFAULT_BLOCK_INTERVAL_TIMEOUT;
42696
42701
  var context = useEthosContext();
42697
42702
 
42698
42703
  var _useState = useState(create(context.ipfsHost)),
@@ -42746,12 +42751,12 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42746
42751
  setIpfsHttpClient(create(context.ipfsHost));
42747
42752
  }, [context]);
42748
42753
 
42749
- function updateBlock() {
42750
- return _updateBlock.apply(this, arguments);
42754
+ function tryUpdateBlock() {
42755
+ return _tryUpdateBlock.apply(this, arguments);
42751
42756
  }
42752
42757
 
42753
- function _updateBlock() {
42754
- _updateBlock = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
42758
+ function _tryUpdateBlock() {
42759
+ _tryUpdateBlock = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
42755
42760
  var currentBlock, currentBlockNumber;
42756
42761
  return regeneratorRuntime.wrap(function _callee$(_context) {
42757
42762
  while (1) {
@@ -42765,7 +42770,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42765
42770
  currentBlock = _context.sent;
42766
42771
  currentBlockNumber = parseInt(currentBlock.number);
42767
42772
 
42768
- if (currentBlockNumber - block >= BLOCK_INTERVAL) {
42773
+ if (currentBlockNumber - block >= realBlockInterval) {
42769
42774
  setBlock(currentBlockNumber);
42770
42775
  }
42771
42776
 
@@ -42783,9 +42788,17 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42783
42788
  }
42784
42789
  }, _callee, null, [[0, 8]]);
42785
42790
  }));
42786
- return _updateBlock.apply(this, arguments);
42791
+ return _tryUpdateBlock.apply(this, arguments);
42787
42792
  }
42788
42793
 
42794
+ function resetBlockInterval() {
42795
+ intervalId && clearInterval(intervalId);
42796
+ setBlock(0);
42797
+ wallet && wallet.ethereum && tryUpdateBlock();
42798
+ wallet && wallet.ethereum && setIntervalId(setInterval(tryUpdateBlock, realBlockIntervalTimeout));
42799
+ }
42800
+
42801
+ useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout]);
42789
42802
  useEffect(function () {
42790
42803
  setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
42791
42804
  setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3(wallet.ethereum)) || null);
@@ -42794,10 +42807,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42794
42807
  setContracts({});
42795
42808
  setGlobalContracts(globalContractNames.map(newContractByName));
42796
42809
  setChainId(wallet && wallet.chainId || null);
42797
- intervalId && clearInterval(intervalId);
42798
- setBlock(0);
42799
- wallet && wallet.ethereum && updateBlock();
42800
- wallet && wallet.ethereum && setIntervalId(setInterval(updateBlock, 35000));
42810
+ resetBlockInterval();
42801
42811
  }, [wallet && wallet.chainId]);
42802
42812
 
42803
42813
  var setConnector = function setConnector(connector) {