diff --git a/libs/remix-debug/src/code/disassembler.ts b/libs/remix-debug/src/code/disassembler.ts index f9524bb482..3c963b8202 100644 --- a/libs/remix-debug/src/code/disassembler.ts +++ b/libs/remix-debug/src/code/disassembler.ts @@ -2,6 +2,7 @@ import { parseCode } from './codeUtils' import { util } from '@remix-project/remix-lib' +import { bufferToHex } from 'ethereumjs-util' function createExpressions (instructions) { const expressions = [] @@ -36,7 +37,7 @@ function createExpressions (instructions) { function toString (expr) { if (expr.name.slice(0, 4) === 'PUSH') { - return util.hexConvert(expr.pushData) + return bufferToHex(expr.pushData) } else if (expr.name === 'JUMPDEST') { return expr.label + ':' } else if (expr.args) { diff --git a/libs/remix-lib/src/util.ts b/libs/remix-lib/src/util.ts index d17129d958..616134dbcd 100644 --- a/libs/remix-lib/src/util.ts +++ b/libs/remix-lib/src/util.ts @@ -13,20 +13,8 @@ import { BN, bufferToHex, keccak, setLengthLeft, toBuffer } from 'ethereumjs-uti /* ints: IntArray */ -export function hexConvert (ints) { - let ret = '0x' - for (let i = 0; i < ints.length; i++) { - const h = ints[i] - if (h) { - ret += (h <= 0xf ? '0' : '') + h.toString(16) - } else { - ret += '00' - } - } - return ret -} -/** + /** * Converts a hex string to an array of integers. */ export function hexToIntArray (hexString) { @@ -56,22 +44,11 @@ export function hexListFromBNs (bnList) { return ret } -/* - ints: list of IntArrays -*/ -export function hexListConvert (intsList) { - const ret = [] - for (const k in intsList) { - ret.push(this.hexConvert(intsList[k])) - } - return ret -} - /* ints: ints: IntArray */ export function formatMemory (mem) { - const hexMem = this.hexConvert(mem).substr(2) + const hexMem = bufferToHex(mem).substr(2) const ret = [] for (let k = 0; k < hexMem.length; k += 32) { const row = hexMem.substr(k, 32) diff --git a/libs/remix-lib/src/web3Provider/web3VmProvider.ts b/libs/remix-lib/src/web3Provider/web3VmProvider.ts index c883899000..367370f928 100644 --- a/libs/remix-lib/src/web3Provider/web3VmProvider.ts +++ b/libs/remix-lib/src/web3Provider/web3VmProvider.ts @@ -1,6 +1,6 @@ -import { hexConvert, hexListFromBNs, formatMemory } from '../util' +import { hexListFromBNs, formatMemory } from '../util' import { normalizeHexAddress } from '../helpers/uiHelper' -import { toChecksumAddress, BN, toBuffer, Address } from 'ethereumjs-util' +import { toChecksumAddress, BN, bufferToHex, Address } from 'ethereumjs-util' import Web3 from 'web3' export class Web3VmProvider { @@ -96,7 +96,7 @@ export class Web3VmProvider { async txWillProcess (data) { this.incr++ - this.processingHash = hexConvert(data.hash()) + this.processingHash = bufferToHex(data.hash()) this.vmTraces[this.processingHash] = { gas: '0x0', return: '0x0', @@ -109,7 +109,7 @@ export class Web3VmProvider { tx['to'] = toChecksumAddress(data.to.toString()) } this.processingAddress = tx['to'] - tx['input'] = hexConvert(data.data) + tx['input'] = bufferToHex(data.data) tx['gas'] = data.gasLimit.toString(10) if (data.value) { tx['value'] = data.value.toString(10) @@ -164,7 +164,7 @@ export class Web3VmProvider { this.vmTraces[this.processingHash].return = toChecksumAddress(address) this.txsReceipt[this.processingHash].contractAddress = toChecksumAddress(address) } else if (data.execResult.returnValue) { - this.vmTraces[this.processingHash].return = hexConvert(data.execResult.returnValue) + this.vmTraces[this.processingHash].return = bufferToHex(data.execResult.returnValue) } else { this.vmTraces[this.processingHash].return = '0x' } @@ -235,7 +235,7 @@ export class Web3VmProvider { getCode (address, cb) { address = toChecksumAddress(address) this.vm.stateManager.getContractCode(Address.fromString(address)).then((result) => { - cb(null, hexConvert(result)) + cb(null, bufferToHex(result)) }).catch((error) => { cb(error) })