Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
128c4c0
Improve encapsulation on ERC165
Sep 3, 2018
0d8a5e4
Improve encapsulation on ERC20
Sep 3, 2018
1c365fe
Improve encapsulation on ERC721
Sep 3, 2018
9ebdae6
Add tests, use standard getters
Sep 3, 2018
963a00b
fix tests
Sep 3, 2018
4d8db8d
Fix lint
Sep 3, 2018
dc7b21e
Merge branch 'master' into refactor/1174/private-state-vars-erc
Sep 4, 2018
0b0d6c6
move interface ids to implementation contracts
frangio Sep 4, 2018
68094d1
Do not prefix getters
Sep 5, 2018
2ea79e9
Merge branch 'master' into refactor/1174/private-state-vars-erc
Sep 5, 2018
5fc3742
Improve encapsulation on Pausable
Sep 3, 2018
172b720
add the underscore
Sep 3, 2018
86bbab3
Improve encapsulation on ownership
Sep 3, 2018
faed52d
fix rebase
Sep 3, 2018
21ae177
fix ownership
Sep 3, 2018
917a019
Improve encapsulation on payments
Sep 3, 2018
478d974
Add missing tests
Sep 4, 2018
0fecbac
add missing test
Sep 4, 2018
9449572
Do not prefix getters
Sep 5, 2018
1856f07
Fix tests.
Sep 5, 2018
f61acdc
Improve encapsulation on Crowdsales
Sep 3, 2018
44d113a
add missing tests
Sep 3, 2018
0257670
remove only
Sep 3, 2018
5a476d1
Do not prefix getters
Sep 5, 2018
85a0fc3
Update modifiers to call public view functions.
Sep 5, 2018
24761a5
remove isMinter
Sep 5, 2018
c14d597
fix is owner call
Sep 5, 2018
ba7fa16
fix isOpen
Sep 5, 2018
776d47a
Merge branch 'master' into feature/1179/modifiers-call-functions
Sep 6, 2018
7a37725
Fix merge
Sep 6, 2018
52352ce
Improve encapsulation on TimedCrowdsale
Sep 6, 2018
63b93cc
Add missing parentheses
Sep 6, 2018
b6bddb2
Merge branch 'master' into refactor/1174/private-state-vars-timed-cro…
frangio Sep 6, 2018
369b8d6
remove duplicate function definition
frangio Sep 6, 2018
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
Prev Previous commit
Next Next commit
Do not prefix getters
  • Loading branch information
