@ethereansos/interfaces-core 0.4.57 → 0.4.58

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 CHANGED
@@ -42722,35 +42722,63 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42722
42722
  web3Instance = _useState6[0],
42723
42723
  setWeb3Instance = _useState6[1];
42724
42724
 
42725
- var _useState7 = React.useState([]),
42725
+ var _useState7 = React.useState(null),
42726
42726
  _useState8 = _slicedToArray(_useState7, 2),
42727
- globalContractNames = _useState8[0],
42728
- setGlobalContractNames = _useState8[1];
42727
+ chainId = _useState8[0],
42728
+ setChainId = _useState8[1];
42729
42729
 
42730
42730
  var _useState9 = React.useState([]),
42731
42731
  _useState10 = _slicedToArray(_useState9, 2),
42732
- globalContracts = _useState10[0],
42733
- setGlobalContracts = _useState10[1];
42732
+ globalContractNames = _useState10[0],
42733
+ setGlobalContractNames = _useState10[1];
42734
42734
 
42735
- var _useState11 = React.useState({}),
42735
+ var _useState11 = React.useState([]),
42736
42736
  _useState12 = _slicedToArray(_useState11, 2),
42737
- contracts = _useState12[0],
42738
- setContracts = _useState12[1];
42737
+ globalContracts = _useState12[0],
42738
+ setGlobalContracts = _useState12[1];
42739
+
42740
+ var _useState13 = React.useState({}),
42741
+ _useState14 = _slicedToArray(_useState13, 2),
42742
+ contracts = _useState14[0],
42743
+ setContracts = _useState14[1];
42739
42744
 
42740
42745
  React.useEffect(function () {
42741
42746
  setIpfsHttpClient(ipfsHttpClient.create(context.ipfsHost));
42742
42747
  }, [context]);
42743
42748
  React.useEffect(function () {
42744
42749
  setConnectionStatus(wallet && wallet.ethereum ? CONNECTED : connectionStatus || NOT_CONNECTED);
42745
- setWeb3Instance(wallet && wallet.ethereum && new Web3__default["default"](wallet.ethereum) || null);
42750
+
42751
+ if (web3Instance && wallet) {
42752
+ setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
42753
+ var web3ChainId;
42754
+ return regeneratorRuntime.wrap(function _callee$(_context) {
42755
+ while (1) {
42756
+ switch (_context.prev = _context.next) {
42757
+ case 0:
42758
+ _context.t0 = parseInt;
42759
+ _context.next = 3;
42760
+ return sendAsync(web3Instance.currentProvider, 'eth_chainId');
42761
+
42762
+ case 3:
42763
+ _context.t1 = _context.sent;
42764
+ web3ChainId = (0, _context.t0)(_context.t1);
42765
+ web3ChainId !== wallet.chainId && setWeb3Instance(wallet && wallet.ethereum && new Web3__default["default"](wallet.ethereum) || null);
42766
+
42767
+ case 6:
42768
+ case "end":
42769
+ return _context.stop();
42770
+ }
42771
+ }
42772
+ }, _callee);
42773
+ })));
42774
+ } else {
42775
+ setWeb3Instance(wallet && wallet.ethereum && new Web3__default["default"](wallet.ethereum) || null);
42776
+ }
42746
42777
  }, [wallet]);
42747
42778
  React.useEffect(function () {
42748
- setContracts(function () {
42749
- return {};
42750
- });
42751
- setGlobalContracts(function () {
42752
- return globalContractNames.map(newContractByName);
42753
- });
42779
+ setContracts({});
42780
+ setGlobalContracts(globalContractNames.map(newContractByName));
42781
+ setChainId(wallet.chainId);
42754
42782
  }, [web3Instance]);
42755
42783
 
42756
42784
  var setConnector = function setConnector(connector) {
@@ -42807,7 +42835,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
42807
42835
  ipfsHttpClient: ipfsHttpClient$1
42808
42836
  }, wallet && connectionStatus === CONNECTED && {
42809
42837
  account: wallet.account,
42810
- chainId: wallet.chainId,
42838
+ chainId: chainId,
42811
42839
  chainName: wallet.networkName,
42812
42840
  web3: web3Instance,
42813
42841
  getGlobalContract: getGlobalContract,