aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2019-06-19 20:08:54 +0800
committerfrankiebee <frankie.diamond@gmail.com>2019-06-19 20:36:24 +0800
commit5cf5359e788d7c93495da2ace5c9f81648b67fea (patch)
tree2e3db2c1de1d7a142ba080099e82aa585204ddf6 /app
parent748801f4179d353959f40049cf6ca27851eebd0e (diff)
downloadtangerine-wallet-browser-5cf5359e788d7c93495da2ace5c9f81648b67fea.tar
tangerine-wallet-browser-5cf5359e788d7c93495da2ace5c9f81648b67fea.tar.gz
tangerine-wallet-browser-5cf5359e788d7c93495da2ace5c9f81648b67fea.tar.bz2
tangerine-wallet-browser-5cf5359e788d7c93495da2ace5c9f81648b67fea.tar.lz
tangerine-wallet-browser-5cf5359e788d7c93495da2ace5c9f81648b67fea.tar.xz
tangerine-wallet-browser-5cf5359e788d7c93495da2ace5c9f81648b67fea.tar.zst
tangerine-wallet-browser-5cf5359e788d7c93495da2ace5c9f81648b67fea.zip
transactions - always hexprefix txParams on update; fixes #6724
Diffstat (limited to 'app')
-rw-r--r--app/scripts/controllers/transactions/lib/util.js8
-rw-r--r--app/scripts/controllers/transactions/tx-state-manager.js6
2 files changed, 6 insertions, 8 deletions
diff --git a/app/scripts/controllers/transactions/lib/util.js b/app/scripts/controllers/transactions/lib/util.js
index 84f7592a0..5a8a0cefe 100644
--- a/app/scripts/controllers/transactions/lib/util.js
+++ b/app/scripts/controllers/transactions/lib/util.js
@@ -17,8 +17,8 @@ module.exports = {
// functions that handle normalizing of that key in txParams
const normalizers = {
- from: from => addHexPrefix(from).toLowerCase(),
- to: to => addHexPrefix(to).toLowerCase(),
+ from: (from, LowerCase = true) => LowerCase ? addHexPrefix(from).toLowerCase() : addHexPrefix(from),
+ to: (to, LowerCase = true) => LowerCase ? addHexPrefix(to).toLowerCase() : addHexPrefix(to),
nonce: nonce => addHexPrefix(nonce),
value: value => addHexPrefix(value),
data: data => addHexPrefix(data),
@@ -31,11 +31,11 @@ const normalizers = {
@param txParams {object}
@returns {object} normalized txParams
*/
-function normalizeTxParams (txParams) {
+function normalizeTxParams (txParams, LowerCase) {
// apply only keys in the normalizers
const normalizedTxParams = {}
for (const key in normalizers) {
- if (txParams[key]) normalizedTxParams[key] = normalizers[key](txParams[key])
+ if (txParams[key]) normalizedTxParams[key] = normalizers[key](txParams[key], LowerCase)
}
return normalizedTxParams
}
diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js
index 1a2cb5dee..9504f43a5 100644
--- a/app/scripts/controllers/transactions/tx-state-manager.js
+++ b/app/scripts/controllers/transactions/tx-state-manager.js
@@ -1,11 +1,10 @@
const extend = require('xtend')
const EventEmitter = require('safe-event-emitter')
const ObservableStore = require('obs-store')
-const ethUtil = require('ethereumjs-util')
const log = require('loglevel')
const txStateHistoryHelper = require('./lib/tx-state-history-helper')
const createId = require('../../lib/random-id')
-const { getFinalStates } = require('./lib/util')
+const { getFinalStates, normalizeTxParams } = require('./lib/util')
/**
TransactionStateManager is responsible for the state of a transaction and
storing the transaction
@@ -180,7 +179,7 @@ class TransactionStateManager extends EventEmitter {
if (typeof txMeta.txParams.data === 'undefined') {
delete txMeta.txParams.data
}
-
+ txMeta.txParams = normalizeTxParams(txMeta.txParams, false)
this.validateTxParams(txMeta.txParams)
}
@@ -227,7 +226,6 @@ class TransactionStateManager extends EventEmitter {
break
default:
if (typeof value !== 'string') throw new Error(`${key} in txParams is not a string. got: (${value})`)
- if (!ethUtil.isHexPrefixed(value)) throw new Error(`${key} in txParams is not hex prefixed. got: (${value})`)
break
}
})