Skip to content

Commit

Permalink
Merge branch '4.x' into fix-6433
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfxjx authored Mar 17, 2024
2 parents 544902a + 2373e94 commit b9c6117
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 13 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
## [Unreleased]
### Changed

#### web3

- Types `ContractDeploySend`, `ContractMethodSend`, `Web3PromiEvent` was exported (#6883)

### Added

#### web3-eth-contract

4 changes: 4 additions & 0 deletions packages/web3-eth-contract/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
31 changes: 22 additions & 9 deletions packages/web3-eth-contract/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -113,7 +121,7 @@ type ContractBoundMethod<
Abi extends AbiFunctionFragment,
Method extends ContractMethod<Abi> = ContractMethod<Abi>,
> = (
...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<Method['Inputs'], Method['Outputs']>
: NonPayableMethodObject<Method['Inputs'], Method['Outputs']>;
Expand Down Expand Up @@ -148,6 +156,16 @@ export type ContractMethodsInterface<Abi extends ContractAbi> = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} & { [key: string]: ContractBoundMethod<any> };

export type ContractMethodSend = Web3PromiEvent<
FormatType<TransactionReceipt, typeof DEFAULT_RETURN_FORMAT>,
SendTransactionEvents<typeof DEFAULT_RETURN_FORMAT>
>;
export type ContractDeploySend<Abi extends ContractAbi> = Web3PromiEvent<
// eslint-disable-next-line no-use-before-define
Contract<Abi>,
SendTransactionEvents<typeof DEFAULT_RETURN_FORMAT>
>;

/**
* @hidden
* The event object can be accessed from `myContract.events.myEvent`.
Expand Down Expand Up @@ -768,12 +786,7 @@ export class Contract<Abi extends ContractAbi>
const deployData = _input ?? _data;
return {
arguments: args,
send: (
options?: PayableTxOptions,
): Web3PromiEvent<
Contract<Abi>,
SendTransactionEvents<typeof DEFAULT_RETURN_FORMAT>
> => {
send: (options?: PayableTxOptions): ContractDeploySend<Abi> => {
const modifiedOptions = { ...options };

// eslint-disable-next-line @typescript-eslint/no-unsafe-return
Expand Down Expand Up @@ -1101,7 +1114,7 @@ export class Contract<Abi extends ContractAbi>
block,
),

send: (options?: PayableTxOptions | NonPayableTxOptions) =>
send: (options?: PayableTxOptions | NonPayableTxOptions): ContractMethodSend =>
this._contractMethodSend(methodAbi, abiParams, internalErrorsAbis, options),

estimateGas: async <ReturnFormat extends DataFormat = typeof DEFAULT_RETURN_FORMAT>(
Expand Down
6 changes: 5 additions & 1 deletion packages/web3/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,8 @@ Documentation:

- Added EIP-6963 utility function `requestEIP6963Providers` for multi provider discovery ( other details are in root changelog )

## [Unreleased]
## [Unreleased]

### Changed

- Types `ContractDeploySend`, `ContractMethodSend`, `Web3PromiEvent` was exported (#6883)
4 changes: 2 additions & 2 deletions packages/web3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit b9c6117

Please sign in to comment.