@ethereansos/interfaces-core 0.4.108 → 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 -120
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +109 -121
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -48779,48 +48779,6 @@ var useEthosContext = function useEthosContext() {
|
|
|
48779
48779
|
var Web3Context = /*#__PURE__*/React__default["default"].createContext('web3');
|
|
48780
48780
|
var DEFAULT_BLOCK_INTERVAL = 15;
|
|
48781
48781
|
var DEFAULT_BLOCK_INTERVAL_TIMEOUT = 40000;
|
|
48782
|
-
/**
|
|
48783
|
-
* WRAP CHAINS START
|
|
48784
|
-
**/
|
|
48785
|
-
|
|
48786
|
-
var ETH = useWallet.chains.getChainInformation(1).nativeCurrency;
|
|
48787
|
-
var WRAPPED_CHAINS = {
|
|
48788
|
-
10: {
|
|
48789
|
-
id: 10,
|
|
48790
|
-
nativeCurrency: ETH,
|
|
48791
|
-
type: 'main',
|
|
48792
|
-
fullName: 'Optimism Mainnet',
|
|
48793
|
-
shortName: 'Optimism',
|
|
48794
|
-
explorerUrl: 'https://optimistic.etherscan.io',
|
|
48795
|
-
testnet: false
|
|
48796
|
-
}
|
|
48797
|
-
};
|
|
48798
|
-
|
|
48799
|
-
function wrap(methodName, funct, force) {
|
|
48800
|
-
var oldFunction = useWallet.chains[methodName];
|
|
48801
|
-
|
|
48802
|
-
useWallet.chains[methodName] = function (chainId) {
|
|
48803
|
-
var args = [].concat(Array.prototype.slice.call(arguments), [oldFunction]);
|
|
48804
|
-
return (WRAPPED_CHAINS[parseInt(chainId)] || force ? funct : oldFunction).apply(useWallet.chains, args);
|
|
48805
|
-
};
|
|
48806
|
-
}
|
|
48807
|
-
|
|
48808
|
-
wrap('isKnownChain', function () {
|
|
48809
|
-
return true;
|
|
48810
|
-
});
|
|
48811
|
-
wrap('getChainInformation', function (chainId) {
|
|
48812
|
-
return WRAPPED_CHAINS[parseInt(chainId)];
|
|
48813
|
-
});
|
|
48814
|
-
wrap('getKnownChainsIds', function (oldFunction) {
|
|
48815
|
-
return [].concat(_toConsumableArray(oldFunction()), _toConsumableArray(Object.keys(WRAPPED_CHAINS)));
|
|
48816
|
-
});
|
|
48817
|
-
wrap('getKnownChainInformation', function (oldFunction) {
|
|
48818
|
-
return [].concat(_toConsumableArray(oldFunction()), _toConsumableArray(Object.values(WRAPPED_CHAINS)));
|
|
48819
|
-
});
|
|
48820
|
-
/**
|
|
48821
|
-
* WRAP CHAINS END
|
|
48822
|
-
**/
|
|
48823
|
-
|
|
48824
48782
|
var web3States = {
|
|
48825
48783
|
NOT_CONNECTED: NOT_CONNECTED,
|
|
48826
48784
|
CONNECTED: CONNECTED,
|
|
@@ -48896,103 +48854,79 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
48896
48854
|
block = _useState18[0],
|
|
48897
48855
|
setBlock = _useState18[1];
|
|
48898
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
|
+
|
|
48899
48872
|
React.useEffect(function () {
|
|
48900
48873
|
setIpfsHttpClient(ipfsHttpClient.create(context.ipfsHost));
|
|
48901
48874
|
}, [context]);
|
|
48902
|
-
|
|
48903
|
-
|
|
48904
|
-
|
|
48905
|
-
|
|
48906
|
-
|
|
48907
|
-
function _tryUpdateBlock() {
|
|
48908
|
-
_tryUpdateBlock = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(force) {
|
|
48909
|
-
var currentBlock, currentBlockNumber;
|
|
48910
|
-
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) {
|
|
48911
48879
|
while (1) {
|
|
48912
|
-
switch (
|
|
48880
|
+
switch (_context.prev = _context.next) {
|
|
48913
48881
|
case 0:
|
|
48914
|
-
|
|
48915
|
-
|
|
48916
|
-
return sendAsync(wallet.ethereum, 'eth_getBlockByNumber', 'latest', true);
|
|
48917
|
-
|
|
48918
|
-
case 3:
|
|
48919
|
-
currentBlock = _context2.sent;
|
|
48920
|
-
currentBlockNumber = parseInt(currentBlock.number);
|
|
48921
|
-
|
|
48922
|
-
if (force === true || currentBlockNumber - block >= realBlockInterval) {
|
|
48923
|
-
setBlock(currentBlockNumber);
|
|
48882
|
+
if (!provider) {
|
|
48883
|
+
setter(0);
|
|
48924
48884
|
}
|
|
48925
48885
|
|
|
48926
|
-
|
|
48927
|
-
|
|
48928
|
-
|
|
48929
|
-
|
|
48930
|
-
_context2.prev = 8;
|
|
48931
|
-
_context2.t0 = _context2["catch"](0);
|
|
48932
|
-
|
|
48933
|
-
case 10:
|
|
48934
|
-
case "end":
|
|
48935
|
-
return _context2.stop();
|
|
48936
|
-
}
|
|
48937
|
-
}
|
|
48938
|
-
}, _callee2, null, [[0, 8]]);
|
|
48939
|
-
}));
|
|
48940
|
-
return _tryUpdateBlock.apply(this, arguments);
|
|
48941
|
-
}
|
|
48886
|
+
_context.prev = 1;
|
|
48887
|
+
_context.t0 = parseInt;
|
|
48888
|
+
_context.next = 5;
|
|
48889
|
+
return sendAsync(provider, 'eth_blockNumber');
|
|
48942
48890
|
|
|
48943
|
-
|
|
48944
|
-
|
|
48945
|
-
|
|
48946
|
-
while (1) {
|
|
48947
|
-
switch (_context.prev = _context.next) {
|
|
48948
|
-
case 0:
|
|
48949
|
-
delete window.account;
|
|
48950
|
-
acc && (window.account = acc);
|
|
48951
|
-
_context.prev = 2;
|
|
48952
|
-
_context.t0 = acc && window.ganache;
|
|
48891
|
+
case 5:
|
|
48892
|
+
_context.t1 = _context.sent;
|
|
48893
|
+
currentBlockNumber = (0, _context.t0)(_context.t1);
|
|
48953
48894
|
|
|
48954
|
-
if (
|
|
48955
|
-
|
|
48956
|
-
break;
|
|
48895
|
+
if (force === true || currentBlockNumber - oldValue >= realBlockInterval) {
|
|
48896
|
+
setter(currentBlockNumber);
|
|
48957
48897
|
}
|
|
48958
48898
|
|
|
48959
|
-
_context.next =
|
|
48960
|
-
return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
|
|
48961
|
-
|
|
48962
|
-
case 7:
|
|
48963
|
-
_context.next = 11;
|
|
48899
|
+
_context.next = 12;
|
|
48964
48900
|
break;
|
|
48965
48901
|
|
|
48966
|
-
case
|
|
48967
|
-
_context.prev =
|
|
48968
|
-
_context.
|
|
48969
|
-
|
|
48970
|
-
case 11:
|
|
48971
|
-
setBlock(new Date().getTime());
|
|
48972
|
-
setTimeout(resetBlockInterval);
|
|
48902
|
+
case 10:
|
|
48903
|
+
_context.prev = 10;
|
|
48904
|
+
_context.t2 = _context["catch"](1);
|
|
48973
48905
|
|
|
48974
|
-
case
|
|
48906
|
+
case 12:
|
|
48975
48907
|
case "end":
|
|
48976
48908
|
return _context.stop();
|
|
48977
48909
|
}
|
|
48978
48910
|
}
|
|
48979
|
-
}, _callee, null, [[
|
|
48911
|
+
}, _callee, null, [[1, 10]]);
|
|
48980
48912
|
}));
|
|
48981
48913
|
|
|
48982
|
-
function
|
|
48983
|
-
return
|
|
48984
|
-
}
|
|
48985
|
-
|
|
48986
|
-
|
|
48987
|
-
}();
|
|
48988
|
-
|
|
48989
|
-
function resetBlockInterval() {
|
|
48914
|
+
return function (_x, _x2, _x3, _x4) {
|
|
48915
|
+
return _ref2.apply(this, arguments);
|
|
48916
|
+
};
|
|
48917
|
+
}(), [realBlockInterval]);
|
|
48918
|
+
var resetBlockInterval = React.useCallback(function () {
|
|
48990
48919
|
intervalId && clearInterval(intervalId);
|
|
48991
|
-
wallet
|
|
48992
|
-
|
|
48993
|
-
|
|
48994
|
-
|
|
48995
|
-
|
|
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]);
|
|
48996
48930
|
React.useEffect(function () {
|
|
48997
48931
|
setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
|
|
48998
48932
|
setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3__default["default"](wallet.ethereum)) || null);
|
|
@@ -49000,7 +48934,11 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
49000
48934
|
React.useEffect(function () {
|
|
49001
48935
|
setContracts({});
|
|
49002
48936
|
setGlobalContracts(globalContractNames.map(newContractByName));
|
|
49003
|
-
|
|
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);
|
|
49004
48942
|
resetBlockInterval();
|
|
49005
48943
|
}, [wallet && wallet.chainId]);
|
|
49006
48944
|
|
|
@@ -49056,6 +48994,53 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
49056
48994
|
return globalContracts[index];
|
|
49057
48995
|
};
|
|
49058
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
|
+
|
|
49059
49044
|
var value = _objectSpread2(_objectSpread2({
|
|
49060
49045
|
connectionStatus: connectionStatus,
|
|
49061
49046
|
setConnector: setConnector,
|
|
@@ -49074,7 +49059,10 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
49074
49059
|
web3: web3Instance,
|
|
49075
49060
|
block: block,
|
|
49076
49061
|
getGlobalContract: getGlobalContract,
|
|
49077
|
-
newContract: newContract
|
|
49062
|
+
newContract: newContract,
|
|
49063
|
+
dualChainId: dualChainId,
|
|
49064
|
+
dualBlock: dualBlock,
|
|
49065
|
+
dualProvider: dualProvider
|
|
49078
49066
|
}), wallet && wallet.error && {
|
|
49079
49067
|
errorMessage: wallet.error.message
|
|
49080
49068
|
});
|