diff --git a/src/config/assets/boba_logo.svg b/src/config/assets/boba_logo.svg new file mode 100644 index 0000000000..a58d770d6f --- /dev/null +++ b/src/config/assets/boba_logo.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/config/networks/boba.ts b/src/config/networks/boba.ts new file mode 100644 index 0000000000..4bde906674 --- /dev/null +++ b/src/config/networks/boba.ts @@ -0,0 +1,73 @@ +import BobaLogo from 'src/config/assets/boba_logo.svg' +import { + EnvironmentSettings, + ETHEREUM_LAYER, + ETHEREUM_NETWORK, + FEATURES, + NetworkConfig, + WALLETS, +} from 'src/config/networks/network.d' + +const baseConfig: EnvironmentSettings = { + //this is the frontend2backend url + clientGatewayUrl: 'http://127.0.0.1:8002/v1', + txServiceUrl: 'http://127.0.0.1:8000/api/v1', + safeUrl: 'http://gnosis-safe.mainnet.boba:3000/app', + gasPriceOracles: [ + { + url: 'https://mainnet.boba.network/', + }, + ], + rpcServiceUrl: 'https://mainnet.boba.network/', + safeAppsRpcServiceUrl: 'https://mainnet.boba.network/', + networkExplorerName: 'BlockExplorer', + networkExplorerUrl: 'https://blockexplorer.boba.network/', + networkExplorerApiUrl: 'https://blockexplorer.boba.network/api', +} + +const boba: NetworkConfig = { + environment: { + dev: { + ...baseConfig, + }, + staging: { + ...baseConfig, + }, + production: { + ...baseConfig, + }, + }, + network: { + id: ETHEREUM_NETWORK.BOBA, + backgroundColor: '#2A3245', + textColor: '#ffffff', + label: 'Boba', + isTestNet: false, + ethereumLayer: ETHEREUM_LAYER.L2, + nativeCoin: { + address: '0x0000000000000000000000000000000000000000', + name: 'ETH', + symbol: 'ETH', + decimals: 18, + logoUri: BobaLogo, + }, + }, + disabledWallets: [ + WALLETS.TREZOR, + WALLETS.LEDGER, + WALLETS.COINBASE, + WALLETS.FORTMATIC, + WALLETS.OPERA, + WALLETS.OPERA_TOUCH, + WALLETS.PORTIS, + WALLETS.TORUS, + WALLETS.TRUST, + WALLETS.WALLET_LINK, + WALLETS.AUTHEREUM, + WALLETS.LATTICE, + WALLETS.KEYSTONE, + ], + disabledFeatures: [FEATURES.DOMAIN_LOOKUP, FEATURES.SPENDING_LIMIT], +} + +export default boba diff --git a/src/config/networks/boba_rinkeby.ts b/src/config/networks/boba_rinkeby.ts new file mode 100644 index 0000000000..fe721558a6 --- /dev/null +++ b/src/config/networks/boba_rinkeby.ts @@ -0,0 +1,73 @@ +import BobaLogo from 'src/config/assets/boba_logo.svg' +import { + EnvironmentSettings, + ETHEREUM_LAYER, + ETHEREUM_NETWORK, + FEATURES, + NetworkConfig, + WALLETS, +} from 'src/config/networks/network.d' + +const baseConfig: EnvironmentSettings = { + //this is the frontend2backend url + clientGatewayUrl: 'http://127.0.0.1:8002/v1', + txServiceUrl: 'http://127.0.0.1:8000/api/v1', + safeUrl: 'http://gnosis-safe.rinkeby.boba:3000/app', + gasPriceOracles: [ + { + url: 'https://rinkeby.boba.network/', + }, + ], + rpcServiceUrl: 'https://rinkeby.boba.network/', + safeAppsRpcServiceUrl: 'https://rinkeby.boba.network/', + networkExplorerName: 'BlockExplorer', + networkExplorerUrl: 'https://blockexplorer.rinkeby.boba.network/', + networkExplorerApiUrl: 'https://blockexplorer.rinkeby.boba.network/api', +} + +const boba_rinkeby: NetworkConfig = { + environment: { + dev: { + ...baseConfig, + }, + staging: { + ...baseConfig, + }, + production: { + ...baseConfig, + }, + }, + network: { + id: ETHEREUM_NETWORK.BOBA_RINKEBY, + backgroundColor: '#2A3245', + textColor: '#ffffff', + label: 'Boba Rinkeby', + isTestNet: true, + ethereumLayer: ETHEREUM_LAYER.L2, + nativeCoin: { + address: '0x0000000000000000000000000000000000000000', + name: 'ETH', + symbol: 'ETH', + decimals: 18, + logoUri: BobaLogo, + }, + }, + disabledWallets: [ + WALLETS.TREZOR, + WALLETS.LEDGER, + WALLETS.COINBASE, + WALLETS.FORTMATIC, + WALLETS.OPERA, + WALLETS.OPERA_TOUCH, + WALLETS.PORTIS, + WALLETS.TORUS, + WALLETS.TRUST, + WALLETS.WALLET_LINK, + WALLETS.AUTHEREUM, + WALLETS.LATTICE, + WALLETS.KEYSTONE, + ], + disabledFeatures: [FEATURES.DOMAIN_LOOKUP, FEATURES.SPENDING_LIMIT], +} + +export default boba_rinkeby diff --git a/src/config/networks/index.ts b/src/config/networks/index.ts index 693c3be7ae..375a6c2f9f 100644 --- a/src/config/networks/index.ts +++ b/src/config/networks/index.ts @@ -7,6 +7,8 @@ import energy_web_chain from './energy_web_chain' import volta from './volta' import polygon from './polygon' import bsc from './bsc' +import boba from './boba' +import boba_rinkeby from './boba_rinkeby' export default { local, @@ -18,4 +20,6 @@ export default { volta, polygon, bsc, + boba, + boba_rinkeby, } diff --git a/src/config/networks/network.d.ts b/src/config/networks/network.d.ts index 19d8d892b9..6f05bcf0b8 100644 --- a/src/config/networks/network.d.ts +++ b/src/config/networks/network.d.ts @@ -56,6 +56,8 @@ export enum ETHEREUM_NETWORK { LOCAL = '4447', ARBITRUM = '42161', VOLTA = '73799', + BOBA = '288', + BOBA_RINKEBY = '28', } // Take from: https://chainid.network/shortNameMapping.json @@ -70,6 +72,8 @@ export enum SHORT_NAME { LOCAL = 'local', ARBITRUM = 'arb1', VOLTA = 'vt', + BOBA = 'boba', + BOBA = 'boba_rinkeby', } export type NetworkSettings = { @@ -93,10 +97,10 @@ export type GasPriceOracle = { url: string // Different gas api providers can use a different name to reflect different gas levels based on tx speed // For example in ethGasStation for ETHEREUM_MAINNET = safeLow | average | fast - gasParameter: string + gasParameter?: string // Some providers may not use the most common standard, gwei to return the gas price value // This is the case of Ethgasstation that returns price as gwei x 10. - gweiFactor: string + gweiFactor?: string } type GasPrice = diff --git a/src/logic/wallets/ethTransactions.ts b/src/logic/wallets/ethTransactions.ts index 7045314c14..fc5fbd4ac5 100644 --- a/src/logic/wallets/ethTransactions.ts +++ b/src/logic/wallets/ethTransactions.ts @@ -1,5 +1,6 @@ import axios from 'axios' import { BigNumber } from 'bignumber.js' +import { BigNumber as BigNumberEthers } from 'ethers' import { EthAdapterTransaction } from '@gnosis.pm/safe-core-sdk/dist/src/ethereumLibs/EthAdapter' import { getSDKWeb3ReadOnly, getWeb3, getWeb3ReadOnly } from 'src/logic/wallets/getWeb3' @@ -16,9 +17,21 @@ const FIXED_GAS_FEE = '2.5' const fetchGasPrice = async (gasPriceOracle: GasPriceOracle): Promise => { const { url, gasParameter, gweiFactor } = gasPriceOracle - const { data: response } = await axios.get(url) - const data = response.data || response.result || response // Sometimes the data comes with a data parameter - return new BigNumber(data[gasParameter]).multipliedBy(gweiFactor).toString() + if (gasParameter === undefined || gweiFactor === undefined) { + const rpcRequest = { + jsonrpc: '2.0', + method: 'eth_gasPrice', + params: [], + id: 1, + } + const headers = { headers: { 'Content-Type': 'application/json' } } + const { data: response } = await axios.post(url, rpcRequest, headers) + return BigNumberEthers.from(response.result).toString() + } else { + const { data: response } = await axios.get(url) + const data = response.data || response.result || response // Sometimes the data comes with a data parameter + return new BigNumber(data[gasParameter]).multipliedBy(gweiFactor).toString() + } } export const calculateGasPrice = async (): Promise => {