(Chore) Update `nativeCoin` address to ZERO_ADDRESS (#2059)
This commit is contained in:
parent
e2c1113377
commit
c41ab4eaec
|
@ -286,7 +286,7 @@ const xDai: NetworkConfig = {
|
||||||
label: 'xDai',
|
label: 'xDai',
|
||||||
isTestNet: false,
|
isTestNet: false,
|
||||||
nativeCoin: {
|
nativeCoin: {
|
||||||
address: '0x000',
|
address: '0x0000000000000000000000000000000000000000',
|
||||||
name: 'xDai',
|
name: 'xDai',
|
||||||
symbol: 'xDai',
|
symbol: 'xDai',
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
|
@ -343,7 +343,7 @@ const mainnet: NetworkConfig = {
|
||||||
label: 'Mainnet',
|
label: 'Mainnet',
|
||||||
isTestNet: false,
|
isTestNet: false,
|
||||||
nativeCoin: {
|
nativeCoin: {
|
||||||
address: '0x000',
|
address: '0x0000000000000000000000000000000000000000',
|
||||||
name: 'Ether',
|
name: 'Ether',
|
||||||
symbol: 'ETH',
|
symbol: 'ETH',
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
|
|
|
@ -38,7 +38,7 @@ const mainnet: NetworkConfig = {
|
||||||
label: 'EWC',
|
label: 'EWC',
|
||||||
isTestNet: false,
|
isTestNet: false,
|
||||||
nativeCoin: {
|
nativeCoin: {
|
||||||
address: '0x000',
|
address: '0x0000000000000000000000000000000000000000',
|
||||||
name: 'Energy web token',
|
name: 'Energy web token',
|
||||||
symbol: 'EWT',
|
symbol: 'EWT',
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
|
|
|
@ -29,7 +29,7 @@ const local: NetworkConfig = {
|
||||||
label: 'LocalRPC',
|
label: 'LocalRPC',
|
||||||
isTestNet: true,
|
isTestNet: true,
|
||||||
nativeCoin: {
|
nativeCoin: {
|
||||||
address: '0x000',
|
address: '0x0000000000000000000000000000000000000000',
|
||||||
name: 'Ether',
|
name: 'Ether',
|
||||||
symbol: 'ETH',
|
symbol: 'ETH',
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
|
|
|
@ -38,7 +38,7 @@ const mainnet: NetworkConfig = {
|
||||||
label: 'Mainnet',
|
label: 'Mainnet',
|
||||||
isTestNet: false,
|
isTestNet: false,
|
||||||
nativeCoin: {
|
nativeCoin: {
|
||||||
address: '0x000',
|
address: '0x0000000000000000000000000000000000000000',
|
||||||
name: 'Ether',
|
name: 'Ether',
|
||||||
symbol: 'ETH',
|
symbol: 'ETH',
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
|
|
|
@ -38,7 +38,7 @@ const rinkeby: NetworkConfig = {
|
||||||
label: 'Rinkeby',
|
label: 'Rinkeby',
|
||||||
isTestNet: true,
|
isTestNet: true,
|
||||||
nativeCoin: {
|
nativeCoin: {
|
||||||
address: '0x000',
|
address: '0x0000000000000000000000000000000000000000',
|
||||||
name: 'Ether',
|
name: 'Ether',
|
||||||
symbol: 'ETH',
|
symbol: 'ETH',
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
|
|
|
@ -35,7 +35,7 @@ const mainnet: NetworkConfig = {
|
||||||
label: 'Volta',
|
label: 'Volta',
|
||||||
isTestNet: true,
|
isTestNet: true,
|
||||||
nativeCoin: {
|
nativeCoin: {
|
||||||
address: '0x000',
|
address: '0x0000000000000000000000000000000000000000',
|
||||||
name: 'Energy web token',
|
name: 'Energy web token',
|
||||||
symbol: 'EWT',
|
symbol: 'EWT',
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
|
|
|
@ -29,7 +29,7 @@ const xDai: NetworkConfig = {
|
||||||
label: 'xDai',
|
label: 'xDai',
|
||||||
isTestNet: false,
|
isTestNet: false,
|
||||||
nativeCoin: {
|
nativeCoin: {
|
||||||
address: '0x000',
|
address: '0x0000000000000000000000000000000000000000',
|
||||||
name: 'xDai',
|
name: 'xDai',
|
||||||
symbol: 'xDai',
|
symbol: 'xDai',
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
|
|
||||||
import { getNetworkInfo } from 'src/config'
|
|
||||||
import { Token } from 'src/logic/tokens/store/model/token'
|
import { Token } from 'src/logic/tokens/store/model/token'
|
||||||
import { sameAddress, ZERO_ADDRESS } from 'src/logic/wallets/ethAddresses'
|
import { sameAddress } from 'src/logic/wallets/ethAddresses'
|
||||||
import { safeKnownCoins } from 'src/routes/safe/container/selector'
|
import { safeKnownCoins } from 'src/routes/safe/container/selector'
|
||||||
|
|
||||||
const { nativeCoin } = getNetworkInfo()
|
|
||||||
|
|
||||||
const useTokenInfo = (address: string): Token | undefined => {
|
const useTokenInfo = (address: string): Token | undefined => {
|
||||||
const tokens = useSelector(safeKnownCoins)
|
const tokens = useSelector(safeKnownCoins)
|
||||||
|
|
||||||
if (tokens) {
|
if (tokens) {
|
||||||
const tokenAddress = sameAddress(address, ZERO_ADDRESS) ? nativeCoin.address : address
|
return tokens.find((token) => sameAddress(token.address, address))
|
||||||
return tokens.find((token) => sameAddress(token.address, tokenAddress)) ?? undefined
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { BigNumber } from 'bignumber.js'
|
import { BigNumber } from 'bignumber.js'
|
||||||
import { getNetworkInfo } from 'src/config'
|
|
||||||
import { AbiItem } from 'web3-utils'
|
import { AbiItem } from 'web3-utils'
|
||||||
|
|
||||||
import { CreateTransactionArgs } from 'src/logic/safe/store/actions/createTransaction'
|
import { CreateTransactionArgs } from 'src/logic/safe/store/actions/createTransaction'
|
||||||
|
@ -9,7 +8,7 @@ import SpendingLimitModule from 'src/logic/contracts/artifacts/AllowanceModule.j
|
||||||
import generateBatchRequests from 'src/logic/contracts/generateBatchRequests'
|
import generateBatchRequests from 'src/logic/contracts/generateBatchRequests'
|
||||||
import { getSpendingLimitContract, MULTI_SEND_ADDRESS } from 'src/logic/contracts/safeContracts'
|
import { getSpendingLimitContract, MULTI_SEND_ADDRESS } from 'src/logic/contracts/safeContracts'
|
||||||
import { SpendingLimit } from 'src/logic/safe/store/models/safe'
|
import { SpendingLimit } from 'src/logic/safe/store/models/safe'
|
||||||
import { sameAddress, ZERO_ADDRESS } from 'src/logic/wallets/ethAddresses'
|
import { sameAddress } from 'src/logic/wallets/ethAddresses'
|
||||||
import { getWeb3, web3ReadOnly } from 'src/logic/wallets/getWeb3'
|
import { getWeb3, web3ReadOnly } from 'src/logic/wallets/getWeb3'
|
||||||
import { SPENDING_LIMIT_MODULE_ADDRESS } from 'src/utils/constants'
|
import { SPENDING_LIMIT_MODULE_ADDRESS } from 'src/utils/constants'
|
||||||
import { getEncodedMultiSendCallData, MultiSendTx } from './upgradeSafe'
|
import { getEncodedMultiSendCallData, MultiSendTx } from './upgradeSafe'
|
||||||
|
@ -138,16 +137,13 @@ type DeleteAllowanceParams = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getDeleteAllowanceTxData = ({ beneficiary, tokenAddress }: DeleteAllowanceParams): string => {
|
export const getDeleteAllowanceTxData = ({ beneficiary, tokenAddress }: DeleteAllowanceParams): string => {
|
||||||
const { nativeCoin } = getNetworkInfo()
|
|
||||||
const token = sameAddress(tokenAddress, nativeCoin.address) ? ZERO_ADDRESS : tokenAddress
|
|
||||||
|
|
||||||
const web3 = getWeb3()
|
const web3 = getWeb3()
|
||||||
const spendingLimitContract = new web3.eth.Contract(
|
const spendingLimitContract = new web3.eth.Contract(
|
||||||
SpendingLimitModule.abi as AbiItem[],
|
SpendingLimitModule.abi as AbiItem[],
|
||||||
SPENDING_LIMIT_MODULE_ADDRESS,
|
SPENDING_LIMIT_MODULE_ADDRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
return spendingLimitContract.methods.deleteAllowance(beneficiary, token).encodeABI()
|
return spendingLimitContract.methods.deleteAllowance(beneficiary, tokenAddress).encodeABI()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enableSpendingLimitModuleMultiSendTx = (safeAddress: string): MultiSendTx => {
|
export const enableSpendingLimitModuleMultiSendTx = (safeAddress: string): MultiSendTx => {
|
||||||
|
@ -188,20 +184,13 @@ export const setSpendingLimitTx = ({
|
||||||
safeAddress,
|
safeAddress,
|
||||||
}: SpendingLimitTxParams): CreateTransactionArgs => {
|
}: SpendingLimitTxParams): CreateTransactionArgs => {
|
||||||
const spendingLimitContract = getSpendingLimitContract()
|
const spendingLimitContract = getSpendingLimitContract()
|
||||||
const { nativeCoin } = getNetworkInfo()
|
|
||||||
|
|
||||||
const txArgs: CreateTransactionArgs = {
|
const txArgs: CreateTransactionArgs = {
|
||||||
safeAddress,
|
safeAddress,
|
||||||
to: SPENDING_LIMIT_MODULE_ADDRESS,
|
to: SPENDING_LIMIT_MODULE_ADDRESS,
|
||||||
valueInWei: ZERO_VALUE,
|
valueInWei: ZERO_VALUE,
|
||||||
txData: spendingLimitContract.methods
|
txData: spendingLimitContract.methods
|
||||||
.setAllowance(
|
.setAllowance(beneficiary, token, spendingLimitInWei, resetTimeMin, resetBaseMin)
|
||||||
beneficiary,
|
|
||||||
token === nativeCoin.address ? ZERO_ADDRESS : token,
|
|
||||||
spendingLimitInWei,
|
|
||||||
resetTimeMin,
|
|
||||||
resetBaseMin,
|
|
||||||
)
|
|
||||||
.encodeABI(),
|
.encodeABI(),
|
||||||
operation: CALL,
|
operation: CALL,
|
||||||
notifiedTransaction: TX_NOTIFICATION_TYPES.NEW_SPENDING_LIMIT_TX,
|
notifiedTransaction: TX_NOTIFICATION_TYPES.NEW_SPENDING_LIMIT_TX,
|
||||||
|
@ -285,12 +274,5 @@ export const getSpendingLimitByTokenAddress = ({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const { nativeCoin } = getNetworkInfo()
|
return spendingLimits.find(({ token }) => sameAddress(token, tokenAddress))
|
||||||
|
|
||||||
return spendingLimits.find(({ token: spendingLimitTokenAddress }) => {
|
|
||||||
spendingLimitTokenAddress = sameAddress(spendingLimitTokenAddress, ZERO_ADDRESS)
|
|
||||||
? nativeCoin.address
|
|
||||||
: spendingLimitTokenAddress
|
|
||||||
return sameAddress(spendingLimitTokenAddress, tokenAddress)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@ import { AppReduxState } from 'src/store'
|
||||||
import { humanReadableValue } from 'src/logic/tokens/utils/humanReadableValue'
|
import { humanReadableValue } from 'src/logic/tokens/utils/humanReadableValue'
|
||||||
import { safeActiveTokensSelector, safeSelector } from 'src/logic/safe/store/selectors'
|
import { safeActiveTokensSelector, safeSelector } from 'src/logic/safe/store/selectors'
|
||||||
import { tokensSelector } from 'src/logic/tokens/store/selectors'
|
import { tokensSelector } from 'src/logic/tokens/store/selectors'
|
||||||
import { sameAddress, ZERO_ADDRESS } from 'src/logic/wallets/ethAddresses'
|
|
||||||
import { getNetworkInfo } from 'src/config'
|
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import { currentCurrencySelector } from 'src/logic/currencyValues/store/selectors'
|
import { currentCurrencySelector } from 'src/logic/currencyValues/store/selectors'
|
||||||
|
|
||||||
|
@ -27,24 +25,20 @@ interface ExtractedData {
|
||||||
tokens: List<Token>
|
tokens: List<Token>
|
||||||
}
|
}
|
||||||
|
|
||||||
const { nativeCoin } = getNetworkInfo()
|
|
||||||
|
|
||||||
const extractDataFromResult = (currentTokens: TokenState) => (
|
const extractDataFromResult = (currentTokens: TokenState) => (
|
||||||
acc: ExtractedData,
|
acc: ExtractedData,
|
||||||
{ balance, fiatBalance, tokenInfo }: TokenBalance,
|
{ balance, fiatBalance, tokenInfo }: TokenBalance,
|
||||||
): ExtractedData => {
|
): ExtractedData => {
|
||||||
const { address: tokenAddress, decimals } = tokenInfo
|
const { address, decimals } = tokenInfo
|
||||||
if (sameAddress(tokenAddress, ZERO_ADDRESS) || sameAddress(tokenAddress, nativeCoin.address)) {
|
|
||||||
acc.ethBalance = humanReadableValue(balance, 18)
|
|
||||||
}
|
|
||||||
acc.balances = acc.balances.merge({
|
acc.balances = acc.balances.merge({
|
||||||
[tokenAddress]: {
|
[address]: {
|
||||||
fiatBalance,
|
fiatBalance,
|
||||||
tokenBalance: humanReadableValue(balance, Number(decimals)),
|
tokenBalance: humanReadableValue(balance, Number(decimals)),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (currentTokens && !currentTokens.get(tokenAddress)) {
|
if (currentTokens && !currentTokens.get(address)) {
|
||||||
acc.tokens = acc.tokens.push(makeToken({ ...tokenInfo }))
|
acc.tokens = acc.tokens.push(makeToken({ ...tokenInfo }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { useDispatch, useSelector } from 'react-redux'
|
||||||
import Block from 'src/components/layout/Block'
|
import Block from 'src/components/layout/Block'
|
||||||
import Col from 'src/components/layout/Col'
|
import Col from 'src/components/layout/Col'
|
||||||
import Row from 'src/components/layout/Row'
|
import Row from 'src/components/layout/Row'
|
||||||
import { getNetworkInfo } from 'src/config'
|
|
||||||
import { createTransaction, CreateTransactionArgs } from 'src/logic/safe/store/actions/createTransaction'
|
import { createTransaction, CreateTransactionArgs } from 'src/logic/safe/store/actions/createTransaction'
|
||||||
import { SafeRecordProps, SpendingLimit } from 'src/logic/safe/store/models/safe'
|
import { SafeRecordProps, SpendingLimit } from 'src/logic/safe/store/models/safe'
|
||||||
import {
|
import {
|
||||||
|
@ -20,7 +19,7 @@ import {
|
||||||
import { MultiSendTx } from 'src/logic/safe/utils/upgradeSafe'
|
import { MultiSendTx } from 'src/logic/safe/utils/upgradeSafe'
|
||||||
import { makeToken, Token } from 'src/logic/tokens/store/model/token'
|
import { makeToken, Token } from 'src/logic/tokens/store/model/token'
|
||||||
import { fromTokenUnit, toTokenUnit } from 'src/logic/tokens/utils/humanReadableValue'
|
import { fromTokenUnit, toTokenUnit } from 'src/logic/tokens/utils/humanReadableValue'
|
||||||
import { sameAddress, ZERO_ADDRESS } from 'src/logic/wallets/ethAddresses'
|
import { sameAddress } from 'src/logic/wallets/ethAddresses'
|
||||||
import { RESET_TIME_OPTIONS } from 'src/routes/safe/components/Settings/SpendingLimit/FormFields/ResetTime'
|
import { RESET_TIME_OPTIONS } from 'src/routes/safe/components/Settings/SpendingLimit/FormFields/ResetTime'
|
||||||
import { AddressInfo, ResetTimeInfo, TokenInfo } from 'src/routes/safe/components/Settings/SpendingLimit/InfoDisplay'
|
import { AddressInfo, ResetTimeInfo, TokenInfo } from 'src/routes/safe/components/Settings/SpendingLimit/InfoDisplay'
|
||||||
import Modal from 'src/routes/safe/components/Settings/SpendingLimit/Modal'
|
import Modal from 'src/routes/safe/components/Settings/SpendingLimit/Modal'
|
||||||
|
@ -34,8 +33,6 @@ import { EditableTxParameters } from 'src/routes/safe/components/Transactions/he
|
||||||
import { TransactionFees } from 'src/components/TransactionsFees'
|
import { TransactionFees } from 'src/components/TransactionsFees'
|
||||||
import { EstimationStatus, useEstimateTransactionGas } from 'src/logic/hooks/useEstimateTransactionGas'
|
import { EstimationStatus, useEstimateTransactionGas } from 'src/logic/hooks/useEstimateTransactionGas'
|
||||||
|
|
||||||
const { nativeCoin } = getNetworkInfo()
|
|
||||||
|
|
||||||
const useExistentSpendingLimit = ({
|
const useExistentSpendingLimit = ({
|
||||||
spendingLimits,
|
spendingLimits,
|
||||||
txToken,
|
txToken,
|
||||||
|
@ -51,9 +48,7 @@ const useExistentSpendingLimit = ({
|
||||||
return useMemo<SpendingLimit | null>(() => {
|
return useMemo<SpendingLimit | null>(() => {
|
||||||
// if `delegate` already exist, check what tokens were delegated to the _beneficiary_ `getTokens(safe, delegate)`
|
// if `delegate` already exist, check what tokens were delegated to the _beneficiary_ `getTokens(safe, delegate)`
|
||||||
const currentDelegate = spendingLimits?.find(
|
const currentDelegate = spendingLimits?.find(
|
||||||
({ delegate, token }) =>
|
({ delegate, token }) => sameAddress(delegate, values.beneficiary) && sameAddress(token, values.token),
|
||||||
sameAddress(delegate, values.beneficiary) &&
|
|
||||||
sameAddress(token, sameAddress(values.token, nativeCoin.address) ? ZERO_ADDRESS : values.token),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// let the user know that is about to replace an existent allowance
|
// let the user know that is about to replace an existent allowance
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { createSelector } from 'reselect'
|
||||||
import { Token } from 'src/logic/tokens/store/model/token'
|
import { Token } from 'src/logic/tokens/store/model/token'
|
||||||
import { tokensSelector } from 'src/logic/tokens/store/selectors'
|
import { tokensSelector } from 'src/logic/tokens/store/selectors'
|
||||||
import { getEthAsToken } from 'src/logic/tokens/utils/tokenHelpers'
|
import { getEthAsToken } from 'src/logic/tokens/utils/tokenHelpers'
|
||||||
import { isUserAnOwner, sameAddress, ZERO_ADDRESS } from 'src/logic/wallets/ethAddresses'
|
import { isUserAnOwner, sameAddress } from 'src/logic/wallets/ethAddresses'
|
||||||
import { userAccountSelector } from 'src/logic/wallets/store/selectors'
|
import { userAccountSelector } from 'src/logic/wallets/store/selectors'
|
||||||
|
|
||||||
import { safeActiveTokensSelector, safeBalancesSelector, safeSelector } from 'src/logic/safe/store/selectors'
|
import { safeActiveTokensSelector, safeBalancesSelector, safeSelector } from 'src/logic/safe/store/selectors'
|
||||||
|
@ -37,7 +37,7 @@ export const extendedSafeTokensSelector = createSelector(
|
||||||
|
|
||||||
if (baseToken) {
|
if (baseToken) {
|
||||||
const updatedBaseToken = baseToken.set('balance', tokenBalance || { tokenBalance: '0', fiatBalance: '0' })
|
const updatedBaseToken = baseToken.set('balance', tokenBalance || { tokenBalance: '0', fiatBalance: '0' })
|
||||||
if (sameAddress(tokenAddress, ZERO_ADDRESS) || sameAddress(tokenAddress, ethAsToken?.address)) {
|
if (sameAddress(tokenAddress, ethAsToken?.address)) {
|
||||||
map.set(tokenAddress, updatedBaseToken.set('logoUri', ethAsToken?.logoUri || baseToken.logoUri))
|
map.set(tokenAddress, updatedBaseToken.set('logoUri', ethAsToken?.logoUri || baseToken.logoUri))
|
||||||
} else {
|
} else {
|
||||||
map.set(tokenAddress, updatedBaseToken)
|
map.set(tokenAddress, updatedBaseToken)
|
||||||
|
|
Loading…
Reference in New Issue