From 3af174b5907ff0c5da6f2f43930d55c796531c1d Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Wed, 9 Jun 2021 22:18:05 -0230 Subject: [PATCH] Stringify gas estimate in backend, before it is serialized and sent to ui (#11266) * Stringify gas estimate in backend, before it is serialized and sent to ui * Fix send.utils.test.js --- app/scripts/metamask-controller.js | 2 +- ui/pages/send/send.utils.js | 6 +----- ui/pages/send/send.utils.test.js | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 67b8286a7..ecee4dd0b 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1937,7 +1937,7 @@ export default class MetamaskController extends EventEmitter { return reject(err); } - return resolve(res); + return resolve(res.toString(16)); }, ); }); diff --git a/ui/pages/send/send.utils.js b/ui/pages/send/send.utils.js index 1603061e2..889015a77 100644 --- a/ui/pages/send/send.utils.js +++ b/ui/pages/send/send.utils.js @@ -254,11 +254,7 @@ async function estimateGasForSend({ // run tx try { const estimatedGas = await estimateGasMethod(paramsForGasEstimate); - const estimateWithBuffer = addGasBuffer( - estimatedGas.toString(16), - blockGasLimit, - 1.5, - ); + const estimateWithBuffer = addGasBuffer(estimatedGas, blockGasLimit, 1.5); return addHexPrefix(estimateWithBuffer); } catch (error) { const simulationFailed = diff --git a/ui/pages/send/send.utils.test.js b/ui/pages/send/send.utils.test.js index 06d3d8edc..91b94d8ef 100644 --- a/ui/pages/send/send.utils.test.js +++ b/ui/pages/send/send.utils.test.js @@ -290,7 +290,7 @@ describe('send utils', () => { if (typeof to === 'string' && to.match(/willFailBecauseOf:/u)) { throw new Error(to.match(/:(.+)$/u)[1]); } - return { toString: (n) => `0xabc${n}` }; + return '0xabc16'; }), }; const baseexpectedCall = {