@ethereansos/interfaces-core 0.4.118 → 0.4.121
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 +176 -58
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +176 -58
- 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
|
-
_context.prev = 5;
|
23786
|
-
_context.t0 = _context["catch"](0);
|
23787
|
-
return _context.abrupt("return", ko(_context.t0));
|
23787
|
+
_context2.t0 = provider.chainId;
|
23788
23788
|
|
23789
|
-
|
23790
|
-
|
23791
|
-
|
23792
|
-
|
23793
|
-
}
|
23794
|
-
}, _callee, null, [[0, 5]]);
|
23795
|
-
}));
|
23789
|
+
if (_context2.t0) {
|
23790
|
+
_context2.next = 9;
|
23791
|
+
break;
|
23792
|
+
}
|
23796
23793
|
|
23797
|
-
|
23798
|
-
|
23799
|
-
|
23800
|
-
|
23794
|
+
_context2.t1 = parseInt;
|
23795
|
+
_context2.next = 7;
|
23796
|
+
return sendAsync(provider, 'eth_chainId');
|
23797
|
+
|
23798
|
+
case 7:
|
23799
|
+
_context2.t2 = _context2.sent;
|
23800
|
+
_context2.t0 = (0, _context2.t1)(_context2.t2);
|
23801
|
+
|
23802
|
+
case 9:
|
23803
|
+
chainId = provider.chainId = _context2.t0;
|
23804
|
+
_ref = sendAsync.context || {
|
23805
|
+
chainProvider: {}
|
23806
|
+
}, chainProvider = _ref.chainProvider;
|
23807
|
+
provider = 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
|
/**
|
@@ -48776,6 +48837,7 @@ var useEthosContext = function useEthosContext() {
|
|
48776
48837
|
return context;
|
48777
48838
|
};
|
48778
48839
|
|
48840
|
+
var abi$8 = new AbiCoder();
|
48779
48841
|
var Web3Context = /*#__PURE__*/React__default["default"].createContext('web3');
|
48780
48842
|
var DEFAULT_BLOCK_INTERVAL = 15;
|
48781
48843
|
var DEFAULT_BLOCK_INTERVAL_TIMEOUT = 40000;
|
@@ -48789,6 +48851,7 @@ var useWeb3 = function useWeb3() {
|
|
48789
48851
|
};
|
48790
48852
|
var Web3ContextProvider = function Web3ContextProvider(props) {
|
48791
48853
|
var context = useEthosContext();
|
48854
|
+
sendAsync.context = sendAsync.context || context;
|
48792
48855
|
var connectors = context.useWalletSettings.reduce(function (acc, connector) {
|
48793
48856
|
return _objectSpread2(_objectSpread2({}, acc), _defineProperty({}, connector.id, _objectSpread2(_objectSpread2({}, connector.settings), {}, {
|
48794
48857
|
buttonText: connector.buttonText
|
@@ -48866,8 +48929,8 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48866
48929
|
|
48867
48930
|
var _useState23 = React.useState(null),
|
48868
48931
|
_useState24 = _slicedToArray(_useState23, 2),
|
48869
|
-
|
48870
|
-
|
48932
|
+
dualChainWeb3 = _useState24[0],
|
48933
|
+
setDualChainWeb3 = _useState24[1];
|
48871
48934
|
|
48872
48935
|
React.useEffect(function () {
|
48873
48936
|
setIpfsHttpClient(ipfsHttpClient.create(context.ipfsHost));
|
@@ -48919,19 +48982,69 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48919
48982
|
return _ref2.apply(this, arguments);
|
48920
48983
|
};
|
48921
48984
|
}(), [realBlockInterval]);
|
48985
|
+
var tryUpdateDualChainBlock = React.useCallback( /*#__PURE__*/function () {
|
48986
|
+
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(web3, oldValue, setter, force) {
|
48987
|
+
var currentBlockNumber;
|
48988
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
48989
|
+
while (1) {
|
48990
|
+
switch (_context2.prev = _context2.next) {
|
48991
|
+
case 0:
|
48992
|
+
if (web3 !== null && web3 !== void 0 && web3.currentProvider) {
|
48993
|
+
_context2.next = 2;
|
48994
|
+
break;
|
48995
|
+
}
|
48996
|
+
|
48997
|
+
return _context2.abrupt("return", setter(0));
|
48998
|
+
|
48999
|
+
case 2:
|
49000
|
+
_context2.prev = 2;
|
49001
|
+
_context2.next = 5;
|
49002
|
+
return sendAsync(web3.currentProvider, 'eth_call', {
|
49003
|
+
to: '0x4200000000000000000000000000000000000013',
|
49004
|
+
data: web3Utils__default["default"].sha3('getL1BlockNumber()').substring(0, 10)
|
49005
|
+
});
|
49006
|
+
|
49007
|
+
case 5:
|
49008
|
+
currentBlockNumber = _context2.sent;
|
49009
|
+
currentBlockNumber = abi$8.decode(['uint256'], currentBlockNumber)[0].toString();
|
49010
|
+
currentBlockNumber = parseInt(currentBlockNumber);
|
49011
|
+
|
49012
|
+
if (force === true || currentBlockNumber - oldValue >= realBlockInterval) {
|
49013
|
+
setter(currentBlockNumber);
|
49014
|
+
}
|
49015
|
+
|
49016
|
+
_context2.next = 13;
|
49017
|
+
break;
|
49018
|
+
|
49019
|
+
case 11:
|
49020
|
+
_context2.prev = 11;
|
49021
|
+
_context2.t0 = _context2["catch"](2);
|
49022
|
+
|
49023
|
+
case 13:
|
49024
|
+
case "end":
|
49025
|
+
return _context2.stop();
|
49026
|
+
}
|
49027
|
+
}
|
49028
|
+
}, _callee2, null, [[2, 11]]);
|
49029
|
+
}));
|
49030
|
+
|
49031
|
+
return function (_x5, _x6, _x7, _x8) {
|
49032
|
+
return _ref3.apply(this, arguments);
|
49033
|
+
};
|
49034
|
+
}(), [realBlockInterval]);
|
48922
49035
|
var resetBlockInterval = React.useCallback(function () {
|
48923
49036
|
intervalId && clearInterval(intervalId);
|
48924
49037
|
tryUpdateBlock(wallet === null || wallet === void 0 ? void 0 : wallet.ethereum, block, setBlock, true);
|
48925
|
-
|
49038
|
+
tryUpdateDualChainBlock(dualChainWeb3 && (wallet === null || wallet === void 0 ? void 0 : wallet.ethereum), dualBlock, setDualBlock, true);
|
48926
49039
|
|
48927
|
-
if (wallet && wallet.ethereum ||
|
49040
|
+
if (wallet && wallet.ethereum || dualChainWeb3) {
|
48928
49041
|
setIntervalId(setInterval(function () {
|
48929
49042
|
wallet && wallet.ethereum && tryUpdateBlock(wallet.ethereum, block, setBlock);
|
48930
|
-
|
49043
|
+
dualChainWeb3 && wallet && wallet.ethereum && tryUpdateDualChainBlock(wallet.ethereum, dualBlock, setDualBlock);
|
48931
49044
|
}, realBlockIntervalTimeout));
|
48932
49045
|
}
|
48933
|
-
}, [wallet,
|
48934
|
-
React.useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum,
|
49046
|
+
}, [wallet, dualChainWeb3, realBlockIntervalTimeout, intervalId]);
|
49047
|
+
React.useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum, dualChainWeb3]);
|
48935
49048
|
React.useEffect(function () {
|
48936
49049
|
setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
|
48937
49050
|
setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3__default["default"](wallet.ethereum)) || null);
|
@@ -48943,7 +49056,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48943
49056
|
setChainId(actualChainId);
|
48944
49057
|
var actualDualChainId = actualChainId && context.dualChainId[actualChainId] || null;
|
48945
49058
|
setDualChainId(actualDualChainId);
|
48946
|
-
|
49059
|
+
setDualChainWeb3(actualDualChainId && new Web3__default["default"](context.chainProvider[actualDualChainId]) || null);
|
48947
49060
|
resetBlockInterval();
|
48948
49061
|
}, [wallet && wallet.chainId]);
|
48949
49062
|
|
@@ -48999,32 +49112,37 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48999
49112
|
return globalContracts[index];
|
49000
49113
|
};
|
49001
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
|
+
|
49002
49120
|
window.setAccount = /*#__PURE__*/function () {
|
49003
|
-
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function
|
49004
|
-
return regeneratorRuntime.wrap(function
|
49121
|
+
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(acc) {
|
49122
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
49005
49123
|
while (1) {
|
49006
|
-
switch (
|
49124
|
+
switch (_context3.prev = _context3.next) {
|
49007
49125
|
case 0:
|
49008
49126
|
delete window.account;
|
49009
49127
|
acc && (window.account = acc);
|
49010
|
-
|
49011
|
-
|
49128
|
+
_context3.prev = 2;
|
49129
|
+
_context3.t0 = acc && window.ganache;
|
49012
49130
|
|
49013
|
-
if (!
|
49014
|
-
|
49131
|
+
if (!_context3.t0) {
|
49132
|
+
_context3.next = 7;
|
49015
49133
|
break;
|
49016
49134
|
}
|
49017
49135
|
|
49018
|
-
|
49136
|
+
_context3.next = 7;
|
49019
49137
|
return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
|
49020
49138
|
|
49021
49139
|
case 7:
|
49022
|
-
|
49140
|
+
_context3.next = 11;
|
49023
49141
|
break;
|
49024
49142
|
|
49025
49143
|
case 9:
|
49026
|
-
|
49027
|
-
|
49144
|
+
_context3.prev = 9;
|
49145
|
+
_context3.t1 = _context3["catch"](2);
|
49028
49146
|
|
49029
49147
|
case 11:
|
49030
49148
|
setBlock(new Date().getTime());
|
@@ -49033,13 +49151,13 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49033
49151
|
|
49034
49152
|
case 14:
|
49035
49153
|
case "end":
|
49036
|
-
return
|
49154
|
+
return _context3.stop();
|
49037
49155
|
}
|
49038
49156
|
}
|
49039
|
-
},
|
49157
|
+
}, _callee3, null, [[2, 9]]);
|
49040
49158
|
}));
|
49041
49159
|
|
49042
|
-
function setAccount(
|
49160
|
+
function setAccount(_x9) {
|
49043
49161
|
return _setAccount.apply(this, arguments);
|
49044
49162
|
}
|
49045
49163
|
|
@@ -49067,7 +49185,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49067
49185
|
newContract: newContract,
|
49068
49186
|
dualChainId: dualChainId,
|
49069
49187
|
dualBlock: dualBlock,
|
49070
|
-
|
49188
|
+
dualChainWeb3: dualChainWeb3
|
49071
49189
|
}), wallet && wallet.error && {
|
49072
49190
|
errorMessage: wallet.error.message
|
49073
49191
|
});
|