Can I disable LavaMoat?

I am currently trying to automate some tasks with my MetaMask wallet using a simple script. One part of this script involves switching my wallet, but unfortunately, I am receiving an error from LavaMoat, preventing me from performing this action.

I am using MetaMask version 12.26.0 and I am trying to disable LavaMoat to allow me to run this script smoothly. I have attached a test-script below for your reference:


``const puppeteer = require(‘puppeteer’);

const userDataDir = ‘./user_data’;
const password = ‘MY_PASSWORD’;
const METAMASK_EXTENSION_URL = ‘chrome-extension:// nldfjhpflkfiglhjcjelnjfdhohogikj/home.html’;
const METAMASK_NOTIFICATION_URL = ‘chrome-extension:// nldfjhpflkfiglhjcjelnjfdhohogikj/notification.html’;

function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

async function launchBrowserWithMetamask() {
return puppeteer.launch({
headless: false,
args: [
‘–disable-extensions-except=/path/to/MetaMask,/path/to/selenium_ide’,
‘–load-extension=/path/to/MetaMask,/path/to/selenium_ide’,
--user-data-dir=${userDataDir},
‘–disable-lava-moat’,
‘–no-sandbox’
],
});
}

async function openMetamaskAndUnlock(browser, password) {
const target = await browser.waitForTarget(target => target.url().startsWith(METAMASK_EXTENSION_URL));
const metamaskPage = await target.page();

await metamaskPage.waitForSelector(‘#password’, { timeout: 30000 });
await metamaskPage.type(‘#password’, password);
await metamaskPage.click(‘[data-testid=“unlock-submit”]’);
await metamaskPage.waitForTimeout(2000);
}

async function clickAccountButton(metamaskPage) {
await metamaskPage.waitForSelector(‘#app-content > div > div.app-header > div > div.app-header__account-menu-container > button > div’, { timeout: 30000 });
const accountButton = await metamaskPage.$(‘#app-content > div > div.app-header > div > div.app-header__account-menu-container > button > div’);
await accountButton.click();
}

async function main() {
const browser = await launchBrowserWithMetamask();
await openMetamaskAndUnlock(browser, password);

const metamaskPage = await browser.newPage();
await metamaskPage.goto(METAMASK_EXTENSION_URL, { waitUntil: ‘networkidle0’ });
await clickAccountButton(metamaskPage);
}

main().catch(console.error);

Once the script tries to click on the element in the wallet to switch the wallet I get following error:
Once I click the MetaMask button I get following error:
Error: Evaluation failed: Error: LavaMoat - property “Map” of globalThis is inaccessible under scuttling mode…

Is there any chance to disable LavaMoat or work around this?

``

I have the same issue. I change to the old version MetaMask 10.25 and it works

Was able to fix the problem.
Here are the steps to disable LavaMoat for the MetaMask browser extension:

  1. Fork the MetaMask extension repository an github: [GitHubURL]/MetaMask/MetaMask-extension.git.

  2. Clone your fork of the repository to your local machine using the command git clone <your-fork>.

  3. Install the dependencies by running yarn in the terminal from the root directory of the cloned repository.

  4. Use the search function (press Ctrl + Shift + F on Windows or Cmd + Shift + F on Mac) to find the line of code that contains “scuttleGlobalThis:” and set it to “false”.

  5. Copy the .metamaskrc.dist file to .metamaskrc, and replace the INFURA_PROJECT_ID with your own personal API key using the search function.
    (More info on that step in the README.md.)

  6. Build the MetaMask extension by running yarn dist in the terminal from the root directory of the cloned repository.

  7. You should now have a local version of MetaMask with scuttling turned off.

  8. Upload it into your browser/script and it should work.

I’m currently using MetaMask version 10.26.2 and works pretty much seamlessly.

Note: If you encounter any dependency errors with yarn or yarn dist , you may need to remove Node.js and all related components from your machine and then reinstall the newest version.

2 Likes

There is an arrow to scroll MetaMask page to Sign or Approve button btw…you can simply click on it

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.