Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
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
8 changes: 8 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
GAS_PRICE_TYPE,
RPC_AUTHENTICATION,
RpcUri,
GasPriceFixed,
} from '@gnosis.pm/safe-react-gateway-sdk'
import { CONFIG_REDUCER_ID, initialConfigState } from 'src/logic/config/store/reducer'

Expand Down Expand Up @@ -89,6 +90,13 @@ export const getGasPriceOracles = (): Extract<ChainInfo['gasPrice'][number], Gas
return getChainInfo().gasPrice.filter(isOracleType)
}

export const getFixedGasPrice = (): Extract<ChainInfo['gasPrice'][number], GasPriceFixed> => {
const isFixed = (gasPrice: ChainInfo['gasPrice'][number]): gasPrice is GasPriceFixed => {
return gasPrice.type === GAS_PRICE_TYPE.FIXED
}
return getChainInfo().gasPrice.filter(isFixed)[0]
}

export const getTxServiceUrl = (): ChainInfo['transactionService'] => {
const { transactionService } = getChainInfo()
// To avoid breaking changes, we define the version the web uses manually
Expand Down
1 change: 0 additions & 1 deletion src/logic/safe/utils/safeVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { Errors, logError } from 'src/logic/exceptions/CodedException'
import { getChainInfo } from 'src/config'

const FEATURES_BY_VERSION: Record<string, string> = {
[FEATURES.ERC1155]: '>=1.1.1',
[FEATURES.SAFE_TX_GAS_OPTIONAL]: '>=1.3.0',
}

Expand Down
8 changes: 7 additions & 1 deletion src/logic/wallets/ethTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BigNumber } from 'bignumber.js'
import { EthAdapterTransaction } from '@gnosis.pm/safe-core-sdk/dist/src/ethereumLibs/EthAdapter'

import { getSDKWeb3ReadOnly, getWeb3, getWeb3ReadOnly } from 'src/logic/wallets/getWeb3'
import { getGasPriceOracles } from 'src/config'
import { getFixedGasPrice, getGasPriceOracles } from 'src/config'
import { CodedException, Errors } from '../exceptions/CodedException'
import { GasPriceOracle } from '@gnosis.pm/safe-react-gateway-sdk'

Expand Down Expand Up @@ -33,6 +33,12 @@ export const calculateGasPrice = async (): Promise<string> => {
}
}

// A fallback to fixed gas price from the chain config
const fixedGasPrice = getFixedGasPrice()
if (fixedGasPrice) {
return fixedGasPrice.weiValue
}

// A fallback based on the latest mined blocks when none of the oracles are working
const web3ReadOnly = getWeb3ReadOnly()
const fixedFee = web3ReadOnly.utils.toWei(FIXED_GAS_FEE, 'gwei')
Expand Down
7 changes: 4 additions & 3 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ export const CONFIG_SERVICE_URL =
process.env.CONFIG_SERVICE_URL || IS_PRODUCTION
? 'https://safe-config.gnosis.io/api/v1'
: 'https://safe-config.staging.gnosisdev.com/api/v1'
export const GATEWAY_URL = IS_PRODUCTION
? 'https://safe-client.gnosis.io/v1'
: 'https://safe-client.staging.gnosisdev.com/v1'
export const GATEWAY_URL =
IS_PRODUCTION || window.location.hash === '#prod'
? 'https://safe-client.gnosis.io/v1'
: 'https://safe-client.staging.gnosisdev.com/v1'
export const IPFS_GATEWAY = process.env.REACT_APP_IPFS_GATEWAY
export const SPENDING_LIMIT_MODULE_ADDRESS =
process.env.REACT_APP_SPENDING_LIMIT_MODULE_ADDRESS || '0xCFbFaC74C26F8647cBDb8c5caf80BB5b32E43134'
Expand Down