difftreelog
refac: rename bytes4 -> Bytes4
in: master
6 files changed
crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth610 let custom_signature = self.expand_custom_signature();610 let custom_signature = self.expand_custom_signature();611 quote! {611 quote! {612 const #screaming_name_signature: ::evm_coder::custom_signature::SignatureUnit = #custom_signature;612 const #screaming_name_signature: ::evm_coder::custom_signature::SignatureUnit = #custom_signature;613 const #screaming_name: ::evm_coder::types::bytes4 = {613 const #screaming_name: ::evm_coder::types::Bytes4 = {614 let mut sum = ::evm_coder::sha3_const::Keccak256::new();614 let mut sum = ::evm_coder::sha3_const::Keccak256::new();615 let mut pos = 0;615 let mut pos = 0;616 while pos < Self::#screaming_name_signature.len {616 while pos < Self::#screaming_name_signature.len {974 #consts974 #consts975 )*975 )*976 /// Return this call ERC165 selector976 /// Return this call ERC165 selector977 pub const fn interface_id() -> ::evm_coder::types::bytes4 {977 pub const fn interface_id() -> ::evm_coder::types::Bytes4 {978 let mut interface_id = 0;978 let mut interface_id = 0;979 #(#interface_id)*979 #(#interface_id)*980 #(#inline_interface_id)*980 #(#inline_interface_id)*1019 }1019 }1020 }1020 }1021 impl #gen_ref ::evm_coder::Call for #call_name #gen_ref {1021 impl #gen_ref ::evm_coder::Call for #call_name #gen_ref {1022 fn parse(method_id: ::evm_coder::types::bytes4, reader: &mut ::evm_coder::abi::AbiReader) -> ::evm_coder::execution::Result<Option<Self>> {1022 fn parse(method_id: ::evm_coder::types::Bytes4, reader: &mut ::evm_coder::abi::AbiReader) -> ::evm_coder::execution::Result<Option<Self>> {1023 use ::evm_coder::abi::AbiRead;1023 use ::evm_coder::abi::AbiRead;1024 match method_id {1024 match method_id {1025 ::evm_coder::ERC165Call::INTERFACE_ID => return Ok(1025 ::evm_coder::ERC165Call::INTERFACE_ID => return Ok(1041 #gen_where1041 #gen_where1042 {1042 {1043 /// Is this contract implements specified ERC165 selector1043 /// Is this contract implements specified ERC165 selector1044 pub fn supports_interface(this: &#name, interface_id: ::evm_coder::types::bytes4) -> bool {1044 pub fn supports_interface(this: &#name, interface_id: ::evm_coder::types::Bytes4) -> bool {1045 interface_id != u32::to_be_bytes(0xffffff) && (1045 interface_id != u32::to_be_bytes(0xffffff) && (1046 interface_id == ::evm_coder::ERC165Call::INTERFACE_ID ||1046 interface_id == ::evm_coder::ERC165Call::INTERFACE_ID ||1047 interface_id == Self::interface_id()1047 interface_id == Self::interface_id()crates/evm-coder/src/abi/impls.rsdiffbeforeafterboth--- a/crates/evm-coder/src/abi/impls.rs
+++ b/crates/evm-coder/src/abi/impls.rs
@@ -81,9 +81,9 @@
}
}
-impl_abi_type!(bytes4, bytes4, false);
-impl AbiRead for bytes4 {
- fn abi_read(reader: &mut AbiReader) -> Result<bytes4> {
+impl_abi_type!(Bytes4, bytes4, false);
+impl AbiRead for Bytes4 {
+ fn abi_read(reader: &mut AbiReader) -> Result<Bytes4> {
reader.bytes4()
}
}
crates/evm-coder/src/abi/mod.rsdiffbeforeafterboth--- a/crates/evm-coder/src/abi/mod.rs
+++ b/crates/evm-coder/src/abi/mod.rs
@@ -54,7 +54,7 @@
}
}
/// Start reading RLP buffer, parsing first 4 bytes as selector
- pub fn new_call(buf: &'i [u8]) -> Result<(bytes4, Self)> {
+ pub fn new_call(buf: &'i [u8]) -> Result<(Bytes4, Self)> {
if buf.len() < 4 {
return Err(Error::Error(ExitError::OutOfOffset));
}
crates/evm-coder/src/lib.rsdiffbeforeafterboth--- a/crates/evm-coder/src/lib.rs
+++ b/crates/evm-coder/src/lib.rs
@@ -132,7 +132,7 @@
use primitive_types::{U256, H160, H256};
pub type Address = H160;
- pub type bytes4 = [u8; 4];
+ pub type Bytes4 = [u8; 4];
pub type topic = H256;
#[cfg(not(feature = "std"))]
@@ -191,7 +191,7 @@
/// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro
pub trait Call: Sized {
/// Parse call buffer into typed call enum
- fn parse(selector: types::bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>>;
+ fn parse(selector: types::Bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>>;
}
/// Intended to be used as `#[weight]` output type
@@ -227,22 +227,22 @@
/// implements specified interface
SupportsInterface {
/// Requested interface
- interface_id: types::bytes4,
+ interface_id: types::Bytes4,
},
}
impl ERC165Call {
/// ERC165 selector is provided by standard
- pub const INTERFACE_ID: types::bytes4 = u32::to_be_bytes(0x01ffc9a7);
+ pub const INTERFACE_ID: types::Bytes4 = u32::to_be_bytes(0x01ffc9a7);
}
impl Call for ERC165Call {
- fn parse(selector: types::bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>> {
+ fn parse(selector: types::Bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>> {
if selector != Self::INTERFACE_ID {
return Ok(None);
}
Ok(Some(Self::SupportsInterface {
- interface_id: types::bytes4::abi_read(input)?,
+ interface_id: types::Bytes4::abi_read(input)?,
}))
}
}
crates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth--- a/crates/evm-coder/src/solidity/impls.rs
+++ b/crates/evm-coder/src/solidity/impls.rs
@@ -27,7 +27,7 @@
u64 => "uint64" true = "0",
u128 => "uint128" true = "0",
U256 => "uint256" true = "0",
- bytes4 => "bytes4" true = "bytes4(0)",
+ Bytes4 => "bytes4" true = "bytes4(0)",
H160 => "address" true = "0x0000000000000000000000000000000000000000",
string => "string" false = "\"\"",
bytes => "bytes" false = "hex\"\"",
crates/evm-coder/src/solidity/mod.rsdiffbeforeafterboth--- a/crates/evm-coder/src/solidity/mod.rs
+++ b/crates/evm-coder/src/solidity/mod.rs
@@ -360,7 +360,7 @@
pub struct SolidityInterface<F: SolidityFunctions> {
pub docs: &'static [&'static str],
- pub selector: bytes4,
+ pub selector: Bytes4,
pub name: &'static str,
pub is: &'static [&'static str],
pub functions: F,