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?
``