Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cycles-minting): Cycles Minting canister refunds automatically. #3484

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rs/nns/cmc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ DEV_DEPENDENCIES = [
"//rs/types/types_test_utils",
"@crate_index//:candid_parser",
"@crate_index//:futures",
"@crate_index//:maplit",
"@crate_index//:serde_bytes",
]

Expand Down
1 change: 1 addition & 0 deletions rs/nns/cmc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ yansi = "0.5.0"

[dev-dependencies]
candid_parser = { workspace = true }
maplit = "1.0.2"
futures = { workspace = true }
ic-types-test-utils = { path = "../../types/types_test_utils" }
serde_bytes = { workspace = true }
Expand Down
13 changes: 13 additions & 0 deletions rs/nns/cmc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,23 @@ pub struct CyclesLedgerDepositResult {
pub block_index: Nat,
}

// When a user sends us ICP, they indicate via memo (or icrc1_memo) what
// operation they want to perform.
//
// We promise that we will NEVER use 0 as one of these values. (This would be
// very bad, because if no memo is explicitly supplied, the Transaction might
// implicitly have 0 in the memo field.)
//
// Note to developers: If you add new values, update MEANINGFUL_MEMOS.
pub const MEMO_CREATE_CANISTER: Memo = Memo(0x41455243); // == 'CREA'
pub const MEMO_TOP_UP_CANISTER: Memo = Memo(0x50555054); // == 'TPUP'
pub const MEMO_MINT_CYCLES: Memo = Memo(0x544e494d); // == 'MINT'

// New values might be added to this later. Do NOT assume that values won't be
// added to this array later.
pub const MEANINGFUL_MEMOS: [Memo; 3] =
[MEMO_CREATE_CANISTER, MEMO_TOP_UP_CANISTER, MEMO_MINT_CYCLES];

pub fn create_canister_txn(
amount: Tokens,
from_subaccount: Option<Subaccount>,
Expand Down
Loading
Loading