FIX code formatting

pull/3094/head
serapath 7 years ago committed by yann300
parent a92e6106f9
commit d5a835095c
  1. 71
      src/universal-dapp.js

@ -7,7 +7,6 @@ var BN = ethJSUtil.BN
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
var crypto = require('crypto') var crypto = require('crypto')
var async = require('async')
var TxRunner = require('./app/execution/txRunner') var TxRunner = require('./app/execution/txRunner')
var yo = require('yo-yo') var yo = require('yo-yo')
var txFormat = require('./app/execution/txFormat') var txFormat = require('./app/execution/txFormat')
@ -475,6 +474,7 @@ UniversalDApp.prototype.replayTx = function (args, cb) {
var env = { self, args, tx } var env = { self, args, tx }
execute(pipeline, env, cb) execute(pipeline, env, cb)
} }
UniversalDApp.prototype.runTx = function (args, cb) { UniversalDApp.prototype.runTx = function (args, cb) {
var self = this var self = this
var tx = { to: args.to, data: args.data, useCall: args.useCall } var tx = { to: args.to, data: args.data, useCall: args.useCall }
@ -483,77 +483,53 @@ UniversalDApp.prototype.runTx = function (args, cb) {
execute(pipeline, env, cb) execute(pipeline, env, cb)
} }
function queryGasLimit (env, next) {
function queryGasLimit (env, next) { var { self, tx } = env
var { self, args, tx } = env
tx.gasLimit = 3000000 tx.gasLimit = 3000000
if (self.transactionContextAPI.getGasLimit) { if (self.transactionContextAPI.getGasLimit) {
self.transactionContextAPI.getGasLimit(function (err, ret) { self.transactionContextAPI.getGasLimit(function (err, ret) {
if (err) { if (err) return next(err)
return next(err)
}
tx.gasLimit = ret tx.gasLimit = ret
next(null, env) next(null, env)
}) })
} else { } else next(null, env)
next(null, env) }
}
}
function queryGasLimit (env, next) { function queryValue (env, next) {
var { self, args, tx } = env var { self, tx } = env
tx.value = 0 tx.value = 0
if (tx.useCall) return next(null, env) if (tx.useCall) return next(null, env)
if (self.transactionContextAPI.getValue) { if (self.transactionContextAPI.getValue) {
self.transactionContextAPI.getValue(function (err, ret) { self.transactionContextAPI.getValue(function (err, ret) {
if (err) { if (err) return next(err)
return next(err)
}
tx.value = ret tx.value = ret
next(null, env) next(null, env)
}) })
} else { } else next(null, env)
next(null, env) }
}
}
function queryAddress (env, next) { function queryAddress (env, next) {
var { self, args, tx } = env var { self, tx } = env
if (self.transactionContextAPI.getAddress) { if (self.transactionContextAPI.getAddress) {
self.transactionContextAPI.getAddress(function (err, ret) { self.transactionContextAPI.getAddress(function (err, ret) {
if (err) { if (err) return next(err)
return next(err)
}
tx.from = ret tx.from = ret
next(null, env) next(null, env)
}) })
} else { } else {
self.getAccounts(function (err, ret) { self.getAccounts(function (err, ret) {
if (err) { if (err) return next(err)
return next(err) if (ret.length === 0) return next('No accounts available')
}
if (ret.length === 0) {
return next('No accounts available')
}
if (executionContext.isVM() && !self.accounts[ret[0]]) { if (executionContext.isVM() && !self.accounts[ret[0]]) {
return next('Invalid account selected') return next('Invalid account selected')
} }
tx.from = ret[0] tx.from = ret[0]
next(null, env) next(null, env)
}) })
} }
} }
function runTransaction (env, next) { function runTransaction (env, next) {
var { self, args, tx } = env var { self, args, tx } = env
var timestamp = Date.now() var timestamp = Date.now()
self.event.trigger('initiatingTransaction', [timestamp, tx]) self.event.trigger('initiatingTransaction', [timestamp, tx])
@ -565,18 +541,15 @@ UniversalDApp.prototype.runTx = function (args, cb) {
} }
if (error) { if (error) {
if (typeof (error) !== 'string') { if (typeof (error) !== 'string') {
if (error.message) { if (error.message) error = error.message
error = error.message else {
} else { try { error = 'error: ' + JSON.stringify(error) } catch (e) {}
try {
error = 'error: ' + JSON.stringify(error)
} catch (e) {}
} }
} }
} }
env.result = result env.result = result
next(error, env) next(error, env)
}) })
} }
module.exports = UniversalDApp module.exports = UniversalDApp

Loading…
Cancel
Save