Skip to content

Commit

Permalink
style: run rust fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
soralit committed Dec 25, 2024
1 parent a16a588 commit f61832f
Show file tree
Hide file tree
Showing 46 changed files with 139 additions and 137 deletions.
2 changes: 1 addition & 1 deletion rust/apps/cardano/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloc::string::{String, ToString};
use alloc::vec::Vec;
use cardano_serialization_lib::protocol_types::Address;
use cryptoxide::hashing::blake2b_256;
use ed25519_bip32_core::{XPrv};
use ed25519_bip32_core::XPrv;
use hex;
use ur_registry::cardano::cardano_delegation::CardanoDelegation;
use ur_registry::cardano::governance::CardanoVotingRegistration;
Expand Down
5 changes: 2 additions & 3 deletions rust/apps/cardano/src/structs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::address::{derive_pubkey_hash};
use crate::address::derive_pubkey_hash;
use crate::errors::{CardanoError, R};
use alloc::collections::BTreeMap;
use alloc::string::{String, ToString};
Expand All @@ -9,8 +9,7 @@ use cardano_serialization_lib::protocol_types::{
Address, BaseAddress, EnterpriseAddress, RewardAddress,
};


use cardano_serialization_lib::protocol_types::{DRepKind};
use cardano_serialization_lib::protocol_types::DRepKind;

