Commit 7bb65899 authored by yann300's avatar yann300

fix debugging

parent c3bae30a
...@@ -57,7 +57,7 @@ export function toBN (value) { ...@@ -57,7 +57,7 @@ export function toBN (value) {
if (value instanceof BN) { if (value instanceof BN) {
return value return value
} else if (value.match && value.match(/^(0x)?([a-f0-9]*)$/)) { } else if (value.match && value.match(/^(0x)?([a-f0-9]*)$/)) {
value = unpadHexString(value.replace(/^(0x)/, '')) value = unpadHexString(value)
value = new BN(value === '' ? '0' : value, 16) value = new BN(value === '' ? '0' : value, 16)
} else if (!isNaN(value)) { } else if (!isNaN(value)) {
value = new BN(value) value = new BN(value)
......
'use strict' 'use strict'
import { BN, bufferToHex, keccak, setLengthLeft } from 'ethereumjs-util' import { BN, bufferToHex, keccak, setLengthLeft, intToBuffer } from 'ethereumjs-util'
/* /*
contains misc util: @TODO should be splitted contains misc util: @TODO should be splitted
...@@ -165,10 +165,13 @@ export function buildCallPath (index, rootCall) { ...@@ -165,10 +165,13 @@ export function buildCallPath (index, rootCall) {
*/ */
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
export function sha3_256 (value) { export function sha3_256 (value) {
if (typeof value === 'string' && value.indexOf('0x') !== 0) { if (typeof value === 'string') {
value = '0x' + value value = Buffer.from(value.replace('0x', ''), 'hex')
} }
const retInBuffer: Buffer = keccak(setLengthLeft(Buffer.from(value.replace('0x', ''), 'hex'), 32)) if (Number.isInteger(value)) {
value = intToBuffer(value)
}
const retInBuffer: Buffer = keccak(setLengthLeft(value, 32))
return bufferToHex(retInBuffer) return bufferToHex(retInBuffer)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment