Skip to content

Conversation

@Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Feb 10, 2021

fetch-mock has been replaced with nock. Both libraries do basically the same thing. I chose to use nock because the types shipped with fetch-mock were incorrect and they were giving me trouble. But nock also has a nicer API, and it's what we use for mocking fetch in most of our other libraries.

@Gudahtt Gudahtt requested a review from a team as a code owner February 10, 2021 07:02
@Gudahtt Gudahtt force-pushed the replace-fetch-mock-with-nock branch from 81550c7 to 4bb06cc Compare February 10, 2021 07:04
@Gudahtt
Copy link
Member Author

Gudahtt commented Feb 10, 2021

The unit test failure is being caused by a bug in a dependency. Currently investigating how to best solve this; I'll move this back into draft in the meantime.

@Gudahtt Gudahtt marked this pull request as draft February 10, 2021 18:12
Gudahtt added a commit that referenced this pull request Feb 11, 2021
The version of `ethjs-query` we're using has an unlisted dependency
upon `babel-runtime`, and will crash if it's not present. Currently
it's working because `babel-runtime` is being brought in by another
dependency (`fetch-mock`), but that dependency is removed in another
PR (#340).

Until we can migrate away from using this version of `ethjs-query`,
`babel-runtime` has been added as an explicit dependency to ensure it
is present.

`ethjs-query` is a transitive dependency of `eth-method-registry` via
`ethjs`. There is a PR open on `eth-method-registry` to replace `ethjs`
altogether [1]. Once those are merged and released, we can update
`eth-method-registry` here and remove this `babel-runtime` dependency.
Gudahtt added a commit that referenced this pull request Feb 11, 2021
The version of `ethjs-query` we're using has an unlisted dependency
upon `babel-runtime`, and will crash if it's not present. Currently
it's working because `babel-runtime` is being brought in by another
dependency (`fetch-mock`), but that dependency is removed in another
PR (#340).

Until we can migrate away from using this version of `ethjs-query`,
`babel-runtime` has been added as an explicit dependency to ensure it
is present.

`ethjs-query` is a transitive dependency of `eth-method-registry` via
`ethjs`. There is a PR open on `eth-method-registry` to replace `ethjs`
altogether [1]. Once those are merged and released, we can update
`eth-method-registry` here and remove this `babel-runtime` dependency.

[1]: MetaMask/eth-method-registry#29
@Gudahtt Gudahtt force-pushed the replace-fetch-mock-with-nock branch from 4bb06cc to 078f87e Compare February 11, 2021 14:10
@Gudahtt Gudahtt changed the base branch from develop to add-babel-runtime February 11, 2021 14:10
@Gudahtt Gudahtt force-pushed the replace-fetch-mock-with-nock branch from 078f87e to 288788e Compare February 11, 2021 14:11
@Gudahtt
Copy link
Member Author

Gudahtt commented Feb 11, 2021

The bug previously causing tests to fail has been addressed in #341 , which this PR now depends upon.

rickycodes
rickycodes previously approved these changes Feb 11, 2021
Base automatically changed from add-babel-runtime to develop February 11, 2021 15:58
@Gudahtt Gudahtt dismissed rickycodes’s stale review February 11, 2021 15:58

The base branch was changed.

Gudahtt added a commit that referenced this pull request Feb 11, 2021
The version of `ethjs-query` we're using has an unlisted dependency
upon `babel-runtime`, and will crash if it's not present. Currently
it's working because `babel-runtime` is being brought in by another
dependency (`fetch-mock`), but that dependency is removed in another
PR (#340).

Until we can migrate away from using this version of `ethjs-query`,
`babel-runtime` has been added as an explicit dependency to ensure it
is present.

`ethjs-query` is a transitive dependency of `eth-method-registry` via
`ethjs`. There is a PR open on `eth-method-registry` to replace `ethjs`
altogether [1]. Once those are merged and released, we can update
`eth-method-registry` here and remove this `babel-runtime` dependency.

[1]: MetaMask/eth-method-registry#29
`fetch-mock` has been replaced with `nock`. Both libraries do basically
the same thing. I chose to use `nock` because the types shipped with
`fetch-mock` were incorrect and they were giving me trouble. But `nock`
also has a nicer API, and it's what we use for mocking `fetch` in most
of our other libraries.
@Gudahtt Gudahtt force-pushed the replace-fetch-mock-with-nock branch from 288788e to 2c7bf06 Compare February 11, 2021 16:55
@Gudahtt Gudahtt marked this pull request as ready for review February 11, 2021 16:55
@Gudahtt Gudahtt merged commit aaf3bcc into develop Feb 12, 2021
@Gudahtt Gudahtt deleted the replace-fetch-mock-with-nock branch February 12, 2021 22:34
rickycodes added a commit that referenced this pull request Feb 18, 2021
…ba into feature/migrate-to-etherscan

* 'feature/migrate-to-etherscan' of github.com:MetaMask/gaba:
  Update `sinon` and `@types/sinon` to latest versions (#352)
  Fix `tsconfig.json` indentation (#355)
  Replace `fetch-mock` with `nock` (#340)
  Update `ethereumjs-wallet` from v0.6.5 to v1.0.1 (#347)
  Add `babel-runtime` dependency required by `ethjs-query` (#341)
  Update `@metamask/eslint-config` from v3 to v4.1.0 (#344)
  Add `docs` to list of ignored eslint patterns (#345)
  Update `uuid` from `v3.3.3` to `v8.3.2` (#346)
  Update approval controller test import (#339)
  Add Dependabot config (#343)
  Update `typedoc` (#342)
  Remove unused test module (#338)
  Replace `await-semaphore` with `async-mutex` (#334)
  Update `eth-json-rpc-filters` in lockfile (#336)
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
The version of `ethjs-query` we're using has an unlisted dependency
upon `babel-runtime`, and will crash if it's not present. Currently
it's working because `babel-runtime` is being brought in by another
dependency (`fetch-mock`), but that dependency is removed in another
PR (#340).

Until we can migrate away from using this version of `ethjs-query`,
`babel-runtime` has been added as an explicit dependency to ensure it
is present.

`ethjs-query` is a transitive dependency of `eth-method-registry` via
`ethjs`. There is a PR open on `eth-method-registry` to replace `ethjs`
altogether [1]. Once those are merged and released, we can update
`eth-method-registry` here and remove this `babel-runtime` dependency.

[1]: MetaMask/eth-method-registry#29
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
`fetch-mock` has been replaced with `nock`. Both libraries do basically
the same thing. I chose to use `nock` because the types shipped with
`fetch-mock` were incorrect and they were giving me trouble. But `nock`
also has a nicer API, and it's what we use for mocking `fetch` in most
of our other libraries.
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
The version of `ethjs-query` we're using has an unlisted dependency
upon `babel-runtime`, and will crash if it's not present. Currently
it's working because `babel-runtime` is being brought in by another
dependency (`fetch-mock`), but that dependency is removed in another
PR (#340).

Until we can migrate away from using this version of `ethjs-query`,
`babel-runtime` has been added as an explicit dependency to ensure it
is present.

`ethjs-query` is a transitive dependency of `eth-method-registry` via
`ethjs`. There is a PR open on `eth-method-registry` to replace `ethjs`
altogether [1]. Once those are merged and released, we can update
`eth-method-registry` here and remove this `babel-runtime` dependency.

[1]: MetaMask/eth-method-registry#29
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
`fetch-mock` has been replaced with `nock`. Both libraries do basically
the same thing. I chose to use `nock` because the types shipped with
`fetch-mock` were incorrect and they were giving me trouble. But `nock`
also has a nicer API, and it's what we use for mocking `fetch` in most
of our other libraries.
Mrtenz pushed a commit that referenced this pull request Oct 16, 2025
* Adds `useCache` param option to `getLatestBlock()` which ignores the
cache block number value in state when false. Defaults: true

These changes are needed to enable a way for the [blockRef middleware

](https://github.com/MetaMask/eth-json-rpc-middleware/blob/1f41907d712d98edd6caf147b522325edc4117ec/src/block-ref.ts#L52C11-L52C28)
to correctly fetch and return the most recent block number when the
BlockTracker isn't polling by avoiding the cache, but also while
ensuring that we don't refetch the block number if it is not stale yet.

See: https://consensyssoftware.atlassian.net/browse/NWNT-615



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds optional `useCache` to `getLatestBlock()` (defaults true) to
bypass cache when needed, refines running/non-running fetch logic with
rate limiting, updates tests, and documents in changelog.
> 
> - **Core (`src/PollingBlockTracker.ts`)**
> - `getLatestBlock({ useCache = true } = {})`: supports cache bypass;
when running, waits for next `latest` event; when not running, fetches
immediately via `_updateLatestBlock()` and rate-limits by delaying
pending promise cleanup to `pollingInterval`.
> - `_updateLatestBlock()` now returns the latest block string instead
of `void`.
> - `checkForLatestBlock()`: marked deprecated in JSDoc; now updates and
returns latest via `getLatestBlock()`.
> - **Tests (`src/PollingBlockTracker.test.ts`)**
> - Add comprehensive cases for `useCache: false` across not-running and
running states, including concurrency and timing.
> - **Docs**
> - Update `CHANGELOG.md` under Unreleased to note the new `useCache`
option and behavior.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
aa0f91076b8d13b3204cf50d93aeefbae02dccf5. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Mrtenz pushed a commit that referenced this pull request Oct 16, 2025
* Request validation should not throw if verifyingContract is not defined in typed signature (#328) (#330)

* 14.0.1 (#331)

* [14.x] fix: support ethermint's EIP712 implementation (#333)

* setting cosmos as allowed string for verifyingContract field

* fixed and linter

* readability

* Update condition to match main branch

* Remove duplicate copy of test

---------

Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Version 14.0.2 (#339)

* Version 14.0.2

* Fix typo

Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com>

---------

Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com>

---------

Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>
Co-authored-by: Michael Tsitrin <114929630+mtsitrin@users.noreply.github.com>
Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com>
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.

4 participants