OpenZeppelin / openzeppelin-sdk

OpenZeppelin SDK repository for CLI and upgrades.js. No longer actively developed.
MIT License
431 stars 200 forks source link

Error when running create having only abstract contracts #1109

Open crazyrabbitLTC opened 5 years ago

crazyrabbitLTC commented 5 years ago

In my contracts folder I have several contracts, including a nested folder of contracts.

Screen Shot 2019-07-16 at 5 21 39 PM

However when I run the oz create command, the cli prompt only shows me two of them:

Screen Shot 2019-07-16 at 5 21 45 PM

I understand if we don't catch nested contracts, (they are in a folder only to be inherited from), but i don't understand why my third contract WordStorage.sol is not showing up.

crazyrabbitLTC commented 5 years ago

I have looked into this a bit more. The error above comes from an error in my contract. However this brings up an interesting UI experience:

oz create simply does not list the contract as available to create. While while oz compile tries to compile everything and shares the error messages.

Screen Shot 2019-07-16 at 5 54 03 PM

However after using oz compile, I then tried oz create again, but the flow is unexpectedly different, it does not ask for me to select the contract to create, rather it seems to "deploy" all the contracts. But does not list the address where they are deployed nor gives me the option to call a function.

Screen Shot 2019-07-16 at 5 54 51 PM

Does this flow make sense?

spalladino commented 5 years ago

Hey @crazyrabbitLTC! The catch here is that create now runs a push under the hood. And push effectively pushes all contracts added to your project, not just the one you are trying to create at that moment.

What is happening on your last create is that that all contracts added to your project are being pushed, since they have changed. After they are deployed, the CLI tries to look for a contract to create. However, for some reason it is failing to pick them up.

So here comes the request for more info: what do your contracts look like? Which of them have errors? Which of them are abstract? Is there a problem with contracts in nested folders after all? What can you see in your build/contracts folder?

crazyrabbitLTC commented 5 years ago

Hello @spalladino! The problem was typos: I renamed ERC20 to erc20 and didn't update elsewhere.

I have a theory about what happens in the flow, when I do create it runs push and compiles the contracts. The contracts that fail to compile however silently fail and only the completed compilations get .json artifacts created. Thus when instead I do oz add WordStorage it also compiles the contract, fails, but then looks for the .json to add to the project .json and doesn't find it.

The second example of oz create I don't quite understand yet though. I would expect, regardless if a contract was already deployed, to be offered the opportunity to create yet a new instance.

spalladino commented 5 years ago

The second example of oz create I don't quite understand yet though. I would expect, regardless if a contract was already deployed, to be offered the opportunity to create yet a new instance.

Is this still happening? Can you upload your current working directory somewhere so I can test it out?

crazyrabbitLTC commented 5 years ago

Yes it's still happening. Maybe I'm not using it correct but then we should maybe have a better error message.

The repo is open, please forgive the spaghetti code. It's a testing work in progress. https://github.com/crazyrabbitLTC/word-dao/tree/refactor

Screen Shot 2019-07-18 at 2 09 39 PM

spalladino commented 5 years ago

I've been able to reproduce it with 2.5.0-rc.0, but it seems to be fixed with 2.5.0-rc.1. Could you confirm?

crazyrabbitLTC commented 5 years ago

Yes! The UI flow seems to be correct with 2.5.0-rc.1 so I'll close the issue. Thanks!

crazyrabbitLTC commented 5 years ago

I'm going to reopen the issue, I seem to have the same problem again.

The UX for dealing with contracts that are abstract is a bit confusing. oz compile now does not seem to catch it, while oz create ChatApp does.

Screen Shot 2019-07-24 at 1 14 55 PM

Additinoally, --verbose doesn't expose that much more detail for compile or create.

Screen Shot 2019-07-24 at 1 18 34 PM

spalladino commented 5 years ago

Just to clarify: the issue is not that there is an error on the contract, but that the only available contract is abstract, right?

crazyrabbitLTC commented 5 years ago

Correct, the only available contract is abstract, but otherwise is fine.