Merge pull request #5856 from paritytech/mh-pubnode-dappsigner

Fixed account selection for Dapps on public node
This commit is contained in:
Maciej Hirsz 2017-06-19 18:29:06 +02:00 committed by GitHub
commit e871b7a0ac
3 changed files with 23 additions and 5 deletions

View File

@ -129,6 +129,8 @@ export default class Accounts {
set dappsDefaultAddress (value) {
this._dappsDefaultAddress = value.toLowerCase();
this.persist();
}
get (address) {
@ -191,10 +193,16 @@ export default class Accounts {
this.persist();
}
addresses () {
allAddresses () {
return Object.keys(this._store);
}
accountAddresses () {
return Object
.keys(this._store)
.filter((address) => this._store[address].uuid);
}
map (mapper) {
const result = {};

View File

@ -29,7 +29,7 @@ export default class LocalAccountsMiddleware extends Middleware {
const register = this.register.bind(this);
register('eth_accounts', () => {
return accounts.addresses();
return accounts.accountAddresses();
});
register('eth_coinbase', () => {
@ -73,7 +73,7 @@ export default class LocalAccountsMiddleware extends Middleware {
});
register('parity_defaultAccount', () => {
return accounts.lastAddress;
return accounts.dappsDefaultAddress;
});
register('parity_exportAccount', ([address, password]) => {
@ -98,11 +98,11 @@ export default class LocalAccountsMiddleware extends Middleware {
});
register('parity_getNewDappsAddresses', () => {
return [];
return accounts.accountAddresses();
});
register('parity_getNewDappsDefaultAddress', () => {
return accounts.lastAddress;
return accounts.dappsDefaultAddress;
});
register('parity_hardwareAccountsInfo', () => {
@ -149,6 +149,8 @@ export default class LocalAccountsMiddleware extends Middleware {
register('parity_setNewDappsDefaultAddress', ([address]) => {
accounts.dappsDefaultAddress = address;
return true;
});
register('parity_postTransaction', ([tx]) => {
@ -210,6 +212,10 @@ export default class LocalAccountsMiddleware extends Middleware {
return account.isValidPassword(password);
});
register('parity_upgradeReady', () => {
return false;
});
register('signer_confirmRequest', ([id, modify, password]) => {
const {
gasPrice,

View File

@ -21,6 +21,10 @@ export default class Middleware {
}
register (method, handler) {
if (method in this._handlers) {
throw new Error(`${method} is already defined in the middleware!`);
}
this._handlers[method] = handler;
}