Skip to content

Commit

Permalink
dapp: fix version validation and comparison
Browse files Browse the repository at this point in the history
The validation and comparison of version numbers for the update procedure was
broken. Reason was an updated version of the library that is used to work with
semantic version strings. In fact the interface of this library has changed (to
the better). For some reason the typing system did not detect this issue. The
fix is basically just an adaption of the imports from this library.
  • Loading branch information
weilbith committed Dec 24, 2021
1 parent f0ab064 commit 827b5cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions raiden-dapp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

### Fixed

- [#3021] Fix version handling to detect client updates

[#3021]: https://github.com/raiden-network/light-client/issues/3021

## [2.0.0] - 2021-12-23

## [2.0.0-rc.2] - 2021-09-14
Expand Down
4 changes: 2 additions & 2 deletions raiden-dapp/src/service-worker/assistant.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* istanbul ignore file */
import compareVersions from 'compare-versions';
import { validate as validateVersion } from 'compare-versions';
import type { Store } from 'vuex';

import type { CombinedStoreState } from '@/store/index';
Expand Down Expand Up @@ -52,7 +52,7 @@ export default class ServiceWorkerAssistant {
const data = await response.json();
const version = data.version.version;

if (compareVersions.validate(version)) {
if (validateVersion(version)) {
this.store.commit('setAvailableVersion', version);
} else {
throw new Error(`Maleformed version string: ${version}`);
Expand Down
6 changes: 3 additions & 3 deletions raiden-dapp/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import compareVersions from 'compare-versions';
import { compare as compareVersions, validate as validateVersion } from 'compare-versions';
import type { BigNumber, providers } from 'ethers';
import clone from 'lodash/clone';
import filter from 'lodash/filter';
Expand Down Expand Up @@ -154,7 +154,7 @@ const store: StoreOptions<CombinedStoreState> = {
state.stateBackupReminderDateMs = newReminderDate;
},
setAvailableVersion(state: RootState, version: string) {
if (compareVersions.validate(version)) {
if (validateVersion(version)) {
state.versionInfo = { ...state.versionInfo, availableVersion: version };
}
},
Expand Down Expand Up @@ -258,7 +258,7 @@ const store: StoreOptions<CombinedStoreState> = {
return (
!!activeVersion &&
!!availableVersion &&
compareVersions.compare(availableVersion, activeVersion, '>')
compareVersions(availableVersion, activeVersion, '>')
);
},
},
Expand Down

0 comments on commit 827b5cf

Please sign in to comment.