refactor getContractCreationCode

pull/62/head
Iuri Matias 4 years ago committed by aniket-engg
parent 98494c3de6
commit 13fe9cb640
  1. 9
      libs/remix-lib/src/code/codeManager.js
  2. 9
      libs/remix-lib/src/trace/traceManager.js
  3. 15
      libs/remix-lib/test/traceManager.js

@ -63,12 +63,9 @@ CodeManager.prototype.getCode = function (address, cb) {
if (codes) {
return cb(null, codes)
}
this.traceManager.getContractCreationCode(address, (error, hexCode) => {
if (!error) {
codes = this.codeResolver.cacheExecutingCode(address, hexCode)
cb(null, codes)
}
})
const hexCode = this.traceManager.getContractCreationCode(address)
codes = this.codeResolver.cacheExecutingCode(address, hexCode)
cb(null, codes)
}
/**

@ -163,12 +163,11 @@ TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex) {
}
}
TraceManager.prototype.getContractCreationCode = function (token, callback) {
if (this.traceCache.contractCreation[token]) {
callback(null, this.traceCache.contractCreation[token])
} else {
callback('no contract creation named ' + token, null)
TraceManager.prototype.getContractCreationCode = function (token) {
if (!this.traceCache.contractCreation[token]) {
throw new Error('no contract creation named ' + token)
}
return this.traceCache.contractCreation[token]
}
TraceManager.prototype.getMemoryAt = function (stepIndex) {

@ -167,15 +167,14 @@ tape('TraceManager', function (t) {
})
t.test('TraceManager.getContractCreationCode', function (st) { // contract code has been retrieved from the memory
traceManager.getContractCreationCode('(Contract Creation - Step 63)', function (error, result) {
try {
const result = traceManager.getContractCreationCode('(Contract Creation - Step 63)')
console.log(result)
if (error) {
st.fail(error)
} else {
st.ok(result === '0x60606040526040516020806045833981016040528080519060200190919050505b806001016000600050819055505b50600a80603b6000396000f360606040526008565b00000000000000000000000000000000000000000000000000000000000000002d')
st.end()
}
})
st.ok(result === '0x60606040526040516020806045833981016040528080519060200190919050505b806001016000600050819055505b50600a80603b6000396000f360606040526008565b00000000000000000000000000000000000000000000000000000000000000002d')
st.end()
} catch (error) {
st.fail(error)
}
})
t.test('TraceManager.getMemoryAt', function (st) {

Loading…
Cancel
Save