Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: updated safe gas multiplier #2585

Merged
merged 2 commits into from
May 3, 2021
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
4 changes: 3 additions & 1 deletion src/common/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const REWARD_TOKEN = process.env.REWARD_TOKEN_OVERRIDE
? process.env.REWARD_TOKEN_OVERRIDE.toUpperCase()
: null;

const SAFE_GAS_MULTIPLIER = +process.env.SAFE_GAS_MULTIPLIER;

// KYCC ENV variables
const KYCC_API_OVERRIDE = process.env.KYCC_API_OVERRIDE;
// Incorporations ENV variables
Expand All @@ -43,7 +45,6 @@ const BANKACCOUNTS_API_URL = process.env.BANKACCOUNTS_API_URL;
const PASSPORTS_TEMPLATE_OVERRIDE = process.env.PASSPORTS_TEMPLATE_OVERRIDE;
const PASSPORTS_PRICE_OVERRIDE = process.env.PASSPORTS_PRICE_OVERRIDE;
const PASSPORTS_API_URL = process.env.PASSPORTS_API_URL;

const COUNTRY_INFO_URL = process.env.COUNTRY_INFO_URL;
const ALL_COUNTRIES_INFO_URL = process.env.ALL_COUNTRIES_INFO_URL;
const MATOMO_SITE = process.env.MATOMO_SITE;
Expand All @@ -64,6 +65,7 @@ const common = {
defaultLanguage: 'en',
forceUpdateAttributes: process.env.FORCE_UPDATE_ATTRIBUTES === 'true' && !isTestMode(),
userAgent: `SelfKeyIDW/${pkg.version}`,
safeGasMultiplier: SAFE_GAS_MULTIPLIER || 1.5,
airtableBaseUrl: 'https://airtable.selfkey.org/airtable?tableName=',

exchangeRateApiUrl: 'https://api.exchangeratesapi.io',
Expand Down
12 changes: 11 additions & 1 deletion src/main/token/token-service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
import config from 'common/config';
import Token from './token';
import { getGlobalContext } from 'common/context';
import { BigNumber } from 'bignumber.js';
Expand Down Expand Up @@ -51,6 +52,15 @@ export class TokenService {
};
}

/**
*
* @param {*} contractAddress
* @param {*} address
* @param {*} amount
* @param {*} decimal
* @param {*} fromAddress
* @returns
*/
async getGasLimit(contractAddress, address, amount, decimal, fromAddress) {
const tokenContract = new this.web3Service.web3.eth.Contract(
this.contractABI,
Expand All @@ -63,7 +73,7 @@ export class TokenService {
const estimate = await tokenContract.methods
.transfer(address, amountWithDecimals)
.estimateGas({ from: fromAddress });
return Math.round(Math.min(estimate * 1.1, MAX_GAS));
return Math.round(Math.min(estimate * config.safeGasMultiplier, MAX_GAS));
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/renderer/wallet-connect/transaction-container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export const TransactionContainer = () => {
walletConnectSelectors.selectWalletConnect
);

console.log(tx);

const [gasPrice, setGasPrice] = useState(tx.gasPrice);
const [gasLimit, setGasLimit] = useState(tx.gas);
const [nonce, setNonce] = useState(tx.nonce ? tx.nonce : defaultNonce);
Expand Down