|
|
|
@ -53,19 +53,18 @@ CodeManager.prototype.resolveStep = function (stepIndex, tx) { |
|
|
|
|
* @param {String} address - address of the contract to get the code from |
|
|
|
|
* @param {Function} cb - callback function, return the bytecode |
|
|
|
|
*/ |
|
|
|
|
CodeManager.prototype.getCode = function (address, cb) { |
|
|
|
|
CodeManager.prototype.getCode = async function (address) { |
|
|
|
|
if (!traceHelper.isContractCreation(address)) { |
|
|
|
|
return this.codeResolver.resolveCode(address).then((code) => { |
|
|
|
|
cb(null, code) |
|
|
|
|
}) |
|
|
|
|
const code = await this.codeResolver.resolveCode(address) |
|
|
|
|
return code |
|
|
|
|
} |
|
|
|
|
var codes = this.codeResolver.getExecutingCodeFromCache(address) |
|
|
|
|
if (codes) { |
|
|
|
|
return cb(null, codes) |
|
|
|
|
return codes |
|
|
|
|
} |
|
|
|
|
const hexCode = this.traceManager.getContractCreationCode(address) |
|
|
|
|
codes = this.codeResolver.cacheExecutingCode(address, hexCode) |
|
|
|
|
cb(null, codes) |
|
|
|
|
return codes |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -120,11 +119,10 @@ CodeManager.prototype.getFunctionFromPC = function (address, pc, sourceMap, ast) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function retrieveCodeAndTrigger (codeMananger, address, stepIndex, tx) { |
|
|
|
|
codeMananger.getCode(address, (error, result) => { |
|
|
|
|
if (error) { |
|
|
|
|
return console.log(error) |
|
|
|
|
} |
|
|
|
|
codeMananger.getCode(address).then((result) => { |
|
|
|
|
retrieveIndexAndTrigger(codeMananger, address, stepIndex, result.instructions) |
|
|
|
|
}).catch((error) => { |
|
|
|
|
return console.log(error) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|