difftreelog
Merge branch 'develop' into feature/ci-refactoring
in: master
6 files changed
crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth--- a/crates/evm-coder/procedural/src/solidity_interface.rs
+++ b/crates/evm-coder/procedural/src/solidity_interface.rs
@@ -718,7 +718,11 @@
}
}
} else {
- quote! {#pascal_name}
+ quote! {
+ #(#[doc = #docs])*
+ #[allow(missing_docs)]
+ #pascal_name
+ }
}
}
@@ -788,6 +792,7 @@
quote! {
#call_name::#pascal_name #matcher => {
+ #[allow(deprecated)]
let result = #receiver #name(
#(
#args,
crates/evm-coder/procedural/src/to_log.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use inflector::cases;18use syn::{Data, DeriveInput, Field, Fields, Ident, Variant, spanned::Spanned};19use std::fmt::Write;20use quote::quote;2122use crate::{parse_ident_from_path, parse_ident_from_type, snake_ident_to_screaming};2324struct EventField {25 name: Ident,26 camel_name: String,27 ty: Ident,28 indexed: bool,29}3031impl EventField {32 fn try_from(field: &Field) -> syn::Result<Self> {33 let name = field.ident.as_ref().unwrap();34 let ty = parse_ident_from_type(&field.ty, false)?;35 let mut indexed = false;36 for attr in &field.attrs {37 if let Ok(ident) = parse_ident_from_path(&attr.path, false) {38 if ident == "indexed" {39 indexed = true;40 }41 }42 }43 Ok(Self {44 name: name.to_owned(),45 camel_name: cases::camelcase::to_camel_case(&name.to_string()),46 ty: ty.to_owned(),47 indexed,48 })49 }50 fn expand_solidity_argument(&self) -> proc_macro2::TokenStream {51 let camel_name = &self.camel_name;52 let ty = &self.ty;53 let indexed = self.indexed;54 quote! {55 <SolidityEventArgument<#ty>>::new(#indexed, #camel_name)56 }57 }58}5960struct Event {61 name: Ident,62 name_screaming: Ident,63 fields: Vec<EventField>,64 selector: [u8; 32],65 selector_str: String,66}6768impl Event {69 fn try_from(variant: &Variant) -> syn::Result<Self> {70 let name = &variant.ident;71 let name_screaming = snake_ident_to_screaming(name);7273 let named = match &variant.fields {74 Fields::Named(named) => named,75 _ => {76 return Err(syn::Error::new(77 variant.fields.span(),78 "expected named fields",79 ))80 }81 };82 let mut fields = Vec::new();83 for field in &named.named {84 fields.push(EventField::try_from(field)?);85 }86 if fields.iter().filter(|f| f.indexed).count() > 3 {87 return Err(syn::Error::new(88 variant.fields.span(),89 "events can have at most 4 indexed fields (1 indexed field is reserved for event signature)"90 ));91 }92 let mut selector_str = format!("{}(", name);93 for (i, arg) in fields.iter().enumerate() {94 if i != 0 {95 write!(selector_str, ",").unwrap();96 }97 write!(selector_str, "{}", arg.ty).unwrap();98 }99 selector_str.push(')');100 let selector = crate::event_selector_str(&selector_str);101102 Ok(Self {103 name: name.to_owned(),104 name_screaming,105 fields,106 selector,107 selector_str,108 })109 }110111 fn expand_serializers(&self) -> proc_macro2::TokenStream {112 let name = &self.name;113 let name_screaming = &self.name_screaming;114 let fields = self.fields.iter().map(|f| &f.name);115116 let indexed = self.fields.iter().filter(|f| f.indexed).map(|f| &f.name);117 let plain = self.fields.iter().filter(|f| !f.indexed).map(|f| &f.name);118119 quote! {120 Self::#name {#(121 #fields,122 )*} => {123 topics.push(topic::from(Self::#name_screaming));124 #(125 topics.push(#indexed.to_topic());126 )*127 #(128 #plain.abi_write(&mut writer);129 )*130 }131 }132 }133134 fn expand_consts(&self) -> proc_macro2::TokenStream {135 let name_screaming = &self.name_screaming;136 let selector_str = &self.selector_str;137 let selector = &self.selector;138139 quote! {140 #[doc = #selector_str]141 const #name_screaming: [u8; 32] = [#(142 #selector,143 )*];144 }145 }146147 fn expand_solidity_function(&self) -> proc_macro2::TokenStream {148 let name = self.name.to_string();149 let args = self.fields.iter().map(EventField::expand_solidity_argument);150 quote! {151 SolidityEvent {152 name: #name,153 args: (154 #(155 #args,156 )*157 ),158 }159 }160 }161}162163pub struct Events {164 name: Ident,165 events: Vec<Event>,166}167168impl Events {169 pub fn try_from(data: &DeriveInput) -> syn::Result<Self> {170 let name = &data.ident;171 let en = match &data.data {172 Data::Enum(en) => en,173 _ => return Err(syn::Error::new(data.span(), "expected enum")),174 };175 let mut events = Vec::new();176 for variant in &en.variants {177 events.push(Event::try_from(variant)?);178 }179 Ok(Self {180 name: name.to_owned(),181 events,182 })183 }184 pub fn expand(&self) -> proc_macro2::TokenStream {185 let name = &self.name;186187 let consts = self.events.iter().map(Event::expand_consts);188 let serializers = self.events.iter().map(Event::expand_serializers);189 let solidity_name = self.name.to_string();190 let solidity_functions = self.events.iter().map(Event::expand_solidity_function);191192 quote! {193 impl #name {194 #(195 #consts196 )*197198 pub fn generate_solidity_interface(tc: &evm_coder::solidity::TypeCollector, is_impl: bool) {199 use evm_coder::solidity::*;200 use core::fmt::Write;201 let interface = SolidityInterface {202 docs: &[],203 selector: [0; 4],204 name: #solidity_name,205 is: &[],206 functions: (#(207 #solidity_functions,208 )*),209 };210 let mut out = string::new();211 out.push_str("/// @dev inlined interface\n");212 let _ = interface.format(is_impl, &mut out, tc);213 tc.collect(out);214 }215 }216217 #[automatically_derived]218 impl ::evm_coder::events::ToLog for #name {219 fn to_log(&self, contract: address) -> ::ethereum::Log {220 use ::evm_coder::events::ToTopic;221 use ::evm_coder::abi::AbiWrite;222 let mut writer = ::evm_coder::abi::AbiWriter::new();223 let mut topics = Vec::new();224 match self {225 #(226 #serializers,227 )*228 }229 ::ethereum::Log {230 address: contract,231 topics,232 data: writer.finish(),233 }234 }235 }236 }237 }238}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use inflector::cases;18use syn::{Data, DeriveInput, Field, Fields, Ident, Variant, spanned::Spanned};19use std::fmt::Write;20use quote::quote;2122use crate::{parse_ident_from_path, parse_ident_from_type, snake_ident_to_screaming};2324struct EventField {25 name: Ident,26 camel_name: String,27 ty: Ident,28 indexed: bool,29}3031impl EventField {32 fn try_from(field: &Field) -> syn::Result<Self> {33 let name = field.ident.as_ref().unwrap();34 let ty = parse_ident_from_type(&field.ty, false)?;35 let mut indexed = false;36 for attr in &field.attrs {37 if let Ok(ident) = parse_ident_from_path(&attr.path, false) {38 if ident == "indexed" {39 indexed = true;40 }41 }42 }43 Ok(Self {44 name: name.to_owned(),45 camel_name: cases::camelcase::to_camel_case(&name.to_string()),46 ty: ty.to_owned(),47 indexed,48 })49 }50 fn expand_solidity_argument(&self) -> proc_macro2::TokenStream {51 let camel_name = &self.camel_name;52 let ty = &self.ty;53 let indexed = self.indexed;54 quote! {55 <SolidityEventArgument<#ty>>::new(#indexed, #camel_name)56 }57 }58}5960struct Event {61 name: Ident,62 name_screaming: Ident,63 fields: Vec<EventField>,64 selector: [u8; 32],65 selector_str: String,66}6768impl Event {69 fn try_from(variant: &Variant) -> syn::Result<Self> {70 let name = &variant.ident;71 let name_screaming = snake_ident_to_screaming(name);7273 let named = match &variant.fields {74 Fields::Named(named) => named,75 _ => {76 return Err(syn::Error::new(77 variant.fields.span(),78 "expected named fields",79 ))80 }81 };82 let mut fields = Vec::new();83 for field in &named.named {84 fields.push(EventField::try_from(field)?);85 }86 if fields.iter().filter(|f| f.indexed).count() > 3 {87 return Err(syn::Error::new(88 variant.fields.span(),89 "events can have at most 4 indexed fields (1 indexed field is reserved for event signature)"90 ));91 }92 let mut selector_str = format!("{}(", name);93 for (i, arg) in fields.iter().enumerate() {94 if i != 0 {95 write!(selector_str, ",").unwrap();96 }97 write!(selector_str, "{}", arg.ty).unwrap();98 }99 selector_str.push(')');100 let selector = crate::event_selector_str(&selector_str);101102 Ok(Self {103 name: name.to_owned(),104 name_screaming,105 fields,106 selector,107 selector_str,108 })109 }110111 fn expand_serializers(&self) -> proc_macro2::TokenStream {112 let name = &self.name;113 let name_screaming = &self.name_screaming;114 let fields = self.fields.iter().map(|f| &f.name);115116 let indexed = self.fields.iter().filter(|f| f.indexed).map(|f| &f.name);117 let plain = self.fields.iter().filter(|f| !f.indexed).map(|f| &f.name);118119 quote! {120 Self::#name {#(121 #fields,122 )*} => {123 topics.push(topic::from(Self::#name_screaming));124 #(125 topics.push(#indexed.to_topic());126 )*127 #(128 #plain.abi_write(&mut writer);129 )*130 }131 }132 }133134 fn expand_consts(&self) -> proc_macro2::TokenStream {135 let name_screaming = &self.name_screaming;136 let selector_str = &self.selector_str;137 let selector = &self.selector;138139 quote! {140 #[doc = #selector_str]141 const #name_screaming: [u8; 32] = [#(142 #selector,143 )*];144 }145 }146147 fn expand_solidity_function(&self) -> proc_macro2::TokenStream {148 let name = self.name.to_string();149 let args = self.fields.iter().map(EventField::expand_solidity_argument);150 quote! {151 SolidityEvent {152 name: #name,153 args: (154 #(155 #args,156 )*157 ),158 }159 }160 }161}162163pub struct Events {164 name: Ident,165 events: Vec<Event>,166}167168impl Events {169 pub fn try_from(data: &DeriveInput) -> syn::Result<Self> {170 let name = &data.ident;171 let en = match &data.data {172 Data::Enum(en) => en,173 _ => return Err(syn::Error::new(data.span(), "expected enum")),174 };175 let mut events = Vec::new();176 for variant in &en.variants {177 events.push(Event::try_from(variant)?);178 }179 Ok(Self {180 name: name.to_owned(),181 events,182 })183 }184 pub fn expand(&self) -> proc_macro2::TokenStream {185 let name = &self.name;186187 let consts = self.events.iter().map(Event::expand_consts);188 let serializers = self.events.iter().map(Event::expand_serializers);189 let solidity_name = self.name.to_string();190 let solidity_functions = self.events.iter().map(Event::expand_solidity_function);191192 quote! {193 impl #name {194 #(195 #consts196 )*197 /// Generate solidity definitions for methods described in this interface198 pub fn generate_solidity_interface(tc: &evm_coder::solidity::TypeCollector, is_impl: bool) {199 use evm_coder::solidity::*;200 use core::fmt::Write;201 let interface = SolidityInterface {202 docs: &[],203 selector: [0; 4],204 name: #solidity_name,205 is: &[],206 functions: (#(207 #solidity_functions,208 )*),209 };210 let mut out = string::new();211 out.push_str("/// @dev inlined interface\n");212 let _ = interface.format(is_impl, &mut out, tc);213 tc.collect(out);214 }215 }216217 #[automatically_derived]218 impl ::evm_coder::events::ToLog for #name {219 fn to_log(&self, contract: address) -> ::ethereum::Log {220 use ::evm_coder::events::ToTopic;221 use ::evm_coder::abi::AbiWrite;222 let mut writer = ::evm_coder::abi::AbiWriter::new();223 let mut topics = Vec::new();224 match self {225 #(226 #serializers,227 )*228 }229 ::ethereum::Log {230 address: contract,231 topics,232 data: writer.finish(),233 }234 }235 }236 }237 }238}pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -64,6 +64,7 @@
/// Does not always represent a full collection, for RFT it is either
/// collection (Implementing ERC721), or specific collection token (Implementing ERC20).
pub trait CommonEvmHandler {
+ /// Raw compiled binary code of the contract stub
const CODE: &'static [u8];
/// Call precompiled handle.
pallets/common/src/weights.rsdiffbeforeafterboth--- a/pallets/common/src/weights.rs
+++ b/pallets/common/src/weights.rs
@@ -26,6 +26,7 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
+#![allow(missing_docs)]
#![allow(clippy::unnecessary_cast)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
pallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/lib.rs
+++ b/pallets/evm-contract-helpers/src/lib.rs
@@ -172,7 +172,7 @@
>;
#[pallet::event]
- #[pallet::generate_deposit(pub fn deposit_event)]
+ #[pallet::generate_deposit(fn deposit_event)]
pub enum Event<T: Config> {
/// Contract sponsor was set.
ContractSponsorSet(
@@ -350,6 +350,7 @@
pub fn sponsoring_mode(contract: H160) -> SponsoringModeT {
<SponsoringMode<T>>::get(contract)
.or_else(|| {
+ #[allow(deprecated)]
<SelfSponsoring<T>>::get(contract).then(|| SponsoringModeT::Allowlisted)
})
.unwrap_or_default()
@@ -362,6 +363,7 @@
} else {
<SponsoringMode<T>>::insert(contract, mode);
}
+ #[allow(deprecated)]
<SelfSponsoring<T>>::remove(contract)
}
@@ -424,6 +426,7 @@
_ => return None,
})
}
+ #[allow(dead_code)]
fn to_eth(self) -> u8 {
match self {
SponsoringModeT::Disabled => 0,
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -137,7 +137,6 @@
/// for the convenience of database access. Notably contains the token metadata.
#[struct_versioning::versioned(version = 2, upper)]
#[derive(Encode, Decode, Default, TypeInfo, MaxEncodedLen)]
-#[deprecated(since = "0.2.0", note = "ItemData is no more contains usefull data")]
pub struct ItemData {
pub const_data: BoundedVec<u8, CustomDataLimit>,
@@ -279,7 +278,8 @@
fn on_runtime_upgrade() -> Weight {
let storage_version = StorageVersion::get::<Pallet<T>>();
if storage_version < StorageVersion::new(2) {
- <TokenData<T>>::remove_all(None);
+ #[allow(deprecated)]
+ let _ = <TokenData<T>>::clear(u32::MAX, None);
}
StorageVersion::new(2).put::<Pallet<T>>();