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 warning #1382

Merged
merged 16 commits into from
Oct 10, 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
5 changes: 1 addition & 4 deletions rust/apps/arweave/src/ao_transaction.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use alloc::{
string::String,
vec::{self, Vec},
};
use alloc::{string::String, vec::Vec};
use app_utils::impl_public_struct;

use crate::{
Expand Down
9 changes: 3 additions & 6 deletions rust/apps/arweave/src/data_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use alloc::{
vec::Vec,
};
use app_utils::impl_public_struct;
use third_party::core2::io::Read;
use third_party::{core2::io::ErrorKind, hex};

impl_public_struct!(Tags {
len: i64,
Expand All @@ -23,7 +21,7 @@ impl Tags {
let mut avro_bytes = serial.to_vec();
let len = avro_decode_long(&mut avro_bytes)?;
let mut tags = vec![];
for i in 0..len {
for _i in 0..len {
let name = avro_decode_string(&mut avro_bytes)?;
let value = avro_decode_string(&mut avro_bytes)?;
tags.push(Tag { name, value })
Expand Down Expand Up @@ -65,7 +63,7 @@ fn avro_decode_long(reader: &mut Vec<u8>) -> Result<i64> {

fn avro_decode_string(reader: &mut Vec<u8>) -> Result<String> {
let len = avro_decode_long(reader)?;
let mut buf = reader.drain(..len as usize).collect();
let buf = reader.drain(..len as usize).collect();
Ok(
String::from_utf8(buf)
.map_err(|e| ArweaveError::AvroError(format!("{}", e.to_string())))?,
Expand Down Expand Up @@ -184,10 +182,9 @@ impl DataItem {

#[cfg(test)]
mod tests {
use crate::data_item::avro_decode_string;

use super::DataItem;
use alloc::{string::String, vec::Vec};

use third_party::hex;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion rust/apps/arweave/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use aes::cipher::{generic_array::GenericArray, BlockDecryptMut, BlockEncryptMut,
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use data_item::DataItem;
use keystore::algorithms::rsa::{get_rsa_secret_from_seed, sign_message};
use keystore::algorithms::rsa::get_rsa_secret_from_seed;
use sha2;
use sha2::Digest;
use third_party::base64;
Expand Down
1 change: 1 addition & 0 deletions rust/apps/bitcoin/src/multi_sig/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ fn get_path_component(index: Option<u32>, hardened: bool) -> URResult<PathCompon
PathComponent::new(index, hardened).map_err(|e| URError::CborEncodeError(e))
}

#[allow(unused)]
fn is_valid_multi_path(path: &str) -> bool {
const VALID_PATHS: [&str; 5] = [
MULTI_P2SH_PATH,
Expand Down
19 changes: 9 additions & 10 deletions rust/apps/bitcoin/src/multi_sig/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use alloc::fmt::format;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::str::FromStr;
Expand Down Expand Up @@ -115,23 +114,23 @@ impl Default for BsmsWallet {
}

fn _parse_plain_xpub_config(content: &str) -> Result<BsmsWallet, BitcoinError> {
let mut bsmsWallet = BsmsWallet::default();
let mut bsms_wallet = BsmsWallet::default();

for line in content.lines() {
if line.trim().starts_with("BSMS") {
if line.contains("BSMS 1.0") {
bsmsWallet.bsms_version = String::from("BSMS 1.0");
bsms_wallet.bsms_version = String::from("BSMS 1.0");
}
} else if line.starts_with("[") {
if let Some(end_bracket_pos) = line.find(']') {
if end_bracket_pos >= 9 {
let xfp = &line[1..=8].trim();
let derivation_path = &line[9..=end_bracket_pos - 1].trim();
let extended_pubkey = &line[end_bracket_pos + 1..].trim();
bsmsWallet.xfp = xfp.to_string();
bsmsWallet.derivation_path = format!("m{}", derivation_path);
bsmsWallet.extended_pubkey = extended_pubkey.to_string();
return Ok(bsmsWallet);
bsms_wallet.xfp = xfp.to_string();
bsms_wallet.derivation_path = format!("m{}", derivation_path);
bsms_wallet.extended_pubkey = extended_pubkey.to_string();
return Ok(bsms_wallet);
}
}
}
Expand All @@ -144,7 +143,7 @@ fn _parse_plain_xpub_config(content: &str) -> Result<BsmsWallet, BitcoinError> {
pub fn parse_bsms_wallet_config(bytes: Bytes) -> Result<BsmsWallet, BitcoinError> {
let content = String::from_utf8(bytes.get_bytes())
.map_err(|e| BitcoinError::MultiSigWalletImportXpubError(e.to_string()))?;
let mut wallet = _parse_plain_xpub_config(&content)?;
let wallet = _parse_plain_xpub_config(&content)?;
Ok(wallet)
}

Expand Down Expand Up @@ -238,7 +237,7 @@ fn _parse_plain_wallet_config(content: &str) -> Result<MultiSigWalletConfig, Bit
wallet.network = this_network;
is_first = false;
} else {
if (wallet.network != this_network) {
if wallet.network != this_network {
return Err(BitcoinError::MultiSigWalletParseError(format!(
"xpub networks inconsistent"
)));
Expand Down Expand Up @@ -426,7 +425,7 @@ fn is_valid_xyzpub(xpub: &str) -> bool {

match result {
Ok(xpub) => Xpub::from_str(&xpub).is_ok(),
Err(e) => false,
Err(_e) => false,
}
}

Expand Down
4 changes: 1 addition & 3 deletions rust/apps/bitcoin/src/transactions/parsed_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use alloc::vec::Vec;
use core::ops::Div;
use third_party::bitcoin::bip32::{DerivationPath, Fingerprint, Xpub};

use super::legacy::input;

#[derive(Debug, Eq, PartialEq)]
pub struct ParsedTx {
pub overview: OverviewTx,
Expand Down Expand Up @@ -136,7 +134,7 @@ pub trait TxParser {
}

fn is_need_sign(parsed_inputs: &[ParsedInput]) -> bool {
for (index, input) in parsed_inputs.iter().enumerate() {
for (_index, input) in parsed_inputs.iter().enumerate() {
if input.need_sign {
return true;
}
Expand Down
17 changes: 8 additions & 9 deletions rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::errors::{BitcoinError, Result};
use alloc::format;
use third_party::bitcoin::opcodes::all::OP_PUSHNUM_1;

use third_party::bitcoin::script::Instruction;
use third_party::itertools::Itertools;

Expand All @@ -17,13 +17,11 @@ use keystore::algorithms::secp256k1::derive_public_key;
use crate::multi_sig::address::calculate_multi_address;
use crate::multi_sig::wallet::calculate_multi_sig_verify_code;
use crate::multi_sig::MultiSigFormat;
use third_party::bitcoin::bip32::{
self, ChildNumber, DerivationPath, Fingerprint, KeySource, Xpub,
};
use third_party::bitcoin::bip32::{ChildNumber, DerivationPath, Fingerprint, KeySource, Xpub};
use third_party::bitcoin::psbt::{GetKey, KeyRequest, Psbt};
use third_party::bitcoin::psbt::{Input, Output};
use third_party::bitcoin::taproot::TapLeafHash;
use third_party::bitcoin::{script, Network, PrivateKey, Script};
use third_party::bitcoin::{Network, PrivateKey};
use third_party::bitcoin::{PublicKey, ScriptBuf, TxOut};
use third_party::secp256k1::{Secp256k1, Signing, XOnlyPublicKey};
use third_party::{bitcoin, secp256k1};
Expand All @@ -33,6 +31,7 @@ pub struct WrappedPsbt {
}

//TODO: use it later
#[allow(unused)]
pub enum SignStatus {
Completed,
PartlySigned,
Expand Down Expand Up @@ -227,11 +226,11 @@ impl WrappedPsbt {
)));
}

pub fn check_my_input_script(&self, input: &Input, index: usize) -> Result<()> {
pub fn check_my_input_script(&self, _input: &Input, _index: usize) -> Result<()> {
Ok(())
}

pub fn check_my_input_derivation(&self, input: &Input, index: usize) -> Result<()> {
pub fn check_my_input_derivation(&self, _input: &Input, _index: usize) -> Result<()> {
Ok(())
}

Expand Down Expand Up @@ -413,7 +412,7 @@ impl WrappedPsbt {
if input.bip32_derivation.len() > 1 {
let (cur, req) = self.get_input_sign_status(input);
//already collected needed signatures
if (cur >= req) {
if cur >= req {
return Ok(false);
}
// or I have signed this input
Expand Down Expand Up @@ -761,7 +760,7 @@ impl WrappedPsbt {
}

fn judge_external_key(child: String, parent: String) -> bool {
let mut sub_path = &child[parent.len()..];
let sub_path = &child[parent.len()..];
fn judge(v: &mut Chars) -> bool {
match v.next() {
Some('/') => judge(v),
Expand Down
2 changes: 1 addition & 1 deletion rust/apps/ethereum/src/legacy_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl TryFrom<EthTx> for LegacyTransaction {
fn try_from(eth_tx: EthTx) -> Result<Self, Self::Error> {
// check this transaction is erc20 transaction or not
if let Some(erc20_override) = eth_tx.r#override {
let contract_address = erc20_override.contract_address;
let _contract_address = erc20_override.contract_address;
// generate erc20 transfer inputdata
let to = crate::H160::from_str(&eth_tx.to).unwrap();
let amount = crate::U256::from(eth_tx.value.parse::<u64>().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion rust/apps/solana/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Read<Message> for Message {
Some(_) => false,
None => return Err(SolanaError::InvalidData("empty message".to_string())),
};
if (is_versioned) {
if is_versioned {
raw.remove(0);
}
let header = MessageHeader::read(raw)?;
Expand Down
4 changes: 1 addition & 3 deletions rust/apps/solana/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ use alloc::borrow::ToOwned;
use alloc::format;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::fmt::DebugList;

use serde_json::json;
use third_party::bitcoin::hex::FromHex;

use crate::errors::{Result, SolanaError};
use crate::message::Message;
Expand All @@ -16,7 +14,7 @@ use crate::parser::overview::{
JupiterV6SwapOverview, JupiterV6SwapTokenInfoOverview, ProgramOverviewGeneral,
ProgramOverviewInstruction, ProgramOverviewInstructions, ProgramOverviewMultisigCreate,
ProgramOverviewProposal, ProgramOverviewSplTokenTransfer, ProgramOverviewTransfer,
ProgramOverviewUnknown, ProgramOverviewVote, SolanaOverview,
ProgramOverviewVote, SolanaOverview,
};
use crate::parser::structs::{ParsedSolanaTx, SolanaTxDisplayType};
use crate::read::Read;
Expand Down
19 changes: 11 additions & 8 deletions rust/apps/solana/src/resolvers/squads_v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn resolve_multisig_create(args: MultisigCreateArgs) -> Result<SolanaDetail> {

fn resolve_multisig_create_v2(
args: MultisigCreateArgsV2,
accounts: Vec<String>,
_accounts: Vec<String>,
) -> Result<SolanaDetail> {
let common_detail = CommonDetail {
program: PROGRAM_NAME.to_string(),
Expand All @@ -54,7 +54,7 @@ fn resolve_multisig_create_v2(

fn resolve_proposal_create(
args: ProposalCreateArgs,
accounts: Vec<String>,
_accounts: Vec<String>,
) -> Result<SolanaDetail> {
let common_detail = CommonDetail {
program: PROGRAM_NAME.to_string(),
Expand All @@ -67,7 +67,7 @@ fn resolve_proposal_create(
Ok(detail)
}

fn resolve_proposal_activate(accounts: Vec<String>) -> Result<SolanaDetail> {
fn resolve_proposal_activate(_accounts: Vec<String>) -> Result<SolanaDetail> {
let common_detail = CommonDetail {
program: PROGRAM_NAME.to_string(),
method: "ProposalActivate".to_string(),
Expand All @@ -79,7 +79,7 @@ fn resolve_proposal_activate(accounts: Vec<String>) -> Result<SolanaDetail> {
Ok(detail)
}

fn resolve_proposal_cancel(args: ProposalVoteArgs, accounts: Vec<String>) -> Result<SolanaDetail> {
fn resolve_proposal_cancel(args: ProposalVoteArgs, _accounts: Vec<String>) -> Result<SolanaDetail> {
let common_detail = CommonDetail {
program: PROGRAM_NAME.to_string(),
method: "ProposalCancel".to_string(),
Expand All @@ -91,7 +91,7 @@ fn resolve_proposal_cancel(args: ProposalVoteArgs, accounts: Vec<String>) -> Res
Ok(detail)
}

fn resolve_proposal_reject(args: ProposalVoteArgs, accounts: Vec<String>) -> Result<SolanaDetail> {
fn resolve_proposal_reject(args: ProposalVoteArgs, _accounts: Vec<String>) -> Result<SolanaDetail> {
let common_detail = CommonDetail {
program: PROGRAM_NAME.to_string(),
method: "ProposalReject".to_string(),
Expand All @@ -103,7 +103,10 @@ fn resolve_proposal_reject(args: ProposalVoteArgs, accounts: Vec<String>) -> Res
Ok(detail)
}

fn resolve_proposal_approve(args: ProposalVoteArgs, accounts: Vec<String>) -> Result<SolanaDetail> {
fn resolve_proposal_approve(
args: ProposalVoteArgs,
_accounts: Vec<String>,
) -> Result<SolanaDetail> {
let common_detail = CommonDetail {
program: PROGRAM_NAME.to_string(),
method: "ProposalApprove".to_string(),
Expand All @@ -117,7 +120,7 @@ fn resolve_proposal_approve(args: ProposalVoteArgs, accounts: Vec<String>) -> Re

fn resolve_vault_transaction_create(
args: VaultTransactionCreateArgs,
accounts: Vec<String>,
_accounts: Vec<String>,
) -> Result<SolanaDetail> {
let common_detail = CommonDetail {
program: PROGRAM_NAME.to_string(),
Expand All @@ -130,7 +133,7 @@ fn resolve_vault_transaction_create(
Ok(detail)
}

fn resolve_vault_transaction_execute(accounts: Vec<String>) -> Result<SolanaDetail> {
fn resolve_vault_transaction_execute(_accounts: Vec<String>) -> Result<SolanaDetail> {
let common_detail = CommonDetail {
program: PROGRAM_NAME.to_string(),
method: "VaultTransactionExecute".to_string(),
Expand Down
3 changes: 3 additions & 0 deletions rust/apps/stellar/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
indent_style="Block"
reorder_imports=true
binop_separator="Front"
Loading
Loading