Commit e801843a authored by Luke Schoen's avatar Luke Schoen
Browse files

fix: Add Gas Limit of 150000 for all transactions with a value in the data field

parent 6cc59cfd
Pipeline #149655 failed with stage
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
"package": "electron-builder", "package": "electron-builder",
"prerelease": "./scripts/revertElectronBug.sh", "prerelease": "./scripts/revertElectronBug.sh",
"release": "electron-builder", "release": "electron-builder",
"start": "cross-env ELECTRON_START_URL=http://localhost:3000 electron-webpack dev --chain goerli", "start": "cross-env ELECTRON_START_URL=http://localhost:3000 electron-webpack dev",
"test": "jest --all --color --coverage" "test": "jest --all --color --coverage"
}, },
"dependencies": { "dependencies": {
......
...@@ -9,6 +9,7 @@ import { fromWei, toWei } from '@parity/api/lib/util/wei'; ...@@ -9,6 +9,7 @@ import { fromWei, toWei } from '@parity/api/lib/util/wei';
import i18n, { packageNS } from '../../../i18n'; import i18n, { packageNS } from '../../../i18n';
import { chainIdToString, isNotErc20TokenAddress } from '../../../utils/chain'; import { chainIdToString, isNotErc20TokenAddress } from '../../../utils/chain';
import { GAS_LIMIT_DATA } from '../../../utils/transaction';
class TxDetails extends Component { class TxDetails extends Component {
renderDetails = () => { renderDetails = () => {
...@@ -51,7 +52,7 @@ ${this.renderTotalAmount()}`; ...@@ -51,7 +52,7 @@ ${this.renderTotalAmount()}`;
// higher Gas Limit. On // higher Gas Limit. On
if (values.data) { if (values.data) {
return i18n.t(`${packageNS}:tx.form.details.gas_limit`, { return i18n.t(`${packageNS}:tx.form.details.gas_limit`, {
gas_limit: new BigNumber(200000) gas_limit: GAS_LIMIT_DATA
}); });
} }
......
...@@ -18,6 +18,7 @@ import EthereumTx from 'ethereumjs-tx'; ...@@ -18,6 +18,7 @@ import EthereumTx from 'ethereumjs-tx';
const debug = Debug('transaction'); const debug = Debug('transaction');
const GAS_MULT_FACTOR = 1.25; // Since estimateGas is not always accurate, we add a 25% factor for buffer. const GAS_MULT_FACTOR = 1.25; // Since estimateGas is not always accurate, we add a 25% factor for buffer.
export const GAS_LIMIT_DATA = new BigNumber(150000);
export const contractForToken = memoize(tokenAddress => export const contractForToken = memoize(tokenAddress =>
makeContract(tokenAddress, abi) makeContract(tokenAddress, abi)
...@@ -100,7 +101,7 @@ export const txForErc20 = (tx, token) => { ...@@ -100,7 +101,7 @@ export const txForErc20 = (tx, token) => {
}; };
if (tx.gas) { if (tx.gas) {
output.options.gas = tx.gas; output.options.gas = tx.data ? GAS_LIMIT_DATA : tx.gas;
} }
return output; return output;
...@@ -120,7 +121,7 @@ export const txForEth = tx => { ...@@ -120,7 +121,7 @@ export const txForEth = tx => {
}; };
// gas field should not be present when the function is called for gas estimation. // gas field should not be present when the function is called for gas estimation.
if (tx.gas) { if (tx.gas) {
output.gas = tx.gas; output.gas = tx.data ? GAS_LIMIT_DATA : tx.gas;
} }
return output; return output;
}; };
...@@ -141,9 +142,12 @@ const getEthereumTx = tx => { ...@@ -141,9 +142,12 @@ const getEthereumTx = tx => {
transactionCount transactionCount
} = tx; } = tx;
// Temporary solution
const gasLimit = data ? GAS_LIMIT_DATA : gas;
const txParams = { const txParams = {
nonce: '0x' + transactionCount.toNumber().toString(16), nonce: '0x' + transactionCount.toNumber().toString(16),
gasLimit: '0x' + gas.toNumber().toString(16), gasLimit: '0x' + gasLimit.toNumber().toString(16),
gasPrice: toWei(gasPrice, 'shannon').toNumber(), gasPrice: toWei(gasPrice, 'shannon').toNumber(),
chainId chainId
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment