Skip to content

Commit 9d5a91e

Browse files
committed
remove totalPresaleWei variable, take presale wei in count for ICO
1 parent edd4683 commit 9d5a91e

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

contracts/LifCrowdsale.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ contract LifCrowdsale is Ownable, Pausable {
8282
// Amount of lif minted and transferred during the TGE
8383
uint256 public tokensSold;
8484

85-
// Amount of wei received as private presale payments
86-
uint256 public totalPresaleWei;
87-
8885
// Address of the vesting schedule for the foundation created at the
8986
// end of the crowdsale
9087
VestedPayment public foundationVestedPayment;
@@ -257,7 +254,7 @@ contract LifCrowdsale is Ownable, Pausable {
257254

258255
uint256 tokens = weiSent.mul(rate);
259256

260-
totalPresaleWei = totalPresaleWei.add(weiSent);
257+
weiRaised = weiRaised.add(weiSent);
261258

262259
token.mint(beneficiary, tokens);
263260

test/CrowdsaleGenTest.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ contract('LifCrowdsale Property-based test', function (accounts) {
3939

4040
let presaleWei = sumBigNumbers(_.map(state.presalePurchases, (p) => p.wei));
4141

42-
presaleWei.should.be.bignumber.equal(await crowdsale.totalPresaleWei.call());
43-
4442
help.debug('checking purchases total wei, purchases:', JSON.stringify(state.purchases));
4543
let weiInPurchases = sumBigNumbers(_.map(state.purchases, (p) => p.wei));
46-
weiInPurchases.should.be.bignumber.equal(await crowdsale.weiRaised());
44+
if (state.crowdsaleFinalized)
45+
new BigNumber(0).should.be.bignumber.equal(await web3.eth.getBalance(crowdsale.address));
46+
else
47+
weiInPurchases.should.be.bignumber.equal(await web3.eth.getBalance(crowdsale.address));
4748

4849
// Check presale tokens sold
49-
state.totalPresaleWei.should.be.bignumber.equal(await crowdsale.totalPresaleWei.call());
5050
assert.equal(state.crowdsaleFinalized, await crowdsale.isFinalized.call());
5151
if (state.crowdsaleFinalized && state.weiPerUSDinTGE > 0) {
5252
assert.equal(state.crowdsaleFunded, await crowdsale.funded());
@@ -179,7 +179,6 @@ contract('LifCrowdsale Property-based test', function (accounts) {
179179
presalePurchases: [],
180180
claimedEth: {},
181181
weiRaised: zero,
182-
totalPresaleWei: zero,
183182
crowdsalePaused: false,
184183
tokenPaused: true,
185184
crowdsaleFinalized: false,

test/commands.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ async function runFinalizeCrowdsaleCommand (command, state) {
375375
async function runAddPrivatePresalePaymentCommand (command, state) {
376376
let { startTimestamp } = state.crowdsaleData,
377377
nextTimestamp = latestTime(),
378-
weiToSend = web3.toWei(command.eth, 'ether'),
378+
weiSent = web3.toWei(command.eth, 'ether'),
379379
account = gen.getAccount(command.fromAccount),
380380
beneficiary = gen.getAccount(command.beneficiaryAccount),
381381
hasZeroAddress = _.some([account, beneficiary], isZeroAddress);
@@ -385,20 +385,20 @@ async function runAddPrivatePresalePaymentCommand (command, state) {
385385
(account !== gen.getAccount(state.owner)) ||
386386
(state.crowdsaleFinalized) ||
387387
hasZeroAddress ||
388-
(weiToSend === 0) ||
388+
(weiSent === 0) ||
389389
(command.rate <= state.crowdsaleData.rate1);
390390

391391
try {
392392
help.debug('Adding presale private tokens for account:', command.beneficiaryAccount, 'eth:', command.eth, 'fromAccount:', command.fromAccount, 'blockTimestamp:', nextTimestamp);
393393

394-
const tx = await state.crowdsaleContract.addPrivatePresaleTokens(beneficiary, weiToSend, command.rate, { from: account });
394+
const tx = await state.crowdsaleContract.addPrivatePresaleTokens(beneficiary, weiSent, command.rate, { from: account });
395395

396396
assert.equal(false, shouldThrow, 'buyTokens should have thrown but it did not');
397397

398-
state.totalSupply = state.totalSupply.plus(weiToSend * command.rate);
399-
state.totalPresaleWei = state.totalPresaleWei.plus(weiToSend);
398+
state.totalSupply = state.totalSupply.plus(weiSent * command.rate);
399+
state.weiRaised = state.weiRaised.plus(weiSent);
400400
state.presalePurchases = _.concat(state.presalePurchases,
401-
{ rate: command.rate, wei: weiToSend, beneficiary: command.beneficiary, account: command.fromAccount }
401+
{ rate: command.rate, wei: weiSent, beneficiary: command.beneficiary, account: command.fromAccount }
402402
);
403403
state = decreaseEthBalance(state, command.fromAccount, help.txGasCost(tx));
404404
} catch (e) {

0 commit comments

Comments
 (0)