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/bigint-buffer@1.1.10 None 0 270 kB davidmurdoch
npm/@trufflesuite/uws-js-unofficial@20.30.0-unofficial.0 environment, network 0 118 MB davidmurdoch
npm/@types/lru-cache@5.1.1 None 0 9.36 kB types
npm/@types/seedrandom@3.0.1 None 0 6.27 kB types
npm/abstract-level@1.0.3 None 0 484 kB vweevers
npm/abstract-leveldown@7.2.0 None 0 243 kB vweevers
npm/async-eventemitter@0.2.4 None 0 19.2 kB ahultgren
npm/async@2.6.4 None 0 541 kB hargasinski
npm/base64-js@1.5.1 None 0 9.62 kB feross
npm/buffer@6.0.3 None 0 91.3 kB feross
npm/bufferutil@4.0.7 None 0 409 kB lpinca
npm/catering@2.1.1 None 0 5 kB vweevers
npm/emittery@0.10.0 None 0 44.1 kB sindresorhus
npm/ganache@7.9.2 environment, filesystem, network 0 55.2 MB truffle-cicd
npm/ieee754@1.2.1 None 0 6.8 kB feross
npm/is-buffer@2.0.5 None 0 4.59 kB feross
npm/keccak@3.0.2 None 0 775 kB fanatid
npm/level-concat-iterator@3.1.0 None 0 8.47 kB vweevers
npm/level-supports@2.1.0 None 0 26.9 kB vweevers
npm/level-transcoder@1.0.1 None 0 35.9 kB vweevers
npm/leveldown@6.1.0 None 0 5.64 MB vweevers
npm/lodash@4.17.21 None 0 1.41 MB bnjmnt4n
npm/module-error@1.0.2 None 0 7.28 kB vweevers
npm/napi-macros@2.0.0 None 0 16.2 kB mafintosh
npm/node-addon-api@2.0.2 None 0 799 kB nicknaso
npm/node-gyp-build@4.8.1 environment, filesystem 0 13.4 kB mafintosh
npm/queue-microtask@1.2.3 None 0 8.37 kB feross
npm/secp256k1@4.0.3 None 0 1.89 MB fanatid
npm/utf-8-validate@6.0.3 None 0 744 kB lpinca
npm/ws@8.13.0 environment, network 0 137 kB lpinca

🚮 Removed packages: npm/buffer-from@1.1.2, npm/cipher-base@1.0.4, npm/create-hash@1.2.0, npm/ethereumjs-util@6.2.1, npm/ethjs-util@0.1.6, npm/ganache-cli@6.12.2, npm/hash-base@3.1.0, npm/is-hex-prefixed@1.0.0, npm/md5.js@1.3.5, npm/ripemd160@2.0.2, npm/rlp@2.2.7, npm/sha.js@2.4.11, npm/source-map-support@0.5.12, npm/source-map@0.6.1, npm/strip-hex-prefix@1.0.0

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/bigint-buffer@1.1.10, npm/@trufflesuite/uws-js-unofficial@20.30.0-unofficial.0, npm/async@2.6.4, npm/bufferutil@4.0.7, npm/ganache@7.9.2, npm/keccak@3.0.2, npm/leveldown@6.1.0, npm/secp256k1@4.0.3, npm/utf-8-validate@6.0.3, npm/ws@8.13.0

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/foo@1.0.0 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/async@2.6.4
@SocketSecurity ignore npm/ws@8.13.0
@SocketSecurity ignore npm/bufferutil@4.0.7
@SocketSecurity ignore npm/keccak@3.0.2
@SocketSecurity ignore npm/secp256k1@4.0.3
@SocketSecurity ignore npm/@trufflesuite/bigint-buffer@1.1.10
@SocketSecurity ignore npm/leveldown@6.1.0
@SocketSecurity ignore npm/utf-8-validate@6.0.3
@SocketSecurity ignore npm/@trufflesuite/uws-js-unofficial@20.30.0-unofficial.0
@SocketSecurity ignore npm/ganache@7.9.2

@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