Skip to content

Commit

Permalink
get rpc values from address
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Oct 4, 2023
1 parent adc24d5 commit 88807aa
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tools/walletextension/api/staticOG/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'],
},
],
Expand Down

0 comments on commit 88807aa

Please sign in to comment.