diff --git a/backend/canisters/community/CHANGELOG.md b/backend/canisters/community/CHANGELOG.md index 526e5675e3..1bfdd5b64a 100644 --- a/backend/canisters/community/CHANGELOG.md +++ b/backend/canisters/community/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] +### Fixed + +- Don't supply a fee when BURNing ([#6948](https://github.com/open-chat-labs/open-chat/pull/6948)) + ## [[2.0.1486](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1486-community)] - 2024-12-02 ### Changed diff --git a/backend/canisters/community/impl/src/lib.rs b/backend/canisters/community/impl/src/lib.rs index 58c2de480e..817d0adf7c 100644 --- a/backend/canisters/community/impl/src/lib.rs +++ b/backend/canisters/community/impl/src/lib.rs @@ -9,7 +9,7 @@ use canister_state_macros::canister_state; use canister_timer_jobs::TimerJobs; use chat_events::ChatMetricsInternal; use community_canister::EventsResponse; -use constants::MINUTE_IN_MS; +use constants::{MINUTE_IN_MS, SNS_LEDGER_CANISTER_ID}; use event_store_producer::{EventStoreClient, EventStoreClientBuilder, EventStoreClientInfo}; use event_store_producer_cdk_runtime::CdkRuntime; use fire_and_forget_handler::FireAndForgetHandler; @@ -141,9 +141,10 @@ impl RuntimeState { let treasury_share = payment.amount.saturating_sub(owner_share * owner_count); let amount = treasury_share.saturating_sub(payment.fee); if amount > 0 { + let is_chat = payment.ledger_canister_id == SNS_LEDGER_CANISTER_ID; self.data.pending_payments_queue.push(PendingPayment { amount, - fee: payment.fee, + fee: if is_chat { 0 } else { payment.fee }, // No fee for BURNing ledger_canister: payment.ledger_canister_id, recipient: PaymentRecipient::Treasury, reason: PendingPaymentReason::AccessGate, diff --git a/backend/canisters/group/CHANGELOG.md b/backend/canisters/group/CHANGELOG.md index 61bd4e9c95..1421f23ac4 100644 --- a/backend/canisters/group/CHANGELOG.md +++ b/backend/canisters/group/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] +### Fixed + +- Don't supply a fee when BURNing ([#6948](https://github.com/open-chat-labs/open-chat/pull/6948)) + ## [[2.0.1487](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1487-group)] - 2024-12-02 ### Changed diff --git a/backend/canisters/group/impl/src/lib.rs b/backend/canisters/group/impl/src/lib.rs index cb1fa2cc43..2b102f810d 100644 --- a/backend/canisters/group/impl/src/lib.rs +++ b/backend/canisters/group/impl/src/lib.rs @@ -8,7 +8,7 @@ use candid::Principal; use canister_state_macros::canister_state; use canister_timer_jobs::TimerJobs; use chat_events::Reader; -use constants::{DAY_IN_MS, HOUR_IN_MS, MINUTE_IN_MS, OPENCHAT_BOT_USER_ID}; +use constants::{DAY_IN_MS, HOUR_IN_MS, MINUTE_IN_MS, OPENCHAT_BOT_USER_ID, SNS_LEDGER_CANISTER_ID}; use event_store_producer::{EventStoreClient, EventStoreClientBuilder, EventStoreClientInfo}; use event_store_producer_cdk_runtime::CdkRuntime; use fire_and_forget_handler::FireAndForgetHandler; @@ -149,9 +149,10 @@ impl RuntimeState { let treasury_share = payment.amount.saturating_sub(owner_share * owner_count); let amount = treasury_share.saturating_sub(payment.fee); if amount > 0 { + let is_chat = payment.ledger_canister_id == SNS_LEDGER_CANISTER_ID; self.data.pending_payments_queue.push(PendingPayment { amount, - fee: payment.fee, + fee: if is_chat { 0 } else { payment.fee }, // No fee for BURNing ledger_canister: payment.ledger_canister_id, recipient: PaymentRecipient::Treasury, reason: PendingPaymentReason::AccessGate, diff --git a/backend/canisters/registry/CHANGELOG.md b/backend/canisters/registry/CHANGELOG.md index 8cbd2d90d3..d0b7a4848c 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] +### Fixed + +- Fix listing fee transfer ([#6948](https://github.com/open-chat-labs/open-chat/pull/6948)) + ## [[2.0.1483](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1483-registry)] - 2024-11-29 ### Added diff --git a/backend/canisters/registry/impl/src/lifecycle/init.rs b/backend/canisters/registry/impl/src/lifecycle/init.rs index ced8f72874..d6b5089bab 100644 --- a/backend/canisters/registry/impl/src/lifecycle/init.rs +++ b/backend/canisters/registry/impl/src/lifecycle/init.rs @@ -1,9 +1,13 @@ +use std::time::Duration; + use crate::lifecycle::{init_env, init_state}; +use crate::updates::add_token::add_token_impl; use crate::Data; +use candid::Principal; use canister_tracing_macros::trace; use ic_cdk::init; use registry_canister::init::Args; -use tracing::info; +use tracing::{error, info}; use utils::cycles::init_cycles_dispenser_client; use utils::env::Environment; @@ -34,4 +38,37 @@ fn init(args: Args) { init_state(env, data, args.wasm_version); info!(version = %args.wasm_version, "Initialization complete"); + + ic_cdk_timers::set_timer(Duration::ZERO, add_token); +} + +fn add_token() { + ic_cdk::spawn(add_token_inner()); + + async fn add_token_inner() { + let ledger_canister_id = Principal::from_text("npnnq-naaaa-aaaam-qb7va-cai").unwrap(); + let payer = Principal::from_text("icbn4-5qaaa-aaaaf-bp72q-cai").unwrap().into(); + let info_url = "https://info.icpswap.com/token/details/npnnq-naaaa-aaaam-qb7va-cai".to_string(); + let how_to_buy_url = + "https://app.icpswap.com/swap?input=ryjl3-tyaaa-aaaaa-aaaba-cai&output=npnnq-naaaa-aaaam-qb7va-cai".to_string(); + let transaction_url_format = "https://ic.house/token/npnnq-naaaa-aaaam-qb7va-cai".to_string(); + + let response = add_token_impl( + ledger_canister_id, + Some(payer), + None, + Some(info_url), + Some(how_to_buy_url), + Some(transaction_url_format), + None, + ) + .await; + + match response { + registry_canister::add_token::Response::Success => { + info!("AWB added"); + } + _ => error!("Failed to add AWB: {response:?}"), + } + } } diff --git a/backend/canisters/registry/impl/src/updates/add_token.rs b/backend/canisters/registry/impl/src/updates/add_token.rs index 90f235390c..0fdb46be07 100644 --- a/backend/canisters/registry/impl/src/updates/add_token.rs +++ b/backend/canisters/registry/impl/src/updates/add_token.rs @@ -42,7 +42,7 @@ pub(crate) async fn add_sns_token(nervous_system: NervousSystemDetails) { } #[allow(clippy::too_many_arguments)] -async fn add_token_impl( +pub(crate) async fn add_token_impl( ledger_canister_id: CanisterId, payer: Option, nervous_system: Option, @@ -115,7 +115,7 @@ async fn add_token_impl( from: from.into(), to: SNS_GOVERNANCE_CANISTER_ID.into(), amount: amount.into(), - fee: Cryptocurrency::CHAT.fee().map(|fee| fee.into()), + fee: None, // No transfer fee for BURNing memo: Some(MEMO_LIST_TOKEN.to_vec().into()), created_at_time: Some(now_nanos), };