use cardano_serialization_lib::{
protocol_types::FixedTransaction as Transaction, protocol_types::VoteKind, NetworkIdKind,
Expand Down
2 changes: 1 addition & 1 deletion rust/apps/cardano/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use alloc::vec::Vec;
use cardano_serialization_lib;
use cardano_serialization_lib::protocol_types::{Ed25519Signature, PublicKey, Vkey, Vkeywitness};
use cryptoxide::hashing::blake2b_256;
use ed25519_bip32_core::{XPrv};
use ed25519_bip32_core::XPrv;
use hex;
use ur_registry::crypto_key_path::CryptoKeyPath;

Expand Down
4 changes: 1 addition & 3 deletions rust/keystore/src/algorithms/zcash/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use core::str::FromStr;

use alloc::{
string::{String, ToString},
};
use alloc::string::{String, ToString};
use bitcoin::bip32::{ChildNumber, DerivationPath};
use hex;
use rand_chacha::rand_core::SeedableRng;
Expand Down
9 changes: 7 additions & 2 deletions rust/rust_c/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ fn main() {
"debug-btc-only",
];
assert!(features.len() > 0, "No build variant enabled");
assert!(features.len() == 1, "Multiple build variants enabled: {:?}", features);
let output_target = env::var("CBINDGEN_BINDINGS_TARGET").unwrap_or(format!("bindings/{}/librust_c.h", features[0]));
assert!(
features.len() == 1,
"Multiple build variants enabled: {:?}",
features
);
let output_target = env::var("CBINDGEN_BINDINGS_TARGET")
.unwrap_or(format!("bindings/{}/librust_c.h", features[0]));
config.parse.expand.features = Some(features.into_iter().map(|s| s.to_string()).collect());

let builder = cbindgen::Builder::new();
Expand Down
14 changes: 7 additions & 7 deletions rust/rust_c/src/aptos/mod.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use structs::DisplayAptosTx;
use crate::common::errors::RustCError;
use crate::common::structs::{SimpleResponse, TransactionCheckResult, TransactionParseResult};
use crate::common::types::{PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{UREncodeResult, FRAGMENT_MAX_LENGTH_DEFAULT};
use crate::common::utils::{convert_c_char, recover_c_char};
use crate::extract_ptr_with_type;
use alloc::format;
use alloc::slice;
use alloc::string::ToString;
use alloc::vec::Vec;
use app_aptos;
use app_aptos::errors::AptosError;
use app_aptos::parser::is_tx;
use crate::common::errors::RustCError;
use crate::extract_ptr_with_type;
use crate::common::structs::{SimpleResponse, TransactionCheckResult, TransactionParseResult};
use crate::common::types::{PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{UREncodeResult, FRAGMENT_MAX_LENGTH_DEFAULT};
use crate::common::utils::{convert_c_char, recover_c_char};
use cty::c_char;
use hex;
use hex::FromHex;
use structs::DisplayAptosTx;
use ur_registry::aptos::aptos_sign_request::{AptosSignRequest, SignType};
use ur_registry::aptos::aptos_signature::AptosSignature;
use ur_registry::traits::RegistryItem;
Expand Down
4 changes: 2 additions & 2 deletions rust/rust_c/src/aptos/structs.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use alloc::string::{String, ToString};
use app_aptos::parser::AptosTx;
use crate::common::free::Free;
use crate::common::structs::TransactionParseResult;
use crate::common::types::{PtrString, PtrT};
use crate::common::utils::convert_c_char;
use crate::{check_and_free_ptr, free_str_ptr, impl_c_ptr, make_free_method};
use alloc::string::{String, ToString};
use app_aptos::parser::AptosTx;
use serde_json::Value;

#[repr(C)]
Expand Down
14 changes: 7 additions & 7 deletions rust/rust_c/src/arweave/structs.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use core::ptr::null_mut;
use crate::common::ffi::VecFFI;
use crate::common::free::Free;
use crate::common::structs::TransactionParseResult;
use crate::common::types::{Ptr, PtrString, PtrT};
use crate::common::utils::convert_c_char;
use crate::{check_and_free_ptr, free_str_ptr, free_vec, impl_c_ptr, make_free_method};
use alloc::vec::Vec;
use app_arweave::{
ao_transaction::AOTransferTransaction,
data_item::{DataItem, Tag},
};
use crate::common::free::Free;
use crate::common::structs::TransactionParseResult;
use crate::common::types::{Ptr, PtrString, PtrT};
use crate::common::utils::convert_c_char;
use crate::{check_and_free_ptr, free_str_ptr, impl_c_ptr, make_free_method, free_vec};
use crate::common::ffi::VecFFI;
use core::ptr::null_mut;

#[repr(C)]
pub enum ArweaveRequestType {
Expand Down
6 changes: 3 additions & 3 deletions rust/rust_c/src/bitcoin/address.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use app_bitcoin;
use app_bitcoin::addresses::xyzpub;
use bitcoin::secp256k1::ffi::types::c_char;
use crate::common::structs::SimpleResponse;
use crate::common::types::PtrString;
use crate::common::utils::{convert_c_char, recover_c_char};
use app_bitcoin;
use app_bitcoin::addresses::xyzpub;
use bitcoin::secp256k1::ffi::types::c_char;
use core::str::FromStr;

#[no_mangle]
Expand Down
4 changes: 2 additions & 2 deletions rust/rust_c/src/bitcoin/legacy.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::structs::DisplayTx;
use alloc::boxed::Box;
use alloc::slice;
use crate::common::errors::RustCError;
use crate::common::keystone;
use crate::common::keystone::{build_parse_context, build_payload};
use crate::common::structs::{TransactionCheckResult, TransactionParseResult};
use crate::common::types::{PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{QRCodeType, UREncodeResult};
use alloc::boxed::Box;
use alloc::slice;

#[no_mangle]
pub extern "C" fn utxo_parse_keystone(
Expand Down
14 changes: 7 additions & 7 deletions rust/rust_c/src/bitcoin/msg.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
use core::ptr::null_mut;
use super::structs::DisplayBtcMsg;
use alloc::{
slice,
string::{String, ToString},
vec::Vec,
};
use base64;
use crate::common::{
errors::RustCError,
ffi::CSliceFFI,
Expand All @@ -16,6 +9,13 @@ use crate::common::{
utils::{convert_c_char, recover_c_array, recover_c_char},
};
use crate::extract_ptr_with_type;
use alloc::{
slice,
string::{String, ToString},
vec::Vec,
};
use base64;
use core::ptr::null_mut;
use keystore::algorithms::secp256k1;
use ur_registry::bitcoin::btc_sign_request::{BtcSignRequest, DataType};
use ur_registry::bitcoin::btc_signature::BtcSignature;
Expand Down
6 changes: 3 additions & 3 deletions rust/rust_c/src/bitcoin/multi_sig/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use alloc::boxed::Box;
use alloc::format;
use alloc::string::ToString;

use alloc::vec::Vec;
use app_bitcoin::multi_sig::wallet::{BsmsWallet, MultiSigWalletConfig};
use app_bitcoin::multi_sig::{MultiSigFormat, MultiSigType, MultiSigXPubInfo, Network};
use crate::common::ffi::VecFFI;
use crate::common::free::Free;
use crate::common::types::{Ptr, PtrBytes, PtrString, PtrT};
use crate::common::ur::UREncodeResult;
use crate::common::utils::{convert_c_char, recover_c_char};
use crate::{check_and_free_ptr, free_str_ptr, free_vec, impl_c_ptr, make_free_method};
use alloc::vec::Vec;
use app_bitcoin::multi_sig::wallet::{BsmsWallet, MultiSigWalletConfig};
use app_bitcoin::multi_sig::{MultiSigFormat, MultiSigType, MultiSigXPubInfo, Network};

#[repr(C)]
pub enum NetworkType {
Expand Down
8 changes: 4 additions & 4 deletions rust/rust_c/src/bitcoin/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ use app_bitcoin::multi_sig::wallet::parse_wallet_config;
use core::ptr::null_mut;
use core::str::FromStr;

use app_bitcoin::parsed_tx::ParseContext;
use app_bitcoin::{self, parse_psbt_hex_sign_status, parse_psbt_sign_status};
use bitcoin::bip32::{DerivationPath, Xpub};
use crate::common::errors::RustCError;
use crate::extract_ptr_with_type;
use crate::common::ffi::{CSliceFFI, VecFFI};
use crate::common::structs::{
ExtendedPublicKey, Response, TransactionCheckResult, TransactionParseResult,
};
use crate::common::types::{Ptr, PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{UREncodeResult, FRAGMENT_MAX_LENGTH_DEFAULT, FRAGMENT_UNLIMITED_LENGTH};
use crate::common::utils::{convert_c_char, recover_c_array, recover_c_char};
use crate::extract_ptr_with_type;
use app_bitcoin::parsed_tx::ParseContext;
use app_bitcoin::{self, parse_psbt_hex_sign_status, parse_psbt_sign_status};
use bitcoin::bip32::{DerivationPath, Xpub};
use hex;
use ur_registry::crypto_psbt::CryptoPSBT;
use ur_registry::traits::RegistryItem;
Expand Down
4 changes: 2 additions & 2 deletions rust/rust_c/src/bitcoin/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use alloc::boxed::Box;
use alloc::vec::Vec;
use core::ptr::null_mut;

use app_bitcoin;
use app_bitcoin::parsed_tx::{DetailTx, OverviewTx, ParsedInput, ParsedOutput, ParsedTx};
use crate::common::ffi::VecFFI;
use crate::common::free::Free;
use crate::common::structs::Response;
Expand All @@ -12,6 +10,8 @@ use crate::common::types::{PtrString, PtrT};
use crate::common::ur::UREncodeResult;
use crate::common::utils::convert_c_char;
use crate::{check_and_free_ptr, free_str_ptr, impl_c_ptr, make_free_method};
use app_bitcoin;
use app_bitcoin::parsed_tx::{DetailTx, OverviewTx, ParsedInput, ParsedOutput, ParsedTx};

#[repr(C)]
pub struct PsbtSignResult {
Expand Down
4 changes: 2 additions & 2 deletions rust/rust_c/src/cardano/address.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use app_cardano;
use app_cardano::address::AddressType;
use crate::common::structs::SimpleResponse;
use crate::common::types::PtrString;
use crate::common::utils::{convert_c_char, recover_c_char};
use app_cardano;
use app_cardano::address::AddressType;
use cty::c_char;

#[no_mangle]
Expand Down
4 changes: 2 additions & 2 deletions rust/rust_c/src/cardano/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ use ur_registry::cardano::cardano_sign_tx_hash_request::CardanoSignTxHashRequest
use ur_registry::cardano::cardano_signature::CardanoSignature;
use ur_registry::crypto_key_path::CryptoKeyPath;

use structs::{DisplayCardanoCatalyst, DisplayCardanoSignData, DisplayCardanoTx};
use crate::common::errors::{RustCError, R};
use crate::extract_ptr_with_type;
use crate::common::structs::{SimpleResponse, TransactionCheckResult, TransactionParseResult};
use crate::common::types::{Ptr, PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{UREncodeResult, FRAGMENT_MAX_LENGTH_DEFAULT};
use crate::common::utils::{convert_c_char, recover_c_char};
use crate::extract_ptr_with_type;
use structs::{DisplayCardanoCatalyst, DisplayCardanoSignData, DisplayCardanoTx};
use ur_registry::registry_types::{
CARDANO_CATALYST_VOTING_REGISTRATION_SIGNATURE, CARDANO_SIGNATURE, CARDANO_SIGN_DATA_SIGNATURE,
};
Expand Down
4 changes: 2 additions & 2 deletions rust/rust_c/src/common/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use thiserror;
use thiserror::Error;
use ur_registry::error::URError;

#[cfg(feature = "bitcoin")]
use app_bitcoin::errors::BitcoinError;
#[cfg(feature = "aptos")]
use app_aptos::errors::AptosError;
#[cfg(feature = "arweave")]
use app_arweave::errors::ArweaveError;
#[cfg(feature = "bitcoin")]
use app_bitcoin::errors::BitcoinError;
#[cfg(feature = "cardano")]
use app_cardano::errors::CardanoError;
#[cfg(feature = "cosmos")]
Expand Down
2 changes: 1 addition & 1 deletion rust/rust_c/src/common/free.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::ffi::VecFFI;
use crate::make_free_method;
use super::structs::SimpleResponse;
use super::types::{PtrString, PtrT};
use super::ur::{UREncodeMultiResult, UREncodeResult, URParseMultiResult, URParseResult};
use crate::make_free_method;
use alloc::boxed::Box;
use cty::{c_char, c_void};

Expand Down
2 changes: 1 addition & 1 deletion rust/rust_c/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,4 @@ pub extern "C" fn pbkdf2_rust_64(
#[no_mangle]
pub extern "C" fn tx_check_pass() -> Ptr<TransactionCheckResult> {
TransactionCheckResult::new().c_ptr()
}
}
20 changes: 10 additions & 10 deletions rust/rust_c/src/common/ur_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@ use alloc::vec::Vec;

use serde_json::{from_slice, from_value, Value};

use ur_registry::bytes::Bytes;
use ur_registry::crypto_account::CryptoAccount;
use ur_registry::crypto_psbt::CryptoPSBT;
use ur_registry::error::URError;
use ur_registry::extend::crypto_multi_accounts::CryptoMultiAccounts;
use ur_registry::pb::protobuf_parser::{parse_protobuf, unzip};
use ur_registry::pb::protoc;
use ur_registry::pb::protoc::Base;
#[cfg(feature = "multi-coins")]
use ur_registry::extend::qr_hardware_call::{CallType, QRHardwareCall};
#[cfg(feature = "aptos")]
use ur_registry::aptos::aptos_sign_request::AptosSignRequest;
#[cfg(feature = "arweave")]
use ur_registry::arweave::arweave_sign_request::{ArweaveSignRequest, SignType};
#[cfg(feature = "bitcoin")]
use ur_registry::bitcoin::btc_sign_request::BtcSignRequest;
use ur_registry::bytes::Bytes;
#[cfg(feature = "cardano")]
use ur_registry::cardano::cardano_catalyst_voting_registration::CardanoCatalystVotingRegistrationRequest;
#[cfg(feature = "cardano")]
Expand All @@ -32,14 +23,23 @@ use ur_registry::cardano::cardano_sign_tx_hash_request::CardanoSignTxHashRequest
use ur_registry::cosmos::cosmos_sign_request::CosmosSignRequest;
#[cfg(feature = "cosmos")]
use ur_registry::cosmos::evm_sign_request::EvmSignRequest;
use ur_registry::crypto_account::CryptoAccount;
use ur_registry::crypto_psbt::CryptoPSBT;
use ur_registry::error::URError;
#[cfg(feature = "ethereum")]
use ur_registry::ethereum::eth_sign_request;
#[cfg(feature = "ethereum")]
use ur_registry::ethereum::eth_sign_request::EthSignRequest;
use ur_registry::extend::crypto_multi_accounts::CryptoMultiAccounts;
#[cfg(feature = "multi-coins")]
use ur_registry::extend::qr_hardware_call::{CallType, QRHardwareCall};
#[cfg(feature = "multi-coins")]
use ur_registry::keystone::keystone_sign_request::KeystoneSignRequest;
#[cfg(feature = "near")]
use ur_registry::near::near_sign_request::NearSignRequest;
use ur_registry::pb::protobuf_parser::{parse_protobuf, unzip};
use ur_registry::pb::protoc;
use ur_registry::pb::protoc::Base;
#[cfg(feature = "solana")]
use ur_registry::solana::sol_sign_request::SolSignRequest;
#[cfg(feature = "stellar")]
Expand Down
2 changes: 1 addition & 1 deletion rust/rust_c/src/common/utils.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use alloc::string::{String, ToString};
use core::slice;

use crate::extract_ptr_with_type;
use super::ffi::CSliceFFI;
use super::free::Free;
use crate::extract_ptr_with_type;
use cstr_core::{CStr, CString};
use cty::c_char;

Expand Down
14 changes: 7 additions & 7 deletions rust/rust_c/src/cosmos/mod.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
pub mod structs;

use structs::DisplayCosmosTx;
use crate::common::errors::RustCError;
use crate::common::structs::{SimpleResponse, TransactionCheckResult, TransactionParseResult};
use crate::common::types::{PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{QRCodeType, UREncodeResult, FRAGMENT_MAX_LENGTH_DEFAULT};
use crate::common::utils::{convert_c_char, recover_c_char};
use crate::extract_ptr_with_type;
use alloc::format;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use app_cosmos::errors::CosmosError;
use app_cosmos::transaction::structs::SignMode;
use app_utils::normalize_path;
use crate::common::errors::RustCError;
use crate::extract_ptr_with_type;
use crate::common::structs::{SimpleResponse, TransactionCheckResult, TransactionParseResult};
use crate::common::types::{PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{QRCodeType, UREncodeResult, FRAGMENT_MAX_LENGTH_DEFAULT};
use crate::common::utils::{convert_c_char, recover_c_char};
use core::slice;
use cty::c_char;
use either::Either;
use structs::DisplayCosmosTx;
use ur_registry::cosmos::cosmos_sign_request::{CosmosSignRequest, DataType};
use ur_registry::cosmos::cosmos_signature::CosmosSignature;
use ur_registry::cosmos::evm_sign_request::{EvmSignRequest, SignDataType};
Expand Down
2 changes: 1 addition & 1 deletion rust/rust_c/src/ethereum/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use alloc::format;
use app_ethereum;
use cty::c_char;

use app_ethereum::errors::EthereumError;
use crate::common::structs::SimpleResponse;
use crate::common::types::PtrString;
use crate::common::utils::{convert_c_char, recover_c_char};
use app_ethereum::errors::EthereumError;

#[no_mangle]
pub extern "C" fn eth_get_address(
Expand Down
Loading

0 comments on commit f61832f

Please sign in to comment.