diff --git a/js/src/api/subscriptions/manager.js b/js/src/api/subscriptions/manager.js index 7a7a61bfa..cfb5c00d9 100644 --- a/js/src/api/subscriptions/manager.js +++ b/js/src/api/subscriptions/manager.js @@ -24,6 +24,7 @@ import Signer from './signer'; const events = { 'logging': { module: 'logging' }, 'eth_blockNumber': { module: 'eth' }, + 'parity_accountsInfo': { module: 'personal' }, 'parity_allAccountsInfo': { module: 'personal' }, 'eth_accounts': { module: 'personal' }, 'signer_requestsToConfirm': { module: 'signer' } diff --git a/js/src/api/subscriptions/personal.js b/js/src/api/subscriptions/personal.js index 5e3280424..78a9b128d 100644 --- a/js/src/api/subscriptions/personal.js +++ b/js/src/api/subscriptions/personal.js @@ -45,10 +45,14 @@ export default class Personal { } _accountsInfo = () => { - return this._api.parity - .allAccountsInfo() - .then((info) => { - this._updateSubscriptions('parity_allAccountsInfo', null, info); + return Promise + .all([ + this._api.parity.accountsInfo(), + this._api.parity.allAccountsInfo() + ]) + .then(([info, allInfo]) => { + this._updateSubscriptions('parity_accountsInfo', null, info); + this._updateSubscriptions('parity_allAccountsInfo', null, allInfo); }); } diff --git a/js/src/api/subscriptions/personal.spec.js b/js/src/api/subscriptions/personal.spec.js index f27f83f70..c4344db3a 100644 --- a/js/src/api/subscriptions/personal.spec.js +++ b/js/src/api/subscriptions/personal.spec.js @@ -27,6 +27,7 @@ const TEST_LIST = ['0xfa64203C044691aA57251aF95f4b48d85eC00Dd5']; function stubApi (accounts, info) { const _calls = { + accountsInfo: [], allAccountsInfo: [], listAccounts: [] }; @@ -34,6 +35,12 @@ function stubApi (accounts, info) { return { _calls, parity: { + accountsInfo: () => { + const stub = sinon.stub().resolves(info || TEST_INFO)(); + + _calls.accountsInfo.push(stub); + return stub; + }, allAccountsInfo: () => { const stub = sinon.stub().resolves(info || TEST_INFO)(); @@ -87,6 +94,10 @@ describe('api/subscriptions/personal', () => { expect(personal.isStarted).to.be.true; }); + it('calls parity_accountsInfo', () => { + expect(api._calls.accountsInfo.length).to.be.ok; + }); + it('calls parity_allAccountsInfo', () => { expect(api._calls.allAccountsInfo.length).to.be.ok; }); @@ -97,7 +108,8 @@ describe('api/subscriptions/personal', () => { it('updates subscribers', () => { expect(cb.firstCall).to.have.been.calledWith('eth_accounts', null, TEST_LIST); - expect(cb.secondCall).to.have.been.calledWith('parity_allAccountsInfo', null, TEST_INFO); + expect(cb.secondCall).to.have.been.calledWith('parity_accountsInfo', null, TEST_INFO); + expect(cb.thirdCall).to.have.been.calledWith('parity_allAccountsInfo', null, TEST_INFO); }); }); @@ -113,6 +125,10 @@ describe('api/subscriptions/personal', () => { }); it('calls personal_accountsInfo', () => { + expect(api._calls.accountsInfo.length).to.be.ok; + }); + + it('calls personal_allAccountsInfo', () => { expect(api._calls.allAccountsInfo.length).to.be.ok; });