@ethereansos/interfaces-core 0.4.68 → 0.4.72

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
@@ -41493,7 +41493,7 @@ function sendBlockchainTransaction(provider, fromOrPlainPrivateKey, to, data, va
41493
41493
 
41494
41494
  case 64:
41495
41495
  tx.gasLimit = _context2.t15;
41496
- _context2.t25 = window.bypassEstimation;
41496
+ _context2.t25 = !window.bypassEstimation;
41497
41497
 
41498
41498
  if (!_context2.t25) {
41499
41499
  _context2.next = 69;
@@ -42681,6 +42681,7 @@ var useEthosContext = function useEthosContext() {
42681
42681
  };
42682
42682
 
42683
42683
  var Web3Context = /*#__PURE__*/React__default["default"].createContext('web3');
42684
+ var BLOCK_INTERVAL = 15;
42684
42685
  var web3States = {
42685
42686
  NOT_CONNECTED: NOT_CONNECTED,
42686
42687
  CONNECTED: CONNECTED,
@@ -42742,9 +42743,60 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42742
42743
  contracts = _useState14[0],
42743
42744
  setContracts = _useState14[1];
42744
42745
 
42746
+ var _useState15 = React.useState(0),
42747
+ _useState16 = _slicedToArray(_useState15, 2),
42748
+ intervalId = _useState16[0],
42749
+ setIntervalId = _useState16[1];
42750
+
42751
+ var _useState17 = React.useState(0),
42752
+ _useState18 = _slicedToArray(_useState17, 2),
42753
+ block = _useState18[0],
42754
+ setBlock = _useState18[1];
42755
+
42745
42756
  React.useEffect(function () {
42746
42757
  setIpfsHttpClient(ipfsHttpClient.create(context.ipfsHost));
42747
42758
  }, [context]);
42759
+
42760
+ function updateBlock() {
42761
+ return _updateBlock.apply(this, arguments);
42762
+ }
42763
+
42764
+ function _updateBlock() {
42765
+ _updateBlock = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
42766
+ var currentBlock, currentBlockNumber;
42767
+ return regeneratorRuntime.wrap(function _callee$(_context) {
42768
+ while (1) {
42769
+ switch (_context.prev = _context.next) {
42770
+ case 0:
42771
+ _context.prev = 0;
42772
+ _context.next = 3;
42773
+ return sendAsync(wallet.ethereum, 'eth_getBlock', 'latest', true);
42774
+
42775
+ case 3:
42776
+ currentBlock = _context.sent;
42777
+ currentBlockNumber = parseInt(currentBlock.number);
42778
+
42779
+ if (currentBlockNumber - block >= BLOCK_INTERVAL) {
42780
+ setBlock(currentBlockNumber);
42781
+ }
42782
+
42783
+ _context.next = 10;
42784
+ break;
42785
+
42786
+ case 8:
42787
+ _context.prev = 8;
42788
+ _context.t0 = _context["catch"](0);
42789
+
42790
+ case 10:
42791
+ case "end":
42792
+ return _context.stop();
42793
+ }
42794
+ }
42795
+ }, _callee, null, [[0, 8]]);
42796
+ }));
42797
+ return _updateBlock.apply(this, arguments);
42798
+ }
42799
+
42748
42800
  React.useEffect(function () {
42749
42801
  setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
42750
42802
  setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3__default["default"](wallet.ethereum)) || null);
@@ -42753,14 +42805,15 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42753
42805
  setContracts({});
42754
42806
  setGlobalContracts(globalContractNames.map(newContractByName));
42755
42807
  setChainId(wallet && wallet.chainId || null);
42808
+ intervalId && clearInterval(intervalId);
42809
+ setBlock(0);
42810
+ wallet && wallet.ethereum && updateBlock();
42811
+ wallet && wallet.ethereum && setIntervalId(setInterval(updateBlock, 35000));
42756
42812
  }, [wallet && wallet.chainId]);
42757
42813
 
42758
42814
  var setConnector = function setConnector(connector) {
42759
42815
  setConnectionStatus(connector ? CONNECTING : NOT_CONNECTED);
42760
42816
  wallet && connector && wallet.connect(connector.id);
42761
- wallet && !connector && setContracts({});
42762
- wallet && !connector && setGlobalContracts(globalContractNames.map(newContractByName));
42763
- wallet && !connector && setChainId(wallet && wallet.chainId || null);
42764
42817
  wallet && !connector && wallet.reset();
42765
42818
  };
42766
42819
 
@@ -42785,14 +42838,25 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42785
42838
  var getGlobalContract = function getGlobalContract(contractName) {
42786
42839
  var index = globalContractNames.indexOf(contractName);
42787
42840
 
42788
- if (index === -1) {
42841
+ if (index === -1 || !globalContracts[index]) {
42789
42842
  var contract = newContractByName(contractName);
42790
- contract && setGlobalContracts(function (oldValue) {
42791
- return [].concat(_toConsumableArray(oldValue), [contract]);
42792
- });
42793
- contract && setGlobalContractNames(function (oldValue) {
42794
- return [].concat(_toConsumableArray(oldValue), [contractName]);
42795
- });
42843
+
42844
+ if (index === -1) {
42845
+ contract && setGlobalContracts(function (oldValue) {
42846
+ return [].concat(_toConsumableArray(oldValue), [contract]);
42847
+ });
42848
+ contract && setGlobalContractNames(function (oldValue) {
42849
+ return [].concat(_toConsumableArray(oldValue), [contractName]);
42850
+ });
42851
+ } else if (contract) {
42852
+ var newGlobalContracts = _toConsumableArray(globalContracts);
42853
+
42854
+ newGlobalContracts[index] = contract;
42855
+ setGlobalContracts(function () {
42856
+ return newGlobalContracts;
42857
+ });
42858
+ }
42859
+
42796
42860
  return contract;
42797
42861
  }
42798
42862
 
@@ -42815,6 +42879,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42815
42879
  chainId: chainId,
42816
42880
  chainName: wallet.networkName,
42817
42881
  web3: web3Instance,
42882
+ block: block,
42818
42883
  getGlobalContract: getGlobalContract,
42819
42884
  newContract: newContract
42820
42885
  }), wallet && wallet.error && {