Skip to content

Commit

Permalink
Merge branch '2.0-steps-integration' into issue#1033#manage
Browse files Browse the repository at this point in the history
  • Loading branch information
mariano-aguero committed Aug 29, 2018
2 parents 173d03a + 0cbeef0 commit 84fb022
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 33 deletions.
53 changes: 27 additions & 26 deletions src/components/stepFour/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ import {
scrollToBottom,
SUMMARY_FILE_CONTENTS
} from './utils'
import {
noContractDataAlert,
successfulDeployment,
skippingTransaction,
networkChanged,
deployHasEnded
} from '../../utils/alerts'
import { noContractDataAlert, successfulDeployment, skippingTransaction, deployHasEnded } from '../../utils/alerts'
import {
DESCRIPTION,
NAVIGATION_STEPS,
Expand All @@ -26,7 +20,7 @@ import {
PUBLISH_DESCRIPTION
} from '../../utils/constants'
import { DOWNLOAD_TYPE } from './constants'
import { toast } from '../../utils/utils'
import { getNetworkID, toast } from '../../utils/utils'
import { StepNavigation } from '../Common/StepNavigation'
import { DisplayField } from '../Common/DisplayField'
import { TxProgressStatus } from '../Common/TxProgressStatus'
Expand All @@ -40,8 +34,10 @@ import { PreventRefresh } from '../Common/PreventRefresh'
import cancelDeploy from '../../utils/cancelDeploy'
import PropTypes from 'prop-types'
import logdown from 'logdown'
import { getNetworkVersion } from '../../utils/blockchainHelpers'
let promiseRetry = require('promise-retry')
import { checkNetWorkByID } from '../../utils/blockchainHelpers'
import { CrowdsaleConfig } from '../Common/config'
import { ButtonContinue } from '../Common/ButtonContinue'
import classNames from 'classnames'

const logger = logdown('TW:stepFour')

Expand Down Expand Up @@ -113,22 +109,21 @@ export class stepFour extends Component {
}

async componentDidMount() {
const { deploymentStore } = this.props
const { deploymentStore, generalStore } = this.props

// Check if network has changed
const networkID = generalStore.networkID || CrowdsaleConfig.networkID || getNetworkID()
generalStore.setProperty('networkID', networkID)

const networkInfo = await checkNetWorkByID(networkID)

if (!networkInfo) {
return Promise.reject('invalid networkID')
}
// Check if deploy has ended
if (deploymentStore.hasEnded) {
return await deployHasEnded()
}
// Check if network has changed
await promiseRetry(async retry => {
const networkChangedResult = await this.checkNetworkChanged()
if (networkChangedResult) {
this.hideModal()
await networkChanged()
this.showModal()
retry()
}
})

scrollToBottom()
copy('copy')
Expand Down Expand Up @@ -527,6 +522,10 @@ export class stepFour extends Component {
/>
)

const submitButtonClass = classNames('button', 'button_fill_secondary', 'button_no_border', {
button_disabled: !deploymentStore.hasEnded
})

const strategyName = isMintedCappedCrowdsale ? MINTED_CAPPED_CROWDSALE_DN : isDutchAuction ? DUTCH_AUCTION_DN : ''

return (
Expand Down Expand Up @@ -566,12 +565,14 @@ export class stepFour extends Component {
</div>
</div>
<div className="button-container">
<div onClick={this.downloadContractButton} className="button button_fill_secondary">
<button
onClick={this.downloadContractButton}
disabled={!deploymentStore.hasEnded}
className={submitButtonClass}
>
Download File
</div>
<a onClick={this.goToCrowdsalePage} className="button button_fill">
Continue
</a>
</button>
<ButtonContinue onClick={this.goToCrowdsalePage} status={deploymentStore.hasEnded} />
</div>
<ModalContainer title={'Tx Status'} showModal={this.state.modal}>
{modalContent}
Expand Down
4 changes: 1 addition & 3 deletions src/components/stepThree/GasPriceInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ class GasPriceInput extends Component {
className="input"
value={this.state.customGasPrice}
name="gas-price-custom-value"
onChange={e => {
this.handleCustomGasPriceChange(e.target.value)
}}
onChange={e => this.handleCustomGasPriceChange(e.target.value)}
/>
) : null}
<p className="description">Slow is cheap, fast is expensive</p>
Expand Down
2 changes: 1 addition & 1 deletion src/stores/GeneralStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import autosave from './autosave'

class GeneralStore {
@observable networkID
@observable gasPrice = GAS_PRICE.SLOW.PRICE
@observable gasPrice
@observable gasTypeSelected
@observable burnExcess

Expand Down
4 changes: 2 additions & 2 deletions src/stores/Web3Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Web3Store {
infuraLink = this.getInfuraLink(CHAINS.MAINNET)
break
}
let httpProvider = new Web3.providers.HttpProvider(infuraLink)
const httpProvider = new Web3.providers.HttpProvider(infuraLink)
web3 = new Web3(httpProvider)
}

Expand All @@ -77,7 +77,7 @@ class Web3Store {
} else {
// window.web3 == web3 most of the time. Don't override the provided,
// web3, just wrap it in your Web3.
let myWeb3 = new Web3(web3.currentProvider)
const myWeb3 = new Web3(web3.currentProvider)

cb(myWeb3, false)
return myWeb3
Expand Down
2 changes: 1 addition & 1 deletion src/utils/blockchainHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const checkNetWorkByID = async _networkIdFromGET => {

if (networkNameFromGET !== networkNameFromNetwork) {
logger.log(`${networkNameFromGET}!=${networkNameFromNetwork}`)
return incorrectNetworkAlert(networkNameFromGET, networkNameFromNetwork)
return await incorrectNetworkAlert(networkNameFromGET, networkNameFromNetwork)
}

return _networkIdFromNetwork
Expand Down

0 comments on commit 84fb022

Please sign in to comment.