From 432d6508ba4a39fefed62e563abf8426c41f5c9f 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 55141af09..d9f6c1e15 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1962,7 +1962,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 12ebc901f..1d7fb3562 100644 --- a/ui/pages/send/send.utils.js +++ b/ui/pages/send/send.utils.js @@ -253,11 +253,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 f1da44f9b..02b45f1fa 100644 --- a/ui/pages/send/send.utils.test.js +++ b/ui/pages/send/send.utils.test.js @@ -289,7 +289,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 = {