Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Build, Lint, and Test

on:
push:
branches: [main]
pull_request:

jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
cache-node-modules: ${{ matrix.node-version == '22.x' }}

build:
name: Build
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
- run: yarn build
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

lint:
name: Lint
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
- run: yarn lint
- name: Validate RC changelog
if: ${{ startsWith(github.head_ref, 'release/') }}
run: yarn lint:changelog --rc
- name: Validate changelog
if: ${{ !startsWith(github.head_ref, 'release/') }}
run: yarn lint:changelog
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

test:
name: Test
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
- run: yarn test
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

compatibility-test:
name: Compatibility test
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
- name: Install dependencies via Yarn
run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
- run: yarn test
- name: Restore lockfile
run: git restore yarn.lock
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

all-jobs-pass:
name: All jobs pass
runs-on: ubuntu-20.04
needs:
- build-lint-test
steps:
- run: echo "Great success!"
44 changes: 0 additions & 44 deletions .github/workflows/build-test.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// All of these are defaults except singleQuote, but we specify them
// for explicitness
const config = {
quoteProps: 'as-needed',
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
plugins: ['prettier-plugin-packagejson'],
};

export default config;
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Expand All @@ -7,60 +8,82 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

## [9.0.0]

### Changed

- **BREAKING:** Adapt to EIP-1193 provider changes by replacing the deprecated `sendAsync` method with the `request` method ([#170](https://github.com/MetaMask/eth-json-rpc-filters/pull/170))

### Fixed

- Bump `@metamask/json-rpc-engine` from `^9.0.0` to `^10.0.0` ([#194](https://github.com/MetaMask/eth-json-rpc-filters/pull/194))

## [8.0.0]

### Changed

- BREAKING: Drop support for Node.js v16, v21 ([#164](https://github.com/MetaMask/eth-json-rpc-filters/pull/164))
- Update `@metamask/json-rpc-engine` from `^8.0.2` to `^9.0.0` ([#165](https://github.com/MetaMask/eth-json-rpc-filters/pull/165))

## [7.0.1]

### Changed

- yarn version 1.22.22 declared as packageManager in package.json ([#156](https://github.com/MetaMask/eth-json-rpc-filters/pull/156))
- Bump `@metamask/eth-query` from `^3.0.1` to `^4.0.0` ([#126](https://github.com/MetaMask/eth-json-rpc-filters/pull/126))
- Bump `@metamask/json-rpc-engine` from `^7.1.0` to `^8.0.2` ([#162](https://github.com/MetaMask/eth-json-rpc-filters/pull/162))

### Fixed

- Bump `async-mutex` from `^0.2.6` to `^0.5.0` ([#163](https://github.com/MetaMask/eth-json-rpc-filters/pull/163))

## [7.0.0]

### Changed

- **BREAKING:** Set minimum Node.js version to v16 ([#102](https://github.com/MetaMask/eth-json-rpc-filters/pull/102))
- **BREAKING:** Rename package from `eth-json-rpc-filters` to `@metamask/eth-json-rpc-filters` ([#103](https://github.com/MetaMask/eth-json-rpc-filters/pull/103))
- Bump `@metamask/json-rpc-engine` from `^6.0.0` to `^7.1.0` ([#104](https://github.com/MetaMask/eth-json-rpc-filters/pull/104))
- Replace `@metamask/eth-query`@`^2.1.2` with `@metamask/eth-query`@`^3.0.1` ([#107](https://github.com/MetaMask/eth-json-rpc-filters/pull/107))

## [6.0.1]

### Changed

- Bump `@metamask/safe-event-emitter` from `^2.0.0` to `^3.0.0` ([#94](https://github.com/MetaMask/eth-json-rpc-filters/pull/94))

## [6.0.0]

### Changed

- **BREAKING:** Block filter middleware will not throw an error if a block is not found ([#89](https://github.com/MetaMask/eth-json-rpc-filters/pull/89))

## [5.1.0]

### Changed

- Remove `eth-json-rpc-middleware` dependency ([#76](https://github.com/MetaMask/eth-json-rpc-filters/pull/76))
- This package is still used in tests as a `devDependency`, but it's not used in the published package anymore.

### Fixed

- Fix `eth_getFilterLogs` ([#84](https://github.com/MetaMask/eth-json-rpc-filters/pull/84))
- Fix for null reference exception when normalizing the block ([#83](https://github.com/MetaMask/eth-json-rpc-filters/pull/83))

## [5.0.0] - 2022-05-10

### Added

- Add retry logic to `getBlocksForRange`, treating a null block number as failure ([#61](https://github.com/MetaMask/eth-json-rpc-filters/pull/61))

### Changed

- **BREAKING:** Set minimum Node.js version to v12 ([#50](https://github.com/MetaMask/eth-json-rpc-filters/pull/50))
- We officially support Node 12, 14, and 16, in alignment with our other packages.

## [4.2.2] - 2021-02-04

### Changed

- Replace `await-semaphore` with `async-mutex` ([#33](https://github.com/MetaMask/eth-json-rpc-filters/pull/33))
- Move `pify` to production dependencies and update to v5 ([#39](https://github.com/MetaMask/eth-json-rpc-filters/pull/39) and [#40](https://github.com/MetaMask/eth-json-rpc-filters/pull/40))
- Cleanup manifest metadata ([#43](https://github.com/MetaMask/eth-json-rpc-filters/pull/43) and [#42](https://github.com/MetaMask/eth-json-rpc-filters/pull/42))
Expand All @@ -69,21 +92,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Remove `lodash.flatmap` dependency ([#36](https://github.com/MetaMask/eth-json-rpc-filters/pull/36))

## [4.2.1] - 2020-09-22

### Changed

- Specify publish files ([#30](https://github.com/MetaMask/eth-json-rpc-filters/pull/30))

## [4.2.0] - 2020-09-22

### Changed

- Update RPC packages ([#29](https://github.com/MetaMask/eth-json-rpc-filters/pull/29))
- `[email protected]`
- `[email protected]`

## [3.0.1] - 2018-10-08

### Changed

- **BREAKING**: `BaseFilter` now extends `SafeEventEmitter` (c583ba9d9410ca7c861282b0a122212b7c22ba47)

## [2.0.0] - 2018-05-22

### Changed

- **BREAKING**: expect EthBlockTracker@4 (062fd0849631a9862780c0591a3987bcadfe880f)

[Unreleased]: https://github.com/MetaMask/eth-json-rpc-filters/compare/v9.0.0...HEAD
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Backed by an [eth-block-tracker](https://github.com/MetaMask/eth-block-tracker) and web3 provider interface (`web3.currentProvider`).

### supported rpc methods

- `eth_newFilter`
- `eth_newBlockFilter`
- `eth_newPendingTransactionFilter`
Expand All @@ -14,15 +15,17 @@ Backed by an [eth-block-tracker](https://github.com/MetaMask/eth-block-tracker)
### usage

basic usage:

```js
const filterMiddleware = createFilterMiddleware({ blockTracker, provider })
engine.push(filterMiddleware)
const filterMiddleware = createFilterMiddleware({ blockTracker, provider });
engine.push(filterMiddleware);
```

cleanup:

```js
// remove blockTracker handler to free middleware for garbage collection
filterMiddleware.destroy()
filterMiddleware.destroy();
```

## Running Tests
Expand All @@ -32,4 +35,5 @@ yarn test
```

## Changelog

[`CHANGELOG.md`](./CHANGELOG.md)
32 changes: 15 additions & 17 deletions base-filter-history.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
const BaseFilter = require('./base-filter')
const BaseFilter = require('./base-filter');

// tracks all results ever recorded
class BaseFilterWithHistory extends BaseFilter {

constructor () {
super()
this.allResults = []
constructor() {
super();
this.allResults = [];
}

async update () {
throw new Error('BaseFilterWithHistory - no update method specified')
async update() {
throw new Error('BaseFilterWithHistory - no update method specified');
}

addResults (newResults) {
this.allResults = this.allResults.concat(newResults)
super.addResults(newResults)
addResults(newResults) {
this.allResults = this.allResults.concat(newResults);
super.addResults(newResults);
}

addInitialResults (newResults) {
this.allResults = this.allResults.concat(newResults)
super.addInitialResults(newResults)
addInitialResults(newResults) {
this.allResults = this.allResults.concat(newResults);
super.addInitialResults(newResults);
}

getAllResults () {
return this.allResults
getAllResults() {
return this.allResults;
}

}

module.exports = BaseFilterWithHistory
module.exports = BaseFilterWithHistory;
Loading