fix merge mobx with old changes and render ***BUGS STILL HERE***
|
@ -4,3 +4,7 @@
|
|||
[submodule "submodules/oracles-combine-solidity"]
|
||||
path = submodules/oracles-combine-solidity
|
||||
url = https://github.com/oraclesorg/oracles-combine-solidity
|
||||
[submodule "submodules/oracles-web3-1.0"]
|
||||
path = submodules/oracles-web3-1.0
|
||||
url = https://github.com/oraclesorg/web3.js
|
||||
branch = 1.0
|
||||
|
|
78
README.md
|
@ -18,8 +18,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)
|
||||
+ [Change maxCap for tier from MetaMask](#change-maxcap-for-tier-from-metamask)
|
||||
* [Deploying of crowdsale to Mainnet](#deploying-of-crowdsale-to-mainnet)
|
||||
+ [Time](#time)
|
||||
+ [Price](#price)
|
||||
|
@ -83,6 +81,34 @@ Open [https://wizard.oracles.org](https://wizard.oracles.org) and follow steps.
|
|||
|
||||
For dev purposes you can build and run ICO Wizard on your machine.
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
Nodejs >= v.6.11.4
|
||||
|
||||
##### For Windows users:
|
||||
|
||||
```
|
||||
npm install --global --production windows-build-tools
|
||||
npm install --global node-gyp
|
||||
```
|
||||
|
||||
restart CMD and run it `As Administrator`
|
||||
|
||||
#### Getting started
|
||||
|
||||
For Windows:
|
||||
|
||||
```
|
||||
git clone https://github.com/oraclesorg/ico-wizard.git wiz
|
||||
cd wiz
|
||||
git submodule update --init --recursive --remote
|
||||
npm install
|
||||
npm run startWin
|
||||
```
|
||||
|
||||
|
||||
Others (macOS, Linux):
|
||||
|
||||
```
|
||||
git clone https://github.com/oraclesorg/ico-wizard.git wiz
|
||||
cd wiz
|
||||
|
@ -128,14 +154,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:
|
||||
|
||||
|
@ -185,36 +211,6 @@ Contract: CrowdsaleTokenExt
|
|||
36 passing (4s)
|
||||
```
|
||||
|
||||
### Investment with transaction from MetaMask
|
||||
|
||||
1. Open MetaMask Chrome plugin
|
||||
|
||||
2. Connect to the network, where the crowdsale contract is deployed. For example `mainnet`.
|
||||
|
||||
3. Choose an account with sufficient balance at this network.
|
||||
|
||||
4. Send transaction to the address of the crowdsale contract with the data `0xa6f2ae3a`. Value to send is in ETH. For example, if you put 0.01 to input, you will invest 0.01 ETH.
|
||||
|
||||

|
||||
|
||||
### Change maxCap for tier from MetaMask
|
||||
|
||||
1. Open MetaMask Chrome plugin
|
||||
|
||||
2. Connect to the network, where the crowdsale contract is deployed. For example `mainnet`.
|
||||
|
||||
3. Choose an account, which is the owner of crowdsale. This account should has sufficient balance at this network too.
|
||||
|
||||
4. Send transaction to the address of the crowdsale contract with the data = `0x2c2de40a` + `hex(n*10**decimals)`.
|
||||
|
||||
where `n` - maxCap of the tier,
|
||||
|
||||
`decimals` - token decimals
|
||||
|
||||
`hex(x)` - hexademical representation of `x`, normalized to 32 bytes (required number of zeros before hex).
|
||||
|
||||
For example, if you need to set `maxCap = 1000` for tier of crowdsale joined with token of 18 `decimals` the data should be: `0x2c2de40a00000000000000000000000000000000000000000000003635c9adc5dea00000`. Amount to send should be 0.
|
||||
|
||||
## Deploying of crowdsale to Mainnet
|
||||
|
||||
|
||||
|
@ -222,7 +218,7 @@ For example, if you need to set `maxCap = 1000` for tier of crowdsale joined wit
|
|||
|
||||
The one-tier crowdsale contract takes ~24 minutes in total.
|
||||
|
||||
Estimates for each contracts:
|
||||
Estimates for each contract:
|
||||
|
||||
|
||||
SafeMathLib : 02:00
|
||||
|
@ -257,15 +253,15 @@ transferOwnership: 00:40
|
|||
|
||||
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:
|
||||
|
||||
|
@ -284,7 +280,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`.
|
||||
|
||||
|
@ -333,4 +329,4 @@ ICO Wizard is constantly under active development. The “Beta” labelling impl
|
|||
|
||||
- lost of tokens/funds from incorrect configuration;
|
||||
- unexpected delays;
|
||||
- unexpected visual artifacts.
|
||||
- unexpected visual artifacts.
|
||||
|
|
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 44 KiB |
59
package.json
|
@ -1,13 +1,9 @@
|
|||
{
|
||||
"name": "oracles",
|
||||
"name": "ico_wizard",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||
"babel-preset-env": "^1.6.0",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"babel-preset-stage-1": "^6.24.1",
|
||||
"ethereumjs-testrpc": "^4.1.3",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-add-src": "^0.2.0",
|
||||
"gulp-autoprefixer": "^3.1.1",
|
||||
|
@ -20,7 +16,9 @@
|
|||
"gulp-sass-glob": "^1.0.6",
|
||||
"gulp-uglify": "^2.0.0",
|
||||
"gulp-uglifycss": "^1.0.6",
|
||||
"gulp-util": "^3.0.8"
|
||||
"gulp-util": "^3.0.8",
|
||||
"markdown-toc": "^1.2.0",
|
||||
"truffle": "^3.4.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"autoprefixer": "7.1.1",
|
||||
|
@ -28,7 +26,11 @@
|
|||
"babel-eslint": "7.2.3",
|
||||
"babel-jest": "20.0.3",
|
||||
"babel-loader": "7.0.0",
|
||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"babel-preset-react-app": "^3.0.1",
|
||||
"babel-preset-stage-1": "^6.24.1",
|
||||
"babel-preset-stage-2": "^6.24.1",
|
||||
"babel-runtime": "6.23.0",
|
||||
"case-sensitive-paths-webpack-plugin": "2.1.1",
|
||||
"chalk": "1.1.3",
|
||||
|
@ -42,8 +44,6 @@
|
|||
"eslint-plugin-import": "2.2.0",
|
||||
"eslint-plugin-jsx-a11y": "5.0.3",
|
||||
"eslint-plugin-react": "7.1.0",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
"ethereumjs-testrpc": "^4.1.3",
|
||||
"extract-text-webpack-plugin": "2.1.2",
|
||||
"file-loader": "0.11.2",
|
||||
"fs-extra": "3.0.1",
|
||||
|
@ -51,8 +51,6 @@
|
|||
"install": "^0.10.1",
|
||||
"jest": "20.0.4",
|
||||
"jquery": "^3.2.1",
|
||||
"jspdf": "^1.3.3",
|
||||
"markdown-toc": "^1.2.0",
|
||||
"mobx": "^3.3.0",
|
||||
"mobx-react": "^4.3.3",
|
||||
"npm": "^5.3.0",
|
||||
|
@ -68,19 +66,16 @@
|
|||
"react-dom": "^15.6.1",
|
||||
"react-error-overlay": "^1.0.9",
|
||||
"react-router-dom": "^4.1.2",
|
||||
"replaceall": "^0.1.6",
|
||||
"solc": "^0.4.14",
|
||||
"style-loader": "0.18.2",
|
||||
"sw-precache-webpack-plugin": "0.11.3",
|
||||
"sweetalert": "^1.1.3",
|
||||
"truffle": "^3.4.9",
|
||||
"url-loader": "0.5.9",
|
||||
"web3": "^0.19.1",
|
||||
"web3": "file:submodules/oracles-web3-1.0/packages/web3",
|
||||
"webpack": "2.6.1",
|
||||
"webpack-dev-server": "2.5.0",
|
||||
"webpack-manifest-plugin": "1.1.0",
|
||||
"whatwg-fetch": "2.0.3",
|
||||
"zeppelin-solidity": "^1.2.0"
|
||||
"whatwg-fetch": "2.0.3"
|
||||
},
|
||||
"config": {
|
||||
"contract_folder": "./public/contracts",
|
||||
|
@ -88,26 +83,18 @@
|
|||
"extension_path": "./scripts/OraclesExtendedCrowdSale.sol",
|
||||
"zeppelin_path": "node_modules/zeppelin-solidity/contracts/crowdsale/",
|
||||
"tokenmarketnet_path": "submodules/oracles-token-market-net-ico/contracts/",
|
||||
"token_transfer_proxy_contract_name": "TokenTransferProxy",
|
||||
"multisig_contract_name": "MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress",
|
||||
"null_finalize_agent_contract_name": "NullFinalizeAgentExt",
|
||||
"finalize_agent_contract_name": "ReservedTokensFinalizeAgent",
|
||||
"standard_crowdsale_contract_name": "SampleCrowdsale",
|
||||
"standard_crowdsale_token_contract_name": "SampleCrowdsaleToken",
|
||||
"crowdsale_contract_name": "MintedTokenCappedCrowdsaleExt",
|
||||
"crowdsale_token_contract_name": "CrowdsaleTokenExt",
|
||||
"crowdsale_pricing_strategy_contract_name": "FlatPricingExt",
|
||||
"safe_math_lib_contract_name": "SafeMathLibExt"
|
||||
},
|
||||
"scripts": {
|
||||
"startReact": "node build_scripts/start.js",
|
||||
"start": "npm run generateFlatSoliditySafeMathLibContract && npm run generateFlatSolidityCrowdsaleNullFinalizeAgentContract && npm run generateFlatSolidityCrowdsaleFinalizeAgentContract && npm run generateFlatSolidityCrowdsaleContract && npm run generateFlatSolidityCrowdsaleTokenContract && npm run generateFlatSolidityCrowdsalePricingStrategyContract && npm run compileSafeMathLibExtContract && npm run compileCrowdsaleNullFinalizeAgentContract && npm run compileCrowdsaleFinalizeAgentContract && npm run compileCrowdsaleContract && npm run compileCrowdsaleTokenContract && npm run compileCrowdsalePricingStrategyContract && node build_scripts/start.js",
|
||||
"build": "git submodule update --init --recursive --remote && npm run generateFlatSoliditySafeMathLibContract && npm run generateFlatSolidityCrowdsaleNullFinalizeAgentContract && npm run generateFlatSolidityCrowdsaleFinalizeAgentContract && npm run generateFlatSolidityCrowdsaleContract && npm run generateFlatSolidityCrowdsaleTokenContract && npm run generateFlatSolidityCrowdsalePricingStrategyContract && npm run compileSafeMathLibExtContract && npm run compileCrowdsaleNullFinalizeAgentContract && npm run compileCrowdsaleFinalizeAgentContract && npm run compileCrowdsaleContract && npm run compileCrowdsaleTokenContract && npm run compileCrowdsalePricingStrategyContract && node build_scripts/build.js",
|
||||
"start": "cd submodules/oracles-web3-1.0 && npm install && cd ../../ && npm install submodules/oracles-web3-1.0/packages/web3 && npm run generateFlatSoliditySafeMathLibContract && npm run generateFlatSolidityCrowdsaleNullFinalizeAgentContract && npm run generateFlatSolidityCrowdsaleFinalizeAgentContract && npm run generateFlatSolidityCrowdsaleContract && npm run generateFlatSolidityCrowdsaleTokenContract && npm run generateFlatSolidityCrowdsalePricingStrategyContract && npm run compileSafeMathLibExtContract && npm run compileCrowdsaleNullFinalizeAgentContract && npm run compileCrowdsaleFinalizeAgentContract && npm run compileCrowdsaleContract && npm run compileCrowdsaleTokenContract && npm run compileCrowdsalePricingStrategyContract && node scripts/start.js",
|
||||
"startWin": "cd submodules/oracles-web3-1.0 && npm install && cd ../../ && npm install submodules/oracles-web3-1.0/packages/web3 && npm run generateFlatSoliditySafeMathLibContractWin && npm run generateFlatSolidityCrowdsaleNullFinalizeAgentContractWin && npm run generateFlatSolidityCrowdsaleFinalizeAgentContractWin && npm run generateFlatSolidityCrowdsaleContractWin && npm run generateFlatSolidityCrowdsaleTokenContractWin && npm run generateFlatSolidityCrowdsalePricingStrategyContractWin && npm run compileSafeMathLibExtContractWin && npm run compileCrowdsaleNullFinalizeAgentContractWin && npm run compileCrowdsaleFinalizeAgentContractWin && npm run compileCrowdsaleContractWin && npm run compileCrowdsaleTokenContractWin && npm run compileCrowdsalePricingStrategyContractWin && node scripts/start.js",
|
||||
"build": "git submodule update --init --recursive --remote && cd submodules/oracles-web3-1.0 && npm install && cd ../../ && npm install submodules/oracles-web3-1.0/packages/web3 && npm run generateFlatSoliditySafeMathLibContract && npm run generateFlatSolidityCrowdsaleNullFinalizeAgentContract && npm run generateFlatSolidityCrowdsaleFinalizeAgentContract && npm run generateFlatSolidityCrowdsaleContract && npm run generateFlatSolidityCrowdsaleTokenContract && npm run generateFlatSolidityCrowdsalePricingStrategyContract && npm run compileSafeMathLibExtContract && npm run compileCrowdsaleNullFinalizeAgentContract && npm run compileCrowdsaleFinalizeAgentContract && npm run compileCrowdsaleContract && npm run compileCrowdsaleTokenContract && npm run compileCrowdsalePricingStrategyContract && node scripts/build.js",
|
||||
"test": "bash ./start_testrpc.sh && cd ./submodules/oracles-token-market-net-ico/ && npm install && node_modules/.bin/truffle migrate --network testrpc && node_modules/.bin/truffle test --network testrpc",
|
||||
"generateFlatSolidityTokenTransferProxyContract": "node $npm_package_config_combine_solidity_script $npm_package_config_0xproject_path/TokenTransferProxy.sol $npm_package_config_contract_folder TokenTransferProxy",
|
||||
"generateFlatSolidityMultiSigContract": "node $npm_package_config_combine_solidity_script $npm_package_config_0xproject_path/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol $npm_package_config_contract_folder MultiSig",
|
||||
"generateFlatSolidityStandardCrowdsaleContract": "node $npm_package_config_combine_solidity_script $npm_package_config_zeppelin_path/Crowdsale.sol $npm_package_config_contract_folder CrowdsaleStandard",
|
||||
"generateFlatSolidityStandardCrowdsaleTokenContract": "node $npm_package_config_combine_solidity_script $npm_package_config_zeppelin_path/Crowdsale.sol $npm_package_config_contract_folder CrowdsaleStandardToken",
|
||||
"generateFlatSoliditySafeMathLibContract": "node $npm_package_config_combine_solidity_script $npm_package_config_tokenmarketnet_path/$npm_package_config_safe_math_lib_contract_name.sol $npm_package_config_contract_folder SafeMathLibExt",
|
||||
"generateFlatSolidityCrowdsaleContract": "node $npm_package_config_combine_solidity_script $npm_package_config_tokenmarketnet_path/$npm_package_config_crowdsale_contract_name.sol $npm_package_config_contract_folder CrowdsaleWhiteListWithCap",
|
||||
"generateFlatSolidityCrowdsaleTokenContract": "node $npm_package_config_combine_solidity_script $npm_package_config_tokenmarketnet_path/$npm_package_config_crowdsale_token_contract_name.sol $npm_package_config_contract_folder CrowdsaleWhiteListWithCapToken",
|
||||
|
@ -115,15 +102,23 @@
|
|||
"generateFlatSolidityCrowdsaleNullFinalizeAgentContract": "node $npm_package_config_combine_solidity_script $npm_package_config_tokenmarketnet_path/$npm_package_config_null_finalize_agent_contract_name.sol $npm_package_config_contract_folder NullFinalizeAgent",
|
||||
"generateFlatSolidityCrowdsaleFinalizeAgentContract": "node $npm_package_config_combine_solidity_script $npm_package_config_tokenmarketnet_path/$npm_package_config_finalize_agent_contract_name.sol $npm_package_config_contract_folder FinalizeAgent",
|
||||
"compileSafeMathLibExtContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/SafeMathLibExt_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path false $npm_package_config_safe_math_lib_contract_name SafeMathLibExt",
|
||||
"compileTokenTransferProxyContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/TokenTransferProxy_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path false $npm_package_config_token_transfer_proxy_contract_name TokenTransferProxy",
|
||||
"compileMultisigContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/MultiSig_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path false $npm_package_config_multisig_contract_name MultiSig",
|
||||
"compileStandardCrowdsaleContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/CrowdsaleStandard_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path true $npm_package_config_standard_crowdsale_contract_name CrowdsaleStandard",
|
||||
"compileStandardCrowdsaleTokenContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/CrowdsaleStandardToken_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path true $npm_package_config_standard_crowdsale_token_contract_name CrowdsaleStandardToken",
|
||||
"compileCrowdsaleContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/CrowdsaleWhiteListWithCap_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path false $npm_package_config_crowdsale_contract_name CrowdsaleWhiteListWithCap",
|
||||
"compileCrowdsaleTokenContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/CrowdsaleWhiteListWithCapToken_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path false $npm_package_config_crowdsale_token_contract_name CrowdsaleWhiteListWithCapToken",
|
||||
"compileCrowdsalePricingStrategyContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/CrowdsaleWhiteListWithCapPricingStrategy_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path false $npm_package_config_crowdsale_pricing_strategy_contract_name CrowdsaleWhiteListWithCapPricingStrategy",
|
||||
"compileCrowdsaleNullFinalizeAgentContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/NullFinalizeAgent_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path false $npm_package_config_null_finalize_agent_contract_name NullFinalizeAgent",
|
||||
"compileCrowdsaleFinalizeAgentContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/FinalizeAgent_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path false $npm_package_config_finalize_agent_contract_name FinalizeAgent"
|
||||
"compileCrowdsaleFinalizeAgentContract": "node ./scripts/compileContract.js $npm_package_config_contract_folder/FinalizeAgent_flat.sol $npm_package_config_contract_folder $npm_package_config_extension_path false $npm_package_config_finalize_agent_contract_name FinalizeAgent",
|
||||
"generateFlatSoliditySafeMathLibContractWin": "node %npm_package_config_combine_solidity_script% %npm_package_config_tokenmarketnet_path%/%npm_package_config_safe_math_lib_contract_name%.sol %npm_package_config_contract_folder% SafeMathLibExt",
|
||||
"generateFlatSolidityCrowdsaleContractWin": "node %npm_package_config_combine_solidity_script% %npm_package_config_tokenmarketnet_path%/%npm_package_config_crowdsale_contract_name%.sol %npm_package_config_contract_folder% CrowdsaleWhiteListWithCap",
|
||||
"generateFlatSolidityCrowdsaleTokenContractWin": "node %npm_package_config_combine_solidity_script% %npm_package_config_tokenmarketnet_path%/%npm_package_config_crowdsale_token_contract_name%.sol %npm_package_config_contract_folder% CrowdsaleWhiteListWithCapToken",
|
||||
"generateFlatSolidityCrowdsalePricingStrategyContractWin": "node %npm_package_config_combine_solidity_script% %npm_package_config_tokenmarketnet_path%/%npm_package_config_crowdsale_pricing_strategy_contract_name%.sol %npm_package_config_contract_folder% CrowdsaleWhiteListWithCapPricingStrategy",
|
||||
"generateFlatSolidityCrowdsaleNullFinalizeAgentContractWin": "node %npm_package_config_combine_solidity_script% %npm_package_config_tokenmarketnet_path%/%npm_package_config_null_finalize_agent_contract_name%.sol %npm_package_config_contract_folder% NullFinalizeAgent",
|
||||
"generateFlatSolidityCrowdsaleFinalizeAgentContractWin": "node %npm_package_config_combine_solidity_script% %npm_package_config_tokenmarketnet_path%/%npm_package_config_finalize_agent_contract_name%.sol %npm_package_config_contract_folder% FinalizeAgent",
|
||||
"compileSafeMathLibExtContractWin": "node ./scripts/compileContract.js %npm_package_config_contract_folder%/SafeMathLibExt_flat.sol %npm_package_config_contract_folder% $npm_package_config_extension_path false %npm_package_config_safe_math_lib_contract_name% SafeMathLibExt",
|
||||
"compileCrowdsaleContractWin": "node ./scripts/compileContract.js %npm_package_config_contract_folder%/CrowdsaleWhiteListWithCap_flat.sol %npm_package_config_contract_folder% %npm_package_config_extension_path% false %npm_package_config_crowdsale_contract_name% CrowdsaleWhiteListWithCap",
|
||||
"compileCrowdsaleTokenContractWin": "node ./scripts/compileContract.js %npm_package_config_contract_folder%/CrowdsaleWhiteListWithCapToken_flat.sol %npm_package_config_contract_folder% %npm_package_config_extension_path% false %npm_package_config_crowdsale_token_contract_name% CrowdsaleWhiteListWithCapToken",
|
||||
"compileCrowdsalePricingStrategyContractWin": "node ./scripts/compileContract.js %npm_package_config_contract_folder%/CrowdsaleWhiteListWithCapPricingStrategy_flat.sol %npm_package_config_contract_folder% %npm_package_config_extension_path% false %npm_package_config_crowdsale_pricing_strategy_contract_name% CrowdsaleWhiteListWithCapPricingStrategy",
|
||||
"compileCrowdsaleNullFinalizeAgentContractWin": "node ./scripts/compileContract.js %npm_package_config_contract_folder%/NullFinalizeAgent_flat.sol %npm_package_config_contract_folder% %npm_package_config_extension_path% false %npm_package_config_null_finalize_agent_contract_name% NullFinalizeAgent",
|
||||
"compileCrowdsaleFinalizeAgentContractWin": "node ./scripts/compileContract.js %npm_package_config_contract_folder%/FinalizeAgent_flat.sol %npm_package_config_contract_folder% %npm_package_config_extension_path% false %npm_package_config_finalize_agent_contract_name% FinalizeAgent"
|
||||
},
|
||||
"jest": {
|
||||
"collectCoverageFrom": [
|
||||
|
|
19726
public/bundle.js
|
@ -0,0 +1,144 @@
|
|||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'production';
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
// ignoring them. In the future, promise rejections that are not handled will
|
||||
// terminate the Node.js process with a non-zero exit code.
|
||||
process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Ensure environment variables are read.
|
||||
require('../config/env');
|
||||
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('fs-extra');
|
||||
const webpack = require('webpack');
|
||||
const config = require('../config/webpack.config.prod');
|
||||
const paths = require('../config/paths');
|
||||
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
||||
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
||||
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
||||
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
||||
|
||||
const measureFileSizesBeforeBuild =
|
||||
FileSizeReporter.measureFileSizesBeforeBuild;
|
||||
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
||||
const useYarn = fs.existsSync(paths.yarnLockFile);
|
||||
|
||||
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
||||
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
||||
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
||||
|
||||
// Warn and crash if required files are missing
|
||||
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// First, read the current file sizes in build directory.
|
||||
// This lets us display how much they changed later.
|
||||
measureFileSizesBeforeBuild(paths.appBuild)
|
||||
.then(previousFileSizes => {
|
||||
// Remove all content but keep the directory so that
|
||||
// if you're in it, you don't end up in Trash
|
||||
fs.emptyDirSync(paths.appBuild);
|
||||
// Merge with the public folder
|
||||
copyPublicFolder();
|
||||
// Start the webpack build
|
||||
return build(previousFileSizes);
|
||||
})
|
||||
.then(
|
||||
({ stats, previousFileSizes, warnings }) => {
|
||||
if (warnings.length) {
|
||||
console.log(chalk.yellow('Compiled with warnings.\n'));
|
||||
console.log(warnings.join('\n\n'));
|
||||
console.log(
|
||||
'\nSearch for the ' +
|
||||
chalk.underline(chalk.yellow('keywords')) +
|
||||
' to learn more about each warning.'
|
||||
);
|
||||
console.log(
|
||||
'To ignore, add ' +
|
||||
chalk.cyan('// eslint-disable-next-line') +
|
||||
' to the line before.\n'
|
||||
);
|
||||
} else {
|
||||
console.log(chalk.green('Compiled successfully.\n'));
|
||||
}
|
||||
|
||||
console.log('File sizes after gzip:\n');
|
||||
printFileSizesAfterBuild(
|
||||
stats,
|
||||
previousFileSizes,
|
||||
paths.appBuild,
|
||||
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
||||
WARN_AFTER_CHUNK_GZIP_SIZE
|
||||
);
|
||||
console.log();
|
||||
|
||||
const appPackage = require(paths.appPackageJson);
|
||||
const publicUrl = paths.publicUrl;
|
||||
const publicPath = config.output.publicPath;
|
||||
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
||||
printHostingInstructions(
|
||||
appPackage,
|
||||
publicUrl,
|
||||
publicPath,
|
||||
buildFolder,
|
||||
useYarn
|
||||
);
|
||||
},
|
||||
err => {
|
||||
console.log(chalk.red('Failed to compile.\n'));
|
||||
console.log((err.message || err) + '\n');
|
||||
process.exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
// Create the production build and print the deployment instructions.
|
||||
function build(previousFileSizes) {
|
||||
console.log('Creating an optimized production build...');
|
||||
|
||||
let compiler = webpack(config);
|
||||
return new Promise((resolve, reject) => {
|
||||
compiler.run((err, stats) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
const messages = formatWebpackMessages(stats.toJson({}, true));
|
||||
if (messages.errors.length) {
|
||||
return reject(new Error(messages.errors.join('\n\n')));
|
||||
}
|
||||
if (
|
||||
process.env.CI &&
|
||||
(typeof process.env.CI !== 'string' ||
|
||||
process.env.CI.toLowerCase() !== 'false') &&
|
||||
messages.warnings.length
|
||||
) {
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
||||
'Most CI servers set it automatically.\n'
|
||||
)
|
||||
);
|
||||
return reject(new Error(messages.warnings.join('\n\n')));
|
||||
}
|
||||
return resolve({
|
||||
stats,
|
||||
previousFileSizes,
|
||||
warnings: messages.warnings,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function copyPublicFolder() {
|
||||
fs.copySync(paths.appPublic, paths.appBuild, {
|
||||
dereference: true,
|
||||
filter: file => file !== paths.appHtml,
|
||||
});
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'development';
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
// ignoring them. In the future, promise rejections that are not handled will
|
||||
// terminate the Node.js process with a non-zero exit code.
|
||||
process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Ensure environment variables are read.
|
||||
require('../config/env');
|
||||
|
||||
const fs = require('fs');
|
||||
const chalk = require('chalk');
|
||||
const webpack = require('webpack');
|
||||
const WebpackDevServer = require('webpack-dev-server');
|
||||
const clearConsole = require('react-dev-utils/clearConsole');
|
||||
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
||||
const {
|
||||
choosePort,
|
||||
createCompiler,
|
||||
prepareProxy,
|
||||
prepareUrls,
|
||||
} = require('react-dev-utils/WebpackDevServerUtils');
|
||||
const openBrowser = require('react-dev-utils/openBrowser');
|
||||
const paths = require('../config/paths');
|
||||
const config = require('../config/webpack.config.dev');
|
||||
const createDevServerConfig = require('../config/webpackDevServer.config');
|
||||
|
||||
const useYarn = fs.existsSync(paths.yarnLockFile);
|
||||
const isInteractive = process.stdout.isTTY;
|
||||
|
||||
// Warn and crash if required files are missing
|
||||
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Tools like Cloud9 rely on this.
|
||||
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
|
||||
const HOST = process.env.HOST || '0.0.0.0';
|
||||
|
||||
// We attempt to use the default port but if it is busy, we offer the user to
|
||||
// run on a different port. `detect()` Promise resolves to the next free port.
|
||||
choosePort(HOST, DEFAULT_PORT)
|
||||
.then(port => {
|
||||
if (port == null) {
|
||||
// We have not found a port.
|
||||
return;
|
||||
}
|
||||
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||
const appName = require(paths.appPackageJson).name;
|
||||
const urls = prepareUrls(protocol, HOST, port);
|
||||
// Create a webpack compiler that is configured with custom messages.
|
||||
const compiler = createCompiler(webpack, config, appName, urls, useYarn);
|
||||
// Load proxy config
|
||||
const proxySetting = require(paths.appPackageJson).proxy;
|
||||
const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
|
||||
// Serve webpack assets generated by the compiler over a web sever.
|
||||
const serverConfig = createDevServerConfig(
|
||||
proxyConfig,
|
||||
urls.lanUrlForConfig
|
||||
);
|
||||
const devServer = new WebpackDevServer(compiler, serverConfig);
|
||||
// Launch WebpackDevServer.
|
||||
devServer.listen(port, HOST, err => {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
if (isInteractive) {
|
||||
clearConsole();
|
||||
}
|
||||
console.log(chalk.cyan('Starting the development server...\n'));
|
||||
openBrowser(urls.localUrlForBrowser);
|
||||
});
|
||||
|
||||
['SIGINT', 'SIGTERM'].forEach(function(sig) {
|
||||
process.on(sig, function() {
|
||||
devServer.close();
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
if (err && err.message) {
|
||||
console.log(err.message);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
|
@ -0,0 +1,27 @@
|
|||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'test';
|
||||
process.env.NODE_ENV = 'test';
|
||||
process.env.PUBLIC_URL = '';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
// ignoring them. In the future, promise rejections that are not handled will
|
||||
// terminate the Node.js process with a non-zero exit code.
|
||||
process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Ensure environment variables are read.
|
||||
require('../config/env');
|
||||
|
||||
const jest = require('jest');
|
||||
const argv = process.argv.slice(2);
|
||||
|
||||
// Watch unless on CI or in coverage mode
|
||||
if (!process.env.CI && argv.indexOf('--coverage') < 0) {
|
||||
argv.push('--watch');
|
||||
}
|
||||
|
||||
|
||||
jest.run(argv);
|
|
@ -9,10 +9,6 @@ import { VALIDATION_MESSAGES, VALIDATION_TYPES, TEXT_FIELDS } from '../../utils/
|
|||
const { EMPTY, VALID, INVALID } = VALIDATION_TYPES
|
||||
const { START_TIME, END_TIME, RATE, SUPPLY, CROWDSALE_SETUP_NAME, ALLOWMODIFYING } = TEXT_FIELDS
|
||||
|
||||
//behaves like normal tier block
|
||||
// accesses data from tierstore
|
||||
//remove all this
|
||||
//pass down onChange function
|
||||
@inject ('tierStore')
|
||||
@observer export class CrowdsaleBlock extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
|
@ -8,7 +8,7 @@ export const Footer = () => (
|
|||
<p className="rights">2017 Oracles Network. All rights reserved.</p>
|
||||
<Link className="logo" to='/'></Link>
|
||||
<div className="socials">
|
||||
<a href="https://twitter.com//oraclesorg" className="social social_twitter"></a>
|
||||
<a href="https://twitter.com/oraclesorg" className="social social_twitter"></a>
|
||||
<a href="https://www.oracles.org" className="social social_oracles"></a>
|
||||
<a href="https://t.me/oraclesnetwork" className="social social_telegram"></a>
|
||||
<a href="https://github.com/oraclesorg/" className="social social_github"></a>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import React, { Component } from 'react';
|
||||
import '../../assets/stylesheets/application.css';
|
||||
import { getWeb3, getNetworkVersion } from '../../utils/blockchainHelpers'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
export class Home extends Component {
|
||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react'
|
|||
import '../../assets/stylesheets/application.css';
|
||||
import { getWeb3, checkWeb3, checkNetWorkByID } from '../../utils/blockchainHelpers'
|
||||
import { getCrowdsaleData, initializeAccumulativeData, getAccumulativeCrowdsaleData, findCurrentContractRecursively, getJoinedTiers } from './utils'
|
||||
import { getQueryVariable, getURLParam, getStandardCrowdsaleAssets, getWhiteListWithCapCrowdsaleAssets } from '../../utils/utils'
|
||||
import { getQueryVariable, getURLParam, getWhiteListWithCapCrowdsaleAssets, toFixed } from '../../utils/utils'
|
||||
import { StepNavigation } from '../Common/StepNavigation'
|
||||
import { NAVIGATION_STEPS, CONTRACT_TYPES } from '../../utils/constants'
|
||||
import { invalidCrowdsaleAddrAlert } from '../../utils/alerts'
|
||||
|
@ -19,7 +19,7 @@ const { CROWDSALE_PAGE } = NAVIGATION_STEPS
|
|||
}
|
||||
|
||||
componentDidMount () {
|
||||
const { web3Store, contractStore, generalStore } = this.props
|
||||
const { web3Store } = this.props
|
||||
const web3 = web3Store.web3
|
||||
checkWeb3(web3);
|
||||
let newState = { ...this.state }
|
||||
|
@ -27,20 +27,23 @@ const { CROWDSALE_PAGE } = NAVIGATION_STEPS
|
|||
newState.tokenIsAlreadyCreated = true;
|
||||
this.setState(newState);
|
||||
const networkID = ICOConfig.networkID?ICOConfig.networkID:getQueryVariable("networkID");
|
||||
const contractType = CONTRACT_TYPES.whitelistwithcap;//getQueryVariable("contractType");
|
||||
const contractType = CONTRACT_TYPES.whitelistwithcap;//getQueryVariable("contractType");
|
||||
this.getCrowdsale(web3, networkID, contractType)
|
||||
}
|
||||
|
||||
getCrowdsale (web3, networkID, contractType) {
|
||||
const { contractStore, generalStore } = this.props
|
||||
if (!web3) {
|
||||
let state = this.state;
|
||||
let state = { ...this.state };
|
||||
state.loading = false;
|
||||
this.setState(state);
|
||||
this.setState(state);
|
||||
return
|
||||
};
|
||||
checkNetWorkByID(web3, networkID);
|
||||
generalStore.setProperty('networkID', networkID);
|
||||
contractStore.setContractType(contractType);
|
||||
|
||||
switch (contractType) {
|
||||
case CONTRACT_TYPES.standard: {
|
||||
getStandardCrowdsaleAssets(this.extractContractsData.bind(this));
|
||||
} break;
|
||||
case CONTRACT_TYPES.whitelistwithcap: {
|
||||
getWhiteListWithCapCrowdsaleAssets(this.extractContractsData.bind(this))
|
||||
} break;
|
||||
|
@ -49,15 +52,13 @@ const { CROWDSALE_PAGE } = NAVIGATION_STEPS
|
|||
}
|
||||
}
|
||||
|
||||
extractContractsData() {
|
||||
console.log('this', this)
|
||||
const { web3Store, contractStore } = this.props
|
||||
const web3 = web3Store.web3
|
||||
extractContractsData(web3) {
|
||||
const { contractStore } = this.props
|
||||
const crowdsaleAddr = ICOConfig.crowdsaleContractURL?ICOConfig.crowdsaleContractURL:getURLParam("addr");
|
||||
if (!web3.isAddress(crowdsaleAddr)) {
|
||||
let state = {...this.state};
|
||||
if (!web3.utils.isAddress(crowdsaleAddr)) {
|
||||
let state = this.state;
|
||||
state.loading = false;
|
||||
this.setState(state);
|
||||
this.setState(state);
|
||||
return invalidCrowdsaleAddrAlert();
|
||||
}
|
||||
getJoinedTiers(web3, contractStore.crowdsale.abi, crowdsaleAddr, [], (joinedCrowdsales) => {
|
||||
|
@ -66,7 +67,7 @@ const { CROWDSALE_PAGE } = NAVIGATION_STEPS
|
|||
|
||||
let _crowdsaleAddrs;
|
||||
if ( typeof joinedCrowdsales === 'string' ) {
|
||||
_crowdsaleAddrs = [ joinedCrowdsales ];
|
||||
_crowdsaleAddrs = [ joinedCrowdsales ];
|
||||
} else {
|
||||
_crowdsaleAddrs = joinedCrowdsales;
|
||||
}
|
||||
|
@ -75,39 +76,43 @@ const { CROWDSALE_PAGE } = NAVIGATION_STEPS
|
|||
if (!contractStore.crowdsale.addr) {
|
||||
return;
|
||||
}
|
||||
findCurrentContractRecursively(0, this, web3, null, (crowdsaleContract) => {
|
||||
if (!crowdsaleContract) {
|
||||
state.loading = false;
|
||||
return this.setState(state);
|
||||
}
|
||||
getCrowdsaleData(web3, this, crowdsaleContract, () => {
|
||||
initializeAccumulativeData(() => {
|
||||
getAccumulativeCrowdsaleData(web3, this, () => {});
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
findCurrentContractRecursively(0, this, web3, null, (crowdsaleContract) => {
|
||||
if (!crowdsaleContract) {
|
||||
state.loading = false;
|
||||
return this.setState(state);
|
||||
}
|
||||
this.getFullCrowdsaleData(web3, crowdsaleContract)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
goToInvestPage = () => {
|
||||
const { contractStore, generalStore } = this.props
|
||||
let queryStr = "";
|
||||
if (!ICOConfig.crowdsaleContractURL || !ICOConfig.networkID) {
|
||||
if (contractStore.crowdsale.addr) {
|
||||
queryStr = "?addr=" + contractStore.crowdsale.addr[0];
|
||||
/*for (let i = 1; i < contractStore.crowdsale.addr.length; i++) {
|
||||
queryStr += `&addr=` + contractStore.crowdsale.addr[i]
|
||||
}*/
|
||||
if (generalStore.networkID) {
|
||||
queryStr += "&networkID=" + generalStore.networkID;
|
||||
}
|
||||
//uncomment, if more then one contractType will appear
|
||||
/*if (this.state.contractType)
|
||||
queryStr += "&contractType=" + this.state.contractType;*/
|
||||
}
|
||||
}
|
||||
this.props.history.push('/invest' + queryStr);
|
||||
}
|
||||
getFullCrowdsaleData(web3, crowdsaleContract) {
|
||||
getCrowdsaleData(web3, this, crowdsaleContract, () => {
|
||||
initializeAccumulativeData(() => {
|
||||
getAccumulativeCrowdsaleData(web3, this, () => {});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
goToInvestPage = () => {
|
||||
const { contractStore, generalStore } = this.props
|
||||
let queryStr = "";
|
||||
if (!ICOConfig.crowdsaleContractURL || !ICOConfig.networkID) {
|
||||
if (contractStore.crowdsale.addr) {
|
||||
queryStr = "?addr=" + contractStore.crowdsale.addr[0];
|
||||
/*for (let i = 1; i < contractStore.crowdsale.addr.length; i++) {
|
||||
queryStr += `&addr=` + contractStore.crowdsale.addr[i]
|
||||
}*/
|
||||
if (generalStore.networkID) {
|
||||
queryStr += "&networkID=" + generalStore.networkID;
|
||||
}
|
||||
//uncomment, if more then one contractType will appear
|
||||
/*if (this.state.contractType)
|
||||
queryStr += "&contractType=" + this.state.contractType;*/
|
||||
}
|
||||
}
|
||||
this.props.history.push('/invest' + queryStr);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { web3Store, contractStore, tokenStore, crowdsalePageStore } = this.props
|
||||
|
@ -128,7 +133,7 @@ const { CROWDSALE_PAGE } = NAVIGATION_STEPS
|
|||
|
||||
//price: tiers, standard
|
||||
const tokensPerETHStandard = !isNaN(rate)?rate:0;
|
||||
const tokensPerETHTiers = !isNaN(1/rate)?1/web3.fromWei(rate, "ether"):0;
|
||||
const tokensPerETHTiers = !isNaN(1/rate)?1/web3.fromWei(toFixed(rate).toString(), "ether"):0;
|
||||
const tokensPerETH = (contractStore.contractType === CONTRACT_TYPES.whitelistwithcap)?tokensPerETHTiers:tokensPerETHStandard;
|
||||
|
||||
//total supply: tiers, standard
|
||||
|
@ -138,7 +143,8 @@ const { CROWDSALE_PAGE } = NAVIGATION_STEPS
|
|||
|
||||
//goal in ETH
|
||||
const goalInETHStandard = (totalSupply/rate).toExponential();
|
||||
const goalInETHTiers = crowdsalePageStore.maximumSellableTokensInWei?(web3.fromWei(crowdsalePageStore.maximumSellableTokensInWei, "ether").toString()):0;
|
||||
let goalInETHTiers = crowdsalePageStore.maximumSellableTokensInWei?(web3.fromWei(toFixed(crowdsalePageStore.maximumSellableTokensInWei).toString(), "ether").toString()):0;
|
||||
goalInETHTiers = 1.0 / 100 * Math.floor(100 * goalInETHTiers)
|
||||
const goalInETH = (contractStore.contractType === CONTRACT_TYPES.whitelistwithcap)?goalInETHTiers:goalInETHStandard;
|
||||
|
||||
const tokensClaimedRatio = goalInETH?(ethRaised/goalInETH)*100:"0";
|
||||
|
|
|
@ -13,7 +13,7 @@ export function getJoinedTiers(web3, abi, addr, joinedCrowdsales, cb) {
|
|||
return cb([]);
|
||||
}
|
||||
|
||||
crowdsaleContract.joinedCrowdsalesLen.call(function(err, joinedCrowdsalesLen) {
|
||||
crowdsaleContract.methods.joinedCrowdsalesLen().call(function(err, joinedCrowdsalesLen) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb([]);
|
||||
|
@ -31,7 +31,7 @@ function getJoinedTiersRecursively(i, crowdsaleContract, joinedCrowdsales, joine
|
|||
return cb(joinedCrowdsales);
|
||||
}
|
||||
|
||||
crowdsaleContract.joinedCrowdsales.call(i, function(err, joinedCrowdsale) {
|
||||
crowdsaleContract.methods.joinedCrowdsales(i).call(function(err, joinedCrowdsale) {
|
||||
if (err) return console.log(err);
|
||||
console.log("joinedCrowdsale: " + joinedCrowdsale);
|
||||
|
||||
|
@ -61,12 +61,12 @@ export function findCurrentContractRecursively(i, $this, web3, firstCrowdsaleCon
|
|||
console.log(contractStore.crowdsale.contractType);
|
||||
if (contractStore.crowdsale.contractType === CONTRACT_TYPES.standard)
|
||||
return cb(crowdsaleContract, i);
|
||||
crowdsaleContract.startsAt.call(function(err, startDate) {
|
||||
crowdsaleContract.methods.startsAt().call(function(err, startDate) {
|
||||
if (err) return console.log(err);
|
||||
|
||||
startDate = startDate*1000;
|
||||
console.log("startDate: " + startDate);
|
||||
crowdsaleContract.endsAt.call(function(err, endDate) {
|
||||
crowdsaleContract.methods.endsAt().call(function(err, endDate) {
|
||||
if (err) return console.log(err);
|
||||
|
||||
endDate = endDate*1000;
|
||||
|
@ -95,9 +95,9 @@ export function getCrowdsaleTargetDates(web3, $this, cb) {
|
|||
console.log("attach to crowdsale contract");
|
||||
if (err) return console.log(err);
|
||||
if (!crowdsaleContract) return noContractAlert();
|
||||
if (crowdsaleContract.startBlock) {
|
||||
if (crowdsaleContract.methods.startBlock) {
|
||||
propsCount++;
|
||||
crowdsaleContract.startBlock.call(function(err, startBlock) {
|
||||
crowdsaleContract.methods.startBlock().call(function(err, startBlock) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
|
@ -111,9 +111,9 @@ export function getCrowdsaleTargetDates(web3, $this, cb) {
|
|||
});
|
||||
}
|
||||
|
||||
if (crowdsaleContract.startsAt) {
|
||||
if (crowdsaleContract.methods.startsAt) {
|
||||
propsCount++;
|
||||
crowdsaleContract.startsAt.call(function(err, startDate) {
|
||||
crowdsaleContract.methods.startsAt().call(function(err, startDate) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
|
@ -127,9 +127,9 @@ export function getCrowdsaleTargetDates(web3, $this, cb) {
|
|||
});
|
||||
}
|
||||
|
||||
if (crowdsaleContract.endBlock) {
|
||||
if (crowdsaleContract.methods.endBlock) {
|
||||
propsCount++;
|
||||
crowdsaleContract.endBlock.call(function(err, endBlock) {
|
||||
crowdsaleContract.methods.endBlock().call(function(err, endBlock) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
|
@ -153,9 +153,9 @@ export function getCrowdsaleTargetDates(web3, $this, cb) {
|
|||
});
|
||||
}
|
||||
|
||||
if (crowdsaleContract.endsAt) {
|
||||
if (crowdsaleContract.methods.endsAt) {
|
||||
propsCount++;
|
||||
crowdsaleContract.endsAt.call(function(err, endDate) {
|
||||
crowdsaleContract.methods.endsAt().call(function(err, endDate) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
|
@ -193,18 +193,18 @@ export function getAccumulativeCrowdsaleData(web3, $this, cb) {
|
|||
if (!crowdsaleContract) return noContractAlert();
|
||||
|
||||
propsCount++;
|
||||
crowdsaleContract.weiRaised.call(function(err, weiRaised) {
|
||||
crowdsaleContract.methods.weiRaised().call(function(err, weiRaised) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
console.log("weiRaised: " + web3.fromWei(parseInt(weiRaised, 10), "ether"));
|
||||
console.log("weiRaised: " + web3.utils.fromWei(parseInt(weiRaised, 10), "ether"));
|
||||
let state = $this.state;
|
||||
const oldWeiRaised = crowdsalePageStore.weiRaised
|
||||
if (crowdsalePageStore.weiRaised)
|
||||
crowdsalePageStore.setProperty('weiRaised', oldWeiRaised + parseInt(weiRaised, 10));//parseFloat(web3.fromWei(parseInt(weiRaised, 10), "ether"));
|
||||
else
|
||||
crowdsalePageStore.setProperty('weiRaised', parseInt(weiRaised, 10));//parseFloat(web3.fromWei(parseInt(weiRaised, 10), "ether"));
|
||||
crowdsalePageStore.setProperty('ethRaised', parseFloat(web3.fromWei(parseInt(crowdsalePageStore.weiRaised, 10), "ether")));
|
||||
crowdsalePageStore.setProperty('ethRaised', parseFloat(web3.fromWei(parseInt(crowdsalePageStore.weiRaised, 10), "ether")));
|
||||
|
||||
if (propsCount === cbCount) {
|
||||
state.loading = false;
|
||||
|
@ -212,14 +212,14 @@ export function getAccumulativeCrowdsaleData(web3, $this, cb) {
|
|||
}
|
||||
});
|
||||
|
||||
if (crowdsaleContract.tokensSold) {
|
||||
if (crowdsaleContract.methods.tokensSold) {
|
||||
propsCount++;
|
||||
crowdsaleContract.tokensSold.call(function(err, tokensSold) {
|
||||
crowdsaleContract.methods.tokensSold().call(function(err, tokensSold) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
console.log("tokensSold: " + tokensSold);
|
||||
let state = $this.state;
|
||||
let state = { ...$this.state };
|
||||
if (crowdsalePageStore.tokensSold)
|
||||
crowdsalePageStore.setProperty('tokensSold',crowdsalePageStore.tokensSold + parseInt(tokensSold, 10));
|
||||
else
|
||||
|
@ -232,9 +232,9 @@ export function getAccumulativeCrowdsaleData(web3, $this, cb) {
|
|||
});
|
||||
};
|
||||
|
||||
if (crowdsaleContract.maximumSellableTokens) {
|
||||
if (crowdsaleContract.methods.maximumSellableTokens) {
|
||||
propsCount++;
|
||||
crowdsaleContract.maximumSellableTokens.call(function(err, maximumSellableTokens) {
|
||||
crowdsaleContract.methods.maximumSellableTokens().call(function(err, maximumSellableTokens) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
|
@ -257,8 +257,8 @@ export function getAccumulativeCrowdsaleData(web3, $this, cb) {
|
|||
}
|
||||
|
||||
let getInvestors;
|
||||
if (crowdsaleContract.investorCount) getInvestors = crowdsaleContract.investorCount;
|
||||
else if (crowdsaleContract.investors) getInvestors = crowdsaleContract.investors;
|
||||
if (crowdsaleContract.methods.investorCount) getInvestors = crowdsaleContract.methods.investorCount();
|
||||
else if (crowdsaleContract.methods.investors) getInvestors = crowdsaleContract.methods.investors();
|
||||
|
||||
if (getInvestors) {
|
||||
propsCount++;
|
||||
|
@ -284,7 +284,7 @@ export function getAccumulativeCrowdsaleData(web3, $this, cb) {
|
|||
}
|
||||
|
||||
function setMaximumSellableTokensInEth(web3, crowdsaleContract, maximumSellableTokens) {
|
||||
crowdsaleContract.pricingStrategy.call(function(err, pricingStrategyAddr) {
|
||||
crowdsaleContract.methods.pricingStrategy().call(function(err, pricingStrategyAddr) {
|
||||
if (err) return console.log(err);
|
||||
|
||||
console.log("pricingStrategy: " + pricingStrategyAddr);
|
||||
|
@ -293,7 +293,7 @@ function setMaximumSellableTokensInEth(web3, crowdsaleContract, maximumSellableT
|
|||
if (err) return console.log(err);
|
||||
if (!pricingStrategyContract) return noContractAlert();
|
||||
|
||||
pricingStrategyContract.oneTokenInWei.call(function(err, oneTokenInWei) {
|
||||
pricingStrategyContract.methods.oneTokenInWei().call(function(err, oneTokenInWei) {
|
||||
if (err) console.log(err);
|
||||
|
||||
console.log("pricing strategy oneTokenInWei: " + oneTokenInWei);
|
||||
|
@ -309,7 +309,7 @@ function setMaximumSellableTokensInEth(web3, crowdsaleContract, maximumSellableT
|
|||
export function getCurrentRate(web3, $this, crowdsaleContract, cb) {
|
||||
if (!crowdsaleContract) return noContractAlert();
|
||||
|
||||
crowdsaleContract.pricingStrategy.call(function(err, pricingStrategyAddr) {
|
||||
crowdsaleContract.methods.pricingStrategy().call(function(err, pricingStrategyAddr) {
|
||||
if (err) return console.log(err);
|
||||
|
||||
console.log("pricingStrategy: " + pricingStrategyAddr);
|
||||
|
@ -329,13 +329,13 @@ export function getCrowdsaleData(web3, $this, crowdsaleContract, cb) {
|
|||
//depreciated: it was for standard type of contract (governed by open-zeppelin-solidity)
|
||||
/*if (crowdsaleContract.rate) {
|
||||
propsCount++;
|
||||
crowdsaleContract.rate.call(function(err, rate) {
|
||||
crowdsaleContrac.methods.rate().call(function(err, rate) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
console.log("rate: " + web3.fromWei(parseInt(rate, 10), "ether"));
|
||||
console.log("rate: " + web3.utils.fromWei(parseInt(rate, 10), "ether"));
|
||||
let state = $this.state;
|
||||
state.pricingStrategy.rate = web3.fromWei(parseInt(rate, 10), "ether");
|
||||
state.pricingStrategy.rate = web3.utils.fromWei(parseInt(rate, 10), "ether");
|
||||
if (propsCount === cbCount) {
|
||||
state.loading = false;
|
||||
$this.setState(state, cb);
|
||||
|
@ -343,9 +343,9 @@ export function getCrowdsaleData(web3, $this, crowdsaleContract, cb) {
|
|||
});
|
||||
}*/
|
||||
|
||||
if (crowdsaleContract.supply) {
|
||||
if (crowdsaleContract.methods.supply) {
|
||||
propsCount++;
|
||||
crowdsaleContract.supply.call(function(err, supply) {
|
||||
crowdsaleContract.methods.supply().call(function(err, supply) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
|
@ -360,7 +360,7 @@ export function getCrowdsaleData(web3, $this, crowdsaleContract, cb) {
|
|||
}
|
||||
|
||||
propsCount++;
|
||||
crowdsaleContract.token.call(function(err, tokenAddr) {
|
||||
crowdsaleContract.methods.token().call(function(err, tokenAddr) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
|
@ -376,10 +376,10 @@ export function getCrowdsaleData(web3, $this, crowdsaleContract, cb) {
|
|||
propsCount++;
|
||||
getTokenData($this, function() {
|
||||
|
||||
if (!crowdsaleContract.pricingStrategy) return;
|
||||
if (!crowdsaleContract.methods.pricingStrategy) return;
|
||||
|
||||
propsCount++;
|
||||
crowdsaleContract.pricingStrategy.call(function(err, pricingStrategyAddr) {
|
||||
crowdsaleContract.methods.pricingStrategy().call(function(err, pricingStrategyAddr) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
|
@ -427,7 +427,7 @@ function getTokenData($this, cb) {
|
|||
if (!tokenContract) return noContractAlert();
|
||||
|
||||
propsCount++;
|
||||
tokenContract["name"].call(function(err, name) {
|
||||
tokenContract.methods.name().call(function(err, name) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
|
@ -440,7 +440,7 @@ function getTokenData($this, cb) {
|
|||
}
|
||||
});
|
||||
propsCount++;
|
||||
tokenContract["symbol"].call(function(err, ticker) {
|
||||
tokenContract.methods.symbol().call(function(err, ticker) {
|
||||
cbCount++;
|
||||
if (err) console.log(err);
|
||||
console.log("token ticker: " + ticker);
|
||||
|
@ -451,9 +451,9 @@ function getTokenData($this, cb) {
|
|||
$this.setState(state, cb);
|
||||
}
|
||||
});
|
||||
if (tokenContract.balanceOf) {
|
||||
if (tokenContract.methods.balanceOf) {
|
||||
propsCount++;
|
||||
tokenContract.balanceOf.call(web3.eth.accounts[0], function(err, balanceOf) {
|
||||
tokenContract.methods.balanceOf.call(web3.eth.accounts[0], function(err, balanceOf) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
|
@ -470,7 +470,7 @@ function getTokenData($this, cb) {
|
|||
});
|
||||
}
|
||||
propsCount++;
|
||||
tokenContract["decimals"].call(function(err, decimals) {
|
||||
tokenContract.methods.decimals().call(function(err, decimals) {
|
||||
cbCount++;
|
||||
if (err) console.log(err);
|
||||
console.log("token decimals: " + decimals);
|
||||
|
@ -482,7 +482,7 @@ function getTokenData($this, cb) {
|
|||
}
|
||||
});
|
||||
propsCount++;
|
||||
tokenContract["totalSupply"].call(function(err, supply) {
|
||||
tokenContract.methods.totalSupply().call(function(err, supply) {
|
||||
cbCount++;
|
||||
if (err) console.log(err);
|
||||
let state = $this.state;
|
||||
|
@ -491,8 +491,85 @@ function getTokenData($this, cb) {
|
|||
if (propsCount === cbCount) {
|
||||
state.loading = false;
|
||||
$this.setState(state, cb);
|
||||
return;
|
||||
} else {
|
||||
let propsCount = 0;
|
||||
let cbCount = 0;
|
||||
attachToContract(web3, $this.state.contracts.token.abi, $this.state.contracts.token.addr, function(err, tokenContract) {
|
||||
console.log("attach to token contract");
|
||||
if (err) return console.log(err);
|
||||
if (!tokenContract) return noContractAlert();
|
||||
|
||||
propsCount++;
|
||||
tokenContract.methods.name().call(function(err, name) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
console.log("token name: " + name);
|
||||
let state = $this.state;
|
||||
tokenStore.setProperty('name', name);
|
||||
if (propsCount === cbCount) {
|
||||
state.loading = false;
|
||||
$this.setState(state, cb);
|
||||
}
|
||||
});
|
||||
propsCount++;
|
||||
tokenContract.methods.symbol().call(function(err, ticker) {
|
||||
cbCount++;
|
||||
if (err) console.log(err);
|
||||
console.log("token ticker: " + ticker);
|
||||
let state = $this.state;
|
||||
tokenStore.setProperty('ticker', ticker);
|
||||
if (propsCount === cbCount) {
|
||||
state.loading = false;
|
||||
$this.setState(state, cb);
|
||||
}
|
||||
});
|
||||
if (tokenContract.methods.balanceOf) {
|
||||
propsCount++;
|
||||
tokenContract.methods.balanceOf(web3.eth.accounts[0]).call(function(err, balanceOf) {
|
||||
cbCount++;
|
||||
if (err) return console.log(err);
|
||||
|
||||
console.log("balanceOf: " + balanceOf);
|
||||
let state = $this.state;
|
||||
if (crowdsalePageStore.tokenAmountOf)
|
||||
crowdsalePageStore.setProperty('tokenAmountOf', crowdsalePageStore.tokenAmountOf + parseInt(balanceOf, 10));
|
||||
else
|
||||
crowdsalePageStore.setProperty('tokenAmountOf', parseInt(balanceOf, 10));
|
||||
if (propsCount === cbCount) {
|
||||
state.loading = false;
|
||||
$this.setState(state, cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
propsCount++;
|
||||
tokenContract.methods.decimals().call(function(err, decimals) {
|
||||
cbCount++;
|
||||
if (err) console.log(err);
|
||||
console.log("token decimals: " + decimals);
|
||||
let state = $this.state;
|
||||
tokenStore.setProperty('decimals', decimals);
|
||||
if (propsCount === cbCount) {
|
||||
state.loading = false;
|
||||
$this.setState(state, cb);
|
||||
}
|
||||
});
|
||||
propsCount++;
|
||||
tokenContract.methods.totalSupply().call(function(err, supply) {
|
||||
cbCount++;
|
||||
if (err) console.log(err);
|
||||
let state = $this.state;
|
||||
console.log("token supply: " + supply);
|
||||
tokenStore.setProperty('supply', supply);
|
||||
if (propsCount === cbCount) {
|
||||
state.loading = false;
|
||||
$this.setState(state, cb);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -502,22 +579,12 @@ export function getPricingStrategyData(web3, cb) {
|
|||
if (err) return console.log(err);
|
||||
if (!pricingStrategyContract) return noContractAlert();
|
||||
|
||||
pricingStrategyContract.oneTokenInWei.call(function(err, rate) {
|
||||
pricingStrategyContract.methods.oneTokenInWei().call(function(err, rate) {
|
||||
if (err) console.log(err);
|
||||
|
||||
console.log("pricing strategy rate: " + rate);
|
||||
crowdsalePageStore.setProperty('rate', parseInt(rate, 10))//web3.fromWei(parseInt(rate, 10), "ether");
|
||||
cb();
|
||||
});
|
||||
|
||||
//EthTranchePricing
|
||||
/*pricingStrategyContract.getCurrentPrice($this.crowdsalePageStore.weiRaised, function(err, rate) {
|
||||
if (err) console.log(err);
|
||||
|
||||
console.log("pricing strategy rate: " + rate);
|
||||
let state = $this.state;
|
||||
state.pricingStrategy.rate = rate.toString();
|
||||
$this.setState(state);
|
||||
});*/
|
||||
});
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
import React from 'react'
|
||||
import ReactCountdownClock from 'react-countdown-clock'
|
||||
import { getWeb3, checkTxMined, attachToContract, checkNetWorkByID } from '../../utils/blockchainHelpers'
|
||||
import { checkTxMined, attachToContract, checkNetWorkByID, sendTXToContract } from '../../utils/blockchainHelpers'
|
||||
import { getCrowdsaleData, getCurrentRate, initializeAccumulativeData, getAccumulativeCrowdsaleData, getCrowdsaleTargetDates, findCurrentContractRecursively, getJoinedTiers } from '../crowdsale/utils'
|
||||
import { getQueryVariable, getURLParam, getStandardCrowdsaleAssets, getWhiteListWithCapCrowdsaleAssets } from '../../utils/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 { CONTRACT_TYPES } from '../../utils/constants'
|
||||
import { CONTRACT_TYPES, GAS_PRICE } from '../../utils/constants'
|
||||
import { observer, inject } from 'mobx-react'
|
||||
|
||||
@inject('contractStore', 'crowdsalePageStore', 'web3Store', 'tierStore', 'tokenStore', 'generalStore', 'investStore')
|
||||
|
@ -42,12 +42,6 @@ import { observer, inject } from 'mobx-react'
|
|||
this.setState({ timeInterval });
|
||||
|
||||
switch (contractType) {
|
||||
case CONTRACT_TYPES.standard: {
|
||||
getStandardCrowdsaleAssets((_newState) => {
|
||||
this.setState(_newState);
|
||||
this.extractContractsData(web3);
|
||||
});
|
||||
} break;
|
||||
case CONTRACT_TYPES.whitelistwithcap: {
|
||||
getWhiteListWithCapCrowdsaleAssets((_newState) => {
|
||||
this.setState(_newState);
|
||||
|
@ -61,10 +55,10 @@ import { observer, inject } from 'mobx-react'
|
|||
|
||||
extractContractsData(web3) {
|
||||
const { contractStore, crowdsalePageStore } = this.props
|
||||
let state = this.state;
|
||||
let state = { ...this.state };
|
||||
|
||||
const crowdsaleAddr = ICOConfig.crowdsaleContractURL?ICOConfig.crowdsaleContractURL:getURLParam("addr");
|
||||
if (!web3.isAddress(crowdsaleAddr)) {
|
||||
if (!web3.utils.isAddress(crowdsaleAddr)) {
|
||||
state.loading = false;
|
||||
this.setState(state);
|
||||
return invalidCrowdsaleAddrAlert();
|
||||
|
@ -81,43 +75,44 @@ import { observer, inject } from 'mobx-react'
|
|||
}
|
||||
contractStore.setContractProperty('crowdsale', 'addr', _crowdsaleAddrs);
|
||||
|
||||
if (web3.eth.accounts.length === 0) {
|
||||
let state = this.state;
|
||||
state.loading = false;
|
||||
this.setState(state);
|
||||
return
|
||||
};
|
||||
web3.eth.getAccounts().then((accounts) => {
|
||||
if (accounts.length === 0) {
|
||||
let state = this.state;
|
||||
state.loading = false;
|
||||
this.setState(state);
|
||||
return
|
||||
};
|
||||
|
||||
state.curAddr = web3.eth.accounts[0];
|
||||
state.web3 = web3;
|
||||
this.setState(state);
|
||||
|
||||
if (!contractStore.crowdsale.addr) {
|
||||
let state = this.state;
|
||||
state.loading = false;
|
||||
state.curAddr = accounts[0];
|
||||
state.web3 = web3;
|
||||
this.setState(state);
|
||||
return
|
||||
};
|
||||
findCurrentContractRecursively(0, this, web3, null, (crowdsaleContract) => {
|
||||
if (!crowdsaleContract) {
|
||||
|
||||
if (!contractStore.crowdsale.addr) {
|
||||
let state = this.state;
|
||||
state.loading = false;
|
||||
return this.setState(state);
|
||||
}
|
||||
getCrowdsaleData(web3, this, crowdsaleContract, () => {
|
||||
initializeAccumulativeData(() => {
|
||||
getAccumulativeCrowdsaleData(web3, this, () => {
|
||||
};
|
||||
findCurrentContractRecursively(0, this, web3, null, (crowdsaleContract) => {
|
||||
if (!crowdsaleContract) {
|
||||
state.loading = false;
|
||||
return this.setState(state);
|
||||
}
|
||||
getCrowdsaleData(web3, this, crowdsaleContract, () => {
|
||||
initializeAccumulativeData(() => {
|
||||
getAccumulativeCrowdsaleData(web3, this, () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
getCrowdsaleTargetDates(web3, this, () => {
|
||||
console.log(crowdsalePageStore);
|
||||
if (crowdsalePageStore.endDate) {
|
||||
let state = this.state;
|
||||
state.seconds = (crowdsalePageStore.endDate - new Date().getTime())/1000;
|
||||
this.setState(state);
|
||||
}
|
||||
getCrowdsaleTargetDates(web3, this, () => {
|
||||
console.log(crowdsalePageStore);
|
||||
if (crowdsalePageStore.endDate) {
|
||||
let state = this.state;
|
||||
state.seconds = (crowdsalePageStore.endDate - new Date().getTime())/1000;
|
||||
this.setState(state);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -144,50 +139,15 @@ import { observer, inject } from 'mobx-react'
|
|||
console.log('contractStore.contractType', contractStore.contractType)
|
||||
|
||||
switch (contractStore.contractType) {
|
||||
case CONTRACT_TYPES.standard: {
|
||||
web3.eth.getBlockNumber((err, curBlock) => {
|
||||
if (err) return console.log(err);
|
||||
this.investToTokensForStandardCrowdsale(web3, curBlock)
|
||||
});
|
||||
} break;
|
||||
case CONTRACT_TYPES.whitelistwithcap: {
|
||||
console.log('CONTRACT_TYPES.whitelistwithcap', CONTRACT_TYPES.whitelistwithcap)
|
||||
this.investToTokensForWhitelistedCrowdsale(web3)
|
||||
this.investToTokensForWhitelistedCrowdsale(web3, web3.eth.accounts)
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
investToTokensForStandardCrowdsale(web3, curBlock) {
|
||||
const { crowdsalePageStore, investStore, contractStore } = this.props
|
||||
if (parseInt(crowdsalePageStore.startBlock, 10) > parseInt(curBlock, 10)) {
|
||||
return investmentDisabledAlert(parseInt(crowdsalePageStore.startBlock, 10), curBlock);
|
||||
}
|
||||
|
||||
let weiToSend = web3.toWei(investStore.tokensToInvest/crowdsalePageStore.rate, "ether");
|
||||
let opts = {
|
||||
from: web3.eth.accounts[0],
|
||||
value: weiToSend
|
||||
};
|
||||
|
||||
attachToContract(web3, contractStore.crowdsale.abi, contractStore.crowdsale.addr[0], (err, crowdsaleContract) => {
|
||||
console.log("attach to crowdsale contract");
|
||||
if (err) return console.log(err);
|
||||
if (!crowdsaleContract) return noContractAlert();
|
||||
|
||||
console.log(crowdsaleContract);
|
||||
console.log(web3.eth.defaultAccount);
|
||||
|
||||
crowdsaleContract.buySampleTokens.sendTransaction(web3.eth.accounts[0], opts, (err, txHash) => {
|
||||
if (err) return console.log(err);
|
||||
|
||||
console.log("tx hash: " + txHash);
|
||||
successfulInvestmentAlert(investStore.tokensToInvest);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
investToTokensForWhitelistedCrowdsale(web3) {
|
||||
const { crowdsalePageStore } = this.props
|
||||
console.log("startDate: " + crowdsalePageStore.startDate);
|
||||
|
@ -205,14 +165,16 @@ import { observer, inject } from 'mobx-react'
|
|||
state.loading = false;
|
||||
return this.setState(state);
|
||||
}
|
||||
console.log(web3)
|
||||
getCurrentRate(web3, this, crowdsaleContract, () => {
|
||||
this.investToTokensForWhitelistedCrowdsaleInternal(crowdsaleContract, tierNum, web3);
|
||||
console.log(web3)
|
||||
this.investToTokensForWhitelistedCrowdsaleInternal(crowdsaleContract, tierNum, web3, web3.eth.accounts);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
investToTokensForWhitelistedCrowdsaleInternal(crowdsaleContract, tierNum, web3) {
|
||||
const { contractStore, tokenStore, crowdsalePageStore, investStore } = this.props
|
||||
investToTokensForWhitelistedCrowdsaleInternal(crowdsaleContract, tierNum, web3, accounts) {
|
||||
const { contractStore, tokenStore, crowdsalePageStore, investStore } = this.props
|
||||
let nextTiers = [];
|
||||
console.log(contractStore.crowdsale);
|
||||
for (let i = tierNum + 1; i < contractStore.crowdsale.addr.length; i++) {
|
||||
|
@ -230,13 +192,21 @@ import { observer, inject } from 'mobx-react'
|
|||
|
||||
let weiToSend = parseInt(tokensToInvest*rate, 10);
|
||||
console.log("weiToSend: " + weiToSend);
|
||||
|
||||
let opts = {
|
||||
from: web3.eth.accounts[0],
|
||||
from: accounts[0],
|
||||
value: weiToSend,
|
||||
gasPrice: 21000000000
|
||||
gasPrice: GAS_PRICE
|
||||
};
|
||||
console.log(opts);
|
||||
crowdsaleContract.buy.sendTransaction(opts, (err, txHash) => {
|
||||
sendTXToContract(web3, crowdsaleContract.methods.buy().send(opts), (err) => {
|
||||
let state = this.state;
|
||||
state.loading = false;
|
||||
this.setState(state);
|
||||
successfulInvestmentAlert(this.state.tokensToInvest);
|
||||
});
|
||||
|
||||
/*crowdsaleContract.methods.buy().send(opts, (err, txHash) => {
|
||||
if (err) {
|
||||
let state = this.state;
|
||||
state.loading = false;
|
||||
|
@ -245,22 +215,26 @@ import { observer, inject } from 'mobx-react'
|
|||
}
|
||||
|
||||
console.log("txHash: " + txHash);
|
||||
let $this = this;
|
||||
checkTxMined(web3, txHash, function txMinedCallback(receipt) {
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
let state = $this.state;
|
||||
state.loading = false;
|
||||
$this.setState(state);
|
||||
successfulInvestmentAlert(investStore.tokensToInvest);
|
||||
}
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
checkTxMined(web3, txHash, txMinedCallback);
|
||||
}, 500);
|
||||
}
|
||||
})
|
||||
});
|
||||
console.log(web3)
|
||||
checkTxMined(web3, txHash, (receipt) => this.txMinedCallback(web3, txHash, receipt))
|
||||
});*/
|
||||
}
|
||||
|
||||
txMinedCallback(web3, txHash, receipt) {
|
||||
console.log(web3);
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
let state = this.state;
|
||||
state.loading = false;
|
||||
this.setState(state);
|
||||
successfulInvestmentAlert(this.state.tokensToInvest);
|
||||
}
|
||||
} else {
|
||||
console.log(web3)
|
||||
setTimeout(() => {
|
||||
checkTxMined(web3, txHash, (receipt) => this.txMinedCallback(web3, txHash, receipt))
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
tokensToInvestOnChange(event) {
|
||||
|
|
|
@ -5,14 +5,14 @@ import { setLastCrowdsaleRecursive, addWhiteListRecursive, setFinalizeAgentRecur
|
|||
import {download, handleContractsForFile, handleTokenForFile, handleCrowdsaleForFile, handlePricingStrategyForFile, handleFinalizeAgentForFile, handleConstantForFile, scrollToBottom } from './utils'
|
||||
import { noMetaMaskAlert, noContractDataAlert } from '../../utils/alerts'
|
||||
import { FILE_CONTENTS, DOWNLOAD_NAME, DOWNLOAD_TYPE, CONTRACT_TYPES } from '../../utils/constants'
|
||||
import { toFixed } from '../../utils/utils'
|
||||
import { toFixed, floorToDecimals } from '../../utils/utils'
|
||||
import { getEncodedABIClientSide } from '../../utils/microservices'
|
||||
import { stepTwo } from '../stepTwo'
|
||||
import { StepNavigation } from '../Common/StepNavigation'
|
||||
import { DisplayField } from '../Common/DisplayField'
|
||||
import { DisplayTextArea } from '../Common/DisplayTextArea'
|
||||
import { Loader } from '../Common/Loader'
|
||||
import { NAVIGATION_STEPS } from '../../utils/constants'
|
||||
import { NAVIGATION_STEPS, TRUNC_TO_DECIMALS } from '../../utils/constants'
|
||||
import { copy } from '../../utils/copy';
|
||||
import { observer, inject } from 'mobx-react'
|
||||
const { PUBLISH } = NAVIGATION_STEPS
|
||||
|
@ -35,31 +35,9 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
copy('copy');
|
||||
checkWeb3(web3);
|
||||
switch (this.props.contractStore.contractType) {
|
||||
//depreciated
|
||||
/*case CONTRACT_TYPES.standard: {
|
||||
let abiCrowdsale = contractStore && contractStore.crowdsale && contractStore.crowdsale.abi || []
|
||||
|
||||
let state = { ...this.state }
|
||||
setTimeout(() => {
|
||||
getWeb3((web3) => {
|
||||
state.web3 = web3;
|
||||
this.setState(state);
|
||||
getEncodedABIClientSide(web3, abiCrowdsale, this.state, [], 0, (ABIencoded) => {
|
||||
let cntrct = "crowdsale";
|
||||
let state = { ...this.state }
|
||||
state.contracts[cntrct].abiConstructor.push(ABIencoded);
|
||||
console.log(cntrct + " ABI encoded params constructor:");
|
||||
console.log(ABIencoded);
|
||||
this.setState(state);
|
||||
});
|
||||
});
|
||||
});
|
||||
} break;*/
|
||||
case CONTRACT_TYPES.whitelistwithcap: {
|
||||
if (!contractStore.safeMathLib) {
|
||||
let newState = { ...this.state }
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
this.hideLoader();
|
||||
return noContractDataAlert();
|
||||
}
|
||||
|
||||
|
@ -71,39 +49,31 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
let abiPricingStrategy = contractStore && contractStore.pricingStrategy && contractStore.pricingStrategy.abi || []
|
||||
|
||||
setTimeout(() => {
|
||||
const web3 = web3Store.web3;
|
||||
let counter = 0;
|
||||
if (!addrToken) {
|
||||
getEncodedABIClientSide(web3, abiToken, [], 0, (ABIencoded) => {
|
||||
counter++;
|
||||
let cntrct = "token";
|
||||
contractStore.setContractProperty(cntrct, 'abiConstructor', ABIencoded)
|
||||
console.log(cntrct + " ABI encoded params constructor:");
|
||||
console.log(ABIencoded);
|
||||
if (counter == (tierStore.tiers.length + 1))
|
||||
this.deploySafeMathLibrary();
|
||||
});
|
||||
}
|
||||
for (let i = 0; i < tierStore.tiers.length; i++) {
|
||||
getEncodedABIClientSide(web3, abiPricingStrategy, [], i, (ABIencoded) => {
|
||||
counter++;
|
||||
let cntrct = "pricingStrategy";
|
||||
const newContract = contractStore[cntrct].abiConstructor.concat(ABIencoded)
|
||||
contractStore.setContractProperty(cntrct, 'abiContstructor', newContract);
|
||||
console.log(cntrct + " ABI encoded params constructor:");
|
||||
console.log(ABIencoded);
|
||||
if (counter == (tierStore.tiers.length + 1))
|
||||
this.deploySafeMathLibrary();
|
||||
});
|
||||
}
|
||||
|
||||
//depreciated
|
||||
/*console.log(contractStore.crowdsale.addr.length);
|
||||
if (contractStore.crowdsale.addr.length === 0) {
|
||||
this.deploySafeMathLibrary();
|
||||
} else {
|
||||
this.deployPricingStrategy();
|
||||
}*/
|
||||
const web3 = web3Store.web3;
|
||||
let counter = 0;
|
||||
if (!addrToken) {
|
||||
getEncodedABIClientSide(web3, abiToken, [], 0, (ABIencoded) => {
|
||||
counter++;
|
||||
let cntrct = "token";
|
||||
contractStore.setContractProperty(cntrct, 'abiConstructor', ABIencoded)
|
||||
console.log(cntrct + " ABI encoded params constructor:");
|
||||
console.log(ABIencoded);
|
||||
if (counter == (tierStore.tiers.length + 1))
|
||||
this.deploySafeMathLibrary();
|
||||
});
|
||||
}
|
||||
for (let i = 0; i < tierStore.tiers.length; i++) {
|
||||
getEncodedABIClientSide(web3, abiPricingStrategy, [], i, (ABIencoded) => {
|
||||
counter++;
|
||||
let cntrct = "pricingStrategy";
|
||||
const newContract = contractStore[cntrct].abiConstructor.concat(ABIencoded)
|
||||
contractStore.setContractProperty(cntrct, 'abiContstructor', newContract);
|
||||
console.log(cntrct + " ABI encoded params constructor:");
|
||||
console.log(ABIencoded);
|
||||
if (counter == (tierStore.tiers.length + 1))
|
||||
this.deploySafeMathLibrary();
|
||||
});
|
||||
}
|
||||
});
|
||||
} break;
|
||||
default:
|
||||
|
@ -111,6 +81,57 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
}
|
||||
}
|
||||
|
||||
hideLoader() {
|
||||
let newState = { ...this.state }
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
}
|
||||
|
||||
/*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':
|
||||
|
@ -137,79 +158,12 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
download(docData.data, DOWNLOAD_NAME, DOWNLOAD_TYPE)
|
||||
}
|
||||
|
||||
//depreciated
|
||||
/*deployTokenTransferProxy = () => {
|
||||
console.log("***Deploy tokenTransferProxy contract***");
|
||||
if (web3.eth.accounts.length === 0) {
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
var contracts = contractStore;
|
||||
var binTokenTransferProxy = contracts && contracts.tokenTransferProxy && contracts.tokenTransferProxy.bin || ''
|
||||
var abiTokenTransferProxy = contracts && contracts.tokenTransferProxy && contracts.tokenTransferProxy.abi || []
|
||||
deployContract(0, web3, abiTokenTransferProxy, binTokenTransferProxy, [], this.state, this.handleDeployedTokenTransferProxy)
|
||||
}
|
||||
|
||||
//depreciated
|
||||
handleDeployedTokenTransferProxy = (err, tokenTransferProxyAddr) => {
|
||||
let newState = { ...this.state }
|
||||
if (err) {
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return console.log(err);
|
||||
}
|
||||
newState.contracts.tokenTransferProxy.addr = tokenTransferProxyAddr;
|
||||
this.deployMultisig();
|
||||
}
|
||||
|
||||
//depreciated
|
||||
deployMultisig = () => {
|
||||
console.log("***Deploy multisig contract***");
|
||||
if (web3.eth.accounts.length === 0) {
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
var contracts = contractStore;
|
||||
var binMultisig = contracts && contracts.multisig && contracts.multisig.bin || ''
|
||||
var abiMultisig = contracts && contracts.multisig && contracts.multisig.abi || []
|
||||
var paramsMultisig = this.getMultisigParams(web3)
|
||||
console.log(paramsMultisig);
|
||||
deployContract(0, web3, abiMultisig, binMultisig, paramsMultisig, this.state, this.handleDeployedMultisig)
|
||||
}
|
||||
|
||||
//depreciated
|
||||
getMultisigParams = (web3) => {
|
||||
return [
|
||||
[web3.eth.accounts[0]],
|
||||
1,
|
||||
60,
|
||||
contractStore.tokenTransferProxy.addr
|
||||
]
|
||||
}
|
||||
|
||||
handleDeployedMultisig = (err, multisigAddr) => {
|
||||
let newState = { ...this.state }
|
||||
if (err) {
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return console.log(err);
|
||||
}
|
||||
newState.contracts.multisig.addr = multisigAddr;
|
||||
this.deployToken();
|
||||
}*/
|
||||
|
||||
deploySafeMathLibrary = () => {
|
||||
const { web3Store, contractStore } = this.props
|
||||
const web3 = web3Store.web3
|
||||
console.log("***Deploy safeMathLib contract***");
|
||||
if (!web3) {
|
||||
let newState = { ...this.state }
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
if (web3.eth.accounts.length === 0) {
|
||||
let newState = { ...this.state }
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
if (!web3 || web3.eth.accounts.length === 0) {
|
||||
this.hideLoader();
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
var contracts = contractStore;
|
||||
|
@ -222,11 +176,8 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
handleDeployedSafeMathLibrary = (err, safeMathLibAddr) => {
|
||||
const { contractStore } = this.props
|
||||
console.log("safeMathLibAddr: " + safeMathLibAddr);
|
||||
let newState = { ...this.state }
|
||||
if (err) {
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return console.log(err);
|
||||
return this.hideLoader();
|
||||
}
|
||||
contractStore.setContractProperty('safeMathLib', 'addr', safeMathLibAddr)
|
||||
let keys = Object.keys(contractStore).filter(key => contractStore[key] !== undefined);
|
||||
|
@ -237,8 +188,6 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
contractStore.setContractProperty(key, 'bin', newBin)
|
||||
|
||||
}
|
||||
// contractStore.setContractProperty('safeMathLib', 'addr', safeMathLibAddr)
|
||||
// contracts[key].bin =
|
||||
}
|
||||
this.deployToken();
|
||||
}
|
||||
|
@ -248,9 +197,7 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
const web3 = web3Store.web3
|
||||
console.log("***Deploy token contract***");
|
||||
if (web3.eth.accounts.length === 0) {
|
||||
let newState = { ...this.state }
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
this.hideLoader();
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
var contracts = contractStore
|
||||
|
@ -277,11 +224,8 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
|
||||
handleDeployedToken = (err, tokenAddr) => {
|
||||
const { contractStore } = this.props
|
||||
let newState = { ...this.state }
|
||||
if (err) {
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return console.log(err);
|
||||
return this.hideLoader();
|
||||
}
|
||||
contractStore.setContractProperty('token', 'addr', tokenAddr)
|
||||
this.deployPricingStrategy();
|
||||
|
@ -292,9 +236,7 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
const web3 = web3Store.web3
|
||||
console.log("***Deploy pricing strategy contract***");
|
||||
if (web3.eth.accounts.length === 0) {
|
||||
let newState = { ...this.state }
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return this.hideLoader();
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
let contracts = contractStore;
|
||||
|
@ -314,10 +256,7 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
deployContract(i, web3, abiPricingStrategy, binPricingStrategy, paramsPricingStrategy, this.state, (err, pricingStrategyAddr) => {
|
||||
i++;
|
||||
if (err) {
|
||||
let newState = {...this.state}
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return console.log(err);
|
||||
this.hideLoader();
|
||||
}
|
||||
const newPricingStrategy = contractStore.pricingStrategy.addr.concat(pricingStrategyAddr)
|
||||
contractStore.setContractProperty('pricingStrategy', 'addr', newPricingStrategy)
|
||||
|
@ -332,67 +271,18 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
getPricingStrategyParams = (web3, pricingStrategy, i, token) => {
|
||||
const { tierStore } = this.props
|
||||
console.log(pricingStrategy);
|
||||
let oneTokenInETH = floorToDecimals(TRUNC_TO_DECIMALS.DECIMALS18, 1/pricingStrategy.rate)
|
||||
return [
|
||||
web3.toWei(1/pricingStrategy.rate, "ether"),
|
||||
web3.toWei(oneTokenInETH, "ether"),
|
||||
tierStore.tiers[i].updatable?tierStore.tiers[i].updatable=="on"?true:false:false
|
||||
]
|
||||
}
|
||||
|
||||
//EthTranchePricing
|
||||
/*getPricingStrategyParams = (web3, pricingStrategy) => {
|
||||
console.log(pricingStrategy);
|
||||
return [
|
||||
pricingStrategy.tranches
|
||||
]
|
||||
}*/
|
||||
|
||||
//MilestonePricing
|
||||
/*getPricingStrategyParams = (web3, crowdsale, pricingStrategy) => {
|
||||
console.log(crowdsale);
|
||||
let pricing = [];
|
||||
for (let i = 0; i < crowdsale.length; i++) {
|
||||
let crowdsaleItem = crowdsale[i];
|
||||
let pricingStrategyItem = pricingStrategy[i];
|
||||
let endDate = new Date(crowdsaleItem.endDate).getTime()/1000;
|
||||
console.log("Milestone end date: " + endDate);
|
||||
let oneTokenInWei = web3.toWei(1/pricingStrategyItem.rate, "ether")
|
||||
console.log("oneTokenInWei: " + oneTokenInWei);
|
||||
pricing.push(endDate);
|
||||
pricing.push(oneTokenInWei);
|
||||
}
|
||||
console.log("Pricing strategy params:");
|
||||
console.log(pricing);
|
||||
return [
|
||||
pricing
|
||||
]
|
||||
}*/
|
||||
|
||||
//TokenTranchePricing
|
||||
/*getPricingStrategyParams = (web3, crowdsale, pricingStrategy) => {
|
||||
console.log(crowdsale);
|
||||
let pricing = [];
|
||||
for (let i = 0; i < crowdsale.length; i++) {
|
||||
let crowdsaleItem = crowdsale[i];
|
||||
let pricingStrategyItem = pricingStrategy[i];
|
||||
let supply = crowdsaleItem.supply;
|
||||
pricing.push(supply);
|
||||
pricing.push(oneTokenInWei);
|
||||
}
|
||||
console.log("Pricing strategy params:");
|
||||
console.log(pricing);
|
||||
return [
|
||||
pricing
|
||||
]
|
||||
}*/
|
||||
|
||||
handleDeployedPricingStrategy = (err, pricingStrategyAddr) => {
|
||||
const { contractStore, tierStore, web3Store } = this.props
|
||||
const web3 = web3Store.web3
|
||||
if (err) {
|
||||
let newState = { ...this.state }
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return console.log(err);
|
||||
return this.hideLoader();
|
||||
}
|
||||
const newPricingStrategy = contractStore.pricingStrategy.addr.concat(pricingStrategyAddr)
|
||||
contractStore.setContractProperty('pricingStrategy', 'addr', newPricingStrategy)
|
||||
|
@ -420,9 +310,7 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
getNetworkVersion(web3, (_networkID) => {
|
||||
console.log('web3', web3)
|
||||
if (web3.eth.accounts.length === 0) {
|
||||
let newState = { ...this.state }
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
this.hideLoader();
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
let newState = { ...this.state }
|
||||
|
@ -456,11 +344,8 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
if (i < crowdsales.length - 1) {
|
||||
deployContract(i, web3, abiCrowdsale, binCrowdsale, paramsCrowdsale, this.state, (err, crowdsaleAddr) => {
|
||||
i++;
|
||||
let newState = { ...this.state }
|
||||
if (err) {
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return console.log(err);
|
||||
return this.hideLoader();
|
||||
}
|
||||
const newAddr = contractStore.crowdsale.addr.concat(crowdsaleAddr);
|
||||
contractStore.setContractProperty('crowdsale', 'addr', newAddr)
|
||||
|
@ -471,21 +356,6 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
}
|
||||
}
|
||||
|
||||
//depreciated
|
||||
/*getStandardCrowdSaleParams = (web3) => {
|
||||
return [
|
||||
parseInt(this.state.crowdsale[0].startBlock, 10),
|
||||
parseInt(this.state.crowdsale[0].endBlock, 10),
|
||||
web3.toWei(tierStore.tiers[0].rate, "ether"),
|
||||
this.state.crowdsale[0].walletAddress,
|
||||
parseInt(this.state.crowdsale[0].supply, 10),
|
||||
tokenStore.name,
|
||||
tokenStore.ticker,
|
||||
parseInt(tokenStore.decimals, 10),
|
||||
parseInt(tokenStore.supply, 10)
|
||||
]
|
||||
}*/
|
||||
|
||||
//MintedTokenCappedCrowdsale
|
||||
getCrowdSaleParams = (web3, i) => {
|
||||
const { contractStore, tierStore, tokenStore } = this.props
|
||||
|
@ -493,9 +363,9 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
contractStore.token.addr,
|
||||
contractStore.pricingStrategy.addr[i],
|
||||
tierStore.tiers[0].walletAddress, //contractStore.multisig.addr,
|
||||
parseInt(Date.parse(tierStore.tiers[i].startTime)/1000, 10),
|
||||
parseInt(Date.parse(tierStore.tiers[i].endTime)/1000, 10),
|
||||
0,
|
||||
toFixed(parseInt(Date.parse(tierStore.tiers[i].startTime)/1000, 10).toString()),
|
||||
toFixed(parseInt(Date.parse(tierStore.tiers[i].endTime)/1000, 10).toString()),
|
||||
toFixed("0"),
|
||||
toFixed(parseInt(tierStore.tiers[i].supply, 10)*10**parseInt(tokenStore.decimals, 10)).toString(),
|
||||
tierStore.tiers[i].updatable?tierStore.tiers[i].updatable=="on"?true:false:false,
|
||||
tierStore.tiers[0].whitelistdisabled?tierStore.tiers[0].whitelistdisabled=="yes"?false:true:false
|
||||
|
@ -504,11 +374,8 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
|
||||
handleDeployedCrowdsaleContract = (err, crowdsaleAddr) => {
|
||||
const { contractStore } = this.props
|
||||
let newState = { ...this.state }
|
||||
if (err) {
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return console.log(err);
|
||||
return this.hideLoader();
|
||||
}
|
||||
const newAddr = contractStore.crowdsale.addr.concat(crowdsaleAddr);
|
||||
contractStore.setContractProperty('crowdsale', 'addr', newAddr)
|
||||
|
@ -552,9 +419,7 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
const web3 = web3Store.web3
|
||||
console.log("***Deploy finalize agent contract***");
|
||||
if (web3.eth.accounts.length === 0) {
|
||||
let newState = { ...this.state }
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
this.hideLoader();
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
let binNullFinalizeAgent = contractStore && contractStore.nullFinalizeAgent && contractStore.nullFinalizeAgent.bin || ''
|
||||
|
@ -585,11 +450,8 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
console.log(paramsFinalizeAgent);
|
||||
deployContract(i, web3, abi, bin, paramsFinalizeAgent, state, (err, finalizeAgentAddr) => {
|
||||
i++;
|
||||
let newState = { ...this.state }
|
||||
if (err) {
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return console.log(err);
|
||||
return this.hideLoader();
|
||||
}
|
||||
const newAddr = contractStore.finalizeAgent.addr.concat(finalizeAgentAddr);
|
||||
contractStore.setContractProperty('finalizeAgent', 'addr', newAddr)
|
||||
|
@ -623,27 +485,33 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
const web3 = web3Store.web3
|
||||
let newState = { ...this.state }
|
||||
if (err) {
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
return console.log(err);
|
||||
return this.hideLoader();
|
||||
}
|
||||
const newAddr = contractStore.finalizeAgent.addr.concat(finalizeAgentAddr);
|
||||
contractStore.setContractProperty('finalizeAgent', 'addr', newAddr)
|
||||
|
||||
this.downloadCrowdsaleInfo();
|
||||
|
||||
//post actions for mintablecappedcrowdsale
|
||||
//if (!tokenStoreIsAlreadyCreated) {
|
||||
console.log("###we create crowdsale firstly###");
|
||||
setLastCrowdsaleRecursive(0, web3, contractStore.pricingStrategy.abi, contractStore.pricingStrategy.addr, contractStore.crowdsale.addr.slice(-1)[0], () => {
|
||||
if (err) return this.hideLoader();
|
||||
setReservedTokensListMultiple(web3, contractStore.token.abi, contractStore.token.addr, tokenStore, () => {
|
||||
if (err) return this.hideLoader();
|
||||
updateJoinedCrowdsalesRecursive(0, web3, contractStore.crowdsale.abi, contractStore.crowdsale.addr, () => {
|
||||
if (err) return this.hideLoader();
|
||||
setMintAgentRecursive(0, web3, contractStore.token.abi, contractStore.token.addr, contractStore.crowdsale.addr, () => {
|
||||
if (err) return this.hideLoader();
|
||||
setMintAgentRecursive(0, web3, contractStore.token.abi, contractStore.token.addr, contractStore.finalizeAgent.addr, () => {
|
||||
if (err) return this.hideLoader();
|
||||
addWhiteListRecursive(0, web3, tierStore, tokenStore, contractStore.crowdsale.abi, contractStore.crowdsale.addr, () => {
|
||||
if (err) return this.hideLoader();
|
||||
setFinalizeAgentRecursive(0, web3, contractStore.crowdsale.abi, contractStore.crowdsale.addr, contractStore.finalizeAgent.addr, () => {
|
||||
if (err) return this.hideLoader();
|
||||
setReleaseAgentRecursive(0, web3, contractStore.token.abi, contractStore.token.addr, contractStore.finalizeAgent.addr, () => {
|
||||
if (err) return this.hideLoader();
|
||||
transferOwnership(web3, contractStore.token.abi, contractStore.token.addr, tierStore.tiers[0].walletAddress, () => {
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
if (err) return this.hideLoader();
|
||||
//this.goToCrowdsalePage();
|
||||
});
|
||||
});
|
||||
|
@ -653,27 +521,6 @@ const { PUBLISH } = NAVIGATION_STEPS
|
|||
});
|
||||
});
|
||||
});
|
||||
/*} else { // creation of additional tier after crowdsale was set up before
|
||||
console.log("###we add tier after crowdsale is created###");
|
||||
let curTierAddr = [ contracts.crowdsale.addr.slice(-1)[0] ];
|
||||
let prevTierAddr = [ contracts.crowdsale.addr.slice(-2)[0] ];
|
||||
let finalizeSet = [prevTierAddr, curTierAddr];
|
||||
this.updateJoinedCrowdsalesRecursive(0, web3, contracts.crowdsale.abi, contracts.crowdsale.addr, () => {
|
||||
this.setMintAgentRecursive(0, web3, contracts.token.abi, contracts.token.addr, curTierAddr, () => {
|
||||
this.setMintAgentRecursive(0, web3, contracts.token.abi, contracts.token.addr, contracts.finalizeAgent.addr, () => {
|
||||
this.addWhiteListRecursive(0, web3, this.state.crowdsale, tokenStore, contracts.crowdsale.abi, curTierAddr, () => {
|
||||
this.setFinalizeAgentRecursive(0, web3, contracts.crowdsale.abi, finalizeSet, contracts.finalizeAgent.addr, () => {
|
||||
this.setReleaseAgentRecursive(0, web3, contracts.token.abi, contracts.token.addr, contracts.finalizeAgent.addr, () => {
|
||||
newState.loading = false;
|
||||
this.setState(newState);
|
||||
this.goToCrowdsalePage();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}*/
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,29 +1,9 @@
|
|||
import { attachToContract, checkTxMined } from '../../utils/blockchainHelpers'
|
||||
import { attachToContract, checkTxMined, sendTXToContract } from '../../utils/blockchainHelpers'
|
||||
import { noContractAlert } from '../../utils/alerts'
|
||||
import { toFixed } from '../../utils/utils'
|
||||
import { GAS_PRICE } from '../../utils/constants'
|
||||
|
||||
/*function setTransferAgent(web3, abi, addr, targetAddr, cb) {
|
||||
console.log("###setTransferAgent:###");
|
||||
attachToContract(web3, abi, addr, function(err, tokenContract) {
|
||||
console.log("attach to token contract");
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb();
|
||||
}
|
||||
if (!tokenContract) return noContractAlert();
|
||||
|
||||
tokenContract.setTransferAgent.sendTransaction(targetAddr, true, function(err, result) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb();
|
||||
}
|
||||
|
||||
console.log("setTransferAgent function transaction: " + result);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
}*/
|
||||
|
||||
function setLastCrowdsale(web3, abi, addr, lastCrowdsale, cb) {
|
||||
function setLastCrowdsale(web3, abi, addr, lastCrowdsale, gasLimit, cb) {
|
||||
console.log("###setLastCrowdsale for Pricing Strategy:###");
|
||||
attachToContract(web3, abi, addr, function(err, pricingStrategyContract) {
|
||||
console.log("attach to pricingStrategy contract");
|
||||
|
@ -33,28 +13,13 @@ function setLastCrowdsale(web3, abi, addr, lastCrowdsale, cb) {
|
|||
}
|
||||
if (!pricingStrategyContract) return noContractAlert();
|
||||
|
||||
pricingStrategyContract.setLastCrowdsale.sendTransaction(lastCrowdsale, {gasPrice: 21000000000}, function(err, txHash) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb();
|
||||
}
|
||||
|
||||
checkTxMined(web3, txHash, function txMinedCallback(receipt) {
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
console.log("setLastCrowdsale function transaction: " + txHash);
|
||||
return cb();
|
||||
}
|
||||
} else {
|
||||
setTimeout(checkTxMined(web3, txHash, txMinedCallback), 1000);
|
||||
}
|
||||
})
|
||||
});
|
||||
let method = pricingStrategyContract.methods.setLastCrowdsale(lastCrowdsale).send({gasLimit: gasLimit, gasPrice: GAS_PRICE})
|
||||
sendTXToContract(web3, method, cb);
|
||||
});
|
||||
}
|
||||
|
||||
//for mintable token
|
||||
function setMintAgent(web3, abi, addr, acc, cb) {
|
||||
function setMintAgent(web3, abi, addr, acc, gasLimit, cb) {
|
||||
console.log("###setMintAgent:###");
|
||||
attachToContract(web3, abi, addr, function(err, tokenContract) {
|
||||
console.log("attach to token contract");
|
||||
|
@ -64,23 +29,8 @@ function setMintAgent(web3, abi, addr, acc, cb) {
|
|||
}
|
||||
if (!tokenContract) return noContractAlert();
|
||||
|
||||
tokenContract.setMintAgent.sendTransaction(acc, true, {gasPrice: 21000000000}, function(err, txHash) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb();
|
||||
}
|
||||
|
||||
checkTxMined(web3, txHash, function txMinedCallback(receipt) {
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
console.log("setMintAgent function transaction: " + txHash);
|
||||
return cb();
|
||||
}
|
||||
} else {
|
||||
setTimeout(checkTxMined(web3, txHash, txMinedCallback), 1000);
|
||||
}
|
||||
})
|
||||
});
|
||||
let method = tokenContract.methods.setMintAgent(acc, true).send({gasLimit: gasLimit, gasPrice: GAS_PRICE})
|
||||
sendTXToContract(web3, method, cb);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -141,8 +91,8 @@ function addWhiteList(round, web3, tierStore, token, abi, addr, cb) {
|
|||
if (!whitelist[i].deleted) {
|
||||
addrs.push(whitelist[i].addr);
|
||||
statuses.push(true);
|
||||
minCaps.push(whitelist[i].min*10**token.decimals);
|
||||
maxCaps.push(whitelist[i].max*10**token.decimals);
|
||||
minCaps.push(whitelist[i].min*10**token.decimals?toFixed((whitelist[i].min*10**token.decimals).toString()):0);
|
||||
maxCaps.push(whitelist[i].max*10**token.decimals?toFixed((whitelist[i].max*10**token.decimals).toString()):0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,23 +105,8 @@ function addWhiteList(round, web3, tierStore, token, abi, addr, cb) {
|
|||
console.log("maxCaps:");
|
||||
console.log(maxCaps);
|
||||
|
||||
crowdsaleContract.setEarlyParicipantsWhitelist.sendTransaction(addrs, statuses, minCaps, maxCaps, {gasPrice: 21000000000}, function(err, txHash) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb();
|
||||
}
|
||||
|
||||
checkTxMined(web3, txHash, function txMinedCallback(receipt) {
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
console.log("setEarlyParicipantsWhitelist function transaction: " + txHash);
|
||||
return cb();
|
||||
}
|
||||
} else {
|
||||
setTimeout(checkTxMined(web3, txHash, txMinedCallback), 1000);
|
||||
}
|
||||
})
|
||||
});
|
||||
let method = crowdsaleContract.methods.setEarlyParicipantsWhitelist(addrs, statuses, minCaps, maxCaps).send({gasPrice: GAS_PRICE})
|
||||
sendTXToContract(web3, method, cb)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -188,27 +123,12 @@ function updateJoinedCrowdsales(web3, abi, addr, joinedCntrctAddrs, cb) {
|
|||
console.log("input: ");
|
||||
console.log(joinedCntrctAddrs);
|
||||
|
||||
crowdsaleContract.updateJoinedCrowdsalesMultiple.sendTransaction(joinedCntrctAddrs, {gasPrice: 21000000000}, function(err, txHash) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb();
|
||||
}
|
||||
|
||||
checkTxMined(web3, txHash, function txMinedCallback(receipt) {
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
console.log("updateJoinedCrowdsales function transaction: " + txHash);
|
||||
return cb();
|
||||
}
|
||||
} else {
|
||||
setTimeout(checkTxMined(web3, txHash, txMinedCallback), 1000);
|
||||
}
|
||||
})
|
||||
});
|
||||
let method = crowdsaleContract.methods.updateJoinedCrowdsalesMultiple(joinedCntrctAddrs).send({gasPrice: GAS_PRICE})
|
||||
sendTXToContract(web3, method, cb);
|
||||
});
|
||||
}
|
||||
|
||||
function setFinalizeAgent(web3, abi, addr, finalizeAgentAddr, cb) {
|
||||
function setFinalizeAgent(web3, abi, addr, finalizeAgentAddr, gasLimit, cb) {
|
||||
console.log("###setFinalizeAgent:###");
|
||||
attachToContract(web3, abi, addr, function(err, crowdsaleContract) {
|
||||
console.log("attach to crowdsale contract");
|
||||
|
@ -218,27 +138,12 @@ function setFinalizeAgent(web3, abi, addr, finalizeAgentAddr, cb) {
|
|||
}
|
||||
if (!crowdsaleContract) return noContractAlert();
|
||||
|
||||
crowdsaleContract.setFinalizeAgent.sendTransaction(finalizeAgentAddr, {gasPrice: 21000000000}, function(err, txHash) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb();
|
||||
}
|
||||
|
||||
checkTxMined(web3, txHash, function txMinedCallback(receipt) {
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
console.log("setFinalizeAgent function transaction: " + txHash);
|
||||
return cb();
|
||||
}
|
||||
} else {
|
||||
setTimeout(checkTxMined(web3, txHash, txMinedCallback), 1000);
|
||||
}
|
||||
})
|
||||
});
|
||||
let method = crowdsaleContract.methods.setFinalizeAgent(finalizeAgentAddr).send({gasLimit: gasLimit, gasPrice: GAS_PRICE})
|
||||
sendTXToContract(web3, method, cb);
|
||||
});
|
||||
}
|
||||
|
||||
function setReleaseAgent(web3, abi, addr, finalizeAgentAddr, cb) {
|
||||
function setReleaseAgent(web3, abi, addr, finalizeAgentAddr, gasLimit, cb) {
|
||||
console.log("###setReleaseAgent:###");
|
||||
attachToContract(web3, abi, addr, function(err, tokenContract) {
|
||||
console.log("attach to token contract");
|
||||
|
@ -248,23 +153,8 @@ function setReleaseAgent(web3, abi, addr, finalizeAgentAddr, cb) {
|
|||
}
|
||||
if (!tokenContract) return noContractAlert();
|
||||
|
||||
tokenContract.setReleaseAgent.sendTransaction(finalizeAgentAddr, {gasPrice: 21000000000}, function(err, txHash) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb();
|
||||
}
|
||||
|
||||
checkTxMined(web3, txHash, function txMinedCallback(receipt) {
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
console.log("setReleaseAgent function transaction: " + txHash);
|
||||
return cb();
|
||||
}
|
||||
} else {
|
||||
setTimeout(checkTxMined(web3, txHash, txMinedCallback), 1000);
|
||||
}
|
||||
})
|
||||
});
|
||||
let method = tokenContract.methods.setReleaseAgent(finalizeAgentAddr).send({gasLimit: gasLimit, gasPrice: GAS_PRICE})
|
||||
sendTXToContract(web3, method, cb);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -312,8 +202,8 @@ export function setReservedTokensListMultiple(web3, abi, addr, token, cb) {
|
|||
let keys = Object.keys(map);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
addrs.push(keys[i]);
|
||||
inTokens.push(map[keys[i]].inTokens);
|
||||
inPercentage.push(map[keys[i]].inPercentage);
|
||||
inTokens.push(map[keys[i]].inTokens?toFixed(map[keys[i]].inTokens.toString()):0);
|
||||
inPercentage.push(map[keys[i]].inPercentage?map[keys[i]].inPercentage:0);
|
||||
}
|
||||
|
||||
if (addrs.length === 0 && inTokens.length === 0 && inPercentage.length === 0) return cb();
|
||||
|
@ -323,27 +213,12 @@ export function setReservedTokensListMultiple(web3, abi, addr, token, cb) {
|
|||
console.log("inTokens: " + inTokens);
|
||||
console.log("inPercentage: " + inPercentage);
|
||||
|
||||
tokenContract.setReservedTokensListMultiple.sendTransaction(addrs, inTokens, inPercentage, {gasPrice: 21000000000}, function(err, txHash) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb();
|
||||
}
|
||||
|
||||
checkTxMined(web3, txHash, function txMinedCallback(receipt) {
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
console.log("setReservedTokensListMultiple function transaction: " + txHash);
|
||||
return cb();
|
||||
}
|
||||
} else {
|
||||
setTimeout(checkTxMined(web3, txHash, txMinedCallback), 1000);
|
||||
}
|
||||
})
|
||||
});
|
||||
let method = tokenContract.methods.setReservedTokensListMultiple(addrs, inTokens, inPercentage).send({gasPrice: GAS_PRICE})
|
||||
sendTXToContract(web3, method, cb);
|
||||
});
|
||||
}
|
||||
|
||||
export function transferOwnership(web3, abi, addr, finalizeAgentAddr, cb) {
|
||||
export function transferOwnership(web3, abi, addr, finalizeAgentAddr, gasLimit, cb) {
|
||||
console.log("###transferOwnership:###");
|
||||
attachToContract(web3, abi, addr, function(err, tokenContract) {
|
||||
console.log("attach to token contract");
|
||||
|
@ -353,89 +228,74 @@ export function transferOwnership(web3, abi, addr, finalizeAgentAddr, cb) {
|
|||
}
|
||||
if (!tokenContract) return noContractAlert();
|
||||
|
||||
tokenContract.transferOwnership.sendTransaction(finalizeAgentAddr, {gasPrice: 21000000000}, function(err, txHash) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb();
|
||||
}
|
||||
|
||||
checkTxMined(web3, txHash, function txMinedCallback(receipt) {
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
console.log("transferOwnership function transaction: " + txHash);
|
||||
return cb();
|
||||
}
|
||||
} else {
|
||||
setTimeout(checkTxMined(web3, txHash, txMinedCallback), 1000);
|
||||
}
|
||||
})
|
||||
});
|
||||
let method = tokenContract.methods.transferOwnership(finalizeAgentAddr).send({gasLimit: gasLimit, gasPrice: GAS_PRICE})
|
||||
sendTXToContract(web3, method, cb);
|
||||
});
|
||||
}
|
||||
|
||||
export function setLastCrowdsaleRecursive (i, web3, abi, pricingStrategyAddrs, lastCrowdsale, cb) {
|
||||
setLastCrowdsale(web3, abi, pricingStrategyAddrs[i], lastCrowdsale, () => {
|
||||
export function setLastCrowdsaleRecursive (i, web3, abi, pricingStrategyAddrs, lastCrowdsale, gasLimit, cb) {
|
||||
setLastCrowdsale(web3, abi, pricingStrategyAddrs[i], lastCrowdsale, gasLimit, (err) => {
|
||||
i++;
|
||||
if (i < pricingStrategyAddrs.length) {
|
||||
setLastCrowdsaleRecursive(i, web3, abi, pricingStrategyAddrs, lastCrowdsale, cb);
|
||||
setLastCrowdsaleRecursive(i, web3, abi, pricingStrategyAddrs, lastCrowdsale, gasLimit, cb);
|
||||
} else {
|
||||
cb();
|
||||
cb(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function setMintAgentRecursive (i, web3, abi, addr, crowdsaleAddrs, cb) {
|
||||
setMintAgent(web3, abi, addr, crowdsaleAddrs[i], () => {
|
||||
export function setMintAgentRecursive (i, web3, abi, addr, crowdsaleAddrs, gasLimit, cb) {
|
||||
setMintAgent(web3, abi, addr, crowdsaleAddrs[i], gasLimit, (err) => {
|
||||
i++;
|
||||
if (i < crowdsaleAddrs.length) {
|
||||
setMintAgentRecursive(i, web3, abi, addr, crowdsaleAddrs, cb);
|
||||
setMintAgentRecursive(i, web3, abi, addr, crowdsaleAddrs, gasLimit, cb);
|
||||
} else {
|
||||
cb();
|
||||
cb(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function updateJoinedCrowdsalesRecursive (i, web3, abi, addrs, cb) {
|
||||
if (addrs.length === 0) return cb();
|
||||
updateJoinedCrowdsales(web3, abi, addrs[i], addrs, () => {
|
||||
updateJoinedCrowdsales(web3, abi, addrs[i], addrs, (err) => {
|
||||
i++;
|
||||
if (i < addrs.length) {
|
||||
updateJoinedCrowdsalesRecursive(i, web3, abi, addrs, cb);
|
||||
} else {
|
||||
cb();
|
||||
cb(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function addWhiteListRecursive (i, web3, tierStore, token, abi, crowdsaleAddrs, cb) {
|
||||
addWhiteList(i, web3, tierStore, token, abi, crowdsaleAddrs[i], () => {
|
||||
addWhiteList(i, web3, tierStore, token, abi, crowdsaleAddrs[i], (err) => {
|
||||
i++;
|
||||
if (i < crowdsaleAddrs.length) {
|
||||
addWhiteListRecursive(i, web3, tierStore, token, abi, crowdsaleAddrs, cb);
|
||||
} else {
|
||||
cb();
|
||||
cb(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function setFinalizeAgentRecursive (i, web3, abi, addrs, finalizeAgentAddrs, cb) {
|
||||
setFinalizeAgent(web3, abi, addrs[i], finalizeAgentAddrs[i], () => {
|
||||
export function setFinalizeAgentRecursive (i, web3, abi, addrs, finalizeAgentAddrs, gasLimit, cb) {
|
||||
setFinalizeAgent(web3, abi, addrs[i], finalizeAgentAddrs[i], gasLimit, (err) => {
|
||||
i++;
|
||||
if (i < finalizeAgentAddrs.length) {
|
||||
setFinalizeAgentRecursive(i, web3, abi, addrs, finalizeAgentAddrs, cb);
|
||||
setFinalizeAgentRecursive(i, web3, abi, addrs, finalizeAgentAddrs, gasLimit, cb);
|
||||
} else {
|
||||
cb();
|
||||
cb(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function setReleaseAgentRecursive (i, web3, abi, addr, finalizeAgentAddrs, cb) {
|
||||
setReleaseAgent(web3, abi, addr, finalizeAgentAddrs[i], () => {
|
||||
export function setReleaseAgentRecursive (i, web3, abi, addr, finalizeAgentAddrs, gasLimit, cb) {
|
||||
setReleaseAgent(web3, abi, addr, finalizeAgentAddrs[i], gasLimit, (err) => {
|
||||
i++;
|
||||
if (i < finalizeAgentAddrs.length) {
|
||||
setReleaseAgentRecursive(i, web3, abi, addr, finalizeAgentAddrs, cb);
|
||||
setReleaseAgentRecursive(i, web3, abi, addr, finalizeAgentAddrs, gasLimit, cb);
|
||||
} else {
|
||||
cb();
|
||||
cb(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import React from 'react'
|
||||
import '../../assets/stylesheets/application.css';
|
||||
import { checkWeb3 } from '../../utils/blockchainHelpers';
|
||||
import { checkWeb3, getWeb3, getNetworkVersion } from '../../utils/blockchainHelpers'
|
||||
import { Link } from 'react-router-dom';
|
||||
import { setFlatFileContentToState } from '../../utils/utils';
|
||||
import { StepNavigation } from '../Common/StepNavigation';
|
||||
import { NAVIGATION_STEPS, CONTRACT_TYPES } from '../../utils/constants';
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import { noDeploymentOnMainnetAlert } from '../../utils/alerts'
|
||||
const { CROWDSALE_CONTRACT } = NAVIGATION_STEPS;
|
||||
|
||||
|
||||
@inject('contractStore', 'web3Store') @observer
|
||||
export class stepOne extends React.Component {
|
||||
|
||||
|
|
|
@ -1,55 +1,40 @@
|
|||
import React from 'react'
|
||||
import '../../assets/stylesheets/application.css';
|
||||
import { Link } from 'react-router-dom'
|
||||
import { getWeb3, checkWeb3, setExistingContractParams } from '../../utils/blockchainHelpers'
|
||||
import { Link, Redirect } from 'react-router-dom'
|
||||
import { getWeb3, checkWeb3, setExistingContractParams, getNetworkVersion } from '../../utils/blockchainHelpers'
|
||||
import { stepTwo } from '../stepTwo'
|
||||
import { defaultCompanyStartDate } from './utils'
|
||||
import { getOldState, stepsAreValid, allFieldsAreValid, defaultCompanyEndDate } from '../../utils/utils'
|
||||
import { defaultCompanyEndDate } from '../../utils/utils'
|
||||
import { StepNavigation } from '../Common/StepNavigation'
|
||||
import { InputField } from '../Common/InputField'
|
||||
import { InputFieldExt } from '../Common/InputFieldExt'
|
||||
import { RadioInputField } from '../Common/RadioInputField'
|
||||
import { CrowdsaleBlock } from '../Common/CrowdsaleBlock'
|
||||
import { WhitelistInputBlock } from '../Common/WhitelistInputBlock'
|
||||
import { NAVIGATION_STEPS, VALIDATION_MESSAGES, VALIDATION_TYPES, TEXT_FIELDS, intitialStepThreeValidations, CONTRACT_TYPES } from '../../utils/constants'
|
||||
import { NAVIGATION_STEPS, VALIDATION_MESSAGES, VALIDATION_TYPES, TEXT_FIELDS, CONTRACT_TYPES } from '../../utils/constants'
|
||||
import { inject, observer } from 'mobx-react'
|
||||
import { noDeploymentOnMainnetAlert, warningOnMainnetAlert } from '../../utils/alerts'
|
||||
const { CROWDSALE_SETUP } = NAVIGATION_STEPS
|
||||
const { EMPTY, VALID, INVALID } = VALIDATION_TYPES
|
||||
const { START_TIME, END_TIME, MINCAP, RATE, SUPPLY, WALLET_ADDRESS, CROWDSALE_SETUP_NAME, ALLOWMODIFYING, DISABLEWHITELISTING } = TEXT_FIELDS
|
||||
//stores to get
|
||||
//contracts
|
||||
//crowdsale
|
||||
//validations
|
||||
//pricing strategy
|
||||
//crowdsaleBlockListStore
|
||||
//web3,
|
||||
//tierCrowdsaleListStore
|
||||
|
||||
@inject('contractStore', 'crowdsaleBlockListStore', 'pricingStrategyStore', 'web3Store', 'tierStore') @observer
|
||||
export class stepThree extends React.Component{
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const { contractStore, crowdsaleBlockListStore, tierStore } = props
|
||||
window.scrollTo(0, 0);
|
||||
// const oldState = getOldState(props, defaultState)
|
||||
if (contractStore.crowdsale.addr.length > 0) {
|
||||
contractStore.setContractProperty('pricingStrategy','addr',[]);
|
||||
setExistingContractParams(contractStore.abi, contractStore.addr[0], contractStore.setContractProperty);
|
||||
}
|
||||
// oldState.children = [];
|
||||
crowdsaleBlockListStore.emptyList()
|
||||
tierStore.setTierProperty("Tier 1", 'name', 0)
|
||||
// oldState.crowdsale[0].tier = "Tier 1"
|
||||
tierStore.setTierProperty( "off", 'updatable', 0)
|
||||
// oldState.crowdsale[0].updatable = "off"
|
||||
tierStore.setTierProperty( "yes", 'whitelistdisabled', 0)
|
||||
// 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() {
|
||||
// let newState = {...this.state}
|
||||
const { crowdsaleBlockListStore, tierStore } = this.props
|
||||
let num = crowdsaleBlockListStore.blockList.length + 1;
|
||||
const newTier = {
|
||||
|
@ -97,6 +82,14 @@ export class stepThree extends React.Component{
|
|||
pricingStrategyStore.setStrategyProperty(value, property, index);
|
||||
}
|
||||
|
||||
gotoDeploymentStage() {
|
||||
console.log("###gotoDeploymentStage###");
|
||||
let state = this.state;
|
||||
state.redirect = true;
|
||||
console.log(state);
|
||||
this.setState(state);
|
||||
}
|
||||
|
||||
addCrowdsaleBlock(num) {
|
||||
this.props.crowdsaleBlockListStore.addCrowdsaleItem(
|
||||
<CrowdsaleBlock num = {num}/>
|
||||
|
@ -107,43 +100,29 @@ export class stepThree extends React.Component{
|
|||
return <Link to={{ pathname: '/4', query: { changeState: this.changeState } }}><a className="button button_fill">Continue</a></Link>
|
||||
}
|
||||
|
||||
/*renderStandardLinkComponent () {
|
||||
if(stepsAreValid(this.state.validations) || allFieldsAreValid('crowdsale', this.state)){
|
||||
return this.renderStandardLink()
|
||||
}
|
||||
return <div onClick={() => this.showErrorMessages('crowdsale')} className="button button_fill"> Continue</div>
|
||||
}
|
||||
|
||||
renderLink () {
|
||||
return <div>
|
||||
<div onClick={() => this.addCrowdsale()} className="button button_fill_secondary"> Add Tier</div>
|
||||
<Link to={{ pathname: '/4', query: { state: this.state, changeState: this.changeState } }}><a className="button button_fill">Continue</a></Link>
|
||||
</div>
|
||||
}*/
|
||||
}
|
||||
|
||||
renderStandardLinkComponent () {
|
||||
if(this.props.tierStore.areTiersValid){
|
||||
console.log('steeeeeep 33333')
|
||||
return this.renderStandardLink()
|
||||
}
|
||||
console.log('not valid')
|
||||
return <div onClick={() => this.showErrorMessages('crowdsale')} className="button button_fill"> Continue</div>
|
||||
}
|
||||
|
||||
renderLink () {
|
||||
console.log('render link four')
|
||||
return <div>
|
||||
<div onClick={() => this.addCrowdsale()} className="button button_fill_secondary"> Add Tier</div>
|
||||
<Link to={{ pathname: '/4', query: { state: this.state, changeState: this.changeState } }}><a className="button button_fill">Continue</a></Link>
|
||||
<div onClick={() => warningOnMainnetAlert(this.state.crowdsale.length, () => this.gotoDeploymentStage())} className="button button_fill"> Continue</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
renderLinkComponent () {
|
||||
//console.log(`stepsAreValid(this.state.validations) || allFieldsAreValid('crowdsale', this.state)`, stepsAreValid(this.state.validations), allFieldsAreValid('crowdsale', this.state))
|
||||
if(this.props.tierStore.areTiersValid){
|
||||
// console.log('step 3 is valididididididididididididididididi')
|
||||
return this.renderLink()
|
||||
}
|
||||
|
||||
console.log('not valid')
|
||||
return <div>
|
||||
<div onClick={() => this.addCrowdsale()} className="button button_fill_secondary"> Add Tier</div>
|
||||
|
@ -161,9 +140,6 @@ export class stepThree extends React.Component{
|
|||
|
||||
render() {
|
||||
const { contractStore, pricingStrategyStore, crowdsaleBlockListStore, tierStore } = this.props
|
||||
const validations = crowdsaleBlockListStore.validCrowdsales
|
||||
// let { pricingStrategy } = this.state
|
||||
// console.log('this.state.contractType', this.state.contractType)
|
||||
let globalSettingsBlock = <div><div className="section-title">
|
||||
<p className="title">Global limits</p>
|
||||
</div>
|
||||
|
|
|
@ -7,6 +7,7 @@ import { InputField } from '../Common/InputField'
|
|||
import { ReservedTokensInputBlock } from '../Common/ReservedTokensInputBlock'
|
||||
import { NAVIGATION_STEPS, VALIDATION_MESSAGES, TEXT_FIELDS } from '../../utils/constants'
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import { noDeploymentOnMainnetAlert } from '../../utils/alerts'
|
||||
const { TOKEN_SETUP } = NAVIGATION_STEPS
|
||||
const { NAME, TICKER, DECIMALS } = TEXT_FIELDS
|
||||
|
||||
|
@ -22,33 +23,6 @@ export class stepTwo extends Component {
|
|||
console.log('error', this.props.tokenStore, this.props.tokenStore.validToken, this.props.tokenStore.isTokenValid)
|
||||
this.props.tokenStore.invalidateToken();
|
||||
}
|
||||
|
||||
//depreciated
|
||||
/*setBlockTimes = (key, property, targetTime) => {
|
||||
let newState = { ...this.state }
|
||||
calculateFutureBlock(targetTime, this.state.blockTimeGeneration, (targetBlock) => {
|
||||
if (property === "startTime") {
|
||||
newState.crowdsale[key].startBlock = targetBlock;
|
||||
console.log("startBlock: " + newState.crowdsale[key].startBlock);
|
||||
} else if (property === "endTime") {
|
||||
newState.crowdsale[key].endBlock = targetBlock;
|
||||
console.log("endBlock: " + newState.crowdsale[key].endBlock);
|
||||
}
|
||||
this.setState(newState);
|
||||
});
|
||||
}*/
|
||||
|
||||
/*getNewParent (property, parent, key, value) {
|
||||
if( Object.prototype.toString.call( {...this.state[`${parent}`]} ) === '[object Array]' ) {
|
||||
let newParent = { ...this.state[`${parent}`][key] }
|
||||
newParent[property][key] = value
|
||||
return newParent
|
||||
} else {
|
||||
let newParent = { ...this.state[`${parent}`] }
|
||||
newParent[property] = value
|
||||
return newParent
|
||||
}
|
||||
}*/
|
||||
|
||||
updateTokenStore = (event, property) => {
|
||||
const value = event.target.value;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
let abi = require("ethereumjs-abi");
|
||||
let reaplaceAll = require("replaceall");
|
||||
|
||||
window.abi = abi;
|
||||
window.reaplaceAll = reaplaceAll;
|
|
@ -82,4 +82,33 @@ export function incorrectNetworkAlert(correctNetworkName, incorrectNetworkName)
|
|||
html: true,
|
||||
type: "warning"
|
||||
});
|
||||
}
|
||||
|
||||
export function noDeploymentOnMainnetAlert() {
|
||||
sweetAlert({
|
||||
title: "Warning",
|
||||
text: "Wizard is under maintenance on Ethereum Mainnet. Please come back later or use Kovan/Rinkeby/Oracles. Follow <a href='https://twitter.com/oraclesorg'>https://twitter.com/oraclesorg</a> for status.",
|
||||
html: true,
|
||||
type: "warning"
|
||||
});
|
||||
}
|
||||
|
||||
export function warningOnMainnetAlert(tiersCount, cb) {
|
||||
let n = 100 //fraction to round
|
||||
let estimatedCost = 1.0 / n * Math.ceil(n * tiersCount * 0.16)
|
||||
let estimatedTxsCount = tiersCount * 12
|
||||
sweetAlert({
|
||||
title: "Warning",
|
||||
text: "You are about to sign " + estimatedTxsCount + " TXs. You will see an individual Metamask windows for each of it. Please don't open two or more instances of Wizard in one browser. ICO Wizard will create " + tiersCount + "-tier(s) crowdsale for you. The total cost will be around " + estimatedCost + " ETH. Are you sure you want to proceed?",
|
||||
html: true,
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Yes, I am sure!',
|
||||
cancelButtonText: "No, cancel it!",
|
||||
},
|
||||
function(isConfirm) {
|
||||
if (isConfirm) {
|
||||
cb();
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import Web3 from 'web3';
|
||||
import { incorrectNetworkAlert, noContractAlert, noMetaMaskAlert, invalidNetworkIDAlert } from './alerts'
|
||||
import { incorrectNetworkAlert, noMetaMaskAlert, invalidNetworkIDAlert } from './alerts'
|
||||
import { getEncodedABIClientSide } from './microservices'
|
||||
import { toFixed } from '../utils/utils'
|
||||
import { GAS_PRICE } from './constants'
|
||||
|
||||
// instantiate new web3 instance
|
||||
const web3 = new Web3();
|
||||
|
@ -17,15 +17,19 @@ export function checkWeb3(web3) {
|
|||
setTimeout(function() {
|
||||
getWeb3((web3) => {
|
||||
if (!web3) return noMetaMaskAlert();
|
||||
if (web3.eth.accounts.length === 0) {
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
web3.eth.getAccounts().then((accounts) => {
|
||||
if (accounts.length === 0) {
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
});
|
||||
});
|
||||
}, 500);
|
||||
} else {
|
||||
if (web3.eth.accounts.length === 0) {
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
web3.eth.getAccounts().then((accounts) => {
|
||||
if (accounts.length === 0) {
|
||||
return noMetaMaskAlert();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,11 +56,7 @@ export function checkNetWorkByID(web3, _networkIdFromGET) {
|
|||
if (!_networkIdFromGET) {
|
||||
return invalidNetworkIDAlert();
|
||||
}
|
||||
web3.version.getNetwork(function(err, _networkIdFromNetwork) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
web3.eth.net.getId().then((_networkIdFromNetwork) => {
|
||||
let networkNameFromGET = getNetWorkNameById(_networkIdFromGET);
|
||||
let networkNameFromNetwork = getNetWorkNameById(_networkIdFromNetwork);
|
||||
if (networkNameFromGET !== networkNameFromNetwork) {
|
||||
|
@ -66,26 +66,6 @@ export function checkNetWorkByID(web3, _networkIdFromGET) {
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
//depreciated
|
||||
export function calculateFutureBlock(targetTime, blockTimeGeneration, cb) {
|
||||
getWeb3((web3) => {
|
||||
web3.eth.getBlockNumber(function(err, curBlock) {
|
||||
if (err) return console.log(err);
|
||||
|
||||
let curTime = new Date();
|
||||
|
||||
let curTimeInSec = curTime.getTime()/1000;
|
||||
let targetTimeInSec = targetTime/1000;
|
||||
let timeDiffInSec = targetTimeInSec - curTimeInSec;
|
||||
let targetBlockDiff = Math.round(timeDiffInSec / blockTimeGeneration, 0);
|
||||
let targetBlock = curBlock + targetBlockDiff;
|
||||
cb(targetBlock);
|
||||
});
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
function getNetWorkNameById(_id) {
|
||||
console.log(_id);
|
||||
switch (parseInt(_id, 10)) {
|
||||
|
@ -114,12 +94,7 @@ function getNetWorkNameById(_id) {
|
|||
}
|
||||
|
||||
export function getNetworkVersion(web3, cb) {
|
||||
web3.version.getNetwork(function(err, netId) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
cb(null);
|
||||
}
|
||||
|
||||
web3.eth.net.getId().then((netId) => {
|
||||
cb(netId);
|
||||
});
|
||||
}
|
||||
|
@ -141,17 +116,6 @@ export function setExistingContractParams(abi, addr, setContractProperty) {
|
|||
// }
|
||||
});
|
||||
|
||||
/*propsCount++;
|
||||
crowdsaleContract.pricingStrategy.call(function(err, pricingStrategyAddr) {
|
||||
cbCount++;
|
||||
console.log("pricingStrategyAddr: " + pricingStrategyAddr);
|
||||
state.contracts.pricingStrategy.addr = pricingStrategyAddr;
|
||||
|
||||
if (propsCount == cbCount) {
|
||||
$this.setState(state);
|
||||
}
|
||||
});*/
|
||||
|
||||
propsCount++;
|
||||
crowdsaleContract.multisigWallet.call(function(err, multisigWalletAddr) {
|
||||
cbCount++;
|
||||
|
@ -172,60 +136,140 @@ export function deployContract(i, web3, abi, bin, params, state, cb) {
|
|||
getEncodedABIClientSide(web3, abi, params, i, (ABIencoded) => {
|
||||
console.log(ABIencoded);
|
||||
let binFull = bin + ABIencoded.substr(2);
|
||||
//console.log(binFull);
|
||||
web3.eth.estimateGas({
|
||||
from: web3.eth.accounts[0],
|
||||
data: binFull
|
||||
}, function(err, estimatedGas) {
|
||||
console.log('estimated gas callback', estimatedGas)
|
||||
if (err) console.log('errrrrrrrrrrrrrrrrr', err);
|
||||
console.log('gas is estimated', estimatedGas, 'err', err)
|
||||
let estimatedGasMax = 3716260;
|
||||
if (!estimatedGas) estimatedGas = estimatedGasMax;
|
||||
else estimatedGas += 100000;
|
||||
web3.eth.getAccounts().then(function(accounts) {
|
||||
web3.eth.estimateGas({
|
||||
from: accounts[0],
|
||||
data: binFull
|
||||
}, function(err, estimatedGas) {
|
||||
if (err) console.log('errrrrrrrrrrrrrrrrr', err);
|
||||
console.log('gas is estimated', estimatedGas, 'err', err)
|
||||
let estimatedGasMax = 3716260;
|
||||
if (!estimatedGas) estimatedGas = estimatedGasMax;
|
||||
if (estimatedGas > estimatedGasMax) estimatedGas = estimatedGasMax;
|
||||
else estimatedGas += 100000;
|
||||
|
||||
if (estimatedGas > estimatedGasMax) estimatedGas = estimatedGasMax;
|
||||
|
||||
var contractInstance = web3.eth.contract(abi);
|
||||
var opts = {
|
||||
from: web3.eth.accounts[0],
|
||||
data: "0x" + bin,
|
||||
gas: estimatedGas,
|
||||
gasPrice: 21000000000
|
||||
};
|
||||
var totalParams = params;
|
||||
totalParams.push(opts);
|
||||
totalParams.push(deployContractCB);
|
||||
console.log('totalParams', totalParams);
|
||||
contractInstance.new(...totalParams);
|
||||
let contractInstance = new web3.eth.Contract(abi);
|
||||
|
||||
function deployContractCB(err, contract) {
|
||||
if (err) {
|
||||
return cb(err, null);
|
||||
}
|
||||
if (contract) {
|
||||
console.log(contract);
|
||||
if (contract.address) {
|
||||
console.log(contract);
|
||||
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
|
||||
cb(null, contract.address);
|
||||
}
|
||||
else if (contract.transactionHash) {
|
||||
checkTxMined(web3, contract.transactionHash, function txMinedCallback(receipt) {
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber)
|
||||
return cb(null, receipt.contractAddress);
|
||||
let deployOpts = {
|
||||
data: "0x" + bin,
|
||||
arguments: params
|
||||
};
|
||||
|
||||
let sendOpts = {
|
||||
from: accounts[0],
|
||||
gas: estimatedGas,
|
||||
gasPrice: GAS_PRICE
|
||||
};
|
||||
|
||||
let isMined = false;
|
||||
|
||||
contractInstance.deploy(deployOpts).send(sendOpts)
|
||||
//contractInstance.new(...totalParams)
|
||||
.on('error', function(error) {
|
||||
console.log(error);
|
||||
return cb(error, null);
|
||||
})
|
||||
.on('transactionHash', function(transactionHash){
|
||||
console.log("contract deployment transaction: " + transactionHash);
|
||||
|
||||
checkTxMined(web3, transactionHash, function txMinedCallback(receipt) {
|
||||
if (isMined) return;
|
||||
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
console.log("Contract deployment is mined from polling of tx receipt");
|
||||
isMined = true;
|
||||
console.log(receipt.contractAddress) // instance with the new contract address
|
||||
return cb(null, receipt.contractAddress);
|
||||
} else {
|
||||
setTimeout(checkTxMined(web3, contract.transactionHash, txMinedCallback), 1000);
|
||||
console.log("Still mining... Polling of transaction once more");
|
||||
setTimeout(function() {
|
||||
checkTxMined(web3, transactionHash, txMinedCallback)
|
||||
}, 5000);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log("Still mining... Polling of transaction once more");
|
||||
setTimeout(function() {
|
||||
checkTxMined(web3, transactionHash, txMinedCallback)
|
||||
}, 5000);
|
||||
}
|
||||
})
|
||||
})
|
||||
/*.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);
|
||||
}*/
|
||||
|
||||
})
|
||||
.then(function(newContractInstance){
|
||||
if (!isMined) {
|
||||
console.log("Contract deployment is mined from Promise");
|
||||
isMined = true;
|
||||
console.log(newContractInstance.options.address) // instance with the new contract address
|
||||
cb(null, newContractInstance.options.address);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function sendTXToContract(web3, method, cb) {
|
||||
let isMined = false;
|
||||
method
|
||||
//contractInstance.new(...totalParams)
|
||||
.on('error', function(error) {
|
||||
console.log(error);
|
||||
return cb(error);
|
||||
})
|
||||
.on('transactionHash', function(transactionHash){
|
||||
console.log("contract method transaction: " + transactionHash);
|
||||
|
||||
checkTxMined(web3, transactionHash, function txMinedCallback(receipt) {
|
||||
if (isMined) return;
|
||||
|
||||
if (receipt) {
|
||||
if (receipt.blockNumber) {
|
||||
console.log("Sending tx to contract is mined from polling of tx receipt");
|
||||
isMined = true;
|
||||
console.log(receipt) // instance with the new contract address
|
||||
return cb();
|
||||
} else {
|
||||
console.log("Still mining... Polling of transaction once more");
|
||||
setTimeout(function() {
|
||||
checkTxMined(web3, transactionHash, txMinedCallback)
|
||||
}, 5000);
|
||||
}
|
||||
} else {
|
||||
console.log("Still mining... Polling of transaction once more");
|
||||
setTimeout(function() {
|
||||
checkTxMined(web3, transactionHash, txMinedCallback)
|
||||
}, 5000);
|
||||
}
|
||||
})
|
||||
})
|
||||
/*.on('receipt', function(receipt){
|
||||
})*/
|
||||
.on('confirmation', function(confirmationNumber, receipt){
|
||||
})
|
||||
.then(function(result){
|
||||
if (!isMined) {
|
||||
console.log("Sending tx to contract is mined from Promise");
|
||||
isMined = true;
|
||||
console.log(result) // instance with the new contract address
|
||||
cb();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function checkTxMined(web3, txhash, cb) {
|
||||
web3.eth.getTransactionReceipt(txhash, function(err, receipt) {
|
||||
if (receipt)
|
||||
|
@ -235,18 +279,19 @@ export function checkTxMined(web3, txhash, cb) {
|
|||
}
|
||||
|
||||
export function attachToContract(web3, abi, addr, cb) {
|
||||
if(!web3.isConnected()) {
|
||||
if (cb) cb({code: 200, title: "Error", message: "check RPC availability"});
|
||||
} else {
|
||||
web3.eth.defaultAccount = web3.eth.accounts[0];
|
||||
web3.eth.getAccounts().then((accounts) => {
|
||||
web3.eth.defaultAccount = accounts[0];
|
||||
console.log("web3.eth.defaultAccount:" + web3.eth.defaultAccount);
|
||||
|
||||
var MyContract = web3.eth.contract(abi);
|
||||
let contractInstance = new web3.eth.Contract(abi, addr, {
|
||||
from: web3.eth.defaultAccount
|
||||
});
|
||||
|
||||
var contractInstance = MyContract.at(addr);
|
||||
//console.log(contractInstance);
|
||||
//console.log(contractInstance.options);
|
||||
|
||||
if (cb) cb(null, contractInstance);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// export web3 object instance
|
||||
|
|
|
@ -55,6 +55,12 @@ export const CONTRACT_TYPES = {
|
|||
whitelistwithcap: "white-list-with-cap"
|
||||
}
|
||||
|
||||
export const TRUNC_TO_DECIMALS = {
|
||||
DECIMALS18: -18
|
||||
}
|
||||
|
||||
export const GAS_PRICE = 5000000000
|
||||
|
||||
export const NAVIGATION_STEPS = {
|
||||
CROWDSALE_CONTRACT: 'Crowdsale Contract',
|
||||
TOKEN_SETUP: 'Token Setup',
|
||||
|
@ -186,4 +192,4 @@ export const FILE_CONTENTS = [
|
|||
]
|
||||
|
||||
export const DOWNLOAD_NAME = 'contractInfo'
|
||||
export const DOWNLOAD_TYPE = 'text/plain'
|
||||
export const DOWNLOAD_TYPE = 'text/plain'
|
||||
|
|
|
@ -1,31 +1,8 @@
|
|||
import { findConstructor, getconstructorParams, toFixed } from '../utils/utils'
|
||||
//import $ from 'jquery'
|
||||
|
||||
//depreciated
|
||||
/*export function getEncodedABIServerSide(abi, state, vals, crowdsaleNum, cb) {
|
||||
const abiConstructor = findConstructor(abi, state)
|
||||
let params = getconstructorParams(abiConstructor, state, vals, crowdsaleNum);
|
||||
$.ajax({
|
||||
url:"https://ico-wizard-encoded-abi.herokuapp.com",
|
||||
type:"POST",
|
||||
data:JSON.stringify(params),
|
||||
contentType:"application/json; charset=utf-8",
|
||||
dataType:"json"
|
||||
}).done((data) => {
|
||||
cb(data.body.ABIencoded);
|
||||
}).fail(function(err) {
|
||||
console.log('failfailfail',err);
|
||||
})
|
||||
}*/
|
||||
|
||||
export function getEncodedABIClientSide(web3, abi, vals, crowdsaleNum, cb) {
|
||||
//console.log(web3, abi, state, vals, crowdsaleNum);
|
||||
const abiConstructor = findConstructor(abi)
|
||||
let params = getconstructorParams(abiConstructor, vals, crowdsaleNum);
|
||||
console.log("params.types: ");
|
||||
console.log(params.types);
|
||||
console.log("params.vals: ");
|
||||
console.log(params.vals);
|
||||
getABIencoded(web3, params.types, params.vals, function(encoded) {
|
||||
cb(encoded);
|
||||
});
|
||||
|
@ -48,7 +25,6 @@ function getABIencoded(web3, types, vals, cb) {
|
|||
console.log(types);
|
||||
console.log(vals);
|
||||
|
||||
let encoded = window.abi.rawEncode(types, vals);
|
||||
console.log(encoded.toString("hex"));
|
||||
let encoded = web3.eth.abi.encodeParameters(types, vals);
|
||||
cb(encoded.toString("hex"));
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { VALIDATION_TYPES } from './constants'
|
||||
import { VALIDATION_TYPES, TRUNC_TO_DECIMALS } from './constants'
|
||||
import { contractStore, tokenStore, tierStore, web3Store } from '../stores'
|
||||
const { VALID, EMPTY, INVALID } = VALIDATION_TYPES
|
||||
|
||||
|
@ -177,43 +177,6 @@ export function getWhiteListWithCapCrowdsaleAssets(cb) {
|
|||
});
|
||||
}
|
||||
|
||||
export function getStandardCrowdsaleAssets(cb) {
|
||||
const contractName = "CrowdsaleStandard";
|
||||
var derivativesLength = 4;
|
||||
var derivativesIterator = 0;
|
||||
setFlatFileContentToState("./contracts/" + contractName + "_flat.bin", function(_bin) {
|
||||
derivativesIterator++;
|
||||
contractStore.setContractProperty('crowdsale', 'bin', _bin);
|
||||
|
||||
if (derivativesIterator === derivativesLength) {
|
||||
cb(contractStore);
|
||||
}
|
||||
});
|
||||
setFlatFileContentToState("./contracts/" + contractName + "_flat.abi", function(_abi) {
|
||||
derivativesIterator++;
|
||||
contractStore.setContractProperty('crowdsale', 'abi', JSON.parse(_abi));
|
||||
if (derivativesIterator === derivativesLength) {
|
||||
cb(contractStore);
|
||||
}
|
||||
});
|
||||
setFlatFileContentToState("./contracts/" + contractName + "Token_flat.bin", function(_bin) {
|
||||
derivativesIterator++;
|
||||
contractStore.setContractProperty('token', 'abi', _bin);
|
||||
|
||||
if (derivativesIterator === derivativesLength) {
|
||||
cb(contractStore);
|
||||
}
|
||||
});
|
||||
setFlatFileContentToState("./contracts/" + contractName + "Token_flat.abi", function(_abi) {
|
||||
derivativesIterator++;
|
||||
contractStore.setContractProperty('token', 'abi', JSON.parse(_abi));
|
||||
|
||||
if (derivativesIterator === derivativesLength) {
|
||||
cb(contractStore);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function readSolFile(path, cb) {
|
||||
var rawFile = new XMLHttpRequest();
|
||||
rawFile.open("GET", path, true);
|
||||
|
@ -258,13 +221,13 @@ export const getconstructorParams = (abiConstructor, vals, crowdsaleNum) => {
|
|||
params.vals.push(tierStore.tiers[crowdsaleNum].startBlock);
|
||||
} break;
|
||||
case "_start": {
|
||||
params.vals.push(new Date(tierStore.tiers[crowdsaleNum].startTime).getTime()/1000);
|
||||
params.vals.push(toFixed(new Date(tierStore.tiers[crowdsaleNum].startTime).getTime()/1000).toString());
|
||||
} break;
|
||||
case "_endBlock": {
|
||||
params.vals.push(tierStore.tiers[crowdsaleNum].endBlock);
|
||||
} break;
|
||||
case "_end": {
|
||||
params.vals.push(new Date(tierStore.tiers[crowdsaleNum].endTime).getTime()/1000);
|
||||
params.vals.push(toFixed(new Date(tierStore.tiers[crowdsaleNum].endTime).getTime()/1000).toString());
|
||||
} break;
|
||||
case "_rate": {
|
||||
params.vals.push(tierStore.tiers[crowdsaleNum].rate);
|
||||
|
@ -334,8 +297,9 @@ export const getconstructorParams = (abiConstructor, vals, crowdsaleNum) => {
|
|||
case "_oneTokenInWei": {
|
||||
//params.vals.push(state.pricingStrategy[crowdsaleNum].rate);
|
||||
//params.vals.push(state.web3.toWei(1/state.pricingStrategy[crowdsaleNum].rate/10**tokenStore.decimals, "ether"));
|
||||
params.vals.push(web3Store.web3.toWei(1/tierStore.tiers[crowdsaleNum].rate, "ether"));
|
||||
} break;
|
||||
let oneTokenInETHRaw = 1/tierStore.tiers[crowdsaleNum].rate
|
||||
let oneTokenInETH = floorToDecimals(TRUNC_TO_DECIMALS.DECIMALS18, oneTokenInETHRaw)
|
||||
params.vals.push(web3Store.web3.utils.toWei(oneTokenInETH, "ether")); } break;
|
||||
case "_isUpdatable": {
|
||||
params.vals.push(tierStore.tiers[crowdsaleNum].updatable?tierStore.tiers[crowdsaleNum].updatable=="on"?true:false:false);
|
||||
} break;
|
||||
|
@ -351,6 +315,28 @@ export const getconstructorParams = (abiConstructor, vals, crowdsaleNum) => {
|
|||
return params;
|
||||
}
|
||||
|
||||
export const floorToDecimals = (n, input) => Math.floor10(input, n)
|
||||
|
||||
const decimalAdjust = (type, inputNumber, exp) => {
|
||||
if (typeof exp === 'undefined' || +exp === 0) {
|
||||
return Math[type](inputNumber);
|
||||
}
|
||||
inputNumber = +inputNumber;
|
||||
exp = +exp;
|
||||
let checkForNaN = isNaN(inputNumber) || !(typeof exp === 'number' && exp % 1 === 0);
|
||||
if (checkForNaN) {
|
||||
return NaN;
|
||||
}
|
||||
inputNumber = inputNumber.toString().split('e');
|
||||
inputNumber = Math[type](+(inputNumber[0] + 'e' + (inputNumber[1] ? (+inputNumber[1] - exp) : -exp)));
|
||||
inputNumber = inputNumber.toString().split('e');
|
||||
return +(inputNumber[0] + 'e' + (inputNumber[1] ? (+inputNumber[1] + exp) : exp));
|
||||
}
|
||||
|
||||
if (!Math.floor10) {
|
||||
Math.floor10 = (value, exp) => decimalAdjust('floor', value, exp)
|
||||
}
|
||||
|
||||
const getTimeAsNumber = (time) => new Date(time).getTime()
|
||||
|
||||
export const getOldState = (props, defaultState) => props && props.location && props.location.query && props.location.query.state || defaultState
|
||||
|
@ -490,4 +476,4 @@ export function defaultCompanyEndDate(startDate) {
|
|||
let endDate = new Date(startDate).setDate(new Date(startDate).getDate() + 4);
|
||||
endDate = new Date(endDate).setUTCHours(0);
|
||||
return new Date(endDate).toISOString().split(".")[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 45b8203eaad8e88078ad80a34c8ee2de2b33e8c3
|
||||
Subproject commit 6ed5e2084ea8bdc30caa4d5503dea0e49e405e53
|
|
@ -1 +1 @@
|
|||
Subproject commit 0e58cb485cd3434e91ffe8699bb767e340b634fa
|
||||
Subproject commit 78ea9a755505b5a07edf4d6768f6fdc1704dd995
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 245f51e6cdd27ff5902906064be59ebcbad50fe3
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"allowJs": true
|
||||
}
|
||||
}
|