From ad1f4a4ae198a84202ae133e025aac6f3d89a59d Mon Sep 17 00:00:00 2001 From: Gleb Date: Tue, 19 Nov 2024 10:27:06 -0800 Subject: [PATCH] Clippy fixes for 1.82 (#1741) --- .../src/commands/contract/deploy/asset.rs | 4 +-- .../src/commands/contract/deploy/wasm.rs | 8 +++--- .../src/commands/contract/extend.rs | 4 +-- .../src/commands/contract/install.rs | 6 ++--- .../src/commands/contract/invoke.rs | 26 +++++++++---------- .../src/commands/contract/restore.rs | 6 ++--- cmd/soroban-cli/src/commands/tx/args.rs | 2 +- cmd/soroban-cli/src/commands/txn_result.rs | 14 +++++----- cmd/soroban-cli/src/wasm.rs | 4 +-- 9 files changed, 36 insertions(+), 38 deletions(-) diff --git a/cmd/soroban-cli/src/commands/contract/deploy/asset.rs b/cmd/soroban-cli/src/commands/contract/deploy/asset.rs index 169c0109a..04a0380ed 100644 --- a/cmd/soroban-cli/src/commands/contract/deploy/asset.rs +++ b/cmd/soroban-cli/src/commands/contract/deploy/asset.rs @@ -110,12 +110,12 @@ impl NetworkRunnable for Cmd { source_account, )?; if self.fee.build_only { - return Ok(TxnResult::Txn(tx)); + return Ok(TxnResult::Txn(Box::new(tx))); } let txn = simulate_and_assemble_transaction(&client, &tx).await?; let txn = self.fee.apply_to_assembled_txn(txn).transaction().clone(); if self.fee.sim_only { - return Ok(TxnResult::Txn(txn)); + return Ok(TxnResult::Txn(Box::new(txn))); } let get_txn_resp = client .send_transaction_polling(&self.config.sign_with_local_key(txn).await?) diff --git a/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs b/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs index 9bf63802c..1d85832b0 100644 --- a/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs +++ b/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs @@ -265,14 +265,14 @@ impl NetworkRunnable for Cmd { // Get the account sequence number let account_details = client.get_account(&source_account.to_string()).await?; let sequence: i64 = account_details.seq_num.into(); - let txn = build_create_contract_tx( + let txn = Box::new(build_create_contract_tx( wasm_hash, sequence + 1, self.fee.fee, source_account, contract_id_preimage, constructor_params.as_ref(), - )?; + )?); if self.fee.build_only { print.checkln("Transaction built!"); @@ -282,7 +282,7 @@ impl NetworkRunnable for Cmd { print.infoln("Simulating deploy transaction…"); let txn = simulate_and_assemble_transaction(&client, &txn).await?; - let txn = self.fee.apply_to_assembled_txn(txn).transaction().clone(); + let txn = Box::new(self.fee.apply_to_assembled_txn(txn).transaction().clone()); if self.fee.sim_only { print.checkln("Done!"); @@ -293,7 +293,7 @@ impl NetworkRunnable for Cmd { print.log_transaction(&txn, &network, true)?; let get_txn_resp = client - .send_transaction_polling(&config.sign_with_local_key(txn).await?) + .send_transaction_polling(&config.sign_with_local_key(*txn).await?) .await? .try_into()?; diff --git a/cmd/soroban-cli/src/commands/contract/extend.rs b/cmd/soroban-cli/src/commands/contract/extend.rs index 6ec8ebdb1..e56cbe166 100644 --- a/cmd/soroban-cli/src/commands/contract/extend.rs +++ b/cmd/soroban-cli/src/commands/contract/extend.rs @@ -140,7 +140,7 @@ impl NetworkRunnable for Cmd { .await?; let sequence: i64 = account_details.seq_num.into(); - let tx = Transaction { + let tx = Box::new(Transaction { source_account, fee: self.fee.fee, seq_num: SequenceNumber(sequence + 1), @@ -167,7 +167,7 @@ impl NetworkRunnable for Cmd { }, resource_fee: 0, }), - }; + }); if self.fee.build_only { return Ok(TxnResult::Txn(tx)); } diff --git a/cmd/soroban-cli/src/commands/contract/install.rs b/cmd/soroban-cli/src/commands/contract/install.rs index a215a987d..0a9ec856d 100644 --- a/cmd/soroban-cli/src/commands/contract/install.rs +++ b/cmd/soroban-cli/src/commands/contract/install.rs @@ -146,7 +146,7 @@ impl NetworkRunnable for Cmd { build_install_contract_code_tx(&contract, sequence + 1, self.fee.fee, &source_account)?; if self.fee.build_only { - return Ok(TxnResult::Txn(tx_without_preflight)); + return Ok(TxnResult::Txn(Box::new(tx_without_preflight))); } // Don't check whether the contract is already installed when the user @@ -186,7 +186,7 @@ impl NetworkRunnable for Cmd { print.infoln("Simulating install transaction…"); let txn = simulate_and_assemble_transaction(&client, &tx_without_preflight).await?; - let txn = self.fee.apply_to_assembled_txn(txn).transaction().clone(); + let txn = Box::new(self.fee.apply_to_assembled_txn(txn).transaction().clone()); if self.fee.sim_only { return Ok(TxnResult::Txn(txn)); @@ -195,7 +195,7 @@ impl NetworkRunnable for Cmd { print.globeln("Submitting install transaction…"); let txn_resp = client - .send_transaction_polling(&self.config.sign_with_local_key(txn).await?) + .send_transaction_polling(&self.config.sign_with_local_key(*txn).await?) .await?; if args.map_or(true, |a| !a.no_cache) { diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 04eeaebd6..c7b631343 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -25,10 +25,10 @@ use crate::{ print, rpc, xdr::{ self, AccountEntry, AccountEntryExt, AccountId, ContractEvent, ContractEventType, - DiagnosticEvent, HostFunction, InvokeContractArgs, InvokeHostFunctionOp, LedgerEntryData, - Limits, Memo, MuxedAccount, Operation, OperationBody, Preconditions, PublicKey, - ScSpecEntry, SequenceNumber, String32, StringM, Thresholds, Transaction, TransactionExt, - Uint256, VecM, WriteXdr, + DiagnosticEvent, HostFunction, InvokeContractArgs, InvokeHostFunctionOp, Limits, Memo, + MuxedAccount, Operation, OperationBody, Preconditions, PublicKey, ScSpecEntry, + SequenceNumber, String32, StringM, Thresholds, Transaction, TransactionExt, Uint256, VecM, + WriteXdr, }, Pwd, }; @@ -93,8 +93,6 @@ pub enum Error { ParseIntError(#[from] ParseIntError), #[error(transparent)] Rpc(#[from] rpc::Error), - #[error("unexpected contract code data type: {0:?}")] - UnexpectedContractCodeDataType(LedgerEntryData), #[error("missing operation result")] MissingOperationResult, #[error("error loading signing key: {0}")] @@ -258,21 +256,22 @@ impl NetworkRunnable for Cmd { let sequence: i64 = account_details.seq_num.into(); let AccountId(PublicKey::PublicKeyTypeEd25519(account_id)) = account_details.account_id; - let tx = build_invoke_contract_tx( + let tx = Box::new(build_invoke_contract_tx( host_function_params.clone(), sequence + 1, self.fee.fee, account_id, - )?; + )?); if self.fee.build_only { return Ok(TxnResult::Txn(tx)); } let txn = simulate_and_assemble_transaction(&client, &tx).await?; - let txn = self.fee.apply_to_assembled_txn(txn); + let assembled = self.fee.apply_to_assembled_txn(txn); + let mut txn = Box::new(assembled.transaction().clone()); if self.fee.sim_only { - return Ok(TxnResult::Txn(txn.transaction().clone())); + return Ok(TxnResult::Txn(txn)); } - let sim_res = txn.sim_response(); + let sim_res = assembled.sim_response(); if global_args.map_or(true, |a| !a.no_cache) { data::write(sim_res.clone().into(), &network.rpc_uri()?)?; } @@ -281,12 +280,11 @@ impl NetworkRunnable for Cmd { ShouldSend::Yes => { let global::Args { no_cache, .. } = global_args.cloned().unwrap_or_default(); // Need to sign all auth entries - let mut txn = txn.transaction().clone(); if let Some(tx) = config.sign_soroban_authorizations(&txn, &signers).await? { - txn = tx; + txn = Box::new(tx); } let res = client - .send_transaction_polling(&config.sign_with_local_key(txn).await?) + .send_transaction_polling(&config.sign_with_local_key(*txn).await?) .await?; if !no_cache { data::write(res.clone().try_into()?, &network.rpc_uri()?)?; diff --git a/cmd/soroban-cli/src/commands/contract/restore.rs b/cmd/soroban-cli/src/commands/contract/restore.rs index 92fc4b41d..cb35e6304 100644 --- a/cmd/soroban-cli/src/commands/contract/restore.rs +++ b/cmd/soroban-cli/src/commands/contract/restore.rs @@ -141,7 +141,7 @@ impl NetworkRunnable for Cmd { .await?; let sequence: i64 = account_details.seq_num.into(); - let tx = Transaction { + let tx = Box::new(Transaction { source_account, fee: self.fee.fee, seq_num: SequenceNumber(sequence + 1), @@ -167,12 +167,12 @@ impl NetworkRunnable for Cmd { }, resource_fee: 0, }), - }; + }); if self.fee.build_only { return Ok(TxnResult::Txn(tx)); } let res = client - .send_transaction_polling(&config.sign_with_local_key(tx).await?) + .send_transaction_polling(&config.sign_with_local_key(*tx).await?) .await?; if args.map_or(true, |a| !a.no_cache) { data::write(res.clone().try_into()?, &network.rpc_uri()?)?; diff --git a/cmd/soroban-cli/src/commands/tx/args.rs b/cmd/soroban-cli/src/commands/tx/args.rs index fc99b9591..1da1f230a 100644 --- a/cmd/soroban-cli/src/commands/tx/args.rs +++ b/cmd/soroban-cli/src/commands/tx/args.rs @@ -87,7 +87,7 @@ impl Args { let network = self.config.get_network()?; let client = Client::new(&network.rpc_url)?; if self.fee.build_only { - return Ok(TxnEnvelopeResult::TxnEnvelope(tx.into())); + return Ok(TxnEnvelopeResult::TxnEnvelope(Box::new(tx.into()))); } let txn_resp = client diff --git a/cmd/soroban-cli/src/commands/txn_result.rs b/cmd/soroban-cli/src/commands/txn_result.rs index d6b308b3a..568fd79d2 100644 --- a/cmd/soroban-cli/src/commands/txn_result.rs +++ b/cmd/soroban-cli/src/commands/txn_result.rs @@ -2,7 +2,7 @@ use crate::xdr::{Transaction, TransactionEnvelope, TransactionV1Envelope, VecM}; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] pub enum TxnResult { - Txn(Transaction), + Txn(Box), Res(R), } @@ -16,12 +16,12 @@ impl TxnResult { pub fn to_envelope(self) -> TxnEnvelopeResult { match self { - TxnResult::Txn(tx) => { - TxnEnvelopeResult::TxnEnvelope(TransactionEnvelope::Tx(TransactionV1Envelope { - tx, + TxnResult::Txn(tx) => TxnEnvelopeResult::TxnEnvelope(Box::new( + TransactionEnvelope::Tx(TransactionV1Envelope { + tx: *tx, signatures: VecM::default(), - })) - } + }), + )), TxnResult::Res(res) => TxnEnvelopeResult::Res(res), } } @@ -29,6 +29,6 @@ impl TxnResult { #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] pub enum TxnEnvelopeResult { - TxnEnvelope(TransactionEnvelope), + TxnEnvelope(Box), Res(R), } diff --git a/cmd/soroban-cli/src/wasm.rs b/cmd/soroban-cli/src/wasm.rs index a907e021a..30f7a3e4a 100644 --- a/cmd/soroban-cli/src/wasm.rs +++ b/cmd/soroban-cli/src/wasm.rs @@ -42,7 +42,7 @@ pub enum Error { #[error(transparent)] Rpc(#[from] soroban_rpc::Error), #[error("unexpected contract data {0:?}")] - UnexpectedContractToken(ContractDataEntry), + UnexpectedContractToken(Box), #[error( "cannot fetch wasm for contract because the contract is \ a network built-in asset contract that does not have a downloadable code binary" @@ -136,5 +136,5 @@ pub async fn fetch_from_contract( ContractExecutable::StellarAsset => Err(ContractIsStellarAsset), }; } - Err(UnexpectedContractToken(data_entry)) + Err(UnexpectedContractToken(Box::new(data_entry))) }