Commit 669dcc55 authored by Simon de la Rouviere's avatar Simon de la Rouviere

Fixes.

parent efe0c6b9
......@@ -4,15 +4,23 @@ var Pudding = require("ether-pudding");
var exported = null;
// Bootstrap
//hack it. Wait for 2 seconds.
if (typeof web3 !== 'undefined') {
// Use the Mist/wallet provider.
exported = new Web3(web3.currentProvider);
var other_web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8547'));
window.web_l = other_web3;
} else {
// Use the provider from the config.
// ENV and WEB3_PROVIDER_LOCATION are rewritten by webpack during build
if (ENV == "development") {
//exported = new Web3(new Web3.providers.HttpProvider(WEB3_PROVIDER_LOCATION));
exported = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545'));
console.log("Setting local web3");
exported = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8546'));
window.web3 = exported;
//exported = new Web3(new Web3.providers.HttpProvider('https://rawtestrpc.metamask.io/'));
}
}
......
......@@ -19,6 +19,7 @@ var TokenPage = React.createClass({
this.setState({contract_address: this.props.params.contract_address});
//var web3_token = web3_rab.eth.contract(Standard_Token.abi).at(this.props.params.contract_address); //for reflux-tx
var web3_token = web3.eth.contract(Standard_Token.abi).at(this.props.params.contract_address); //for reflux-tx
window.token_c = web3_token;
this.setState({web3_token: web3_token});
var that = this;
web3.eth.getAccounts(function(err, accounts){
......
......@@ -2,6 +2,8 @@ import React from "react";
import InputForm from "./inputform.jsx";
import { TXActions } from 'reflux-tx';
window.txa = TXActions;
var TxForm = React.createClass({
getInitialState: function() {
return {
......@@ -17,6 +19,7 @@ var TxForm = React.createClass({
for(var i = 0; i < this.props.confirmed.length; i+=1) {
if(this.props.confirmed[i].receipt.transactionHash == this.state.txHash) {
console.log(this.props.confirmed[i].receipt);
//console.log(web_l.eth.blockNumber);
this.setState({processing: false});
console.log('processed');
this.props.successful(this.state.txArgs, this.props.confirmed[i].receipt); //successful transaction with these arguments
......@@ -24,10 +27,11 @@ var TxForm = React.createClass({
}
} else {
if(this.props.pending.length > 0) {
console.log(this.props.pending);
this.setState({processing: true});
//this seems dangerous! Assumes only 1 tx at a time.
//revise
this.setState({txHash: this.props.pending[0].receipt.transactionHash});
this.setState({txHash: this.props.pending[0].data.hash});
} else if (this.props.received.length > 0) {
this.setState({processing: true});
this.setState({txHash: this.props.received[0].receipt.transactionHash});
......@@ -61,8 +65,13 @@ var TxForm = React.createClass({
var addr = accounts[0];
console.log(addr);
console.log(ST);
console.log(Standard_Token.abi);
console.log("0x"+Standard_Token.prototype.binary);
ST.new(args[0], {from: addr, data: "0x" + Standard_Token.prototype.binary, gas: 3100000}, function(err, result) {
//TODO: change gas price
var creation_data = ST.new.getData(args[0], {from: addr, data: "0x" + Standard_Token.prototype.binary, gasPrice: 50000000000, gas: 3100000});
console.log(creation_data);
console.log(args[0]);
ST.new(args[0], {from: addr, data: "0x" + Standard_Token.prototype.binary, gasPrice: 50000000000, gas: 3100000}, function(err, result) {
//NOTE: This callback fires twice. Once tx hash comes in. Then when mined.
if(err) {
console.log(err);
......@@ -87,22 +96,24 @@ var TxForm = React.createClass({
this.props.successful(result, args); //fires callback function.
}
else if(this.props.txStyle == "transaction") {
args.push(function(err, result) {
if(!err) {
console.log(result);
if(result != null) {
var tx_hash = result;
that.setState({txArgs: args}); //need to keep transaction arguments for success function.
that.submitTransaction(tx_hash, that.props.txType);
}
}
});
var that = this;
args.push({ gas: 3000000});
args.push({gas: 300000});
web3.eth.getAccounts(function(err, accounts){
var addr = accounts[0];
args.push({from: addr});
this.props.web3_token[this.props.abiFunction].sendTransaction.apply(this, args);
//the callback (must be after part)
args.push(function(err, result) {
if(!err) {
console.log(result);
if(result != null) {
var tx_hash = result;
that.setState({txArgs: args}); //need to keep transaction arguments for success function.
that.submitTransaction(tx_hash, that.props.txType);
}
}
});
console.log(args);
that.props.web3_token[that.props.abiFunction].sendTransaction.apply(that, args);
});
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment