web3.js
web3.js copied to clipboard
Example Plugin Implementation
Example implementation for #5091
Points of Discussion
- I believe the
Web3APISpec
on this line should beChainlinkPluginAPI
, but when making the change the following error appears for this
Argument of type 'this' is not assignable to parameter of type 'Web3Context<EthExecutionAPI, { logs: typeof LogsSubscription; newHeads: typeof NewHeadsSubscription; newBlockHeaders: typeof NewHeadsSubscription; }>'.
Type 'ChainlinkPlugin' is not assignable to type 'Web3Context<EthExecutionAPI, { logs: typeof LogsSubscription; newHeads: typeof NewHeadsSubscription; newBlockHeaders: typeof NewHeadsSubscription; }>'.
Types of property '_requestManager' are incompatible.
Type 'Web3RequestManager<ChainlinkPluginAPI>' is not assignable to type 'Web3RequestManager<EthExecutionAPI>'.
Type 'ChainlinkPluginAPI' is missing the following properties from type 'EthExecutionAPI': eth_getBlockByHash, eth_getBlockByNumber, eth_getBlockTransactionCountByHash, eth_getBlockTransactionCountByNumber, and 44 more.ts(2345)
- ~In order to get the declare module to work, I needed to update the Web3 package from using the
default
export to a named one - I'm not sure if/how this affects anything~ This commit updatesWeb3
to be exported usingdefault
and named export- ~Related to this change, importing
Web3
like this is the only way I could get the module augmentation to work~ The above mentioned commit also updates this to useweb3
to augment module instead ofweb3/dist/web3
- ~Related to this change, importing
- The return type for getPrice is inferred from the contract ABI instead of
ChainlinkPluginAPI
- This doesn't matter so much because the type the end user will see when calling
web3.chainlink.getPrice
is defined byChainlinkPluginAPI
(i.e. user will seegetPrice
returnsPromise<Price>
)
- This doesn't matter so much because the type the end user will see when calling
Your Render PR Server URL is https://web3js-docs-pr-5393.onrender.com.
Follow its progress at https://dashboard.render.com/static/srv-cc6n52pgp3jv8lhb6gb0.
This pull request introduces 1 alert when merging d0d388b6f26b739d787653285f1ba8a88eb4fcfe into aeceed263c4b031e57ae32b5acd452b08a75a505 - view on LGTM.com
new alerts:
- 1 for Unused variable, import, function or class
This pull request introduces 1 alert when merging db296ff7f47723980cb520f2bf98340dde096803 into aeceed263c4b031e57ae32b5acd452b08a75a505 - view on LGTM.com
new alerts:
- 1 for Unused variable, import, function or class
This pull request introduces 1 alert when merging a2f43db59abaa84072894182af333dbfa2979011 into e2afb752b2e6fd0d8bec0b0dabe5c279415dc20c - view on LGTM.com
new alerts:
- 1 for Unused variable, import, function or class
If we want to keep this as example for others to implement plugins, :
web3-plugin-example
example package should be placed under tools
@jdevcs My thinking was to create this package with unit and black box tests that can be ran as apart of our test suite for releases to verify the plugin system continues to work as expected. I could move this under tools/
, but we'd have to setup Lerna and such to build and execute tests in tools/
and packages/
This pull request introduces 1 alert when merging 9b4896e5cacc8e83b93999cc16492813389f38d5 into a804401e2177dc76b87f5f20bf54460f93978239 - view on LGTM.com
new alerts:
- 1 for Unused variable, import, function or class
This pull request introduces 1 alert when merging dc36d4b087c011516a5b8a19da8d71148e845fb4 into a804401e2177dc76b87f5f20bf54460f93978239 - view on LGTM.com
new alerts:
- 1 for Unused variable, import, function or class
This pull request introduces 1 alert when merging 755d6d65fb490493b3fbf529589f27069e6e7f59 into 37219fc114ce4d53387b7b9626358b12f4eaa3c6 - view on LGTM.com
new alerts:
- 1 for Unused variable, import, function or class
This pull request introduces 1 alert when merging 103683687341718ab4adc280c82276562b1db1bc into 37219fc114ce4d53387b7b9626358b12f4eaa3c6 - view on LGTM.com
new alerts:
- 1 for Unused variable, import, function or class
Hello @spacesailor24, I opened an MR (https://github.com/ChainSafe/web3.js/pull/5416) for addressing the discussion points mentioned at #5393 (comment). More details are at its description. Please feel free to check and discuss. Thanks,
@spacesailor24 this PR is still draft and waiting from few sprints, are there any pending items or required discussion?
Please check that this PR is not causing any actions failing in CI.+ Just need some minor changes, and we can merge this PR.
As discussed in call for remaining bugs, improvements and more features we should do in another PR.
Please check that this PR is not causing any actions failing in CI.+ Just need some minor changes, and we can merge this PR.
As discussed in call for remaining bugs, improvements and more features we should do in another PR.
@jdevcs It looks like failing tests are related to a validation error in web-eth-contract
that is unrelated to the changes introduced in this PR