Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
use nightly fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rnbguy committed Mar 4, 2024
1 parent b36c021 commit 260d6ba
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 121 deletions.
5 changes: 5 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
reorder_imports = true

# unstable features
group_imports = "StdExternalCrate"
imports_granularity = "Module"
41 changes: 17 additions & 24 deletions src/account.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
use cosmos_sdk_proto::cosmos::{
crypto::secp256k1::PubKey,
tx::{
signing::v1beta1::SignMode,
v1beta1::{Tx, TxBody},
},
};
use cosmos_sdk_proto::prost_wkt_types::Any;
use std::str::FromStr;

use crate::{
keys::{
from_pk_bytes_to_address, get_priv_key_from_memory, get_priv_key_from_os,
get_uncompressed_pub_key_from_memory, get_uncompressed_pub_key_from_os, AddressType,
},
ledger::{get_pub_key, get_signature},
txs::{
create_transaction, generate_auth_info, generate_legacy_amino_json,
get_account_number_and_sequence,
},
Result,
use bip32::secp256k1::ecdsa::signature::Signer;
use bip32::secp256k1::ecdsa::{Signature, VerifyingKey};
use bip32::{DerivationPath, PrivateKey, PublicKey};
use cosmos_sdk_proto::cosmos::crypto::secp256k1::PubKey;
use cosmos_sdk_proto::cosmos::tx::signing::v1beta1::SignMode;
use cosmos_sdk_proto::cosmos::tx::v1beta1::{Tx, TxBody};
use cosmos_sdk_proto::prost_wkt_types::Any;
use serde::{Deserialize, Serialize};

use crate::keys::{
from_pk_bytes_to_address, get_priv_key_from_memory, get_priv_key_from_os,
get_uncompressed_pub_key_from_memory, get_uncompressed_pub_key_from_os, AddressType,
};
use bip32::{secp256k1::ecdsa::VerifyingKey, DerivationPath, PublicKey};
use bip32::{
secp256k1::ecdsa::{signature::Signer, Signature},
PrivateKey,
use crate::ledger::{get_pub_key, get_signature};
use crate::txs::{
create_transaction, generate_auth_info, generate_legacy_amino_json,
get_account_number_and_sequence,
};
use serde::{Deserialize, Serialize};
use crate::Result;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum KeyStoreBackend {
Expand Down
10 changes: 4 additions & 6 deletions src/broadcast.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
use anyhow::Context;
use cosmos_sdk_proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmos_sdk_proto::cosmos::tx::v1beta1::service_client::ServiceClient;
use cosmos_sdk_proto::cosmos::tx::v1beta1::{
service_client::ServiceClient, BroadcastTxRequest, BroadcastTxResponse,
BroadcastMode, BroadcastTxRequest, BroadcastTxResponse, SimulateRequest, SimulateResponse, Tx,
};
use cosmos_sdk_proto::cosmos::tx::v1beta1::{BroadcastMode, SimulateRequest, SimulateResponse, Tx};

use cosmos_sdk_proto::prost_wkt_types::MessageSerde;

use crate::Result;

use serde::Serialize;
use tendermint_rpc::endpoint::broadcast::tx_sync::Response as TendermintResponse;
use tendermint_rpc::{Client, HttpClient};

use crate::Result;

pub fn create_broadcast_sync_payload(tx: &Tx) -> Result<BroadcastTxRequest> {
Ok(BroadcastTxRequest {
tx_bytes: tx.try_encoded()?,
Expand Down
14 changes: 6 additions & 8 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ use anyhow::Context;
use clap::Parser;
use cosmos_sdk_proto::cosmos::base::v1beta1::Coin;

use crate::{
account::{Account, KeyStoreBackend},
endpoint::{get_rpc_endpoints, transform_to_grpc_endpoint},
keys::{save_key_to_os_from_mmseed, AddressType},
query::{get_chain_id_info, get_chain_id_rpc, get_rpc_endpoint_chain_info},
utils::{read_data_from_yaml, write_data_as_yaml},
Result,
};
use crate::account::{Account, KeyStoreBackend};
use crate::endpoint::{get_rpc_endpoints, transform_to_grpc_endpoint};
use crate::keys::{save_key_to_os_from_mmseed, AddressType};
use crate::query::{get_chain_id_info, get_chain_id_rpc, get_rpc_endpoint_chain_info};
use crate::utils::{read_data_from_yaml, write_data_as_yaml};
use crate::Result;

pub mod tx;
pub mod utils;
Expand Down
26 changes: 11 additions & 15 deletions src/cli/tx.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
use std::collections::HashMap;

use crate::endpoint::get_cosmos_directory_name;
use crate::txs::get_account_number_and_sequence;
use crate::{
account::Account, endpoint::get_rpc_endpoints, msg::generate_grant_exec,
utils::read_data_from_yaml, Result,
};
use anyhow::Context;
use clap::Subcommand;
use cosmos_sdk_proto::cosmos::base::v1beta1::Coin;
use cosmos_sdk_proto::cosmos::gov::v1beta1::MsgVote;
use cosmos_sdk_proto::cosmos::staking::v1beta1::{MsgBeginRedelegate, MsgDelegate};
use cosmos_sdk_proto::cosmwasm::wasm::v1::MsgExecuteContract;
use cosmos_sdk_proto::ibc::applications::transfer::v1::MsgTransfer;
use cosmos_sdk_proto::prost_wkt_types::Any;
use cosmos_sdk_proto::{
cosmos::{
base::v1beta1::Coin,
gov::v1beta1::MsgVote,
staking::v1beta1::{MsgBeginRedelegate, MsgDelegate},
},
cosmwasm::wasm::v1::MsgExecuteContract,
ibc::applications::transfer::v1::MsgTransfer,
};
use futures::StreamExt;

use super::utils::{custom_coin, custom_io_string, VotePair};
use crate::account::Account;
use crate::endpoint::{get_cosmos_directory_name, get_rpc_endpoints};
use crate::msg::generate_grant_exec;
use crate::txs::get_account_number_and_sequence;
use crate::utils::read_data_from_yaml;
use crate::Result;

#[derive(Subcommand, Debug)]
pub enum Transaction {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::io::BufRead;
use std::str::FromStr;

use anyhow::Context;
Expand All @@ -6,7 +7,6 @@ use cosmos_sdk_proto::cosmos::gov::v1beta1::VoteOption;

use crate::account::KeyStoreBackend;
use crate::Result;
use std::io::BufRead;

pub fn custom_keystorebackend(backend_str: &str) -> Result<KeyStoreBackend> {
Ok(if backend_str == "Ledger" {
Expand Down
13 changes: 5 additions & 8 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use crate::{
query::{validate_grpc, validate_rpc},
Result,
};

use anyhow::Context;

use futures::future::join_all;
use serde::{de::Error, Deserialize, Deserializer, Serialize};
use serde::de::Error;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;

use url::Url;

use crate::query::{validate_grpc, validate_rpc};
use crate::Result;

#[derive(Debug, Deserialize)]
pub struct ZoneNodes {
pub zone_nodes: Vec<RpcAddress>,
Expand Down
16 changes: 7 additions & 9 deletions src/keys.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
use std::collections::HashMap;
use std::str::FromStr;
use std::sync::{Arc, Mutex};

use anyhow::Context;
use bip32::{secp256k1::ecdsa::SigningKey, DerivationPath, Language, Mnemonic, XPrv};
use clap::ValueEnum;
use secp256k1::{PublicKey, Secp256k1, SecretKey};

use std::collections::HashMap;

use crate::Result;

use base64::prelude::{Engine as _, BASE64_STANDARD};
use bech32::{Bech32, Hrp};
use bip32::secp256k1::ecdsa::SigningKey;
use bip32::{DerivationPath, Language, Mnemonic, XPrv};
use clap::ValueEnum;
use ripemd::Ripemd160;
use secp256k1::{PublicKey, Secp256k1, SecretKey};
use sha2::{Digest, Sha256};
use sha3::Keccak256;

use bech32::{Bech32, Hrp};
use crate::Result;

// https://iancoleman.io/bip39

Expand Down
5 changes: 1 addition & 4 deletions src/ledger.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use anyhow::Context;
use bip32::DerivationPath;

use ledger_transport_hid::{hidapi, TransportNativeHID};

use ledger_transport::{APDUCommand, APDUErrorCode};

use ledger_transport_hid::{hidapi, TransportNativeHID};
use serde_json::Value;

use crate::Result;
Expand Down
10 changes: 4 additions & 6 deletions src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ use cosmos_sdk_proto::cosmos::authz::v1beta1::{
};
use cosmos_sdk_proto::cosmos::bank::v1beta1::MsgSend;
use cosmos_sdk_proto::cosmos::base::v1beta1::Coin;
use cosmos_sdk_proto::cosmos::staking::v1beta1::stake_authorization::{Policy, Validators};
use cosmos_sdk_proto::cosmos::staking::v1beta1::{AuthorizationType, StakeAuthorization};

use cosmos_sdk_proto::cosmos::distribution::v1beta1::{
MsgWithdrawDelegatorReward, QueryDelegationTotalRewardsRequest,
QueryDelegationTotalRewardsResponse,
};
use cosmos_sdk_proto::cosmos::feegrant::v1beta1::{
BasicAllowance, MsgGrantAllowance, MsgRevokeAllowance,
};

use cosmos_sdk_proto::cosmos::gov::v1beta1::MsgVote;
use cosmos_sdk_proto::cosmos::staking::v1beta1::MsgDelegate;

use cosmos_sdk_proto::cosmos::staking::v1beta1::stake_authorization::{Policy, Validators};
use cosmos_sdk_proto::cosmos::staking::v1beta1::{
AuthorizationType, MsgDelegate, StakeAuthorization,
};
use cosmos_sdk_proto::prost_wkt_types::{Any, MessageSerde};

use crate::query::perform_rpc_query;
Expand Down
24 changes: 9 additions & 15 deletions src/query.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
use anyhow::Context;
use cosmos_sdk_proto::cosmos::bank::v1beta1::{
query_client::QueryClient as QueryTotalSupplyClient, QueryTotalSupplyRequest,
QueryTotalSupplyResponse,
};
use cosmos_sdk_proto::cosmos::base::query::v1beta1::PageRequest;
use cosmos_sdk_proto::cosmos::vesting::v1beta1::ContinuousVestingAccount;
use cosmos_sdk_proto::prost_wkt_types::{Any, MessageSerde};

use cosmos_sdk_proto::cosmos::auth::v1beta1::{
BaseAccount, QueryAccountRequest, QueryAccountResponse, QueryAccountsRequest,
QueryAccountsResponse,
};

use cosmos_sdk_proto::cosmos::bank::v1beta1::query_client::QueryClient as QueryTotalSupplyClient;
use cosmos_sdk_proto::cosmos::bank::v1beta1::{QueryTotalSupplyRequest, QueryTotalSupplyResponse};
use cosmos_sdk_proto::cosmos::base::query::v1beta1::PageRequest;
use cosmos_sdk_proto::cosmos::vesting::v1beta1::ContinuousVestingAccount;
use cosmos_sdk_proto::prost_wkt_types::{Any, MessageSerde};
use futures::stream::StreamExt;
use serde_json::Value;
use tracing::info;

use crate::endpoint::get_rpc_endpoints;
use crate::Result;

use tendermint::abci::response::Info;
use tendermint_rpc::endpoint::status::Response as NodeStatus;
use tendermint_rpc::Client;
use tracing::info;

use futures::stream::StreamExt;
use crate::endpoint::get_rpc_endpoints;
use crate::Result;

pub async fn perform_rpc_query<S, R>(endpoint: &str, query: S) -> Result<R>
where
Expand Down
22 changes: 7 additions & 15 deletions src/txs.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
use anyhow::Context;
use bip32::secp256k1::ecdsa::signature::SignatureEncoding;
use bip32::secp256k1::ecdsa::{signature::Signer, signature::Verifier, Signature};

use cosmos_sdk_proto::cosmos::tx::v1beta1::{AuthInfo, TxBody};
use cosmos_sdk_proto::cosmos::vesting::v1beta1::ContinuousVestingAccount;
use cosmos_sdk_proto::cosmos::{
auth::v1beta1::BaseAccount,
crypto::secp256k1::PubKey,
tx::v1beta1::{Fee, ModeInfo, SignDoc, Tx},
};

use bip32::secp256k1::ecdsa::signature::{SignatureEncoding, Signer, Verifier};
use bip32::secp256k1::ecdsa::Signature;
use cosmos_sdk_proto::cosmos::auth::v1beta1::BaseAccount;
use cosmos_sdk_proto::cosmos::base::v1beta1::Coin;

use cosmos_sdk_proto::cosmos::crypto::secp256k1::PubKey;
use cosmos_sdk_proto::cosmos::tx::signing::v1beta1::SignMode;
use cosmos_sdk_proto::cosmos::tx::v1beta1::mode_info::{Single, Sum};
use cosmos_sdk_proto::cosmos::tx::v1beta1::{
mode_info::{Single, Sum},
SignerInfo,
AuthInfo, Fee, ModeInfo, SignDoc, SignerInfo, Tx, TxBody,
};

use cosmos_sdk_proto::cosmos::vesting::v1beta1::ContinuousVestingAccount;
use cosmos_sdk_proto::prost_wkt_types::{Any, MessageSerde};
use serde_json::Value;

Expand Down
6 changes: 4 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::Result;
use base64::prelude::{Engine as _, BASE64_STANDARD};
use bech32::{Bech32, Hrp};
use cosmos_sdk_proto::prost_wkt_types::MessageSerde;
use serde::{de::DeserializeOwned, Serialize};
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde_json::Value;

use crate::Result;

pub fn write_base64_to_file<T>(t: &T, file_name: &str) -> Result<()>
where
T: MessageSerde,
Expand Down
16 changes: 8 additions & 8 deletions src/vanity.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::{
sync::{atomic::Ordering, Arc, RwLock},
time::SystemTime,
};
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::{Arc, RwLock};
use std::time::SystemTime;

use crate::keys::mnemonic_to_cosmos_addr;
use crate::Result;
use anyhow::Context;
use bip32::{secp256k1::elliptic_curve::rand_core::OsRng, Language, Mnemonic};
use bip32::secp256k1::elliptic_curve::rand_core::OsRng;
use bip32::{Language, Mnemonic};
use rayon::prelude::*;
use std::sync::atomic::AtomicU64;

use crate::keys::mnemonic_to_cosmos_addr;
use crate::Result;

pub fn find_parallel(vanity_prefix: &str, coin_type: &u64) -> Result<(String, Mnemonic)> {
// https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32
Expand Down

0 comments on commit 260d6ba

Please sign in to comment.