git.delta.rocks / unique-network / refs/commits / 08c4c52a9f35

difftreelog

refac: rename bytes4 -> Bytes4

Trubnikov Sergey2023-01-18parent: #314a48d.patch.diff
in: master

6 files changed

modifiedcrates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth
610 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 #consts
975 )*975 )*
976 /// Return this call ERC165 selector976 /// Return this call ERC165 selector
977 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_where
1042 {1042 {
1043 /// Is this contract implements specified ERC165 selector1043 /// Is this contract implements specified ERC165 selector
1044 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()
modifiedcrates/evm-coder/src/abi/impls.rsdiffbeforeafterboth
81 }81 }
82}82}
8383
84impl_abi_type!(bytes4, bytes4, false);84impl_abi_type!(Bytes4, bytes4, false);
85impl AbiRead for bytes4 {85impl AbiRead for Bytes4 {
86 fn abi_read(reader: &mut AbiReader) -> Result<bytes4> {86 fn abi_read(reader: &mut AbiReader) -> Result<Bytes4> {
87 reader.bytes4()87 reader.bytes4()
88 }88 }
89}89}
modifiedcrates/evm-coder/src/abi/mod.rsdiffbeforeafterboth
54 }54 }
55 }55 }
56 /// Start reading RLP buffer, parsing first 4 bytes as selector56 /// Start reading RLP buffer, parsing first 4 bytes as selector
57 pub fn new_call(buf: &'i [u8]) -> Result<(bytes4, Self)> {57 pub fn new_call(buf: &'i [u8]) -> Result<(Bytes4, Self)> {
58 if buf.len() < 4 {58 if buf.len() < 4 {
59 return Err(Error::Error(ExitError::OutOfOffset));59 return Err(Error::Error(ExitError::OutOfOffset));
60 }60 }
modifiedcrates/evm-coder/src/lib.rsdiffbeforeafterboth
132 use primitive_types::{U256, H160, H256};132 use primitive_types::{U256, H160, H256};
133133
134 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;
137137
138 #[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`] macro
192pub trait Call: Sized {192pub trait Call: Sized {
193 /// Parse call buffer into typed call enum193 /// Parse call buffer into typed call enum
194 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}
196196
197/// Intended to be used as `#[weight]` output type197/// Intended to be used as `#[weight]` output type
227 /// implements specified interface227 /// implements specified interface
228 SupportsInterface {228 SupportsInterface {
229 /// Requested interface229 /// Requested interface
230 interface_id: types::bytes4,230 interface_id: types::Bytes4,
231 },231 },
232}232}
233233
234impl ERC165Call {234impl ERC165Call {
235 /// ERC165 selector is provided by standard235 /// ERC165 selector is provided by standard
236 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}
238238
239impl 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}
modifiedcrates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth
27 u64 => "uint64" true = "0",27 u64 => "uint64" true = "0",
28 u128 => "uint128" true = "0",28 u128 => "uint128" true = "0",
29 U256 => "uint256" true = "0",29 U256 => "uint256" true = "0",
30 bytes4 => "bytes4" true = "bytes4(0)",30 Bytes4 => "bytes4" true = "bytes4(0)",
31 H160 => "address" true = "0x0000000000000000000000000000000000000000",31 H160 => "address" true = "0x0000000000000000000000000000000000000000",
32 string => "string" false = "\"\"",32 string => "string" false = "\"\"",
33 bytes => "bytes" false = "hex\"\"",33 bytes => "bytes" false = "hex\"\"",
modifiedcrates/evm-coder/src/solidity/mod.rsdiffbeforeafterboth
360360
361pub struct SolidityInterface<F: SolidityFunctions> {361pub struct SolidityInterface<F: SolidityFunctions> {
362 pub docs: &'static [&'static str],362 pub docs: &'static [&'static str],
363 pub selector: bytes4,363 pub selector: Bytes4,
364 pub name: &'static str,364 pub name: &'static str,
365 pub is: &'static [&'static str],365 pub is: &'static [&'static str],
366 pub functions: F,366 pub functions: F,