Skip to content

Commit

Permalink
fix(EWM-346): allow legacy wallet types in SeedList (#126)
Browse files Browse the repository at this point in the history
Co-authored-by: Egor Komarov <[email protected]>
  • Loading branch information
Odrin and Egor Komarov authored Oct 22, 2024
1 parent c5ab3ff commit 87389b4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 60 deletions.
5 changes: 1 addition & 4 deletions lib/src/nekoton_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,8 @@ class NekotonRepository
required Map<PublicKey, SeedMetadata> seedMeta,
}) {
final planeExternalAccounts = externalAccounts.values.expand((e) => e);
final transportedAllAccounts = allAccounts.where(
(a) => transport.availableWalletTypes.contains(a.tonWallet.contract),
);
final mapped = <PublicKey, List<KeyAccount>>{};
for (final account in transportedAllAccounts) {
for (final account in allAccounts) {
final key = account.publicKey;
final isHidden = hiddenAccounts.contains(account.address);
final isExternal = planeExternalAccounts.contains(account.address);
Expand Down
56 changes: 0 additions & 56 deletions test/src/seeds_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -383,61 +383,5 @@ void main() {
);
expect(seed2.subKeys, equals([]));
});

test('Only WalletType.v3 available by transport', () {
final strategy = OnlyV3WalletTypeSupports();
final seedsList = NekotonRepository().buildSeeds(
allKeys: [masterKey, subKey1, subKey2, masterKey2],
allAccounts: [
account1Pure.account,
account1ExternalHidden.account,
accountSub1Pure.account,
accountSub2Hidden.account,
account2External.account,
],
hiddenAccounts: [
account1ExternalHidden.account.address,
accountSub2Hidden.account.address,
],
externalAccounts: {
masterKey.publicKey: [account1ExternalHidden.account.address],
masterKey2.publicKey: [account2External.account.address],
},
transport: strategy,
seedMeta: {},
);

expect(seedsList.seeds.length, 2);
final seed1 = seedsList.findSeed(key1)!;
expect(seed1.name, key1Ellipse);
expect(
seed1.masterKey,
SeedKey(
key: masterKey,
accountList: AccountList.empty(masterKey.publicKey),
),
);
expect(seed1.masterKey.accountList.allAccounts.length, 0);
expect(
seed1.subKeys,
equals([
SeedKey(
key: subKey1,
accountList: AccountList.empty(subKey1.publicKey),
),
SeedKey(key: subKey2, accountList: accountsSub2),
]),
);
final seed2 = seedsList.findSeed(key4)!;
expect(seed2.name, key4Ellipse);
expect(
seed2.masterKey,
SeedKey(
key: masterKey2,
accountList: AccountList.empty(masterKey2.publicKey),
),
);
expect(seed2.subKeys, equals([]));
});
});
}

0 comments on commit 87389b4

Please sign in to comment.