Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Jan 4, 2024
1 parent 89b8a61 commit cc2552d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions cmd/crates/soroban-spec-tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ impl Spec {
let val = self.from_json(v, &f.type_)?;
let key = StringM::from_str(name).unwrap();
Ok(ScMapEntry {
key: ScVal::Symbol(key.try_into()?),
key: ScVal::Symbol(key.into()),
val,
})
})
Expand Down Expand Up @@ -1135,7 +1135,7 @@ impl Spec {
match self.find(&name.to_utf8_string_lossy()).ok()? {
ScSpecEntry::UdtStructV0(ScSpecUdtStructV0 { fields, .. })
if fields
.get(0)
.first()
.map(|f| f.name.to_utf8_string_lossy() == "0")
.unwrap_or_default() =>
{
Expand Down
2 changes: 1 addition & 1 deletion cmd/crates/soroban-spec-typescript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub fn entry_to_parser(entry: &Entry) -> Option<(String, String)> {
}

let output = outputs
.get(0)
.first()
.map(|_| format!("this.spec.funcResToNative(\"{name}\", result)"))
.unwrap_or_default();
let parse_result_xdr = if return_type == "void" {
Expand Down
6 changes: 1 addition & 5 deletions cmd/soroban-cli/src/commands/contract/id/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ pub fn get_contract_id(
contract_id_preimage: ContractIdPreimage,
network_passphrase: &str,
) -> Result<Hash, Error> {
let network_id = Hash(
Sha256::digest(network_passphrase.as_bytes())
.try_into()
.unwrap(),
);
let network_id = Hash(Sha256::digest(network_passphrase.as_bytes()).into());
let preimage = HashIdPreimage::ContractId(HashIdPreimageContractId {
network_id,
contract_id_preimage,
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ fn log_resources(resources: &SorobanResources) {

pub fn output_to_string(spec: &Spec, res: &ScVal, function: &str) -> Result<String, Error> {
let mut res_str = String::new();
if let Some(output) = spec.find_function(function)?.outputs.get(0) {
if let Some(output) = spec.find_function(function)?.outputs.first() {
res_str = spec
.xdr_to_json(res, output)
.map_err(|e| Error::CannotPrintResult {
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl Cmd {
}

fn parse_operations(ops: &[OperationMeta]) -> Option<u32> {
ops.get(0).and_then(|op| {
ops.first().and_then(|op| {
op.changes.iter().find_map(|entry| match entry {
LedgerEntryChange::Updated(LedgerEntry {
data:
Expand Down
6 changes: 3 additions & 3 deletions cmd/soroban-cli/src/rpc/txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ impl Assembled {
pub fn auth(&self) -> VecM<SorobanAuthorizationEntry> {
self.txn
.operations
.get(0)
.first()
.and_then(|op| match op.body {
OperationBody::InvokeHostFunction(ref body) => (matches!(
body.auth.get(0).map(|x| &x.root_invocation.function),
body.auth.first().map(|x| &x.root_invocation.function),
Some(&SorobanAuthorizedFunction::ContractFn(_))
))
.then_some(body.auth.clone()),
Expand Down Expand Up @@ -235,7 +235,7 @@ fn sign_soroban_authorizations(
body: OperationBody::InvokeHostFunction(InvokeHostFunctionOp { auth, .. }),
..
}] if matches!(
auth.get(0).map(|x| &x.root_invocation.function),
auth.first().map(|x| &x.root_invocation.function),
Some(&SorobanAuthorizedFunction::ContractFn(_))
) =>
{
Expand Down
6 changes: 1 addition & 5 deletions cmd/soroban-cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,7 @@ pub fn contract_id_hash_from_asset(
asset: &Asset,
network_passphrase: &str,
) -> Result<Hash, XdrError> {
let network_id = Hash(
Sha256::digest(network_passphrase.as_bytes())
.try_into()
.unwrap(),
);
let network_id = Hash(Sha256::digest(network_passphrase.as_bytes()).into());
let preimage = HashIdPreimage::ContractId(HashIdPreimageContractId {
network_id,
contract_id_preimage: ContractIdPreimage::Asset(asset.clone()),
Expand Down

0 comments on commit cc2552d

Please sign in to comment.