diff --git a/src/components/Common/CrowdsaleBlock.js b/src/components/Common/CrowdsaleBlock.js index 23116253f..068ec2cd4 100644 --- a/src/components/Common/CrowdsaleBlock.js +++ b/src/components/Common/CrowdsaleBlock.js @@ -12,17 +12,6 @@ export class CrowdsaleBlock extends React.Component { constructor(props) { super(props); - //props.onChange.bind(this); - //let oldState = getOldState(props, defaultState) - //this.state = Object.assign({}, oldState) - //let state = props.state - //state.crowdsale[props.num].tier = "Tier " + (this.props.num + 1) - //state.crowdsale[props.num].updatable = "off" - //state.crowdsale[props.num].startTime = state.crowdsale[props.num - 1].endTime; - //state.crowdsale[props.num].endTime = defaultCompanyEndDate(state.crowdsale[props.num].startTime); - //this.setState(newState); - //this.setState(state); - //console.log('333 validations', state.validations) } componentDidMount() { @@ -50,49 +39,49 @@ export class CrowdsaleBlock extends React.Component { return (
- handleInputBlur('crowdsale', 'tier', num)} onChange={(e) => onChange(e, 'crowdsale', num, 'tier')} description={`Name of a tier, e.g. PrePreIco, PreICO, ICO with bonus A, ICO with bonus B, etc. We simplified that and will increment a number after each tier.`} /> - handleInputBlur('pricingStrategy', 'rate', num)} onChange={(e) => onChange(e, 'pricingStrategy', num, 'rate')} description={`Exchange rate Ethereum to Tokens. If it's 100, then for 1 Ether you can buy 100 tokens`} />
- handleInputBlur('crowdsale', 'startTime', num)} defaultValue={this.props.state.crowdsale[this.props.num - 1].endTime} onChange={(e) => onChange(e, 'crowdsale', num, 'startTime')} description={`Date and time when the tier starts. Can't be in the past from the current moment.`} /> - handleInputBlur('crowdsale', 'endTime', num)} defaultValue={defaultCompanyEndDate(this.props.state.crowdsale[this.props.num - 1].endTime)} onChange={(e) => onChange(e, 'crowdsale', num, 'endTime')} @@ -100,19 +89,19 @@ export class CrowdsaleBlock extends React.Component { />
- handleInputBlur('crowdsale', 'supply', num)} + onBlur={() => handleInputBlur('crowdsale', 'supply', num)} onChange={(e) => onChange(e, 'crowdsale', num, 'supply')} description={`How many tokens will be sold on this tier. Cap of crowdsale equals to sum of supply of all tiers`} /> - ) } -} \ No newline at end of file +} diff --git a/src/components/Common/RadioInputField.js b/src/components/Common/RadioInputField.js index 5db3ebe93..b710ebab0 100644 --- a/src/components/Common/RadioInputField.js +++ b/src/components/Common/RadioInputField.js @@ -5,7 +5,7 @@ export class RadioInputField extends React.Component { constructor(props) { super(props); this.state = { - "checked1": props.defaultValue===this.props.vals[0]?true:false, + "checked1": props.defaultValue===this.props.vals[0]?true:false, "checked2": props.defaultValue===this.props.vals[0]?false:true } } @@ -13,7 +13,7 @@ export class RadioInputField extends React.Component { onChange(e) { console.log(e.target); this.setState({ - "checked1": e.target.value===this.props.vals[0]?true:false, + "checked1": e.target.value===this.props.vals[0]?true:false, "checked2": e.target.value===this.props.vals[0]?false:true}); this.props.onChange(e); } @@ -23,9 +23,9 @@ export class RadioInputField extends React.Component {
- {/*
-
- {this.props.items[0]} - -
-
- {this.props.items[1]} -
-
*/}

{this.props.description}

) } -} \ No newline at end of file +} diff --git a/src/components/Common/ReservedTokensInputBlock.js b/src/components/Common/ReservedTokensInputBlock.js index 26ab44b20..8f76d5986 100644 --- a/src/components/Common/ReservedTokensInputBlock.js +++ b/src/components/Common/ReservedTokensInputBlock.js @@ -11,10 +11,7 @@ export class ReservedTokensInputBlock extends React.Component { constructor(props) { super(props); - //let oldState = getOldState(props, defaultState) - //console.log('oldState', oldState) - //this.state = Object.assign({}, defaultState, oldState, initialStepTwoValues, intitialStepTwoValidations ) - + let oldState = getOldState(props, defaultState) this.state = Object.assign({}, oldState) } @@ -45,7 +42,7 @@ export class ReservedTokensInputBlock extends React.Component { }); this.setState(state, function() { state.token.reservedTokensElements.push( -
- this.reservedTokensInputAddr = reservedTokensInputAddr} - side='reserved-tokens-input-property reserved-tokens-input-property-left' - type='text' - title={ADDRESS} + side='reserved-tokens-input-property reserved-tokens-input-property-left' + type='text' + title={ADDRESS} value={token.reservedTokensInput.addr} onChange={(e) => onChange(e, 'token', 0, 'reservedtokens_addr')} description={`Address where to send reserved tokens.`} /> - onChange(e, 'token', 0, 'reservedtokens_dim')} description={`Fixed amount or % of crowdsaled tokens. Will be deposited to the account after fintalization of the crowdsale. `} /> - this.reservedTokensInputVal = reservedTokensInputVal} side='reserved-tokens-input-property reserved-tokens-input-property-right' - type='number' - title={VALUE} + type='number' + title={VALUE} value={token.reservedTokensInput.val} onChange={(e) => onChange(e, 'token', 0, 'reservedtokens_val')} description={`Value in tokens or percents. Don't forget to press + button for each reserved token.`} @@ -110,4 +107,4 @@ export class ReservedTokensInputBlock extends React.Component { {token.reservedTokensElements}
) } -} \ No newline at end of file +} diff --git a/src/components/Common/config.js b/src/components/Common/config.js index b93444b7a..8200b427e 100644 --- a/src/components/Common/config.js +++ b/src/components/Common/config.js @@ -7,14 +7,4 @@ const networks = { oraclesTest: 12648430 } -/* -DEMO CONFIG: -export const ICOConfig = { - crowdsaleContractURL: '0xc5a21a3e32d9d614ed46e4b2352670fcb21009ee', - networkID: networks.kovan -}; -*/ - -export const ICOConfig = { - -}; \ No newline at end of file +export const ICOConfig = {}; diff --git a/src/components/Footer/index.js b/src/components/Footer/index.js index 58ceb86b4..d3d1c271e 100644 --- a/src/components/Footer/index.js +++ b/src/components/Footer/index.js @@ -12,12 +12,7 @@ export const Footer = () => ( - {/* - - - - */}
-) \ No newline at end of file +) diff --git a/src/components/Home/index.js b/src/components/Home/index.js index 2228a46a8..04810d34e 100644 --- a/src/components/Home/index.js +++ b/src/components/Home/index.js @@ -11,20 +11,6 @@ export class Home extends Component { this.state = defaultState } - componentDidMount() { - //emergency alert - /*setTimeout(() => { - getWeb3((web3) => { - getNetworkVersion(web3, (_networkID) => { - console.log(_networkID); - if (_networkID == 1) { - return noDeploymentOnMainnetAlert(); - } - }) - }) - }, 500);*/ - } - render() { return (
@@ -84,4 +70,4 @@ export class Home extends Component {
); } -} \ No newline at end of file +} diff --git a/src/components/crowdsale/index.js b/src/components/crowdsale/index.js index 1ccefc913..898ee78df 100644 --- a/src/components/crowdsale/index.js +++ b/src/components/crowdsale/index.js @@ -90,11 +90,11 @@ export class Crowdsale extends React.Component { } getFullCrowdsaleData(web3, crowdsaleContract) { - getCrowdsaleData(web3, this, crowdsaleContract, () => { + getCrowdsaleData(web3, this, crowdsaleContract, () => { initializeAccumulativeData(this, () => { getAccumulativeCrowdsaleData(web3, this, () => { }); - }); + }); }); } @@ -103,17 +103,12 @@ export class Crowdsale extends React.Component { if (!ICOConfig.crowdsaleContractURL || !ICOConfig.networkID) { if (this.state.contracts.crowdsale.addr) { queryStr = "?addr=" + this.state.contracts.crowdsale.addr[0]; - /*for (let i = 1; i < this.state.contracts.crowdsale.addr.length; i++) { - queryStr += `&addr=` + this.state.contracts.crowdsale.addr[i] - }*/ if (this.state.networkID) queryStr += "&networkID=" + this.state.networkID; - //uncomment, if more then one contractType will appear - /*if (this.state.contractType) - queryStr += "&contractType=" + this.state.contractType;*/ } } - this.props.history.push('/invest' + queryStr); + + this.props.history.push('/invest' + queryStr); } render() { @@ -126,29 +121,29 @@ export class Crowdsale extends React.Component { const ethRaised = this.state.crowdsale.ethRaised; //tokens claimed: tiers, standard - const tokensClaimedStandard = rate?(this.state.crowdsale.ethRaised/rate/*.toFixed(tokenDecimals)*/):0; + const tokensClaimedStandard = rate?(this.state.crowdsale.ethRaised/rate):0; const tokensClaimedTiers = rate?(this.state.crowdsale.tokensSold/10**tokenDecimals):0; const tokensClaimed = (this.state.contractType === this.state.contractTypes.whitelistwithcap)?tokensClaimedTiers:tokensClaimedStandard; - + //price: tiers, standard const tokensPerETHStandard = !isNaN(rate)?rate:0; const tokensPerETHTiers = !isNaN(1/rate)?1/this.state.web3.utils.fromWei(toFixed(rate).toString(), "ether"):0; const tokensPerETH = (this.state.contractType === this.state.contractTypes.whitelistwithcap)?tokensPerETHTiers:tokensPerETHStandard; - + //total supply: tiers, standard - const tierCap = maxCapBeforeDecimals?(maxCapBeforeDecimals/*.toFixed(tokenDecimals)*/).toString():0; - const standardCrowdsaleSupply = !isNaN(this.state.crowdsale.supply)?(this.state.crowdsale.supply/*.toFixed(tokenDecimals)*/).toString():0; + const tierCap = maxCapBeforeDecimals?(maxCapBeforeDecimals).toString():0; + const standardCrowdsaleSupply = !isNaN(this.state.crowdsale.supply)?(this.state.crowdsale.supply).toString():0; const totalSupply = (this.state.contractType === this.state.contractTypes.whitelistwithcap)?tierCap:standardCrowdsaleSupply; //goal in ETH const goalInETHStandard = (totalSupply/rate).toExponential(); let goalInETHTiers = this.state.crowdsale.maximumSellableTokensInWei?(this.state.web3.utils.fromWei(toFixed(this.state.crowdsale.maximumSellableTokensInWei).toString(), "ether").toString()):0; goalInETHTiers = 1.0 / 100 * Math.floor(100 * goalInETHTiers) - const goalInETH = (this.state.contractType === this.state.contractTypes.whitelistwithcap)?goalInETHTiers:goalInETHStandard; + const goalInETH = (this.state.contractType === this.state.contractTypes.whitelistwithcap)?goalInETHTiers:goalInETHStandard; const tokensClaimedRatio = goalInETH?(ethRaised/goalInETH)*100:"0"; - + return (
@@ -236,12 +231,10 @@ export class Crowdsale extends React.Component {
- {/*Invest*/} - {/*Add crowdsale*/} Invest
) } -} \ No newline at end of file +} diff --git a/src/components/crowdsale/utils.js b/src/components/crowdsale/utils.js index 8ed94dc67..257e81497 100644 --- a/src/components/crowdsale/utils.js +++ b/src/components/crowdsale/utils.js @@ -61,17 +61,17 @@ export function findCurrentContractRecursively(i, $this, web3, firstCrowdsaleCon return cb(crowdsaleContract, i); crowdsaleContract.methods.startsAt().call(function(err, startDate) { if (err) return console.log(err); - + startDate = startDate*1000; console.log("startDate: " + startDate); crowdsaleContract.methods.endsAt().call(function(err, endDate) { if (err) return console.log(err); - + endDate = endDate*1000; console.log("endDate: " + endDate); - + let curDate = new Date().getTime(); - console.log("curDate: " + curDate); + console.log("curDate: " + curDate); if (curDate < endDate && curDate >= startDate) { cb(crowdsaleContract, i); } else { @@ -97,8 +97,8 @@ export function getCrowdsaleTargetDates(web3, $this, cb) { propsCount++; crowdsaleContract.methods.startBlock().call(function(err, startBlock) { cbCount++; - if (err) return console.log(err); - + if (err) return console.log(err); + console.log("startBlock: " + startBlock); if (!state.crowdsale.startBlock || state.crowdsale.startBlock > startBlock) state.crowdsale.startBlock = startBlock; @@ -114,7 +114,7 @@ export function getCrowdsaleTargetDates(web3, $this, cb) { crowdsaleContract.methods.startsAt().call(function(err, startDate) { cbCount++; if (err) return console.log(err); - + console.log("startDate: " + startDate*1000); if (!state.crowdsale.startDate || state.crowdsale.startDate > startDate*1000) state.crowdsale.startDate = startDate*1000; @@ -130,18 +130,18 @@ export function getCrowdsaleTargetDates(web3, $this, cb) { crowdsaleContract.methods.endBlock().call(function(err, endBlock) { cbCount++; if (err) return console.log(err); - + console.log("endBlock: " + endBlock); if (!state.crowdsale.endBlock || state.crowdsale.endBlock < endBlock) state.crowdsale.endBlock = endBlock; web3.eth.getBlockNumber(function(err, curBlock) { if (err) return console.log(err); - + console.log("curBlock: " + curBlock); var blocksDiff = parseInt($this.state.crowdsale.endBlock, 10) - parseInt(curBlock, 10); console.log("blocksDiff: " + blocksDiff); var blocksDiffInSec = blocksDiff * state.blockTimeGeneration; - console.log("blocksDiffInSec: " + blocksDiffInSec); + console.log("blocksDiffInSec: " + blocksDiffInSec); state.seconds = blocksDiffInSec; if (propsCount === cbCount) { state.loading = false; @@ -156,7 +156,7 @@ export function getCrowdsaleTargetDates(web3, $this, cb) { crowdsaleContract.methods.endsAt().call(function(err, endDate) { cbCount++; if (err) return console.log(err); - + console.log("endDate: " + endDate*1000); if (!state.crowdsale.endDate || state.crowdsale.endDate < endDate*1000) state.crowdsale.endDate = endDate*1000; @@ -195,13 +195,13 @@ export function getAccumulativeCrowdsaleData(web3, $this, cb) { crowdsaleContract.methods.weiRaised().call(function(err, weiRaised) { cbCount++; if (err) return console.log(err); - + console.log("weiRaised: " + web3.utils.fromWei(parseInt(weiRaised, 10), "ether")); let state = $this.state; if (state.crowdsale.weiRaised) - state.crowdsale.weiRaised += parseInt(weiRaised, 10);//parseFloat(web3.utils.fromWei(parseInt(weiRaised, 10), "ether")); + state.crowdsale.weiRaised += parseInt(weiRaised, 10); else - state.crowdsale.weiRaised = parseInt(weiRaised, 10);//parseFloat(web3.utils.fromWei(parseInt(weiRaised, 10), "ether")); + state.crowdsale.weiRaised = parseInt(weiRaised, 10); state.crowdsale.ethRaised = parseFloat(web3.utils.fromWei(parseInt(state.crowdsale.weiRaised, 10), "ether")); @@ -216,7 +216,7 @@ export function getAccumulativeCrowdsaleData(web3, $this, cb) { crowdsaleContract.methods.tokensSold().call(function(err, tokensSold) { cbCount++; if (err) return console.log(err); - + console.log("tokensSold: " + tokensSold); let state = $this.state; if (state.crowdsale.tokensSold) @@ -236,7 +236,7 @@ export function getAccumulativeCrowdsaleData(web3, $this, cb) { crowdsaleContract.methods.maximumSellableTokens().call(function(err, maximumSellableTokens) { cbCount++; if (err) return console.log(err); - + console.log("maximumSellableTokens: " + maximumSellableTokens); let state = $this.state; if (state.crowdsale.maximumSellableTokens) @@ -263,7 +263,7 @@ export function getAccumulativeCrowdsaleData(web3, $this, cb) { getInvestors.call(function(err, investors) { cbCount++; if (err) return console.log(err); - + console.log("investors: " + investors); let state = $this.state; if (state.crowdsale.investors) @@ -283,7 +283,7 @@ export function getAccumulativeCrowdsaleData(web3, $this, cb) { function setMaximumSellableTokensInEth(web3, crowdsaleContract, maximumSellableTokens, $this) { crowdsaleContract.methods.pricingStrategy().call(function(err, pricingStrategyAddr) { if (err) return console.log(err); - + console.log("pricingStrategy: " + pricingStrategyAddr); attachToContract(web3, $this.state.contracts.pricingStrategy.abi, pricingStrategyAddr, function(err, pricingStrategyContract) { console.log("attach to pricing strategy contract"); @@ -292,7 +292,7 @@ function setMaximumSellableTokensInEth(web3, crowdsaleContract, maximumSellableT pricingStrategyContract.methods.oneTokenInWei().call(function(err, oneTokenInWei) { if (err) console.log(err); - + console.log("pricing strategy oneTokenInWei: " + oneTokenInWei); let state = $this.state; if (state.crowdsale.maximumSellableTokensInWei) @@ -310,7 +310,7 @@ export function getCurrentRate(web3, $this, crowdsaleContract, cb) { crowdsaleContract.methods.pricingStrategy().call(function(err, pricingStrategyAddr) { if (err) return console.log(err); - + console.log("pricingStrategy: " + pricingStrategyAddr); let state = $this.state; state.contracts.pricingStrategy.addr = pricingStrategyAddr; @@ -329,29 +329,12 @@ export function getCrowdsaleData(web3, $this, crowdsaleContract, cb) { let propsCount = 0; let cbCount = 0; - //depreciated: it was for standard type of contract (governed by open-zeppelin-solidity) - /*if (crowdsaleContract.rate) { - propsCount++; - crowdsaleContrac.methods.rate().call(function(err, rate) { - cbCount++; - if (err) return console.log(err); - - console.log("rate: " + web3.utils.fromWei(parseInt(rate, 10), "ether")); - let state = $this.state; - state.pricingStrategy.rate = web3.utils.fromWei(parseInt(rate, 10), "ether"); - if (propsCount === cbCount) { - state.loading = false; - $this.setState(state, cb); - } - }); - }*/ - if (crowdsaleContract.methods.supply) { propsCount++; crowdsaleContract.methods.supply().call(function(err, supply) { cbCount++; if (err) return console.log(err); - + console.log("supply: " + supply); let state = $this.state; state.crowdsale.supply = supply; @@ -366,7 +349,7 @@ export function getCrowdsaleData(web3, $this, crowdsaleContract, cb) { crowdsaleContract.methods.token().call(function(err, tokenAddr) { cbCount++; if (err) return console.log(err); - + console.log("token: " + tokenAddr); let state = $this.state; state.contracts.token.addr = tokenAddr; @@ -385,7 +368,7 @@ export function getCrowdsaleData(web3, $this, crowdsaleContract, cb) { crowdsaleContract.methods.pricingStrategy().call(function(err, pricingStrategyAddr) { cbCount++; if (err) return console.log(err); - + console.log("pricingStrategy: " + pricingStrategyAddr); let state = $this.state; state.contracts.pricingStrategy.addr = pricingStrategyAddr; @@ -432,7 +415,7 @@ function getTokenData(web3, $this, cb) { tokenContract.methods.name().call(function(err, name) { cbCount++; if (err) return console.log(err); - + console.log("token name: " + name); let state = $this.state; state.token.name = name; @@ -458,7 +441,7 @@ function getTokenData(web3, $this, cb) { tokenContract.methods.balanceOf(accounts[0]).call(function(err, balanceOf) { cbCount++; if (err) return console.log(err); - + console.log("balanceOf: " + balanceOf); let state = $this.state; if (state.crowdsale.tokenAmountOf) @@ -509,11 +492,11 @@ export function getPricingStrategyData(web3, $this, cb) { pricingStrategyContract.methods.oneTokenInWei().call(function(err, rate) { if (err) console.log(err); - + console.log("pricing strategy rate: " + rate); let state = $this.state; - state.pricingStrategy.rate = parseInt(rate, 10);//web3.utils.fromWei(parseInt(rate, 10), "ether"); + state.pricingStrategy.rate = parseInt(rate, 10); $this.setState(state, cb); }); }); -} \ No newline at end of file +} diff --git a/src/components/invest/index.js b/src/components/invest/index.js index 8e9ce6f84..5b68f1d66 100644 --- a/src/components/invest/index.js +++ b/src/components/invest/index.js @@ -33,7 +33,7 @@ export class Invest extends React.Component { }; const networkID = ICOConfig.networkID?ICOConfig.networkID:getQueryVariable("networkID"); - const contractType = this.state.contractTypes.whitelistwithcap;// getQueryVariable("contractType"); + const contractType = this.state.contractTypes.whitelistwithcap; checkNetWorkByID(web3, networkID); newState.contractType = contractType; @@ -92,7 +92,7 @@ export class Invest extends React.Component { state.loading = false; return this.setState(state); } - getCrowdsaleData(web3, this, crowdsaleContract, () => { + getCrowdsaleData(web3, this, crowdsaleContract, () => { initializeAccumulativeData(this, () => { getAccumulativeCrowdsaleData(web3, this, () => { }); @@ -160,7 +160,7 @@ export class Invest extends React.Component { return this.setState(state); } console.log(web3) - getCurrentRate(web3, this, crowdsaleContract, () => { + getCurrentRate(web3, this, crowdsaleContract, () => { console.log(web3) this.investToTokensForWhitelistedCrowdsaleInternal(crowdsaleContract, tierNum, web3, accounts); }); @@ -197,24 +197,11 @@ export class Invest extends React.Component { this.setState({ loading: false }); if (!err) { - successfulInvestmentAlert(this.state.tokensToInvest); + successfulInvestmentAlert(this.state.tokensToInvest); } else { toast.showToaster({ type: TOAST.TYPE.ERROR, message: TOAST.MESSAGE.USER_REJECTED_TRANSACTION }) } }); - - /*crowdsaleContract.methods.buy().send(opts, (err, txHash) => { - if (err) { - let state = this.state; - state.loading = false; - this.setState(state); - return console.log(err); - } - - console.log("txHash: " + txHash); - console.log(web3) - checkTxMined(web3, txHash, (receipt) => this.txMinedCallback(web3, txHash, receipt)) - });*/ } txMinedCallback(web3, txHash, receipt) { @@ -248,7 +235,7 @@ export class Invest extends React.Component { renderPieTracker () { return
- {investorBalance} {tokenTicker}

Balance

- Your balance in tokens. + Your balance in tokens.

@@ -385,5 +372,3 @@ export class Invest extends React.Component { } } - - diff --git a/src/components/stepFour/index.js b/src/components/stepFour/index.js index 714aff093..55c1ed0cf 100644 --- a/src/components/stepFour/index.js +++ b/src/components/stepFour/index.js @@ -44,15 +44,15 @@ export class stepFour extends stepTwo { if (!this.state.contracts.safeMathLib) { this.hideLoader(); return noContractDataAlert(); - } + } let state = { ...this.state } state.loading = true; this.setState(state); let abiToken = this.state.contracts && this.state.contracts.token && this.state.contracts.token.abi || [] - + let abiPricingStrategy = this.state.contracts && this.state.contracts.pricingStrategy && this.state.contracts.pricingStrategy.abi || [] - + setTimeout(() => { getWeb3((web3) => { state.web3 = web3; @@ -96,52 +96,7 @@ export class stepFour extends stepTwo { this.setState({ contractDownloaded: true }) toast.showToaster({ message: TOAST.MESSAGE.CONTRACT_DOWNLOAD_SUCCESS, options }) } - - /*testM() { - let state = this.state; - //mainnet - //state.contracts.finalizeAgent.addr[0] = "0x9ee173a3e54014c6b89e5d5e01d06b269315a6e9" - //state.contracts.crowdsale.addr[0] = "0x1c6d46dedd61ef982f0938e73975404b8de6d739" - //state.contracts.pricingStrategy.addr[0] = "0xf188df9b40f5a5598a1d7088021a679312e62d03" - //state.contracts.token.addr = "0x13462c0292f3007ee6d0aaf600dbe1db2ebcf4be" - //testnet - state.contracts.finalizeAgent.addr[0] = "0x24430ab3a5564034b2c878746223f4148cae1471" - state.contracts.crowdsale.addr[0] = "0x050007744327a34a00c472951faebcdea1f8560e" - state.contracts.pricingStrategy.addr[0] = "0x85704d886ba65b233dd589300509e40136a5bd68" - state.contracts.token.addr = "0x12f05ca69f6244bf5aa48eecd3f5c516821a5326" - this.setState(() => { - let web3 = this.state.web3; - let contracts = this.state.contracts; - setLastCrowdsaleRecursive(0, web3, contracts.pricingStrategy.abi, contracts.pricingStrategy.addr, contracts.crowdsale.addr.slice(-1)[0], 42982, (err) => { - if (err) return this.hideLoader(); - setReservedTokensListMultiple(web3, contracts.token.abi, contracts.token.addr, this.state.token, (err) => { - if (err) return this.hideLoader(); - updateJoinedCrowdsalesRecursive(0, web3, contracts.crowdsale.abi, contracts.crowdsale.addr, (err) => { - if (err) return this.hideLoader(); - setMintAgentRecursive(0, web3, contracts.token.abi, contracts.token.addr, contracts.crowdsale.addr, 68425, (err) => { - if (err) return this.hideLoader(); - setMintAgentRecursive(0, web3, contracts.token.abi, contracts.token.addr, contracts.finalizeAgent.addr, 68425, (err) => { - if (err) return this.hideLoader(); - addWhiteListRecursive(0, web3, this.state.crowdsale, this.state.token, contracts.crowdsale.abi, contracts.crowdsale.addr, (err) => { - if (err) return this.hideLoader(); - setFinalizeAgentRecursive(0, web3, contracts.crowdsale.abi, contracts.crowdsale.addr, contracts.finalizeAgent.addr, 68622, (err) => { - if (err) return this.hideLoader(); - setReleaseAgentRecursive(0, web3, contracts.token.abi, contracts.token.addr, contracts.finalizeAgent.addr, 65905, (err) => { - transferOwnership(web3, this.state.contracts.token.abi, contracts.token.addr, this.state.crowdsale[0].walletAddress, 46699, (err) => { - if (err) return this.hideLoader(); - //this.goToCrowdsalePage(); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }*/ - + handleContentByParent(content, docData) { switch(content.parent) { case 'token': @@ -335,7 +290,7 @@ export class stepFour extends stepTwo { let binCrowdsale = contracts && contracts.crowdsale && contracts.crowdsale.bin || '' let abiCrowdsale = contracts && contracts.crowdsale && contracts.crowdsale.abi || [] let crowdsales = this.state.crowdsale; - + this.deployCrowdsaleRecursive(0, crowdsales, binCrowdsale, abiCrowdsale) }); }); @@ -345,10 +300,6 @@ export class stepFour extends stepTwo { deployCrowdsaleRecursive = (i, crowdsales, binCrowdsale, abiCrowdsale) => { let paramsCrowdsale; switch (this.state.contractType) { - //depreciated - /*case this.state.contractTypes.standard: { - paramsCrowdsale = this.getStandardCrowdSaleParams(this.state.web3) - } break;*/ case this.state.contractTypes.whitelistwithcap: { paramsCrowdsale = this.getCrowdSaleParams(this.state.web3, i) } break; @@ -377,9 +328,9 @@ export class stepFour extends stepTwo { return [ this.state.contracts.token.addr, this.state.contracts.pricingStrategy.addr[i], - this.state.crowdsale[0].walletAddress, //this.state.contracts.multisig.addr, - toFixed(parseInt(Date.parse(this.state.crowdsale[i].startTime)/1000, 10).toString()), - toFixed(parseInt(Date.parse(this.state.crowdsale[i].endTime)/1000, 10).toString()), + this.state.crowdsale[0].walletAddress, + toFixed(parseInt(Date.parse(this.state.crowdsale[i].startTime)/1000, 10).toString()), + toFixed(parseInt(Date.parse(this.state.crowdsale[i].endTime)/1000, 10).toString()), toFixed("0"), toFixed(parseInt(this.state.crowdsale[i].supply, 10)*10**parseInt(this.state.token.decimals, 10)).toString(), this.state.crowdsale[i].updatable?this.state.crowdsale[i].updatable=="on"?true:false:false, @@ -393,7 +344,7 @@ export class stepFour extends stepTwo { } let newState = { ...this.state } newState.contracts.crowdsale.addr.push(crowdsaleAddr); - this.setState(newState, this.calculateABIEncodedArgumentsForFinalizeAgentContractDeployment); + this.setState(newState, this.calculateABIEncodedArgumentsForFinalizeAgentContractDeployment); } calculateABIEncodedArgumentsForFinalizeAgentContractDeployment = () => { @@ -430,7 +381,7 @@ export class stepFour extends stepTwo { let binFinalizeAgent = contracts && contracts.finalizeAgent && contracts.finalizeAgent.bin || '' let abiFinalizeAgent = contracts && contracts.finalizeAgent && contracts.finalizeAgent.abi || [] - + let crowdsales; if (this.state.tokenIsAlreadyCreated) { let curTierAddr = [ contracts.crowdsale.addr.slice(-1)[0] ]; @@ -439,7 +390,7 @@ export class stepFour extends stepTwo { } else crowdsales = this.state.contracts.crowdsale.addr; - this.deployFinalizeAgentRecursive(0, crowdsales, this.state.web3, abiNullFinalizeAgent, binNullFinalizeAgent, abiFinalizeAgent, binFinalizeAgent, this.state) + this.deployFinalizeAgentRecursive(0, crowdsales, this.state.web3, abiNullFinalizeAgent, binNullFinalizeAgent, abiFinalizeAgent, binFinalizeAgent, this.state) }) } @@ -514,7 +465,6 @@ export class stepFour extends stepTwo { transferOwnership(web3, this.state.contracts.token.abi, contracts.token.addr, this.state.crowdsale[0].walletAddress, 46699, (err) => { if (err) return this.hideLoader(); this.hideLoader(); - //this.goToCrowdsalePage(); }); }); }); @@ -545,13 +495,7 @@ export class stepFour extends stepTwo { const isValidContract = contracts && contracts.crowdsale && contracts.crowdsale.addr let url; url = crowdsalePage + `?addr=` + contracts.crowdsale.addr[0] - //crowdsale contracts relations are in the blockchain - /*for (let i = 1; i < contracts.crowdsale.addr.length; i++) { - url += `&addr=` + contracts.crowdsale.addr[i] - }*/ url += `&networkID=` + contracts.crowdsale.networkID - //uncomment, if more then one contractType will appear - //url += `&contractType=` + this.state.contractType let newHistory = isValidContract ? url : crowdsalePage if (!this.state.contractDownloaded) { @@ -565,48 +509,48 @@ export class stepFour extends stepTwo { render() { let crowdsaleSetups = []; for (let i = 0; i < this.state.crowdsale.length; i++) { - let capBlock = - let updatableBlock = - + crowdsaleSetups.push(

Crowdsale Setup {this.state.crowdsale[i].tier}

- -
- -
@@ -651,10 +595,10 @@ export class stepFour extends stepTwo {

Global Limits

-
; @@ -707,7 +651,7 @@ export class stepFour extends stepTwo {

Publish

- On this step we provide you artifacts about your token and crowdsale contracts. They are useful to verify contracts source code on Etherscan + On this step we provide you artifacts about your token and crowdsale contracts. They are useful to verify contracts source code on Etherscan

@@ -725,24 +669,24 @@ export class stepFour extends stepTwo {
- -
-
@@ -752,22 +696,22 @@ export class stepFour extends stepTwo {

Crowdsale Setup

- - -
diff --git a/src/components/stepFour/utils.js b/src/components/stepFour/utils.js index 54077dbb0..55914c6b1 100644 --- a/src/components/stepFour/utils.js +++ b/src/components/stepFour/utils.js @@ -194,7 +194,7 @@ export function setReservedTokensListMultiple(web3, abi, addr, token, cb) { let val = token.reservedTokens[i].val let addr = token.reservedTokens[i].addr let obj = map[addr]?map[addr]:{} - if (token.reservedTokens[i].dim === "tokens") + if (token.reservedTokens[i].dim === "tokens") obj.inTokens = val * 10**token.decimals else { obj.inPercentageDecimals = countDecimals(val) @@ -296,7 +296,7 @@ export function setFinalizeAgentRecursive (i, web3, abi, addrs, finalizeAgentAdd } }) } - + export function setReleaseAgentRecursive (i, web3, abi, addr, finalizeAgentAddrs, gasLimit, cb) { setReleaseAgent(web3, abi, addr, finalizeAgentAddrs[i], gasLimit, (err) => { i++; @@ -311,7 +311,7 @@ export function setReleaseAgentRecursive (i, web3, abi, addr, finalizeAgentAddrs export const handleTokenForFile = (content, docData, state) => { const title = content.value const fileContent = title + state.token[content.field] - docData.data += fileContent + '\n\n' + docData.data += fileContent + '\n\n' } export const handleCrowdsaleForFile = (content, docData, state) => { @@ -390,8 +390,8 @@ export const download = (data, filename, type) => { a.click(); setTimeout(function() { document.body.removeChild(a); - window.URL.revokeObjectURL(url); - }, 0); + window.URL.revokeObjectURL(url); + }, 0); } } diff --git a/src/components/stepOne/index.js b/src/components/stepOne/index.js index cdc4d9336..0e4d48c76 100644 --- a/src/components/stepOne/index.js +++ b/src/components/stepOne/index.js @@ -24,10 +24,8 @@ export class stepOne extends React.Component { this.getCrowdsaleAsset("CrowdsaleWhiteListWithCapToken", "token", state) this.getCrowdsaleAsset("CrowdsaleWhiteListWithCapPricingStrategy", "pricingStrategy", state) this.getCrowdsaleAsset("CrowdsaleWhiteListWithCapPricingStrategy", "pricingStrategy", state) - //this.getCrowdsaleAsset("TokenTransferProxy", "tokenTransferProxy", state) - //this.getCrowdsaleAsset("MultiSig", "multisig", state) this.getCrowdsaleAsset("FinalizeAgent", "finalizeAgent", state) - this.getCrowdsaleAsset("NullFinalizeAgent", "nullFinalizeAgent", state) + this.getCrowdsaleAsset("NullFinalizeAgent", "nullFinalizeAgent", state) } getCrowdsaleAsset(contractName, stateProp, state) { @@ -63,7 +61,6 @@ export class stepOne extends React.Component { } addContractsToState (src, bin, abi, contract, state) { - //let newState = Object.assign({}, state) console.log('state', state) state.contracts[contract] = { src, @@ -85,18 +82,6 @@ export class stepOne extends React.Component { componentDidMount() { checkWeb3(this.state.web3); - //emergency alert - /*setTimeout(() => { - getWeb3((web3) => { - getNetworkVersion(web3, (_networkID) => { - console.log(_networkID); - if (_networkID == 1) { - return noDeploymentOnMainnetAlert(); - } - }) - }) - }, 500);*/ - let newState = { ...this.state } newState.contractType = this.state.contractTypes.whitelistwithcap @@ -112,34 +97,21 @@ export class stepOne extends React.Component {

Crowdsale Contract

- Select a strategy for your crowdsale contract. + Select a strategy for your crowdsale contract.

- {/**/}
diff --git a/src/components/stepThree/index.js b/src/components/stepThree/index.js index f128a8199..094a03210 100644 --- a/src/components/stepThree/index.js +++ b/src/components/stepThree/index.js @@ -30,9 +30,7 @@ export class stepThree extends stepTwo { oldState.crowdsale[0].tier = "Tier 1" oldState.crowdsale[0].updatable = "off" oldState.crowdsale[0].whitelistdisabled = "yes" - //this.state = Object.assign({}, oldState, {validations: { ...oldState.validations, startTime: VALID, endTime: VALID, walletAddress: VALID, supply: EMPTY, rate: EMPTY } } ) this.state = Object.assign({}, oldState, intitialStepThreeValidations ) - //console.log('this.state', this.state) } addCrowdsale() { @@ -42,8 +40,8 @@ export class stepThree extends stepTwo { tier: "Tier " + (num + 1), supply: 0, updatable: "off", - whitelist:[], - whiteListElements: [], + whitelist:[], + whiteListElements: [], whiteListInput:{} }); newState.validations.push({ @@ -53,8 +51,6 @@ export class stepThree extends stepTwo { supply: EMPTY, rate: EMPTY }); - //newState.crowdsale[num].startTime = newState.crowdsale[num - 1].endTime; - //newState.crowdsale[num].endTime = defaultCompanyEndDate(newState.crowdsale[num].startTime); newState.pricingStrategy.push({rate: 0}); this.setState(newState, () => this.addCrowdsaleBlock(num)); } @@ -89,12 +85,10 @@ export class stepThree extends stepTwo { return
this.addCrowdsale()} className="button button_fill_secondary"> Add Tier
warningOnMainnetAlert(this.state.crowdsale.length, () => this.gotoDeploymentStage())} className="button button_fill"> Continue
- {/*Continue*/}
} renderLinkComponent () { - //console.log(`stepsAreValid(this.state.validations) || allFieldsAreValid('crowdsale', this.state)`, stepsAreValid(this.state.validations), allFieldsAreValid('crowdsale', this.state)) if(stepsAreValid(this.state.validations) || (allFieldsAreValid('crowdsale', this.state) && allFieldsAreValid('pricingStrategy', this.state))){ return this.renderLink() } @@ -112,15 +106,6 @@ export class stepThree extends stepTwo { checkWeb3(this.state.web3); setTimeout( () => { getWeb3((web3) => { - - //emergency alert - /*getNetworkVersion(web3, (_networkID) => { - console.log(_networkID); - if (_networkID == 1) { - return noDeploymentOnMainnetAlert(); - } - })*/ - web3.eth.getAccounts().then((accounts) => { console.log('timeout state', this.state) let newState = {...this.state} @@ -143,13 +128,13 @@ export class stepThree extends stepTwo {

Global limits

- this.handleInputBlur('token', 'globalmincap')} onChange={(e) => this.changeState(e, 'token', 0, 'globalmincap')} description={`Minimum amount tokens to buy. Not a mininal size of a transaction. If minCap is 1 and user bought 1 token in a previous transaction and buying 0.1 token it will allow him to buy.`} @@ -174,81 +159,81 @@ export class stepThree extends stepTwo {
- this.handleInputBlur('crowdsale', 'tier', 0)} onChange={(e) => this.changeState(e, 'crowdsale', 0, 'tier')} description={`Name of a tier, e.g. PrePreIco, PreICO, ICO with bonus A, ICO with bonus B, etc. We simplified that and will increment a number after each tier.`} /> - this.handleInputBlur('crowdsale', 'walletAddress', 0)} onChange={(e) => this.changeState(e, 'crowdsale', 0, 'walletAddress')} description={`Where the money goes after investors transactions. Immediately after each transaction. We recommend to setup a multisig wallet with hardware based signers.`} />
- this.handleInputBlur('crowdsale', 'startTime', 0)} onChange={(e) => this.changeState(e, 'crowdsale', 0, 'startTime')} description={`Date and time when the tier starts. Can't be in the past from the current moment.`} /> - this.handleInputBlur('crowdsale', 'endTime', 0)} onChange={(e) => this.changeState(e, 'crowdsale', 0, 'endTime')} description={`Date and time when the tier ends. Can be only in the future.`} />
- this.handleInputBlur('pricingStrategy', 'rate', 0)} onChange={(e) => this.changeState(e, 'pricingStrategy', 0, 'rate')} description={`Exchange rate Ethereum to Tokens. If it's 100, then for 1 Ether you can buy 100 tokens`} /> - this.handleInputBlur('crowdsale', 'supply', 0)} onChange={(e) => this.changeState(e, 'crowdsale', 0, 'supply')} description={`How many tokens will be sold on this tier. Cap of crowdsale equals to sum of supply of all tiers`} />
- this.changeState(e, 'crowdsale', 0, 'updatable')} description={`Pandora box feature. If it's enabled, a creator of the crowdsale can modify Start time, End time, Rate, Limit after publishing.`} /> - ) } -} \ No newline at end of file +} diff --git a/src/components/stepThree/utils.js b/src/components/stepThree/utils.js index f2b72d84f..9ecdc44ee 100644 --- a/src/components/stepThree/utils.js +++ b/src/components/stepThree/utils.js @@ -1,11 +1,8 @@ export function defaultCompanyStartDate() { let curDate = new Date(); - /*curDate = curDate.setDate(curDate.getDate() + 1); - curDate = new Date(curDate).setUTCHours(0); - curDate = new Date(curDate).setMinutes(0);*/ curDate = new Date(curDate).setUTCHours(new Date().getHours()); curDate = new Date(curDate).setMinutes(new Date(curDate).getMinutes() + 5); let curDateISO = new Date(curDate).toISOString(); let targetDate = curDateISO.split(".")[0].substring(0, curDateISO.lastIndexOf(":")) return targetDate; -} \ No newline at end of file +} diff --git a/src/components/stepTwo/index.js b/src/components/stepTwo/index.js index 29113e8fe..deb2ac43e 100644 --- a/src/components/stepTwo/index.js +++ b/src/components/stepTwo/index.js @@ -24,18 +24,6 @@ export class stepTwo extends React.Component { componentDidMount() { checkWeb3(this.state.web3); - - //emergency alert - /*setTimeout(() => { - getWeb3((web3) => { - getNetworkVersion(web3, (_networkID) => { - console.log(_networkID); - if (_networkID == 1) { - return noDeploymentOnMainnetAlert(); - } - }) - }) - }, 500);*/ } getNewParent (property, parent, value) { @@ -55,7 +43,7 @@ export class stepTwo extends React.Component { console.log(newState); if (property === "startTime" || property === "endTime") { let targetTime = new Date(value); - let targetTimeTemp = targetTime.setHours(targetTime.getHours() - targetTime.getTimezoneOffset()/60);//.setUTCHours(new Date(targetTime).getHours()); + let targetTimeTemp = targetTime.setHours(targetTime.getHours() - targetTime.getTimezoneOffset()/60); if (property === "startTime") { console.log("property == startTime"); if (targetTimeTemp) @@ -65,7 +53,7 @@ export class stepTwo extends React.Component { } else if (property === "endTime") { if (targetTimeTemp) newState.crowdsale[key].endTime = new Date(targetTimeTemp).toISOString().split(".")[0]; - else + else newState.crowdsale[key].endTime = null if (newState.crowdsale[key + 1]) { newState.crowdsale[key + 1].startTime = newState.crowdsale[key].endTime; @@ -83,9 +71,9 @@ export class stepTwo extends React.Component { newState.token[`reservedTokensInput`][prop] = value } else { if( Object.prototype.toString.call( newState[parent] ) === '[object Array]' ) { - newState[parent][key][property] = value;//this.getNewParent(property, parent, key, value) + newState[parent][key][property] = value; } else { - newState[parent][property] = value;//this.getNewParent(property, parent, key, value) + newState[parent][property] = value; } } if (property.indexOf("whitelist") === -1 && property.indexOf("reservedtokens") === -1) { @@ -95,15 +83,12 @@ export class stepTwo extends React.Component { } else { newState[`validations`][property] = validateValue(value, property, newState) } - //console.log('property', property) - //console.log('newState[`validations`][property]', newState[`validations`], validateValue(value, property, newState), 'newState', newState) } console.log('newState', newState) this.setState(newState) } handleInputBlur (parent, property, key) { - //console.log(parent, property, key); let newState = { ...this.state } let value if (property === 'rate') { @@ -127,11 +112,9 @@ export class stepTwo extends React.Component { renderLink () { return Continue } - + validateAllFields (parent ) { let newState = { ...this.state } - //let properties = Object.keys(newState[parent]) - //let values = Object.values(newState[parent]) let properties = [] let values = [] @@ -151,9 +134,6 @@ export class stepTwo extends React.Component { values = Object.values(newState[parent]) } - //console.log(properties); - //console.log(values); - properties.forEach((property, index) => { if ( Object.prototype.toString.call( newState[`validations`] ) === '[object Array]' ) { newState[`validations`][inds[index]][property] = validateValue(values[index], property) @@ -165,7 +145,6 @@ export class stepTwo extends React.Component { } renderLinkComponent () { - // console.log(`stepsAreValid(this.state.validations) || allFieldsAreValid('token', this.state)`, stepsAreValid(this.state.validations), allFieldsAreValid('token', this.state)) if(stepsAreValid(this.state.validations) || allFieldsAreValid('token', this.state)){ return this.renderLink() } @@ -183,35 +162,35 @@ export class stepTwo extends React.Component {

Token setup

- Configure properties of your token. Created token contract will be ERC-20 compatible. + Configure properties of your token. Created token contract will be ERC-20 compatible.

- this.handleInputBlur('token', 'name')} onChange={(e) => this.changeState(e, 'token', 0, 'name')} description={`The name of your token. Will be used by Etherscan and other token browsers. Be afraid of trademarks.`} /> - this.handleInputBlur('token', 'ticker')} onChange={(e) => this.changeState(e, 'token', 0, 'ticker')} description={`The three letter ticker for your token. There are 17,576 combinations for 26 english letters. Be hurry. `} /> - this.handleInputBlur('token', 'decimals')} onChange={(e) => this.changeState(e, 'token', 0, 'decimals')} description={`Refers to how divisible a token can be, from 0 (not at all divisible) to 18 (pretty much continuous).`} @@ -230,4 +209,4 @@ export class stepTwo extends React.Component {
)} -} \ No newline at end of file +} diff --git a/src/utils/blockchainHelpers.js b/src/utils/blockchainHelpers.js index df7f3ec56..43f8b90de 100644 --- a/src/utils/blockchainHelpers.js +++ b/src/utils/blockchainHelpers.js @@ -49,9 +49,7 @@ export function getWeb3(cb) { // web3, just wrap it in your Web3. var myWeb3 = new Web3(web3.currentProvider); - //checkNetworkVersion(myWeb3, function(isOraclesNetwork) { cb(myWeb3, false); - //}); } return myWeb3; } @@ -146,7 +144,7 @@ export function deployContract(i, web3, abi, bin, params, state, cb) { let binFull = bin + ABIencoded.substr(2); web3.eth.getAccounts().then(function(accounts) { web3.eth.estimateGas({ - from: accounts[0], + from: accounts[0], data: binFull }, function(err, estimatedGas) { if (err) console.log('errrrrrrrrrrrrrrrrr', err); @@ -172,12 +170,11 @@ export function deployContract(i, web3, abi, bin, params, state, cb) { let isMined = false; contractInstance.deploy(deployOpts).send(sendOpts) - //contractInstance.new(...totalParams) - .on('error', function(error) { + .on('error', function(error) { console.log(error); - return cb(error, null); + return cb(error, null); }) - .on('transactionHash', function(transactionHash){ + .on('transactionHash', function(transactionHash){ console.log("contract deployment transaction: " + transactionHash); checkTxMined(web3, transactionHash, function txMinedCallback(receipt) { @@ -203,20 +200,7 @@ export function deployContract(i, web3, abi, bin, params, state, cb) { } }) }) - /*.on('receipt', function(receipt){ - if (errorArised) { - console.log(receipt.contractAddress) // contains the new contract address - cb(null, receipt.contractAddress); - } - })*/ - .on('confirmation', function(confirmationNumber, receipt){ - //console.log(confirmationNumber, receipt); - /*if (errorArised) { - console.log(receipt.contractAddress) // contains the new contract address - cb(null, receipt.contractAddress); - }*/ - - }) + .on('confirmation', function(confirmationNumber, receipt) { }) .then(function(newContractInstance){ if (!isMined) { console.log("Contract deployment is mined from Promise"); @@ -233,12 +217,11 @@ export function deployContract(i, web3, abi, bin, params, state, cb) { export function sendTXToContract(web3, method, cb) { let isMined = false; method - //contractInstance.new(...totalParams) - .on('error', function(error) { + .on('error', function(error) { console.log(error); - return cb(error); + return cb(error); }) - .on('transactionHash', function(transactionHash){ + .on('transactionHash', function(transactionHash){ console.log("contract method transaction: " + transactionHash); checkTxMined(web3, transactionHash, function txMinedCallback(receipt) { @@ -264,9 +247,7 @@ export function sendTXToContract(web3, method, cb) { } }) }) - /*.on('receipt', function(receipt){ - })*/ - .on('confirmation', function(confirmationNumber, receipt){ + .on('confirmation', function(confirmationNumber, receipt){ }) .then(function(result){ if (!isMined) { @@ -290,14 +271,11 @@ export function attachToContract(web3, abi, addr, cb) { web3.eth.getAccounts().then((accounts) => { web3.eth.defaultAccount = accounts[0]; console.log("web3.eth.defaultAccount:" + web3.eth.defaultAccount); - + let contractInstance = new web3.eth.Contract(abi, addr, { from: web3.eth.defaultAccount }); - //console.log(contractInstance); - //console.log(contractInstance.options); - if (cb) cb(null, contractInstance); }); } diff --git a/src/utils/microservices.js b/src/utils/microservices.js index cf007dd04..7bdf043ea 100644 --- a/src/utils/microservices.js +++ b/src/utils/microservices.js @@ -1,7 +1,6 @@ import { findConstructor, getconstructorParams, toFixed } from '../utils/utils' export function getEncodedABIClientSide(web3, abi, state, vals, crowdsaleNum, cb) { - //console.log(web3, abi, state, vals, crowdsaleNum); const abiConstructor = findConstructor(abi, state) let params = getconstructorParams(abiConstructor, state, vals, crowdsaleNum); @@ -31,4 +30,4 @@ function getABIencoded(web3, types, vals, cb) { let ABIencodedRaw = encoded.toString("hex") let ABIencoded = ABIencodedRaw.indexOf("0x") > -1 ? ABIencodedRaw.substr(2) : ABIencodedRaw cb(ABIencoded); -} \ No newline at end of file +} diff --git a/src/utils/utils.js b/src/utils/utils.js index 55e308b60..09915b9d2 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -33,7 +33,7 @@ export function getURLParam(key,target){ } if (!values.length) { - return null; + return null; } else { return values.length == 1 ? values[0] : values; } @@ -106,40 +106,6 @@ export function getWhiteListWithCapCrowdsaleAssets(state, cb) { cb(state); } }); - /*const tokenTransferProxyContractName = "TokenTransferProxy"; - setFlatFileContentToState("./contracts/" + tokenTransferProxyContractName + "_flat.bin", function(_bin) { - derivativesIterator++; - state.contracts.tokenTransferProxy.bin = _bin; - - if (derivativesIterator === derivativesLength) { - cb(state); - } - }); - setFlatFileContentToState("./contracts/" + tokenTransferProxyContractName + "_flat.abi", function(_abi) { - derivativesIterator++; - state.contracts.tokenTransferProxy.abi = JSON.parse(_abi); - - if (derivativesIterator === derivativesLength) { - cb(state); - } - }); - const multisigContractName = "MultiSig"; - setFlatFileContentToState("./contracts/" + multisigContractName + "_flat.bin", function(_bin) { - derivativesIterator++; - state.contracts.multisig.bin = _bin; - - if (derivativesIterator === derivativesLength) { - cb(state); - } - }); - setFlatFileContentToState("./contracts/" + multisigContractName + "_flat.abi", function(_abi) { - derivativesIterator++; - state.contracts.multisig.abi = JSON.parse(_abi); - - if (derivativesIterator === derivativesLength) { - cb(state); - } - });*/ const finalizeAgentContractName = "FinalizeAgent"; setFlatFileContentToState("./contracts/" + finalizeAgentContractName + "_flat.bin", function(_bin) { derivativesIterator++; @@ -206,7 +172,6 @@ export const findConstructor = (abi) => { } export const getconstructorParams = (abiConstructor, state, vals, crowdsaleNum) => { - //console.log(abiConstructor, state, vals, crowdsaleNum); let params = {"types": [], "vals": []}; if (!abiConstructor) return params; for (let j = 0; j < abiConstructor.length; j++) { @@ -279,9 +244,6 @@ export const getconstructorParams = (abiConstructor, state, vals, crowdsaleNum) params.vals.push(1) } break; case "_oneTokenInWei": { - //params.vals.push(state.pricingStrategy[crowdsaleNum].rate); - //params.vals.push(state.web3.toWei(1/state.pricingStrategy[crowdsaleNum].rate/10**state.token.decimals, "ether")); - let oneTokenInETHRaw = toFixed(1/state.pricingStrategy[crowdsaleNum].rate).toString() let oneTokenInETH = floorToDecimals(TRUNC_TO_DECIMALS.DECIMALS18, oneTokenInETHRaw) params.vals.push(state.web3.utils.toWei(oneTokenInETH, "ether")); @@ -341,7 +303,7 @@ const validateDecimals = (decimals) => isNaN(Number(decimals)) === false && deci const validateTicker = (ticker) => typeof ticker === 'string' && ticker.length < 4 && ticker.length > 0 -const validateTime = (time) => getTimeAsNumber(time) > Date.now() +const validateTime = (time) => getTimeAsNumber(time) > Date.now() const validateRate = (rate) => isNaN(Number(rate)) === false && Number(rate) > 0 @@ -370,13 +332,10 @@ const isNotWhiteListTierObject = (value) => !(typeof value === 'object' && value // still thinks that we do not have an array... we do export const validateValue = (value, property) => { - //console.log("'" + property + "'"); - //console.log("'" + value + "'"); if (!isNaN(property) || property === 'reservedTokensInput' || property === 'reservedTokens' || property === 'reservedTokensElements') return VALID; - //console.log('value of : ' + value + ' and property of : ' + property, Array.isArray(value), JSON.stringify(value)) let validationFunction, valueIsValid; if(isNotWhiteListTierObject(value)) { validationFunction = inputFieldValidators[property] @@ -387,7 +346,6 @@ export const validateValue = (value, property) => { if (validationFunction) valueIsValid = validationFunction(value[property]) } - //console.log("valueIsValid: " + valueIsValid); return valueIsValid === true ? VALID : INVALID } @@ -409,15 +367,12 @@ export const allFieldsAreValid = (parent, state) => { } else { properties = Object.keys(newState[parent]) } - //console.log(newState); - //console.log(properties); - //console.log(properties.filter(property => property !== 'startBlock' && property !== 'endBlock' && property !== 'updatable' && property.toLowerCase().indexOf("whitelist") == -1 )); let iterator = 0 - let validationValues = properties/*.filter(property => property !== 'startBlock' && property !== 'endBlock' && property !== 'updatable' && property.toLowerCase().indexOf("whitelist") == -1 )*/.map(property => { + let validationValues = properties.map(property => { if (property === 'startBlock' || property === 'endBlock' || property === 'updatable' || property.toLowerCase().indexOf("whitelist") > -1) { iterator++ return VALID - } + } let value if( Object.prototype.toString.call( newState[parent] ) === '[object Array]' ) { if (newState[parent].length > 0) @@ -425,14 +380,11 @@ export const allFieldsAreValid = (parent, state) => { } else { value = newState[parent][property] } - //console.log("value: " + value, "property: " + property, "iterator: " + iterator); iterator++ if (parent == "token" && property == "supply") return VALID return validateValue(value, property) }) - //console.log(validationValues); - //console.log(values); - + return validationValues.find(value => value === INVALID) === undefined }