Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 21059cd

Browse files
allow smart contract methods to accept parameters even when no ABI was provided
1 parent 7461c8e commit 21059cd

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/web3-eth-contract/src/contract.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ type ContractBoundMethod<
114114
Abi extends AbiFunctionFragment,
115115
Method extends ContractMethod<Abi> = ContractMethod<Abi>,
116116
> = (
117-
...args: Method['Inputs']
117+
...args: Abi extends AbiFunctionFragment ? Method['Inputs'] : any
118118
) => Method['Abi']['stateMutability'] extends 'payable' | 'pure'
119119
? PayableMethodObject<Method['Inputs'], Method['Outputs']>
120120
: NonPayableMethodObject<Method['Inputs'], Method['Outputs']>;
@@ -371,9 +371,8 @@ export class Contract<Abi extends ContractAbi>
371371
: returnFormat ?? DEFAULT_RETURN_FORMAT;
372372
const address =
373373
typeof addressOrOptionsOrContext === 'string' ? addressOrOptionsOrContext : undefined;
374-
this.config.contractDataInputFill =
375-
(options as ContractInitOptions)?.dataInputFill ??
376-
this.config.contractDataInputFill;
374+
this.config.contractDataInputFill =
375+
(options as ContractInitOptions)?.dataInputFill ?? this.config.contractDataInputFill;
377376
this._parseAndSetJsonInterface(jsonInterface, returnDataFormat);
378377

379378
if (!isNullish(address)) {
@@ -1083,13 +1082,13 @@ export class Contract<Abi extends ContractAbi>
10831082
options: { ...options, dataInputFill: this.config.contractDataInputFill },
10841083
contractOptions: modifiedContractOptions,
10851084
});
1086-
1085+
10871086
const transactionToSend = sendTransaction(this, tx, DEFAULT_RETURN_FORMAT, {
10881087
// TODO Should make this configurable by the user
10891088
checkRevertBeforeSending: false,
10901089
contractAbi: this._jsonInterface,
10911090
});
1092-
1091+
10931092
// eslint-disable-next-line no-void
10941093
void transactionToSend.on('error', (error: unknown) => {
10951094
if (error instanceof ContractExecutionError) {

0 commit comments

Comments
 (0)