-
Notifications
You must be signed in to change notification settings - Fork 329
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
Open
daniel-wong-dfinity-org
wants to merge
18
commits into
master
Choose a base branch
from
cmc-automatic-refund-daniel-wong
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
300b362
Implemented automatic refund in Cycles Minting canister. Builds, and …
daniel-wong-dfinity-org 66544fc
Some tests. Also, simplified set_block_status_to_processing.
daniel-wong-dfinity-org 88d9253
docstring
daniel-wong-dfinity-org 3fc1cae
more test
daniel-wong-dfinity-org e6eb70e
lint
daniel-wong-dfinity-org 54d8d29
lint again
daniel-wong-dfinity-org 9291d8d
Test CMC automatic refund.
daniel-wong-dfinity-org 0536eb2
Adjust test, depending on whether automatic refunds are enabled.
daniel-wong-dfinity-org 247e73e
lint
daniel-wong-dfinity-org ff02f49
Strengthing test by making many calls to the code under test. Unfortu…
daniel-wong-dfinity-org 3be81cc
lint
daniel-wong-dfinity-org d9dd565
lint
daniel-wong-dfinity-org 8a76367
minor comment change
daniel-wong-dfinity-org b6f0fb2
Do not set status of block to Processing if it is too old.
daniel-wong-dfinity-org 928da52
comment
daniel-wong-dfinity-org bc6492c
Trying and failing to replace send_ingress_safe with submit_ingress_as.
daniel-wong-dfinity-org d72841c
lint
daniel-wong-dfinity-org eb682c1
Revert "Trying and failing to replace send_ingress_safe with submit_i…
daniel-wong-dfinity-org File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ use icp_ledger::{ | |
use icrc_ledger_types::icrc1::account::Account; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub const IS_AUTOMATIC_REFUND_ENABLED: bool = false; | ||
|
||
pub const DEFAULT_CYCLES_PER_XDR: u128 = 1_000_000_000_000u128; // 1T cycles = 1 XDR | ||
|
||
pub const PERMYRIAD_DECIMAL_PLACES: u32 = 4; | ||
|
@@ -313,10 +315,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] = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why can't we use lazy_static to define these values in a hash map? Something like lazy_static! {
RESERVED_MEMOS: BTreeMap<String, Memo> = btreemap! {
"CREATE_CANISTER".to_string() => Memo(0x41455243),
// ...
};
} |
||
[MEMO_CREATE_CANISTER, MEMO_TOP_UP_CANISTER, MEMO_MINT_CYCLES]; | ||
|
||
pub fn create_canister_txn( | ||
amount: Tokens, | ||
from_subaccount: Option<Subaccount>, | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would it be bad, though?