Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions libs/ghaction-helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"@ethereum-waffle/chai": "^3.4.4",
"@remix-project/remix-simulator": "^0.2.79",
"chai": "^4.3.7",
"ethers": "^6.14.0",
"web3": "^4.1.1"
"ethers": "^6.14.0"
},
"types": "./src/index.d.ts",
"gitHead": "326045634cac1e4a67dd21ac2d7716d21ebd6754"
Expand Down
3 changes: 0 additions & 3 deletions libs/ghaction-helper/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { BrowserProvider, Contract, InterfaceAbi } from "ethers"
import { Provider } from '@remix-project/remix-simulator'
import { getArtifactsByContractName } from './artifacts-helper'
import { Web3 } from "web3"

const providerConfig = {
fork: global.fork || null,
Expand All @@ -16,8 +15,6 @@ global.remixProvider.init()
global.web3Provider = new BrowserProvider(global.remixProvider)
global.provider = global.web3Provider
global.ethereum = global.web3Provider
global.web3 = new Web3(global.web3Provider)
global.web3.eth.setConfig(config)

const isFactoryOptions = (signerOrOptions: any) => {
if (!signerOrOptions || signerOrOptions === undefined || typeof(signerOrOptions.connect) === 'function') return false
Expand Down
3 changes: 1 addition & 2 deletions libs/remix-analyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"async": "^2.6.2",
"ethers": "^6.14.0",
"ethjs-util": "^0.1.6",
"string-similarity": "^4.0.4",
"web3": "^4.1.1"
"string-similarity": "^4.0.4"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 1 addition & 2 deletions libs/remix-astwalker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
"string-similarity": "^4.0.4",
"tape": "^4.10.1",
"ts-node": "^8.0.3",
"typescript": "^3.4.3",
"web3": "^4.1.1"
"typescript": "^3.4.3"
},
"devDependencies": {
"tap-spec": "^5.0.0"
Expand Down
1 change: 0 additions & 1 deletion libs/remix-debug/src/Ethdebugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { CodeManager } from './code/codeManager'
import { contractCreationToken } from './trace/traceHelper'
import { EventManager } from './eventManager'
import { SolidityProxy, stateDecoder, localDecoder, InternalCallTree } from './solidity-decoder'
import { extractStateVariables } from './solidity-decoder/stateDecoder'

/**
* Ethdebugger is a wrapper around a few classes that helps debug a transaction
Expand Down
4 changes: 2 additions & 2 deletions libs/remix-debug/src/cmdline/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Web3 } from 'web3'
import { ethers } from 'ethers'
import { Debugger } from '../debugger/debugger'
import { EventEmitter } from 'events'

Expand All @@ -22,7 +22,7 @@ export class CmdLine {

connect (providerType, url) {
if (providerType !== 'http') throw new Error('unsupported provider type')
this.web3 = new Web3(new Web3.providers.HttpProvider(url))
this.web3 = new ethers.JsonRpcProvider(url)
}

loadCompilationData (inputJson, outputJson) {
Expand Down
49 changes: 14 additions & 35 deletions libs/remix-debug/src/init.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
'use strict'
import { Web3, Web3PluginBase } from 'web3'
import { toNumber } from 'web3-utils'
import { toNumber, ethers } from 'ethers'

export function extendWeb3 (web3) {
if (!web3.debug){
web3.registerPlugin(new Web3DebugPlugin())
}
}

export function loadWeb3 (url) {
if (!url) url = 'http://localhost:8545'
const web3 = new Web3()
web3.setProvider(new Web3.providers.HttpProvider(url))
extendWeb3(web3)
return web3
}

export function setProvider (web3, url) {
web3.setProvider(new web3.providers.HttpProvider(url))
export function loadWeb3 (url = 'http://localhost:8545') {
const provider = new ethers.JsonRpcProvider(url)
extendProvider(provider)
return provider
}

export function web3DebugNode (network) {
Expand All @@ -35,32 +22,24 @@ export function web3DebugNode (network) {
return null
}

class Web3DebugPlugin extends Web3PluginBase {
public pluginNamespace = 'debug'
export function extendProvider (provider) { // Provider should be ethers.js provider

if (!provider.debug) provider.debug = {}

public preimage(key, cb) {
this.requestManager.send({
method: 'debug_preimage',
params: [key]
})
provider.debug.preimage = (key, cb) => {
this.send('debug_preimage', [key])
.then(result => cb(null, result))
.catch(error => cb(error))
}

public traceTransaction(txHash, options, cb) {
this.requestManager.send({
method: 'debug_traceTransaction',
params: [txHash, options]
})
provider.debug.traceTransaction = (txHash, options, cb) => {
this.send('debug_traceTransaction', [txHash, options])
.then(result => cb(null, result))
.catch(error => cb(error))
}

public storageRangeAt(txBlockHash, txIndex, address, start, maxSize, cb) {
this.requestManager.send({
method: 'debug_storageRangeAt',
params: [txBlockHash, toNumber(txIndex), address, start, maxSize]
})
provider.debug.storageRangeAt = (txBlockHash, txIndex, address, start, maxSize, cb) => {
this.send('debug_storageRangeAt', [txBlockHash, toNumber(txIndex), address, start, maxSize])
.then(result => cb(null, result))
.catch(error => cb(error))
}
Expand Down
15 changes: 0 additions & 15 deletions libs/remix-debug/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,6 @@ const cmdLine = new CmdLine()
cmdLine.connect('http', 'http://localhost:8545')
cmdLine.loadCompilationResult(compilation)
cmdLine.initDebugger()

// var deployContract = function (cb) {
// let _web3 = cmdLine.debugger.debugger.web3
//
// let blockNumber = null
// let txNumber = null
// let tx = null
//
// let code = compilation.data.contracts[shortFilename].SimpleStorage.evm.bytecode.object
// console.dir('deploying...')
// console.dir(code)
// _web3.eth.sendTransaction({data: '0x' + code, from: _web3.eth.accounts[0], gas: 800000}, cb)
// }

// let _web3 = cmdLine.debugger.debugger.web3
const tx = '0xf510c4f0b1d9ee262d7b9e9e87b4262f275fe029c2c733feef7dfa1e2b1e32aa'

// deployContract((err, tx) => {
Expand Down
23 changes: 12 additions & 11 deletions libs/remix-debug/test/vmCall.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
'use strict'
import { extendWeb3 } from '../src/init'
import { extendProvider } from '../src/init'
import { createAddressFromPrivateKey } from '@ethereumjs/util'
import { Web3 } from 'web3';
const { Provider } = require('@remix-project/remix-simulator')
import { Provider } from '@remix-project/remix-simulator'
import { ethers } from 'ethers'

async function getWeb3 () {
const remixSimulatorProvider = new Provider({ fork: 'cancun' })
await remixSimulatorProvider.init()
await remixSimulatorProvider.Accounts.resetAccounts()
const web3 = new Web3(remixSimulatorProvider)
extendWeb3(web3)
return web3
const provider = new ethers.BrowserProvider(remixSimulatorProvider as any)
extendProvider(provider)
return provider
}

async function sendTx (web3, from, to, value, data, cb) {
async function sendTx (provider, from, to, value, data, cb) {
try {
cb = cb || (() => {})
const receipt = await web3.eth.sendTransaction({
const signer = await provider.getSigner()
const receipt = await signer.sendTransaction({
from: createAddressFromPrivateKey(from.privateKey).toString(),
to,
value,
data,
gas: 7000000
}, null, { checkRevertBeforeSending: false, ignoreGasPricing: true })
cb(null, receipt.transactionHash)
return receipt.transactionHash
})
cb(null, receipt.hash)
return receipt.hash
} catch (e) {
cb(e)
}
Expand Down
4 changes: 1 addition & 3 deletions libs/remix-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
"rlp": "^3.0.0",
"solc": "0.8.26",
"string-similarity": "^4.0.4",
"viem": "2.22.3",
"web3": "^4.1.1",
"web3-validator": "^2.0.0"
"viem": "2.22.3"
},
"devDependencies": {
"@babel/core": "^7.4.5",
Expand Down
42 changes: 20 additions & 22 deletions libs/remix-lib/src/execution/txRunnerWeb3.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict'
import { EventManager } from '../eventManager'
import type { Transaction as InternalTransaction } from './txRunner'
import { Web3 } from 'web3'
import { BrowserProvider } from 'ethers'
import { BrowserProvider, getAddress, parseUnits } from 'ethers'
import { normalizeHexAddress } from '../helpers/uiHelper'
import { aaSupportedNetworks, aaLocalStorageKey, getPimlicoBundlerURL, aaDeterminiticProxyAddress } from '../helpers/aaConstants'
import { toBigInt, toHex, toChecksumAddress } from 'web3-utils'
import { randomBytes } from 'crypto'
import "viem/window"
import { custom, http, createWalletClient, createPublicClient, encodePacked, getContractAddress } from "viem"
import { custom, http, createWalletClient, createPublicClient, encodePacked, getContractAddress, toHex } from "viem"
import * as chains from "viem/chains"
import { entryPoint07Address } from "viem/account-abstraction"
const { createSmartAccountClient } = require("permissionless")
Expand All @@ -18,7 +16,7 @@ const { createPimlicoClient } = require("permissionless/clients/pimlico")
export class TxRunnerWeb3 {
event
_api
getWeb3: () => Web3
getWeb3: () => BrowserProvider
currentblockGasLimit: () => number

constructor (api, getWeb3, currentblockGasLimit) {
Expand All @@ -38,11 +36,11 @@ export class TxRunnerWeb3 {
}
if (txFee) {
if (txFee.baseFeePerGas) {
tx.maxPriorityFeePerGas = toHex(BigInt(this.getWeb3().utils.toWei(txFee.maxPriorityFee, 'gwei')))
tx.maxFeePerGas = toHex(BigInt(this.getWeb3().utils.toWei(txFee.maxFee, 'gwei')))
tx.maxPriorityFeePerGas = toHex(BigInt(parseUnits(txFee.maxPriorityFee, 'gwei')))
tx.maxFeePerGas = toHex(BigInt(parseUnits(txFee.maxFee, 'gwei')))
tx.type = '0x2'
} else {
tx.gasPrice = toHex(BigInt(this.getWeb3().utils.toWei(txFee.gasPrice, 'gwei')))
tx.gasPrice = toHex(BigInt(parseUnits(txFee.gasPrice, 'gwei')))
// tx.type = '0x1'
}
if (tx.authorizationList) {
Expand Down Expand Up @@ -70,7 +68,7 @@ export class TxRunnerWeb3 {
if (receipt.logs && receipt.logs.length) {
receipt.logs.map((log) => {
if (log.topics[0] === '0xa1fb700aaee2ae4a2ff6f91ce7eba292f89c2f5488b8ec4c5c5c8150692595c3') {
(receipt as any).contractAddress = toChecksumAddress(normalizeHexAddress(toHex(log.topics[2])))
(receipt as any).contractAddress = getAddress(normalizeHexAddress(toHex(log.topics[2])))
}
})
}
Expand Down Expand Up @@ -98,8 +96,8 @@ export class TxRunnerWeb3 {
promptCb(
async (value) => {
try {
const res = await (this.getWeb3() as any).eth.personal.sendTransaction({ ...tx, value }, { checkRevertBeforeSending: false, ignoreGasPricing: true })
cb(null, res.transactionHash, isCreation, false, null)
const res = await (await this.getWeb3().getSigner()).sendTransaction({ ...tx, value })
cb(null, res.hash, isCreation, false, null)

} catch (e) {
console.log(`Send transaction failed: ${e.message || e.error} . if you use an injected provider, please check it is properly unlocked. `)
Expand All @@ -119,8 +117,8 @@ export class TxRunnerWeb3 {
const { txHash, contractAddress } = await this.sendUserOp(tx, network.id)
cb(null, txHash, isCreation, true, contractAddress)
} else {
const res = await this.getWeb3().eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true })
cb(null, res.transactionHash, isCreation, false, null)
const res = await (await this.getWeb3().getSigner()).sendTransaction(tx)
cb(null, res.hash, isCreation, false, null)
}
} catch (e) {
if (!e.message) e.message = ''
Expand All @@ -147,7 +145,7 @@ export class TxRunnerWeb3 {
if (this._api && this._api.isVM()) {
(this.getWeb3() as any).remix.registerCallId(timestamp)
}
this.getWeb3().eth.call(tx)
this.getWeb3().call(tx)
.then((result: any) => callback(null, {
result: result
}))
Expand All @@ -165,13 +163,13 @@ export class TxRunnerWeb3 {
// the sending stack (web3.js / metamask need to have the type defined)
// this is to avoid the following issue: https://github.com/MetaMask/metamask-extension/issues/11824
txCopy.type = '0x2'
txCopy.maxFeePerGas = Math.ceil(Number((toBigInt(network.lastBlock.baseFeePerGas) + toBigInt(network.lastBlock.baseFeePerGas) / BigInt(3)).toString()))
txCopy.maxFeePerGas = Math.ceil(Number((BigInt(network.lastBlock.baseFeePerGas) + BigInt(network.lastBlock.baseFeePerGas) / BigInt(3)).toString()))
} else {
txCopy.type = '0x1'
txCopy.gasPrice = undefined
}
}
const ethersProvider = new BrowserProvider(this.getWeb3().currentProvider as any)
const ethersProvider = this.getWeb3()
ethersProvider.estimateGas(txCopy)
.then(gasEstimationBigInt => {
gasEstimationForceSend(null, () => {
Expand Down Expand Up @@ -323,9 +321,9 @@ export class TxRunnerWeb3 {
}
}

async function tryTillReceiptAvailable (txhash: string, web3: Web3) {
async function tryTillReceiptAvailable (txhash: string, provider: BrowserProvider) {
try {
const receipt = await web3.eth.getTransactionReceipt(txhash)
const receipt = await provider.getTransactionReceipt(txhash)
if (receipt) {
if (!receipt.to && !receipt.contractAddress) {
// this is a contract creation and the receipt doesn't contain a contract address. we have to keep polling...
Expand All @@ -335,15 +333,15 @@ async function tryTillReceiptAvailable (txhash: string, web3: Web3) {
}
} catch (e) {}
await pause()
return await tryTillReceiptAvailable(txhash, web3)
return await tryTillReceiptAvailable(txhash, provider)
}

async function tryTillTxAvailable (txhash: string, web3: Web3) {
async function tryTillTxAvailable (txhash: string, provider: BrowserProvider) {
try {
const tx = await web3.eth.getTransaction(txhash)
const tx = await provider.getTransaction(txhash)
if (tx && tx.blockHash) return tx
} catch (e) {}
return await tryTillTxAvailable(txhash, web3)
return await tryTillTxAvailable(txhash, provider)
}

async function pause () { return new Promise((resolve, reject) => { setTimeout(resolve, 500) }) }
5 changes: 2 additions & 3 deletions libs/remix-lib/src/execution/typeConversion.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict'
import { BN } from 'bn.js'
import { bytesToHex } from '@ethereumjs/util'
import { isBigInt } from 'web3-validator'

export function toInt (h) {
if (h.indexOf && h.indexOf('0x') === 0) {
return (new BN(h.replace('0x', ''), 16)).toString(10)
} else if ((h.constructor && h.constructor.name === 'BigNumber') || BN.isBN(h) || isBigInt(h)) {
} else if ((h.constructor && h.constructor.name === 'BigNumber') || BN.isBN(h) || (typeof h === 'bigint')) {
return h.toString(10)
}
return h
Expand All @@ -22,7 +21,7 @@ function convertToString (v) {
ret.push(convertToString(v[k]))
}
return ret
} else if (BN.isBN(v) || (v.constructor && v.constructor.name === 'BigNumber') || isBigInt(v)) {
} else if (BN.isBN(v) || (v.constructor && v.constructor.name === 'BigNumber') || (typeof v === 'bigint')) {
return v.toString(10)
} else if (v._isBigNumber) {
return toInt(v._hex)
Expand Down
3 changes: 1 addition & 2 deletions libs/remix-lib/src/helpers/txResultHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
import { bytesToHex } from '@ethereumjs/util'
import { isHexString } from 'ethjs-util'
import { BN } from 'bn.js'
import { isBigInt } from 'web3-validator'

function convertToPrefixedHex (input) {
if (input === undefined || input === null || isHexString(input)) {
return input
}
if ((input.constructor && input.constructor.name === 'BigNumber')
|| BN.isBN(input)
|| isBigInt(input)
|| (typeof input === 'bigint')
|| typeof input === 'number') {
return '0x' + input.toString(16)
}
Expand Down
Loading