View on GitHub
File Changes
            LastSyncInfoId: ids.lastSyncInfoId,
          }),
          parentDerivationId: null,
+
          pathStartLevel: 0,
          pathToPublic: [
+
            {
+
              index: 0,
+
              insert: {},
+
            },
            {
              index: BIP44_PURPOSE,
              insert: {},
          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: {},
  bip44WrapperId: number,
  publicKey: KeyInsert,
  parentDerivationId: null | number,
+
  pathStartLevel: number,
  pathToPublic: InsertPath,
  publicDeriverInsert: {
    derivationId: number,
  ): 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,
            ...request.pathToPublic[i].insert,
          }),
        },
-
        i,
+
        request.pathStartLevel + i,
      );
      parentId = levelResult.KeyDerivation.KeyDerivationId;
    }
    ],
  },
  Object {
-
    "Bip44CoinType": Array [],
+
    "Bip44CoinType": Array [
+
      Object {
+
        "Bip44CoinTypeId": 1,
+
        "KeyDerivationId": 3,
+
      },
+
    ],
  },
  Object {
    "Bip44Purpose": Array [
      Object {
        "Bip44PurposeId": 1,
-
        "KeyDerivationId": 3,
+
        "KeyDerivationId": 2,
      },
    ],
  },
        "Bip44RootId": 1,
        "KeyDerivationId": 1,
      },
+
    ],
+
  },
+
  Object {
+
    "Bip44Wrapper": Array [
      Object {
-
        "Bip44RootId": 2,
-
        "KeyDerivationId": 2,
+
        "Bip44WrapperId": 1,
+
        "ConceptualWalletId": 1,
+
        "IsBundled": false,
+
        "PublicDeriverLevel": 3,
+
        "SignerLevel": 0,
+
        "Version": 2,
      },
    ],
  },
  await RustModule.load();
});

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

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