Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The minor version will be incremented upon a breaking change and the patch versi

### Breaking

- client: Make sending a tx not panic and instead return an Error when signing fails ([#3865](https://github.com/solana-foundation/anchor/pull/3865)).
- spl: Update SPL dependencies to latest compatible versions ([#3860](https://github.com/solana-foundation/anchor/pull/3860)).
- cli: Replace `anchor verify` to use `solana-verify` under the hood, adding automatic installation via AVM, local path support, and future-proof argument passing ([#3768](https://github.com/solana-foundation/anchor/pull/3768)).
- cli: Upload IDL by default with an option to skip ((#3863)[https://github.com/solana-foundation/anchor/pull/3863]).
Expand Down
22 changes: 9 additions & 13 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ pub enum ClientError {
LogParseError(String),
#[error(transparent)]
IOError(#[from] std::io::Error),
#[error("{0}")]
SignerError(#[from] SignerError),
}

pub trait AsSigner {
Expand Down Expand Up @@ -604,7 +606,7 @@ impl<C: Deref<Target = impl Signer> + Clone, S: AsSigner> RequestBuilder<'_, C,
self
}

pub fn instructions(&self) -> Result<Vec<Instruction>, ClientError> {
pub fn instructions(&self) -> Vec<Instruction> {
let mut instructions = self.instructions.clone();
if let Some(ix_data) = &self.instruction_data {
instructions.push(Instruction {
Expand All @@ -614,32 +616,26 @@ impl<C: Deref<Target = impl Signer> + Clone, S: AsSigner> RequestBuilder<'_, C,
});
}

Ok(instructions)
instructions
}

fn signed_transaction_with_blockhash(
&self,
latest_hash: Hash,
) -> Result<Transaction, ClientError> {
let instructions = self.instructions()?;
let signers: Vec<&dyn Signer> = self.signers.iter().map(|s| s.as_signer()).collect();
let mut all_signers = signers;
all_signers.push(&*self.payer);

let tx = Transaction::new_signed_with_payer(
&instructions,
Some(&self.payer.pubkey()),
&all_signers,
latest_hash,
);
let mut tx = self.transaction();
tx.try_sign(&all_signers, latest_hash)?;

Ok(tx)
}

pub fn transaction(&self) -> Result<Transaction, ClientError> {
let instructions = &self.instructions;
let tx = Transaction::new_with_payer(instructions, Some(&self.payer.pubkey()));
Ok(tx)
pub fn transaction(&self) -> Transaction {
let instructions = &self.instructions();
Transaction::new_with_payer(instructions, Some(&self.payer.pubkey()))
}

async fn signed_transaction_internal(&self) -> Result<Transaction, ClientError> {
Expand Down