@ethereansos/interfaces-core 0.4.71 → 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 +57 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +57 -0
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -42670,6 +42670,7 @@ var useEthosContext = function useEthosContext() {
|
|
42670
42670
|
};
|
42671
42671
|
|
42672
42672
|
var Web3Context = /*#__PURE__*/React.createContext('web3');
|
42673
|
+
var BLOCK_INTERVAL = 15;
|
42673
42674
|
var web3States = {
|
42674
42675
|
NOT_CONNECTED: NOT_CONNECTED,
|
42675
42676
|
CONNECTED: CONNECTED,
|
@@ -42731,9 +42732,60 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
42731
42732
|
contracts = _useState14[0],
|
42732
42733
|
setContracts = _useState14[1];
|
42733
42734
|
|
42735
|
+
var _useState15 = useState(0),
|
42736
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
42737
|
+
intervalId = _useState16[0],
|
42738
|
+
setIntervalId = _useState16[1];
|
42739
|
+
|
42740
|
+
var _useState17 = useState(0),
|
42741
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
42742
|
+
block = _useState18[0],
|
42743
|
+
setBlock = _useState18[1];
|
42744
|
+
|
42734
42745
|
useEffect(function () {
|
42735
42746
|
setIpfsHttpClient(create(context.ipfsHost));
|
42736
42747
|
}, [context]);
|
42748
|
+
|
42749
|
+
function updateBlock() {
|
42750
|
+
return _updateBlock.apply(this, arguments);
|
42751
|
+
}
|
42752
|
+
|
42753
|
+
function _updateBlock() {
|
42754
|
+
_updateBlock = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
42755
|
+
var currentBlock, currentBlockNumber;
|
42756
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
42757
|
+
while (1) {
|
42758
|
+
switch (_context.prev = _context.next) {
|
42759
|
+
case 0:
|
42760
|
+
_context.prev = 0;
|
42761
|
+
_context.next = 3;
|
42762
|
+
return sendAsync(wallet.ethereum, 'eth_getBlock', 'latest', true);
|
42763
|
+
|
42764
|
+
case 3:
|
42765
|
+
currentBlock = _context.sent;
|
42766
|
+
currentBlockNumber = parseInt(currentBlock.number);
|
42767
|
+
|
42768
|
+
if (currentBlockNumber - block >= BLOCK_INTERVAL) {
|
42769
|
+
setBlock(currentBlockNumber);
|
42770
|
+
}
|
42771
|
+
|
42772
|
+
_context.next = 10;
|
42773
|
+
break;
|
42774
|
+
|
42775
|
+
case 8:
|
42776
|
+
_context.prev = 8;
|
42777
|
+
_context.t0 = _context["catch"](0);
|
42778
|
+
|
42779
|
+
case 10:
|
42780
|
+
case "end":
|
42781
|
+
return _context.stop();
|
42782
|
+
}
|
42783
|
+
}
|
42784
|
+
}, _callee, null, [[0, 8]]);
|
42785
|
+
}));
|
42786
|
+
return _updateBlock.apply(this, arguments);
|
42787
|
+
}
|
42788
|
+
|
42737
42789
|
useEffect(function () {
|
42738
42790
|
setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
|
42739
42791
|
setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3(wallet.ethereum)) || null);
|
@@ -42742,6 +42794,10 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
42742
42794
|
setContracts({});
|
42743
42795
|
setGlobalContracts(globalContractNames.map(newContractByName));
|
42744
42796
|
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));
|
42745
42801
|
}, [wallet && wallet.chainId]);
|
42746
42802
|
|
42747
42803
|
var setConnector = function setConnector(connector) {
|
@@ -42812,6 +42868,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
42812
42868
|
chainId: chainId,
|
42813
42869
|
chainName: wallet.networkName,
|
42814
42870
|
web3: web3Instance,
|
42871
|
+
block: block,
|
42815
42872
|
getGlobalContract: getGlobalContract,
|
42816
42873
|
newContract: newContract
|
42817
42874
|
}), wallet && wallet.error && {
|