pull/7/head
Iuri Matias 7 years ago
parent 79764e2dc0
commit 06292d53f9
  1. 2
      src/compiler.js
  2. 12
      src/deployer.js
  3. 4
      src/provider.js
  4. 9
      src/txProcess.js

@ -38,8 +38,6 @@ function compileFileOrFiles (filename, isDirectory, cb) {
compiler.compile(sources, filepath) compiler.compile(sources, filepath)
} }
], function (err, result) { ], function (err, result) {
console.dir(err);
console.dir(result);
let errors = (result.errors || []).filter((e) => e.type === 'Error') let errors = (result.errors || []).filter((e) => e.type === 'Error')
if (errors.length > 0) { if (errors.length > 0) {
console.dir(errors) console.dir(errors)

@ -79,17 +79,11 @@ function deployAll (compileResult, web3, callback) {
let deployObject = contractObject.deploy({arguments: [], data: contractCode}) let deployObject = contractObject.deploy({arguments: [], data: contractCode})
deployObject.estimateGas().then((gasValue) => { deployObject.estimateGas().then((gasValue) => {
console.dir("got gas estimation " + gasValue);
console.dir(accounts);
deployObject.send({ deployObject.send({
from: accounts[0], from: accounts[0],
//gas: Math.ceil(gasValue * 1.2) gas: Math.ceil(gasValue * 1.2)
gas: 1200000 //gas: 1200000
}).on('receipt', function (receipt) { }).on('receipt', function (receipt) {
console.dir("==== got the receipt");
console.dir(receipt);
contractObject.options.address = receipt.contractAddress contractObject.options.address = receipt.contractAddress
contractObject.options.from = accounts[0] contractObject.options.from = accounts[0]
contractObject.options.gas = 5000 * 1000 contractObject.options.gas = 5000 * 1000
@ -99,8 +93,6 @@ function deployAll (compileResult, web3, callback) {
nextEach() nextEach()
}).on('error', function(err) { }).on('error', function(err) {
console.dir("===============");
console.dir("error");
console.dir(err); console.dir(err);
}) })
}) })

@ -23,14 +23,12 @@ Provider = function() {
Provider.prototype.sendAsync = function(payload, callback) { Provider.prototype.sendAsync = function(payload, callback) {
const self = this; const self = this;
//console.log("=========== sendAsync");
//console.dir(payload);
if (payload.method === 'eth_accounts') { if (payload.method === 'eth_accounts') {
return callback(null, jsonRPCResponse(payload.id, this.accounts.map((x) => x.address))) return callback(null, jsonRPCResponse(payload.id, this.accounts.map((x) => x.address)))
} }
if (payload.method === 'eth_estimateGas') { if (payload.method === 'eth_estimateGas') {
callback(null, jsonRPCResponse(payload.id, 1200000)) callback(null, jsonRPCResponse(payload.id, 3000000))
} }
if (payload.method === 'eth_gasPrice') { if (payload.method === 'eth_gasPrice') {
callback(null, jsonRPCResponse(payload.id, 1)) callback(null, jsonRPCResponse(payload.id, 1))

@ -8,13 +8,9 @@ function jsonRPCResponse(id, result) {
} }
function runTx(payload, from, to, data, value, gasLimit, txRunner, callbacks, isCall, callback) { function runTx(payload, from, to, data, value, gasLimit, txRunner, callbacks, isCall, callback) {
console.log('-- runTx');
let finalCallback = function(err, result) { let finalCallback = function(err, result) {
let toReturn; let toReturn;
if (isCall) { if (isCall) {
console.dir('---- result is ');
console.dir(result.result.vm.return);
console.dir(result.result.vm);
toReturn = "0x" + result.result.vm.return.toString('hex') toReturn = "0x" + result.result.vm.return.toString('hex')
if (toReturn === '0x') { if (toReturn === '0x') {
toReturn = '0x0' toReturn = '0x0'
@ -30,8 +26,6 @@ function runTx(payload, from, to, data, value, gasLimit, txRunner, callbacks, is
} }
function createContract(payload, from, data, value, gasLimit, txRunner, callbacks, callback) { function createContract(payload, from, data, value, gasLimit, txRunner, callbacks, callback) {
console.log('-- createContract');
console.dir(arguments);
let finalCallback = function(err, result) { let finalCallback = function(err, result) {
if (err) { if (err) {
return callback(err); return callback(err);
@ -44,7 +38,6 @@ function createContract(payload, from, data, value, gasLimit, txRunner, callback
} }
function processTx(accounts, payload, isCall, callback) { function processTx(accounts, payload, isCall, callback) {
console.log('-- processTx');
let api = { let api = {
logMessage: (msg) => { logMessage: (msg) => {
}, },
@ -75,7 +68,7 @@ function processTx(accounts, payload, isCall, callback) {
let txRunner = new TxRunner(accounts, api); let txRunner = new TxRunner(accounts, api);
let { from: from, to: to, data: data, value: value, gas: gas } = payload.params[0]; let { from: from, to: to, data: data, value: value, gas: gas } = payload.params[0];
gas = gas || 1200000; gas = gas || 3000000;
let callbacks = { let callbacks = {
confirmationCb: (network, tx, gasEstimation, continueTxExecution, cancelCb) => { confirmationCb: (network, tx, gasEstimation, continueTxExecution, cancelCb) => {

Loading…
Cancel
Save