Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code fore blockchain network management #1691

Merged
merged 19 commits into from
Jul 16, 2024
Merged

Conversation

clangenb
Copy link
Member

@clangenb clangenb commented Jul 15, 2024

I did this as a preparation for task for #1603 in order to simplify management of multiple endpoints per network.

Changes

  • Use an enum for the different networks instead of a json map containing network specific (nullable - why??) fields. This fixes many nullcheck !/? operators in the code base.
  • Remove some outdated fields and computed of the settings store.
  • We only cache the network-id instead of the whole network info type. The network info is static, no need to cache it. It also makes it hard in case the data structure (like adding multple endpoints per network ;)) changes.

Testing:

  • The integration tests passed locally.

@clangenb clangenb added A2-technical PR introduces technical changes B0-low Does not elevate a release containing this beyond "low priority" C0-breaksnothing PR does not introduce any breaking changes labels Jul 15, 2024
@clangenb clangenb changed the title Refactor code fore blockchain newtork management Refactor code fore blockchain network management Jul 15, 2024
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unused, we kept it as a reference, as it fetches data from subscan. By now I guess, we can be certain that we won't use subscan anymore.

Comment on lines -49 to +40
return !endpointIsTeeProxy;
}

@computed
bool get endpointIsTeeProxy {
return endpoint.worker != null;
return true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unused endPointIsTeeProxy and default to true for endPointIsNoTee

Comment on lines 88 to 96
Future<String?> getKV(String cacheKey) {
return Future.value();
return Future.value(storage[cacheKey] as String?);
}

@override
Future<void> setKV(String cacheKey, String value) {
storage[cacheKey] = value;
return Future.value();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to properly overwrite some new LocalStorage methods because we use method in the real thing now.

Comment on lines +48 to +55
String id() {
return switch (this) {
encointerKusama => kusamaId,
encointerRococo => rococoId,
gesell => gesellId,
gesellDev => gesellDevId,
};
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this was stored at the endpoint.info, but I think that ID fits better.

Comment on lines +76 to +82
Future<bool> removeObject(String key) {
return storage.removeKey('${customKVKey}_$key');
}

Future<bool> removeKV(String key) {
return storage.removeKey(key);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a weird ambiguity before. We should have a look at the local storage implementation at some point: #1692

@@ -15,7 +15,7 @@ class AccountSelectList extends StatelessWidget {
Widget build(BuildContext context) {
return ListView(
children: accounts.map((account) {
final address = AddressUtils.pubKeyHexToAddress(account.pubKey, prefix: store.settings.endpoint.ss58!);
final address = AddressUtils.pubKeyHexToAddress(account.pubKey, prefix: store.settings.currentNetwork.ss58());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think endpoint was a misnomer since ever. I changed it to currentNetwork.

@clangenb clangenb merged commit 68e3ec7 into master Jul 16, 2024
7 of 10 checks passed
@clangenb clangenb deleted the cl/network-management branch July 22, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A2-technical PR introduces technical changes B0-low Does not elevate a release containing this beyond "low priority" C0-breaksnothing PR does not introduce any breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant