Make addAccount() internal to the VM mode

pull/1/head
Alex Beregszaszi 9 years ago
parent a6f8207063
commit fcbed88ffa
  1. 16
      src/universal-dapp.js

@ -42,11 +42,11 @@ UniversalDApp.prototype.reset = function (contracts, getAddress, getValue, getGa
this.renderOutputModifier = renderer; this.renderOutputModifier = renderer;
this.accounts = {}; this.accounts = {};
if (this.executionContext.isVM()) { if (this.executionContext.isVM()) {
this.addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'); this._addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511');
this.addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c'); this._addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c');
this.addAccount('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'); this._addAccount('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a');
this.addAccount('d74aa6d18aa79a05f3473dd030a97d3305737cbc8337d940344345c1f6b72eea'); this._addAccount('d74aa6d18aa79a05f3473dd030a97d3305737cbc8337d940344345c1f6b72eea');
this.addAccount('71975fbf7fe448e004ac7ae54cad0a383c3906055a65468714156a07385e96ce'); this._addAccount('71975fbf7fe448e004ac7ae54cad0a383c3906055a65468714156a07385e96ce');
} }
}; };
@ -58,9 +58,13 @@ UniversalDApp.prototype.newAccount = function () {
this._addAccount(privateKey); this._addAccount(privateKey);
}; };
UniversalDApp.prototype.addAccount = function (privateKey, balance) { UniversalDApp.prototype._addAccount = function (privateKey, balance) {
var self = this; var self = this;
if (!self.executionContext.isVM()) {
throw new Error('_addAccount() cannot be called in non-VM mode');
}
if (self.accounts) { if (self.accounts) {
privateKey = new Buffer(privateKey, 'hex'); privateKey = new Buffer(privateKey, 'hex');
var address = ethJSUtil.privateToAddress(privateKey); var address = ethJSUtil.privateToAddress(privateKey);

Loading…
Cancel
Save