2
Cargo.lock
generated
2
Cargo.lock
generated
@ -4648,7 +4648,6 @@ name = "solana-stake-accounts"
|
|||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"itertools 0.9.0",
|
|
||||||
"solana-clap-utils",
|
"solana-clap-utils",
|
||||||
"solana-cli-config",
|
"solana-cli-config",
|
||||||
"solana-client",
|
"solana-client",
|
||||||
@ -4743,7 +4742,6 @@ dependencies = [
|
|||||||
"dirs 2.0.2",
|
"dirs 2.0.2",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"indicatif",
|
"indicatif",
|
||||||
"itertools 0.9.0",
|
|
||||||
"pickledb",
|
"pickledb",
|
||||||
"serde",
|
"serde",
|
||||||
"solana-clap-utils",
|
"solana-clap-utils",
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use crate::{pubkey::Pubkey, transaction::TransactionError};
|
use crate::{pubkey::Pubkey, transaction::TransactionError};
|
||||||
use generic_array::{typenum::U64, GenericArray};
|
use generic_array::{typenum::U64, GenericArray};
|
||||||
use hmac::Hmac;
|
use hmac::Hmac;
|
||||||
|
use itertools::Itertools;
|
||||||
use rand::{rngs::OsRng, CryptoRng, RngCore};
|
use rand::{rngs::OsRng, CryptoRng, RngCore};
|
||||||
use std::{
|
use std::{
|
||||||
borrow::{Borrow, Cow},
|
borrow::{Borrow, Cow},
|
||||||
@ -155,6 +156,11 @@ impl std::fmt::Debug for dyn Signer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove duplicates signers while preserving order. O(n²)
|
||||||
|
pub fn unique_signers(signers: Vec<&dyn Signer>) -> Vec<&dyn Signer> {
|
||||||
|
signers.into_iter().unique_by(|s| s.pubkey()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
impl Signer for Keypair {
|
impl Signer for Keypair {
|
||||||
/// Return the public key for the given keypair
|
/// Return the public key for the given keypair
|
||||||
fn pubkey(&self) -> Pubkey {
|
fn pubkey(&self) -> Pubkey {
|
||||||
@ -553,4 +559,18 @@ mod tests {
|
|||||||
let presigner2 = Presigner::new(&pubkey, &sig);
|
let presigner2 = Presigner::new(&pubkey, &sig);
|
||||||
assert_eq!(presigner, presigner2);
|
assert_eq!(presigner, presigner2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pubkeys(signers: &[&dyn Signer]) -> Vec<Pubkey> {
|
||||||
|
signers.into_iter().map(|x| x.pubkey()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_unique_signers() {
|
||||||
|
let alice = Keypair::new();
|
||||||
|
let bob = Keypair::new();
|
||||||
|
assert_eq!(
|
||||||
|
pubkeys(&unique_signers(vec![&alice, &bob, &alice])),
|
||||||
|
pubkeys(&[&alice, &bob])
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ homepage = "https://solana.com/"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33.1"
|
clap = "2.33.1"
|
||||||
itertools = "0.9.0"
|
|
||||||
solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
|
solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
|
||||||
solana-cli-config = { path = "../cli-config", version = "1.2.0" }
|
solana-cli-config = { path = "../cli-config", version = "1.2.0" }
|
||||||
solana-client = { path = "../client", version = "1.2.0" }
|
solana-client = { path = "../client", version = "1.2.0" }
|
||||||
|
@ -6,7 +6,6 @@ use crate::arg_parser::parse_args;
|
|||||||
use crate::args::{
|
use crate::args::{
|
||||||
resolve_command, AuthorizeArgs, Command, MoveArgs, NewArgs, RebaseArgs, SetLockupArgs,
|
resolve_command, AuthorizeArgs, Command, MoveArgs, NewArgs, RebaseArgs, SetLockupArgs,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
|
||||||
use solana_cli_config::Config;
|
use solana_cli_config::Config;
|
||||||
use solana_client::client_error::ClientError;
|
use solana_client::client_error::ClientError;
|
||||||
use solana_client::rpc_client::RpcClient;
|
use solana_client::rpc_client::RpcClient;
|
||||||
@ -14,7 +13,7 @@ use solana_sdk::{
|
|||||||
message::Message,
|
message::Message,
|
||||||
native_token::lamports_to_sol,
|
native_token::lamports_to_sol,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{Signature, Signer},
|
signature::{unique_signers, Signature, Signer},
|
||||||
signers::Signers,
|
signers::Signers,
|
||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
};
|
};
|
||||||
@ -65,10 +64,6 @@ fn get_lockups(
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unique_signers(signers: Vec<&dyn Signer>) -> Vec<&dyn Signer> {
|
|
||||||
signers.into_iter().unique_by(|s| s.pubkey()).collect_vec()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process_new_stake_account(
|
fn process_new_stake_account(
|
||||||
client: &RpcClient,
|
client: &RpcClient,
|
||||||
args: &NewArgs<Pubkey, Box<dyn Signer>>,
|
args: &NewArgs<Pubkey, Box<dyn Signer>>,
|
||||||
|
@ -16,7 +16,6 @@ csv = "1.1.3"
|
|||||||
dirs = "2.0.2"
|
dirs = "2.0.2"
|
||||||
indexmap = "1.3.2"
|
indexmap = "1.3.2"
|
||||||
indicatif = "0.14.0"
|
indicatif = "0.14.0"
|
||||||
itertools = "0.9.0"
|
|
||||||
pickledb = "0.4.1"
|
pickledb = "0.4.1"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
|
solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
|
||||||
|
@ -5,13 +5,12 @@ use console::style;
|
|||||||
use csv::{ReaderBuilder, Trim};
|
use csv::{ReaderBuilder, Trim};
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use indicatif::{ProgressBar, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressStyle};
|
||||||
use itertools::Itertools;
|
|
||||||
use pickledb::PickleDb;
|
use pickledb::PickleDb;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
message::Message,
|
message::Message,
|
||||||
native_token::{lamports_to_sol, sol_to_lamports},
|
native_token::{lamports_to_sol, sol_to_lamports},
|
||||||
signature::{Signature, Signer},
|
signature::{unique_signers, Signature, Signer},
|
||||||
system_instruction,
|
system_instruction,
|
||||||
transport::TransportError,
|
transport::TransportError,
|
||||||
};
|
};
|
||||||
@ -48,12 +47,6 @@ pub enum Error {
|
|||||||
PickleDbError(#[from] pickledb::error::Error),
|
PickleDbError(#[from] pickledb::error::Error),
|
||||||
#[error("Transport error")]
|
#[error("Transport error")]
|
||||||
TransportError(#[from] TransportError),
|
TransportError(#[from] TransportError),
|
||||||
#[error("Signature not found")]
|
|
||||||
SignatureNotFound,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn unique_signers(signers: Vec<&dyn Signer>) -> Vec<&dyn Signer> {
|
|
||||||
signers.into_iter().unique_by(|s| s.pubkey()).collect_vec()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn merge_allocations(allocations: &[Allocation]) -> Vec<Allocation> {
|
fn merge_allocations(allocations: &[Allocation]) -> Vec<Allocation> {
|
||||||
@ -343,11 +336,11 @@ fn update_finalized_transactions<T: Client>(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let unconfirmed_signatures = unconfirmed_transactions
|
let unconfirmed_signatures: Vec<_> = unconfirmed_transactions
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tx| tx.signatures[0])
|
.map(|tx| tx.signatures[0])
|
||||||
.filter(|sig| *sig != Signature::default()) // Filter out dry-run signatures
|
.filter(|sig| *sig != Signature::default()) // Filter out dry-run signatures
|
||||||
.collect_vec();
|
.collect();
|
||||||
let transaction_statuses = client.get_signature_statuses(&unconfirmed_signatures)?;
|
let transaction_statuses = client.get_signature_statuses(&unconfirmed_signatures)?;
|
||||||
let recent_blockhashes = client.get_recent_blockhashes()?;
|
let recent_blockhashes = client.get_recent_blockhashes()?;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user