Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Oct 8, 2017
2 parents fe5457c + 6a64981 commit 9fee714
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 50 deletions.
2 changes: 1 addition & 1 deletion log/stress_0200.log
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type gasUsed gasPrice 1ETH*USD gasUsed*gasPrice(Ether) gasUsed*gasPrice(USD)
create 1692580 2 303 0.00338516 1.02570348
register 119815 2 303 0.00023963 0.07260789000000001
batchAttend 2968867 2 303 0.005937734 1.799133402
batchAttend 2969251 2 303 0.005938502 1.799366106
payback 84325 2 303 0.00016865 0.05110095
withdraw 37660 2 303 0.00007532 0.022821960000000002
16 changes: 11 additions & 5 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ let name = ''; // empty name falls back to the contract default
let deposit = 0; // 0 falls back to the contract default
let limitOfParticipants = 0; // 0 falls back to the contract default
let confirmationAddress = 0;

// eg: truffle migrate --config '{"name":"CodeUp No..", "encryption":"./tmp/test_public.key", "confirmation":true}'
if (yargs.argv.config) {
var config = JSON.parse(yargs.argv.config);
}

module.exports = function(deployer) {
const app_config = require('../app_config.js')[deployer.network];
console.log('app_config', app_config)

if (deployer.network == 'test') return 'no need to deploy contract';
if (config.name){
name = config.name;
Expand All @@ -28,10 +30,14 @@ module.exports = function(deployer) {
deployer
.then(() => {
if (config.confirmation) {
return deployer.deploy(ConfirmationRepository)
.then(instance => {
confirmationAddress = ConfirmationRepository.address;
})
if (app_config && app_config.contract_addresses['ConfirmationRepository']) {
confirmationAddress = app_config.contract_addresses['ConfirmationRepository'];
}else{
return deployer.deploy(ConfirmationRepository)
.then(instance => {
confirmationAddress = ConfirmationRepository.address;
})
}
}
})
.then(() => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"material-ui": "^0.15.2",
"mathjs": "^3.2.1",
"moment": "^2.18.1",
"prompt": "^1.0.0",
"react": "15.3.2",
"react-addons-css-transition-group": "^15.1.0",
"react-dom": "15.3.2",
Expand Down
5 changes: 3 additions & 2 deletions scripts/change_owner.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
let arg = require('yargs').argv;
let fs = require('fs');
let Conference = artifacts.require("./Conference.sol");
let setGas = require('./util/set_gas');
let setContract = require('./util/set_contract');

if (!(arg.f && arg.t)) {
throw('usage: truffle exec scripts/change_owner.js -f original_owner.txt -t address_to_change.txt');
}
Expand All @@ -11,7 +12,7 @@ module.exports = async function() {
let from = fs.readFileSync(arg.f, 'utf8').trim().split('\n')[0];
let to = fs.readFileSync(arg.t, 'utf8').trim().split('\n')[0];
console.log('Changing ownership from ', from, ' to ', to);
let conference = await Conference.deployed();
const conference = await setContract(artifacts, 'Conference');
let owner = await conference.owner.call();
console.log('owner', owner, from, owner === from)
if (owner != from) {
Expand Down
3 changes: 2 additions & 1 deletion scripts/decrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports = async function(callback) {
if (contractAccount) {
conference = await Conference.at(contractAccount);
}else{
conference = await Conference.deployed();
let setContract = require('./util/set_contract');
conference = await setContract(artifacts, 'Conference');
}
let event = conference.RegisterEvent({}, {fromBlock:fromBlock});
console.log(['regisered at ', '@twitter', 'full name'].join('\t'));
Expand Down
24 changes: 12 additions & 12 deletions scripts/repository.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
let fs = require('fs');
let setGas = require('./util/set_gas');
let setContract = require('./util/set_contract');
let ConfirmationRepository = artifacts.require("./ConfirmationRepository.sol");

let repository;
let arg = require('yargs').argv;

if (!(arg.i && arg.t)) {
throw('usage: truffle exec scripts/repository.js -t confirmation -i codes.txt');
if (!(arg.i)) {
throw('usage: truffle exec scripts/repository.js -i codes.txt');
}

module.exports = async function(callback) {
let gas = await setGas(web3);
let file = arg.i;
console.log('file', file)
switch (arg.t) {
case 'confirmation':
repository = await ConfirmationRepository.deployed();
console.log('repository', repository.address)
break;
default:
throw('-t must be either confirmation');
const gas = await setGas(web3);
const conference = await setContract(artifacts, 'Conference');
const repositoryAddress = await conference.confirmationRepository.call();
if (!repositoryAddress) {
throw("repository address does not exist")
}
const repository = await ConfirmationRepository.at(repositoryAddress);
let file = arg.i;

let codes = fs.readFileSync(file, 'utf8').trim().split('\n');
let encrypted_codes = [];
for (var i = 0; i < codes.length; i++) {
Expand Down
47 changes: 18 additions & 29 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,29 @@ function setup(){

window.onload = function() {
setup().then(({provider, web3, read_only, network_id}) => {
var env;
switch (network_id) {
case '1':
env = 'mainnet';
break;
case '3':
env = 'ropsten';
break;
default:
env = 'development';
}
var network_obj = require('../app_config.js')[env];

var Conference = TruffleContract(artifacts);
let contract, contractAddress;
Conference.setProvider(provider);
Conference.setNetwork(network_id);
try {
contract = Conference.at(Conference.address);
if (network_obj.contract_addresses['Conference']) {
contract = Conference.at(network_obj.contract_addresses['Conference']);
}else{
contract = Conference.at(Conference.address);
}
} catch (e) {
console.log("ERROR")
console.log(e)
Expand All @@ -96,34 +113,6 @@ window.onload = function() {
window.web3 = web3
const eventEmitter = EventEmitter()

var network_obj;
switch (network_id) {
case '1':
network_obj = {
name: 'MAINNET',
etherscan_url: 'https://etherscan.io'
}
break;
case '3':
network_obj = {
name: 'ROPSTEN NET',
etherscan_url: 'https://ropsten.etherscan.io'
}
break;
case '42':
network_obj = {
name: 'KOVAN NET',
etherscan_url: 'https://kovan.etherscan.io'
}
break;
default:
network_obj = {
name: 'PRIVATE NET',
etherscan_url: null
}

}

function getBalance(address){
return new Promise(function(resolve,reject){
web3.eth.getBalance(address, function(err, result){
Expand Down

0 comments on commit 9fee714

Please sign in to comment.