make sure contract creation are handled properly (address from the receipt)

pull/1/head
yann300 5 years ago
parent 105118530b
commit 1ca80d1212
  1. 11
      src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js
  2. 6
      src/app/tabs/debugger-tab.js
  3. 11
      src/app/tabs/debugger/debuggerUI.js

@ -17,7 +17,6 @@ export default class FetchAndCompile extends Plugin {
constructor () {
super(profile)
this.unresolvedAddresses = []
this.firstResolvedAddress = null
this.sourceVerifierNetWork = ['Main', 'Rinkeby', 'Ropsten', 'Goerli']
}
@ -26,15 +25,12 @@ export default class FetchAndCompile extends Plugin {
* Put the artifacts in the file explorer
* Compile the code using Solidity compiler
* Returns compilation data
* if no contract address are passed, we default to the first resolved address.
*
* @param {string} contractAddress - Address of the contrac to resolve
* @param {string} compilersartefacts - Object containing a mapping of compilation results (byContractAddress and __last)
* @return {CompilerAbstract} - compilation data targeting the given @arg contractAddress
*/
async resolve (contractAddress, targetPath, web3) {
contractAddress = contractAddress || this.firstResolvedAddress
const compilersartefacts = globalRegistry.get('compilersartefacts').api
const localCompilation = () => compilersartefacts.get('__last') ? compilersartefacts.get('__last') : null
@ -42,9 +38,8 @@ export default class FetchAndCompile extends Plugin {
const resolved = compilersartefacts.get(contractAddress)
if (resolved) return resolved
if (this.unresolvedAddresses.includes(contractAddress)) return localCompilation()
if (this.firstResolvedAddress) return compilersartefacts.get(this.firstResolvedAddress)
// ^ for the moment we don't add compilation result for each adddress, but just for the root addres ^ . We can add this later.
// usecase is: sometimes when doing an internal call, the only available artifact is the Solidity interface.
// sometimes when doing an internal call, the only available artifact is the Solidity interface.
// resolving addresses of internal call would allow to step over the source code, even if the declaration was made using an Interface.
let network
@ -67,7 +62,6 @@ export default class FetchAndCompile extends Plugin {
})
if (found) {
compilersartefacts.addResolvedContract(contractAddress, compilation)
this.firstResolvedAddress = contractAddress
setTimeout(_ => this.emit('usingLocalCompilation', contractAddress), 0)
return compilation
}
@ -119,7 +113,6 @@ export default class FetchAndCompile extends Plugin {
setTimeout(_ => this.emit('compiling', settings), 0)
const compData = await compile(compilationTargets, settings)
compilersartefacts.addResolvedContract(contractAddress, compData)
this.firstResolvedAddress = contractAddress
return compData
} catch (e) {
this.unresolvedAddresses.push(contractAddress)

@ -1,4 +1,5 @@
const yo = require('yo-yo')
const remixLib = require('remix-lib')
const css = require('./styles/debugger-tab-styles')
import toaster from '../ui/tooltip'
const DebuggerUI = require('./debugger/debuggerUI')
@ -57,7 +58,10 @@ class DebuggerTab extends ViewPlugin {
this.debuggerUI = new DebuggerUI(
this.el.querySelector('#debugger'),
this.blockchain,
adddress => this.call('fetchAndCompile', 'resolve', adddress, '.debug', this.blockchain.web3()))
(address, receipt) => {
const target = (address && remixLib.helpers.trace.isContractCreation(address)) ? receipt.contractAddress : address
return this.call('fetchAndCompile', 'resolve', target || receipt.contractAddress || receipt.to, '.debug', this.blockchain.web3())
})
this.call('manager', 'activatePlugin', 'source-verification')
// this.call('manager', 'activatePlugin', 'udapp')

@ -44,6 +44,7 @@ class DebuggerUI {
this.stepManager = null
this.statusMessage = ''
this.currentReceipt
this.view
@ -79,7 +80,9 @@ class DebuggerUI {
})
this.debugger.event.register('newSourceLocation', async function (lineColumnPos, rawLocation) {
const contracts = await self.fetchContractAndCompile()
const contracts = await self.fetchContractAndCompile(
self.currentReceipt.contractAddress || self.currentReceipt.to,
self.currentReceipt)
if (contracts) {
const path = contracts.getSourceName(rawLocation.file)
if (path) self.sourceHighlighter.currentSourceLocationFromfileName(lineColumnPos, path)
@ -128,12 +131,13 @@ class DebuggerUI {
if (this.debugger) this.unLoad()
let web3 = await this.getDebugWeb3()
this.currentReceipt = await web3.eth.getTransactionReceipt(txNumber)
this.debugger = new Debugger({
web3,
offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api,
compilationResult: async (address) => {
try {
return await this.fetchContractAndCompile(address)
return await this.fetchContractAndCompile(address, this.currentReceipt)
} catch (e) {
console.error(e)
}
@ -157,12 +161,13 @@ class DebuggerUI {
return new Promise(async (resolve, reject) => {
const web3 = await this.getDebugWeb3()
this.currentReceipt = await web3.eth.getTransactionReceipt(hash)
const debug = new Debugger({
web3,
offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api,
compilationResult: async (address) => {
try {
return await this.fetchContractAndCompile(address)
return await this.fetchContractAndCompile(address, this.currentReceipt)
} catch (e) {
console.error(e)
}

Loading…
Cancel
Save