@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.cjs.js
CHANGED
@@ -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,6 +42805,10 @@ 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) {
|
@@ -42823,6 +42879,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
42823
42879
|
chainId: chainId,
|
42824
42880
|
chainName: wallet.networkName,
|
42825
42881
|
web3: web3Instance,
|
42882
|
+
block: block,
|
42826
42883
|
getGlobalContract: getGlobalContract,
|
42827
42884
|
newContract: newContract
|
42828
42885
|
}), wallet && wallet.error && {
|