From 951d409fc524d3fb05c61fa339730688acecd665 Mon Sep 17 00:00:00 2001 From: cryptopapi997 Date: Tue, 18 Feb 2025 15:31:09 +0800 Subject: [PATCH 1/2] rm unused Results --- client/src/lib.rs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index efd1eb23bb..a3e51f56c0 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -596,7 +596,7 @@ impl + Clone, S: AsSigner> RequestBuilder<'_, C, self } - pub fn instructions(&self) -> Result, ClientError> { + pub fn instructions(&self) -> Vec { let mut instructions = self.instructions.clone(); if let Some(ix_data) = &self.instruction_data { instructions.push(Instruction { @@ -606,44 +606,38 @@ impl + Clone, S: AsSigner> RequestBuilder<'_, C, }); } - Ok(instructions) + instructions } - fn signed_transaction_with_blockhash( - &self, - latest_hash: Hash, - ) -> Result { - 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 { + 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 { let latest_hash = self.internal_rpc_client.get_latest_blockhash().await?; - let tx = self.signed_transaction_with_blockhash(latest_hash)?; + let tx = self.signed_transaction_with_blockhash(latest_hash); Ok(tx) } async fn send_internal(&self) -> Result { let latest_hash = self.internal_rpc_client.get_latest_blockhash().await?; - 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) @@ -656,7 +650,7 @@ impl + Clone, S: AsSigner> RequestBuilder<'_, C, config: RpcSendTransactionConfig, ) -> Result { let latest_hash = self.internal_rpc_client.get_latest_blockhash().await?; - 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( From 37c80cd6a364c09eb0bcc864664057c6ed2523e3 Mon Sep 17 00:00:00 2001 From: cryptopapi997 Date: Tue, 18 Feb 2025 15:34:13 +0800 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index addcdcb934..ef35699269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,6 +143,7 @@ The minor version will be incremented upon a breaking change and the patch versi - 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