@ethereansos/interfaces-core 0.4.119 → 0.4.122
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs.js +115 -48
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +115 -48
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -23746,46 +23746,107 @@ var URL_REGEXP = new RegExp('(http://www.|https://www.|http://|https://)?[a-z0-9
|
|
23746
23746
|
var solidityImportRule = new RegExp('import( )+"(\\d+)"( )*;', 'gs');
|
23747
23747
|
var pragmaSolidityRule = new RegExp('pragma( )+solidity( )*(\\^|>)\\d+.\\d+.\\d+;', 'gs');
|
23748
23748
|
|
23749
|
-
|
23750
|
-
var params = Array.prototype.slice.call(arguments).slice(2) || [];
|
23751
|
-
return new Promise( /*#__PURE__*/function () {
|
23752
|
-
var _ref = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ok, ko) {
|
23753
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
23754
|
-
while (1) {
|
23755
|
-
switch (_context.prev = _context.next) {
|
23756
|
-
case 0:
|
23757
|
-
_context.prev = 0;
|
23758
|
-
_context.next = 3;
|
23759
|
-
return (provider.sendAsync || provider.send).call(provider, {
|
23760
|
-
jsonrpc: '2.0',
|
23761
|
-
method: method,
|
23762
|
-
params: params,
|
23763
|
-
id: new Date().getTime()
|
23764
|
-
}, function (error, response) {
|
23765
|
-
return error || response && response.error ? ko(error || response && response.error) : ok(response && response.result);
|
23766
|
-
});
|
23749
|
+
var instrumentedProviders = {};
|
23767
23750
|
|
23768
|
-
|
23769
|
-
|
23751
|
+
function sendAsync(_x, _x2) {
|
23752
|
+
return _sendAsync.apply(this, arguments);
|
23753
|
+
}
|
23754
|
+
|
23755
|
+
function _sendAsync() {
|
23756
|
+
_sendAsync = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(inputProvider, method) {
|
23757
|
+
var provider,
|
23758
|
+
chainId,
|
23759
|
+
_ref,
|
23760
|
+
chainProvider,
|
23761
|
+
params,
|
23762
|
+
_args2 = arguments;
|
23763
|
+
|
23764
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
23765
|
+
while (1) {
|
23766
|
+
switch (_context2.prev = _context2.next) {
|
23767
|
+
case 0:
|
23768
|
+
provider = inputProvider;
|
23769
|
+
|
23770
|
+
if (!(method !== 'eth_chainId')) {
|
23771
|
+
_context2.next = 12;
|
23770
23772
|
break;
|
23773
|
+
}
|
23771
23774
|
|
23772
|
-
|
23773
|
-
|
23774
|
-
_context.t0 = _context["catch"](0);
|
23775
|
-
return _context.abrupt("return", ko(_context.t0));
|
23775
|
+
_context2.t0 = parseInt;
|
23776
|
+
_context2.t1 = provider.chainId;
|
23776
23777
|
|
23777
|
-
|
23778
|
-
|
23779
|
-
|
23780
|
-
|
23781
|
-
}
|
23782
|
-
}, _callee, null, [[0, 5]]);
|
23783
|
-
}));
|
23778
|
+
if (_context2.t1) {
|
23779
|
+
_context2.next = 8;
|
23780
|
+
break;
|
23781
|
+
}
|
23784
23782
|
|
23785
|
-
|
23786
|
-
|
23787
|
-
|
23788
|
-
|
23783
|
+
_context2.next = 7;
|
23784
|
+
return sendAsync(provider, 'eth_chainId');
|
23785
|
+
|
23786
|
+
case 7:
|
23787
|
+
_context2.t1 = _context2.sent;
|
23788
|
+
|
23789
|
+
case 8:
|
23790
|
+
_context2.t2 = _context2.t1;
|
23791
|
+
chainId = provider.chainId = (0, _context2.t0)(_context2.t2);
|
23792
|
+
_ref = sendAsync.context || {
|
23793
|
+
chainProvider: {}
|
23794
|
+
}, chainProvider = _ref.chainProvider;
|
23795
|
+
provider = chainId !== 1 && chainProvider[chainId] ? instrumentedProviders[chainId] = instrumentedProviders[chainId] || new Web3.providers.HttpProvider(chainProvider[chainId]) : provider;
|
23796
|
+
|
23797
|
+
case 12:
|
23798
|
+
params = Array.prototype.slice.call(_args2).slice(2) || [];
|
23799
|
+
_context2.next = 15;
|
23800
|
+
return new Promise( /*#__PURE__*/function () {
|
23801
|
+
var _ref2 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ok, ko) {
|
23802
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
23803
|
+
while (1) {
|
23804
|
+
switch (_context.prev = _context.next) {
|
23805
|
+
case 0:
|
23806
|
+
_context.prev = 0;
|
23807
|
+
_context.next = 3;
|
23808
|
+
return (provider.request || provider.sendAsync || provider.send).call(provider, {
|
23809
|
+
jsonrpc: '2.0',
|
23810
|
+
method: method,
|
23811
|
+
params: params,
|
23812
|
+
id: new Date().getTime()
|
23813
|
+
}, function (error, response) {
|
23814
|
+
return error || response && response.error ? ko(error || response && response.error) : ok(response && response.result);
|
23815
|
+
});
|
23816
|
+
|
23817
|
+
case 3:
|
23818
|
+
_context.next = 8;
|
23819
|
+
break;
|
23820
|
+
|
23821
|
+
case 5:
|
23822
|
+
_context.prev = 5;
|
23823
|
+
_context.t0 = _context["catch"](0);
|
23824
|
+
return _context.abrupt("return", ko(_context.t0));
|
23825
|
+
|
23826
|
+
case 8:
|
23827
|
+
case "end":
|
23828
|
+
return _context.stop();
|
23829
|
+
}
|
23830
|
+
}
|
23831
|
+
}, _callee, null, [[0, 5]]);
|
23832
|
+
}));
|
23833
|
+
|
23834
|
+
return function (_x3, _x4) {
|
23835
|
+
return _ref2.apply(this, arguments);
|
23836
|
+
};
|
23837
|
+
}());
|
23838
|
+
|
23839
|
+
case 15:
|
23840
|
+
return _context2.abrupt("return", _context2.sent);
|
23841
|
+
|
23842
|
+
case 16:
|
23843
|
+
case "end":
|
23844
|
+
return _context2.stop();
|
23845
|
+
}
|
23846
|
+
}
|
23847
|
+
}, _callee2);
|
23848
|
+
}));
|
23849
|
+
return _sendAsync.apply(this, arguments);
|
23789
23850
|
}
|
23790
23851
|
|
23791
23852
|
/**
|
@@ -48778,6 +48839,7 @@ var useWeb3 = function useWeb3() {
|
|
48778
48839
|
};
|
48779
48840
|
var Web3ContextProvider = function Web3ContextProvider(props) {
|
48780
48841
|
var context = useEthosContext();
|
48842
|
+
sendAsync.context = sendAsync.context || context;
|
48781
48843
|
var connectors = context.useWalletSettings.reduce(function (acc, connector) {
|
48782
48844
|
return _objectSpread2(_objectSpread2({}, acc), _defineProperty({}, connector.id, _objectSpread2(_objectSpread2({}, connector.settings), {}, {
|
48783
48845
|
buttonText: connector.buttonText
|
@@ -48855,8 +48917,8 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48855
48917
|
|
48856
48918
|
var _useState23 = useState(null),
|
48857
48919
|
_useState24 = _slicedToArray(_useState23, 2),
|
48858
|
-
|
48859
|
-
|
48920
|
+
dualChainWeb3 = _useState24[0],
|
48921
|
+
setDualChainWeb3 = _useState24[1];
|
48860
48922
|
|
48861
48923
|
useEffect(function () {
|
48862
48924
|
setIpfsHttpClient(create(context.ipfsHost));
|
@@ -48908,14 +48970,14 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48908
48970
|
return _ref2.apply(this, arguments);
|
48909
48971
|
};
|
48910
48972
|
}(), [realBlockInterval]);
|
48911
|
-
var
|
48912
|
-
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(
|
48973
|
+
var tryUpdateDualChainBlock = useCallback( /*#__PURE__*/function () {
|
48974
|
+
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(web3, oldValue, setter, force) {
|
48913
48975
|
var currentBlockNumber;
|
48914
48976
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
48915
48977
|
while (1) {
|
48916
48978
|
switch (_context2.prev = _context2.next) {
|
48917
48979
|
case 0:
|
48918
|
-
if (
|
48980
|
+
if (web3 !== null && web3 !== void 0 && web3.currentProvider) {
|
48919
48981
|
_context2.next = 2;
|
48920
48982
|
break;
|
48921
48983
|
}
|
@@ -48925,7 +48987,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48925
48987
|
case 2:
|
48926
48988
|
_context2.prev = 2;
|
48927
48989
|
_context2.next = 5;
|
48928
|
-
return sendAsync(
|
48990
|
+
return sendAsync(web3.currentProvider, 'eth_call', {
|
48929
48991
|
to: '0x4200000000000000000000000000000000000013',
|
48930
48992
|
data: web3Utils.sha3('getL1BlockNumber()').substring(0, 10)
|
48931
48993
|
});
|
@@ -48961,16 +49023,16 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48961
49023
|
var resetBlockInterval = useCallback(function () {
|
48962
49024
|
intervalId && clearInterval(intervalId);
|
48963
49025
|
tryUpdateBlock(wallet === null || wallet === void 0 ? void 0 : wallet.ethereum, block, setBlock, true);
|
48964
|
-
|
49026
|
+
tryUpdateDualChainBlock(dualChainWeb3 && (wallet === null || wallet === void 0 ? void 0 : wallet.ethereum), dualBlock, setDualBlock, true);
|
48965
49027
|
|
48966
|
-
if (wallet && wallet.ethereum ||
|
49028
|
+
if (wallet && wallet.ethereum || dualChainWeb3) {
|
48967
49029
|
setIntervalId(setInterval(function () {
|
48968
49030
|
wallet && wallet.ethereum && tryUpdateBlock(wallet.ethereum, block, setBlock);
|
48969
|
-
|
49031
|
+
dualChainWeb3 && wallet && wallet.ethereum && tryUpdateDualChainBlock(wallet.ethereum, dualBlock, setDualBlock);
|
48970
49032
|
}, realBlockIntervalTimeout));
|
48971
49033
|
}
|
48972
|
-
}, [wallet,
|
48973
|
-
useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum,
|
49034
|
+
}, [wallet, dualChainWeb3, realBlockIntervalTimeout, intervalId]);
|
49035
|
+
useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum, dualChainWeb3]);
|
48974
49036
|
useEffect(function () {
|
48975
49037
|
setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
|
48976
49038
|
setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3(wallet.ethereum)) || null);
|
@@ -48982,7 +49044,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48982
49044
|
setChainId(actualChainId);
|
48983
49045
|
var actualDualChainId = actualChainId && context.dualChainId[actualChainId] || null;
|
48984
49046
|
setDualChainId(actualDualChainId);
|
48985
|
-
|
49047
|
+
setDualChainWeb3(actualDualChainId && new Web3(context.chainProvider[actualDualChainId]) || null);
|
48986
49048
|
resetBlockInterval();
|
48987
49049
|
}, [wallet && wallet.chainId]);
|
48988
49050
|
|
@@ -49038,6 +49100,11 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49038
49100
|
return globalContracts[index];
|
49039
49101
|
};
|
49040
49102
|
|
49103
|
+
useEffect(function () {
|
49104
|
+
chainId && web3Instance && web3Instance.currentProvider && !web3Instance.currentProvider.chainId && (web3Instance.currentProvider.chainId = chainId);
|
49105
|
+
dualChainId && dualChainWeb3 && dualChainWeb3.currentProvider && !dualChainWeb3.currentProvider.chainId && (dualChainWeb3.currentProvider.chainId = dualChainId);
|
49106
|
+
}, [chainId, web3Instance, dualChainId, dualChainWeb3]);
|
49107
|
+
|
49041
49108
|
window.setAccount = /*#__PURE__*/function () {
|
49042
49109
|
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(acc) {
|
49043
49110
|
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
@@ -49106,7 +49173,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49106
49173
|
newContract: newContract,
|
49107
49174
|
dualChainId: dualChainId,
|
49108
49175
|
dualBlock: dualBlock,
|
49109
|
-
|
49176
|
+
dualChainWeb3: dualChainWeb3
|
49110
49177
|
}), wallet && wallet.error && {
|
49111
49178
|
errorMessage: wallet.error.message
|
49112
49179
|
});
|