|
|
@ -1,10 +1,10 @@ |
|
|
|
var $ = require('jquery'); |
|
|
|
var $ = require('jquery'); |
|
|
|
var EthJSVM = require('ethereumjs-vm'); |
|
|
|
var EthJSVM = require('ethereumjs-vm'); |
|
|
|
var Trie = require('merkle-patricia-tree'); |
|
|
|
|
|
|
|
var ethJSUtil = require('ethereumjs-util'); |
|
|
|
var ethJSUtil = require('ethereumjs-util'); |
|
|
|
var EthJSTX = require('ethereumjs-tx'); |
|
|
|
var EthJSTX = require('ethereumjs-tx'); |
|
|
|
var ethJSABI = require('ethereumjs-abi'); |
|
|
|
var ethJSABI = require('ethereumjs-abi'); |
|
|
|
var EthJSBlock = require('ethereumjs-block'); |
|
|
|
var EthJSBlock = require('ethereumjs-block'); |
|
|
|
|
|
|
|
var BN = ethJSUtil.BN; |
|
|
|
|
|
|
|
|
|
|
|
function UniversalDApp (contracts, options) { |
|
|
|
function UniversalDApp (contracts, options) { |
|
|
|
this.options = options || {}; |
|
|
|
this.options = options || {}; |
|
|
@ -20,9 +20,7 @@ function UniversalDApp (contracts, options) { |
|
|
|
|
|
|
|
|
|
|
|
this.accounts = {}; |
|
|
|
this.accounts = {}; |
|
|
|
|
|
|
|
|
|
|
|
this.BN = ethJSUtil.BN; |
|
|
|
this.vm = new EthJSVM(null, null, { activatePrecompiles: true, enableHomestead: true }); |
|
|
|
this.stateTrie = new Trie(); |
|
|
|
|
|
|
|
this.vm = new EthJSVM(this.stateTrie, null, { activatePrecompiles: true }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'); |
|
|
|
this.addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'); |
|
|
|
this.addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c'); |
|
|
|
this.addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c'); |
|
|
@ -75,7 +73,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
cb('Account not found'); |
|
|
|
cb('Account not found'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
cb(null, new ethJSUtil.BN(res).toString(10)); |
|
|
|
cb(null, new BN(res).toString(10)); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -636,7 +634,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) { |
|
|
|
gasPrice: 1, |
|
|
|
gasPrice: 1, |
|
|
|
gasLimit: 3000000000, // plenty
|
|
|
|
gasLimit: 3000000000, // plenty
|
|
|
|
to: to, |
|
|
|
to: to, |
|
|
|
value: new this.BN(value, 10), |
|
|
|
value: new BN(value, 10), |
|
|
|
data: new Buffer(data.slice(2), 'hex') |
|
|
|
data: new Buffer(data.slice(2), 'hex') |
|
|
|
}); |
|
|
|
}); |
|
|
|
tx.sign(account.privateKey); |
|
|
|
tx.sign(account.privateKey); |
|
|
@ -648,7 +646,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) { |
|
|
|
transactions: [], |
|
|
|
transactions: [], |
|
|
|
uncleHeaders: [] |
|
|
|
uncleHeaders: [] |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.vm.runTx({block: block, tx: tx, skipBalance: true, skipNonce: true, enableHomestead: true}, cb); |
|
|
|
this.vm.runTx({block: block, tx: tx, skipBalance: true, skipNonce: true}, cb); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
cb(e, null); |
|
|
|
cb(e, null); |
|
|
|
} |
|
|
|
} |
|
|
|