diff --git a/libs/remix-lib/src/execution/txListener.ts b/libs/remix-lib/src/execution/txListener.ts index b72f947b11..0affb581fe 100644 --- a/libs/remix-lib/src/execution/txListener.ts +++ b/libs/remix-lib/src/execution/txListener.ts @@ -33,7 +33,7 @@ export class TxListener { _listenOnNetwork:boolean _loopId blocks - + constructor (opt, executionContext) { this.event = new EventManager() // has a default for now for backwards compatability @@ -94,9 +94,7 @@ export class TxListener { // in web3 mode && listen remix txs only if (!this._isListening) return // we don't listen if (this._loopId) return // we seems to already listen on a "web3" network - this.executionContext.web3().eth.getTransaction(txResult.transactionHash, async (error, tx) => { - if (error) return console.log(error) - + this.executionContext.web3().eth.getTransaction(txResult.transactionHash).then(async tx=>{ let execResult if (this.executionContext.isVM()) { execResult = await this.executionContext.web3().testPlugin.getExecutionResultFromSimulator(txResult.transactionHash) @@ -106,7 +104,7 @@ export class TxListener { tx.envMode = this.executionContext.getProvider() tx.status = txResult.receipt.status this._resolve([tx]) - }) + }).catch(error=>console.log(error)) }) } @@ -204,7 +202,7 @@ export class TxListener { async _manageBlock (blockNumber) { try { const result = await this.executionContext.web3().eth.getBlock(blockNumber, true) - return await this._newBlock(Object.assign({ type: 'web3' }, result)) + return await this._newBlock(Object.assign({ type: 'web3' }, result)) } catch (e) {} } @@ -285,8 +283,7 @@ export class TxListener { // first check known contract, resolve against the `runtimeBytecode` if not known contract = this._resolvedContracts[tx.to] if (!contract) { - this.executionContext.web3().eth.getCode(tx.to, (error, code) => { - if (error) return cb(error) + this.executionContext.web3().eth.getCode(tx.to).then(code=>{ if (code) { const contract = this._tryResolveContract(code, contracts, false) if (contract) { @@ -296,7 +293,7 @@ export class TxListener { } } return cb() - }) + }).catch(error=>cb(error)) return } if (contract) { diff --git a/libs/remix-lib/src/execution/txRunner.ts b/libs/remix-lib/src/execution/txRunner.ts index 62e9bb0988..19f643cc7d 100644 --- a/libs/remix-lib/src/execution/txRunner.ts +++ b/libs/remix-lib/src/execution/txRunner.ts @@ -32,6 +32,10 @@ export class TxRunner { } execute (args: Transaction, confirmationCb, gasEstimationForceSend, promptCb, callback) { + let data = args.data + if (data.slice(0, 2) !== '0x') { + data = '0x' + data + } this.internalRunner.execute(args, confirmationCb, gasEstimationForceSend, promptCb, callback) } } diff --git a/libs/remix-lib/src/execution/txRunnerVM.ts b/libs/remix-lib/src/execution/txRunnerVM.ts index b1b535abb2..bbac9c5392 100644 --- a/libs/remix-lib/src/execution/txRunnerVM.ts +++ b/libs/remix-lib/src/execution/txRunnerVM.ts @@ -56,7 +56,7 @@ export class TxRunnerVM { execute (args: InternalTransaction, confirmationCb, gasEstimationForceSend, promptCb, callback: VMExecutionCallBack) { let data = args.data - if (data && data.slice(0, 2) !== '0x') { + if (data.slice(0, 2) !== '0x') { data = '0x' + data } diff --git a/libs/remix-lib/src/execution/txRunnerWeb3.ts b/libs/remix-lib/src/execution/txRunnerWeb3.ts index a222e7075b..6325876f69 100644 --- a/libs/remix-lib/src/execution/txRunnerWeb3.ts +++ b/libs/remix-lib/src/execution/txRunnerWeb3.ts @@ -82,7 +82,7 @@ export class TxRunnerWeb3 { execute (args: InternalTransaction, confirmationCb, gasEstimationForceSend, promptCb, callback) { let data = args.data - if (data && data.slice(0, 2) !== '0x') { + if (data.slice(0, 2) !== '0x') { data = '0x' + data } diff --git a/libs/remix-tests/tests/testRunner.cli.spec.ts b/libs/remix-tests/tests/testRunner.cli.spec.ts index 30d7e4cd7d..543466d68a 100644 --- a/libs/remix-tests/tests/testRunner.cli.spec.ts +++ b/libs/remix-tests/tests/testRunner.cli.spec.ts @@ -60,7 +60,7 @@ Commands: it('remix-tests running a test file', function() { const res = spawnSync(executablePath, [resolve(__dirname + '/examples_0/assert_ok_test.sol')]) - // console.log(res.stdout.toString()) + console.log(res.stdout.toString()) // match initial lines expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/) expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)