Skip to content
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

Update web3js 4 #4108

Merged
merged 66 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
ecebda8
Bump web3 to v4
spacesailor24 Jul 25, 2023
9eb2a6d
Manually bump web3 to v4
spacesailor24 Jul 25, 2023
4620aab
Fix yarn run build:libs
spacesailor24 Jul 25, 2023
8d5fbf8
Add web3-utils-legacy as dep
spacesailor24 Jul 25, 2023
c23004e
Fix yarn nx build
spacesailor24 Jul 25, 2023
20da177
Fix yarn nx run remix-simulator:test
spacesailor24 Jul 25, 2023
855b38a
Fix yarn nx run remix-debug:test
spacesailor24 Jul 25, 2023
059c998
WIP - Fix yarn nx run remix-tests:test
spacesailor24 Jul 26, 2023
bbcee6b
Update README.md
avkos Jul 31, 2023
dd17d40
revert test
avkos Jul 31, 2023
2858e52
fix tests
avkos Aug 10, 2023
fc28788
fix tests
avkos Aug 10, 2023
29aab75
remove web3-utils-legacy. fix lib tests
avkos Aug 14, 2023
db972f2
Merge remote-tracking branch 'upstream/master' into spacesailor24/web…
avkos Aug 14, 2023
07c93ae
fix bigInt validation
avkos Aug 14, 2023
fe81d5a
fix remix-tests tests
avkos Aug 14, 2023
f04ad5c
fix cors
avkos Aug 15, 2023
fb2af3a
fix
avkos Aug 15, 2023
e1e2ed4
fix lint
avkos Aug 15, 2023
28ca150
fix lint
avkos Aug 15, 2023
2b2fd77
test
avkos Aug 15, 2023
3f9ca4c
fix ui
avkos Aug 16, 2023
8d0c157
Merge remote-tracking branch 'upstream/master' into spacesailor24/web…
avkos Aug 16, 2023
dec61d8
remove unused code
avkos Aug 16, 2023
5315383
check data before slice
avkos Aug 16, 2023
2aae76c
test
avkos Aug 16, 2023
8e9f275
Merge remote-tracking branch 'upstream/master' into spacesailor24/web…
avkos Aug 16, 2023
92a0814
fix provider
avkos Aug 16, 2023
a72a3a6
fix libs tests
avkos Aug 16, 2023
7177b10
web3 up
avkos Aug 16, 2023
36c72f5
test
avkos Aug 16, 2023
c765fa9
comment the test
avkos Aug 17, 2023
5f83bda
Merge remote-tracking branch 'upstream/master' into spacesailor24/web…
avkos Aug 17, 2023
967e438
ipc provider and callbacks
avkos Aug 21, 2023
e7890b1
Merge remote-tracking branch 'upstream/master' into spacesailor24/web…
avkos Aug 21, 2023
3a34f5c
update latest web3
avkos Aug 21, 2023
898e2fa
revert comment and logs
avkos Aug 21, 2023
d15c3b3
Merge remote-tracking branch 'upstream/master' into spacesailor24/web…
avkos Sep 13, 2023
ff08aa1
rerun tests
avkos Sep 13, 2023
bc7f13b
fix sendAsync call
yann300 Sep 18, 2023
38d2dc7
fix tx runner
avkos Sep 25, 2023
41ce94f
Merge remote-tracking branch 'upstream/master' into spacesailor24/web…
avkos Sep 25, 2023
196426d
fix
avkos Sep 26, 2023
36d85d5
fix plugins
avkos Sep 26, 2023
da7864e
Merge remote-tracking branch 'upstream/master' into spacesailor24/web…
avkos Sep 27, 2023
fc7a659
Update README.md
avkos Sep 28, 2023
b495ae4
Merge remote-tracking branch 'origin/master' into update_web3js_4
yann300 Oct 2, 2023
6145fff
misc fix
yann300 Oct 3, 2023
c3402c4
fiw test status field
yann300 Oct 23, 2023
74677d3
Merge remote-tracking branch 'origin/master' into update_web3js_4
yann300 Oct 23, 2023
55ecfcf
fix calling custom web3.js functions
yann300 Oct 23, 2023
d7840d4
use eth_callBySimulator
yann300 Oct 23, 2023
13fb5d1
fix setting 0x1 type
yann300 Oct 23, 2023
b93a417
fix web3js throwing when revert
yann300 Oct 23, 2023
2d1b0f7
fix sign message
yann300 Oct 23, 2023
2c3340c
fix test
yann300 Oct 23, 2023
32278b0
fix calling a provider from a plugin
yann300 Oct 24, 2023
8533171
fix sol unit test
yann300 Oct 24, 2023
8d21261
fix stringifying bigint
yann300 Oct 24, 2023
c729fe1
fix solidity unittest, listen on failed tx
yann300 Oct 24, 2023
c741f57
fix listening on new block
yann300 Oct 24, 2023
9196470
fix debugging call in test
yann300 Oct 24, 2023
368d584
rename testPlugin to remix
yann300 Oct 24, 2023
d6b6f9d
remove call by simulator
yann300 Oct 24, 2023
c37f24f
Merge remote-tracking branch 'origin/master' into update_web3js_4
yann300 Oct 25, 2023
8fa6043
Merge remote-tracking branch 'origin/master' into update_web3js_4
yann300 Oct 26, 2023
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ parameters:
default: true
```


## Important Links

- Official website: https://remix-project.org
Expand Down
4 changes: 2 additions & 2 deletions apps/remix-ide-e2e/src/tests/ballot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = {
.clickFunction('delegate - transact (not payable)', { types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"' })
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
},
Expand Down Expand Up @@ -87,7 +87,7 @@ module.exports = {
.clickFunction('delegate - transact (not payable)', { types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"' })
.testFunction('last',
{
status: 'false Transaction mined but execution failed',
status: '0x0 Transaction mined but execution failed',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
},
Expand Down
4 changes: 2 additions & 2 deletions apps/remix-ide-e2e/src/tests/ballot_0_4_14.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = {
.clickFunction('delegate - transact (not payable)', { types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"' })
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
},
Expand Down Expand Up @@ -83,7 +83,7 @@ module.exports = {
.clickFunction('delegate - transact (not payable)', { types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"' })
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
},
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide-e2e/src/tests/erc721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {
.createContract('')
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded input': {}
}).end()
}
Expand Down
5 changes: 0 additions & 5 deletions apps/remix-ide-e2e/src/tests/plugin_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ const debugValues = async function (browser: NightwatchBrowser, field: string, e
return
}
browser.waitForElementVisible(`//*[@id="${field}"]`).getText(`//*[@id="${field}"]`, (result) => {
console.log(result)
if (!result.value.toString().includes(expected)) {
console.log('Actual result:')
console.log(result.value.toString())
console.log('Expected result:')
console.log(expected)
getBrowserLogs(browser)
browser.assert.ok(false, 'Returned value from call does not match expected value.')
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide-e2e/src/tests/recorder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = {
.pause(1000)
.clickFunction('set2 - transact (not payable)', { types: 'uint256 _po', values: '10' })
.testFunction('last', {
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded input': { 'uint256 _po': '10' }
})
},
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide-e2e/src/tests/remixd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ module.exports = {
.createContract('')
.testFunction('last',
{
status: 'true Transaction mined and execution succeed'
status: '0x1 Transaction mined and execution succeed'
})


Expand Down
4 changes: 2 additions & 2 deletions apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {
.click('*[data-id="Deploy - transact (not payable)"]')
.pause(5000)
.testFunction('last', {
status: 'true Transaction mined and execution succeed'
status: '0x1 Transaction mined and execution succeed'
})
},

Expand Down Expand Up @@ -95,7 +95,7 @@ module.exports = {
.click('*[data-id="pluginManagerSettingsDeployAndRunLLTxSendTransaction"]')
.pause(5000)
.testFunction('last', {
status: 'true Transaction mined and execution succeed'
status: '0x1 Transaction mined and execution succeed'
})
// When this is removed and tests are running by connecting to metamask
// Consider adding tests to check return value of contract call
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide-e2e/src/tests/terminal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ const scriptBlockAndTransaction = `
(async () => {
try {
web3.eth.getTransaction('0x022ccd55747677ac50f8d9dfd1bf5b843fa2f36438a28c1d0a0958e057bb3e2a').then(console.log)
web3.eth.getBlock('7367447').then(console.log);
web3.eth.getBlock(7367447).then(console.log);
let ethersProvider = new ethers.providers.Web3Provider(web3Provider)
ethersProvider.getBlock(7367447).then(console.log)
} catch (e) {
Expand Down
16 changes: 8 additions & 8 deletions apps/remix-ide-e2e/src/tests/transactionExecution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ module.exports = {
.clickFunction('f - transact (not payable)')
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded output': { 0: 'uint256: 8' }
})
.clickFunction('g - transact (not payable)')
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded output': {
0: 'uint256: 345',
1: 'string: comment_comment_',
Expand All @@ -45,7 +45,7 @@ module.exports = {
.clickFunction('retunValues1 - transact (not payable)')
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded output': {
0: 'bool: _b true',
1: 'uint256: _u 345',
Expand All @@ -56,7 +56,7 @@ module.exports = {
.clickFunction('retunValues2 - transact (not payable)')
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded output': {
0: 'bytes1: _b 0x12',
1: 'bytes2: _b2 0x1223',
Expand All @@ -73,7 +73,7 @@ module.exports = {
.clickFunction('retunValues3 - transact (not payable)')
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded output': {
0: 'uint8: _en 2',
1: 'int256[5][]: _a1 1,-45,-78,56,60,-1,42,334,-45455,-446,1,10,-5435,45,-7'
Expand All @@ -89,7 +89,7 @@ module.exports = {
.clickFunction('inputValue1 - transact (not payable)', { types: 'uint256 _u, int256 _i, string _str', values: '"2343242", "-4324324", "string _ string _ string _ string _ string _ string _ string _ string _ string _ string _"' })
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded output': {
0: 'uint256: _uret 2343242',
1: 'int256: _iret -4324324',
Expand All @@ -99,7 +99,7 @@ module.exports = {
.pause(500)
.clickFunction('inputValue2 - transact (not payable)', { types: 'uint256[3] _n, bytes8[4] _b8', values: '[1,2,3], ["0x1234000000000000", "0x1234000000000000","0x1234000000000000","0x1234000000000000"]' })
.testFunction('last', {
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded output': {
0: 'uint256[3]: _nret 1,2,3',
1: 'bytes8[4]: _b8ret 0x1234000000000000,0x1234000000000000,0x1234000000000000,0x1234000000000000'
Expand Down Expand Up @@ -222,7 +222,7 @@ module.exports = {
.clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '24' })
.testFunction('last', // we check if the contract is actually reachable.
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded input': {
'uint256 num': '24'
}
Expand Down
4 changes: 2 additions & 2 deletions apps/remix-ide-e2e/src/tests/txListener.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
.clickFunction('delegate - transact (not payable)', { types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"' })
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
status: '0x1 Transaction mined and execution succeed',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
.clickLaunchIcon('solidity')
Expand All @@ -40,7 +40,7 @@ module.exports = {
.clickFunction('delegate - transact (not payable)', { types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"' })
.testFunction('last',
{
status: 'false Transaction mined but execution failed',
status: '0x0 Transaction mined but execution failed',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
.end()
Expand Down
6 changes: 3 additions & 3 deletions apps/remix-ide/src/app/plugins/solidity-script.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react' // eslint-disable-line
import {format} from 'util'
import {Plugin} from '@remixproject/engine'
import {compile} from '@remix-project/remix-solidity'
import {TransactionConfig} from 'web3-core'
import {Transaction} from 'web3-types'
const _paq = (window._paq = window._paq || []) //eslint-disable-line

const profile = {
Expand Down Expand Up @@ -69,7 +69,7 @@ export class SolidityScript extends Plugin {
}

// deploy the contract
let tx: TransactionConfig = {
let tx: Transaction = {
from: accounts[0],
data: bytecode
}
Expand All @@ -81,7 +81,7 @@ export class SolidityScript extends Plugin {
}
const receiptCall = await web3.eth.sendTransaction(tx)

const hhlogs = await web3.eth.getHHLogsForTx(receiptCall.transactionHash)
const hhlogs = await web3.remix.getHHLogsForTx(receiptCall.transactionHash)

if (hhlogs && hhlogs.length) {
const finalLogs = (
Expand Down
8 changes: 2 additions & 6 deletions apps/remix-ide/src/app/providers/injected-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,8 @@ export abstract class InjectedProvider extends Plugin implements IProvider {
}
try {
let resultData
if (web3Provider.send) resultData = await web3Provider.send(data.method, data.params)
else if (web3Provider.request)
resultData = await web3Provider.request({
method: data.method,
params: data.params
})
if (web3Provider.request) resultData = await web3Provider.request({method: data.method, params: data.params})
else if (web3Provider.send) resultData = await web3Provider.send(data.method, data.params)
else {
resolve({jsonrpc: '2.0', error: 'provider not valid', id: data.id})
return
Expand Down
6 changes: 3 additions & 3 deletions apps/remix-ide/src/app/tabs/debugger-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ export class DebuggerTab extends DebuggerApiMixin(ViewPlugin) {
'timestamp': block.timestamp,
}
if (block.baseFeePerGas) {
blockContext['basefee'] = Web3.utils.toBN(block.baseFeePerGas).toString(10) + ` Wei (${block.baseFeePerGas})`
blockContext['basefee'] = Web3.utils.toBigInt(block.baseFeePerGas).toString(10) + ` Wei (${block.baseFeePerGas})`
}
const msg = {
const msg = {
'sender': tx.from,
'sig': tx.input.substring(0, 10),
'value': tx.value + ' Wei'
Expand All @@ -97,7 +97,7 @@ export class DebuggerTab extends DebuggerApiMixin(ViewPlugin) {
const txOrigin = {
'origin': tx.from
}

return {
block: blockContext,
msg,
Expand Down
3 changes: 2 additions & 1 deletion apps/remix-ide/src/app/tabs/network-module.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../../../package.json'
import { Web3 } from 'web3'
import IpcProvider from 'web3-providers-ipc'

export const profile = {
name: 'network',
Expand Down Expand Up @@ -49,7 +50,7 @@ export class NetworkModule extends Plugin {

/** Add a custom network to the list of available networks */
addNetwork (network) { // { name, url }
const provider = network.url === 'ipc' ? new Web3.providers.IpcProvider() : new Web3.providers.HttpProvider(network.url)
const provider = network.url === 'ipc' ? new IpcProvider() : new Web3.providers.HttpProvider(network.url)
this.blockchain.addProvider({ name: network.name, provider })
}

Expand Down
18 changes: 14 additions & 4 deletions apps/remix-ide/src/app/tabs/web3-provider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../../../package.json'
import {isBigInt} from 'web3-validator'

export const profile = {
name: 'web3Provider',
Expand All @@ -10,6 +11,11 @@ export const profile = {
kind: 'provider'
}

const replacer = (key, value) => {
if (isBigInt(value)) value = value.toString()
return value
}

export class Web3ProviderModule extends Plugin {
constructor(blockchain) {
super(profile)
Expand All @@ -23,12 +29,11 @@ export class Web3ProviderModule extends Plugin {
sendAsync(payload) {

return new Promise((resolve, reject) => {
this.askUserPermission('sendAsync', `Calling ${payload.method} with parameters ${JSON.stringify(payload.params, null, '\t')}`).then(
this.askUserPermission('sendAsync', `Calling ${payload.method} with parameters ${JSON.stringify(payload.params, replacer, '\t')}`).then(
async (result) => {
if (result) {
const provider = this.blockchain.web3().currentProvider
// see https://github.com/ethereum/web3.js/pull/1018/files#diff-d25786686c1053b786cc2626dc6e048675050593c0ebaafbf0814e1996f22022R129
provider[provider.sendAsync ? 'sendAsync' : 'send'](payload, async (error, message) => {
const resultFn = async (error, message) => {
if (error) {
// Handle 'The method "debug_traceTransaction" does not exist / is not available.' error
if(error.message && error.code && error.code === -32601) {
Expand All @@ -55,7 +60,12 @@ export class Web3ProviderModule extends Plugin {
}
}
resolve(message)
})
}
try {
resultFn(null, await provider.sendAsync(payload))
} catch (e) {
resultFn(e.message)
}
} else {
reject(new Error('User denied permission'))
}
Expand Down
10 changes: 9 additions & 1 deletion apps/remix-ide/src/app/udapp/make-udapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ export function makeUdapp (blockchain, compilersArtefacts, logHtmlCallback) {
if (_transactionReceipts[tx.hash]) {
return cb(null, _transactionReceipts[tx.hash])
}
blockchain.web3().eth.getTransactionReceipt(tx.hash, (error, receipt) => {
let res = blockchain.web3().eth.getTransactionReceipt(tx.hash, (error, receipt) => {
if (error) {
return cb(error)
}
_transactionReceipts[tx.hash] = receipt
cb(null, receipt)
})
if(res && typeof res.then ==='function'){
res.then((receipt)=>{
_transactionReceipts[tx.hash] = receipt
cb(null, receipt)
}).catch((error)=>{
cb(error)
})
}
}

const txlistener = blockchain.getTxListener({
Expand Down
10 changes: 3 additions & 7 deletions apps/remix-ide/src/app/udapp/run-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,9 @@ export class RunTab extends ViewPlugin {
}
},
provider: {
async sendAsync(payload, callback) {
try {
const result = await udapp.call(name, 'sendAsync', payload)
callback(null, result)
} catch (e) {
callback(e)
}

async sendAsync (payload) {
return udapp.call(name, 'sendAsync', payload)
}
}
})
Expand Down
Loading
Loading