check data before slice

pull/5370/head
Oleksii Kosynskyi 1 year ago
parent 55ab40a2ee
commit 54f1e27a13
  1. 10
      libs/remix-lib/src/execution/txRunnerVM.ts
  2. 10
      libs/remix-lib/src/execution/txRunnerWeb3.ts

@ -56,7 +56,7 @@ export class TxRunnerVM {
execute (args: InternalTransaction, confirmationCb, gasEstimationForceSend, promptCb, callback: VMExecutionCallBack) {
let data = args.data
if (data.slice(0, 2) !== '0x') {
if (data && data.slice(0, 2) !== '0x') {
data = '0x' + data
}
@ -72,12 +72,12 @@ export class TxRunnerVM {
if (!from && useCall && Object.keys(this.vmaccounts).length) {
from = Object.keys(this.vmaccounts)[0]
account = this.vmaccounts[from]
} else account = this.vmaccounts[from]
} else account = this.vmaccounts[from]
if (!account) {
return callback('Invalid account selected')
}
this.getVMObject().stateManager.getAccount(Address.fromString(from)).then((res: Account) => {
const EIP1559 = this.commonContext.hardfork() !== 'berlin' // berlin is the only pre eip1559 fork that we handle.
let tx
@ -106,7 +106,7 @@ export class TxRunnerVM {
const coinbases = ['0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a', '0x8945a1288dc78a6d8952a92c77aee6730b414778', '0x94d76e24f818426ae84aa404140e8d5f60e10e7e']
const difficulties = [69762765929000, 70762765929000, 71762765929000]
const difficulty = this.commonContext.consensusType() === ConsensusType.ProofOfStake ? 0 : difficulties[this.blockNumber % difficulties.length]
const blocknumber = this.blockNumber + 1
const block = Block.fromBlockData({
header: {

@ -82,7 +82,7 @@ export class TxRunnerWeb3 {
execute (args: InternalTransaction, confirmationCb, gasEstimationForceSend, promptCb, callback) {
let data = args.data
if (data.slice(0, 2) !== '0x') {
if (data && data.slice(0, 2) !== '0x') {
data = '0x' + data
}
@ -123,11 +123,11 @@ export class TxRunnerWeb3 {
gasEstimationForceSend(null, () => {
// callback is called whenever no error
tx['gas'] = !gasEstimation ? gasLimit : gasEstimation
if (this._api.config.getUnpersistedProperty('doNotShowTransactionConfirmationAgain')) {
return this._executeTx(tx, network, null, this._api, promptCb, callback)
}
confirmCb(network, tx, tx['gas'], (txFee) => {
return this._executeTx(tx, network, txFee, this._api, promptCb, callback)
}, (error) => {
@ -143,11 +143,11 @@ export class TxRunnerWeb3 {
err = network.name === 'VM' ? null : err // just send the tx if "VM"
gasEstimationForceSend(err, () => {
tx['gas'] = gasLimit
if (this._api.config.getUnpersistedProperty('doNotShowTransactionConfirmationAgain')) {
return this._executeTx(tx, network, null, this._api, promptCb, callback)
}
confirmCb(network, tx, tx['gas'], (txFee) => {
return this._executeTx(tx, network, txFee, this._api, promptCb, callback)
}, (error) => {

Loading…
Cancel
Save