1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

ensure that values written to txParams are hex strings

This commit is contained in:
frankiebee 2017-09-13 14:27:27 -07:00
parent 59909601b8
commit 77a48fb0b1
2 changed files with 10 additions and 1 deletions

View File

@ -212,7 +212,7 @@ module.exports = class TransactionController extends EventEmitter {
const txParams = txMeta.txParams
const fromAddress = txParams.from
// add network/chain id
txParams.chainId = this.getChainId()
txParams.chainId = ethUtil.addHexPrefix(this.getChainId().toString(16))
const ethTx = new Transaction(txParams)
await this.signEthTx(ethTx, fromAddress)
this.txStateManager.setTxStatusSigned(txMeta.id)

View File

@ -1,6 +1,7 @@
const extend = require('xtend')
const EventEmitter = require('events')
const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util')
const txStateHistoryHelper = require('./tx-state-history-helper')
module.exports = class TransactionStateManger extends EventEmitter {
@ -82,6 +83,14 @@ module.exports = class TransactionStateManger extends EventEmitter {
}
updateTx (txMeta) {
if (txMeta.txParams) {
Object.keys(txMeta.txParams).forEach((key) => {
let value = txMeta.txParams[key]
if (typeof value !== 'string') console.error(`${key}: ${value} in txParams is not a string`)
if (!ethUtil.isHexPrefixed(value)) console.error('is not hex prefixed, anything on txParams must be hex prefixed')
})
}
// create txMeta snapshot for history
const currentState = txStateHistoryHelper.snapshotFromTxMeta(txMeta)
// recover previous tx state obj