Skip to content

Commit

Permalink
fix make lint
Browse files Browse the repository at this point in the history
  • Loading branch information
harryliisme3 committed Dec 16, 2022
1 parent e044206 commit aca8d38
Show file tree
Hide file tree
Showing 24 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/components/abciapp/src/abci/staking/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn check_block_rewards_rate() -> Result<()> {

{
let rate = ledger.staking_get_block_rewards_rate();
let rate = [rate[0] as u128, rate[1] as u128];
let rate = [rate[0], rate[1]];
// max value: 105%
assert!(rate[0] * 100 <= rate[1] * 105);
// min value: 2%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ pub async fn query_validators(
})
.collect();
return Ok(web::Json(ValidatorList::new(
staking.cur_height() as u64,
staking.cur_height(),
validators_list,
)));
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/baseapp/src/tm_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn get_pending_hash() -> Result<Vec<H256>, attohttpc::Error> {
})
.map(|json_resp| {
for tx in json_resp.result.txs {
base64::decode(&tx)
base64::decode(tx)
.map(|bytes| {
let hasher = sha2_256(&bytes);
pending_hash.push(H256::from_slice(&hasher))
Expand Down
6 changes: 3 additions & 3 deletions src/components/contracts/modules/evm/tests/utils/solidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl ContractConstructor {
{
let bin_file = format!("{}.bin", contract_name);
let abi_file = format!("{}.abi", contract_name);
let hex_path = artifacts_base_path.as_ref().join(&bin_file);
let hex_path = artifacts_base_path.as_ref().join(bin_file);
let hex_rep = match std::fs::read_to_string(&hex_path) {
Ok(hex) => hex,
Err(_) => {
Expand All @@ -40,8 +40,8 @@ impl ContractConstructor {
std::fs::read_to_string(hex_path).unwrap()
}
};
let code = hex::decode(&hex_rep).unwrap();
let abi_path = artifacts_base_path.as_ref().join(&abi_file);
let code = hex::decode(hex_rep).unwrap();
let abi_path = artifacts_base_path.as_ref().join(abi_file);
let reader = std::fs::File::open(abi_path).unwrap();
let abi = ethabi::Contract::load(reader).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/primitives/mocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub struct KeyPair {
}

pub fn generate_address(seed: u8) -> KeyPair {
let private_key = H256::from_slice(&[(seed + 1) as u8; 32]);
let private_key = H256::from_slice(&[(seed + 1); 32]);
let secret_key = libsecp256k1::SecretKey::parse_slice(&private_key[..]).unwrap();
let public_key =
&libsecp256k1::PublicKey::from_secret_key(&secret_key).serialize()[1..65];
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/primitives/types/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ pub fn secp256k1_ecdsa_recover(sig: &[u8; 65], msg: &[u8; 32]) -> ruc::Result<[u
.map_err(|_| eg!("Ecdsa signature verify error: bad RS"))?;
let v =
libsecp256k1::RecoveryId::parse(
if sig[64] > 26 { sig[64] - 27 } else { sig[64] } as u8,
if sig[64] > 26 { sig[64] - 27 } else { sig[64] },
)
.map_err(|_| eg!("Ecdsa signature verify error: bad V"))?;
let pubkey = libsecp256k1::recover(&libsecp256k1::Message::parse(msg), &rs, &v)
Expand Down
4 changes: 2 additions & 2 deletions src/components/contracts/primitives/utils/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<'de> Deserialize<'de> for Public {
D: Deserializer<'de>,
{
let pk =
base64::decode_config(&String::deserialize(deserializer)?, base64::URL_SAFE)
base64::decode_config(String::deserialize(deserializer)?, base64::URL_SAFE)
.map_err(|e| de::Error::custom(format!("{:?}", e)))?;
Public::try_from(pk.as_slice())
.map_err(|e| de::Error::custom(format!("{:?}", e)))
Expand Down Expand Up @@ -173,7 +173,7 @@ impl<'de> Deserialize<'de> for Signature {
where
D: Deserializer<'de>,
{
let signature_hex = hex::decode(&String::deserialize(deserializer)?)
let signature_hex = hex::decode(String::deserialize(deserializer)?)
.map_err(|e| de::Error::custom(format!("{:?}", e)))?;
Signature::try_from(signature_hex.as_ref())
.map_err(|e| de::Error::custom(format!("{:?}", e)))
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/primitives/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use primitive_types::H160;
pub fn timestamp_converter(timestamp: protobuf::well_known_types::Timestamp) -> u64 {
let unix_time =
core::time::Duration::new(timestamp.seconds as u64, timestamp.nanos as u32);
unix_time.as_secs() as u64
unix_time.as_secs()
}

pub fn proposer_converter(address: Vec<u8>) -> Option<H160> {
Expand Down
12 changes: 6 additions & 6 deletions src/components/contracts/primitives/wasm/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ pub fn recover_signer(transaction: &Transaction) -> Option<H160> {
}
let pubkey = fp_types::crypto::secp256k1_ecdsa_recover(&sig, &msg).ok()?;
Some(H160::from(H256::from_slice(
Keccak256::digest(&pubkey).as_slice(),
Keccak256::digest(pubkey).as_slice(),
)))
}

#[wasm_bindgen]
pub fn recover_tx_signer(raw_tx: String) -> Result<String, JsValue> {
let tx_bytes = base64::decode_config(&raw_tx, base64::URL_SAFE)
let tx_bytes = base64::decode_config(raw_tx, base64::URL_SAFE)
.c(d!())
.map_err(error_to_jsvalue)?;
let raw_tx = EvmRawTxWrapper::unwrap(&tx_bytes)
Expand All @@ -89,7 +89,7 @@ pub fn recover_tx_signer(raw_tx: String) -> Result<String, JsValue> {

#[wasm_bindgen]
pub fn evm_tx_hash(raw_tx: String) -> Result<String, JsValue> {
let tx_bytes = base64::decode_config(&raw_tx, base64::URL_SAFE)
let tx_bytes = base64::decode_config(raw_tx, base64::URL_SAFE)
.c(d!())
.map_err(error_to_jsvalue)?;
let raw_tx = EvmRawTxWrapper::unwrap(&tx_bytes)
Expand Down Expand Up @@ -122,7 +122,7 @@ mod test {
#[test]
fn recover_signer_works() {
let raw_tx = String::from("ZXZtOnsic2lnbmF0dXJlIjpudWxsLCJmdW5jdGlvbiI6eyJFdGhlcmV1bSI6eyJUcmFuc2FjdCI6eyJub25jZSI6IjB4MSIsImdhc19wcmljZSI6IjB4MTc0ODc2ZTgwMCIsImdhc19saW1pdCI6IjB4NTIwOCIsImFjdGlvbiI6eyJDYWxsIjoiMHgyYWQzMjg0NmM2ZGQyZmZkM2VkYWRiZTUxY2Q1YWUwNGFhNWU1NzVlIn0sInZhbHVlIjoiMHg1NmJjNzVlMmQ2MzEwMDAwMCIsImlucHV0IjpbXSwic2lnbmF0dXJlIjp7InYiOjEwODIsInIiOiIweGY4YWVmN2Y4MDUzZDg5ZmVlMzk1MGM0ZDcwMjA4MGJmM2E4MDcyYmVkNWQ4NGEzYWYxOWEzNjAwODFiNjM2YTIiLCJzIjoiMHgyOTYyOTlhOGYyNDMwYjg2ZmQzZWI5NzZlYWJjNzMwYWMxY2ZiYmJlMzZlYjY5ZWFlMzM4Y2ZmMzNjNGE5OGMxIn19fX19");
let tx_bytes = base64::decode_config(&raw_tx, base64::URL_SAFE).unwrap();
let tx_bytes = base64::decode_config(raw_tx, base64::URL_SAFE).unwrap();
let evm_tx = EvmRawTxWrapper::unwrap(&tx_bytes).unwrap();
let unchecked_tx: LegacyUncheckedTransaction<()> =
serde_json::from_slice(evm_tx).unwrap();
Expand All @@ -139,7 +139,7 @@ mod test {
}

let raw_tx = String::from("ZXZtOnsiRXRoZXJldW0iOnsiVHJhbnNhY3QiOnsiRUlQMTU1OSI6eyJjaGFpbl9pZCI6MjE1Miwibm9uY2UiOiIweDEiLCJtYXhfcHJpb3JpdHlfZmVlX3Blcl9nYXMiOiIweDI3MTAiLCJtYXhfZmVlX3Blcl9nYXMiOiIweDI3MTAiLCJnYXNfbGltaXQiOiIweDI3MTAiLCJhY3Rpb24iOnsiQ2FsbCI6IjB4MmFkMzI4NDZjNmRkMmZmZDNlZGFkYmU1MWNkNWFlMDRhYTVlNTc1ZSJ9LCJ2YWx1ZSI6IjB4MjcxMCIsImlucHV0IjpbXSwiYWNjZXNzX2xpc3QiOltdLCJvZGRfeV9wYXJpdHkiOmZhbHNlLCJyIjoiMHhmOGFlZjdmODA1M2Q4OWZlZTM5NTBjNGQ3MDIwODBiZjNhODA3MmJlZDVkODRhM2FmMTlhMzYwMDgxYjYzNmEyIiwicyI6IjB4Mjk2Mjk5YThmMjQzMGI4NmZkM2ViOTc2ZWFiYzczMGFjMWNmYmJiZTM2ZWI2OWVhZTMzOGNmZjMzYzRhOThjMSJ9fX19");
let tx_bytes = base64::decode_config(&raw_tx, base64::URL_SAFE).unwrap();
let tx_bytes = base64::decode_config(raw_tx, base64::URL_SAFE).unwrap();
let evm_tx = EvmRawTxWrapper::unwrap(&tx_bytes).unwrap();
let action: Action = serde_json::from_slice(evm_tx).unwrap();
if let Action::Ethereum(EthAction::Transact(tx)) = action {
Expand All @@ -156,7 +156,7 @@ mod test {
#[test]
fn evm_tx_hash_works() {
let raw_tx = String::from("eyJzaWduYXR1cmUiOm51bGwsImZ1bmN0aW9uIjp7IkV0aGVyZXVtIjp7IlRyYW5zYWN0Ijp7Im5vbmNlIjoiMHg5IiwiZ2FzX3ByaWNlIjoiMHhlOGQ0YTUxMDAwIiwiZ2FzX2xpbWl0IjoiMHg1MjA4IiwiYWN0aW9uIjp7IkNhbGwiOiIweGE1MjI1Y2JlZTUwNTIxMDBlYzJkMmQ5NGFhNmQyNTg1NTgwNzM3NTcifSwidmFsdWUiOiIweDk4YTdkOWI4MzE0YzAwMDAiLCJpbnB1dCI6W10sInNpZ25hdHVyZSI6eyJ2IjoxMDgyLCJyIjoiMHg4MDBjZjQ5ZTAzMmJhYzY4MjY3MzdhZGJhZDEzN2Y0MTk5OTRjNjgxZWE1ZDUyYjliMGJhZDJmNDAyYjMwMTI0IiwicyI6IjB4Mjk1Mjc3ZWY2NTYzNDAwY2VkNjFiODhkM2ZiNGM3YjMyY2NkNTcwYThiOWJiOGNiYmUyNTkyMTRhYjdkZTI1YSJ9fX19fQ==");
let tx_bytes = base64::decode_config(&raw_tx, base64::URL_SAFE).unwrap();
let tx_bytes = base64::decode_config(raw_tx, base64::URL_SAFE).unwrap();
let unchecked_tx: LegacyUncheckedTransaction<()> =
serde_json::from_slice(tx_bytes.as_slice()).unwrap();
if let LegacyAction::Ethereum(LegacyEthAction::Transact(tx)) =
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/rpc/src/eth_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl SubscriptionResult {
let mut log_index: u32 = 0;
for (receipt_index, receipt) in receipts.into_iter().enumerate() {
let transaction_hash: Option<H256> = if !receipt.logs.is_empty() {
let transaction = &block.transactions[receipt_index as usize];
let transaction = &block.transactions[receipt_index];
Some(transaction.hash())
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/rpc/src/web3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Web3Api for Web3ApiImpl {

fn sha3(&self, input: Bytes) -> Result<H256> {
Ok(H256::from_slice(
Keccak256::digest(&input.into_vec()).as_slice(),
Keccak256::digest(input.into_vec()).as_slice(),
))
}
}
2 changes: 1 addition & 1 deletion src/components/finutils/src/bins/stt/init/i_testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ struct TmValidator {

fn get_26657_validators(sa: &str) -> Result<TmValidatorsBody> {
let url = format!("{}:26657/validators", sa);
attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand Down
26 changes: 13 additions & 13 deletions src/components/finutils/src/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn send_tx(tx: &Transaction) -> Result<()> {

let tx_bytes = serde_json::to_vec(tx).c(d!())?;

let _ = attohttpc::post(&url)
let _ = attohttpc::post(url)
.header(attohttpc::header::CONTENT_TYPE, "application/json")
.bytes(&tx_bytes)
.send()
Expand Down Expand Up @@ -484,7 +484,7 @@ struct TmStatus {
fn get_network_status(addr: &str) -> Result<TmStatus> {
let url = format!("{}:26657/status", addr);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand Down Expand Up @@ -515,7 +515,7 @@ pub fn get_local_block_height() -> u64 {
pub fn get_asset_type(code: &str) -> Result<AssetType> {
let url = format!("{}:8668/asset_token/{}", get_serv_addr().c(d!())?, code);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand All @@ -533,7 +533,7 @@ pub fn get_created_assets(addr: &XfrPublicKey) -> Result<Vec<DefineAsset>> {
wallet::public_key_to_base64(addr)
);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand Down Expand Up @@ -587,7 +587,7 @@ fn get_owned_utxos_x(
wallet::public_key_to_base64(addr)
);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand All @@ -608,7 +608,7 @@ pub fn get_owned_abar(com: &Commitment) -> Result<(ATxoSID, AnonAssetRecord)> {
wallet::commitment_to_base58(com)
);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand Down Expand Up @@ -637,7 +637,7 @@ fn get_seq_id() -> Result<u64> {

let url = format!("{}:8668/global_state", get_serv_addr().c(d!())?);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand All @@ -662,7 +662,7 @@ pub fn get_owner_memo_batch(ids: &[TxoSID]) -> Result<Vec<Option<OwnerMemo>>> {
ids
);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand All @@ -678,7 +678,7 @@ pub fn get_abar_memo(id: &ATxoSID) -> Result<Option<AxfrOwnerMemo>> {
let id = id.0.to_string();
let url = format!("{}:8667/get_abar_memo/{}", get_serv_addr().c(d!())?, id);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand All @@ -698,7 +698,7 @@ pub fn get_abar_proof(atxo_sid: &ATxoSID) -> Result<Option<MTLeafInfo>> {
atxo_sid
);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand All @@ -717,7 +717,7 @@ pub fn check_nullifier_hash(null_hash: &str) -> Result<Option<bool>> {
null_hash
);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand All @@ -735,7 +735,7 @@ pub fn get_delegation_info(pk: &XfrPublicKey) -> Result<DelegationInfo> {
wallet::public_key_to_base64(pk)
);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand All @@ -753,7 +753,7 @@ pub fn get_validator_detail(td_addr: TendermintAddrRef) -> Result<ValidatorDetai
td_addr
);

attohttpc::get(&url)
attohttpc::get(url)
.send()
.c(d!())?
.error_for_status()
Expand Down
2 changes: 1 addition & 1 deletion src/components/finutils/src/txn_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ impl AnonTransferOperationBuilder {
};
}

let remainder = sum_input - sum_output - (fees as u64);
let remainder = sum_input - sum_output - (fees);
if remainder > 0 {
let oabar_money_back = OpenAnonAssetRecordBuilder::new()
.amount(remainder)
Expand Down
2 changes: 1 addition & 1 deletion src/components/wallet_mobile/src/rust/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl EVMTransactionBuilder {
};

let txn_with_tag = EvmRawTxWrapper::wrap(&txn);
base64::encode(&txn_with_tag)
base64::encode(txn_with_tag)
}

pub fn into_ptr(self) -> *mut Self {
Expand Down
2 changes: 1 addition & 1 deletion src/ledger/src/data_model/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fn gen_sample_tx() -> Transaction {
let issuance_operation = Operation::IssueAsset(asset_issuance.clone());

// Instantiate an DefineAsset operation
let mut asset = Box::new(Asset::default());
let mut asset = Box::<Asset>::default();
asset.code = AssetTypeCode::gen_random();

let asset_creation = DefineAsset::new(
Expand Down
4 changes: 2 additions & 2 deletions src/ledger/src/staking/cosig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub struct CoSigRule {
impl CoSigRule {
#[allow(missing_docs)]
pub fn new(threshold: [u64; 2]) -> Result<Self> {
if threshold[0] > threshold[1] || threshold[1] > MAX_TOTAL_POWER as u64 {
if threshold[0] > threshold[1] || threshold[1] > MAX_TOTAL_POWER {
return Err(eg!("invalid threshold"));
}

Expand Down Expand Up @@ -263,7 +263,7 @@ mod test {
vd.cosig_rule = pnk!(CoSigRule::new([75, 100]));

assert!(CoSigRule::new([200, 100]).is_err());
assert!(CoSigRule::new([200, 1 + MAX_TOTAL_POWER as u64]).is_err());
assert!(CoSigRule::new([200, 1 + MAX_TOTAL_POWER]).is_err());

let mut data = CoSigOp::create(Data::default(), no_replay_token());
pnk!(data.batch_sign(&kps.iter().skip(10).collect::<Vec<_>>()));
Expand Down
2 changes: 1 addition & 1 deletion src/ledger/src/staking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ impl Staking {
) -> Result<Vec<Validator>> {
self.validator_info
.remove(&h)
.map(|v| v.body.into_iter().map(|(_, v)| v).collect())
.map(|v| v.body.into_values().collect())
.c(d!("not exists"))
}

Expand Down
2 changes: 1 addition & 1 deletion src/ledger/src/store/api_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ pub fn check_lost_data(ledger: &mut LedgerState) -> Result<()> {
// update the last txo sid
api_cache
.last_sid
.insert("last_txo_sid".to_string(), index as u64);
.insert("last_txo_sid".to_string(), index);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ledger/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ impl LedgerStatus {
);
if seq_id > self.block_commit_count {
return Err(eg!(("Transaction seq_id ahead of block_count")));
} else if seq_id + (TRANSACTION_WINDOW_WIDTH as u64) < self.block_commit_count {
} else if seq_id + (TRANSACTION_WINDOW_WIDTH) < self.block_commit_count {
return Err(eg!(("Transaction seq_id too far behind block_count")));
} else {
// Check to see that this nrpt has not been seen before
Expand Down
4 changes: 2 additions & 2 deletions src/libs/bitmap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ fn count_byte(mask: usize) -> u8 {
let mut result = 0;

for i in 0..8 {
result += if mask & (1 << i) == 0 { 0 } else { 1 };
result += u8::from(mask & (1 << i) != 0);
}

result
Expand Down Expand Up @@ -1097,7 +1097,7 @@ impl BitMap {
// Append a list of the set bits to the serialization
// results.
fn append_set(&self, index: usize, result: &mut Vec<u8>) {
let set_bits = self.set_bits[index] as u32;
let set_bits = self.set_bits[index];

// Append the header to the serialization.
self.append_header(index, BIT_DESC_SET, set_bits, result);
Expand Down
Loading

0 comments on commit aca8d38

Please sign in to comment.