Skip to content

fix: Fixed exiting the interactive account verification survey#558

Draft
FroVolod wants to merge 9 commits intomainfrom
account-state-error
Draft

fix: Fixed exiting the interactive account verification survey#558
FroVolod wants to merge 9 commits intomainfrom
account-state-error

Conversation

@FroVolod
Copy link
Collaborator

@FroVolod FroVolod commented Feb 11, 2026

  1. Fixed some UI issues for interactive mode.
  2. Fixed exiting the interactive account verification survey.

Before update:

Screen.Recording.2026-02-12.at.16.49.57.mov

After update:

Screen.Recording.2026-02-12.at.16.44.41.mov

@FroVolod FroVolod marked this pull request as ready for review February 13, 2026 07:32
@FroVolod FroVolod requested a review from a team as a code owner February 13, 2026 07:32
@FroVolod
Copy link
Collaborator Author

@race-of-sloths

@race-of-sloths
Copy link

@FroVolod Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
Weekly streak is on the road, smart strategy! Secure your streak with another PR!

Shows inviting banner with latest news.

Shows profile picture for the author of the PR

Current status: waiting for scoring

We're waiting for maintainer to score this pull request with @race-of-sloths score [0,1,2,3,5,8,13] command. Alternatively, autoscoring [1,2] will be applied for this pull request

What is the Race of Sloths

Race 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:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

@FroVolod FroVolod marked this pull request as draft February 13, 2026 16:43
@FroVolod FroVolod marked this pull request as ready for review February 13, 2026 16:46
@r-near r-near requested a review from Copilot February 13, 2026 17:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 Skip path 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.

Comment on lines 58 to 63
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()
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done (c1b513c)

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 ",
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
"\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",

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

@FroVolod FroVolod Feb 14, 2026

Choose a reason for hiding this comment

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

This correctly changes the displayed result.
Screenshot 2026-02-14 at 09 15 37

After removing the space at the end of the line:
Screenshot 2026-02-14 at 08 47 24

&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 ",
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
"\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",

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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 ",
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

This formatted string ends with an extra trailing space ("\n "), which alters the displayed message. Consider removing the trailing space.

Suggested change
"\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",

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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 "
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
"\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"

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This correctly changes the displayed result.

Comment on lines +502 to +520
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);
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 156 to 163
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()
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done (e75c873)

Comment on lines +95 to 105
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)
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

@FroVolod FroVolod Feb 14, 2026

Choose a reason for hiding this comment

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

done (becacf7)

Image

Comment on lines +521 to 539
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);
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
…d_action/delete_account/mod.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@FroVolod FroVolod marked this pull request as draft February 15, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: NEW❗

Development

Successfully merging this pull request may close these issues.

3 participants