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

Add unsubscribeByID #4061

Merged
merged 8 commits into from
May 17, 2021
Merged

Add unsubscribeByID #4061

merged 8 commits into from
May 17, 2021

Conversation

spacesailor24
Copy link
Contributor

@spacesailor24 spacesailor24 commented May 13, 2021

closes #4007
Addressing this feature,
call web3.eth.removeSubscriptionById(id) to unsubscribe by ID

@render
Copy link

render bot commented May 13, 2021

@spacesailor24 spacesailor24 changed the title Alex/unsubscribe with Add unsubscribeByID May 13, 2021
Copy link
Contributor Author

@spacesailor24 spacesailor24 left a comment

Choose a reason for hiding this comment

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

Yea, I shouldn't have created that for you, now it's my PR and I can't request changes or approve xD

.on('connected', function (result) {
assert(result)
assert.equal(1, web3.eth._requestManager.subscriptions.size);
subscription.unsubscribeById(subscription.id); // Stop listening..
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think adding unsubscribeById to an instance of the Subscription class makes sense, since unsubscribe already exists - this would just be adding a semi duplicate method to the class (bloat). Instead, if we can make unsubscribeById a static method, or similar, and we could have it unsubscribe with just the id, and not have to have an instance available to call the method from, I could see this being a useful method to add

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put this comment here to reference what I'm talking about

Instead of doing:

subscription = web3.eth.subscribe(...')
subscription.unsubscribeById(...)

It would be cool if you could find a way to do

Subscription.unsubscribeById(...)

Or maybe it would be

web3.eth.subscribe.unsubscribeById(...)

so you don't have to have access to an instance of Subscription. But maybe what you have already works like that too? Idk, can you tell me? :)

Copy link
Contributor

Choose a reason for hiding this comment

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

can probably make use of looking through web3.eth._requestManager.subscriptions and loop through the ids! Great suggestion

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool! the request manager was helpful :).
It can now be called with

web3.eth. removeSubscriptionById( id)

@coveralls
Copy link

coveralls commented May 13, 2021

Pull Request Test Coverage Report for Build 845165093

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 227 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+2.5%) to 76.245%

Files with Coverage Reduction New Missed Lines %
packages/web3-core-requestmanager/src/jsonrpc.js 1 70.0%
packages/web3-eth/lib/index.js 1 89.96%
packages/web3-core-helpers/src/formatters.js 8 82.27%
packages/web3-utils/src/utils.js 27 10.74%
packages/web3-core-helpers/src/errors.js 29 1.56%
packages/web3-utils/src/soliditySha3.js 34 3.92%
packages/web3-utils/src/index.js 42 32.12%
packages/web3-eth-accounts/src/index.js 85 33.06%
Totals Coverage Status
Change from base Build 840909188: 2.5%
Covered Lines: 3157
Relevant Lines: 3928

💛 - Coveralls

@GregTheGreek GregTheGreek marked this pull request as ready for review May 14, 2021 17:06
@luu-alex luu-alex merged commit 49b0130 into 1.x May 17, 2021
@luu-alex luu-alex deleted the alex/unsubscribeWithID branch May 17, 2021 13:22
luu-alex pushed a commit that referenced this pull request May 20, 2021
* adding function unsubscribe by id

* adding an unsubscribe testcase

* adding testcase

* seperated unsubscribebyid to its own method

* adding testcases

* adding await

* fixing testcases

Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: Alex <alex@chainsafe.io>
spacesailor24 added a commit that referenced this pull request Jul 2, 2021
* Release/1.3.5 (#3974)

* Update changelog

* Built dist

* Update version numbers

* v1.3.5

Co-authored-by: Ubuntu <ubuntu@ip-172-31-69-58.ec2.internal>

* Bump underscore (#4051)

* bump underscore

* update package-locks

* bump lcoks again

* Release 1.3.6 (#4053)

* Update CHANGELOG and ran npm i

* Built lib for 1.3.6-rc.0

* v1.3.6-rc.0

* npm i

* Built lib for 1.3.6-rc.1

* v1.3.6-rc.1

* 1.3.6-rc.2 (#4059)

* npm i && npm audit fix

* Manually bump version to 1.3.6-rc.2

* Built lib for 1.3.6-rc.2

* v1.3.6-rc.2

* 1.3.6-rc.2 fixes (#4062)

* Manually update dependency versions to 1.3.6-rc.2

* Accidental commit

* npm i

* Manually update web3 dependency version to 1.3.6-rc.2

* npm i

* Built manually for 1.3.6-rc.2

* Update CHANGELOG

* Update CHANGELOG.md

Co-authored-by: Gregory Markou <16929357+GregTheGreek@users.noreply.github.com>

Co-authored-by: Gregory Markou <16929357+GregTheGreek@users.noreply.github.com>

* Add web3-core-helpers as dev dependency

* Add web3-core-helpers as dev dependency

* Fixing 1.3.6-rc.2 related issues (#4063)

* Remove web3-eth-ens as dependency

* Regen package-locks and build lib

* Remove dtslint from ci scripts (#4064)

* Remove web3-eth-ens as dependency

* Regen package-locks and build lib

* Remove npm run dtslint from build and lint

* 1.3.6-rc.2 Fixes (#4065)

* Remove web3-eth-ens as dependency

* Regen package-locks and build lib

* Remove npm run dtslint from build and lint

* Add back removed package: web3-eth-ens

* npm i

* Build lib

* Add back npm run dtslint

* Update geth-dev-assistant

* v1.3.6

Co-authored-by: Gregory Markou <16929357+GregTheGreek@users.noreply.github.com>

* Add unsubscribeByID (#4061)

* adding function unsubscribe by id

* adding an unsubscribe testcase

* adding testcase

* seperated unsubscribebyid to its own method

* adding testcases

* adding await

* fixing testcases

Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: Alex <alex@chainsafe.io>

* ignore .md and docs (#4077)

* adding berlin tx support (#4109)

* add berlin tx support

* update install locations

* update package name in comment

* fix existing tests to support new tx sigining format

* remove build

* remove old test case

* use latest ethereumjs/tx

* bump deps and fix test

* update hashes

* fix messageHash, decoding bug

* fix tests

* add hack

* adding eip2930 and common object

* fix lint updating package-lock

* fix berlin tx signing and recovery

* updating ethereumjs/tx package

* updating checksum

* removing helper.js

* updating changelog and docs

* fixing typo

Co-authored-by: Gregory Markou <gregorymarkou@gmail.com>

* Update scripts/e2e.geth.instamine.sh to use v1.10.3 of Geth (#4154)

* Update scripts/e2e.geth.instamine.sh to use v1.10.3 of Geth

* Update scripts/e2e.geth.instamine.sh to use v1.10.3 of Geth

* Fix typo

* Release v1.4.0 (#4118)

* npm run build for 1.4.0-rc.0

* v1.4.0-rc.0

* 1.4.0 Geth version downgrade (#4149)

* Update pull Geth docker version from stable to pre-london (1.10.3)

* Update CHANGELOG

* v1.4.0

Co-authored-by: Ubuntu <ubuntu@ip-172-31-69-58.ec2.internal>
Co-authored-by: Gregory Markou <16929357+GregTheGreek@users.noreply.github.com>
Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: Alex <alex@chainsafe.io>
Co-authored-by: Gregory Markou <gregorymarkou@gmail.com>
spacesailor24 added a commit that referenced this pull request Jul 27, 2021
* adding function unsubscribe by id

* adding an unsubscribe testcase

* adding testcase

* seperated unsubscribebyid to its own method

* adding testcases

* adding await

* fixing testcases

Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: Alex <alex@chainsafe.io>
spacesailor24 added a commit that referenced this pull request Jul 28, 2021
* Release/1.3.5 (#3974)

* Update changelog

* Built dist

* Update version numbers

* v1.3.5

Co-authored-by: Ubuntu <ubuntu@ip-172-31-69-58.ec2.internal>

* Merge conflicts

* Merge conflicts

* Add unsubscribeByID (#4061)

* adding function unsubscribe by id

* adding an unsubscribe testcase

* adding testcase

* seperated unsubscribebyid to its own method

* adding testcases

* adding await

* fixing testcases

Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: Alex <alex@chainsafe.io>

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Update CHANGELOG (#4193)

Test don't run when only changes to `CHANGELOG.md` have been made

Co-authored-by: Ubuntu <ubuntu@ip-172-31-69-58.ec2.internal>
Co-authored-by: Gregory Markou <16929357+GregTheGreek@users.noreply.github.com>
Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: Alex <alex@chainsafe.io>
spacesailor24 added a commit that referenced this pull request Aug 26, 2021
* adding function unsubscribe by id

* adding an unsubscribe testcase

* adding testcase

* seperated unsubscribebyid to its own method

* adding testcases

* adding await

* fixing testcases

Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: Alex <alex@chainsafe.io>
spacesailor24 added a commit that referenced this pull request Aug 26, 2021
* Merge conflitcs

* Add unsubscribeByID (#4061)

* adding function unsubscribe by id

* adding an unsubscribe testcase

* adding testcase

* seperated unsubscribebyid to its own method

* adding testcases

* adding await

* fixing testcases

Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: Alex <alex@chainsafe.io>

* ignore .md and docs (#4077)

* Merge conflicts

* Merge conflicts

* Release v1.4.0 (#4118)

* npm run build for 1.4.0-rc.0

* v1.4.0-rc.0

* 1.4.0 Geth version downgrade (#4149)

* Update pull Geth docker version from stable to pre-london (1.10.3)

* Update CHANGELOG

* v1.4.0

* remove underscore (#4069)

* removed some of the underscore methods in web3-core-method

* removed underscore from bzz

* adding subscriptions

* fixing up test cases

* changing variable names

* removed underscore from formatters.js

* removed underscore from request manager and abi

* removing underscore in the rest of the web3 packages

* fixing exports

* fixing failing testcases

* removing underscore from tests

* addressing feedback

* removing unwanted code from transaction

* removing underscore from remaining packages

* updating change log

* addressing feedback

* adding strict equality

* efficient short circuiting

* fixing test case

* Merge conflicts

* Update docs 2 (#4188)

* add nonce to send options.

* add nonce to send options.

* Update CHANGELOG.md

* linting

* updating docs

* update web3-shh.rst : whisper-overview broken link (#4170)

whisper overview has been moved from https://github.com/ethereum/go-ethereum/wiki/Whisper to https://eth.wiki/concepts/whisper/whisper-overview

* [Docs] Fixed a broken link (#4151)

Original link gives out a 404, replaced by the closest thing I could find.

* Possible typo in docs (#4088)

I think the author missed a "this" in the phrase

* Typically you will have only one Web3 connection, use const (#3967)

Co-authored-by: Gregory Markou <16929357+GregTheGreek@users.noreply.github.com>

* Removing deprecation notice for HttpProvider (#4008)

* Removing deprecation notice for HttpProvider

From my view, it is just a provider with less capabilities than websockets, but still widely useful — and widely used as well.

@frozeman @nivida @GregTheGreek any thoughts?

* Update include_package-core.rst

* Update CHANGELOG.md

Co-authored-by: Gregory Markou <16929357+GregTheGreek@users.noreply.github.com>
Co-authored-by: Alex <alex.luu@mail.utoronto.ca>

* [Docs] Updated solidity example to modern syntax (#4147)

* [Docs] Updated solidity example to modern syntax

Replaced the old constructor function syntax with the modern one, added 'emit' to event calls, added pragma, added a valid bytes32 value and updated the JSON ABI.

* [Docs] Fixed a broken link (#1)

Original link gives out a 404, replaced by the proper guide.

Co-authored-by: Juan Alonso <Juan.Alonso@trimble.com>

* Revert "[Docs] Fixed a broken link (#1)"

This reverts commit 0de1272.

Co-authored-by: Juan Alonso <Juan.Alonso@trimble.com>

* added EIP-2718 and EIP-1559 documentation

* fixing typo

* addressing feedback

* changing possible types for maxPriorityFeePerGas

* updating maxFeePerGas type

* update changelog

Co-authored-by: exx8 <exx8eran@gmail.com>
Co-authored-by: starwalker00 <68958932+starwalker00@users.noreply.github.com>
Co-authored-by: mongolsteppe <75075420+mongolsteppe@users.noreply.github.com>
Co-authored-by: João Monteiro <joao.monteiro95@hotmail.com>
Co-authored-by: William Entriken <github.com@phor.net>
Co-authored-by: Gregory Markou <16929357+GregTheGreek@users.noreply.github.com>
Co-authored-by: Ev <evertonfrag@gmail.com>
Co-authored-by: Juan Alonso <Juan.Alonso@trimble.com>

* eth_feeHistory (EIP 1559) (#4191)

* WIP

* Add missing fields for test runner

* Correct function arguments for getFeeHistory

* getFeeHistory tests with correct arguments

* Init utils.toNumber function

* Rename toNumber test to hexToNumber

* Add inputFormatters to getFeeHistory

* Rename newestBlock to lastBlock. Update types for blockCount and lastBlock

* Add additional tests with different input types

* Add missing function export

* eth-feehistory docs (#4190)

* updating docs

* updating example

* updating types and adding example of list

* Update docs/web3-eth.rst

* Update docs/web3-eth.rst

* Update docs/web3-eth.rst

Co-authored-by: alex <luu.alex@outlook.com>
Co-authored-by: Wyatt Barnes <wyatt@writerof.software>

Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: alex <luu.alex@outlook.com>

* Update CHANGELOG (#4193)

Test don't run when only changes to `CHANGELOG.md` have been made

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Merge conflicts

* Merge conflicts

Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: Alex <alex@chainsafe.io>
Co-authored-by: Gregory Markou <16929357+GregTheGreek@users.noreply.github.com>
Co-authored-by: exx8 <exx8eran@gmail.com>
Co-authored-by: starwalker00 <68958932+starwalker00@users.noreply.github.com>
Co-authored-by: mongolsteppe <75075420+mongolsteppe@users.noreply.github.com>
Co-authored-by: João Monteiro <joao.monteiro95@hotmail.com>
Co-authored-by: William Entriken <github.com@phor.net>
Co-authored-by: Ev <evertonfrag@gmail.com>
Co-authored-by: Juan Alonso <Juan.Alonso@trimble.com>
Co-authored-by: alex <luu.alex@outlook.com>
Co-authored-by: jdevcs <86780488+jdevcs@users.noreply.github.com>
@adnandothussain
Copy link

Seems like the typescript is update for this method

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.

Unsubscring Using Subscription ID
5 participants