@ethereansos/interfaces-core 0.4.109 → 0.4.112
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 -123
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +108 -123
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -48767,51 +48767,6 @@ var useEthosContext = function useEthosContext() {
|
|
|
48767
48767
|
var Web3Context = /*#__PURE__*/React.createContext('web3');
|
|
48768
48768
|
var DEFAULT_BLOCK_INTERVAL = 15;
|
|
48769
48769
|
var DEFAULT_BLOCK_INTERVAL_TIMEOUT = 40000;
|
|
48770
|
-
|
|
48771
|
-
var chains = require('use-wallet').chains;
|
|
48772
|
-
/**
|
|
48773
|
-
* WRAP CHAINS START
|
|
48774
|
-
**/
|
|
48775
|
-
|
|
48776
|
-
|
|
48777
|
-
var ETH = chains.getChainInformation(1).nativeCurrency;
|
|
48778
|
-
var WRAPPED_CHAINS = {
|
|
48779
|
-
10: {
|
|
48780
|
-
id: 10,
|
|
48781
|
-
nativeCurrency: ETH,
|
|
48782
|
-
type: 'main',
|
|
48783
|
-
fullName: 'Optimism Mainnet',
|
|
48784
|
-
shortName: 'Optimism',
|
|
48785
|
-
explorerUrl: 'https://optimistic.etherscan.io',
|
|
48786
|
-
testnet: false
|
|
48787
|
-
}
|
|
48788
|
-
};
|
|
48789
|
-
|
|
48790
|
-
function wrap(methodName, funct, force) {
|
|
48791
|
-
var oldFunction = chains[methodName];
|
|
48792
|
-
|
|
48793
|
-
chains[methodName] = function (chainId) {
|
|
48794
|
-
var args = [].concat(Array.prototype.slice.call(arguments), [oldFunction]);
|
|
48795
|
-
return (WRAPPED_CHAINS[parseInt(chainId)] || force ? funct : oldFunction).apply(chains, args);
|
|
48796
|
-
};
|
|
48797
|
-
}
|
|
48798
|
-
|
|
48799
|
-
wrap('isKnownChain', function () {
|
|
48800
|
-
return true;
|
|
48801
|
-
});
|
|
48802
|
-
wrap('getChainInformation', function (chainId) {
|
|
48803
|
-
return WRAPPED_CHAINS[parseInt(chainId)];
|
|
48804
|
-
});
|
|
48805
|
-
wrap('getKnownChainsIds', function (oldFunction) {
|
|
48806
|
-
return [].concat(_toConsumableArray(oldFunction()), _toConsumableArray(Object.keys(WRAPPED_CHAINS)));
|
|
48807
|
-
});
|
|
48808
|
-
wrap('getKnownChainInformation', function (oldFunction) {
|
|
48809
|
-
return [].concat(_toConsumableArray(oldFunction()), _toConsumableArray(Object.values(WRAPPED_CHAINS)));
|
|
48810
|
-
});
|
|
48811
|
-
/**
|
|
48812
|
-
* WRAP CHAINS END
|
|
48813
|
-
**/
|
|
48814
|
-
|
|
48815
48770
|
var web3States = {
|
|
48816
48771
|
NOT_CONNECTED: NOT_CONNECTED,
|
|
48817
48772
|
CONNECTED: CONNECTED,
|
|
@@ -48887,103 +48842,79 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
48887
48842
|
block = _useState18[0],
|
|
48888
48843
|
setBlock = _useState18[1];
|
|
48889
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
|
+
|
|
48890
48860
|
useEffect(function () {
|
|
48891
48861
|
setIpfsHttpClient(create(context.ipfsHost));
|
|
48892
48862
|
}, [context]);
|
|
48893
|
-
|
|
48894
|
-
|
|
48895
|
-
|
|
48896
|
-
|
|
48897
|
-
|
|
48898
|
-
function _tryUpdateBlock() {
|
|
48899
|
-
_tryUpdateBlock = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(force) {
|
|
48900
|
-
var currentBlock, currentBlockNumber;
|
|
48901
|
-
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) {
|
|
48902
48867
|
while (1) {
|
|
48903
|
-
switch (
|
|
48868
|
+
switch (_context.prev = _context.next) {
|
|
48904
48869
|
case 0:
|
|
48905
|
-
|
|
48906
|
-
|
|
48907
|
-
return sendAsync(wallet.ethereum, 'eth_getBlockByNumber', 'latest', true);
|
|
48908
|
-
|
|
48909
|
-
case 3:
|
|
48910
|
-
currentBlock = _context2.sent;
|
|
48911
|
-
currentBlockNumber = parseInt(currentBlock.number);
|
|
48912
|
-
|
|
48913
|
-
if (force === true || currentBlockNumber - block >= realBlockInterval) {
|
|
48914
|
-
setBlock(currentBlockNumber);
|
|
48870
|
+
if (!provider) {
|
|
48871
|
+
setter(0);
|
|
48915
48872
|
}
|
|
48916
48873
|
|
|
48917
|
-
|
|
48918
|
-
|
|
48919
|
-
|
|
48920
|
-
|
|
48921
|
-
_context2.prev = 8;
|
|
48922
|
-
_context2.t0 = _context2["catch"](0);
|
|
48923
|
-
|
|
48924
|
-
case 10:
|
|
48925
|
-
case "end":
|
|
48926
|
-
return _context2.stop();
|
|
48927
|
-
}
|
|
48928
|
-
}
|
|
48929
|
-
}, _callee2, null, [[0, 8]]);
|
|
48930
|
-
}));
|
|
48931
|
-
return _tryUpdateBlock.apply(this, arguments);
|
|
48932
|
-
}
|
|
48874
|
+
_context.prev = 1;
|
|
48875
|
+
_context.t0 = parseInt;
|
|
48876
|
+
_context.next = 5;
|
|
48877
|
+
return sendAsync(provider, 'eth_blockNumber');
|
|
48933
48878
|
|
|
48934
|
-
|
|
48935
|
-
|
|
48936
|
-
|
|
48937
|
-
while (1) {
|
|
48938
|
-
switch (_context.prev = _context.next) {
|
|
48939
|
-
case 0:
|
|
48940
|
-
delete window.account;
|
|
48941
|
-
acc && (window.account = acc);
|
|
48942
|
-
_context.prev = 2;
|
|
48943
|
-
_context.t0 = acc && window.ganache;
|
|
48879
|
+
case 5:
|
|
48880
|
+
_context.t1 = _context.sent;
|
|
48881
|
+
currentBlockNumber = (0, _context.t0)(_context.t1);
|
|
48944
48882
|
|
|
48945
|
-
if (
|
|
48946
|
-
|
|
48947
|
-
break;
|
|
48883
|
+
if (force === true || currentBlockNumber - oldValue >= realBlockInterval) {
|
|
48884
|
+
setter(currentBlockNumber);
|
|
48948
48885
|
}
|
|
48949
48886
|
|
|
48950
|
-
_context.next =
|
|
48951
|
-
return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
|
|
48952
|
-
|
|
48953
|
-
case 7:
|
|
48954
|
-
_context.next = 11;
|
|
48887
|
+
_context.next = 12;
|
|
48955
48888
|
break;
|
|
48956
48889
|
|
|
48957
|
-
case
|
|
48958
|
-
_context.prev =
|
|
48959
|
-
_context.
|
|
48960
|
-
|
|
48961
|
-
case 11:
|
|
48962
|
-
setBlock(new Date().getTime());
|
|
48963
|
-
setTimeout(resetBlockInterval);
|
|
48890
|
+
case 10:
|
|
48891
|
+
_context.prev = 10;
|
|
48892
|
+
_context.t2 = _context["catch"](1);
|
|
48964
48893
|
|
|
48965
|
-
case
|
|
48894
|
+
case 12:
|
|
48966
48895
|
case "end":
|
|
48967
48896
|
return _context.stop();
|
|
48968
48897
|
}
|
|
48969
48898
|
}
|
|
48970
|
-
}, _callee, null, [[
|
|
48899
|
+
}, _callee, null, [[1, 10]]);
|
|
48971
48900
|
}));
|
|
48972
48901
|
|
|
48973
|
-
function
|
|
48974
|
-
return
|
|
48975
|
-
}
|
|
48976
|
-
|
|
48977
|
-
|
|
48978
|
-
}();
|
|
48979
|
-
|
|
48980
|
-
function resetBlockInterval() {
|
|
48902
|
+
return function (_x, _x2, _x3, _x4) {
|
|
48903
|
+
return _ref2.apply(this, arguments);
|
|
48904
|
+
};
|
|
48905
|
+
}(), [realBlockInterval]);
|
|
48906
|
+
var resetBlockInterval = useCallback(function () {
|
|
48981
48907
|
intervalId && clearInterval(intervalId);
|
|
48982
|
-
wallet
|
|
48983
|
-
|
|
48984
|
-
|
|
48985
|
-
|
|
48986
|
-
|
|
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, realBlockIntervalTimeout, intervalId]);
|
|
48917
|
+
useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum, dualProvider]);
|
|
48987
48918
|
useEffect(function () {
|
|
48988
48919
|
setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
|
|
48989
48920
|
setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3(wallet.ethereum)) || null);
|
|
@@ -48991,7 +48922,11 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
48991
48922
|
useEffect(function () {
|
|
48992
48923
|
setContracts({});
|
|
48993
48924
|
setGlobalContracts(globalContractNames.map(newContractByName));
|
|
48994
|
-
|
|
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);
|
|
48995
48930
|
resetBlockInterval();
|
|
48996
48931
|
}, [wallet && wallet.chainId]);
|
|
48997
48932
|
|
|
@@ -49047,6 +48982,53 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
49047
48982
|
return globalContracts[index];
|
|
49048
48983
|
};
|
|
49049
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
|
+
|
|
49050
49032
|
var value = _objectSpread2(_objectSpread2({
|
|
49051
49033
|
connectionStatus: connectionStatus,
|
|
49052
49034
|
setConnector: setConnector,
|
|
@@ -49065,7 +49047,10 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
|
49065
49047
|
web3: web3Instance,
|
|
49066
49048
|
block: block,
|
|
49067
49049
|
getGlobalContract: getGlobalContract,
|
|
49068
|
-
newContract: newContract
|
|
49050
|
+
newContract: newContract,
|
|
49051
|
+
dualChainId: dualChainId,
|
|
49052
|
+
dualBlock: dualBlock,
|
|
49053
|
+
dualProvider: dualProvider
|
|
49069
49054
|
}), wallet && wallet.error && {
|
|
49070
49055
|
errorMessage: wallet.error.message
|
|
49071
49056
|
});
|