Skip to content
New issue

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

View keyworld dissapears #353

Closed
Amxx opened this issue Jul 18, 2019 · 2 comments
Closed

View keyworld dissapears #353

Amxx opened this issue Jul 18, 2019 · 2 comments

Comments

@Amxx
Copy link

Amxx commented Jul 18, 2019

I'm trying to use solidity-coverage on kitsune-contracts

One of the contracts overloads the classic owner() method. waffle (that I usually use) and truffle both compile this code without issues. However, solidity-coverage gives me the following error:

Error: CompileError: openzeppelin-solidity/contracts/ownership/Ownable.sol:28:5: TypeError: Overriding function changes state mutability from "nonpayable" to "view".
    function owner() public view returns (address) {
    ^ (Relevant source part starts here and spans across multiple lines).
/home/amxx/Work/KitsuneWallet/kitsune-monorepo/kitsune-contracts/coverageEnv/contracts/interfaces/IERC725.sol:17:2: Overridden function is here:
	function owner() public      returns (address);
	^---------------------------------------------^

Line 17 of IERC725.sol is

function owner() public view returns (address);

How come the view modifier was lost between the source and the coverageEnv version ?

@cgewecke
Copy link
Member

@Amxx It's intentionally removed because Solidity will not compile when events are in a view or pure function. This is why the contracts get double compiled - first we compile to get the 'correct' ABI, which marks methods as view or pure and which Truffle uses to decide whether to execute a method as a send or a call. Then we remove the visibility modifiers and instrument to get the correct bytecode. Then we swap the 'correct' ABI back into the artifact. (See #146 for more).

TLDR; the modifiers are removed but because of this trick, truffle invokes those methods as .call rather than .send.

@Amxx
Copy link
Author

Amxx commented Jul 18, 2019

Ok that makes sense ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants