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

Refunds return remaining portion of original contribution #37

Merged
merged 5 commits into from Sep 13, 2018

Conversation

Projects
None yet
2 participants
@JordoBrooks
Member

JordoBrooks commented Aug 22, 2018

Addresses issue #29.

Changes:

  • When milestone funds are released to a developer, percentageFundsReleased is updated in storage
  • When a refund is requested, the amount sent back to the user is amountContributed * (100 - percentageFundsReleased) / 100. For example, if the original contribution is 10 ETH, and 20% of the milestone funds have already been released, then the refund will be for 8 ETH.
  • Truffle tests
let vaultWatcher = fundingVault.EthWithdrawn().watch(function (error, result) {
if (!error) {
refundRecipient = result.args.receiver;
refundAmount = result.args.amount.toNumber();

This comment has been minimized.

@ericmuyser

ericmuyser Sep 7, 2018

Member

Did we confirm this number matches the amount that should be refunded?

This comment has been minimized.

@JordoBrooks

JordoBrooks Sep 8, 2018

Member

I believe so. In this case, since the project didn't meet its minimum funding goal, the expected refund amount should be equal to the full contribution. This is checked on line 241:

assert.equal(refundAmount, fundsToContribute, "Refund was for wrong amount.");

Where refundAmount came directly from the event that the FundingVault fired upon Eth withdrawal, and fundsToContribute was the amount sent in by the contributor.

This comment has been minimized.

@ericmuyser

ericmuyser Sep 8, 2018

Member

Oh that's right, makes sense. I didn't catch it's the synchronous because of the await contributionContract.refund call.

let vaultWatcher = fundingVault.EthWithdrawn().watch(function (error, result) {
if (!error) {
refundRecipient = result.args.receiver;
refundAmount = result.args.amount.toNumber();

This comment has been minimized.

@ericmuyser

ericmuyser Sep 7, 2018

Member

Same here

This comment has been minimized.

@JordoBrooks

JordoBrooks Sep 8, 2018

Member

Likewise, here we would expect the refund amount to be less than the original contribution since the first milestone is going to release a certain percentage of it. The amount that we expect to be refunded is determined on line 293:

let expectedRefundAmount = fundsToContribute * (100 - projectMilestone0Percentage) / 100;

Following this, line 296 checks that the value actually refunded (as determined by the EthWithdrawn event) matches up with this expected amount:

assert.equal(refundAmount, expectedRefundAmount, "Refund was for wrong amount.");

@JordoBrooks JordoBrooks merged commit 39dca2c into master Sep 13, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment