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::instruction::InstructionError;
use crate::{clock::Epoch, pubkey::Pubkey};
use crate::{
hash::Hash,
instruction::InstructionError,
{clock::Epoch, pubkey::Pubkey},
};
use std::{
cell::{Ref, RefCell, RefMut},
cmp, fmt,

View File

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

View File

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

View File

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

View File

@ -2,10 +2,7 @@
use bs58;
use sha2::{Digest, Sha256};
use std::convert::TryFrom;
use std::fmt;
use std::mem;
use std::str::FromStr;
use std::{convert::TryFrom, fmt, mem, str::FromStr};
pub const HASH_BYTES: usize = 32;
#[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.
use crate::pubkey::Pubkey;
use crate::short_vec;
use crate::system_instruction::SystemError;
use crate::{pubkey::Pubkey, short_vec, system_instruction::SystemError};
use bincode::serialize;
use serde::Serialize;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,9 @@
use serde::de::{self, Deserializer, SeqAccess, Visitor};
use serde::ser::{self, SerializeTuple, Serializer};
use serde::{Deserialize, Serialize};
use std::fmt;
use std::marker::PhantomData;
use std::mem::size_of;
use serde::{
de::{self, Deserializer, SeqAccess, Visitor},
ser::{self, SerializeTuple, Serializer},
{Deserialize, Serialize},
};
use std::{fmt, marker::PhantomData, mem::size_of};
/// 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

View File

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

View File

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

View File

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

View File

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