Skip to content
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
2 changes: 1 addition & 1 deletion core/control-panel/impl/src/controllers/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn init_timers_fn() {
async fn initialize_rng_timer() {
use orbit_essentials::utils::initialize_rng;
if let Err(e) = initialize_rng().await {
ic_cdk::print(format!("initializing rng failed: {}", e));
ic_cdk::print(format!("initializing rng failed: {e}"));
ic_cdk_timers::set_timer(std::time::Duration::from_secs(60), move || {
spawn(initialize_rng_timer())
});
Expand Down
3 changes: 1 addition & 2 deletions core/control-panel/impl/src/controllers/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ mod tests {
assert_eq!(
response.body,
format!(
r#"[{{"targets": ["{}"],"labels": {{"__metrics_path__":"/metrics","dapp":"orbit"}}}}]"#,
station_host
r#"[{{"targets": ["{station_host}"],"labels": {{"__metrics_path__":"/metrics","dapp":"orbit"}}}}]"#
)
.as_bytes()
.to_owned()
Expand Down
2 changes: 1 addition & 1 deletion core/control-panel/impl/src/core/middlewares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ where
ic_cdk::api::print(
serde_json::to_string(&LogMessage {
function: target_fn.to_string(),
message: format!("completed execution with result {:?}", result),
message: format!("completed execution with result {result:?}"),
timestamp: ic_cdk::api::time(),
caller: context.caller().to_text(),
})
Expand Down
3 changes: 1 addition & 2 deletions core/control-panel/impl/src/mappers/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ impl HelperMapper {
}

print(format!(
"Failed to parse semver {}, fallback to 0.0.0",
version_text
"Failed to parse semver {version_text}, fallback to 0.0.0"
));

semver::Version::new(0, 0, 0)
Expand Down
13 changes: 5 additions & 8 deletions core/control-panel/impl/src/models/registry_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ fn validate_wasm_module_version(version: &str) -> ModelValidatorResult<RegistryE

if let Err(e) = semver::Version::parse(version) {
return Err(RegistryError::ValidationError {
info: format!("Invalid semver: {}", e),
info: format!("Invalid semver: {e}"),
});
}

Expand Down Expand Up @@ -381,16 +381,13 @@ fn validate_chars(field: &str, content: &str) -> ModelValidatorResult<RegistryEr
.all(|c| c.is_ascii_lowercase() || c.is_numeric() || c == '-')
{
return Err(RegistryError::ValidationError {
info: format!(
"{} can only contain lowercase letters, numbers, and hyphens",
field
),
info: format!("{field} can only contain lowercase letters, numbers, and hyphens"),
});
}

if content.starts_with('-') || content.ends_with('-') {
return Err(RegistryError::ValidationError {
info: format!("{} cannot start or end with a hyphen", field),
info: format!("{field} cannot start or end with a hyphen"),
});
}

Expand Down Expand Up @@ -730,7 +727,7 @@ mod tests {
}

#[rstest]
#[case::too_many_categories((0..RegistryEntry::MAX_CATEGORIES + 1).map(|i| format!("test-{}", i).to_string()).collect())]
#[case::too_many_categories((0..RegistryEntry::MAX_CATEGORIES + 1).map(|i| format!("test-{i}").to_string()).collect())]
#[case::category_too_small(vec!["a".to_string()])]
#[case::category_too_big(vec!["a".repeat(RegistryEntry::MAX_CATEGORY_LENGTH + 1)])]
#[case::duplicate_categories(vec!["test".to_string(), "test".to_string()])]
Expand Down Expand Up @@ -870,7 +867,7 @@ mod tests {
let dependencies = (0..WasmModuleRegistryValue::MAX_DEPENDENCIES + 1)
.map(|i| WasmModuleRegistryEntryDependency {
name: i.to_string(),
version: format!("1.0.{}", i),
version: format!("1.0.{i}"),
})
.collect();

Expand Down
4 changes: 2 additions & 2 deletions core/control-panel/impl/src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn validate_email(email: &str) -> ModelValidatorResult<UserError> {
}
if let Err(e) = EmailAddress::from_str(email) {
return Err(UserError::ValidationError {
info: format!("Email validation failed: {}", e,),
info: format!("Email validation failed: {e}",),
});
}

Expand All @@ -166,7 +166,7 @@ fn validate_stations(stations: &[UserStation]) -> ModelValidatorResult<UserError
for station in stations.iter() {
if let Err(e) = station.validate() {
return Err(UserError::ValidationError {
info: format!("Station validation failed: {:?}", e,),
info: format!("Station validation failed: {e:?}",),
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/control-panel/impl/src/models/user_station.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn validate_labels(labels: &[String]) -> ModelValidatorResult<UserError> {
for label in labels {
if label.len() > MAX_LABEL_LEN {
return Err(UserError::ValidationError {
info: format!("Station label length cannot exceed {}", MAX_LABEL_LEN),
info: format!("Station label length cannot exceed {MAX_LABEL_LEN}"),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ mod tests {
let repository = RegistryIndexRepository::default();
for i in 0..10 {
repository.insert(RegistryIndex {
index: RegistryIndexKind::Namespace(format!("ns-{}", i)),
index: RegistryIndexKind::Namespace(format!("ns-{i}")),
registry_entry_id: [i; 16],
});
}
Expand Down
12 changes: 6 additions & 6 deletions core/control-panel/impl/src/repositories/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ mod tests {
for i in 0..5 {
let mut entry = create_registry_entry();
entry.namespace = "orbit".to_string();
entry.name = format!("entry-{}", i);
entry.name = format!("entry-{i}");
entry.validate().unwrap();

repository.insert(entry.id, entry);
Expand Down Expand Up @@ -607,7 +607,7 @@ mod tests {
for i in 0..5 {
let mut entry = create_registry_entry();
entry.namespace = "orbit".to_string();
entry.name = format!("entry-{}", i);
entry.name = format!("entry-{i}");
entry.validate().unwrap();

repository.insert(entry.id, entry);
Expand Down Expand Up @@ -636,7 +636,7 @@ mod tests {
for i in 0..5 {
let mut entry = create_registry_entry();
entry.namespace = RegistryEntry::DEFAULT_NAMESPACE.to_string();
entry.name = format!("entry-{}", i);
entry.name = format!("entry-{i}");
entry.validate().unwrap();

repository.insert(entry.id, entry);
Expand All @@ -661,7 +661,7 @@ mod tests {
let repository = RegistryRepository::default();
for i in 0..5 {
let mut entry = create_registry_entry();
entry.categories.push(format!("category-{}", i));
entry.categories.push(format!("category-{i}"));
entry.validate().unwrap();

repository.insert(entry.id, entry);
Expand Down Expand Up @@ -693,7 +693,7 @@ mod tests {
let repository = RegistryRepository::default();
for i in 0..5 {
let mut entry = create_registry_entry();
entry.tags.push(format!("tag-{}", i));
entry.tags.push(format!("tag-{i}"));
entry.validate().unwrap();

repository.insert(entry.id, entry);
Expand Down Expand Up @@ -749,7 +749,7 @@ mod tests {
entry.name = "station".to_string();
entry.value = RegistryValue::WasmModule(WasmModuleRegistryValue {
wasm_artifact_id: *Uuid::new_v4().as_bytes(),
version: format!("1.0.{}", i),
version: format!("1.0.{i}"),
dependencies: Vec::new(),
module_extra_chunks: None,
});
Expand Down
2 changes: 1 addition & 1 deletion core/control-panel/impl/src/services/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl CanisterService {

USER_REPOSITORY.insert(user.to_key(), user.clone());
}),
Some(version) => print(format!("No migration for version: {}", version)),
Some(version) => print(format!("No migration for version: {version}")),
};
}
}
10 changes: 5 additions & 5 deletions core/control-panel/impl/src/services/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ mod tests {
for i in 0..10 {
let mut entry = create_registry_entry();
entry.namespace = "orbit".to_string();
entry.name = format!("module-{}", i);
entry.name = format!("module-{i}");

REGISTRY_REPOSITORY.insert(entry.id, entry.clone());
}
Expand Down Expand Up @@ -387,7 +387,7 @@ mod tests {
for i in 0..10 {
let mut entry = create_registry_entry();
entry.namespace = "test".to_string();
entry.name = format!("module-{}", i);
entry.name = format!("module-{i}");

REGISTRY_REPOSITORY.insert(entry.id, entry.clone());
}
Expand Down Expand Up @@ -415,7 +415,7 @@ mod tests {
entry.name = "module".to_string();
entry.value = RegistryValue::WasmModule(WasmModuleRegistryValue {
wasm_artifact_id: *Uuid::new_v4().as_bytes(),
version: format!("1.0.{}", i),
version: format!("1.0.{i}"),
dependencies: Vec::new(),
module_extra_chunks: None,
});
Expand Down Expand Up @@ -583,7 +583,7 @@ mod tests {
entry.name = "module".to_string();
entry.value = RegistryValue::WasmModule(WasmModuleRegistryValue {
wasm_artifact_id: *Uuid::new_v4().as_bytes(),
version: format!("1.0.{}", i),
version: format!("1.0.{i}"),
dependencies: Vec::new(),
module_extra_chunks: None,
});
Expand Down Expand Up @@ -611,7 +611,7 @@ mod tests {
entry.name = "module".to_string();
entry.value = RegistryValue::WasmModule(WasmModuleRegistryValue {
wasm_artifact_id: *Uuid::new_v4().as_bytes(),
version: format!("1.0.{}", i),
version: format!("1.0.{i}"),
dependencies: Vec::new(),
module_extra_chunks: None,
});
Expand Down
4 changes: 2 additions & 2 deletions core/station/api/src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ impl Display for NotificationTypeInput {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
NotificationTypeInput::SystemMessage => {
write!(f, "{}", SYSTEM_MESSAGE_NOTIFICATION_TYPE)
write!(f, "{SYSTEM_MESSAGE_NOTIFICATION_TYPE}")
}
NotificationTypeInput::RequestCreated => {
write!(f, "{}", REQUEST_CREATED_NOTIFICATION_TYPE)
write!(f, "{REQUEST_CREATED_NOTIFICATION_TYPE}")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/station/impl/src/controllers/external_canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async fn canister_status(input: CanisterStatusInput) -> CanisterStatusResponse {
CONTROLLER
.canister_status(input)
.await
.unwrap_or_else(|e| trap(&format!("{:?}", e)))
.unwrap_or_else(|e| trap(&format!("{e:?}")))
}

#[update(name = "canister_snapshots")]
Expand Down
2 changes: 1 addition & 1 deletion core/station/impl/src/controllers/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl NotificationController {
NotificationMapperError::InvalidRequestStatus {
expected, found
} => {
print(format!("Invalid request status when mapping to NotificationDTO: expected \"{}\", found \"{}\"", expected, found));
print(format!("Invalid request status when mapping to NotificationDTO: expected \"{expected}\", found \"{found}\""));
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion core/station/impl/src/core/middlewares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn authorize(ctx: &CallContext, resources: &[Resource]) {
let allowed = Authorization::is_allowed(ctx, resource);

if !allowed {
unauthorized_resources.push(format!("{}", resource));
unauthorized_resources.push(format!("{resource}"));
}

allowed
Expand Down
2 changes: 1 addition & 1 deletion core/station/impl/src/core/observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ mod tests {
fn test_observer_debug() {
let observer = Observer::<i32>::default();

assert_eq!(format!("{:?}", observer), "Observer { listeners: 0 }");
assert_eq!(format!("{observer:?}"), "Observer { listeners: 0 }");
}
}
4 changes: 2 additions & 2 deletions core/station/impl/src/errors/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl From<RecordValidationError> for RequestError {
fn from(err: RecordValidationError) -> RequestError {
match err {
RecordValidationError::NotFound { id, model_name } => RequestError::ValidationError {
info: format!("Invalid UUID: {} {} not found", model_name, id),
info: format!("Invalid UUID: {model_name} {id} not found"),
},
}
}
Expand All @@ -99,7 +99,7 @@ impl From<ExternalCanisterValidationError> for RequestError {
match err {
ExternalCanisterValidationError::InvalidExternalCanister { principal } => {
RequestError::ValidationError {
info: format!("Invalid external canister {}", principal),
info: format!("Invalid external canister {principal}"),
}
}
ExternalCanisterValidationError::ValidationError { info } => {
Expand Down
4 changes: 2 additions & 2 deletions core/station/impl/src/errors/request_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl From<RecordValidationError> for RequestPolicyError {
match err {
RecordValidationError::NotFound { id, model_name } => {
RequestPolicyError::ValidationError {
info: format!("Invalid UUID: {} {} not found", model_name, id),
info: format!("Invalid UUID: {model_name} {id} not found"),
}
}
}
Expand All @@ -67,7 +67,7 @@ impl From<ExternalCanisterValidationError> for RequestPolicyError {
match err {
ExternalCanisterValidationError::InvalidExternalCanister { principal } => {
RequestPolicyError::ValidationError {
info: format!("Invalid external canister {}", principal),
info: format!("Invalid external canister {principal}"),
}
}
ExternalCanisterValidationError::ValidationError { info } => {
Expand Down
6 changes: 3 additions & 3 deletions core/station/impl/src/errors/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ pub enum ValidationError {
impl Display for ValidationError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
ValidationError::RecordValidationError(err) => write!(f, "{}", err),
ValidationError::ExternalCanisterValidationError(err) => write!(f, "{}", err),
ValidationError::SystemInfoValidationError(err) => write!(f, "{}", err),
ValidationError::RecordValidationError(err) => write!(f, "{err}"),
ValidationError::ExternalCanisterValidationError(err) => write!(f, "{err}"),
ValidationError::SystemInfoValidationError(err) => write!(f, "{err}"),
}
}
}
Expand Down
21 changes: 10 additions & 11 deletions core/station/impl/src/factories/blockchains/internet_computer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,21 @@ impl InternetComputer {
.map_err(|err| BlockchainApiError::TransactionSubmitFailed {
info: match err {
ic_ledger_types::TransferError::BadFee { expected_fee } => {
format!("Bad fee, expected: {}", expected_fee)
format!("Bad fee, expected: {expected_fee}")
}
ic_ledger_types::TransferError::InsufficientFunds { balance } => {
format!("Insufficient balance, balance: {}", balance)
format!("Insufficient balance, balance: {balance}")
}
ic_ledger_types::TransferError::TxTooOld {
allowed_window_nanos,
} => {
format!("Tx too old, allowed_window_nanos: {}", allowed_window_nanos)
format!("Tx too old, allowed_window_nanos: {allowed_window_nanos}")
}
ic_ledger_types::TransferError::TxCreatedInFuture => {
"Tx created in future".to_string()
}
ic_ledger_types::TransferError::TxDuplicate { duplicate_of } => {
format!("Tx duplicate, duplicate_of: {}", duplicate_of)
format!("Tx duplicate, duplicate_of: {duplicate_of}")
}
},
})?;
Expand All @@ -291,8 +291,7 @@ impl InternetComputer {
},
None => {
print(format!(
"Error: no ICP ledger block found at height {}",
block_height
"Error: no ICP ledger block found at height {block_height}"
));
None
}
Expand Down Expand Up @@ -368,12 +367,12 @@ impl InternetComputer {
.map_err(|err| BlockchainApiError::TransactionSubmitFailed {
info: match err {
icrc_ledger_types::icrc1::transfer::TransferError::BadFee { expected_fee } => {
format!("Bad fee, expected: {}", expected_fee)
format!("Bad fee, expected: {expected_fee}")
}
icrc_ledger_types::icrc1::transfer::TransferError::InsufficientFunds {
balance,
} => {
format!("Insufficient balance, balance: {}", balance)
format!("Insufficient balance, balance: {balance}")
}
icrc_ledger_types::icrc1::transfer::TransferError::TooOld => {
"Tx too old".to_string()
Expand All @@ -382,10 +381,10 @@ impl InternetComputer {
"Tx created in future".to_string()
}
icrc_ledger_types::icrc1::transfer::TransferError::Duplicate { duplicate_of } => {
format!("Tx duplicate, duplicate_of: {}", duplicate_of)
format!("Tx duplicate, duplicate_of: {duplicate_of}")
}
icrc_ledger_types::icrc1::transfer::TransferError::BadBurn { min_burn_amount } => {
format!("Bad burn, min_burn_amount: {}", min_burn_amount)
format!("Bad burn, min_burn_amount: {min_burn_amount}")
}
icrc_ledger_types::icrc1::transfer::TransferError::TemporarilyUnavailable => {
"Ledger temporarily unavailable".to_string()
Expand All @@ -394,7 +393,7 @@ impl InternetComputer {
error_code,
message,
} => {
format!("Error occurred. Code: {}, message: {}", error_code, message)
format!("Error occurred. Code: {error_code}, message: {message}")
}
},
})?;
Expand Down
Loading
Loading