Merge pull request #1 from oraclesorg/master

Get updates
This commit is contained in:
BokkyPooBah 2017-11-15 18:16:55 +11:00 committed by GitHub
commit 38f87d3eac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 2520 additions and 932 deletions

View File

@ -51,8 +51,10 @@ parity --jsonrpc-port 8549 --chain kovan --unlock 0x0039F22efB07A647557C7C5d1785
```
5. Copy list of addresses into [scripts/ARRAY_OF_ADDRESSES.json](scripts/ARRAY_OF_ADDRESSES.json)
6. run `node whitelist.js`
The script will show you how many total transactions will be generated
Caution:
### Caution:
If you see this error:
```diff
- Unhandled rejection Error: Transaction was not mined within 50 blocks, please make sure your transaction was properly send. Be aware that it might still be mined!
@ -121,13 +123,14 @@ it's totally ok because the transaction is still in the queue and hasn't been mi
```
# Testnet deployment
=====
## Latest Contract deployment
https://kovan.etherscan.io/address/0x6f3f79941f89e03d4af9bdb8be0623dc24f2bef0
=====
## Latest Contract deployments
With Claimable:
https://kovan.etherscan.io/address/0x985dbb1c5dda22ff9d529abc1c3539bc525943f4#code
## Previous deployments with old source code:
https://kovan.etherscan.io/address/0x6f3f79941f89e03d4af9bdb8be0623dc24f2bef0
Contract Deployment: https://kovan.etherscan.io/address/0xb9b49e21e77d2d89a9e4c7ef4f684ad2a4e99663#code
Called Initialize by Owner with params:

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
import "zeppelin-solidity/contracts/math/SafeMath.sol";
import "zeppelin-solidity/contracts/token/BasicToken.sol";
import "zeppelin-solidity/contracts/ownership/Ownable.sol";
import "zeppelin-solidity/contracts/token/ERC20Basic.sol";
import "zeppelin-solidity/contracts/ownership/Claimable.sol";
pragma solidity ^0.4.17;
pragma solidity ^0.4.18;
contract PresaleOracles is Ownable {
contract PresaleOracles is Claimable {
/*
* PresaleOracles
* Simple Presale contract
@ -14,7 +14,6 @@ contract PresaleOracles is Ownable {
uint256 public startTime;
uint256 public endTime;
uint256 public cap;
uint256 public rate;
uint256 public totalInvestedInWei;
uint256 public minimumContribution;
mapping(address => uint256) public investorBalances;
@ -47,6 +46,7 @@ contract PresaleOracles is Ownable {
vault = _vault;
}
//TESTED by Roman Storm
event Contribution(address indexed investor, uint256 investorAmount, uint256 investorTotal, uint256 totalAmount);
function buy() public payable {
require(whitelist[msg.sender]);
require(isValidPurchase(msg.value));
@ -56,6 +56,7 @@ contract PresaleOracles is Ownable {
investorBalances[investor] += msg.value;
totalInvestedInWei += msg.value;
forwardFunds(msg.value);
Contribution(msg.sender, msg.value, investorBalances[investor], totalInvestedInWei);
}
//TESTED by Roman Storm
@ -69,7 +70,7 @@ contract PresaleOracles is Ownable {
return;
}
BasicToken token = BasicToken(_token);
ERC20Basic token = ERC20Basic(_token);
uint256 balance = token.balanceOf(this);
token.transfer(owner, balance);
}

View File

@ -63,6 +63,35 @@ contract Ownable {
}
contract Claimable is Ownable {
address public pendingOwner;
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
pendingOwner = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() onlyPendingOwner public {
OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = 0x0;
}
}
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) public constant returns (uint256);
@ -70,38 +99,7 @@ contract ERC20Basic {
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
}
contract PresaleOracles is Ownable {
contract PresaleOracles is Claimable {
/*
* PresaleOracles
* Simple Presale contract
@ -111,7 +109,6 @@ contract PresaleOracles is Ownable {
uint256 public startTime;
uint256 public endTime;
uint256 public cap;
uint256 public rate;
uint256 public totalInvestedInWei;
uint256 public minimumContribution;
mapping(address => uint256) public investorBalances;
@ -144,6 +141,7 @@ contract PresaleOracles is Ownable {
vault = _vault;
}
//TESTED by Roman Storm
event Contribution(address indexed investor, uint256 investorAmount, uint256 investorTotal, uint256 totalAmount);
function buy() public payable {
require(whitelist[msg.sender]);
require(isValidPurchase(msg.value));
@ -153,6 +151,7 @@ contract PresaleOracles is Ownable {
investorBalances[investor] += msg.value;
totalInvestedInWei += msg.value;
forwardFunds(msg.value);
Contribution(msg.sender, msg.value, investorBalances[investor], totalInvestedInWei);
}
//TESTED by Roman Storm
@ -166,7 +165,7 @@ contract PresaleOracles is Ownable {
return;
}
BasicToken token = BasicToken(_token);
ERC20Basic token = ERC20Basic(_token);
uint256 balance = token.balanceOf(this);
token.transfer(owner, balance);
}

View File

@ -2,14 +2,15 @@ require('dotenv').config();
const ContributionABI = require('../build/contracts/PresaleOracles.json').abi;
// const Web3 = require('web3');
// // const MAINET_RPC_URL = 'https://mainnet.infura.io/metamask'
// // const KOVAN_RPC_URL = 'https://kovan.infura.io/metamask'
// const MAINET_RPC_URL = 'https://mainnet.infura.io/metamask'
// const KOVAN_RPC_URL = 'https://kovan.infura.io/metamask'
// const local = `http://localhost:${process.env.RPC_PORT}`;
// const provider = new Web3.providers.HttpProvider(local);
// const web3 = new Web3(provider);
// var myContract = new web3.eth.Contract(ContributionABI, '0x6F3f79941f89E03D4aF9bDb8BE0623DC24F2bef0');
// var myContract = new web3.eth.Contract(ContributionABI, process.env.PRESALE_ADDRESS);
// const ARRAY_OF_ADDRESSES = require('./ARRAY_OF_ADDRESSES.json');
// filterAddresses(ARRAY_OF_ADDRESSES).then(console.log)
// readCap();
function setup({web3Param, contribAddress}){
web3 = web3Param;
CONTRIBUTION_ADDRESS = contribAddress
@ -17,12 +18,11 @@ function setup({web3Param, contribAddress}){
}
function readCap() {
myContract.methods.cap().call().then((cap) => {
myContract.methods.investorsLength().call().then((cap) => {
console.log('cap', cap);
})
}
function isWhitelisted(toCheckAddress) {
readCap();
var count = 0;
var leftRun = toCheckAddress.length;
let notWhitelisted = [];
@ -30,7 +30,6 @@ function isWhitelisted(toCheckAddress) {
if(toCheckAddress.length === 0 || !toCheckAddress) {
rej('array is empty');
}
console.log(toCheckAddress.length)
toCheckAddress.forEach((address, index) => {
myContract.methods.whitelist(address).call().then((isWhitelisted) => {
leftRun--;
@ -39,7 +38,7 @@ function isWhitelisted(toCheckAddress) {
notWhitelisted.push(address);
}
if (leftRun === 0) {
console.log('FINISHED! notWhitelisted: ', notWhitelisted.length);
console.log('FINISHED filtering array! notWhitelisted: ', notWhitelisted.length);
res(notWhitelisted);
}
});
@ -50,7 +49,7 @@ function isWhitelisted(toCheckAddress) {
function filterAddresses(arrayOfAddresses) {
const date = Date.now();
console.log(date, 'DATE NOW', arrayOfAddresses.length);
console.log(date, 'DATE NOW, to process array length', arrayOfAddresses.length);
return new Promise((res, rej) => {
return isWhitelisted(arrayOfAddresses).then((whitelistedAddress) => {
res(whitelistedAddress);

View File

@ -1,5 +1,6 @@
require('dotenv').config();
const ARRAY_OF_ADDRESSES = require('./ARRAY_OF_ADDRESSES.json');
let ARRAY_OF_ADDRESSES = require('./ARRAY_OF_ADDRESSES.json');
ARRAY_OF_ADDRESSES = Array.from(new Set(ARRAY_OF_ADDRESSES));
const RPC_PORT = process.env.RPC_PORT;
const PRESALE_ADDRESS = process.env.PRESALE_ADDRESS;
const UNLOCKED_ADDRESS = process.env.UNLOCKED_ADDRESS;
@ -10,18 +11,8 @@ const provider = new Web3.providers.HttpProvider(`http://localhost:${RPC_PORT}`)
const web3 = new Web3(provider);
const { filterAddresses, setup } = require('./filterAddresses');
setup({ web3Param: web3, contribAddress: PRESALE_ADDRESS});
filterAddresses(ARRAY_OF_ADDRESSES).then(async (toWhitelist) => {
console.log(toWhitelist.length);
const addPerTx = 160;
const slices = Math.ceil(toWhitelist.length / addPerTx);
console.log(`THIS SCRIPT WILL GENERATE ${slices} transactions`);
var txcount = await web3.eth.getTransactionCount(UNLOCKED_ADDRESS);
const nonce = web3.utils.toHex(txcount);
console.log('STARTED', nonce);
return sendTransactionToContribution({array: toWhitelist, slice: slices, addPerTx, nonce});
}).then(console.log).catch(console.error);
setup({ web3Param: web3, contribAddress: PRESALE_ADDRESS});
const GAS_PRICE = web3.utils.toWei(process.env.GAS_PRICE, 'gwei');
const GAS_LIMIT = '6700000';
const myContract = new web3.eth.Contract(ICO_ABI, PRESALE_ADDRESS, {
@ -30,6 +21,20 @@ const myContract = new web3.eth.Contract(ICO_ABI, PRESALE_ADDRESS, {
gas: GAS_LIMIT // default gas price in wei
});
filterAddresses(ARRAY_OF_ADDRESSES).then(async (toWhitelist) => {
let currentInvestors = await myContract.methods.investorsLength().call();
currentInvestors = Number(currentInvestors.toString(10));
console.log('current whitelisted investors: ', currentInvestors);
console.log('to whitelist', toWhitelist.length);
console.log('Expected total whitelisted count after execution', toWhitelist.length + currentInvestors);
const addPerTx = 160;
const slices = Math.ceil(toWhitelist.length / addPerTx);
console.log(`THIS SCRIPT WILL GENERATE ${slices} transactions`);
var txcount = await web3.eth.getTransactionCount(UNLOCKED_ADDRESS);
const nonce = web3.utils.toHex(txcount);
console.log('STARTED', nonce);
return sendTransactionToContribution({array: toWhitelist, slice: slices, addPerTx, nonce});
}).then(console.log).catch(console.error);
async function sendTransactionToContribution({array, slice, addPerTx, nonce}) {
if(array.length === 0){
@ -58,7 +63,7 @@ async function sendTransactionToContribution({array, slice, addPerTx, nonce}) {
sendTransactionToContribution({array, slice, addPerTx, nonce});
} else {
res({ result: 'completed' });
// process.exit();
process.exit();
}
});