Skip to content

Commit 643c4a8

Browse files
committed
implement feedback
1 parent 9a52b8f commit 643c4a8

File tree

8 files changed

+18
-11
lines changed

8 files changed

+18
-11
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ account-compression = { path = "programs/account-compression", version = "2.0.0"
185185
light-compressed-token = { path = "programs/compressed-token/program", version = "2.0.0", features = [
186186
"cpi",
187187
] }
188-
light-compressed-token-types = { path = "sdk-libs/compressed-token-types" }
189-
light-compressed-token-sdk = { path = "sdk-libs/compressed-token-sdk" }
190-
light-token-client = { path = "sdk-libs/token-client" }
188+
light-compressed-token-types = { path = "sdk-libs/compressed-token-types", version = "0.1.0" }
189+
light-compressed-token-sdk = { path = "sdk-libs/compressed-token-sdk", version = "0.1.0" }
190+
light-token-client = { path = "sdk-libs/token-client", version = "0.1.0" }
191191
light-system-program-anchor = { path = "anchor-programs/system", version = "2.0.0", features = [
192192
"cpi",
193193
] }

program-libs/ctoken-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "light-ctoken-types"
3-
version = { workspace = true }
3+
version = "0.1.0"
44
edition = { workspace = true }
55

66
[features]

program-libs/ctoken-types/tests/token_data.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ fn equivalency_of_hash_functions() {
5252
fn legacy_hash(token_data: &TokenData) -> std::result::Result<[u8; 32], HasherError> {
5353
let hashed_mint = hash_to_bn254_field_size_be(token_data.mint.to_bytes().as_slice());
5454
let hashed_owner = hash_to_bn254_field_size_be(token_data.owner.to_bytes().as_slice());
55-
let amount_bytes = token_data.amount.to_le_bytes();
55+
let mut amount_bytes = [0u8; 32];
56+
amount_bytes[24..].copy_from_slice(token_data.amount.to_le_bytes().as_slice());
5657
let hashed_delegate;
5758
let hashed_delegate_option = if let Some(delegate) = token_data.delegate {
5859
hashed_delegate = hash_to_bn254_field_size_be(delegate.to_bytes().as_slice());

programs/compressed-token/anchor/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ pub enum ErrorCode {
379379
Transfer2InvalidChangeAccountData,
380380
#[msg("Cpi context expected but not provided.")]
381381
CpiContextExpected,
382+
#[msg("CPI accounts slice exceeds provided account infos")]
383+
CpiAccountsSliceOutOfBounds,
382384
}
383385

384386
impl From<ErrorCode> for ProgramError {

programs/compressed-token/program/src/mint_action/accounts.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,15 @@ impl<'info> MintActionAccounts<'info> {
274274
&self,
275275
deduplicated: bool,
276276
account_infos: &'a [AccountInfo],
277-
) -> &'a [AccountInfo] {
277+
) -> Result<&'a [AccountInfo], ProgramError> {
278278
let start_offset = self.cpi_accounts_start_offset();
279279
let end_offset = self.cpi_accounts_end_offset(deduplicated);
280-
// TODO: validate len.
281-
&account_infos[start_offset..end_offset]
280+
281+
if end_offset > account_infos.len() {
282+
return Err(ErrorCode::CpiAccountsSliceOutOfBounds.into());
283+
}
284+
285+
Ok(&account_infos[start_offset..end_offset])
282286
}
283287
}
284288

programs/compressed-token/program/src/mint_action/processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub fn process_mint_action(
157157

158158
sol_log_compute_units();
159159

160-
let cpi_accounts = validated_accounts.get_cpi_accounts(queue_indices.deduplicated, accounts);
160+
let cpi_accounts = validated_accounts.get_cpi_accounts(queue_indices.deduplicated, accounts)?;
161161
if let Some(executing) = validated_accounts.executing.as_ref() {
162162
// Execute CPI to light-system-program
163163
execute_cpi_invoke(

sdk-libs/compressed-token-sdk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "light-compressed-token-sdk"
3-
version = { workspace = true }
3+
version = "0.1.0"
44
edition = { workspace = true }
55

66
[features]

sdk-libs/token-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "light-token-client"
3-
version = { workspace = true }
3+
version = "0.1.0"
44
edition = { workspace = true }
55

66
[features]

0 commit comments

Comments
 (0)