Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

adapt frontend for Boba #2

Open
wants to merge 1 commit into
base: v3.15.6
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions src/config/assets/boba_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions src/config/networks/boba.ts
Original file line number Diff line number Diff line change
@@ -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
73 changes: 73 additions & 0 deletions src/config/networks/boba_rinkeby.ts
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions src/config/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,4 +20,6 @@ export default {
volta,
polygon,
bsc,
boba,
boba_rinkeby,
}
8 changes: 6 additions & 2 deletions src/config/networks/network.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -70,6 +72,8 @@ export enum SHORT_NAME {
LOCAL = 'local',
ARBITRUM = 'arb1',
VOLTA = 'vt',
BOBA = 'boba',
BOBA = 'boba_rinkeby',
}

export type NetworkSettings = {
Expand All @@ -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 =
Expand Down
19 changes: 16 additions & 3 deletions src/logic/wallets/ethTransactions.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -16,9 +17,21 @@ const FIXED_GAS_FEE = '2.5'

const fetchGasPrice = async (gasPriceOracle: GasPriceOracle): Promise<string> => {
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<string> => {
Expand Down