From 96540180dab15b6d7d8b6028d1c6151fb324bccc Mon Sep 17 00:00:00 2001 From: Matt Grogan Date: Wed, 29 Nov 2023 16:58:15 +0000 Subject: [PATCH] Burn any CHAT going to the treasury (#4891) --- backend/canisters/community/CHANGELOG.md | 4 ++++ .../impl/src/jobs/make_pending_payments.rs | 18 ++++-------------- backend/canisters/group/CHANGELOG.md | 4 ++++ .../impl/src/jobs/make_pending_payments.rs | 18 ++++-------------- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/backend/canisters/community/CHANGELOG.md b/backend/canisters/community/CHANGELOG.md index afa9023116..9dee4fade1 100644 --- a/backend/canisters/community/CHANGELOG.md +++ b/backend/canisters/community/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] +### Changed + +- Burn any CHAT going to the treasury ([#4891](https://github.com/open-chat-labs/open-chat/pull/4891)) + ## [[2.0.949](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.949-community)] - 2023-11-28 ### Added diff --git a/backend/canisters/community/impl/src/jobs/make_pending_payments.rs b/backend/canisters/community/impl/src/jobs/make_pending_payments.rs index 5ddf5d389f..7e868cca1a 100644 --- a/backend/canisters/community/impl/src/jobs/make_pending_payments.rs +++ b/backend/canisters/community/impl/src/jobs/make_pending_payments.rs @@ -3,13 +3,11 @@ use candid::Principal; use group_community_common::{PaymentRecipient, PendingPayment, PendingPaymentReason}; use ic_cdk_timers::TimerId; use ic_ledger_types::BlockIndex; -use icrc_ledger_types::icrc1::transfer::TransferArg; -use icrc_ledger_types::icrc1::{account::Account, transfer::Memo}; -use ledger_utils::convert_to_subaccount; +use icrc_ledger_types::icrc1::transfer::{Memo, TransferArg}; use std::cell::Cell; use std::time::Duration; use tracing::{error, trace}; -use types::{CanisterId, Cryptocurrency, TimestampNanos}; +use types::{CanisterId, TimestampNanos}; use utils::consts::{MEMO_JOINING_FEE, SNS_GOVERNANCE_CANISTER_ID}; thread_local! { @@ -40,16 +38,8 @@ pub fn run() { async fn process_payment(pending_payment: PendingPayment, now_nanos: TimestampNanos) { let to = match pending_payment.recipient { - PaymentRecipient::Treasury => { - if pending_payment.ledger_canister == Cryptocurrency::CHAT.ledger_canister_id().unwrap() { - Account { - owner: SNS_GOVERNANCE_CANISTER_ID, - subaccount: Some(convert_to_subaccount(&SNS_GOVERNANCE_CANISTER_ID).0), - } - } else { - SNS_GOVERNANCE_CANISTER_ID.into() - } - } + // Note in the case of CHAT this will cause the tokens to be burned + PaymentRecipient::Treasury => SNS_GOVERNANCE_CANISTER_ID.into(), PaymentRecipient::Member(user_id) => Principal::from(user_id).into(), PaymentRecipient::Account(account) => account, }; diff --git a/backend/canisters/group/CHANGELOG.md b/backend/canisters/group/CHANGELOG.md index a2a97b602c..80be639418 100644 --- a/backend/canisters/group/CHANGELOG.md +++ b/backend/canisters/group/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] +### Changed + +- Burn any CHAT going to the treasury ([#4891](https://github.com/open-chat-labs/open-chat/pull/4891)) + ## [[2.0.950](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.950-group)] - 2023-11-28 ### Added diff --git a/backend/canisters/group/impl/src/jobs/make_pending_payments.rs b/backend/canisters/group/impl/src/jobs/make_pending_payments.rs index 5ddf5d389f..7e868cca1a 100644 --- a/backend/canisters/group/impl/src/jobs/make_pending_payments.rs +++ b/backend/canisters/group/impl/src/jobs/make_pending_payments.rs @@ -3,13 +3,11 @@ use candid::Principal; use group_community_common::{PaymentRecipient, PendingPayment, PendingPaymentReason}; use ic_cdk_timers::TimerId; use ic_ledger_types::BlockIndex; -use icrc_ledger_types::icrc1::transfer::TransferArg; -use icrc_ledger_types::icrc1::{account::Account, transfer::Memo}; -use ledger_utils::convert_to_subaccount; +use icrc_ledger_types::icrc1::transfer::{Memo, TransferArg}; use std::cell::Cell; use std::time::Duration; use tracing::{error, trace}; -use types::{CanisterId, Cryptocurrency, TimestampNanos}; +use types::{CanisterId, TimestampNanos}; use utils::consts::{MEMO_JOINING_FEE, SNS_GOVERNANCE_CANISTER_ID}; thread_local! { @@ -40,16 +38,8 @@ pub fn run() { async fn process_payment(pending_payment: PendingPayment, now_nanos: TimestampNanos) { let to = match pending_payment.recipient { - PaymentRecipient::Treasury => { - if pending_payment.ledger_canister == Cryptocurrency::CHAT.ledger_canister_id().unwrap() { - Account { - owner: SNS_GOVERNANCE_CANISTER_ID, - subaccount: Some(convert_to_subaccount(&SNS_GOVERNANCE_CANISTER_ID).0), - } - } else { - SNS_GOVERNANCE_CANISTER_ID.into() - } - } + // Note in the case of CHAT this will cause the tokens to be burned + PaymentRecipient::Treasury => SNS_GOVERNANCE_CANISTER_ID.into(), PaymentRecipient::Member(user_id) => Principal::from(user_id).into(), PaymentRecipient::Account(account) => account, };