-
Notifications
You must be signed in to change notification settings - Fork 12
fix(ui): improve auth key error message and suppress on startup auto-select #761
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
base: v1.0-dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,20 @@ pub mod top_up_identity_screen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub mod transfer_screen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub mod withdraw_screen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Substring used to identify the "missing document-signing key" error returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// by [`get_selected_wallet`] when an identity has no key suitable for signing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// document state transitions. Callsites that auto-select an identity (e.g. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// DashPay startup) use this to suppress the expected case while still | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// surfacing unrelated errors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const MISSING_DOCUMENT_SIGNING_KEY_MARKER: &str = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "doesn't have an authentication key for signing document transitions"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Returns `true` if the given error string is the expected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// "identity has no document-signing key" error from [`get_selected_wallet`]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub fn is_missing_document_signing_key_error(error: &str) -> bool { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error.contains(MISSING_DOCUMENT_SIGNING_KEY_MARKER) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+36
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift Replace string-marker detection with a typed error variant.
The fragility is real: any future rephrasing of the marker (typo fix, wording change) silently breaks detection — The fix is to introduce a typed error enum and change ♻️ Suggested approach+#[derive(Debug)]
+pub enum GetWalletError {
+ MissingDocumentSigningKey { label: String, id: String },
+ NoKeyProvided,
+ DpnsError(String),
+}
+
+impl fmt::Display for GetWalletError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ Self::MissingDocumentSigningKey { label, id } => write!(
+ f,
+ "Identity {} ({}) doesn't have an authentication key for signing document transitions",
+ label, id
+ ),
+ Self::NoKeyProvided => write!(f, "No key provided when getting selected wallet"),
+ Self::DpnsError(e) => write!(f, "DPNS preorder document type not found: {}", e),
+ }
+ }
+}
+
+pub fn is_missing_document_signing_key_error(err: &GetWalletError) -> bool {
+ matches!(err, GetWalletError::MissingDocumentSigningKey { .. })
+}
-const MISSING_DOCUMENT_SIGNING_KEY_MARKER: &str =
- "doesn't have an authentication key for signing document transitions";
-
-pub fn is_missing_document_signing_key_error(error: &str) -> bool {
- error.contains(MISSING_DOCUMENT_SIGNING_KEY_MARKER)
-}Then update As per coding guidelines: "Never parse error strings to extract information — always use the typed error chain via downcast, match on variants, or access structured fields." 🤖 Prompt for AI Agents
Comment on lines
+31
to
+43
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: Substring-matching a
A dedicated error type (e.g. source: ['claude', 'codex'] 🤖 Fix this with AI agents
Comment on lines
+41
to
+43
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: No test pins the marker/message contract together Suppression in source: ['claude'] 🤖 Fix this with AI agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Retrieves the appropriate wallet (if any) associated with the given identity. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// # Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -78,8 +92,24 @@ pub fn get_selected_wallet( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| qualified_identity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .document_signing_key(&preorder_document_type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .ok_or_else(|| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Identity doesn't have an authentication key for signing document transitions" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .to_string() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use dash_sdk::dpp::identity::accessors::IdentityGettersV0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use dash_sdk::dpp::platform_value::string_encoding::Encoding; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let identity_label = qualified_identity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .as_deref() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .or_else(|| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| qualified_identity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .dpns_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .first() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|n| n.name.as_str()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .unwrap_or(""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| format!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Identity {} ({}) {}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| identity_label, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| qualified_identity.identity.id().to_string(Encoding::Base58), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MISSING_DOCUMENT_SIGNING_KEY_MARKER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+95
to
+112
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Display impl for Identifier outputs Base58 — same encoding used elsewhere in the UI. No mismatch here.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in a6bd8f3 — the identity id is now formatted explicitly with Encoding::Base58. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| })? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+97
to
113
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 Nitpick: Empty identity label produces a double space in the rendered message When 💡 Suggested change
Suggested change
source: ['claude'] |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Fallback: directly use the provided selected key. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
🟡 Suggestion: Error message uses jargon and lacks an actionable next step
Per the Dash Evo Tool review skill user-facing message rules: user-facing messages must avoid jargon and must include a concrete self-service action ("what happened + what to do"). The marker text —
"doesn't have an authentication key for signing document transitions"— is the original pre-PR wording and fails on both counts: it uses platform terminology aimed at developers ("authentication key", "document transitions") and tells the user nothing about what to do (e.g., "Add a signing key in this identity's Keys screen"). Since this PR already reformats the message, it's a reasonable touchpoint to bring the wording into compliance — though doing so requires updating the marker constant, which underlines the brittleness of the substring-matching design.source: ['claude']
🤖 Fix this with AI agents