Merge pull request #377 from poanetwork/vb-fix-sign-msg
Sign message screen: do not decode message if it is not hex encoded
This commit is contained in:
commit
ee1fece5c4
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
## Current Master
|
## Current Master
|
||||||
|
|
||||||
- [#364](https://github.com/poanetwork/nifty-wallet/pull/364) - Fix notifications order in batch requests
|
- [#377](https://github.com/poanetwork/nifty-wallet/pull/377) - (Fix) Sign message screen: do not decode message if it is not hex encoded
|
||||||
|
- [#364](https://github.com/poanetwork/nifty-wallet/pull/364) - (Fix) notifications order in batch requests
|
||||||
|
|
||||||
## 5.0.3 Fri May 01 2020
|
## 5.0.3 Fri May 01 2020
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const Component = require('react').Component
|
import { Component } from 'react'
|
||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const ethUtil = require('ethereumjs-util')
|
import ethUtil from 'ethereumjs-util'
|
||||||
const extend = require('xtend')
|
import extend from 'xtend'
|
||||||
|
|
||||||
module.exports = BinaryRenderer
|
module.exports = BinaryRenderer
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ function BinaryRenderer () {
|
||||||
BinaryRenderer.prototype.render = function () {
|
BinaryRenderer.prototype.render = function () {
|
||||||
const props = this.props
|
const props = this.props
|
||||||
const { value, style } = props
|
const { value, style } = props
|
||||||
const text = this.hexToText(value)
|
const message = this.msgHexToText(value)
|
||||||
|
|
||||||
const defaultStyle = extend({
|
const defaultStyle = extend({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
@ -30,16 +30,16 @@ BinaryRenderer.prototype.render = function () {
|
||||||
h('textarea.font-small', {
|
h('textarea.font-small', {
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
defaultValue: text,
|
defaultValue: message,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryRenderer.prototype.hexToText = function (hex) {
|
BinaryRenderer.prototype.msgHexToText = (hex) => {
|
||||||
try {
|
try {
|
||||||
const stripped = ethUtil.stripHexPrefix(hex)
|
const stripped = ethUtil.stripHexPrefix(hex)
|
||||||
const buff = Buffer.from(stripped, 'hex')
|
const buff = Buffer.from(stripped, 'hex')
|
||||||
return buff.toString('utf8')
|
return buff.length === 32 ? hex : buff.toString('utf8')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return hex
|
return hex
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,12 @@ describe('BinaryRenderer', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('recovers message', function () {
|
it('recovers message', function () {
|
||||||
const result = binaryRenderer.hexToText(hex)
|
const result = binaryRenderer.msgHexToText(hex)
|
||||||
assert.equal(result, message)
|
assert.equal(result, message)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('recovers message with hex prefix', function () {
|
it('recovers message with hex prefix', function () {
|
||||||
const result = binaryRenderer.hexToText('0x' + hex)
|
const result = binaryRenderer.msgHexToText('0x' + hex)
|
||||||
assert.equal(result, message)
|
assert.equal(result, message)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue