difftreelog
refac: rename bytes4 -> Bytes4
in: master
6 files changed
crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth--- a/crates/evm-coder/procedural/src/solidity_interface.rs
+++ b/crates/evm-coder/procedural/src/solidity_interface.rs
@@ -610,7 +610,7 @@
let custom_signature = self.expand_custom_signature();
quote! {
const #screaming_name_signature: ::evm_coder::custom_signature::SignatureUnit = #custom_signature;
- const #screaming_name: ::evm_coder::types::bytes4 = {
+ const #screaming_name: ::evm_coder::types::Bytes4 = {
let mut sum = ::evm_coder::sha3_const::Keccak256::new();
let mut pos = 0;
while pos < Self::#screaming_name_signature.len {
@@ -974,7 +974,7 @@
#consts
)*
/// Return this call ERC165 selector
- pub const fn interface_id() -> ::evm_coder::types::bytes4 {
+ pub const fn interface_id() -> ::evm_coder::types::Bytes4 {
let mut interface_id = 0;
#(#interface_id)*
#(#inline_interface_id)*
@@ -1019,7 +1019,7 @@
}
}
impl #gen_ref ::evm_coder::Call for #call_name #gen_ref {
- fn parse(method_id: ::evm_coder::types::bytes4, reader: &mut ::evm_coder::abi::AbiReader) -> ::evm_coder::execution::Result<Option<Self>> {
+ fn parse(method_id: ::evm_coder::types::Bytes4, reader: &mut ::evm_coder::abi::AbiReader) -> ::evm_coder::execution::Result<Option<Self>> {
use ::evm_coder::abi::AbiRead;
match method_id {
::evm_coder::ERC165Call::INTERFACE_ID => return Ok(
@@ -1041,7 +1041,7 @@
#gen_where
{
/// Is this contract implements specified ERC165 selector
- pub fn supports_interface(this: &#name, interface_id: ::evm_coder::types::bytes4) -> bool {
+ pub fn supports_interface(this: &#name, interface_id: ::evm_coder::types::Bytes4) -> bool {
interface_id != u32::to_be_bytes(0xffffff) && (
interface_id == ::evm_coder::ERC165Call::INTERFACE_ID ||
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.rsdiffbeforeafterboth132 use primitive_types::{U256, H160, H256};132 use primitive_types::{U256, H160, H256};133133134 pub type Address = H160;134 pub type Address = H160;135 pub type bytes4 = [u8; 4];135 pub type Bytes4 = [u8; 4];136 pub type topic = H256;136 pub type topic = H256;137137138 #[cfg(not(feature = "std"))]138 #[cfg(not(feature = "std"))]191/// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro191/// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro192pub trait Call: Sized {192pub trait Call: Sized {193 /// Parse call buffer into typed call enum193 /// Parse call buffer into typed call enum194 fn parse(selector: types::bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>>;194 fn parse(selector: types::Bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>>;195}195}196196197/// Intended to be used as `#[weight]` output type197/// Intended to be used as `#[weight]` output type227 /// implements specified interface227 /// implements specified interface228 SupportsInterface {228 SupportsInterface {229 /// Requested interface229 /// Requested interface230 interface_id: types::bytes4,230 interface_id: types::Bytes4,231 },231 },232}232}233233234impl ERC165Call {234impl ERC165Call {235 /// ERC165 selector is provided by standard235 /// ERC165 selector is provided by standard236 pub const INTERFACE_ID: types::bytes4 = u32::to_be_bytes(0x01ffc9a7);236 pub const INTERFACE_ID: types::Bytes4 = u32::to_be_bytes(0x01ffc9a7);237}237}238238239impl Call for ERC165Call {239impl Call for ERC165Call {240 fn parse(selector: types::bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>> {240 fn parse(selector: types::Bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>> {241 if selector != Self::INTERFACE_ID {241 if selector != Self::INTERFACE_ID {242 return Ok(None);242 return Ok(None);243 }243 }244 Ok(Some(Self::SupportsInterface {244 Ok(Some(Self::SupportsInterface {245 interface_id: types::bytes4::abi_read(input)?,245 interface_id: types::Bytes4::abi_read(input)?,246 }))246 }))247 }247 }248}248}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,