difftreelog
refactor unify function and type signature handling
in: master
12 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
@@ -24,8 +24,8 @@
use quote::{quote, format_ident};
use inflector::cases;
use syn::{
- Expr, FnArg, GenericArgument, Generics, Ident, ImplItem, ImplItemMethod, ItemImpl, Lit, Meta,
- MetaNameValue, PatType, PathArguments, ReturnType, Type,
+ Expr, FnArg, Generics, Ident, ImplItem, ImplItemMethod, ItemImpl, Lit, Meta, MetaNameValue,
+ PatType, ReturnType, Type,
spanned::Spanned,
parse::{Parse, ParseStream},
parenthesized, Token, LitInt, LitStr,
@@ -601,12 +601,12 @@
let screaming_name_signature = format_ident!("{}_SIGNATURE", &self.screaming_name);
let custom_signature = self.expand_custom_signature();
quote! {
- const #screaming_name_signature: ::evm_coder::custom_signature::FunctionSignature = #custom_signature;
+ const #screaming_name_signature: ::evm_coder::custom_signature::SignatureUnit = #custom_signature;
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.unit.len {
- sum = sum.update(&[Self::#screaming_name_signature.unit.data[pos]; 1]);
+ while pos < Self::#screaming_name_signature.len {
+ sum = sum.update(&[Self::#screaming_name_signature.data[pos]; 1]);
pos += 1;
}
let a = sum.finalize();
@@ -710,192 +710,28 @@
};
quote! {
Self::#pascal_name #matcher => ().into()
- }
- }
- }
-
- fn expand_type(ty: &Type, token_stream: &mut proc_macro2::TokenStream, read_signature: bool) {
- match ty {
- Type::Path(tp) => {
- if let Some(qself) = &tp.qself {
- panic!("no receiver expected {:?}", qself.ty.span());
- }
- let path = &tp.path;
- if path.segments.len() != 1 {
- panic!("expected path to have only one segment {:?}", path.span());
- }
- let last_segment = path.segments.last().unwrap();
-
- if last_segment.ident == "Vec" {
- let args = match &last_segment.arguments {
- PathArguments::AngleBracketed(e) => e,
- _ => {
- panic!("missing Vec generic {:?}", last_segment.arguments.span());
- }
- };
- let args = &args.args;
- if args.len() != 1 {
- panic!("expected only one generic for vec {:?}", args.span());
- }
- let arg = args.first().expect("first arg");
-
- let ty = match arg {
- GenericArgument::Type(ty) => ty,
- _ => {
- panic!("expected first generic to be type {:?}", arg.span());
- }
- };
-
- let mut vec_token = proc_macro2::TokenStream::new();
- Self::expand_type(ty, &mut vec_token, false);
- vec_token = if read_signature {
- quote! { (<Vec<#vec_token>>::SIGNATURE) }
- } else {
- quote! { <Vec<#vec_token>> }
- };
- token_stream.extend(vec_token);
- } else {
- if !last_segment.arguments.is_empty() {
- panic!(
- "unexpected generic arguments for non-vec type {:?}",
- last_segment.arguments.span()
- );
- }
-
- let ident = &last_segment.ident;
- let plain_token = if read_signature {
- quote! {
- (<#ident>::SIGNATURE)
- }
- } else {
- quote! {
- #ident
- }
- };
-
- token_stream.extend(plain_token);
- }
- }
-
- Type::Tuple(tt) => {
- // for ty in tt.elems.iter() {
- // out.push(AbiType::try_from(ty)?)
- // }
-
- let mut tuple_types = proc_macro2::TokenStream::new();
- let mut is_first = true;
-
- for ty in tt.elems.iter() {
- if is_first {
- is_first = false
- } else {
- tuple_types.extend(quote!(,));
- }
- Self::expand_type(ty, &mut tuple_types, false);
- }
- tuple_types = if read_signature {
- quote! { (<(#tuple_types)>::SIGNATURE) }
- } else {
- quote! { (#tuple_types) }
- };
- token_stream.extend(tuple_types);
}
-
- // Type::Array(arr) => {
- // let wrapped = AbiType::try_from(&arr.elem)?;
- // match &arr.len {
- // Expr::Lit(l) => match &l.lit {
- // Lit::Int(i) => {
- // let num = i.base10_parse::<usize>()?;
- // Ok(AbiType::Array(Box::new(wrapped), num as usize))
- // }
- // _ => Err(syn::Error::new(arr.len.span(), "should be int literal")),
- // },
- // _ => Err(syn::Error::new(arr.len.span(), "should be literal")),
- // }
- // }
- _ => panic!("Unexpected type {ty:?}"),
}
- // match ty {
- // AbiType::Plain(ref ident) => {
- // let plain_token = if read_signature {
- // quote! {
- // (<#ident>::SIGNATURE)
- // }
- // } else {
- // quote! {
- // #ident
- // }
- // };
-
- // token_stream.extend(plain_token);
- // }
-
- // AbiType::Tuple(ref tuple_type) => {
- // let mut tuple_types = proc_macro2::TokenStream::new();
- // let mut is_first = true;
-
- // for ty in tuple_type {
- // if is_first {
- // is_first = false
- // } else {
- // tuple_types.extend(quote!(,));
- // }
- // Self::expand_type(ty, &mut tuple_types, false);
- // }
- // tuple_types = if read_signature {
- // quote! { (<(#tuple_types)>::SIGNATURE) }
- // } else {
- // quote! { (#tuple_types) }
- // };
- // token_stream.extend(tuple_types);
- // }
-
- // AbiType::Vec(ref vec_type) => {
- // let mut vec_token = proc_macro2::TokenStream::new();
- // Self::expand_type(vec_type.as_ref(), &mut vec_token, false);
- // vec_token = if read_signature {
- // quote! { (<Vec<#vec_token>>::SIGNATURE) }
- // } else {
- // quote! { <Vec<#vec_token>> }
- // };
- // token_stream.extend(vec_token);
- // }
-
- // AbiType::Array(_, _) => todo!("Array eth signature"),
- // };
}
fn expand_custom_signature(&self) -> proc_macro2::TokenStream {
- let mut token_stream = TokenStream::new();
+ let mut args = TokenStream::new();
let mut is_first = true;
- for arg in &self.args {
- if arg.is_special() {
- continue;
- }
-
- if is_first {
- is_first = false;
- } else {
- token_stream.extend(quote!(,));
- }
- Self::expand_type(&arg.ty, &mut token_stream, true);
+ for arg in self.args.iter().filter(|a| !a.is_special()) {
+ is_first = false;
+ let ty = &arg.ty;
+ args.extend(quote! {nameof(#ty)});
+ args.extend(quote! {fixed(",")})
}
+ // Remove trailing comma
if !is_first {
- token_stream.extend(quote!(,));
+ args.extend(quote! {shift_left(1)})
}
let func_name = self.camel_name.clone();
- let func_name = quote!(SignaturePreferences {
- open_name: Some(SignatureUnit::new(#func_name)),
- open_delimiter: Some(SignatureUnit::new("(")),
- param_delimiter: Some(SignatureUnit::new(",")),
- close_delimiter: Some(SignatureUnit::new(")")),
- close_name: None,
- });
- quote!({ ::evm_coder::make_signature!(new fn(#func_name), #token_stream) })
+ quote! { ::evm_coder::make_signature!(new fixed(#func_name) fixed("(") #args fixed(")")) }
}
fn expand_solidity_function(&self) -> proc_macro2::TokenStream {
@@ -916,12 +752,6 @@
let screaming_name = &self.screaming_name;
let hide = self.hide;
let custom_signature = self.expand_custom_signature();
- let custom_signature = quote!(
- {
- const cs: FunctionSignature = #custom_signature;
- cs
- }
- );
let is_payable = self.has_value_args;
quote! {
crates/evm-coder/src/abi.rsdiffbeforeafterboth--- a/crates/evm-coder/src/abi.rs
+++ b/crates/evm-coder/src/abi.rs
@@ -27,7 +27,7 @@
execution::{Error, ResultWithPostInfo, WithPostDispatchInfo},
types::*,
make_signature,
- custom_signature::{SignatureUnit, SIGNATURE_SIZE_LIMIT},
+ custom_signature::{SignatureUnit},
};
use crate::execution::Result;
@@ -428,7 +428,7 @@
}
impl<R: Signature> Signature for Vec<R> {
- make_signature!(new nameof(R) fixed("[]"));
+ const SIGNATURE: SignatureUnit = make_signature!(new nameof(R) fixed("[]"));
}
impl sealed::CanBePlacedInVec for EthCrossAccount {}
@@ -522,7 +522,7 @@
where
$($ident: Signature,)+
{
- make_signature!(
+ const SIGNATURE: SignatureUnit = make_signature!(
new fixed("(")
$(nameof($ident) fixed(","))+
shift_left(1)
@@ -758,13 +758,13 @@
1ACF2D55
0000000000000000000000000000000000000000000000000000000000000020 // offset of (address, uint256)[]
0000000000000000000000000000000000000000000000000000000000000003 // length of (address, uint256)[]
-
+
0000000000000000000000002D2FF76104B7BACB2E8F6731D5BFC184EBECDDBC // address
000000000000000000000000000000000000000000000000000000000000000A // uint256
-
+
000000000000000000000000AB8E3D9134955566483B11E6825C9223B6737B10 // address
0000000000000000000000000000000000000000000000000000000000000014 // uint256
-
+
0000000000000000000000008C582BDF2953046705FC56F189385255EFC1BE18 // address
000000000000000000000000000000000000000000000000000000000000001E // uint256
"
crates/evm-coder/src/custom_signature.rsdiffbeforeafterboth--- a/crates/evm-coder/src/custom_signature.rs
+++ b/crates/evm-coder/src/custom_signature.rs
@@ -74,132 +74,11 @@
//! impl<T: SoliditySignature> SoliditySignature for Vec<T> {
//! make_signature!(new nameof(T) fixed("[]"));
//! }
-//!
-//! // Function signature settings
-//! const SIGNATURE_PREFERENCES: SignaturePreferences = SignaturePreferences {
-//! open_name: Some(SignatureUnit::new("some_funk")),
-//! open_delimiter: Some(SignatureUnit::new("(")),
-//! param_delimiter: Some(SignatureUnit::new(",")),
-//! close_delimiter: Some(SignatureUnit::new(")")),
-//! close_name: None,
-//! };
-//!
-//! // Create functions signatures
-//! fn make_func_without_args() {
-//! const SIG: FunctionSignature = make_signature!(
-//! new fn(SIGNATURE_PREFERENCES),
-//! );
-//! let name = SIG.as_str();
-//! similar_asserts::assert_eq!(name, "some_funk()");
-//! }
-//!
-//! fn make_func_with_3_args() {
-//! const SIG: FunctionSignature = make_signature!(
-//! new fn(SIGNATURE_PREFERENCES),
-//! (<u8>::SIGNATURE),
-//! (<u8>::SIGNATURE),
-//! (<Vec<u8>>::SIGNATURE),
-//! );
-//! let name = SIG.as_str();
-//! similar_asserts::assert_eq!(name, "some_funk(uint8,uint8,uint8[])");
-//! }
//! ```
-use core::str::from_utf8;
/// The maximum length of the signature.
pub const SIGNATURE_SIZE_LIMIT: usize = 256;
-
-/// Function signature formatting preferences.
-#[derive(Debug)]
-pub struct SignaturePreferences {
- /// The name of the function before the list of parameters: `*some*(param1,param2)func`
- pub open_name: Option<SignatureUnit>,
- /// Opening separator: `some*(*param1,param2)func`
- pub open_delimiter: Option<SignatureUnit>,
- /// Parameters separator: `some(param1*,*param2)func`
- pub param_delimiter: Option<SignatureUnit>,
- /// Closinging separator: `some(param1,param2*)*func`
- pub close_delimiter: Option<SignatureUnit>,
- /// The name of the function after the list of parameters: `some(param1,param2)*func*`
- pub close_name: Option<SignatureUnit>,
-}
-
-/// Constructs and stores the signature of the function.
-#[derive(Debug)]
-pub struct FunctionSignature {
- /// Storage for function signature.
- pub unit: SignatureUnit,
- preferences: SignaturePreferences,
-}
-impl FunctionSignature {
- /// Start constructing the signature. It is written to the storage
- /// [`SignaturePreferences::open_name`] and [`SignaturePreferences::open_delimiter`].
- pub const fn new(preferences: SignaturePreferences) -> FunctionSignature {
- let mut dst = [0_u8; SIGNATURE_SIZE_LIMIT];
- let mut dst_offset = 0;
- if let Some(ref name) = preferences.open_name {
- crate::make_signature!(@copy(name.data, dst, name.len, dst_offset));
- }
- if let Some(ref delimiter) = preferences.open_delimiter {
- crate::make_signature!(@copy(delimiter.data, dst, delimiter.len, dst_offset));
- }
- FunctionSignature {
- unit: SignatureUnit {
- data: dst,
- len: dst_offset,
- },
- preferences,
- }
- }
-
- /// Add a function parameter to the signature. It is written to the storage
- /// `param` [`SignatureUnit`] and [`SignaturePreferences::param_delimiter`].
- pub const fn add_param(
- signature: FunctionSignature,
- param: SignatureUnit,
- ) -> FunctionSignature {
- let mut dst = signature.unit.data;
- let mut dst_offset = signature.unit.len;
- crate::make_signature!(@copy(param.data, dst, param.len, dst_offset));
- if let Some(ref delimiter) = signature.preferences.param_delimiter {
- crate::make_signature!(@copy(delimiter.data, dst, delimiter.len, dst_offset));
- }
- FunctionSignature {
- unit: SignatureUnit {
- data: dst,
- len: dst_offset,
- },
- ..signature
- }
- }
-
- /// Complete signature construction. It is written to the storage
- /// [`SignaturePreferences::close_delimiter`] and [`SignaturePreferences::close_name`].
- pub const fn done(signature: FunctionSignature, owerride: bool) -> FunctionSignature {
- let mut dst = signature.unit.data;
- let mut dst_offset = signature.unit.len - if owerride { 1 } else { 0 };
- if let Some(ref delimiter) = signature.preferences.close_delimiter {
- crate::make_signature!(@copy(delimiter.data, dst, delimiter.len, dst_offset));
- }
- if let Some(ref name) = signature.preferences.close_name {
- crate::make_signature!(@copy(name.data, dst, name.len, dst_offset));
- }
- FunctionSignature {
- unit: SignatureUnit {
- data: dst,
- len: dst_offset,
- },
- ..signature
- }
- }
-
- /// Represent the signature as `&str'.
- pub fn as_str(&self) -> &str {
- from_utf8(&self.unit.data[..self.unit.len]).expect("bad utf-8")
- }
-}
-
/// Storage for the signature or its elements.
#[derive(Debug)]
pub struct SignatureUnit {
@@ -222,6 +101,10 @@
len: name_len,
}
}
+ /// String conversion
+ pub fn as_str(&self) -> Option<&str> {
+ core::str::from_utf8(&self.data[0..self.len]).ok()
+ }
}
/// ### Macro to create signatures of types and functions.
@@ -231,85 +114,52 @@
/// make_signature!(new fixed("uint8")); // Simple type
/// make_signature!(new fixed("(") nameof(u8) fixed(",") nameof(u8) fixed(")")); // Composite type
/// ```
-/// Format for creating a function of the function:
-/// ```ignore
-/// const SIG: FunctionSignature = make_signature!(
-/// new fn(SIGNATURE_PREFERENCES),
-/// (u8::SIGNATURE),
-/// (<(u8,u8)>::SIGNATURE),
-/// );
-/// ```
#[macro_export]
macro_rules! make_signature {
- (new fn($func:expr)$(,)*) => {
- {
- let fs = FunctionSignature::new($func);
- let fs = FunctionSignature::done(fs, false);
- fs
- }
- };
- (new fn($func:expr), $($tt:tt,)*) => {
- {
- let fs = FunctionSignature::new($func);
- let fs = make_signature!(@param; fs, $($tt),*);
- fs
- }
+ (new $($tt:tt)*) => {
+ ($crate::custom_signature::SignatureUnit {
+ data: {
+ let mut out = [0u8; $crate::custom_signature::SIGNATURE_SIZE_LIMIT];
+ let mut dst_offset = 0;
+ $crate::make_signature!(@data(out, dst_offset); $($tt)*);
+ out
+ },
+ len: {0 + $crate::make_signature!(@size; $($tt)*)},
+ })
};
- (@param; $func:expr) => {
- FunctionSignature::done($func, true)
+ (@size;) => {
+ 0
};
- (@param; $func:expr, $param:expr) => {
- make_signature!(@param; FunctionSignature::add_param($func, $param))
+ (@size; fixed($expr:expr) $($tt:tt)*) => {
+ $expr.len() + $crate::make_signature!(@size; $($tt)*)
};
- (@param; $func:expr, $param:expr, $($tt:tt),*) => {
- make_signature!(@param; FunctionSignature::add_param($func, $param), $($tt),*)
+ (@size; nameof($expr:ty) $($tt:tt)*) => {
+ <$expr>::SIGNATURE.len + $crate::make_signature!(@size; $($tt)*)
};
-
- (new $($tt:tt)*) => {
- const SIGNATURE: SignatureUnit = SignatureUnit {
- data: {
- let mut out = [0u8; SIGNATURE_SIZE_LIMIT];
- let mut dst_offset = 0;
- make_signature!(@data(out, dst_offset); $($tt)*);
- out
- },
- len: {0 + make_signature!(@size; $($tt)*)},
- };
- };
-
- (@size;) => {
- 0
- };
- (@size; fixed($expr:expr) $($tt:tt)*) => {
- $expr.len() + make_signature!(@size; $($tt)*)
- };
- (@size; nameof($expr:ty) $($tt:tt)*) => {
- <$expr>::SIGNATURE.len + make_signature!(@size; $($tt)*)
- };
(@size; shift_left($expr:expr) $($tt:tt)*) => {
- make_signature!(@size; $($tt)*) - $expr
+ $crate::make_signature!(@size; $($tt)*) - $expr
};
- (@data($dst:ident, $dst_offset:ident);) => {};
- (@data($dst:ident, $dst_offset:ident); fixed($expr:expr) $($tt:tt)*) => {
- {
- let data = $expr.as_bytes();
+ (@data($dst:ident, $dst_offset:ident);) => {};
+ (@data($dst:ident, $dst_offset:ident); fixed($expr:expr) $($tt:tt)*) => {
+ {
+ let data = $expr.as_bytes();
let data_len = data.len();
- make_signature!(@copy(data, $dst, data_len, $dst_offset));
- }
- make_signature!(@data($dst, $dst_offset); $($tt)*)
- };
- (@data($dst:ident, $dst_offset:ident); nameof($expr:ty) $($tt:tt)*) => {
- {
- make_signature!(@copy(&<$expr>::SIGNATURE.data, $dst, <$expr>::SIGNATURE.len, $dst_offset));
- }
- make_signature!(@data($dst, $dst_offset); $($tt)*)
- };
+ $crate::make_signature!(@copy(data, $dst, data_len, $dst_offset));
+ }
+ $crate::make_signature!(@data($dst, $dst_offset); $($tt)*)
+ };
+ (@data($dst:ident, $dst_offset:ident); nameof($expr:ty) $($tt:tt)*) => {
+ {
+ $crate::make_signature!(@copy(&<$expr>::SIGNATURE.data, $dst, <$expr>::SIGNATURE.len, $dst_offset));
+ }
+ $crate::make_signature!(@data($dst, $dst_offset); $($tt)*)
+ };
(@data($dst:ident, $dst_offset:ident); shift_left($expr:expr) $($tt:tt)*) => {
- $dst_offset -= $expr;
- make_signature!(@data($dst, $dst_offset); $($tt)*)
- };
+ $dst_offset -= $expr;
+ $crate::make_signature!(@data($dst, $dst_offset); $($tt)*)
+ };
(@copy($src:expr, $dst:expr, $src_len:expr, $dst_offset:ident)) => {
{
@@ -328,7 +178,7 @@
mod test {
use core::str::from_utf8;
- use super::{SIGNATURE_SIZE_LIMIT, SignatureUnit, FunctionSignature, SignaturePreferences};
+ use super::{SIGNATURE_SIZE_LIMIT, SignatureUnit};
trait Name {
const SIGNATURE: SignatureUnit;
@@ -339,19 +189,21 @@
}
impl Name for u8 {
- make_signature!(new fixed("uint8"));
+ const SIGNATURE: SignatureUnit = make_signature!(new fixed("uint8"));
}
impl Name for u32 {
- make_signature!(new fixed("uint32"));
+ const SIGNATURE: SignatureUnit = make_signature!(new fixed("uint32"));
}
impl<T: Name> Name for Vec<T> {
- make_signature!(new nameof(T) fixed("[]"));
+ const SIGNATURE: SignatureUnit = make_signature!(new nameof(T) fixed("[]"));
}
impl<A: Name, B: Name> Name for (A, B) {
- make_signature!(new fixed("(") nameof(A) fixed(",") nameof(B) fixed(")"));
+ const SIGNATURE: SignatureUnit =
+ make_signature!(new fixed("(") nameof(A) fixed(",") nameof(B) fixed(")"));
}
impl<A: Name> Name for (A,) {
- make_signature!(new fixed("(") nameof(A) fixed(",") shift_left(1) fixed(")"));
+ const SIGNATURE: SignatureUnit =
+ make_signature!(new fixed("(") nameof(A) fixed(",") shift_left(1) fixed(")"));
}
struct MaxSize();
@@ -361,14 +213,6 @@
len: SIGNATURE_SIZE_LIMIT,
};
}
-
- const SIGNATURE_PREFERENCES: SignaturePreferences = SignaturePreferences {
- open_name: Some(SignatureUnit::new("some_funk")),
- open_delimiter: Some(SignatureUnit::new("(")),
- param_delimiter: Some(SignatureUnit::new(",")),
- close_delimiter: Some(SignatureUnit::new(")")),
- close_name: None,
- };
#[test]
fn simple() {
@@ -421,68 +265,6 @@
#[test]
fn max_size() {
assert_eq!(<MaxSize>::name(), "!".repeat(SIGNATURE_SIZE_LIMIT));
- }
-
- #[test]
- fn make_func_without_args() {
- const SIG: FunctionSignature = make_signature!(
- new fn(SIGNATURE_PREFERENCES)
- );
- let name = SIG.as_str();
- similar_asserts::assert_eq!(name, "some_funk()");
- }
-
- #[test]
- fn make_func_with_1_args() {
- const SIG: FunctionSignature = make_signature!(
- new fn(SIGNATURE_PREFERENCES),
- (<u8>::SIGNATURE),
- );
- let name = SIG.as_str();
- similar_asserts::assert_eq!(name, "some_funk(uint8)");
- }
-
- #[test]
- fn make_func_with_2_args() {
- const SIG: FunctionSignature = make_signature!(
- new fn(SIGNATURE_PREFERENCES),
- (u8::SIGNATURE),
- (<Vec<u32>>::SIGNATURE),
- );
- let name = SIG.as_str();
- similar_asserts::assert_eq!(name, "some_funk(uint8,uint32[])");
- }
-
- #[test]
- fn make_func_with_3_args() {
- const SIG: FunctionSignature = make_signature!(
- new fn(SIGNATURE_PREFERENCES),
- (<u8>::SIGNATURE),
- (<u32>::SIGNATURE),
- (<Vec<u32>>::SIGNATURE),
- );
- let name = SIG.as_str();
- similar_asserts::assert_eq!(name, "some_funk(uint8,uint32,uint32[])");
- }
-
- #[test]
- fn make_slice_from_signature() {
- const SIG: FunctionSignature = make_signature!(
- new fn(SIGNATURE_PREFERENCES),
- (<u8>::SIGNATURE),
- (<u32>::SIGNATURE),
- (<Vec<u32>>::SIGNATURE),
- );
- const NAME: [u8; SIG.unit.len] = {
- let mut name: [u8; SIG.unit.len] = [0; SIG.unit.len];
- let mut i = 0;
- while i < SIG.unit.len {
- name[i] = SIG.unit.data[i];
- i += 1;
- }
- name
- };
- similar_asserts::assert_eq!(&NAME, b"some_funk(uint8,uint32,uint32[])");
}
#[test]
crates/evm-coder/src/lib.rsdiffbeforeafterboth--- a/crates/evm-coder/src/lib.rs
+++ b/crates/evm-coder/src/lib.rs
@@ -122,7 +122,7 @@
use primitive_types::{U256, H160, H256};
use core::str::from_utf8;
- use crate::custom_signature::{SignatureUnit, SIGNATURE_SIZE_LIMIT};
+ use crate::custom_signature::SignatureUnit;
pub trait Signature {
const SIGNATURE: SignatureUnit;
@@ -133,14 +133,14 @@
}
impl Signature for bool {
- make_signature!(new fixed("bool"));
+ const SIGNATURE: SignatureUnit = make_signature!(new fixed("bool"));
}
macro_rules! define_simple_type {
(type $ident:ident = $ty:ty) => {
pub type $ident = $ty;
impl Signature for $ty {
- make_signature!(new fixed(stringify!($ident)));
+ const SIGNATURE: SignatureUnit = make_signature!(new fixed(stringify!($ident)));
}
};
}
@@ -165,7 +165,7 @@
#[derive(Default, Debug)]
pub struct bytes(pub Vec<u8>);
impl Signature for bytes {
- make_signature!(new fixed("bytes"));
+ const SIGNATURE: SignatureUnit = make_signature!(new fixed("bytes"));
}
/// Solidity doesn't have `void` type, however we have special implementation
@@ -259,7 +259,7 @@
}
impl Signature for EthCrossAccount {
- make_signature!(new fixed("(address,uint256)"));
+ const SIGNATURE: SignatureUnit = make_signature!(new fixed("(address,uint256)"));
}
/// Convert `CrossAccountId` to `uint256`.
crates/evm-coder/src/solidity.rsdiffbeforeafterboth--- a/crates/evm-coder/src/solidity.rs
+++ b/crates/evm-coder/src/solidity.rs
@@ -32,7 +32,7 @@
cmp::Reverse,
};
use impl_trait_for_tuples::impl_for_tuples;
-use crate::{types::*, custom_signature::FunctionSignature};
+use crate::{types::*, custom_signature::SignatureUnit};
#[derive(Default)]
pub struct TypeCollector {
@@ -486,7 +486,7 @@
pub docs: &'static [&'static str],
pub selector: u32,
pub hide: bool,
- pub custom_signature: FunctionSignature,
+ pub custom_signature: SignatureUnit,
pub name: &'static str,
pub args: A,
pub result: R,
@@ -512,7 +512,7 @@
writeln!(
writer,
"\t{hide_comment}/// or in textual repr: {}",
- self.custom_signature.as_str()
+ self.custom_signature.as_str().expect("bad utf-8")
)?;
write!(writer, "\t{hide_comment}function {}(", self.name)?;
self.args.solidity_name(writer, tc)?;
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -21,8 +21,6 @@
types::*,
execution::{Result, Error},
weight,
- custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},
- make_signature,
};
pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};
use pallet_evm_coder_substrate::dispatch_to_evm;
pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -19,13 +19,7 @@
extern crate alloc;
use core::marker::PhantomData;
use evm_coder::{
- abi::AbiWriter,
- execution::Result,
- generate_stubgen, solidity_interface,
- types::*,
- ToLog,
- custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},
- make_signature,
+ abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,
};
use pallet_evm::{
ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,
pallets/fungible/src/erc.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! ERC-20 standart support implementation.1819extern crate alloc;20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};21use core::convert::TryInto;22use evm_coder::{23 ToLog,24 execution::*,25 generate_stubgen, solidity_interface,26 types::*,27 weight,28 custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},29 make_signature,30};31use up_data_structs::CollectionMode;32use pallet_common::erc::{CommonEvmHandler, PrecompileResult};33use sp_std::vec::Vec;34use pallet_evm::{account::CrossAccountId, PrecompileHandle};35use pallet_evm_coder_substrate::{call, dispatch_to_evm};36use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};37use pallet_common::{CollectionHandle, erc::CollectionCall};3839use crate::{40 Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,41 weights::WeightInfo,42};4344#[derive(ToLog)]45pub enum ERC20Events {46 Transfer {47 #[indexed]48 from: address,49 #[indexed]50 to: address,51 value: uint256,52 },53 Approval {54 #[indexed]55 owner: address,56 #[indexed]57 spender: address,58 value: uint256,59 },60}6162#[solidity_interface(name = ERC20, events(ERC20Events))]63impl<T: Config> FungibleHandle<T> {64 fn name(&self) -> Result<string> {65 Ok(decode_utf16(self.name.iter().copied())66 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))67 .collect::<string>())68 }69 fn symbol(&self) -> Result<string> {70 Ok(string::from_utf8_lossy(&self.token_prefix).into())71 }72 fn total_supply(&self) -> Result<uint256> {73 self.consume_store_reads(1)?;74 Ok(<TotalSupply<T>>::get(self.id).into())75 }7677 fn decimals(&self) -> Result<uint8> {78 Ok(if let CollectionMode::Fungible(decimals) = &self.mode {79 *decimals80 } else {81 unreachable!()82 })83 }84 fn balance_of(&self, owner: address) -> Result<uint256> {85 self.consume_store_reads(1)?;86 let owner = T::CrossAccountId::from_eth(owner);87 let balance = <Balance<T>>::get((self.id, owner));88 Ok(balance.into())89 }90 #[weight(<SelfWeightOf<T>>::transfer())]91 fn transfer(&mut self, caller: caller, to: address, amount: uint256) -> Result<bool> {92 let caller = T::CrossAccountId::from_eth(caller);93 let to = T::CrossAccountId::from_eth(to);94 let amount = amount.try_into().map_err(|_| "amount overflow")?;95 let budget = self96 .recorder97 .weight_calls_budget(<StructureWeight<T>>::find_parent());9899 <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;100 Ok(true)101 }102 #[weight(<SelfWeightOf<T>>::transfer_from())]103 fn transfer_from(104 &mut self,105 caller: caller,106 from: address,107 to: address,108 amount: uint256,109 ) -> Result<bool> {110 let caller = T::CrossAccountId::from_eth(caller);111 let from = T::CrossAccountId::from_eth(from);112 let to = T::CrossAccountId::from_eth(to);113 let amount = amount.try_into().map_err(|_| "amount overflow")?;114 let budget = self115 .recorder116 .weight_calls_budget(<StructureWeight<T>>::find_parent());117118 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)119 .map_err(dispatch_to_evm::<T>)?;120 Ok(true)121 }122 #[weight(<SelfWeightOf<T>>::approve())]123 fn approve(&mut self, caller: caller, spender: address, amount: uint256) -> Result<bool> {124 let caller = T::CrossAccountId::from_eth(caller);125 let spender = T::CrossAccountId::from_eth(spender);126 let amount = amount.try_into().map_err(|_| "amount overflow")?;127128 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)129 .map_err(dispatch_to_evm::<T>)?;130 Ok(true)131 }132 fn allowance(&self, owner: address, spender: address) -> Result<uint256> {133 self.consume_store_reads(1)?;134 let owner = T::CrossAccountId::from_eth(owner);135 let spender = T::CrossAccountId::from_eth(spender);136137 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())138 }139}140141#[solidity_interface(name = ERC20Mintable)]142impl<T: Config> FungibleHandle<T> {143 /// Mint tokens for `to` account.144 /// @param to account that will receive minted tokens145 /// @param amount amount of tokens to mint146 #[weight(<SelfWeightOf<T>>::create_item())]147 fn mint(&mut self, caller: caller, to: address, amount: uint256) -> Result<bool> {148 let caller = T::CrossAccountId::from_eth(caller);149 let to = T::CrossAccountId::from_eth(to);150 let amount = amount.try_into().map_err(|_| "amount overflow")?;151 let budget = self152 .recorder153 .weight_calls_budget(<StructureWeight<T>>::find_parent());154 <Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)155 .map_err(dispatch_to_evm::<T>)?;156 Ok(true)157 }158}159160#[solidity_interface(name = ERC20UniqueExtensions)]161impl<T: Config> FungibleHandle<T>162where163 T::AccountId: From<[u8; 32]>,164{165 #[weight(<SelfWeightOf<T>>::approve())]166 fn approve_cross(167 &mut self,168 caller: caller,169 spender: EthCrossAccount,170 amount: uint256,171 ) -> Result<bool> {172 let caller = T::CrossAccountId::from_eth(caller);173 let spender = spender.into_sub_cross_account::<T>()?;174 let amount = amount.try_into().map_err(|_| "amount overflow")?;175176 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)177 .map_err(dispatch_to_evm::<T>)?;178 Ok(true)179 }180181 /// Burn tokens from account182 /// @dev Function that burns an `amount` of the tokens of a given account,183 /// deducting from the sender's allowance for said account.184 /// @param from The account whose tokens will be burnt.185 /// @param amount The amount that will be burnt.186 #[weight(<SelfWeightOf<T>>::burn_from())]187 fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {188 let caller = T::CrossAccountId::from_eth(caller);189 let from = T::CrossAccountId::from_eth(from);190 let amount = amount.try_into().map_err(|_| "amount overflow")?;191 let budget = self192 .recorder193 .weight_calls_budget(<StructureWeight<T>>::find_parent());194195 <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)196 .map_err(dispatch_to_evm::<T>)?;197 Ok(true)198 }199200 /// Burn tokens from account201 /// @dev Function that burns an `amount` of the tokens of a given account,202 /// deducting from the sender's allowance for said account.203 /// @param from The account whose tokens will be burnt.204 /// @param amount The amount that will be burnt.205 #[weight(<SelfWeightOf<T>>::burn_from())]206 fn burn_from_cross(207 &mut self,208 caller: caller,209 from: EthCrossAccount,210 amount: uint256,211 ) -> Result<bool> {212 let caller = T::CrossAccountId::from_eth(caller);213 let from = from.into_sub_cross_account::<T>()?;214 let amount = amount.try_into().map_err(|_| "amount overflow")?;215 let budget = self216 .recorder217 .weight_calls_budget(<StructureWeight<T>>::find_parent());218219 <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)220 .map_err(dispatch_to_evm::<T>)?;221 Ok(true)222 }223224 /// Mint tokens for multiple accounts.225 /// @param amounts array of pairs of account address and amount226 #[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]227 fn mint_bulk(&mut self, caller: caller, amounts: Vec<(address, uint256)>) -> Result<bool> {228 let caller = T::CrossAccountId::from_eth(caller);229 let budget = self230 .recorder231 .weight_calls_budget(<StructureWeight<T>>::find_parent());232 let amounts = amounts233 .into_iter()234 .map(|(to, amount)| {235 Ok((236 T::CrossAccountId::from_eth(to),237 amount.try_into().map_err(|_| "amount overflow")?,238 ))239 })240 .collect::<Result<_>>()?;241242 <Pallet<T>>::create_multiple_items(&self, &caller, amounts, &budget)243 .map_err(dispatch_to_evm::<T>)?;244 Ok(true)245 }246247 #[weight(<SelfWeightOf<T>>::transfer_from())]248 fn transfer_from_cross(249 &mut self,250 caller: caller,251 from: EthCrossAccount,252 to: EthCrossAccount,253 amount: uint256,254 ) -> Result<bool> {255 let caller = T::CrossAccountId::from_eth(caller);256 let from = from.into_sub_cross_account::<T>()?;257 let to = to.into_sub_cross_account::<T>()?;258 let amount = amount.try_into().map_err(|_| "amount overflow")?;259 let budget = self260 .recorder261 .weight_calls_budget(<StructureWeight<T>>::find_parent());262263 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)264 .map_err(dispatch_to_evm::<T>)?;265 Ok(true)266 }267}268269#[solidity_interface(270 name = UniqueFungible,271 is(272 ERC20,273 ERC20Mintable,274 ERC20UniqueExtensions,275 Collection(via(common_mut returns CollectionHandle<T>)),276 )277)]278impl<T: Config> FungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}279280generate_stubgen!(gen_impl, UniqueFungibleCall<()>, true);281generate_stubgen!(gen_iface, UniqueFungibleCall<()>, false);282283impl<T: Config> CommonEvmHandler for FungibleHandle<T>284where285 T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,286{287 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueFungible.raw");288289 fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {290 call::<T, UniqueFungibleCall<T>, _, _>(handle, self)291 }292}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! ERC-20 standart support implementation.1819extern crate alloc;20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};21use core::convert::TryInto;22use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};23use up_data_structs::CollectionMode;24use pallet_common::erc::{CommonEvmHandler, PrecompileResult};25use sp_std::vec::Vec;26use pallet_evm::{account::CrossAccountId, PrecompileHandle};27use pallet_evm_coder_substrate::{call, dispatch_to_evm};28use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};29use pallet_common::{CollectionHandle, erc::CollectionCall};3031use crate::{32 Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,33 weights::WeightInfo,34};3536#[derive(ToLog)]37pub enum ERC20Events {38 Transfer {39 #[indexed]40 from: address,41 #[indexed]42 to: address,43 value: uint256,44 },45 Approval {46 #[indexed]47 owner: address,48 #[indexed]49 spender: address,50 value: uint256,51 },52}5354#[solidity_interface(name = ERC20, events(ERC20Events))]55impl<T: Config> FungibleHandle<T> {56 fn name(&self) -> Result<string> {57 Ok(decode_utf16(self.name.iter().copied())58 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))59 .collect::<string>())60 }61 fn symbol(&self) -> Result<string> {62 Ok(string::from_utf8_lossy(&self.token_prefix).into())63 }64 fn total_supply(&self) -> Result<uint256> {65 self.consume_store_reads(1)?;66 Ok(<TotalSupply<T>>::get(self.id).into())67 }6869 fn decimals(&self) -> Result<uint8> {70 Ok(if let CollectionMode::Fungible(decimals) = &self.mode {71 *decimals72 } else {73 unreachable!()74 })75 }76 fn balance_of(&self, owner: address) -> Result<uint256> {77 self.consume_store_reads(1)?;78 let owner = T::CrossAccountId::from_eth(owner);79 let balance = <Balance<T>>::get((self.id, owner));80 Ok(balance.into())81 }82 #[weight(<SelfWeightOf<T>>::transfer())]83 fn transfer(&mut self, caller: caller, to: address, amount: uint256) -> Result<bool> {84 let caller = T::CrossAccountId::from_eth(caller);85 let to = T::CrossAccountId::from_eth(to);86 let amount = amount.try_into().map_err(|_| "amount overflow")?;87 let budget = self88 .recorder89 .weight_calls_budget(<StructureWeight<T>>::find_parent());9091 <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;92 Ok(true)93 }94 #[weight(<SelfWeightOf<T>>::transfer_from())]95 fn transfer_from(96 &mut self,97 caller: caller,98 from: address,99 to: address,100 amount: uint256,101 ) -> Result<bool> {102 let caller = T::CrossAccountId::from_eth(caller);103 let from = T::CrossAccountId::from_eth(from);104 let to = T::CrossAccountId::from_eth(to);105 let amount = amount.try_into().map_err(|_| "amount overflow")?;106 let budget = self107 .recorder108 .weight_calls_budget(<StructureWeight<T>>::find_parent());109110 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)111 .map_err(dispatch_to_evm::<T>)?;112 Ok(true)113 }114 #[weight(<SelfWeightOf<T>>::approve())]115 fn approve(&mut self, caller: caller, spender: address, amount: uint256) -> Result<bool> {116 let caller = T::CrossAccountId::from_eth(caller);117 let spender = T::CrossAccountId::from_eth(spender);118 let amount = amount.try_into().map_err(|_| "amount overflow")?;119120 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)121 .map_err(dispatch_to_evm::<T>)?;122 Ok(true)123 }124 fn allowance(&self, owner: address, spender: address) -> Result<uint256> {125 self.consume_store_reads(1)?;126 let owner = T::CrossAccountId::from_eth(owner);127 let spender = T::CrossAccountId::from_eth(spender);128129 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())130 }131}132133#[solidity_interface(name = ERC20Mintable)]134impl<T: Config> FungibleHandle<T> {135 /// Mint tokens for `to` account.136 /// @param to account that will receive minted tokens137 /// @param amount amount of tokens to mint138 #[weight(<SelfWeightOf<T>>::create_item())]139 fn mint(&mut self, caller: caller, to: address, amount: uint256) -> Result<bool> {140 let caller = T::CrossAccountId::from_eth(caller);141 let to = T::CrossAccountId::from_eth(to);142 let amount = amount.try_into().map_err(|_| "amount overflow")?;143 let budget = self144 .recorder145 .weight_calls_budget(<StructureWeight<T>>::find_parent());146 <Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)147 .map_err(dispatch_to_evm::<T>)?;148 Ok(true)149 }150}151152#[solidity_interface(name = ERC20UniqueExtensions)]153impl<T: Config> FungibleHandle<T>154where155 T::AccountId: From<[u8; 32]>,156{157 #[weight(<SelfWeightOf<T>>::approve())]158 fn approve_cross(159 &mut self,160 caller: caller,161 spender: EthCrossAccount,162 amount: uint256,163 ) -> Result<bool> {164 let caller = T::CrossAccountId::from_eth(caller);165 let spender = spender.into_sub_cross_account::<T>()?;166 let amount = amount.try_into().map_err(|_| "amount overflow")?;167168 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)169 .map_err(dispatch_to_evm::<T>)?;170 Ok(true)171 }172173 /// Burn tokens from account174 /// @dev Function that burns an `amount` of the tokens of a given account,175 /// deducting from the sender's allowance for said account.176 /// @param from The account whose tokens will be burnt.177 /// @param amount The amount that will be burnt.178 #[weight(<SelfWeightOf<T>>::burn_from())]179 fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {180 let caller = T::CrossAccountId::from_eth(caller);181 let from = T::CrossAccountId::from_eth(from);182 let amount = amount.try_into().map_err(|_| "amount overflow")?;183 let budget = self184 .recorder185 .weight_calls_budget(<StructureWeight<T>>::find_parent());186187 <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)188 .map_err(dispatch_to_evm::<T>)?;189 Ok(true)190 }191192 /// Burn tokens from account193 /// @dev Function that burns an `amount` of the tokens of a given account,194 /// deducting from the sender's allowance for said account.195 /// @param from The account whose tokens will be burnt.196 /// @param amount The amount that will be burnt.197 #[weight(<SelfWeightOf<T>>::burn_from())]198 fn burn_from_cross(199 &mut self,200 caller: caller,201 from: EthCrossAccount,202 amount: uint256,203 ) -> Result<bool> {204 let caller = T::CrossAccountId::from_eth(caller);205 let from = from.into_sub_cross_account::<T>()?;206 let amount = amount.try_into().map_err(|_| "amount overflow")?;207 let budget = self208 .recorder209 .weight_calls_budget(<StructureWeight<T>>::find_parent());210211 <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)212 .map_err(dispatch_to_evm::<T>)?;213 Ok(true)214 }215216 /// Mint tokens for multiple accounts.217 /// @param amounts array of pairs of account address and amount218 #[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]219 fn mint_bulk(&mut self, caller: caller, amounts: Vec<(address, uint256)>) -> Result<bool> {220 let caller = T::CrossAccountId::from_eth(caller);221 let budget = self222 .recorder223 .weight_calls_budget(<StructureWeight<T>>::find_parent());224 let amounts = amounts225 .into_iter()226 .map(|(to, amount)| {227 Ok((228 T::CrossAccountId::from_eth(to),229 amount.try_into().map_err(|_| "amount overflow")?,230 ))231 })232 .collect::<Result<_>>()?;233234 <Pallet<T>>::create_multiple_items(&self, &caller, amounts, &budget)235 .map_err(dispatch_to_evm::<T>)?;236 Ok(true)237 }238239 #[weight(<SelfWeightOf<T>>::transfer_from())]240 fn transfer_from_cross(241 &mut self,242 caller: caller,243 from: EthCrossAccount,244 to: EthCrossAccount,245 amount: uint256,246 ) -> Result<bool> {247 let caller = T::CrossAccountId::from_eth(caller);248 let from = from.into_sub_cross_account::<T>()?;249 let to = to.into_sub_cross_account::<T>()?;250 let amount = amount.try_into().map_err(|_| "amount overflow")?;251 let budget = self252 .recorder253 .weight_calls_budget(<StructureWeight<T>>::find_parent());254255 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)256 .map_err(dispatch_to_evm::<T>)?;257 Ok(true)258 }259}260261#[solidity_interface(262 name = UniqueFungible,263 is(264 ERC20,265 ERC20Mintable,266 ERC20UniqueExtensions,267 Collection(via(common_mut returns CollectionHandle<T>)),268 )269)]270impl<T: Config> FungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}271272generate_stubgen!(gen_impl, UniqueFungibleCall<()>, true);273generate_stubgen!(gen_iface, UniqueFungibleCall<()>, false);274275impl<T: Config> CommonEvmHandler for FungibleHandle<T>276where277 T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,278{279 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueFungible.raw");280281 fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {282 call::<T, UniqueFungibleCall<T>, _, _>(handle, self)283 }284}pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -24,15 +24,7 @@
char::{REPLACEMENT_CHARACTER, decode_utf16},
convert::TryInto,
};
-use evm_coder::{
- ToLog,
- execution::*,
- generate_stubgen, solidity, solidity_interface,
- types::*,
- weight,
- custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},
- make_signature,
-};
+use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
use frame_support::BoundedVec;
use up_data_structs::{
TokenId, PropertyPermission, PropertyKeyPermission, Property, CollectionId, PropertyKey,
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -25,15 +25,7 @@
char::{REPLACEMENT_CHARACTER, decode_utf16},
convert::TryInto,
};
-use evm_coder::{
- ToLog,
- execution::*,
- generate_stubgen, solidity, solidity_interface,
- types::*,
- weight,
- custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},
- make_signature,
-};
+use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
use frame_support::{BoundedBTreeMap, BoundedVec};
use pallet_common::{
CollectionHandle, CollectionPropertyPermissions,
pallets/refungible/src/erc_token.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -29,15 +29,7 @@
convert::TryInto,
ops::Deref,
};
-use evm_coder::{
- ToLog,
- execution::*,
- generate_stubgen, solidity_interface,
- types::*,
- weight,
- custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},
- make_signature,
-};
+use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};
use pallet_common::{
CommonWeightInfo,
erc::{CommonEvmHandler, PrecompileResult},
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -18,13 +18,7 @@
use core::marker::PhantomData;
use ethereum as _;
-use evm_coder::{
- execution::*,
- generate_stubgen, solidity, solidity_interface,
- types::*,
- custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},
- make_signature, weight,
-};
+use evm_coder::{execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
use frame_support::traits::Get;
use crate::Pallet;