-
Notifications
You must be signed in to change notification settings - Fork 379
Closed
Description
Issue 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)
}
}krzkaczor
Metadata
Metadata
Assignees
Labels
No labels