difftreelog
refactor custom_signature.rs
in: master
13 files changed
crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth20// about Procedural Macros in Rust book:20// about Procedural Macros in Rust book:21// https://doc.rust-lang.org/reference/procedural-macros.html21// https://doc.rust-lang.org/reference/procedural-macros.html222223use proc_macro2::{TokenStream, Group};23use proc_macro2::TokenStream;24use quote::{quote, ToTokens, format_ident};24use quote::{quote, ToTokens, format_ident};25use inflector::cases;25use inflector::cases;26use std::fmt::Write;26use std::fmt::Write;735 #[doc = #selector_str]735 #[doc = #selector_str]736 const #screaming_name: ::evm_coder::types::bytes4 = {736 const #screaming_name: ::evm_coder::types::bytes4 = {737 let a = ::evm_coder::sha3_const::Keccak256::new()737 let a = ::evm_coder::sha3_const::Keccak256::new()738 .update_with_size(&Self::#screaming_name_signature.signature, Self::#screaming_name_signature.signature_len)738 .update_with_size(&Self::#screaming_name_signature.data, Self::#screaming_name_signature.len)739 .finalize();739 .finalize();740 [a[0], a[1], a[2], a[3]]740 [a[0], a[1], a[2], a[3]]741 };741 };841 }841 }842 }842 }843844 fn expand_type(ty: &AbiType, token_stream: &mut proc_macro2::TokenStream) {845 match ty {846 AbiType::Plain(ref ident) => {847 token_stream.extend(quote! {848 (<#ident>::SIGNATURE),849 });850 }851852 AbiType::Tuple(ref tuple_type) => {853 let mut tuple_types = proc_macro2::TokenStream::new();854 for ty in tuple_type {855 Self::expand_type(ty, &mut tuple_types);856 }857 let group =858 proc_macro2::Group::new(proc_macro2::Delimiter::Parenthesis, tuple_types);859 token_stream.extend(group.stream());860 }861862 AbiType::Vec(ref _vec_type) => {}863864 AbiType::Array(_, _) => todo!("Array eth signature"),865 };866 }843867844 fn expand_custom_signature(&self) -> proc_macro2::TokenStream {868 fn expand_custom_signature(&self) -> proc_macro2::TokenStream {845 let mut custom_signature = TokenStream::new();869 let mut token_stream = TokenStream::new();846870847 self.args871 for arg in &self.args {848 .iter()849 .filter_map(|a| {850 if a.is_special() {872 if arg.is_special() {851 return None;873 continue;852 };874 }853875854 match a.ty {855 AbiType::Plain(ref ident) => Some(ident),876 Self::expand_type(&arg.ty, &mut token_stream);856 _ => None,857 }858 })877 }859 .for_each(|ident| {860 custom_signature.extend(quote! {861 (<#ident>::SIGNATURE, <#ident>::SIGNATURE_LEN)862 });863 });864878865 let func_name = self.camel_name.clone();879 let func_name = self.camel_name.clone();866 let func_name = quote!(FunctionName::new(#func_name));880 let func_name = quote!(SignaturePreferences {881 open_name: Some(SignatureUnit::new(#func_name)),882 open_delimiter: Some(SignatureUnit::new("(")),883 param_delimiter: Some(SignatureUnit::new(",")),884 close_delimiter: Some(SignatureUnit::new(")")),885 close_name: None,886 });867 custom_signature =887 token_stream = quote!({ ::evm_coder::make_signature!(new fn(#func_name),#token_stream) });868 quote!({ ::evm_coder::make_signature!(new fn(& #func_name),#custom_signature) });869888870 // println!("!!!!! {}", custom_signature);889 // println!("!!!!! {}", custom_signature);871890872 custom_signature891 token_stream873 }892 }874893875 fn expand_solidity_function(&self) -> proc_macro2::TokenStream {894 fn expand_solidity_function(&self) -> proc_macro2::TokenStream {crates/evm-coder/src/abi.rsdiffbeforeafterboth26use crate::{26use crate::{27 execution::{Error, ResultWithPostInfo, WithPostDispatchInfo},27 execution::{Error, ResultWithPostInfo, WithPostDispatchInfo},28 types::*,28 types::*,29 make_signature,30 custom_signature::{SignatureUnit, SIGNATURE_SIZE_LIMIT},29};31};30use crate::execution::Result;32use crate::execution::Result;3133378impl_abi_readable!(bytes4, bytes4, false);380impl_abi_readable!(bytes4, bytes4, false);379impl_abi_readable!(address, address, false);381impl_abi_readable!(address, address, false);380impl_abi_readable!(string, string, true);382impl_abi_readable!(string, string, true);381// impl_abi_readable!(bytes, bytes, true);382383383impl TypeHelper for bytes {384impl TypeHelper for bytes {384 fn is_dynamic() -> bool {385 fn is_dynamic() -> bool {420 }421 }421}422}423424impl<R: Signature> Signature for Vec<R> {425 make_signature!(new nameof(R) fixed("[]"));426}422427423impl TypeHelper for EthCrossAccount {428impl TypeHelper for EthCrossAccount {424 fn is_dynamic() -> bool {429 fn is_dynamic() -> bool {504 }512 }505 }513 }514515 impl<$($ident),+> Signature for ($($ident,)+)516 where517 $($ident: Signature,)+518 {519 make_signature!(520 new fixed("(")521 $(nameof($ident) fixed(","))+522 shift_left(1)523 fixed(")")524 );525 }506 };526 };507}527}508528crates/evm-coder/src/custom_signature.rsdiffbeforeafterboth223pub const SIGNATURE_SIZE_LIMIT: usize = 256;3pub const SIGNATURE_SIZE_LIMIT: usize = 256;445#[derive(Debug)]5pub trait Name {6pub struct SignaturePreferences {6 const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT];7 pub open_name: Option<SignatureUnit>,7 const SIGNATURE_LEN: usize;8 pub open_delimiter: Option<SignatureUnit>,89 pub param_delimiter: Option<SignatureUnit>,9 fn name() -> &'static str {10 pub close_delimiter: Option<SignatureUnit>,10 from_utf8(&Self::SIGNATURE[..Self::SIGNATURE_LEN]).expect("bad utf-8")11 pub close_name: Option<SignatureUnit>,11 }12}12}131314#[derive(Debug)]14#[derive(Debug)]15pub struct FunctionSignature {15pub struct FunctionSignature {16 pub signature: [u8; SIGNATURE_SIZE_LIMIT],16 pub data: [u8; SIGNATURE_SIZE_LIMIT],17 pub signature_len: usize,17 pub len: usize,1819 preferences: SignaturePreferences,18}20}192120impl FunctionSignature {22impl FunctionSignature {21 pub const fn new(name: &'static FunctionName) -> FunctionSignature {23 pub const fn new(preferences: SignaturePreferences) -> FunctionSignature {22 let mut signature = [0_u8; SIGNATURE_SIZE_LIMIT];24 let mut dst = [0_u8; SIGNATURE_SIZE_LIMIT];23 let name_len = name.signature_len;24 let name = name.signature;25 let mut dst_offset = 0;25 let mut dst_offset = 0;26 let bracket_open = {26 if let Some(ref name) = preferences.open_name {27 let mut b = [0_u8; SIGNATURE_SIZE_LIMIT];28 b[0] = b"("[0];29 b30 };31 crate::make_signature!(@copy(name, signature, name_len, dst_offset));27 crate::make_signature!(@copy(name.data, dst, name.len, dst_offset));28 }29 if let Some(ref delimiter) = preferences.open_delimiter {32 crate::make_signature!(@copy(bracket_open, signature, 1, dst_offset));30 crate::make_signature!(@copy(delimiter.data, dst, delimiter.len, dst_offset));31 }33 FunctionSignature {32 FunctionSignature {34 signature,33 data: dst,35 signature_len: dst_offset,34 len: dst_offset,35 preferences,36 }36 }37 }37 }383839 pub const fn add_param(39 pub const fn add_param(40 signature: FunctionSignature,40 signature: FunctionSignature,41 param: ([u8; SIGNATURE_SIZE_LIMIT], usize),41 param: SignatureUnit,42 ) -> FunctionSignature {42 ) -> FunctionSignature {43 let mut dst = signature.signature;43 let mut dst = signature.data;44 let mut dst_offset = signature.signature_len;44 let mut dst_offset = signature.len;45 let (param_name, param_len) = param;45 crate::make_signature!(@copy(param.data, dst, param.len, dst_offset));46 let comma = {46 if let Some(ref delimiter) = signature.preferences.param_delimiter {47 let mut b = [0_u8; SIGNATURE_SIZE_LIMIT];48 b[0] = b","[0];49 b50 };51 FunctionSignature {52 signature: {53 crate::make_signature!(@copy(param_name, dst, param_len, dst_offset));47 crate::make_signature!(@copy(delimiter.data, dst, delimiter.len, dst_offset));54 crate::make_signature!(@copy(comma, dst, 1, dst_offset));55 dst56 },57 signature_len: dst_offset,58 }48 }49 FunctionSignature {50 data: dst,51 len: dst_offset,52 ..signature53 }59 }54 }605561 pub const fn done(signature: FunctionSignature, owerride: bool) -> FunctionSignature {56 pub const fn done(signature: FunctionSignature, owerride: bool) -> FunctionSignature {62 let mut dst = signature.signature;57 let mut dst = signature.data;63 let mut dst_offset = signature.signature_len - if owerride { 1 } else { 0 };58 let mut dst_offset = signature.len - if owerride { 1 } else { 0 };64 let bracket_close = {59 if let Some(ref delimiter) = signature.preferences.close_delimiter {65 let mut b = [0_u8; SIGNATURE_SIZE_LIMIT];66 b[0] = b")"[0];60 crate::make_signature!(@copy(delimiter.data, dst, delimiter.len, dst_offset));67 b61 }68 };69 FunctionSignature {62 if let Some(ref name) = signature.preferences.close_name {70 signature: {71 crate::make_signature!(@copy(bracket_close, dst, 1, dst_offset));63 crate::make_signature!(@copy(name.data, dst, name.len, dst_offset));72 dst73 },74 signature_len: dst_offset,75 }64 }65 FunctionSignature {66 data: dst,67 len: dst_offset,68 ..signature69 }76 }70 }777178 // fn as_str(&self) -> &'static str {72 pub fn as_str(&self) -> &str {79 // from_utf8(&self.signature[..self.signature_len]).expect("bad utf-8")73 from_utf8(&self.data[..self.len]).expect("bad utf-8")80 // }74 }81}75}827683#[derive(Debug)]77#[derive(Debug)]84pub struct FunctionName {78pub struct SignatureUnit {85 signature: [u8; SIGNATURE_SIZE_LIMIT],79 pub data: [u8; SIGNATURE_SIZE_LIMIT],86 signature_len: usize,80 pub len: usize,87}81}888289impl FunctionName {83impl SignatureUnit {90 pub const fn new(name: &'static str) -> FunctionName {84 pub const fn new(name: &'static str) -> SignatureUnit {91 let mut signature = [0_u8; SIGNATURE_SIZE_LIMIT];85 let mut signature = [0_u8; SIGNATURE_SIZE_LIMIT];92 let name = name.as_bytes();86 let name = name.as_bytes();93 let name_len = name.len();87 let name_len = name.len();94 let mut dst_offset = 0;88 let mut dst_offset = 0;95 crate::make_signature!(@copy(name, signature, name_len, dst_offset));89 crate::make_signature!(@copy(name, signature, name_len, dst_offset));96 FunctionName {90 SignatureUnit {97 signature,91 data: signature,98 signature_len: name_len,92 len: name_len,99 }93 }100 }94 }101}95}105macro_rules! make_signature { // May be "define_signature"?99macro_rules! make_signature { // May be "define_signature"?106 (new fn($func:expr)$(,)+) => {100 (new fn($func:expr)$(,)+) => {107 {101 {108 let fs = FunctionSignature::new(& $func);102 let fs = FunctionSignature::new($func);109 let fs = FunctionSignature::done(fs, false);103 let fs = FunctionSignature::done(fs, false);110 fs104 fs111 }105 }112 };106 };113 (new fn($func:expr), $($tt:tt)*) => {107 (new fn($func:expr), $($tt:tt,)*) => {114 {108 {115 let fs = FunctionSignature::new(& $func);109 let fs = FunctionSignature::new($func);116 let fs = make_signature!(@param; fs, $($tt),*);110 let fs = make_signature!(@param; fs, $($tt),*);117 fs111 fs118 }112 }129 };123 };130124131 (new $($tt:tt)*) => {125 (new $($tt:tt)*) => {132 const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT] = {126 const SIGNATURE: SignatureUnit = SignatureUnit {127 data: {133 let mut out = [0u8; SIGNATURE_SIZE_LIMIT];128 let mut out = [0u8; SIGNATURE_SIZE_LIMIT];134 let mut dst_offset = 0;129 let mut dst_offset = 0;135 make_signature!(@data(out, dst_offset); $($tt)*);130 make_signature!(@data(out, dst_offset); $($tt)*);136 out131 out137 };132 },138 const SIGNATURE_LEN: usize = 0 + make_signature!(@size; $($tt)*);133 len: {0 + make_signature!(@size; $($tt)*)},134 };139 };135 };140141 // (@bytes)142136143 (@size;) => {137 (@size;) => {144 0138 0147 $expr.len() + make_signature!(@size; $($tt)*)141 $expr.len() + make_signature!(@size; $($tt)*)148 };142 };149 (@size; nameof($expr:ty) $($tt:tt)*) => {143 (@size; nameof($expr:ty) $($tt:tt)*) => {150 <$expr>::SIGNATURE_LEN + make_signature!(@size; $($tt)*)144 <$expr>::SIGNATURE.len + make_signature!(@size; $($tt)*)151 };145 };146 (@size; shift_left($expr:expr) $($tt:tt)*) => {147 make_signature!(@size; $($tt)*) - $expr148 };152149153 (@data($dst:ident, $dst_offset:ident);) => {};150 (@data($dst:ident, $dst_offset:ident);) => {};154 (@data($dst:ident, $dst_offset:ident); fixed($expr:expr) $($tt:tt)*) => {151 (@data($dst:ident, $dst_offset:ident); fixed($expr:expr) $($tt:tt)*) => {161 };158 };162 (@data($dst:ident, $dst_offset:ident); nameof($expr:ty) $($tt:tt)*) => {159 (@data($dst:ident, $dst_offset:ident); nameof($expr:ty) $($tt:tt)*) => {163 {160 {164 let data = &<$expr>::SIGNATURE;161 make_signature!(@copy(&<$expr>::SIGNATURE.data, $dst, <$expr>::SIGNATURE.len, $dst_offset));165 let data_len = <$expr>::SIGNATURE_LEN;166 make_signature!(@copy(data, $dst, data_len, $dst_offset));167 }162 }168 make_signature!(@data($dst, $dst_offset); $($tt)*)163 make_signature!(@data($dst, $dst_offset); $($tt)*)169 };164 };165 (@data($dst:ident, $dst_offset:ident); shift_left($expr:expr) $($tt:tt)*) => {166 $dst_offset -= $expr;167 make_signature!(@data($dst, $dst_offset); $($tt)*)168 };170169171 (@copy($src:ident, $dst:ident, $src_len:expr, $dst_offset:ident)) => {170 (@copy($src:expr, $dst:expr, $src_len:expr, $dst_offset:ident)) => {172 {171 {173 let mut src_offset = 0;172 let mut src_offset = 0;174 let src_len: usize = $src_len;173 let src_len: usize = $src_len;185mod test {184mod test {186 use core::str::from_utf8;185 use core::str::from_utf8;187188 use frame_support::sp_runtime::app_crypto::sp_core::hexdisplay::AsBytesRef;189186190 use super::{Name, SIGNATURE_SIZE_LIMIT, FunctionName, FunctionSignature};187 use super::{SIGNATURE_SIZE_LIMIT, SignatureUnit, FunctionSignature, SignaturePreferences};188189 trait Name {190 const SIGNATURE: SignatureUnit;191192 fn name() -> &'static str {193 from_utf8(&Self::SIGNATURE.data[..Self::SIGNATURE.len]).expect("bad utf-8")194 }195 }191196192 impl Name for u8 {197 impl Name for u8 {193 make_signature!(new fixed("uint8"));198 make_signature!(new fixed("uint8"));201 impl<A: Name, B: Name> Name for (A, B) {206 impl<A: Name, B: Name> Name for (A, B) {202 make_signature!(new fixed("(") nameof(A) fixed(",") nameof(B) fixed(")"));207 make_signature!(new fixed("(") nameof(A) fixed(",") nameof(B) fixed(")"));203 }208 }209 impl<A: Name> Name for (A,) {210 make_signature!(new fixed("(") nameof(A) fixed(",") shift_left(1) fixed(")"));211 }204212205 struct MaxSize();213 struct MaxSize();206 impl Name for MaxSize {214 impl Name for MaxSize {207 const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT] = [b'!'; SIGNATURE_SIZE_LIMIT];215 const SIGNATURE: SignatureUnit = SignatureUnit {216 data: [b'!'; SIGNATURE_SIZE_LIMIT],208 const SIGNATURE_LEN: usize = SIGNATURE_SIZE_LIMIT;217 len: SIGNATURE_SIZE_LIMIT,218 };209 }219 }220221 const SIGNATURE_PREFERENCES: SignaturePreferences = SignaturePreferences {222 open_name: Some(SignatureUnit::new("some_funk")),223 open_delimiter: Some(SignatureUnit::new("(")),224 param_delimiter: Some(SignatureUnit::new(",")),225 close_delimiter: Some(SignatureUnit::new(")")),226 close_name: None,227 };210228211 #[test]229 #[test]212 fn simple() {230 fn simple() {269287270 #[test]288 #[test]271 fn make_func_without_args() {289 fn make_func_without_args() {272 const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");273 const SIG: FunctionSignature = make_signature!(290 const SIG: FunctionSignature = make_signature!(274 new fn(&SOME_FUNK_NAME),291 new fn(SIGNATURE_PREFERENCES),275 );292 );276 let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();293 let name = SIG.as_str();277 assert_eq!(name, "some_funk()");294 similar_asserts::assert_eq!(name, "some_funk()");278 }295 }279296280 #[test]297 #[test]281 fn make_func_with_1_args() {298 fn make_func_with_1_args() {282 const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");283 const SIG: FunctionSignature = make_signature!(299 const SIG: FunctionSignature = make_signature!(284 new fn(&SOME_FUNK_NAME),300 new fn(SIGNATURE_PREFERENCES),285 (u8::SIGNATURE, u8::SIGNATURE_LEN)301 (<u8>::SIGNATURE),286 );302 );287 let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();303 let name = SIG.as_str();288 assert_eq!(name, "some_funk(uint8)");304 similar_asserts::assert_eq!(name, "some_funk(uint8)");289 }305 }290306291 #[test]307 #[test]292 fn make_func_with_2_args() {308 fn make_func_with_2_args() {293 const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");294 const SIG: FunctionSignature = make_signature!(309 const SIG: FunctionSignature = make_signature!(295 new fn(&SOME_FUNK_NAME),310 new fn(SIGNATURE_PREFERENCES),296 (u8::SIGNATURE, u8::SIGNATURE_LEN)311 (u8::SIGNATURE),297 (<Vec<u32>>::SIGNATURE, <Vec<u32>>::SIGNATURE_LEN)312 (<Vec<u32>>::SIGNATURE),298 );313 );299 let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();314 let name = SIG.as_str();300 assert_eq!(name, "some_funk(uint8,uint32[])");315 similar_asserts::assert_eq!(name, "some_funk(uint8,uint32[])");301 }316 }302317303 #[test]318 #[test]304 fn make_func_with_3_args() {319 fn make_func_with_3_args() {305 const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");306 const SIG: FunctionSignature = make_signature!(320 const SIG: FunctionSignature = make_signature!(307 new fn(&SOME_FUNK_NAME),321 new fn(SIGNATURE_PREFERENCES),308 (u8::SIGNATURE, u8::SIGNATURE_LEN)322 (<u8>::SIGNATURE),309 (u32::SIGNATURE, u32::SIGNATURE_LEN)323 (<u32>::SIGNATURE),310 (<Vec<u32>>::SIGNATURE, <Vec<u32>>::SIGNATURE_LEN)324 (<Vec<u32>>::SIGNATURE),311 );325 );312 let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();326 let name = SIG.as_str();313 assert_eq!(name, "some_funk(uint8,uint32,uint32[])");327 similar_asserts::assert_eq!(name, "some_funk(uint8,uint32,uint32[])");314 }328 }315329316 #[test]330 #[test]317 fn make_slice_from_signature() {331 fn make_slice_from_signature() {318 const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");319 const SIG: FunctionSignature = make_signature!(332 const SIG: FunctionSignature = make_signature!(320 new fn(&SOME_FUNK_NAME),333 new fn(SIGNATURE_PREFERENCES),321 (u8::SIGNATURE, u8::SIGNATURE_LEN)334 (<u8>::SIGNATURE),322 (u32::SIGNATURE, u32::SIGNATURE_LEN)335 (<u32>::SIGNATURE),323 (<Vec<u32>>::SIGNATURE, <Vec<u32>>::SIGNATURE_LEN)336 (<Vec<u32>>::SIGNATURE),324 );337 );325 const NAME: [u8; SIG.signature_len] = {338 const NAME: [u8; SIG.len] = {326 let mut name: [u8; SIG.signature_len] = [0; SIG.signature_len];339 let mut name: [u8; SIG.len] = [0; SIG.len];327 let mut i = 0;340 let mut i = 0;328 while i < SIG.signature_len {341 while i < SIG.len {329 name[i] = SIG.signature[i];342 name[i] = SIG.data[i];330 i += 1;343 i += 1;331 }344 }332 name345 name333 };346 };334 assert_eq!(&NAME, b"some_funk(uint8,uint32,uint32[])");347 similar_asserts::assert_eq!(&NAME, b"some_funk(uint8,uint32,uint32[])");335 }348 }349350 #[test]351 fn shift() {352 assert_eq!(<(u32,)>::name(), "(uint32)");353 }336}354}337355crates/evm-coder/src/lib.rsdiffbeforeafterboth124 use primitive_types::{U256, H160, H256};124 use primitive_types::{U256, H160, H256};125 use core::str::from_utf8;125 use core::str::from_utf8;126126127 use crate::custom_signature::SIGNATURE_SIZE_LIMIT;127 use crate::custom_signature::{SignatureUnit, SIGNATURE_SIZE_LIMIT};128128129 pub trait Signature {129 pub trait Signature {130 const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT];130 const SIGNATURE: SignatureUnit;131 const SIGNATURE_LEN: usize;132131133 fn as_str() -> &'static str {132 fn as_str() -> &'static str {134 from_utf8(&Self::SIGNATURE[..Self::SIGNATURE_LEN]).expect("bad utf-8")133 from_utf8(&Self::SIGNATURE.data[..Self::SIGNATURE.len]).expect("bad utf-8")135 }134 }136 }135 }137136crates/evm-coder/src/solidity.rsdiffbeforeafterboth30 marker::PhantomData,30 marker::PhantomData,31 cell::{Cell, RefCell},31 cell::{Cell, RefCell},32 cmp::Reverse,32 cmp::Reverse,33 str::from_utf8,34};33};35use impl_trait_for_tuples::impl_for_tuples;34use impl_trait_for_tuples::impl_for_tuples;36use crate::{types::*, custom_signature::FunctionSignature};35use crate::{types::*, custom_signature::FunctionSignature};514 writeln!(513 writeln!(515 writer,514 writer,516 "\t{hide_comment}/// or in textual repr: {}",515 "\t{hide_comment}/// or in textual repr: {}",517 // from_utf8(self.custom_signature.as_str()).expect("bad utf8")518 self.selector_str516 self.selector_str519 )?;517 )?;518 if self.selector_str != self.custom_signature.as_str() {519 writeln!(520 writer,521 "\t{hide_comment}/// or in the expanded repr: {}",522 self.custom_signature.as_str()523 )?;524 }520 write!(writer, "\t{hide_comment}function {}(", self.name)?;525 write!(writer, "\tfunction {}(", self.name)?;521 self.args.solidity_name(writer, tc)?;526 self.args.solidity_name(writer, tc)?;522 write!(writer, ")")?;527 write!(writer, ")")?;523 if is_impl {528 if is_impl {pallets/common/src/erc.rsdiffbeforeafterboth21 types::*,21 types::*,22 execution::{Result, Error},22 execution::{Result, Error},23 weight,23 weight,24 custom_signature::{FunctionName, FunctionSignature},24 custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},25 make_signature,25 make_signature,26};26};27pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};27pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth17//! Implementation of magic contract17//! Implementation of magic contract181819extern crate alloc;19extern crate alloc;20use alloc::{format, string::ToString};20use alloc::string::ToString;21use core::marker::PhantomData;21use core::marker::PhantomData;22use evm_coder::{22use evm_coder::{23 abi::AbiWriter,23 abi::AbiWriter,24 execution::Result,24 execution::Result,25 generate_stubgen, solidity_interface,25 generate_stubgen, solidity_interface,26 types::*,26 types::*,27 ToLog,27 ToLog,28 custom_signature::{FunctionName, FunctionSignature},28 custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},29 make_signature,29 make_signature,30};30};31use pallet_evm::{31use pallet_evm::{pallets/fungible/src/erc.rsdiffbeforeafterboth17//! ERC-20 standart support implementation.17//! ERC-20 standart support implementation.181819extern crate alloc;19extern crate alloc;20use alloc::{format, string::ToString};21use core::char::{REPLACEMENT_CHARACTER, decode_utf16};20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};22use core::convert::TryInto;21use core::convert::TryInto;23use evm_coder::{22use evm_coder::{26 generate_stubgen, solidity_interface,25 generate_stubgen, solidity_interface,27 types::*,26 types::*,28 weight,27 weight,29 custom_signature::{FunctionName, FunctionSignature},28 custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},30 make_signature,29 make_signature,31};30};32use pallet_common::eth::convert_tuple_to_cross_account;31use pallet_common::eth::convert_tuple_to_cross_account;pallets/nonfungible/expand.rsdiffbeforeafterbothno changes
pallets/nonfungible/src/erc.rsdiffbeforeafterboth20//! Method implementations are mostly doing parameter conversion and calling Nonfungible Pallet methods.20//! Method implementations are mostly doing parameter conversion and calling Nonfungible Pallet methods.212122extern crate alloc;22extern crate alloc;23use alloc::{format, string::ToString};23use alloc::string::ToString;24use core::{24use core::{25 char::{REPLACEMENT_CHARACTER, decode_utf16},25 char::{REPLACEMENT_CHARACTER, decode_utf16},26 convert::TryInto,26 convert::TryInto,31 generate_stubgen, solidity, solidity_interface,31 generate_stubgen, solidity, solidity_interface,32 types::*,32 types::*,33 weight,33 weight,34 custom_signature::{FunctionName, FunctionSignature},34 custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},35 make_signature,35 make_signature,36};36};37use frame_support::BoundedVec;37use frame_support::BoundedVec;pallets/refungible/src/erc.rsdiffbeforeafterboth212122extern crate alloc;22extern crate alloc;232324use alloc::{format, string::ToString};24use alloc::string::ToString;25use core::{25use core::{26 char::{REPLACEMENT_CHARACTER, decode_utf16},26 char::{REPLACEMENT_CHARACTER, decode_utf16},27 convert::TryInto,27 convert::TryInto,32 generate_stubgen, solidity, solidity_interface,32 generate_stubgen, solidity, solidity_interface,33 types::*,33 types::*,34 weight,34 weight,35 custom_signature::{FunctionName, FunctionSignature},35 custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},36 make_signature,36 make_signature,37};37};38use frame_support::{BoundedBTreeMap, BoundedVec};38use frame_support::{BoundedBTreeMap, BoundedVec};pallets/refungible/src/erc_token.rsdiffbeforeafterboth35 generate_stubgen, solidity_interface,35 generate_stubgen, solidity_interface,36 types::*,36 types::*,37 weight,37 weight,38 custom_signature::{FunctionName, FunctionSignature},38 custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},39 make_signature,39 make_signature,40};40};41use pallet_common::{41use pallet_common::{pallets/unique/src/eth/mod.rsdiffbeforeafterboth22 execution::*,22 execution::*,23 generate_stubgen, solidity, solidity_interface,23 generate_stubgen, solidity, solidity_interface,24 types::*,24 types::*,25 custom_signature::{FunctionName, FunctionSignature},25 custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},26 make_signature,26 make_signature,27, weight};27, weight};28use frame_support::{traits::Get, storage::StorageNMap};28use frame_support::{traits::Get, storage::StorageNMap};