cargo clippy --fix (#346)
This commit is contained in:
parent
d31d19c3b7
commit
ed83223b93
|
@ -204,7 +204,7 @@ impl Context {
|
||||||
.map(|(i, input)| {
|
.map(|(i, input)| {
|
||||||
// NOTE: Events can contain nameless values.
|
// NOTE: Events can contain nameless values.
|
||||||
let name = util::expand_input_name(i, &input.name);
|
let name = util::expand_input_name(i, &input.name);
|
||||||
let ty = self.expand_input_type(&input)?;
|
let ty = self.expand_input_type(input)?;
|
||||||
|
|
||||||
Ok((name, ty, input.indexed))
|
Ok((name, ty, input.indexed))
|
||||||
})
|
})
|
||||||
|
@ -271,7 +271,7 @@ impl Context {
|
||||||
} else {
|
} else {
|
||||||
util::safe_ident(¶m.name.to_snake_case())
|
util::safe_ident(¶m.name.to_snake_case())
|
||||||
};
|
};
|
||||||
let ty = self.expand_input_type(¶m)?;
|
let ty = self.expand_input_type(param)?;
|
||||||
|
|
||||||
Ok(quote! {
|
Ok(quote! {
|
||||||
#doc
|
#doc
|
||||||
|
|
|
@ -305,7 +305,7 @@ fn param_type_quote(kind: &ParamType) -> proc_macro2::TokenStream {
|
||||||
let elements = tuple.iter().map(param_type_quote);
|
let elements = tuple.iter().map(param_type_quote);
|
||||||
quote! {
|
quote! {
|
||||||
ethers_core::abi::ParamType::Tuple(
|
ethers_core::abi::ParamType::Tuple(
|
||||||
vec![
|
::std::vec![
|
||||||
#( #elements ),*
|
#( #elements ),*
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -398,14 +398,14 @@ fn derive_decode_from_log_impl(
|
||||||
.filter(|f| f.is_indexed())
|
.filter(|f| f.is_indexed())
|
||||||
.map(|f| topic_param_type_quote(&f.param.kind));
|
.map(|f| topic_param_type_quote(&f.param.kind));
|
||||||
|
|
||||||
let topic_types_init = quote! {let topic_types = vec![#( #topic_types ),*];};
|
let topic_types_init = quote! {let topic_types = ::std::vec![#( #topic_types ),*];};
|
||||||
|
|
||||||
let data_types = event_fields
|
let data_types = event_fields
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| !f.is_indexed())
|
.filter(|f| !f.is_indexed())
|
||||||
.map(|f| param_type_quote(&f.param.kind));
|
.map(|f| param_type_quote(&f.param.kind));
|
||||||
|
|
||||||
let data_types_init = quote! {let data_types = vec![#( #data_types ),*];};
|
let data_types_init = quote! {let data_types = ::std::vec![#( #data_types ),*];};
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
let (signature_check, flat_topics_init, topic_tokens_len_check) = if event.anonymous {
|
let (signature_check, flat_topics_init, topic_tokens_len_check) = if event.anonymous {
|
||||||
|
@ -449,7 +449,7 @@ fn derive_decode_from_log_impl(
|
||||||
quote! {
|
quote! {
|
||||||
let topic_tokens = ethers_core::abi::decode(&topic_types, &flat_topics)?;
|
let topic_tokens = ethers_core::abi::decode(&topic_types, &flat_topics)?;
|
||||||
#topic_tokens_len_check
|
#topic_tokens_len_check
|
||||||
let data_tokens = ethers_core::abi::decode(&data_types, &data)?;
|
let data_tokens = ethers_core::abi::decode(&data_types, data)?;
|
||||||
let tokens:Vec<_> = topic_tokens.into_iter().chain(data_tokens.into_iter()).collect();
|
let tokens:Vec<_> = topic_tokens.into_iter().chain(data_tokens.into_iter()).collect();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -794,7 +794,7 @@ fn derive_tokenizeable_impl(input: &DeriveInput) -> proc_macro2::TokenStream {
|
||||||
// can't encode an empty struct
|
// can't encode an empty struct
|
||||||
// TODO: panic instead?
|
// TODO: panic instead?
|
||||||
quote! {
|
quote! {
|
||||||
ethers_core::abi::Token::Tuple(vec![])
|
ethers_core::abi::Token::Tuple(Vec::new())
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
1 => {
|
1 => {
|
||||||
|
@ -821,7 +821,7 @@ fn derive_tokenizeable_impl(input: &DeriveInput) -> proc_macro2::TokenStream {
|
||||||
let from_token = quote! {
|
let from_token = quote! {
|
||||||
if let ethers_core::abi::Token::Tuple(tokens) = token {
|
if let ethers_core::abi::Token::Tuple(tokens) = token {
|
||||||
if tokens.len() != #params_len {
|
if tokens.len() != #params_len {
|
||||||
return Err(ethers_core::abi::InvalidOutputType(format!(
|
return Err(ethers_core::abi::InvalidOutputType(::std::format!(
|
||||||
"Expected {} tokens, got {}: {:?}",
|
"Expected {} tokens, got {}: {:?}",
|
||||||
#params_len,
|
#params_len,
|
||||||
tokens.len(),
|
tokens.len(),
|
||||||
|
@ -833,7 +833,7 @@ fn derive_tokenizeable_impl(input: &DeriveInput) -> proc_macro2::TokenStream {
|
||||||
|
|
||||||
Ok(#init_struct_impl)
|
Ok(#init_struct_impl)
|
||||||
} else {
|
} else {
|
||||||
Err(ethers_core::abi::InvalidOutputType(format!(
|
Err(ethers_core::abi::InvalidOutputType(::std::format!(
|
||||||
"Expected Tuple, got {:?}",
|
"Expected Tuple, got {:?}",
|
||||||
token
|
token
|
||||||
)))
|
)))
|
||||||
|
@ -842,7 +842,7 @@ fn derive_tokenizeable_impl(input: &DeriveInput) -> proc_macro2::TokenStream {
|
||||||
|
|
||||||
let into_token = quote! {
|
let into_token = quote! {
|
||||||
ethers_core::abi::Token::Tuple(
|
ethers_core::abi::Token::Tuple(
|
||||||
vec![
|
::std::vec![
|
||||||
#into_token_impl
|
#into_token_impl
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -312,7 +312,7 @@ impl<M: Middleware> Multicall<M> {
|
||||||
.iter()
|
.iter()
|
||||||
.zip(&return_data)
|
.zip(&return_data)
|
||||||
.map(|(call, bytes)| {
|
.map(|(call, bytes)| {
|
||||||
let mut tokens: Vec<Token> = call.function.decode_output(&bytes)?;
|
let mut tokens: Vec<Token> = call.function.decode_output(bytes)?;
|
||||||
|
|
||||||
Ok(match tokens.len() {
|
Ok(match tokens.len() {
|
||||||
0 => Token::Tuple(vec![]),
|
0 => Token::Tuple(vec![]),
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl AbiParser {
|
||||||
for mut line in types {
|
for mut line in types {
|
||||||
line = line.trim_start();
|
line = line.trim_start();
|
||||||
if line.starts_with("function") {
|
if line.starts_with("function") {
|
||||||
let function = self.parse_function(&line)?;
|
let function = self.parse_function(line)?;
|
||||||
abi.functions
|
abi.functions
|
||||||
.entry(function.name.clone())
|
.entry(function.name.clone())
|
||||||
.or_default()
|
.or_default()
|
||||||
|
|
|
@ -281,7 +281,7 @@ fn parse_mapping(s: &str) -> Result<MappingType> {
|
||||||
if !input.starts_with("mapping") {
|
if !input.starts_with("mapping") {
|
||||||
bail!("Not a mapping `{}`", input)
|
bail!("Not a mapping `{}`", input)
|
||||||
}
|
}
|
||||||
input = &input[7..].trim_start();
|
input = input[7..].trim_start();
|
||||||
let mut iter = input
|
let mut iter = input
|
||||||
.trim_start_matches('(')
|
.trim_start_matches('(')
|
||||||
.trim_end_matches(')')
|
.trim_end_matches(')')
|
||||||
|
|
|
@ -198,13 +198,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_blk_no_txs() {
|
fn deserialize_blk_no_txs() {
|
||||||
let block = r#"{"number":"0x3","hash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","parentHash":"0x689c70c080ca22bc0e681694fa803c1aba16a69c8b6368fed5311d279eb9de90","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x7270c1c4440180f2bd5215809ee3d545df042b67329499e1ab97eb759d31610d","stateRoot":"0x29f32984517a7d25607da485b23cefabfd443751422ca7e603395e1de9bc8a4b","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","miner":"0x0000000000000000000000000000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0x3e8","gasLimit":"0x6691b7","gasUsed":"0x5208","timestamp":"0x5ecedbb9","transactions":["0xc3c5f700243de37ae986082fd2af88d2a7c2752a0c0f7b9d6ac47c729d45e067"],"uncles":[]}"#;
|
let block = r#"{"number":"0x3","hash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","parentHash":"0x689c70c080ca22bc0e681694fa803c1aba16a69c8b6368fed5311d279eb9de90","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x7270c1c4440180f2bd5215809ee3d545df042b67329499e1ab97eb759d31610d","stateRoot":"0x29f32984517a7d25607da485b23cefabfd443751422ca7e603395e1de9bc8a4b","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","miner":"0x0000000000000000000000000000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0x3e8","gasLimit":"0x6691b7","gasUsed":"0x5208","timestamp":"0x5ecedbb9","transactions":["0xc3c5f700243de37ae986082fd2af88d2a7c2752a0c0f7b9d6ac47c729d45e067"],"uncles":[]}"#;
|
||||||
let _block: Block<TxHash> = serde_json::from_str(&block).unwrap();
|
let _block: Block<TxHash> = serde_json::from_str(block).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_blk_with_txs() {
|
fn deserialize_blk_with_txs() {
|
||||||
let block = r#"{"number":"0x3","hash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","parentHash":"0x689c70c080ca22bc0e681694fa803c1aba16a69c8b6368fed5311d279eb9de90","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x7270c1c4440180f2bd5215809ee3d545df042b67329499e1ab97eb759d31610d","stateRoot":"0x29f32984517a7d25607da485b23cefabfd443751422ca7e603395e1de9bc8a4b","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","miner":"0x0000000000000000000000000000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0x3e8","gasLimit":"0x6691b7","gasUsed":"0x5208","timestamp":"0x5ecedbb9","transactions":[{"hash":"0xc3c5f700243de37ae986082fd2af88d2a7c2752a0c0f7b9d6ac47c729d45e067","nonce":"0x2","blockHash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","blockNumber":"0x3","transactionIndex":"0x0","from":"0xfdcedc3bfca10ecb0890337fbdd1977aba84807a","to":"0xdca8ce283150ab773bcbeb8d38289bdb5661de1e","value":"0x0","gas":"0x15f90","gasPrice":"0x4a817c800","input":"0x","v":"0x25","r":"0x19f2694eb9113656dbea0b925e2e7ceb43df83e601c4116aee9c0dd99130be88","s":"0x73e5764b324a4f7679d890a198ba658ba1c8cd36983ff9797e10b1b89dbb448e"}],"uncles":[]}"#;
|
let block = r#"{"number":"0x3","hash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","parentHash":"0x689c70c080ca22bc0e681694fa803c1aba16a69c8b6368fed5311d279eb9de90","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x7270c1c4440180f2bd5215809ee3d545df042b67329499e1ab97eb759d31610d","stateRoot":"0x29f32984517a7d25607da485b23cefabfd443751422ca7e603395e1de9bc8a4b","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","miner":"0x0000000000000000000000000000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0x3e8","gasLimit":"0x6691b7","gasUsed":"0x5208","timestamp":"0x5ecedbb9","transactions":[{"hash":"0xc3c5f700243de37ae986082fd2af88d2a7c2752a0c0f7b9d6ac47c729d45e067","nonce":"0x2","blockHash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","blockNumber":"0x3","transactionIndex":"0x0","from":"0xfdcedc3bfca10ecb0890337fbdd1977aba84807a","to":"0xdca8ce283150ab773bcbeb8d38289bdb5661de1e","value":"0x0","gas":"0x15f90","gasPrice":"0x4a817c800","input":"0x","v":"0x25","r":"0x19f2694eb9113656dbea0b925e2e7ceb43df83e601c4116aee9c0dd99130be88","s":"0x73e5764b324a4f7679d890a198ba658ba1c8cd36983ff9797e10b1b89dbb448e"}],"uncles":[]}"#;
|
||||||
let _block: Block<Transaction> = serde_json::from_str(&block).unwrap();
|
let _block: Block<Transaction> = serde_json::from_str(block).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ impl Bytes {
|
||||||
|
|
||||||
impl AsRef<[u8]> for Bytes {
|
impl AsRef<[u8]> for Bytes {
|
||||||
fn as_ref(&self) -> &[u8] {
|
fn as_ref(&self) -> &[u8] {
|
||||||
&self.0.as_ref()
|
self.0.as_ref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ where
|
||||||
// will poll and await the futures concurrently
|
// will poll and await the futures concurrently
|
||||||
let (gas_price, gas, nonce) = join!(
|
let (gas_price, gas, nonce) = join!(
|
||||||
maybe(tx.gas_price, self.inner.get_gas_price()),
|
maybe(tx.gas_price, self.inner.get_gas_price()),
|
||||||
maybe(tx.gas, self.inner.estimate_gas(&tx)),
|
maybe(tx.gas, self.inner.estimate_gas(tx)),
|
||||||
maybe(
|
maybe(
|
||||||
tx.nonce,
|
tx.nonce,
|
||||||
self.inner.get_transaction_count(self.address(), block)
|
self.inner.get_transaction_count(self.address(), block)
|
||||||
|
|
|
@ -310,7 +310,7 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
|
||||||
|
|
||||||
if let Some(NameOrAddress::Name(ref ens_name)) = tx.to {
|
if let Some(NameOrAddress::Name(ref ens_name)) = tx.to {
|
||||||
// resolve to an address
|
// resolve to an address
|
||||||
let addr = self.resolve_name(&ens_name).await?;
|
let addr = self.resolve_name(ens_name).await?;
|
||||||
|
|
||||||
// set the value
|
// set the value
|
||||||
tx.to = Some(addr.into())
|
tx.to = Some(addr.into())
|
||||||
|
@ -782,7 +782,7 @@ impl Provider<MockProvider> {
|
||||||
///
|
///
|
||||||
/// If the provided bytes were not an interpretation of an address
|
/// If the provided bytes were not an interpretation of an address
|
||||||
fn decode_bytes<T: Detokenize>(param: ParamType, bytes: Bytes) -> T {
|
fn decode_bytes<T: Detokenize>(param: ParamType, bytes: Bytes) -> T {
|
||||||
let tokens = abi::decode(&[param], &bytes.as_ref())
|
let tokens = abi::decode(&[param], bytes.as_ref())
|
||||||
.expect("could not abi-decode bytes to address tokens");
|
.expect("could not abi-decode bytes to address tokens");
|
||||||
T::from_tokens(tokens).expect("could not parse tokens as address")
|
T::from_tokens(tokens).expect("could not parse tokens as address")
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ where
|
||||||
warn!("Replacing a pending request with id {:?}", id);
|
warn!("Replacing a pending request with id {:?}", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = self.socket_writer.write(&request.as_bytes()).await {
|
if let Err(err) = self.socket_writer.write(request.as_bytes()).await {
|
||||||
error!("WS connection error: {:?}", err);
|
error!("WS connection error: {:?}", err);
|
||||||
self.pending.remove(&id);
|
self.pending.remove(&id);
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ where
|
||||||
let read_len = {
|
let read_len = {
|
||||||
// Deserialize as many full elements from the stream as exists
|
// Deserialize as many full elements from the stream as exists
|
||||||
let mut de: serde_json::StreamDeserializer<_, serde_json::Value> =
|
let mut de: serde_json::StreamDeserializer<_, serde_json::Value> =
|
||||||
serde_json::Deserializer::from_slice(&read_buffer).into_iter();
|
serde_json::Deserializer::from_slice(read_buffer).into_iter();
|
||||||
|
|
||||||
// Iterate through these elements, and handle responses/notifications
|
// Iterate through these elements, and handle responses/notifications
|
||||||
while let Some(Ok(value)) = de.next() {
|
while let Some(Ok(value)) = de.next() {
|
||||||
|
|
|
@ -97,8 +97,8 @@ impl<D: DigestSigner<Sha256Proxy, RecoverableSignature>> Wallet<D> {
|
||||||
|
|
||||||
let r_bytes: FieldBytes<Secp256k1> = recoverable_sig.r().into();
|
let r_bytes: FieldBytes<Secp256k1> = recoverable_sig.r().into();
|
||||||
let s_bytes: FieldBytes<Secp256k1> = recoverable_sig.s().into();
|
let s_bytes: FieldBytes<Secp256k1> = recoverable_sig.s().into();
|
||||||
let r = H256::from_slice(&r_bytes.as_slice());
|
let r = H256::from_slice(r_bytes.as_slice());
|
||||||
let s = H256::from_slice(&s_bytes.as_slice());
|
let s = H256::from_slice(s_bytes.as_slice());
|
||||||
|
|
||||||
Signature { r, s, v }
|
Signature { r, s, v }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue