diff --git a/tools/walletextension/api/staticOG/javascript.js b/tools/walletextension/api/staticOG/javascript.js index 44a0419b4e..b04bddd6f3 100644 --- a/tools/walletextension/api/staticOG/javascript.js +++ b/tools/walletextension/api/staticOG/javascript.js @@ -50,6 +50,22 @@ async function fetchAndDisplayVersion() { } } +function getRPCFromUrl(gatewayAddress) { + // get the correct RPC endpoint for each network + switch(gatewayAddress) { + case 'https://testnet.obscu.ro/': + return 'https://rpc.sepolia-testnet.obscu.ro' + case 'https://sepolia-testnet.obscu.ro': + return 'https://rpc.sepolia-testnet.obscu.ro' + case 'https://uat-testnet.obscu.ro/': + return 'https://rpc.uat-testnet.obscu.ro'; + case 'https://dev-testnet.obscu.ro/': + return 'https://rpc.dev-testnet.obscu.ro'; + default: + return gatewayAddress; + } +} + async function addNetworkToMetaMask(ethereum, userID, chainIDDecimal) { // add network to MetaMask let chainIdHex = "0x" + chainIDDecimal.toString(16); // Convert to hexadecimal and prefix with '0x' @@ -65,7 +81,7 @@ async function addNetworkToMetaMask(ethereum, userID, chainIDDecimal) { symbol: 'ETH', decimals: 18 }, - rpcUrls: [obscuroGatewayAddress+"/"+obscuroGatewayVersion+'/?u='+userID], + rpcUrls: [getRPCFromUrl(obscuroGatewayAddress)+"/"+obscuroGatewayVersion+'/?u='+userID], blockExplorerUrls: ['https://testnet.obscuroscan.io'], }, ],