diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eebc67..e13df64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.3 + +- Fix functions with enum and contract arguments. + ## 0.1.2 - Fix missing dependency. diff --git a/contracts/Test.sol b/contracts/Test.sol index 7b30a1a..abb76f7 100644 --- a/contracts/Test.sol +++ b/contracts/Test.sol @@ -75,3 +75,12 @@ abstract contract Child3 is Parent1, Parent2, Child2 {} abstract contract Child4 is Parent1, Parent2, Parent3 { constructor(uint c) {} } + +contract Types { + enum Enum { + A + } + function _testEnumType(Enum e) internal {} + function _testContractType(Types t) internal {} + function _testMappingType(mapping (uint => uint) storage m) internal {} +} diff --git a/src/core.test.ts.md b/src/core.test.ts.md index 79efa80..55f1272 100644 --- a/src/core.test.ts.md +++ b/src/core.test.ts.md @@ -129,4 +129,16 @@ Generated by [AVA](https://avajs.dev). return super._testParent1();␊ }␊ }␊ + ␊ + contract XTypes is Types {␊ + constructor() {}␊ + ␊ + function x_testEnumType(Types.Enum e) external {␊ + return super._testEnumType(e);␊ + }␊ + ␊ + function x_testContractType(Types t) external {␊ + return super._testContractType(t);␊ + }␊ + }␊ ` diff --git a/src/core.test.ts.snap b/src/core.test.ts.snap index 2953025..f164b99 100644 Binary files a/src/core.test.ts.snap and b/src/core.test.ts.snap differ diff --git a/src/core.ts b/src/core.ts index b1942b8..ea422dc 100644 --- a/src/core.ts +++ b/src/core.ts @@ -188,7 +188,7 @@ function getType(varDecl: VariableDeclaration, location: StorageLocation = varDe if (typeof typeString !== 'string' || typeof typeIdentifier !== 'string') { throw new Error('Missing type information'); } - const type = typeString.replace(/^struct /, '') + (typeIdentifier.endsWith('_ptr') ? ` ${location}` : ''); + const type = typeString.replace(/^(struct|enum|contract) /, '') + (typeIdentifier.endsWith('_ptr') ? ` ${location}` : ''); return type; }