Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions contracts/crowdsale/FinalizableCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ contract FinalizableCrowdsale is Crowdsale, Ownable {

event Finalized();

// should be called after crowdsale ends, to do
// some extra finalization work
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() onlyOwner {
require(!isFinalized);
require(hasEnded());
Expand All @@ -28,12 +30,11 @@ contract FinalizableCrowdsale is Crowdsale, Ownable {
isFinalized = true;
}

// end token minting on finalization
// override this with custom logic if needed
/**
* @dev Can be overriden to add finalization logic. The overriding function
* should call super.finalization() to ensure the chain of finalization is
* executed entirely.
*/
function finalization() internal {
token.finishMinting();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't finalization be abstract now that it's empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it. If it's left abstract you can't call super.finalization() in the deriving contract, which we want everyone to do to make sure the whole finalization chain runs.




}
7 changes: 0 additions & 7 deletions test/FinalizableCrowdsale.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,4 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {
should.exist(event)
})

it('finishes minting of token', async function () {
await increaseTimeTo(this.afterEndTime)
await this.crowdsale.finalize({from: owner})
const finished = await this.token.mintingFinished()
finished.should.equal(true)
})

})
8 changes: 7 additions & 1 deletion test/MintableToken.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const assertJump = require('./helpers/assertJump');
import expectThrow from './helpers/expectThrow';
var MintableToken = artifacts.require('../contracts/Tokens/MintableToken.sol');

contract('Mintable', function(accounts) {
Expand Down Expand Up @@ -37,4 +37,10 @@ contract('Mintable', function(accounts) {
assert(totalSupply, 100);
})

it('should fail to mint after call to finishMinting', async function () {
await token.finishMinting();
assert.equal(await token.mintingFinished(), true);
await expectThrow(token.mint(accounts[0], 100));
})

});