Cleanup SDK use syntax (#8004)

This commit is contained in:
Jack May 2020-01-28 16:11:22 -08:00 committed by GitHub
parent 4197cce8c9
commit 12eff5a2f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 59 additions and 66 deletions

View File

@ -1,6 +1,8 @@
use crate::hash::Hash; use crate::{
use crate::instruction::InstructionError; hash::Hash,
use crate::{clock::Epoch, pubkey::Pubkey}; instruction::InstructionError,
{clock::Epoch, pubkey::Pubkey},
};
use std::{ use std::{
cell::{Ref, RefCell, RefMut}, cell::{Ref, RefCell, RefMut},
cmp, fmt, cmp, fmt,

View File

@ -46,8 +46,7 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::account::Account; use crate::{account::Account, pubkey::Pubkey};
use crate::pubkey::Pubkey;
#[test] #[test]
fn test_account_state() { fn test_account_state() {

View File

@ -3,8 +3,7 @@ use bincode::deserialize_from;
use rand::{Rng, SeedableRng}; use rand::{Rng, SeedableRng};
use rand_chacha::ChaChaRng; use rand_chacha::ChaChaRng;
use serde::{Deserialize, Serialize, Serializer}; use serde::{Deserialize, Serialize, Serializer};
use std::fmt; use std::{fmt, io::Cursor};
use std::io::Cursor;
// Type for representing a bank accounts state. // Type for representing a bank accounts state.
// Taken by xor of a sha256 of accounts state for lower 32-bytes, and // Taken by xor of a sha256 of accounts state for lower 32-bytes, and

View File

@ -133,8 +133,7 @@ impl FeeCalculator {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::pubkey::Pubkey; use crate::{pubkey::Pubkey, system_instruction};
use crate::system_instruction;
#[test] #[test]
fn test_fee_calculator_burn() { fn test_fee_calculator_burn() {

View File

@ -2,10 +2,7 @@
use bs58; use bs58;
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use std::convert::TryFrom; use std::{convert::TryFrom, fmt, mem, str::FromStr};
use std::fmt;
use std::mem;
use std::str::FromStr;
pub const HASH_BYTES: usize = 32; pub const HASH_BYTES: usize = 32;
#[derive(Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]

View File

@ -1,8 +1,6 @@
//! Defines a composable Instruction type and a memory-efficient CompiledInstruction. //! Defines a composable Instruction type and a memory-efficient CompiledInstruction.
use crate::pubkey::Pubkey; use crate::{pubkey::Pubkey, short_vec, system_instruction::SystemError};
use crate::short_vec;
use crate::system_instruction::SystemError;
use bincode::serialize; use bincode::serialize;
use serde::Serialize; use serde::Serialize;

View File

@ -1,6 +1,8 @@
use crate::instruction::{AccountMeta, Instruction}; use crate::{
use crate::pubkey::Pubkey; instruction::{AccountMeta, Instruction},
use crate::sysvar::rent; pubkey::Pubkey,
sysvar::rent,
};
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub enum LoaderInstruction { pub enum LoaderInstruction {

View File

@ -1,9 +1,11 @@
//! A library for generating a message from a sequence of instructions //! A library for generating a message from a sequence of instructions
use crate::hash::Hash; use crate::{
use crate::instruction::{AccountMeta, CompiledInstruction, Instruction}; hash::Hash,
use crate::pubkey::Pubkey; instruction::{AccountMeta, CompiledInstruction, Instruction},
use crate::short_vec; pubkey::Pubkey,
short_vec,
};
use itertools::Itertools; use itertools::Itertools;
fn position(keys: &[Pubkey], key: &Pubkey) -> u8 { fn position(keys: &[Pubkey], key: &Pubkey) -> u8 {
@ -245,8 +247,10 @@ impl Message {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::instruction::AccountMeta; use crate::{
use crate::signature::{Keypair, KeypairUtil}; instruction::AccountMeta,
signature::{Keypair, KeypairUtil},
};
#[test] #[test]
fn test_message_unique_program_ids() { fn test_message_unique_program_ids() {

View File

@ -1,5 +1,4 @@
use crate::account::Account; use crate::{account::Account, hash::Hash};
use crate::hash::Hash;
crate::declare_id!("NativeLoader1111111111111111111111111111111"); crate::declare_id!("NativeLoader1111111111111111111111111111111");

View File

@ -6,8 +6,7 @@ use crate::{
pubkey::Pubkey, pubkey::Pubkey,
system_instruction::NonceError, system_instruction::NonceError,
system_program, system_program,
sysvar::recent_blockhashes::RecentBlockhashes, sysvar::{recent_blockhashes::RecentBlockhashes, rent::Rent},
sysvar::rent::Rent,
}; };
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use std::{cell::RefCell, collections::HashSet}; use std::{cell::RefCell, collections::HashSet};

View File

@ -1,8 +1,10 @@
use crate::clock::Slot; use crate::clock::Slot;
use bincode::Result; use bincode::Result;
use serde::Serialize; use serde::Serialize;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use std::{
use std::{fmt, io}; net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
{fmt, io},
};
/// Maximum over-the-wire size of a Transaction /// Maximum over-the-wire size of a Transaction
/// 1280 is IPv6 minimum MTU /// 1280 is IPv6 minimum MTU

View File

@ -1,8 +1,4 @@
use std::convert::TryFrom; use std::{convert::TryFrom, error, fmt, mem, str::FromStr};
use std::error;
use std::fmt;
use std::mem;
use std::str::FromStr;
pub use bs58; pub use bs58;

View File

@ -1,9 +1,9 @@
use serde::de::{self, Deserializer, SeqAccess, Visitor}; use serde::{
use serde::ser::{self, SerializeTuple, Serializer}; de::{self, Deserializer, SeqAccess, Visitor},
use serde::{Deserialize, Serialize}; ser::{self, SerializeTuple, Serializer},
use std::fmt; {Deserialize, Serialize},
use std::marker::PhantomData; };
use std::mem::size_of; use std::{fmt, marker::PhantomData, mem::size_of};
/// Same as u16, but serialized with 1 to 3 bytes. If the value is above /// Same as u16, but serialized with 1 to 3 bytes. If the value is above
/// 0x7f, the top bit is set and the remaining value is stored in the next /// 0x7f, the top bit is set and the remaining value is stored in the next

View File

@ -1,10 +1,12 @@
use crate::hash::hashv; use crate::{
use crate::instruction::{AccountMeta, Instruction, WithSigner}; hash::hashv,
use crate::instruction_processor_utils::DecodeError; instruction::{AccountMeta, Instruction, WithSigner},
use crate::nonce_state::NonceState; instruction_processor_utils::DecodeError,
use crate::pubkey::Pubkey; nonce_state::NonceState,
use crate::system_program; pubkey::Pubkey,
use crate::sysvar::{recent_blockhashes, rent}; system_program,
sysvar::{recent_blockhashes, rent},
};
use num_derive::{FromPrimitive, ToPrimitive}; use num_derive::{FromPrimitive, ToPrimitive};
use thiserror::Error; use thiserror::Error;

View File

@ -4,9 +4,7 @@ use crate::{
sysvar::Sysvar, sysvar::Sysvar,
}; };
use bincode::serialize; use bincode::serialize;
use std::collections::BinaryHeap; use std::{collections::BinaryHeap, iter::FromIterator, ops::Deref};
use std::iter::FromIterator;
use std::ops::Deref;
const MAX_ENTRIES: usize = 32; const MAX_ENTRIES: usize = 32;

View File

@ -1,12 +1,14 @@
//! Defines a Transaction type to package an atomic sequence of instructions. //! Defines a Transaction type to package an atomic sequence of instructions.
use crate::hash::Hash; use crate::{
use crate::instruction::{CompiledInstruction, Instruction, InstructionError}; hash::Hash,
use crate::message::Message; instruction::{CompiledInstruction, Instruction, InstructionError},
use crate::pubkey::Pubkey; message::Message,
use crate::short_vec; pubkey::Pubkey,
use crate::signature::{KeypairUtil, Signature}; short_vec,
use crate::system_instruction; signature::{KeypairUtil, Signature},
system_instruction,
};
use bincode::serialize; use bincode::serialize;
use std::result; use std::result;
use thiserror::Error; use thiserror::Error;
@ -337,10 +339,7 @@ impl Transaction {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::hash::hash; use crate::{hash::hash, instruction::AccountMeta, signature::Keypair, system_instruction};
use crate::instruction::AccountMeta;
use crate::signature::Keypair;
use crate::system_instruction;
use bincode::{deserialize, serialize, serialized_size}; use bincode::{deserialize, serialize, serialized_size};
use std::mem::size_of; use std::mem::size_of;

View File

@ -1,7 +1,5 @@
use crate::transaction::TransactionError; use crate::transaction::TransactionError;
use std::error; use std::{error, fmt, io};
use std::fmt;
use std::io;
#[derive(Debug)] #[derive(Debug)]
pub enum TransportError { pub enum TransportError {