Skip to content

Conversation

@brunobar79
Copy link

@brunobar79 brunobar79 commented Feb 13, 2018

🚀 Description

After a quick chat with @spalladino and @fiiiu we all agreed that it would be a good idea to decouple RefundVault from RefundableCrowdsale.

Right now, after the Crowdsale goal is reached, ALL the funds are transferred to the wallet on finalization and there's no way of adding / overriding any logic.

After this, you should be able to create a contract that extends from RefundVault which will give you the ability to override its methods ( mainly close() and refund() )

  • 📘 I've reviewed the OpenZeppelin Contributor Guidelines
  • ✅ I've added tests where applicable to test my new functionality.
  • 📖 I've made sure that my contracts are well-documented.
  • 🎨 I've run the JS/Solidity linters and fixed any issues (npm run lint:all:fix).

address _wallet,
uint256 _goal,
RefundVault _vault,
MintableToken _token
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the same params order (vault, token or token, vault) for both the mock here and the SampleCrowdsale example, just for the sake of consistency.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spalladino 100% agree. Just pushed a fix

@spalladino spalladino requested a review from fiiiu February 14, 2018 14:34
@spalladino
Copy link
Contributor

LGTM!

Copy link
Contributor

@fiiiu fiiiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@fiiiu
Copy link
Contributor

fiiiu commented Feb 15, 2018

@brunobar79 thanks for your work! I'm closing this as a refactoring of the crowdsale codebase is underway, your changes are included in the new version, please see #744.

@fiiiu fiiiu closed this Feb 15, 2018
@fiiiu fiiiu removed the next label Feb 15, 2018
@fiiiu fiiiu mentioned this pull request Feb 19, 2018
4 tasks
@martriay
Copy link
Contributor

martriay commented Feb 19, 2018

Actually I find this change a bit dangerous.

If it's not the crowdsale who deploys the RefundVault, it's not guaranteed that the crowdsale is going to be its owner. This requires trust in the deployer that it will set the crowdsale as the vault owner, otherwise it can steal all the funds anytime by providing a modified RefundVault version where anyone (not only the owner) can call RefundVault.deposit, allowing the crowdsale to send its funds to be stolen.

I understand that this change enables the possibility of using a modified version of RefundVault and it also lowers deployment costs, to mitigate the issue maybe the RefundVault can be added in a post-construction stage where the crowdsale can know its own address to check if it's the vault's owner.

Thoughts?

@spalladino
Copy link
Contributor

spalladino commented Feb 19, 2018 via email

@martriay
Copy link
Contributor

You're right, I thought that a constructor couldn't know its own address, but it can. I suggest performing that check then.

@spalladino
Copy link
Contributor

spalladino commented Feb 19, 2018 via email

@martriay
Copy link
Contributor

martriay commented Feb 19, 2018

@spalladino If by "we're perfectly fine with" you mean "this won't work even if you can know your address at construction time because how can the RefundVault know it before that? we should forget about" (this check), then we agree.

Whoops

@spalladino
Copy link
Contributor

Good point. Still, even if we skip that check, any purchase to the crowdsale would later fail since deposit is only callable by the owner. Again, I'd keep this implementation, considering it's in the right direction w.r.t. zOS on-chain factories.

@i6mi6
Copy link

i6mi6 commented Feb 27, 2018

So as far as I understand correctly RefundableCrowdsale doesn't function properly, because deposit() is marked as ownerOnly in RefundVault?

@spalladino
Copy link
Contributor

@i6mi6 it does, you only have to remember to transfer ownership to the crowdsale contract before starting the sale.

@i6mi6
Copy link

i6mi6 commented Feb 27, 2018

Apologies for the noob-ish question but doesn't deposit() function invocation happen by an investor who is not the owner of the contract? Who is going the be msg.sender at the time of deposit invocation?

@martriay
Copy link
Contributor

martriay commented Feb 28, 2018

@i6mi6 the crowdsale is supposed to be the owner of the RefundVault contract, and its _fowardFunds() is the one that performs the call to deposit. Don't confuse msg.sender, which stands for the caller of the function, with tx.origin, the address that initated the transaction.

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

Successfully merging this pull request may close these issues.

6 participants