Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit bc93d7e

Browse files
Add computed fields for restore: seed indices, verify and copy.
1 parent 90f9d73 commit bc93d7e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/computed/seed.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ const ComputedSeed = store => {
1717
const c2 = formatOrdinal(seedVerifyIndexes[2]);
1818
return `Type the ${c0}, ${c1}, and ${c2} words of your recovery phrase.`;
1919
}),
20+
restoreIndexes: computed(() => [...Array(24).keys()].map(x => ++x)),
21+
restoreVerifyIndexes: computed(() => {
22+
const { restoreIndexes } = store;
23+
const { restoreIndex } = store.wallet;
24+
return restoreIndexes.slice(restoreIndex, restoreIndex + 3);
25+
}),
26+
restoreVerifyCopy: computed(() => {
27+
const { restoreVerifyIndexes } = store;
28+
const c0 = formatOrdinal(restoreVerifyIndexes[0]);
29+
const c1 = formatOrdinal(restoreVerifyIndexes[1]);
30+
const c2 = formatOrdinal(restoreVerifyIndexes[2]);
31+
return `Type the ${c0}, ${c1}, and ${c2} words of your recovery phrase.`;
32+
}),
2033
});
2134
};
2235

test/unit/computed/seed.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ describe('Computed Seed Unit Tests', () => {
5454
}
5555
expect(store.seedVerifyCopy, 'to match', /^Type /);
5656
});
57+
58+
it('should set restore seed check attributes', () => {
59+
store.wallet.restoreIndex = 3;
60+
ComputedSeed(store);
61+
expect(store.restoreIndexes.length, 'to equal', 24);
62+
for (let i = 0; i < 24; i++) {
63+
expect(store.restoreIndexes[i], 'to be greater than', 0);
64+
expect(store.restoreIndexes[i], 'to be less than', 25);
65+
if (i > 0) {
66+
expect(
67+
store.restoreIndexes[i],
68+
'to equal',
69+
store.restoreIndexes[i - 1] + 1
70+
);
71+
}
72+
}
73+
expect(store.restoreVerifyIndexes, 'to equal', [4, 5, 6]);
74+
expect(store.restoreVerifyCopy, 'to match', /^Type /);
75+
});
5776
});
5877

5978
describe('formatOrdinal()', () => {

0 commit comments

Comments
 (0)