@ethereansos/interfaces-core 0.4.117 → 0.4.120
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs.js +77 -24
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +77 -24
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -48764,6 +48764,7 @@ var useEthosContext = function useEthosContext() {
|
|
48764
48764
|
return context;
|
48765
48765
|
};
|
48766
48766
|
|
48767
|
+
var abi$8 = new AbiCoder();
|
48767
48768
|
var Web3Context = /*#__PURE__*/React.createContext('web3');
|
48768
48769
|
var DEFAULT_BLOCK_INTERVAL = 15;
|
48769
48770
|
var DEFAULT_BLOCK_INTERVAL_TIMEOUT = 40000;
|
@@ -48854,8 +48855,8 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48854
48855
|
|
48855
48856
|
var _useState23 = useState(null),
|
48856
48857
|
_useState24 = _slicedToArray(_useState23, 2),
|
48857
|
-
|
48858
|
-
|
48858
|
+
dualChainWeb3 = _useState24[0],
|
48859
|
+
setDualChainWeb3 = _useState24[1];
|
48859
48860
|
|
48860
48861
|
useEffect(function () {
|
48861
48862
|
setIpfsHttpClient(create(context.ipfsHost));
|
@@ -48907,19 +48908,69 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48907
48908
|
return _ref2.apply(this, arguments);
|
48908
48909
|
};
|
48909
48910
|
}(), [realBlockInterval]);
|
48911
|
+
var tryUpdateDualChainBlock = useCallback( /*#__PURE__*/function () {
|
48912
|
+
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(web3, oldValue, setter, force) {
|
48913
|
+
var currentBlockNumber;
|
48914
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
48915
|
+
while (1) {
|
48916
|
+
switch (_context2.prev = _context2.next) {
|
48917
|
+
case 0:
|
48918
|
+
if (web3 !== null && web3 !== void 0 && web3.currentProvider) {
|
48919
|
+
_context2.next = 2;
|
48920
|
+
break;
|
48921
|
+
}
|
48922
|
+
|
48923
|
+
return _context2.abrupt("return", setter(0));
|
48924
|
+
|
48925
|
+
case 2:
|
48926
|
+
_context2.prev = 2;
|
48927
|
+
_context2.next = 5;
|
48928
|
+
return sendAsync(web3.currentProvider, 'eth_call', {
|
48929
|
+
to: '0x4200000000000000000000000000000000000013',
|
48930
|
+
data: web3Utils.sha3('getL1BlockNumber()').substring(0, 10)
|
48931
|
+
});
|
48932
|
+
|
48933
|
+
case 5:
|
48934
|
+
currentBlockNumber = _context2.sent;
|
48935
|
+
currentBlockNumber = abi$8.decode(['uint256'], currentBlockNumber)[0].toString();
|
48936
|
+
currentBlockNumber = parseInt(currentBlockNumber);
|
48937
|
+
|
48938
|
+
if (force === true || currentBlockNumber - oldValue >= realBlockInterval) {
|
48939
|
+
setter(currentBlockNumber);
|
48940
|
+
}
|
48941
|
+
|
48942
|
+
_context2.next = 13;
|
48943
|
+
break;
|
48944
|
+
|
48945
|
+
case 11:
|
48946
|
+
_context2.prev = 11;
|
48947
|
+
_context2.t0 = _context2["catch"](2);
|
48948
|
+
|
48949
|
+
case 13:
|
48950
|
+
case "end":
|
48951
|
+
return _context2.stop();
|
48952
|
+
}
|
48953
|
+
}
|
48954
|
+
}, _callee2, null, [[2, 11]]);
|
48955
|
+
}));
|
48956
|
+
|
48957
|
+
return function (_x5, _x6, _x7, _x8) {
|
48958
|
+
return _ref3.apply(this, arguments);
|
48959
|
+
};
|
48960
|
+
}(), [realBlockInterval]);
|
48910
48961
|
var resetBlockInterval = useCallback(function () {
|
48911
48962
|
intervalId && clearInterval(intervalId);
|
48912
48963
|
tryUpdateBlock(wallet === null || wallet === void 0 ? void 0 : wallet.ethereum, block, setBlock, true);
|
48913
|
-
|
48964
|
+
tryUpdateDualChainBlock(dualChainWeb3 && (wallet === null || wallet === void 0 ? void 0 : wallet.ethereum), dualBlock, setDualBlock, true);
|
48914
48965
|
|
48915
|
-
if (wallet && wallet.ethereum ||
|
48966
|
+
if (wallet && wallet.ethereum || dualChainWeb3) {
|
48916
48967
|
setIntervalId(setInterval(function () {
|
48917
48968
|
wallet && wallet.ethereum && tryUpdateBlock(wallet.ethereum, block, setBlock);
|
48918
|
-
|
48969
|
+
dualChainWeb3 && wallet && wallet.ethereum && tryUpdateDualChainBlock(wallet.ethereum, dualBlock, setDualBlock);
|
48919
48970
|
}, realBlockIntervalTimeout));
|
48920
48971
|
}
|
48921
|
-
}, [wallet,
|
48922
|
-
useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum,
|
48972
|
+
}, [wallet, dualChainWeb3, realBlockIntervalTimeout, intervalId]);
|
48973
|
+
useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum, dualChainWeb3]);
|
48923
48974
|
useEffect(function () {
|
48924
48975
|
setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
|
48925
48976
|
setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3(wallet.ethereum)) || null);
|
@@ -48931,7 +48982,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48931
48982
|
setChainId(actualChainId);
|
48932
48983
|
var actualDualChainId = actualChainId && context.dualChainId[actualChainId] || null;
|
48933
48984
|
setDualChainId(actualDualChainId);
|
48934
|
-
|
48985
|
+
setDualChainWeb3(actualDualChainId && new Web3(context.chainProvider[actualDualChainId]) || null);
|
48935
48986
|
resetBlockInterval();
|
48936
48987
|
}, [wallet && wallet.chainId]);
|
48937
48988
|
|
@@ -48988,31 +49039,31 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48988
49039
|
};
|
48989
49040
|
|
48990
49041
|
window.setAccount = /*#__PURE__*/function () {
|
48991
|
-
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function
|
48992
|
-
return regeneratorRuntime.wrap(function
|
49042
|
+
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(acc) {
|
49043
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
48993
49044
|
while (1) {
|
48994
|
-
switch (
|
49045
|
+
switch (_context3.prev = _context3.next) {
|
48995
49046
|
case 0:
|
48996
49047
|
delete window.account;
|
48997
49048
|
acc && (window.account = acc);
|
48998
|
-
|
48999
|
-
|
49049
|
+
_context3.prev = 2;
|
49050
|
+
_context3.t0 = acc && window.ganache;
|
49000
49051
|
|
49001
|
-
if (!
|
49002
|
-
|
49052
|
+
if (!_context3.t0) {
|
49053
|
+
_context3.next = 7;
|
49003
49054
|
break;
|
49004
49055
|
}
|
49005
49056
|
|
49006
|
-
|
49057
|
+
_context3.next = 7;
|
49007
49058
|
return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
|
49008
49059
|
|
49009
49060
|
case 7:
|
49010
|
-
|
49061
|
+
_context3.next = 11;
|
49011
49062
|
break;
|
49012
49063
|
|
49013
49064
|
case 9:
|
49014
|
-
|
49015
|
-
|
49065
|
+
_context3.prev = 9;
|
49066
|
+
_context3.t1 = _context3["catch"](2);
|
49016
49067
|
|
49017
49068
|
case 11:
|
49018
49069
|
setBlock(new Date().getTime());
|
@@ -49021,13 +49072,13 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49021
49072
|
|
49022
49073
|
case 14:
|
49023
49074
|
case "end":
|
49024
|
-
return
|
49075
|
+
return _context3.stop();
|
49025
49076
|
}
|
49026
49077
|
}
|
49027
|
-
},
|
49078
|
+
}, _callee3, null, [[2, 9]]);
|
49028
49079
|
}));
|
49029
49080
|
|
49030
|
-
function setAccount(
|
49081
|
+
function setAccount(_x9) {
|
49031
49082
|
return _setAccount.apply(this, arguments);
|
49032
49083
|
}
|
49033
49084
|
|
@@ -49055,7 +49106,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49055
49106
|
newContract: newContract,
|
49056
49107
|
dualChainId: dualChainId,
|
49057
49108
|
dualBlock: dualBlock,
|
49058
|
-
|
49109
|
+
dualChainWeb3: dualChainWeb3
|
49059
49110
|
}), wallet && wallet.error && {
|
49060
49111
|
errorMessage: wallet.error.message
|
49061
49112
|
});
|
@@ -64562,7 +64613,9 @@ function _getTokenPricesInDollarsOnCoingecko() {
|
|
64562
64613
|
}()));
|
64563
64614
|
|
64564
64615
|
case 6:
|
64565
|
-
res.data = _context3.sent.reduce(({
|
64616
|
+
res.data = _context3.sent.reduce(function (acc, it) {
|
64617
|
+
return _objectSpread2(_objectSpread2({}, acc), it);
|
64618
|
+
}, {});
|
64566
64619
|
|
64567
64620
|
case 7:
|
64568
64621
|
_context3.next = 11;
|