Skip to content

Commit

Permalink
Add alert warning in crowdsale section
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariano Aguero committed Aug 22, 2018
1 parent 44aad8e commit 17bda18
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/components/crowdsale/index.js
Expand Up @@ -10,14 +10,14 @@ import {
getCrowdsaleStrategyByName
} from '../../utils/blockchainHelpers'
import { getContractStoreProperty, getCrowdsaleData, getTokenData, initializeAccumulativeData } from './utils'
import { getExecID, getAddr, getNetworkID, toBigNumber } from '../../utils/utils'
import { getExecID, getAddr, getNetworkID, toBigNumber, isExecIDValid, isAddressValid } from '../../utils/utils'
import { getCrowdsaleAssets } from '../../stores/utils'
import { StepNavigation } from '../Common/StepNavigation'
import { NAVIGATION_STEPS } from '../../utils/constants'
import { Loader } from '../Common/Loader'
import { CrowdsaleConfig } from '../Common/config'
import { inject, observer } from 'mobx-react'
import { invalidCrowdsaleExecIDAlert, invalidNetworkIDAlert } from '../../utils/alerts'
import { invalidCrowdsaleExecIDAlert, invalidNetworkIDAlert, invalidCrowdsaleProxyAlert } from '../../utils/alerts'
import logdown from 'logdown'

const logger = logdown('TW:crowdsale')
Expand Down Expand Up @@ -62,7 +62,7 @@ export class Crowdsale extends React.Component {
}

//todo: change config to support exec-id and address
const crowdsaleExecID = CrowdsaleConfig.crowdsaleContractURL || getExecID()
const crowdsaleExecID = getExecID()
contractStore.setContractProperty('crowdsale', 'execID', crowdsaleExecID)
}

Expand All @@ -71,7 +71,18 @@ export class Crowdsale extends React.Component {

try {
await getCrowdsaleAssets(generalStore.networkID)
const crowdsaleAddr = CrowdsaleConfig.crowdsaleContractURL || getAddr()
const crowdsaleAddr = getAddr()

if (!isExecIDValid(contractStore.crowdsale.execID) && contractStore.crowdsale.execID) {
invalidCrowdsaleExecIDAlert()
return Promise.reject('invalid exec-id')
}

if (!isAddressValid(crowdsaleAddr) && !contractStore.crowdsale.execID) {
invalidCrowdsaleProxyAlert()
return Promise.reject('invalid proxy addr')
}

let strategy
if (contractStore.crowdsale.execID) {
strategy = await getCrowdsaleStrategy(contractStore.crowdsale.execID)
Expand All @@ -86,11 +97,6 @@ export class Crowdsale extends React.Component {
}
crowdsaleStore.setProperty('strategy', strategy)
contractStore.setContractProperty(crowdsaleStore.proxyName, 'addr', crowdsaleAddr)
//todo: change to 2 alerts
if (!contractStore.crowdsale.execID && !crowdsaleAddr) {
invalidCrowdsaleExecIDAlert()
return Promise.reject('invalid exec-id or addr')
}
} catch (err) {
return Promise.reject(err)
}
Expand Down

0 comments on commit 17bda18

Please sign in to comment.