Skip to content

Commit

Permalink
Merge pull request #348 from oraclesorg/master
Browse files Browse the repository at this point in the history
(Sync) bridge <- master
  • Loading branch information
vbaranov authored Nov 7, 2017
2 parents 1d3353f + 8cb6bd2 commit f3f58ae
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ install:
- npm install

after-script:
- sudo kill `sudo lsof -t -i:8545`
- sudo kill `sudo lsof -t -i:8545`
55 changes: 29 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
![ICO Wizard DApp](https://forum.oracles.org//uploads/default/original/1X/0883f34b870fac19914d7b5e43e4f815dbe5c267.png)
![ICO Wizard DApp](https://forum.oracles.org/uploads/default/original/1X/4defd4c248825a9216a247ab3c5cb1f613d7e5ef.png)

# ICO Wizard DApp

[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE)
[![Build Status](https://travis-ci.org/oraclesorg/ico-wizard.svg?branch=master)](https://travis-ci.org/oraclesorg/ico-wizard)
[![Waffle.io - Columns and their card count](https://badge.waffle.io/oraclesorg/ico-wizard.svg?columns=all)](http://waffle.io/oraclesorg/ico-wizard)
[![Join the chat at https://gitter.im/oraclesorg/ico-wizard](https://badges.gitter.im/oraclesorg/ico-wizard.svg)](https://gitter.im/oraclesorg/ico-wizard?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

_Attention_!

Expand All @@ -18,7 +20,6 @@ Please, read instruction before you'll start to create crowdsales using ICO Wiza
+ [Run local version for development](#run-local-version-for-development)
+ [ICO configuration](#ico-configuration)
+ [Tests](#tests)
+ [Investment with transaction from MetaMask](#investment-with-transaction-from-metamask)
* [Deploying of crowdsale to Mainnet](#deploying-of-crowdsale-to-mainnet)
+ [Time](#time)
+ [Price](#price)
Expand All @@ -29,7 +30,6 @@ Please, read instruction before you'll start to create crowdsales using ICO Wiza
* [Support](#support)
* [Notable Contributors](#notable-contributors)
* [Disclaimer](#disclaimer)
* [Bridge testing](#bridge-testing)


## Introduction
Expand Down Expand Up @@ -156,14 +156,14 @@ Test scripts are added to Travis CI and executed at every pull request.
If you want to start it by yourself, simply run the command `npm test` from the root directory.
It will start testrpc at port 8545, Truffle will compile, deploy contracts to it and Truffle will execute tests.

*Note:* Kill testrpc after tests will executed:
*Note:* Kill testrpc after tests will be executed:
```
sudo kill `sudo lsof -t -i:8545`.
```

Currently available tests cover the following scenario:
Currently, available tests cover the following scenario:

The updatable, whitelisted one tier crowdsale contract with one address in white list and reserved tokens for the same address (both: in absolute values and in percentage)
The updatable, whitelisted one tier crowdsale contract with one address in whitelist and reserved tokens for the same address (both: in absolute values and in percentage)

Checklist of contracts' testing:

Expand Down Expand Up @@ -220,50 +220,49 @@ Contract: CrowdsaleTokenExt

The one-tier crowdsale contract takes ~24 minutes in total.

Estimates for each contracts:
Estimates for each contract:


SafeMathLib : 02:00
* SafeMathLib : 02:00

Token: 04:15
* Token: 04:15

Pricing strategy: 01:32
* Pricing strategy: 01:32

Crowdsale: 04:52
* Crowdsale: 04:52

Finalize agent: 01:52
* Finalize agent: 01:52


Estimates for each methods invocation:

* setLastCrowdsale for Pricing Strategy: 00:58

setLastCrowdsale for Pricing Strategy: 00:58
* updateJoinedCrowdsales: 02:00

updateJoinedCrowdsales: 02:00
* setMintAgent: 01:30

setMintAgent: 01:30
* setMintAgent: 02:10

setMintAgent: 02:10
* setFinalizeAgent: 01:20

setFinalizeAgent: 01:20
* setReleaseAgent: 00:53

setReleaseAgent: 00:53

transferOwnership: 00:40
* transferOwnership: 00:40

### Price

Attention!

Deploying to the Mainnet is expensive. For a contract with one tier the price is 0.16 ETH.
Deploying to the Mainnet is expensive. For a contract with one tier, the price is 0.16 ETH.

With the price of 1 ETH of $300.0 USD the price of one deployment will be $48.0 USD.
With the price of 1 ETH of $300.0 USD, the price of one deployment will be $48.0 USD.



## How to verify ICO Wizard contracts in Etherscan

**Important!:** All information required for verification of ICO Wizard contracts located in a text file. You must download it on the Step 4 of ICO Wizard. There is **no** way to get it later and you'll need to repeat wizard for the new set of conracts to get the file.
**Important!:** All information required for verification of ICO Wizard contracts located in a text file. You must download it on Step 4 of ICO Wizard. There is **no** way to get it later and you'll need to repeat wizard for the new set of contracts to get the file.

### Crowdsale contract verification:

Expand All @@ -282,7 +281,7 @@ With the price of 1 ETH of $300.0 USD the price of one deployment will be $48.0

2.6. **Constructor Arguments ABI-encoded (For contracts that accept constructor parameters)** is *Crowdsale contract ABI encoded constructor arguments for [Tier name]*

3. For **Contract Library Address (For contracts that use libraries, supports up to 5 libraries)** By default we use only one library.
3. For **Contract Library Address (For contracts that use libraries, supports up to 5 libraries)** By default, we use only one library.

**Library_1 Name** type `:` and then the value of *SafeMathlLib library name* header from the file. Default value: `:SafeMathLibExt`.

Expand All @@ -309,12 +308,16 @@ We created ICO Wizard for a crowdsale of [Oracles Network](https://oracles.org/)

## Contributors guide

Issues which are looking for a handsome contributors are marked as _LookingForContributor_ label in [Issues](https://github.com/oraclesorg/ico-wizard/issues?q=is%3Aissue+is%3Aopen+label%3ALookingForContributor) section of the GitHub
Issues which are looking for a handsome contributors are marked as _LookingForContributor_ label in [Issues](https://github.com/oraclesorg/ico-wizard/issues?q=is%3Aissue+is%3Aopen+label%3ALookingForContributor) section of the GitHub.

Take a look at our [PR Policy](https://github.com/oraclesorg/ico-wizard/wiki/Pull-Request-Policy).

## Support

You can get support on [Telegram](https://t.me/oraclesnetwork).

Need more info? [Go Wiki](https://github.com/oraclesorg/ico-wizard/wiki).

## Notable Contributors

Brought to you by [Oracles Network](https://oracles.org/team) team.
Expand Down Expand Up @@ -418,4 +421,4 @@ ABI of the right-side contract is [here](https://github.com/oraclesorg/parity-br

8. Invest in the crowdsale page.

9. After ~10 - 20 seconds (for Oracles network) check at Kovan: https://kovan.etherscan.io/address/[verified_right-side_bridge_contract_address]#readContract `balances` for the same address that invest at ICO Wizard.
9. After ~10 - 20 seconds (for Oracles network) check at Kovan: https://kovan.etherscan.io/address/[verified_right-side_bridge_contract_address]#readContract `balances` for the same address that invest at ICO Wizard.
Binary file added docs/MyEtherWalletAttachToContract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/MyEtherWalletChooseNetwork.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/MyEtherWalletConnectToMetaMask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/MyEtherWalletGenerateTransactionBasic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/MyEtherWalletGenerateTransactionBuy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/MyEtherWalletSelectFunction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"oracles-combine-solidity": "file:submodules/oracles-combine-solidity",
"path": "^0.12.7",
"react": "^15.6.1",
"react-alert": "^2.4.0",
"react-countdown-clock": "^2.0.0",
"react-dom": "^15.6.1",
"react-router-dom": "^4.1.2",
Expand Down
4 changes: 4 additions & 0 deletions src/components/invest/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const alertOptions = {
offset: '80px 14',
position: 'top right'
};
34 changes: 26 additions & 8 deletions src/components/invest/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react'
import ReactCountdownClock from 'react-countdown-clock'
import AlertContainer from 'react-alert'
import { getWeb3, checkTxMined, attachToContract, checkNetWorkByID, sendTXToContract } from '../../utils/blockchainHelpers'
import { getCrowdsaleData, getCurrentRate, initializeAccumulativeData, getAccumulativeCrowdsaleData, getCrowdsaleTargetDates, findCurrentContractRecursively, getJoinedTiers } from '../crowdsale/utils'
import { getQueryVariable, getURLParam, getWhiteListWithCapCrowdsaleAssets } from '../../utils/utils'
import { noMetaMaskAlert, noContractAlert, investmentDisabledAlert, investmentDisabledAlertInTime, successfulInvestmentAlert, invalidCrowdsaleAddrAlert } from '../../utils/alerts'
import { Loader } from '../Common/Loader'
import { ICOConfig } from '../Common/config'
import { defaultState, GAS_PRICE } from '../../utils/constants'
import { alertOptions } from './constants'

export class Invest extends React.Component {
constructor(props) {
Expand All @@ -18,6 +20,7 @@ export class Invest extends React.Component {
var state = defaultState;
state.seconds = 0;
state.loading = true;
state.pristineTokenInput = true;
this.state = state;
}

Expand Down Expand Up @@ -115,7 +118,7 @@ export class Invest extends React.Component {
event.preventDefault();

if (!this.isValidToken(this.state.tokensToInvest)) {
this.pristineTokenInput = false;
this.setState({ pristineTokenInput: false });
return;
}

Expand Down Expand Up @@ -192,11 +195,17 @@ export class Invest extends React.Component {
gasPrice: GAS_PRICE
};
console.log(opts);
sendTXToContract(web3, crowdsaleContract.methods.buy().send(opts), (err) => {
let state = this.state;
state.loading = false;
this.setState(state);
successfulInvestmentAlert(this.state.tokensToInvest);

sendTXToContract(web3, crowdsaleContract.methods.buy().send(opts), err => {
this.setState({ loading: false });

if (!err) {
successfulInvestmentAlert(this.state.tokensToInvest);
} else {
const type = 'error';
const message = 'User Rejected Transaction';
this.showToaster({type, message});
}
});

/*crowdsaleContract.methods.buy().send(opts, (err, txHash) => {
Expand Down Expand Up @@ -231,7 +240,7 @@ export class Invest extends React.Component {
}

tokensToInvestOnChange(event) {
this.pristineTokenInput = false;
this.setState({ pristineTokenInput: false });

let state = this.state;
state["tokensToInvest"] = event.target.value;
Expand Down Expand Up @@ -273,6 +282,14 @@ export class Invest extends React.Component {
return { days, hours, minutes}
}

showToaster = ({type = 'info', message = ''}) => {
if (!message) {
return
}

this.msg[type](message);
}

render(state){
const { seconds } = this.state
const { days, hours, minutes } = this.getTimeStamps(seconds)
Expand All @@ -296,7 +313,7 @@ export class Invest extends React.Component {
const totalSupply = (this.state.contractType === this.state.contractTypes.whitelistwithcap)?tierCap:standardCrowdsaleSupply;

let invalidTokenDescription = null;
if (!this.pristineTokenInput && !this.isValidToken(this.state.tokensToInvest)) {
if (!this.state.pristineTokenInput && !this.isValidToken(this.state.tokensToInvest)) {
invalidTokenDescription = <p className="error">Number of tokens to buy should be positive</p>;
}

Expand Down Expand Up @@ -378,6 +395,7 @@ export class Invest extends React.Component {
</div>
</div>
<Loader show={this.state.loading}></Loader>
<AlertContainer ref={a => this.msg = a} {...alertOptions} />
</div>
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/stepFour/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const alertOptions = { time: 10000, position: 'top right' }
export const fileDownloadedToasterMsg = "A file with contracts and metadata downloaded on your computer"
15 changes: 14 additions & 1 deletion src/components/stepFour/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { DisplayTextArea } from '../Common/DisplayTextArea'
import { Loader } from '../Common/Loader'
import { NAVIGATION_STEPS, TRUNC_TO_DECIMALS } from '../../utils/constants'
import { copy } from '../../utils/copy';
import AlertContainer from 'react-alert'
import { alertOptions, fileDownloadedToasterMsg } from './constants'
const { PUBLISH } = NAVIGATION_STEPS

export class stepFour extends stepTwo {
Expand Down Expand Up @@ -479,7 +481,6 @@ export class stepFour extends stepTwo {
let web3 = this.state.web3;
let contracts = this.state.contracts;
console.log(contracts);
this.downloadCrowdsaleInfo();

this.setState(() => {
setLastCrowdsaleRecursive(0, web3, contracts.pricingStrategy.abi, contracts.pricingStrategy.addr, contracts.crowdsale.addr.slice(-1)[0], 142982, (err) => {
Expand All @@ -500,6 +501,9 @@ 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.downloadCrowdsaleInfo();
this.showToaster({ message: fileDownloadedToasterMsg })
//this.goToCrowdsalePage();
});
});
Expand Down Expand Up @@ -537,6 +541,14 @@ export class stepFour extends stepTwo {
this.props.history.push(newHistory);
}

showToaster = ({type = 'info', message = ''}) => {
if (!message) {
return
}

this.msg[type](message);
}

render() {
let crowdsaleSetups = [];
for (let i = 0; i < this.state.crowdsale.length; i++) {
Expand Down Expand Up @@ -770,6 +782,7 @@ export class stepFour extends stepTwo {
<a onClick={this.goToCrowdsalePage} className="button button_fill">Continue</a>
</div>
<Loader show={this.state.loading}></Loader>
<AlertContainer ref={a => this.msg = a} {...alertOptions} />
</section>
)}
}
2 changes: 1 addition & 1 deletion src/components/stepFour/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function setReservedTokensListMultiple(web3, abi, addr, token, cb) {
console.log("inPercentageDecimals: " + inPercentageDecimals)

let method = tokenContract.methods.setReservedTokensListMultiple(addrs, inTokens, inPercentageUnit, inPercentageDecimals).send({gasPrice: GAS_PRICE})
sendTXToContract(web3, method, cb);
sendTXToContract(web3, method, cb)
});
}

Expand Down
7 changes: 6 additions & 1 deletion src/utils/blockchainHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ export function getWeb3(cb) {
if (typeof web3 === 'undefined') {
// no web3, use fallback
console.error("Please use a web3 browser");
const devEnvironment = process.env.NODE_ENV === 'development';
if (devEnvironment) {
web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
}

cb(web3, false);
} else {
// window.web3 == web3 most of the time. Don't override the provided,
// web3, just wrap it in your Web3.
var myWeb3 = new Web3(web3.currentProvider);
var myWeb3 = new Web3(web3.currentProvider);

//checkNetworkVersion(myWeb3, function(isOraclesNetwork) {
cb(myWeb3, false);
Expand Down
6 changes: 3 additions & 3 deletions src/utils/microservices.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function getABIencoded(web3, types, vals, cb) {
console.log(vals);

let encoded = web3.eth.abi.encodeParameters(types, vals);
let outputRaw = encoded.toString("hex")
let output = outputRaw.indexOf("0x") > -1?outputRaw.substr(2):outputRaw
cb(output);
let ABIencodedRaw = encoded.toString("hex")
let ABIencoded = ABIencodedRaw.indexOf("0x") > -1 ? ABIencodedRaw.substr(2) : ABIencodedRaw
cb(ABIencoded);
}

0 comments on commit f3f58ae

Please sign in to comment.