Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions packages/boba/gateway/src/api/buyerAxios.js

This file was deleted.

14 changes: 0 additions & 14 deletions packages/boba/gateway/src/api/sellerAxios.js

This file was deleted.

14 changes: 0 additions & 14 deletions packages/boba/gateway/src/api/serviceAxios.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import React, { useCallback, useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'

import {
selectBaseEnabled,
selectAccountEnabled,
selectLayer,
selectConnectETH,
Expand Down Expand Up @@ -58,6 +59,7 @@ import { LAYER } from 'util/constant.js'
function LayerSwitcher({ visisble = true }) {
const dispatch = useDispatch()
const accountEnabled = useSelector(selectAccountEnabled())
const baseEnabled = useSelector(selectBaseEnabled())

let layer = useSelector(selectLayer())
const network = useSelector(selectActiveNetwork())
Expand Down Expand Up @@ -87,7 +89,7 @@ function LayerSwitcher({ visisble = true }) {

const dispatchBootAccount = useCallback(() => {

if (!accountEnabled) initializeAccount()
if (!accountEnabled && baseEnabled) initializeAccount()

async function initializeAccount() {

Expand Down Expand Up @@ -117,7 +119,7 @@ function LayerSwitcher({ visisble = true }) {
return false
}
}
}, [dispatch, accountEnabled, network, networkType])
}, [dispatch, accountEnabled, network, networkType, baseEnabled])

const doConnectToLayer = useCallback((layer) => {
async function doConnect() {
Expand Down
14 changes: 11 additions & 3 deletions packages/boba/gateway/src/services/networkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import tokenInfo from "@boba/register/addresses/tokenInfo"
import { bobaBridges } from 'util/bobaBridges'
import { MIN_NATIVE_L1_BALANCE, SPEED_CHECK } from 'util/constant'
import { getPoolDetail } from 'util/poolDetails'
import { getNetworkDetail, NETWORK, NETWORK_TYPE } from 'util/network/network.util'
import { pingRpcUrl, getNetworkDetail, NETWORK, NETWORK_TYPE } from 'util/network/network.util'
import appService from './app.service'
import BobaGasPriceOracleABI from './abi/BobaGasPriceOracle.abi'
import L1StandardBridgeABI from './abi/L1StandardBridge.abi'
Expand Down Expand Up @@ -443,8 +443,16 @@ class NetworkService {
this.gasEstimateAccount = networkDetail.gasEstimateAccount
}

let activeL1RpcURL = networkDetail['L1']['rpcUrl'][0]
for (const rpcURL of networkDetail['L1']['rpcUrl']) {
if (await pingRpcUrl(rpcURL)) {
activeL1RpcURL = rpcURL
break
}
}

this.L1Provider = new ethers.providers.StaticJsonRpcProvider(
networkDetail['L1']['rpcUrl']
activeL1RpcURL
)

this.L2Provider = new ethers.providers.StaticJsonRpcProvider(
Expand Down Expand Up @@ -742,7 +750,7 @@ class NetworkService {
const chainParam = {
chainId: '0x' + networkDetail[targetLayer].chainId.toString(16),
chainName: networkDetail[targetLayer].name,
rpcUrls: [networkDetail[targetLayer].rpcUrl],
rpcUrls: this.L1Provider.connection.url,
nativeCurrency: {
name: 'BOBA TOKEN',
symbol: 'BOBA',
Expand Down
2 changes: 0 additions & 2 deletions packages/boba/gateway/src/util/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export const INFURA_ID = process.env.REACT_APP_INFURA_ID
export const MAX_HEALTH_BLOCK_LAG = process.env.REACT_APP_MAX_HEALTH_BLOCK_LAG
export const WALLET_VERSION = process.env.REACT_APP_WALLET_VERSION
export const APP_STATUS = process.env.REACT_APP_STATUS || 'normal'
export const SELLER_OPTIMISM_API_URL = process.env.REACT_APP_SELLER_OPTIMISM_API_URL
export const SERVICE_OPTIMISM_API_URL = process.env.REACT_APP_SERVICE_OPTIMISM_API_URL
export const SPEED_CHECK = process.env.REACT_APP_SPEED_CHECK
export const TARGET_CHAIN_URL = process.env.REACT_APP_TARGET_CHAIN_URL
// VE DAO FLAG
Expand Down
4 changes: 0 additions & 4 deletions packages/boba/gateway/src/util/masterConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ import {

const BaseServices = {
WALLET_SERVICE: `https://api-service.boba.network/`,
//relevant to local?
SERVICE_OPTIMISM_API_URL: `https://zlba6djrv6.execute-api.us-west-1.amazonaws.com/prod/`,
//relevant to local?
WEBSOCKET_API_URL: `wss://d1cj5xnal2.execute-api.us-west-1.amazonaws.com/prod`,
//Coing gecko url
COIN_GECKO_URL: `https://api.coingecko.com/api/v3/`,
//ETH gas station
Expand Down
11 changes: 9 additions & 2 deletions packages/boba/gateway/src/util/network/config/avax.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export const avaxConfig = {
name: "Avalanche Testnet",
chainId: 43113,
chainIdHex: '0xA869',
rpcUrl: `https://api.avax-test.network/ext/bc/C/rpc`,
rpcUrl: [
`https://api.avax-test.network/ext/bc/C/rpc`,
`https://rpc.ankr.com/avalanche_fuji`,
],
transaction: `https://testnet.snowtrace.io/tx/`,
blockExplorerUrl: `https://testnet.snowtrace.io/`,
symbol: "AVAX",
Expand All @@ -36,7 +39,11 @@ export const avaxConfig = {
name: "Avalanche Mainnet",
chainId: 43114,
chainIdHex: '0xA86A',
rpcUrl: `https://api.avax.network/ext/bc/C/rpc`,
rpcUrl: [
`https://api.avax.network/ext/bc/C/rpc`,
`https://rpc.ankr.com/avalanche`,
`https://1rpc.io/avax/c`,
],
transaction: `https://snowtrace.io/tx/`,
blockExplorerUrl: `https://snowtrace.io/`,
symbol: "AVAX",
Expand Down
12 changes: 10 additions & 2 deletions packages/boba/gateway/src/util/network/config/bnb.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export const bnbConfig = {
name: "BNB Testnet",
chainId: 97,
chainIdHex: '0x61',
rpcUrl: `https://data-seed-prebsc-1-s1.binance.org:8545`,
rpcUrl: [
`https://data-seed-prebsc-1-s1.binance.org:8545`,
`https://data-seed-prebsc-2-s1.binance.org:8545`,
`https://bsc-testnet.public.blastapi.io`,
],
transaction: `https://testnet.bscscan.com/tx/`,
blockExplorerUrl: `https://testnet.bscscan.com/`,
symbol: "tBNB",
Expand All @@ -36,7 +40,11 @@ export const bnbConfig = {
name: "Binance Smart Chain Mainnet",
chainId: 56,
chainIdHex: '0x38',
rpcUrl: `https://bsc-dataseed.binance.org`,
rpcUrl: [
`https://bsc-dataseed.binance.org`,
`https://rpc.ankr.com/bsc`,
`https://1rpc.io/bnb`,
],
transaction: `https://bscscan.com/tx/`,
blockExplorerUrl: `https://bscscan.com/`,
symbol: "BNB",
Expand Down
19 changes: 9 additions & 10 deletions packages/boba/gateway/src/util/network/config/ethereum.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export const ethereumConfig = {
name: "Goerli",
chainId: 5,
chainIdHex: '0x5',
rpcUrl: `https://goerli.infura.io/v3/${INFURA_ID}`,
rpcUrl: [
`https://goerli.infura.io/v3/${INFURA_ID}`,
`https://rpc.ankr.com/eth_goerli`,
],
transaction: `https://goerli.etherscan.io/tx/`,
blockExplorerUrl: `https://goerli.etherscan.io/`,
symbol: 'ETH',
Expand All @@ -26,14 +29,6 @@ export const ethereumConfig = {
transaction: `https://testnet.bobascan.com/tx/`,
blockExplorerUrl: `https://testnet.bobascan.com/`
},
ALTL1: {
name: "Alt L1s",
// chainId: 28,
// chainIdHex: '0x1C',
rpcUrl: ``,
// blockExplorer: `https://testnet.bobascan.com/`,
// transaction: `https://testnet.bobascan.com/tx/`
},
payloadForL1SecurityFee: {
from: '0x122816e7A7AeB40601d0aC0DCAA8402F7aa4cDfA',
to: '0x4df04E20cCd9a8B82634754fcB041e86c5FF085A',
Expand Down Expand Up @@ -61,7 +56,11 @@ export const ethereumConfig = {
name: "Mainnet",
chainId: 1,
chainIdHex: '0x1',
rpcUrl: `https://mainnet.infura.io/v3/${INFURA_ID}`,
rpcUrl: [
`https://mainnet.infura.io/v3/${INFURA_ID}`,
`https://rpc.ankr.com/eth`,
`https://cloudflare-eth.com`,
],
transaction: ` https://etherscan.io/tx/`,
blockExplorerUrl: `https://etherscan.io/`,
symbol: 'ETH',
Expand Down
12 changes: 10 additions & 2 deletions packages/boba/gateway/src/util/network/config/fantom.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export const fantomConfig = {
name: "Fantom Testnet",
chainId: 4002,
chainIdHex: '0xFA2',
rpcUrl: `https://rpc.testnet.fantom.network`,
rpcUrl: [
`https://rpc.testnet.fantom.network`,
`https://rpc.ankr.com/fantom_testnet`,
`https://fantom-testnet.public.blastapi.io`,
],
transaction: `https://testnet.ftmscan.com/tx/`,
blockExplorerUrl: `https://testnet.ftmscan.com/`,
symbol: 'FTM',
Expand All @@ -36,7 +40,11 @@ export const fantomConfig = {
name: "Fantom Mainnet",
chainId: 250,
chainIdHex: '0xFA',
rpcUrl: `https://rpc.fantom.network`,
rpcUrl: [
`https://rpc.fantom.network`,
`https://rpc.ankr.com/fantom`,
`https://1rpc.io/ftm`,
],
transaction: `https://ftmscan.com/tx/`,
blockExplorerUrl: `https://ftmscan.com/`,
symbol: 'FTM',
Expand Down
12 changes: 10 additions & 2 deletions packages/boba/gateway/src/util/network/config/moonbeam.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ export const moonbeamConfig = {
name: "MoonBase",
chainId: 1287,
chainIdHex: '0x507',
rpcUrl: `https://rpc.api.moonbase.moonbeam.network`,
rpcUrl: [
`https://rpc.api.moonbase.moonbeam.network`,
`https://moonbase-alpha.public.blastapi.io`,
`https://moonbeam-alpha.api.onfinality.io/public`,
],
transaction: `https://moonbase.moonscan.io/tx/`,
blockExplorerUrl: `https://moonbase.moonscan.io`,
symbol: 'DEV',
Expand All @@ -35,7 +39,11 @@ export const moonbeamConfig = {
name: "MoonBeam",
chainId: 1284,
chainIdHex: '0x504',
rpcUrl: `https://rpc.api.moonbeam.network`,
rpcUrl: [
`https://rpc.api.moonbeam.network`,
`https://rpc.ankr.com/moonbeam`,
`https://1rpc.io/glmr`,
],
transaction: `https://moonscan.io/tx/`,
blockExplorerUrl: `https://moonscan.io/`,
symbol: "GLMR",
Expand Down
15 changes: 15 additions & 0 deletions packages/boba/gateway/src/util/network/network.util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { providers } from 'ethers';

import EthereumIcon from 'components/icons/chain/L1/EthereumIcon';
import BNBIcon from 'components/icons/chain/L1/BNBIcon';
import AvalancheIcon from 'components/icons/chain/L1/AvalancheIcon';
Expand Down Expand Up @@ -284,3 +286,16 @@ export const getBlockExplorerUrl = ({
}) => {
return networkConfig[network][networkType][layer]?.blockExplorerUrl
}

export const pingRpcUrl = async (
rpcUrl,
) => {
const provider = new providers.JsonRpcProvider(rpcUrl)
try {
await provider.getBlockNumber()
return true
} catch (e) {
console.log(`Error pinging Rpc Url: ${rpcUrl}`)
return false
}
}