fix debugging

pull/1122/head
yann300 4 years ago
parent c3bae30a40
commit 7bb6589903
  1. 2
      libs/remix-debug/src/solidity-decoder/types/util.ts
  2. 11
      libs/remix-lib/src/util.ts

@ -57,7 +57,7 @@ export function toBN (value) {
if (value instanceof BN) {
return value
} 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)
} else if (!isNaN(value)) {
value = new BN(value)

@ -1,5 +1,5 @@
'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
@ -165,10 +165,13 @@ export function buildCallPath (index, rootCall) {
*/
// eslint-disable-next-line camelcase
export function sha3_256 (value) {
if (typeof value === 'string' && value.indexOf('0x') !== 0) {
value = '0x' + value
if (typeof value === 'string') {
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)
}

Loading…
Cancel
Save