-
Notifications
You must be signed in to change notification settings - Fork 376
feat(ICRC-Ledger): DEFI-1687: implement ICRC-107 fee collector #8217
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
base: master
Are you sure you want to change the base?
Changes from all commits
1b98a38
71e4b6a
c07af35
5dda884
561005a
8973bab
76e35cb
816719f
48a948f
5237a5d
b4b2a1e
1a8f5cb
5ac5de8
b59a42d
df4cc15
cea1742
539ef8c
ee265bb
cf62736
9a2483b
a67b6e0
a24cfb7
172d1a3
ad12027
806f889
13feab0
5cb8a43
941d632
22653f7
93c51bc
ad712ba
584016b
4d110f0
dd51ea9
a814866
f59cd00
78260f3
2205cbc
cba734f
1fdb60d
ed3e054
094be1e
1e657df
3527a8d
f0a4054
cef36b7
d6f6ce8
844855f
c23f316
be773e0
6cc667a
db9e2a0
0cf1aaf
3100ac0
8c0b230
12d0312
85488e2
7718d43
28dead3
aa3ef36
627333c
5c896c2
30ae880
53f04f8
093924a
6acc722
304e2d5
9868c66
11d0cf6
52f9aa1
8134ea1
04c1528
92fe672
fc5919c
31695e3
97a8feb
21db7e5
40b6e74
398d290
70c92f4
8fd876a
a62d085
85ab3b8
fe7d54f
a50e892
8516089
c0e9cec
6e1a69f
f577ca9
d857983
c565e44
f0a2e19
53ea05f
0cf417f
d45af12
c5f7638
4de9ca2
81262b7
fa85ece
4767419
ce46106
fbc089e
7e3d456
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,10 @@ | |
| "rev": "2190613d3b5bcd9b74c382b22d151580b8ac271a", | ||
| "sha256": "25071c2c55ad4571293e00d8e277f442aec7aed88109743ac52df3125209ff45" | ||
| }, | ||
| "ck_btc_ledger_v5": { | ||
| "rev": "e446c64d99a97e38166be23ff2bfade997d15ff7", | ||
| "sha256": "71c27c5dc10034a1175296892b37827df0265d0ae072f5c59e99b8a1f6c45c76" | ||
| }, | ||
|
Comment on lines
30
to
33
Contributor
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. This points to ledger-suite-icrc-2025-04-14. Is there a particular reason for this specific version, or could we use ledger-suite-icrc-2025-10-27, which is the minimum version we point to from the currently most recent version ledger-suite-icrc-2026-02-02?
Contributor
Author
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. No reason, I just used the same version as current mainnet ledger :) Changed! |
||
| "ck_eth_archive": { | ||
| "rev": "512cf412f33d430b79f42330518166d14fc6884e", | ||
| "sha256": "3fafdd895c44886e38199882afcf06efb8e6e0b73af51eca327dcba4da7a0106" | ||
|
|
@@ -47,6 +51,10 @@ | |
| "rev": "2190613d3b5bcd9b74c382b22d151580b8ac271a", | ||
| "sha256": "9637743e1215a4db376a62ee807a0986faf20833be2b332df09b3d5dbdd7339e" | ||
| }, | ||
| "ck_eth_ledger_v5": { | ||
| "rev": "e446c64d99a97e38166be23ff2bfade997d15ff7", | ||
| "sha256": "15ec452faf00c40135b96a3ba0951ea13050e6e95e38cff249305462f81db62d" | ||
| }, | ||
| "cycles-minting": { | ||
| "rev": "6f1ce3bb4c253f1bc4c5f432c7c47b06dccdba7e", | ||
| "sha256": "40a204bf4abc14bd61553b2b56413709a2fc7175227253d2809ffdb977c934de" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| pub mod schema; | ||
| pub mod set_fee_collector; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| use candid::{CandidType, Deserialize, Nat}; | ||
| use serde::Serialize; | ||
|
|
||
| use super::super::icrc1::account::Account; | ||
|
|
||
| /// The arguments for the | ||
| /// [ICRC-107 `icrc107_set_fee_collector`](https://github.com/dfinity/ICRC/blob/main/ICRCs/ICRC-107/ICRC-107.md#icrc107_set_fee_collector) | ||
| /// endpoint. | ||
| #[derive(CandidType, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] | ||
| pub struct SetFeeCollectorArgs { | ||
| #[serde(default)] | ||
| pub fee_collector: Option<Account>, | ||
| pub created_at_time: u64, | ||
| } | ||
|
|
||
| /// The error return type for the | ||
| /// [ICRC-107 `icrc107_set_fee_collector`](https://github.com/dfinity/ICRC/blob/main/ICRCs/ICRC-107/ICRC-107.md#icrc107_set_fee_collector) | ||
| /// endpoint. | ||
| #[derive(CandidType, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] | ||
| pub enum SetFeeCollectorError { | ||
| AccessDenied(String), | ||
| InvalidAccount(String), | ||
| Duplicate { duplicate_of: Nat }, | ||
| GenericError { error_code: Nat, message: String }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -848,7 +848,7 @@ mod withdraw_erc20 { | |
| .assert_has_unique_events_in_order(&[EventPayload::ReimbursedErc20Withdrawal { | ||
| withdrawal_id: cketh_block_index.clone(), | ||
| burn_in_block: ckerc20_block_index.clone(), | ||
| reimbursed_in_block: Nat::from(3_u8), | ||
| reimbursed_in_block: Nat::from(4_u8), | ||
|
Contributor
Author
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. If the ICRC ledger is installed with a 107 fee collector, the first block is the fee collector setting block and therefore all block indexes that are tested need to be increased by 1. |
||
| ledger_id: deposit_params.token().ledger_canister_id, | ||
| reimbursed_amount: ckerc20_withdrawal_amount.into(), | ||
| transaction_hash: Some( | ||
|
|
@@ -857,7 +857,7 @@ mod withdraw_erc20 { | |
| }]) | ||
| .call_ckerc20_ledger_get_transaction( | ||
| deposit_params.token().ledger_canister_id, | ||
| 3_u8, | ||
| 4_u8, | ||
| ) | ||
| .expect_mint(Mint { | ||
| amount: ckerc20_withdrawal_amount.into(), | ||
|
|
@@ -1346,7 +1346,7 @@ fn should_deposit_ckerc20() { | |
| ckerc20 | ||
| .deposit(params.clone()) | ||
| .expect_mint() | ||
| .call_ckerc20_ledger_get_transaction(params.token().ledger_canister_id, 0_u8) | ||
| .call_ckerc20_ledger_get_transaction(params.token().ledger_canister_id, 1_u8) | ||
| .expect_mint(Mint { | ||
| amount: Nat::from(params.ckerc20_amount()), | ||
| to: params.recipient(), | ||
|
|
@@ -1452,7 +1452,7 @@ fn should_deposit_cketh_and_ckerc20() { | |
| created_at_time: None, | ||
| fee: None, | ||
| }) | ||
| .call_ckerc20_ledger_get_transaction(params.token().ledger_canister_id, 0_u8) | ||
| .call_ckerc20_ledger_get_transaction(params.token().ledger_canister_id, 1_u8) | ||
| .expect_mint(Mint { | ||
| amount: Nat::from(params.ckerc20_amount()), | ||
| to: params.recipient(), | ||
|
|
@@ -1548,7 +1548,7 @@ fn should_deposit_cketh_and_ckerc20_when_ledger_temporary_offline() { | |
| }, | ||
| ckerc20_token_symbol: ckusdc.ckerc20_token_symbol, | ||
| erc20_contract_address: ckusdc.erc20_contract_address, | ||
| mint_block_index: Nat::from(0_u8), | ||
| mint_block_index: Nat::from(1_u8), | ||
| }, | ||
| ]); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,6 @@ fn example_block() -> Block { | |
| transaction, | ||
| TimeStamp::new(1, 1), | ||
| DEFAULT_TRANSFER_FEE, | ||
| None, | ||
| ) | ||
| } | ||
|
|
||
|
|
||
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.
Would it make sense to rename this to something more descriptive, and/or perhaps add a comment somewhere (I think comments don't work in
mainnet-canister-revisions.json, but here would be ok?)? Especially since thev5doesn't correspond to theLEDGER_VERSION, so it can be confusing.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.
Good point! Maybe we could change it to correspond to the ledger versions, i.e.:
v1 -> no_mem_mgr
v3 -> v1
v5 -> v3
WDYT?