re-add queryValue function to the waterfall; update to take into account value and gasLimit

pull/1/head
Iuri Matias 7 years ago
parent 5823627bd4
commit 0d78a7d162
  1. 25
      src/universal-dapp.js

@ -211,10 +211,25 @@ UniversalDApp.prototype.runTx = function (args, cb) {
} }
next(null, 3000000) next(null, 3000000)
}, },
function getAccount (gasLimit, next) { function queryValue (gasLimit, next) {
if (args.value) {
return next(null, args.value, gasLimit)
}
if (args.useCall) return next(null, 0, gasLimit)
if (self.transactionContextAPI.getValue) {
self.transactionContextAPI.getValue(function (err, value) {
next(err, value, gasLimit)
})
}
next(null, 0, gasLimit)
},
function getAccount (value, gasLimit, next) {
if (args.from) {
return next(null, args.from, value, gasLimit)
}
if (self.transactionContextAPI.getAddress) { if (self.transactionContextAPI.getAddress) {
return self.transactionContextAPI.getAddress(function (err, address) { return self.transactionContextAPI.getAddress(function (err, address) {
next(err, address, gasLimit) next(err, address, value, gasLimit)
}) })
} }
self.getAccounts(function (err, accounts) { self.getAccounts(function (err, accounts) {
@ -225,11 +240,11 @@ UniversalDApp.prototype.runTx = function (args, cb) {
if (executionContext.isVM() && !self.accounts[address]) { if (executionContext.isVM() && !self.accounts[address]) {
return next('Invalid account selected') return next('Invalid account selected')
} }
next(null, address, gasLimit) next(null, address, value, gasLimit)
}) })
}, },
function runTransaction (fromAddress, gasLimit, next) { function runTransaction (fromAddress, value, gasLimit, next) {
var tx = { to: args.to, data: args.data.dataHex, useCall: args.useCall, from: fromAddress, value: args.value, gasLimit: gasLimit } var tx = { to: args.to, data: args.data.dataHex, useCall: args.useCall, from: fromAddress, value: value, gasLimit: gasLimit }
var payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs, contractBytecode: args.data.contractBytecode, contractName: args.data.contractName } var payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs, contractBytecode: args.data.contractBytecode, contractName: args.data.contractName }
var timestamp = Date.now() var timestamp = Date.now()

Loading…
Cancel
Save