[Bug] Static call and function calls doesn't match whats in the function property
See original GitHub issueIssue with type generation
Using ethersv5 and typechain and hardhat
Below of is a snippet of a simple test contract:
contract YourContract {
event SetPurpose(address sender, string purpose);
string _purpose = 'Building Unstoppable Apps';
constructor() {
// what should we do on deploy?
}
function purpose() public view returns (string memory) {
return _purpose;
}
function setPurpose(string memory newPurpose) public payable {
_purpose = newPurpose;
console.log(msg.sender, 'set purpose to', _purpose);
emit SetPurpose(msg.sender, _purpose);
}
}
Typechain generates a purpose
function that has multiple return types. string and [string] as shown below.
This is what typechain generates
...
functions: {
purpose(overrides?: CallOverrides): Promise<[string]>;
setPurpose(
newPurpose: string,
overrides?: PayableOverrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
};
purpose(overrides?: CallOverrides): Promise<string>;
setPurpose(
newPurpose: string,
overrides?: PayableOverrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
callStatic: {
purpose(overrides?: CallOverrides): Promise<string>;
setPurpose(newPurpose: string, overrides?: CallOverrides): Promise<void>;
};
...
The return type of
functions: {
purpose(overrides?: CallOverrides): Promise<[string]>;
}
does not match the static call and function call return type
purpose(overrides?: CallOverrides): Promise<string>;
callStatic: {
purpose(overrides?: CallOverrides): Promise<string>;
setPurpose(newPurpose: string, overrides?: CallOverrides): Promise<void>;
};
Possible Cause
It seems to have to do with something with the target-ethers-v5
implementation of generateOutputTypes
export function generateOutputTypes(options: GenerateTypeOptions, outputs: Array<AbiOutputParameter>): string {
if (!options.returnResultObject && outputs.length === 1) {
return generateOutputType(options, outputs[0].type)
} else {
return generateOutputComplexType(outputs, options)
}
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
java - What is the reason behind "non-static method cannot be ...
You can't call something that doesn't exist. Since you haven't created an object, the non-static method doesn't exist yet. A static method ......
Read more >Linker Tools Error LNK2019 - Microsoft Learn
A function or variable is declared but not defined. LNK2019 can occur when a declaration exists in a header file, but no matching...
Read more >Fixing common type problems - Dart
Fixing common type problems · Undefined member · Invalid method override · Missing type arguments · Unexpected collection element type · Constructor initialization ......
Read more >Common issues and solutions - mypy 0.991 documentation
This section has examples of cases when you need to update your code to use static typing, and ideas for working around issues...
Read more >Code Inspections in PHP | PhpStorm Documentation - JetBrains
Functions with such a return type are not expected to return any value and must prevent the rest of the script execution by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
here is a link to a reproduction: https://github.com/dethcrypto/TypeChain/pull/593/files#r778495210
Please repoen if this is still a problem.