Merge pull request #4260 from ethereum/fix_using_web3_checkers_2

fix using checkRevertBeforeSending and ignoreGasPricing
pull/5370/head
yann300 1 year ago committed by GitHub
commit 6b8bb26dc7
  1. 28
      apps/remix-ide-e2e/src/commands/waitForElementNotContainsText.ts
  2. 2
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  3. 1
      apps/remix-ide-e2e/src/types/index.d.ts
  4. 4
      apps/remix-ide/src/app/plugins/solidity-script.tsx
  5. 2
      apps/remix-ide/src/blockchain/execution-context.js
  6. 1
      apps/remix-ide/src/blockchain/providers/vm.ts
  7. 2
      libs/ghaction-helper/src/methods.ts
  8. 2
      libs/remix-debug/test/vmCall.ts
  9. 4
      libs/remix-lib/src/execution/txRunnerWeb3.ts

@ -0,0 +1,28 @@
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class waitForElementNotContainsText extends EventEmitter {
command (this: NightwatchBrowser, id: string, value: string, timeout = 10000): NightwatchBrowser {
let waitId // eslint-disable-line
let currentValue
const runid = setInterval(() => {
this.api.getText(id, (result) => {
currentValue = result.value
if (typeof result.value === 'string' && result.value.indexOf(value) !== -1) {
clearInterval(runid)
clearTimeout(waitId)
this.api.assert.ok(false, `WaitForElementContainsText ${id} contains ${value} . It should not`)
this.emit('complete')
}
})
}, 200)
waitId = setTimeout(() => {
clearInterval(runid)
this.api.assert.ok(true, `"${value}" wasn't found.`)
}, timeout)
return this
}
}
module.exports = waitForElementNotContainsText

@ -356,6 +356,8 @@ module.exports = {
}) })
.useCss() .useCss()
.waitForElementContainsText('*[data-id="terminalJournal"]', 'test running free function', 120000) .waitForElementContainsText('*[data-id="terminalJournal"]', 'test running free function', 120000)
.waitForElementNotContainsText('*[data-id="terminalJournal"]', `test running free function
test running free function`, 2000)
} }
} }

@ -69,6 +69,7 @@ declare module 'nightwatch' {
switchWorkspace: (workspaceName: string) => NightwatchBrowser switchWorkspace: (workspaceName: string) => NightwatchBrowser
switchEnvironment: (provider: string) => NightwatchBrowser switchEnvironment: (provider: string) => NightwatchBrowser
connectToExternalHttpProvider: (url: string, identifier: string) => NightwatchBrowser connectToExternalHttpProvider: (url: string, identifier: string) => NightwatchBrowser
waitForElementNotContainsText: (id: string, value: string, timeout: number = 10000) => NightwatchBrowser
} }
export interface NightwatchBrowser { export interface NightwatchBrowser {

@ -73,13 +73,13 @@ export class SolidityScript extends Plugin {
from: accounts[0], from: accounts[0],
data: bytecode data: bytecode
} }
const receipt = await web3.eth.sendTransaction(tx) const receipt = await web3.eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true })
tx = { tx = {
from: accounts[0], from: accounts[0],
to: receipt.contractAddress, to: receipt.contractAddress,
data: '0x69d4394b' // function remixRun() public data: '0x69d4394b' // function remixRun() public
} }
const receiptCall = await web3.eth.sendTransaction(tx) const receiptCall = await web3.eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true })
const hhlogs = await web3.remix.getHHLogsForTx(receiptCall.transactionHash) const hhlogs = await web3.remix.getHHLogsForTx(receiptCall.transactionHash)

@ -7,7 +7,7 @@ const _paq = window._paq = window._paq || []
let web3 let web3
const config = { defaultTransactionType: '0x0', ignoreGasPricing: true } const config = { defaultTransactionType: '0x0' }
if (typeof window !== 'undefined' && typeof window.ethereum !== 'undefined') { if (typeof window !== 'undefined' && typeof window.ethereum !== 'undefined') {
var injectedProvider = window.ethereum var injectedProvider = window.ethereum
web3 = new Web3(injectedProvider) web3 = new Web3(injectedProvider)

@ -62,6 +62,7 @@ export class VMProvider {
} }
} }
this.web3 = new Web3(this.provider as LegacySendAsyncProvider) this.web3 = new Web3(this.provider as LegacySendAsyncProvider)
this.web3.setConfig({ defaultTransactionType: '0x0' })
extend(this.web3) extend(this.web3)
this.executionContext.setWeb3(this.executionContext.getProvider(), this.web3) this.executionContext.setWeb3(this.executionContext.getProvider(), this.web3)
resolve({}) resolve({})

@ -11,7 +11,7 @@ const providerConfig = {
blockNumber: global.blockNumber || null blockNumber: global.blockNumber || null
} }
const config = { defaultTransactionType: '0x0', ignoreGasPricing: true } const config = { defaultTransactionType: '0x0' }
global.remixProvider = new Provider(providerConfig) global.remixProvider = new Provider(providerConfig)
global.remixProvider.init() global.remixProvider.init()
global.web3Provider = new ethers.providers.Web3Provider(global.remixProvider) global.web3Provider = new ethers.providers.Web3Provider(global.remixProvider)

@ -23,7 +23,7 @@ async function sendTx (web3, from, to, value, data, cb) {
value, value,
data, data,
gas: 7000000 gas: 7000000
}) }, null, { checkRevertBeforeSending: false, ignoreGasPricing: true })
cb(null, receipt.transactionHash) cb(null, receipt.transactionHash)
return receipt.transactionHash return receipt.transactionHash
} catch (e) { } catch (e) {

@ -65,7 +65,7 @@ export class TxRunnerWeb3 {
promptCb( promptCb(
async (value) => { async (value) => {
try { try {
const res = await (this.getWeb3() as any).eth.personal.sendTransaction({...tx, value}) const res = await (this.getWeb3() as any).eth.personal.sendTransaction({...tx, value}, { checkRevertBeforeSending: false, ignoreGasPricing: true })
cb(null, res.transactionHash) cb(null, res.transactionHash)
} catch (e) { } catch (e) {
console.log(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `) console.log(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)
@ -81,7 +81,7 @@ export class TxRunnerWeb3 {
) )
} else { } else {
try { try {
const res = await this.getWeb3().eth.sendTransaction(tx, null, { checkRevertBeforeSending: false }) const res = await this.getWeb3().eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true})
cb(null, res.transactionHash) cb(null, res.transactionHash)
} catch (e) { } catch (e) {
console.log(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `) console.log(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)

Loading…
Cancel
Save