Skip to content

Commit

Permalink
Merge pull request #689 from poanetwork/unprecise-total-supply-#674
Browse files Browse the repository at this point in the history
(Fix) Supply calculus for invest page
  • Loading branch information
Franco Victorio committed Mar 14, 2018
2 parents ca55ee0 + 23fbf8c commit c3192e3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/invest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
getCrowdsaleTargetDates,
getCurrentRate,
getJoinedTiers,
initializeAccumulativeData
initializeAccumulativeData,
toBigNumber
} from '../crowdsale/utils'
import { countDecimalPlaces, getQueryVariable, toast } from '../../utils/utils'
import { getWhiteListWithCapCrowdsaleAssets } from '../../stores/utils'
Expand Down Expand Up @@ -314,7 +315,7 @@ export class Invest extends React.Component {

render () {
const { crowdsalePageStore, tokenStore, contractStore, investStore } = this.props
const { rate, tokenAmountOf, ethRaised, supply } = crowdsalePageStore
const { rate, tokenAmountOf, ethRaised } = crowdsalePageStore
const { crowdsale, contractType } = contractStore
const { tokensToInvest } = investStore

Expand All @@ -327,7 +328,9 @@ export class Invest extends React.Component {
const tokenDecimals = !isNaN(decimals) ? decimals : 0
const tokenTicker = ticker ? ticker.toString() : ''
const tokenName = name ? name.toString() : ''
const maxCapBeforeDecimals = crowdsalePageStore.maximumSellableTokens / 10 ** tokenDecimals
const supply = toBigNumber(crowdsalePageStore.supply)
const maximumSellableTokens = toBigNumber(crowdsalePageStore.maximumSellableTokens)
const maxCapBeforeDecimals = toBigNumber(maximumSellableTokens).div(`1e${tokenDecimals}`)
const tokenAddress = getContractStoreProperty('token', 'addr')

//balance: tiers, standard
Expand All @@ -336,8 +339,8 @@ export class Invest extends React.Component {
const investorBalance = isWhitelistWithCap ? investorBalanceTiers : investorBalanceStandard

//total supply: tiers, standard
const tierCap = !isNaN(maxCapBeforeDecimals) ? maxCapBeforeDecimals.toString() : '0'
const standardCrowdsaleSupply = !isNaN(supply) ? supply.toString() : '0'
const tierCap = maxCapBeforeDecimals.toFixed()
const standardCrowdsaleSupply = supply.toFixed()
const totalSupply = isWhitelistWithCap ? tierCap : standardCrowdsaleSupply

let invalidTokenDescription = null
Expand Down

0 comments on commit c3192e3

Please sign in to comment.