import type { HTTPResponse } from 'puppeteer-core'; import logger from '../lib/logger'; import { browser } from '../state/browser'; import stable from './stable'; /** * Change the URL of the MetaMask extension; useful short to bypass buttons click, etc. * @param {string} url The new URL to visit. * @returns {Promise} */ export default async function visit(url: string): Promise { await stable(); const base = browser.metaMask.url().match(/(chrome-extension:\/\/[a-z]+)/)?.[0]; if (!base) { throw new Error('page does not match the chrome-extension:// protocol'); } const newUrl = `${base}/${url.replace(/^\/+/, '')}`; logger.debug('visit', newUrl); return browser.metaMask.goto(newUrl); }