From 5af31166e6dbea77661c2cc18234e08149a64c3c Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Fri, 19 Aug 2022 16:02:12 +0000 Subject: [PATCH] doc: clarification review --- --- a/crates/evm-coder/procedural/src/solidity_interface.rs +++ b/crates/evm-coder/procedural/src/solidity_interface.rs @@ -16,6 +16,10 @@ #![allow(dead_code)] +// NOTE: In order to understand this Rust macro better, first read this chapter +// about Procedural Macros in Rust book: +// https://doc.rust-lang.org/reference/procedural-macros.html + use quote::{quote, ToTokens}; use inflector::cases; use std::fmt::Write; @@ -485,6 +489,8 @@ Pure, } +/// Group all keywords for this macro. Usage example: +/// #[solidity_interface(name = "B", inline_is(A))] mod kw { syn::custom_keyword!(weight); @@ -498,6 +504,7 @@ syn::custom_keyword!(rename_selector); } +/// Rust methods are parsed into this structure when Solidity code is generated struct Method { name: Ident, camel_name: String, --- a/crates/evm-coder/src/execution.rs +++ b/crates/evm-coder/src/execution.rs @@ -78,7 +78,7 @@ info.weight - self.calc_actual_weight(info) } - /// Calculate actual cansumed weight, saturating to weight reported + /// Calculate actual consumed weight, saturating to weight reported /// pre-dispatch pub fn calc_actual_weight(&self, info: &DispatchInfo) -> Weight { if let Some(actual_weight) = self.actual_weight { --- a/crates/evm-coder/src/lib.rs +++ b/crates/evm-coder/src/lib.rs @@ -34,17 +34,18 @@ /// /// `#[solidity_interface(name, is, inline_is, events)]` /// - *name* - used in generated code, and for Call enum name -/// - *is* - used to provide call inheritance, not found methods will be delegated to all contracts -/// specified in is/inline_is -/// - *inline_is* - same as is, but selectors for passed contracts will be used by derived ERC165 -/// implementation +/// - *is* - used to provide inheritance in Solidity +/// - *inline_is* - same as `is`, but ERC165::SupportsInterface will work differently: For `is` SupportsInterface(A) will return true +/// if A is one of the interfaces the contract is inherited from (e.g. B is created as `is(A)`). If B is created as `inline_is(A)` +/// SupportsInterface(A) will internally create a new interface that combines all methods of A and B, so SupportsInterface(A) will return +/// false. /// /// `#[weight(value)]` /// Can be added to every method of impl block, used for deriving [`crate::Weighted`], which /// is used by substrate bridge. /// - *value*: expression, which evaluates to weight required to call this method. /// This expression can use call arguments to calculate non-constant execution time. -/// This expression should evaluate faster than actual execution does, and may provide worser case +/// This expression should evaluate faster than actual execution does, and may provide worse case /// than one is called. /// /// `#[solidity_interface(rename_selector)]` -- gitstuff