Skip to content

Commit 12e380c

Browse files
cli: Fix not respecting provider.cluster in keys sync command (solana-foundation#3761)
1 parent cbb89ed commit 12e380c

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The minor version will be incremented upon a breaking change and the patch versi
1616

1717
- docker: Upgrade `node` to 20.18.0 LTS ([#3687](https://github.com/solana-foundation/anchor/pull/3687)).
1818
- cli: Fix using deprecated commitment `recent` in migration scripts ([#3725](https://github.com/coral-xyz/anchor/pull/3725)).
19+
- cli: Fix not respecting `provider.cluster` in `keys sync` command ([#3761](https://github.com/coral-xyz/anchor/pull/3761)).
1920

2021
### Breaking
2122

cli/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4595,6 +4595,9 @@ fn keys_sync(cfg_override: &ConfigOverride, program_name: Option<String>) -> Res
45954595
.build()
45964596
.unwrap();
45974597

4598+
let cfg_cluster = cfg.provider.cluster.to_owned();
4599+
println!("Syncing program ids for the configured cluster ({cfg_cluster})\n");
4600+
45984601
let mut changed_src = false;
45994602
for program in cfg.get_programs(program_name)? {
46004603
// Get the pubkey from the keypair file
@@ -4628,7 +4631,12 @@ fn keys_sync(cfg_override: &ConfigOverride, program_name: Option<String>) -> Res
46284631
}
46294632

46304633
// Handle declaration in Anchor.toml
4631-
'outer: for programs in cfg.programs.values_mut() {
4634+
'outer: for (cluster, programs) in &mut cfg.programs {
4635+
// Only change if the configured cluster matches the program's cluster
4636+
if cluster != &cfg_cluster {
4637+
continue;
4638+
}
4639+
46324640
for (name, deployment) in programs {
46334641
// Skip other programs
46344642
if name != &program.lib_name {

0 commit comments

Comments
 (0)