Skip to content

Commit

Permalink
fix functions with enum and contract arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
frangio committed Jun 7, 2021
1 parent 37a9bad commit 211116f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.3

- Fix functions with enum and contract arguments.

## 0.1.2

- Fix missing dependency.
Expand Down
9 changes: 9 additions & 0 deletions contracts/Test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
12 changes: 12 additions & 0 deletions src/core.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);␊
}␊
}␊
`
Binary file modified src/core.test.ts.snap
Binary file not shown.
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 211116f

Please sign in to comment.