diff --git a/golem_cli/src/command/yagna.rs b/golem_cli/src/command/yagna.rs index 14aa09f237..93698b205f 100644 --- a/golem_cli/src/command/yagna.rs +++ b/golem_cli/src/command/yagna.rs @@ -124,7 +124,10 @@ lazy_static! { name: "erc20next", } }; - pub static ref DRIVERS: Vec<&'static PaymentDriver> = vec![&ERC20_DRIVER]; + + // Drivers are searched in order when more than one supports a given network, + // so erc20next should be preferred over erc20. + pub static ref DRIVERS: Vec<&'static PaymentDriver> = vec![&ERC20NEXT_DRIVER, &ERC20_DRIVER]; } impl PaymentDriver { diff --git a/golem_cli/src/status.rs b/golem_cli/src/status.rs index 0ca0b71dfc..ac32ac17f0 100644 --- a/golem_cli/src/status.rs +++ b/golem_cli/src/status.rs @@ -13,11 +13,20 @@ use ya_core_model::NodeId; use crate::appkey; use crate::command::{ - NetworkGroup, PaymentSummary, YaCommand, DRIVERS, ERC20_DRIVER, NETWORK_GROUP_MAP, + NetworkGroup, PaymentDriver, PaymentSummary, YaCommand, DRIVERS, ERC20_DRIVER, + NETWORK_GROUP_MAP, }; use crate::platform::Status as KvmStatus; use crate::utils::{is_yagna_running, payment_account}; +fn get_driver_for_network(network: &NetworkName) -> Option<&PaymentDriver> { + DRIVERS + .iter() + .find(|drv| drv.platform(network).is_ok()) + .as_deref() + .copied() +} + async fn payment_status( cmd: &YaCommand, network: &NetworkName, @@ -32,11 +41,9 @@ async fn payment_status( let mut f = vec![]; let mut l = vec![]; for nn in NETWORK_GROUP_MAP[&network_group].iter() { - for driver in DRIVERS.iter() { - if driver.platform(nn).is_ok() { - l.push(driver.status_label(nn)); - f.push(cmd.yagna()?.payment_status(&address, nn, driver)); - } + if let Some(driver) = get_driver_for_network(nn) { + l.push(driver.status_label(nn)); + f.push(cmd.yagna()?.payment_status(&address, nn, driver)); } } (f, l)