Skip to content

Commit

Permalink
app: Fix for potential bug in account selector widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
patniemeyer committed Jul 14, 2024
1 parent 4a28314 commit 8a55611
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gui-orchid/lib/api/orchid_eth/orchid_account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Account {
required this.funder, // required?
});

/// Create an account with referencing a stored signer key
/// Create an account referencing a stored signer key
Account.fromSignerKeyRef({
required StoredEthereumKeyRef signerKey,
int version = 0,
Expand Down
28 changes: 19 additions & 9 deletions gui-orchid/lib/orchid/account/account_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,25 @@ class _AccountSelectorState extends State<AccountSelector> {
}

Widget _buildAccountList() {
List<AccountViewModel> accounts = widget.accounts.map((Account account) {
log("XXX: build view model for account: $account");
return AccountViewModel(
chain: Chains.chainFor(account.chainId),
signerKey: account.signerKey,
funder: account.funder,
active: widget.selectedAccounts.contains(account),
detail: _accountDetailStore.get(account));
}).toList();
List<AccountViewModel> accounts = widget.accounts
.map((Account account) {
// There should not be errors stored in accounts that would cause a problem here, however
// we've had at least one bug involving an orphaned account with no signer key. This will
// at least prevent those types of bugs from blocking the user.
try {
return AccountViewModel(
chain: Chains.chainFor(account.chainId),
signerKey: account.signerKey,
funder: account.funder,
active: widget.selectedAccounts.contains(account),
detail: _accountDetailStore.get(account));
} catch (err) {
log("_buildAccountList: error building account view model: $err");
return null;
}
})
.whereType<AccountViewModel>() // remove nulls
.toList();

// final footer = () {
// return OrchidActionButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ class _AccountManagerPageState extends State<AccountManagerPage> {
void _deleteIdentity(StoredEthereumKey identity) async {
await UserPreferencesKeys().removeKey(identity.ref());
// Remove accounts for this key.
var matchingAccounts = UserPreferencesVPN().cachedDiscoveredAccounts.get();
Set<Account>? matchingAccounts = UserPreferencesVPN().cachedDiscoveredAccounts.get();

// var matching = matchingAccounts
// .where((account) => account.signerKeyRef == identity.ref());
// log("XXX: delete identity removed ${matching.length} matching accounts");
var matching = (matchingAccounts ?? {})
.where((account) => account.signerKeyRef == identity.ref());
log("XXX: delete identity removing ${matching.length} matching accounts");

matchingAccounts
?.removeWhere((account) => account.signerKeyRef == identity.ref());
Expand Down
2 changes: 2 additions & 0 deletions storage/commitments/test_kzg_commitments.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def test_roots_of_unity():
'0000000000000000000000000000000000000000000000000000000000000001')
assert (bytes_from_fr(roots_of_unity[1]).hex() ==
'73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000')
assert (bytes_from_fr(roots_of_unity[3]).hex() ==
'73eda753299d7d47a5e80b39939ed33467baa40089fb5bfefffeffff00000001')
print("Roots of unity look correct")


Expand Down

0 comments on commit 8a55611

Please sign in to comment.