diff --git a/packages/web3-core/package.json b/packages/web3-core/package.json
index 8db0707032b..72ba5ee3cd8 100644
--- a/packages/web3-core/package.json
+++ b/packages/web3-core/package.json
@@ -44,6 +44,7 @@
"dependencies": {
"web3-errors": "^1.1.4",
"web3-eth-iban": "^4.0.7",
+ "web3-eth-accounts": "^4.1.0",
"web3-providers-http": "^4.1.0",
"web3-providers-ws": "^4.0.7",
"web3-types": "^1.3.1",
diff --git a/packages/web3-core/src/web3_context.ts b/packages/web3-core/src/web3_context.ts
index f653b581456..d29833c513e 100644
--- a/packages/web3-core/src/web3_context.ts
+++ b/packages/web3-core/src/web3_context.ts
@@ -15,28 +15,23 @@ You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see .
*/
// eslint-disable-next-line max-classes-per-file
+import { ExistingPluginNamespaceError } from 'web3-errors';
import {
- Web3APISpec,
- Web3BaseWallet,
- Web3BaseWalletAccount,
- Web3AccountProvider,
- SupportedProviders,
- HexString,
EthExecutionAPI,
- Web3BaseProvider,
- Transaction,
+ HexString, Numbers, SupportedProviders, Transaction, Web3AccountProvider, Web3APISpec, Web3BaseProvider, Web3BaseWallet,
+ Web3BaseWalletAccount
} from 'web3-types';
import { isNullish } from 'web3-utils';
-import { ExistingPluginNamespaceError } from 'web3-errors';
-
+import { BaseTransaction, TransactionFactory } from 'web3-eth-accounts';
import { isSupportedProvider } from './utils.js';
// eslint-disable-next-line import/no-cycle
+import { ExtensionObject } from './types.js';
+import { Web3BatchRequest } from './web3_batch_request.js';
+// eslint-disable-next-line import/no-cycle
import { Web3Config, Web3ConfigEvent, Web3ConfigOptions } from './web3_config.js';
import { Web3RequestManager } from './web3_request_manager.js';
import { Web3SubscriptionConstructor } from './web3_subscriptions.js';
import { Web3SubscriptionManager } from './web3_subscription_manager.js';
-import { Web3BatchRequest } from './web3_batch_request.js';
-import { ExtensionObject } from './types.js';
// To avoid circular dependencies, we need to export type from here.
export type Web3ContextObject<
@@ -395,16 +390,6 @@ export class Web3Context<
}
}
-// To avoid cycle dependency declare this type in this file
-export type TransactionBuilder = <
- ReturnType = Transaction,
->(options: {
- transaction: Transaction;
- web3Context: Web3Context;
- privateKey?: HexString | Uint8Array;
- fillGasPrice?: boolean;
-}) => Promise;
-
/**
* Extend this class when creating a plugin that either doesn't require {@link EthExecutionAPI},
* or interacts with a RPC node that doesn't fully implement {@link EthExecutionAPI}.
@@ -422,29 +407,44 @@ export type TransactionBuilder = <
* class CustomPlugin extends Web3PluginBase {...}
* ```
*/
-export abstract class Web3PluginBase<
- API extends Web3APISpec = Web3APISpec,
+ export abstract class Web3PluginBase<
+ API extends Web3APISpec = Web3APISpec,
> extends Web3Context {
- public abstract pluginNamespace: string;
+ public abstract pluginNamespace: string;
+
+ // eslint-disable-next-line class-methods-use-this
+ protected registerNewTransactionType>(type: Numbers, txClass: NewTxTypeClass): void {
+ TransactionFactory.registerTransactionType(type, txClass);
+ }
}
/**
- * Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
- * or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
- *
- * To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
- * define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
- *
- * @example
- * ```ts
- * type CustomRpcApi = {
- * custom_rpc_method: () => string;
- * custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
- * };
- *
- * class CustomPlugin extends Web3PluginBase {...}
- * ```
- */
+* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
+* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
+*
+* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
+* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
+*
+* @example
+* ```ts
+* type CustomRpcApi = {
+* custom_rpc_method: () => string;
+* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
+* };
+*
+* class CustomPlugin extends Web3PluginBase {...}
+* ```
+*/
export abstract class Web3EthPluginBase extends Web3PluginBase<
- API & EthExecutionAPI
+ API & EthExecutionAPI
> {}
+
+// To avoid cycle dependency declare this type in this file
+export type TransactionBuilder = <
+ ReturnType = Transaction,
+>(options: {
+ transaction: Transaction;
+ web3Context: Web3Context;
+ privateKey?: HexString | Uint8Array;
+ fillGasPrice?: boolean;
+}) => Promise;
diff --git a/packages/web3/test/integration/web3-plugin-add-tx.test.ts b/packages/web3/test/integration/web3-plugin-add-tx.test.ts
index d1971b7f4ef..13a3e0df615 100644
--- a/packages/web3/test/integration/web3-plugin-add-tx.test.ts
+++ b/packages/web3/test/integration/web3-plugin-add-tx.test.ts
@@ -17,7 +17,7 @@ along with web3.js. If not, see .
/* eslint-disable @typescript-eslint/no-magic-numbers */
-import { Transaction, TransactionFactory, Web3Account } from 'web3-eth-accounts';
+import { Transaction, Web3Account } from 'web3-eth-accounts';
import { SupportedProviders, Web3, Web3PluginBase } from '../../src';
import {
createAccount,
@@ -31,7 +31,7 @@ class Eip4844Plugin extends Web3PluginBase {
public pluginNamespace = 'txType3';
public constructor() {
super();
- TransactionFactory.registerTransactionType(TRANSACTION_TYPE, SomeNewTxTypeTransaction);
+ this.registerNewTransactionType(TRANSACTION_TYPE, SomeNewTxTypeTransaction);
}
}