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

Middleware documentation / Guide #6963

Closed
2 tasks done
jdevcs opened this issue Apr 8, 2024 · 3 comments · Fixed by #7158
Closed
2 tasks done

Middleware documentation / Guide #6963

jdevcs opened this issue Apr 8, 2024 · 3 comments · Fixed by #7158
Labels
4.x 4.0 related

Comments

@jdevcs
Copy link
Contributor

jdevcs commented Apr 8, 2024

  • web3 middleware usecase test / feedback: Check with real usecase if any breaking changes are required before merging and release
  • publish middleware ( include in next release )

Related feature work can be found at:
#7134
#7002
#7003

@jdevcs jdevcs added the 4.x 4.0 related label Apr 8, 2024
@jdevcs jdevcs mentioned this issue Apr 8, 2024
17 tasks
@jdevcs jdevcs changed the title Middleware usecase test/feedback Middleware documentation / Guide May 28, 2024
@jdevcs
Copy link
Contributor Author

jdevcs commented Jul 16, 2024

Create plugin developers Guide for Middleware implementation:
Types of Middleware:
1 - Request Middleware: can be use to modify request before sent to RPC node by web3.js and/or modify response before returning back to web3.js, steps:

2- Transaction Middleware: ( works for Eth and Contracts package )
steps:

Some code snippets in tests:
Requests middleware:

const web3 = new Web3('http://127.0.0.1:8545');

Eth Transaction middleware:
const web3 = new Web3('http://127.0.0.1:8545');

Contract Transaction middleware:
const plugin: TransactionMiddlewarePlugin = new TransactionMiddlewarePlugin();

@danforbes
Copy link
Contributor

@jdevcs
Copy link
Contributor Author

jdevcs commented Jul 22, 2024

@jdevcs why is it necessary to add a new property to the plugin class AND register the plugin in the link method?

@danforbes add a new property to the plugin class is not necessary, middleware can be injected in plugin, or plugin can have access to middleware via other ways,

but registering (Transaction or Request ) middleware in link method is necessary because it will set middleware via web3-context to Web3-Eth & Web3-Contract or Web3-Request-Manager, so when normal request is sent via other web3 packages it can see if middleware is there or not for usage.

danforbes added a commit that referenced this issue Jul 22, 2024
* Add Plugin Middleware Documentation

Closes #6963

* Clarify Request Middleware Response Processing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x 4.0 related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants