Unable to open MetaMask wallet On retool

Hi, I am new to retool and I want to add a button that would open Metamask for wallet connection. I have import the web3js library but and window.ethereum is currently present in my browser. When I add the code below as run script to the button, metamask doesn't open

f (window.ethereum) {
     await window.ethereum.request({ method: "eth_requestAccounts" });
     window.web3 = new Web3(window.ethereum);
     const account = web3.eth.accounts;
     //Get the current MetaMask selected/active wallet
     const walletAddress = account.givenProvider.selectedAddress;
     console.log(`Wallet: ${walletAddress}`);
  
  } else {
   console.log("No wallet");
  }

AND

if (window.ethereum) {
  window.ethereum
    .request({ method: "eth_requestAccounts" })
    .then(() => {
      window.web3 = new Web3(window.ethereum);
      const account = web3.eth.accounts;
      // Get the current MetaMask selected/active wallet
      const walletAddress = account.givenProvider.selectedAddress;
      console.log(`Wallet: ${walletAddress}`);
    })
    .catch((error) => {
      console.error("Error requesting accounts:", error);
    });
} else {
  console.log("No wallet");
}