Leo Arias committed Sep 5, 2018
commit 5a476d14e548595217d9c5a9ddf0e82b51618281
10 changes: 5 additions & 5 deletions contracts/crowdsale/Crowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,28 @@ contract Crowdsale {
/**
* @return the token being sold.
*/
function getToken() public view returns(IERC20) {
function token() public view returns(IERC20) {
return token_;
}

/**
* @return the address where funds are collected.
*/
function getWallet() public view returns(address) {
function wallet() public view returns(address) {
return wallet_;
}

/**
* @return the number of token units a buyer gets per wei.
*/
function getRate() public view returns(uint256) {
function rate() public view returns(uint256) {
return rate_;
}

/**
* @return the mount of wei raised.
*/
function getWeiRaised() public view returns (uint256) {
function weiRaised() public view returns (uint256) {
return weiRaised_;
}

Expand Down Expand Up @@ -141,7 +141,7 @@ contract Crowdsale {
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use `super` in contracts that inherit from Crowdsale to extend their validations.
* Example from CappedCrowdsale.sol's _preValidatePurchase method:
* super._preValidatePurchase(_beneficiary, _weiAmount);
* require(getWeiRaised().add(_weiAmount) <= cap);
* require(weiRaised().add(_weiAmount) <= cap);
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
Expand Down
2 changes: 1 addition & 1 deletion contracts/crowdsale/distribution/FinalizableCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract FinalizableCrowdsale is Ownable, TimedCrowdsale {
/**
* @return true if the crowdsale is finalized, false otherwise.
*/
function isFinalized() public view returns(bool) {
function finalized() public view returns(bool) {
return finalized_;
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract PostDeliveryCrowdsale is TimedCrowdsale {
/**
* @return the balance of an account.
*/
function getBalance(address _account) public view returns(uint256) {
function balanceOf(address _account) public view returns(uint256) {
return balances_[_account];
}

Expand Down
8 changes: 4 additions & 4 deletions contracts/crowdsale/distribution/RefundableCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
*/
constructor(uint256 _goal) public {
require(_goal > 0);
escrow_ = new RefundEscrow(getWallet());
escrow_ = new RefundEscrow(wallet());
goal_ = _goal;
}

/**
* @return minimum amount of funds to be raised in wei.
*/
function getGoal() public view returns(uint256) {
function goal() public view returns(uint256) {
return goal_;
}

/**
* @dev Investors can claim refunds here if crowdsale is unsuccessful
*/
function claimRefund() public {
require(isFinalized());
require(finalized());
require(!goalReached());

escrow_.withdraw(msg.sender);
Expand All @@ -52,7 +52,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
* @return Whether funding goal was reached
*/
function goalReached() public view returns (bool) {
return getWeiRaised() >= goal_;
return weiRaised() >= goal_;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions contracts/crowdsale/emission/AllowanceCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract AllowanceCrowdsale is Crowdsale {
/**
* @return the address of the wallet that will hold the tokens.
*/
function getTokenWallet() public view returns(address) {
function tokenWallet() public view returns(address) {
return tokenWallet_;
}

Expand All @@ -37,7 +37,7 @@ contract AllowanceCrowdsale is Crowdsale {
* @return Amount of tokens left in the allowance
*/
function remainingTokens() public view returns (uint256) {
return getToken().allowance(tokenWallet_, this);
return token().allowance(tokenWallet_, this);
}

/**
Expand All @@ -51,6 +51,6 @@ contract AllowanceCrowdsale is Crowdsale {
)
internal
{
getToken().safeTransferFrom(tokenWallet_, _beneficiary, _tokenAmount);
token().safeTransferFrom(tokenWallet_, _beneficiary, _tokenAmount);
}
}
2 changes: 1 addition & 1 deletion contracts/crowdsale/emission/MintedCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ contract MintedCrowdsale is Crowdsale {
{
// Potentially dangerous assumption about the type of the token.
require(
ERC20Mintable(address(getToken())).mint(_beneficiary, _tokenAmount));
ERC20Mintable(address(token())).mint(_beneficiary, _tokenAmount));
}
}
4 changes: 2 additions & 2 deletions contracts/crowdsale/price/IncreasingPriceCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
/**
* @return the initial rate of the crowdsale.
*/
function getInitialRate() public view returns(uint256) {
function initialRate() public view returns(uint256) {
return initialRate_;
}

/**
* @return the final rate of the crowdsale.
*/
function getFinalRate() public view returns (uint256) {
function finalRate() public view returns (uint256) {
return finalRate_;
}

Expand Down
6 changes: 3 additions & 3 deletions contracts/crowdsale/validation/CappedCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract CappedCrowdsale is Crowdsale {
/**
* @return the cap of the crowdsale.
*/
function getCap() public view returns(uint256) {
function cap() public view returns(uint256) {
return cap_;
}

Expand All @@ -34,7 +34,7 @@ contract CappedCrowdsale is Crowdsale {
* @return Whether the cap was reached
*/
function capReached() public view returns (bool) {
return getWeiRaised() >= cap_;
return weiRaised() >= cap_;
}

/**
Expand All @@ -49,7 +49,7 @@ contract CappedCrowdsale is Crowdsale {
internal
{
super._preValidatePurchase(_beneficiary, _weiAmount);
require(getWeiRaised().add(_weiAmount) <= cap_);
require(weiRaised().add(_weiAmount) <= cap_);
}

}
2 changes: 1 addition & 1 deletion test/crowdsale/AllowanceCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW

describe('accepting payments', function () {
it('should have token wallet', async function () {
(await this.crowdsale.getTokenWallet()).should.be.equal(tokenWallet);
(await this.crowdsale.tokenWallet()).should.be.equal(tokenWallet);
});

it('should accept sends', async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/crowdsale/IncreasingPriceCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
});

it('should have initial and final rate', async function () {
(await this.crowdsale.getInitialRate()).should.be.bignumber.equal(initialRate);
(await this.crowdsale.getFinalRate()).should.be.bignumber.equal(finalRate);
(await this.crowdsale.initialRate()).should.be.bignumber.equal(initialRate);
(await this.crowdsale.finalRate()).should.be.bignumber.equal(finalRate);
});

it('at start', async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/crowdsale/PostDeliveryCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
});

it('does not immediately assign tokens to beneficiaries', async function () {
(await this.crowdsale.getBalance(investor)).should.be.bignumber.equal(value);
(await this.crowdsale.balanceOf(investor)).should.be.bignumber.equal(value);
(await this.token.balanceOf(investor)).should.be.bignumber.equal(0);
});

Expand All @@ -62,7 +62,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {

it('allows beneficiaries to withdraw tokens', async function () {
await this.crowdsale.withdrawTokens({ from: investor });
(await this.crowdsale.getBalance(investor)).should.be.bignumber.equal(0);
(await this.crowdsale.balanceOf(investor)).should.be.bignumber.equal(0);
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value);
});

Expand Down
8 changes: 4 additions & 4 deletions test/examples/SampleCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ contract('SampleCrowdsale', function ([_, owner, wallet, investor]) {

(await this.crowdsale.openingTime()).should.be.bignumber.equal(this.openingTime);
(await this.crowdsale.closingTime()).should.be.bignumber.equal(this.closingTime);
(await this.crowdsale.getRate()).should.be.bignumber.equal(RATE);
(await this.crowdsale.getWallet()).should.be.equal(wallet);
(await this.crowdsale.getGoal()).should.be.bignumber.equal(GOAL);
(await this.crowdsale.getCap()).should.be.bignumber.equal(CAP);
(await this.crowdsale.rate()).should.be.bignumber.equal(RATE);
(await this.crowdsale.wallet()).should.be.equal(wallet);
(await this.crowdsale.goal()).should.be.bignumber.equal(GOAL);
(await this.crowdsale.cap()).should.be.bignumber.equal(CAP);
});

it('should not accept payments before start', async function () {
Expand Down