diff --git a/apps/remix-ide/src/app/plugins/solidity-script.tsx b/apps/remix-ide/src/app/plugins/solidity-script.tsx index 66b2366b4f..5ea9bdaf8c 100644 --- a/apps/remix-ide/src/app/plugins/solidity-script.tsx +++ b/apps/remix-ide/src/app/plugins/solidity-script.tsx @@ -55,6 +55,7 @@ export class SolidityScript extends Plugin { }) } + await this.call('compilerArtefacts', 'saveCompilerAbstract', 'script.sol', compilation) // get the contract const contract = compilation.getContract('SolidityScript') if (!contract) { @@ -73,13 +74,27 @@ export class SolidityScript extends Plugin { from: accounts[0], data: bytecode } - const receipt = await web3.eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true }) + let receipt + try { + receipt = await web3.eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true }) + } catch (e) { + this.call('terminal', 'logHtml', e.message) + return + } + tx = { from: accounts[0], to: receipt.contractAddress, data: '0x69d4394b' // function remixRun() public } - const receiptCall = await web3.eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true }) + let receiptCall + + try { + receiptCall = await web3.eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true }) + } catch (e) { + this.call('terminal', 'logHtml', e.message) + return + } const hhlogs = await web3.remix.getHHLogsForTx(receiptCall.transactionHash) diff --git a/libs/remix-core-plugin/src/lib/compiler-artefacts.ts b/libs/remix-core-plugin/src/lib/compiler-artefacts.ts index c37e3a7dab..698b03c0d3 100644 --- a/libs/remix-core-plugin/src/lib/compiler-artefacts.ts +++ b/libs/remix-core-plugin/src/lib/compiler-artefacts.ts @@ -5,7 +5,7 @@ import { CompilerAbstract } from '@remix-project/remix-solidity' const profile = { name: 'compilerArtefacts', - methods: ['get', 'addResolvedContract', 'getCompilerAbstract', 'getAllContractDatas', 'getLastCompilationResult', 'getArtefactsByContractName', 'getContractDataFromAddress', 'getContractDataFromByteCode'], + methods: ['get', 'addResolvedContract', 'getCompilerAbstract', 'getAllContractDatas', 'getLastCompilationResult', 'getArtefactsByContractName', 'getContractDataFromAddress', 'getContractDataFromByteCode', 'saveCompilerAbstract'], events: [], version: '0.0.1' } @@ -24,6 +24,10 @@ export class CompilerArtefacts extends Plugin { this.compilersArtefactsPerFile = {} } + saveCompilerAbstract (file: string, compilerAbstract: CompilerAbstract) { + this.compilersArtefactsPerFile[file] = compilerAbstract + } + onActivation () { const saveCompilationPerFileResult = (file, source, languageVersion, data, input?) => { this.compilersArtefactsPerFile[file] = new CompilerAbstract(languageVersion, data, source, input)