From a777d66e0478e0819c200c36030ab51864756f47 Mon Sep 17 00:00:00 2001 From: 0xpause Date: Tue, 5 Dec 2023 22:47:12 +0800 Subject: [PATCH] fmt --- .../src/natives/rooch_framework/bcs.rs | 5 +---- .../crypto/ecdsa_k1_recoverable.rs | 17 +++----------- .../src/natives/moveos_stdlib/bcs.rs | 5 +---- .../src/natives/moveos_stdlib/json.rs | 5 +---- .../src/natives/moveos_stdlib/move_module.rs | 22 ++++--------------- .../natives/moveos_stdlib/raw_table/mod.rs | 20 ++++------------- 6 files changed, 14 insertions(+), 60 deletions(-) diff --git a/crates/rooch-framework/src/natives/rooch_framework/bcs.rs b/crates/rooch-framework/src/natives/rooch_framework/bcs.rs index 2595b18ca9..b7c2640f89 100644 --- a/crates/rooch-framework/src/natives/rooch_framework/bcs.rs +++ b/crates/rooch-framework/src/natives/rooch_framework/bcs.rs @@ -51,10 +51,7 @@ fn native_from_bytes( let val = match Value::simple_deserialize(&bytes, &layout) { Some(val) => val, None => { - return Ok(NativeResult::err( - cost, - E_TYPE_NOT_MATCH, - )); + return Ok(NativeResult::err(cost, E_TYPE_NOT_MATCH)); } }; // TODO(gas): charge gas for deserialization diff --git a/crates/rooch-framework/src/natives/rooch_framework/crypto/ecdsa_k1_recoverable.rs b/crates/rooch-framework/src/natives/rooch_framework/crypto/ecdsa_k1_recoverable.rs index d48e68c27a..ff8b9549de 100644 --- a/crates/rooch-framework/src/natives/rooch_framework/crypto/ecdsa_k1_recoverable.rs +++ b/crates/rooch-framework/src/natives/rooch_framework/crypto/ecdsa_k1_recoverable.rs @@ -54,12 +54,7 @@ pub fn native_ecrecover( let pk = match hash { KECCAK256 => sig.recover_with_hash::(&msg_ref), SHA256 => sig.recover_with_hash::(&msg_ref), - _ => { - return Ok(NativeResult::err( - cost, - E_INVALID_HASH_TYPE, - )) - } // We should never reach here + _ => return Ok(NativeResult::err(cost, E_INVALID_HASH_TYPE)), // We should never reach here }; match pk { @@ -67,10 +62,7 @@ pub fn native_ecrecover( cost, smallvec![Value::vector_u8(pk.as_bytes().to_vec())], )), - Err(_) => Ok(NativeResult::err( - cost, - E_FAIL_TO_RECOVER_PUBKEY, - )), + Err(_) => Ok(NativeResult::err(cost, E_FAIL_TO_RECOVER_PUBKEY)), } } @@ -97,10 +89,7 @@ pub fn native_decompress_pubkey( smallvec![Value::vector_u8(uncompressed.to_vec())], )) } - Err(_) => Ok(NativeResult::err( - cost, - E_INVALID_PUBKEY, - )), + Err(_) => Ok(NativeResult::err(cost, E_INVALID_PUBKEY)), } } diff --git a/moveos/moveos-stdlib/src/natives/moveos_stdlib/bcs.rs b/moveos/moveos-stdlib/src/natives/moveos_stdlib/bcs.rs index 14e81f5254..3efd5bb47e 100644 --- a/moveos/moveos-stdlib/src/natives/moveos_stdlib/bcs.rs +++ b/moveos/moveos-stdlib/src/natives/moveos_stdlib/bcs.rs @@ -51,10 +51,7 @@ fn native_from_bytes( let val = match Value::simple_deserialize(&bytes, &layout) { Some(val) => val, None => { - return Ok(NativeResult::err( - cost, - E_TYPE_NOT_MATCH, - )); + return Ok(NativeResult::err(cost, E_TYPE_NOT_MATCH)); } }; // TODO(gas): charge gas for deserialization diff --git a/moveos/moveos-stdlib/src/natives/moveos_stdlib/json.rs b/moveos/moveos-stdlib/src/natives/moveos_stdlib/json.rs index 256c094f8a..8907520cf2 100644 --- a/moveos/moveos-stdlib/src/natives/moveos_stdlib/json.rs +++ b/moveos/moveos-stdlib/src/natives/moveos_stdlib/json.rs @@ -269,10 +269,7 @@ fn native_from_json( }; Ok(NativeResult::ok(cost, smallvec![Value::struct_(result)])) } else { - Ok(NativeResult::err( - cost, - E_TYPE_NOT_MATCH, - )) + Ok(NativeResult::err(cost, E_TYPE_NOT_MATCH)) } } diff --git a/moveos/moveos-stdlib/src/natives/moveos_stdlib/move_module.rs b/moveos/moveos-stdlib/src/natives/moveos_stdlib/move_module.rs index 67b02c261b..5665a223dd 100644 --- a/moveos/moveos-stdlib/src/natives/moveos_stdlib/move_module.rs +++ b/moveos/moveos-stdlib/src/natives/moveos_stdlib/move_module.rs @@ -133,10 +133,7 @@ fn native_sort_and_verify_modules_inner( let mut init_identifier = vec![]; for module in &compiled_modules { if *module.self_id().address() != account_address { - return Ok(NativeResult::err( - cost, - E_ADDRESS_NOT_MATCH_WITH_SIGNER, - )); + return Ok(NativeResult::err(cost, E_ADDRESS_NOT_MATCH_WITH_SIGNER)); } let result = moveos_verifier::verifier::verify_module(module, module_context.resolver); match result { @@ -149,10 +146,7 @@ fn native_sort_and_verify_modules_inner( Err(e) => { //TODO provide a flag to control whether to print debug log. log::info!("module {} verification error: {:?}", module.self_id(), e); - return Ok(NativeResult::err( - cost, - E_MODULE_VERIFICATION_ERROR, - )); + return Ok(NativeResult::err(cost, E_MODULE_VERIFICATION_ERROR)); } } } @@ -252,12 +246,7 @@ fn check_compatibililty_inner( match compat.check(&old_m, &new_m) { Ok(_) => {} - Err(_) => { - return Ok(NativeResult::err( - cost, - E_MODULE_INCOMPATIBLE, - )) - } + Err(_) => return Ok(NativeResult::err(cost, E_MODULE_INCOMPATIBLE)), } } Ok(NativeResult::ok(cost, smallvec![])) @@ -291,10 +280,7 @@ where let old_vec = pop_arg!(args, Vector); let vec_len = new_vec.elem_views().len(); if vec_len != old_vec.elem_views().len() { - return Ok(NativeResult::err( - cost, - E_LENTH_NOT_MATCH, - )); + return Ok(NativeResult::err(cost, E_LENTH_NOT_MATCH)); }; let vec_len = vec_len as u64; let new_values = new_vec.unpack(&element_type, vec_len)?; diff --git a/moveos/moveos-stdlib/src/natives/moveos_stdlib/raw_table/mod.rs b/moveos/moveos-stdlib/src/natives/moveos_stdlib/raw_table/mod.rs index c76b245fc2..04ec8996ed 100644 --- a/moveos/moveos-stdlib/src/natives/moveos_stdlib/raw_table/mod.rs +++ b/moveos/moveos-stdlib/src/natives/moveos_stdlib/raw_table/mod.rs @@ -480,10 +480,7 @@ fn native_add_box( table.size_increment += 1; Ok(NativeResult::ok(cost, smallvec![])) } - Err(_) => Ok(NativeResult::err( - cost, - E_ALREADY_EXISTS, - )), + Err(_) => Ok(NativeResult::err(cost, E_ALREADY_EXISTS)), } } @@ -532,10 +529,7 @@ fn native_borrow_box( let value_type = type_to_type_tag(context, &ty_args[1])?; match tv.borrow_global(value_type) { Ok(ref_val) => Ok(NativeResult::ok(cost, smallvec![ref_val])), - Err(_) => Ok(NativeResult::err( - cost, - E_NOT_FOUND, - )), + Err(_) => Ok(NativeResult::err(cost, E_NOT_FOUND)), } } @@ -642,10 +636,7 @@ fn native_remove_box( table.size_increment -= 1; Ok(NativeResult::ok(cost, smallvec![val])) } - Err(_) => Ok(NativeResult::err( - cost, - E_NOT_FOUND, - )), + Err(_) => Ok(NativeResult::err(cost, E_NOT_FOUND)), } } @@ -730,10 +721,7 @@ fn native_drop_unchecked_box( if table_data.removed_tables.insert(handle) { Ok(NativeResult::ok(gas_params.base, smallvec![])) } else { - Ok(NativeResult::err( - gas_params.base, - E_DUPLICATE_OPERATION, - )) + Ok(NativeResult::err(gas_params.base, E_DUPLICATE_OPERATION)) } }