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

feat/docs/plugin-middleware #7158

Merged
merged 3 commits into from
Jul 22, 2024
Merged

feat/docs/plugin-middleware #7158

merged 3 commits into from
Jul 22, 2024

Conversation

danforbes
Copy link
Contributor

Add plugin middleware documentation

Closes #6963

Copy link

github-actions bot commented Jul 17, 2024

Bundle Stats

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
10 636.12 kB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
web3.min.js 616.83 kB 0%
../lib/commonjs/index.d.ts 8.69 kB 0%
../lib/commonjs/accounts.d.ts 3.89 kB 0%
../lib/commonjs/types.d.ts 2.67 kB 0%
../lib/commonjs/web3.d.ts 1.35 kB 0%
../lib/commonjs/web3_eip6963.d.ts 1.2 kB 0%
../lib/commonjs/abi.d.ts 999 B 0%
../lib/commonjs/eth.exports.d.ts 280 B 0%
../lib/commonjs/providers.exports.d.ts 183 B 0%
../lib/commonjs/version.d.ts 60 B 0%

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: eb29499 Previous: 5f6deeb Ratio
processingTx 8887 ops/sec (±4.94%) 9233 ops/sec (±3.97%) 1.04
processingContractDeploy 39097 ops/sec (±7.05%) 40168 ops/sec (±4.88%) 1.03
processingContractMethodSend 16534 ops/sec (±7.46%) 16302 ops/sec (±6.45%) 0.99
processingContractMethodCall 28387 ops/sec (±6.22%) 28306 ops/sec (±6.19%) 1.00
abiEncode 43396 ops/sec (±6.78%) 42794 ops/sec (±8.67%) 0.99
abiDecode 30773 ops/sec (±5.83%) 31117 ops/sec (±7.21%) 1.01
sign 1525 ops/sec (±3.92%) 1588 ops/sec (±0.64%) 1.04
verify 366 ops/sec (±0.47%) 367 ops/sec (±0.70%) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Copy link

codecov bot commented Jul 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.46%. Comparing base (6b80cf0) to head (eb29499).
Report is 4 commits behind head on 4.x.

Additional details and impacted files
@@           Coverage Diff           @@
##              4.x    #7158   +/-   ##
=======================================
  Coverage   94.45%   94.46%           
=======================================
  Files         215      215           
  Lines        8391     8396    +5     
  Branches     2313     2315    +2     
=======================================
+ Hits         7926     7931    +5     
  Misses        465      465           
Flag Coverage Δ
UnitTests 94.46% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.


### Request Middleware

Request middleware allows plugins to modify RPC requests before they are sent to the network and modify RPC responses before they are returned to the user. Request middleware must implement the [`RequestManagerMiddleware`](/api/web3-core/interface/RequestManagerMiddleware) interface, which specifies two functions: [`processRequest`](/api/web3-core/interface/RequestManagerMiddleware#processRequest) and [`processResponse`](/api/web3-core/interface/RequestManagerMiddleware#processResponse). Here is a simple example of request middleware that prints RPC requests and responses to the console:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Request middleware allows plugins to modify RPC requests before they are sent to the network and modify RPC responses before they are returned to the user. Request middleware must implement the [`RequestManagerMiddleware`](/api/web3-core/interface/RequestManagerMiddleware) interface, which specifies two functions: [`processRequest`](/api/web3-core/interface/RequestManagerMiddleware#processRequest) and [`processResponse`](/api/web3-core/interface/RequestManagerMiddleware#processResponse). Here is a simple example of request middleware that prints RPC requests and responses to the console:
Request middleware allows plugins to modify RPC requests before they are sent to the network and modify RPC responses before they are returned to the web3.js lib's other packages for internal processing. Request middleware must implement the [`RequestManagerMiddleware`](/api/web3-core/interface/RequestManagerMiddleware) interface, which specifies two functions: [`processRequest`](/api/web3-core/interface/RequestManagerMiddleware#processRequest) and [`processResponse`](/api/web3-core/interface/RequestManagerMiddleware#processResponse). Here is a simple example of request middleware that prints RPC requests and responses to the console:

Copy link
Contributor

@jdevcs jdevcs left a comment

Choose a reason for hiding this comment

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

@danforbes looks good, thanks.
I suggested a change before merging.

@danforbes danforbes merged commit e5efe49 into 4.x Jul 22, 2024
23 of 24 checks passed
@danforbes danforbes deleted the feat/docs/plugin-middleware branch July 22, 2024 15:16
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.

Middleware documentation / Guide
3 participants