Skip to content

Commit

Permalink
Burn any CHAT going to the treasury (#4891)
Browse files Browse the repository at this point in the history
  • Loading branch information
megrogan authored Nov 29, 2023
1 parent af59228 commit 9654018
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/community/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 4 additions & 14 deletions backend/canisters/community/impl/src/jobs/make_pending_payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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,
};
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/group/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 4 additions & 14 deletions backend/canisters/group/impl/src/jobs/make_pending_payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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,
};
Expand Down

0 comments on commit 9654018

Please sign in to comment.