difftreelog
refactor reuse code generation patterns
in: master
22 files changed
crates/evm-coder/procedural/src/abi_derive/derive_enum.rsdiffbeforeafterboth--- a/crates/evm-coder/procedural/src/abi_derive/derive_enum.rs
+++ b/crates/evm-coder/procedural/src/abi_derive/derive_enum.rs
@@ -1,20 +1,52 @@
use quote::quote;
+use super::extract_docs;
+
pub fn impl_solidity_option<'a>(
+ docs: Vec<String>,
name: &proc_macro2::Ident,
- enum_options: impl Iterator<Item = &'a syn::Ident>,
+ enum_options: impl Iterator<Item = &'a syn::Variant> + Clone,
) -> proc_macro2::TokenStream {
- let enum_options = enum_options.map(|opt| {
+ let variant_names = enum_options.clone().map(|opt| {
+ let opt = &opt.ident;
let s = name.to_string() + "." + opt.to_string().as_str();
let as_string = proc_macro2::Literal::string(s.as_str());
quote!(#name::#opt => #as_string,)
});
+ let solidity_name = name.to_string();
+
+ let solidity_fields = enum_options.map(|v| {
+ let docs = extract_docs(&v.attrs).expect("TODO: handle bad docs");
+ let name = v.ident.to_string();
+ quote! {
+ SolidityEnumVariant {
+ docs: &[#(#docs),*],
+ name: #name,
+ }
+ }
+ });
+
quote!(
#[cfg(feature = "stubgen")]
- impl ::evm_coder::solidity::SolidityEnum for #name {
+ impl ::evm_coder::solidity::SolidityEnumTy for #name {
+ fn generate_solidity_interface(tc: &evm_coder::solidity::TypeCollector) -> String {
+ use evm_coder::solidity::*;
+ use core::fmt::Write;
+ let interface = SolidityEnum {
+ docs: &[#(#docs),*],
+ name: #solidity_name,
+ fields: &[#(
+ #solidity_fields,
+ )*],
+ };
+ let mut out = String::new();
+ let _ = interface.format(&mut out, tc);
+ tc.collect(out);
+ #solidity_name.to_string()
+ }
fn solidity_option(&self) -> &str {
match self {
- #(#enum_options)*
+ #(#variant_names)*
}
}
}
@@ -23,11 +55,12 @@
pub fn impl_enum_from_u8<'a>(
name: &proc_macro2::Ident,
- enum_options: impl Iterator<Item = &'a syn::Ident>,
+ enum_options: impl Iterator<Item = &'a syn::Variant>,
) -> proc_macro2::TokenStream {
let error_str = format!("Value not convertible into enum \"{name}\"");
let error_str = proc_macro2::Literal::string(&error_str);
let enum_options = enum_options.enumerate().map(|(i, opt)| {
+ let opt = &opt.ident;
let n = proc_macro2::Literal::u8_suffixed(i as u8);
quote! {#n => Ok(#name::#opt),}
});
@@ -83,21 +116,6 @@
}
}
)
-}
-
-pub fn impl_enum_solidity_type<'a>(name: &syn::Ident) -> proc_macro2::TokenStream {
- quote! {
- #[cfg(feature = "stubgen")]
- impl ::evm_coder::solidity::SolidityType for #name {
- fn names(tc: &::evm_coder::solidity::TypeCollector) -> Vec<String> {
- Vec::new()
- }
-
- fn len() -> usize {
- 1
- }
- }
- }
}
pub fn impl_enum_solidity_type_name(name: &syn::Ident) -> proc_macro2::TokenStream {
@@ -108,7 +126,7 @@
writer: &mut impl ::core::fmt::Write,
tc: &::evm_coder::solidity::TypeCollector,
) -> ::core::fmt::Result {
- write!(writer, "{}", tc.collect_struct::<Self>())
+ write!(writer, "{}", tc.collect_enum::<Self>())
}
fn is_simple() -> bool {
@@ -119,49 +137,7 @@
writer: &mut impl ::core::fmt::Write,
tc: &::evm_coder::solidity::TypeCollector,
) -> ::core::fmt::Result {
- write!(writer, "{}", <#name as ::evm_coder::solidity::SolidityEnum>::solidity_option(&<#name>::default()))
- }
- }
- )
-}
-
-pub fn impl_enum_solidity_struct_collect<'a>(
- name: &syn::Ident,
- enum_options: impl Iterator<Item = &'a syn::Ident>,
- option_count: usize,
- enum_options_docs: impl Iterator<Item = syn::Result<Vec<proc_macro2::TokenStream>>>,
- docs: &[proc_macro2::TokenStream],
-) -> proc_macro2::TokenStream {
- let string_name = name.to_string();
- let enum_options = enum_options
- .zip(enum_options_docs)
- .enumerate()
- .map(|(i, (opt, doc))| {
- let opt = proc_macro2::Literal::string(opt.to_string().as_str());
- let doc = doc.expect("Doc parsing error");
- let comma = if i != option_count - 1 { "," } else { "" };
- quote! {
- #(#doc)*
- writeln!(str, "\t{}{}", #opt, #comma).expect("Enum format option");
- }
- });
-
- quote!(
- #[cfg(feature = "stubgen")]
- impl ::evm_coder::solidity::StructCollect for #name {
- fn name() -> String {
- #string_name.into()
- }
-
- fn declaration() -> String {
- use std::fmt::Write;
-
- let mut str = String::new();
- #(#docs)*
- writeln!(str, "enum {} {{", <Self as ::evm_coder::solidity::StructCollect>::name()).unwrap();
- #(#enum_options)*
- writeln!(str, "}}").unwrap();
- str
+ write!(writer, "{}", <#name as ::evm_coder::solidity::SolidityEnumTy>::solidity_option(&<#name>::default()))
}
}
)
crates/evm-coder/procedural/src/abi_derive/derive_struct.rsdiffbeforeafterboth1use super::extract_docs;2use quote::quote;34pub fn tuple_type<'a>(5 field_types: impl Iterator<Item = &'a syn::Type> + Clone,6) -> proc_macro2::TokenStream {7 let field_types = field_types.map(|ty| quote!(#ty,));8 quote! {(#(#field_types)*)}9}1011pub fn tuple_ref_type<'a>(12 field_types: impl Iterator<Item = &'a syn::Type> + Clone,13) -> proc_macro2::TokenStream {14 let field_types = field_types.map(|ty| quote!(&#ty,));15 quote! {(#(#field_types)*)}16}1718pub fn tuple_data_as_ref(19 is_named_fields: bool,20 field_names: impl Iterator<Item = syn::Ident> + Clone,21) -> proc_macro2::TokenStream {22 let field_names = field_names.enumerate().map(|(i, field)| {23 if is_named_fields {24 quote!(&self.#field,)25 } else {26 let field = proc_macro2::Literal::usize_unsuffixed(i);27 quote!(&self.#field,)28 }29 });30 quote! {(#(#field_names)*)}31}3233pub fn tuple_names(34 is_named_fields: bool,35 field_names: impl Iterator<Item = syn::Ident> + Clone,36) -> proc_macro2::TokenStream {37 let field_names = field_names.enumerate().map(|(i, field)| {38 if is_named_fields {39 quote!(#field,)40 } else {41 let field = proc_macro2::Ident::new(42 format!("field{}", i).as_str(),43 proc_macro2::Span::call_site(),44 );45 quote!(#field,)46 }47 });48 quote! {(#(#field_names)*)}49}5051pub fn struct_from_tuple(52 name: &syn::Ident,53 is_named_fields: bool,54 field_names: impl Iterator<Item = syn::Ident> + Clone,55) -> proc_macro2::TokenStream {56 let field_names = field_names.enumerate().map(|(i, field)| {57 if is_named_fields {58 quote!(#field,)59 } else {60 let field = proc_macro2::Ident::new(61 format!("field{}", i).as_str(),62 proc_macro2::Span::call_site(),63 );64 quote!(#field,)65 }66 });6768 if is_named_fields {69 quote! {#name {#(#field_names)*}}70 } else {71 quote! {#name (#(#field_names)*)}72 }73}7475pub fn map_field_to_name(field: (usize, &syn::Field)) -> syn::Ident {76 match field.1.ident.as_ref() {77 Some(name) => name.clone(),78 None => {79 let mut name = "field".to_string();80 name.push_str(field.0.to_string().as_str());81 syn::Ident::new(name.as_str(), proc_macro2::Span::call_site())82 }83 }84}8586pub fn map_field_to_type(field: &syn::Field) -> &syn::Type {87 &field.ty88}8990pub fn map_field_to_doc(field: &syn::Field) -> syn::Result<Vec<proc_macro2::TokenStream>> {91 extract_docs(&field.attrs, true)92}9394pub fn impl_can_be_placed_in_vec(ident: &syn::Ident) -> proc_macro2::TokenStream {95 quote! {96 impl ::evm_coder::sealed::CanBePlacedInVec for #ident {}97 }98}99100pub fn impl_struct_abi_type(101 name: &syn::Ident,102 tuple_type: proc_macro2::TokenStream,103) -> proc_macro2::TokenStream {104 quote! {105 impl ::evm_coder::abi::AbiType for #name {106 const SIGNATURE: ::evm_coder::custom_signature::SignatureUnit = <#tuple_type as ::evm_coder::abi::AbiType>::SIGNATURE;107 fn is_dynamic() -> bool {108 <#tuple_type as ::evm_coder::abi::AbiType>::is_dynamic()109 }110 fn size() -> usize {111 <#tuple_type as ::evm_coder::abi::AbiType>::size()112 }113 }114 }115}116117pub fn impl_struct_abi_read(118 name: &syn::Ident,119 tuple_type: proc_macro2::TokenStream,120 tuple_names: proc_macro2::TokenStream,121 struct_from_tuple: proc_macro2::TokenStream,122) -> proc_macro2::TokenStream {123 quote!(124 impl ::evm_coder::abi::AbiRead for #name {125 fn abi_read(reader: &mut ::evm_coder::abi::AbiReader) -> ::evm_coder::execution::Result<Self> {126 let #tuple_names = <#tuple_type as ::evm_coder::abi::AbiRead>::abi_read(reader)?;127 Ok(#struct_from_tuple)128 }129 }130 )131}132133pub fn impl_struct_abi_write(134 name: &syn::Ident,135 _is_named_fields: bool,136 tuple_type: proc_macro2::TokenStream,137 tuple_data: proc_macro2::TokenStream,138) -> proc_macro2::TokenStream {139 quote!(140 impl ::evm_coder::abi::AbiWrite for #name {141 fn abi_write(&self, writer: &mut ::evm_coder::abi::AbiWriter) {142 <#tuple_type as ::evm_coder::abi::AbiWrite>::abi_write(&#tuple_data, writer)143 }144 }145 )146}147148pub fn impl_struct_solidity_type<'a>(149 name: &syn::Ident,150 field_types: impl Iterator<Item = &'a syn::Type> + Clone,151 params_count: usize,152) -> proc_macro2::TokenStream {153 let len = proc_macro2::Literal::usize_suffixed(params_count);154 quote! {155 #[cfg(feature = "stubgen")]156 impl ::evm_coder::solidity::SolidityType for #name {157 fn names(tc: &::evm_coder::solidity::TypeCollector) -> Vec<String> {158 let mut collected =159 Vec::with_capacity(<Self as ::evm_coder::solidity::SolidityType>::len());160 #({161 let mut out = String::new();162 <#field_types as ::evm_coder::solidity::SolidityTypeName>::solidity_name(&mut out, tc)163 .expect("no fmt error");164 collected.push(out);165 })*166 collected167 }168169 fn len() -> usize {170 #len171 }172 }173 }174}175176pub fn impl_struct_solidity_type_name<'a>(177 name: &syn::Ident,178 field_types: impl Iterator<Item = &'a syn::Type> + Clone,179 params_count: usize,180) -> proc_macro2::TokenStream {181 let arg_dafaults = field_types.enumerate().map(|(i, ty)| {182 let mut defult_value = quote!(<#ty as ::evm_coder::solidity::SolidityTypeName183 >::solidity_default(writer, tc)?;);184 let last_item = params_count - 1;185 if i != last_item {186 defult_value.extend(quote! {write!(writer, ",")?;})187 }188 defult_value189 });190191 quote! {192 #[cfg(feature = "stubgen")]193 impl ::evm_coder::solidity::SolidityTypeName for #name {194 fn solidity_name(195 writer: &mut impl ::core::fmt::Write,196 tc: &::evm_coder::solidity::TypeCollector,197 ) -> ::core::fmt::Result {198 write!(writer, "{}", tc.collect_struct::<Self>())199 }200201 fn is_simple() -> bool {202 false203 }204205 fn solidity_default(206 writer: &mut impl ::core::fmt::Write,207 tc: &::evm_coder::solidity::TypeCollector,208 ) -> ::core::fmt::Result {209 write!(writer, "{}(", tc.collect_struct::<Self>())?;210211 #(#arg_dafaults)*212213 write!(writer, ")")214 }215 }216 }217}218219pub fn impl_struct_solidity_struct_collect<'a>(220 name: &syn::Ident,221 field_names: impl Iterator<Item = proc_macro2::Ident> + Clone,222 field_types: impl Iterator<Item = &'a syn::Type> + Clone,223 field_docs: impl Iterator<Item = syn::Result<Vec<proc_macro2::TokenStream>>> + Clone,224 docs: &[proc_macro2::TokenStream],225) -> syn::Result<proc_macro2::TokenStream> {226 let string_name = name.to_string();227 let name_type = field_names228 .into_iter()229 .zip(field_types)230 .zip(field_docs)231 .map(|((name, ty), doc)| {232 let field_docs = doc.expect("Doc parse error");233 let name = format!("{}", name);234 quote!(235 #(#field_docs)*236 write!(str, "\t{} ", <#ty as ::evm_coder::solidity::StructCollect>::name()).unwrap();237 writeln!(str, "{};", #name).unwrap();238 )239 });240241 Ok(quote! {242 #[cfg(feature = "stubgen")]243 impl ::evm_coder::solidity::StructCollect for #name {244 fn name() -> String {245 #string_name.into()246 }247248 fn declaration() -> String {249 use std::fmt::Write;250251 let mut str = String::new();252 #(#docs)*253 writeln!(str, "struct {} {{", Self::name()).unwrap();254 #(#name_type)*255 writeln!(str, "}}").unwrap();256 str257 }258 }259 })260}1use super::extract_docs;2use quote::quote;3use syn::Field;45pub fn tuple_type<'a>(6 field_types: impl Iterator<Item = &'a syn::Type> + Clone,7) -> proc_macro2::TokenStream {8 let field_types = field_types.map(|ty| quote!(#ty,));9 quote! {(#(#field_types)*)}10}1112pub fn tuple_ref_type<'a>(13 field_types: impl Iterator<Item = &'a syn::Type> + Clone,14) -> proc_macro2::TokenStream {15 let field_types = field_types.map(|ty| quote!(&#ty,));16 quote! {(#(#field_types)*)}17}1819pub fn tuple_data_as_ref(20 is_named_fields: bool,21 field_names: impl Iterator<Item = syn::Ident> + Clone,22) -> proc_macro2::TokenStream {23 let field_names = field_names.enumerate().map(|(i, field)| {24 if is_named_fields {25 quote!(&self.#field,)26 } else {27 let field = proc_macro2::Literal::usize_unsuffixed(i);28 quote!(&self.#field,)29 }30 });31 quote! {(#(#field_names)*)}32}3334pub fn tuple_names(35 is_named_fields: bool,36 field_names: impl Iterator<Item = syn::Ident> + Clone,37) -> proc_macro2::TokenStream {38 let field_names = field_names.enumerate().map(|(i, field)| {39 if is_named_fields {40 quote!(#field,)41 } else {42 let field = proc_macro2::Ident::new(43 format!("field{}", i).as_str(),44 proc_macro2::Span::call_site(),45 );46 quote!(#field,)47 }48 });49 quote! {(#(#field_names)*)}50}5152pub fn struct_from_tuple(53 name: &syn::Ident,54 is_named_fields: bool,55 field_names: impl Iterator<Item = syn::Ident> + Clone,56) -> proc_macro2::TokenStream {57 let field_names = field_names.enumerate().map(|(i, field)| {58 if is_named_fields {59 quote!(#field,)60 } else {61 let field = proc_macro2::Ident::new(62 format!("field{}", i).as_str(),63 proc_macro2::Span::call_site(),64 );65 quote!(#field,)66 }67 });6869 if is_named_fields {70 quote! {#name {#(#field_names)*}}71 } else {72 quote! {#name (#(#field_names)*)}73 }74}7576pub fn map_field_to_name(field: (usize, &syn::Field)) -> syn::Ident {77 match field.1.ident.as_ref() {78 Some(name) => name.clone(),79 None => {80 let mut name = "field".to_string();81 name.push_str(field.0.to_string().as_str());82 syn::Ident::new(name.as_str(), proc_macro2::Span::call_site())83 }84 }85}8687pub fn map_field_to_type(field: &syn::Field) -> &syn::Type {88 &field.ty89}9091pub fn impl_can_be_placed_in_vec(ident: &syn::Ident) -> proc_macro2::TokenStream {92 quote! {93 impl ::evm_coder::sealed::CanBePlacedInVec for #ident {}94 }95}9697pub fn impl_struct_abi_type(98 name: &syn::Ident,99 tuple_type: proc_macro2::TokenStream,100) -> proc_macro2::TokenStream {101 quote! {102 impl ::evm_coder::abi::AbiType for #name {103 const SIGNATURE: ::evm_coder::custom_signature::SignatureUnit = <#tuple_type as ::evm_coder::abi::AbiType>::SIGNATURE;104 fn is_dynamic() -> bool {105 <#tuple_type as ::evm_coder::abi::AbiType>::is_dynamic()106 }107 fn size() -> usize {108 <#tuple_type as ::evm_coder::abi::AbiType>::size()109 }110 }111 }112}113114pub fn impl_struct_abi_read(115 name: &syn::Ident,116 tuple_type: proc_macro2::TokenStream,117 tuple_names: proc_macro2::TokenStream,118 struct_from_tuple: proc_macro2::TokenStream,119) -> proc_macro2::TokenStream {120 quote!(121 impl ::evm_coder::abi::AbiRead for #name {122 fn abi_read(reader: &mut ::evm_coder::abi::AbiReader) -> ::evm_coder::execution::Result<Self> {123 let #tuple_names = <#tuple_type as ::evm_coder::abi::AbiRead>::abi_read(reader)?;124 Ok(#struct_from_tuple)125 }126 }127 )128}129130pub fn impl_struct_abi_write(131 name: &syn::Ident,132 _is_named_fields: bool,133 tuple_type: proc_macro2::TokenStream,134 tuple_data: proc_macro2::TokenStream,135) -> proc_macro2::TokenStream {136 quote!(137 impl ::evm_coder::abi::AbiWrite for #name {138 fn abi_write(&self, writer: &mut ::evm_coder::abi::AbiWriter) {139 <#tuple_type as ::evm_coder::abi::AbiWrite>::abi_write(&#tuple_data, writer)140 }141 }142 )143}144145pub fn impl_struct_solidity_type<'a>(146 name: &syn::Ident,147 docs: Vec<String>,148 fields: impl Iterator<Item = &'a Field> + Clone,149) -> proc_macro2::TokenStream {150 let solidity_name = name.to_string();151 let solidity_fields = fields.enumerate().map(|(i, f)| {152 let name = f153 .ident154 .as_ref()155 .map(|i| i.to_string())156 .unwrap_or_else(|| format!("field_{i}"));157 let ty = &f.ty;158 let docs = extract_docs(&f.attrs).expect("TODO: handle bad docs");159 quote! {160 SolidityStructField::<#ty> {161 docs: &[#(#docs),*],162 name: #name,163 ty: ::core::marker::PhantomData,164 }165 }166 });167 quote! {168 #[cfg(feature = "stubgen")]169 impl ::evm_coder::solidity::SolidityStructTy for #name {170 /// Generate solidity definitions for methods described in this struct171 fn generate_solidity_interface(tc: &evm_coder::solidity::TypeCollector) -> String {172 use evm_coder::solidity::*;173 use core::fmt::Write;174 let interface = SolidityStruct {175 docs: &[#(#docs),*],176 name: #solidity_name,177 fields: (#(178 #solidity_fields,179 )*),180 };181 let mut out = String::new();182 let _ = interface.format(&mut out, tc);183 tc.collect(out);184 #solidity_name.to_string()185 }186 }187 }188}189190pub fn impl_struct_solidity_type_name<'a>(191 name: &syn::Ident,192 field_types: impl Iterator<Item = &'a syn::Type> + Clone,193 params_count: usize,194) -> proc_macro2::TokenStream {195 let arg_dafaults = field_types.enumerate().map(|(i, ty)| {196 let mut defult_value = quote!(<#ty as ::evm_coder::solidity::SolidityTypeName197 >::solidity_default(writer, tc)?;);198 let last_item = params_count - 1;199 if i != last_item {200 defult_value.extend(quote! {write!(writer, ",")?;})201 }202 defult_value203 });204205 quote! {206 #[cfg(feature = "stubgen")]207 impl ::evm_coder::solidity::SolidityTypeName for #name {208 fn solidity_name(209 writer: &mut impl ::core::fmt::Write,210 tc: &::evm_coder::solidity::TypeCollector,211 ) -> ::core::fmt::Result {212 write!(writer, "{}", tc.collect_struct::<Self>())213 }214215 fn is_simple() -> bool {216 false217 }218219 fn solidity_default(220 writer: &mut impl ::core::fmt::Write,221 tc: &::evm_coder::solidity::TypeCollector,222 ) -> ::core::fmt::Result {223 write!(writer, "{}(", tc.collect_struct::<Self>())?;224225 #(#arg_dafaults)*226227 write!(writer, ")")228 }229 }230 }231}crates/evm-coder/procedural/src/abi_derive/mod.rsdiffbeforeafterboth--- a/crates/evm-coder/procedural/src/abi_derive/mod.rs
+++ b/crates/evm-coder/procedural/src/abi_derive/mod.rs
@@ -19,20 +19,18 @@
ast: &syn::DeriveInput,
) -> syn::Result<proc_macro2::TokenStream> {
let name = &ast.ident;
- let docs = extract_docs(&ast.attrs, false)?;
- let (is_named_fields, field_names, field_types, field_docs, params_count) = match ds.fields {
+ let docs = extract_docs(&ast.attrs)?;
+ let (is_named_fields, field_names, field_types, params_count) = match ds.fields {
syn::Fields::Named(ref fields) => Ok((
true,
fields.named.iter().enumerate().map(map_field_to_name),
fields.named.iter().map(map_field_to_type),
- fields.named.iter().map(map_field_to_doc),
fields.named.len(),
)),
syn::Fields::Unnamed(ref fields) => Ok((
false,
fields.unnamed.iter().enumerate().map(map_field_to_name),
fields.unnamed.iter().map(map_field_to_type),
- fields.unnamed.iter().map(map_field_to_doc),
fields.unnamed.len(),
)),
syn::Fields::Unit => Err(syn::Error::new(name.span(), "Unit structs not supported")),
@@ -52,11 +50,9 @@
let abi_type = impl_struct_abi_type(name, tuple_type.clone());
let abi_read = impl_struct_abi_read(name, tuple_type, tuple_names, struct_from_tuple);
let abi_write = impl_struct_abi_write(name, is_named_fields, tuple_ref_type, tuple_data);
- let solidity_type = impl_struct_solidity_type(name, field_types.clone(), params_count);
+ let solidity_type = impl_struct_solidity_type(name, docs, ds.fields.iter());
let solidity_type_name =
impl_struct_solidity_type_name(name, field_types.clone(), params_count);
- let solidity_struct_collect =
- impl_struct_solidity_struct_collect(name, field_names, field_types, field_docs, &docs)?;
Ok(quote! {
#can_be_plcaed_in_vec
@@ -65,7 +61,6 @@
#abi_write
#solidity_type
#solidity_type_name
- #solidity_struct_collect
})
}
@@ -75,26 +70,16 @@
) -> syn::Result<proc_macro2::TokenStream> {
let name = &ast.ident;
check_repr_u8(name, &ast.attrs)?;
- let docs = extract_docs(&ast.attrs, false)?;
- let option_count = check_and_count_options(de)?;
- let enum_options = de.variants.iter().map(|v| &v.ident);
- let enum_options_docs = de.variants.iter().map(|v| extract_docs(&v.attrs, true));
+ let docs = extract_docs(&ast.attrs)?;
+ let enum_options = de.variants.iter();
let from = impl_enum_from_u8(name, enum_options.clone());
- let solidity_option = impl_solidity_option(name, enum_options.clone());
+ let solidity_option = impl_solidity_option(docs, name, enum_options.clone());
let can_be_plcaed_in_vec = impl_can_be_placed_in_vec(name);
let abi_type = impl_enum_abi_type(name);
let abi_read = impl_enum_abi_read(name);
let abi_write = impl_enum_abi_write(name);
- let solidity_type = impl_enum_solidity_type(name);
let solidity_type_name = impl_enum_solidity_type_name(name);
- let solidity_struct_collect = impl_enum_solidity_struct_collect(
- name,
- enum_options,
- option_count,
- enum_options_docs,
- &docs,
- );
Ok(quote! {
#from
@@ -103,16 +88,11 @@
#abi_type
#abi_read
#abi_write
- #solidity_type
#solidity_type_name
- #solidity_struct_collect
})
}
-fn extract_docs(
- attrs: &[syn::Attribute],
- is_field_doc: bool,
-) -> syn::Result<Vec<proc_macro2::TokenStream>> {
+fn extract_docs(attrs: &[syn::Attribute]) -> syn::Result<Vec<String>> {
attrs
.iter()
.filter_map(|attr| {
@@ -132,16 +112,6 @@
}
}
None
- })
- .enumerate()
- .map(|(i, doc)| {
- let doc = doc?;
- let doc = doc.trim();
- let dev = if i == 0 { " @dev" } else { "" };
- let tab = if is_field_doc { "\t" } else { "" };
- Ok(quote! {
- writeln!(str, "{}///{} {}", #tab, #dev, #doc).unwrap();
- })
})
.collect()
}
crates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth--- a/crates/evm-coder/src/solidity/impls.rs
+++ b/crates/evm-coder/src/solidity/impls.rs
@@ -1,4 +1,4 @@
-use super::{TypeCollector, SolidityTypeName, SolidityType, StructCollect};
+use super::{TypeCollector, SolidityTypeName, SolidityTupleTy};
use crate::{sealed, types::*};
use core::fmt;
use primitive_types::{U256, H160};
@@ -17,16 +17,6 @@
write!(writer, $default)
}
}
-
- impl StructCollect for $ty {
- fn name() -> String {
- $name.to_string()
- }
-
- fn declaration() -> String {
- String::default()
- }
- }
)*
};
}
@@ -71,17 +61,7 @@
write!(writer, "new ")?;
T::solidity_name(writer, tc)?;
write!(writer, "[](0)")
- }
-}
-
-impl<T: StructCollect + sealed::CanBePlacedInVec> StructCollect for Vec<T> {
- fn name() -> String {
- <T as StructCollect>::name() + "[]"
}
-
- fn declaration() -> String {
- unimplemented!("Vectors have not declarations.")
- }
}
macro_rules! count {
@@ -91,8 +71,8 @@
macro_rules! impl_tuples {
($($ident:ident)+) => {
- impl<$($ident: SolidityTypeName + 'static),+> SolidityType for ($($ident,)+) {
- fn names(tc: &TypeCollector) -> Vec<string> {
+ impl<$($ident: SolidityTypeName + 'static),+> SolidityTupleTy for ($($ident,)+) {
+ fn fields(tc: &TypeCollector) -> Vec<string> {
let mut collected = Vec::with_capacity(Self::len());
$({
let mut out = string::new();
crates/evm-coder/src/solidity/mod.rsdiffbeforeafterboth--- a/crates/evm-coder/src/solidity/mod.rs
+++ b/crates/evm-coder/src/solidity/mod.rs
@@ -44,6 +44,7 @@
/// id ordering is required to perform topo-sort on the resulting data
structs: RefCell<BTreeMap<string, usize>>,
anonymous: RefCell<BTreeMap<Vec<string>, usize>>,
+ // generic: RefCell<BTreeMap<string, usize>>,
id: Cell<usize>,
}
impl TypeCollector {
@@ -59,8 +60,9 @@
self.id.set(v + 1);
v
}
- pub fn collect_tuple<T: SolidityType>(&self) -> String {
- let names = T::names(self);
+ /// Collect typle, deduplicating it by type, and returning generated name
+ pub fn collect_tuple<T: SolidityTupleTy>(&self) -> String {
+ let names = T::fields(self);
if let Some(id) = self.anonymous.borrow().get(&names).cloned() {
return format!("Tuple{}", id);
}
@@ -76,11 +78,12 @@
self.anonymous.borrow_mut().insert(names, id);
format!("Tuple{}", id)
}
- pub fn collect_struct<T: StructCollect + SolidityType>(&self) -> String {
- let _names = T::names(self);
- self.collect(<T as StructCollect>::declaration());
- <T as StructCollect>::name()
+ pub fn collect_struct<T: SolidityStructTy>(&self) -> String {
+ T::generate_solidity_interface(self)
}
+ pub fn collect_enum<T: SolidityEnumTy>(&self) -> String {
+ T::generate_solidity_interface(self)
+ }
pub fn finish(self) -> Vec<string> {
let mut data = self.structs.into_inner().into_iter().collect::<Vec<_>>();
data.sort_by_key(|(_, id)| Reverse(*id));
@@ -420,3 +423,93 @@
writeln!(writer, ");")
}
}
+
+#[impl_for_tuples(0, 48)]
+impl SolidityItems for Tuple {
+ for_tuples!( where #( Tuple: SolidityItems ),* );
+
+ fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
+ for_tuples!( #(
+ Tuple.solidity_name(writer, tc)?;
+ )* );
+ Ok(())
+ }
+}
+
+pub struct SolidityStructField<T> {
+ pub docs: &'static [&'static str],
+ pub name: &'static str,
+ pub ty: PhantomData<*const T>,
+}
+
+impl<T> SolidityItems for SolidityStructField<T>
+where
+ T: SolidityTypeName,
+{
+ fn solidity_name(&self, out: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
+ for doc in self.docs {
+ writeln!(out, "///{}", doc)?;
+ }
+ write!(out, "\t")?;
+ T::solidity_name(out, tc)?;
+ writeln!(out, " {};", self.name)?;
+ Ok(())
+ }
+}
+pub struct SolidityStruct<F> {
+ pub docs: &'static [&'static str],
+ // pub generics:
+ pub name: &'static str,
+ pub fields: F,
+}
+impl<F> SolidityStruct<F>
+where
+ F: SolidityItems,
+{
+ pub fn format(&self, out: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
+ for doc in self.docs {
+ writeln!(out, "///{}", doc)?;
+ }
+ writeln!(out, "struct {} {{", self.name)?;
+ self.fields.solidity_name(out, tc)?;
+ writeln!(out, "}}")?;
+ Ok(())
+ }
+}
+
+pub struct SolidityEnumVariant {
+ pub docs: &'static [&'static str],
+ pub name: &'static str,
+}
+impl SolidityItems for SolidityEnumVariant {
+ fn solidity_name(&self, out: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {
+ for doc in self.docs {
+ writeln!(out, "///{}", doc)?;
+ }
+ write!(out, "\t{}", self.name)?;
+ Ok(())
+ }
+}
+pub struct SolidityEnum {
+ pub docs: &'static [&'static str],
+ pub name: &'static str,
+ pub fields: &'static [SolidityEnumVariant],
+}
+impl SolidityEnum {
+ pub fn format(&self, out: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
+ for doc in self.docs {
+ writeln!(out, "///{}", doc)?;
+ }
+ write!(out, "enum {} {{", self.name)?;
+ for (i, field) in self.fields.iter().enumerate() {
+ if i != 0 {
+ write!(out, ",")?;
+ }
+ writeln!(out)?;
+ field.solidity_name(out, tc)?;
+ }
+ writeln!(out)?;
+ writeln!(out, "}}")?;
+ Ok(())
+ }
+}
crates/evm-coder/src/solidity/traits.rsdiffbeforeafterboth--- a/crates/evm-coder/src/solidity/traits.rs
+++ b/crates/evm-coder/src/solidity/traits.rs
@@ -1,17 +1,6 @@
use super::TypeCollector;
use core::fmt;
-pub trait StructCollect: 'static {
- /// Structure name.
- fn name() -> String;
- /// Structure declaration.
- fn declaration() -> String;
-}
-
-pub trait SolidityEnum: 'static {
- fn solidity_option(&self) -> &str;
-}
-
pub trait SolidityTypeName: 'static {
fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;
/// "simple" types are stored inline, no `memory` modifier should be used in solidity
@@ -23,10 +12,17 @@
}
}
-pub trait SolidityType {
- fn names(tc: &TypeCollector) -> Vec<String>;
+pub trait SolidityTupleTy: 'static {
+ fn fields(tc: &TypeCollector) -> Vec<String>;
fn len() -> usize;
}
+pub trait SolidityStructTy: 'static {
+ fn generate_solidity_interface(tc: &TypeCollector) -> String;
+}
+pub trait SolidityEnumTy: 'static {
+ fn generate_solidity_interface(tc: &TypeCollector) -> String;
+ fn solidity_option(&self) -> &str;
+}
pub trait SolidityArguments {
fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;
@@ -46,3 +42,9 @@
tc: &TypeCollector,
) -> fmt::Result;
}
+
+pub trait SolidityItems {
+ fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;
+ // For PhantomData fields
+ // fn is_void()
+}
crates/evm-coder/tests/abi_derive_generation.rsdiffbeforeafterboth--- a/crates/evm-coder/tests/abi_derive_generation.rs
+++ b/crates/evm-coder/tests/abi_derive_generation.rs
@@ -74,41 +74,6 @@
}
#[test]
- #[cfg(feature = "stubgen")]
- fn struct_collect_type_struct3_derived_mixed_param() {
- assert_eq!(
- <TypeStruct3DerivedMixedParam as ::evm_coder::solidity::StructCollect>::name(),
- "TypeStruct3DerivedMixedParam"
- );
- similar_asserts::assert_eq!(
- <TypeStruct3DerivedMixedParam as ::evm_coder::solidity::StructCollect>::declaration(),
- r#"/// @dev Some docs
-/// At multi
-/// line
-struct TypeStruct3DerivedMixedParam {
- /// @dev Docs for A
- /// multi
- /// line
- TypeStruct1SimpleParam _a;
- /// @dev Docs for B
- TypeStruct2DynamicParam _b;
- /// @dev Docs for C
- TypeStruct2MixedParam _c;
-}
-"#
- );
- }
-
- #[test]
- #[cfg(feature = "stubgen")]
- fn struct_collect_vec() {
- assert_eq!(
- <Vec<u8> as ::evm_coder::solidity::StructCollect>::name(),
- "uint8[]"
- );
- }
-
- #[test]
fn impl_abi_type_signature() {
assert_eq!(
<TypeStruct1SimpleParam as evm_coder::abi::AbiType>::SIGNATURE
@@ -303,31 +268,6 @@
);
#[test]
- #[cfg(feature = "stubgen")]
- fn struct_collect_tuple_struct3_derived_mixed_param() {
- assert_eq!(
- <TupleStruct3DerivedMixedParam as ::evm_coder::solidity::StructCollect>::name(),
- "TupleStruct3DerivedMixedParam"
- );
- similar_asserts::assert_eq!(
- <TupleStruct3DerivedMixedParam as ::evm_coder::solidity::StructCollect>::declaration(),
- r#"/// @dev Some docs
-/// At multi
-/// line
-struct TupleStruct3DerivedMixedParam {
- /// @dev Docs for A
- /// multi
- /// line
- TupleStruct1SimpleParam field0;
- TupleStruct2DynamicParam field1;
- /// @dev Docs for C
- TupleStruct2MixedParam field2;
-}
-"#
- );
- }
-
- #[test]
fn impl_abi_type_signature_same_for_structs() {
assert_eq!(
<TypeStruct1SimpleParam as evm_coder::abi::AbiType>::SIGNATURE
@@ -821,30 +761,5 @@
<Color as evm_coder::abi::AbiRead>::abi_read(&mut decoder).unwrap();
assert_eq!(restored_enum_data, Color::Green);
}
- }
-
- #[test]
- #[cfg(feature = "stubgen")]
- fn struct_collect_enum() {
- assert_eq!(
- <Color as ::evm_coder::solidity::StructCollect>::name(),
- "Color"
- );
- similar_asserts::assert_eq!(
- <Color as ::evm_coder::solidity::StructCollect>::declaration(),
- r#"/// @dev Some docs
-/// At multi
-/// line
-enum Color {
- /// @dev Docs for Red
- /// multi
- /// line
- Red,
- Green,
- /// @dev Docs for Blue
- Blue
-}
-"#
- );
}
}
pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
+++ b/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
@@ -265,13 +265,13 @@
}
}
-/// @dev Cross account struct
+/// Cross account struct
struct CrossAddress {
address eth;
uint256 sub;
}
-/// @dev Ethereum representation of Optional value with CrossAddress.
+/// Ethereum representation of Optional value with CrossAddress.
struct OptionCrossAddress {
bool status;
CrossAddress value;
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -437,67 +437,67 @@
}
}
-/// @dev Cross account struct
+/// Cross account struct
struct CrossAddress {
address eth;
uint256 sub;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
bool value;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
enum CollectionPermissionField {
- /// @dev Owner of token can nest tokens under it.
+ /// Owner of token can nest tokens under it.
TokenOwner,
- /// @dev Admin of token collection can nest tokens under token.
+ /// Admin of token collection can nest tokens under token.
CollectionAdmin
}
-/// @dev Nested collections.
+/// Nested collections.
struct CollectionNesting {
bool token_owner;
uint256[] ids;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
struct CollectionLimit {
CollectionLimitField field;
OptionUint value;
}
-/// @dev Ethereum representation of Optional value with uint256.
+/// Ethereum representation of Optional value with uint256.
struct OptionUint {
bool status;
uint256 value;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
enum CollectionLimitField {
- /// @dev How many tokens can a user have on one account.
+ /// How many tokens can a user have on one account.
AccountTokenOwnership,
- /// @dev How many bytes of data are available for sponsorship.
+ /// How many bytes of data are available for sponsorship.
SponsoredDataSize,
- /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
SponsoredDataRateLimit,
- /// @dev How many tokens can be mined into this collection.
+ /// How many tokens can be mined into this collection.
TokenLimit,
- /// @dev Timeouts for transfer sponsoring.
+ /// Timeouts for transfer sponsoring.
SponsorTransferTimeout,
- /// @dev Timeout for sponsoring an approval in passed blocks.
+ /// Timeout for sponsoring an approval in passed blocks.
SponsorApproveTimeout,
- /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ /// Whether the collection owner of the collection can send tokens (which belong to other users).
OwnerCanTransfer,
- /// @dev Can the collection owner burn other people's tokens.
+ /// Can the collection owner burn other people's tokens.
OwnerCanDestroy,
- /// @dev Is it possible to send tokens from this collection between users.
+ /// Is it possible to send tokens from this collection between users.
TransferEnabled
}
-/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
+/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
struct Property {
string key;
bytes value;
pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -127,35 +127,35 @@
}
}
-/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
+/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
struct Property {
string key;
bytes value;
}
-/// @dev Ethereum representation of Token Property Permissions.
+/// Ethereum representation of Token Property Permissions.
struct TokenPropertyPermission {
- /// @dev Token property key.
+ /// Token property key.
string key;
- /// @dev Token property permissions.
+ /// Token property permissions.
PropertyPermission[] permissions;
}
-/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
+/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
struct PropertyPermission {
- /// @dev TokenPermission field.
+ /// TokenPermission field.
TokenPermissionField code;
- /// @dev TokenPermission value.
+ /// TokenPermission value.
bool value;
}
-/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
+/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
enum TokenPermissionField {
- /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
+ /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
Mutable,
- /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
+ /// Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
TokenOwner,
- /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
+ /// Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
CollectionAdmin
}
@@ -579,63 +579,63 @@
}
}
-/// @dev Cross account struct
+/// Cross account struct
struct CrossAddress {
address eth;
uint256 sub;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
bool value;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
enum CollectionPermissionField {
- /// @dev Owner of token can nest tokens under it.
+ /// Owner of token can nest tokens under it.
TokenOwner,
- /// @dev Admin of token collection can nest tokens under token.
+ /// Admin of token collection can nest tokens under token.
CollectionAdmin
}
-/// @dev Nested collections.
+/// Nested collections.
struct CollectionNesting {
bool token_owner;
uint256[] ids;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
struct CollectionLimit {
CollectionLimitField field;
OptionUint value;
}
-/// @dev Ethereum representation of Optional value with uint256.
+/// Ethereum representation of Optional value with uint256.
struct OptionUint {
bool status;
uint256 value;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
enum CollectionLimitField {
- /// @dev How many tokens can a user have on one account.
+ /// How many tokens can a user have on one account.
AccountTokenOwnership,
- /// @dev How many bytes of data are available for sponsorship.
+ /// How many bytes of data are available for sponsorship.
SponsoredDataSize,
- /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
SponsoredDataRateLimit,
- /// @dev How many tokens can be mined into this collection.
+ /// How many tokens can be mined into this collection.
TokenLimit,
- /// @dev Timeouts for transfer sponsoring.
+ /// Timeouts for transfer sponsoring.
SponsorTransferTimeout,
- /// @dev Timeout for sponsoring an approval in passed blocks.
+ /// Timeout for sponsoring an approval in passed blocks.
SponsorApproveTimeout,
- /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ /// Whether the collection owner of the collection can send tokens (which belong to other users).
OwnerCanTransfer,
- /// @dev Can the collection owner burn other people's tokens.
+ /// Can the collection owner burn other people's tokens.
OwnerCanDestroy,
- /// @dev Is it possible to send tokens from this collection between users.
+ /// Is it possible to send tokens from this collection between users.
TransferEnabled
}
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -127,35 +127,35 @@
}
}
-/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
+/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
struct Property {
string key;
bytes value;
}
-/// @dev Ethereum representation of Token Property Permissions.
+/// Ethereum representation of Token Property Permissions.
struct TokenPropertyPermission {
- /// @dev Token property key.
+ /// Token property key.
string key;
- /// @dev Token property permissions.
+ /// Token property permissions.
PropertyPermission[] permissions;
}
-/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
+/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
struct PropertyPermission {
- /// @dev TokenPermission field.
+ /// TokenPermission field.
TokenPermissionField code;
- /// @dev TokenPermission value.
+ /// TokenPermission value.
bool value;
}
-/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
+/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
enum TokenPermissionField {
- /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
+ /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
Mutable,
- /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
+ /// Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
TokenOwner,
- /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
+ /// Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
CollectionAdmin
}
@@ -579,63 +579,63 @@
}
}
-/// @dev Cross account struct
+/// Cross account struct
struct CrossAddress {
address eth;
uint256 sub;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
bool value;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
enum CollectionPermissionField {
- /// @dev Owner of token can nest tokens under it.
+ /// Owner of token can nest tokens under it.
TokenOwner,
- /// @dev Admin of token collection can nest tokens under token.
+ /// Admin of token collection can nest tokens under token.
CollectionAdmin
}
-/// @dev Nested collections.
+/// Nested collections.
struct CollectionNesting {
bool token_owner;
uint256[] ids;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
struct CollectionLimit {
CollectionLimitField field;
OptionUint value;
}
-/// @dev Ethereum representation of Optional value with uint256.
+/// Ethereum representation of Optional value with uint256.
struct OptionUint {
bool status;
uint256 value;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
enum CollectionLimitField {
- /// @dev How many tokens can a user have on one account.
+ /// How many tokens can a user have on one account.
AccountTokenOwnership,
- /// @dev How many bytes of data are available for sponsorship.
+ /// How many bytes of data are available for sponsorship.
SponsoredDataSize,
- /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
SponsoredDataRateLimit,
- /// @dev How many tokens can be mined into this collection.
+ /// How many tokens can be mined into this collection.
TokenLimit,
- /// @dev Timeouts for transfer sponsoring.
+ /// Timeouts for transfer sponsoring.
SponsorTransferTimeout,
- /// @dev Timeout for sponsoring an approval in passed blocks.
+ /// Timeout for sponsoring an approval in passed blocks.
SponsorApproveTimeout,
- /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ /// Whether the collection owner of the collection can send tokens (which belong to other users).
OwnerCanTransfer,
- /// @dev Can the collection owner burn other people's tokens.
+ /// Can the collection owner burn other people's tokens.
OwnerCanDestroy,
- /// @dev Is it possible to send tokens from this collection between users.
+ /// Is it possible to send tokens from this collection between users.
TransferEnabled
}
pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungibleToken.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungibleToken.sol
@@ -128,7 +128,7 @@
}
}
-/// @dev Cross account struct
+/// Cross account struct
struct CrossAddress {
address eth;
uint256 sub;
tests/src/eth/api/ContractHelpers.soldiffbeforeafterboth--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -171,13 +171,13 @@
function toggleAllowlist(address contractAddress, bool enabled) external;
}
-/// @dev Ethereum representation of Optional value with CrossAddress.
+/// Ethereum representation of Optional value with CrossAddress.
struct OptionCrossAddress {
bool status;
CrossAddress value;
}
-/// @dev Cross account struct
+/// Cross account struct
struct CrossAddress {
address eth;
uint256 sub;
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -279,67 +279,67 @@
function changeCollectionOwnerCross(CrossAddress memory newOwner) external;
}
-/// @dev Cross account struct
+/// Cross account struct
struct CrossAddress {
address eth;
uint256 sub;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
bool value;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
enum CollectionPermissionField {
- /// @dev Owner of token can nest tokens under it.
+ /// Owner of token can nest tokens under it.
TokenOwner,
- /// @dev Admin of token collection can nest tokens under token.
+ /// Admin of token collection can nest tokens under token.
CollectionAdmin
}
-/// @dev Nested collections.
+/// Nested collections.
struct CollectionNesting {
bool token_owner;
uint256[] ids;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
struct CollectionLimit {
CollectionLimitField field;
OptionUint value;
}
-/// @dev Ethereum representation of Optional value with uint256.
+/// Ethereum representation of Optional value with uint256.
struct OptionUint {
bool status;
uint256 value;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
enum CollectionLimitField {
- /// @dev How many tokens can a user have on one account.
+ /// How many tokens can a user have on one account.
AccountTokenOwnership,
- /// @dev How many bytes of data are available for sponsorship.
+ /// How many bytes of data are available for sponsorship.
SponsoredDataSize,
- /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
SponsoredDataRateLimit,
- /// @dev How many tokens can be mined into this collection.
+ /// How many tokens can be mined into this collection.
TokenLimit,
- /// @dev Timeouts for transfer sponsoring.
+ /// Timeouts for transfer sponsoring.
SponsorTransferTimeout,
- /// @dev Timeout for sponsoring an approval in passed blocks.
+ /// Timeout for sponsoring an approval in passed blocks.
SponsorApproveTimeout,
- /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ /// Whether the collection owner of the collection can send tokens (which belong to other users).
OwnerCanTransfer,
- /// @dev Can the collection owner burn other people's tokens.
+ /// Can the collection owner burn other people's tokens.
OwnerCanDestroy,
- /// @dev Is it possible to send tokens from this collection between users.
+ /// Is it possible to send tokens from this collection between users.
TransferEnabled
}
-/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
+/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
struct Property {
string key;
bytes value;
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -80,35 +80,35 @@
function property(uint256 tokenId, string memory key) external view returns (bytes memory);
}
-/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
+/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
struct Property {
string key;
bytes value;
}
-/// @dev Ethereum representation of Token Property Permissions.
+/// Ethereum representation of Token Property Permissions.
struct TokenPropertyPermission {
- /// @dev Token property key.
+ /// Token property key.
string key;
- /// @dev Token property permissions.
+ /// Token property permissions.
PropertyPermission[] permissions;
}
-/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
+/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
struct PropertyPermission {
- /// @dev TokenPermission field.
+ /// TokenPermission field.
TokenPermissionField code;
- /// @dev TokenPermission value.
+ /// TokenPermission value.
bool value;
}
-/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
+/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
enum TokenPermissionField {
- /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
+ /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
Mutable,
- /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
+ /// Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
TokenOwner,
- /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
+ /// Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
CollectionAdmin
}
@@ -379,63 +379,63 @@
function changeCollectionOwnerCross(CrossAddress memory newOwner) external;
}
-/// @dev Cross account struct
+/// Cross account struct
struct CrossAddress {
address eth;
uint256 sub;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
bool value;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
enum CollectionPermissionField {
- /// @dev Owner of token can nest tokens under it.
+ /// Owner of token can nest tokens under it.
TokenOwner,
- /// @dev Admin of token collection can nest tokens under token.
+ /// Admin of token collection can nest tokens under token.
CollectionAdmin
}
-/// @dev Nested collections.
+/// Nested collections.
struct CollectionNesting {
bool token_owner;
uint256[] ids;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
struct CollectionLimit {
CollectionLimitField field;
OptionUint value;
}
-/// @dev Ethereum representation of Optional value with uint256.
+/// Ethereum representation of Optional value with uint256.
struct OptionUint {
bool status;
uint256 value;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
enum CollectionLimitField {
- /// @dev How many tokens can a user have on one account.
+ /// How many tokens can a user have on one account.
AccountTokenOwnership,
- /// @dev How many bytes of data are available for sponsorship.
+ /// How many bytes of data are available for sponsorship.
SponsoredDataSize,
- /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
SponsoredDataRateLimit,
- /// @dev How many tokens can be mined into this collection.
+ /// How many tokens can be mined into this collection.
TokenLimit,
- /// @dev Timeouts for transfer sponsoring.
+ /// Timeouts for transfer sponsoring.
SponsorTransferTimeout,
- /// @dev Timeout for sponsoring an approval in passed blocks.
+ /// Timeout for sponsoring an approval in passed blocks.
SponsorApproveTimeout,
- /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ /// Whether the collection owner of the collection can send tokens (which belong to other users).
OwnerCanTransfer,
- /// @dev Can the collection owner burn other people's tokens.
+ /// Can the collection owner burn other people's tokens.
OwnerCanDestroy,
- /// @dev Is it possible to send tokens from this collection between users.
+ /// Is it possible to send tokens from this collection between users.
TransferEnabled
}
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -80,35 +80,35 @@
function property(uint256 tokenId, string memory key) external view returns (bytes memory);
}
-/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
+/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
struct Property {
string key;
bytes value;
}
-/// @dev Ethereum representation of Token Property Permissions.
+/// Ethereum representation of Token Property Permissions.
struct TokenPropertyPermission {
- /// @dev Token property key.
+ /// Token property key.
string key;
- /// @dev Token property permissions.
+ /// Token property permissions.
PropertyPermission[] permissions;
}
-/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
+/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
struct PropertyPermission {
- /// @dev TokenPermission field.
+ /// TokenPermission field.
TokenPermissionField code;
- /// @dev TokenPermission value.
+ /// TokenPermission value.
bool value;
}
-/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
+/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
enum TokenPermissionField {
- /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
+ /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
Mutable,
- /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
+ /// Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
TokenOwner,
- /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
+ /// Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
CollectionAdmin
}
@@ -379,63 +379,63 @@
function changeCollectionOwnerCross(CrossAddress memory newOwner) external;
}
-/// @dev Cross account struct
+/// Cross account struct
struct CrossAddress {
address eth;
uint256 sub;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
bool value;
}
-/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
enum CollectionPermissionField {
- /// @dev Owner of token can nest tokens under it.
+ /// Owner of token can nest tokens under it.
TokenOwner,
- /// @dev Admin of token collection can nest tokens under token.
+ /// Admin of token collection can nest tokens under token.
CollectionAdmin
}
-/// @dev Nested collections.
+/// Nested collections.
struct CollectionNesting {
bool token_owner;
uint256[] ids;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
struct CollectionLimit {
CollectionLimitField field;
OptionUint value;
}
-/// @dev Ethereum representation of Optional value with uint256.
+/// Ethereum representation of Optional value with uint256.
struct OptionUint {
bool status;
uint256 value;
}
-/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.
enum CollectionLimitField {
- /// @dev How many tokens can a user have on one account.
+ /// How many tokens can a user have on one account.
AccountTokenOwnership,
- /// @dev How many bytes of data are available for sponsorship.
+ /// How many bytes of data are available for sponsorship.
SponsoredDataSize,
- /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
SponsoredDataRateLimit,
- /// @dev How many tokens can be mined into this collection.
+ /// How many tokens can be mined into this collection.
TokenLimit,
- /// @dev Timeouts for transfer sponsoring.
+ /// Timeouts for transfer sponsoring.
SponsorTransferTimeout,
- /// @dev Timeout for sponsoring an approval in passed blocks.
+ /// Timeout for sponsoring an approval in passed blocks.
SponsorApproveTimeout,
- /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ /// Whether the collection owner of the collection can send tokens (which belong to other users).
OwnerCanTransfer,
- /// @dev Can the collection owner burn other people's tokens.
+ /// Can the collection owner burn other people's tokens.
OwnerCanDestroy,
- /// @dev Is it possible to send tokens from this collection between users.
+ /// Is it possible to send tokens from this collection between users.
TransferEnabled
}
tests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungibleToken.sol
+++ b/tests/src/eth/api/UniqueRefungibleToken.sol
@@ -79,7 +79,7 @@
) external returns (bool);
}
-/// @dev Cross account struct
+/// Cross account struct
struct CrossAddress {
address eth;
uint256 sub;