difftreelog
doc: clarification review
in: master
3 files changed
crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth161617#![allow(dead_code)]17#![allow(dead_code)]1819// NOTE: In order to understand this Rust macro better, first read this chapter20// about Procedural Macros in Rust book:21// https://doc.rust-lang.org/reference/procedural-macros.html182219use quote::{quote, ToTokens};23use quote::{quote, ToTokens};20use inflector::cases;24use inflector::cases;485 Pure,489 Pure,486}490}487491492/// Group all keywords for this macro. Usage example:493/// #[solidity_interface(name = "B", inline_is(A))]488mod kw {494mod kw {489 syn::custom_keyword!(weight);495 syn::custom_keyword!(weight);490496498 syn::custom_keyword!(rename_selector);504 syn::custom_keyword!(rename_selector);499}505}500506507/// Rust methods are parsed into this structure when Solidity code is generated501struct Method {508struct Method {502 name: Ident,509 name: Ident,503 camel_name: String,510 camel_name: String,crates/evm-coder/src/execution.rsdiffbeforeafterboth78 info.weight - self.calc_actual_weight(info)78 info.weight - self.calc_actual_weight(info)79 }79 }808081 /// Calculate actual cansumed weight, saturating to weight reported81 /// Calculate actual consumed weight, saturating to weight reported82 /// pre-dispatch82 /// pre-dispatch83 pub fn calc_actual_weight(&self, info: &DispatchInfo) -> Weight {83 pub fn calc_actual_weight(&self, info: &DispatchInfo) -> Weight {84 if let Some(actual_weight) = self.actual_weight {84 if let Some(actual_weight) = self.actual_weight {crates/evm-coder/src/lib.rsdiffbeforeafterboth34///34///35/// `#[solidity_interface(name, is, inline_is, events)]`35/// `#[solidity_interface(name, is, inline_is, events)]`36/// - *name* - used in generated code, and for Call enum name36/// - *name* - used in generated code, and for Call enum name37/// - *is* - used to provide call inheritance, not found methods will be delegated to all contracts37/// - *is* - used to provide inheritance in Solidity38/// specified in is/inline_is38/// - *inline_is* - same as `is`, but ERC165::SupportsInterface will work differently: For `is` SupportsInterface(A) will return true39/// - *inline_is* - same as is, but selectors for passed contracts will be used by derived ERC16539/// 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)`40/// SupportsInterface(A) will internally create a new interface that combines all methods of A and B, so SupportsInterface(A) will return40/// implementation41/// false.41///42///42/// `#[weight(value)]`43/// `#[weight(value)]`43/// Can be added to every method of impl block, used for deriving [`crate::Weighted`], which44/// Can be added to every method of impl block, used for deriving [`crate::Weighted`], which44/// is used by substrate bridge.45/// is used by substrate bridge.45/// - *value*: expression, which evaluates to weight required to call this method.46/// - *value*: expression, which evaluates to weight required to call this method.46/// This expression can use call arguments to calculate non-constant execution time.47/// This expression can use call arguments to calculate non-constant execution time.47/// This expression should evaluate faster than actual execution does, and may provide worser case48/// This expression should evaluate faster than actual execution does, and may provide worse case48/// than one is called.49/// than one is called.49///50///50/// `#[solidity_interface(rename_selector)]`51/// `#[solidity_interface(rename_selector)]`