-
Notifications
You must be signed in to change notification settings - Fork 1.2k
remove web3js dependency #6409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
remove web3js dependency #6409
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
a6158ac
remove dep from astwalker
Aniket-Engg 5a2d91c
remove from analyzer
Aniket-Engg c1609ca
remove web3 dep from gh-action helper
Aniket-Engg c17fe4e
remove web3 from remix-solidity and few from remix-debug
Aniket-Engg 417e95a
simulator account ut
Aniket-Engg d91c3a4
remix simulator blocks ut1
Aniket-Engg 871ddb0
no web3 in blocks ut
Aniket-Engg 68e8274
no web3 in events ut
Aniket-Engg b29df25
no web3 in misc ut
Aniket-Engg 0f2ae2e
no web3 in tx ut
Aniket-Engg 1b9a2eb
remix-sim web3-utils removal
Aniket-Engg f20341f
no web3-utils in remix-simulator
Aniket-Engg d935b7d
web3 removed from remix-simulator
Aniket-Engg 7c73820
web-validator and web-utils removed frmo remix-lib
Aniket-Engg 7ab29a2
no web3 in remix-lib
Aniket-Engg cb58824
no web3 in remix-debug
Aniket-Engg 78caa8b
no web3 in remix-tests
Aniket-Engg c9642a0
fix initial ut of remix-tests
Aniket-Engg 6c0defc
more remix-tests unit tests
Aniket-Engg 9dfab81
fix signature retreival
Aniket-Engg f3edccc
fixed remix-tests runsource UT
Aniket-Engg 9f8e694
all remix-tests ut
Aniket-Engg 1b0d6cf
fix build
Aniket-Engg 324d6f0
fix extendProvider and removed init from remix-lib
Aniket-Engg 9a0eb81
no web3 in remix-ws-templates
Aniket-Engg 6503f9a
no web3 in remix-dapp
Aniket-Engg 8ff5bee
no web3 in remix-ui
Aniket-Engg ccc58cf
some web3 removal in remix-ide
Aniket-Engg cf88fdd
web3 import removed from code
Aniket-Engg b2516e8
remove web3 dependency
Aniket-Engg d803a97
fix remix loading and workspace e2e
Aniket-Engg f415e0c
minor fixes
Aniket-Engg fffa9fc
Merge branch 'master' into removeWeb3
Aniket-Engg 174f436
fix build
Aniket-Engg 6958e59
show tx details in terminal
Aniket-Engg 2916d2e
removed all .eth method calls
Aniket-Engg 3ac5228
removed web3 from terminal
Aniket-Engg 73500de
fix simulator methods
Aniket-Engg 2659e1b
Merge branch 'master' into removeWeb3
Aniket-Engg 64a547e
fix tx signer and tx response
Aniket-Engg fb0df90
fix debugging
Aniket-Engg 1d2e420
Merge branch 'master' into removeWeb3
Aniket-Engg 17e9b24
revert before sending fixed
Aniket-Engg e188701
fix contract code storage in remix-debug
Aniket-Engg 1655160
fix accounts call for external web3
Aniket-Engg a8c8d34
Merge branch 'master' into removeWeb3
Aniket-Engg a9acba3
more e2e fixing
Aniket-Engg cf32e82
fix data display to fix ballot e2e
Aniket-Engg e54a10c
fix eip7702 e2e
Aniket-Engg b9a08d9
fix for debugger e2e
Aniket-Engg 8da346d
web3 provider sendAsync fix and linting
Aniket-Engg 44ee764
Merge branch 'master' into removeWeb3
Aniket-Engg 37ddec4
fix debugger provider
Aniket-Engg e527a9f
fix foundry e2e
Aniket-Engg df298f5
fix free fn e2e
Aniket-Engg 6571f90
fix env and provider e2e
Aniket-Engg 8a90002
fix listen tx e2e
Aniket-Engg fd91357
fix unit testing
Aniket-Engg 8469e17
fix debugger e2e
Aniket-Engg a4e98ee
fix SUT e2e
Aniket-Engg f4218bb
fix seacrh e2e
Aniket-Engg 7924b00
Merge branch 'master' into removeWeb3
Aniket-Engg 5c761e0
fix recorder e2e
Aniket-Engg 39e2a95
fix signing e2e
Aniket-Engg f337f6a
fix linting
Aniket-Engg 89d5af2
fix remix-tests ui
Aniket-Engg 2cc84b8
fix remix-debug ut
Aniket-Engg fe2f676
linting fix
Aniket-Engg 66e5c74
update signing logic
Aniket-Engg d9fefd2
update getSigner
Aniket-Engg f80be91
fix build
Aniket-Engg 18fb733
fix execute script e2e
Aniket-Engg 9e88621
fix signing
Aniket-Engg c53ce90
added personal_sign in simulator
Aniket-Engg 7b8c79d
Merge branch 'master' into removeWeb3
Aniket-Engg ca2acf5
fix linting
Aniket-Engg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,9 @@ | ||
| import Web3, { | ||
| FMT_NUMBER, | ||
| type EthExecutionAPI, | ||
| type SupportedProviders, | ||
| FMT_BYTES, | ||
| type Bytes, | ||
| } from 'web3'; | ||
| import { addHexPrefix, toBytes } from '@ethereumjs/util'; | ||
| import { execution } from '@remix-project/remix-lib'; | ||
| import { toBigInt } from 'web3-utils'; | ||
| import { saveSettings } from '../actions'; | ||
| import { BrowserProvider, ethers, formatUnits, toNumber, TransactionReceipt, TransactionResponse } from 'ethers' | ||
|
|
||
| const web3 = new Web3(); | ||
| const provider = ethers.getDefaultProvider() | ||
|
|
||
| export const shortenAddress = (address: string, etherBalance?: string) => { | ||
| const len = address.length; | ||
|
|
@@ -29,12 +22,9 @@ async function pause() { | |
| }); | ||
| } | ||
|
|
||
| async function tryTillReceiptAvailable(txhash: Bytes) { | ||
| async function tryTillReceiptAvailable(txhash) { | ||
| try { | ||
| const receipt = await web3.eth.getTransactionReceipt(txhash, { | ||
| number: FMT_NUMBER.NUMBER, | ||
| bytes: FMT_BYTES.HEX, | ||
| }); | ||
| const receipt: TransactionReceipt = 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... | ||
|
|
@@ -52,12 +42,9 @@ async function tryTillReceiptAvailable(txhash: Bytes) { | |
| return await tryTillReceiptAvailable(txhash); | ||
| } | ||
|
|
||
| async function tryTillTxAvailable(txhash: Bytes) { | ||
| async function tryTillTxAvailable(txhash) { | ||
| try { | ||
| const tx = await web3.eth.getTransaction(txhash, { | ||
| number: FMT_NUMBER.NUMBER, | ||
| bytes: FMT_BYTES.HEX, | ||
| }); | ||
| const tx: TransactionResponse = await provider.getTransaction(txhash, ); | ||
| if (tx?.blockHash) return tx; | ||
| return tx; | ||
| } catch (e) { | ||
|
|
@@ -90,16 +77,13 @@ export class TxRunner { | |
| }, 30000); | ||
| } | ||
|
|
||
| setProvider( | ||
| provider: string | SupportedProviders<EthExecutionAPI> | undefined | ||
| ) { | ||
| web3.setProvider(provider); | ||
| setProvider(provider) { | ||
| new ethers.BrowserProvider(provider) | ||
| } | ||
|
|
||
| getAccounts() { | ||
| saveSettings({ isRequesting: true }); | ||
| void web3.eth | ||
| .getAccounts() | ||
| (provider as any).send("eth_requestAccounts", []) | ||
| .then(async (accounts) => { | ||
| const loadedAccounts: any = {}; | ||
| for (const account of accounts) { | ||
|
|
@@ -115,17 +99,18 @@ export class TxRunner { | |
| } | ||
|
|
||
| async getBalanceInEther(address: string) { | ||
| const balance = await web3.eth.getBalance(address); | ||
| return Web3.utils.fromWei(balance.toString(10), 'ether'); | ||
| const balance = await provider.getBalance(address); | ||
| return formatUnits(balance.toString(10), 'ether'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, formatUnits https://docs.ethers.org/v6/api/utils/#formatUnits works with that |
||
| } | ||
|
|
||
| async getGasPrice() { | ||
| return await web3.eth.getGasPrice(); | ||
| const { gasPrice } = await provider.getFeeData() | ||
| return gasPrice; | ||
| } | ||
|
|
||
| async runTx(tx: any, gasLimit: any, useCall: boolean) { | ||
| if (useCall) { | ||
| const returnValue = await web3.eth.call({ ...tx, gas: gasLimit }); | ||
| const returnValue = await provider.call({ ...tx, gasLimit }); | ||
|
|
||
| return toBytes(addHexPrefix(returnValue)); | ||
| } | ||
|
|
@@ -147,8 +132,8 @@ export class TxRunner { | |
| txCopy.maxFeePerGas = Math.ceil( | ||
| Number( | ||
| ( | ||
| toBigInt(network.lastBlock.baseFeePerGas) + | ||
| toBigInt(network.lastBlock.baseFeePerGas) / BigInt(3) | ||
| BigInt(network.lastBlock.baseFeePerGas) + | ||
| BigInt(network.lastBlock.baseFeePerGas) / BigInt(3) | ||
| ).toString() | ||
| ) | ||
| ); | ||
|
|
@@ -159,8 +144,8 @@ export class TxRunner { | |
| } | ||
|
|
||
| try { | ||
| const gasEstimation = await web3.eth.estimateGas(txCopy); | ||
| tx.gas = !gasEstimation ? gasLimit : gasEstimation; | ||
| const gasEstimation = await provider.estimateGas(txCopy); | ||
| tx.gasLimit = !gasEstimation ? gasLimit : gasEstimation; | ||
| return await this._executeTx(tx, network); | ||
| } catch (error) { | ||
| console.log(error); | ||
|
|
@@ -169,7 +154,8 @@ export class TxRunner { | |
| } | ||
|
|
||
| async detectNetwork() { | ||
| const id = Number(await web3.eth.net.getId()); | ||
| const { chainId } = await provider.getNetwork() | ||
| const id = Number(chainId) | ||
| let name = ''; | ||
| if (id === 1) name = 'Main'; | ||
| else if (id === 3) name = 'Ropsten'; | ||
|
|
@@ -180,7 +166,7 @@ export class TxRunner { | |
| else name = 'Custom'; | ||
|
|
||
| if (id === 1) { | ||
| const block = await web3.eth.getBlock(0); | ||
| const block = await provider.getBlock(0); | ||
| if (block && block.hash !== this.mainNetGenesisHash) name = 'Custom'; | ||
| return { | ||
| id, | ||
|
|
@@ -205,18 +191,18 @@ export class TxRunner { | |
|
|
||
| async _updateChainContext() { | ||
| try { | ||
| const block = await web3.eth.getBlock('latest'); | ||
| const block = await provider.getBlock('latest'); | ||
| // we can't use the blockGasLimit cause the next blocks could have a lower limit : https://github.com/ethereum/remix/issues/506 | ||
| this.blockGasLimit = block?.gasLimit | ||
| ? Math.floor( | ||
| Number(web3.utils.toNumber(block.gasLimit)) - | ||
| (5 * Number(web3.utils.toNumber(block.gasLimit))) / 1024 | ||
| Number(toNumber(block.gasLimit)) - | ||
| (5 * Number(toNumber(block.gasLimit))) / 1024 | ||
| ) | ||
| : web3.utils.toNumber(this.blockGasLimitDefault); | ||
| : toNumber(this.blockGasLimitDefault); | ||
| this.lastBlock = block; | ||
| try { | ||
| this.currentFork = execution.forkAt( | ||
| await web3.eth.net.getId(), | ||
| (await provider.getNetwork()).chainId, | ||
| block.number | ||
| ); | ||
| } catch (e) { | ||
|
|
@@ -247,19 +233,16 @@ export class TxRunner { | |
|
|
||
| let currentDateTime = new Date(); | ||
| try { | ||
| const { transactionHash } = await web3.eth.sendTransaction( | ||
| tx, | ||
| undefined, | ||
| { checkRevertBeforeSending: false, ignoreGasPricing: true } | ||
| ); | ||
| const receipt = await tryTillReceiptAvailable(transactionHash); | ||
| tx = await tryTillTxAvailable(transactionHash); | ||
| const signer = await (provider as BrowserProvider).getSigner(tx.from || 0); | ||
| const { hash } = await signer.sendTransaction(tx); | ||
| const receipt = await tryTillReceiptAvailable(hash); | ||
| tx = await tryTillTxAvailable(hash); | ||
|
|
||
| currentDateTime = new Date(); | ||
| return { | ||
| receipt, | ||
| tx, | ||
| transactionHash: receipt ? receipt.transactionHash : null, | ||
| transactionHash: receipt ? receipt.hash : null, | ||
| }; | ||
| } catch (error: any) { | ||
| console.log( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you make sure the input types ar ethe same?