Skip to content

Commit

Permalink
feat: add optional lamport amount to InputTokenDataWithContext
Browse files Browse the repository at this point in the history
  • Loading branch information
ananas-block committed Jun 25, 2024
1 parent 89fb84d commit 34f47d4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion programs/compressed-token/src/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ mod test {
let input_token_data_with_context = vec![
InputTokenDataWithContext {
amount: 100,

merkle_context: PackedMerkleContext {
merkle_tree_pubkey_index: 0,
nullifier_queue_pubkey_index: 1,
leaf_index: 1,
},
root_index: 0,
delegate_index: Some(1),
lamports: None,
},
InputTokenDataWithContext {
amount: 101,
Expand All @@ -288,6 +288,7 @@ mod test {
},
root_index: 0,
delegate_index: None,
lamports: None,
},
];
let inputs = CompressedTokenInstructionDataBurn {
Expand Down
4 changes: 4 additions & 0 deletions programs/compressed-token/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ mod test {
},
root_index: 0,
delegate_index: Some(1),
lamports: None,
},
InputTokenDataWithContext {
amount: 101,
Expand All @@ -436,6 +437,7 @@ mod test {
},
root_index: 0,
delegate_index: None,
lamports: None,
},
];
let inputs = CompressedTokenInstructionDataApprove {
Expand Down Expand Up @@ -522,6 +524,7 @@ mod test {
},
root_index: 0,
delegate_index: Some(1), // Doesn't matter it is not checked if the proof is not verified
lamports: None,
},
InputTokenDataWithContext {
amount: 101,
Expand All @@ -533,6 +536,7 @@ mod test {
},
root_index: 0,
delegate_index: Some(1), // Doesn't matter it is not checked if the proof is not verified
lamports: None,
},
];
let inputs = CompressedTokenInstructionDataRevoke {
Expand Down
2 changes: 2 additions & 0 deletions programs/compressed-token/src/freeze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ pub mod test_freeze {
},
root_index: 0,
delegate_index: None,
lamports: None,
},
InputTokenDataWithContext {
amount: 101,
Expand All @@ -364,6 +365,7 @@ pub mod test_freeze {
},
root_index: 0,
delegate_index: Some(2),
lamports: None,
},
];
// Freeze
Expand Down
4 changes: 3 additions & 1 deletion programs/compressed-token/src/process_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ pub struct InputTokenDataWithContext {
pub delegate_index: Option<u8>,
pub merkle_context: PackedMerkleContext,
pub root_index: u16,
pub lamports: Option<u64>,
}

#[derive(Debug, Clone, AnchorSerialize, AnchorDeserialize)]
Expand Down Expand Up @@ -485,7 +486,7 @@ pub fn get_input_compressed_accounts_with_merkle_context_and_check_signer<const
}
let compressed_account = CompressedAccount {
owner: crate::ID,
lamports: 0,
lamports: input_token_data.lamports.unwrap_or_default(),
data: None,
address: None,
};
Expand Down Expand Up @@ -810,6 +811,7 @@ pub mod transfer_sdk {
leaf_index: input_merkle_context[i].leaf_index,
},
root_index: root_indices[i],
lamports: None, // TODO: test
};
input_token_data_with_context.push(token_data_with_context);
}
Expand Down

0 comments on commit 34f47d4

Please sign in to comment.