From 8f12430d54a9b1884d7a3e5758a8075b3de9ab44 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Wed, 24 Jul 2024 18:21:51 +0100 Subject: [PATCH 1/3] Fix ICRC1 compatibility check --- backend/canisters/registry/impl/src/metadata_helper.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/canisters/registry/impl/src/metadata_helper.rs b/backend/canisters/registry/impl/src/metadata_helper.rs index 0cf760212d..499d7ab967 100644 --- a/backend/canisters/registry/impl/src/metadata_helper.rs +++ b/backend/canisters/registry/impl/src/metadata_helper.rs @@ -1,3 +1,4 @@ +use candid::Nat; use icrc_ledger_types::icrc::generic_metadata_value::MetadataValue; pub struct MetadataHelper { @@ -27,7 +28,9 @@ impl MetadataHelper { ("icrc1:fee", MetadataValue::Nat(n)) => fee = u128::try_from(n.0).ok(), ("icrc1:burn_fee", MetadataValue::Nat(n)) => burn_fee = u128::try_from(n.0).ok(), ("icrc1:logo", MetadataValue::Text(s)) => logo = Some(s), - ("icrc1:transfer_fee_rate" | "icrc1:burn_fee_rate", _) => is_icrc1_compatible = false, + ("icrc1:transfer_fee_rate" | "icrc1:burn_fee_rate", MetadataValue::Nat(n)) if n > Nat::from(0u32) => { + is_icrc1_compatible = false + } _ => {} } } From 3a178a72723fcde73b88f17d00815d5ad0502766 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Wed, 24 Jul 2024 18:28:04 +0100 Subject: [PATCH 2/3] clippy --- backend/canisters/registry/impl/src/metadata_helper.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/canisters/registry/impl/src/metadata_helper.rs b/backend/canisters/registry/impl/src/metadata_helper.rs index 499d7ab967..9a8662d1dd 100644 --- a/backend/canisters/registry/impl/src/metadata_helper.rs +++ b/backend/canisters/registry/impl/src/metadata_helper.rs @@ -28,7 +28,9 @@ impl MetadataHelper { ("icrc1:fee", MetadataValue::Nat(n)) => fee = u128::try_from(n.0).ok(), ("icrc1:burn_fee", MetadataValue::Nat(n)) => burn_fee = u128::try_from(n.0).ok(), ("icrc1:logo", MetadataValue::Text(s)) => logo = Some(s), - ("icrc1:transfer_fee_rate" | "icrc1:burn_fee_rate", MetadataValue::Nat(n)) if n > Nat::from(0u32) => { + ("icrc1:transfer_fee_rate" | "icrc1:burn_fee_rate", MetadataValue::Nat(n)) + if u128::try_from(n.0).unwrap_or_default() > 0 => + { is_icrc1_compatible = false } _ => {} From 921e437ecbe3ef62e8f5d8b07903b9a987866007 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Wed, 24 Jul 2024 18:29:41 +0100 Subject: [PATCH 3/3] Take 2 --- backend/canisters/registry/impl/src/metadata_helper.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/canisters/registry/impl/src/metadata_helper.rs b/backend/canisters/registry/impl/src/metadata_helper.rs index 9a8662d1dd..4e7119c37e 100644 --- a/backend/canisters/registry/impl/src/metadata_helper.rs +++ b/backend/canisters/registry/impl/src/metadata_helper.rs @@ -28,9 +28,7 @@ impl MetadataHelper { ("icrc1:fee", MetadataValue::Nat(n)) => fee = u128::try_from(n.0).ok(), ("icrc1:burn_fee", MetadataValue::Nat(n)) => burn_fee = u128::try_from(n.0).ok(), ("icrc1:logo", MetadataValue::Text(s)) => logo = Some(s), - ("icrc1:transfer_fee_rate" | "icrc1:burn_fee_rate", MetadataValue::Nat(n)) - if u128::try_from(n.0).unwrap_or_default() > 0 => - { + ("icrc1:transfer_fee_rate" | "icrc1:burn_fee_rate", MetadataValue::Nat(n)) if n > Nat::default() => { is_icrc1_compatible = false } _ => {}