@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.esm.js
CHANGED
|
@@ -48842,103 +48842,79 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
48842
48842
|
block = _useState18[0],
|
|
48843
48843
|
setBlock = _useState18[1];
|
|
48844
48844
|
|
|
48845
|
+
var _useState19 = useState(null),
|
|
48846
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
48847
|
+
dualChainId = _useState20[0],
|
|
48848
|
+
setDualChainId = _useState20[1];
|
|
48849
|
+
|
|
48850
|
+
var _useState21 = useState(0),
|
|
48851
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
48852
|
+
dualBlock = _useState22[0],
|
|
48853
|
+
setDualBlock = _useState22[1];
|
|
48854
|
+
|
|
48855
|
+
var _useState23 = useState(null),
|
|
48856
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
48857
|
+
dualProvider = _useState24[0],
|
|
48858
|
+
setDualProvider = _useState24[1];
|
|
48859
|
+
|
|
48845
48860
|
useEffect(function () {
|
|
48846
48861
|
setIpfsHttpClient(create(context.ipfsHost));
|
|
48847
48862
|
}, [context]);
|
|
48848
|
-
|
|
48849
|
-
|
|
48850
|
-
|
|
48851
|
-
|
|
48852
|
-
|
|
48853
|
-
function _tryUpdateBlock() {
|
|
48854
|
-
_tryUpdateBlock = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(force) {
|
|
48855
|
-
var currentBlock, currentBlockNumber;
|
|
48856
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
48863
|
+
var tryUpdateBlock = useCallback( /*#__PURE__*/function () {
|
|
48864
|
+
var _ref2 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(provider, oldValue, setter, force) {
|
|
48865
|
+
var currentBlockNumber;
|
|
48866
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
48857
48867
|
while (1) {
|
|
48858
|
-
switch (
|
|
48868
|
+
switch (_context.prev = _context.next) {
|
|
48859
48869
|
case 0:
|
|
48860
|
-
|
|
48861
|
-
|
|
48862
|
-
return sendAsync(wallet.ethereum, 'eth_getBlockByNumber', 'latest', true);
|
|
48863
|
-
|
|
48864
|
-
case 3:
|
|
48865
|
-
currentBlock = _context2.sent;
|
|
48866
|
-
currentBlockNumber = parseInt(currentBlock.number);
|
|
48867
|
-
|
|
48868
|
-
if (force === true || currentBlockNumber - block >= realBlockInterval) {
|
|
48869
|
-
setBlock(currentBlockNumber);
|
|
48870
|
+
if (!provider) {
|
|
48871
|
+
setter(0);
|
|
48870
48872
|
}
|
|
48871
48873
|
|
|
48872
|
-
|
|
48873
|
-
|
|
48874
|
-
|
|
48875
|
-
|
|
48876
|
-
_context2.prev = 8;
|
|
48877
|
-
_context2.t0 = _context2["catch"](0);
|
|
48878
|
-
|
|
48879
|
-
case 10:
|
|
48880
|
-
case "end":
|
|
48881
|
-
return _context2.stop();
|
|
48882
|
-
}
|
|
48883
|
-
}
|
|
48884
|
-
}, _callee2, null, [[0, 8]]);
|
|
48885
|
-
}));
|
|
48886
|
-
return _tryUpdateBlock.apply(this, arguments);
|
|
48887
|
-
}
|
|
48874
|
+
_context.prev = 1;
|
|
48875
|
+
_context.t0 = parseInt;
|
|
48876
|
+
_context.next = 5;
|
|
48877
|
+
return sendAsync(provider, 'eth_blockNumber');
|
|
48888
48878
|
|
|
48889
|
-
|
|
48890
|
-
|
|
48891
|
-
|
|
48892
|
-
while (1) {
|
|
48893
|
-
switch (_context.prev = _context.next) {
|
|
48894
|
-
case 0:
|
|
48895
|
-
delete window.account;
|
|
48896
|
-
acc && (window.account = acc);
|
|
48897
|
-
_context.prev = 2;
|
|
48898
|
-
_context.t0 = acc && window.ganache;
|
|
48879
|
+
case 5:
|
|
48880
|
+
_context.t1 = _context.sent;
|
|
48881
|
+
currentBlockNumber = (0, _context.t0)(_context.t1);
|
|
48899
48882
|
|
|
48900
|
-
if (
|
|
48901
|
-
|
|
48902
|
-
break;
|
|
48883
|
+
if (force === true || currentBlockNumber - oldValue >= realBlockInterval) {
|
|
48884
|
+
setter(currentBlockNumber);
|
|
48903
48885
|
}
|
|
48904
48886
|
|
|
48905
|
-
_context.next =
|
|
48906
|
-
return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
|
|
48907
|
-
|
|
48908
|
-
case 7:
|
|
48909
|
-
_context.next = 11;
|
|
48887
|
+
_context.next = 12;
|
|
48910
48888
|
break;
|
|
48911
48889
|
|
|
48912
|
-
case
|
|
48913
|
-
_context.prev =
|
|
48914
|
-
_context.
|
|
48915
|
-
|
|
48916
|
-
case 11:
|
|
48917
|
-
setBlock(new Date().getTime());
|
|
48918
|
-
setTimeout(resetBlockInterval);
|
|
48890
|
+
case 10:
|
|
48891
|
+
_context.prev = 10;
|
|
48892
|
+
_context.t2 = _context["catch"](1);
|
|
48919
48893
|
|
|
48920
|
-
case
|
|
48894
|
+
case 12:
|
|
48921
48895
|
case "end":
|
|
48922
48896
|
return _context.stop();
|
|
48923
48897
|
}
|
|
48924
48898
|
}
|
|
48925
|
-
}, _callee, null, [[
|
|
48899
|
+
}, _callee, null, [[1, 10]]);
|
|
48926
48900
|
}));
|
|
48927
48901
|
|
|
48928
|
-
function
|
|
48929
|
-
return
|
|
48930
|
-
}
|
|
48931
|
-
|
|
48932
|
-
|
|
48933
|
-
}();
|
|
48934
|
-
|
|
48935
|
-
function resetBlockInterval() {
|
|
48902
|
+
return function (_x, _x2, _x3, _x4) {
|
|
48903
|
+
return _ref2.apply(this, arguments);
|
|
48904
|
+
};
|
|
48905
|
+
}(), [realBlockInterval]);
|
|
48906
|
+
var resetBlockInterval = useCallback(function () {
|
|
48936
48907
|
intervalId && clearInterval(intervalId);
|
|
48937
|
-
wallet
|
|
48938
|
-
|
|
48939
|
-
|
|
48940
|
-
|
|
48941
|
-
|
|
48908
|
+
tryUpdateBlock(wallet === null || wallet === void 0 ? void 0 : wallet.ethereum, block, setBlock, true);
|
|
48909
|
+
tryUpdateBlock(dualProvider, dualBlock, setDualBlock, true);
|
|
48910
|
+
wallet && wallet.ethereum && setIntervalId(setInterval(function () {
|
|
48911
|
+
return tryUpdateBlock(wallet.ethereum, block, setBlock);
|
|
48912
|
+
}, realBlockIntervalTimeout));
|
|
48913
|
+
dualProvider && setIntervalId(setInterval(function () {
|
|
48914
|
+
return tryUpdateBlock(dualProvider, dualBlock, setDualBlock);
|
|
48915
|
+
}, realBlockIntervalTimeout));
|
|
48916
|
+
}, [wallet, dualProvider, intervalId]);
|
|
48917
|
+
useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum, dualProvider, intervalId]);
|
|
48942
48918
|
useEffect(function () {
|
|
48943
48919
|
setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
|
|
48944
48920
|
setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3(wallet.ethereum)) || null);
|
|
@@ -48946,7 +48922,11 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
48946
48922
|
useEffect(function () {
|
|
48947
48923
|
setContracts({});
|
|
48948
48924
|
setGlobalContracts(globalContractNames.map(newContractByName));
|
|
48949
|
-
|
|
48925
|
+
var actualChainId = wallet && wallet.chainId || null;
|
|
48926
|
+
setChainId(actualChainId);
|
|
48927
|
+
var actualDualChainId = actualChainId && context.dualChainId[actualChainId] || null;
|
|
48928
|
+
setDualChainId(actualDualChainId);
|
|
48929
|
+
setDualProvider(actualDualChainId && new Web3.providers.HttpProvider(context.chainProvider[actualDualChainId]) || null);
|
|
48950
48930
|
resetBlockInterval();
|
|
48951
48931
|
}, [wallet && wallet.chainId]);
|
|
48952
48932
|
|
|
@@ -49002,6 +48982,53 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
49002
48982
|
return globalContracts[index];
|
|
49003
48983
|
};
|
|
49004
48984
|
|
|
48985
|
+
window.setAccount = /*#__PURE__*/function () {
|
|
48986
|
+
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(acc) {
|
|
48987
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
48988
|
+
while (1) {
|
|
48989
|
+
switch (_context2.prev = _context2.next) {
|
|
48990
|
+
case 0:
|
|
48991
|
+
delete window.account;
|
|
48992
|
+
acc && (window.account = acc);
|
|
48993
|
+
_context2.prev = 2;
|
|
48994
|
+
_context2.t0 = acc && window.ganache;
|
|
48995
|
+
|
|
48996
|
+
if (!_context2.t0) {
|
|
48997
|
+
_context2.next = 7;
|
|
48998
|
+
break;
|
|
48999
|
+
}
|
|
49000
|
+
|
|
49001
|
+
_context2.next = 7;
|
|
49002
|
+
return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
|
|
49003
|
+
|
|
49004
|
+
case 7:
|
|
49005
|
+
_context2.next = 11;
|
|
49006
|
+
break;
|
|
49007
|
+
|
|
49008
|
+
case 9:
|
|
49009
|
+
_context2.prev = 9;
|
|
49010
|
+
_context2.t1 = _context2["catch"](2);
|
|
49011
|
+
|
|
49012
|
+
case 11:
|
|
49013
|
+
setBlock(new Date().getTime());
|
|
49014
|
+
setDualBlock(new Date().getTime());
|
|
49015
|
+
setTimeout(resetBlockInterval);
|
|
49016
|
+
|
|
49017
|
+
case 14:
|
|
49018
|
+
case "end":
|
|
49019
|
+
return _context2.stop();
|
|
49020
|
+
}
|
|
49021
|
+
}
|
|
49022
|
+
}, _callee2, null, [[2, 9]]);
|
|
49023
|
+
}));
|
|
49024
|
+
|
|
49025
|
+
function setAccount(_x5) {
|
|
49026
|
+
return _setAccount.apply(this, arguments);
|
|
49027
|
+
}
|
|
49028
|
+
|
|
49029
|
+
return setAccount;
|
|
49030
|
+
}();
|
|
49031
|
+
|
|
49005
49032
|
var value = _objectSpread2(_objectSpread2({
|
|
49006
49033
|
connectionStatus: connectionStatus,
|
|
49007
49034
|
setConnector: setConnector,
|
|
@@ -49020,7 +49047,10 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
49020
49047
|
web3: web3Instance,
|
|
49021
49048
|
block: block,
|
|
49022
49049
|
getGlobalContract: getGlobalContract,
|
|
49023
|
-
newContract: newContract
|
|
49050
|
+
newContract: newContract,
|
|
49051
|
+
dualChainId: dualChainId,
|
|
49052
|
+
dualBlock: dualBlock,
|
|
49053
|
+
dualProvider: dualProvider
|
|
49024
49054
|
}), wallet && wallet.error && {
|
|
49025
49055
|
errorMessage: wallet.error.message
|
|
49026
49056
|
});
|