Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy #1741

Merged
merged 2 commits into from
Nov 19, 2024
Merged
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
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/deploy/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
Expand Down
8 changes: 4 additions & 4 deletions cmd/soroban-cli/src/commands/contract/deploy/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand All @@ -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!");
Expand All @@ -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()?;

Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -167,7 +167,7 @@ impl NetworkRunnable for Cmd {
},
resource_fee: 0,
}),
};
});
if self.fee.build_only {
return Ok(TxnResult::Txn(tx));
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/soroban-cli/src/commands/contract/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand All @@ -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) {
Expand Down
26 changes: 12 additions & 14 deletions cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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}")]
Expand Down Expand Up @@ -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()?)?;
}
Expand All @@ -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()?)?;
Expand Down
6 changes: 3 additions & 3 deletions cmd/soroban-cli/src/commands/contract/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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()?)?;
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/tx/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions cmd/soroban-cli/src/commands/txn_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::xdr::{Transaction, TransactionEnvelope, TransactionV1Envelope, VecM};

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum TxnResult<R> {
Txn(Transaction),
Txn(Box<Transaction>),
Res(R),
}

Expand All @@ -16,19 +16,19 @@ impl<R> TxnResult<R> {

pub fn to_envelope(self) -> TxnEnvelopeResult<R> {
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),
}
}
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum TxnEnvelopeResult<R> {
TxnEnvelope(TransactionEnvelope),
TxnEnvelope(Box<TransactionEnvelope>),
Res(R),
}
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub enum Error {
#[error(transparent)]
Rpc(#[from] soroban_rpc::Error),
#[error("unexpected contract data {0:?}")]
UnexpectedContractToken(ContractDataEntry),
UnexpectedContractToken(Box<ContractDataEntry>),
Ifropc marked this conversation as resolved.
Show resolved Hide resolved
#[error(
"cannot fetch wasm for contract because the contract is \
a network built-in asset contract that does not have a downloadable code binary"
Expand Down Expand Up @@ -136,5 +136,5 @@ pub async fn fetch_from_contract(
ContractExecutable::StellarAsset => Err(ContractIsStellarAsset),
};
}
Err(UnexpectedContractToken(data_entry))
Err(UnexpectedContractToken(Box::new(data_entry)))
}
Loading