Fix yarn run build:libs

pull/5370/head
Wyatt Barnes 1 year ago
parent 4a8aada220
commit debcd570e6
  1. 70
      libs/remix-lib/src/execution/txRunnerWeb3.ts
  2. 7
      libs/remix-simulator/src/VmProxy.ts
  3. 6
      libs/remix-simulator/src/methods/transactions.ts
  4. 10
      libs/remix-tests/src/runTestFiles.ts

@ -95,12 +95,11 @@ export class TxRunnerWeb3 {
if (useCall) {
tx['gas'] = gasLimit
if (this._api && this._api.isVM()) tx['timestamp'] = timestamp
return this.getWeb3().eth.call(tx, function (error, result: any) {
if (error) return callback(error)
callback(null, {
this.getWeb3().eth.call(tx)
.then((result: any) => callback(null, {
result: result
})
})
}))
.catch(error => callback(error))
}
this._api.detectNetwork((errNetWork, network) => {
if (errNetWork) {
@ -119,42 +118,43 @@ export class TxRunnerWeb3 {
txCopy.gasPrice = network.lastBlock.baseFeePerGas
}
}
this.getWeb3().eth.estimateGas(txCopy, (err, gasEstimation) => {
if (err && err.message.indexOf('Invalid JSON RPC response') !== -1) {
// // @todo(#378) this should be removed when https://github.com/WalletConnect/walletconnect-monorepo/issues/334 is fixed
callback(new Error('Gas estimation failed because of an unknown internal error. This may indicated that the transaction will fail.'))
}
err = network.name === 'VM' ? null : err // just send the tx if "VM"
gasEstimationForceSend(err, () => {
// callback is called whenever no error
tx['gas'] = !gasEstimation ? gasLimit : gasEstimation
this.getWeb3().eth.estimateGas(txCopy)
.then(gasEstimation => {
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)
}
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) => {
callback(error)
confirmCb(network, tx, tx['gas'], (txFee) => {
return this._executeTx(tx, network, txFee, this._api, promptCb, callback)
}, (error) => {
callback(error)
})
})
}, () => {
const blockGasLimit = this.currentblockGasLimit()
// NOTE: estimateGas very likely will return a large limit if execution of the code failed
// we want to be able to run the code in order to debug and find the cause for the failure
if (err) return callback(err)
})
.catch(err => {
if (err && err.message.indexOf('Invalid JSON RPC response') !== -1) {
// // @todo(#378) this should be removed when https://github.com/WalletConnect/walletconnect-monorepo/issues/334 is fixed
callback(new Error('Gas estimation failed because of an unknown internal error. This may indicated that the transaction will fail.'))
}
err = network.name === 'VM' ? null : err // just send the tx if "VM"
gasEstimationForceSend(err, () => {
tx['gas'] = gasLimit
let warnEstimation = ' An important gas estimation might also be the sign of a problem in the contract code. Please check loops and be sure you did not sent value to a non payable function (that\'s also the reason of strong gas estimation). '
warnEstimation += ' ' + err
if (this._api.config.getUnpersistedProperty('doNotShowTransactionConfirmationAgain')) {
return this._executeTx(tx, network, null, this._api, promptCb, callback)
}
if (gasEstimation > gasLimit) {
return callback('Gas required exceeds limit: ' + gasLimit + '. ' + warnEstimation)
}
if (gasEstimation > blockGasLimit) {
return callback('Gas required exceeds block gas limit: ' + gasLimit + '. ' + warnEstimation)
}
confirmCb(network, tx, tx['gas'], (txFee) => {
return this._executeTx(tx, network, txFee, this._api, promptCb, callback)
}, (error) => {
callback(error)
})
})
})
})
})
}
}

@ -4,7 +4,6 @@ import { helpers } from '@remix-project/remix-lib'
const { normalizeHexAddress } = helpers.ui
import { ConsoleLogs, hash } from '@remix-project/remix-lib'
import BN from 'bn.js'
import { isBigNumber } from 'web3-utils'
import { toChecksumAddress, bufferToHex, Address, toBuffer } from '@ethereumjs/util'
import utils from 'web3-utils'
import { ethers } from 'ethers'
@ -84,7 +83,8 @@ export class VmProxy {
this.fromDecimal = (...args) => utils.fromDecimal.apply(this, args)
this.fromWei = (...args) => utils.fromWei.apply(this, args)
this.toWei = (...args) => utils.toWei.apply(this, args)
this.toBigNumber = (...args) => utils.toBN.apply(this, args)
// TODO Is this still needed?
// this.toBigNumber = (...args) => utils.toBN.apply(this, args)
this.isAddress = (...args) => utils.isAddress.apply(this, args)
this.utils = utils
this.txsMapBlock = {}
@ -278,7 +278,8 @@ export class VmProxy {
}
let consoleArgs = iface.decodeFunctionData(functionDesc, payload)
consoleArgs = consoleArgs.map((value) => {
if (isBigNumber(value)) {
// Copied from: https://github.com/web3/web3.js/blob/e68194bdc590d811d4bf66dde12f99659861a110/packages/web3-utils/src/utils.js#L48C10-L48C10
if (value && value.constructor && value.constructor.name === 'BigNumber') {
return value.toString()
}
return value

@ -1,4 +1,4 @@
import { toHex, toDecimal } from 'web3-utils'
import { toHex, toNumber } from 'web3-utils'
import BN from 'bn.js'
import { toChecksumAddress, Address, bigIntToHex } from '@ethereumjs/util'
import { processTx } from './txProcess'
@ -292,7 +292,7 @@ export class Transactions {
const txIndex = payload.params[1]
const txBlock = this.vmContext.blocks[payload.params[0]]
const txHash = '0x' + txBlock.transactions[toDecimal(txIndex)].hash().toString('hex')
const txHash = '0x' + txBlock.transactions[toNumber(txIndex) as number].hash().toString('hex')
this.vmContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => {
if (error) {
@ -337,7 +337,7 @@ export class Transactions {
const txIndex = payload.params[1]
const txBlock = this.vmContext.blocks[payload.params[0]]
const txHash = '0x' + txBlock.transactions[toDecimal(txIndex)].hash().toString('hex')
const txHash = '0x' + txBlock.transactions[toNumber(txIndex) as number].hash().toString('hex')
this.vmContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => {
if (error) {

@ -62,10 +62,12 @@ export function runTestFiles (filepath: string, isDirectory: boolean, web3: Web3
async.waterfall([
function getAccountList (next) {
if (accounts) return next(null)
web3.eth.getAccounts((_err: Error | null | undefined, _accounts) => {
accounts = _accounts
next(null)
})
web3.eth.getAccounts()
.then(_accounts => {
accounts = _accounts
next(null)
})
.catch((_err: Error | null | undefined) => next(null))
},
function compile (next) {
compileFileOrFiles(filepath, isDirectory, { accounts }, compilerConfig, next)

Loading…
Cancel
Save