mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-27 09:54:51 +00:00
remove fee calculation from send funds modal
This commit is contained in:
parent
48eb83c288
commit
a25da6d869
@ -1,5 +1,4 @@
|
||||
// @flow
|
||||
import { getSignaturesFrom } from '~/utils/storage/signatures'
|
||||
import { BigNumber } from 'bignumber.js'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
||||
@ -90,6 +89,7 @@ export const generateTxGasEstimateFrom = async (
|
||||
export const calculateTxFee = async (
|
||||
safe: any,
|
||||
safeAddress: string,
|
||||
from: string,
|
||||
data: string,
|
||||
to: string,
|
||||
valueInWei: number,
|
||||
@ -100,42 +100,16 @@ export const calculateTxFee = async (
|
||||
if (!safeInstance) {
|
||||
safeInstance = await getSafeEthereumInstance(safeAddress)
|
||||
}
|
||||
window.safeInstance = safeInstance
|
||||
|
||||
// Estimate safe transaction (need to be called with "from" set to the safe address)
|
||||
const nonce = await safeInstance.nonce()
|
||||
const threshold = await safeInstance.getThreshold()
|
||||
const txGasEstimate = await generateTxGasEstimateFrom(safeInstance, safeAddress, data, to, valueInWei, operation)
|
||||
const dataGasEstimate = await estimateDataGas(
|
||||
safeInstance,
|
||||
to,
|
||||
valueInWei,
|
||||
data,
|
||||
operation,
|
||||
txGasEstimate,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
nonce,
|
||||
Number(threshold),
|
||||
safeAddress,
|
||||
)
|
||||
console.log({ dataGasEstimate, txGasEstimate })
|
||||
|
||||
const sigs = `0x000000000000000000000000${'0xbc2BB26a6d821e69A38016f3858561a1D80d4182'.replace(
|
||||
// https://gnosis-safe.readthedocs.io/en/latest/contracts/signatures.html#pre-validated-signatures
|
||||
const sigs = `0x000000000000000000000000${from.replace(
|
||||
'0x',
|
||||
'',
|
||||
)}0000000000000000000000000000000000000000000000000000000000000000` + '01'
|
||||
console.log({
|
||||
to,
|
||||
valueInWei,
|
||||
data,
|
||||
operation,
|
||||
txGasEstimate: 0,
|
||||
dataGasEstimate: 0,
|
||||
gasPrice: 0,
|
||||
txGasToken: '0x0000000000000000000000000000000000000000',
|
||||
refundReceiver: '0x0000000000000000000000000000000000000000',
|
||||
sigs,
|
||||
})
|
||||
)}000000000000000000000000000000000000000000000000000000000000000001`
|
||||
|
||||
// we get gas limit from this call, then it needs to be multiplied by the gas price
|
||||
// https://safe-relay.gnosis.pm/api/v1/gas-station/
|
||||
// https://safe-relay.rinkeby.gnosis.pm/api/v1/about/
|
||||
const estimate = await safeInstance.execTransaction.estimateGas(
|
||||
to,
|
||||
valueInWei,
|
||||
|
@ -1,5 +1,5 @@
|
||||
// @flow
|
||||
import React, { useState } from 'react'
|
||||
import React from 'react'
|
||||
import { List } from 'immutable'
|
||||
import { withStyles } from '@material-ui/core/styles'
|
||||
import { OnChange } from 'react-final-form-listeners'
|
||||
@ -14,9 +14,7 @@ import Block from '~/components/layout/Block'
|
||||
import Hairline from '~/components/layout/Hairline'
|
||||
import ButtonLink from '~/components/layout/ButtonLink'
|
||||
import Field from '~/components/forms/Field'
|
||||
import Bold from '~/components/layout/Bold'
|
||||
import TextField from '~/components/forms/TextField'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { type Token } from '~/logic/tokens/store/model/token'
|
||||
import {
|
||||
composeValidators,
|
||||
@ -28,7 +26,6 @@ import {
|
||||
} from '~/components/forms/validator'
|
||||
import TokenSelectField from '~/routes/safe/components/Balances/SendModal/screens/SendFunds/TokenSelectField'
|
||||
import SafeInfo from '~/routes/safe/components/Balances/SendModal/screens/SendFunds/SafeInfo'
|
||||
import { calculateTxFee } from '~/logic/safe/transactions'
|
||||
import ArrowDown from './assets/arrow-down.svg'
|
||||
import { styles } from './style'
|
||||
|
||||
@ -42,12 +39,9 @@ type Props = {
|
||||
tokens: List<Token>,
|
||||
}
|
||||
|
||||
const web3 = getWeb3()
|
||||
|
||||
const SendFunds = ({
|
||||
classes, onClose, safeAddress, etherScanLink, safeName, ethBalance, tokens,
|
||||
}: Props) => {
|
||||
const [txFee, setTxFee] = useState(0)
|
||||
const handleSubmit = () => {}
|
||||
const formMutators = {
|
||||
setMax: (args, state, utils) => {
|
||||
@ -85,13 +79,7 @@ const SendFunds = ({
|
||||
{(...args) => {
|
||||
const formState = args[2]
|
||||
const mutators = args[3]
|
||||
const { token, recipientAddress, amount } = formState.values
|
||||
|
||||
const estimateFee = async () => {
|
||||
const valueInWei = web3.utils.toWei(amount, 'ether')
|
||||
const fee = await calculateTxFee(null, safeAddress, '0x', recipientAddress, valueInWei, 0)
|
||||
setTxFee(fee)
|
||||
}
|
||||
const { token } = formState.values
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
@ -144,11 +132,6 @@ const SendFunds = ({
|
||||
}
|
||||
}
|
||||
/>
|
||||
<OnChange name="amount">
|
||||
{() => {
|
||||
estimateFee()
|
||||
}}
|
||||
</OnChange>
|
||||
<OnChange name="token">
|
||||
{() => {
|
||||
mutators.onTokenChange()
|
||||
@ -156,22 +139,6 @@ const SendFunds = ({
|
||||
</OnChange>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row margin="xs">
|
||||
<Col>
|
||||
<Paragraph size="md" color="disabled" style={{ letterSpacing: '-0.5px' }} noMargin>
|
||||
Fee
|
||||
</Paragraph>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col layout="column">
|
||||
<Bold>
|
||||
{web3.utils.fromWei(web3.utils.toBN(txFee), 'ether')}
|
||||
{' '}
|
||||
ETH
|
||||
</Bold>
|
||||
</Col>
|
||||
</Row>
|
||||
</React.Fragment>
|
||||
)
|
||||
}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user