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

cli: Fix anchor account command panicking outside of workspace #2620

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- cli: Fix `anchor build --no-docs` adding docs to the IDL ([#2575](https://github.com/coral-xyz/anchor/pull/2575)).
- ts: Load workspace programs on-demand rather than loading all of them at once ([#2579](https://github.com/coral-xyz/anchor/pull/2579)).
- lang: Fix `associated_token::token_program` constraint ([#2603](https://github.com/coral-xyz/anchor/pull/2603)).
- cli: Fix `anchor account` command panicking outside of workspace ([#2620](https://github.com/coral-xyz/anchor/pull/2620)).

### Breaking

Expand Down
11 changes: 6 additions & 5 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2594,11 +2594,12 @@ fn account(
},
);

let mut cluster = &Config::discover(cfg_override)
.map(|cfg| cfg.unwrap())
.map(|cfg| cfg.provider.cluster.clone())
.unwrap_or(Cluster::Localnet);
cluster = cfg_override.cluster.as_ref().unwrap_or(cluster);
let cluster = match &cfg_override.cluster {
Some(cluster) => cluster.clone(),
None => Config::discover(cfg_override)?
.map(|cfg| cfg.provider.cluster.clone())
.unwrap_or(Cluster::Localnet),
};

let data = create_client(cluster.url()).get_account_data(&address)?;
if data.len() < 8 {
Expand Down
Loading