Fixed encoding

feature/default_network_editable
Dan Finlay 8 years ago
parent 6253885e28
commit fba7a50e1b
  1. 15
      app/scripts/lib/personal-message-manager.js
  2. 2
      test/unit/personal-message-manager-test.js

@ -118,21 +118,8 @@ module.exports = class PersonalMessageManager extends EventEmitter{
log.debug(`Message was not hex encoded, interpreting as utf8.`)
}
return this.hexEncode(data)
}
hexEncode(text){
var hex, i
var result = ''
for (i = 0; i < text.length; i++) {
hex = text.charCodeAt(i).toString(16)
result += ('000' + hex).slice(-4)
}
return '0x' + result
return ethUtil.bufferToHex(new Buffer(data, 'utf8'))
}
}

@ -91,7 +91,7 @@ describe('Personal Message Manager', function() {
it('converts text to a utf8 hex string', function() {
var input = 'hello'
var output = messageManager.normalizeMsgData(input)
assert.equal(output, '0x00680065006c006c006f', 'predictably hex encoded')
assert.equal(output, '0x68656c6c6f', 'predictably hex encoded')
})
it('tolerates a hex prefix', function() {

Loading…
Cancel
Save