Skip to content

Commit 28e1143

Browse files
committed
fix: use earliest stacks app version check
1 parent de3edf5 commit 28e1143

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

app/constants/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const LATEST_LEDGER_VERSION_MAJOR = 0;
7070

7171
export const LATEST_LEDGER_VERSION_MINOR = 14;
7272

73-
export const SUPPORTED_LEDGER_VERSIONS_MINOR = [11, LATEST_LEDGER_VERSION_MINOR];
73+
export const EARLIEST_SUPPORTED_LEDGER_VERSION = '0.11.0';
7474

7575
export const DEFAULT_POLLING_INTERVAL = 10_000;
7676

app/hooks/use-prepare-ledger.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import { useEffect, useMemo, useState } from 'react';
22
import { LedgerError } from '@zondax/ledger-blockstack';
3+
import compareVersions from 'compare-versions';
34
import { Observable } from 'rxjs';
45
import { filter } from 'rxjs/operators';
5-
import {
6-
LATEST_LEDGER_VERSION_MAJOR,
7-
LATEST_LEDGER_VERSION_MINOR,
8-
SUPPORTED_LEDGER_VERSIONS_MINOR,
9-
} from '@constants/index';
106

7+
import { EARLIEST_SUPPORTED_LEDGER_VERSION } from '@constants/index';
8+
import { isTestnet } from '@utils/network-utils';
119
import type { LedgerMessageEvents } from '../main/register-ledger-listeners';
1210
import { useListenLedgerEffect } from './use-listen-ledger-effect';
13-
import { isTestnet } from '@utils/network-utils';
1411
import { messages$ } from './use-message-events';
1512
import { useCheckForUpdates } from './use-check-for-updates';
1613

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

5150
const appVersionErrorText = useMemo(() => {
@@ -58,10 +57,18 @@ export function usePrepareLedger() {
5857
? 'You should also upgrade your Stacks Wallet to the latest version.'
5958
: ''
6059
}
61-
This version of the Stacks Wallet only works with ${LATEST_LEDGER_VERSION_MAJOR}.${LATEST_LEDGER_VERSION_MINOR}.
62-
Detected version ${String(appVersion?.major)}.${String(appVersion?.minor)}
60+
This version of the Stacks Wallet works with ${EARLIEST_SUPPORTED_LEDGER_VERSION} onwards.
61+
Detected version ${String(appVersion?.major)}.${String(appVersion?.minor)}.${String(
62+
appVersion?.patch
63+
)}
6364
`;
64-
}, [appVersion?.major, appVersion?.minor, isNewerReleaseAvailable, versionSupportsTestnetLedger]);
65+
}, [
66+
appVersion?.major,
67+
appVersion?.minor,
68+
appVersion?.patch,
69+
isNewerReleaseAvailable,
70+
versionSupportsTestnetLedger,
71+
]);
6572

6673
useListenLedgerEffect();
6774

app/store/stacking/stacking.actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const fetchStackerInfo = createAsyncThunk(
4242
network.coreApiUrl = node.url;
4343
const stackingClient = new StackingClient(address, network as any);
4444
const [error, resp] = await safeAwait(stackingClient.getStatus());
45-
if (resp) return resp;
45+
if (resp) return resp as any;
4646
if (error) return { error };
4747
throw new Error();
4848
}

app/tests/restore-wallet.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { getTestConfigPath } from './get-test-config-path';
1010
import { createGlobalFeature, resetWallet } from './features/global.feature';
1111
import { HomeFeature } from './features/home.feature';
1212
import { initSoftwareWallet } from './features/onboarding.feature';
13-
import path from 'path';
1413

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

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

33-
test('Restore wallet', async done => {
32+
test('Restore wallet', async () => {
3433
await initSoftwareWallet(page)(SEED_PHRASE, PASSWORD);
3534

3635
const globalFeature = createGlobalFeature(page);
@@ -69,7 +68,5 @@ describe('Restore wallet flow', () => {
6968
await resetWallet(page);
7069
await delay(1000);
7170
await page.screenshot({ path: 'screenshots/finished-page.png' });
72-
73-
done();
7471
}, 120_0000);
7572
});

app/utils/blast-undo-stack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export function blastUndoStackToRemovePasswordFromMemory(element: HTMLInputEleme
88
for (let i = 0; i < 256; i++) document.execCommand('undo');
99
const newFakeValue = '0'.repeat(pwLength);
1010
element.value = newFakeValue;
11-
global.gc();
11+
global.gc?.();
1212
}

0 commit comments

Comments
 (0)