A function that takes a rpc endpoint url or infura ID. Returning a promise that resolves with a web3 instance using the MEWconnect web3 provider

import MEWconnect from '@myetherwallet/mewconnect-web-client'
import Web3 from 'web3';

export function ConnectToMewConnect(opts) {
  return new Promise(async (resolve, reject) => {

    if (!MEWconnect.Provider.isConnected) {
      const mewConnect = new MEWconnect.Provider({
      infuraId: opts.infuraId,
      chainId: 1,
      noUrlCheck: true,
      rpcUrl: opts.rpcUrl,
      });
      const provider = mewConnect.makeWeb3Provider()

      mewConnect.on('disconnected', () => {
      alert('MEWconnect Disconnected')
      })
      try {
        await mewConnect.enable();
        resolve(new Web3(provider));
      } catch (e) {
        reject(e);
      }
    }

  });
};