diff --git a/clients/rust/asset/src/impls.rs b/clients/rust/asset/src/impls.rs index 07e5659..fbf953c 100644 --- a/clients/rust/asset/src/impls.rs +++ b/clients/rust/asset/src/impls.rs @@ -159,6 +159,7 @@ macro_rules! allocate_update_data_length { macro_rules! allocate_and_write { ( $program:expr, $asset:expr, $payer:expr, $system_program:expr, $extension_type:expr, $data:expr, $signers_seeds:expr ) => {{ const CPI_LIMIT: usize = 1280; + const ACCOUNT_METAS_SIZE: usize = 102; // 3 X (32 bytes for pubkey + 1 byte for is_signer + 1 byte for is_writable) let total_data_len = $data.len(); // (1) discriminator // (1) extension type @@ -167,7 +168,7 @@ macro_rules! allocate_and_write { // (4) data length // total = 11 const ALLOCATE_HEADER: usize = 11; - let data_len = std::cmp::min(total_data_len, CPI_LIMIT - ALLOCATE_HEADER); + let data_len = std::cmp::min(total_data_len, CPI_LIMIT - ALLOCATE_HEADER - ACCOUNT_METAS_SIZE); let accounts = vec![ solana_program::instruction::AccountMeta::new(*$asset.key, true), @@ -207,7 +208,7 @@ macro_rules! allocate_and_write { // (1) overwrite // total = 2 const WRITE_HEADER: usize = 2; - let data_len = std::cmp::min(total_data_len - offset, CPI_LIMIT - WRITE_HEADER); + let data_len = std::cmp::min(total_data_len - offset, CPI_LIMIT - WRITE_HEADER - ACCOUNT_METAS_SIZE); instruction.data.push(12); // write discriminator instruction.data.push(0); // overwrite (false)