mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Fix normalizeMsgData function to always return hex prefixed
This commit is contained in:
parent
26ea5993a9
commit
e66e755766
@ -112,7 +112,7 @@ module.exports = class PersonalMessageManager extends EventEmitter{
|
||||
try {
|
||||
const stripped = ethUtil.stripHexPrefix(data)
|
||||
if (stripped.match(hexRe)) {
|
||||
return stripped
|
||||
return ethUtil.addHexPrefix(stripped)
|
||||
}
|
||||
} catch (e) {
|
||||
log.debug(`Message was not hex encoded, interpreting as utf8.`)
|
||||
|
@ -97,13 +97,13 @@ describe('Personal Message Manager', function() {
|
||||
it('tolerates a hex prefix', function() {
|
||||
var input = '0x12'
|
||||
var output = messageManager.normalizeMsgData(input)
|
||||
assert.equal(output, '12', 'un modified')
|
||||
assert.equal(output, '0x12', 'un modified')
|
||||
})
|
||||
|
||||
it('tolerates normal hex', function() {
|
||||
var input = '12'
|
||||
var output = messageManager.normalizeMsgData(input)
|
||||
assert.equal(output, '12', 'adds prefix')
|
||||
assert.equal(output, '0x12', 'adds prefix')
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user