-
Notifications
You must be signed in to change notification settings - Fork 0
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
First pass at DAP resolution #3
Conversation
lib/src/dap_resolver.dart
Outdated
final registryServices = registryDidResolution.didDocument!.service ?? []; | ||
final dapRegistryService = registryServices.firstWhere( | ||
(service) => service.type == 'DAPRegistry', | ||
orElse: () => throw DapResolutionException( | ||
'Registry DID does not have a DAPRegistry service'), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
Since you're handing the orElse
in the 2nd case, you might want to avoid force unwrapping the didDocument!
in the first. Maybe something like:
final dapRegistryService = registryDidResolution.didDocument?.service.firstWhereOrNull((s) => s.type == 'DAPRegistry');
if (dapRegistryService == null) {
throw DapResolutionException(
'Registry DID does not have a DAPRegistry service');
}
(this code is probably wrong since I just wrote it in Github 😂 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a few other places where force unwarpping is happening here too. Either way is cool, but I tend to lean towards never force unwrapping expect in specific cases in widget layout trees
lib/src/dap_resolver.dart
Outdated
if (dapRegistryService.serviceEndpoint.isEmpty) { | ||
throw DapResolutionException( | ||
'DAPRegistry service does not have a service endpoint'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
You could grab the endpoint here so you don't need to use first
below if you want.
final serviceEndpoint = dapRegistryService.serviceEndpoint.firstOrNull;
if (serviceEndpoint == null) {
throw DapResolutionException('DAPRegistry service does not have a service endpoint');
}
// then below
registryEndpoint = Uri.parse(serviceEndpoint)
thanks for the comments @wesbillman ! I agree that force unwrapping is a footgun. created an issue to remove all force unwrapping in a subsequent PR: #4. Also created an issue in |
just saw this comment! latest commit actually closes TBD54566975/web5-dart#93 :)) |
First pass at implementing DAP Resolution. There will almost certainly be some refactoring in subsequent PRs, but wanted to get something out that works.
Warning
Resolver
gets used 18,327 times. You'll see in the Usage section belowUsage