From f5702cfe28f5e57c477ae459a58509e4a4cb1386 Mon Sep 17 00:00:00 2001 From: Jon Cinque Date: Tue, 24 Oct 2023 11:11:36 +0200 Subject: [PATCH 001/154] transfer-hook: Move interface and example into subfolders (#5640) --- interface/Cargo.toml | 24 ++ interface/README.md | 149 +++++++ interface/src/error.rs | 20 + interface/src/instruction.rs | 243 ++++++++++++ interface/src/lib.rs | 52 +++ interface/src/offchain.rs | 70 ++++ interface/src/onchain.rs | 93 +++++ program/Cargo.toml | 30 ++ program/README.md | 66 +++ program/src/entrypoint.rs | 24 ++ program/src/lib.rs | 18 + program/src/processor.rs | 151 +++++++ program/src/state.rs | 15 + program/tests/functional.rs | 749 +++++++++++++++++++++++++++++++++++ 14 files changed, 1704 insertions(+) create mode 100644 interface/Cargo.toml create mode 100644 interface/README.md create mode 100644 interface/src/error.rs create mode 100644 interface/src/instruction.rs create mode 100644 interface/src/lib.rs create mode 100644 interface/src/offchain.rs create mode 100644 interface/src/onchain.rs create mode 100644 program/Cargo.toml create mode 100644 program/README.md create mode 100644 program/src/entrypoint.rs create mode 100644 program/src/lib.rs create mode 100644 program/src/processor.rs create mode 100644 program/src/state.rs create mode 100644 program/tests/functional.rs diff --git a/interface/Cargo.toml b/interface/Cargo.toml new file mode 100644 index 0000000..79644bc --- /dev/null +++ b/interface/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "spl-transfer-hook-interface" +version = "0.3.0" +description = "Solana Program Library Transfer Hook Interface" +authors = ["Solana Labs Maintainers "] +repository = "https://github.com/solana-labs/solana-program-library" +license = "Apache-2.0" +edition = "2021" + +[dependencies] +arrayref = "0.3.7" +bytemuck = { version = "1.14.0", features = ["derive"] } +solana-program = "1.17.2" +spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } +spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } +spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } +spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } +spl-pod = { version = "0.1", path = "../../../libraries/pod" } + +[lib] +crate-type = ["cdylib", "lib"] + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/interface/README.md b/interface/README.md new file mode 100644 index 0000000..84dab20 --- /dev/null +++ b/interface/README.md @@ -0,0 +1,149 @@ +## Transfer-Hook Interface + +### Example program + +Here is an example program that only implements the required "execute" instruction, +assuming that the proper account data is already written to the appropriate +program-derived address defined by the interface. + +```rust +use { + solana_program::{entrypoint::ProgramResult, program_error::ProgramError}, + spl_tlv_account_resolution::state::ExtraAccountMetaList, + spl_transfer_hook_interface::instruction::{ExecuteInstruction, TransferHookInstruction}, + spl_type_length_value::state::TlvStateBorrowed, +}; +pub fn process_instruction( + program_id: &Pubkey, + accounts: &[AccountInfo], + input: &[u8], +) -> ProgramResult { + let instruction = TransferHookInstruction::unpack(input)?; + let _amount = match instruction { + TransferHookInstruction::Execute { amount } => amount, + _ => return Err(ProgramError::InvalidInstructionData), + }; + let account_info_iter = &mut accounts.iter(); + + // Pull out the accounts in order, none are validated in this test program + let _source_account_info = next_account_info(account_info_iter)?; + let mint_info = next_account_info(account_info_iter)?; + let _destination_account_info = next_account_info(account_info_iter)?; + let _authority_info = next_account_info(account_info_iter)?; + let extra_account_metas_info = next_account_info(account_info_iter)?; + + // Only check that the correct pda and account are provided + let expected_validation_address = get_extra_account_metas_address(mint_info.key, program_id); + if expected_validation_address != *extra_account_metas_info.key { + return Err(ProgramError::InvalidSeeds); + } + + // Load the extra required accounts from the validation account + let data = extra_account_metas_info.try_borrow_data()?; + + // Check the provided accounts against the validation data + ExtraAccountMetaList::check_account_infos::( + accounts, + &TransferHookInstruction::Execute { amount }.pack(), + program_id, + &data, + )?; + + Ok(()) +} +``` + +### Motivation + +Token creators may need more control over how their token is transferred. The +most prominent use case revolves around NFT royalties. Whenever a token is moved, +the creator should be entitled to royalties, but due to the design of the current +token program, it's impossible to stop a transfer at the protocol level. + +Current solutions typically resort to perpetually freezing tokens, which requires +a whole proxy layer to interact with the token. Wallets and marketplaces need +to be aware of the proxy layer in order to properly use the token. + +Worse still, different royalty systems have different proxy layers for using +their token. All in all, these systems harm composability and make development +harder. + +### Solution + +To improve the situation, Token-2022 introduces the concept of the transfer-hook +interface and extension. A token creator must develop and deploy a program that +implements the interface and then configure their token mint to use their program. + +During transfer, Token-2022 calls into the program with the accounts specified +at a well-defined program-derived address for that mint and program id. This +call happens after all other transfer logic, so the accounts reflect the *end* +state of the transfer. + +### How to Use + +Developers must implement the `Execute` instruction, and optionally the +`InitializeExtraAccountMetaList` instruction to write the required additional account +pubkeys into the program-derived address defined by the mint and program id. + +Note: it's technically not required to implement `InitializeExtraAccountMetaList` +at that instruction descriminator. Your program may implement multiple interfaces, +so any other instruction in your program can create the account at the program-derived +address! + +When your program stores configurations for extra required accounts in the +well-defined program-derived address, it's possible to send an instruction - +such as `Execute` (transfer) - to your program with only accounts required +for the interface instruction, and all extra required accounts are +automatically resolved! + +### Account Resolution + +Implementers of the transfer-hook interface are encouraged to make use of the +[spl-tlv-account-resolution](https://github.com/solana-labs/solana-program-library/tree/master/libraries/tlv-account-resolution/README.md) +library to manage the additional required accounts for their transfer hook +program. + +TLV Account Resolution is capable of powering on-chain account resolution +when an instruction that requires extra accounts is invoked. +Read more about how account resolution works in the repository's +[README file](https://github.com/solana-labs/solana-program-library/tree/master/libraries/tlv-account-resolution/README.md). + +### An Example + +You have created a DAO to govern a community. Your DAO's authority is a +multisig account, and you want to ensure that any transfer of your token is +approved by the DAO. You also want to make sure that someone who intends to +transfer your token has the proper permissions to do so. + +Let's assume the DAO multisig has some **fixed address**. And let's assume that +in order to have the `can_transfer` permission, a user must have this +**dynamic program-derived address** associated with their wallet via the +following seeds: `"can_transfer" + `. + +Using the transfer-hook interface, you can store these configurations in the +well-defined program-derived address for your mint and program id. + +When a user attempts to transfer your token, they might provide to Token-2022: + +```rust +[source, mint, destination, owner/delegate] +``` + +Token-2022 will then call into your program, +**resolving the extra required accounts automatically** from your stored +configurations, to result in the following accounts being provided to your +program: + +```rust +[source, mint, destination, owner/delegate, dao_authority, can_transfer_pda] +``` + +### Utilities + +The `spl-transfer-hook-interface` library provides offchain and onchain helpers +for resolving the additional accounts required. See +[invoke.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface/src/invoke.rs) +for usage on-chain, and +[offchain.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface/src/offchain.rs) +for fetching the additional required account metas with any async off-chain client +like `BanksClient` or `RpcClient`. diff --git a/interface/src/error.rs b/interface/src/error.rs new file mode 100644 index 0000000..aaf25e1 --- /dev/null +++ b/interface/src/error.rs @@ -0,0 +1,20 @@ +//! Error types + +use spl_program_error::*; + +/// Errors that may be returned by the interface. +#[spl_program_error(hash_error_code_start = 2_110_272_652)] +pub enum TransferHookError { + /// Incorrect account provided + #[error("Incorrect account provided")] + IncorrectAccount, + /// Mint has no mint authority + #[error("Mint has no mint authority")] + MintHasNoMintAuthority, + /// Incorrect mint authority has signed the instruction + #[error("Incorrect mint authority has signed the instruction")] + IncorrectMintAuthority, + /// Program called outside of a token transfer + #[error("Program called outside of a token transfer")] + ProgramCalledOutsideOfTransfer, +} diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs new file mode 100644 index 0000000..a1fdcfe --- /dev/null +++ b/interface/src/instruction.rs @@ -0,0 +1,243 @@ +//! Instruction types + +use { + solana_program::{ + instruction::{AccountMeta, Instruction}, + program_error::ProgramError, + pubkey::Pubkey, + system_program, + }, + spl_discriminator::{ArrayDiscriminator, SplDiscriminate}, + spl_pod::{bytemuck::pod_slice_to_bytes, slice::PodSlice}, + spl_tlv_account_resolution::account::ExtraAccountMeta, + std::convert::TryInto, +}; + +/// Instructions supported by the transfer hook interface. +#[repr(C)] +#[derive(Clone, Debug, PartialEq)] +pub enum TransferHookInstruction { + /// Runs additional transfer logic. + /// + /// Accounts expected by this instruction: + /// + /// 0. `[]` Source account + /// 1. `[]` Token mint + /// 2. `[]` Destination account + /// 3. `[]` Source account's owner/delegate + /// 4. `[]` Validation account + /// 5..5+M `[]` `M` additional accounts, written in validation account data + /// + Execute { + /// Amount of tokens to transfer + amount: u64, + }, + /// Initializes the extra account metas on an account, writing into + /// the first open TLV space. + /// + /// Accounts expected by this instruction: + /// + /// 0. `[w]` Account with extra account metas + /// 1. `[]` Mint + /// 2. `[s]` Mint authority + /// 3. `[]` System program + /// + InitializeExtraAccountMetaList { + /// List of `ExtraAccountMeta`s to write into the account + extra_account_metas: Vec, + }, +} +/// TLV instruction type only used to define the discriminator. The actual data +/// is entirely managed by `ExtraAccountMetaList`, and it is the only data contained +/// by this type. +#[derive(SplDiscriminate)] +#[discriminator_hash_input("spl-transfer-hook-interface:execute")] +pub struct ExecuteInstruction; + +/// TLV instruction type used to initialize extra account metas +/// for the transfer hook +#[derive(SplDiscriminate)] +#[discriminator_hash_input("spl-transfer-hook-interface:initialize-extra-account-metas")] +pub struct InitializeExtraAccountMetaListInstruction; + +impl TransferHookInstruction { + /// Unpacks a byte buffer into a [TransferHookInstruction](enum.TransferHookInstruction.html). + pub fn unpack(input: &[u8]) -> Result { + if input.len() < ArrayDiscriminator::LENGTH { + return Err(ProgramError::InvalidInstructionData); + } + let (discriminator, rest) = input.split_at(ArrayDiscriminator::LENGTH); + Ok(match discriminator { + ExecuteInstruction::SPL_DISCRIMINATOR_SLICE => { + let amount = rest + .get(..8) + .and_then(|slice| slice.try_into().ok()) + .map(u64::from_le_bytes) + .ok_or(ProgramError::InvalidInstructionData)?; + Self::Execute { amount } + } + InitializeExtraAccountMetaListInstruction::SPL_DISCRIMINATOR_SLICE => { + let pod_slice = PodSlice::::unpack(rest)?; + let extra_account_metas = pod_slice.data().to_vec(); + Self::InitializeExtraAccountMetaList { + extra_account_metas, + } + } + _ => return Err(ProgramError::InvalidInstructionData), + }) + } + + /// Packs a [TokenInstruction](enum.TokenInstruction.html) into a byte buffer. + pub fn pack(&self) -> Vec { + let mut buf = vec![]; + match self { + Self::Execute { amount } => { + buf.extend_from_slice(ExecuteInstruction::SPL_DISCRIMINATOR_SLICE); + buf.extend_from_slice(&amount.to_le_bytes()); + } + Self::InitializeExtraAccountMetaList { + extra_account_metas, + } => { + buf.extend_from_slice( + InitializeExtraAccountMetaListInstruction::SPL_DISCRIMINATOR_SLICE, + ); + buf.extend_from_slice(&(extra_account_metas.len() as u32).to_le_bytes()); + buf.extend_from_slice(pod_slice_to_bytes(extra_account_metas)); + } + }; + buf + } +} + +/// Creates an `Execute` instruction, provided all of the additional required +/// account metas +#[allow(clippy::too_many_arguments)] +pub fn execute_with_extra_account_metas( + program_id: &Pubkey, + source_pubkey: &Pubkey, + mint_pubkey: &Pubkey, + destination_pubkey: &Pubkey, + authority_pubkey: &Pubkey, + validate_state_pubkey: &Pubkey, + additional_accounts: &[AccountMeta], + amount: u64, +) -> Instruction { + let mut instruction = execute( + program_id, + source_pubkey, + mint_pubkey, + destination_pubkey, + authority_pubkey, + validate_state_pubkey, + amount, + ); + instruction.accounts.extend_from_slice(additional_accounts); + instruction +} + +/// Creates an `Execute` instruction, without the additional accounts +#[allow(clippy::too_many_arguments)] +pub fn execute( + program_id: &Pubkey, + source_pubkey: &Pubkey, + mint_pubkey: &Pubkey, + destination_pubkey: &Pubkey, + authority_pubkey: &Pubkey, + validate_state_pubkey: &Pubkey, + amount: u64, +) -> Instruction { + let data = TransferHookInstruction::Execute { amount }.pack(); + let accounts = vec![ + AccountMeta::new_readonly(*source_pubkey, false), + AccountMeta::new_readonly(*mint_pubkey, false), + AccountMeta::new_readonly(*destination_pubkey, false), + AccountMeta::new_readonly(*authority_pubkey, false), + AccountMeta::new_readonly(*validate_state_pubkey, false), + ]; + Instruction { + program_id: *program_id, + accounts, + data, + } +} + +/// Creates a `InitializeExtraAccountMetaList` instruction. +pub fn initialize_extra_account_meta_list( + program_id: &Pubkey, + extra_account_metas_pubkey: &Pubkey, + mint_pubkey: &Pubkey, + authority_pubkey: &Pubkey, + extra_account_metas: &[ExtraAccountMeta], +) -> Instruction { + let data = TransferHookInstruction::InitializeExtraAccountMetaList { + extra_account_metas: extra_account_metas.to_vec(), + } + .pack(); + + let accounts = vec![ + AccountMeta::new(*extra_account_metas_pubkey, false), + AccountMeta::new_readonly(*mint_pubkey, false), + AccountMeta::new_readonly(*authority_pubkey, true), + AccountMeta::new_readonly(system_program::id(), false), + ]; + + Instruction { + program_id: *program_id, + accounts, + data, + } +} + +#[cfg(test)] +mod test { + use {super::*, crate::NAMESPACE, solana_program::hash, spl_pod::bytemuck::pod_from_bytes}; + + #[test] + fn validate_packing() { + let amount = 111_111_111; + let check = TransferHookInstruction::Execute { amount }; + let packed = check.pack(); + // Please use ExecuteInstruction::SPL_DISCRIMINATOR in your program, the + // following is just for test purposes + let preimage = hash::hashv(&[format!("{NAMESPACE}:execute").as_bytes()]); + let discriminator = &preimage.as_ref()[..ArrayDiscriminator::LENGTH]; + let mut expect = vec![]; + expect.extend_from_slice(discriminator.as_ref()); + expect.extend_from_slice(&amount.to_le_bytes()); + assert_eq!(packed, expect); + let unpacked = TransferHookInstruction::unpack(&expect).unwrap(); + assert_eq!(unpacked, check); + } + + #[test] + fn initialize_validation_pubkeys_packing() { + let extra_meta_len_bytes = &[ + 1, 0, 0, 0, // `1u32` + ]; + let extra_meta_bytes = &[ + 0, // `AccountMeta` + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, // pubkey + 0, // is_signer + 0, // is_writable + ]; + let extra_account_metas = + vec![*pod_from_bytes::(extra_meta_bytes).unwrap()]; + let check = TransferHookInstruction::InitializeExtraAccountMetaList { + extra_account_metas, + }; + let packed = check.pack(); + // Please use INITIALIZE_EXTRA_ACCOUNT_METAS_DISCRIMINATOR in your program, + // the following is just for test purposes + let preimage = + hash::hashv(&[format!("{NAMESPACE}:initialize-extra-account-metas").as_bytes()]); + let discriminator = &preimage.as_ref()[..ArrayDiscriminator::LENGTH]; + let mut expect = vec![]; + expect.extend_from_slice(discriminator.as_ref()); + expect.extend_from_slice(extra_meta_len_bytes); + expect.extend_from_slice(extra_meta_bytes); + assert_eq!(packed, expect); + let unpacked = TransferHookInstruction::unpack(&expect).unwrap(); + assert_eq!(unpacked, check); + } +} diff --git a/interface/src/lib.rs b/interface/src/lib.rs new file mode 100644 index 0000000..20af3ab --- /dev/null +++ b/interface/src/lib.rs @@ -0,0 +1,52 @@ +//! Crate defining an interface for performing a hook on transfer, where the +//! token program calls into a separate program with additional accounts after +//! all other logic, to be sure that a transfer has accomplished all required +//! preconditions. + +#![allow(clippy::arithmetic_side_effects)] +#![deny(missing_docs)] +#![cfg_attr(not(test), forbid(unsafe_code))] + +pub mod error; +pub mod instruction; +pub mod offchain; +pub mod onchain; + +// Export current sdk types for downstream users building with a different sdk version +pub use solana_program; +use solana_program::pubkey::Pubkey; + +/// Namespace for all programs implementing transfer-hook +pub const NAMESPACE: &str = "spl-transfer-hook-interface"; + +/// Seed for the state +const EXTRA_ACCOUNT_METAS_SEED: &[u8] = b"extra-account-metas"; + +/// Get the state address PDA +pub fn get_extra_account_metas_address(mint: &Pubkey, program_id: &Pubkey) -> Pubkey { + get_extra_account_metas_address_and_bump_seed(mint, program_id).0 +} + +/// Function used by programs implementing the interface, when creating the PDA, +/// to also get the bump seed +pub fn get_extra_account_metas_address_and_bump_seed( + mint: &Pubkey, + program_id: &Pubkey, +) -> (Pubkey, u8) { + Pubkey::find_program_address(&collect_extra_account_metas_seeds(mint), program_id) +} + +/// Function used by programs implementing the interface, when creating the PDA, +/// to get all of the PDA seeds +pub fn collect_extra_account_metas_seeds(mint: &Pubkey) -> [&[u8]; 2] { + [EXTRA_ACCOUNT_METAS_SEED, mint.as_ref()] +} + +/// Function used by programs implementing the interface, when creating the PDA, +/// to sign for the PDA +pub fn collect_extra_account_metas_signer_seeds<'a>( + mint: &'a Pubkey, + bump_seed: &'a [u8], +) -> [&'a [u8]; 3] { + [EXTRA_ACCOUNT_METAS_SEED, mint.as_ref(), bump_seed] +} diff --git a/interface/src/offchain.rs b/interface/src/offchain.rs new file mode 100644 index 0000000..60b7ea5 --- /dev/null +++ b/interface/src/offchain.rs @@ -0,0 +1,70 @@ +//! Offchain helper for fetching required accounts to build instructions + +pub use spl_tlv_account_resolution::state::{AccountDataResult, AccountFetchError}; +use { + crate::{get_extra_account_metas_address, instruction::ExecuteInstruction}, + solana_program::{ + instruction::{AccountMeta, Instruction}, + program_error::ProgramError, + pubkey::Pubkey, + }, + spl_tlv_account_resolution::state::ExtraAccountMetaList, + std::future::Future, +}; + +/// Offchain helper to get all additional required account metas for a mint +/// +/// To be client-agnostic and to avoid pulling in the full solana-sdk, this +/// simply takes a function that will return its data as `Future>` for +/// the given address. Can be called in the following way: +/// +/// ```rust,ignore +/// use futures_util::TryFutureExt; +/// use solana_client::nonblocking::rpc_client::RpcClient; +/// use solana_program::pubkey::Pubkey; +/// +/// let program_id = Pubkey::new_unique(); +/// let mint = Pubkey::new_unique(); +/// let client = RpcClient::new_mock("succeeds".to_string()); +/// let mut account_metas = vec![]; +/// +/// get_extra_account_metas( +/// &mut account_metas, +/// |address| self.client.get_account(&address).map_ok(|opt| opt.map(|acc| acc.data)), +/// &mint, +/// &program_id, +/// ).await?; +/// ``` +pub async fn resolve_extra_account_metas( + instruction: &mut Instruction, + fetch_account_data_fn: F, + mint: &Pubkey, + permissioned_transfer_program_id: &Pubkey, +) -> Result<(), AccountFetchError> +where + F: Fn(Pubkey) -> Fut, + Fut: Future, +{ + let validation_address = + get_extra_account_metas_address(mint, permissioned_transfer_program_id); + let validation_account_data = fetch_account_data_fn(validation_address) + .await? + .ok_or(ProgramError::InvalidAccountData)?; + ExtraAccountMetaList::add_to_instruction::( + instruction, + fetch_account_data_fn, + &validation_account_data, + ) + .await?; + // The onchain helpers pull out the required accounts from an opaque + // slice by pubkey, so the order doesn't matter here! + instruction.accounts.push(AccountMeta::new_readonly( + *permissioned_transfer_program_id, + false, + )); + instruction + .accounts + .push(AccountMeta::new_readonly(validation_address, false)); + + Ok(()) +} diff --git a/interface/src/onchain.rs b/interface/src/onchain.rs new file mode 100644 index 0000000..1c0e0fb --- /dev/null +++ b/interface/src/onchain.rs @@ -0,0 +1,93 @@ +//! On-chain program invoke helper to perform on-chain `execute` with correct accounts + +use { + crate::{error::TransferHookError, get_extra_account_metas_address, instruction}, + solana_program::{ + account_info::AccountInfo, + entrypoint::ProgramResult, + instruction::{AccountMeta, Instruction}, + program::invoke, + pubkey::Pubkey, + }, + spl_tlv_account_resolution::state::ExtraAccountMetaList, +}; +/// Helper to CPI into a transfer-hook program on-chain, looking through the +/// additional account infos to create the proper instruction +pub fn invoke_execute<'a>( + program_id: &Pubkey, + source_info: AccountInfo<'a>, + mint_info: AccountInfo<'a>, + destination_info: AccountInfo<'a>, + authority_info: AccountInfo<'a>, + additional_accounts: &[AccountInfo<'a>], + amount: u64, +) -> ProgramResult { + let validation_pubkey = get_extra_account_metas_address(mint_info.key, program_id); + let validation_info = additional_accounts + .iter() + .find(|&x| *x.key == validation_pubkey) + .ok_or(TransferHookError::IncorrectAccount)?; + let mut cpi_instruction = instruction::execute( + program_id, + source_info.key, + mint_info.key, + destination_info.key, + authority_info.key, + &validation_pubkey, + amount, + ); + + let mut cpi_account_infos = vec![ + source_info, + mint_info, + destination_info, + authority_info, + validation_info.clone(), + ]; + ExtraAccountMetaList::add_to_cpi_instruction::( + &mut cpi_instruction, + &mut cpi_account_infos, + &validation_info.try_borrow_data()?, + additional_accounts, + )?; + invoke(&cpi_instruction, &cpi_account_infos) +} + +/// Helper to add accounts required for the transfer-hook program on-chain, looking +/// through the additional account infos to add the proper accounts +pub fn add_cpi_accounts_for_execute<'a>( + cpi_instruction: &mut Instruction, + cpi_account_infos: &mut Vec>, + mint_pubkey: &Pubkey, + program_id: &Pubkey, + additional_accounts: &[AccountInfo<'a>], +) -> ProgramResult { + let validation_pubkey = get_extra_account_metas_address(mint_pubkey, program_id); + let validation_info = additional_accounts + .iter() + .find(|&x| *x.key == validation_pubkey) + .ok_or(TransferHookError::IncorrectAccount)?; + + let program_info = additional_accounts + .iter() + .find(|&x| x.key == program_id) + .ok_or(TransferHookError::IncorrectAccount)?; + + ExtraAccountMetaList::add_to_cpi_instruction::( + cpi_instruction, + cpi_account_infos, + &validation_info.try_borrow_data()?, + additional_accounts, + )?; + // The onchain helpers pull out the required accounts from an opaque + // slice by pubkey, so the order doesn't matter here! + cpi_account_infos.push(validation_info.clone()); + cpi_account_infos.push(program_info.clone()); + cpi_instruction + .accounts + .push(AccountMeta::new_readonly(validation_pubkey, false)); + cpi_instruction + .accounts + .push(AccountMeta::new_readonly(*program_id, false)); + Ok(()) +} diff --git a/program/Cargo.toml b/program/Cargo.toml new file mode 100644 index 0000000..b8a4821 --- /dev/null +++ b/program/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "spl-transfer-hook-example" +version = "0.3.0" +description = "Solana Program Library Transfer Hook Example Program" +authors = ["Solana Labs Maintainers "] +repository = "https://github.com/solana-labs/solana-program-library" +license = "Apache-2.0" +edition = "2021" + +[features] +no-entrypoint = [] +test-sbf = [] + +[dependencies] +arrayref = "0.3.7" +solana-program = "1.17.2" +spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } +spl-token-2022 = { version = "0.9", path = "../../program-2022", features = ["no-entrypoint"] } +spl-transfer-hook-interface = { version = "0.3" , path = "../interface" } +spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } + +[dev-dependencies] +solana-program-test = "1.17.2" +solana-sdk = "1.17.2" + +[lib] +crate-type = ["cdylib", "lib"] + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/program/README.md b/program/README.md new file mode 100644 index 0000000..f3d2aef --- /dev/null +++ b/program/README.md @@ -0,0 +1,66 @@ +## Transfer-Hook Example + +Full example program and tests implementing the `spl-transfer-hook-interface`, +to be used for testing a program that calls into the `spl-transfer-hook-interface`. + +See the +[SPL Transfer Hook Interface](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface) +code for more information. + +### Example usage of example + +When testing your program that uses `spl-transfer-hook-interface`, you can also +import this crate, and then use it with `solana-program-test`, ie: + +```rust +use { + solana_program_test::{processor, ProgramTest}, + solana_sdk::{account::Account, instruction::AccountMeta}, + spl_transfer_hook_example::state::example_data, + spl_transfer_hook_interface::get_extra_account_metas_address, +}; + +#[test] +fn my_program_test() { + let mut program_test = ProgramTest::new( + "my_program", + my_program_id, + processor!(my_program_processor), + ); + + let transfer_hook_program_id = Pubkey::new_unique(); + program_test.prefer_bpf(false); // BPF won't work, unless you've built this from scratch! + program_test.add_program( + "spl_transfer_hook_example", + transfer_hook_program_id, + processor!(spl_transfer_hook_example::processor::process), + ); + + let mint = Pubkey::new_unique(); + let extra_accounts_address = get_extra_account_metas_address(&mint, &transfer_hook_program_id); + let account_metas = vec![ + AccountMeta { + pubkey: Pubkey::new_unique(), + is_signer: false, + is_writable: false, + }, + AccountMeta { + pubkey: Pubkey::new_unique(), + is_signer: false, + is_writable: false, + }, + ]; + let data = example_data(&account_metas); + program_test.add_account( + extra_accounts_address, + Account { + lamports: 1_000_000_000, // a lot, just to be safe + data, + owner: transfer_hook_program_id, + ..Account::default() + }, + ); + + // run your test logic! +} +``` diff --git a/program/src/entrypoint.rs b/program/src/entrypoint.rs new file mode 100644 index 0000000..14a2bc5 --- /dev/null +++ b/program/src/entrypoint.rs @@ -0,0 +1,24 @@ +//! Program entrypoint + +use { + crate::processor, + solana_program::{ + account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, + program_error::PrintProgramError, pubkey::Pubkey, + }, + spl_transfer_hook_interface::error::TransferHookError, +}; + +entrypoint!(process_instruction); +fn process_instruction( + program_id: &Pubkey, + accounts: &[AccountInfo], + instruction_data: &[u8], +) -> ProgramResult { + if let Err(error) = processor::process(program_id, accounts, instruction_data) { + // catch the error so we can print it + error.print::(); + return Err(error); + } + Ok(()) +} diff --git a/program/src/lib.rs b/program/src/lib.rs new file mode 100644 index 0000000..9db06d9 --- /dev/null +++ b/program/src/lib.rs @@ -0,0 +1,18 @@ +//! Crate defining an example program for performing a hook on transfer, where +//! the token program calls into a separate program with additional accounts +//! after all other logic, to be sure that a transfer has accomplished all +//! required preconditions. + +#![allow(clippy::arithmetic_side_effects)] +#![deny(missing_docs)] +#![cfg_attr(not(test), forbid(unsafe_code))] + +pub mod processor; +pub mod state; + +#[cfg(not(feature = "no-entrypoint"))] +mod entrypoint; + +// Export current sdk types for downstream users building with a different sdk +// version +pub use solana_program; diff --git a/program/src/processor.rs b/program/src/processor.rs new file mode 100644 index 0000000..fccd0ba --- /dev/null +++ b/program/src/processor.rs @@ -0,0 +1,151 @@ +//! Program state processor + +use { + solana_program::{ + account_info::{next_account_info, AccountInfo}, + entrypoint::ProgramResult, + msg, + program::invoke_signed, + program_error::ProgramError, + pubkey::Pubkey, + system_instruction, + }, + spl_tlv_account_resolution::{account::ExtraAccountMeta, state::ExtraAccountMetaList}, + spl_token_2022::{ + extension::{ + transfer_hook::TransferHookAccount, BaseStateWithExtensions, StateWithExtensions, + }, + state::{Account, Mint}, + }, + spl_transfer_hook_interface::{ + collect_extra_account_metas_signer_seeds, + error::TransferHookError, + get_extra_account_metas_address, get_extra_account_metas_address_and_bump_seed, + instruction::{ExecuteInstruction, TransferHookInstruction}, + }, +}; + +fn check_token_account_is_transferring(account_info: &AccountInfo) -> Result<(), ProgramError> { + let account_data = account_info.try_borrow_data()?; + let token_account = StateWithExtensions::::unpack(&account_data)?; + let extension = token_account.get_extension::()?; + if bool::from(extension.transferring) { + Ok(()) + } else { + Err(TransferHookError::ProgramCalledOutsideOfTransfer.into()) + } +} + +/// Processes an [Execute](enum.TransferHookInstruction.html) instruction. +pub fn process_execute( + program_id: &Pubkey, + accounts: &[AccountInfo], + amount: u64, +) -> ProgramResult { + let account_info_iter = &mut accounts.iter(); + + let source_account_info = next_account_info(account_info_iter)?; + let mint_info = next_account_info(account_info_iter)?; + let destination_account_info = next_account_info(account_info_iter)?; + let _authority_info = next_account_info(account_info_iter)?; + let extra_account_metas_info = next_account_info(account_info_iter)?; + + // Check that the accounts are properly in "transferring" mode + check_token_account_is_transferring(source_account_info)?; + check_token_account_is_transferring(destination_account_info)?; + + // For the example program, we just check that the correct pda and validation + // pubkeys are provided + let expected_validation_address = get_extra_account_metas_address(mint_info.key, program_id); + if expected_validation_address != *extra_account_metas_info.key { + return Err(ProgramError::InvalidSeeds); + } + + let data = extra_account_metas_info.try_borrow_data()?; + + ExtraAccountMetaList::check_account_infos::( + accounts, + &TransferHookInstruction::Execute { amount }.pack(), + program_id, + &data, + )?; + + Ok(()) +} + +/// Processes a [InitializeExtraAccountMetaList](enum.TransferHookInstruction.html) instruction. +pub fn process_initialize_extra_account_meta_list( + program_id: &Pubkey, + accounts: &[AccountInfo], + extra_account_metas: &[ExtraAccountMeta], +) -> ProgramResult { + let account_info_iter = &mut accounts.iter(); + + let extra_account_metas_info = next_account_info(account_info_iter)?; + let mint_info = next_account_info(account_info_iter)?; + let authority_info = next_account_info(account_info_iter)?; + let _system_program_info = next_account_info(account_info_iter)?; + + // check that the mint authority is valid without fully deserializing + let mint_data = mint_info.try_borrow_data()?; + let mint = StateWithExtensions::::unpack(&mint_data)?; + let mint_authority = mint + .base + .mint_authority + .ok_or(TransferHookError::MintHasNoMintAuthority)?; + + // Check signers + if !authority_info.is_signer { + return Err(ProgramError::MissingRequiredSignature); + } + if *authority_info.key != mint_authority { + return Err(TransferHookError::IncorrectMintAuthority.into()); + } + + // Check validation account + let (expected_validation_address, bump_seed) = + get_extra_account_metas_address_and_bump_seed(mint_info.key, program_id); + if expected_validation_address != *extra_account_metas_info.key { + return Err(ProgramError::InvalidSeeds); + } + + // Create the account + let bump_seed = [bump_seed]; + let signer_seeds = collect_extra_account_metas_signer_seeds(mint_info.key, &bump_seed); + let length = extra_account_metas.len(); + let account_size = ExtraAccountMetaList::size_of(length)?; + invoke_signed( + &system_instruction::allocate(extra_account_metas_info.key, account_size as u64), + &[extra_account_metas_info.clone()], + &[&signer_seeds], + )?; + invoke_signed( + &system_instruction::assign(extra_account_metas_info.key, program_id), + &[extra_account_metas_info.clone()], + &[&signer_seeds], + )?; + + // Write the data + let mut data = extra_account_metas_info.try_borrow_mut_data()?; + ExtraAccountMetaList::init::(&mut data, extra_account_metas)?; + + Ok(()) +} + +/// Processes an [Instruction](enum.Instruction.html). +pub fn process(program_id: &Pubkey, accounts: &[AccountInfo], input: &[u8]) -> ProgramResult { + let instruction = TransferHookInstruction::unpack(input)?; + + match instruction { + TransferHookInstruction::Execute { amount } => { + msg!("Instruction: Execute"); + process_execute(program_id, accounts, amount) + } + TransferHookInstruction::InitializeExtraAccountMetaList { + extra_account_metas, + } => { + msg!("Instruction: InitializeExtraAccountMetaList"); + process_initialize_extra_account_meta_list(program_id, accounts, &extra_account_metas) + } + } +} diff --git a/program/src/state.rs b/program/src/state.rs new file mode 100644 index 0000000..b2c962c --- /dev/null +++ b/program/src/state.rs @@ -0,0 +1,15 @@ +//! State helpers for working with the example program + +use { + solana_program::program_error::ProgramError, + spl_tlv_account_resolution::{account::ExtraAccountMeta, state::ExtraAccountMetaList}, + spl_transfer_hook_interface::instruction::ExecuteInstruction, +}; + +/// Generate example data to be used directly in an account for testing +pub fn example_data(account_metas: &[ExtraAccountMeta]) -> Result, ProgramError> { + let account_size = ExtraAccountMetaList::size_of(account_metas.len())?; + let mut data = vec![0; account_size]; + ExtraAccountMetaList::init::(&mut data, account_metas)?; + Ok(data) +} diff --git a/program/tests/functional.rs b/program/tests/functional.rs new file mode 100644 index 0000000..989b6f9 --- /dev/null +++ b/program/tests/functional.rs @@ -0,0 +1,749 @@ +// Mark this test as SBF-only due to current `ProgramTest` limitations when +// CPIing into the system program +#![cfg(feature = "test-sbf")] + +use { + solana_program_test::{processor, tokio, ProgramTest}, + solana_sdk::{ + account::Account as SolanaAccount, + account_info::AccountInfo, + entrypoint::ProgramResult, + instruction::{AccountMeta, InstructionError}, + program_error::ProgramError, + program_option::COption, + pubkey::Pubkey, + signature::Signer, + signer::keypair::Keypair, + system_instruction, sysvar, + transaction::{Transaction, TransactionError}, + }, + spl_tlv_account_resolution::{ + account::ExtraAccountMeta, error::AccountResolutionError, seeds::Seed, + state::ExtraAccountMetaList, + }, + spl_token_2022::{ + extension::{transfer_hook::TransferHookAccount, ExtensionType, StateWithExtensionsMut}, + state::{Account, AccountState, Mint}, + }, + spl_transfer_hook_interface::{ + error::TransferHookError, + get_extra_account_metas_address, + instruction::{execute_with_extra_account_metas, initialize_extra_account_meta_list}, + onchain, + }, +}; + +fn setup(program_id: &Pubkey) -> ProgramTest { + let mut program_test = ProgramTest::new( + "spl_transfer_hook_example", + *program_id, + processor!(spl_transfer_hook_example::processor::process), + ); + + program_test.prefer_bpf(false); // simplicity in the build + + program_test.add_program( + "spl_token_2022", + spl_token_2022::id(), + processor!(spl_token_2022::processor::Processor::process), + ); + + program_test +} + +#[allow(clippy::too_many_arguments)] +fn setup_token_accounts( + program_test: &mut ProgramTest, + program_id: &Pubkey, + mint_address: &Pubkey, + mint_authority: &Pubkey, + source: &Pubkey, + destination: &Pubkey, + owner: &Pubkey, + decimals: u8, + transferring: bool, +) { + // add mint, source, and destination accounts by hand to always force + // the "transferring" flag to true + let mint_size = ExtensionType::try_calculate_account_len::(&[]).unwrap(); + let mut mint_data = vec![0; mint_size]; + let mut state = StateWithExtensionsMut::::unpack_uninitialized(&mut mint_data).unwrap(); + let token_amount = 1_000_000_000_000; + state.base = Mint { + mint_authority: COption::Some(*mint_authority), + supply: token_amount, + decimals, + is_initialized: true, + freeze_authority: COption::None, + }; + state.pack_base(); + program_test.add_account( + *mint_address, + SolanaAccount { + lamports: 1_000_000_000, + data: mint_data, + owner: *program_id, + ..SolanaAccount::default() + }, + ); + + let account_size = + ExtensionType::try_calculate_account_len::(&[ExtensionType::TransferHookAccount]) + .unwrap(); + let mut account_data = vec![0; account_size]; + let mut state = + StateWithExtensionsMut::::unpack_uninitialized(&mut account_data).unwrap(); + let extension = state.init_extension::(true).unwrap(); + extension.transferring = transferring.into(); + let token_amount = 1_000_000_000_000; + state.base = Account { + mint: *mint_address, + owner: *owner, + amount: token_amount, + delegate: COption::None, + state: AccountState::Initialized, + is_native: COption::None, + delegated_amount: 0, + close_authority: COption::None, + }; + state.pack_base(); + state.init_account_type().unwrap(); + + program_test.add_account( + *source, + SolanaAccount { + lamports: 1_000_000_000, + data: account_data.clone(), + owner: *program_id, + ..SolanaAccount::default() + }, + ); + program_test.add_account( + *destination, + SolanaAccount { + lamports: 1_000_000_000, + data: account_data, + owner: *program_id, + ..SolanaAccount::default() + }, + ); +} + +#[tokio::test] +async fn success_execute() { + let program_id = Pubkey::new_unique(); + let mut program_test = setup(&program_id); + + let token_program_id = spl_token_2022::id(); + let wallet = Keypair::new(); + let mint_address = Pubkey::new_unique(); + let mint_authority = Keypair::new(); + let mint_authority_pubkey = mint_authority.pubkey(); + let source = Pubkey::new_unique(); + let destination = Pubkey::new_unique(); + let decimals = 2; + let amount = 0u64; + + setup_token_accounts( + &mut program_test, + &token_program_id, + &mint_address, + &mint_authority_pubkey, + &source, + &destination, + &wallet.pubkey(), + decimals, + true, + ); + + let extra_account_metas_address = get_extra_account_metas_address(&mint_address, &program_id); + + let writable_pubkey = Pubkey::new_unique(); + + let init_extra_account_metas = [ + ExtraAccountMeta::new_with_pubkey(&sysvar::instructions::id(), false, false).unwrap(), + ExtraAccountMeta::new_with_pubkey(&mint_authority_pubkey, true, false).unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::Literal { + bytes: b"seed-prefix".to_vec(), + }, + Seed::AccountKey { index: 0 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::InstructionData { + index: 8, // After instruction discriminator + length: 8, // `u64` (amount) + }, + Seed::AccountKey { index: 2 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_pubkey(&writable_pubkey, false, true).unwrap(), + ]; + + let extra_pda_1 = Pubkey::find_program_address( + &[ + b"seed-prefix", // Literal prefix + source.as_ref(), // Account at index 0 + ], + &program_id, + ) + .0; + let extra_pda_2 = Pubkey::find_program_address( + &[ + &amount.to_le_bytes(), // Instruction data bytes 8 to 16 + destination.as_ref(), // Account at index 2 + ], + &program_id, + ) + .0; + + let extra_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, true), + AccountMeta::new(extra_pda_1, false), + AccountMeta::new(extra_pda_2, false), + AccountMeta::new(writable_pubkey, false), + ]; + + let mut context = program_test.start_with_context().await; + let rent = context.banks_client.get_rent().await.unwrap(); + let rent_lamports = rent + .minimum_balance(ExtraAccountMetaList::size_of(init_extra_account_metas.len()).unwrap()); + let transaction = Transaction::new_signed_with_payer( + &[ + system_instruction::transfer( + &context.payer.pubkey(), + &extra_account_metas_address, + rent_lamports, + ), + initialize_extra_account_meta_list( + &program_id, + &extra_account_metas_address, + &mint_address, + &mint_authority_pubkey, + &init_extra_account_metas, + ), + ], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + + context + .banks_client + .process_transaction(transaction) + .await + .unwrap(); + + // fail with missing account + { + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &extra_account_metas[..2], + amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError( + 0, + InstructionError::Custom(AccountResolutionError::IncorrectAccount as u32), + ) + ); + } + + // fail with wrong account + { + let extra_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, true), + AccountMeta::new(extra_pda_1, false), + AccountMeta::new(extra_pda_2, false), + AccountMeta::new(Pubkey::new_unique(), false), + ]; + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &extra_account_metas, + amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError( + 0, + InstructionError::Custom(AccountResolutionError::IncorrectAccount as u32), + ) + ); + } + + // fail with wrong PDA + let wrong_pda_2 = Pubkey::find_program_address( + &[ + &99u64.to_le_bytes(), // Wrong data + destination.as_ref(), + ], + &program_id, + ) + .0; + { + let extra_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, true), + AccountMeta::new(extra_pda_1, false), + AccountMeta::new(wrong_pda_2, false), + AccountMeta::new(writable_pubkey, false), + ]; + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &extra_account_metas, + amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError( + 0, + InstructionError::Custom(AccountResolutionError::IncorrectAccount as u32), + ) + ); + } + + // fail with not signer + { + let extra_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, false), + AccountMeta::new(extra_pda_1, false), + AccountMeta::new(extra_pda_2, false), + AccountMeta::new(writable_pubkey, false), + ]; + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &extra_account_metas, + amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError( + 0, + InstructionError::Custom(AccountResolutionError::IncorrectAccount as u32), + ) + ); + } + + // success with correct params + { + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &extra_account_metas, + amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + context + .banks_client + .process_transaction(transaction) + .await + .unwrap(); + } +} + +#[tokio::test] +async fn fail_incorrect_derivation() { + let program_id = Pubkey::new_unique(); + let mut program_test = setup(&program_id); + + let token_program_id = spl_token_2022::id(); + let wallet = Keypair::new(); + let mint_address = Pubkey::new_unique(); + let mint_authority = Keypair::new(); + let mint_authority_pubkey = mint_authority.pubkey(); + let source = Pubkey::new_unique(); + let destination = Pubkey::new_unique(); + let decimals = 2; + setup_token_accounts( + &mut program_test, + &token_program_id, + &mint_address, + &mint_authority_pubkey, + &source, + &destination, + &wallet.pubkey(), + decimals, + true, + ); + + // wrong derivation + let extra_account_metas = get_extra_account_metas_address(&program_id, &mint_address); + + let mut context = program_test.start_with_context().await; + let rent = context.banks_client.get_rent().await.unwrap(); + let rent_lamports = rent.minimum_balance(ExtraAccountMetaList::size_of(0).unwrap()); + + let transaction = Transaction::new_signed_with_payer( + &[ + system_instruction::transfer( + &context.payer.pubkey(), + &extra_account_metas, + rent_lamports, + ), + initialize_extra_account_meta_list( + &program_id, + &extra_account_metas, + &mint_address, + &mint_authority_pubkey, + &[], + ), + ], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError(1, InstructionError::InvalidSeeds) + ); +} + +/// Test program to CPI into default transfer-hook-interface program +pub fn process_instruction( + _program_id: &Pubkey, + accounts: &[AccountInfo], + input: &[u8], +) -> ProgramResult { + let amount = input + .get(8..16) + .and_then(|slice| slice.try_into().ok()) + .map(u64::from_le_bytes) + .ok_or(ProgramError::InvalidInstructionData)?; + onchain::invoke_execute( + accounts[0].key, + accounts[1].clone(), + accounts[2].clone(), + accounts[3].clone(), + accounts[4].clone(), + &accounts[5..], + amount, + ) +} + +#[tokio::test] +async fn success_on_chain_invoke() { + let hook_program_id = Pubkey::new_unique(); + let mut program_test = setup(&hook_program_id); + let program_id = Pubkey::new_unique(); + program_test.add_program( + "test_cpi_program", + program_id, + processor!(process_instruction), + ); + + let token_program_id = spl_token_2022::id(); + let wallet = Keypair::new(); + let mint_address = Pubkey::new_unique(); + let mint_authority = Keypair::new(); + let mint_authority_pubkey = mint_authority.pubkey(); + let source = Pubkey::new_unique(); + let destination = Pubkey::new_unique(); + let decimals = 2; + let amount = 0u64; + + setup_token_accounts( + &mut program_test, + &token_program_id, + &mint_address, + &mint_authority_pubkey, + &source, + &destination, + &wallet.pubkey(), + decimals, + true, + ); + + let extra_account_metas_address = + get_extra_account_metas_address(&mint_address, &hook_program_id); + let writable_pubkey = Pubkey::new_unique(); + + let init_extra_account_metas = [ + ExtraAccountMeta::new_with_pubkey(&sysvar::instructions::id(), false, false).unwrap(), + ExtraAccountMeta::new_with_pubkey(&mint_authority_pubkey, true, false).unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::Literal { + bytes: b"seed-prefix".to_vec(), + }, + Seed::AccountKey { index: 0 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::InstructionData { + index: 8, // After instruction discriminator + length: 8, // `u64` (amount) + }, + Seed::AccountKey { index: 2 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_pubkey(&writable_pubkey, false, true).unwrap(), + ]; + + let extra_pda_1 = Pubkey::find_program_address( + &[ + b"seed-prefix", // Literal prefix + source.as_ref(), // Account at index 0 + ], + &hook_program_id, + ) + .0; + let extra_pda_2 = Pubkey::find_program_address( + &[ + &amount.to_le_bytes(), // Instruction data bytes 8 to 16 + destination.as_ref(), // Account at index 2 + ], + &hook_program_id, + ) + .0; + + let extra_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, true), + AccountMeta::new(extra_pda_1, false), + AccountMeta::new(extra_pda_2, false), + AccountMeta::new(writable_pubkey, false), + ]; + + let mut context = program_test.start_with_context().await; + let rent = context.banks_client.get_rent().await.unwrap(); + let rent_lamports = rent + .minimum_balance(ExtraAccountMetaList::size_of(init_extra_account_metas.len()).unwrap()); + let transaction = Transaction::new_signed_with_payer( + &[ + system_instruction::transfer( + &context.payer.pubkey(), + &extra_account_metas_address, + rent_lamports, + ), + initialize_extra_account_meta_list( + &hook_program_id, + &extra_account_metas_address, + &mint_address, + &mint_authority_pubkey, + &init_extra_account_metas, + ), + ], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + + context + .banks_client + .process_transaction(transaction) + .await + .unwrap(); + + // easier to hack this up! + let mut test_instruction = execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &extra_account_metas, + amount, + ); + test_instruction + .accounts + .insert(0, AccountMeta::new_readonly(hook_program_id, false)); + let transaction = Transaction::new_signed_with_payer( + &[test_instruction], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + + context + .banks_client + .process_transaction(transaction) + .await + .unwrap(); +} + +#[tokio::test] +async fn fail_without_transferring_flag() { + let program_id = Pubkey::new_unique(); + let mut program_test = setup(&program_id); + + let token_program_id = spl_token_2022::id(); + let wallet = Keypair::new(); + let mint_address = Pubkey::new_unique(); + let mint_authority = Keypair::new(); + let mint_authority_pubkey = mint_authority.pubkey(); + let source = Pubkey::new_unique(); + let destination = Pubkey::new_unique(); + let decimals = 2; + + setup_token_accounts( + &mut program_test, + &token_program_id, + &mint_address, + &mint_authority_pubkey, + &source, + &destination, + &wallet.pubkey(), + decimals, + false, + ); + + let extra_account_metas_address = get_extra_account_metas_address(&mint_address, &program_id); + let extra_account_metas = []; + let init_extra_account_metas = []; + let mut context = program_test.start_with_context().await; + let rent = context.banks_client.get_rent().await.unwrap(); + let rent_lamports = rent + .minimum_balance(ExtraAccountMetaList::size_of(init_extra_account_metas.len()).unwrap()); + let transaction = Transaction::new_signed_with_payer( + &[ + system_instruction::transfer( + &context.payer.pubkey(), + &extra_account_metas_address, + rent_lamports, + ), + initialize_extra_account_meta_list( + &program_id, + &extra_account_metas_address, + &mint_address, + &mint_authority_pubkey, + &init_extra_account_metas, + ), + ], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + + context + .banks_client + .process_transaction(transaction) + .await + .unwrap(); + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &extra_account_metas, + 0, + )], + Some(&context.payer.pubkey()), + &[&context.payer], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError( + 0, + InstructionError::Custom(TransferHookError::ProgramCalledOutsideOfTransfer as u32) + ) + ); +} From 2c6be09713096d0281e70febe9e7c1e9ae1f2701 Mon Sep 17 00:00:00 2001 From: Jon Cinque Date: Wed, 25 Oct 2023 15:00:05 +0200 Subject: [PATCH 002/154] transfer-hook-cli: Add a tool for creating account metas (#5659) * transfer-hook-cli: Create tool for creating account metas * Add to token CI, remove from general CI * Review feedback: change command name and check account --- clients/cli/Cargo.toml | 33 ++++ clients/cli/src/main.rs | 407 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 440 insertions(+) create mode 100644 clients/cli/Cargo.toml create mode 100644 clients/cli/src/main.rs diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml new file mode 100644 index 0000000..b9f1550 --- /dev/null +++ b/clients/cli/Cargo.toml @@ -0,0 +1,33 @@ +[package] +authors = ["Solana Labs Maintainers "] +description = "SPL-Token Command-line Utility" +edition = "2021" +homepage = "https://spl.solana.com/token" +license = "Apache-2.0" +name = "spl-transfer-hook-cli" +repository = "https://github.com/solana-labs/solana-program-library" +version = "0.1.0" + +[dependencies] +clap = { version = "3", features = ["cargo"] } +futures-util = "0.3.19" +solana-clap-v3-utils = "=1.17.2" +solana-cli-config = "=1.17.2" +solana-client = "=1.17.2" +solana-logger = "=1.17.2" +solana-remote-wallet = "=1.17.2" +solana-sdk = "=1.17.2" +spl-transfer-hook-interface = { version = "0.3", path = "../interface" } +spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } +strum = "0.25" +strum_macros = "0.25" +tokio = { version = "1", features = ["full"] } + +[dev-dependencies] +solana-test-validator = "=1.17.2" +spl-token-2022 = { version = "0.9", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-client = { version = "0.7", path = "../../client" } + +[[bin]] +name = "spl-transfer-hook" +path = "src/main.rs" diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs new file mode 100644 index 0000000..63d11f8 --- /dev/null +++ b/clients/cli/src/main.rs @@ -0,0 +1,407 @@ +use { + clap::{crate_description, crate_name, crate_version, Arg, Command}, + solana_clap_v3_utils::{ + input_parsers::{parse_url_or_moniker, pubkey_of_signer}, + input_validators::{is_valid_pubkey, is_valid_signer, normalize_to_url_if_moniker}, + keypair::DefaultSigner, + }, + solana_client::nonblocking::rpc_client::RpcClient, + solana_remote_wallet::remote_wallet::RemoteWalletManager, + solana_sdk::{ + commitment_config::CommitmentConfig, + instruction::AccountMeta, + pubkey::Pubkey, + signature::{Signature, Signer}, + system_instruction, system_program, + transaction::Transaction, + }, + spl_tlv_account_resolution::state::ExtraAccountMetaList, + spl_transfer_hook_interface::{ + get_extra_account_metas_address, instruction::initialize_extra_account_meta_list, + }, + std::{fmt, process::exit, rc::Rc, str::FromStr}, + strum_macros::{EnumString, IntoStaticStr}, +}; + +#[derive(Debug, Clone, Copy, PartialEq, EnumString, IntoStaticStr)] +#[strum(serialize_all = "kebab-case")] +pub enum AccountMetaRole { + Readonly, + Writable, + ReadonlySigner, + WritableSigner, +} +impl fmt::Display for AccountMetaRole { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}", self) + } +} +fn parse_transfer_hook_account(arg: &str) -> Result { + match arg.split(':').collect::>().as_slice() { + [address, role] => { + let address = Pubkey::from_str(address).map_err(|e| format!("{e}"))?; + let meta = match AccountMetaRole::from_str(role).map_err(|e| format!("{e}"))? { + AccountMetaRole::Readonly => AccountMeta::new_readonly(address, false), + AccountMetaRole::Writable => AccountMeta::new(address, false), + AccountMetaRole::ReadonlySigner => AccountMeta::new_readonly(address, true), + AccountMetaRole::WritableSigner => AccountMeta::new(address, true), + }; + Ok(meta) + } + _ => Err("Transfer hook account must be present as
:".to_string()), + } +} + +fn clap_is_valid_pubkey(arg: &str) -> Result<(), String> { + is_valid_pubkey(arg) +} + +struct Config { + commitment_config: CommitmentConfig, + default_signer: Box, + json_rpc_url: String, + verbose: bool, +} + +async fn process_create_extra_account_metas( + rpc_client: &RpcClient, + program_id: &Pubkey, + token: &Pubkey, + transfer_hook_accounts: Vec, + mint_authority: &dyn Signer, + payer: &dyn Signer, +) -> Result> { + let extra_account_metas_address = get_extra_account_metas_address(token, program_id); + let extra_account_metas = transfer_hook_accounts + .into_iter() + .map(|v| v.into()) + .collect::>(); + + let length = extra_account_metas.len(); + let account_size = ExtraAccountMetaList::size_of(length)?; + let required_lamports = rpc_client + .get_minimum_balance_for_rent_exemption(account_size) + .await + .map_err(|err| format!("error: unable to fetch rent-exemption: {err}"))?; + let extra_account_metas_account = rpc_client.get_account(&extra_account_metas_address).await; + if let Ok(account) = &extra_account_metas_account { + if account.owner != system_program::id() { + return Err(format!("error: extra account metas for mint {token} and program {program_id} already exists").into()); + } + } + let current_lamports = extra_account_metas_account.map(|a| a.lamports).unwrap_or(0); + let transfer_lamports = required_lamports.saturating_sub(current_lamports); + + let mut ixs = vec![]; + if transfer_lamports > 0 { + ixs.push(system_instruction::transfer( + &payer.pubkey(), + &extra_account_metas_address, + transfer_lamports, + )); + } + ixs.push(initialize_extra_account_meta_list( + program_id, + &extra_account_metas_address, + token, + &mint_authority.pubkey(), + &extra_account_metas, + )); + + let mut transaction = Transaction::new_with_payer(&ixs, Some(&payer.pubkey())); + let blockhash = rpc_client + .get_latest_blockhash() + .await + .map_err(|err| format!("error: unable to get latest blockhash: {err}"))?; + let mut signers = vec![payer]; + if payer.pubkey() != mint_authority.pubkey() { + signers.push(mint_authority); + } + transaction + .try_sign(&signers, blockhash) + .map_err(|err| format!("error: failed to sign transaction: {err}"))?; + + rpc_client + .send_and_confirm_transaction_with_spinner(&transaction) + .await + .map_err(|err| format!("error: send transaction: {err}").into()) +} + +#[tokio::main] +async fn main() -> Result<(), Box> { + let app_matches = Command::new(crate_name!()) + .about(crate_description!()) + .version(crate_version!()) + .subcommand_required(true) + .arg_required_else_help(true) + .arg({ + let arg = Arg::new("config_file") + .short('C') + .long("config") + .value_name("PATH") + .takes_value(true) + .global(true) + .help("Configuration file to use"); + if let Some(ref config_file) = *solana_cli_config::CONFIG_FILE { + arg.default_value(config_file) + } else { + arg + } + }) + .arg( + Arg::new("fee_payer") + .long("fee-payer") + .value_name("KEYPAIR") + .validator(|s| is_valid_signer(s)) + .takes_value(true) + .global(true) + .help("Filepath or URL to a keypair to pay transaction fee [default: client keypair]"), + ) + .arg( + Arg::new("verbose") + .long("verbose") + .short('v') + .takes_value(false) + .global(true) + .help("Show additional information"), + ) + .arg( + Arg::new("json_rpc_url") + .short('u') + .long("url") + .value_name("URL") + .takes_value(true) + .global(true) + .value_parser(parse_url_or_moniker) + .help("JSON RPC URL for the cluster [default: value from configuration file]"), + ) + .subcommand( + Command::new("create-extra-metas") + .about("Create the extra account metas account for a transfer hook program") + .arg( + Arg::with_name("program_id") + .validator(clap_is_valid_pubkey) + .value_name("TRANSFER_HOOK_PROGRAM") + .takes_value(true) + .index(1) + .required(true) + .help("The transfer hook program id"), + ) + .arg( + Arg::with_name("token") + .validator(clap_is_valid_pubkey) + .value_name("TOKEN_MINT_ADDRESS") + .takes_value(true) + .index(2) + .required(true) + .help("The token mint address for the transfer hook"), + ) + .arg( + Arg::with_name("transfer_hook_account") + .value_parser(parse_transfer_hook_account) + .value_name("PUBKEY:ROLE") + .takes_value(true) + .multiple(true) + .min_values(0) + .index(3) + .help("Additional pubkey(s) required for a transfer hook and their \ + role, in the format \":\". The role must be \ + \"readonly\", \"writable\". \"readonly-signer\", or \"writable-signer\".") + ) + .arg( + Arg::new("mint_authority") + .long("mint-authority") + .value_name("KEYPAIR") + .validator(|s| is_valid_signer(s)) + .takes_value(true) + .global(true) + .help("Filepath or URL to mint-authority keypair [default: client keypair]"), + ) + ).get_matches(); + + let (command, matches) = app_matches.subcommand().unwrap(); + let mut wallet_manager: Option> = None; + + let cli_config = if let Some(config_file) = matches.value_of("config_file") { + solana_cli_config::Config::load(config_file).unwrap_or_default() + } else { + solana_cli_config::Config::default() + }; + + let config = { + let default_signer = DefaultSigner::new( + "fee_payer", + matches + .value_of("fee_payer") + .map(|s| s.to_string()) + .unwrap_or_else(|| cli_config.keypair_path.clone()), + ); + + let json_rpc_url = normalize_to_url_if_moniker( + matches + .value_of("json_rpc_url") + .unwrap_or(&cli_config.json_rpc_url), + ); + + Config { + commitment_config: CommitmentConfig::confirmed(), + default_signer: default_signer + .signer_from_path(matches, &mut wallet_manager) + .unwrap_or_else(|err| { + eprintln!("error: {err}"); + exit(1); + }), + json_rpc_url, + verbose: matches.is_present("verbose"), + } + }; + solana_logger::setup_with_default("solana=info"); + + if config.verbose { + println!("JSON RPC URL: {}", config.json_rpc_url); + } + let rpc_client = + RpcClient::new_with_commitment(config.json_rpc_url.clone(), config.commitment_config); + + match (command, matches) { + ("create-extra-metas", arg_matches) => { + let program_id = pubkey_of_signer(arg_matches, "program_id", &mut wallet_manager) + .unwrap() + .unwrap(); + let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager) + .unwrap() + .unwrap(); + let transfer_hook_accounts = arg_matches + .get_many::("transfer_hook_account") + .unwrap_or_default() + .cloned() + .collect(); + let mint_authority = DefaultSigner::new( + "mint_authority", + matches + .value_of("mint_authority") + .map(|s| s.to_string()) + .unwrap_or_else(|| cli_config.keypair_path.clone()), + ) + .signer_from_path(matches, &mut wallet_manager) + .unwrap_or_else(|err| { + eprintln!("error: {err}"); + exit(1); + }); + let signature = process_create_extra_account_metas( + &rpc_client, + &program_id, + &token, + transfer_hook_accounts, + mint_authority.as_ref(), + config.default_signer.as_ref(), + ) + .await + .unwrap_or_else(|err| { + eprintln!("error: send transaction: {err}"); + exit(1); + }); + println!("Signature: {signature}"); + } + _ => unreachable!(), + }; + + Ok(()) +} + +#[cfg(test)] +mod test { + use { + super::*, + solana_sdk::{bpf_loader_upgradeable, signer::keypair::Keypair}, + solana_test_validator::{TestValidator, TestValidatorGenesis, UpgradeableProgramInfo}, + spl_token_client::{ + client::{ + ProgramClient, ProgramRpcClient, ProgramRpcClientSendTransaction, SendTransaction, + SimulateTransaction, + }, + token::Token, + }, + std::{path::PathBuf, sync::Arc}, + }; + + async fn new_validator_for_test(program_id: Pubkey) -> (TestValidator, Keypair) { + solana_logger::setup(); + let mut test_validator_genesis = TestValidatorGenesis::default(); + test_validator_genesis.add_upgradeable_programs_with_path(&[UpgradeableProgramInfo { + program_id, + loader: bpf_loader_upgradeable::id(), + program_path: PathBuf::from("../../../target/deploy/spl_transfer_hook_example.so"), + upgrade_authority: Pubkey::new_unique(), + }]); + test_validator_genesis.start_async().await + } + + async fn setup_mint( + program_id: &Pubkey, + mint_authority: &Pubkey, + decimals: u8, + payer: Arc, + client: Arc>, + ) -> Token { + let mint_account = Keypair::new(); + let token = Token::new( + client, + program_id, + &mint_account.pubkey(), + Some(decimals), + payer, + ); + token + .create_mint(mint_authority, None, vec![], &[&mint_account]) + .await + .unwrap(); + token + } + + #[tokio::test] + async fn test_create() { + let program_id = Pubkey::new_unique(); + + let (test_validator, payer) = new_validator_for_test(program_id).await; + let payer: Arc = Arc::new(payer); + let rpc_client = Arc::new(test_validator.get_async_rpc_client()); + let client = Arc::new(ProgramRpcClient::new( + rpc_client.clone(), + ProgramRpcClientSendTransaction, + )); + + let mint_authority = Keypair::new(); + let decimals = 2; + + let token = setup_mint( + &spl_token_2022::id(), + &mint_authority.pubkey(), + decimals, + payer.clone(), + client.clone(), + ) + .await; + + let required_address = Pubkey::new_unique(); + let accounts = vec![AccountMeta::new_readonly(required_address, false)]; + process_create_extra_account_metas( + &rpc_client, + &program_id, + token.get_address(), + accounts, + &mint_authority, + payer.as_ref(), + ) + .await + .unwrap(); + + let extra_account_metas_address = + get_extra_account_metas_address(token.get_address(), &program_id); + let account = rpc_client + .get_account(&extra_account_metas_address) + .await + .unwrap(); + assert_eq!(account.owner, program_id); + } +} From 44d96bb5919e2939be01f030b84dc4d3dbeaff35 Mon Sep 17 00:00:00 2001 From: Jon Cinque Date: Sun, 29 Oct 2023 22:09:42 +0100 Subject: [PATCH 003/154] token-cli{,ent}: Bump version for release (#5689) --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index b9f1550..7bb6efd 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -26,7 +26,7 @@ tokio = { version = "1", features = ["full"] } [dev-dependencies] solana-test-validator = "=1.17.2" spl-token-2022 = { version = "0.9", path = "../../program-2022", features = ["no-entrypoint"] } -spl-token-client = { version = "0.7", path = "../../client" } +spl-token-client = { version = "0.8", path = "../../client" } [[bin]] name = "spl-transfer-hook" From af4d4ab2891db705bed98c846dc8bd4c99ea3f24 Mon Sep 17 00:00:00 2001 From: Joe C Date: Wed, 8 Nov 2023 20:36:07 +0000 Subject: [PATCH 004/154] rustfmt: use entrypoint full path This PR swaps any calls to the `entrypoint!` macro with the full path, ie: `solana_program::entrypoint!`. This will play a role in the effort to introduce a linting standard to SPL. --- program/src/entrypoint.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/program/src/entrypoint.rs b/program/src/entrypoint.rs index 14a2bc5..b204603 100644 --- a/program/src/entrypoint.rs +++ b/program/src/entrypoint.rs @@ -3,13 +3,13 @@ use { crate::processor, solana_program::{ - account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, - program_error::PrintProgramError, pubkey::Pubkey, + account_info::AccountInfo, entrypoint::ProgramResult, program_error::PrintProgramError, + pubkey::Pubkey, }, spl_transfer_hook_interface::error::TransferHookError, }; -entrypoint!(process_instruction); +solana_program::entrypoint!(process_instruction); fn process_instruction( program_id: &Pubkey, accounts: &[AccountInfo], From b8ed5ba69079c1b2f050ee6ca8f05bbb191e334e Mon Sep 17 00:00:00 2001 From: Joe C Date: Wed, 8 Nov 2023 20:41:36 +0000 Subject: [PATCH 005/154] rustfmt: format comments This PR adds comment formatting configurations to the repository's `rustfmt.toml` file, and the associated changes from `cargo +nightly fmt --all`. Comment width 80. --- interface/src/instruction.rs | 15 ++++++++------- interface/src/lib.rs | 3 ++- interface/src/onchain.rs | 7 ++++--- program/src/processor.rs | 4 +++- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index a1fdcfe..5784f1b 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -26,8 +26,8 @@ pub enum TransferHookInstruction { /// 2. `[]` Destination account /// 3. `[]` Source account's owner/delegate /// 4. `[]` Validation account - /// 5..5+M `[]` `M` additional accounts, written in validation account data - /// + /// 5..5+M `[]` `M` additional accounts, written in validation account + /// data Execute { /// Amount of tokens to transfer amount: u64, @@ -41,15 +41,14 @@ pub enum TransferHookInstruction { /// 1. `[]` Mint /// 2. `[s]` Mint authority /// 3. `[]` System program - /// InitializeExtraAccountMetaList { /// List of `ExtraAccountMeta`s to write into the account extra_account_metas: Vec, }, } /// TLV instruction type only used to define the discriminator. The actual data -/// is entirely managed by `ExtraAccountMetaList`, and it is the only data contained -/// by this type. +/// is entirely managed by `ExtraAccountMetaList`, and it is the only data +/// contained by this type. #[derive(SplDiscriminate)] #[discriminator_hash_input("spl-transfer-hook-interface:execute")] pub struct ExecuteInstruction; @@ -61,7 +60,8 @@ pub struct ExecuteInstruction; pub struct InitializeExtraAccountMetaListInstruction; impl TransferHookInstruction { - /// Unpacks a byte buffer into a [TransferHookInstruction](enum.TransferHookInstruction.html). + /// Unpacks a byte buffer into a + /// [TransferHookInstruction](enum.TransferHookInstruction.html). pub fn unpack(input: &[u8]) -> Result { if input.len() < ArrayDiscriminator::LENGTH { return Err(ProgramError::InvalidInstructionData); @@ -87,7 +87,8 @@ impl TransferHookInstruction { }) } - /// Packs a [TokenInstruction](enum.TokenInstruction.html) into a byte buffer. + /// Packs a [TokenInstruction](enum.TokenInstruction.html) into a byte + /// buffer. pub fn pack(&self) -> Vec { let mut buf = vec![]; match self { diff --git a/interface/src/lib.rs b/interface/src/lib.rs index 20af3ab..d22b7f8 100644 --- a/interface/src/lib.rs +++ b/interface/src/lib.rs @@ -12,7 +12,8 @@ pub mod instruction; pub mod offchain; pub mod onchain; -// Export current sdk types for downstream users building with a different sdk version +// Export current sdk types for downstream users building with a different sdk +// version pub use solana_program; use solana_program::pubkey::Pubkey; diff --git a/interface/src/onchain.rs b/interface/src/onchain.rs index 1c0e0fb..7eb52e3 100644 --- a/interface/src/onchain.rs +++ b/interface/src/onchain.rs @@ -1,4 +1,5 @@ -//! On-chain program invoke helper to perform on-chain `execute` with correct accounts +//! On-chain program invoke helper to perform on-chain `execute` with correct +//! accounts use { crate::{error::TransferHookError, get_extra_account_metas_address, instruction}, @@ -53,8 +54,8 @@ pub fn invoke_execute<'a>( invoke(&cpi_instruction, &cpi_account_infos) } -/// Helper to add accounts required for the transfer-hook program on-chain, looking -/// through the additional account infos to add the proper accounts +/// Helper to add accounts required for the transfer-hook program on-chain, +/// looking through the additional account infos to add the proper accounts pub fn add_cpi_accounts_for_execute<'a>( cpi_instruction: &mut Instruction, cpi_account_infos: &mut Vec>, diff --git a/program/src/processor.rs b/program/src/processor.rs index fccd0ba..16b2d1f 100644 --- a/program/src/processor.rs +++ b/program/src/processor.rs @@ -73,7 +73,9 @@ pub fn process_execute( Ok(()) } -/// Processes a [InitializeExtraAccountMetaList](enum.TransferHookInstruction.html) instruction. +/// Processes a +/// [InitializeExtraAccountMetaList](enum.TransferHookInstruction.html) +/// instruction. pub fn process_initialize_extra_account_meta_list( program_id: &Pubkey, accounts: &[AccountInfo], From 63926dc0d5e91f5af74b4e8354ba7a0e47600b67 Mon Sep 17 00:00:00 2001 From: Jon Cinque Date: Wed, 29 Nov 2023 12:55:07 +0100 Subject: [PATCH 006/154] repo: Update to 1.17.6 (#5863) * repo: Update to 1.17.6 with script * Update lockfile * Remove disabling feature in token-cli tests --- clients/cli/Cargo.toml | 14 +++++++------- interface/Cargo.toml | 2 +- program/Cargo.toml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 7bb6efd..b36b2c0 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -11,12 +11,12 @@ version = "0.1.0" [dependencies] clap = { version = "3", features = ["cargo"] } futures-util = "0.3.19" -solana-clap-v3-utils = "=1.17.2" -solana-cli-config = "=1.17.2" -solana-client = "=1.17.2" -solana-logger = "=1.17.2" -solana-remote-wallet = "=1.17.2" -solana-sdk = "=1.17.2" +solana-clap-v3-utils = "=1.17.6" +solana-cli-config = "=1.17.6" +solana-client = "=1.17.6" +solana-logger = "=1.17.6" +solana-remote-wallet = "=1.17.6" +solana-sdk = "=1.17.6" spl-transfer-hook-interface = { version = "0.3", path = "../interface" } spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } strum = "0.25" @@ -24,7 +24,7 @@ strum_macros = "0.25" tokio = { version = "1", features = ["full"] } [dev-dependencies] -solana-test-validator = "=1.17.2" +solana-test-validator = "=1.17.6" spl-token-2022 = { version = "0.9", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.8", path = "../../client" } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 79644bc..c0db5b1 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" bytemuck = { version = "1.14.0", features = ["derive"] } -solana-program = "1.17.2" +solana-program = "1.17.6" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } diff --git a/program/Cargo.toml b/program/Cargo.toml index b8a4821..9eed486 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -13,15 +13,15 @@ test-sbf = [] [dependencies] arrayref = "0.3.7" -solana-program = "1.17.2" +solana-program = "1.17.6" spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "0.9", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.3" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] -solana-program-test = "1.17.2" -solana-sdk = "1.17.2" +solana-program-test = "1.17.6" +solana-sdk = "1.17.6" [lib] crate-type = ["cdylib", "lib"] From b7bc8e52242f6082743965ddd34d6815f243befb Mon Sep 17 00:00:00 2001 From: tonton-sol <19677766+tonton-sol@users.noreply.github.com> Date: Thu, 7 Dec 2023 21:56:09 +0900 Subject: [PATCH 007/154] Token 22: Add functionality to update extra_account_metas after initializing. (#5894) * Added update function for ExtraAccountMetaList * Updated interface to handle new update instruction * Updated Cli to handle update command * updated example program to handle updating * Rust fmt trailing whitespace fix * Removed unused variable * Added more explicit update instruction doc comment * Allow for resizing to smaller account size * Removed system program from update instruction * Added helper fn to calculate transfer lamports * Added unit tests for update function * Added unit test for update instruction * removed unnecessary commented out code * re-added checks on initialization * turned of zero_init for realloc for performance * Fixed update doc comments * Used block-scoping rather than explicit drop() * Removed unnecessary convert to vec * refactored updated test into single test * added additional off-chain test of update instruct * made on-chain invoke update test to match original * moved helper function up to others * refactored create and update with helpers * rustfmt: fix * rustfmt: fix * removed commented out system program in update * renamed helpers and removed unnecessary helper * moved test helper up * fixed test attribute location * removed multiple init extra account metas in test * added instruction assert to update test * renamed transfer address to extra account metas * rustfmt: comment fix * clippy: fix * added update test with simple PDA * made more changes to updated metas in test * added check for if extra metas have be initialized * spelling fix * fixed initialized condition --- clients/cli/src/main.rs | 254 +++++++++++--- interface/src/instruction.rs | 66 +++- program/src/processor.rs | 68 ++++ program/tests/functional.rs | 651 ++++++++++++++++++++++++++++++++++- 4 files changed, 996 insertions(+), 43 deletions(-) diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index 63d11f8..06b0788 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -9,15 +9,16 @@ use { solana_remote_wallet::remote_wallet::RemoteWalletManager, solana_sdk::{ commitment_config::CommitmentConfig, - instruction::AccountMeta, + instruction::{AccountMeta, Instruction}, pubkey::Pubkey, signature::{Signature, Signer}, system_instruction, system_program, transaction::Transaction, }, - spl_tlv_account_resolution::state::ExtraAccountMetaList, + spl_tlv_account_resolution::{account::ExtraAccountMeta, state::ExtraAccountMetaList}, spl_transfer_hook_interface::{ - get_extra_account_metas_address, instruction::initialize_extra_account_meta_list, + get_extra_account_metas_address, + instruction::{initialize_extra_account_meta_list, update_extra_account_meta_list}, }, std::{fmt, process::exit, rc::Rc, str::FromStr}, strum_macros::{EnumString, IntoStaticStr}, @@ -56,6 +57,74 @@ fn clap_is_valid_pubkey(arg: &str) -> Result<(), String> { is_valid_pubkey(arg) } +// Helper function to calculate the required lamports for rent +async fn calculate_rent_lamports( + rpc_client: &RpcClient, + account_address: &Pubkey, + account_size: usize, +) -> Result> { + let required_lamports = rpc_client + .get_minimum_balance_for_rent_exemption(account_size) + .await + .map_err(|err| format!("error: unable to fetch rent-exemption: {err}"))?; + let account_info = rpc_client.get_account(account_address).await; + let current_lamports = account_info.map(|a| a.lamports).unwrap_or(0); + Ok(required_lamports.saturating_sub(current_lamports)) +} + +async fn build_transaction_with_rent_transfer( + rpc_client: &RpcClient, + payer: &dyn Signer, + extra_account_metas_address: &Pubkey, + extra_account_metas: &Vec, + instruction: Instruction, +) -> Result> { + let account_size = ExtraAccountMetaList::size_of(extra_account_metas.len())?; + let transfer_lamports = + calculate_rent_lamports(rpc_client, extra_account_metas_address, account_size).await?; + + let mut instructions = vec![]; + if transfer_lamports > 0 { + instructions.push(system_instruction::transfer( + &payer.pubkey(), + extra_account_metas_address, + transfer_lamports, + )); + } + + instructions.push(instruction); + + let transaction = Transaction::new_with_payer(&instructions, Some(&payer.pubkey())); + + Ok(transaction) +} + +async fn sign_and_send_transaction( + transaction: &mut Transaction, + rpc_client: &RpcClient, + payer: &dyn Signer, + mint_authority: &dyn Signer, +) -> Result> { + let mut signers = vec![payer]; + if payer.pubkey() != mint_authority.pubkey() { + signers.push(mint_authority); + } + + let blockhash = rpc_client + .get_latest_blockhash() + .await + .map_err(|err| format!("error: unable to get latest blockhash: {err}"))?; + + transaction + .try_sign(&signers, blockhash) + .map_err(|err| format!("error: failed to sign transaction: {err}"))?; + + rpc_client + .send_and_confirm_transaction_with_spinner(transaction) + .await + .map_err(|err| format!("error: send transaction: {err}").into()) +} + struct Config { commitment_config: CommitmentConfig, default_signer: Box, @@ -72,59 +141,82 @@ async fn process_create_extra_account_metas( payer: &dyn Signer, ) -> Result> { let extra_account_metas_address = get_extra_account_metas_address(token, program_id); - let extra_account_metas = transfer_hook_accounts - .into_iter() - .map(|v| v.into()) - .collect::>(); - let length = extra_account_metas.len(); - let account_size = ExtraAccountMetaList::size_of(length)?; - let required_lamports = rpc_client - .get_minimum_balance_for_rent_exemption(account_size) - .await - .map_err(|err| format!("error: unable to fetch rent-exemption: {err}"))?; + // Check if the extra meta account has already been initialized let extra_account_metas_account = rpc_client.get_account(&extra_account_metas_address).await; if let Ok(account) = &extra_account_metas_account { if account.owner != system_program::id() { return Err(format!("error: extra account metas for mint {token} and program {program_id} already exists").into()); } } - let current_lamports = extra_account_metas_account.map(|a| a.lamports).unwrap_or(0); - let transfer_lamports = required_lamports.saturating_sub(current_lamports); - let mut ixs = vec![]; - if transfer_lamports > 0 { - ixs.push(system_instruction::transfer( - &payer.pubkey(), - &extra_account_metas_address, - transfer_lamports, - )); - } - ixs.push(initialize_extra_account_meta_list( + let extra_account_metas = transfer_hook_accounts + .into_iter() + .map(|v| v.into()) + .collect::>(); + + let instruction = initialize_extra_account_meta_list( program_id, &extra_account_metas_address, token, &mint_authority.pubkey(), &extra_account_metas, - )); + ); - let mut transaction = Transaction::new_with_payer(&ixs, Some(&payer.pubkey())); - let blockhash = rpc_client - .get_latest_blockhash() - .await - .map_err(|err| format!("error: unable to get latest blockhash: {err}"))?; - let mut signers = vec![payer]; - if payer.pubkey() != mint_authority.pubkey() { - signers.push(mint_authority); + let mut transaction = build_transaction_with_rent_transfer( + rpc_client, + payer, + &extra_account_metas_address, + &extra_account_metas, + instruction, + ) + .await?; + + sign_and_send_transaction(&mut transaction, rpc_client, payer, mint_authority).await +} + +async fn process_update_extra_account_metas( + rpc_client: &RpcClient, + program_id: &Pubkey, + token: &Pubkey, + transfer_hook_accounts: Vec, + mint_authority: &dyn Signer, + payer: &dyn Signer, +) -> Result> { + let extra_account_metas_address = get_extra_account_metas_address(token, program_id); + + // Check if the extra meta account has been initialized first + let extra_account_metas_account = rpc_client.get_account(&extra_account_metas_address).await; + if extra_account_metas_account.is_err() { + return Err(format!( + "error: extra account metas for mint {token} and program {program_id} does not exist" + ) + .into()); } - transaction - .try_sign(&signers, blockhash) - .map_err(|err| format!("error: failed to sign transaction: {err}"))?; - rpc_client - .send_and_confirm_transaction_with_spinner(&transaction) - .await - .map_err(|err| format!("error: send transaction: {err}").into()) + let extra_account_metas = transfer_hook_accounts + .into_iter() + .map(|v| v.into()) + .collect::>(); + + let instruction = update_extra_account_meta_list( + program_id, + &extra_account_metas_address, + token, + &mint_authority.pubkey(), + &extra_account_metas, + ); + + let mut transaction = build_transaction_with_rent_transfer( + rpc_client, + payer, + &extra_account_metas_address, + &extra_account_metas, + instruction, + ) + .await?; + + sign_and_send_transaction(&mut transaction, rpc_client, payer, mint_authority).await } #[tokio::main] @@ -217,6 +309,49 @@ async fn main() -> Result<(), Box> { .global(true) .help("Filepath or URL to mint-authority keypair [default: client keypair]"), ) + ) + .subcommand( + Command::new("update-extra-metas") + .about("Update the extra account metas account for a transfer hook program") + .arg( + Arg::with_name("program_id") + .validator(clap_is_valid_pubkey) + .value_name("TRANSFER_HOOK_PROGRAM") + .takes_value(true) + .index(1) + .required(true) + .help("The transfer hook program id"), + ) + .arg( + Arg::with_name("token") + .validator(clap_is_valid_pubkey) + .value_name("TOKEN_MINT_ADDRESS") + .takes_value(true) + .index(2) + .required(true) + .help("The token mint address for the transfer hook"), + ) + .arg( + Arg::with_name("transfer_hook_account") + .value_parser(parse_transfer_hook_account) + .value_name("PUBKEY:ROLE") + .takes_value(true) + .multiple(true) + .min_values(0) + .index(3) + .help("Additional pubkey(s) required for a transfer hook and their \ + role, in the format \":\". The role must be \ + \"readonly\", \"writable\". \"readonly-signer\", or \"writable-signer\".") + ) + .arg( + Arg::new("mint_authority") + .long("mint-authority") + .value_name("KEYPAIR") + .validator(|s| is_valid_signer(s)) + .takes_value(true) + .global(true) + .help("Filepath or URL to mint-authority keypair [default: client keypair]"), + ) ).get_matches(); let (command, matches) = app_matches.subcommand().unwrap(); @@ -303,6 +438,45 @@ async fn main() -> Result<(), Box> { }); println!("Signature: {signature}"); } + ("update-extra-metas", arg_matches) => { + let program_id = pubkey_of_signer(arg_matches, "program_id", &mut wallet_manager) + .unwrap() + .unwrap(); + let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager) + .unwrap() + .unwrap(); + let transfer_hook_accounts = arg_matches + .get_many::("transfer_hook_account") + .unwrap_or_default() + .cloned() + .collect(); + let mint_authority = DefaultSigner::new( + "mint_authority", + matches + .value_of("mint_authority") + .map(|s| s.to_string()) + .unwrap_or_else(|| cli_config.keypair_path.clone()), + ) + .signer_from_path(matches, &mut wallet_manager) + .unwrap_or_else(|err| { + eprintln!("error: {err}"); + exit(1); + }); + let signature = process_update_extra_account_metas( + &rpc_client, + &program_id, + &token, + transfer_hook_accounts, + mint_authority.as_ref(), + config.default_signer.as_ref(), + ) + .await + .unwrap_or_else(|err| { + eprintln!("error: send transaction: {err}"); + exit(1); + }); + println!("Signature: {signature}"); + } _ => unreachable!(), }; diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 5784f1b..39639d5 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -32,8 +32,9 @@ pub enum TransferHookInstruction { /// Amount of tokens to transfer amount: u64, }, - /// Initializes the extra account metas on an account, writing into - /// the first open TLV space. + + /// Initializes the extra account metas on an account, writing into the + /// first open TLV space. /// /// Accounts expected by this instruction: /// @@ -45,6 +46,19 @@ pub enum TransferHookInstruction { /// List of `ExtraAccountMeta`s to write into the account extra_account_metas: Vec, }, + /// Updates the extra account metas on an account by overwriting the + /// existing list. + /// + /// Accounts expected by this instruction: + /// + /// 0. `[w]` Account with extra account metas + /// 1. `[]` Mint + /// 2. `[s]` Mint authority + UpdateExtraAccountMetaList { + /// The new list of `ExtraAccountMetas` to overwrite the existing entry + /// in the account. + extra_account_metas: Vec, + }, } /// TLV instruction type only used to define the discriminator. The actual data /// is entirely managed by `ExtraAccountMetaList`, and it is the only data @@ -59,6 +73,12 @@ pub struct ExecuteInstruction; #[discriminator_hash_input("spl-transfer-hook-interface:initialize-extra-account-metas")] pub struct InitializeExtraAccountMetaListInstruction; +/// TLV instruction type used to update extra account metas +/// for the transfer hook +#[derive(SplDiscriminate)] +#[discriminator_hash_input("spl-transfer-hook-interface:update-extra-account-metas")] +pub struct UpdateExtraAccountMetaListInstruction; + impl TransferHookInstruction { /// Unpacks a byte buffer into a /// [TransferHookInstruction](enum.TransferHookInstruction.html). @@ -83,6 +103,13 @@ impl TransferHookInstruction { extra_account_metas, } } + UpdateExtraAccountMetaListInstruction::SPL_DISCRIMINATOR_SLICE => { + let pod_slice = PodSlice::::unpack(rest)?; + let extra_account_metas = pod_slice.data().to_vec(); + Self::UpdateExtraAccountMetaList { + extra_account_metas, + } + } _ => return Err(ProgramError::InvalidInstructionData), }) } @@ -105,6 +132,15 @@ impl TransferHookInstruction { buf.extend_from_slice(&(extra_account_metas.len() as u32).to_le_bytes()); buf.extend_from_slice(pod_slice_to_bytes(extra_account_metas)); } + Self::UpdateExtraAccountMetaList { + extra_account_metas, + } => { + buf.extend_from_slice( + UpdateExtraAccountMetaListInstruction::SPL_DISCRIMINATOR_SLICE, + ); + buf.extend_from_slice(&(extra_account_metas.len() as u32).to_le_bytes()); + buf.extend_from_slice(pod_slice_to_bytes(extra_account_metas)); + } }; buf } @@ -189,6 +225,32 @@ pub fn initialize_extra_account_meta_list( } } +/// Creates a `UpdateExtraAccountMetaList` instruction. +pub fn update_extra_account_meta_list( + program_id: &Pubkey, + extra_account_metas_pubkey: &Pubkey, + mint_pubkey: &Pubkey, + authority_pubkey: &Pubkey, + extra_account_metas: &[ExtraAccountMeta], +) -> Instruction { + let data = TransferHookInstruction::UpdateExtraAccountMetaList { + extra_account_metas: extra_account_metas.to_vec(), + } + .pack(); + + let accounts = vec![ + AccountMeta::new(*extra_account_metas_pubkey, false), + AccountMeta::new_readonly(*mint_pubkey, false), + AccountMeta::new_readonly(*authority_pubkey, true), + ]; + + Instruction { + program_id: *program_id, + accounts, + data, + } +} + #[cfg(test)] mod test { use {super::*, crate::NAMESPACE, solana_program::hash, spl_pod::bytemuck::pod_from_bytes}; diff --git a/program/src/processor.rs b/program/src/processor.rs index 16b2d1f..e398b20 100644 --- a/program/src/processor.rs +++ b/program/src/processor.rs @@ -134,6 +134,68 @@ pub fn process_initialize_extra_account_meta_list( Ok(()) } +/// Processes a +/// [UpdateExtraAccountMetaList](enum.TransferHookInstruction.html) +/// instruction. +pub fn process_update_extra_account_meta_list( + program_id: &Pubkey, + accounts: &[AccountInfo], + extra_account_metas: &[ExtraAccountMeta], +) -> ProgramResult { + let account_info_iter = &mut accounts.iter(); + + let extra_account_metas_info = next_account_info(account_info_iter)?; + let mint_info = next_account_info(account_info_iter)?; + let authority_info = next_account_info(account_info_iter)?; + + // check that the mint authority is valid without fully deserializing + let mint_data = mint_info.try_borrow_data()?; + let mint = StateWithExtensions::::unpack(&mint_data)?; + let mint_authority = mint + .base + .mint_authority + .ok_or(TransferHookError::MintHasNoMintAuthority)?; + + // Check signers + if !authority_info.is_signer { + return Err(ProgramError::MissingRequiredSignature); + } + if *authority_info.key != mint_authority { + return Err(TransferHookError::IncorrectMintAuthority.into()); + } + + // Check validation account + let expected_validation_address = get_extra_account_metas_address(mint_info.key, program_id); + if expected_validation_address != *extra_account_metas_info.key { + return Err(ProgramError::InvalidSeeds); + } + + // Check if the extra metas have been initialized + let min_account_size = ExtraAccountMetaList::size_of(0)?; + let original_account_size = extra_account_metas_info.data_len(); + if program_id != extra_account_metas_info.owner || original_account_size < min_account_size { + return Err(ProgramError::UninitializedAccount); + } + + // If the new extra_account_metas length is different, resize the account and + // update + let length = extra_account_metas.len(); + let account_size = ExtraAccountMetaList::size_of(length)?; + if account_size >= original_account_size { + extra_account_metas_info.realloc(account_size, false)?; + let mut data = extra_account_metas_info.try_borrow_mut_data()?; + ExtraAccountMetaList::update::(&mut data, extra_account_metas)?; + } else { + { + let mut data = extra_account_metas_info.try_borrow_mut_data()?; + ExtraAccountMetaList::update::(&mut data, extra_account_metas)?; + } + extra_account_metas_info.realloc(account_size, false)?; + } + + Ok(()) +} + /// Processes an [Instruction](enum.Instruction.html). pub fn process(program_id: &Pubkey, accounts: &[AccountInfo], input: &[u8]) -> ProgramResult { let instruction = TransferHookInstruction::unpack(input)?; @@ -149,5 +211,11 @@ pub fn process(program_id: &Pubkey, accounts: &[AccountInfo], input: &[u8]) -> P msg!("Instruction: InitializeExtraAccountMetaList"); process_initialize_extra_account_meta_list(program_id, accounts, &extra_account_metas) } + TransferHookInstruction::UpdateExtraAccountMetaList { + extra_account_metas, + } => { + msg!("Instruction: UpdateExtraAccountMetaList"); + process_update_extra_account_meta_list(program_id, accounts, &extra_account_metas) + } } } diff --git a/program/tests/functional.rs b/program/tests/functional.rs index 989b6f9..4e078c1 100644 --- a/program/tests/functional.rs +++ b/program/tests/functional.rs @@ -28,7 +28,10 @@ use { spl_transfer_hook_interface::{ error::TransferHookError, get_extra_account_metas_address, - instruction::{execute_with_extra_account_metas, initialize_extra_account_meta_list}, + instruction::{ + execute_with_extra_account_metas, initialize_extra_account_meta_list, + update_extra_account_meta_list, + }, onchain, }, }; @@ -747,3 +750,649 @@ async fn fail_without_transferring_flag() { ) ); } + +#[tokio::test] +async fn success_on_chain_invoke_with_updated_extra_account_metas() { + let hook_program_id = Pubkey::new_unique(); + let mut program_test = setup(&hook_program_id); + let program_id = Pubkey::new_unique(); + program_test.add_program( + "test_cpi_program", + program_id, + processor!(process_instruction), + ); + + let token_program_id = spl_token_2022::id(); + let wallet = Keypair::new(); + let mint_address = Pubkey::new_unique(); + let mint_authority = Keypair::new(); + let mint_authority_pubkey = mint_authority.pubkey(); + let source = Pubkey::new_unique(); + let destination = Pubkey::new_unique(); + let decimals = 2; + let amount = 0u64; + + setup_token_accounts( + &mut program_test, + &token_program_id, + &mint_address, + &mint_authority_pubkey, + &source, + &destination, + &wallet.pubkey(), + decimals, + true, + ); + + let extra_account_metas_address = + get_extra_account_metas_address(&mint_address, &hook_program_id); + let writable_pubkey = Pubkey::new_unique(); + + // Create an initial account metas list + let init_extra_account_metas = [ + ExtraAccountMeta::new_with_pubkey(&sysvar::instructions::id(), false, false).unwrap(), + ExtraAccountMeta::new_with_pubkey(&mint_authority_pubkey, true, false).unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::Literal { + bytes: b"init-seed-prefix".to_vec(), + }, + Seed::AccountKey { index: 0 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::InstructionData { + index: 8, // After instruction discriminator + length: 8, // `u64` (amount) + }, + Seed::AccountKey { index: 2 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_pubkey(&writable_pubkey, false, true).unwrap(), + ]; + + let mut context = program_test.start_with_context().await; + let rent = context.banks_client.get_rent().await.unwrap(); + let rent_lamports = rent + .minimum_balance(ExtraAccountMetaList::size_of(init_extra_account_metas.len()).unwrap()); + let init_transaction = Transaction::new_signed_with_payer( + &[ + system_instruction::transfer( + &context.payer.pubkey(), + &extra_account_metas_address, + rent_lamports, + ), + initialize_extra_account_meta_list( + &hook_program_id, + &extra_account_metas_address, + &mint_address, + &mint_authority_pubkey, + &init_extra_account_metas, + ), + ], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + + context + .banks_client + .process_transaction(init_transaction) + .await + .unwrap(); + + // Create an updated account metas list + let updated_extra_account_metas = [ + ExtraAccountMeta::new_with_pubkey(&sysvar::instructions::id(), false, false).unwrap(), + ExtraAccountMeta::new_with_pubkey(&mint_authority_pubkey, true, false).unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::Literal { + bytes: b"updated-seed-prefix".to_vec(), + }, + Seed::AccountKey { index: 0 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::InstructionData { + index: 8, // After instruction discriminator + length: 8, // `u64` (amount) + }, + Seed::AccountKey { index: 2 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_pubkey(&writable_pubkey, false, true).unwrap(), + ]; + + let rent = context.banks_client.get_rent().await.unwrap(); + let rent_lamports = rent + .minimum_balance(ExtraAccountMetaList::size_of(updated_extra_account_metas.len()).unwrap()); + let update_transaction = Transaction::new_signed_with_payer( + &[ + system_instruction::transfer( + &context.payer.pubkey(), + &extra_account_metas_address, + rent_lamports, + ), + update_extra_account_meta_list( + &hook_program_id, + &extra_account_metas_address, + &mint_address, + &mint_authority_pubkey, + &updated_extra_account_metas, + ), + ], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + + context + .banks_client + .process_transaction(update_transaction) + .await + .unwrap(); + + let updated_extra_pda_1 = Pubkey::find_program_address( + &[ + b"updated-seed-prefix", // Literal prefix + source.as_ref(), // Account at index 0 + ], + &hook_program_id, + ) + .0; + let extra_pda_2 = Pubkey::find_program_address( + &[ + &amount.to_le_bytes(), // Instruction data bytes 8 to 16 + destination.as_ref(), // Account at index 2 + ], + &hook_program_id, + ) + .0; + + let test_updated_extra_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, true), + AccountMeta::new(updated_extra_pda_1, false), + AccountMeta::new(extra_pda_2, false), + AccountMeta::new(writable_pubkey, false), + ]; + + // Use updated account metas list + let mut test_instruction = execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &test_updated_extra_account_metas, + amount, + ); + test_instruction + .accounts + .insert(0, AccountMeta::new_readonly(hook_program_id, false)); + let transaction = Transaction::new_signed_with_payer( + &[test_instruction], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + + context + .banks_client + .process_transaction(transaction) + .await + .unwrap(); +} + +#[tokio::test] +async fn success_execute_with_updated_extra_account_metas() { + let program_id = Pubkey::new_unique(); + let mut program_test = setup(&program_id); + + let token_program_id = spl_token_2022::id(); + let wallet = Keypair::new(); + let mint_address = Pubkey::new_unique(); + let mint_authority = Keypair::new(); + let mint_authority_pubkey = mint_authority.pubkey(); + let source = Pubkey::new_unique(); + let destination = Pubkey::new_unique(); + let decimals = 2; + let amount = 0u64; + + setup_token_accounts( + &mut program_test, + &token_program_id, + &mint_address, + &mint_authority_pubkey, + &source, + &destination, + &wallet.pubkey(), + decimals, + true, + ); + + let extra_account_metas_address = get_extra_account_metas_address(&mint_address, &program_id); + + let writable_pubkey = Pubkey::new_unique(); + + let init_extra_account_metas = [ + ExtraAccountMeta::new_with_pubkey(&sysvar::instructions::id(), false, false).unwrap(), + ExtraAccountMeta::new_with_pubkey(&mint_authority_pubkey, true, false).unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::Literal { + bytes: b"seed-prefix".to_vec(), + }, + Seed::AccountKey { index: 0 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::InstructionData { + index: 8, // After instruction discriminator + length: 8, // `u64` (amount) + }, + Seed::AccountKey { index: 2 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_pubkey(&writable_pubkey, false, true).unwrap(), + ]; + + let extra_pda_1 = Pubkey::find_program_address( + &[ + b"seed-prefix", // Literal prefix + source.as_ref(), // Account at index 0 + ], + &program_id, + ) + .0; + + let extra_pda_2 = Pubkey::find_program_address( + &[ + &amount.to_le_bytes(), // Instruction data bytes 8 to 16 + destination.as_ref(), // Account at index 2 + ], + &program_id, + ) + .0; + + let init_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, true), + AccountMeta::new(extra_pda_1, false), + AccountMeta::new(extra_pda_2, false), + AccountMeta::new(writable_pubkey, false), + ]; + + let mut context = program_test.start_with_context().await; + let rent = context.banks_client.get_rent().await.unwrap(); + let rent_lamports = rent + .minimum_balance(ExtraAccountMetaList::size_of(init_extra_account_metas.len()).unwrap()); + let transaction = Transaction::new_signed_with_payer( + &[ + system_instruction::transfer( + &context.payer.pubkey(), + &extra_account_metas_address, + rent_lamports, + ), + initialize_extra_account_meta_list( + &program_id, + &extra_account_metas_address, + &mint_address, + &mint_authority_pubkey, + &init_extra_account_metas, + ), + ], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + + context + .banks_client + .process_transaction(transaction) + .await + .unwrap(); + + let updated_amount = 1u64; + let updated_writable_pubkey = Pubkey::new_unique(); + + // Create updated extra account metas + let updated_extra_account_metas = [ + ExtraAccountMeta::new_with_pubkey(&sysvar::instructions::id(), false, false).unwrap(), + ExtraAccountMeta::new_with_pubkey(&mint_authority_pubkey, true, false).unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::Literal { + bytes: b"updated-seed-prefix".to_vec(), + }, + Seed::AccountKey { index: 0 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::InstructionData { + index: 8, // After instruction discriminator + length: 8, // `u64` (amount) + }, + Seed::AccountKey { index: 2 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_pubkey(&updated_writable_pubkey, false, true).unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::Literal { + bytes: b"new-seed-prefix".to_vec(), + }, + Seed::AccountKey { index: 0 }, + ], + false, + true, + ) + .unwrap(), + ]; + + let updated_extra_pda_1 = Pubkey::find_program_address( + &[ + b"updated-seed-prefix", // Literal prefix + source.as_ref(), // Account at index 0 + ], + &program_id, + ) + .0; + + let updated_extra_pda_2 = Pubkey::find_program_address( + &[ + &updated_amount.to_le_bytes(), // Instruction data bytes 8 to 16 + destination.as_ref(), // Account at index 2 + ], + &program_id, + ) + .0; + + // add another PDA + let new_extra_pda = Pubkey::find_program_address( + &[ + b"new-seed-prefix", // Literal prefix + source.as_ref(), // Account at index 0 + ], + &program_id, + ) + .0; + + let updated_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, true), + AccountMeta::new(updated_extra_pda_1, false), + AccountMeta::new(updated_extra_pda_2, false), + AccountMeta::new(updated_writable_pubkey, false), + AccountMeta::new(new_extra_pda, false), + ]; + + let update_transaction = Transaction::new_signed_with_payer( + &[ + system_instruction::transfer( + &context.payer.pubkey(), + &extra_account_metas_address, + rent_lamports, + ), + update_extra_account_meta_list( + &program_id, + &extra_account_metas_address, + &mint_address, + &mint_authority_pubkey, + &updated_extra_account_metas, + ), + ], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + + context + .banks_client + .process_transaction(update_transaction) + .await + .unwrap(); + + // fail with initial account metas list + { + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &init_account_metas, + updated_amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError( + 0, + InstructionError::Custom(AccountResolutionError::IncorrectAccount as u32), + ) + ); + } + + // fail with missing account + { + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &updated_account_metas[..2], + updated_amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError( + 0, + InstructionError::Custom(AccountResolutionError::IncorrectAccount as u32), + ) + ); + } + + // fail with wrong account + { + let extra_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, true), + AccountMeta::new(updated_extra_pda_1, false), + AccountMeta::new(updated_extra_pda_2, false), + AccountMeta::new(Pubkey::new_unique(), false), + ]; + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &extra_account_metas, + updated_amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError( + 0, + InstructionError::Custom(AccountResolutionError::IncorrectAccount as u32), + ) + ); + } + + // fail with wrong PDA + let wrong_pda_2 = Pubkey::find_program_address( + &[ + &99u64.to_le_bytes(), // Wrong data + destination.as_ref(), + ], + &program_id, + ) + .0; + { + let extra_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, true), + AccountMeta::new(updated_extra_pda_1, false), + AccountMeta::new(wrong_pda_2, false), + AccountMeta::new(writable_pubkey, false), + ]; + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &extra_account_metas, + updated_amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError( + 0, + InstructionError::Custom(AccountResolutionError::IncorrectAccount as u32), + ) + ); + } + + // fail with not signer + { + let extra_account_metas = [ + AccountMeta::new_readonly(sysvar::instructions::id(), false), + AccountMeta::new_readonly(mint_authority_pubkey, false), + AccountMeta::new(updated_extra_pda_1, false), + AccountMeta::new(updated_extra_pda_2, false), + AccountMeta::new(writable_pubkey, false), + ]; + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &extra_account_metas, + updated_amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError( + 0, + InstructionError::Custom(AccountResolutionError::IncorrectAccount as u32), + ) + ); + } + + // success with correct params + { + let transaction = Transaction::new_signed_with_payer( + &[execute_with_extra_account_metas( + &program_id, + &source, + &mint_address, + &destination, + &wallet.pubkey(), + &extra_account_metas_address, + &updated_account_metas, + updated_amount, + )], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + context + .banks_client + .process_transaction(transaction) + .await + .unwrap(); + } +} From 782a1cd39190eaa783f123ddda8f0ae8603cf2f6 Mon Sep 17 00:00:00 2001 From: Jon Cinque Date: Fri, 8 Dec 2023 12:49:09 +0100 Subject: [PATCH 008/154] token-2022: Bump to 1.0.0 for prod release (#5954) * token-2022: Bump to 1.0.0 for first prod release * Update security.txt --- clients/cli/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index b36b2c0..289ee7f 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -25,7 +25,7 @@ tokio = { version = "1", features = ["full"] } [dev-dependencies] solana-test-validator = "=1.17.6" -spl-token-2022 = { version = "0.9", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.8", path = "../../client" } [[bin]] diff --git a/program/Cargo.toml b/program/Cargo.toml index 9eed486..ff88c70 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -15,7 +15,7 @@ test-sbf = [] arrayref = "0.3.7" solana-program = "1.17.6" spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } -spl-token-2022 = { version = "0.9", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.3" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } From 73dae41760ccb040f893c06001929752b01820cc Mon Sep 17 00:00:00 2001 From: Joe C Date: Mon, 11 Dec 2023 05:53:12 -0600 Subject: [PATCH 009/154] transfer hook: bump (#5970) --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 289ee7f..be8155f 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -17,7 +17,7 @@ solana-client = "=1.17.6" solana-logger = "=1.17.6" solana-remote-wallet = "=1.17.6" solana-sdk = "=1.17.6" -spl-transfer-hook-interface = { version = "0.3", path = "../interface" } +spl-transfer-hook-interface = { version = "0.4", path = "../interface" } spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } strum = "0.25" strum_macros = "0.25" diff --git a/interface/Cargo.toml b/interface/Cargo.toml index c0db5b1..9c064f3 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.3.0" +version = "0.4.0" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" diff --git a/program/Cargo.toml b/program/Cargo.toml index ff88c70..0d2e25a 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-example" -version = "0.3.0" +version = "0.4.0" description = "Solana Program Library Transfer Hook Example Program" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" @@ -16,7 +16,7 @@ arrayref = "0.3.7" solana-program = "1.17.6" spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.3" , path = "../interface" } +spl-transfer-hook-interface = { version = "0.4" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] From f72ba69743aa1b40a4c45f996b15977562cf27a2 Mon Sep 17 00:00:00 2001 From: Joe C Date: Mon, 11 Dec 2023 09:44:04 -0600 Subject: [PATCH 010/154] tlv account resolution: bump (#5985) --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index be8155f..a6c7743 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -18,7 +18,7 @@ solana-logger = "=1.17.6" solana-remote-wallet = "=1.17.6" solana-sdk = "=1.17.6" spl-transfer-hook-interface = { version = "0.4", path = "../interface" } -spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } strum = "0.25" strum_macros = "0.25" tokio = { version = "1", features = ["full"] } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 9c064f3..fc3f892 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -13,7 +13,7 @@ bytemuck = { version = "1.14.0", features = ["derive"] } solana-program = "1.17.6" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } -spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } spl-pod = { version = "0.1", path = "../../../libraries/pod" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 0d2e25a..6fd6523 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -14,7 +14,7 @@ test-sbf = [] [dependencies] arrayref = "0.3.7" solana-program = "1.17.6" -spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.4" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } From cc1ab437f2097c1ebf3b9c04cde510881686da0c Mon Sep 17 00:00:00 2001 From: Joe C Date: Mon, 11 Dec 2023 11:31:30 -0600 Subject: [PATCH 011/154] transfer hook: bump interface to 0.4.1 (#5986) --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index fc3f892..0db28e9 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.4.0" +version = "0.4.1" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" From a1054d81f33321fdacff1dda448ebf1d7e8a6946 Mon Sep 17 00:00:00 2001 From: Joe C Date: Mon, 11 Dec 2023 12:11:50 -0600 Subject: [PATCH 012/154] transfer hook cli: bump (#5984) --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index a6c7743..8af0450 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://spl.solana.com/token" license = "Apache-2.0" name = "spl-transfer-hook-cli" repository = "https://github.com/solana-labs/solana-program-library" -version = "0.1.0" +version = "0.2.0" [dependencies] clap = { version = "3", features = ["cargo"] } From cc9284e11e315466ec7f27c873a4440765782145 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 03:09:24 +0100 Subject: [PATCH 013/154] build(deps): bump futures-util from 0.3.29 to 0.3.30 (#6024) Bumps [futures-util](https://github.com/rust-lang/futures-rs) from 0.3.29 to 0.3.30. - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.29...0.3.30) --- updated-dependencies: - dependency-name: futures-util dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 8af0450..3b245d2 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -10,7 +10,7 @@ version = "0.2.0" [dependencies] clap = { version = "3", features = ["cargo"] } -futures-util = "0.3.19" +futures-util = "0.3.30" solana-clap-v3-utils = "=1.17.6" solana-cli-config = "=1.17.6" solana-client = "=1.17.6" From dd794093c91c8754c63626de40d2ee37c2e41512 Mon Sep 17 00:00:00 2001 From: Joe C Date: Fri, 5 Jan 2024 12:43:31 -0600 Subject: [PATCH 014/154] transfer hook cli: add support for PDAs as extra metas (#5997) * transfer hook cli: refactor account meta parsing into new module * transfer hook cli: refactor account meta parsing to deal directly with `ExtraAccountMeta`s * tlv account resolution: add serde-traits to seeds * transfer hook cli: add transfer hook config file support * transfer hook cli: help docs * address some nits * refactor out raw discriminator use * transfer hook cli: refactor transfer hook accounts with better use of serde * remove snake case * restrict role configs to `Role` object * update documentation * drop kebab case --- clients/cli/Cargo.toml | 5 +- clients/cli/src/main.rs | 167 +++++++++++++-------- clients/cli/src/meta.rs | 322 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 433 insertions(+), 61 deletions(-) create mode 100644 clients/cli/src/meta.rs diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 3b245d2..4d4ed93 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -18,10 +18,13 @@ solana-logger = "=1.17.6" solana-remote-wallet = "=1.17.6" solana-sdk = "=1.17.6" spl-transfer-hook-interface = { version = "0.4", path = "../interface" } -spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.25" strum_macros = "0.25" tokio = { version = "1", features = ["full"] } +serde = { version = "1.0.193", features = ["derive"] } +serde_json = "1.0.108" +serde_yaml = "0.9.27" [dev-dependencies] solana-test-validator = "=1.17.6" diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index 06b0788..010bf71 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -1,4 +1,7 @@ +pub mod meta; + use { + crate::meta::parse_transfer_hook_account_arg, clap::{crate_description, crate_name, crate_version, Arg, Command}, solana_clap_v3_utils::{ input_parsers::{parse_url_or_moniker, pubkey_of_signer}, @@ -9,7 +12,7 @@ use { solana_remote_wallet::remote_wallet::RemoteWalletManager, solana_sdk::{ commitment_config::CommitmentConfig, - instruction::{AccountMeta, Instruction}, + instruction::Instruction, pubkey::Pubkey, signature::{Signature, Signer}, system_instruction, system_program, @@ -20,39 +23,9 @@ use { get_extra_account_metas_address, instruction::{initialize_extra_account_meta_list, update_extra_account_meta_list}, }, - std::{fmt, process::exit, rc::Rc, str::FromStr}, - strum_macros::{EnumString, IntoStaticStr}, + std::{process::exit, rc::Rc}, }; -#[derive(Debug, Clone, Copy, PartialEq, EnumString, IntoStaticStr)] -#[strum(serialize_all = "kebab-case")] -pub enum AccountMetaRole { - Readonly, - Writable, - ReadonlySigner, - WritableSigner, -} -impl fmt::Display for AccountMetaRole { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{:?}", self) - } -} -fn parse_transfer_hook_account(arg: &str) -> Result { - match arg.split(':').collect::>().as_slice() { - [address, role] => { - let address = Pubkey::from_str(address).map_err(|e| format!("{e}"))?; - let meta = match AccountMetaRole::from_str(role).map_err(|e| format!("{e}"))? { - AccountMetaRole::Readonly => AccountMeta::new_readonly(address, false), - AccountMetaRole::Writable => AccountMeta::new(address, false), - AccountMetaRole::ReadonlySigner => AccountMeta::new_readonly(address, true), - AccountMetaRole::WritableSigner => AccountMeta::new(address, true), - }; - Ok(meta) - } - _ => Err("Transfer hook account must be present as
:".to_string()), - } -} - fn clap_is_valid_pubkey(arg: &str) -> Result<(), String> { is_valid_pubkey(arg) } @@ -136,7 +109,7 @@ async fn process_create_extra_account_metas( rpc_client: &RpcClient, program_id: &Pubkey, token: &Pubkey, - transfer_hook_accounts: Vec, + extra_account_metas: Vec, mint_authority: &dyn Signer, payer: &dyn Signer, ) -> Result> { @@ -150,11 +123,6 @@ async fn process_create_extra_account_metas( } } - let extra_account_metas = transfer_hook_accounts - .into_iter() - .map(|v| v.into()) - .collect::>(); - let instruction = initialize_extra_account_meta_list( program_id, &extra_account_metas_address, @@ -179,7 +147,7 @@ async fn process_update_extra_account_metas( rpc_client: &RpcClient, program_id: &Pubkey, token: &Pubkey, - transfer_hook_accounts: Vec, + extra_account_metas: Vec, mint_authority: &dyn Signer, payer: &dyn Signer, ) -> Result> { @@ -194,11 +162,6 @@ async fn process_update_extra_account_metas( .into()); } - let extra_account_metas = transfer_hook_accounts - .into_iter() - .map(|v| v.into()) - .collect::>(); - let instruction = update_extra_account_meta_list( program_id, &extra_account_metas_address, @@ -289,16 +252,57 @@ async fn main() -> Result<(), Box> { .help("The token mint address for the transfer hook"), ) .arg( - Arg::with_name("transfer_hook_account") - .value_parser(parse_transfer_hook_account) - .value_name("PUBKEY:ROLE") + Arg::with_name("transfer_hook_accounts") + .value_parser(parse_transfer_hook_account_arg) + .value_name("TRANSFER_HOOK_ACCOUNTS") .takes_value(true) .multiple(true) .min_values(0) .index(3) - .help("Additional pubkey(s) required for a transfer hook and their \ - role, in the format \":\". The role must be \ - \"readonly\", \"writable\". \"readonly-signer\", or \"writable-signer\".") + .help(r#"Additional account(s) required for a transfer hook and their respective configurations, whether they are a fixed address or PDA. + +Additional accounts with known fixed addresses can be passed at the command line in the format ":". The role must be "readonly", "writable". "readonlySigner", or "writableSigner". + +Additional acounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: + +```json +{ + "extraMetas": [ + { + "pubkey": "39UhV...", + "role": "readonlySigner" + }, + { + "seeds": [ + { + "literal": { + "bytes": [1, 2, 3, 4, 5, 6] + } + }, + { + "accountKey": { + "index": 0 + } + } + ], + "role": "writable" + } + ] +} +``` + +```yaml +extraMetas: + - pubkey: "39UhV..." + role: "readonlySigner" + - seeds: + - literal: + bytes: [1, 2, 3, 4, 5, 6] + - accountKey: + index: 0 + role: "writable" +``` +"#) ) .arg( Arg::new("mint_authority") @@ -332,16 +336,57 @@ async fn main() -> Result<(), Box> { .help("The token mint address for the transfer hook"), ) .arg( - Arg::with_name("transfer_hook_account") - .value_parser(parse_transfer_hook_account) - .value_name("PUBKEY:ROLE") + Arg::with_name("transfer_hook_accounts") + .value_parser(parse_transfer_hook_account_arg) + .value_name("TRANSFER_HOOK_ACCOUNTS") .takes_value(true) .multiple(true) .min_values(0) .index(3) - .help("Additional pubkey(s) required for a transfer hook and their \ - role, in the format \":\". The role must be \ - \"readonly\", \"writable\". \"readonly-signer\", or \"writable-signer\".") + .help(r#"Additional account(s) required for a transfer hook and their respective configurations, whether they are a fixed address or PDA. + +Additional accounts with known fixed addresses can be passed at the command line in the format ":". The role must be "readonly", "writable". "readonlySigner", or "writableSigner". + +Additional acounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: + +```json +{ + "extraMetas": [ + { + "pubkey": "39UhV...", + "role": "readonlySigner" + }, + { + "seeds": [ + { + "literal": { + "bytes": [1, 2, 3, 4, 5, 6] + } + }, + { + "accountKey": { + "index": 0 + } + } + ], + "role": "writable" + } + ] +} +``` + +```yaml +extraMetas: + - pubkey: "39UhV..." + role: "readonlySigner" + - seeds: + - literal: + bytes: [1, 2, 3, 4, 5, 6] + - accountKey: + index: 0 + role: "writable" +``` +"#) ) .arg( Arg::new("mint_authority") @@ -407,8 +452,9 @@ async fn main() -> Result<(), Box> { .unwrap() .unwrap(); let transfer_hook_accounts = arg_matches - .get_many::("transfer_hook_account") + .get_many::>("transfer_hook_accounts") .unwrap_or_default() + .flatten() .cloned() .collect(); let mint_authority = DefaultSigner::new( @@ -446,8 +492,9 @@ async fn main() -> Result<(), Box> { .unwrap() .unwrap(); let transfer_hook_accounts = arg_matches - .get_many::("transfer_hook_account") + .get_many::>("transfer_hook_accounts") .unwrap_or_default() + .flatten() .cloned() .collect(); let mint_authority = DefaultSigner::new( @@ -487,7 +534,7 @@ async fn main() -> Result<(), Box> { mod test { use { super::*, - solana_sdk::{bpf_loader_upgradeable, signer::keypair::Keypair}, + solana_sdk::{bpf_loader_upgradeable, instruction::AccountMeta, signer::keypair::Keypair}, solana_test_validator::{TestValidator, TestValidatorGenesis, UpgradeableProgramInfo}, spl_token_client::{ client::{ @@ -563,7 +610,7 @@ mod test { &rpc_client, &program_id, token.get_address(), - accounts, + accounts.iter().map(|a| a.into()).collect(), &mint_authority, payer.as_ref(), ) diff --git a/clients/cli/src/meta.rs b/clients/cli/src/meta.rs new file mode 100644 index 0000000..b72dfa8 --- /dev/null +++ b/clients/cli/src/meta.rs @@ -0,0 +1,322 @@ +use { + serde::{Deserialize, Serialize}, + solana_sdk::pubkey::Pubkey, + spl_tlv_account_resolution::{account::ExtraAccountMeta, seeds::Seed}, + std::{path::Path, str::FromStr}, + strum_macros::{EnumString, IntoStaticStr}, +}; + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +struct Access { + is_signer: bool, + is_writable: bool, +} + +#[derive(Debug, Clone, Copy, PartialEq, EnumString, IntoStaticStr, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[strum(serialize_all = "camelCase")] +enum Role { + Readonly, + Writable, + ReadonlySigner, + WritableSigner, +} + +#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +enum AddressConfig { + Pubkey(String), + Seeds(Vec), +} + +#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +struct Config { + #[serde(flatten)] + address_config: AddressConfig, + role: Role, +} + +#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +struct ConfigFile { + extra_metas: Vec, +} + +impl From<&Role> for Access { + fn from(role: &Role) -> Self { + match role { + Role::Readonly => Access { + is_signer: false, + is_writable: false, + }, + Role::Writable => Access { + is_signer: false, + is_writable: true, + }, + Role::ReadonlySigner => Access { + is_signer: true, + is_writable: false, + }, + Role::WritableSigner => Access { + is_signer: true, + is_writable: true, + }, + } + } +} + +impl From<&Config> for ExtraAccountMeta { + fn from(config: &Config) -> Self { + let Access { + is_signer, + is_writable, + } = Access::from(&config.role); + match &config.address_config { + AddressConfig::Pubkey(pubkey_string) => ExtraAccountMeta::new_with_pubkey( + &Pubkey::from_str(pubkey_string).unwrap(), + is_signer, + is_writable, + ) + .unwrap(), + AddressConfig::Seeds(seeds) => { + ExtraAccountMeta::new_with_seeds(seeds, is_signer, is_writable).unwrap() + } + } + } +} + +type ParseFn = fn(&str) -> Result; + +fn get_parse_function(path: &Path) -> Result { + match path.extension().and_then(|s| s.to_str()) { + Some("json") => Ok(|v: &str| { + serde_json::from_str::(v).map_err(|e| format!("Unable to parse file: {e}")) + }), + Some("yaml") | Some("yml") => Ok(|v: &str| { + serde_yaml::from_str::(v).map_err(|e| format!("Unable to parse file: {e}")) + }), + _ => Err(format!( + "Unsupported file extension: {}. Only JSON and YAML files are supported", + path.display() + )), + } +} + +fn parse_config_file_arg(path_str: &str) -> Result, String> { + let path = Path::new(path_str); + let parse_fn = get_parse_function(path)?; + let file = + std::fs::read_to_string(path).map_err(|err| format!("Unable to read file: {err}"))?; + let parsed_config_file = parse_fn(&file)?; + Ok(parsed_config_file + .extra_metas + .iter() + .map(ExtraAccountMeta::from) + .collect()) +} + +fn parse_pubkey_role_arg(pubkey_string: &str, role: &str) -> Result, String> { + let pubkey = Pubkey::from_str(pubkey_string).map_err(|e| format!("{e}"))?; + let role = &Role::from_str(role).map_err(|e| format!("{e}"))?; + let Access { + is_signer, + is_writable, + } = role.into(); + ExtraAccountMeta::new_with_pubkey(&pubkey, is_signer, is_writable) + .map(|meta| vec![meta]) + .map_err(|e| format!("{e}")) +} + +pub fn parse_transfer_hook_account_arg(arg: &str) -> Result, String> { + match arg.split(':').collect::>().as_slice() { + [pubkey_str, role] => parse_pubkey_role_arg(pubkey_str, role), + _ => parse_config_file_arg(arg), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse_json() { + let config = r#"{ + "extraMetas": [ + { + "pubkey": "39UhVsxAmJwzPnoWhBSHsZ6nBDtdzt9D8rfDa8zGHrP6", + "role": "readonlySigner" + }, + { + "pubkey": "6WEvW9B9jTKc3EhP1ewGEJPrxw5d8vD9eMYCf2snNYsV", + "role": "readonly" + }, + { + "seeds": [ + { + "literal": { + "bytes": [1, 2, 3, 4, 5, 6] + } + }, + { + "instructionData": { + "index": 0, + "length": 8 + } + }, + { + "accountKey": { + "index": 0 + } + } + ], + "role": "writable" + }, + { + "seeds": [ + { + "accountData": { + "accountIndex": 1, + "dataIndex": 4, + "length": 4 + } + }, + { + "accountKey": { + "index": 1 + } + } + ], + "role": "readonly" + } + ] + }"#; + let parsed_config_file = serde_json::from_str::(config).unwrap(); + let parsed_extra_metas: Vec = parsed_config_file + .extra_metas + .iter() + .map(|config| config.into()) + .collect::>(); + let expected = vec![ + ExtraAccountMeta::new_with_pubkey( + &Pubkey::from_str("39UhVsxAmJwzPnoWhBSHsZ6nBDtdzt9D8rfDa8zGHrP6").unwrap(), + true, + false, + ) + .unwrap(), + ExtraAccountMeta::new_with_pubkey( + &Pubkey::from_str("6WEvW9B9jTKc3EhP1ewGEJPrxw5d8vD9eMYCf2snNYsV").unwrap(), + false, + false, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::Literal { + bytes: vec![1, 2, 3, 4, 5, 6], + }, + Seed::InstructionData { + index: 0, + length: 8, + }, + Seed::AccountKey { index: 0 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::AccountData { + account_index: 1, + data_index: 4, + length: 4, + }, + Seed::AccountKey { index: 1 }, + ], + false, + false, + ) + .unwrap(), + ]; + assert_eq!(parsed_extra_metas, expected); + } + + #[test] + fn test_parse_yaml() { + let config = r#" + extraMetas: + - pubkey: "39UhVsxAmJwzPnoWhBSHsZ6nBDtdzt9D8rfDa8zGHrP6" + role: "readonlySigner" + - pubkey: "6WEvW9B9jTKc3EhP1ewGEJPrxw5d8vD9eMYCf2snNYsV" + role: "readonly" + - seeds: + - literal: + bytes: [1, 2, 3, 4, 5, 6] + - instructionData: + index: 0 + length: 8 + - accountKey: + index: 0 + role: "writable" + - seeds: + - accountData: + accountIndex: 1 + dataIndex: 4 + length: 4 + - accountKey: + index: 1 + role: "readonly" + "#; + let parsed_config_file = serde_yaml::from_str::(config).unwrap(); + let parsed_extra_metas: Vec = parsed_config_file + .extra_metas + .iter() + .map(|config| config.into()) + .collect::>(); + let expected = vec![ + ExtraAccountMeta::new_with_pubkey( + &Pubkey::from_str("39UhVsxAmJwzPnoWhBSHsZ6nBDtdzt9D8rfDa8zGHrP6").unwrap(), + true, + false, + ) + .unwrap(), + ExtraAccountMeta::new_with_pubkey( + &Pubkey::from_str("6WEvW9B9jTKc3EhP1ewGEJPrxw5d8vD9eMYCf2snNYsV").unwrap(), + false, + false, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::Literal { + bytes: vec![1, 2, 3, 4, 5, 6], + }, + Seed::InstructionData { + index: 0, + length: 8, + }, + Seed::AccountKey { index: 0 }, + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::AccountData { + account_index: 1, + data_index: 4, + length: 4, + }, + Seed::AccountKey { index: 1 }, + ], + false, + false, + ) + .unwrap(), + ]; + assert_eq!(parsed_extra_metas, expected); + } +} From 1791c627f2ac8f3c784b6ff019f52b5422e2de63 Mon Sep 17 00:00:00 2001 From: Joe C Date: Fri, 5 Jan 2024 15:42:22 -0600 Subject: [PATCH 015/154] psuedo-bump transfer hook CLI to 0.1.0 (#6069) --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 4d4ed93..8d5029c 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://spl.solana.com/token" license = "Apache-2.0" name = "spl-transfer-hook-cli" repository = "https://github.com/solana-labs/solana-program-library" -version = "0.2.0" +version = "0.1.0" [dependencies] clap = { version = "3", features = ["cargo"] } From 1c03d240b130d2a5c1097dd184677b73c35f4f6f Mon Sep 17 00:00:00 2001 From: Joe C Date: Fri, 5 Jan 2024 16:28:46 -0600 Subject: [PATCH 016/154] tlv account resolution: bump to include serde (#6070) --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 8d5029c..5a78373 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -18,7 +18,7 @@ solana-logger = "=1.17.6" solana-remote-wallet = "=1.17.6" solana-sdk = "=1.17.6" spl-transfer-hook-interface = { version = "0.4", path = "../interface" } -spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } +spl-tlv-account-resolution = { version = "0.5.1" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.25" strum_macros = "0.25" tokio = { version = "1", features = ["full"] } From 3f22fef3e4db074e311ee50838e623f45c85e56c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 13:03:11 +0100 Subject: [PATCH 017/154] build(deps): bump serde_yaml from 0.9.27 to 0.9.30 (#6074) Bumps [serde_yaml](https://github.com/dtolnay/serde-yaml) from 0.9.27 to 0.9.30. - [Release notes](https://github.com/dtolnay/serde-yaml/releases) - [Commits](https://github.com/dtolnay/serde-yaml/compare/0.9.27...0.9.30) --- updated-dependencies: - dependency-name: serde_yaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 5a78373..0cb655e 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -24,7 +24,7 @@ strum_macros = "0.25" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.193", features = ["derive"] } serde_json = "1.0.108" -serde_yaml = "0.9.27" +serde_yaml = "0.9.30" [dev-dependencies] solana-test-validator = "=1.17.6" From a27f7db9ded8ed12248f2f81c557ecc3d22a6660 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 13:56:39 +0100 Subject: [PATCH 018/154] build(deps): bump serde from 1.0.194 to 1.0.195 (#6075) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.194 to 1.0.195. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.194...v1.0.195) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 0cb655e..2f71834 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-tlv-account-resolution = { version = "0.5.1" , path = "../../../libraries/tl strum = "0.25" strum_macros = "0.25" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.193", features = ["derive"] } +serde = { version = "1.0.195", features = ["derive"] } serde_json = "1.0.108" serde_yaml = "0.9.30" From 0a46e448b0d4e24fde8fc82f68572bf501fa6efb Mon Sep 17 00:00:00 2001 From: Joe C Date: Thu, 11 Jan 2024 15:15:25 -0600 Subject: [PATCH 019/154] transfer hook: add new offchain helper This PR adds a new offchain helper for adding the necessary account metas for an `ExecuteInstruction` to the SPL Transfer Hook interface, deprecating the old one. As described in #6064, the offchain helper in Token2022 was using the original offchain helper from the SPL Transfer Hook interface incorrectly when resolving extra account metas for a transfer. In order to provide a safer, more robust helper, this new function takes the instruction, fetch account data function, as well as the individual arguments for `instruction::execute(..)`. This will help to ensure Token2022 as well as anyone else using the helpers from the SPL Transfer Hook interface are properly resolving the necessary additional accounts. Note: Although deprecated, the original helper in the SPL Transfer Hook interface is not broken. It's just less safe to use than this new helper, since it can easily be misused. --- interface/Cargo.toml | 3 + interface/src/offchain.rs | 253 +++++++++++++++++++++++++++++++++++++- 2 files changed, 255 insertions(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 0db28e9..79d4a7d 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -20,5 +20,8 @@ spl-pod = { version = "0.1", path = "../../../libraries/pod" } [lib] crate-type = ["cdylib", "lib"] +[dev-dependencies] +tokio = { version = "1.35.1", features = ["full"] } + [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/interface/src/offchain.rs b/interface/src/offchain.rs index 60b7ea5..692f5dd 100644 --- a/interface/src/offchain.rs +++ b/interface/src/offchain.rs @@ -2,7 +2,11 @@ pub use spl_tlv_account_resolution::state::{AccountDataResult, AccountFetchError}; use { - crate::{get_extra_account_metas_address, instruction::ExecuteInstruction}, + crate::{ + error::TransferHookError, + get_extra_account_metas_address, + instruction::{execute, ExecuteInstruction}, + }, solana_program::{ instruction::{AccountMeta, Instruction}, program_error::ProgramError, @@ -35,6 +39,10 @@ use { /// &program_id, /// ).await?; /// ``` +#[deprecated( + since = "0.5.0", + note = "Please use `add_extra_account_metas_for_execute` instead" +)] pub async fn resolve_extra_account_metas( instruction: &mut Instruction, fetch_account_data_fn: F, @@ -68,3 +76,246 @@ where Ok(()) } + +/// Offchain helper to get all additional required account metas for an execute +/// instruction, based on a validation state account. +/// +/// The instruction being provided to this function must contain at least the +/// same account keys as the ones being provided, in order. Specifically: +/// 1. source +/// 2. mint +/// 3. destination +/// 4. authority +/// +/// The `program_id` should be the program ID of the program that the +/// created `ExecuteInstruction` is for. +/// +/// To be client-agnostic and to avoid pulling in the full solana-sdk, this +/// simply takes a function that will return its data as `Future>` for +/// the given address. Can be called in the following way: +/// +/// ```rust,ignore +/// add_extra_account_metas_for_execute( +/// &mut instruction, +/// &program_id, +/// &source, +/// &mint, +/// &destination, +/// &authority, +/// amount, +/// |address| self.client.get_account(&address).map_ok(|opt| opt.map(|acc| acc.data)), +/// ) +/// .await?; +/// ``` +#[allow(clippy::too_many_arguments)] +pub async fn add_extra_account_metas_for_execute( + instruction: &mut Instruction, + program_id: &Pubkey, + source_pubkey: &Pubkey, + mint_pubkey: &Pubkey, + destination_pubkey: &Pubkey, + authority_pubkey: &Pubkey, + amount: u64, + fetch_account_data_fn: F, +) -> Result<(), AccountFetchError> +where + F: Fn(Pubkey) -> Fut, + Fut: Future, +{ + let validate_state_pubkey = get_extra_account_metas_address(mint_pubkey, program_id); + let validate_state_data = fetch_account_data_fn(validate_state_pubkey) + .await? + .ok_or(ProgramError::InvalidAccountData)?; + + // Check to make sure the provided keys are in the instruction + if [ + source_pubkey, + mint_pubkey, + destination_pubkey, + authority_pubkey, + ] + .iter() + .any(|&key| !instruction.accounts.iter().any(|meta| meta.pubkey == *key)) + { + Err(TransferHookError::IncorrectAccount)?; + } + + let mut execute_instruction = execute( + program_id, + source_pubkey, + mint_pubkey, + destination_pubkey, + authority_pubkey, + &validate_state_pubkey, + amount, + ); + + ExtraAccountMetaList::add_to_instruction::( + &mut execute_instruction, + fetch_account_data_fn, + &validate_state_data, + ) + .await?; + + // Add only the extra accounts resolved from the validation state + instruction + .accounts + .extend_from_slice(&execute_instruction.accounts[5..]); + + // Add the program id and validation state account + instruction + .accounts + .push(AccountMeta::new_readonly(*program_id, false)); + instruction + .accounts + .push(AccountMeta::new_readonly(validate_state_pubkey, false)); + + Ok(()) +} + +#[cfg(test)] +mod tests { + use { + super::*, + spl_tlv_account_resolution::{account::ExtraAccountMeta, seeds::Seed}, + tokio, + }; + + const PROGRAM_ID: Pubkey = Pubkey::new_from_array([1u8; 32]); + const EXTRA_META_1: Pubkey = Pubkey::new_from_array([2u8; 32]); + const EXTRA_META_2: Pubkey = Pubkey::new_from_array([3u8; 32]); + + // Mock to return the validation state account data + async fn mock_fetch_account_data_fn(_address: Pubkey) -> AccountDataResult { + let extra_metas = vec![ + ExtraAccountMeta::new_with_pubkey(&EXTRA_META_1, true, false).unwrap(), + ExtraAccountMeta::new_with_pubkey(&EXTRA_META_2, true, false).unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::AccountKey { index: 0 }, // source + Seed::AccountKey { index: 2 }, // destination + Seed::AccountKey { index: 4 }, // validation state + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::InstructionData { + index: 8, + length: 8, + }, // amount + Seed::AccountKey { index: 2 }, // destination + Seed::AccountKey { index: 5 }, // extra meta 1 + Seed::AccountKey { index: 7 }, // extra meta 3 (PDA) + ], + false, + true, + ) + .unwrap(), + ]; + let account_size = ExtraAccountMetaList::size_of(extra_metas.len()).unwrap(); + let mut data = vec![0u8; account_size]; + ExtraAccountMetaList::init::(&mut data, &extra_metas)?; + Ok(Some(data)) + } + + #[tokio::test] + async fn test_add_extra_account_metas_for_execute() { + let source = Pubkey::new_unique(); + let mint = Pubkey::new_unique(); + let destination = Pubkey::new_unique(); + let authority = Pubkey::new_unique(); + let amount = 100u64; + + let validate_state_pubkey = get_extra_account_metas_address(&mint, &PROGRAM_ID); + let extra_meta_3_pubkey = Pubkey::find_program_address( + &[ + source.as_ref(), + destination.as_ref(), + validate_state_pubkey.as_ref(), + ], + &PROGRAM_ID, + ) + .0; + let extra_meta_4_pubkey = Pubkey::find_program_address( + &[ + amount.to_le_bytes().as_ref(), + destination.as_ref(), + EXTRA_META_1.as_ref(), + extra_meta_3_pubkey.as_ref(), + ], + &PROGRAM_ID, + ) + .0; + + // Fail missing key + let mut instruction = Instruction::new_with_bytes( + PROGRAM_ID, + &[], + vec![ + // source missing + AccountMeta::new_readonly(mint, false), + AccountMeta::new(destination, false), + AccountMeta::new_readonly(authority, true), + ], + ); + assert_eq!( + add_extra_account_metas_for_execute( + &mut instruction, + &PROGRAM_ID, + &source, + &mint, + &destination, + &authority, + amount, + mock_fetch_account_data_fn, + ) + .await + .unwrap_err() + .downcast::() + .unwrap(), + Box::new(TransferHookError::IncorrectAccount) + ); + + // Success + let mut instruction = Instruction::new_with_bytes( + PROGRAM_ID, + &[], + vec![ + AccountMeta::new(source, false), + AccountMeta::new_readonly(mint, false), + AccountMeta::new(destination, false), + AccountMeta::new_readonly(authority, true), + ], + ); + add_extra_account_metas_for_execute( + &mut instruction, + &PROGRAM_ID, + &source, + &mint, + &destination, + &authority, + amount, + mock_fetch_account_data_fn, + ) + .await + .unwrap(); + + let check_metas = [ + AccountMeta::new(source, false), + AccountMeta::new_readonly(mint, false), + AccountMeta::new(destination, false), + AccountMeta::new_readonly(authority, true), + AccountMeta::new_readonly(EXTRA_META_1, true), + AccountMeta::new_readonly(EXTRA_META_2, true), + AccountMeta::new(extra_meta_3_pubkey, false), + AccountMeta::new(extra_meta_4_pubkey, false), + AccountMeta::new_readonly(PROGRAM_ID, false), + AccountMeta::new_readonly(validate_state_pubkey, false), + ]; + + assert_eq!(instruction.accounts, check_metas); + } +} From c68365d9d29ca80b073513cb186d80cb107630f5 Mon Sep 17 00:00:00 2001 From: Joe C Date: Thu, 11 Jan 2024 15:22:36 -0600 Subject: [PATCH 020/154] transfer hook: add new onchain helper As another step for solving #6064, the onchain helpers now need to be replaced. This PR makes that change in the SPL Transfer Hook interface. Specifically, this commit adds a new `add_extra_accounts_for_execute_cpi(..)` helper and deprecates the old one. Like its offchain counterpart, this new helper requires the arguments for `instruction::execute(..)` in order to validate that a proper `ExecuteInstruction` is being resolved, thus ensuring proper account resolution. This function, like its now-deprecated sibling, is designed specifically to add extra accounts to an `ExecuteInstruction` CPI instruction. It's expected that the instruction being provided is a CPI instruction for another program, and that program will CPI to the transfer hook program in question. Details about this have been added to the helper's documentation. --- interface/src/onchain.rs | 442 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 442 insertions(+) diff --git a/interface/src/onchain.rs b/interface/src/onchain.rs index 7eb52e3..cca63c4 100644 --- a/interface/src/onchain.rs +++ b/interface/src/onchain.rs @@ -56,6 +56,10 @@ pub fn invoke_execute<'a>( /// Helper to add accounts required for the transfer-hook program on-chain, /// looking through the additional account infos to add the proper accounts +#[deprecated( + since = "0.5.0", + note = "Please use `add_extra_accounts_for_execute_cpi` instead" +)] pub fn add_cpi_accounts_for_execute<'a>( cpi_instruction: &mut Instruction, cpi_account_infos: &mut Vec>, @@ -92,3 +96,441 @@ pub fn add_cpi_accounts_for_execute<'a>( .push(AccountMeta::new_readonly(*program_id, false)); Ok(()) } + +/// Helper to add accounts required for an `ExecuteInstruction` on-chain, +/// looking through the additional account infos to add the proper accounts. +/// +/// Note this helper is designed to add the extra accounts that will be +/// required for a CPI to a transfer hook program. However, the instruction +/// being provided to this helper is for the program that will CPI to the +/// transfer hook program. Because of this, we must resolve the extra accounts +/// for the `ExecuteInstruction` CPI, then add those extra resolved accounts to +/// the provided instruction. +#[allow(clippy::too_many_arguments)] +pub fn add_extra_accounts_for_execute_cpi<'a>( + cpi_instruction: &mut Instruction, + cpi_account_infos: &mut Vec>, + program_id: &Pubkey, + source_info: AccountInfo<'a>, + mint_info: AccountInfo<'a>, + destination_info: AccountInfo<'a>, + authority_info: AccountInfo<'a>, + amount: u64, + additional_accounts: &[AccountInfo<'a>], +) -> ProgramResult { + let validate_state_pubkey = get_extra_account_metas_address(mint_info.key, program_id); + let validate_state_info = additional_accounts + .iter() + .find(|&x| *x.key == validate_state_pubkey) + .ok_or(TransferHookError::IncorrectAccount)?; + + let program_info = additional_accounts + .iter() + .find(|&x| x.key == program_id) + .ok_or(TransferHookError::IncorrectAccount)?; + + let mut execute_instruction = instruction::execute( + program_id, + source_info.key, + mint_info.key, + destination_info.key, + authority_info.key, + &validate_state_pubkey, + amount, + ); + let mut execute_account_infos = vec![ + source_info, + mint_info, + destination_info, + authority_info, + validate_state_info.clone(), + ]; + + ExtraAccountMetaList::add_to_cpi_instruction::( + &mut execute_instruction, + &mut execute_account_infos, + &validate_state_info.try_borrow_data()?, + additional_accounts, + )?; + + // Add only the extra accounts resolved from the validation state + cpi_instruction + .accounts + .extend_from_slice(&execute_instruction.accounts[5..]); + cpi_account_infos.extend_from_slice(&execute_account_infos[5..]); + + // Add the program id and validation state account + cpi_instruction + .accounts + .push(AccountMeta::new_readonly(*program_id, false)); + cpi_instruction + .accounts + .push(AccountMeta::new_readonly(validate_state_pubkey, false)); + cpi_account_infos.push(program_info.clone()); + cpi_account_infos.push(validate_state_info.clone()); + + Ok(()) +} + +#[cfg(test)] +mod tests { + use { + super::*, + crate::instruction::ExecuteInstruction, + solana_program::{bpf_loader_upgradeable, system_program}, + spl_tlv_account_resolution::{ + account::ExtraAccountMeta, error::AccountResolutionError, seeds::Seed, + }, + }; + + const EXTRA_META_1: Pubkey = Pubkey::new_from_array([2u8; 32]); + const EXTRA_META_2: Pubkey = Pubkey::new_from_array([3u8; 32]); + + fn setup_validation_data() -> Vec { + let extra_metas = vec![ + ExtraAccountMeta::new_with_pubkey(&EXTRA_META_1, true, false).unwrap(), + ExtraAccountMeta::new_with_pubkey(&EXTRA_META_2, true, false).unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::AccountKey { index: 0 }, // source + Seed::AccountKey { index: 2 }, // destination + Seed::AccountKey { index: 4 }, // validation state + ], + false, + true, + ) + .unwrap(), + ExtraAccountMeta::new_with_seeds( + &[ + Seed::InstructionData { + index: 8, + length: 8, + }, // amount + Seed::AccountKey { index: 2 }, // destination + Seed::AccountKey { index: 5 }, // extra meta 1 + Seed::AccountKey { index: 7 }, // extra meta 3 (PDA) + ], + false, + true, + ) + .unwrap(), + ]; + let account_size = ExtraAccountMetaList::size_of(extra_metas.len()).unwrap(); + let mut data = vec![0u8; account_size]; + ExtraAccountMetaList::init::(&mut data, &extra_metas).unwrap(); + data + } + + #[test] + fn test_add_extra_accounts_for_execute_cpi() { + let spl_token_2022_program_id = Pubkey::new_unique(); // Mock + let transfer_hook_program_id = Pubkey::new_unique(); + + let amount = 100u64; + + let source_pubkey = Pubkey::new_unique(); + let mut source_data = vec![0; 165]; // Mock + let mut source_lamports = 0; // Mock + let source_account_info = AccountInfo::new( + &source_pubkey, + false, + true, + &mut source_lamports, + &mut source_data, + &spl_token_2022_program_id, + false, + 0, + ); + + let mint_pubkey = Pubkey::new_unique(); + let mut mint_data = vec![0; 165]; // Mock + let mut mint_lamports = 0; // Mock + let mint_account_info = AccountInfo::new( + &mint_pubkey, + false, + true, + &mut mint_lamports, + &mut mint_data, + &spl_token_2022_program_id, + false, + 0, + ); + + let destination_pubkey = Pubkey::new_unique(); + let mut destination_data = vec![0; 165]; // Mock + let mut destination_lamports = 0; // Mock + let destination_account_info = AccountInfo::new( + &destination_pubkey, + false, + true, + &mut destination_lamports, + &mut destination_data, + &spl_token_2022_program_id, + false, + 0, + ); + + let authority_pubkey = Pubkey::new_unique(); + let mut authority_data = vec![]; // Mock + let mut authority_lamports = 0; // Mock + let authority_account_info = AccountInfo::new( + &authority_pubkey, + false, + true, + &mut authority_lamports, + &mut authority_data, + &system_program::ID, + false, + 0, + ); + + let validate_state_pubkey = + get_extra_account_metas_address(&mint_pubkey, &transfer_hook_program_id); + + let extra_meta_1_pubkey = EXTRA_META_1; + let mut extra_meta_1_data = vec![]; // Mock + let mut extra_meta_1_lamports = 0; // Mock + let extra_meta_1_account_info = AccountInfo::new( + &extra_meta_1_pubkey, + true, + false, + &mut extra_meta_1_lamports, + &mut extra_meta_1_data, + &system_program::ID, + false, + 0, + ); + + let extra_meta_2_pubkey = EXTRA_META_2; + let mut extra_meta_2_data = vec![]; // Mock + let mut extra_meta_2_lamports = 0; // Mock + let extra_meta_2_account_info = AccountInfo::new( + &extra_meta_2_pubkey, + true, + false, + &mut extra_meta_2_lamports, + &mut extra_meta_2_data, + &system_program::ID, + false, + 0, + ); + + let extra_meta_3_pubkey = Pubkey::find_program_address( + &[ + &source_pubkey.to_bytes(), + &destination_pubkey.to_bytes(), + &validate_state_pubkey.to_bytes(), + ], + &transfer_hook_program_id, + ) + .0; + let mut extra_meta_3_data = vec![]; // Mock + let mut extra_meta_3_lamports = 0; // Mock + let extra_meta_3_account_info = AccountInfo::new( + &extra_meta_3_pubkey, + false, + true, + &mut extra_meta_3_lamports, + &mut extra_meta_3_data, + &transfer_hook_program_id, + false, + 0, + ); + + let extra_meta_4_pubkey = Pubkey::find_program_address( + &[ + &amount.to_le_bytes(), + &destination_pubkey.to_bytes(), + &extra_meta_1_pubkey.to_bytes(), + &extra_meta_3_pubkey.to_bytes(), + ], + &transfer_hook_program_id, + ) + .0; + let mut extra_meta_4_data = vec![]; // Mock + let mut extra_meta_4_lamports = 0; // Mock + let extra_meta_4_account_info = AccountInfo::new( + &extra_meta_4_pubkey, + false, + true, + &mut extra_meta_4_lamports, + &mut extra_meta_4_data, + &transfer_hook_program_id, + false, + 0, + ); + + let mut validate_state_data = setup_validation_data(); + let mut validate_state_lamports = 0; // Mock + let validate_state_account_info = AccountInfo::new( + &validate_state_pubkey, + false, + true, + &mut validate_state_lamports, + &mut validate_state_data, + &transfer_hook_program_id, + false, + 0, + ); + + let mut transfer_hook_program_data = vec![]; // Mock + let mut transfer_hook_program_lamports = 0; // Mock + let transfer_hook_program_account_info = AccountInfo::new( + &transfer_hook_program_id, + false, + true, + &mut transfer_hook_program_lamports, + &mut transfer_hook_program_data, + &bpf_loader_upgradeable::ID, + false, + 0, + ); + + let mut cpi_instruction = Instruction::new_with_bytes( + spl_token_2022_program_id, + &[], + vec![ + AccountMeta::new(source_pubkey, false), + AccountMeta::new_readonly(mint_pubkey, false), + AccountMeta::new(destination_pubkey, false), + AccountMeta::new_readonly(authority_pubkey, true), + ], + ); + let mut cpi_account_infos = vec![ + source_account_info.clone(), + mint_account_info.clone(), + destination_account_info.clone(), + authority_account_info.clone(), + ]; + let additional_account_infos = vec![ + extra_meta_1_account_info.clone(), + extra_meta_2_account_info.clone(), + extra_meta_3_account_info.clone(), + extra_meta_4_account_info.clone(), + transfer_hook_program_account_info.clone(), + validate_state_account_info.clone(), + ]; + + // Fail missing validation info from additional account infos + let additional_account_infos_missing_infos = vec![ + extra_meta_1_account_info.clone(), + extra_meta_2_account_info.clone(), + extra_meta_3_account_info.clone(), + extra_meta_4_account_info.clone(), + // validate state missing + transfer_hook_program_account_info.clone(), + ]; + assert_eq!( + add_extra_accounts_for_execute_cpi( + &mut cpi_instruction, + &mut cpi_account_infos, + &transfer_hook_program_id, + source_account_info.clone(), + mint_account_info.clone(), + destination_account_info.clone(), + authority_account_info.clone(), + amount, + &additional_account_infos_missing_infos, // Missing account info + ) + .unwrap_err(), + TransferHookError::IncorrectAccount.into() + ); + + // Fail missing program info from additional account infos + let additional_account_infos_missing_infos = vec![ + extra_meta_1_account_info.clone(), + extra_meta_2_account_info.clone(), + extra_meta_3_account_info.clone(), + extra_meta_4_account_info.clone(), + validate_state_account_info.clone(), + // transfer hook program missing + ]; + assert_eq!( + add_extra_accounts_for_execute_cpi( + &mut cpi_instruction, + &mut cpi_account_infos, + &transfer_hook_program_id, + source_account_info.clone(), + mint_account_info.clone(), + destination_account_info.clone(), + authority_account_info.clone(), + amount, + &additional_account_infos_missing_infos, // Missing account info + ) + .unwrap_err(), + TransferHookError::IncorrectAccount.into() + ); + + // Fail missing extra meta info from additional account infos + let additional_account_infos_missing_infos = vec![ + extra_meta_1_account_info.clone(), + extra_meta_2_account_info.clone(), + // extra meta 3 missing + extra_meta_4_account_info.clone(), + validate_state_account_info.clone(), + transfer_hook_program_account_info.clone(), + ]; + assert_eq!( + add_extra_accounts_for_execute_cpi( + &mut cpi_instruction, + &mut cpi_account_infos, + &transfer_hook_program_id, + source_account_info.clone(), + mint_account_info.clone(), + destination_account_info.clone(), + authority_account_info.clone(), + amount, + &additional_account_infos_missing_infos, // Missing account info + ) + .unwrap_err(), + AccountResolutionError::IncorrectAccount.into() // Note the error + ); + + // Success + add_extra_accounts_for_execute_cpi( + &mut cpi_instruction, + &mut cpi_account_infos, + &transfer_hook_program_id, + source_account_info.clone(), + mint_account_info.clone(), + destination_account_info.clone(), + authority_account_info.clone(), + amount, + &additional_account_infos, + ) + .unwrap(); + + let check_metas = [ + AccountMeta::new(source_pubkey, false), + AccountMeta::new_readonly(mint_pubkey, false), + AccountMeta::new(destination_pubkey, false), + AccountMeta::new_readonly(authority_pubkey, true), + AccountMeta::new_readonly(EXTRA_META_1, true), + AccountMeta::new_readonly(EXTRA_META_2, true), + AccountMeta::new(extra_meta_3_pubkey, false), + AccountMeta::new(extra_meta_4_pubkey, false), + AccountMeta::new_readonly(transfer_hook_program_id, false), + AccountMeta::new_readonly(validate_state_pubkey, false), + ]; + + let check_account_infos = vec![ + source_account_info, + mint_account_info, + destination_account_info, + authority_account_info, + extra_meta_1_account_info, + extra_meta_2_account_info, + extra_meta_3_account_info, + extra_meta_4_account_info, + transfer_hook_program_account_info, + validate_state_account_info, + ]; + + assert_eq!(cpi_instruction.accounts, check_metas); + for (a, b) in std::iter::zip(cpi_account_infos, check_account_infos) { + assert_eq!(a.key, b.key); + assert_eq!(a.is_signer, b.is_signer); + assert_eq!(a.is_writable, b.is_writable); + } + } +} From 9ef43764b0d387e2505bd99b30905abde7b947cf Mon Sep 17 00:00:00 2001 From: Emanuele Cesena Date: Wed, 17 Jan 2024 17:03:22 -0800 Subject: [PATCH 021/154] token 2022: upgrade sdk to 1.17.13 (#6147) * token 2022: upgrade sdk to 1.17.13 * Upgrade all remaining packages --------- Co-authored-by: Jon C --- clients/cli/Cargo.toml | 14 +++++++------- interface/Cargo.toml | 2 +- program/Cargo.toml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 2f71834..2db588c 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -11,12 +11,12 @@ version = "0.1.0" [dependencies] clap = { version = "3", features = ["cargo"] } futures-util = "0.3.30" -solana-clap-v3-utils = "=1.17.6" -solana-cli-config = "=1.17.6" -solana-client = "=1.17.6" -solana-logger = "=1.17.6" -solana-remote-wallet = "=1.17.6" -solana-sdk = "=1.17.6" +solana-clap-v3-utils = "=1.17.13" +solana-cli-config = "=1.17.13" +solana-client = "=1.17.13" +solana-logger = "=1.17.13" +solana-remote-wallet = "=1.17.13" +solana-sdk = "=1.17.13" spl-transfer-hook-interface = { version = "0.4", path = "../interface" } spl-tlv-account-resolution = { version = "0.5.1" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.25" @@ -27,7 +27,7 @@ serde_json = "1.0.108" serde_yaml = "0.9.30" [dev-dependencies] -solana-test-validator = "=1.17.6" +solana-test-validator = "=1.17.13" spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.8", path = "../../client" } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 79d4a7d..96188be 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" bytemuck = { version = "1.14.0", features = ["derive"] } -solana-program = "1.17.6" +solana-program = "1.17.13" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 6fd6523..5c45060 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -13,15 +13,15 @@ test-sbf = [] [dependencies] arrayref = "0.3.7" -solana-program = "1.17.6" +solana-program = "1.17.13" spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.4" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] -solana-program-test = "1.17.6" -solana-sdk = "1.17.6" +solana-program-test = "1.17.13" +solana-sdk = "1.17.13" [lib] crate-type = ["cdylib", "lib"] From 8d4bef279183fe4098d6ca37162690d908cc5f11 Mon Sep 17 00:00:00 2001 From: Joe C Date: Thu, 18 Jan 2024 14:33:56 -0500 Subject: [PATCH 022/154] token 2022 & transfer hook: drop deprecated helpers (#6122) * token 2022 & transfer hook: drop deprecated helpers * token js: drop deprecated helper --- interface/src/offchain.rs | 61 --------------------------------------- interface/src/onchain.rs | 43 --------------------------- 2 files changed, 104 deletions(-) diff --git a/interface/src/offchain.rs b/interface/src/offchain.rs index 692f5dd..2d3b7bb 100644 --- a/interface/src/offchain.rs +++ b/interface/src/offchain.rs @@ -16,67 +16,6 @@ use { std::future::Future, }; -/// Offchain helper to get all additional required account metas for a mint -/// -/// To be client-agnostic and to avoid pulling in the full solana-sdk, this -/// simply takes a function that will return its data as `Future>` for -/// the given address. Can be called in the following way: -/// -/// ```rust,ignore -/// use futures_util::TryFutureExt; -/// use solana_client::nonblocking::rpc_client::RpcClient; -/// use solana_program::pubkey::Pubkey; -/// -/// let program_id = Pubkey::new_unique(); -/// let mint = Pubkey::new_unique(); -/// let client = RpcClient::new_mock("succeeds".to_string()); -/// let mut account_metas = vec![]; -/// -/// get_extra_account_metas( -/// &mut account_metas, -/// |address| self.client.get_account(&address).map_ok(|opt| opt.map(|acc| acc.data)), -/// &mint, -/// &program_id, -/// ).await?; -/// ``` -#[deprecated( - since = "0.5.0", - note = "Please use `add_extra_account_metas_for_execute` instead" -)] -pub async fn resolve_extra_account_metas( - instruction: &mut Instruction, - fetch_account_data_fn: F, - mint: &Pubkey, - permissioned_transfer_program_id: &Pubkey, -) -> Result<(), AccountFetchError> -where - F: Fn(Pubkey) -> Fut, - Fut: Future, -{ - let validation_address = - get_extra_account_metas_address(mint, permissioned_transfer_program_id); - let validation_account_data = fetch_account_data_fn(validation_address) - .await? - .ok_or(ProgramError::InvalidAccountData)?; - ExtraAccountMetaList::add_to_instruction::( - instruction, - fetch_account_data_fn, - &validation_account_data, - ) - .await?; - // The onchain helpers pull out the required accounts from an opaque - // slice by pubkey, so the order doesn't matter here! - instruction.accounts.push(AccountMeta::new_readonly( - *permissioned_transfer_program_id, - false, - )); - instruction - .accounts - .push(AccountMeta::new_readonly(validation_address, false)); - - Ok(()) -} - /// Offchain helper to get all additional required account metas for an execute /// instruction, based on a validation state account. /// diff --git a/interface/src/onchain.rs b/interface/src/onchain.rs index cca63c4..41c2ec1 100644 --- a/interface/src/onchain.rs +++ b/interface/src/onchain.rs @@ -54,49 +54,6 @@ pub fn invoke_execute<'a>( invoke(&cpi_instruction, &cpi_account_infos) } -/// Helper to add accounts required for the transfer-hook program on-chain, -/// looking through the additional account infos to add the proper accounts -#[deprecated( - since = "0.5.0", - note = "Please use `add_extra_accounts_for_execute_cpi` instead" -)] -pub fn add_cpi_accounts_for_execute<'a>( - cpi_instruction: &mut Instruction, - cpi_account_infos: &mut Vec>, - mint_pubkey: &Pubkey, - program_id: &Pubkey, - additional_accounts: &[AccountInfo<'a>], -) -> ProgramResult { - let validation_pubkey = get_extra_account_metas_address(mint_pubkey, program_id); - let validation_info = additional_accounts - .iter() - .find(|&x| *x.key == validation_pubkey) - .ok_or(TransferHookError::IncorrectAccount)?; - - let program_info = additional_accounts - .iter() - .find(|&x| x.key == program_id) - .ok_or(TransferHookError::IncorrectAccount)?; - - ExtraAccountMetaList::add_to_cpi_instruction::( - cpi_instruction, - cpi_account_infos, - &validation_info.try_borrow_data()?, - additional_accounts, - )?; - // The onchain helpers pull out the required accounts from an opaque - // slice by pubkey, so the order doesn't matter here! - cpi_account_infos.push(validation_info.clone()); - cpi_account_infos.push(program_info.clone()); - cpi_instruction - .accounts - .push(AccountMeta::new_readonly(validation_pubkey, false)); - cpi_instruction - .accounts - .push(AccountMeta::new_readonly(*program_id, false)); - Ok(()) -} - /// Helper to add accounts required for an `ExecuteInstruction` on-chain, /// looking through the additional account infos to add the proper accounts. /// From 4ec046394016e5679e3ebd15283981b8758e6305 Mon Sep 17 00:00:00 2001 From: Joe C Date: Fri, 19 Jan 2024 14:14:16 -0500 Subject: [PATCH 023/154] Transfer hook: bump versions (#6119) * transfer hook: bump interface * transfer hook: bump cli --- clients/cli/Cargo.toml | 4 ++-- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 2db588c..ed76df0 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://spl.solana.com/token" license = "Apache-2.0" name = "spl-transfer-hook-cli" repository = "https://github.com/solana-labs/solana-program-library" -version = "0.1.0" +version = "0.1.1" [dependencies] clap = { version = "3", features = ["cargo"] } @@ -17,7 +17,7 @@ solana-client = "=1.17.13" solana-logger = "=1.17.13" solana-remote-wallet = "=1.17.13" solana-sdk = "=1.17.13" -spl-transfer-hook-interface = { version = "0.4", path = "../interface" } +spl-transfer-hook-interface = { version = "0.5", path = "../interface" } spl-tlv-account-resolution = { version = "0.5.1" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.25" strum_macros = "0.25" diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 96188be..b747c3c 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.4.1" +version = "0.5.0" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" diff --git a/program/Cargo.toml b/program/Cargo.toml index 5c45060..a38ad76 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -16,7 +16,7 @@ arrayref = "0.3.7" solana-program = "1.17.13" spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.4" , path = "../interface" } +spl-transfer-hook-interface = { version = "0.5" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] From f7d3551f1902ff4cc0c30486a7ff8ebf890bb9f6 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Fri, 19 Jan 2024 21:34:21 +0100 Subject: [PATCH 024/154] Fix broken link in transfer-hook interface Readme.md (#6154) Fix typo --- interface/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/README.md b/interface/README.md index 84dab20..376cdb1 100644 --- a/interface/README.md +++ b/interface/README.md @@ -142,7 +142,7 @@ program: The `spl-transfer-hook-interface` library provides offchain and onchain helpers for resolving the additional accounts required. See -[invoke.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface/src/invoke.rs) +[onchain.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface/src/onchain.rs) for usage on-chain, and [offchain.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface/src/offchain.rs) for fetching the additional required account metas with any async off-chain client From b294e7864018332181a567fc649e9c995894a128 Mon Sep 17 00:00:00 2001 From: Joe C Date: Fri, 19 Jan 2024 17:34:13 -0500 Subject: [PATCH 025/154] bump transfer hook example (#6155) --- program/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/Cargo.toml b/program/Cargo.toml index a38ad76..84d3ff9 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-example" -version = "0.4.0" +version = "0.5.0" description = "Solana Program Library Transfer Hook Example Program" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" From 52a0595c9f11bb807908fe7351c62f07e1310f6c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:58:50 +0100 Subject: [PATCH 026/154] build(deps): bump bytemuck from 1.14.0 to 1.14.1 (#6179) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.14.0 to 1.14.1. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.14.0...v1.14.1) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index b747c3c..706de0a 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" -bytemuck = { version = "1.14.0", features = ["derive"] } +bytemuck = { version = "1.14.1", features = ["derive"] } solana-program = "1.17.13" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } From 5b27daf14d801c3074e208ca44647f025efb7c4b Mon Sep 17 00:00:00 2001 From: Will Hickey Date: Fri, 26 Jan 2024 15:31:55 -0600 Subject: [PATCH 027/154] Update solana dependency version to allow 2.0.0 (#6182) * Update solana dependency version to allow 2.0.0 * Fix version number in solana-version.sh * Fix version numbers * Revert solana-version.sh with note * Revert Anchor version change * Relax dependency version upper bound to 2 --- clients/cli/Cargo.toml | 14 +++++++------- interface/Cargo.toml | 2 +- program/Cargo.toml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index ed76df0..fb23671 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -11,12 +11,12 @@ version = "0.1.1" [dependencies] clap = { version = "3", features = ["cargo"] } futures-util = "0.3.30" -solana-clap-v3-utils = "=1.17.13" -solana-cli-config = "=1.17.13" -solana-client = "=1.17.13" -solana-logger = "=1.17.13" -solana-remote-wallet = "=1.17.13" -solana-sdk = "=1.17.13" +solana-clap-v3-utils = ">=1.17.13,<=2" +solana-cli-config = ">=1.17.13,<=2" +solana-client = ">=1.17.13,<=2" +solana-logger = ">=1.17.13,<=2" +solana-remote-wallet = ">=1.17.13,<=2" +solana-sdk = ">=1.17.13,<=2" spl-transfer-hook-interface = { version = "0.5", path = "../interface" } spl-tlv-account-resolution = { version = "0.5.1" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.25" @@ -27,7 +27,7 @@ serde_json = "1.0.108" serde_yaml = "0.9.30" [dev-dependencies] -solana-test-validator = "=1.17.13" +solana-test-validator = ">=1.17.13,<=2" spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.8", path = "../../client" } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 706de0a..f2f7b0f 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" bytemuck = { version = "1.14.1", features = ["derive"] } -solana-program = "1.17.13" +solana-program = ">=1.17.13,<=2" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 84d3ff9..d52b89a 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -13,15 +13,15 @@ test-sbf = [] [dependencies] arrayref = "0.3.7" -solana-program = "1.17.13" +solana-program = ">=1.17.13,<=2" spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.5" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] -solana-program-test = "1.17.13" -solana-sdk = "1.17.13" +solana-program-test = ">=1.17.13,<=2" +solana-sdk = ">=1.17.13,<=2" [lib] crate-type = ["cdylib", "lib"] From e182ee1c6849b0a6fa653b8a1071c506ba6dbe55 Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 26 Jan 2024 23:19:53 +0100 Subject: [PATCH 028/154] token-2022: Bump to v2 (#6187) --- clients/cli/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index fb23671..3278b4e 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -28,7 +28,7 @@ serde_yaml = "0.9.30" [dev-dependencies] solana-test-validator = ">=1.17.13,<=2" -spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "2.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.8", path = "../../client" } [[bin]] diff --git a/program/Cargo.toml b/program/Cargo.toml index d52b89a..49513f6 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -15,7 +15,7 @@ test-sbf = [] arrayref = "0.3.7" solana-program = ">=1.17.13,<=2" spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } -spl-token-2022 = { version = "1.0", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "2.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.5" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } From bdd6f45ffe91bb7b3c5627d007ae56b7f823e360 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:27:41 +0100 Subject: [PATCH 029/154] build(deps): bump serde from 1.0.195 to 1.0.196 (#6193) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.195 to 1.0.196. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.195...v1.0.196) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 3278b4e..6a3551c 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-tlv-account-resolution = { version = "0.5.1" , path = "../../../libraries/tl strum = "0.25" strum_macros = "0.25" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.195", features = ["derive"] } +serde = { version = "1.0.196", features = ["derive"] } serde_json = "1.0.108" serde_yaml = "0.9.30" From 7956b27648054d3eb6d0766f28c9278b29586a8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:27:50 +0100 Subject: [PATCH 030/154] build(deps): bump serde_yaml from 0.9.30 to 0.9.31 (#6194) Bumps [serde_yaml](https://github.com/dtolnay/serde-yaml) from 0.9.30 to 0.9.31. - [Release notes](https://github.com/dtolnay/serde-yaml/releases) - [Commits](https://github.com/dtolnay/serde-yaml/compare/0.9.30...0.9.31) --- updated-dependencies: - dependency-name: serde_yaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 6a3551c..24f374b 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -24,7 +24,7 @@ strum_macros = "0.25" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.196", features = ["derive"] } serde_json = "1.0.108" -serde_yaml = "0.9.30" +serde_yaml = "0.9.31" [dev-dependencies] solana-test-validator = ">=1.17.13,<=2" From 87a6dac63638a88cd270e3a5b1806b5a6af0179e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:28:04 +0100 Subject: [PATCH 031/154] build(deps): bump strum_macros from 0.25.3 to 0.26.1 (#6197) Bumps [strum_macros](https://github.com/Peternator7/strum) from 0.25.3 to 0.26.1. - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum_macros dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 24f374b..1434c28 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -20,7 +20,7 @@ solana-sdk = ">=1.17.13,<=2" spl-transfer-hook-interface = { version = "0.5", path = "../interface" } spl-tlv-account-resolution = { version = "0.5.1" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.25" -strum_macros = "0.25" +strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.196", features = ["derive"] } serde_json = "1.0.108" From 5581b6598a7158a180837cfd8ff6a893a99131b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:04:29 +0100 Subject: [PATCH 032/154] build(deps): bump serde_json from 1.0.111 to 1.0.113 (#6195) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.111 to 1.0.113. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.111...v1.0.113) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 1434c28..0cd367e 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.25" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.196", features = ["derive"] } -serde_json = "1.0.108" +serde_json = "1.0.113" serde_yaml = "0.9.31" [dev-dependencies] From 673031cba2d713b1ab220629d9d415fbae0d5395 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:04:40 +0100 Subject: [PATCH 033/154] build(deps): bump strum from 0.25.0 to 0.26.1 (#6196) Bumps [strum](https://github.com/Peternator7/strum) from 0.25.0 to 0.26.1. - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 0cd367e..db0761d 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -19,7 +19,7 @@ solana-remote-wallet = ">=1.17.13,<=2" solana-sdk = ">=1.17.13,<=2" spl-transfer-hook-interface = { version = "0.5", path = "../interface" } spl-tlv-account-resolution = { version = "0.5.1" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } -strum = "0.25" +strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.196", features = ["derive"] } From 22ac3e5c1fe290a82a64eb2900cee24146b71b31 Mon Sep 17 00:00:00 2001 From: samkim-crypto Date: Thu, 1 Feb 2024 10:09:45 +0900 Subject: [PATCH 034/154] Upgrade to solana 1.17.17 (#6189) * upgrade to solana version 1.17.17 * add display for the group extensions * upgrade to solana version 1.17.17 * update cargo lock --- clients/cli/Cargo.toml | 14 +++++++------- interface/Cargo.toml | 2 +- program/Cargo.toml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index db0761d..4112339 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -11,12 +11,12 @@ version = "0.1.1" [dependencies] clap = { version = "3", features = ["cargo"] } futures-util = "0.3.30" -solana-clap-v3-utils = ">=1.17.13,<=2" -solana-cli-config = ">=1.17.13,<=2" -solana-client = ">=1.17.13,<=2" -solana-logger = ">=1.17.13,<=2" -solana-remote-wallet = ">=1.17.13,<=2" -solana-sdk = ">=1.17.13,<=2" +solana-clap-v3-utils = ">=1.17.17,<=2" +solana-cli-config = ">=1.17.17,<=2" +solana-client = ">=1.17.17,<=2" +solana-logger = ">=1.17.17,<=2" +solana-remote-wallet = ">=1.17.17,<=2" +solana-sdk = ">=1.17.17,<=2" spl-transfer-hook-interface = { version = "0.5", path = "../interface" } spl-tlv-account-resolution = { version = "0.5.1" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.26" @@ -27,7 +27,7 @@ serde_json = "1.0.113" serde_yaml = "0.9.31" [dev-dependencies] -solana-test-validator = ">=1.17.13,<=2" +solana-test-validator = ">=1.17.17,<=2" spl-token-2022 = { version = "2.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.8", path = "../../client" } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index f2f7b0f..b98090e 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" bytemuck = { version = "1.14.1", features = ["derive"] } -solana-program = ">=1.17.13,<=2" +solana-program = ">=1.17.17,<=2" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 49513f6..7bdc678 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -13,15 +13,15 @@ test-sbf = [] [dependencies] arrayref = "0.3.7" -solana-program = ">=1.17.13,<=2" +solana-program = ">=1.17.17,<=2" spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "2.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.5" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] -solana-program-test = ">=1.17.13,<=2" -solana-sdk = ">=1.17.13,<=2" +solana-program-test = ">=1.17.17,<=2" +solana-sdk = ">=1.17.17,<=2" [lib] crate-type = ["cdylib", "lib"] From baa6fa1573652c5c7a5e1809f6169db1a41067e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:21:03 -0500 Subject: [PATCH 035/154] build(deps): bump tokio from 1.35.1 to 1.36.0 (#6222) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.35.1 to 1.36.0. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.35.1...tokio-1.36.0) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index b98090e..84307a5 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -21,7 +21,7 @@ spl-pod = { version = "0.1", path = "../../../libraries/pod" } crate-type = ["cdylib", "lib"] [dev-dependencies] -tokio = { version = "1.35.1", features = ["full"] } +tokio = { version = "1.36.0", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From 5d1e9ea4fe0b00ac5282f4bc6b5c6287878652f4 Mon Sep 17 00:00:00 2001 From: Will Hickey Date: Mon, 5 Feb 2024 14:52:18 -0600 Subject: [PATCH 036/154] Bump SPL crate versions (#6221) * Update associated-token-account version to 2.3.1 * Update discriminator version to 0.1.1 * Update discriminator-derive version to 0.1.2 * Update discriminator-syn version to 0.1.2 * Update instruction-padding version to 0.1.1 * Update memo version to 4.0.1 * Update pod version to 0.1.1 * Update program-error version to 0.3.1 * Update program-error-derive version to 0.3.2 * Update tlv-account-resolution version to 0.5.2 * Update token version to 4.0.1 * Cargo.lock * Update token-group-interface version to 0.1.1 * Update token-metadata-interface version to 0.2.1 * Update transfer-hook-interface version to 0.5.1 * Update type-length-value version to 0.3.1 * Cargo.lock * Remove extraneous whitespace --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 4112339..ee134f6 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -18,7 +18,7 @@ solana-logger = ">=1.17.17,<=2" solana-remote-wallet = ">=1.17.17,<=2" solana-sdk = ">=1.17.17,<=2" spl-transfer-hook-interface = { version = "0.5", path = "../interface" } -spl-tlv-account-resolution = { version = "0.5.1" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } +spl-tlv-account-resolution = { version = "0.5.2" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 84307a5..d96eee5 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.5.0" +version = "0.5.1" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" From 39945a0ef989fa9c95363b87999048a30ca84baf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Feb 2024 12:03:05 -0500 Subject: [PATCH 037/154] build(deps): bump bytemuck from 1.14.1 to 1.14.2 (#6231) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.14.1 to 1.14.2. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.14.1...v1.14.2) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index d96eee5..d0634d9 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" -bytemuck = { version = "1.14.1", features = ["derive"] } +bytemuck = { version = "1.14.2", features = ["derive"] } solana-program = ">=1.17.17,<=2" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } From 6f2813233d02feb963395fa95d19521b359c8fce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Feb 2024 19:01:35 -0500 Subject: [PATCH 038/154] build(deps): bump bytemuck from 1.14.2 to 1.14.3 (#6240) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.14.2 to 1.14.3. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.14.2...v1.14.3) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index d0634d9..c926ec3 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" -bytemuck = { version = "1.14.2", features = ["derive"] } +bytemuck = { version = "1.14.3", features = ["derive"] } solana-program = ">=1.17.17,<=2" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } From 7a3b4c382868e8421a666b5e19224dd0b08fcb9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:46:59 +0100 Subject: [PATCH 039/154] build(deps): bump serde_yaml from 0.9.31 to 0.9.32 (#6265) Bumps [serde_yaml](https://github.com/dtolnay/serde-yaml) from 0.9.31 to 0.9.32. - [Release notes](https://github.com/dtolnay/serde-yaml/releases) - [Commits](https://github.com/dtolnay/serde-yaml/compare/0.9.31...0.9.32) --- updated-dependencies: - dependency-name: serde_yaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index ee134f6..e936d7b 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -24,7 +24,7 @@ strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.196", features = ["derive"] } serde_json = "1.0.113" -serde_yaml = "0.9.31" +serde_yaml = "0.9.32" [dev-dependencies] solana-test-validator = ">=1.17.17,<=2" From eea045c2ea53bef90d38cd18ba891067ba1d2aeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 12:08:58 +0100 Subject: [PATCH 040/154] build(deps): bump serde from 1.0.196 to 1.0.197 (#6270) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.196 to 1.0.197. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.196...v1.0.197) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index e936d7b..d74ecfd 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-tlv-account-resolution = { version = "0.5.2" , path = "../../../libraries/tl strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.196", features = ["derive"] } +serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.113" serde_yaml = "0.9.32" From a5db338f1df469dc7d2fd9afdd4da90bed27708b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 12:41:57 +0100 Subject: [PATCH 041/154] build(deps): bump serde_json from 1.0.113 to 1.0.114 (#6272) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.113 to 1.0.114. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.113...v1.0.114) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index d74ecfd..4ff3c80 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } -serde_json = "1.0.113" +serde_json = "1.0.114" serde_yaml = "0.9.32" [dev-dependencies] From bd1da31ad2e764db6a3fe2a44831f6471048406a Mon Sep 17 00:00:00 2001 From: samkim-crypto Date: Thu, 29 Feb 2024 10:06:27 +0900 Subject: [PATCH 042/154] Upgrade to Solana 1.18.2 (#6278) * upgrade to solana 1.18.2 * upgrade rust version to 1.76.0 * update borsh to 1.2.1 * replace deprecated `try_to_vec` with `borsh::to_vec` * temporarily allow deprecated functions in cli that uses clap-v3 * use `repr(u32)` for enums in token lending --- clients/cli/Cargo.toml | 14 +++++++------- clients/cli/src/main.rs | 2 ++ interface/Cargo.toml | 2 +- program/Cargo.toml | 6 +++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 4ff3c80..05fbda8 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -11,12 +11,12 @@ version = "0.1.1" [dependencies] clap = { version = "3", features = ["cargo"] } futures-util = "0.3.30" -solana-clap-v3-utils = ">=1.17.17,<=2" -solana-cli-config = ">=1.17.17,<=2" -solana-client = ">=1.17.17,<=2" -solana-logger = ">=1.17.17,<=2" -solana-remote-wallet = ">=1.17.17,<=2" -solana-sdk = ">=1.17.17,<=2" +solana-clap-v3-utils = ">=1.18.2,<=2" +solana-cli-config = ">=1.18.2,<=2" +solana-client = ">=1.18.2,<=2" +solana-logger = ">=1.18.2,<=2" +solana-remote-wallet = ">=1.18.2,<=2" +solana-sdk = ">=1.18.2,<=2" spl-transfer-hook-interface = { version = "0.5", path = "../interface" } spl-tlv-account-resolution = { version = "0.5.2" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.26" @@ -27,7 +27,7 @@ serde_json = "1.0.114" serde_yaml = "0.9.32" [dev-dependencies] -solana-test-validator = ">=1.17.17,<=2" +solana-test-validator = ">=1.18.2,<=2" spl-token-2022 = { version = "2.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.8", path = "../../client" } diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index 010bf71..237b47e 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + pub mod meta; use { diff --git a/interface/Cargo.toml b/interface/Cargo.toml index c926ec3..90b80d7 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" bytemuck = { version = "1.14.3", features = ["derive"] } -solana-program = ">=1.17.17,<=2" +solana-program = ">=1.18.2,<=2" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 7bdc678..da79a92 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -13,15 +13,15 @@ test-sbf = [] [dependencies] arrayref = "0.3.7" -solana-program = ">=1.17.17,<=2" +solana-program = ">=1.18.2,<=2" spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "2.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.5" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] -solana-program-test = ">=1.17.17,<=2" -solana-sdk = ">=1.17.17,<=2" +solana-program-test = ">=1.18.2,<=2" +solana-sdk = ">=1.18.2,<=2" [lib] crate-type = ["cdylib", "lib"] From 9841e9811309a44b2839df08483f84e8c81fefab Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 5 Mar 2024 11:22:20 +0100 Subject: [PATCH 043/154] token-2022: Refactor `StateWithExtensionsMut` functionality into trait (#6329) * Refactor `StateWithExtensionsMut` functionality into trait * Dedupe unpack function * Simplify passing function --- program/tests/functional.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/program/tests/functional.rs b/program/tests/functional.rs index 4e078c1..82a5937 100644 --- a/program/tests/functional.rs +++ b/program/tests/functional.rs @@ -22,7 +22,10 @@ use { state::ExtraAccountMetaList, }, spl_token_2022::{ - extension::{transfer_hook::TransferHookAccount, ExtensionType, StateWithExtensionsMut}, + extension::{ + transfer_hook::TransferHookAccount, BaseStateWithExtensionsMut, ExtensionType, + StateWithExtensionsMut, + }, state::{Account, AccountState, Mint}, }, spl_transfer_hook_interface::{ From e44d5527013715105166c68906203aa9d62fbd2c Mon Sep 17 00:00:00 2001 From: gcmutator <134900551+gcmutator@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:50:09 +0800 Subject: [PATCH 044/154] refactor: Optimize code based on cargo clippy suggestions (#6373) refactor: Optimize code based on cargo clippy suggestions refactor: Optimize code based on cargo clippy suggestions Signed-off-by: gcmutator <329964069@qq.com> --- clients/cli/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index 237b47e..d611ba5 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -51,7 +51,7 @@ async fn build_transaction_with_rent_transfer( rpc_client: &RpcClient, payer: &dyn Signer, extra_account_metas_address: &Pubkey, - extra_account_metas: &Vec, + extra_account_metas: &[ExtraAccountMeta], instruction: Instruction, ) -> Result> { let account_size = ExtraAccountMetaList::size_of(extra_account_metas.len())?; From b4798abb313bbf6e0c1b8f1b111b7ed63adeb543 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 12:38:01 +0100 Subject: [PATCH 045/154] build(deps): bump bytemuck from 1.14.3 to 1.15.0 (#6415) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.14.3 to 1.15.0. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.14.3...v1.15.0) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 90b80d7..fda986e 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" -bytemuck = { version = "1.14.3", features = ["derive"] } +bytemuck = { version = "1.15.0", features = ["derive"] } solana-program = ">=1.18.2,<=2" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } From 02b97c797766567c41c8caf99cd54ef4a188d17b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 13:10:37 +0100 Subject: [PATCH 046/154] build(deps): bump serde_yaml from 0.9.32 to 0.9.33 (#6444) Bumps [serde_yaml](https://github.com/dtolnay/serde-yaml) from 0.9.32 to 0.9.33. - [Release notes](https://github.com/dtolnay/serde-yaml/releases) - [Commits](https://github.com/dtolnay/serde-yaml/compare/0.9.32...0.9.33) --- updated-dependencies: - dependency-name: serde_yaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 05fbda8..699b4d6 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -24,7 +24,7 @@ strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.114" -serde_yaml = "0.9.32" +serde_yaml = "0.9.33" [dev-dependencies] solana-test-validator = ">=1.18.2,<=2" From b986cf1cff894436f8b2010ac2e470d5268d42ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 12:15:43 +0100 Subject: [PATCH 047/154] build(deps): bump serde_yaml from 0.9.33 to 0.9.34+deprecated (#6488) Bumps [serde_yaml](https://github.com/dtolnay/serde-yaml) from 0.9.33 to 0.9.34+deprecated. - [Release notes](https://github.com/dtolnay/serde-yaml/releases) - [Commits](https://github.com/dtolnay/serde-yaml/compare/0.9.33...0.9.34) --- updated-dependencies: - dependency-name: serde_yaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 699b4d6..4ba369f 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -24,7 +24,7 @@ strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.114" -serde_yaml = "0.9.33" +serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = ">=1.18.2,<=2" From badc17ac2e6992f5a2d97f0560234770c04d033c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:52:54 +0100 Subject: [PATCH 048/154] build(deps): bump serde_json from 1.0.114 to 1.0.115 (#6495) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.114 to 1.0.115. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.114...v1.0.115) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 4ba369f..613f509 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } -serde_json = "1.0.114" +serde_json = "1.0.115" serde_yaml = "0.9.34" [dev-dependencies] From 099318012b357532822ba61cdf7b8d681fce1e7f Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 28 Mar 2024 01:04:40 +0100 Subject: [PATCH 049/154] bump: Bump everything up for new token cli (#6507) --- clients/cli/Cargo.toml | 4 ++-- program/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 613f509..62550e0 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] authors = ["Solana Labs Maintainers "] -description = "SPL-Token Command-line Utility" +description = "SPL Transfer Hook Command-line Utility" edition = "2021" homepage = "https://spl.solana.com/token" license = "Apache-2.0" @@ -28,7 +28,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = ">=1.18.2,<=2" -spl-token-2022 = { version = "2.0", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "3.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.8", path = "../../client" } [[bin]] diff --git a/program/Cargo.toml b/program/Cargo.toml index da79a92..94bb7d3 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -15,7 +15,7 @@ test-sbf = [] arrayref = "0.3.7" solana-program = ">=1.18.2,<=2" spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } -spl-token-2022 = { version = "2.0", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "3.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.5" , path = "../interface" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } From 655e7cbd4be77a6fab73ca3c58f916884b0e0e0d Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 28 Mar 2024 12:34:33 +0100 Subject: [PATCH 050/154] pod: Bump to 0.2.0 --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index fda986e..051806b 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -15,7 +15,7 @@ spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } -spl-pod = { version = "0.1", path = "../../../libraries/pod" } +spl-pod = { version = "0.2", path = "../../../libraries/pod" } [lib] crate-type = ["cdylib", "lib"] From 9ed0c71ee27b8590f10d25a041f4c69ef3e5b2c1 Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 28 Mar 2024 12:37:59 +0100 Subject: [PATCH 051/154] tlv: Bump to 0.4 --- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 051806b..92ad1fd 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -14,7 +14,7 @@ solana-program = ">=1.18.2,<=2" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } -spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } +spl-type-length-value = { version = "0.4" , path = "../../../libraries/type-length-value" } spl-pod = { version = "0.2", path = "../../../libraries/pod" } [lib] diff --git a/program/Cargo.toml b/program/Cargo.toml index 94bb7d3..0eafaee 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -17,7 +17,7 @@ solana-program = ">=1.18.2,<=2" spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "3.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.5" , path = "../interface" } -spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } +spl-type-length-value = { version = "0.4" , path = "../../../libraries/type-length-value" } [dev-dependencies] solana-program-test = ">=1.18.2,<=2" From 804040ea2348ee6bca2a0f71968557fb4f413f16 Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 28 Mar 2024 12:40:25 +0100 Subject: [PATCH 052/154] tlv-account-resolution: Bump to 0.6.0 --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 62550e0..477aa11 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -18,7 +18,7 @@ solana-logger = ">=1.18.2,<=2" solana-remote-wallet = ">=1.18.2,<=2" solana-sdk = ">=1.18.2,<=2" spl-transfer-hook-interface = { version = "0.5", path = "../interface" } -spl-tlv-account-resolution = { version = "0.5.2" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } +spl-tlv-account-resolution = { version = "0.6" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 92ad1fd..4556225 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -13,7 +13,7 @@ bytemuck = { version = "1.15.0", features = ["derive"] } solana-program = ">=1.18.2,<=2" spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } -spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.6" , path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.4" , path = "../../../libraries/type-length-value" } spl-pod = { version = "0.2", path = "../../../libraries/pod" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 0eafaee..a118c96 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -14,7 +14,7 @@ test-sbf = [] [dependencies] arrayref = "0.3.7" solana-program = ">=1.18.2,<=2" -spl-tlv-account-resolution = { version = "0.5" , path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.6" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "3.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.5" , path = "../interface" } spl-type-length-value = { version = "0.4" , path = "../../../libraries/type-length-value" } From 074c6daf911265d8e2aa2711f11aeb59e20dadc4 Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 28 Mar 2024 12:48:45 +0100 Subject: [PATCH 053/154] transfer-hook-interface: Bump to 0.6.0 --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 477aa11..3744915 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -17,7 +17,7 @@ solana-client = ">=1.18.2,<=2" solana-logger = ">=1.18.2,<=2" solana-remote-wallet = ">=1.18.2,<=2" solana-sdk = ">=1.18.2,<=2" -spl-transfer-hook-interface = { version = "0.5", path = "../interface" } +spl-transfer-hook-interface = { version = "0.6", path = "../interface" } spl-tlv-account-resolution = { version = "0.6" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.26" strum_macros = "0.26" diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 4556225..e0a9db2 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.5.1" +version = "0.6.0" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" diff --git a/program/Cargo.toml b/program/Cargo.toml index a118c96..7998e0a 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -16,7 +16,7 @@ arrayref = "0.3.7" solana-program = ">=1.18.2,<=2" spl-tlv-account-resolution = { version = "0.6" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "3.0", path = "../../program-2022", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.5" , path = "../interface" } +spl-transfer-hook-interface = { version = "0.6" , path = "../interface" } spl-type-length-value = { version = "0.4" , path = "../../../libraries/type-length-value" } [dev-dependencies] From a5e47817fa642938c85731641f0c3c7e09fa315f Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 28 Mar 2024 12:50:07 +0100 Subject: [PATCH 054/154] transfer-hook-example: Bump to 0.6.0 --- program/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/Cargo.toml b/program/Cargo.toml index 7998e0a..b3310e2 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-example" -version = "0.5.0" +version = "0.6.0" description = "Solana Program Library Transfer Hook Example Program" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" From 747cea9194481a6cf5dd641211c91c4694c9208e Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 28 Mar 2024 12:50:42 +0100 Subject: [PATCH 055/154] transfer-hook-cli: Bump to 0.2.0 --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 3744915..0a72455 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://spl.solana.com/token" license = "Apache-2.0" name = "spl-transfer-hook-cli" repository = "https://github.com/solana-labs/solana-program-library" -version = "0.1.1" +version = "0.2.0" [dependencies] clap = { version = "3", features = ["cargo"] } From 3fca038c493fdc92a03c82f8c7296b1c9bfd52d3 Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 28 Mar 2024 12:52:23 +0100 Subject: [PATCH 056/154] token-client: Bump to 0.9.0 --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 0a72455..5f802c1 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -29,7 +29,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = ">=1.18.2,<=2" spl-token-2022 = { version = "3.0", path = "../../program-2022", features = ["no-entrypoint"] } -spl-token-client = { version = "0.8", path = "../../client" } +spl-token-client = { version = "0.9", path = "../../client" } [[bin]] name = "spl-transfer-hook" From a7acda282c3fd74b4a11f117dbe5b8b011adce8d Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 28 Mar 2024 15:57:20 +0100 Subject: [PATCH 057/154] discriminator: Bump to 0.2.0 (#6513) * discriminator: Bump borsh * Bump to 0.2.0 * Update dependencies to use new discriminator library --- interface/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index e0a9db2..5c3337d 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.6.0" +version = "0.6.1" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" @@ -11,7 +11,7 @@ edition = "2021" arrayref = "0.3.7" bytemuck = { version = "1.15.0", features = ["derive"] } solana-program = ">=1.18.2,<=2" -spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } +spl-discriminator = { version = "0.2" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.6" , path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.4" , path = "../../../libraries/type-length-value" } From b9bf2a5c329840576c181bdcdf6f88f9dc07a178 Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 28 Mar 2024 23:46:27 +0100 Subject: [PATCH 058/154] Bump all crates for token-cli release (#6516) * Bump pod to 0.2.2 * Bump program-error and derive to 0.4.0 * Bump type-length-value to 0.4.3 * Bump tlv-account-resolution to 0.6.3 * Bump token-group-interface to 0.2.3 * Bump token-metadata-interface to 0.3.3 * Bump token-2022 to 3.0.2 * Bump transfer-hook-interface to 0.6.3 * Bump token-client to 0.9.2 * Bump associated-token-account to 3.0.2 * Bump discriminator, derive, and syn to 0.2.x --- clients/cli/Cargo.toml | 8 ++++---- interface/Cargo.toml | 12 ++++++------ program/Cargo.toml | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 5f802c1..977ddca 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -17,8 +17,8 @@ solana-client = ">=1.18.2,<=2" solana-logger = ">=1.18.2,<=2" solana-remote-wallet = ">=1.18.2,<=2" solana-sdk = ">=1.18.2,<=2" -spl-transfer-hook-interface = { version = "0.6", path = "../interface" } -spl-tlv-account-resolution = { version = "0.6" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } +spl-transfer-hook-interface = { version = "0.6.3", path = "../interface" } +spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } @@ -28,8 +28,8 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = ">=1.18.2,<=2" -spl-token-2022 = { version = "3.0", path = "../../program-2022", features = ["no-entrypoint"] } -spl-token-client = { version = "0.9", path = "../../client" } +spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-client = { version = "0.9.2", path = "../../client" } [[bin]] name = "spl-transfer-hook" diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 5c3337d..15e4332 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.6.1" +version = "0.6.3" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" @@ -11,11 +11,11 @@ edition = "2021" arrayref = "0.3.7" bytemuck = { version = "1.15.0", features = ["derive"] } solana-program = ">=1.18.2,<=2" -spl-discriminator = { version = "0.2" , path = "../../../libraries/discriminator" } -spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } -spl-tlv-account-resolution = { version = "0.6" , path = "../../../libraries/tlv-account-resolution" } -spl-type-length-value = { version = "0.4" , path = "../../../libraries/type-length-value" } -spl-pod = { version = "0.2", path = "../../../libraries/pod" } +spl-discriminator = { version = "0.2.2" , path = "../../../libraries/discriminator" } +spl-program-error = { version = "0.4.0" , path = "../../../libraries/program-error" } +spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } +spl-type-length-value = { version = "0.4.3" , path = "../../../libraries/type-length-value" } +spl-pod = { version = "0.2.2", path = "../../../libraries/pod" } [lib] crate-type = ["cdylib", "lib"] diff --git a/program/Cargo.toml b/program/Cargo.toml index b3310e2..c4efb55 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -14,10 +14,10 @@ test-sbf = [] [dependencies] arrayref = "0.3.7" solana-program = ">=1.18.2,<=2" -spl-tlv-account-resolution = { version = "0.6" , path = "../../../libraries/tlv-account-resolution" } -spl-token-2022 = { version = "3.0", path = "../../program-2022", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.6" , path = "../interface" } -spl-type-length-value = { version = "0.4" , path = "../../../libraries/type-length-value" } +spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } +spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } +spl-transfer-hook-interface = { version = "0.6.3" , path = "../interface" } +spl-type-length-value = { version = "0.4.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] solana-program-test = ">=1.18.2,<=2" From f0e55a2eef3c27f30f5099c83e2ca259a7c09790 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 12:08:49 +0100 Subject: [PATCH 059/154] build(deps): bump tokio from 1.36.0 to 1.37.0 (#6519) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.36.0 to 1.37.0. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.36.0...tokio-1.37.0) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 15e4332..52cb6c7 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -21,7 +21,7 @@ spl-pod = { version = "0.2.2", path = "../../../libraries/pod" } crate-type = ["cdylib", "lib"] [dev-dependencies] -tokio = { version = "1.36.0", features = ["full"] } +tokio = { version = "1.37.0", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From 42e58d2e80d3729e53bad0981d36353f3ff0c88e Mon Sep 17 00:00:00 2001 From: tonton <19677766+tonton-sol@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:11:01 -0400 Subject: [PATCH 060/154] [transfer-hook] Remove deprecated functions from cli (#6525) * removed allow deprecated * remove deprecated validators * spelling * added allow_all() to SignerSourceParserBuilder --- clients/cli/src/main.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index d611ba5..a6bb65c 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -1,13 +1,13 @@ -#![allow(deprecated)] - pub mod meta; use { crate::meta::parse_transfer_hook_account_arg, clap::{crate_description, crate_name, crate_version, Arg, Command}, solana_clap_v3_utils::{ - input_parsers::{parse_url_or_moniker, pubkey_of_signer}, - input_validators::{is_valid_pubkey, is_valid_signer, normalize_to_url_if_moniker}, + input_parsers::{ + parse_url_or_moniker, pubkey_of_signer, signer::SignerSourceParserBuilder, + }, + input_validators::normalize_to_url_if_moniker, keypair::DefaultSigner, }, solana_client::nonblocking::rpc_client::RpcClient, @@ -28,10 +28,6 @@ use { std::{process::exit, rc::Rc}, }; -fn clap_is_valid_pubkey(arg: &str) -> Result<(), String> { - is_valid_pubkey(arg) -} - // Helper function to calculate the required lamports for rent async fn calculate_rent_lamports( rpc_client: &RpcClient, @@ -209,7 +205,7 @@ async fn main() -> Result<(), Box> { Arg::new("fee_payer") .long("fee-payer") .value_name("KEYPAIR") - .validator(|s| is_valid_signer(s)) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .takes_value(true) .global(true) .help("Filepath or URL to a keypair to pay transaction fee [default: client keypair]"), @@ -237,7 +233,7 @@ async fn main() -> Result<(), Box> { .about("Create the extra account metas account for a transfer hook program") .arg( Arg::with_name("program_id") - .validator(clap_is_valid_pubkey) + .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TRANSFER_HOOK_PROGRAM") .takes_value(true) .index(1) @@ -246,7 +242,7 @@ async fn main() -> Result<(), Box> { ) .arg( Arg::with_name("token") - .validator(clap_is_valid_pubkey) + .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TOKEN_MINT_ADDRESS") .takes_value(true) .index(2) @@ -265,7 +261,7 @@ async fn main() -> Result<(), Box> { Additional accounts with known fixed addresses can be passed at the command line in the format ":". The role must be "readonly", "writable". "readonlySigner", or "writableSigner". -Additional acounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: +Additional accounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: ```json { @@ -310,7 +306,7 @@ extraMetas: Arg::new("mint_authority") .long("mint-authority") .value_name("KEYPAIR") - .validator(|s| is_valid_signer(s)) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .takes_value(true) .global(true) .help("Filepath or URL to mint-authority keypair [default: client keypair]"), @@ -321,7 +317,7 @@ extraMetas: .about("Update the extra account metas account for a transfer hook program") .arg( Arg::with_name("program_id") - .validator(clap_is_valid_pubkey) + .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TRANSFER_HOOK_PROGRAM") .takes_value(true) .index(1) @@ -330,7 +326,7 @@ extraMetas: ) .arg( Arg::with_name("token") - .validator(clap_is_valid_pubkey) + .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TOKEN_MINT_ADDRESS") .takes_value(true) .index(2) @@ -349,7 +345,7 @@ extraMetas: Additional accounts with known fixed addresses can be passed at the command line in the format ":". The role must be "readonly", "writable". "readonlySigner", or "writableSigner". -Additional acounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: +Additional accounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: ```json { @@ -394,7 +390,7 @@ extraMetas: Arg::new("mint_authority") .long("mint-authority") .value_name("KEYPAIR") - .validator(|s| is_valid_signer(s)) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .takes_value(true) .global(true) .help("Filepath or URL to mint-authority keypair [default: client keypair]"), From 72217ca0cf346319294eeddaf34dcb5aabd8bf72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:03:22 +0200 Subject: [PATCH 061/154] build(deps): bump serde_json from 1.0.115 to 1.0.116 (#6584) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.115 to 1.0.116. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.115...v1.0.116) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 977ddca..f6c4857 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } -serde_json = "1.0.115" +serde_json = "1.0.116" serde_yaml = "0.9.34" [dev-dependencies] From 68885964569d5f0551da818e315c1cebf6089c2a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 12:33:26 +0200 Subject: [PATCH 062/154] build(deps): bump serde from 1.0.197 to 1.0.198 (#6589) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.197 to 1.0.198. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.197...v1.0.198) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index f6c4857..390ef44 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tl strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.197", features = ["derive"] } +serde = { version = "1.0.198", features = ["derive"] } serde_json = "1.0.116" serde_yaml = "0.9.34" From 0f803f248cdc6aed9e60aa8a9abd949a52ecaf47 Mon Sep 17 00:00:00 2001 From: samkim-crypto Date: Wed, 24 Apr 2024 12:01:47 +0900 Subject: [PATCH 063/154] Bump solana version to 1.18.11 (#6624) upgrade solana version to 1.18.11 --- clients/cli/Cargo.toml | 14 +++++++------- interface/Cargo.toml | 2 +- program/Cargo.toml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 390ef44..02e916f 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -11,12 +11,12 @@ version = "0.2.0" [dependencies] clap = { version = "3", features = ["cargo"] } futures-util = "0.3.30" -solana-clap-v3-utils = ">=1.18.2,<=2" -solana-cli-config = ">=1.18.2,<=2" -solana-client = ">=1.18.2,<=2" -solana-logger = ">=1.18.2,<=2" -solana-remote-wallet = ">=1.18.2,<=2" -solana-sdk = ">=1.18.2,<=2" +solana-clap-v3-utils = ">=1.18.11,<=2" +solana-cli-config = ">=1.18.11,<=2" +solana-client = ">=1.18.11,<=2" +solana-logger = ">=1.18.11,<=2" +solana-remote-wallet = ">=1.18.11,<=2" +solana-sdk = ">=1.18.11,<=2" spl-transfer-hook-interface = { version = "0.6.3", path = "../interface" } spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.26" @@ -27,7 +27,7 @@ serde_json = "1.0.116" serde_yaml = "0.9.34" [dev-dependencies] -solana-test-validator = ">=1.18.2,<=2" +solana-test-validator = ">=1.18.11,<=2" spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.9.2", path = "../../client" } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 52cb6c7..4ad60a3 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" bytemuck = { version = "1.15.0", features = ["derive"] } -solana-program = ">=1.18.2,<=2" +solana-program = ">=1.18.11,<=2" spl-discriminator = { version = "0.2.2" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.4.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } diff --git a/program/Cargo.toml b/program/Cargo.toml index c4efb55..0ce30d4 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -13,15 +13,15 @@ test-sbf = [] [dependencies] arrayref = "0.3.7" -solana-program = ">=1.18.2,<=2" +solana-program = ">=1.18.11,<=2" spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.6.3" , path = "../interface" } spl-type-length-value = { version = "0.4.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] -solana-program-test = ">=1.18.2,<=2" -solana-sdk = ">=1.18.2,<=2" +solana-program-test = ">=1.18.11,<=2" +solana-sdk = ">=1.18.11,<=2" [lib] crate-type = ["cdylib", "lib"] From b38c71d2154156e87ae802dde40adfd4185ee38e Mon Sep 17 00:00:00 2001 From: samkim-crypto Date: Thu, 25 Apr 2024 04:08:36 +0900 Subject: [PATCH 064/154] [transfer-hook-cli] Replace `pubkey_of_signer` with `pubkey_from_source` (#6625) replace `pubkey_of_signer` with `pubkey_from_source` --- clients/cli/src/main.rs | 43 +++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index a6bb65c..4dae0be 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -5,10 +5,11 @@ use { clap::{crate_description, crate_name, crate_version, Arg, Command}, solana_clap_v3_utils::{ input_parsers::{ - parse_url_or_moniker, pubkey_of_signer, signer::SignerSourceParserBuilder, + parse_url_or_moniker, + signer::{SignerSource, SignerSourceParserBuilder}, }, input_validators::normalize_to_url_if_moniker, - keypair::DefaultSigner, + keypair::{pubkey_from_source, DefaultSigner}, }, solana_client::nonblocking::rpc_client::RpcClient, solana_remote_wallet::remote_wallet::RemoteWalletManager, @@ -443,12 +444,23 @@ extraMetas: match (command, matches) { ("create-extra-metas", arg_matches) => { - let program_id = pubkey_of_signer(arg_matches, "program_id", &mut wallet_manager) - .unwrap() + let program_id_source = arg_matches + .try_get_one::("program_id")? .unwrap(); - let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager) - .unwrap() + let program_id = pubkey_from_source( + arg_matches, + program_id_source, + "program_id", + &mut wallet_manager, + ) + .unwrap(); + + let token_source = arg_matches + .try_get_one::("program_id")? .unwrap(); + let token = pubkey_from_source(arg_matches, token_source, "token", &mut wallet_manager) + .unwrap(); + let transfer_hook_accounts = arg_matches .get_many::>("transfer_hook_accounts") .unwrap_or_default() @@ -483,12 +495,23 @@ extraMetas: println!("Signature: {signature}"); } ("update-extra-metas", arg_matches) => { - let program_id = pubkey_of_signer(arg_matches, "program_id", &mut wallet_manager) - .unwrap() + let program_id_source = arg_matches + .try_get_one::("program_id")? .unwrap(); - let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager) - .unwrap() + let program_id = pubkey_from_source( + arg_matches, + program_id_source, + "program_id", + &mut wallet_manager, + ) + .unwrap(); + + let token_source = arg_matches + .try_get_one::("program_id")? .unwrap(); + let token = pubkey_from_source(arg_matches, token_source, "token", &mut wallet_manager) + .unwrap(); + let transfer_hook_accounts = arg_matches .get_many::>("transfer_hook_accounts") .unwrap_or_default() From ab5553463596fc77bc91d2a896fb2b760befc4f7 Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 26 Apr 2024 01:52:42 +0200 Subject: [PATCH 065/154] token-client: Bump for token-cli release (#6636) --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 02e916f..9e2deb5 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -29,7 +29,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = ">=1.18.11,<=2" spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } -spl-token-client = { version = "0.9.2", path = "../../client" } +spl-token-client = { version = "0.10.0", path = "../../client" } [[bin]] name = "spl-transfer-hook" From 1bab0c668c7b24bcc97e213073ede7ea37052deb Mon Sep 17 00:00:00 2001 From: Joe C Date: Fri, 26 Apr 2024 12:31:27 -0500 Subject: [PATCH 066/154] transfer-hook-cli: patch token arg (#6643) --- clients/cli/src/main.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index 4dae0be..2ffd54c 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -455,9 +455,7 @@ extraMetas: ) .unwrap(); - let token_source = arg_matches - .try_get_one::("program_id")? - .unwrap(); + let token_source = arg_matches.try_get_one::("token")?.unwrap(); let token = pubkey_from_source(arg_matches, token_source, "token", &mut wallet_manager) .unwrap(); @@ -506,9 +504,7 @@ extraMetas: ) .unwrap(); - let token_source = arg_matches - .try_get_one::("program_id")? - .unwrap(); + let token_source = arg_matches.try_get_one::("token")?.unwrap(); let token = pubkey_from_source(arg_matches, token_source, "token", &mut wallet_manager) .unwrap(); From 1bc0c2065aac2aa40aee0eaa78970ffbc34f7065 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:51:40 +0200 Subject: [PATCH 067/154] build(deps): bump serde from 1.0.198 to 1.0.199 (#6647) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.198 to 1.0.199. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.198...v1.0.199) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 9e2deb5..230ba6a 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tl strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.198", features = ["derive"] } +serde = { version = "1.0.199", features = ["derive"] } serde_json = "1.0.116" serde_yaml = "0.9.34" From a9d449a9cebcc1cedcf9eac6ec76f2d813335796 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 May 2024 12:52:05 +0200 Subject: [PATCH 068/154] build(deps): bump serde from 1.0.199 to 1.0.200 (#6679) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.199 to 1.0.200. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.199...v1.0.200) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 230ba6a..bd94202 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tl strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.199", features = ["derive"] } +serde = { version = "1.0.200", features = ["derive"] } serde_json = "1.0.116" serde_yaml = "0.9.34" From 423ef190a3826e399dcc549b650dfd866363db73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 12:51:47 +0200 Subject: [PATCH 069/154] build(deps): bump serde_json from 1.0.116 to 1.0.117 (#6705) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.116 to 1.0.117. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.116...v1.0.117) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index bd94202..1cd6ac1 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.200", features = ["derive"] } -serde_json = "1.0.116" +serde_json = "1.0.117" serde_yaml = "0.9.34" [dev-dependencies] From 60bc3e50be8d26c6d63e463624b6b8c132a819f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 13:20:31 +0200 Subject: [PATCH 070/154] build(deps): bump serde from 1.0.200 to 1.0.201 (#6706) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.200 to 1.0.201. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.200...v1.0.201) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 1cd6ac1..b086250 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tl strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.200", features = ["derive"] } +serde = { version = "1.0.201", features = ["derive"] } serde_json = "1.0.117" serde_yaml = "0.9.34" From 7f68e0da86cf80750a05ef948ef241dd2018a3dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 22:20:09 +0200 Subject: [PATCH 071/154] build(deps): bump bytemuck from 1.15.0 to 1.16.0 (#6729) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.15.0 to 1.16.0. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.15.0...v1.16.0) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 4ad60a3..224e6ab 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" -bytemuck = { version = "1.15.0", features = ["derive"] } +bytemuck = { version = "1.16.0", features = ["derive"] } solana-program = ">=1.18.11,<=2" spl-discriminator = { version = "0.2.2" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.4.0" , path = "../../../libraries/program-error" } From cd0f50ec8bbdc31beb1b66732b824b1592c51e99 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 12:24:00 +0200 Subject: [PATCH 072/154] build(deps): bump serde from 1.0.201 to 1.0.202 (#6733) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.201 to 1.0.202. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.201...v1.0.202) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index b086250..5393c69 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tl strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.201", features = ["derive"] } +serde = { version = "1.0.202", features = ["derive"] } serde_json = "1.0.117" serde_yaml = "0.9.34" From 7b64ac44cce9227c4d359f580deb39de094b6456 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 17:02:42 +0200 Subject: [PATCH 073/154] build(deps): bump serde from 1.0.202 to 1.0.203 (#6763) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.202 to 1.0.203. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.202...v1.0.203) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 5393c69..42144ec 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tl strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.202", features = ["derive"] } +serde = { version = "1.0.203", features = ["derive"] } serde_json = "1.0.117" serde_yaml = "0.9.34" From 3376b16001876801765298046f9c0c47b9d74791 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 22:41:35 +0200 Subject: [PATCH 074/154] build(deps): bump tokio from 1.37.0 to 1.38.0 (#6774) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.37.0 to 1.38.0. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.37.0...tokio-1.38.0) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 224e6ab..d2d9201 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -21,7 +21,7 @@ spl-pod = { version = "0.2.2", path = "../../../libraries/pod" } crate-type = ["cdylib", "lib"] [dev-dependencies] -tokio = { version = "1.37.0", features = ["full"] } +tokio = { version = "1.38.0", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From ff9de03691c2aff2214f722f5ea68a136c0e05d2 Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 7 Jun 2024 15:45:50 +0200 Subject: [PATCH 075/154] transfer-hook-example: Only allow one mint to initialize (#6812) * transfer-hook-example: Only allow one mint * Add a crate feature to fix downstream tests easily --- clients/cli/Cargo.toml | 1 + clients/cli/src/main.rs | 87 ++++++++++++++++++++----------------- program/Cargo.toml | 2 + program/src/lib.rs | 12 +++++ program/src/processor.rs | 7 +++ program/tests/functional.rs | 75 +++++++++++++++++++++++++++++--- 6 files changed, 139 insertions(+), 45 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 42144ec..ecdc2fe 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -30,6 +30,7 @@ serde_yaml = "0.9.34" solana-test-validator = ">=1.18.11,<=2" spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.10.0", path = "../../client" } +spl-transfer-hook-example = { version = "0.6.0", path = "../example" } [[bin]] name = "spl-transfer-hook" diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index 2ffd54c..6772138 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -263,7 +263,7 @@ async fn main() -> Result<(), Box> { Additional accounts with known fixed addresses can be passed at the command line in the format ":". The role must be "readonly", "writable". "readonlySigner", or "writableSigner". Additional accounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: - + ```json { "extraMetas": [ @@ -347,7 +347,7 @@ extraMetas: Additional accounts with known fixed addresses can be passed at the command line in the format ":". The role must be "readonly", "writable". "readonlySigner", or "writableSigner". Additional accounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: - + ```json { "extraMetas": [ @@ -551,19 +551,27 @@ extraMetas: mod test { use { super::*, - solana_sdk::{bpf_loader_upgradeable, instruction::AccountMeta, signer::keypair::Keypair}, + solana_sdk::{ + account::Account, bpf_loader_upgradeable, instruction::AccountMeta, + program_option::COption, signer::keypair::Keypair, + }, solana_test_validator::{TestValidator, TestValidatorGenesis, UpgradeableProgramInfo}, + spl_token_2022::{ + extension::{ExtensionType, StateWithExtensionsMut}, + state::Mint, + }, spl_token_client::{ - client::{ - ProgramClient, ProgramRpcClient, ProgramRpcClientSendTransaction, SendTransaction, - SimulateTransaction, - }, + client::{ProgramRpcClient, ProgramRpcClientSendTransaction}, token::Token, }, std::{path::PathBuf, sync::Arc}, }; - async fn new_validator_for_test(program_id: Pubkey) -> (TestValidator, Keypair) { + async fn new_validator_for_test( + program_id: Pubkey, + mint_authority: &Pubkey, + decimals: u8, + ) -> (TestValidator, Keypair) { solana_logger::setup(); let mut test_validator_genesis = TestValidatorGenesis::default(); test_validator_genesis.add_upgradeable_programs_with_path(&[UpgradeableProgramInfo { @@ -572,36 +580,41 @@ mod test { program_path: PathBuf::from("../../../target/deploy/spl_transfer_hook_example.so"), upgrade_authority: Pubkey::new_unique(), }]); - test_validator_genesis.start_async().await - } - async fn setup_mint( - program_id: &Pubkey, - mint_authority: &Pubkey, - decimals: u8, - payer: Arc, - client: Arc>, - ) -> Token { - let mint_account = Keypair::new(); - let token = Token::new( - client, - program_id, - &mint_account.pubkey(), - Some(decimals), - payer, + let mint_size = ExtensionType::try_calculate_account_len::(&[]).unwrap(); + let mut mint_data = vec![0; mint_size]; + let mut state = + StateWithExtensionsMut::::unpack_uninitialized(&mut mint_data).unwrap(); + let token_amount = 1_000_000_000_000; + state.base = Mint { + mint_authority: COption::Some(*mint_authority), + supply: token_amount, + decimals, + is_initialized: true, + freeze_authority: COption::None, + }; + state.pack_base(); + test_validator_genesis.add_account( + spl_transfer_hook_example::mint::id(), + Account { + lamports: 1_000_000_000, + data: mint_data, + owner: spl_token_2022::id(), + ..Account::default() + } + .into(), ); - token - .create_mint(mint_authority, None, vec![], &[&mint_account]) - .await - .unwrap(); - token + test_validator_genesis.start_async().await } #[tokio::test] async fn test_create() { let program_id = Pubkey::new_unique(); - let (test_validator, payer) = new_validator_for_test(program_id).await; + let decimals = 2; + let mint_authority = Keypair::new(); + let (test_validator, payer) = + new_validator_for_test(program_id, &mint_authority.pubkey(), decimals).await; let payer: Arc = Arc::new(payer); let rpc_client = Arc::new(test_validator.get_async_rpc_client()); let client = Arc::new(ProgramRpcClient::new( @@ -609,17 +622,13 @@ mod test { ProgramRpcClientSendTransaction, )); - let mint_authority = Keypair::new(); - let decimals = 2; - - let token = setup_mint( + let token = Token::new( + client.clone(), &spl_token_2022::id(), - &mint_authority.pubkey(), - decimals, + &spl_transfer_hook_example::mint::id(), + Some(decimals), payer.clone(), - client.clone(), - ) - .await; + ); let required_address = Pubkey::new_unique(); let accounts = vec![AccountMeta::new_readonly(required_address, false)]; diff --git a/program/Cargo.toml b/program/Cargo.toml index 0ce30d4..b5b0056 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -8,8 +8,10 @@ license = "Apache-2.0" edition = "2021" [features] +default = ["forbid-additional-mints"] no-entrypoint = [] test-sbf = [] +forbid-additional-mints = [] [dependencies] arrayref = "0.3.7" diff --git a/program/src/lib.rs b/program/src/lib.rs index 9db06d9..aa49d80 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -16,3 +16,15 @@ mod entrypoint; // Export current sdk types for downstream users building with a different sdk // version pub use solana_program; + +/// Place the mint id that you want to target with your transfer hook program. +/// Any other mint will fail to initialize, protecting the transfer hook program +/// from rogue mints trying to get access to accounts. +/// +/// There are many situations where it's reasonable to support multiple mints +/// with one transfer-hook program, but because it's easy to make something +/// unsafe, this simple example implementation only allows for one mint. +#[cfg(feature = "forbid-additional-mints")] +pub mod mint { + solana_program::declare_id!("Mint111111111111111111111111111111111111111"); +} diff --git a/program/src/processor.rs b/program/src/processor.rs index e398b20..8bac5a9 100644 --- a/program/src/processor.rs +++ b/program/src/processor.rs @@ -88,6 +88,13 @@ pub fn process_initialize_extra_account_meta_list( let authority_info = next_account_info(account_info_iter)?; let _system_program_info = next_account_info(account_info_iter)?; + // check that the one mint we want to target is trying to create extra + // account metas + #[cfg(feature = "forbid-additional-mints")] + if *mint_info.key != crate::mint::id() { + return Err(ProgramError::InvalidArgument); + } + // check that the mint authority is valid without fully deserializing let mint_data = mint_info.try_borrow_data()?; let mint = StateWithExtensions::::unpack(&mint_data)?; diff --git a/program/tests/functional.rs b/program/tests/functional.rs index 82a5937..0d64d1a 100644 --- a/program/tests/functional.rs +++ b/program/tests/functional.rs @@ -142,7 +142,7 @@ async fn success_execute() { let token_program_id = spl_token_2022::id(); let wallet = Keypair::new(); - let mint_address = Pubkey::new_unique(); + let mint_address = spl_transfer_hook_example::mint::id(); let mint_authority = Keypair::new(); let mint_authority_pubkey = mint_authority.pubkey(); let source = Pubkey::new_unique(); @@ -439,7 +439,7 @@ async fn fail_incorrect_derivation() { let token_program_id = spl_token_2022::id(); let wallet = Keypair::new(); - let mint_address = Pubkey::new_unique(); + let mint_address = spl_transfer_hook_example::mint::id(); let mint_authority = Keypair::new(); let mint_authority_pubkey = mint_authority.pubkey(); let source = Pubkey::new_unique(); @@ -495,6 +495,69 @@ async fn fail_incorrect_derivation() { ); } +#[tokio::test] +async fn fail_incorrect_mint() { + let program_id = Pubkey::new_unique(); + let mut program_test = setup(&program_id); + + let token_program_id = spl_token_2022::id(); + let wallet = Keypair::new(); + // wrong mint, only `spl_transfer_hook_example::mint::id()` allowed + let mint_address = Pubkey::new_unique(); + let mint_authority = Keypair::new(); + let mint_authority_pubkey = mint_authority.pubkey(); + let source = Pubkey::new_unique(); + let destination = Pubkey::new_unique(); + let decimals = 2; + setup_token_accounts( + &mut program_test, + &token_program_id, + &mint_address, + &mint_authority_pubkey, + &source, + &destination, + &wallet.pubkey(), + decimals, + true, + ); + + let extra_account_metas = get_extra_account_metas_address(&mint_address, &program_id); + + let mut context = program_test.start_with_context().await; + let rent = context.banks_client.get_rent().await.unwrap(); + let rent_lamports = rent.minimum_balance(ExtraAccountMetaList::size_of(0).unwrap()); + + let transaction = Transaction::new_signed_with_payer( + &[ + system_instruction::transfer( + &context.payer.pubkey(), + &extra_account_metas, + rent_lamports, + ), + initialize_extra_account_meta_list( + &program_id, + &extra_account_metas, + &mint_address, + &mint_authority_pubkey, + &[], + ), + ], + Some(&context.payer.pubkey()), + &[&context.payer, &mint_authority], + context.last_blockhash, + ); + let error = context + .banks_client + .process_transaction(transaction) + .await + .unwrap_err() + .unwrap(); + assert_eq!( + error, + TransactionError::InstructionError(1, InstructionError::InvalidArgument) + ); +} + /// Test program to CPI into default transfer-hook-interface program pub fn process_instruction( _program_id: &Pubkey, @@ -530,7 +593,7 @@ async fn success_on_chain_invoke() { let token_program_id = spl_token_2022::id(); let wallet = Keypair::new(); - let mint_address = Pubkey::new_unique(); + let mint_address = spl_transfer_hook_example::mint::id(); let mint_authority = Keypair::new(); let mint_authority_pubkey = mint_authority.pubkey(); let source = Pubkey::new_unique(); @@ -673,7 +736,7 @@ async fn fail_without_transferring_flag() { let token_program_id = spl_token_2022::id(); let wallet = Keypair::new(); - let mint_address = Pubkey::new_unique(); + let mint_address = spl_transfer_hook_example::mint::id(); let mint_authority = Keypair::new(); let mint_authority_pubkey = mint_authority.pubkey(); let source = Pubkey::new_unique(); @@ -767,7 +830,7 @@ async fn success_on_chain_invoke_with_updated_extra_account_metas() { let token_program_id = spl_token_2022::id(); let wallet = Keypair::new(); - let mint_address = Pubkey::new_unique(); + let mint_address = spl_transfer_hook_example::mint::id(); let mint_authority = Keypair::new(); let mint_authority_pubkey = mint_authority.pubkey(); let source = Pubkey::new_unique(); @@ -970,7 +1033,7 @@ async fn success_execute_with_updated_extra_account_metas() { let token_program_id = spl_token_2022::id(); let wallet = Keypair::new(); - let mint_address = Pubkey::new_unique(); + let mint_address = spl_transfer_hook_example::mint::id(); let mint_authority = Keypair::new(); let mint_authority_pubkey = mint_authority.pubkey(); let source = Pubkey::new_unique(); From 3d354e1e00861a1ee51e62a26b824be90e2928c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 15:04:54 +0200 Subject: [PATCH 076/154] build(deps): bump bytemuck from 1.16.0 to 1.16.1 (#6875) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.16.0 to 1.16.1. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.16.0...v1.16.1) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index d2d9201..cfb159d 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" -bytemuck = { version = "1.16.0", features = ["derive"] } +bytemuck = { version = "1.16.1", features = ["derive"] } solana-program = ">=1.18.11,<=2" spl-discriminator = { version = "0.2.2" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.4.0" , path = "../../../libraries/program-error" } From 1cc20765e547d11296e31aa1bf4c6efd0eb7238d Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 25 Jun 2024 11:11:23 +0200 Subject: [PATCH 077/154] deps: Upgrade to Solana v2 (#6908) * solana: Update deps to 2.0.0 * Update lockfile * Update toolchain version * Update nightly version * Fix check issues * Fix clippy * Revert upgrade for account compression libs * Install build deps for serde test * Fixup versions * Fixup twoxtx build * Revert solana install version * Actually, get version 2.0.0 from the correct place --- clients/cli/Cargo.toml | 14 +++++++------- clients/cli/src/main.rs | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index ecdc2fe..43d6ea8 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -11,12 +11,12 @@ version = "0.2.0" [dependencies] clap = { version = "3", features = ["cargo"] } futures-util = "0.3.30" -solana-clap-v3-utils = ">=1.18.11,<=2" -solana-cli-config = ">=1.18.11,<=2" -solana-client = ">=1.18.11,<=2" -solana-logger = ">=1.18.11,<=2" -solana-remote-wallet = ">=1.18.11,<=2" -solana-sdk = ">=1.18.11,<=2" +solana-clap-v3-utils = "2.0.0" +solana-cli-config = "2.0.0" +solana-client = "2.0.0" +solana-logger = "2.0.0" +solana-remote-wallet = "2.0.0" +solana-sdk = "2.0.0" spl-transfer-hook-interface = { version = "0.6.3", path = "../interface" } spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.26" @@ -27,7 +27,7 @@ serde_json = "1.0.117" serde_yaml = "0.9.34" [dev-dependencies] -solana-test-validator = ">=1.18.11,<=2" +solana-test-validator = "2.0.0" spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.10.0", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index 6772138..5566fe7 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -631,7 +631,7 @@ mod test { ); let required_address = Pubkey::new_unique(); - let accounts = vec![AccountMeta::new_readonly(required_address, false)]; + let accounts = [AccountMeta::new_readonly(required_address, false)]; process_create_extra_account_metas( &rpc_client, &program_id, diff --git a/interface/Cargo.toml b/interface/Cargo.toml index cfb159d..6d7e7cb 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] arrayref = "0.3.7" bytemuck = { version = "1.16.1", features = ["derive"] } -solana-program = ">=1.18.11,<=2" +solana-program = "2.0.0" spl-discriminator = { version = "0.2.2" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.4.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } diff --git a/program/Cargo.toml b/program/Cargo.toml index b5b0056..65dac3a 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -15,15 +15,15 @@ forbid-additional-mints = [] [dependencies] arrayref = "0.3.7" -solana-program = ">=1.18.11,<=2" +solana-program = "2.0.0" spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.6.3" , path = "../interface" } spl-type-length-value = { version = "0.4.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] -solana-program-test = ">=1.18.11,<=2" -solana-sdk = ">=1.18.11,<=2" +solana-program-test = "2.0.0" +solana-sdk = "2.0.0" [lib] crate-type = ["cdylib", "lib"] From d5bf99bfe38cae3e37791f1d542892b5dc9b920d Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 25 Jun 2024 12:04:41 +0200 Subject: [PATCH 078/154] discriminator: Bump to 0.3.0 for Solana v2 (#6911) --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 6d7e7cb..774b842 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -11,7 +11,7 @@ edition = "2021" arrayref = "0.3.7" bytemuck = { version = "1.16.1", features = ["derive"] } solana-program = "2.0.0" -spl-discriminator = { version = "0.2.2" , path = "../../../libraries/discriminator" } +spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.4.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.4.3" , path = "../../../libraries/type-length-value" } From 73b941b4028079793082b4868c38ad9053c60bc7 Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 25 Jun 2024 12:50:09 +0200 Subject: [PATCH 079/154] program-error: Bump to 0.5.0 for Solana v2 compatibility (#6914) --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 774b842..cc487f5 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -12,7 +12,7 @@ arrayref = "0.3.7" bytemuck = { version = "1.16.1", features = ["derive"] } solana-program = "2.0.0" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } -spl-program-error = { version = "0.4.0" , path = "../../../libraries/program-error" } +spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.4.3" , path = "../../../libraries/type-length-value" } spl-pod = { version = "0.2.2", path = "../../../libraries/pod" } From 34013b10b3ec36d07b0916209e988a21cae3ae8e Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 25 Jun 2024 13:41:25 +0200 Subject: [PATCH 080/154] pod: Bump to 0.3.0 for Solana v2 compat (#6917) --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index cc487f5..aa7bee1 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -15,7 +15,7 @@ spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminat spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.4.3" , path = "../../../libraries/type-length-value" } -spl-pod = { version = "0.2.2", path = "../../../libraries/pod" } +spl-pod = { version = "0.3.0", path = "../../../libraries/pod" } [lib] crate-type = ["cdylib", "lib"] From 464db8abb3188e52ae7a3b2f494f65574d846ac5 Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 25 Jun 2024 14:10:20 +0200 Subject: [PATCH 081/154] tlv: Bump to 0.5.0 for Solana v2 compatibility (#6919) --- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index aa7bee1..3d3f47a 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -14,7 +14,7 @@ solana-program = "2.0.0" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } -spl-type-length-value = { version = "0.4.3" , path = "../../../libraries/type-length-value" } +spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } spl-pod = { version = "0.3.0", path = "../../../libraries/pod" } [lib] diff --git a/program/Cargo.toml b/program/Cargo.toml index 65dac3a..171ccd1 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -19,7 +19,7 @@ solana-program = "2.0.0" spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.6.3" , path = "../interface" } -spl-type-length-value = { version = "0.4.3" , path = "../../../libraries/type-length-value" } +spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } [dev-dependencies] solana-program-test = "2.0.0" From 722855d0d6591c3bba493b0c01a2432c5db6abd1 Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 25 Jun 2024 14:36:54 +0200 Subject: [PATCH 082/154] tlv-account-resolution: Bump to 0.7.0 for Solana v2 (#6920) --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 43d6ea8..ab8dbb7 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -18,7 +18,7 @@ solana-logger = "2.0.0" solana-remote-wallet = "2.0.0" solana-sdk = "2.0.0" spl-transfer-hook-interface = { version = "0.6.3", path = "../interface" } -spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } +spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 3d3f47a..7ef7aa1 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -13,7 +13,7 @@ bytemuck = { version = "1.16.1", features = ["derive"] } solana-program = "2.0.0" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } -spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } spl-pod = { version = "0.3.0", path = "../../../libraries/pod" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 171ccd1..30c9345 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -16,7 +16,7 @@ forbid-additional-mints = [] [dependencies] arrayref = "0.3.7" solana-program = "2.0.0" -spl-tlv-account-resolution = { version = "0.6.3" , path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.6.3" , path = "../interface" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } From 3e30c1b24f44ef2a9e415c16691ed1e3092cf534 Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 25 Jun 2024 15:10:49 +0200 Subject: [PATCH 083/154] token-{metadata,group,transfer-hook}-interface: Bump for Solana v2 compatibility (#6929) * token-metadata-interface: Bump to 0.4.0 for Solana v2 * token-group-interface: Bump to v0.3.0 for Solana v2 * transfer-hook-interface: Bump to 0.7.0 * Update lockfile --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index ab8dbb7..1f5ef8c 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -17,8 +17,8 @@ solana-client = "2.0.0" solana-logger = "2.0.0" solana-remote-wallet = "2.0.0" solana-sdk = "2.0.0" -spl-transfer-hook-interface = { version = "0.6.3", path = "../interface" } spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } +spl-transfer-hook-interface = { version = "0.7.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 7ef7aa1..c798575 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.6.3" +version = "0.7.0" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" diff --git a/program/Cargo.toml b/program/Cargo.toml index 30c9345..ce80582 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -18,7 +18,7 @@ arrayref = "0.3.7" solana-program = "2.0.0" spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.6.3" , path = "../interface" } +spl-transfer-hook-interface = { version = "0.7.0" , path = "../interface" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } [dev-dependencies] From f66830018c9c7591074f4216d727c6895662bee3 Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 25 Jun 2024 15:42:18 +0200 Subject: [PATCH 084/154] token-2022: Bump to v4 for Solana v2 compatibility (#6930) --- clients/cli/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 1f5ef8c..38b37c7 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -28,7 +28,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = "2.0.0" -spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "4.0.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.10.0", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } diff --git a/program/Cargo.toml b/program/Cargo.toml index ce80582..0526c33 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -17,7 +17,7 @@ forbid-additional-mints = [] arrayref = "0.3.7" solana-program = "2.0.0" spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } -spl-token-2022 = { version = "3.0.2", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "4.0.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.7.0" , path = "../interface" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } From c3052fb0cf108df62cc0b59834434ac96e6e5f36 Mon Sep 17 00:00:00 2001 From: Jon C Date: Wed, 26 Jun 2024 01:39:08 +0200 Subject: [PATCH 085/154] token-client: Bump to v0.11 for Solana v2 compatibility (#6932) --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 38b37c7..e3eaaf0 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -29,7 +29,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = "2.0.0" spl-token-2022 = { version = "4.0.0", path = "../../program-2022", features = ["no-entrypoint"] } -spl-token-client = { version = "0.10.0", path = "../../client" } +spl-token-client = { version = "0.11.0", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } [[bin]] From 19f215730b99765f26f6a26ddc0555f630f44052 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2024 02:21:40 +0200 Subject: [PATCH 086/154] build(deps): bump serde_json from 1.0.117 to 1.0.118 (#6909) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.117 to 1.0.118. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.117...v1.0.118) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index e3eaaf0..6090635 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.203", features = ["derive"] } -serde_json = "1.0.117" +serde_json = "1.0.118" serde_yaml = "0.9.34" [dev-dependencies] From b1df340853dfb36cd7d590e3f4143cb24f9e0764 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:20:42 +0200 Subject: [PATCH 087/154] build(deps): bump serde_json from 1.0.118 to 1.0.119 (#6957) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.118 to 1.0.119. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.118...v1.0.119) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 6090635..dba04d6 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.203", features = ["derive"] } -serde_json = "1.0.118" +serde_json = "1.0.119" serde_yaml = "0.9.34" [dev-dependencies] From fac9efbd399a223f71c2c4f073df83a688a51633 Mon Sep 17 00:00:00 2001 From: samkim-crypto Date: Tue, 2 Jul 2024 21:10:57 +0900 Subject: [PATCH 088/154] [transfer-hook] Remove clap deprecated functions (#6952) --- clients/cli/src/main.rs | 138 +++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 78 deletions(-) diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index 5566fe7..bf7273b 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -2,14 +2,14 @@ pub mod meta; use { crate::meta::parse_transfer_hook_account_arg, - clap::{crate_description, crate_name, crate_version, Arg, Command}, + clap::{crate_description, crate_name, crate_version, Arg, ArgAction, Command}, solana_clap_v3_utils::{ input_parsers::{ parse_url_or_moniker, signer::{SignerSource, SignerSourceParserBuilder}, }, input_validators::normalize_to_url_if_moniker, - keypair::{pubkey_from_source, DefaultSigner}, + keypair::signer_from_path, }, solana_client::nonblocking::rpc_client::RpcClient, solana_remote_wallet::remote_wallet::RemoteWalletManager, @@ -233,7 +233,7 @@ async fn main() -> Result<(), Box> { Command::new("create-extra-metas") .about("Create the extra account metas account for a transfer hook program") .arg( - Arg::with_name("program_id") + Arg::new("program_id") .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TRANSFER_HOOK_PROGRAM") .takes_value(true) @@ -242,7 +242,7 @@ async fn main() -> Result<(), Box> { .help("The transfer hook program id"), ) .arg( - Arg::with_name("token") + Arg::new("token") .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TOKEN_MINT_ADDRESS") .takes_value(true) @@ -251,11 +251,11 @@ async fn main() -> Result<(), Box> { .help("The token mint address for the transfer hook"), ) .arg( - Arg::with_name("transfer_hook_accounts") + Arg::new("transfer_hook_accounts") .value_parser(parse_transfer_hook_account_arg) .value_name("TRANSFER_HOOK_ACCOUNTS") .takes_value(true) - .multiple(true) + .action(ArgAction::Append) .min_values(0) .index(3) .help(r#"Additional account(s) required for a transfer hook and their respective configurations, whether they are a fixed address or PDA. @@ -317,7 +317,7 @@ extraMetas: Command::new("update-extra-metas") .about("Update the extra account metas account for a transfer hook program") .arg( - Arg::with_name("program_id") + Arg::new("program_id") .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TRANSFER_HOOK_PROGRAM") .takes_value(true) @@ -326,7 +326,7 @@ extraMetas: .help("The transfer hook program id"), ) .arg( - Arg::with_name("token") + Arg::new("token") .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TOKEN_MINT_ADDRESS") .takes_value(true) @@ -335,11 +335,11 @@ extraMetas: .help("The token mint address for the transfer hook"), ) .arg( - Arg::with_name("transfer_hook_accounts") + Arg::new("transfer_hook_accounts") .value_parser(parse_transfer_hook_account_arg) .value_name("TRANSFER_HOOK_ACCOUNTS") .takes_value(true) - .multiple(true) + .action(ArgAction::Append) .min_values(0) .index(3) .help(r#"Additional account(s) required for a transfer hook and their respective configurations, whether they are a fixed address or PDA. @@ -401,37 +401,37 @@ extraMetas: let (command, matches) = app_matches.subcommand().unwrap(); let mut wallet_manager: Option> = None; - let cli_config = if let Some(config_file) = matches.value_of("config_file") { + let cli_config = if let Some(config_file) = matches.get_one::("config_file") { solana_cli_config::Config::load(config_file).unwrap_or_default() } else { solana_cli_config::Config::default() }; let config = { - let default_signer = DefaultSigner::new( - "fee_payer", - matches - .value_of("fee_payer") - .map(|s| s.to_string()) - .unwrap_or_else(|| cli_config.keypair_path.clone()), - ); + let default_signer = if let Some((signer, _)) = + SignerSource::try_get_signer(matches, "fee_payer", &mut wallet_manager)? + { + signer + } else { + signer_from_path( + matches, + &cli_config.keypair_path, + "fee_payer", + &mut wallet_manager, + )? + }; let json_rpc_url = normalize_to_url_if_moniker( matches - .value_of("json_rpc_url") + .get_one::("json_rpc_url") .unwrap_or(&cli_config.json_rpc_url), ); Config { commitment_config: CommitmentConfig::confirmed(), - default_signer: default_signer - .signer_from_path(matches, &mut wallet_manager) - .unwrap_or_else(|err| { - eprintln!("error: {err}"); - exit(1); - }), + default_signer, json_rpc_url, - verbose: matches.is_present("verbose"), + verbose: matches.try_contains_id("verbose")?, } }; solana_logger::setup_with_default("solana=info"); @@ -444,20 +444,11 @@ extraMetas: match (command, matches) { ("create-extra-metas", arg_matches) => { - let program_id_source = arg_matches - .try_get_one::("program_id")? - .unwrap(); - let program_id = pubkey_from_source( - arg_matches, - program_id_source, - "program_id", - &mut wallet_manager, - ) - .unwrap(); - - let token_source = arg_matches.try_get_one::("token")?.unwrap(); - let token = pubkey_from_source(arg_matches, token_source, "token", &mut wallet_manager) - .unwrap(); + let program_id = + SignerSource::try_get_pubkey(arg_matches, "program_id", &mut wallet_manager)? + .unwrap(); + let token = + SignerSource::try_get_pubkey(arg_matches, "token", &mut wallet_manager)?.unwrap(); let transfer_hook_accounts = arg_matches .get_many::>("transfer_hook_accounts") @@ -465,18 +456,18 @@ extraMetas: .flatten() .cloned() .collect(); - let mint_authority = DefaultSigner::new( - "mint_authority", - matches - .value_of("mint_authority") - .map(|s| s.to_string()) - .unwrap_or_else(|| cli_config.keypair_path.clone()), - ) - .signer_from_path(matches, &mut wallet_manager) - .unwrap_or_else(|err| { - eprintln!("error: {err}"); - exit(1); - }); + let mint_authority = if let Some((signer, _)) = + SignerSource::try_get_signer(matches, "mint_authority", &mut wallet_manager)? + { + signer + } else { + signer_from_path( + matches, + &cli_config.keypair_path, + "mint_authority", + &mut wallet_manager, + )? + }; let signature = process_create_extra_account_metas( &rpc_client, &program_id, @@ -493,20 +484,11 @@ extraMetas: println!("Signature: {signature}"); } ("update-extra-metas", arg_matches) => { - let program_id_source = arg_matches - .try_get_one::("program_id")? - .unwrap(); - let program_id = pubkey_from_source( - arg_matches, - program_id_source, - "program_id", - &mut wallet_manager, - ) - .unwrap(); - - let token_source = arg_matches.try_get_one::("token")?.unwrap(); - let token = pubkey_from_source(arg_matches, token_source, "token", &mut wallet_manager) - .unwrap(); + let program_id = + SignerSource::try_get_pubkey(arg_matches, "program_id", &mut wallet_manager)? + .unwrap(); + let token = + SignerSource::try_get_pubkey(arg_matches, "token", &mut wallet_manager)?.unwrap(); let transfer_hook_accounts = arg_matches .get_many::>("transfer_hook_accounts") @@ -514,18 +496,18 @@ extraMetas: .flatten() .cloned() .collect(); - let mint_authority = DefaultSigner::new( - "mint_authority", - matches - .value_of("mint_authority") - .map(|s| s.to_string()) - .unwrap_or_else(|| cli_config.keypair_path.clone()), - ) - .signer_from_path(matches, &mut wallet_manager) - .unwrap_or_else(|err| { - eprintln!("error: {err}"); - exit(1); - }); + let mint_authority = if let Some((signer, _)) = + SignerSource::try_get_signer(matches, "mint_authority", &mut wallet_manager)? + { + signer + } else { + signer_from_path( + matches, + &cli_config.keypair_path, + "mint_authority", + &mut wallet_manager, + )? + }; let signature = process_update_extra_account_metas( &rpc_client, &program_id, From 053e1564a78df18f8d8fc60b5e1bf4e6e011c60a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 22:38:22 +0200 Subject: [PATCH 089/154] build(deps): bump serde_json from 1.0.119 to 1.0.120 (#6966) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.119 to 1.0.120. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.119...v1.0.120) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index dba04d6..e47392c 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.203", features = ["derive"] } -serde_json = "1.0.119" +serde_json = "1.0.120" serde_yaml = "0.9.34" [dev-dependencies] From 44e1087f420abcb0af76a393e70489fbc5f2c702 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 21:54:31 +0200 Subject: [PATCH 090/154] build(deps): bump serde from 1.0.203 to 1.0.204 (#6983) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.203 to 1.0.204. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.203...v1.0.204) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index e47392c..2224303 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.7.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.203", features = ["derive"] } +serde = { version = "1.0.204", features = ["derive"] } serde_json = "1.0.120" serde_yaml = "0.9.34" From ddeb5cf1b6815e082dbbe08fc926d6a1cbf188fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:00:48 +0200 Subject: [PATCH 091/154] build(deps): bump tokio from 1.38.0 to 1.38.1 (#7022) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.38.0 to 1.38.1. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.38.0...tokio-1.38.1) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index c798575..66733a1 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -21,7 +21,7 @@ spl-pod = { version = "0.3.0", path = "../../../libraries/pod" } crate-type = ["cdylib", "lib"] [dev-dependencies] -tokio = { version = "1.38.0", features = ["full"] } +tokio = { version = "1.38.1", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From 840a912633095d884be55026399b7d3226f6e95d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 13:14:12 +0200 Subject: [PATCH 092/154] build(deps): bump arrayref from 0.3.7 to 0.3.8 (#7034) Bumps [arrayref](https://github.com/droundy/arrayref) from 0.3.7 to 0.3.8. - [Commits](https://github.com/droundy/arrayref/commits) --- updated-dependencies: - dependency-name: arrayref dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 66733a1..b60095b 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -8,7 +8,7 @@ license = "Apache-2.0" edition = "2021" [dependencies] -arrayref = "0.3.7" +arrayref = "0.3.8" bytemuck = { version = "1.16.1", features = ["derive"] } solana-program = "2.0.0" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 0526c33..6eb58bd 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -14,7 +14,7 @@ test-sbf = [] forbid-additional-mints = [] [dependencies] -arrayref = "0.3.7" +arrayref = "0.3.8" solana-program = "2.0.0" spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "4.0.0", path = "../../program-2022", features = ["no-entrypoint"] } From 71a0bea528dfd78fb3b1b8884fe19a827b4ceb54 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:54:53 +0200 Subject: [PATCH 093/154] build(deps): bump tokio from 1.38.1 to 1.39.1 (#7048) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.38.1 to 1.39.1. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.38.1...tokio-1.39.1) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index b60095b..2e3fb0c 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -21,7 +21,7 @@ spl-pod = { version = "0.3.0", path = "../../../libraries/pod" } crate-type = ["cdylib", "lib"] [dev-dependencies] -tokio = { version = "1.38.1", features = ["full"] } +tokio = { version = "1.39.1", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From dfb73f4e3a34f129c0b1bcf00b1b60fab4e4fbe6 Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 25 Jul 2024 16:53:13 +0200 Subject: [PATCH 094/154] ci: Bump crates to Solana 2.0.3 (#7047) * Run script * Update lockfile * Use "processed" instead of deprecated "recent" * Fixup account compression tests * account-compression: Remove `only` in test --- clients/cli/Cargo.toml | 14 +++++++------- interface/Cargo.toml | 2 +- program/Cargo.toml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 2224303..3ed2402 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -11,12 +11,12 @@ version = "0.2.0" [dependencies] clap = { version = "3", features = ["cargo"] } futures-util = "0.3.30" -solana-clap-v3-utils = "2.0.0" -solana-cli-config = "2.0.0" -solana-client = "2.0.0" -solana-logger = "2.0.0" -solana-remote-wallet = "2.0.0" -solana-sdk = "2.0.0" +solana-clap-v3-utils = "2.0.3" +solana-cli-config = "2.0.3" +solana-client = "2.0.3" +solana-logger = "2.0.3" +solana-remote-wallet = "2.0.3" +solana-sdk = "2.0.3" spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } spl-transfer-hook-interface = { version = "0.7.0", path = "../interface" } strum = "0.26" @@ -27,7 +27,7 @@ serde_json = "1.0.120" serde_yaml = "0.9.34" [dev-dependencies] -solana-test-validator = "2.0.0" +solana-test-validator = "2.0.3" spl-token-2022 = { version = "4.0.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.11.0", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 2e3fb0c..8ab712b 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] arrayref = "0.3.8" bytemuck = { version = "1.16.1", features = ["derive"] } -solana-program = "2.0.0" +solana-program = "2.0.3" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 6eb58bd..9df4d2a 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -15,15 +15,15 @@ forbid-additional-mints = [] [dependencies] arrayref = "0.3.8" -solana-program = "2.0.0" +solana-program = "2.0.3" spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "4.0.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.7.0" , path = "../interface" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } [dev-dependencies] -solana-program-test = "2.0.0" -solana-sdk = "2.0.0" +solana-program-test = "2.0.3" +solana-sdk = "2.0.3" [lib] crate-type = ["cdylib", "lib"] From a870b6cf810ef913338c1725a87ef6ecef294ada Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:01:55 +0200 Subject: [PATCH 095/154] build(deps): bump tokio from 1.39.1 to 1.39.2 (#7063) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.39.1 to 1.39.2. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.39.1...tokio-1.39.2) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 8ab712b..c120069 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -21,7 +21,7 @@ spl-pod = { version = "0.3.0", path = "../../../libraries/pod" } crate-type = ["cdylib", "lib"] [dev-dependencies] -tokio = { version = "1.39.1", features = ["full"] } +tokio = { version = "1.39.2", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From 499448d1b57c7c3aefd8220020b109c49ee2d3e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:02:05 +0200 Subject: [PATCH 096/154] build(deps): bump serde_json from 1.0.120 to 1.0.121 (#7062) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.120 to 1.0.121. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.120...v1.0.121) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 3ed2402..2a27ea9 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.204", features = ["derive"] } -serde_json = "1.0.120" +serde_json = "1.0.121" serde_yaml = "0.9.34" [dev-dependencies] From 8976f2857235bce1a371e724a3fb8397cbb36bee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:36:08 +0200 Subject: [PATCH 097/154] build(deps): bump bytemuck from 1.16.1 to 1.16.3 (#7077) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.16.1 to 1.16.3. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.16.1...v1.16.3) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index c120069..6b30494 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.8" -bytemuck = { version = "1.16.1", features = ["derive"] } +bytemuck = { version = "1.16.3", features = ["derive"] } solana-program = "2.0.3" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } From 1391a05b03b0021d9450951d3e0becd218f30cc8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 12:34:29 +0200 Subject: [PATCH 098/154] build(deps): bump serde_json from 1.0.121 to 1.0.122 (#7102) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.121 to 1.0.122. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.121...v1.0.122) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 2a27ea9..9696309 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.204", features = ["derive"] } -serde_json = "1.0.121" +serde_json = "1.0.122" serde_yaml = "0.9.34" [dev-dependencies] From e6cf10bc12da80221a91effb29039e5b4fdbf2ef Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 2 Aug 2024 19:54:27 +0200 Subject: [PATCH 099/154] transfer-hook: Relax requirement of validation account (#7099) * transfer-hook-interface: Allow validation pubkey to be missing * token-2022: Add end-to-end test with it working --- interface/src/instruction.rs | 12 +-- interface/src/offchain.rs | 4 +- interface/src/onchain.rs | 176 ++++++++++++++++++++--------------- 3 files changed, 112 insertions(+), 80 deletions(-) diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 39639d5..8888054 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -25,9 +25,9 @@ pub enum TransferHookInstruction { /// 1. `[]` Token mint /// 2. `[]` Destination account /// 3. `[]` Source account's owner/delegate - /// 4. `[]` Validation account - /// 5..5+M `[]` `M` additional accounts, written in validation account - /// data + /// 4. `[]` (Optional) Validation account + /// 5..5+M `[]` `M` optional additional accounts, written in validation + /// account data Execute { /// Amount of tokens to transfer amount: u64, @@ -165,9 +165,11 @@ pub fn execute_with_extra_account_metas( mint_pubkey, destination_pubkey, authority_pubkey, - validate_state_pubkey, amount, ); + instruction + .accounts + .push(AccountMeta::new_readonly(*validate_state_pubkey, false)); instruction.accounts.extend_from_slice(additional_accounts); instruction } @@ -180,7 +182,6 @@ pub fn execute( mint_pubkey: &Pubkey, destination_pubkey: &Pubkey, authority_pubkey: &Pubkey, - validate_state_pubkey: &Pubkey, amount: u64, ) -> Instruction { let data = TransferHookInstruction::Execute { amount }.pack(); @@ -189,7 +190,6 @@ pub fn execute( AccountMeta::new_readonly(*mint_pubkey, false), AccountMeta::new_readonly(*destination_pubkey, false), AccountMeta::new_readonly(*authority_pubkey, false), - AccountMeta::new_readonly(*validate_state_pubkey, false), ]; Instruction { program_id: *program_id, diff --git a/interface/src/offchain.rs b/interface/src/offchain.rs index 2d3b7bb..50c8c57 100644 --- a/interface/src/offchain.rs +++ b/interface/src/offchain.rs @@ -85,9 +85,11 @@ where mint_pubkey, destination_pubkey, authority_pubkey, - &validate_state_pubkey, amount, ); + execute_instruction + .accounts + .push(AccountMeta::new_readonly(validate_state_pubkey, false)); ExtraAccountMetaList::add_to_instruction::( &mut execute_instruction, diff --git a/interface/src/onchain.rs b/interface/src/onchain.rs index 41c2ec1..1e33257 100644 --- a/interface/src/onchain.rs +++ b/interface/src/onchain.rs @@ -23,34 +23,36 @@ pub fn invoke_execute<'a>( additional_accounts: &[AccountInfo<'a>], amount: u64, ) -> ProgramResult { - let validation_pubkey = get_extra_account_metas_address(mint_info.key, program_id); - let validation_info = additional_accounts - .iter() - .find(|&x| *x.key == validation_pubkey) - .ok_or(TransferHookError::IncorrectAccount)?; let mut cpi_instruction = instruction::execute( program_id, source_info.key, mint_info.key, destination_info.key, authority_info.key, - &validation_pubkey, amount, ); - let mut cpi_account_infos = vec![ - source_info, - mint_info, - destination_info, - authority_info, - validation_info.clone(), - ]; - ExtraAccountMetaList::add_to_cpi_instruction::( - &mut cpi_instruction, - &mut cpi_account_infos, - &validation_info.try_borrow_data()?, - additional_accounts, - )?; + let validation_pubkey = get_extra_account_metas_address(mint_info.key, program_id); + + let mut cpi_account_infos = vec![source_info, mint_info, destination_info, authority_info]; + + if let Some(validation_info) = additional_accounts + .iter() + .find(|&x| *x.key == validation_pubkey) + { + cpi_instruction + .accounts + .push(AccountMeta::new_readonly(validation_pubkey, false)); + cpi_account_infos.push(validation_info.clone()); + + ExtraAccountMetaList::add_to_cpi_instruction::( + &mut cpi_instruction, + &mut cpi_account_infos, + &validation_info.try_borrow_data()?, + additional_accounts, + )?; + } + invoke(&cpi_instruction, &cpi_account_infos) } @@ -76,55 +78,60 @@ pub fn add_extra_accounts_for_execute_cpi<'a>( additional_accounts: &[AccountInfo<'a>], ) -> ProgramResult { let validate_state_pubkey = get_extra_account_metas_address(mint_info.key, program_id); - let validate_state_info = additional_accounts - .iter() - .find(|&x| *x.key == validate_state_pubkey) - .ok_or(TransferHookError::IncorrectAccount)?; let program_info = additional_accounts .iter() .find(|&x| x.key == program_id) .ok_or(TransferHookError::IncorrectAccount)?; - let mut execute_instruction = instruction::execute( - program_id, - source_info.key, - mint_info.key, - destination_info.key, - authority_info.key, - &validate_state_pubkey, - amount, - ); - let mut execute_account_infos = vec![ - source_info, - mint_info, - destination_info, - authority_info, - validate_state_info.clone(), - ]; - - ExtraAccountMetaList::add_to_cpi_instruction::( - &mut execute_instruction, - &mut execute_account_infos, - &validate_state_info.try_borrow_data()?, - additional_accounts, - )?; - - // Add only the extra accounts resolved from the validation state - cpi_instruction - .accounts - .extend_from_slice(&execute_instruction.accounts[5..]); - cpi_account_infos.extend_from_slice(&execute_account_infos[5..]); + if let Some(validate_state_info) = additional_accounts + .iter() + .find(|&x| *x.key == validate_state_pubkey) + { + let mut execute_instruction = instruction::execute( + program_id, + source_info.key, + mint_info.key, + destination_info.key, + authority_info.key, + amount, + ); + execute_instruction + .accounts + .push(AccountMeta::new_readonly(validate_state_pubkey, false)); + let mut execute_account_infos = vec![ + source_info, + mint_info, + destination_info, + authority_info, + validate_state_info.clone(), + ]; - // Add the program id and validation state account + ExtraAccountMetaList::add_to_cpi_instruction::( + &mut execute_instruction, + &mut execute_account_infos, + &validate_state_info.try_borrow_data()?, + additional_accounts, + )?; + + // Add only the extra accounts resolved from the validation state + cpi_instruction + .accounts + .extend_from_slice(&execute_instruction.accounts[5..]); + cpi_account_infos.extend_from_slice(&execute_account_infos[5..]); + + // Add the validation state account + cpi_instruction + .accounts + .push(AccountMeta::new_readonly(validate_state_pubkey, false)); + cpi_account_infos.push(validate_state_info.clone()); + } + + // Add the program id cpi_instruction .accounts .push(AccountMeta::new_readonly(*program_id, false)); - cpi_instruction - .accounts - .push(AccountMeta::new_readonly(validate_state_pubkey, false)); cpi_account_infos.push(program_info.clone()); - cpi_account_infos.push(validate_state_info.clone()); Ok(()) } @@ -368,16 +375,18 @@ mod tests { validate_state_account_info.clone(), ]; - // Fail missing validation info from additional account infos - let additional_account_infos_missing_infos = vec![ - extra_meta_1_account_info.clone(), - extra_meta_2_account_info.clone(), - extra_meta_3_account_info.clone(), - extra_meta_4_account_info.clone(), - // validate state missing - transfer_hook_program_account_info.clone(), - ]; - assert_eq!( + // Allow missing validation info from additional account infos + { + let additional_account_infos_missing_infos = vec![ + extra_meta_1_account_info.clone(), + extra_meta_2_account_info.clone(), + extra_meta_3_account_info.clone(), + extra_meta_4_account_info.clone(), + // validate state missing + transfer_hook_program_account_info.clone(), + ]; + let mut cpi_instruction = cpi_instruction.clone(); + let mut cpi_account_infos = cpi_account_infos.clone(); add_extra_accounts_for_execute_cpi( &mut cpi_instruction, &mut cpi_account_infos, @@ -387,11 +396,32 @@ mod tests { destination_account_info.clone(), authority_account_info.clone(), amount, - &additional_account_infos_missing_infos, // Missing account info + &additional_account_infos_missing_infos, ) - .unwrap_err(), - TransferHookError::IncorrectAccount.into() - ); + .unwrap(); + let check_metas = [ + AccountMeta::new(source_pubkey, false), + AccountMeta::new_readonly(mint_pubkey, false), + AccountMeta::new(destination_pubkey, false), + AccountMeta::new_readonly(authority_pubkey, true), + AccountMeta::new_readonly(transfer_hook_program_id, false), + ]; + + let check_account_infos = vec![ + source_account_info.clone(), + mint_account_info.clone(), + destination_account_info.clone(), + authority_account_info.clone(), + transfer_hook_program_account_info.clone(), + ]; + + assert_eq!(cpi_instruction.accounts, check_metas); + for (a, b) in std::iter::zip(cpi_account_infos, check_account_infos) { + assert_eq!(a.key, b.key); + assert_eq!(a.is_signer, b.is_signer); + assert_eq!(a.is_writable, b.is_writable); + } + } // Fail missing program info from additional account infos let additional_account_infos_missing_infos = vec![ @@ -466,8 +496,8 @@ mod tests { AccountMeta::new_readonly(EXTRA_META_2, true), AccountMeta::new(extra_meta_3_pubkey, false), AccountMeta::new(extra_meta_4_pubkey, false), - AccountMeta::new_readonly(transfer_hook_program_id, false), AccountMeta::new_readonly(validate_state_pubkey, false), + AccountMeta::new_readonly(transfer_hook_program_id, false), ]; let check_account_infos = vec![ @@ -479,8 +509,8 @@ mod tests { extra_meta_2_account_info, extra_meta_3_account_info, extra_meta_4_account_info, - transfer_hook_program_account_info, validate_state_account_info, + transfer_hook_program_account_info, ]; assert_eq!(cpi_instruction.accounts, check_metas); From d81b835be28320a7bc62fcdc8845ab4578201d49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 12:11:42 +0200 Subject: [PATCH 100/154] build(deps): bump serde from 1.0.204 to 1.0.205 (#7124) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.204 to 1.0.205. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.204...v1.0.205) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 9696309..c5bace7 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.7.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.204", features = ["derive"] } +serde = { version = "1.0.205", features = ["derive"] } serde_json = "1.0.122" serde_yaml = "0.9.34" From b80ee4f6e802723c949a25f661cfc693d8d14953 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:28:40 +0200 Subject: [PATCH 101/154] build(deps): bump serde from 1.0.205 to 1.0.206 (#7131) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.205 to 1.0.206. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.205...v1.0.206) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index c5bace7..a26b27a 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.7.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.205", features = ["derive"] } +serde = { version = "1.0.206", features = ["derive"] } serde_json = "1.0.122" serde_yaml = "0.9.34" From 61daec4167f453d711cc19b169907817140d2450 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:17:06 +0200 Subject: [PATCH 102/154] build(deps): bump serde_json from 1.0.122 to 1.0.124 (#7132) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.122 to 1.0.124. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.122...v1.0.124) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index a26b27a..1907405 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.206", features = ["derive"] } -serde_json = "1.0.122" +serde_json = "1.0.124" serde_yaml = "0.9.34" [dev-dependencies] From bb4498c6e92798de66a1f97d2f8dbf7df5f6d7eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:22:01 +0200 Subject: [PATCH 103/154] build(deps): bump serde from 1.0.206 to 1.0.207 (#7139) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.206 to 1.0.207. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.206...v1.0.207) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 1907405..ef4514f 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.7.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.206", features = ["derive"] } +serde = { version = "1.0.207", features = ["derive"] } serde_json = "1.0.124" serde_yaml = "0.9.34" From bd40f087b2538e3ac0426e4ec0cec8bfdb80f4ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 08:48:10 -0400 Subject: [PATCH 104/154] build(deps): bump serde_json from 1.0.124 to 1.0.125 (#7157) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.124 to 1.0.125. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.124...1.0.125) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index ef4514f..4c1e05f 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.207", features = ["derive"] } -serde_json = "1.0.124" +serde_json = "1.0.125" serde_yaml = "0.9.34" [dev-dependencies] From 16f2a8472bd246fb4cfbf4b576097956a3526765 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 08:48:26 -0400 Subject: [PATCH 105/154] build(deps): bump bytemuck from 1.16.3 to 1.17.0 (#7159) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.16.3 to 1.17.0. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.16.3...v1.17.0) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 6b30494..85aadcc 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.8" -bytemuck = { version = "1.16.3", features = ["derive"] } +bytemuck = { version = "1.17.0", features = ["derive"] } solana-program = "2.0.3" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } From a83792af77978749a3f07e1a6ef1fbe0310e8f7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 10:22:10 -0400 Subject: [PATCH 106/154] build(deps): bump serde from 1.0.207 to 1.0.208 (#7158) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.207 to 1.0.208. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.207...v1.0.208) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 4c1e05f..29871e7 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.7.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.207", features = ["derive"] } +serde = { version = "1.0.208", features = ["derive"] } serde_json = "1.0.125" serde_yaml = "0.9.34" From 9b69b3f3fba81fe0ad1e8772770ed9847809f616 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 08:52:28 -0400 Subject: [PATCH 107/154] build(deps): bump tokio from 1.39.2 to 1.39.3 (#7167) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.39.2 to 1.39.3. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.39.2...tokio-1.39.3) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 85aadcc..80f4e5c 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -21,7 +21,7 @@ spl-pod = { version = "0.3.0", path = "../../../libraries/pod" } crate-type = ["cdylib", "lib"] [dev-dependencies] -tokio = { version = "1.39.2", features = ["full"] } +tokio = { version = "1.39.3", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From 247037e2c0cd8b0085b90376c63e568b041a0634 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:57:55 +0200 Subject: [PATCH 108/154] build(deps): bump serde from 1.0.208 to 1.0.209 (#7187) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.208 to 1.0.209. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.208...v1.0.209) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 29871e7..507f6c2 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.7.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.208", features = ["derive"] } +serde = { version = "1.0.209", features = ["derive"] } serde_json = "1.0.125" serde_yaml = "0.9.34" From ffd90cb6db24927779eb3568dd14f74238a0c0b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 13:36:36 +0200 Subject: [PATCH 109/154] build(deps): bump serde_json from 1.0.125 to 1.0.127 (#7188) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.125 to 1.0.127. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/1.0.125...1.0.127) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 507f6c2..9fb06c9 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.209", features = ["derive"] } -serde_json = "1.0.125" +serde_json = "1.0.127" serde_yaml = "0.9.34" [dev-dependencies] From 70b637825a01074462a3ca83685fb562f931c0b2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 14:07:57 +0000 Subject: [PATCH 110/154] Publish pod v0.3.2 --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 80f4e5c..0d810df 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -15,7 +15,7 @@ spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminat spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } -spl-pod = { version = "0.3.0", path = "../../../libraries/pod" } +spl-pod = { version = "0.3.2", path = "../../../libraries/pod" } [lib] crate-type = ["cdylib", "lib"] From 8c17ef67f1a666f15b2c6d28b7eb85edab09338a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:10:19 +0000 Subject: [PATCH 111/154] Publish transfer-hook-interface v0.8.0 --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 9fb06c9..0bf2d65 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -18,7 +18,7 @@ solana-logger = "2.0.3" solana-remote-wallet = "2.0.3" solana-sdk = "2.0.3" spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } -spl-transfer-hook-interface = { version = "0.7.0", path = "../interface" } +spl-transfer-hook-interface = { version = "0.8.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 0d810df..b90aa66 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.7.0" +version = "0.8.0" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" diff --git a/program/Cargo.toml b/program/Cargo.toml index 9df4d2a..9a849ea 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -18,7 +18,7 @@ arrayref = "0.3.8" solana-program = "2.0.3" spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "4.0.0", path = "../../program-2022", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.7.0" , path = "../interface" } +spl-transfer-hook-interface = { version = "0.8.0", path = "../interface" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } [dev-dependencies] From 54762444fde2bb70f8bfdd1e76b805683510ad29 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:49:52 +0000 Subject: [PATCH 112/154] Publish token-2022 v5.0.0 --- clients/cli/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 0bf2d65..17fc74b 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -28,7 +28,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = "2.0.3" -spl-token-2022 = { version = "4.0.0", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "5.0.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.11.0", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 9a849ea..69f09d7 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -17,7 +17,7 @@ forbid-additional-mints = [] arrayref = "0.3.8" solana-program = "2.0.3" spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } -spl-token-2022 = { version = "4.0.0", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "5.0.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.8.0", path = "../interface" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } From 3766d48b047c6bb27f80c3f82cb85cf3f0fe7d5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:46:28 +0200 Subject: [PATCH 113/154] build(deps): bump bytemuck from 1.17.0 to 1.17.1 (#7209) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.17.0 to 1.17.1. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.17.0...v1.17.1) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index b90aa66..5c278f5 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.8" -bytemuck = { version = "1.17.0", features = ["derive"] } +bytemuck = { version = "1.17.1", features = ["derive"] } solana-program = "2.0.3" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } From 415ef3df343d4b4f9cdbe29f1bbb83673164083e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:11:21 +0000 Subject: [PATCH 114/154] Publish pod v0.4.0 --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 5c278f5..5dc92d0 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -15,7 +15,7 @@ spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminat spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } -spl-pod = { version = "0.3.2", path = "../../../libraries/pod" } +spl-pod = { version = "0.4.0", path = "../../../libraries/pod" } [lib] crate-type = ["cdylib", "lib"] From e8880531ebfaaf1f00bb179c674067ce4b41762f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:15:29 +0000 Subject: [PATCH 115/154] Publish tlv-account-resolution v0.8.0 --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 17fc74b..a7c2266 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -17,7 +17,7 @@ solana-client = "2.0.3" solana-logger = "2.0.3" solana-remote-wallet = "2.0.3" solana-sdk = "2.0.3" -spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } +spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } spl-transfer-hook-interface = { version = "0.8.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 5dc92d0..9738d48 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -13,7 +13,7 @@ bytemuck = { version = "1.17.1", features = ["derive"] } solana-program = "2.0.3" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } -spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } spl-pod = { version = "0.4.0", path = "../../../libraries/pod" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 69f09d7..b2bc429 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -16,7 +16,7 @@ forbid-additional-mints = [] [dependencies] arrayref = "0.3.8" solana-program = "2.0.3" -spl-tlv-account-resolution = { version = "0.7.0" , path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "5.0.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.8.0", path = "../interface" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } From 204e920fe260d59789a40d1f64c31e3dce8a7056 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:17:44 +0000 Subject: [PATCH 116/154] Publish transfer-hook-interface v0.8.1 --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index a7c2266..0403269 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -18,7 +18,7 @@ solana-logger = "2.0.3" solana-remote-wallet = "2.0.3" solana-sdk = "2.0.3" spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } -spl-transfer-hook-interface = { version = "0.8.0", path = "../interface" } +spl-transfer-hook-interface = { version = "0.8.1", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 9738d48..44fa7da 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.8.0" +version = "0.8.1" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" diff --git a/program/Cargo.toml b/program/Cargo.toml index b2bc429..ddb0166 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -18,7 +18,7 @@ arrayref = "0.3.8" solana-program = "2.0.3" spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "5.0.0", path = "../../program-2022", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.8.0", path = "../interface" } +spl-transfer-hook-interface = { version = "0.8.1", path = "../interface" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } [dev-dependencies] From 283cd3a5efaf42be184855a7646e532b749d0552 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:34:07 +0000 Subject: [PATCH 117/154] Publish token-2022 v5.0.1 --- clients/cli/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 0403269..f758c15 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -28,7 +28,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = "2.0.3" -spl-token-2022 = { version = "5.0.0", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "5.0.1", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.11.0", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } diff --git a/program/Cargo.toml b/program/Cargo.toml index ddb0166..fb69107 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -17,7 +17,7 @@ forbid-additional-mints = [] arrayref = "0.3.8" solana-program = "2.0.3" spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution" } -spl-token-2022 = { version = "5.0.0", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "5.0.1", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.8.1", path = "../interface" } spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } From a2c320656de1c8ac9bb50404621f73c451e650ec Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:21:45 +0000 Subject: [PATCH 118/154] Publish token-client v0.12.0 --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index f758c15..0f4ab10 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -29,7 +29,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = "2.0.3" spl-token-2022 = { version = "5.0.1", path = "../../program-2022", features = ["no-entrypoint"] } -spl-token-client = { version = "0.11.0", path = "../../client" } +spl-token-client = { version = "0.12.0", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } [[bin]] From 6f21417cc25cd634c2416d9bccdd5e122cf9c34b Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 3 Sep 2024 14:46:06 +0200 Subject: [PATCH 119/154] Publish type-length-value v0.6.0 (#7233) --- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 44fa7da..f2834cf 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -14,7 +14,7 @@ solana-program = "2.0.3" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution" } -spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } +spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } spl-pod = { version = "0.4.0", path = "../../../libraries/pod" } [lib] diff --git a/program/Cargo.toml b/program/Cargo.toml index fb69107..fc3e44f 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -19,7 +19,7 @@ solana-program = "2.0.3" spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "5.0.1", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.8.1", path = "../interface" } -spl-type-length-value = { version = "0.5.0" , path = "../../../libraries/type-length-value" } +spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } [dev-dependencies] solana-program-test = "2.0.3" From dc9a9be38e9a87e3ba17962a2cf1ebd96e3877b2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:28:53 +0000 Subject: [PATCH 120/154] Publish tlv-account-resolution v0.8.1 --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 0f4ab10..5454528 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -17,7 +17,7 @@ solana-client = "2.0.3" solana-logger = "2.0.3" solana-remote-wallet = "2.0.3" solana-sdk = "2.0.3" -spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } +spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } spl-transfer-hook-interface = { version = "0.8.1", path = "../interface" } strum = "0.26" strum_macros = "0.26" diff --git a/interface/Cargo.toml b/interface/Cargo.toml index f2834cf..a77212f 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -13,7 +13,7 @@ bytemuck = { version = "1.17.1", features = ["derive"] } solana-program = "2.0.3" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } -spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } spl-pod = { version = "0.4.0", path = "../../../libraries/pod" } diff --git a/program/Cargo.toml b/program/Cargo.toml index fc3e44f..579576c 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -16,7 +16,7 @@ forbid-additional-mints = [] [dependencies] arrayref = "0.3.8" solana-program = "2.0.3" -spl-tlv-account-resolution = { version = "0.8.0", path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "5.0.1", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.8.1", path = "../interface" } spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } From f081c0c2b4fd5b06a369b11c70e601fd7192dbe6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:04:39 +0200 Subject: [PATCH 121/154] build(deps): bump tokio from 1.39.3 to 1.40.0 (#7217) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.39.3 to 1.40.0. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.39.3...tokio-1.40.0) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index a77212f..e1c0854 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -21,7 +21,7 @@ spl-pod = { version = "0.4.0", path = "../../../libraries/pod" } crate-type = ["cdylib", "lib"] [dev-dependencies] -tokio = { version = "1.39.3", features = ["full"] } +tokio = { version = "1.40.0", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From e47211f8a968dfcb3cb89bb8fabf83d1ce88dc7f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:35:37 +0000 Subject: [PATCH 122/154] Publish transfer-hook-interface v0.8.2 --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 5454528..8886109 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -18,7 +18,7 @@ solana-logger = "2.0.3" solana-remote-wallet = "2.0.3" solana-sdk = "2.0.3" spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } -spl-transfer-hook-interface = { version = "0.8.1", path = "../interface" } +spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index e1c0854..ecd298a 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.8.1" +version = "0.8.2" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" diff --git a/program/Cargo.toml b/program/Cargo.toml index 579576c..0ef3525 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -18,7 +18,7 @@ arrayref = "0.3.8" solana-program = "2.0.3" spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "5.0.1", path = "../../program-2022", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.8.1", path = "../interface" } +spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } [dev-dependencies] From 82204d89ede5137df84937975d6118650a89b9c2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:48:37 +0000 Subject: [PATCH 123/154] Publish token-2022 v5.0.2 --- clients/cli/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 8886109..c4770d7 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -28,7 +28,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = "2.0.3" -spl-token-2022 = { version = "5.0.1", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.12.0", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 0ef3525..1032b17 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -17,7 +17,7 @@ forbid-additional-mints = [] arrayref = "0.3.8" solana-program = "2.0.3" spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } -spl-token-2022 = { version = "5.0.1", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } From 1373092fc202e7e28a39712c50087ff033630274 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:33:01 +0000 Subject: [PATCH 124/154] Publish token-client v0.12.1 --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index c4770d7..ea989fe 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -29,7 +29,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = "2.0.3" spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } -spl-token-client = { version = "0.12.0", path = "../../client" } +spl-token-client = { version = "0.12.1", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } [[bin]] From 097d09b374b883fe45b46b9bce15cb743482ad07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 12:15:35 +0200 Subject: [PATCH 125/154] build(deps): bump serde_json from 1.0.127 to 1.0.128 (#7241) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.127 to 1.0.128. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/1.0.127...1.0.128) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index ea989fe..04c0a99 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.209", features = ["derive"] } -serde_json = "1.0.127" +serde_json = "1.0.128" serde_yaml = "0.9.34" [dev-dependencies] From 88f6e4fe0cd945f38173c88aada4a495be1de842 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:27:55 +0200 Subject: [PATCH 126/154] build(deps): bump bytemuck from 1.17.1 to 1.18.0 (#7244) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.17.1 to 1.18.0. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.17.1...v1.18.0) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index ecd298a..763ea7e 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.8" -bytemuck = { version = "1.17.1", features = ["derive"] } +bytemuck = { version = "1.18.0", features = ["derive"] } solana-program = "2.0.3" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } From 0b8fd2710cf1585a994b5122790bfdca01867294 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:36:00 +0200 Subject: [PATCH 127/154] build(deps): bump serde from 1.0.209 to 1.0.210 (#7250) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.209 to 1.0.210. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.209...v1.0.210) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 04c0a99..d23afbe 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.209", features = ["derive"] } +serde = { version = "1.0.210", features = ["derive"] } serde_json = "1.0.128" serde_yaml = "0.9.34" From 442a1252238de8ad82831abed60bfe0428cf1201 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 00:38:10 +0800 Subject: [PATCH 128/154] build(deps): bump arrayref from 0.3.8 to 0.3.9 (#7278) Bumps [arrayref](https://github.com/droundy/arrayref) from 0.3.8 to 0.3.9. - [Commits](https://github.com/droundy/arrayref/commits) --- updated-dependencies: - dependency-name: arrayref dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 763ea7e..81c86d7 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -8,7 +8,7 @@ license = "Apache-2.0" edition = "2021" [dependencies] -arrayref = "0.3.8" +arrayref = "0.3.9" bytemuck = { version = "1.18.0", features = ["derive"] } solana-program = "2.0.3" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 1032b17..c92600a 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -14,7 +14,7 @@ test-sbf = [] forbid-additional-mints = [] [dependencies] -arrayref = "0.3.8" +arrayref = "0.3.9" solana-program = "2.0.3" spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } From 11d971d63cd0201a75fe7eb96752c59a4e944002 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:38:35 -0400 Subject: [PATCH 129/154] build(deps): bump futures-util from 0.3.30 to 0.3.31 (#7326) Bumps [futures-util](https://github.com/rust-lang/futures-rs) from 0.3.30 to 0.3.31. - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.30...0.3.31) --- updated-dependencies: - dependency-name: futures-util dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index d23afbe..378e9d9 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -10,7 +10,7 @@ version = "0.2.0" [dependencies] clap = { version = "3", features = ["cargo"] } -futures-util = "0.3.30" +futures-util = "0.3.31" solana-clap-v3-utils = "2.0.3" solana-cli-config = "2.0.3" solana-client = "2.0.3" From a9da5113d625bd58f4a75cf6df75a43d8a3e6b5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:59:51 +0200 Subject: [PATCH 130/154] build(deps): bump bytemuck from 1.18.0 to 1.19.0 (#7345) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.18.0 to 1.19.0. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.18.0...v1.19.0) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 81c86d7..9e611cb 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.9" -bytemuck = { version = "1.18.0", features = ["derive"] } +bytemuck = { version = "1.19.0", features = ["derive"] } solana-program = "2.0.3" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } From 32e43204191c6c9f69ad57a0cf1abdd3ef5baaeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:40:30 +0200 Subject: [PATCH 131/154] build(deps): bump serde_json from 1.0.128 to 1.0.129 (#7364) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.128 to 1.0.129. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/1.0.128...1.0.129) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 378e9d9..b818be4 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.210", features = ["derive"] } -serde_json = "1.0.128" +serde_json = "1.0.129" serde_yaml = "0.9.34" [dev-dependencies] From 2d89c95c86e2c8256fb675de0938242a0219f4e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:55:33 +0200 Subject: [PATCH 132/154] build(deps): bump serde_json from 1.0.129 to 1.0.132 (#7372) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.129 to 1.0.132. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/1.0.129...1.0.132) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index b818be4..5010dc1 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.210", features = ["derive"] } -serde_json = "1.0.129" +serde_json = "1.0.132" serde_yaml = "0.9.34" [dev-dependencies] From 9cccbcc586c921d157e1ad0a515729d88baf68fe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:52:26 +0200 Subject: [PATCH 133/154] build(deps): bump tokio from 1.40.0 to 1.41.0 (#7379) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.40.0 to 1.41.0. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.40.0...tokio-1.41.0) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 9e611cb..2a3739d 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -21,7 +21,7 @@ spl-pod = { version = "0.4.0", path = "../../../libraries/pod" } crate-type = ["cdylib", "lib"] [dev-dependencies] -tokio = { version = "1.40.0", features = ["full"] } +tokio = { version = "1.41.0", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From 6c64d9188b8450a02c0e4852cdb7dc95331a4be6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:52:40 +0200 Subject: [PATCH 134/154] build(deps): bump serde from 1.0.210 to 1.0.211 (#7380) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.210 to 1.0.211. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.210...v1.0.211) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 5010dc1..3936666 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.210", features = ["derive"] } +serde = { version = "1.0.211", features = ["derive"] } serde_json = "1.0.132" serde_yaml = "0.9.34" From 477fce25564950b13c34c88eb5b957041025dae1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 15:43:59 +0200 Subject: [PATCH 135/154] build(deps): bump serde from 1.0.211 to 1.0.213 (#7388) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.211 to 1.0.213. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.211...v1.0.213) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 3936666..af9a64c 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.211", features = ["derive"] } +serde = { version = "1.0.213", features = ["derive"] } serde_json = "1.0.132" serde_yaml = "0.9.34" From 8f2204efa123027fff9470dca77aea2b8db3e7b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:36:21 +0100 Subject: [PATCH 136/154] build(deps): bump serde from 1.0.213 to 1.0.214 (#7405) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.213 to 1.0.214. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.213...v1.0.214) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index af9a64c..a61bc38 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.213", features = ["derive"] } +serde = { version = "1.0.214", features = ["derive"] } serde_json = "1.0.132" serde_yaml = "0.9.34" From 6ede12ae707bfa47c47aefb10078394c6164b2e7 Mon Sep 17 00:00:00 2001 From: Jon C Date: Thu, 31 Oct 2024 12:25:30 +0100 Subject: [PATCH 137/154] CI: Update to Solana v2.1 crates (#7416) * Run update script, update curve25519-dalek dep, rust * Run clippy + fmt * Add workspace lints, start fixing doc comments * Update doc comments for clippy * Re-run cargo fmt after doc comment update * Update solana-version * Update CI jobs --- clients/cli/Cargo.toml | 14 +++++++------- interface/Cargo.toml | 2 +- interface/src/instruction.rs | 4 ++-- program/Cargo.toml | 6 +++--- program/tests/functional.rs | 14 +++++++------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index a61bc38..255b40e 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -11,12 +11,12 @@ version = "0.2.0" [dependencies] clap = { version = "3", features = ["cargo"] } futures-util = "0.3.31" -solana-clap-v3-utils = "2.0.3" -solana-cli-config = "2.0.3" -solana-client = "2.0.3" -solana-logger = "2.0.3" -solana-remote-wallet = "2.0.3" -solana-sdk = "2.0.3" +solana-clap-v3-utils = "2.1.0" +solana-cli-config = "2.1.0" +solana-client = "2.1.0" +solana-logger = "2.1.0" +solana-remote-wallet = "2.1.0" +solana-sdk = "2.1.0" spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } strum = "0.26" @@ -27,7 +27,7 @@ serde_json = "1.0.132" serde_yaml = "0.9.34" [dev-dependencies] -solana-test-validator = "2.0.3" +solana-test-validator = "2.1.0" spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.12.1", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 2a3739d..5699da4 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] arrayref = "0.3.9" bytemuck = { version = "1.19.0", features = ["derive"] } -solana-program = "2.0.3" +solana-program = "2.1.0" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 8888054..d6d7132 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -26,8 +26,8 @@ pub enum TransferHookInstruction { /// 2. `[]` Destination account /// 3. `[]` Source account's owner/delegate /// 4. `[]` (Optional) Validation account - /// 5..5+M `[]` `M` optional additional accounts, written in validation - /// account data + /// 5. ..5+M `[]` `M` optional additional accounts, written in validation + /// account data Execute { /// Amount of tokens to transfer amount: u64, diff --git a/program/Cargo.toml b/program/Cargo.toml index c92600a..5197d15 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -15,15 +15,15 @@ forbid-additional-mints = [] [dependencies] arrayref = "0.3.9" -solana-program = "2.0.3" +solana-program = "2.1.0" spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } [dev-dependencies] -solana-program-test = "2.0.3" -solana-sdk = "2.0.3" +solana-program-test = "2.1.0" +solana-sdk = "2.1.0" [lib] crate-type = ["cdylib", "lib"] diff --git a/program/tests/functional.rs b/program/tests/functional.rs index 0d64d1a..5e0aa09 100644 --- a/program/tests/functional.rs +++ b/program/tests/functional.rs @@ -220,7 +220,7 @@ async fn success_execute() { AccountMeta::new(writable_pubkey, false), ]; - let mut context = program_test.start_with_context().await; + let context = program_test.start_with_context().await; let rent = context.banks_client.get_rent().await.unwrap(); let rent_lamports = rent .minimum_balance(ExtraAccountMetaList::size_of(init_extra_account_metas.len()).unwrap()); @@ -460,7 +460,7 @@ async fn fail_incorrect_derivation() { // wrong derivation let extra_account_metas = get_extra_account_metas_address(&program_id, &mint_address); - let mut context = program_test.start_with_context().await; + let context = program_test.start_with_context().await; let rent = context.banks_client.get_rent().await.unwrap(); let rent_lamports = rent.minimum_balance(ExtraAccountMetaList::size_of(0).unwrap()); @@ -523,7 +523,7 @@ async fn fail_incorrect_mint() { let extra_account_metas = get_extra_account_metas_address(&mint_address, &program_id); - let mut context = program_test.start_with_context().await; + let context = program_test.start_with_context().await; let rent = context.banks_client.get_rent().await.unwrap(); let rent_lamports = rent.minimum_balance(ExtraAccountMetaList::size_of(0).unwrap()); @@ -671,7 +671,7 @@ async fn success_on_chain_invoke() { AccountMeta::new(writable_pubkey, false), ]; - let mut context = program_test.start_with_context().await; + let context = program_test.start_with_context().await; let rent = context.banks_client.get_rent().await.unwrap(); let rent_lamports = rent .minimum_balance(ExtraAccountMetaList::size_of(init_extra_account_metas.len()).unwrap()); @@ -758,7 +758,7 @@ async fn fail_without_transferring_flag() { let extra_account_metas_address = get_extra_account_metas_address(&mint_address, &program_id); let extra_account_metas = []; let init_extra_account_metas = []; - let mut context = program_test.start_with_context().await; + let context = program_test.start_with_context().await; let rent = context.banks_client.get_rent().await.unwrap(); let rent_lamports = rent .minimum_balance(ExtraAccountMetaList::size_of(init_extra_account_metas.len()).unwrap()); @@ -884,7 +884,7 @@ async fn success_on_chain_invoke_with_updated_extra_account_metas() { ExtraAccountMeta::new_with_pubkey(&writable_pubkey, false, true).unwrap(), ]; - let mut context = program_test.start_with_context().await; + let context = program_test.start_with_context().await; let rent = context.banks_client.get_rent().await.unwrap(); let rent_lamports = rent .minimum_balance(ExtraAccountMetaList::size_of(init_extra_account_metas.len()).unwrap()); @@ -1112,7 +1112,7 @@ async fn success_execute_with_updated_extra_account_metas() { AccountMeta::new(writable_pubkey, false), ]; - let mut context = program_test.start_with_context().await; + let context = program_test.start_with_context().await; let rent = context.banks_client.get_rent().await.unwrap(); let rent_lamports = rent .minimum_balance(ExtraAccountMetaList::size_of(init_extra_account_metas.len()).unwrap()); From 9507a5f0e548ea839cbd9c5aaf6794b6b8c62e7c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:14:45 +0000 Subject: [PATCH 138/154] Publish spl-pod v0.5.0 --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 5699da4..8f1d9a8 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -15,7 +15,7 @@ spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminat spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } -spl-pod = { version = "0.4.0", path = "../../../libraries/pod" } +spl-pod = { version = "0.5.0", path = "../../../libraries/pod" } [lib] crate-type = ["cdylib", "lib"] From 5b102f1c709d1cb8bf7fafcffcc6577fef67684e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:37:28 +0000 Subject: [PATCH 139/154] Publish spl-program-error v0.6.0 --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 8f1d9a8..d1508e1 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -12,7 +12,7 @@ arrayref = "0.3.9" bytemuck = { version = "1.19.0", features = ["derive"] } solana-program = "2.1.0" spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } -spl-program-error = { version = "0.5.0" , path = "../../../libraries/program-error" } +spl-program-error = { version = "0.6.0", path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } spl-pod = { version = "0.5.0", path = "../../../libraries/pod" } From 435b9e7b7174592b5c49835f4d898551da6cea09 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:43:04 +0000 Subject: [PATCH 140/154] Publish spl-discriminator v0.4.0 --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index d1508e1..cfef1bc 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -11,7 +11,7 @@ edition = "2021" arrayref = "0.3.9" bytemuck = { version = "1.19.0", features = ["derive"] } solana-program = "2.1.0" -spl-discriminator = { version = "0.3.0" , path = "../../../libraries/discriminator" } +spl-discriminator = { version = "0.4.0", path = "../../../libraries/discriminator" } spl-program-error = { version = "0.6.0", path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } From 5b8f38fd4cc733474f1b6504bfbb494736f5f424 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:23:01 +0000 Subject: [PATCH 141/154] Publish spl-type-length-value v0.7.0 --- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index cfef1bc..fe4e9b2 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -14,7 +14,7 @@ solana-program = "2.1.0" spl-discriminator = { version = "0.4.0", path = "../../../libraries/discriminator" } spl-program-error = { version = "0.6.0", path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } -spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } +spl-type-length-value = { version = "0.7.0", path = "../../../libraries/type-length-value" } spl-pod = { version = "0.5.0", path = "../../../libraries/pod" } [lib] diff --git a/program/Cargo.toml b/program/Cargo.toml index 5197d15..441eb04 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -19,7 +19,7 @@ solana-program = "2.1.0" spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } -spl-type-length-value = { version = "0.6.0", path = "../../../libraries/type-length-value" } +spl-type-length-value = { version = "0.7.0", path = "../../../libraries/type-length-value" } [dev-dependencies] solana-program-test = "2.1.0" From fc3b43eedfdabdc1be6d5510827856aaaf1f975c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:39:08 +0000 Subject: [PATCH 142/154] Publish spl-tlv-account-resolution v0.9.0 --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 255b40e..51ae4c7 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -17,7 +17,7 @@ solana-client = "2.1.0" solana-logger = "2.1.0" solana-remote-wallet = "2.1.0" solana-sdk = "2.1.0" -spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } +spl-tlv-account-resolution = { version = "0.9.0", path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } strum = "0.26" strum_macros = "0.26" diff --git a/interface/Cargo.toml b/interface/Cargo.toml index fe4e9b2..634ce42 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -13,7 +13,7 @@ bytemuck = { version = "1.19.0", features = ["derive"] } solana-program = "2.1.0" spl-discriminator = { version = "0.4.0", path = "../../../libraries/discriminator" } spl-program-error = { version = "0.6.0", path = "../../../libraries/program-error" } -spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.9.0", path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.7.0", path = "../../../libraries/type-length-value" } spl-pod = { version = "0.5.0", path = "../../../libraries/pod" } diff --git a/program/Cargo.toml b/program/Cargo.toml index 441eb04..8043dce 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -16,7 +16,7 @@ forbid-additional-mints = [] [dependencies] arrayref = "0.3.9" solana-program = "2.1.0" -spl-tlv-account-resolution = { version = "0.8.1", path = "../../../libraries/tlv-account-resolution" } +spl-tlv-account-resolution = { version = "0.9.0", path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } spl-type-length-value = { version = "0.7.0", path = "../../../libraries/type-length-value" } From 5ac1759af1f4cf2a4465ddc05cf60d640cbdaae6 Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 1 Nov 2024 17:38:32 +0100 Subject: [PATCH 143/154] transfer-hook-interface: Remove solana-program dependency (#7442) * transfer-hook-interface: Remove solana-program dependency #### Problem The transfer-hook-interface pulls in solana-program, but it doesn't need to. #### Summary of changes Use the component crates. The only breaking change is the re-exports. It still uses a dev-dependency on solana-program since the system program id isn't available yet outside of solana-program. * Add missing solana-pubkey feature * Add all test programs * Run cargo fmt * Fixup imports --- interface/Cargo.toml | 14 +++++++++-- interface/src/error.rs | 49 +++++++++++++++++++++++++++++++++--- interface/src/instruction.rs | 18 +++++++------ interface/src/lib.rs | 7 ++++-- interface/src/offchain.rs | 8 +++--- interface/src/onchain.rs | 12 ++++----- 6 files changed, 82 insertions(+), 26 deletions(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 634ce42..fa40b4b 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -10,17 +10,27 @@ edition = "2021" [dependencies] arrayref = "0.3.9" bytemuck = { version = "1.19.0", features = ["derive"] } -solana-program = "2.1.0" -spl-discriminator = { version = "0.4.0", path = "../../../libraries/discriminator" } +num-derive = "0.4" +num-traits = "0.2" +solana-account-info = "2.1.0" +solana-cpi = "2.1.0" +solana-decode-error = "2.1.0" +solana-instruction = { version = "2.1.0", features = ["std"] } +solana-msg = "2.1.0" +solana-program-error = "2.1.0" +solana-pubkey = { version = "2.1.0", features = ["curve25519"] } +spl-discriminator = { version = "0.4.0" , path = "../../../libraries/discriminator" } spl-program-error = { version = "0.6.0", path = "../../../libraries/program-error" } spl-tlv-account-resolution = { version = "0.9.0", path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.7.0", path = "../../../libraries/type-length-value" } spl-pod = { version = "0.5.0", path = "../../../libraries/pod" } +thiserror = "1.0" [lib] crate-type = ["cdylib", "lib"] [dev-dependencies] +solana-program = "2.1.0" tokio = { version = "1.41.0", features = ["full"] } [package.metadata.docs.rs] diff --git a/interface/src/error.rs b/interface/src/error.rs index aaf25e1..de50ec8 100644 --- a/interface/src/error.rs +++ b/interface/src/error.rs @@ -1,13 +1,18 @@ //! Error types -use spl_program_error::*; +use { + solana_decode_error::DecodeError, + solana_msg::msg, + solana_program_error::{PrintProgramError, ProgramError}, +}; /// Errors that may be returned by the interface. -#[spl_program_error(hash_error_code_start = 2_110_272_652)] +#[repr(u32)] +#[derive(Clone, Debug, Eq, thiserror::Error, num_derive::FromPrimitive, PartialEq)] pub enum TransferHookError { /// Incorrect account provided #[error("Incorrect account provided")] - IncorrectAccount, + IncorrectAccount = 2_110_272_652, /// Mint has no mint authority #[error("Mint has no mint authority")] MintHasNoMintAuthority, @@ -18,3 +23,41 @@ pub enum TransferHookError { #[error("Program called outside of a token transfer")] ProgramCalledOutsideOfTransfer, } + +impl From for ProgramError { + fn from(e: TransferHookError) -> Self { + ProgramError::Custom(e as u32) + } +} + +impl DecodeError for TransferHookError { + fn type_of() -> &'static str { + "TransferHookError" + } +} + +impl PrintProgramError for TransferHookError { + fn print(&self) + where + E: 'static + + std::error::Error + + DecodeError + + PrintProgramError + + num_traits::FromPrimitive, + { + match self { + TransferHookError::IncorrectAccount => { + msg!("Incorrect account provided") + } + TransferHookError::MintHasNoMintAuthority => { + msg!("Mint has no mint authority") + } + TransferHookError::IncorrectMintAuthority => { + msg!("Incorrect mint authority has signed the instruction") + } + TransferHookError::ProgramCalledOutsideOfTransfer => { + msg!("Program called outside of a token transfer") + } + } + } +} diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index d6d7132..52419b6 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -1,18 +1,17 @@ //! Instruction types use { - solana_program::{ - instruction::{AccountMeta, Instruction}, - program_error::ProgramError, - pubkey::Pubkey, - system_program, - }, + solana_instruction::{AccountMeta, Instruction}, + solana_program_error::ProgramError, + solana_pubkey::Pubkey, spl_discriminator::{ArrayDiscriminator, SplDiscriminate}, spl_pod::{bytemuck::pod_slice_to_bytes, slice::PodSlice}, spl_tlv_account_resolution::account::ExtraAccountMeta, std::convert::TryInto, }; +const SYSTEM_PROGRAM_ID: Pubkey = Pubkey::from_str_const("11111111111111111111111111111111"); + /// Instructions supported by the transfer hook interface. #[repr(C)] #[derive(Clone, Debug, PartialEq)] @@ -215,7 +214,7 @@ pub fn initialize_extra_account_meta_list( AccountMeta::new(*extra_account_metas_pubkey, false), AccountMeta::new_readonly(*mint_pubkey, false), AccountMeta::new_readonly(*authority_pubkey, true), - AccountMeta::new_readonly(system_program::id(), false), + AccountMeta::new_readonly(SYSTEM_PROGRAM_ID, false), ]; Instruction { @@ -255,6 +254,11 @@ pub fn update_extra_account_meta_list( mod test { use {super::*, crate::NAMESPACE, solana_program::hash, spl_pod::bytemuck::pod_from_bytes}; + #[test] + fn system_program_id() { + assert_eq!(solana_program::system_program::id(), SYSTEM_PROGRAM_ID); + } + #[test] fn validate_packing() { let amount = 111_111_111; diff --git a/interface/src/lib.rs b/interface/src/lib.rs index d22b7f8..0e4f382 100644 --- a/interface/src/lib.rs +++ b/interface/src/lib.rs @@ -14,8 +14,11 @@ pub mod onchain; // Export current sdk types for downstream users building with a different sdk // version -pub use solana_program; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; +pub use { + solana_account_info, solana_cpi, solana_decode_error, solana_instruction, solana_msg, + solana_program_error, solana_pubkey, +}; /// Namespace for all programs implementing transfer-hook pub const NAMESPACE: &str = "spl-transfer-hook-interface"; diff --git a/interface/src/offchain.rs b/interface/src/offchain.rs index 50c8c57..46e078e 100644 --- a/interface/src/offchain.rs +++ b/interface/src/offchain.rs @@ -7,11 +7,9 @@ use { get_extra_account_metas_address, instruction::{execute, ExecuteInstruction}, }, - solana_program::{ - instruction::{AccountMeta, Instruction}, - program_error::ProgramError, - pubkey::Pubkey, - }, + solana_instruction::{AccountMeta, Instruction}, + solana_program_error::ProgramError, + solana_pubkey::Pubkey, spl_tlv_account_resolution::state::ExtraAccountMetaList, std::future::Future, }; diff --git a/interface/src/onchain.rs b/interface/src/onchain.rs index 1e33257..7bd8eff 100644 --- a/interface/src/onchain.rs +++ b/interface/src/onchain.rs @@ -3,13 +3,11 @@ use { crate::{error::TransferHookError, get_extra_account_metas_address, instruction}, - solana_program::{ - account_info::AccountInfo, - entrypoint::ProgramResult, - instruction::{AccountMeta, Instruction}, - program::invoke, - pubkey::Pubkey, - }, + solana_account_info::AccountInfo, + solana_cpi::invoke, + solana_instruction::{AccountMeta, Instruction}, + solana_program_error::ProgramResult, + solana_pubkey::Pubkey, spl_tlv_account_resolution::state::ExtraAccountMetaList, }; /// Helper to CPI into a transfer-hook program on-chain, looking through the From 40dec168104b550e33ed4ad189cda70de13774b6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:51:39 +0000 Subject: [PATCH 144/154] Publish spl-transfer-hook-interface v0.9.0 --- clients/cli/Cargo.toml | 2 +- interface/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 51ae4c7..3c64df5 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -18,7 +18,7 @@ solana-logger = "2.1.0" solana-remote-wallet = "2.1.0" solana-sdk = "2.1.0" spl-tlv-account-resolution = { version = "0.9.0", path = "../../../libraries/tlv-account-resolution", features = ["serde-traits"] } -spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } +spl-transfer-hook-interface = { version = "0.9.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } diff --git a/interface/Cargo.toml b/interface/Cargo.toml index fa40b4b..d8a5ca6 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-transfer-hook-interface" -version = "0.8.2" +version = "0.9.0" description = "Solana Program Library Transfer Hook Interface" authors = ["Solana Labs Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" diff --git a/program/Cargo.toml b/program/Cargo.toml index 8043dce..ac84a3f 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -18,7 +18,7 @@ arrayref = "0.3.9" solana-program = "2.1.0" spl-tlv-account-resolution = { version = "0.9.0", path = "../../../libraries/tlv-account-resolution" } spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.8.2", path = "../interface" } +spl-transfer-hook-interface = { version = "0.9.0", path = "../interface" } spl-type-length-value = { version = "0.7.0", path = "../../../libraries/type-length-value" } [dev-dependencies] From 2a684e3ddf99cd51bdf0d1224ecb44a64b1b36a1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 17:49:26 +0000 Subject: [PATCH 145/154] Publish spl-token-2022 v6.0.0 --- clients/cli/Cargo.toml | 2 +- program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 3c64df5..7023eb1 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -28,7 +28,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = "2.1.0" -spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "6.0.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-token-client = { version = "0.12.1", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } diff --git a/program/Cargo.toml b/program/Cargo.toml index ac84a3f..ee6d475 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -17,7 +17,7 @@ forbid-additional-mints = [] arrayref = "0.3.9" solana-program = "2.1.0" spl-tlv-account-resolution = { version = "0.9.0", path = "../../../libraries/tlv-account-resolution" } -spl-token-2022 = { version = "5.0.2", path = "../../program-2022", features = ["no-entrypoint"] } +spl-token-2022 = { version = "6.0.0", path = "../../program-2022", features = ["no-entrypoint"] } spl-transfer-hook-interface = { version = "0.9.0", path = "../interface" } spl-type-length-value = { version = "0.7.0", path = "../../../libraries/type-length-value" } From 5957862bd55c6fe5e5a06f0974c8711d31885388 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:30:57 +0000 Subject: [PATCH 146/154] Publish spl-token-client v0.13.0 --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 7023eb1..cd74411 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -29,7 +29,7 @@ serde_yaml = "0.9.34" [dev-dependencies] solana-test-validator = "2.1.0" spl-token-2022 = { version = "6.0.0", path = "../../program-2022", features = ["no-entrypoint"] } -spl-token-client = { version = "0.12.1", path = "../../client" } +spl-token-client = { version = "0.13.0", path = "../../client" } spl-transfer-hook-example = { version = "0.6.0", path = "../example" } [[bin]] From 591f221abb902045885ec021f8d081226251855b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 11:44:32 +0100 Subject: [PATCH 147/154] build(deps): bump thiserror from 1.0.68 to 2.0.0 (#7462) Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.68 to 2.0.0. - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](https://github.com/dtolnay/thiserror/compare/1.0.68...2.0.0) --- updated-dependencies: - dependency-name: thiserror dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index d8a5ca6..d68c9d6 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -24,7 +24,7 @@ spl-program-error = { version = "0.6.0", path = "../../../libraries/program-erro spl-tlv-account-resolution = { version = "0.9.0", path = "../../../libraries/tlv-account-resolution" } spl-type-length-value = { version = "0.7.0", path = "../../../libraries/type-length-value" } spl-pod = { version = "0.5.0", path = "../../../libraries/pod" } -thiserror = "1.0" +thiserror = "2.0" [lib] crate-type = ["cdylib", "lib"] From b9c12c773e5738d0192d67a4921f90d67dd86a15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 12:45:11 +0100 Subject: [PATCH 148/154] build(deps): bump tokio from 1.41.0 to 1.41.1 (#7469) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.41.0 to 1.41.1. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.41.0...tokio-1.41.1) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index d68c9d6..1deb735 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -31,7 +31,7 @@ crate-type = ["cdylib", "lib"] [dev-dependencies] solana-program = "2.1.0" -tokio = { version = "1.41.0", features = ["full"] } +tokio = { version = "1.41.1", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From 28a4191b42a383c28d87e244386f222994633181 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:41:55 +0100 Subject: [PATCH 149/154] build(deps): bump serde from 1.0.214 to 1.0.215 (#7485) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.214 to 1.0.215. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.214...v1.0.215) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index cd74411..207452d 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.9.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.214", features = ["derive"] } +serde = { version = "1.0.215", features = ["derive"] } serde_json = "1.0.132" serde_yaml = "0.9.34" From 8307b0dddf4be2340cb3e6cede08eeb412442df4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:40:08 +0100 Subject: [PATCH 150/154] build(deps): bump serde_json from 1.0.132 to 1.0.133 (#7497) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.132 to 1.0.133. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.132...v1.0.133) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 207452d..4ae36cd 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -23,7 +23,7 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } serde = { version = "1.0.215", features = ["derive"] } -serde_json = "1.0.132" +serde_json = "1.0.133" serde_yaml = "0.9.34" [dev-dependencies] From a4f1fee8a09e401d0e840fcf6d14e99b942bbdac Mon Sep 17 00:00:00 2001 From: Jon C Date: Mon, 18 Nov 2024 23:23:54 +0100 Subject: [PATCH 151/154] token: Fix typos for cargo-spellcheck (#7503) * token: Fix typos #### Problem There are typos in the token code, and people sometimes fix them, but mostly don't. #### Summary of changes Starting with the `token/*` directory, fix all typos or properly put them between backticks if they're code. These were all found using `cargo spellcheck` and a specialized dictionary with programming / Solana / ZK terminology. Once all of the typos are fixed, then we can add the spellchecking to CI. * Update doctests --- interface/README.md | 4 ++-- interface/src/instruction.rs | 10 +++++----- program/README.md | 2 +- program/src/processor.rs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/interface/README.md b/interface/README.md index 376cdb1..17c320b 100644 --- a/interface/README.md +++ b/interface/README.md @@ -86,7 +86,7 @@ Developers must implement the `Execute` instruction, and optionally the pubkeys into the program-derived address defined by the mint and program id. Note: it's technically not required to implement `InitializeExtraAccountMetaList` -at that instruction descriminator. Your program may implement multiple interfaces, +at that instruction discriminator. Your program may implement multiple interfaces, so any other instruction in your program can create the account at the program-derived address! @@ -98,7 +98,7 @@ automatically resolved! ### Account Resolution -Implementers of the transfer-hook interface are encouraged to make use of the +Implementations of the transfer-hook interface are encouraged to make use of the [spl-tlv-account-resolution](https://github.com/solana-labs/solana-program-library/tree/master/libraries/tlv-account-resolution/README.md) library to manage the additional required accounts for their transfer hook program. diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index 52419b6..68485bc 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -25,8 +25,8 @@ pub enum TransferHookInstruction { /// 2. `[]` Destination account /// 3. `[]` Source account's owner/delegate /// 4. `[]` (Optional) Validation account - /// 5. ..5+M `[]` `M` optional additional accounts, written in validation - /// account data + /// 5. ..`5+M` `[]` `M` optional additional accounts, written in + /// validation account data Execute { /// Amount of tokens to transfer amount: u64, @@ -80,7 +80,7 @@ pub struct UpdateExtraAccountMetaListInstruction; impl TransferHookInstruction { /// Unpacks a byte buffer into a - /// [TransferHookInstruction](enum.TransferHookInstruction.html). + /// [`TransferHookInstruction`](enum.TransferHookInstruction.html). pub fn unpack(input: &[u8]) -> Result { if input.len() < ArrayDiscriminator::LENGTH { return Err(ProgramError::InvalidInstructionData); @@ -113,8 +113,8 @@ impl TransferHookInstruction { }) } - /// Packs a [TokenInstruction](enum.TokenInstruction.html) into a byte - /// buffer. + /// Packs a [`TransferHookInstruction`](enum.TransferHookInstruction.html) + /// into a byte buffer. pub fn pack(&self) -> Vec { let mut buf = vec![]; match self { diff --git a/program/README.md b/program/README.md index f3d2aef..4f49072 100644 --- a/program/README.md +++ b/program/README.md @@ -10,7 +10,7 @@ code for more information. ### Example usage of example When testing your program that uses `spl-transfer-hook-interface`, you can also -import this crate, and then use it with `solana-program-test`, ie: +import this crate, and then use it with `solana-program-test`: ```rust use { diff --git a/program/src/processor.rs b/program/src/processor.rs index 8bac5a9..0a5f4c1 100644 --- a/program/src/processor.rs +++ b/program/src/processor.rs @@ -74,7 +74,7 @@ pub fn process_execute( } /// Processes a -/// [InitializeExtraAccountMetaList](enum.TransferHookInstruction.html) +/// [`InitializeExtraAccountMetaList`](enum.TransferHookInstruction.html) /// instruction. pub fn process_initialize_extra_account_meta_list( program_id: &Pubkey, @@ -142,7 +142,7 @@ pub fn process_initialize_extra_account_meta_list( } /// Processes a -/// [UpdateExtraAccountMetaList](enum.TransferHookInstruction.html) +/// [`UpdateExtraAccountMetaList`](enum.TransferHookInstruction.html) /// instruction. pub fn process_update_extra_account_meta_list( program_id: &Pubkey, From c50e3163d21a9b83f628a70980637a3530a79222 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:04:56 +0100 Subject: [PATCH 152/154] build(deps): bump bytemuck from 1.19.0 to 1.20.0 (#7507) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.19.0 to 1.20.0. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](https://github.com/Lokathor/bytemuck/compare/v1.19.0...v1.20.0) --- updated-dependencies: - dependency-name: bytemuck dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 1deb735..8774db0 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] arrayref = "0.3.9" -bytemuck = { version = "1.19.0", features = ["derive"] } +bytemuck = { version = "1.20.0", features = ["derive"] } num-derive = "0.4" num-traits = "0.2" solana-account-info = "2.1.0" From 0518c26f8e367963efbe4f2928b4fe7ad5475f85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:37:47 +0100 Subject: [PATCH 153/154] build(deps): bump tokio from 1.41.1 to 1.42.0 (#7556) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.41.1 to 1.42.0. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.41.1...tokio-1.42.0) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 8774db0..601189d 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -31,7 +31,7 @@ crate-type = ["cdylib", "lib"] [dev-dependencies] solana-program = "2.1.0" -tokio = { version = "1.41.1", features = ["full"] } +tokio = { version = "1.42.0", features = ["full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From bb02ad3a340c4f5f3c3b7793ed0400c3f4d72b5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 11:31:06 +0100 Subject: [PATCH 154/154] build(deps): bump serde from 1.0.215 to 1.0.216 (#7576) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.215 to 1.0.216. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.215...v1.0.216) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- clients/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 4ae36cd..2099dcf 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -22,7 +22,7 @@ spl-transfer-hook-interface = { version = "0.9.0", path = "../interface" } strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } -serde = { version = "1.0.215", features = ["derive"] } +serde = { version = "1.0.216", features = ["derive"] } serde_json = "1.0.133" serde_yaml = "0.9.34"