|
|
@ -25,22 +25,22 @@ function UniversalDApp (contracts, options) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UniversalDApp.prototype.addAccount = function (privateKey, balance) { |
|
|
|
UniversalDApp.prototype.addAccount = function (privateKey, balance) { |
|
|
|
if (this.accounts) { |
|
|
|
if (this.accounts) { |
|
|
|
privateKey = new Buffer(privateKey, 'hex') |
|
|
|
privateKey = new Buffer(privateKey, 'hex') |
|
|
|
var address = EthJS.Util.privateToAddress(privateKey); |
|
|
|
var address = EthJS.Util.privateToAddress(privateKey); |
|
|
|
|
|
|
|
|
|
|
|
var account = new EthJS.Account(); |
|
|
|
var account = new EthJS.Account(); |
|
|
|
account.balance = balance || 'f00000000000000001'; |
|
|
|
account.balance = balance || 'f00000000000000001'; |
|
|
|
this.vm.stateManager.trie.put(address, account.serialize()); |
|
|
|
this.vm.stateManager.trie.put(address, account.serialize()); |
|
|
|
|
|
|
|
|
|
|
|
this.accounts['0x' + address.toString('hex')] = { privateKey: privateKey, nonce: 0 }; |
|
|
|
this.accounts['0x' + address.toString('hex')] = { privateKey: privateKey, nonce: 0 }; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
UniversalDApp.prototype.getAccounts = function (cb) { |
|
|
|
UniversalDApp.prototype.getAccounts = function (cb) { |
|
|
|
if (!this.accounts) return cb("No accounts?"); |
|
|
|
if (!this.accounts) return cb("No accounts?"); |
|
|
|
|
|
|
|
|
|
|
|
cb(null, Object.keys(this.accounts)); |
|
|
|
cb(null, Object.keys(this.accounts)); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
UniversalDApp.prototype.render = function () { |
|
|
|
UniversalDApp.prototype.render = function () { |
|
|
|