diff --git a/CHANGELOG.md b/CHANGELOG.md index 5049f52f06d..610c70a2cd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2383,4 +2383,14 @@ If there are any bugs, improvements, optimizations or any new feature proposal f - replaced our eventEmitter to EventEmitter3 to support react native builds (#6253) -## [Unreleased] \ No newline at end of file +## [Unreleased] +### Changed + +#### web3 + +- Types `ContractDeploySend`, `ContractMethodSend`, `Web3PromiEvent` was exported (#6883) + +### Added + +#### web3-eth-contract + diff --git a/packages/web3-eth-contract/CHANGELOG.md b/packages/web3-eth-contract/CHANGELOG.md index 38436bdb830..19fb98ecdcc 100644 --- a/packages/web3-eth-contract/CHANGELOG.md +++ b/packages/web3-eth-contract/CHANGELOG.md @@ -365,3 +365,7 @@ Documentation: - Fixed: The Contract is not using the context wallet passed if context was passed at constructor. (#6661) ## [Unreleased] + +### Added + +- Types `ContractDeploySend`, `ContractMethodSend` was added (#6883) diff --git a/packages/web3-eth-contract/src/contract.ts b/packages/web3-eth-contract/src/contract.ts index 44e8d2f74df..54b7e4e792d 100644 --- a/packages/web3-eth-contract/src/contract.ts +++ b/packages/web3-eth-contract/src/contract.ts @@ -82,8 +82,16 @@ import { EventLog, ContractAbiWithSignature, ContractOptions, + TransactionReceipt, + FormatType, } from 'web3-types'; -import { format, isDataFormat, keccak256, toChecksumAddress , isContractInitOptions } from 'web3-utils'; +import { + format, + isDataFormat, + keccak256, + toChecksumAddress, + isContractInitOptions, +} from 'web3-utils'; import { isNullish, validator, @@ -113,7 +121,7 @@ type ContractBoundMethod< Abi extends AbiFunctionFragment, Method extends ContractMethod = ContractMethod, > = ( - ...args: Method['Inputs'] extends undefined|unknown ? any[] : Method['Inputs'] + ...args: Method['Inputs'] extends undefined | unknown ? any[] : Method['Inputs'] ) => Method['Abi']['stateMutability'] extends 'payable' | 'pure' ? PayableMethodObject : NonPayableMethodObject; @@ -148,6 +156,16 @@ export type ContractMethodsInterface = { // eslint-disable-next-line @typescript-eslint/no-explicit-any } & { [key: string]: ContractBoundMethod }; +export type ContractMethodSend = Web3PromiEvent< + FormatType, + SendTransactionEvents +>; +export type ContractDeploySend = Web3PromiEvent< + // eslint-disable-next-line no-use-before-define + Contract, + SendTransactionEvents +>; + /** * @hidden * The event object can be accessed from `myContract.events.myEvent`. @@ -768,12 +786,7 @@ export class Contract const deployData = _input ?? _data; return { arguments: args, - send: ( - options?: PayableTxOptions, - ): Web3PromiEvent< - Contract, - SendTransactionEvents - > => { + send: (options?: PayableTxOptions): ContractDeploySend => { const modifiedOptions = { ...options }; // eslint-disable-next-line @typescript-eslint/no-unsafe-return @@ -1101,7 +1114,7 @@ export class Contract block, ), - send: (options?: PayableTxOptions | NonPayableTxOptions) => + send: (options?: PayableTxOptions | NonPayableTxOptions): ContractMethodSend => this._contractMethodSend(methodAbi, abiParams, internalErrorsAbis, options), estimateGas: async ( diff --git a/packages/web3/CHANGELOG.md b/packages/web3/CHANGELOG.md index 7557dcb0ff0..685ed153fb4 100644 --- a/packages/web3/CHANGELOG.md +++ b/packages/web3/CHANGELOG.md @@ -197,4 +197,8 @@ Documentation: - Added EIP-6963 utility function `requestEIP6963Providers` for multi provider discovery ( other details are in root changelog ) -## [Unreleased] \ No newline at end of file +## [Unreleased] + +### Changed + +- Types `ContractDeploySend`, `ContractMethodSend`, `Web3PromiEvent` was exported (#6883) diff --git a/packages/web3/src/index.ts b/packages/web3/src/index.ts index 0fcc8a1dd4a..45d625b6e48 100644 --- a/packages/web3/src/index.ts +++ b/packages/web3/src/index.ts @@ -333,9 +333,9 @@ export default Web3; * Named exports for all objects which are the default-exported-object in their packages */ export { Web3 }; -export { Web3Context, Web3PluginBase, Web3EthPluginBase } from 'web3-core'; +export { Web3Context, Web3PluginBase, Web3EthPluginBase, Web3PromiEvent } from 'web3-core'; export { Web3Eth } from 'web3-eth'; -export { Contract } from 'web3-eth-contract'; +export { Contract, ContractDeploySend, ContractMethodSend } from 'web3-eth-contract'; export { Iban } from 'web3-eth-iban'; export { Personal } from 'web3-eth-personal'; export { Net } from 'web3-net';