fix: Fixed exiting the interactive account verification survey#558
fix: Fixed exiting the interactive account verification survey#558
Conversation
|
@FroVolod Thank you for your contribution! Your pull request is now a part of the Race of Sloths! Current status: waiting for scoringWe're waiting for maintainer to score this pull request with What is the Race of SlothsRace of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow For contributors:
For maintainers:
Feel free to check our website for additional details! Bot commands
|
There was a problem hiding this comment.
Pull request overview
This PR adjusts interactive-mode UX and control flow around account verification (including allowing users to skip verification), and aligns user-facing output to go through tracing rather than direct eprintln!.
Changes:
- Update tracing formatter and several interactive warnings/prompts to improve UI output in interactive mode.
- Extend account-state error handling with a new
Skippath and propagate it through account-existence checks. - Deduplicate configured network names when rendering UI messages.
Reviewed changes
Copilot reviewed 15 out of 18 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib.rs | Custom tracing formatter now prints the raw message field for cleaner interactive output. |
| src/config/mod.rs | network_names() now dedupes network names across multiple RPC endpoints. |
| src/common.rs | Adds AccountStateError::Skip and threads “skip verification” behavior through account state/existence helpers. |
| src/commands/transaction/send_meta_transaction/sign_as/mod.rs | Switch missing-account output from eprintln! to tracing::warn!. |
| src/commands/transaction/construct_transaction/add_action_3/add_action/delete_account/mod.rs | Improves beneficiary existence checking with Skip handling and tracing warnings. |
| src/commands/transaction/construct_transaction/add_action_2/add_action/delete_account/mod.rs | Same beneficiary verification flow updates as add_action_3. |
| src/commands/transaction/construct_transaction/add_action_1/add_action/delete_account/mod.rs | Same beneficiary verification flow updates as add_action_3. |
| src/commands/tokens/send_ft/amount_ft.rs | Adapts to updated find_network_where_account_exist error type by mapping errors into Report. |
| src/commands/contract/call_function/mod.rs | Refactors ABI-based function-name selection to be conditional on successful network/ABI resolution. |
| src/commands/account/update_social_profile/sign_as.rs | Switch missing-account output from eprintln! to tracing::warn!. |
| src/commands/account/storage_management/storage_deposit.rs | Switch missing-account output from eprintln! to tracing::warn!. |
| src/commands/account/import_account/using_web_wallet/mod.rs | Tweaks verification error messaging shown during web-wallet import. |
| src/commands/account/import_account/using_seed_phrase/mod.rs | Tweaks verification error messaging shown during seed-phrase import. |
| src/commands/account/import_account/using_private_key/mod.rs | Tweaks verification error messaging shown during private-key import. |
| src/commands/account/import_account/mod.rs | Uses AccountStateError display for cancel propagation. |
| src/commands/account/delete_account/mod.rs | Improves beneficiary verification with Skip handling and tracing warnings. |
| src/commands/account/create_account/fund_myself_create_account/sign_as/mod.rs | Allows continuing when verification is skipped; improves transport-error messaging. |
| src/commands/account/create_account/fund_myself_create_account/mod.rs | Adds “skip verification” paths and improves warnings around account availability checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if let Ok(network) = | ||
| crate::common::find_network_where_account_exist(global_context, contract_account_id.clone()) | ||
| && let Some(network_config) = network | ||
| && let Ok(contract_abi) = | ||
| tokio::runtime::Runtime::new() | ||
| .unwrap() |
There was a problem hiding this comment.
This refactor swallows all errors from find_network_where_account_exist (including Cancel) by only entering the branch on Ok(...). Previously the ? would propagate errors and let users abort. Consider explicitly handling Err(AccountStateError::Cancel) (and possibly other errors) so cancellations don’t silently fall back to manual function-name entry.
| let key_pair_properties_buf = serde_json::to_string(&key_pair_properties)?; | ||
| let error_message = format!( | ||
| "\nIt is currently not possible to verify the account access key.\nYou may not be logged in to {} or you may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n", | ||
| "\nIt is currently not possible to verify the account access key.\nYou may not be logged in to {} or you may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n ", |
There was a problem hiding this comment.
The formatted error_message literal now ends with an extra space ("\n "). This changes the rendered output (and can produce awkward trailing whitespace). Consider removing the trailing space from the string.
| "\nIt is currently not possible to verify the account access key.\nYou may not be logged in to {} or you may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n ", | |
| "\nIt is currently not possible to verify the account access key.\nYou may not be logged in to {} or you may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n", |
| &key_pair_properties.public_key_str, | ||
| &format!( | ||
| "\nIt is currently not possible to verify the account access key on network <{}>.\nYou may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n", | ||
| "\nIt is currently not possible to verify the account access key on network <{}>.\nYou may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n ", |
There was a problem hiding this comment.
This prompt string now has a trailing space at the end ("\n "), which will show up in the UI output. Consider removing the trailing space.
| "\nIt is currently not possible to verify the account access key on network <{}>.\nYou may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n ", | |
| "\nIt is currently not possible to verify the account access key on network <{}>.\nYou may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n", |
There was a problem hiding this comment.
This correctly changes the displayed result.
| &public_key.to_string(), | ||
| &format!( | ||
| "\nIt is currently not possible to verify the account access key on network <{}>.\nYou may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n", | ||
| "\nIt is currently not possible to verify the account access key on network <{}>.\nYou may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n ", |
There was a problem hiding this comment.
This formatted string ends with an extra trailing space ("\n "), which alters the displayed message. Consider removing the trailing space.
| "\nIt is currently not possible to verify the account access key on network <{}>.\nYou may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n ", | |
| "\nIt is currently not possible to verify the account access key on network <{}>.\nYou may have entered an incorrect account_id.\nYou have the option to reconfirm your account or save your access key information.\n", |
There was a problem hiding this comment.
This correctly changes the displayed result.
| crate::common::indent_payload( | ||
| "\nIt is currently possible to continue creating an account offline.\nYou can sign and send the created transaction later.\n" | ||
| ) | ||
| "\nIt is currently possible to continue creating an account offline.\nYou can sign and send the created transaction later.\n " |
There was a problem hiding this comment.
The indent_payload message ends with a trailing space ("\n "). This can result in awkward whitespace in the warning output. Consider trimming the trailing space from the string literal.
| "\nIt is currently possible to continue creating an account offline.\nYou can sign and send the created transaction later.\n " | |
| "\nIt is currently possible to continue creating an account offline.\nYou can sign and send the created transaction later.\n" |
There was a problem hiding this comment.
This correctly changes the displayed result.
| Err(near_jsonrpc_client::errors::JsonRpcError::TransportError(err)) => { | ||
| let need_check_account = suspend_tracing_indicatif::<_, color_eyre::eyre::Result<bool>>( | ||
| || { | ||
| need_check_account(format!( | ||
| "\nAccount information ({account_id}) cannot be fetched on <{}> network due to connectivity issue.", | ||
| "Account information ({account_id}) cannot be fetched on <{}> network due to connectivity issue.", | ||
| network_config.network_name | ||
| )) | ||
| }); | ||
| if need_check_account.is_err() { | ||
| return Err(AccountStateError::Cancel); | ||
| } | ||
| if let Ok(false) = need_check_account { | ||
| return Err(AccountStateError::JsonRpcError( | ||
| near_jsonrpc_client::errors::JsonRpcError::TransportError(err), | ||
| )); | ||
| } | ||
| }, | ||
| ); | ||
| if need_check_account.is_err() { | ||
| return Err(AccountStateError::Cancel); | ||
| } | ||
| Err(near_jsonrpc_client::errors::JsonRpcError::ServerError(err)) => { | ||
| let need_check_account = suspend_tracing_indicatif::< | ||
| _, | ||
| color_eyre::eyre::Result<bool>, | ||
| >(|| { | ||
| if let Ok(true) = need_check_account { | ||
| return Err(AccountStateError::JsonRpcError( | ||
| near_jsonrpc_client::errors::JsonRpcError::TransportError(err), | ||
| )); | ||
| } | ||
| return Err(AccountStateError::Skip); | ||
| } |
There was a problem hiding this comment.
In get_account_state, the need_check_account response is handled inversely: selecting “Yes, I want to check the account again” currently returns JsonRpcError(...), while selecting “No” returns Skip. This also removes the previous retry loop behavior, so “try again” never actually retries. Consider reintroducing the loop and only returning Skip when the user selects “No”; when the user selects “Yes”, retry the RPC call instead of returning an error.
| pub fn network_names(&self) -> Vec<String> { | ||
| self.network_connection | ||
| .iter() | ||
| .map(|(_, network_config)| network_config.network_name.clone()) | ||
| .collect::<std::collections::HashSet<_>>() | ||
| .into_iter() | ||
| .collect() | ||
| } |
There was a problem hiding this comment.
Config::network_names() now collects into a HashSet and then into a Vec, which makes the output order nondeterministic. Since these names are shown to users (e.g., joined into warning strings), consider deduping while preserving the original LinkedHashMap iteration order (or sort the final list) so the UI remains stable between runs.
| let mut visitor = RawMessageVisitor { | ||
| writer: writer.by_ref(), | ||
| result: Ok(()), | ||
| }; | ||
| event.record(&mut visitor); | ||
| visitor.result?; | ||
|
|
||
| ctx.field_format().format_fields(writer.by_ref(), event)?; | ||
| write!(writer, "\x1b[0m")?; | ||
|
|
||
| writeln!(writer) | ||
| } |
There was a problem hiding this comment.
SimpleFormatter no longer outputs any structured event fields besides message (the previous ctx.field_format().format_fields(...) call is gone). This is a behavior change for logs like tracing::info!(account_id=%..., "..."), where the extra fields will now be dropped. If you only want to special-case message, consider formatting the remaining fields after writing the raw message so important context isn’t lost.
src/commands/transaction/construct_transaction/add_action_3/add_action/delete_account/mod.rs
Outdated
Show resolved
Hide resolved
| Err(near_jsonrpc_client::errors::JsonRpcError::ServerError(err)) => { | ||
| let need_check_account = suspend_tracing_indicatif::<_, color_eyre::eyre::Result<bool>>( | ||
| || { | ||
| need_check_account(format!( | ||
| "\nAccount information ({account_id}) cannot be fetched on <{}> network due to server error.", | ||
| "Account information ({account_id}) cannot be fetched on <{}> network due to server error.", | ||
| network_config.network_name | ||
| )) | ||
| }); | ||
| if need_check_account.is_err() { | ||
| return Err(AccountStateError::Cancel); | ||
| } | ||
| if let Ok(false) = need_check_account { | ||
| return Err(AccountStateError::JsonRpcError( | ||
| near_jsonrpc_client::errors::JsonRpcError::ServerError(err), | ||
| )); | ||
| } | ||
| }, | ||
| ); | ||
| if need_check_account.is_err() { | ||
| return Err(AccountStateError::Cancel); | ||
| } | ||
| if let Ok(true) = need_check_account { | ||
| return Err(AccountStateError::JsonRpcError( | ||
| near_jsonrpc_client::errors::JsonRpcError::ServerError(err), | ||
| )); | ||
| } | ||
| return Err(AccountStateError::Skip); | ||
| } |
There was a problem hiding this comment.
Same issue as the transport-error branch: on server errors, Ok(true) from need_check_account (meaning “Yes, try again”) currently returns JsonRpcError, and Ok(false) returns Skip. This prevents retrying and flips the intended meaning of the prompt.
…d_action/delete_account/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>



Before update:
Screen.Recording.2026-02-12.at.16.49.57.mov
After update:
Screen.Recording.2026-02-12.at.16.44.41.mov