Skip to content

Commit

Permalink
Merge pull request #681 from poanetwork/remove-start-end-block
Browse files Browse the repository at this point in the history
(Refactor) remove obsolete contracts methods and derivatives
  • Loading branch information
fvictorio committed Mar 14, 2018
2 parents b031157 + 8da6ac5 commit f87fbb6
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 75 deletions.
64 changes: 0 additions & 64 deletions src/components/crowdsale/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,6 @@ export function getCrowdsaleTargetDates($this, cb) {

if (!crowdsaleContract) return noContractAlert();

if (crowdsaleContract.methods.startBlock) {
propsCount++;
crowdsaleContract.methods.startBlock().call((err, startBlock) => {
cbCount++;
if (err) return console.log(err);

console.log("startBlock: " + startBlock);
if (!crowdsalePageStore.startBlock || crowdsalePageStore.startBlock > startBlock)
crowdsalePageStore.setProperty('startBlock', startBlock);
if (propsCount === cbCount) {
state.loading = false;
$this.setState(state, cb);
}
});
}

if (crowdsaleContract.methods.startsAt) {
propsCount++;
crowdsaleContract.methods.startsAt().call((err, startDate) => {
Expand All @@ -146,36 +130,6 @@ export function getCrowdsaleTargetDates($this, cb) {
});
}

if (crowdsaleContract.methods.endBlock) {
propsCount++;
crowdsaleContract.methods.endBlock().call((err, endBlock) => {
cbCount++;
if (err) return console.log(err);

console.log("endBlock: " + endBlock);

if (!crowdsalePageStore.endBlock || crowdsalePageStore.endBlock < endBlock) crowdsalePageStore.endBlock = endBlock;

web3.eth.getBlockNumber((err, curBlock) => {
if (err) return console.log(err);

console.log("curBlock: " + curBlock);
let blocksDiff = parseInt($this.crowdsalePageStore.endBlock, 10) - parseInt(curBlock, 10);

console.log("blocksDiff: " + blocksDiff);
let blocksDiffInSec = blocksDiff * state.blockTimeGeneration;

console.log("blocksDiffInSec: " + blocksDiffInSec);
state.seconds = blocksDiffInSec;

if (propsCount === cbCount) {
state.loading = false;
$this.setState(state, cb);
}
});
});
}

if (crowdsaleContract.methods.endsAt) {
propsCount++;
crowdsaleContract.methods.endsAt().call((err, endDate) => {
Expand Down Expand Up @@ -328,24 +282,6 @@ export function getCrowdsaleData (crowdsaleContract) {
let propsCount = 0
let cbCount = 0

if (crowdsaleContract.methods.supply) {
propsCount++
crowdsaleContract.methods.supply().call((err, supply) => {
cbCount++

if (err) {
return console.log(err)
}

console.log('supply:', supply)
crowdsalePageStore.supply = supply

if (propsCount === cbCount) {
resolve()
}
})
}

propsCount++
crowdsaleContract.methods.token().call((err, tokenAddr) => {
cbCount++
Expand Down
3 changes: 1 addition & 2 deletions src/components/invest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,9 @@ export class Invest extends React.Component {

this.setState({ loading: true })

const startBlock = parseInt(crowdsalePageStore.startBlock, 10)
const { startDate } = crowdsalePageStore

if ((isNaN(startBlock) || startBlock === 0) && !startDate) {
if (!startDate) {
this.setState({ loading: false })
return
}
Expand Down
1 change: 0 additions & 1 deletion src/stores/CrowdsalePageStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class CrowdsalePageStore {
@observable rate;
@observable tokensSold;
@observable tokenAmountOf;
@observable startBlock
@observable endDate;

@action setProperty = (property, value) => {
Expand Down
8 changes: 0 additions & 8 deletions src/utils/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ export function successfulInvestmentAlert(tokensToInvest) {
});
}

export function investmentDisabledAlert(startBlock, curBlock) {
sweetAlert2({
title: "Warning",
html: "Wait, please. Crowdsale company hasn't started yet. It'll start from <b>" + startBlock + "</b> block. Current block is <b>" + curBlock + "</b>.",
type: "warning"
});
}

export function investmentDisabledAlertInTime(startTime) {
sweetAlert2({
title: "Warning",
Expand Down

0 comments on commit f87fbb6

Please sign in to comment.