diff --git a/CHANGELOG.md b/CHANGELOG.md index af90950969..905b8670bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - [\#1338](https://github.com/cosmos/voyager/issues/1338) Add Ledger Nano S support for signing transactions @fedekunze - [\#1869](https://github.com/cosmos/voyager/issues/1869) Added PageNetwork @jbibla - [\#1894](https://github.com/cosmos/voyager/issues/1894) Added favicons for all the browsers and devices @jbibla +- [\#1865](https://github.com/cosmos/voyager/issues/1865) Added Vuex blocks module @sabau ### Changed diff --git a/app/src/renderer/vuex/modules/blocks.js b/app/src/renderer/vuex/modules/blocks.js index cb1a102820..d9eeaeef5d 100644 --- a/app/src/renderer/vuex/modules/blocks.js +++ b/app/src/renderer/vuex/modules/blocks.js @@ -97,6 +97,9 @@ export default ({ node }) => { node.rpc.subscribe({ query: `tm.event = 'NewBlock'` }, event => { if (state.subscription === false) commit(`setSubscription`, true) commit(`addBlock`, event.block) + event.block && + event.block.header && + commit(`setBlockHeight`, event.block.header.height) }) return true diff --git a/test/unit/specs/store/blocks.spec.js b/test/unit/specs/store/blocks.spec.js index 57e66e68b5..739baf0e1b 100644 --- a/test/unit/specs/store/blocks.spec.js +++ b/test/unit/specs/store/blocks.spec.js @@ -145,10 +145,10 @@ describe(`Module: Blocks`, () => { } }), subscribe: (query, cb) => { - cb({ block: `subscribe here` }) + cb({ block: { header: { height: 1 } } }) expect(commit).toBeCalledWith(`setSubscription`, true) module.state.subscription = true - cb({ block: `already subscribed` }) + cb({ block: { header: { height: 2 } } }) } } } @@ -167,8 +167,10 @@ describe(`Module: Blocks`, () => { [`setSyncing`, false], [`setBlocks`, []], [`setSubscription`, true], - [`addBlock`, `subscribe here`], - [`addBlock`, `already subscribed`] + [`addBlock`, { header: { height: 1 } }], + [`setBlockHeight`, 1], + [`addBlock`, { header: { height: 2 } }], + [`setBlockHeight`, 2] ]) })