Fix a hash displayed in tooltip when signing arbitrary data (#6283)

* Allow connections from firefox extension.

* Displaying actual data that will be signed on hover.

* Display a tooltip.

* Revert "Allow connections from firefox extension."

This reverts commit d3323b76fe28564c2366ceec3d891de19884192f.
This commit is contained in:
Tomasz Drwięga
2017-08-13 17:41:08 +02:00
committed by Gav Wood
parent 604ea5d684
commit b5b6e3dd2a
5 changed files with 65 additions and 5 deletions

View File

@@ -75,7 +75,10 @@ export function bytesToAscii (bytes) {
}
export function asciiToHex (string) {
return '0x' + string.split('').map((s) => s.charCodeAt(0).toString(16)).join('');
return '0x' + string.split('')
.map(s => s.charCodeAt(0))
.map(s => s < 0x10 ? '0' + s.toString(16) : s.toString(16))
.join('');
}
export function padRight (input, length) {

View File

@@ -67,6 +67,7 @@ describe('api/util/format', () => {
it('correctly converts a non-empty string', () => {
expect(asciiToHex('abc')).to.equal('0x616263');
expect(asciiToHex('a\nb')).to.equal('0x610a62');
});
});

View File

@@ -17,7 +17,7 @@
import { isAddress as isAddressValid, toChecksumAddress } from '../../abi/util/address';
import { abiDecode, decodeCallData, decodeMethodInput, methodToAbi } from './decode';
import { abiEncode, abiUnencode, abiSignature, encodeMethodCallAbi } from './encode';
import { bytesToHex, hexToAscii, asciiToHex, cleanupValue } from './format';
import { bytesToHex, hexToAscii, hexToBytes, asciiToHex, cleanupValue } from './format';
import { fromWei, toWei } from './wei';
import { sha3 } from './sha3';
import { isArray, isFunction, isHex, isInstanceOf, isString } from './types';
@@ -37,6 +37,7 @@ export default {
isString,
bytesToHex,
hexToAscii,
hexToBytes,
asciiToHex,
createIdentityImg,
decodeCallData,