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

adapt to eip-1193 provider changes #170

Merged
merged 20 commits into from
Jul 24, 2024

Conversation

kanthesha
Copy link
Contributor

@kanthesha kanthesha commented Jul 11, 2024

After SafeEventEmitterProvider is updated to support EIP-1193 and a new version of @metamask/eth-json-rpc-provider is released, we should adapt to the changes:

  • sendAsync deprecated method has been replaced with request method.

Fixes #151


// deploy log-echo contract
const coinbase = await sendAsync({ method: 'eth_coinbase' })
const { contractAddress } = await deployLogEchoContract({ tools, from: coinbase })
const accounts = await request({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was throwing Error: Returned error: sender account not recognized, when coinbase (0x000....) supplied as a from account. So coinbase account has been replaced with first account from the accounts array.


// deploy log-echo contract
const coinbase = await sendAsync({ method: 'eth_coinbase' })
const { contractAddress } = await deployLogEchoContract({ tools, from: coinbase })
const accounts = await request({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was throwing Error: Returned error: sender account not recognized, when coinbase (0x000....) supplied as a from account. So coinbase account has been replaced with first account from the accounts array.

method: 'eth_sendTransaction',
params: {
from: coinbase,
params: [{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was throwing Error: Incorrect number of arguments. 'eth_sendTransaction' requires exactly 1 argument error without the [].

Copy link

socket-security bot commented Jul 18, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@trufflesuite/[email protected] None 0 270 kB davidmurdoch
npm/@trufflesuite/[email protected] environment, network 0 118 MB davidmurdoch
npm/@types/[email protected] None 0 9.36 kB types
npm/@types/[email protected] None 0 6.27 kB types
npm/[email protected] None 0 484 kB vweevers
npm/[email protected] None 0 243 kB vweevers
npm/[email protected] None 0 19.2 kB ahultgren
npm/[email protected] None 0 541 kB hargasinski
npm/[email protected] None 0 9.62 kB feross
npm/[email protected] None 0 91.3 kB feross
npm/[email protected] None 0 409 kB lpinca
npm/[email protected] None 0 5 kB vweevers
npm/[email protected] None 0 44.1 kB sindresorhus
npm/[email protected] environment, filesystem, network 0 55.2 MB truffle-cicd
npm/[email protected] None 0 6.8 kB feross
npm/[email protected] None 0 4.59 kB feross
npm/[email protected] None 0 775 kB fanatid
npm/[email protected] None 0 8.47 kB vweevers
npm/[email protected] None 0 26.9 kB vweevers
npm/[email protected] None 0 35.9 kB vweevers
npm/[email protected] None 0 5.64 MB vweevers
npm/[email protected] None 0 1.41 MB bnjmnt4n
npm/[email protected] None 0 7.28 kB vweevers
npm/[email protected] None 0 16.2 kB mafintosh
npm/[email protected] None 0 799 kB nicknaso
npm/[email protected] environment, filesystem 0 13.4 kB mafintosh
npm/[email protected] None 0 8.37 kB feross
npm/[email protected] None 0 1.89 MB fanatid
npm/[email protected] None 0 744 kB lpinca
npm/[email protected] environment, network 0 137 kB lpinca

🚮 Removed packages: npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

Copy link

socket-security bot commented Jul 18, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring: npm/@trufflesuite/[email protected], npm/@trufflesuite/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

Next steps

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

package.json Outdated Show resolved Hide resolved
@@ -52,8 +55,14 @@
"ethereumjs-util>ethereum-cryptography>keccak": false,
"ethereumjs-util>ethereum-cryptography>secp256k1": false,
"ethjs-query>babel-runtime>core-js": false,
"ganache-cli>ethereumjs-util>ethereum-cryptography>keccak": false,
"ganache-cli>ethereumjs-util>ethereum-cryptography>secp256k1": false
"ganache>keccak": false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New ganache config has been added to fix.

@lavamoat/allow-scripts has detected dependencies without configuration. explicit configuration required.
run "allow-scripts auto" to automatically populate the configuration.

packages missing configuration:
- ganache>@trufflesuite/bigint-buffer [1 location(s)]
- ganache>@trufflesuite/uws-js-unofficial>bufferutil [1 location(s)]
- ganache>@trufflesuite/uws-js-unofficial>utf-8-validate [1 location(s)]
- ganache>bufferutil [1 location(s)]
- ganache>leveldown [1 location(s)]
- ganache>utf-8-validate [1 location(s)]
error Command failed with exit code 1.

@kanthesha kanthesha marked this pull request as ready for review July 18, 2024 09:15
@kanthesha kanthesha requested a review from a team as a code owner July 18, 2024 09:15
package.json Outdated Show resolved Hide resolved
package.json Outdated
"sinon": "^15.2.0",
"tape": "^5.7.0"
},
"resolutions": {
"@metamask/eth-json-rpc-provider": "^4.1.0"
Copy link
Contributor

@legobeat legobeat Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done without relying on resolutions? As this package does not have dependencies bundled, it means the desired version will not be used by users/dependencies of this package as intended.

(Unless this is purely for the sake of transitive devDependency for tests, in which case OK for now i guess?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, removed the resolutions from package.json.

Copy link
Contributor Author

@kanthesha kanthesha Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've to revert it and bring back the resolutions.

Yes, it is for the tests. Even before this PR, we are using @metamask/eth-json-rpc-provider package in the tests without implicitly specifying in the package.json (which will be supplied by @metamask/eth-block-tracker). The request method is available only from 4.1.0 of @metamask/eth-json-rpc-provider. Without the resolutions, I see tests failing for request method not available.

Copy link
Contributor

@legobeat legobeat Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like there is an undeclared peerDependencies requirement somewhere, seeing that @metamask/eth-json-rpc-middleware v13 seems necessary be a new requirement after this change and v12 and lower break...?

Would it be possible to introduce these changes in a non-breaking way which are still compatible with the non-latest versions of the peer-packages?

(Tests pass without resolutions when bumping @metamask/eth-json-rpc-middleware to 13)

@kanthesha kanthesha marked this pull request as ready for review July 22, 2024 13:01
getBlocksForRange.js Outdated Show resolved Hide resolved
Copy link
Contributor

@cryptodev-2s cryptodev-2s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kanthesha
Copy link
Contributor Author

@SocketSecurity ignore npm/[email protected]
@SocketSecurity ignore npm/[email protected]
@SocketSecurity ignore npm/[email protected]
@SocketSecurity ignore npm/[email protected]
@SocketSecurity ignore npm/[email protected]
@SocketSecurity ignore npm/@trufflesuite/[email protected]
@SocketSecurity ignore npm/[email protected]
@SocketSecurity ignore npm/[email protected]
@SocketSecurity ignore npm/@trufflesuite/[email protected]
@SocketSecurity ignore npm/[email protected]

@kanthesha kanthesha merged commit 51b39b4 into main Jul 24, 2024
7 checks passed
@kanthesha kanthesha deleted the feat/adapt-eip-1193-provider-changes branch July 24, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adapt to EIP-1193 provider changes
3 participants