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

@ -4,7 +4,6 @@ import { helpers } from '@remix-project/remix-lib'
const { normalizeHexAddress } = helpers.ui const { normalizeHexAddress } = helpers.ui
import { ConsoleLogs, hash } from '@remix-project/remix-lib' import { ConsoleLogs, hash } from '@remix-project/remix-lib'
import BN from 'bn.js' import BN from 'bn.js'
import { isBigNumber } from 'web3-utils'
import { toChecksumAddress, bufferToHex, Address, toBuffer } from '@ethereumjs/util' import { toChecksumAddress, bufferToHex, Address, toBuffer } from '@ethereumjs/util'
import utils from 'web3-utils' import utils from 'web3-utils'
import { ethers } from 'ethers' import { ethers } from 'ethers'
@ -84,7 +83,8 @@ export class VmProxy {
this.fromDecimal = (...args) => utils.fromDecimal.apply(this, args) this.fromDecimal = (...args) => utils.fromDecimal.apply(this, args)
this.fromWei = (...args) => utils.fromWei.apply(this, args) this.fromWei = (...args) => utils.fromWei.apply(this, args)
this.toWei = (...args) => utils.toWei.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.isAddress = (...args) => utils.isAddress.apply(this, args)
this.utils = utils this.utils = utils
this.txsMapBlock = {} this.txsMapBlock = {}
@ -278,7 +278,8 @@ export class VmProxy {
} }
let consoleArgs = iface.decodeFunctionData(functionDesc, payload) let consoleArgs = iface.decodeFunctionData(functionDesc, payload)
consoleArgs = consoleArgs.map((value) => { 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.toString()
} }
return value return value

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

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

Loading…
Cancel
Save