difftreelog
refactor reuse code generation patterns
in: master
22 files changed
crates/evm-coder/procedural/src/abi_derive/derive_enum.rsdiffbeforeafterboth1use quote::quote;1use quote::quote;23use super::extract_docs;243pub fn impl_solidity_option<'a>(5pub fn impl_solidity_option<'a>(6 docs: Vec<String>,4 name: &proc_macro2::Ident,7 name: &proc_macro2::Ident,5 enum_options: impl Iterator<Item = &'a syn::Ident>,8 enum_options: impl Iterator<Item = &'a syn::Variant> + Clone,6) -> proc_macro2::TokenStream {9) -> proc_macro2::TokenStream {7 let enum_options = enum_options.map(|opt| {10 let variant_names = enum_options.clone().map(|opt| {11 let opt = &opt.ident;8 let s = name.to_string() + "." + opt.to_string().as_str();12 let s = name.to_string() + "." + opt.to_string().as_str();9 let as_string = proc_macro2::Literal::string(s.as_str());13 let as_string = proc_macro2::Literal::string(s.as_str());10 quote!(#name::#opt => #as_string,)14 quote!(#name::#opt => #as_string,)11 });15 });16 let solidity_name = name.to_string();1718 let solidity_fields = enum_options.map(|v| {19 let docs = extract_docs(&v.attrs).expect("TODO: handle bad docs");20 let name = v.ident.to_string();21 quote! {22 SolidityEnumVariant {23 docs: &[#(#docs),*],24 name: #name,25 }26 }27 });2812 quote!(29 quote!(13 #[cfg(feature = "stubgen")]30 #[cfg(feature = "stubgen")]14 impl ::evm_coder::solidity::SolidityEnum for #name {31 impl ::evm_coder::solidity::SolidityEnumTy for #name {32 fn generate_solidity_interface(tc: &evm_coder::solidity::TypeCollector) -> String {33 use evm_coder::solidity::*;34 use core::fmt::Write;35 let interface = SolidityEnum {36 docs: &[#(#docs),*],37 name: #solidity_name,38 fields: &[#(39 #solidity_fields,40 )*],41 };42 let mut out = String::new();43 let _ = interface.format(&mut out, tc);44 tc.collect(out);45 #solidity_name.to_string()46 }15 fn solidity_option(&self) -> &str {47 fn solidity_option(&self) -> &str {16 match self {48 match self {17 #(#enum_options)*49 #(#variant_names)*18 }50 }19 }51 }20 }52 }235524pub fn impl_enum_from_u8<'a>(56pub fn impl_enum_from_u8<'a>(25 name: &proc_macro2::Ident,57 name: &proc_macro2::Ident,26 enum_options: impl Iterator<Item = &'a syn::Ident>,58 enum_options: impl Iterator<Item = &'a syn::Variant>,27) -> proc_macro2::TokenStream {59) -> proc_macro2::TokenStream {28 let error_str = format!("Value not convertible into enum \"{name}\"");60 let error_str = format!("Value not convertible into enum \"{name}\"");29 let error_str = proc_macro2::Literal::string(&error_str);61 let error_str = proc_macro2::Literal::string(&error_str);30 let enum_options = enum_options.enumerate().map(|(i, opt)| {62 let enum_options = enum_options.enumerate().map(|(i, opt)| {63 let opt = &opt.ident;31 let n = proc_macro2::Literal::u8_suffixed(i as u8);64 let n = proc_macro2::Literal::u8_suffixed(i as u8);32 quote! {#n => Ok(#name::#opt),}65 quote! {#n => Ok(#name::#opt),}33 });66 });85 )118 )86}119}8788pub fn impl_enum_solidity_type<'a>(name: &syn::Ident) -> proc_macro2::TokenStream {89 quote! {90 #[cfg(feature = "stubgen")]91 impl ::evm_coder::solidity::SolidityType for #name {92 fn names(tc: &::evm_coder::solidity::TypeCollector) -> Vec<String> {93 Vec::new()94 }9596 fn len() -> usize {97 198 }99 }100 }101}102120103pub fn impl_enum_solidity_type_name(name: &syn::Ident) -> proc_macro2::TokenStream {121pub fn impl_enum_solidity_type_name(name: &syn::Ident) -> proc_macro2::TokenStream {104 quote!(122 quote!(108 writer: &mut impl ::core::fmt::Write,126 writer: &mut impl ::core::fmt::Write,109 tc: &::evm_coder::solidity::TypeCollector,127 tc: &::evm_coder::solidity::TypeCollector,110 ) -> ::core::fmt::Result {128 ) -> ::core::fmt::Result {111 write!(writer, "{}", tc.collect_struct::<Self>())129 write!(writer, "{}", tc.collect_enum::<Self>())112 }130 }113131114 fn is_simple() -> bool {132 fn is_simple() -> bool {119 writer: &mut impl ::core::fmt::Write,137 writer: &mut impl ::core::fmt::Write,120 tc: &::evm_coder::solidity::TypeCollector,138 tc: &::evm_coder::solidity::TypeCollector,121 ) -> ::core::fmt::Result {139 ) -> ::core::fmt::Result {122 write!(writer, "{}", <#name as ::evm_coder::solidity::SolidityEnum>::solidity_option(&<#name>::default()))140 write!(writer, "{}", <#name as ::evm_coder::solidity::SolidityEnumTy>::solidity_option(&<#name>::default()))123 }141 }124 }142 }125 )143 )126}144}127128pub fn impl_enum_solidity_struct_collect<'a>(129 name: &syn::Ident,130 enum_options: impl Iterator<Item = &'a syn::Ident>,131 option_count: usize,132 enum_options_docs: impl Iterator<Item = syn::Result<Vec<proc_macro2::TokenStream>>>,133 docs: &[proc_macro2::TokenStream],134) -> proc_macro2::TokenStream {135 let string_name = name.to_string();136 let enum_options = enum_options137 .zip(enum_options_docs)138 .enumerate()139 .map(|(i, (opt, doc))| {140 let opt = proc_macro2::Literal::string(opt.to_string().as_str());141 let doc = doc.expect("Doc parsing error");142 let comma = if i != option_count - 1 { "," } else { "" };143 quote! {144 #(#doc)*145 writeln!(str, "\t{}{}", #opt, #comma).expect("Enum format option");146 }147 });148149 quote!(150 #[cfg(feature = "stubgen")]151 impl ::evm_coder::solidity::StructCollect for #name {152 fn name() -> String {153 #string_name.into()154 }155156 fn declaration() -> String {157 use std::fmt::Write;158159 let mut str = String::new();160 #(#docs)*161 writeln!(str, "enum {} {{", <Self as ::evm_coder::solidity::StructCollect>::name()).unwrap();162 #(#enum_options)*163 writeln!(str, "}}").unwrap();164 str165 }166 }167 )168}169145170pub fn check_and_count_options(de: &syn::DataEnum) -> syn::Result<usize> {146pub fn check_and_count_options(de: &syn::DataEnum) -> syn::Result<usize> {171 let mut count = 0;147 let mut count = 0;crates/evm-coder/procedural/src/abi_derive/derive_struct.rsdiffbeforeafterboth1use super::extract_docs;1use super::extract_docs;2use quote::quote;2use quote::quote;3use syn::Field;344pub fn tuple_type<'a>(5pub fn tuple_type<'a>(5 field_types: impl Iterator<Item = &'a syn::Type> + Clone,6 field_types: impl Iterator<Item = &'a syn::Type> + Clone,87 &field.ty88 &field.ty88}89}8990pub fn map_field_to_doc(field: &syn::Field) -> syn::Result<Vec<proc_macro2::TokenStream>> {91 extract_docs(&field.attrs, true)92}939094pub fn impl_can_be_placed_in_vec(ident: &syn::Ident) -> proc_macro2::TokenStream {91pub fn impl_can_be_placed_in_vec(ident: &syn::Ident) -> proc_macro2::TokenStream {95 quote! {92 quote! {147144148pub fn impl_struct_solidity_type<'a>(145pub fn impl_struct_solidity_type<'a>(149 name: &syn::Ident,146 name: &syn::Ident,147 docs: Vec<String>,150 field_types: impl Iterator<Item = &'a syn::Type> + Clone,148 fields: impl Iterator<Item = &'a Field> + Clone,151 params_count: usize,152) -> proc_macro2::TokenStream {149) -> proc_macro2::TokenStream {150 let solidity_name = name.to_string();153 let len = proc_macro2::Literal::usize_suffixed(params_count);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 });154 quote! {167 quote! {155 #[cfg(feature = "stubgen")]168 #[cfg(feature = "stubgen")]156 impl ::evm_coder::solidity::SolidityType for #name {169 impl ::evm_coder::solidity::SolidityStructTy for #name {170 /// Generate solidity definitions for methods described in this struct157 fn names(tc: &::evm_coder::solidity::TypeCollector) -> Vec<String> {171 fn generate_solidity_interface(tc: &evm_coder::solidity::TypeCollector) -> String {158 let mut collected =159 Vec::with_capacity(<Self as ::evm_coder::solidity::SolidityType>::len());172 use evm_coder::solidity::*;173 use core::fmt::Write;174 let interface = SolidityStruct {175 docs: &[#(#docs),*],160 #({176 name: #solidity_name,177 fields: (#(178 #solidity_fields,179 )*),180 };161 let mut out = String::new();181 let mut out = String::new();162 <#field_types as ::evm_coder::solidity::SolidityTypeName>::solidity_name(&mut out, tc)182 let _ = interface.format(&mut out, tc);163 .expect("no fmt error");164 collected.push(out);183 tc.collect(out);165 })*166 collected167 }168169 fn len() -> usize {170 #len184 #solidity_name.to_string()171 }185 }172 }186 }173 }187 }174}188}216 }230 }217}231}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}261232crates/evm-coder/procedural/src/abi_derive/mod.rsdiffbeforeafterboth19 ast: &syn::DeriveInput,19 ast: &syn::DeriveInput,20) -> syn::Result<proc_macro2::TokenStream> {20) -> syn::Result<proc_macro2::TokenStream> {21 let name = &ast.ident;21 let name = &ast.ident;22 let docs = extract_docs(&ast.attrs, false)?;22 let docs = extract_docs(&ast.attrs)?;23 let (is_named_fields, field_names, field_types, field_docs, params_count) = match ds.fields {23 let (is_named_fields, field_names, field_types, params_count) = match ds.fields {24 syn::Fields::Named(ref fields) => Ok((24 syn::Fields::Named(ref fields) => Ok((25 true,25 true,26 fields.named.iter().enumerate().map(map_field_to_name),26 fields.named.iter().enumerate().map(map_field_to_name),27 fields.named.iter().map(map_field_to_type),27 fields.named.iter().map(map_field_to_type),28 fields.named.iter().map(map_field_to_doc),29 fields.named.len(),28 fields.named.len(),30 )),29 )),31 syn::Fields::Unnamed(ref fields) => Ok((30 syn::Fields::Unnamed(ref fields) => Ok((32 false,31 false,33 fields.unnamed.iter().enumerate().map(map_field_to_name),32 fields.unnamed.iter().enumerate().map(map_field_to_name),34 fields.unnamed.iter().map(map_field_to_type),33 fields.unnamed.iter().map(map_field_to_type),35 fields.unnamed.iter().map(map_field_to_doc),36 fields.unnamed.len(),34 fields.unnamed.len(),37 )),35 )),38 syn::Fields::Unit => Err(syn::Error::new(name.span(), "Unit structs not supported")),36 syn::Fields::Unit => Err(syn::Error::new(name.span(), "Unit structs not supported")),52 let abi_type = impl_struct_abi_type(name, tuple_type.clone());50 let abi_type = impl_struct_abi_type(name, tuple_type.clone());53 let abi_read = impl_struct_abi_read(name, tuple_type, tuple_names, struct_from_tuple);51 let abi_read = impl_struct_abi_read(name, tuple_type, tuple_names, struct_from_tuple);54 let abi_write = impl_struct_abi_write(name, is_named_fields, tuple_ref_type, tuple_data);52 let abi_write = impl_struct_abi_write(name, is_named_fields, tuple_ref_type, tuple_data);55 let solidity_type = impl_struct_solidity_type(name, field_types.clone(), params_count);53 let solidity_type = impl_struct_solidity_type(name, docs, ds.fields.iter());56 let solidity_type_name =54 let solidity_type_name =57 impl_struct_solidity_type_name(name, field_types.clone(), params_count);55 impl_struct_solidity_type_name(name, field_types.clone(), params_count);58 let solidity_struct_collect =59 impl_struct_solidity_struct_collect(name, field_names, field_types, field_docs, &docs)?;605661 Ok(quote! {57 Ok(quote! {62 #can_be_plcaed_in_vec58 #can_be_plcaed_in_vec65 #abi_write61 #abi_write66 #solidity_type62 #solidity_type67 #solidity_type_name63 #solidity_type_name68 #solidity_struct_collect69 })64 })70}65}716675) -> syn::Result<proc_macro2::TokenStream> {70) -> syn::Result<proc_macro2::TokenStream> {76 let name = &ast.ident;71 let name = &ast.ident;77 check_repr_u8(name, &ast.attrs)?;72 check_repr_u8(name, &ast.attrs)?;78 let docs = extract_docs(&ast.attrs, false)?;73 let docs = extract_docs(&ast.attrs)?;79 let option_count = check_and_count_options(de)?;80 let enum_options = de.variants.iter().map(|v| &v.ident);74 let enum_options = de.variants.iter();81 let enum_options_docs = de.variants.iter().map(|v| extract_docs(&v.attrs, true));827583 let from = impl_enum_from_u8(name, enum_options.clone());76 let from = impl_enum_from_u8(name, enum_options.clone());84 let solidity_option = impl_solidity_option(name, enum_options.clone());77 let solidity_option = impl_solidity_option(docs, name, enum_options.clone());85 let can_be_plcaed_in_vec = impl_can_be_placed_in_vec(name);78 let can_be_plcaed_in_vec = impl_can_be_placed_in_vec(name);86 let abi_type = impl_enum_abi_type(name);79 let abi_type = impl_enum_abi_type(name);87 let abi_read = impl_enum_abi_read(name);80 let abi_read = impl_enum_abi_read(name);88 let abi_write = impl_enum_abi_write(name);81 let abi_write = impl_enum_abi_write(name);89 let solidity_type = impl_enum_solidity_type(name);90 let solidity_type_name = impl_enum_solidity_type_name(name);82 let solidity_type_name = impl_enum_solidity_type_name(name);91 let solidity_struct_collect = impl_enum_solidity_struct_collect(92 name,93 enum_options,94 option_count,95 enum_options_docs,96 &docs,97 );988399 Ok(quote! {84 Ok(quote! {100 #from85 #from103 #abi_type88 #abi_type104 #abi_read89 #abi_read105 #abi_write90 #abi_write106 #solidity_type107 #solidity_type_name91 #solidity_type_name108 #solidity_struct_collect109 })92 })110}93}11194112fn extract_docs(95fn extract_docs(attrs: &[syn::Attribute]) -> syn::Result<Vec<String>> {113 attrs: &[syn::Attribute],114 is_field_doc: bool,115) -> syn::Result<Vec<proc_macro2::TokenStream>> {116 attrs96 attrs117 .iter()97 .iter()118 .filter_map(|attr| {98 .filter_map(|attr| {133 }113 }134 None114 None135 })115 })136 .enumerate()137 .map(|(i, doc)| {138 let doc = doc?;139 let doc = doc.trim();140 let dev = if i == 0 { " @dev" } else { "" };141 let tab = if is_field_doc { "\t" } else { "" };142 Ok(quote! {143 writeln!(str, "{}///{} {}", #tab, #dev, #doc).unwrap();144 })145 })146 .collect()116 .collect()147}117}148118crates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth1use super::{TypeCollector, SolidityTypeName, SolidityType, StructCollect};1use super::{TypeCollector, SolidityTypeName, SolidityTupleTy};2use crate::{sealed, types::*};2use crate::{sealed, types::*};3use core::fmt;3use core::fmt;4use primitive_types::{U256, H160};4use primitive_types::{U256, H160};18 }18 }19 }19 }2021 impl StructCollect for $ty {22 fn name() -> String {23 $name.to_string()24 }2526 fn declaration() -> String {27 String::default()28 }29 }30 )*20 )*31 };21 };32}22}74 }64 }75}65}7677impl<T: StructCollect + sealed::CanBePlacedInVec> StructCollect for Vec<T> {78 fn name() -> String {79 <T as StructCollect>::name() + "[]"80 }8182 fn declaration() -> String {83 unimplemented!("Vectors have not declarations.")84 }85}866687macro_rules! count {67macro_rules! count {88 () => (0usize);68 () => (0usize);917192macro_rules! impl_tuples {72macro_rules! impl_tuples {93 ($($ident:ident)+) => {73 ($($ident:ident)+) => {94 impl<$($ident: SolidityTypeName + 'static),+> SolidityType for ($($ident,)+) {74 impl<$($ident: SolidityTypeName + 'static),+> SolidityTupleTy for ($($ident,)+) {95 fn names(tc: &TypeCollector) -> Vec<string> {75 fn fields(tc: &TypeCollector) -> Vec<string> {96 let mut collected = Vec::with_capacity(Self::len());76 let mut collected = Vec::with_capacity(Self::len());97 $({77 $({98 let mut out = string::new();78 let mut out = string::new();crates/evm-coder/src/solidity/mod.rsdiffbeforeafterboth44 /// id ordering is required to perform topo-sort on the resulting data44 /// id ordering is required to perform topo-sort on the resulting data45 structs: RefCell<BTreeMap<string, usize>>,45 structs: RefCell<BTreeMap<string, usize>>,46 anonymous: RefCell<BTreeMap<Vec<string>, usize>>,46 anonymous: RefCell<BTreeMap<Vec<string>, usize>>,47 // generic: RefCell<BTreeMap<string, usize>>,47 id: Cell<usize>,48 id: Cell<usize>,48}49}49impl TypeCollector {50impl TypeCollector {59 self.id.set(v + 1);60 self.id.set(v + 1);60 v61 v61 }62 }63 /// Collect typle, deduplicating it by type, and returning generated name62 pub fn collect_tuple<T: SolidityType>(&self) -> String {64 pub fn collect_tuple<T: SolidityTupleTy>(&self) -> String {63 let names = T::names(self);65 let names = T::fields(self);64 if let Some(id) = self.anonymous.borrow().get(&names).cloned() {66 if let Some(id) = self.anonymous.borrow().get(&names).cloned() {65 return format!("Tuple{}", id);67 return format!("Tuple{}", id);66 }68 }76 self.anonymous.borrow_mut().insert(names, id);78 self.anonymous.borrow_mut().insert(names, id);77 format!("Tuple{}", id)79 format!("Tuple{}", id)78 }80 }79 pub fn collect_struct<T: StructCollect + SolidityType>(&self) -> String {81 pub fn collect_struct<T: SolidityStructTy>(&self) -> String {80 let _names = T::names(self);82 T::generate_solidity_interface(self)81 self.collect(<T as StructCollect>::declaration());82 <T as StructCollect>::name()83 }83 }84 pub fn collect_enum<T: SolidityEnumTy>(&self) -> String {85 T::generate_solidity_interface(self)86 }84 pub fn finish(self) -> Vec<string> {87 pub fn finish(self) -> Vec<string> {85 let mut data = self.structs.into_inner().into_iter().collect::<Vec<_>>();88 let mut data = self.structs.into_inner().into_iter().collect::<Vec<_>>();86 data.sort_by_key(|(_, id)| Reverse(*id));89 data.sort_by_key(|(_, id)| Reverse(*id));421 }424 }422}425}426427#[impl_for_tuples(0, 48)]428impl SolidityItems for Tuple {429 for_tuples!( where #( Tuple: SolidityItems ),* );430431 fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {432 for_tuples!( #(433 Tuple.solidity_name(writer, tc)?;434 )* );435 Ok(())436 }437}438439pub struct SolidityStructField<T> {440 pub docs: &'static [&'static str],441 pub name: &'static str,442 pub ty: PhantomData<*const T>,443}444445impl<T> SolidityItems for SolidityStructField<T>446where447 T: SolidityTypeName,448{449 fn solidity_name(&self, out: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {450 for doc in self.docs {451 writeln!(out, "///{}", doc)?;452 }453 write!(out, "\t")?;454 T::solidity_name(out, tc)?;455 writeln!(out, " {};", self.name)?;456 Ok(())457 }458}459pub struct SolidityStruct<F> {460 pub docs: &'static [&'static str],461 // pub generics:462 pub name: &'static str,463 pub fields: F,464}465impl<F> SolidityStruct<F>466where467 F: SolidityItems,468{469 pub fn format(&self, out: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {470 for doc in self.docs {471 writeln!(out, "///{}", doc)?;472 }473 writeln!(out, "struct {} {{", self.name)?;474 self.fields.solidity_name(out, tc)?;475 writeln!(out, "}}")?;476 Ok(())477 }478}479480pub struct SolidityEnumVariant {481 pub docs: &'static [&'static str],482 pub name: &'static str,483}484impl SolidityItems for SolidityEnumVariant {485 fn solidity_name(&self, out: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {486 for doc in self.docs {487 writeln!(out, "///{}", doc)?;488 }489 write!(out, "\t{}", self.name)?;490 Ok(())491 }492}493pub struct SolidityEnum {494 pub docs: &'static [&'static str],495 pub name: &'static str,496 pub fields: &'static [SolidityEnumVariant],497}498impl SolidityEnum {499 pub fn format(&self, out: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {500 for doc in self.docs {501 writeln!(out, "///{}", doc)?;502 }503 write!(out, "enum {} {{", self.name)?;504 for (i, field) in self.fields.iter().enumerate() {505 if i != 0 {506 write!(out, ",")?;507 }508 writeln!(out)?;509 field.solidity_name(out, tc)?;510 }511 writeln!(out)?;512 writeln!(out, "}}")?;513 Ok(())514 }515}423516crates/evm-coder/src/solidity/traits.rsdiffbeforeafterboth1use super::TypeCollector;1use super::TypeCollector;2use core::fmt;2use core::fmt;34pub trait StructCollect: 'static {5 /// Structure name.6 fn name() -> String;7 /// Structure declaration.8 fn declaration() -> String;9}1011pub trait SolidityEnum: 'static {12 fn solidity_option(&self) -> &str;13}14315pub trait SolidityTypeName: 'static {4pub trait SolidityTypeName: 'static {16 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;5 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;23 }12 }24}13}251426pub trait SolidityType {15pub trait SolidityTupleTy: 'static {27 fn names(tc: &TypeCollector) -> Vec<String>;16 fn fields(tc: &TypeCollector) -> Vec<String>;28 fn len() -> usize;17 fn len() -> usize;29}18}19pub trait SolidityStructTy: 'static {20 fn generate_solidity_interface(tc: &TypeCollector) -> String;21}22pub trait SolidityEnumTy: 'static {23 fn generate_solidity_interface(tc: &TypeCollector) -> String;24 fn solidity_option(&self) -> &str;25}302631pub trait SolidityArguments {27pub trait SolidityArguments {32 fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;28 fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;47 ) -> fmt::Result;43 ) -> fmt::Result;48}44}4546pub trait SolidityItems {47 fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;48 // For PhantomData fields49 // fn is_void()50}4951crates/evm-coder/tests/abi_derive_generation.rsdiffbeforeafterboth73 _c: TypeStruct2MixedParam,73 _c: TypeStruct2MixedParam,74 }74 }7576 #[test]77 #[cfg(feature = "stubgen")]78 fn struct_collect_type_struct3_derived_mixed_param() {79 assert_eq!(80 <TypeStruct3DerivedMixedParam as ::evm_coder::solidity::StructCollect>::name(),81 "TypeStruct3DerivedMixedParam"82 );83 similar_asserts::assert_eq!(84 <TypeStruct3DerivedMixedParam as ::evm_coder::solidity::StructCollect>::declaration(),85 r#"/// @dev Some docs86/// At multi87/// line88struct TypeStruct3DerivedMixedParam {89 /// @dev Docs for A90 /// multi91 /// line92 TypeStruct1SimpleParam _a;93 /// @dev Docs for B94 TypeStruct2DynamicParam _b;95 /// @dev Docs for C96 TypeStruct2MixedParam _c;97}98"#99 );100 }101102 #[test]103 #[cfg(feature = "stubgen")]104 fn struct_collect_vec() {105 assert_eq!(106 <Vec<u8> as ::evm_coder::solidity::StructCollect>::name(),107 "uint8[]"108 );109 }11075111 #[test]76 #[test]112 fn impl_abi_type_signature() {77 fn impl_abi_type_signature() {302 TupleStruct2MixedParam,267 TupleStruct2MixedParam,303 );268 );304305 #[test]306 #[cfg(feature = "stubgen")]307 fn struct_collect_tuple_struct3_derived_mixed_param() {308 assert_eq!(309 <TupleStruct3DerivedMixedParam as ::evm_coder::solidity::StructCollect>::name(),310 "TupleStruct3DerivedMixedParam"311 );312 similar_asserts::assert_eq!(313 <TupleStruct3DerivedMixedParam as ::evm_coder::solidity::StructCollect>::declaration(),314 r#"/// @dev Some docs315/// At multi316/// line317struct TupleStruct3DerivedMixedParam {318 /// @dev Docs for A319 /// multi320 /// line321 TupleStruct1SimpleParam field0;322 TupleStruct2DynamicParam field1;323 /// @dev Docs for C324 TupleStruct2MixedParam field2;325}326"#327 );328 }329269330 #[test]270 #[test]331 fn impl_abi_type_signature_same_for_structs() {271 fn impl_abi_type_signature_same_for_structs() {823 }763 }824 }764 }825826 #[test]827 #[cfg(feature = "stubgen")]828 fn struct_collect_enum() {829 assert_eq!(830 <Color as ::evm_coder::solidity::StructCollect>::name(),831 "Color"832 );833 similar_asserts::assert_eq!(834 <Color as ::evm_coder::solidity::StructCollect>::declaration(),835 r#"/// @dev Some docs836/// At multi837/// line838enum Color {839 /// @dev Docs for Red840 /// multi841 /// line842 Red,843 Green,844 /// @dev Docs for Blue845 Blue846}847"#848 );849 }850}765}851766pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth265 }265 }266}266}267267268/// @dev Cross account struct268/// Cross account struct269struct CrossAddress {269struct CrossAddress {270 address eth;270 address eth;271 uint256 sub;271 uint256 sub;272}272}273273274/// @dev Ethereum representation of Optional value with CrossAddress.274/// Ethereum representation of Optional value with CrossAddress.275struct OptionCrossAddress {275struct OptionCrossAddress {276 bool status;276 bool status;277 CrossAddress value;277 CrossAddress value;pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth437 }437 }438}438}439439440/// @dev Cross account struct440/// Cross account struct441struct CrossAddress {441struct CrossAddress {442 address eth;442 address eth;443 uint256 sub;443 uint256 sub;444}444}445445446/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.446/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.447struct CollectionNestingPermission {447struct CollectionNestingPermission {448 CollectionPermissionField field;448 CollectionPermissionField field;449 bool value;449 bool value;450}450}451451452/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.452/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.453enum CollectionPermissionField {453enum CollectionPermissionField {454 /// @dev Owner of token can nest tokens under it.454 /// Owner of token can nest tokens under it.455 TokenOwner,455 TokenOwner,456 /// @dev Admin of token collection can nest tokens under token.456 /// Admin of token collection can nest tokens under token.457 CollectionAdmin457 CollectionAdmin458}458}459459460/// @dev Nested collections.460/// Nested collections.461struct CollectionNesting {461struct CollectionNesting {462 bool token_owner;462 bool token_owner;463 uint256[] ids;463 uint256[] ids;464}464}465465466/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.466/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.467struct CollectionLimit {467struct CollectionLimit {468 CollectionLimitField field;468 CollectionLimitField field;469 OptionUint value;469 OptionUint value;470}470}471471472/// @dev Ethereum representation of Optional value with uint256.472/// Ethereum representation of Optional value with uint256.473struct OptionUint {473struct OptionUint {474 bool status;474 bool status;475 uint256 value;475 uint256 value;476}476}477477478/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.478/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.479enum CollectionLimitField {479enum CollectionLimitField {480 /// @dev How many tokens can a user have on one account.480 /// How many tokens can a user have on one account.481 AccountTokenOwnership,481 AccountTokenOwnership,482 /// @dev How many bytes of data are available for sponsorship.482 /// How many bytes of data are available for sponsorship.483 SponsoredDataSize,483 SponsoredDataSize,484 /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]484 /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]485 SponsoredDataRateLimit,485 SponsoredDataRateLimit,486 /// @dev How many tokens can be mined into this collection.486 /// How many tokens can be mined into this collection.487 TokenLimit,487 TokenLimit,488 /// @dev Timeouts for transfer sponsoring.488 /// Timeouts for transfer sponsoring.489 SponsorTransferTimeout,489 SponsorTransferTimeout,490 /// @dev Timeout for sponsoring an approval in passed blocks.490 /// Timeout for sponsoring an approval in passed blocks.491 SponsorApproveTimeout,491 SponsorApproveTimeout,492 /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).492 /// Whether the collection owner of the collection can send tokens (which belong to other users).493 OwnerCanTransfer,493 OwnerCanTransfer,494 /// @dev Can the collection owner burn other people's tokens.494 /// Can the collection owner burn other people's tokens.495 OwnerCanDestroy,495 OwnerCanDestroy,496 /// @dev Is it possible to send tokens from this collection between users.496 /// Is it possible to send tokens from this collection between users.497 TransferEnabled497 TransferEnabled498}498}499499500/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).500/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).501struct Property {501struct Property {502 string key;502 string key;503 bytes value;503 bytes value;pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth127 }127 }128}128}129129130/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).130/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).131struct Property {131struct Property {132 string key;132 string key;133 bytes value;133 bytes value;134}134}135135136/// @dev Ethereum representation of Token Property Permissions.136/// Ethereum representation of Token Property Permissions.137struct TokenPropertyPermission {137struct TokenPropertyPermission {138 /// @dev Token property key.138 /// Token property key.139 string key;139 string key;140 /// @dev Token property permissions.140 /// Token property permissions.141 PropertyPermission[] permissions;141 PropertyPermission[] permissions;142}142}143143144/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.144/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.145struct PropertyPermission {145struct PropertyPermission {146 /// @dev TokenPermission field.146 /// TokenPermission field.147 TokenPermissionField code;147 TokenPermissionField code;148 /// @dev TokenPermission value.148 /// TokenPermission value.149 bool value;149 bool value;150}150}151151152/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.152/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.153enum TokenPermissionField {153enum TokenPermissionField {154 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]154 /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]155 Mutable,155 Mutable,156 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]156 /// Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]157 TokenOwner,157 TokenOwner,158 /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]158 /// Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]159 CollectionAdmin159 CollectionAdmin160}160}161161579 }579 }580}580}581581582/// @dev Cross account struct582/// Cross account struct583struct CrossAddress {583struct CrossAddress {584 address eth;584 address eth;585 uint256 sub;585 uint256 sub;586}586}587587588/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.588/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.589struct CollectionNestingPermission {589struct CollectionNestingPermission {590 CollectionPermissionField field;590 CollectionPermissionField field;591 bool value;591 bool value;592}592}593593594/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.594/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.595enum CollectionPermissionField {595enum CollectionPermissionField {596 /// @dev Owner of token can nest tokens under it.596 /// Owner of token can nest tokens under it.597 TokenOwner,597 TokenOwner,598 /// @dev Admin of token collection can nest tokens under token.598 /// Admin of token collection can nest tokens under token.599 CollectionAdmin599 CollectionAdmin600}600}601601602/// @dev Nested collections.602/// Nested collections.603struct CollectionNesting {603struct CollectionNesting {604 bool token_owner;604 bool token_owner;605 uint256[] ids;605 uint256[] ids;606}606}607607608/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.608/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.609struct CollectionLimit {609struct CollectionLimit {610 CollectionLimitField field;610 CollectionLimitField field;611 OptionUint value;611 OptionUint value;612}612}613613614/// @dev Ethereum representation of Optional value with uint256.614/// Ethereum representation of Optional value with uint256.615struct OptionUint {615struct OptionUint {616 bool status;616 bool status;617 uint256 value;617 uint256 value;618}618}619619620/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.620/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.621enum CollectionLimitField {621enum CollectionLimitField {622 /// @dev How many tokens can a user have on one account.622 /// How many tokens can a user have on one account.623 AccountTokenOwnership,623 AccountTokenOwnership,624 /// @dev How many bytes of data are available for sponsorship.624 /// How many bytes of data are available for sponsorship.625 SponsoredDataSize,625 SponsoredDataSize,626 /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]626 /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]627 SponsoredDataRateLimit,627 SponsoredDataRateLimit,628 /// @dev How many tokens can be mined into this collection.628 /// How many tokens can be mined into this collection.629 TokenLimit,629 TokenLimit,630 /// @dev Timeouts for transfer sponsoring.630 /// Timeouts for transfer sponsoring.631 SponsorTransferTimeout,631 SponsorTransferTimeout,632 /// @dev Timeout for sponsoring an approval in passed blocks.632 /// Timeout for sponsoring an approval in passed blocks.633 SponsorApproveTimeout,633 SponsorApproveTimeout,634 /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).634 /// Whether the collection owner of the collection can send tokens (which belong to other users).635 OwnerCanTransfer,635 OwnerCanTransfer,636 /// @dev Can the collection owner burn other people's tokens.636 /// Can the collection owner burn other people's tokens.637 OwnerCanDestroy,637 OwnerCanDestroy,638 /// @dev Is it possible to send tokens from this collection between users.638 /// Is it possible to send tokens from this collection between users.639 TransferEnabled639 TransferEnabled640}640}641641pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth127 }127 }128}128}129129130/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).130/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).131struct Property {131struct Property {132 string key;132 string key;133 bytes value;133 bytes value;134}134}135135136/// @dev Ethereum representation of Token Property Permissions.136/// Ethereum representation of Token Property Permissions.137struct TokenPropertyPermission {137struct TokenPropertyPermission {138 /// @dev Token property key.138 /// Token property key.139 string key;139 string key;140 /// @dev Token property permissions.140 /// Token property permissions.141 PropertyPermission[] permissions;141 PropertyPermission[] permissions;142}142}143143144/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.144/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.145struct PropertyPermission {145struct PropertyPermission {146 /// @dev TokenPermission field.146 /// TokenPermission field.147 TokenPermissionField code;147 TokenPermissionField code;148 /// @dev TokenPermission value.148 /// TokenPermission value.149 bool value;149 bool value;150}150}151151152/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.152/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.153enum TokenPermissionField {153enum TokenPermissionField {154 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]154 /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]155 Mutable,155 Mutable,156 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]156 /// Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]157 TokenOwner,157 TokenOwner,158 /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]158 /// Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]159 CollectionAdmin159 CollectionAdmin160}160}161161579 }579 }580}580}581581582/// @dev Cross account struct582/// Cross account struct583struct CrossAddress {583struct CrossAddress {584 address eth;584 address eth;585 uint256 sub;585 uint256 sub;586}586}587587588/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.588/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.589struct CollectionNestingPermission {589struct CollectionNestingPermission {590 CollectionPermissionField field;590 CollectionPermissionField field;591 bool value;591 bool value;592}592}593593594/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.594/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.595enum CollectionPermissionField {595enum CollectionPermissionField {596 /// @dev Owner of token can nest tokens under it.596 /// Owner of token can nest tokens under it.597 TokenOwner,597 TokenOwner,598 /// @dev Admin of token collection can nest tokens under token.598 /// Admin of token collection can nest tokens under token.599 CollectionAdmin599 CollectionAdmin600}600}601601602/// @dev Nested collections.602/// Nested collections.603struct CollectionNesting {603struct CollectionNesting {604 bool token_owner;604 bool token_owner;605 uint256[] ids;605 uint256[] ids;606}606}607607608/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.608/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.609struct CollectionLimit {609struct CollectionLimit {610 CollectionLimitField field;610 CollectionLimitField field;611 OptionUint value;611 OptionUint value;612}612}613613614/// @dev Ethereum representation of Optional value with uint256.614/// Ethereum representation of Optional value with uint256.615struct OptionUint {615struct OptionUint {616 bool status;616 bool status;617 uint256 value;617 uint256 value;618}618}619619620/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.620/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.621enum CollectionLimitField {621enum CollectionLimitField {622 /// @dev How many tokens can a user have on one account.622 /// How many tokens can a user have on one account.623 AccountTokenOwnership,623 AccountTokenOwnership,624 /// @dev How many bytes of data are available for sponsorship.624 /// How many bytes of data are available for sponsorship.625 SponsoredDataSize,625 SponsoredDataSize,626 /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]626 /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]627 SponsoredDataRateLimit,627 SponsoredDataRateLimit,628 /// @dev How many tokens can be mined into this collection.628 /// How many tokens can be mined into this collection.629 TokenLimit,629 TokenLimit,630 /// @dev Timeouts for transfer sponsoring.630 /// Timeouts for transfer sponsoring.631 SponsorTransferTimeout,631 SponsorTransferTimeout,632 /// @dev Timeout for sponsoring an approval in passed blocks.632 /// Timeout for sponsoring an approval in passed blocks.633 SponsorApproveTimeout,633 SponsorApproveTimeout,634 /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).634 /// Whether the collection owner of the collection can send tokens (which belong to other users).635 OwnerCanTransfer,635 OwnerCanTransfer,636 /// @dev Can the collection owner burn other people's tokens.636 /// Can the collection owner burn other people's tokens.637 OwnerCanDestroy,637 OwnerCanDestroy,638 /// @dev Is it possible to send tokens from this collection between users.638 /// Is it possible to send tokens from this collection between users.639 TransferEnabled639 TransferEnabled640}640}641641pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth128 }128 }129}129}130130131/// @dev Cross account struct131/// Cross account struct132struct CrossAddress {132struct CrossAddress {133 address eth;133 address eth;134 uint256 sub;134 uint256 sub;tests/src/eth/api/ContractHelpers.soldiffbeforeafterboth171 function toggleAllowlist(address contractAddress, bool enabled) external;171 function toggleAllowlist(address contractAddress, bool enabled) external;172}172}173173174/// @dev Ethereum representation of Optional value with CrossAddress.174/// Ethereum representation of Optional value with CrossAddress.175struct OptionCrossAddress {175struct OptionCrossAddress {176 bool status;176 bool status;177 CrossAddress value;177 CrossAddress value;178}178}179179180/// @dev Cross account struct180/// Cross account struct181struct CrossAddress {181struct CrossAddress {182 address eth;182 address eth;183 uint256 sub;183 uint256 sub;tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth279 function changeCollectionOwnerCross(CrossAddress memory newOwner) external;279 function changeCollectionOwnerCross(CrossAddress memory newOwner) external;280}280}281281282/// @dev Cross account struct282/// Cross account struct283struct CrossAddress {283struct CrossAddress {284 address eth;284 address eth;285 uint256 sub;285 uint256 sub;286}286}287287288/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.288/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.289struct CollectionNestingPermission {289struct CollectionNestingPermission {290 CollectionPermissionField field;290 CollectionPermissionField field;291 bool value;291 bool value;292}292}293293294/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.294/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.295enum CollectionPermissionField {295enum CollectionPermissionField {296 /// @dev Owner of token can nest tokens under it.296 /// Owner of token can nest tokens under it.297 TokenOwner,297 TokenOwner,298 /// @dev Admin of token collection can nest tokens under token.298 /// Admin of token collection can nest tokens under token.299 CollectionAdmin299 CollectionAdmin300}300}301301302/// @dev Nested collections.302/// Nested collections.303struct CollectionNesting {303struct CollectionNesting {304 bool token_owner;304 bool token_owner;305 uint256[] ids;305 uint256[] ids;306}306}307307308/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.308/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.309struct CollectionLimit {309struct CollectionLimit {310 CollectionLimitField field;310 CollectionLimitField field;311 OptionUint value;311 OptionUint value;312}312}313313314/// @dev Ethereum representation of Optional value with uint256.314/// Ethereum representation of Optional value with uint256.315struct OptionUint {315struct OptionUint {316 bool status;316 bool status;317 uint256 value;317 uint256 value;318}318}319319320/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.320/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.321enum CollectionLimitField {321enum CollectionLimitField {322 /// @dev How many tokens can a user have on one account.322 /// How many tokens can a user have on one account.323 AccountTokenOwnership,323 AccountTokenOwnership,324 /// @dev How many bytes of data are available for sponsorship.324 /// How many bytes of data are available for sponsorship.325 SponsoredDataSize,325 SponsoredDataSize,326 /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]326 /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]327 SponsoredDataRateLimit,327 SponsoredDataRateLimit,328 /// @dev How many tokens can be mined into this collection.328 /// How many tokens can be mined into this collection.329 TokenLimit,329 TokenLimit,330 /// @dev Timeouts for transfer sponsoring.330 /// Timeouts for transfer sponsoring.331 SponsorTransferTimeout,331 SponsorTransferTimeout,332 /// @dev Timeout for sponsoring an approval in passed blocks.332 /// Timeout for sponsoring an approval in passed blocks.333 SponsorApproveTimeout,333 SponsorApproveTimeout,334 /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).334 /// Whether the collection owner of the collection can send tokens (which belong to other users).335 OwnerCanTransfer,335 OwnerCanTransfer,336 /// @dev Can the collection owner burn other people's tokens.336 /// Can the collection owner burn other people's tokens.337 OwnerCanDestroy,337 OwnerCanDestroy,338 /// @dev Is it possible to send tokens from this collection between users.338 /// Is it possible to send tokens from this collection between users.339 TransferEnabled339 TransferEnabled340}340}341341342/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).342/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).343struct Property {343struct Property {344 string key;344 string key;345 bytes value;345 bytes value;tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth80 function property(uint256 tokenId, string memory key) external view returns (bytes memory);80 function property(uint256 tokenId, string memory key) external view returns (bytes memory);81}81}828283/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).83/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).84struct Property {84struct Property {85 string key;85 string key;86 bytes value;86 bytes value;87}87}888889/// @dev Ethereum representation of Token Property Permissions.89/// Ethereum representation of Token Property Permissions.90struct TokenPropertyPermission {90struct TokenPropertyPermission {91 /// @dev Token property key.91 /// Token property key.92 string key;92 string key;93 /// @dev Token property permissions.93 /// Token property permissions.94 PropertyPermission[] permissions;94 PropertyPermission[] permissions;95}95}969697/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.97/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.98struct PropertyPermission {98struct PropertyPermission {99 /// @dev TokenPermission field.99 /// TokenPermission field.100 TokenPermissionField code;100 TokenPermissionField code;101 /// @dev TokenPermission value.101 /// TokenPermission value.102 bool value;102 bool value;103}103}104104105/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.105/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.106enum TokenPermissionField {106enum TokenPermissionField {107 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]107 /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]108 Mutable,108 Mutable,109 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]109 /// Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]110 TokenOwner,110 TokenOwner,111 /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]111 /// Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]112 CollectionAdmin112 CollectionAdmin113}113}114114379 function changeCollectionOwnerCross(CrossAddress memory newOwner) external;379 function changeCollectionOwnerCross(CrossAddress memory newOwner) external;380}380}381381382/// @dev Cross account struct382/// Cross account struct383struct CrossAddress {383struct CrossAddress {384 address eth;384 address eth;385 uint256 sub;385 uint256 sub;386}386}387387388/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.388/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.389struct CollectionNestingPermission {389struct CollectionNestingPermission {390 CollectionPermissionField field;390 CollectionPermissionField field;391 bool value;391 bool value;392}392}393393394/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.394/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.395enum CollectionPermissionField {395enum CollectionPermissionField {396 /// @dev Owner of token can nest tokens under it.396 /// Owner of token can nest tokens under it.397 TokenOwner,397 TokenOwner,398 /// @dev Admin of token collection can nest tokens under token.398 /// Admin of token collection can nest tokens under token.399 CollectionAdmin399 CollectionAdmin400}400}401401402/// @dev Nested collections.402/// Nested collections.403struct CollectionNesting {403struct CollectionNesting {404 bool token_owner;404 bool token_owner;405 uint256[] ids;405 uint256[] ids;406}406}407407408/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.408/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.409struct CollectionLimit {409struct CollectionLimit {410 CollectionLimitField field;410 CollectionLimitField field;411 OptionUint value;411 OptionUint value;412}412}413413414/// @dev Ethereum representation of Optional value with uint256.414/// Ethereum representation of Optional value with uint256.415struct OptionUint {415struct OptionUint {416 bool status;416 bool status;417 uint256 value;417 uint256 value;418}418}419419420/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.420/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.421enum CollectionLimitField {421enum CollectionLimitField {422 /// @dev How many tokens can a user have on one account.422 /// How many tokens can a user have on one account.423 AccountTokenOwnership,423 AccountTokenOwnership,424 /// @dev How many bytes of data are available for sponsorship.424 /// How many bytes of data are available for sponsorship.425 SponsoredDataSize,425 SponsoredDataSize,426 /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]426 /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]427 SponsoredDataRateLimit,427 SponsoredDataRateLimit,428 /// @dev How many tokens can be mined into this collection.428 /// How many tokens can be mined into this collection.429 TokenLimit,429 TokenLimit,430 /// @dev Timeouts for transfer sponsoring.430 /// Timeouts for transfer sponsoring.431 SponsorTransferTimeout,431 SponsorTransferTimeout,432 /// @dev Timeout for sponsoring an approval in passed blocks.432 /// Timeout for sponsoring an approval in passed blocks.433 SponsorApproveTimeout,433 SponsorApproveTimeout,434 /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).434 /// Whether the collection owner of the collection can send tokens (which belong to other users).435 OwnerCanTransfer,435 OwnerCanTransfer,436 /// @dev Can the collection owner burn other people's tokens.436 /// Can the collection owner burn other people's tokens.437 OwnerCanDestroy,437 OwnerCanDestroy,438 /// @dev Is it possible to send tokens from this collection between users.438 /// Is it possible to send tokens from this collection between users.439 TransferEnabled439 TransferEnabled440}440}441441tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth80 function property(uint256 tokenId, string memory key) external view returns (bytes memory);80 function property(uint256 tokenId, string memory key) external view returns (bytes memory);81}81}828283/// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).83/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).84struct Property {84struct Property {85 string key;85 string key;86 bytes value;86 bytes value;87}87}888889/// @dev Ethereum representation of Token Property Permissions.89/// Ethereum representation of Token Property Permissions.90struct TokenPropertyPermission {90struct TokenPropertyPermission {91 /// @dev Token property key.91 /// Token property key.92 string key;92 string key;93 /// @dev Token property permissions.93 /// Token property permissions.94 PropertyPermission[] permissions;94 PropertyPermission[] permissions;95}95}969697/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.97/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.98struct PropertyPermission {98struct PropertyPermission {99 /// @dev TokenPermission field.99 /// TokenPermission field.100 TokenPermissionField code;100 TokenPermissionField code;101 /// @dev TokenPermission value.101 /// TokenPermission value.102 bool value;102 bool value;103}103}104104105/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.105/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.106enum TokenPermissionField {106enum TokenPermissionField {107 /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]107 /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]108 Mutable,108 Mutable,109 /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]109 /// Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]110 TokenOwner,110 TokenOwner,111 /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]111 /// Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]112 CollectionAdmin112 CollectionAdmin113}113}114114379 function changeCollectionOwnerCross(CrossAddress memory newOwner) external;379 function changeCollectionOwnerCross(CrossAddress memory newOwner) external;380}380}381381382/// @dev Cross account struct382/// Cross account struct383struct CrossAddress {383struct CrossAddress {384 address eth;384 address eth;385 uint256 sub;385 uint256 sub;386}386}387387388/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.388/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.389struct CollectionNestingPermission {389struct CollectionNestingPermission {390 CollectionPermissionField field;390 CollectionPermissionField field;391 bool value;391 bool value;392}392}393393394/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.394/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.395enum CollectionPermissionField {395enum CollectionPermissionField {396 /// @dev Owner of token can nest tokens under it.396 /// Owner of token can nest tokens under it.397 TokenOwner,397 TokenOwner,398 /// @dev Admin of token collection can nest tokens under token.398 /// Admin of token collection can nest tokens under token.399 CollectionAdmin399 CollectionAdmin400}400}401401402/// @dev Nested collections.402/// Nested collections.403struct CollectionNesting {403struct CollectionNesting {404 bool token_owner;404 bool token_owner;405 uint256[] ids;405 uint256[] ids;406}406}407407408/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.408/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.409struct CollectionLimit {409struct CollectionLimit {410 CollectionLimitField field;410 CollectionLimitField field;411 OptionUint value;411 OptionUint value;412}412}413413414/// @dev Ethereum representation of Optional value with uint256.414/// Ethereum representation of Optional value with uint256.415struct OptionUint {415struct OptionUint {416 bool status;416 bool status;417 uint256 value;417 uint256 value;418}418}419419420/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.420/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.421enum CollectionLimitField {421enum CollectionLimitField {422 /// @dev How many tokens can a user have on one account.422 /// How many tokens can a user have on one account.423 AccountTokenOwnership,423 AccountTokenOwnership,424 /// @dev How many bytes of data are available for sponsorship.424 /// How many bytes of data are available for sponsorship.425 SponsoredDataSize,425 SponsoredDataSize,426 /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]426 /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]427 SponsoredDataRateLimit,427 SponsoredDataRateLimit,428 /// @dev How many tokens can be mined into this collection.428 /// How many tokens can be mined into this collection.429 TokenLimit,429 TokenLimit,430 /// @dev Timeouts for transfer sponsoring.430 /// Timeouts for transfer sponsoring.431 SponsorTransferTimeout,431 SponsorTransferTimeout,432 /// @dev Timeout for sponsoring an approval in passed blocks.432 /// Timeout for sponsoring an approval in passed blocks.433 SponsorApproveTimeout,433 SponsorApproveTimeout,434 /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).434 /// Whether the collection owner of the collection can send tokens (which belong to other users).435 OwnerCanTransfer,435 OwnerCanTransfer,436 /// @dev Can the collection owner burn other people's tokens.436 /// Can the collection owner burn other people's tokens.437 OwnerCanDestroy,437 OwnerCanDestroy,438 /// @dev Is it possible to send tokens from this collection between users.438 /// Is it possible to send tokens from this collection between users.439 TransferEnabled439 TransferEnabled440}440}441441tests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth79 ) external returns (bool);79 ) external returns (bool);80}80}818182/// @dev Cross account struct82/// Cross account struct83struct CrossAddress {83struct CrossAddress {84 address eth;84 address eth;85 uint256 sub;85 uint256 sub;