Skip to content

Commit b2c26a5

Browse files
committed
add support for decimals f64 in vesting CLI.
1 parent 4671427 commit b2c26a5

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

Anchor.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ seeds = true
66
skip-lint = false
77

88
[programs.devnet]
9-
merkle_distributor = "32q88TuJFJuRLFZzZLmpVLEF5Hzcb8aoMsCpzPJPvtaB"
9+
merkle_distributor = "nHU2sptsUARgKih9UJnYLuAGgiUHA2wPyeu5vm8h3yW"
1010

1111
[registry]
1212
url = "https://api.apr.dev"

cli/readme.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cargo run -- --mint 4dzPmLDFSpuaCcTUoQjw71Bq8u8RWgHJQcLS63Y8ZrZp \
2+
--rpc-url https://api.devnet.solana.com \
3+
--keypair-path /Users/mykyta/development/composable/mantis-staking-program/solana/merkle-tree/test_fixtures/test.json \
4+
new-distributor \
5+
--clawback-receiver-token-account 5pT9ijgv2Qpxn4ux4u4crCCJhgAe4w7GoeaCPJKgP4NW \
6+
--start-vesting-ts 1738958910 \
7+
--end-vesting-ts 1739317492 \
8+
--merkle-tree-path /Users/mykyta/development/composable/mantis-staking-program/solana/merkle-tree/test_fixtures/test_csv.csv \
9+
--clawback-start-ts 1739458492
10+
11+
12+
13+
cargo run -- --mint 4dzPmLDFSpuaCcTUoQjw71Bq8u8RWgHJQcLS63Y8ZrZp \
14+
--rpc-url https://api.devnet.solana.com \
15+
--keypair-path /Users/mykyta/development/composable/mantis-staking-program/solana/merkle-tree/test_fixtures/test.json \
16+
claim \
17+
--merkle-tree-path /Users/mykyta/development/composable/mantis-staking-program/solana/merkle-tree/test_fixtures/test_csv.csv

merkle-tree/src/csv_entry.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ pub enum AirdropCategory {
1515
}
1616

1717
/// Represents a single entry in a CSV
18-
#[derive(Debug, Clone, Eq, Hash, PartialEq, Serialize, Deserialize)]
18+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1919
pub struct CsvEntry {
2020
/// Pubkey of the claimant; will be responsible for signing the claim
2121
pub pubkey: String,
2222
/// amount unlocked, (ui amount)
23-
pub amount_unlocked: u64,
23+
pub amount_unlocked: f64,
2424
/// amount locked, (ui amount)
25-
pub amount_locked: u64,
25+
pub amount_locked: f64,
2626
/// Category
2727
pub category: AirdropCategory,
2828
}
@@ -57,8 +57,8 @@ mod tests {
5757
entries[0].pubkey,
5858
"4SX6nqv5VRLMoNfYM5phvHgcBNcBEwUEES4qPPjf1EqS"
5959
);
60-
assert_eq!(entries[0].amount_unlocked, 1000);
61-
assert_eq!(entries[0].amount_locked, 500);
60+
assert_eq!(entries[0].amount_unlocked, 1000f64);
61+
assert_eq!(entries[0].amount_locked, 500f64);
6262
assert_eq!(entries[0].category, AirdropCategory::Staker);
6363
}
6464
}

merkle-tree/src/tree_node.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ impl TreeNode {
6464
}
6565

6666
/// Converts a ui amount to a token amount (with decimals)
67-
fn ui_amount_to_token_amount(amount: u64) -> u64 {
68-
amount * 10u64.checked_pow(MINT_DECIMALS).unwrap()
67+
fn ui_amount_to_token_amount(amount: f64) -> u64 {
68+
(amount * 10u64.checked_pow(MINT_DECIMALS).unwrap() as f64) as u64
6969
}
7070

7171
impl From<CsvEntry> for TreeNode {
@@ -125,7 +125,7 @@ mod tests {
125125

126126
#[test]
127127
fn test_ui_amount_to_token_amount() {
128-
let ui_amount = 5;
128+
let ui_amount = 5f64;
129129
let token_amount = ui_amount_to_token_amount(ui_amount);
130130
assert_eq!(token_amount, 5_000_000_000);
131131
}

programs/merkle-distributor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ security_txt! {
3030
source_code: "https://github.com/jito-foundation/distributor"
3131
}
3232

33-
declare_id!("32q88TuJFJuRLFZzZLmpVLEF5Hzcb8aoMsCpzPJPvtaB");
33+
declare_id!("nHU2sptsUARgKih9UJnYLuAGgiUHA2wPyeu5vm8h3yW");
3434

3535
#[program]
3636
pub mod merkle_distributor {

0 commit comments

Comments
 (0)