@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.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
|
-
_context.prev = 5;
|
23774
|
-
_context.t0 = _context["catch"](0);
|
23775
|
-
return _context.abrupt("return", ko(_context.t0));
|
23775
|
+
_context2.t0 = provider.chainId;
|
23776
23776
|
|
23777
|
-
|
23778
|
-
|
23779
|
-
|
23780
|
-
|
23781
|
-
}
|
23782
|
-
}, _callee, null, [[0, 5]]);
|
23783
|
-
}));
|
23777
|
+
if (_context2.t0) {
|
23778
|
+
_context2.next = 9;
|
23779
|
+
break;
|
23780
|
+
}
|
23784
23781
|
|
23785
|
-
|
23786
|
-
|
23787
|
-
|
23788
|
-
|
23782
|
+
_context2.t1 = parseInt;
|
23783
|
+
_context2.next = 7;
|
23784
|
+
return sendAsync(provider, 'eth_chainId');
|
23785
|
+
|
23786
|
+
case 7:
|
23787
|
+
_context2.t2 = _context2.sent;
|
23788
|
+
_context2.t0 = (0, _context2.t1)(_context2.t2);
|
23789
|
+
|
23790
|
+
case 9:
|
23791
|
+
chainId = provider.chainId = _context2.t0;
|
23792
|
+
_ref = sendAsync.context || {
|
23793
|
+
chainProvider: {}
|
23794
|
+
}, chainProvider = _ref.chainProvider;
|
23795
|
+
provider = 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
|
/**
|
@@ -48764,6 +48825,7 @@ var useEthosContext = function useEthosContext() {
|
|
48764
48825
|
return context;
|
48765
48826
|
};
|
48766
48827
|
|
48828
|
+
var abi$8 = new AbiCoder();
|
48767
48829
|
var Web3Context = /*#__PURE__*/React.createContext('web3');
|
48768
48830
|
var DEFAULT_BLOCK_INTERVAL = 15;
|
48769
48831
|
var DEFAULT_BLOCK_INTERVAL_TIMEOUT = 40000;
|
@@ -48777,6 +48839,7 @@ var useWeb3 = function useWeb3() {
|
|
48777
48839
|
};
|
48778
48840
|
var Web3ContextProvider = function Web3ContextProvider(props) {
|
48779
48841
|
var context = useEthosContext();
|
48842
|
+
sendAsync.context = sendAsync.context || context;
|
48780
48843
|
var connectors = context.useWalletSettings.reduce(function (acc, connector) {
|
48781
48844
|
return _objectSpread2(_objectSpread2({}, acc), _defineProperty({}, connector.id, _objectSpread2(_objectSpread2({}, connector.settings), {}, {
|
48782
48845
|
buttonText: connector.buttonText
|
@@ -48854,8 +48917,8 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48854
48917
|
|
48855
48918
|
var _useState23 = useState(null),
|
48856
48919
|
_useState24 = _slicedToArray(_useState23, 2),
|
48857
|
-
|
48858
|
-
|
48920
|
+
dualChainWeb3 = _useState24[0],
|
48921
|
+
setDualChainWeb3 = _useState24[1];
|
48859
48922
|
|
48860
48923
|
useEffect(function () {
|
48861
48924
|
setIpfsHttpClient(create(context.ipfsHost));
|
@@ -48907,19 +48970,69 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48907
48970
|
return _ref2.apply(this, arguments);
|
48908
48971
|
};
|
48909
48972
|
}(), [realBlockInterval]);
|
48973
|
+
var tryUpdateDualChainBlock = useCallback( /*#__PURE__*/function () {
|
48974
|
+
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(web3, oldValue, setter, force) {
|
48975
|
+
var currentBlockNumber;
|
48976
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
48977
|
+
while (1) {
|
48978
|
+
switch (_context2.prev = _context2.next) {
|
48979
|
+
case 0:
|
48980
|
+
if (web3 !== null && web3 !== void 0 && web3.currentProvider) {
|
48981
|
+
_context2.next = 2;
|
48982
|
+
break;
|
48983
|
+
}
|
48984
|
+
|
48985
|
+
return _context2.abrupt("return", setter(0));
|
48986
|
+
|
48987
|
+
case 2:
|
48988
|
+
_context2.prev = 2;
|
48989
|
+
_context2.next = 5;
|
48990
|
+
return sendAsync(web3.currentProvider, 'eth_call', {
|
48991
|
+
to: '0x4200000000000000000000000000000000000013',
|
48992
|
+
data: web3Utils.sha3('getL1BlockNumber()').substring(0, 10)
|
48993
|
+
});
|
48994
|
+
|
48995
|
+
case 5:
|
48996
|
+
currentBlockNumber = _context2.sent;
|
48997
|
+
currentBlockNumber = abi$8.decode(['uint256'], currentBlockNumber)[0].toString();
|
48998
|
+
currentBlockNumber = parseInt(currentBlockNumber);
|
48999
|
+
|
49000
|
+
if (force === true || currentBlockNumber - oldValue >= realBlockInterval) {
|
49001
|
+
setter(currentBlockNumber);
|
49002
|
+
}
|
49003
|
+
|
49004
|
+
_context2.next = 13;
|
49005
|
+
break;
|
49006
|
+
|
49007
|
+
case 11:
|
49008
|
+
_context2.prev = 11;
|
49009
|
+
_context2.t0 = _context2["catch"](2);
|
49010
|
+
|
49011
|
+
case 13:
|
49012
|
+
case "end":
|
49013
|
+
return _context2.stop();
|
49014
|
+
}
|
49015
|
+
}
|
49016
|
+
}, _callee2, null, [[2, 11]]);
|
49017
|
+
}));
|
49018
|
+
|
49019
|
+
return function (_x5, _x6, _x7, _x8) {
|
49020
|
+
return _ref3.apply(this, arguments);
|
49021
|
+
};
|
49022
|
+
}(), [realBlockInterval]);
|
48910
49023
|
var resetBlockInterval = useCallback(function () {
|
48911
49024
|
intervalId && clearInterval(intervalId);
|
48912
49025
|
tryUpdateBlock(wallet === null || wallet === void 0 ? void 0 : wallet.ethereum, block, setBlock, true);
|
48913
|
-
|
49026
|
+
tryUpdateDualChainBlock(dualChainWeb3 && (wallet === null || wallet === void 0 ? void 0 : wallet.ethereum), dualBlock, setDualBlock, true);
|
48914
49027
|
|
48915
|
-
if (wallet && wallet.ethereum ||
|
49028
|
+
if (wallet && wallet.ethereum || dualChainWeb3) {
|
48916
49029
|
setIntervalId(setInterval(function () {
|
48917
49030
|
wallet && wallet.ethereum && tryUpdateBlock(wallet.ethereum, block, setBlock);
|
48918
|
-
|
49031
|
+
dualChainWeb3 && wallet && wallet.ethereum && tryUpdateDualChainBlock(wallet.ethereum, dualBlock, setDualBlock);
|
48919
49032
|
}, realBlockIntervalTimeout));
|
48920
49033
|
}
|
48921
|
-
}, [wallet,
|
48922
|
-
useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum,
|
49034
|
+
}, [wallet, dualChainWeb3, realBlockIntervalTimeout, intervalId]);
|
49035
|
+
useEffect(resetBlockInterval, [realBlockInterval, realBlockIntervalTimeout, wallet && wallet.ethereum, dualChainWeb3]);
|
48923
49036
|
useEffect(function () {
|
48924
49037
|
setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus === CONNECTING ? CONNECTING : NOT_CONNECTED);
|
48925
49038
|
setWeb3Instance(wallet && wallet.ethereum && (web3Instance || new Web3(wallet.ethereum)) || null);
|
@@ -48931,7 +49044,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48931
49044
|
setChainId(actualChainId);
|
48932
49045
|
var actualDualChainId = actualChainId && context.dualChainId[actualChainId] || null;
|
48933
49046
|
setDualChainId(actualDualChainId);
|
48934
|
-
|
49047
|
+
setDualChainWeb3(actualDualChainId && new Web3(context.chainProvider[actualDualChainId]) || null);
|
48935
49048
|
resetBlockInterval();
|
48936
49049
|
}, [wallet && wallet.chainId]);
|
48937
49050
|
|
@@ -48987,32 +49100,37 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48987
49100
|
return globalContracts[index];
|
48988
49101
|
};
|
48989
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
|
+
|
48990
49108
|
window.setAccount = /*#__PURE__*/function () {
|
48991
|
-
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function
|
48992
|
-
return regeneratorRuntime.wrap(function
|
49109
|
+
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(acc) {
|
49110
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
48993
49111
|
while (1) {
|
48994
|
-
switch (
|
49112
|
+
switch (_context3.prev = _context3.next) {
|
48995
49113
|
case 0:
|
48996
49114
|
delete window.account;
|
48997
49115
|
acc && (window.account = acc);
|
48998
|
-
|
48999
|
-
|
49116
|
+
_context3.prev = 2;
|
49117
|
+
_context3.t0 = acc && window.ganache;
|
49000
49118
|
|
49001
|
-
if (!
|
49002
|
-
|
49119
|
+
if (!_context3.t0) {
|
49120
|
+
_context3.next = 7;
|
49003
49121
|
break;
|
49004
49122
|
}
|
49005
49123
|
|
49006
|
-
|
49124
|
+
_context3.next = 7;
|
49007
49125
|
return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
|
49008
49126
|
|
49009
49127
|
case 7:
|
49010
|
-
|
49128
|
+
_context3.next = 11;
|
49011
49129
|
break;
|
49012
49130
|
|
49013
49131
|
case 9:
|
49014
|
-
|
49015
|
-
|
49132
|
+
_context3.prev = 9;
|
49133
|
+
_context3.t1 = _context3["catch"](2);
|
49016
49134
|
|
49017
49135
|
case 11:
|
49018
49136
|
setBlock(new Date().getTime());
|
@@ -49021,13 +49139,13 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49021
49139
|
|
49022
49140
|
case 14:
|
49023
49141
|
case "end":
|
49024
|
-
return
|
49142
|
+
return _context3.stop();
|
49025
49143
|
}
|
49026
49144
|
}
|
49027
|
-
},
|
49145
|
+
}, _callee3, null, [[2, 9]]);
|
49028
49146
|
}));
|
49029
49147
|
|
49030
|
-
function setAccount(
|
49148
|
+
function setAccount(_x9) {
|
49031
49149
|
return _setAccount.apply(this, arguments);
|
49032
49150
|
}
|
49033
49151
|
|
@@ -49055,7 +49173,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49055
49173
|
newContract: newContract,
|
49056
49174
|
dualChainId: dualChainId,
|
49057
49175
|
dualBlock: dualBlock,
|
49058
|
-
|
49176
|
+
dualChainWeb3: dualChainWeb3
|
49059
49177
|
}), wallet && wallet.error && {
|
49060
49178
|
errorMessage: wallet.error.message
|
49061
49179
|
});
|