@ethereansos/interfaces-core 0.4.110 → 0.4.111
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 +108 -78
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +108 -78
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -48854,103 +48854,79 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
48854
48854
|
block = _useState18[0],
|
|
48855
48855
|
setBlock = _useState18[1];
|
|
48856
48856
|
|
|
48857
|
+
var _useState19 = React.useState(null),
|
|
48858
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
48859
|
+
dualChainId = _useState20[0],
|
|
48860
|
+
setDualChainId = _useState20[1];
|
|
48861
|
+
|
|
48862
|
+
var _useState21 = React.useState(0),
|
|
48863
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
48864
|
+
dualBlock = _useState22[0],
|
|
48865
|
+
setDualBlock = _useState22[1];
|
|
48866
|
+
|
|
48867
|
+
var _useState23 = React.useState(null),
|
|
48868
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
48869
|
+
dualProvider = _useState24[0],
|
|
48870
|
+
setDualProvider = _useState24[1];
|
|
48871
|
+
|
|
48857
48872
|
React.useEffect(function () {
|
|
48858
48873
|
setIpfsHttpClient(ipfsHttpClient.create(context.ipfsHost));
|
|
48859
48874
|
}, [context]);
|
|
48860
|
-
|
|
48861
|
-
|
|
48862
|
-
|
|
48863
|
-
|
|
48864
|
-
|
|
48865
|
-
function _tryUpdateBlock() {
|
|
48866
|
-
_tryUpdateBlock = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(force) {
|
|
48867
|
-
var currentBlock, currentBlockNumber;
|
|
48868
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
48875
|
+
var tryUpdateBlock = React.useCallback( /*#__PURE__*/function () {
|
|
48876
|
+
var _ref2 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(provider, oldValue, setter, force) {
|
|
48877
|
+
var currentBlockNumber;
|
|
48878
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
48869
48879
|
while (1) {
|
|
48870
|
-
switch (
|
|
48880
|
+
switch (_context.prev = _context.next) {
|
|
48871
48881
|
case 0:
|
|
48872
|
-
|
|
48873
|
-
|
|
48874
|
-
return sendAsync(wallet.ethereum, 'eth_getBlockByNumber', 'latest', true);
|
|
48875
|
-
|
|
48876
|
-
case 3:
|
|
48877
|
-
currentBlock = _context2.sent;
|
|
48878
|
-
currentBlockNumber = parseInt(currentBlock.number);
|
|
48879
|
-
|
|
48880
|
-
if (force === true || currentBlockNumber - block >= realBlockInterval) {
|
|
48881
|
-
setBlock(currentBlockNumber);
|
|
48882
|
+
if (!provider) {
|
|
48883
|
+
setter(0);
|
|
48882
48884
|
}
|
|
48883
48885
|
|
|
48884
|
-
|
|
48885
|
-
|
|
48886
|
-
|
|
48887
|
-
|
|
48888
|
-
_context2.prev = 8;
|
|
48889
|
-
_context2.t0 = _context2["catch"](0);
|
|
48890
|
-
|
|
48891
|
-
case 10:
|
|
48892
|
-
case "end":
|
|
48893
|
-
return _context2.stop();
|
|
48894
|
-
}
|
|
48895
|
-
}
|
|
48896
|
-
}, _callee2, null, [[0, 8]]);
|
|
48897
|
-
}));
|
|
48898
|
-
return _tryUpdateBlock.apply(this, arguments);
|
|
48899
|
-
}
|
|
48886
|
+
_context.prev = 1;
|
|
48887
|
+
_context.t0 = parseInt;
|
|
48888
|
+
_context.next = 5;
|
|
48889
|
+
return sendAsync(provider, 'eth_blockNumber');
|
|
48900
48890
|
|
|
48901
|
-
|
|
48902
|
-
|
|
48903
|
-
|
|
48904
|
-
while (1) {
|
|
48905
|
-
switch (_context.prev = _context.next) {
|
|
48906
|
-
case 0:
|
|
48907
|
-
delete window.account;
|
|
48908
|
-
acc && (window.account = acc);
|
|
48909
|
-
_context.prev = 2;
|
|
48910
|
-
_context.t0 = acc && window.ganache;
|
|
48891
|
+
case 5:
|
|
48892
|
+
_context.t1 = _context.sent;
|
|
48893
|
+
currentBlockNumber = (0, _context.t0)(_context.t1);
|
|
48911
48894
|
|
|
48912
|
-
if (
|
|
48913
|
-
|
|
48914
|
-
break;
|
|
48895
|
+
if (force === true || currentBlockNumber - oldValue >= realBlockInterval) {
|
|
48896
|
+
setter(currentBlockNumber);
|
|
48915
48897
|
}
|
|
48916
48898
|
|
|
48917
|
-
_context.next =
|
|
48918
|
-
return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
|
|
48919
|
-
|
|
48920
|
-
case 7:
|
|
48921
|
-
_context.next = 11;
|
|
48899
|
+
_context.next = 12;
|
|
48922
48900
|
break;
|
|
48923
48901
|
|
|
48924
|
-
case
|
|
48925
|
-
_context.prev =
|
|
48926
|
-
_context.
|
|
48927
|
-
|
|
48928
|
-
case 11:
|
|
48929
|
-
setBlock(new Date().getTime());
|
|
48930
|
-
setTimeout(resetBlockInterval);
|
|
48902
|
+
case 10:
|
|
48903
|
+
_context.prev = 10;
|
|
48904
|
+
_context.t2 = _context["catch"](1);
|
|
48931
48905
|
|
|
48932
|
-
case
|
|
48906
|
+
case 12:
|
|
48933
48907
|
case "end":
|
|
48934
48908
|
return _context.stop();
|
|
48935
48909
|
}
|
|
48936
48910
|
}
|
|
48937
|
-
}, _callee, null, [[
|
|
48911
|
+
}, _callee, null, [[1, 10]]);
|
|
48938
48912
|
}));
|
|
48939
48913
|
|
|
48940
|
-
function
|
|
48941
|
-
return
|
|
48942
|
-
}
|
|
48943
|
-
|
|
48944
|
-
|
|
48945
|
-
}();
|
|
48946
|
-
|
|
48947
|
-
function resetBlockInterval() {
|
|
48914
|
+
return function (_x, _x2, _x3, _x4) {
|
|
48915
|
+
return _ref2.apply(this, arguments);
|
|
48916
|
+
};
|
|
48917
|
+
}(), [realBlockInterval]);
|
|
48918
|
+
var resetBlockInterval = React.useCallback(function () {
|
|
48948
48919
|
intervalId && clearInterval(intervalId);
|
|
48949
|
-
wallet
|
|
48950
|
-
|
|
48951
|
-
|
|
48952
|
-
|
|
48953
|
-
|
|
48920
|
+
tryUpdateBlock(wallet === null || wallet === void 0 ? void 0 : wallet.ethereum, block, setBlock, true);
|
|
48921
|
+
tryUpdateBlock(dualProvider, dualBlock, setDualBlock, true);
|
|
48922
|
+
wallet && wallet.ethereum && setIntervalId(setInterval(function () {
|
|
48923
|
+
return tryUpdateBlock(wallet.ethereum, block, setBlock);
|
|
48924
|
+
}, realBlockIntervalTimeout));
|
|
48925
|
+
dualProvider && setIntervalId(setInterval(function () {
|
|
48926
|
+
return tryUpdateBlock(dualProvider, dualBlock, setDualBlock);
|
|
48927
|
+
}, realBlockIntervalTimeout));
|
|
48928
|
+
}, [wallet, dualProvider, intervalId]);
|
|
48929
|
+
React.useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum, dualProvider, intervalId]);
|
|
48954
48930
|
React.useEffect(function () {
|
|
48955
48931
|
setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
|
|
48956
48932
|
setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3__default["default"](wallet.ethereum)) || null);
|
|
@@ -48958,7 +48934,11 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
48958
48934
|
React.useEffect(function () {
|
|
48959
48935
|
setContracts({});
|
|
48960
48936
|
setGlobalContracts(globalContractNames.map(newContractByName));
|
|
48961
|
-
|
|
48937
|
+
var actualChainId = wallet && wallet.chainId || null;
|
|
48938
|
+
setChainId(actualChainId);
|
|
48939
|
+
var actualDualChainId = actualChainId && context.dualChainId[actualChainId] || null;
|
|
48940
|
+
setDualChainId(actualDualChainId);
|
|
48941
|
+
setDualProvider(actualDualChainId && new Web3__default["default"].providers.HttpProvider(context.chainProvider[actualDualChainId]) || null);
|
|
48962
48942
|
resetBlockInterval();
|
|
48963
48943
|
}, [wallet && wallet.chainId]);
|
|
48964
48944
|
|
|
@@ -49014,6 +48994,53 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
49014
48994
|
return globalContracts[index];
|
|
49015
48995
|
};
|
|
49016
48996
|
|
|
48997
|
+
window.setAccount = /*#__PURE__*/function () {
|
|
48998
|
+
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(acc) {
|
|
48999
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
49000
|
+
while (1) {
|
|
49001
|
+
switch (_context2.prev = _context2.next) {
|
|
49002
|
+
case 0:
|
|
49003
|
+
delete window.account;
|
|
49004
|
+
acc && (window.account = acc);
|
|
49005
|
+
_context2.prev = 2;
|
|
49006
|
+
_context2.t0 = acc && window.ganache;
|
|
49007
|
+
|
|
49008
|
+
if (!_context2.t0) {
|
|
49009
|
+
_context2.next = 7;
|
|
49010
|
+
break;
|
|
49011
|
+
}
|
|
49012
|
+
|
|
49013
|
+
_context2.next = 7;
|
|
49014
|
+
return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
|
|
49015
|
+
|
|
49016
|
+
case 7:
|
|
49017
|
+
_context2.next = 11;
|
|
49018
|
+
break;
|
|
49019
|
+
|
|
49020
|
+
case 9:
|
|
49021
|
+
_context2.prev = 9;
|
|
49022
|
+
_context2.t1 = _context2["catch"](2);
|
|
49023
|
+
|
|
49024
|
+
case 11:
|
|
49025
|
+
setBlock(new Date().getTime());
|
|
49026
|
+
setDualBlock(new Date().getTime());
|
|
49027
|
+
setTimeout(resetBlockInterval);
|
|
49028
|
+
|
|
49029
|
+
case 14:
|
|
49030
|
+
case "end":
|
|
49031
|
+
return _context2.stop();
|
|
49032
|
+
}
|
|
49033
|
+
}
|
|
49034
|
+
}, _callee2, null, [[2, 9]]);
|
|
49035
|
+
}));
|
|
49036
|
+
|
|
49037
|
+
function setAccount(_x5) {
|
|
49038
|
+
return _setAccount.apply(this, arguments);
|
|
49039
|
+
}
|
|
49040
|
+
|
|
49041
|
+
return setAccount;
|
|
49042
|
+
}();
|
|
49043
|
+
|
|
49017
49044
|
var value = _objectSpread2(_objectSpread2({
|
|
49018
49045
|
connectionStatus: connectionStatus,
|
|
49019
49046
|
setConnector: setConnector,
|
|
@@ -49032,7 +49059,10 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
49032
49059
|
web3: web3Instance,
|
|
49033
49060
|
block: block,
|
|
49034
49061
|
getGlobalContract: getGlobalContract,
|
|
49035
|
-
newContract: newContract
|
|
49062
|
+
newContract: newContract,
|
|
49063
|
+
dualChainId: dualChainId,
|
|
49064
|
+
dualBlock: dualBlock,
|
|
49065
|
+
dualProvider: dualProvider
|
|
49036
49066
|
}), wallet && wallet.error && {
|
|
49037
49067
|
errorMessage: wallet.error.message
|
|
49038
49068
|
});
|