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

Implemented Support eth_subscribe with logs param #16633

Merged
merged 2 commits into from
Jan 16, 2023

Conversation

vadimstruts
Copy link
Collaborator

@vadimstruts vadimstruts commented Jan 12, 2023

This extends support for a eth_subscribe method that can be used in Ethereum provider requests.
See a description of this here: https://docs.infura.io/infura/networks/ethereum/json-rpc-methods/subscription-methods/eth_subscribe
In addition to previously implemented newHeads (brave/brave-browser#21350), this adds new logs parameter support, but for now filtering options is not supported. It requires the follow up implementation

Resolves brave/brave-browser#27283

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Use eth_subscribe to listen for new logs. You should see a console message in the developer console matching the same subscription ID every 20 seconds. You can subscribe multiple times, each time will give a new subscription ID.
Ex:
window.ethereum.on('message', (x, y, z) => console.log('message event: ', x, y, z)) window.ethereum.send({ id:5, method: 'eth_subscribe', params:["logs"]}, console.log)

Use eth_unsubscribe to stop listening to an event by putting the subscription ID from the eth_subscribe call. It should stop ending events and return true to the console when you unsubscribe successfully from something.

window.ethereum.on('message', (x, y, z) => console.log('message event: ', x, y, z)) window.ethereum.send({ id:5, method: 'eth_unsubscribe', params:["0x0b4fcbf913cf950c936489965ba189df"]}, console.log)
where 0x0b4fcbf913cf950c936489965ba189df - subscription identifier returned by subscription method

@vadimstruts vadimstruts requested a review from a team as a code owner January 12, 2023 01:29
@vadimstruts vadimstruts linked an issue Jan 12, 2023 that may be closed by this pull request
@github-actions
Copy link
Contributor

⚠️ PR head is an unsigned commit
commit: a17df8933eb47772e705e4942204f1fc911dd055
reason: no_user
Please follow the handbook to configure commit signing
cc: @null

1 similar comment
@github-actions
Copy link
Contributor

⚠️ PR head is an unsigned commit
commit: a17df8933eb47772e705e4942204f1fc911dd055
reason: no_user
Please follow the handbook to configure commit signing
cc: @null

@vadimstruts vadimstruts force-pushed the 27283-support-eth_subscribe-with-logs-param branch from a17df89 to cbc12f7 Compare January 12, 2023 14:23
@github-actions
Copy link
Contributor

⚠️ PR head is an unsigned commit
commit: cbc12f7da649d4735db6f309f102f0199a83d997
reason: no_user
Please follow the handbook to configure commit signing
cc: @null

@vadimstruts vadimstruts force-pushed the 27283-support-eth_subscribe-with-logs-param branch from cbc12f7 to 57d5d5b Compare January 12, 2023 14:55
@github-actions
Copy link
Contributor

⚠️ PR head is an unsigned commit
commit: 57d5d5beeaffdf7eeaf97f3f718f791c4515be27
reason: no_user
Please follow the handbook to configure commit signing
cc: @null

Copy link
Member

@SergeyZhukovsky SergeyZhukovsky left a comment

Choose a reason for hiding this comment

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

++

@github-actions
Copy link
Contributor

⚠️ PR head is an unsigned commit
commit: 57d5d5beeaffdf7eeaf97f3f718f791c4515be27
reason: no_user
Please follow the handbook to configure commit signing
cc: @null

Signed-off-by: Vadym Struts <vstruts@brave.com>
Signed-off-by: Vadym Struts <vstruts@brave.com>
@vadimstruts vadimstruts force-pushed the 27283-support-eth_subscribe-with-logs-param branch from 57d5d5b to 0df37f8 Compare January 13, 2023 15:42
Copy link
Collaborator

@supermassive supermassive left a comment

Choose a reason for hiding this comment

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

LGTM

@vadimstruts vadimstruts merged commit c49ef5a into master Jan 16, 2023
@vadimstruts vadimstruts deleted the 27283-support-eth_subscribe-with-logs-param branch January 16, 2023 15:26
@github-actions github-actions bot added this to the 1.49.x - Nightly milestone Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support eth_subscribe with "logs" param
3 participants