Skip to content

Commit

Permalink
temporary allow keyshares produced by version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya committed Aug 30, 2024
1 parent e370c87 commit 06098a5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/KeyShares/KeyShares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import pkg from '../../../package.json';

import { IsOptional, ValidateNested, validateSync } from 'class-validator';

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (ubuntu-latest)

'IsOptional' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (ubuntu-latest)

'ValidateNested' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_macos (macos-latest)

'IsOptional' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_macos (macos-latest)

'ValidateNested' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (windows-latest)

'IsOptional' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (windows-latest)

'ValidateNested' is defined but never used
import { KeySharesItem } from './KeySharesItem';
import { SSVKeysException } from '../../lib/exceptions/base';
import { SSVKeysException } from '../exceptions/base';

/**
* Represents a collection of KeyShares items with functionality for serialization,
Expand Down Expand Up @@ -60,11 +60,12 @@ export class KeyShares {
const body = typeof content === 'string' ? JSON.parse(content) : content;
const extVersion = semver.parse(body.version);
const currentVersion = semver.parse(pkg.version);
const tmpPrevVersion = semver.parse('v1.1.0');

if (!extVersion || !currentVersion) {
if (!extVersion || !currentVersion || !tmpPrevVersion) {
throw new SSVKeysException(`The file for keyshares must contain a version mark provided by ssv-keys.`);
}
if (!extVersion || (currentVersion.major !== extVersion.major) || (currentVersion.minor !== extVersion.minor)) {
if (!extVersion || (currentVersion.major !== extVersion.major) || (currentVersion.minor !== extVersion.minor && tmpPrevVersion.minor !== extVersion.minor)) {
throw new SSVKeysException(`The keyshares file you are attempting to reuse does not have the same version (v${pkg.version}) as supported by ssv-keys`);
}

Expand Down

0 comments on commit 06098a5

Please sign in to comment.