fix sending tx with the api

pull/3355/head
yann300 2 years ago committed by Aniket
parent 991656d710
commit e8b7f0cdd0
  1. 10
      apps/remix-ide/src/blockchain/blockchain.js
  2. 16
      libs/remix-lib/src/execution/txRunner.ts
  3. 3
      libs/remix-lib/src/execution/txRunnerVM.ts
  4. 3
      libs/remix-lib/src/execution/txRunnerWeb3.ts

@ -13,7 +13,8 @@ import { execution, EventManager, helpers } from '@remix-project/remix-lib'
import { etherScanLink } from './helper'
import { logBuilder, cancelUpgradeMsg, cancelProxyMsg, addressToString } from "@remix-ui/helper"
const { txFormat, txExecution, typeConversion, txListener: Txlistener, TxRunner, TxRunnerWeb3, txHelper } = execution
const { txResultHelper: resultToRemixTx } = helpers
const { txResultHelper } = helpers
const { resultToRemixTx } = txResultHelper
const packageJson = require('../../../../package.json')
const _paq = window._paq = window._paq || [] //eslint-disable-line
@ -575,8 +576,11 @@ export class Blockchain extends Plugin {
async (error, result) => {
if (error) return reject(error)
try {
const execResult = await this.web3().eth.getExecutionResultFromSimulator(result.transactionHash)
resolve(resultToRemixTx(result, execResult))
if (this.executionContext.isVM()) {
const execResult = await this.web3().eth.getExecutionResultFromSimulator(result.transactionHash)
resolve(resultToRemixTx(result, execResult))
} else
resolve(resultToRemixTx(result))
} catch (e) {
reject(e)
}

@ -1,6 +1,16 @@
'use strict'
import { EventManager } from '../eventManager'
export type Transaction = {
from: string,
to: string,
value: string,
data: string,
gasLimit: number,
useCall: boolean,
timestamp?: number
}
export class TxRunner {
event
runAsync
@ -19,11 +29,11 @@ export class TxRunner {
this.queusTxs = []
}
rawRun (args, confirmationCb, gasEstimationForceSend, promptCb, cb) {
rawRun (args: Transaction, confirmationCb, gasEstimationForceSend, promptCb, cb) {
run(this, args, args.timestamp || Date.now(), confirmationCb, gasEstimationForceSend, promptCb, cb)
}
execute (args, confirmationCb, gasEstimationForceSend, promptCb, callback) {
execute (args: Transaction, confirmationCb, gasEstimationForceSend, promptCb, callback) {
let data = args.data
if (data.slice(0, 2) !== '0x') {
data = '0x' + data
@ -32,7 +42,7 @@ export class TxRunner {
}
}
function run (self, tx, stamp, confirmationCb, gasEstimationForceSend = null, promptCb = null, callback = null) {
function run (self, tx: Transaction, stamp, confirmationCb, gasEstimationForceSend = null, promptCb = null, callback = null) {
if (!self.runAsync && Object.keys(self.pendingTxs).length) {
return self.queusTxs.push({ tx, stamp, callback })
}

@ -6,6 +6,7 @@ import { BN, bufferToHex, Address } from 'ethereumjs-util'
import type { Account } from '@ethereumjs/util'
import { EventManager } from '../eventManager'
import { LogsManager } from './logsManager'
import type { Transaction as InternalTransaction } from './txRunner'
export type VMexecutionResult = {
result: RunTxResult,
@ -52,7 +53,7 @@ export class TxRunnerVM {
this.nextNonceForCall = 0
}
execute (args, confirmationCb, gasEstimationForceSend, promptCb, callback: VMExecutionCallBack) {
execute (args: InternalTransaction, confirmationCb, gasEstimationForceSend, promptCb, callback: VMExecutionCallBack) {
let data = args.data
if (data.slice(0, 2) !== '0x') {
data = '0x' + data

@ -1,5 +1,6 @@
'use strict'
import { EventManager } from '../eventManager'
import type { Transaction as InternalTransaction } from './txRunner'
import Web3 from 'web3'
export class TxRunnerWeb3 {
@ -79,7 +80,7 @@ export class TxRunnerWeb3 {
}
}
execute (args, confirmationCb, gasEstimationForceSend, promptCb, callback) {
execute (args: InternalTransaction, confirmationCb, gasEstimationForceSend, promptCb, callback) {
let data = args.data
if (data.slice(0, 2) !== '0x') {
data = '0x' + data

Loading…
Cancel
Save