diff options
author | frankiebee <frankie.diamond@gmail.com> | 2018-04-05 11:18:44 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2018-04-05 13:29:43 +0800 |
commit | 343f0e9e80af804f256a5fa1a55b136c8241c368 (patch) | |
tree | fa82e5e3741e3a39095afcaf15ab52b65dab6e7c | |
parent | 1153120fe84e9d4cde47a7e416028be0fec3c61c (diff) | |
download | tangerine-wallet-browser-343f0e9e80af804f256a5fa1a55b136c8241c368.tar tangerine-wallet-browser-343f0e9e80af804f256a5fa1a55b136c8241c368.tar.gz tangerine-wallet-browser-343f0e9e80af804f256a5fa1a55b136c8241c368.tar.bz2 tangerine-wallet-browser-343f0e9e80af804f256a5fa1a55b136c8241c368.tar.lz tangerine-wallet-browser-343f0e9e80af804f256a5fa1a55b136c8241c368.tar.xz tangerine-wallet-browser-343f0e9e80af804f256a5fa1a55b136c8241c368.tar.zst tangerine-wallet-browser-343f0e9e80af804f256a5fa1a55b136c8241c368.zip |
transactions - remove unnecessary keys on txParams
-rw-r--r-- | app/scripts/controllers/transactions.js | 12 | ||||
-rw-r--r-- | test/unit/tx-controller-test.js | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index a73a8b36d..0b78d62f1 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -315,6 +315,18 @@ module.exports = class TransactionController extends EventEmitter { // _normalizeTxParams (txParams) { + const acceptableKeys = [ + 'from', + 'to', + 'nonce', + 'value', + 'data', + 'gas', + 'gasPrice', + ] + Object.keys(txParams).forEach((key) => { + if (!acceptableKeys.includes(key)) delete txParams[key] + }) delete txParams.chainId if ( !txParams.to ) { diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js index 3fec9758f..e552464cf 100644 --- a/test/unit/tx-controller-test.js +++ b/test/unit/tx-controller-test.js @@ -239,6 +239,7 @@ describe('Transaction Controller', function () { from: 'a7df1beDBF813f57096dF77FCd515f0B3900e402', to: null, data: '68656c6c6f20776f726c64', + random: 'hello world', } txController._normalizeTxParams(txParams) @@ -247,7 +248,7 @@ describe('Transaction Controller', function () { assert(!txParams.to, 'their should be no to address if null') assert.equal(txParams.from.slice(0, 2), '0x', 'from should be hexPrefixd') assert.equal(txParams.data.slice(0, 2), '0x', 'data should be hexPrefixd') - + assert(!('random' in txParams), 'their should be no random key in txParams') txParams.to = 'a7df1beDBF813f57096dF77FCd515f0B3900e402' txController._normalizeTxParams(txParams) |