fix: use stapps core version to compare with backends' core version

Note: not app version (e.g. 2.0.0).

Closes #77
This commit is contained in:
Jovan Krunić
2020-11-27 15:36:55 +01:00
parent 072204b748
commit 66b8720da0
4 changed files with 18 additions and 7 deletions

View File

@@ -16,6 +16,7 @@ import {Injectable} from '@angular/core';
import {Client} from '@openstapps/api/lib/client';
import {SCAppConfiguration, SCIndexResponse} from '@openstapps/core';
import {NGXLogger} from 'ngx-logger';
import {dependencies} from '../../../../package.json';
import {environment} from '../../../environments/environment';
import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
import {StorageProvider} from '../storage/storage.provider';
@@ -52,6 +53,11 @@ export class ConfigProvider {
*/
initialised = false;
/**
* Version of the @openstapps/core package that app is using
*/
scVersion = dependencies['@openstapps/core'];
/**
* Constructor, initialise api client
*
@@ -70,7 +76,7 @@ export class ConfigProvider {
*/
async fetch(): Promise<SCIndexResponse> {
try {
return await this.client.handshake(environment.backend_version);
return await this.client.handshake(this.scVersion);
} catch (error) {
throw new ConfigFetchError();
}
@@ -113,8 +119,8 @@ export class ConfigProvider {
this.config = await this.loadLocal();
this.initialised = true;
this.logger.log(`initialised configuration from storage`);
if (this.config.backend.SCVersion !== environment.backend_version) {
loadError = new WrongConfigVersionInStorage(environment.backend_version, this.config.backend.SCVersion);
if (this.config.backend.SCVersion !== this.scVersion) {
loadError = new WrongConfigVersionInStorage(this.scVersion, this.config.backend.SCVersion);
this.logger.warn(loadError);
}
} catch (error) {