Skip to content

Commit

Permalink
fix: use earliest stacks app version check
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Jul 13, 2021
1 parent de3edf5 commit 28e1143
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const LATEST_LEDGER_VERSION_MAJOR = 0;

export const LATEST_LEDGER_VERSION_MINOR = 14;

export const SUPPORTED_LEDGER_VERSIONS_MINOR = [11, LATEST_LEDGER_VERSION_MINOR];
export const EARLIEST_SUPPORTED_LEDGER_VERSION = '0.11.0';

export const DEFAULT_POLLING_INTERVAL = 10_000;

Expand Down
27 changes: 17 additions & 10 deletions app/hooks/use-prepare-ledger.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { useEffect, useMemo, useState } from 'react';
import { LedgerError } from '@zondax/ledger-blockstack';
import compareVersions from 'compare-versions';
import { Observable } from 'rxjs';
import { filter } from 'rxjs/operators';
import {
LATEST_LEDGER_VERSION_MAJOR,
LATEST_LEDGER_VERSION_MINOR,
SUPPORTED_LEDGER_VERSIONS_MINOR,
} from '@constants/index';

import { EARLIEST_SUPPORTED_LEDGER_VERSION } from '@constants/index';
import { isTestnet } from '@utils/network-utils';
import type { LedgerMessageEvents } from '../main/register-ledger-listeners';
import { useListenLedgerEffect } from './use-listen-ledger-effect';
import { isTestnet } from '@utils/network-utils';
import { messages$ } from './use-message-events';
import { useCheckForUpdates } from './use-check-for-updates';

Expand Down Expand Up @@ -45,7 +42,9 @@ export function usePrepareLedger() {
const isSupportedAppVersion = useMemo(() => {
if (appVersion === null) return true;
if (!versionSupportsTestnetLedger && isTestnet()) return false;
return SUPPORTED_LEDGER_VERSIONS_MINOR.includes(appVersion.minor);
const { major, minor, patch } = appVersion;
const currentVersion = `${major}.${minor}.${patch}`;
return compareVersions.compare(currentVersion, EARLIEST_SUPPORTED_LEDGER_VERSION, '>=');
}, [appVersion, versionSupportsTestnetLedger]);

const appVersionErrorText = useMemo(() => {
Expand All @@ -58,10 +57,18 @@ export function usePrepareLedger() {
? 'You should also upgrade your Stacks Wallet to the latest version.'
: ''
}
This version of the Stacks Wallet only works with ${LATEST_LEDGER_VERSION_MAJOR}.${LATEST_LEDGER_VERSION_MINOR}.
Detected version ${String(appVersion?.major)}.${String(appVersion?.minor)}
This version of the Stacks Wallet works with ${EARLIEST_SUPPORTED_LEDGER_VERSION} onwards.
Detected version ${String(appVersion?.major)}.${String(appVersion?.minor)}.${String(
appVersion?.patch
)}
`;
}, [appVersion?.major, appVersion?.minor, isNewerReleaseAvailable, versionSupportsTestnetLedger]);
}, [
appVersion?.major,
appVersion?.minor,
appVersion?.patch,
isNewerReleaseAvailable,
versionSupportsTestnetLedger,
]);

useListenLedgerEffect();

Expand Down
2 changes: 1 addition & 1 deletion app/store/stacking/stacking.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const fetchStackerInfo = createAsyncThunk(
network.coreApiUrl = node.url;
const stackingClient = new StackingClient(address, network as any);
const [error, resp] = await safeAwait(stackingClient.getStatus());
if (resp) return resp;
if (resp) return resp as any;
if (error) return { error };
throw new Error();
}
Expand Down
5 changes: 1 addition & 4 deletions app/tests/restore-wallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { getTestConfigPath } from './get-test-config-path';
import { createGlobalFeature, resetWallet } from './features/global.feature';
import { HomeFeature } from './features/home.feature';
import { initSoftwareWallet } from './features/onboarding.feature';
import path from 'path';

const PASSWORD = 'hello9*&^*^*dkfskjdfskljdfsj';
const SEED_PHRASE =
Expand All @@ -30,7 +29,7 @@ describe('Restore wallet flow', () => {

afterEach(async () => await app.close());

test('Restore wallet', async done => {
test('Restore wallet', async () => {
await initSoftwareWallet(page)(SEED_PHRASE, PASSWORD);

const globalFeature = createGlobalFeature(page);
Expand Down Expand Up @@ -69,7 +68,5 @@ describe('Restore wallet flow', () => {
await resetWallet(page);
await delay(1000);
await page.screenshot({ path: 'screenshots/finished-page.png' });

done();
}, 120_0000);
});
2 changes: 1 addition & 1 deletion app/utils/blast-undo-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export function blastUndoStackToRemovePasswordFromMemory(element: HTMLInputEleme
for (let i = 0; i < 256; i++) document.execCommand('undo');
const newFakeValue = '0'.repeat(pwLength);
element.value = newFakeValue;
global.gc();
global.gc?.();
}

0 comments on commit 28e1143

Please sign in to comment.