You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -739,6 +739,9 @@ should use 4.0.1-alpha.0 for testing.
#### web3-core
- If the response error was `execution reverted`, raise `ContractExecutionError` and pass the response error to it in order to be set as `innerError` (this innerError will be decoded at web3-eth-contract if its ABI was provided according to EIP-838). (#5434)
- `registerPlugin` method to `Web3Context` (#5393)
- `Web3PluginBase` exported abstract class (#5393)
- `Web3EthPluginBase` exported abstract class (#5393)
#### web3-error
Expand All
@@ -749,6 +752,7 @@ should use 4.0.1-alpha.0 for testing.
- Added `SignatureError` to `web3-errors/src/errors/signature_errors.ts` (moved from `web3-eth/src/errors.ts`) (#5462)
- Added the errors' classes to `web3-errors/src/errors/transaction_errors.ts` from `web3-eth/src/errors.ts` (#5462)
- Added `TransactionBlockTimeoutError` class and its error code `ERR_TX_BLOCK_TIMEOUT` (#5294)
- `ExistingPluginNamespaceError` class and it's error code `ERR_EXISTING_PLUGIN_NAMESPACE` (#5393)
#### web3-eth
Expand All
@@ -771,6 +775,15 @@ should use 4.0.1-alpha.0 for testing.
Muhammad-Altabba marked this conversation as resolved.
- Default value for `API` generic for `Web3ContextObject` from `any` to `unknown` (#5393)
- Default value for `API` generic for `Web3ContextInitOptions` from `any` to `unknown` (#5393)
#### web3-error
- Moved `SignerError` from `web3-errors/src/errors/signature_errors.ts` to `web3-errors/src/errors/transaction_errors.ts`, and renamed it to `TransactionSigningError` (#5462)
Expand All
@@ -789,6 +802,10 @@ should use 4.0.1-alpha.0 for testing.
- Return `BigInt` instead of `string` when decoding function parameters for large numbers, such as `uint256`. (#5435)
#### web3-types
- `Web3APISpec`, `Web3APIMethod`, and `Web3APIParams` not support `unknown` APIs (#5393)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -40,3 +40,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- If the response error was `execution reverted`, raise `ContractExecutionError` and pass the response error to it in order to be set as `innerError` (this innerError will be decoded at web3-eth-contract if its ABI was provided according to EIP-838). (#5434)
- `registerPlugin` method to `Web3Context` (#5393)
Muhammad-Altabba marked this conversation as resolved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
I created a simple javascript project with the following code:
constWeb3=require('web3');constweb3=newWeb3();
And only when using this branch, the following error occurs:
TypeError: Web3 is not a constructor
So, could you please revert back any changes made to how Web3 is exported? Or else, if it is necessary to have those changes for the plugin, then please let me know where exactly this is needed so we can investigate more on this matter...
The reason will be displayed to describe this comment to others. Learn more.
Yes, TypeScript module augmentation seems to be designed to work with named ES modules. So only exporting Web3 as a CommonJS module results in the following error
test/unit/contract_method_wrappers.test.ts:27:16 - error TS2664: Invalid module name in augmentation, module 'web3' cannot be found.
27 declare module 'web3' {
I've tried many different ways to work around this, but it boils down to us not being able to mix CommonJS and ES modules, the latter being needed to provide module augmentation
The reason will be displayed to describe this comment to others. Learn more.
@spacesailor24 Limitation is for module augmentation there must be named export as mentioned in ts docs Module Augmentation part:
""
so If we do named export of Web3 in current CJS settings module augmentation works fine.
As discussed earlier for supporting legacy applications, and not introducing breaking change, I am in favour of keeping current Web3 4x export settings ( Also mentioned by Muhammad-Altabba ) and there is a workaround for module augmentation for now:
so in user plugin project where web3 augmentation is required: if Web3 is imported and reexported as named, users can augment.
web3.ts in user project
import Web3 from 'web3';
export { Web3 };
and pluginConsumer.ts using named reexported web3 from user's web3.ts
import { Web3 } from './web3';
import { Web3Context } from 'web3-core';
import { EthExecutionAPI } from 'web3-types';
import { ContractMethodWrappersPlugin } from './contract_method_wrappers';
import { ERC20TokenAbi } from './ERC20Token';
declare module './web3' {
interface Web3 extends Web3Context<EthExecutionAPI> {
contractMethodWrappersPlugin: ContractMethodWrappersPlugin;
}
}
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jdevcs for the great workaround.
And thanks @spacesailor24 for the great implementation.
I think the MR is ready to be merged after updating the CHANGELOG.md.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.