Skip to content
Permalink
Browse files

fix memory wallet migration

  • Loading branch information...
SebastienGllmt committed Oct 9, 2019
1 parent 6abc673 commit 1c11b6f4e401a15b33ddd896ad38b5c470373047
@@ -304,7 +304,12 @@ export async function createHardwareWallet(request: {
LastSyncInfoId: ids.lastSyncInfoId,
}),
parentDerivationId: null,
pathStartLevel: 0,
pathToPublic: [
{
index: 0,
insert: {},
},
{
index: BIP44_PURPOSE,
insert: {},
@@ -445,7 +450,15 @@ export async function migrateFromStorageV1(request: {
parentDerivationId: finalState.privateDeriver == null
? null
: finalState.privateDeriver.privateDeriverResult.KeyDerivationId,
pathStartLevel: finalState.privateDeriver == null ? 0 : 1,
pathToPublic: [
...(finalState.privateDeriver != null
? []
: [{
index: 0,
insert: {},
}]
),
{
index: BIP44_PURPOSE,
insert: {},
@@ -631,6 +631,7 @@ export type AddAdhocPublicDeriverRequest = {|
bip44WrapperId: number,
publicKey: KeyInsert,
parentDerivationId: null | number,
pathStartLevel: number,
pathToPublic: InsertPath,
publicDeriverInsert: {
derivationId: number,
@@ -662,7 +663,7 @@ export class AddAdhocPublicDeriver {
): Promise<AddAdhocPublicDeriverResponse<Row>> {
let parentId: number | null = request.parentDerivationId;
for (let i = 0; i < request.pathToPublic.length - 1; i++) {
const levelResult = await AddPrivateDeriver.depTables.AddDerivation.add(
const levelResult = await AddAdhocPublicDeriver.depTables.AddDerivation.add(
db, tx,
{
privateKeyInfo: null,
@@ -680,7 +681,7 @@ export class AddAdhocPublicDeriver {
...request.pathToPublic[i].insert,
}),
},
i,
request.pathStartLevel + i,
);
parentId = levelResult.KeyDerivation.KeyDerivationId;
}
@@ -25,13 +25,18 @@ Array [
],
},
Object {
"Bip44CoinType": Array [],
"Bip44CoinType": Array [
Object {
"Bip44CoinTypeId": 1,
"KeyDerivationId": 3,
},
],
},
Object {
"Bip44Purpose": Array [
Object {
"Bip44PurposeId": 1,
"KeyDerivationId": 3,
"KeyDerivationId": 2,
},
],
},
@@ -41,9 +46,17 @@ Array [
"Bip44RootId": 1,
"KeyDerivationId": 1,
},
],
},
Object {
"Bip44Wrapper": Array [
Object {
"Bip44RootId": 2,
"KeyDerivationId": 2,
"Bip44WrapperId": 1,
"ConceptualWalletId": 1,
"IsBundled": false,
"PublicDeriverLevel": 3,
"SignerLevel": 0,
"Version": 2,
},
],
},
@@ -13,6 +13,9 @@ beforeAll(async () => {
await RustModule.load();
});

beforeEach(() => {
mockDate();
});

test('Migrate storage v1 to storage v2', async (done) => {
const db = await loadLovefieldDB(schema.DataStoreType.MEMORY);
@@ -25,6 +28,7 @@ test('Migrate storage v1 to storage v2', async (done) => {
const keysForTest = [
'ConceptualWallet',
'Key',
'Bip44Wrapper',
'Bip44Root', // why two roots?
'Bip44Purpose',
'Bip44CoinType', // TODO: why is this missing?

0 comments on commit 1c11b6f

Please sign in to comment.
You can’t perform that action at this time.