Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
pause125 committed Dec 5, 2023
1 parent d8789e9 commit a777d66
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 60 deletions.
5 changes: 1 addition & 4 deletions crates/rooch-framework/src/natives/rooch_framework/bcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,15 @@ pub fn native_ecrecover(
let pk = match hash {
KECCAK256 => sig.recover_with_hash::<Keccak256>(&msg_ref),
SHA256 => sig.recover_with_hash::<Sha256>(&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 {
Ok(pk) => Ok(NativeResult::ok(
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)),
}
}

Expand All @@ -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)),
}
}

Expand Down
5 changes: 1 addition & 4 deletions moveos/moveos-stdlib/src/natives/moveos_stdlib/bcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions moveos/moveos-stdlib/src/natives/moveos_stdlib/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
22 changes: 4 additions & 18 deletions moveos/moveos-stdlib/src/natives/moveos_stdlib/move_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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));
}
}
}
Expand Down Expand Up @@ -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![]))
Expand Down Expand Up @@ -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)?;
Expand Down
20 changes: 4 additions & 16 deletions moveos/moveos-stdlib/src/natives/moveos_stdlib/raw_table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}
}

Expand Down Expand Up @@ -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)),
}
}

Expand Down Expand Up @@ -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)),
}
}

Expand Down Expand Up @@ -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))
}
}

Expand Down

0 comments on commit a777d66

Please sign in to comment.