git.delta.rocks / unique-network / refs/commits / 7bd00bbda0e0

difftreelog

Merge pull request #704 from UniqueNetwork/feature/AbiType_remake

ut-akuznetsov2022-11-10parents: #20c9944 #2ca9f67.patch.diff
in: master
AbiType

17 files changed

modifiedcrates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth
328 }328 }
329}329}
330330
331trait AbiType {331trait AbiTypeHelper {
332 fn plain(&self) -> syn::Result<&Ident>;332 fn plain(&self) -> syn::Result<&Ident>;
333 fn is_value(&self) -> bool;333 fn is_value(&self) -> bool;
334 fn is_caller(&self) -> bool;334 fn is_caller(&self) -> bool;
335 fn is_special(&self) -> bool;335 fn is_special(&self) -> bool;
336}336}
337337
338impl AbiType for Type {338impl AbiTypeHelper for Type {
339 fn plain(&self) -> syn::Result<&Ident> {339 fn plain(&self) -> syn::Result<&Ident> {
340 let path = parse_path(self)?;340 let path = parse_path(self)?;
341 let segment = parse_path_segment(path)?;341 let segment = parse_path_segment(path)?;
deletedcrates/evm-coder/src/abi.rsdiffbeforeafterboth

no changes

addedcrates/evm-coder/src/abi/impls.rsdiffbeforeafterboth

no changes

addedcrates/evm-coder/src/abi/mod.rsdiffbeforeafterboth

no changes

addedcrates/evm-coder/src/abi/test.rsdiffbeforeafterboth

no changes

addedcrates/evm-coder/src/abi/traits.rsdiffbeforeafterboth

no changes

modifiedcrates/evm-coder/src/lib.rsdiffbeforeafterboth
121 use alloc::{vec::Vec};121 use alloc::{vec::Vec};
122 use pallet_evm::account::CrossAccountId;122 use pallet_evm::account::CrossAccountId;
123 use primitive_types::{U256, H160, H256};123 use primitive_types::{U256, H160, H256};
124 use core::str::from_utf8;
125
126 use crate::custom_signature::SignatureUnit;
127
128 pub trait Signature {
129 const SIGNATURE: SignatureUnit;
130
131 fn as_str() -> &'static str {
132 from_utf8(&Self::SIGNATURE.data[..Self::SIGNATURE.len]).expect("bad utf-8")
133 }
134 }
135
136 impl Signature for bool {
137 const SIGNATURE: SignatureUnit = make_signature!(new fixed("bool"));
138 }
139
140 macro_rules! define_simple_type {
141 (type $ident:ident = $ty:ty) => {
142 pub type $ident = $ty;
143 impl Signature for $ty {
144 const SIGNATURE: SignatureUnit = make_signature!(new fixed(stringify!($ident)));
145 }
146 };
147 }
148124
149 define_simple_type!(type address = H160);125 pub type address = H160;
150
151 define_simple_type!(type uint8 = u8);126 pub type uint8 = u8;
152 define_simple_type!(type uint16 = u16);127 pub type uint16 = u16;
153 define_simple_type!(type uint32 = u32);128 pub type uint32 = u32;
154 define_simple_type!(type uint64 = u64);129 pub type uint64 = u64;
155 define_simple_type!(type uint128 = u128);130 pub type uint128 = u128;
156 define_simple_type!(type uint256 = U256);131 pub type uint256 = U256;
157 define_simple_type!(type bytes4 = [u8; 4]);132 pub type bytes4 = [u8; 4];
158
159 define_simple_type!(type topic = H256);133 pub type topic = H256;
160134
161 #[cfg(not(feature = "std"))]135 #[cfg(not(feature = "std"))]
162 define_simple_type!(type string = ::alloc::string::String);136 pub type string = ::alloc::string::String;
163 #[cfg(feature = "std")]137 #[cfg(feature = "std")]
164 define_simple_type!(type string = ::std::string::String);138 pub type string = ::std::string::String;
165139
166 #[derive(Default, Debug, PartialEq)]140 #[derive(Default, Debug, PartialEq)]
167 pub struct bytes(pub Vec<u8>);141 pub struct bytes(pub Vec<u8>);
168 impl Signature for bytes {
169 const SIGNATURE: SignatureUnit = make_signature!(new fixed("bytes"));
170 }
171142
172 /// Solidity doesn't have `void` type, however we have special implementation143 /// Solidity doesn't have `void` type, however we have special implementation
173 /// for empty tuple return type144 /// for empty tuple return type
259 }230 }
260 }231 }
261
262 impl Signature for EthCrossAccount {
263 const SIGNATURE: SignatureUnit = make_signature!(new fixed("(address,uint256)"));
264 }
265232
266 /// Convert `CrossAccountId` to `uint256`.233 /// Convert `CrossAccountId` to `uint256`.
267 pub fn convert_cross_account_to_uint256<T: pallet_evm::account::Config>(234 pub fn convert_cross_account_to_uint256<T: pallet_evm::account::Config>(
modifiedcrates/evm-coder/tests/random.rsdiffbeforeafterboth
17#![allow(dead_code)] // This test only checks that macros is not panicking17#![allow(dead_code)] // This test only checks that macros is not panicking
1818
19use evm_coder::{ToLog, execution::Result, solidity_interface, types::*, solidity, weight};19use evm_coder::{
20use evm_coder::{types::Signature};20 abi::AbiType, ToLog, execution::Result, solidity_interface, types::*, solidity, weight,
21};
2122
22pub struct Impls;23pub struct Impls;
modifiedcrates/evm-coder/tests/solidity_generation.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17use evm_coder::{execution::Result, generate_stubgen, solidity_interface, types::*};17use evm_coder::{abi::AbiType, execution::Result, generate_stubgen, solidity_interface, types::*};
18use evm_coder::{types::Signature};
1918
20pub struct ERC20;19pub struct ERC20;
2120
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
17//! This module contains the implementation of pallet methods for evm.17//! This module contains the implementation of pallet methods for evm.
1818
19use evm_coder::{19use evm_coder::{
20 abi::AbiType,
20 solidity_interface, solidity, ToLog,21 solidity_interface, solidity, ToLog,
21 types::*,22 types::*,
22 execution::{Result, Error},23 execution::{Result, Error},
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
19extern crate alloc;19extern crate alloc;
20use core::marker::PhantomData;20use core::marker::PhantomData;
21use evm_coder::{21use evm_coder::{
22 abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,22 abi::{AbiWriter, AbiType},
23 execution::Result,
24 generate_stubgen, solidity_interface,
25 types::*,
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};
21use core::convert::TryInto;21use core::convert::TryInto;
22use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};22use evm_coder::{
23 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight,
24};
23use up_data_structs::CollectionMode;25use up_data_structs::CollectionMode;
24use pallet_common::erc::{CommonEvmHandler, PrecompileResult};26use pallet_common::erc::{CommonEvmHandler, PrecompileResult};
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
25 convert::TryInto,25 convert::TryInto,
26};26};
27use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};27use evm_coder::{
28 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,
29 weight,
30};
28use frame_support::BoundedVec;31use frame_support::BoundedVec;
29use up_data_structs::{32use up_data_structs::{
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
26 convert::TryInto,26 convert::TryInto,
27};27};
28use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};28use evm_coder::{
29 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,
30 weight,
31};
29use frame_support::{BoundedBTreeMap, BoundedVec};32use frame_support::{BoundedBTreeMap, BoundedVec};
30use pallet_common::{33use pallet_common::{
modifiedpallets/refungible/src/erc_token.rsdiffbeforeafterboth
30 ops::Deref,30 ops::Deref,
31};31};
32use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};32use evm_coder::{
33 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight,
34};
33use pallet_common::{35use pallet_common::{
34 CommonWeightInfo,36 CommonWeightInfo,
modifiedpallets/unique/Cargo.tomldiffbeforeafterboth

no syntactic changes

modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
19use core::marker::PhantomData;19use core::marker::PhantomData;
20use ethereum as _;20use ethereum as _;
21use evm_coder::{execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};21use evm_coder::{
22 abi::AbiType, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight,
23};
22use frame_support::traits::Get;24use frame_support::traits::Get;
23use crate::Pallet;25use crate::Pallet;
2426
25use pallet_common::{27use pallet_common::{
26 CollectionById,28 CollectionById,
27 dispatch::CollectionDispatch,29 dispatch::CollectionDispatch,
28 erc::{static_property::key, CollectionHelpersEvents},30 erc::{CollectionHelpersEvents, static_property::key},
29 Pallet as PalletCommon,31 Pallet as PalletCommon,
30};32};
31use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};33use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};