Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ Releases for anchor will also be published under the `solanafoundation` Github o
- spl: Upgrade SPL deps to latest ([#3346](https://github.com/coral-xyz/anchor/pull/3346)).
- cli: Upgrade `typescript` version of templates to v5 ([#3480](https://github.com/coral-xyz/anchor/pull/3480)).
- ts: Remove `snake-case` dependency ([#3507](https://github.com/coral-xyz/anchor/pull/3507)).
- client: Remove unused `Result` return types to simplify certain functions ([#3563](https://github.com/coral-xyz/anchor/pull/3563)).

## [0.30.1] - 2024-06-20

Expand Down
28 changes: 11 additions & 17 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,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 @@ -613,32 +613,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()?;
fn signed_transaction_with_blockhash(&self, latest_hash: Hash) -> Transaction {
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(
Transaction::new_signed_with_payer(
&instructions,
Some(&self.payer.pubkey()),
&all_signers,
latest_hash,
);

Ok(tx)
)
}

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

async fn signed_transaction_internal(&self) -> Result<Transaction, ClientError> {
Expand All @@ -648,7 +642,7 @@ impl<C: Deref<Target = impl Signer> + Clone, S: AsSigner> RequestBuilder<'_, C,
.await
.map_err(Box::new)?;

let tx = self.signed_transaction_with_blockhash(latest_hash)?;
let tx = self.signed_transaction_with_blockhash(latest_hash);
Ok(tx)
}

Expand All @@ -658,7 +652,7 @@ impl<C: Deref<Target = impl Signer> + Clone, S: AsSigner> RequestBuilder<'_, C,
.get_latest_blockhash()
.await
.map_err(Box::new)?;
let tx = self.signed_transaction_with_blockhash(latest_hash)?;
let tx = self.signed_transaction_with_blockhash(latest_hash);

self.internal_rpc_client
.send_and_confirm_transaction(&tx)
Expand All @@ -675,7 +669,7 @@ impl<C: Deref<Target = impl Signer> + Clone, S: AsSigner> RequestBuilder<'_, C,
.get_latest_blockhash()
.await
.map_err(Box::new)?;
let tx = self.signed_transaction_with_blockhash(latest_hash)?;
let tx = self.signed_transaction_with_blockhash(latest_hash);

self.internal_rpc_client
.send_and_confirm_transaction_with_spinner_and_config(
Expand Down