@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.cjs.js
CHANGED
@@ -23758,46 +23758,107 @@ var URL_REGEXP = new RegExp('(http://www.|https://www.|http://|https://)?[a-z0-9
|
|
23758
23758
|
var solidityImportRule = new RegExp('import( )+"(\\d+)"( )*;', 'gs');
|
23759
23759
|
var pragmaSolidityRule = new RegExp('pragma( )+solidity( )*(\\^|>)\\d+.\\d+.\\d+;', 'gs');
|
23760
23760
|
|
23761
|
-
|
23762
|
-
var params = Array.prototype.slice.call(arguments).slice(2) || [];
|
23763
|
-
return new Promise( /*#__PURE__*/function () {
|
23764
|
-
var _ref = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ok, ko) {
|
23765
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
23766
|
-
while (1) {
|
23767
|
-
switch (_context.prev = _context.next) {
|
23768
|
-
case 0:
|
23769
|
-
_context.prev = 0;
|
23770
|
-
_context.next = 3;
|
23771
|
-
return (provider.sendAsync || provider.send).call(provider, {
|
23772
|
-
jsonrpc: '2.0',
|
23773
|
-
method: method,
|
23774
|
-
params: params,
|
23775
|
-
id: new Date().getTime()
|
23776
|
-
}, function (error, response) {
|
23777
|
-
return error || response && response.error ? ko(error || response && response.error) : ok(response && response.result);
|
23778
|
-
});
|
23761
|
+
var instrumentedProviders = {};
|
23779
23762
|
|
23780
|
-
|
23781
|
-
|
23763
|
+
function sendAsync(_x, _x2) {
|
23764
|
+
return _sendAsync.apply(this, arguments);
|
23765
|
+
}
|
23766
|
+
|
23767
|
+
function _sendAsync() {
|
23768
|
+
_sendAsync = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(inputProvider, method) {
|
23769
|
+
var provider,
|
23770
|
+
chainId,
|
23771
|
+
_ref,
|
23772
|
+
chainProvider,
|
23773
|
+
params,
|
23774
|
+
_args2 = arguments;
|
23775
|
+
|
23776
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
23777
|
+
while (1) {
|
23778
|
+
switch (_context2.prev = _context2.next) {
|
23779
|
+
case 0:
|
23780
|
+
provider = inputProvider;
|
23781
|
+
|
23782
|
+
if (!(method !== 'eth_chainId')) {
|
23783
|
+
_context2.next = 12;
|
23782
23784
|
break;
|
23785
|
+
}
|
23783
23786
|
|
23784
|
-
|
23785
|
-
|
23786
|
-
_context.t0 = _context["catch"](0);
|
23787
|
-
return _context.abrupt("return", ko(_context.t0));
|
23787
|
+
_context2.t0 = parseInt;
|
23788
|
+
_context2.t1 = provider.chainId;
|
23788
23789
|
|
23789
|
-
|
23790
|
-
|
23791
|
-
|
23792
|
-
|
23793
|
-
}
|
23794
|
-
}, _callee, null, [[0, 5]]);
|
23795
|
-
}));
|
23790
|
+
if (_context2.t1) {
|
23791
|
+
_context2.next = 8;
|
23792
|
+
break;
|
23793
|
+
}
|
23796
23794
|
|
23797
|
-
|
23798
|
-
|
23799
|
-
|
23800
|
-
|
23795
|
+
_context2.next = 7;
|
23796
|
+
return sendAsync(provider, 'eth_chainId');
|
23797
|
+
|
23798
|
+
case 7:
|
23799
|
+
_context2.t1 = _context2.sent;
|
23800
|
+
|
23801
|
+
case 8:
|
23802
|
+
_context2.t2 = _context2.t1;
|
23803
|
+
chainId = provider.chainId = (0, _context2.t0)(_context2.t2);
|
23804
|
+
_ref = sendAsync.context || {
|
23805
|
+
chainProvider: {}
|
23806
|
+
}, chainProvider = _ref.chainProvider;
|
23807
|
+
provider = chainId !== 1 && chainProvider[chainId] ? instrumentedProviders[chainId] = instrumentedProviders[chainId] || new Web3__default["default"].providers.HttpProvider(chainProvider[chainId]) : provider;
|
23808
|
+
|
23809
|
+
case 12:
|
23810
|
+
params = Array.prototype.slice.call(_args2).slice(2) || [];
|
23811
|
+
_context2.next = 15;
|
23812
|
+
return new Promise( /*#__PURE__*/function () {
|
23813
|
+
var _ref2 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ok, ko) {
|
23814
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
23815
|
+
while (1) {
|
23816
|
+
switch (_context.prev = _context.next) {
|
23817
|
+
case 0:
|
23818
|
+
_context.prev = 0;
|
23819
|
+
_context.next = 3;
|
23820
|
+
return (provider.request || provider.sendAsync || provider.send).call(provider, {
|
23821
|
+
jsonrpc: '2.0',
|
23822
|
+
method: method,
|
23823
|
+
params: params,
|
23824
|
+
id: new Date().getTime()
|
23825
|
+
}, function (error, response) {
|
23826
|
+
return error || response && response.error ? ko(error || response && response.error) : ok(response && response.result);
|
23827
|
+
});
|
23828
|
+
|
23829
|
+
case 3:
|
23830
|
+
_context.next = 8;
|
23831
|
+
break;
|
23832
|
+
|
23833
|
+
case 5:
|
23834
|
+
_context.prev = 5;
|
23835
|
+
_context.t0 = _context["catch"](0);
|
23836
|
+
return _context.abrupt("return", ko(_context.t0));
|
23837
|
+
|
23838
|
+
case 8:
|
23839
|
+
case "end":
|
23840
|
+
return _context.stop();
|
23841
|
+
}
|
23842
|
+
}
|
23843
|
+
}, _callee, null, [[0, 5]]);
|
23844
|
+
}));
|
23845
|
+
|
23846
|
+
return function (_x3, _x4) {
|
23847
|
+
return _ref2.apply(this, arguments);
|
23848
|
+
};
|
23849
|
+
}());
|
23850
|
+
|
23851
|
+
case 15:
|
23852
|
+
return _context2.abrupt("return", _context2.sent);
|
23853
|
+
|
23854
|
+
case 16:
|
23855
|
+
case "end":
|
23856
|
+
return _context2.stop();
|
23857
|
+
}
|
23858
|
+
}
|
23859
|
+
}, _callee2);
|
23860
|
+
}));
|
23861
|
+
return _sendAsync.apply(this, arguments);
|
23801
23862
|
}
|
23802
23863
|
|
23803
23864
|
/**
|
@@ -48790,6 +48851,7 @@ var useWeb3 = function useWeb3() {
|
|
48790
48851
|
};
|
48791
48852
|
var Web3ContextProvider = function Web3ContextProvider(props) {
|
48792
48853
|
var context = useEthosContext();
|
48854
|
+
sendAsync.context = sendAsync.context || context;
|
48793
48855
|
var connectors = context.useWalletSettings.reduce(function (acc, connector) {
|
48794
48856
|
return _objectSpread2(_objectSpread2({}, acc), _defineProperty({}, connector.id, _objectSpread2(_objectSpread2({}, connector.settings), {}, {
|
48795
48857
|
buttonText: connector.buttonText
|
@@ -48867,8 +48929,8 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48867
48929
|
|
48868
48930
|
var _useState23 = React.useState(null),
|
48869
48931
|
_useState24 = _slicedToArray(_useState23, 2),
|
48870
|
-
|
48871
|
-
|
48932
|
+
dualChainWeb3 = _useState24[0],
|
48933
|
+
setDualChainWeb3 = _useState24[1];
|
48872
48934
|
|
48873
48935
|
React.useEffect(function () {
|
48874
48936
|
setIpfsHttpClient(ipfsHttpClient.create(context.ipfsHost));
|
@@ -48920,14 +48982,14 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48920
48982
|
return _ref2.apply(this, arguments);
|
48921
48983
|
};
|
48922
48984
|
}(), [realBlockInterval]);
|
48923
|
-
var
|
48924
|
-
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(
|
48985
|
+
var tryUpdateDualChainBlock = React.useCallback( /*#__PURE__*/function () {
|
48986
|
+
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(web3, oldValue, setter, force) {
|
48925
48987
|
var currentBlockNumber;
|
48926
48988
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
48927
48989
|
while (1) {
|
48928
48990
|
switch (_context2.prev = _context2.next) {
|
48929
48991
|
case 0:
|
48930
|
-
if (
|
48992
|
+
if (web3 !== null && web3 !== void 0 && web3.currentProvider) {
|
48931
48993
|
_context2.next = 2;
|
48932
48994
|
break;
|
48933
48995
|
}
|
@@ -48937,7 +48999,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48937
48999
|
case 2:
|
48938
49000
|
_context2.prev = 2;
|
48939
49001
|
_context2.next = 5;
|
48940
|
-
return sendAsync(
|
49002
|
+
return sendAsync(web3.currentProvider, 'eth_call', {
|
48941
49003
|
to: '0x4200000000000000000000000000000000000013',
|
48942
49004
|
data: web3Utils__default["default"].sha3('getL1BlockNumber()').substring(0, 10)
|
48943
49005
|
});
|
@@ -48973,16 +49035,16 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48973
49035
|
var resetBlockInterval = React.useCallback(function () {
|
48974
49036
|
intervalId && clearInterval(intervalId);
|
48975
49037
|
tryUpdateBlock(wallet === null || wallet === void 0 ? void 0 : wallet.ethereum, block, setBlock, true);
|
48976
|
-
|
49038
|
+
tryUpdateDualChainBlock(dualChainWeb3 && (wallet === null || wallet === void 0 ? void 0 : wallet.ethereum), dualBlock, setDualBlock, true);
|
48977
49039
|
|
48978
|
-
if (wallet && wallet.ethereum ||
|
49040
|
+
if (wallet && wallet.ethereum || dualChainWeb3) {
|
48979
49041
|
setIntervalId(setInterval(function () {
|
48980
49042
|
wallet && wallet.ethereum && tryUpdateBlock(wallet.ethereum, block, setBlock);
|
48981
|
-
|
49043
|
+
dualChainWeb3 && wallet && wallet.ethereum && tryUpdateDualChainBlock(wallet.ethereum, dualBlock, setDualBlock);
|
48982
49044
|
}, realBlockIntervalTimeout));
|
48983
49045
|
}
|
48984
|
-
}, [wallet,
|
48985
|
-
React.useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum,
|
49046
|
+
}, [wallet, dualChainWeb3, realBlockIntervalTimeout, intervalId]);
|
49047
|
+
React.useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum, dualChainWeb3]);
|
48986
49048
|
React.useEffect(function () {
|
48987
49049
|
setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
|
48988
49050
|
setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3__default["default"](wallet.ethereum)) || null);
|
@@ -48994,7 +49056,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48994
49056
|
setChainId(actualChainId);
|
48995
49057
|
var actualDualChainId = actualChainId && context.dualChainId[actualChainId] || null;
|
48996
49058
|
setDualChainId(actualDualChainId);
|
48997
|
-
|
49059
|
+
setDualChainWeb3(actualDualChainId && new Web3__default["default"](context.chainProvider[actualDualChainId]) || null);
|
48998
49060
|
resetBlockInterval();
|
48999
49061
|
}, [wallet && wallet.chainId]);
|
49000
49062
|
|
@@ -49050,6 +49112,11 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49050
49112
|
return globalContracts[index];
|
49051
49113
|
};
|
49052
49114
|
|
49115
|
+
React.useEffect(function () {
|
49116
|
+
chainId && web3Instance && web3Instance.currentProvider && !web3Instance.currentProvider.chainId && (web3Instance.currentProvider.chainId = chainId);
|
49117
|
+
dualChainId && dualChainWeb3 && dualChainWeb3.currentProvider && !dualChainWeb3.currentProvider.chainId && (dualChainWeb3.currentProvider.chainId = dualChainId);
|
49118
|
+
}, [chainId, web3Instance, dualChainId, dualChainWeb3]);
|
49119
|
+
|
49053
49120
|
window.setAccount = /*#__PURE__*/function () {
|
49054
49121
|
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(acc) {
|
49055
49122
|
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
@@ -49118,7 +49185,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49118
49185
|
newContract: newContract,
|
49119
49186
|
dualChainId: dualChainId,
|
49120
49187
|
dualBlock: dualBlock,
|
49121
|
-
|
49188
|
+
dualChainWeb3: dualChainWeb3
|
49122
49189
|
}), wallet && wallet.error && {
|
49123
49190
|
errorMessage: wallet.error.message
|
49124
49191
|
});
|