Missing @walletconnect/web3-provider moralis v0.0.39

Just upgraded moralis client to latest 0.0.39 and now telling me I’m missing @walletconnect/web3-provider dependency.
Added it and all fine, but just wanted to let you know, and if this is as intended :+1:

Hey @matiyin

About a few weeks ago, Moralis stopped installing WalletConnect automatically. And the installation instructions were immediately added to the documentation.

Yes I’m still on an ‘old fashioned’ setup I guess from starting months ago.

But interestingly enough, I don’t include walletconnect anywhere in my project. So let’s investigate:

I removed walletconnect again and this is the error I get when compiling:

Upgraded “moralis”: “^0.0.25” to “moralis”: “^0.0.39”

I tried yarn remove moralis and then yarn add moralis and still getting the same error. So it seems to me it’s not been removed fully and still referencing this dependency somewhere :space_invader:

Hey @matiyin

Could you share your package.json? When it gives you an error

  "dependencies": {
    "@quasar/extras": "^1.10.7",
    "@quasar/quasar-ui-qmarkdown": "^2.0.0-alpha.5",
    "confetti-js": "^0.0.18",
    "core-js": "^3.15.2",
    "moralis": "^0.0.39",
    "node-polyfill-webpack-plugin": "^1.1.3",
    "quasar": "^2.0.0",
    "vue-simple-password-meter": "^1.1.0",
    "vuex": "^4.0.2"
  },
  "devDependencies": {
    "@quasar/app": "^3.0.0",
    "babel-eslint": "^10.0.1",
    "chai": "^4.3.4",
    "dotenv": "^10.0.0",
    "eslint": "^7.14.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-plugin-vue": "^7.0.0",
    "eslint-webpack-plugin": "^2.4.0",
    "quasar-app-extension-system-environment-variables": "^2.0.3",
    "workbox-webpack-plugin": "^6.0.0"
  },

Guess triggered in MoralisWalletConnectProvider.js at
if (!this.provider)

var MoralisWalletConnectProvider = /*#__PURE__*/function () {
  function MoralisWalletConnectProvider() {
    (0, _classCallCheck2.default)(this, MoralisWalletConnectProvider);
  }

  (0, _createClass2.default)(MoralisWalletConnectProvider, [{
    key: "type",
    get: function () {
      return 'WalletConnect';
    }
  }, {
    key: "activate",
    value: function () {
      var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
        var options,
            WalletConnectProvider,
            MWeb3,
            _args = arguments;
        return _regenerator.default.wrap(function (_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};

                if (!this.provider) {
                  try {
                    WalletConnectProvider = require('@walletconnect/web3-provider');
                  } catch (error) {// Do nothing. User might not need walletconnect
                  }

                  if (typeof WalletConnectProvider.default === 'function') {
                    this.provider = new WalletConnectProvider.default({
                      rpc: MORALIS_RPCS,
                      chainId: options.chainId
                    });
                  } else {
                    this.provider = new window.WalletConnectProvider.default({
                      rpc: MORALIS_RPCS,
                      chainId: options.chainId
                    });
                  }
                }

                _context.next = 4;
                return this.provider.enable();

              case 4:
                MWeb3 = typeof _web.default === 'function' ? _web.default : window.Web3;
                this.web3 = new MWeb3(this.provider);
                this.isActivated = true;
                return _context.abrupt("return", this.web3);

              case 8:
              case "end":
                return _context.stop();
            }
          }
        }, _callee, this);
      }));

I tested again and on fresh builds there is no problem with WalletConnect.

hmmm could it be yarn cache? Cause quoted MoralisWalletConnectProvider.js is in the newly added moralis package at moralis/lib/browser, not my code

will try with flushing yarn cache

nope no luck with flushing yarn cache, that file is still causing webpack to look for the dependency.
Not a problem for now, just so you know.

1 Like

Hello, I am using the same code, but the error same. Can you help me? It was working before today but now gives an error :

Cannot enable WalletConnect: dependency “@walletconnect/web3-provider” is missing

you can try to install walletconnect

I’m having the same issue @cryptokid, I tried to install and the error persists. I’m using Vite.

Have you installed @walletconnect/web3-provider? Which error are you getting exactly? For Vite, there are some issues with WalletConnect.