We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
any[]
Contract methods have typed parameters.
Contract methods have parameters with the type any[].
import Web3 from "web3"; const abi = [{ inputs: [ { internalType: "uint256", name: "testArg1", type: "uint256" }, { internalType: "uint256", name: "testArg2", type: "uint256" }, ], name: "test", outputs: [{ internalType: "uint256", name: "testRes1", type: "uint256" }], stateMutability: "nonpayable", type: "function", }] as const; const web3 = new Web3(); const contract = new web3.eth.Contract(abi); // Actual: No error occurs here. // Expected: Error - Expected 2 arguments, but got 0 contract.methods.test(); // Actual: any[] // Expected: [MatchPrimitiveType<"uint256", unknown>, MatchPrimitiveType<"uint256", unknown>] type Params = Parameters<typeof contract['methods']['test']>;
web3.js/packages/web3-eth-contract/src/contract.ts
Line 131 in dcd9d6a
extends never
unknown
web3: 4.13.0 typescript: 5.6.2
The text was updated successfully, but these errors were encountered:
Hey @nicklatkovich , I'll have someone look into this soon.
Sorry, something went wrong.
Same happens for us. The methods are properly inferred, but the parameters are any[], which is very dangerous
avkos
Successfully merging a pull request may close this issue.
Expected behavior
Contract methods have typed parameters.
Actual behavior
Contract methods have parameters with the type
any[]
.Steps to reproduce the behavior
Solution
web3.js/packages/web3-eth-contract/src/contract.ts
Line 131 in dcd9d6a
Should be changed to
extends never
or something similar. Since everything is extending typeunknown
.Environment
The text was updated successfully, but these errors were encountered: