From 37f99e566574edde9674870e0d9d57e952863459 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Tue, 30 Jul 2024 10:12:12 +0100 Subject: [PATCH] Mark tokens as incompatible with ICRC1 if they have a non-zero burn fee (#6143) --- backend/canisters/registry/CHANGELOG.md | 4 ++++ backend/canisters/registry/impl/src/metadata_helper.rs | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/canisters/registry/CHANGELOG.md b/backend/canisters/registry/CHANGELOG.md index dd68671b95..67e29d705f 100644 --- a/backend/canisters/registry/CHANGELOG.md +++ b/backend/canisters/registry/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] +### Changed + +- Mark tokens as incompatible with ICRC1 if they have a non-zero burn fee ([#6143](https://github.com/open-chat-labs/open-chat/pull/6143)) + ## [[2.0.1250](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1250-registry)] - 2024-07-25 ### Changed diff --git a/backend/canisters/registry/impl/src/metadata_helper.rs b/backend/canisters/registry/impl/src/metadata_helper.rs index 4e7119c37e..4e07bde02d 100644 --- a/backend/canisters/registry/impl/src/metadata_helper.rs +++ b/backend/canisters/registry/impl/src/metadata_helper.rs @@ -16,7 +16,6 @@ impl MetadataHelper { let mut symbol = None; let mut decimals = None; let mut fee = None; - let mut burn_fee = None; let mut logo = None; let mut is_icrc1_compatible = true; @@ -26,9 +25,10 @@ impl MetadataHelper { ("icrc1:symbol", MetadataValue::Text(s)) => symbol = Some(s), ("icrc1:decimals", MetadataValue::Nat(n)) => decimals = u8::try_from(n.0).ok(), ("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::default() => { + ("icrc1:burn_fee | icrc1:transfer_fee_rate" | "icrc1:burn_fee_rate", MetadataValue::Nat(n)) + if n > Nat::default() => + { is_icrc1_compatible = false } _ => {} @@ -40,7 +40,7 @@ impl MetadataHelper { name: n, symbol: s, decimals: d, - fee: f + burn_fee.unwrap_or_default(), + fee: f, logo, is_icrc1_compatible, }),