difftreelog
feat Add custum signature with unlimited nesting.
in: master
17 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
@@ -21,7 +21,7 @@
// https://doc.rust-lang.org/reference/procedural-macros.html
use proc_macro2::{TokenStream, Group};
-use quote::{quote, ToTokens};
+use quote::{quote, ToTokens, format_ident};
use inflector::cases;
use std::fmt::Write;
use syn::{
@@ -725,25 +725,20 @@
}
}
- fn expand_selector(&self) -> proc_macro2::TokenStream {
- let custom_signature = self.expand_custom_signature();
- quote! {
- {
- let a = ::evm_coder::sha3_const::Keccak256::new()
- .update(#custom_signature.as_bytes())
- .finalize();
- [a[0], a[1], a[2], a[3]]
- }
- }
- }
-
fn expand_const(&self) -> proc_macro2::TokenStream {
let screaming_name = &self.screaming_name;
+ let screaming_name_signature = format_ident!("{}_SIGNATURE", &self.screaming_name);
let selector_str = &self.selector_str;
- let selector = &self.expand_selector();
+ let custom_signature = self.expand_custom_signature();
quote! {
+ const #screaming_name_signature: ::evm_coder::custom_signature::FunctionSignature = #custom_signature;
#[doc = #selector_str]
- const #screaming_name: ::evm_coder::types::bytes4 = #selector;
+ const #screaming_name: ::evm_coder::types::bytes4 = {
+ let a = ::evm_coder::sha3_const::Keccak256::new()
+ .update_with_size(&Self::#screaming_name_signature.signature, Self::#screaming_name_signature.signature_len)
+ .finalize();
+ [a[0], a[1], a[2], a[3]]
+ };
}
}
@@ -847,9 +842,8 @@
}
fn expand_custom_signature(&self) -> proc_macro2::TokenStream {
- let mut first_comma = true;
let mut custom_signature = TokenStream::new();
- let mut template = self.camel_name.clone() + "(";
+
self.args
.iter()
.filter_map(|a| {
@@ -863,39 +857,18 @@
}
})
.for_each(|ident| {
- if !first_comma {
- custom_signature.extend(quote!(,));
- template.push(',');
- } else {
- first_comma = false;
- };
- template.push_str("{}");
- let ident_str = ident.to_string();
- match ident_str.as_str() {
- "address" | "uint8" | "uint16" | "uint32" | "uint64" | "uint128"
- | "uint256" | "bytes4" | "topic" | "string" | "bytes" | "void" | "caller"
- | "bool" | "" => {
- custom_signature.extend(quote!(#ident_str));
- }
- _ => {
- custom_signature.extend(quote! {
- #ident::SIGNATURE_STRING
- });
- }
- }
+ custom_signature.extend(quote! {
+ (<#ident>::SIGNATURE, <#ident>::SIGNATURE_LEN)
+ });
});
- template.push(')');
- let mut template = quote!(#template);
- template.extend(quote!(,));
- template.extend(custom_signature);
- let custom_signature_group = Group::new(proc_macro2::Delimiter::Parenthesis, template);
- let mut custom_signature = quote! {
- ::evm_coder::const_format::formatcp!
- };
- custom_signature.extend(custom_signature_group.to_token_stream());
+ let func_name = self.camel_name.clone();
+ let func_name = quote!(FunctionName::new(#func_name));
+ custom_signature =
+ quote!({ ::evm_coder::make_signature!(new fn(& #func_name),#custom_signature) });
+
+ // println!("!!!!! {}", custom_signature);
- println!("!!!!! {}", custom_signature);
custom_signature
}
@@ -915,16 +888,23 @@
.map(MethodArg::expand_solidity_argument);
let docs = &self.docs;
let selector_str = &self.selector_str;
- let selector = &self.expand_selector();
+ let screaming_name = &self.screaming_name;
let hide = self.hide;
let custom_signature = self.expand_custom_signature();
+ let custom_signature = quote!(
+ {
+ const cs: FunctionSignature = #custom_signature;
+ cs
+ }
+ );
+ // println!("!!!!! {}", custom_signature);
let is_payable = self.has_value_args;
- quote! {
+ let out = quote! {
SolidityFunction {
docs: &[#(#docs),*],
selector_str: #selector_str,
hide: #hide,
- selector: u32::from_be_bytes(#selector),
+ selector: u32::from_be_bytes(Self::#screaming_name),
custom_signature: #custom_signature,
name: #camel_name,
mutability: #mutability,
@@ -936,7 +916,9 @@
),
result: <UnnamedArgument<#result>>::default(),
}
- }
+ };
+ // println!("@@@ {}", out);
+ out
}
}
crates/evm-coder/src/custom_signature.rsdiffbeforeafterboth--- /dev/null
+++ b/crates/evm-coder/src/custom_signature.rs
@@ -0,0 +1,336 @@
+use core::str::from_utf8;
+
+pub const SIGNATURE_SIZE_LIMIT: usize = 256;
+
+pub trait Name {
+ const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT];
+ const SIGNATURE_LEN: usize;
+
+ fn name() -> &'static str {
+ from_utf8(&Self::SIGNATURE[..Self::SIGNATURE_LEN]).expect("bad utf-8")
+ }
+}
+
+#[derive(Debug)]
+pub struct FunctionSignature {
+ pub signature: [u8; SIGNATURE_SIZE_LIMIT],
+ pub signature_len: usize,
+}
+
+impl FunctionSignature {
+ pub const fn new(name: &'static FunctionName) -> FunctionSignature {
+ let mut signature = [0_u8; SIGNATURE_SIZE_LIMIT];
+ let name_len = name.signature_len;
+ let name = name.signature;
+ let mut dst_offset = 0;
+ let bracket_open = {
+ let mut b = [0_u8; SIGNATURE_SIZE_LIMIT];
+ b[0] = b"("[0];
+ b
+ };
+ crate::make_signature!(@copy(name, signature, name_len, dst_offset));
+ crate::make_signature!(@copy(bracket_open, signature, 1, dst_offset));
+ FunctionSignature {
+ signature,
+ signature_len: dst_offset,
+ }
+ }
+
+ pub const fn add_param(
+ signature: FunctionSignature,
+ param: ([u8; SIGNATURE_SIZE_LIMIT], usize),
+ ) -> FunctionSignature {
+ let mut dst = signature.signature;
+ let mut dst_offset = signature.signature_len;
+ let (param_name, param_len) = param;
+ let comma = {
+ let mut b = [0_u8; SIGNATURE_SIZE_LIMIT];
+ b[0] = b","[0];
+ b
+ };
+ FunctionSignature {
+ signature: {
+ crate::make_signature!(@copy(param_name, dst, param_len, dst_offset));
+ crate::make_signature!(@copy(comma, dst, 1, dst_offset));
+ dst
+ },
+ signature_len: dst_offset,
+ }
+ }
+
+ pub const fn done(signature: FunctionSignature, owerride: bool) -> FunctionSignature {
+ let mut dst = signature.signature;
+ let mut dst_offset = signature.signature_len - if owerride { 1 } else { 0 };
+ let bracket_close = {
+ let mut b = [0_u8; SIGNATURE_SIZE_LIMIT];
+ b[0] = b")"[0];
+ b
+ };
+ FunctionSignature {
+ signature: {
+ crate::make_signature!(@copy(bracket_close, dst, 1, dst_offset));
+ dst
+ },
+ signature_len: dst_offset,
+ }
+ }
+
+ // fn as_str(&self) -> &'static str {
+ // from_utf8(&self.signature[..self.signature_len]).expect("bad utf-8")
+ // }
+}
+
+#[derive(Debug)]
+pub struct FunctionName {
+ signature: [u8; SIGNATURE_SIZE_LIMIT],
+ signature_len: usize,
+}
+
+impl FunctionName {
+ pub const fn new(name: &'static str) -> FunctionName {
+ let mut signature = [0_u8; SIGNATURE_SIZE_LIMIT];
+ let name = name.as_bytes();
+ let name_len = name.len();
+ let mut dst_offset = 0;
+ crate::make_signature!(@copy(name, signature, name_len, dst_offset));
+ FunctionName {
+ signature,
+ signature_len: name_len,
+ }
+ }
+}
+
+#[macro_export]
+#[allow(missing_docs)]
+macro_rules! make_signature { // May be "define_signature"?
+ (new fn($func:expr)$(,)+) => {
+ {
+ let fs = FunctionSignature::new(& $func);
+ let fs = FunctionSignature::done(fs, false);
+ fs
+ }
+ };
+ (new fn($func:expr), $($tt:tt)*) => {
+ {
+ let fs = FunctionSignature::new(& $func);
+ let fs = make_signature!(@param; fs, $($tt),*);
+ fs
+ }
+ };
+
+ (@param; $func:expr) => {
+ FunctionSignature::done($func, true)
+ };
+ (@param; $func:expr, $param:expr) => {
+ make_signature!(@param; FunctionSignature::add_param($func, $param))
+ };
+ (@param; $func:expr, $param:expr, $($tt:tt),*) => {
+ make_signature!(@param; FunctionSignature::add_param($func, $param), $($tt),*)
+ };
+
+ (new $($tt:tt)*) => {
+ const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT] = {
+ let mut out = [0u8; SIGNATURE_SIZE_LIMIT];
+ let mut dst_offset = 0;
+ make_signature!(@data(out, dst_offset); $($tt)*);
+ out
+ };
+ const SIGNATURE_LEN: usize = 0 + make_signature!(@size; $($tt)*);
+ };
+
+ // (@bytes)
+
+ (@size;) => {
+ 0
+ };
+ (@size; fixed($expr:expr) $($tt:tt)*) => {
+ $expr.len() + make_signature!(@size; $($tt)*)
+ };
+ (@size; nameof($expr:ty) $($tt:tt)*) => {
+ <$expr>::SIGNATURE_LEN + make_signature!(@size; $($tt)*)
+ };
+
+ (@data($dst:ident, $dst_offset:ident);) => {};
+ (@data($dst:ident, $dst_offset:ident); fixed($expr:expr) $($tt:tt)*) => {
+ {
+ let data = $expr.as_bytes();
+ let data_len = data.len();
+ make_signature!(@copy(data, $dst, data_len, $dst_offset));
+ }
+ make_signature!(@data($dst, $dst_offset); $($tt)*)
+ };
+ (@data($dst:ident, $dst_offset:ident); nameof($expr:ty) $($tt:tt)*) => {
+ {
+ let data = &<$expr>::SIGNATURE;
+ let data_len = <$expr>::SIGNATURE_LEN;
+ make_signature!(@copy(data, $dst, data_len, $dst_offset));
+ }
+ make_signature!(@data($dst, $dst_offset); $($tt)*)
+ };
+
+ (@copy($src:ident, $dst:ident, $src_len:expr, $dst_offset:ident)) => {
+ {
+ let mut src_offset = 0;
+ let src_len: usize = $src_len;
+ while src_offset < src_len {
+ $dst[$dst_offset] = $src[src_offset];
+ $dst_offset += 1;
+ src_offset += 1;
+ }
+ }
+ }
+}
+
+#[cfg(test)]
+mod test {
+ use core::str::from_utf8;
+
+ use frame_support::sp_runtime::app_crypto::sp_core::hexdisplay::AsBytesRef;
+
+ use super::{Name, SIGNATURE_SIZE_LIMIT, FunctionName, FunctionSignature};
+
+ impl Name for u8 {
+ make_signature!(new fixed("uint8"));
+ }
+ impl Name for u32 {
+ make_signature!(new fixed("uint32"));
+ }
+ impl<T: Name> Name for Vec<T> {
+ make_signature!(new nameof(T) fixed("[]"));
+ }
+ impl<A: Name, B: Name> Name for (A, B) {
+ make_signature!(new fixed("(") nameof(A) fixed(",") nameof(B) fixed(")"));
+ }
+
+ struct MaxSize();
+ impl Name for MaxSize {
+ const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT] = [b'!'; SIGNATURE_SIZE_LIMIT];
+ const SIGNATURE_LEN: usize = SIGNATURE_SIZE_LIMIT;
+ }
+
+ #[test]
+ fn simple() {
+ assert_eq!(u8::name(), "uint8");
+ assert_eq!(u32::name(), "uint32");
+ }
+
+ #[test]
+ fn vector_of_simple() {
+ assert_eq!(<Vec<u8>>::name(), "uint8[]");
+ assert_eq!(<Vec<u32>>::name(), "uint32[]");
+ }
+
+ #[test]
+ fn vector_of_vector() {
+ assert_eq!(<Vec<Vec<u8>>>::name(), "uint8[][]");
+ }
+
+ #[test]
+ fn tuple_of_simple() {
+ assert_eq!(<(u32, u8)>::name(), "(uint32,uint8)");
+ }
+
+ #[test]
+ fn tuple_of_tuple() {
+ assert_eq!(
+ <((u32, u8), (u8, u32))>::name(),
+ "((uint32,uint8),(uint8,uint32))"
+ );
+ }
+
+ #[test]
+ fn vector_of_tuple() {
+ assert_eq!(<Vec<(u32, u8)>>::name(), "(uint32,uint8)[]");
+ }
+
+ #[test]
+ fn tuple_of_vector() {
+ assert_eq!(<(Vec<u32>, u8)>::name(), "(uint32[],uint8)");
+ }
+
+ #[test]
+ fn complex() {
+ assert_eq!(
+ <(Vec<u32>, (u32, Vec<u8>))>::name(),
+ "(uint32[],(uint32,uint8[]))"
+ );
+ }
+
+ #[test]
+ fn max_size() {
+ assert_eq!(<MaxSize>::name(), "!".repeat(SIGNATURE_SIZE_LIMIT));
+ }
+
+ // This test must NOT compile!
+ // #[test]
+ // fn over_max_size() {
+ // assert_eq!(<Vec<MaxSize>>::name(), "!".repeat(SIZE_LIMIT) + "[]");
+ // }
+
+ #[test]
+ fn make_func_without_args() {
+ const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");
+ const SIG: FunctionSignature = make_signature!(
+ new fn(&SOME_FUNK_NAME),
+ );
+ let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();
+ assert_eq!(name, "some_funk()");
+ }
+
+ #[test]
+ fn make_func_with_1_args() {
+ const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");
+ const SIG: FunctionSignature = make_signature!(
+ new fn(&SOME_FUNK_NAME),
+ (u8::SIGNATURE, u8::SIGNATURE_LEN)
+ );
+ let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();
+ assert_eq!(name, "some_funk(uint8)");
+ }
+
+ #[test]
+ fn make_func_with_2_args() {
+ const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");
+ const SIG: FunctionSignature = make_signature!(
+ new fn(&SOME_FUNK_NAME),
+ (u8::SIGNATURE, u8::SIGNATURE_LEN)
+ (<Vec<u32>>::SIGNATURE, <Vec<u32>>::SIGNATURE_LEN)
+ );
+ let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();
+ assert_eq!(name, "some_funk(uint8,uint32[])");
+ }
+
+ #[test]
+ fn make_func_with_3_args() {
+ const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");
+ const SIG: FunctionSignature = make_signature!(
+ new fn(&SOME_FUNK_NAME),
+ (u8::SIGNATURE, u8::SIGNATURE_LEN)
+ (u32::SIGNATURE, u32::SIGNATURE_LEN)
+ (<Vec<u32>>::SIGNATURE, <Vec<u32>>::SIGNATURE_LEN)
+ );
+ let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();
+ assert_eq!(name, "some_funk(uint8,uint32,uint32[])");
+ }
+
+ #[test]
+ fn make_slice_from_signature() {
+ const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");
+ const SIG: FunctionSignature = make_signature!(
+ new fn(&SOME_FUNK_NAME),
+ (u8::SIGNATURE, u8::SIGNATURE_LEN)
+ (u32::SIGNATURE, u32::SIGNATURE_LEN)
+ (<Vec<u32>>::SIGNATURE, <Vec<u32>>::SIGNATURE_LEN)
+ );
+ const NAME: [u8; SIG.signature_len] = {
+ let mut name: [u8; SIG.signature_len] = [0; SIG.signature_len];
+ let mut i = 0;
+ while i < SIG.signature_len {
+ name[i] = SIG.signature[i];
+ i += 1;
+ }
+ name
+ };
+ assert_eq!(&NAME, b"some_funk(uint8,uint32,uint32[])");
+ }
+}
crates/evm-coder/src/lib.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/>.1617#![doc = include_str!("../README.md")]18#![deny(missing_docs)]19#![cfg_attr(not(feature = "std"), no_std)]20#[cfg(not(feature = "std"))]21extern crate alloc;2223use abi::{AbiRead, AbiReader, AbiWriter};24pub use evm_coder_procedural::{event_topic, fn_selector};25pub mod abi;26pub use events::{ToLog, ToTopic};27use execution::DispatchInfo;28pub mod execution;2930/// Derives call enum implementing [`crate::Callable`], [`crate::Weighted`]31/// and [`crate::Call`] from impl block.32///33/// ## Macro syntax34///35/// `#[solidity_interface(name, is, inline_is, events)]`36/// - *name* - used in generated code, and for Call enum name37/// - *is* - used to provide inheritance in Solidity38/// - *inline_is* - same as `is`, but ERC165::SupportsInterface will work differently: For `is` SupportsInterface(A) will return true39/// 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 return41/// false.42///43/// `#[weight(value)]`44/// Can be added to every method of impl block, used for deriving [`crate::Weighted`], which45/// is used by substrate bridge.46/// - *value*: expression, which evaluates to weight required to call this method.47/// This expression can use call arguments to calculate non-constant execution time.48/// This expression should evaluate faster than actual execution does, and may provide worse case49/// than one is called.50///51/// `#[solidity_interface(rename_selector)]`52/// - *rename_selector* - by default, selector name will be generated by transforming method name53/// from snake_case to camelCase. Use this option, if other naming convention is required.54/// I.e: method `token_uri` will be automatically renamed to `tokenUri` in selector, but name55/// required by ERC721 standard is `tokenURI`, thus we need to specify `rename_selector = "tokenURI"`56/// explicitly.57///58/// Both contract and contract methods may have doccomments, which will end up in a generated59/// solidity interface file, thus you should use [solidity syntax](https://docs.soliditylang.org/en/latest/natspec-format.html) for writing documentation in this macro60///61/// ## Example62///63/// ```ignore64/// struct SuperContract;65/// struct InlineContract;66/// struct Contract;67///68/// #[derive(ToLog)]69/// enum ContractEvents {70/// Event(#[indexed] uint32),71/// }72///73/// /// @dev This contract provides function to multiply two numbers74/// #[solidity_interface(name = MyContract, is(SuperContract), inline_is(InlineContract))]75/// impl Contract {76/// /// Multiply two numbers77/// /// @param a First number78/// /// @param b Second number79/// /// @return uint32 Product of two passed numbers80/// /// @dev This function returns error in case of overflow81/// #[weight(200 + a + b)]82/// #[solidity_interface(rename_selector = "mul")]83/// fn mul(&mut self, a: uint32, b: uint32) -> Result<uint32> {84/// Ok(a.checked_mul(b).ok_or("overflow")?)85/// }86/// }87/// ```88pub use evm_coder_procedural::solidity_interface;89/// See [`solidity_interface`]90pub use evm_coder_procedural::solidity;91/// See [`solidity_interface`]92pub use evm_coder_procedural::weight;93pub use const_format;94pub use sha3_const;9596/// Derives [`ToLog`] for enum97///98/// Selectors will be derived from variant names, there is currently no way to have custom naming99/// for them100///101/// `#[indexed]`102/// Marks this field as indexed, so it will appear in [`ethereum::Log`] topics instead of data103pub use evm_coder_procedural::ToLog;104105// Api of those modules shouldn't be consumed directly, it is only exported for usage in proc macros106#[doc(hidden)]107pub mod events;108#[doc(hidden)]109pub mod solidity;110111/// Solidity type definitions (aliases from solidity name to rust type)112/// To be used in [`solidity_interface`] definitions, to make sure there is no113/// type conflict between Rust code and generated definitions114pub mod types {115 #![allow(non_camel_case_types, missing_docs)]116117 #[cfg(not(feature = "std"))]118 use alloc::{vec::Vec};119 use pallet_evm::account::CrossAccountId;120 use primitive_types::{U256, H160, H256};121122 pub type address = H160;123124 pub type uint8 = u8;125 pub type uint16 = u16;126 pub type uint32 = u32;127 pub type uint64 = u64;128 pub type uint128 = u128;129 pub type uint256 = U256;130131 pub type bytes4 = [u8; 4];132133 pub type topic = H256;134135 #[cfg(not(feature = "std"))]136 pub type string = ::alloc::string::String;137 #[cfg(feature = "std")]138 pub type string = ::std::string::String;139140 #[derive(Default, Debug)]141 pub struct bytes(pub Vec<u8>);142143 /// Solidity doesn't have `void` type, however we have special implementation144 /// for empty tuple return type145 pub type void = ();146147 //#region Special types148 /// Makes function payable149 pub type value = U256;150 /// Makes function caller-sensitive151 pub type caller = address;152 //#endregion153154 /// Ethereum typed call message, similar to solidity155 /// `msg` object.156 pub struct Msg<C> {157 pub call: C,158 /// Address of user, which called this contract.159 pub caller: H160,160 /// Payment amount to contract.161 /// Contract should reject payment, if target call is not payable,162 /// and there is no `receiver()` function defined.163 pub value: U256,164 }165166 impl From<Vec<u8>> for bytes {167 fn from(src: Vec<u8>) -> Self {168 Self(src)169 }170 }171172 #[allow(clippy::from_over_into)]173 impl Into<Vec<u8>> for bytes {174 fn into(self) -> Vec<u8> {175 self.0176 }177 }178179 impl bytes {180 #[must_use]181 pub fn len(&self) -> usize {182 self.0.len()183 }184185 #[must_use]186 pub fn is_empty(&self) -> bool {187 self.len() == 0188 }189 }190191 #[derive(Debug)]192 pub struct EthCrossAccount {193 pub(crate) eth: address,194 pub(crate) sub: uint256,195 }196197 impl EthCrossAccount {198 pub fn from_sub_cross_account<T>(cross_account_id: &T::CrossAccountId) -> Self199 where200 T: pallet_evm::account::Config,201 T::AccountId: AsRef<[u8; 32]>,202 {203 if cross_account_id.is_canonical_substrate() {204 Self {205 eth: Default::default(),206 sub: convert_cross_account_to_uint256::<T>(cross_account_id),207 }208 } else {209 Self {210 eth: *cross_account_id.as_eth(),211 sub: Default::default(),212 }213 }214 }215216 pub fn into_sub_cross_account<T>(&self) -> crate::execution::Result<T::CrossAccountId>217 where218 T: pallet_evm::account::Config,219 T::AccountId: From<[u8; 32]>,220 {221 if self.eth == Default::default() && self.sub == Default::default() {222 Err("All fields of cross account is zeroed".into())223 } else if self.eth == Default::default() {224 Ok(convert_uint256_to_cross_account::<T>(self.sub))225 } else if self.sub == Default::default() {226 Ok(T::CrossAccountId::from_eth(self.eth))227 } else {228 Err("All fields of cross account is non zeroed".into())229 }230 }231 }232233 impl SignatureString for EthCrossAccount {234 const SIGNATURE_STRING: &'static str = "(address,uint256)";235 }236237 pub trait SignatureString {238 const SIGNATURE_STRING: &'static str;239 }240241 /// Convert `CrossAccountId` to `uint256`.242 pub fn convert_cross_account_to_uint256<T: pallet_evm::account::Config>(243 from: &T::CrossAccountId,244 ) -> uint256245 where246 T::AccountId: AsRef<[u8; 32]>,247 {248 let slice = from.as_sub().as_ref();249 uint256::from_big_endian(slice)250 }251252 /// Convert `uint256` to `CrossAccountId`.253 pub fn convert_uint256_to_cross_account<T: pallet_evm::account::Config>(254 from: uint256,255 ) -> T::CrossAccountId256 where257 T::AccountId: From<[u8; 32]>,258 {259 let mut new_admin_arr = [0_u8; 32];260 from.to_big_endian(&mut new_admin_arr);261 let account_id = T::AccountId::from(new_admin_arr);262 T::CrossAccountId::from_sub(account_id)263 }264}265266/// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro267pub trait Call: Sized {268 /// Parse call buffer into typed call enum269 fn parse(selector: types::bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>>;270}271272/// Intended to be used as `#[weight]` output type273/// Should be same between evm-coder and substrate to avoid confusion274///275/// Isn't same thing as gas, some mapping is required between those types276pub type Weight = frame_support::weights::Weight;277278/// In substrate, we have benchmarking, which allows279/// us to not rely on gas metering, but instead predict amount of gas to execute call280pub trait Weighted: Call {281 /// Predict weight of this call282 fn weight(&self) -> DispatchInfo;283}284285/// Type callable with ethereum message, may be implemented by [`solidity_interface`] macro286/// on interface implementation, or for externally-owned real EVM contract287pub trait Callable<C: Call> {288 /// Call contract using specified call data289 fn call(&mut self, call: types::Msg<C>) -> execution::ResultWithPostInfo<AbiWriter>;290}291292/// Implementation of ERC165 is implicitly generated for all interfaces in [`solidity_interface`],293/// this structure holds parsed data for ERC165Call subvariant294///295/// Note: no [`Callable`] implementation is provided, call implementation is inlined into every296/// implementing contract297///298/// See <https://eips.ethereum.org/EIPS/eip-165>299#[derive(Debug)]300pub enum ERC165Call {301 /// ERC165 provides single method, which returns true, if contract302 /// implements specified interface303 SupportsInterface {304 /// Requested interface305 interface_id: types::bytes4,306 },307}308309impl ERC165Call {310 /// ERC165 selector is provided by standard311 pub const INTERFACE_ID: types::bytes4 = u32::to_be_bytes(0x01ffc9a7);312}313314impl Call for ERC165Call {315 fn parse(selector: types::bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>> {316 if selector != Self::INTERFACE_ID {317 return Ok(None);318 }319 Ok(Some(Self::SupportsInterface {320 interface_id: input.abi_read()?,321 }))322 }323}324325/// Generate "tests", which will generate solidity code on execution and print it to stdout326/// Script at .maintain/scripts/generate_api.sh can split this output from test runtime327///328/// This macro receives type usage as second argument, but you can use anything as generics,329/// because no bounds are implied330#[macro_export]331macro_rules! generate_stubgen {332 ($name:ident, $decl:ty, $is_impl:literal) => {333 #[test]334 #[ignore]335 fn $name() {336 use evm_coder::solidity::TypeCollector;337 let mut out = TypeCollector::new();338 <$decl>::generate_solidity_interface(&mut out, $is_impl);339 println!("=== SNIP START ===");340 println!("// SPDX-License-Identifier: OTHER");341 println!("// This code is automatically generated");342 println!();343 println!("pragma solidity >=0.8.0 <0.9.0;");344 println!();345 for b in out.finish() {346 println!("{}", b);347 }348 println!("=== SNIP END ===");349 }350 };351}352353#[cfg(test)]354mod tests {355 use super::*;356357 #[test]358 fn function_selector_generation() {359 assert_eq!(fn_selector!(transfer(address, uint256)), 0xa9059cbb);360 }361362 // #[test]363 // fn function_selector_generation_1() {364 // assert_eq!(365 // fn_selector!(transferFromCrossAccountToCrossAccount(366 // EthCrossAccount,367 // EthCrossAccount,368 // uint256369 // )),370 // 2543295963371 // );372 // }373374 #[test]375 fn event_topic_generation() {376 assert_eq!(377 hex::encode(&event_topic!(Transfer(address, address, uint256))[..]),378 "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",379 );380 }381}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/>.1617#![doc = include_str!("../README.md")]18// #![deny(missing_docs)]19#![warn(missing_docs)]20#![macro_use]21#![cfg_attr(not(feature = "std"), no_std)]22#[cfg(not(feature = "std"))]23extern crate alloc;2425use abi::{AbiRead, AbiReader, AbiWriter};26pub use evm_coder_procedural::{event_topic, fn_selector};27pub mod abi;28pub use events::{ToLog, ToTopic};29use execution::DispatchInfo;30pub mod execution;31#[macro_use]32pub mod custom_signature;3334/// Derives call enum implementing [`crate::Callable`], [`crate::Weighted`]35/// and [`crate::Call`] from impl block.36///37/// ## Macro syntax38///39/// `#[solidity_interface(name, is, inline_is, events)]`40/// - *name* - used in generated code, and for Call enum name41/// - *is* - used to provide inheritance in Solidity42/// - *inline_is* - same as `is`, but ERC165::SupportsInterface will work differently: For `is` SupportsInterface(A) will return true43/// 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)`44/// SupportsInterface(A) will internally create a new interface that combines all methods of A and B, so SupportsInterface(A) will return45/// false.46///47/// `#[weight(value)]`48/// Can be added to every method of impl block, used for deriving [`crate::Weighted`], which49/// is used by substrate bridge.50/// - *value*: expression, which evaluates to weight required to call this method.51/// This expression can use call arguments to calculate non-constant execution time.52/// This expression should evaluate faster than actual execution does, and may provide worse case53/// than one is called.54///55/// `#[solidity_interface(rename_selector)]`56/// - *rename_selector* - by default, selector name will be generated by transforming method name57/// from snake_case to camelCase. Use this option, if other naming convention is required.58/// I.e: method `token_uri` will be automatically renamed to `tokenUri` in selector, but name59/// required by ERC721 standard is `tokenURI`, thus we need to specify `rename_selector = "tokenURI"`60/// explicitly.61///62/// Both contract and contract methods may have doccomments, which will end up in a generated63/// solidity interface file, thus you should use [solidity syntax](https://docs.soliditylang.org/en/latest/natspec-format.html) for writing documentation in this macro64///65/// ## Example66///67/// ```ignore68/// struct SuperContract;69/// struct InlineContract;70/// struct Contract;71///72/// #[derive(ToLog)]73/// enum ContractEvents {74/// Event(#[indexed] uint32),75/// }76///77/// /// @dev This contract provides function to multiply two numbers78/// #[solidity_interface(name = MyContract, is(SuperContract), inline_is(InlineContract))]79/// impl Contract {80/// /// Multiply two numbers81/// /// @param a First number82/// /// @param b Second number83/// /// @return uint32 Product of two passed numbers84/// /// @dev This function returns error in case of overflow85/// #[weight(200 + a + b)]86/// #[solidity_interface(rename_selector = "mul")]87/// fn mul(&mut self, a: uint32, b: uint32) -> Result<uint32> {88/// Ok(a.checked_mul(b).ok_or("overflow")?)89/// }90/// }91/// ```92pub use evm_coder_procedural::solidity_interface;93/// See [`solidity_interface`]94pub use evm_coder_procedural::solidity;95/// See [`solidity_interface`]96pub use evm_coder_procedural::weight;97pub use const_format;98pub use sha3_const;99100/// Derives [`ToLog`] for enum101///102/// Selectors will be derived from variant names, there is currently no way to have custom naming103/// for them104///105/// `#[indexed]`106/// Marks this field as indexed, so it will appear in [`ethereum::Log`] topics instead of data107pub use evm_coder_procedural::ToLog;108109// Api of those modules shouldn't be consumed directly, it is only exported for usage in proc macros110#[doc(hidden)]111pub mod events;112#[doc(hidden)]113pub mod solidity;114115/// Solidity type definitions (aliases from solidity name to rust type)116/// To be used in [`solidity_interface`] definitions, to make sure there is no117/// type conflict between Rust code and generated definitions118pub mod types {119 #![allow(non_camel_case_types, missing_docs)]120121 #[cfg(not(feature = "std"))]122 use alloc::{vec::Vec};123 use pallet_evm::account::CrossAccountId;124 use primitive_types::{U256, H160, H256};125 use core::str::from_utf8;126127 use crate::custom_signature::SIGNATURE_SIZE_LIMIT;128129 pub trait Signature {130 const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT];131 const SIGNATURE_LEN: usize;132133 fn as_str() -> &'static str {134 from_utf8(&Self::SIGNATURE[..Self::SIGNATURE_LEN]).expect("bad utf-8")135 }136 }137138 impl Signature for bool {139 make_signature!(new fixed("bool"));140 }141142 macro_rules! define_simple_type {143 (type $ident:ident = $ty:ty) => {144 pub type $ident = $ty;145 impl Signature for $ty {146 make_signature!(new fixed(stringify!($ident)));147 }148 };149 }150151 define_simple_type!(type address = H160);152153 define_simple_type!(type uint8 = u8);154 define_simple_type!(type uint16 = u16);155 define_simple_type!(type uint32 = u32);156 define_simple_type!(type uint64 = u64);157 define_simple_type!(type uint128 = u128);158 define_simple_type!(type uint256 = U256);159 define_simple_type!(type bytes4 = [u8; 4]);160161 define_simple_type!(type topic = H256);162163 #[cfg(not(feature = "std"))]164 define_simple_type!(type string = ::alloc::string::String);165 #[cfg(feature = "std")]166 define_simple_type!(type string = ::std::string::String);167168 #[derive(Default, Debug)]169 pub struct bytes(pub Vec<u8>);170 impl Signature for bytes {171 make_signature!(new fixed("bytes"));172 }173174 /// Solidity doesn't have `void` type, however we have special implementation175 /// for empty tuple return type176 pub type void = ();177178 //#region Special types179 /// Makes function payable180 pub type value = U256;181 /// Makes function caller-sensitive182 pub type caller = address;183 //#endregion184185 /// Ethereum typed call message, similar to solidity186 /// `msg` object.187 pub struct Msg<C> {188 pub call: C,189 /// Address of user, which called this contract.190 pub caller: H160,191 /// Payment amount to contract.192 /// Contract should reject payment, if target call is not payable,193 /// and there is no `receiver()` function defined.194 pub value: U256,195 }196197 impl From<Vec<u8>> for bytes {198 fn from(src: Vec<u8>) -> Self {199 Self(src)200 }201 }202203 #[allow(clippy::from_over_into)]204 impl Into<Vec<u8>> for bytes {205 fn into(self) -> Vec<u8> {206 self.0207 }208 }209210 impl bytes {211 #[must_use]212 pub fn len(&self) -> usize {213 self.0.len()214 }215216 #[must_use]217 pub fn is_empty(&self) -> bool {218 self.len() == 0219 }220 }221222 #[derive(Debug)]223 pub struct EthCrossAccount {224 pub(crate) eth: address,225 pub(crate) sub: uint256,226 }227228 impl EthCrossAccount {229 pub fn from_sub_cross_account<T>(cross_account_id: &T::CrossAccountId) -> Self230 where231 T: pallet_evm::account::Config,232 T::AccountId: AsRef<[u8; 32]>,233 {234 if cross_account_id.is_canonical_substrate() {235 Self {236 eth: Default::default(),237 sub: convert_cross_account_to_uint256::<T>(cross_account_id),238 }239 } else {240 Self {241 eth: *cross_account_id.as_eth(),242 sub: Default::default(),243 }244 }245 }246247 pub fn into_sub_cross_account<T>(&self) -> crate::execution::Result<T::CrossAccountId>248 where249 T: pallet_evm::account::Config,250 T::AccountId: From<[u8; 32]>,251 {252 if self.eth == Default::default() && self.sub == Default::default() {253 Err("All fields of cross account is zeroed".into())254 } else if self.eth == Default::default() {255 Ok(convert_uint256_to_cross_account::<T>(self.sub))256 } else if self.sub == Default::default() {257 Ok(T::CrossAccountId::from_eth(self.eth))258 } else {259 Err("All fields of cross account is non zeroed".into())260 }261 }262 }263264 impl Signature for EthCrossAccount {265 make_signature!(new fixed("(address,uint256)"));266 }267268 /// Convert `CrossAccountId` to `uint256`.269 pub fn convert_cross_account_to_uint256<T: pallet_evm::account::Config>(270 from: &T::CrossAccountId,271 ) -> uint256272 where273 T::AccountId: AsRef<[u8; 32]>,274 {275 let slice = from.as_sub().as_ref();276 uint256::from_big_endian(slice)277 }278279 /// Convert `uint256` to `CrossAccountId`.280 pub fn convert_uint256_to_cross_account<T: pallet_evm::account::Config>(281 from: uint256,282 ) -> T::CrossAccountId283 where284 T::AccountId: From<[u8; 32]>,285 {286 let mut new_admin_arr = [0_u8; 32];287 from.to_big_endian(&mut new_admin_arr);288 let account_id = T::AccountId::from(new_admin_arr);289 T::CrossAccountId::from_sub(account_id)290 }291}292293/// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro294pub trait Call: Sized {295 /// Parse call buffer into typed call enum296 fn parse(selector: types::bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>>;297}298299/// Intended to be used as `#[weight]` output type300/// Should be same between evm-coder and substrate to avoid confusion301///302/// Isn't same thing as gas, some mapping is required between those types303pub type Weight = frame_support::weights::Weight;304305/// In substrate, we have benchmarking, which allows306/// us to not rely on gas metering, but instead predict amount of gas to execute call307pub trait Weighted: Call {308 /// Predict weight of this call309 fn weight(&self) -> DispatchInfo;310}311312/// Type callable with ethereum message, may be implemented by [`solidity_interface`] macro313/// on interface implementation, or for externally-owned real EVM contract314pub trait Callable<C: Call> {315 /// Call contract using specified call data316 fn call(&mut self, call: types::Msg<C>) -> execution::ResultWithPostInfo<AbiWriter>;317}318319/// Implementation of ERC165 is implicitly generated for all interfaces in [`solidity_interface`],320/// this structure holds parsed data for ERC165Call subvariant321///322/// Note: no [`Callable`] implementation is provided, call implementation is inlined into every323/// implementing contract324///325/// See <https://eips.ethereum.org/EIPS/eip-165>326#[derive(Debug)]327pub enum ERC165Call {328 /// ERC165 provides single method, which returns true, if contract329 /// implements specified interface330 SupportsInterface {331 /// Requested interface332 interface_id: types::bytes4,333 },334}335336impl ERC165Call {337 /// ERC165 selector is provided by standard338 pub const INTERFACE_ID: types::bytes4 = u32::to_be_bytes(0x01ffc9a7);339}340341impl Call for ERC165Call {342 fn parse(selector: types::bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>> {343 if selector != Self::INTERFACE_ID {344 return Ok(None);345 }346 Ok(Some(Self::SupportsInterface {347 interface_id: input.abi_read()?,348 }))349 }350}351352/// Generate "tests", which will generate solidity code on execution and print it to stdout353/// Script at .maintain/scripts/generate_api.sh can split this output from test runtime354///355/// This macro receives type usage as second argument, but you can use anything as generics,356/// because no bounds are implied357#[macro_export]358macro_rules! generate_stubgen {359 ($name:ident, $decl:ty, $is_impl:literal) => {360 #[test]361 #[ignore]362 fn $name() {363 use evm_coder::solidity::TypeCollector;364 let mut out = TypeCollector::new();365 <$decl>::generate_solidity_interface(&mut out, $is_impl);366 println!("=== SNIP START ===");367 println!("// SPDX-License-Identifier: OTHER");368 println!("// This code is automatically generated");369 println!();370 println!("pragma solidity >=0.8.0 <0.9.0;");371 println!();372 for b in out.finish() {373 println!("{}", b);374 }375 println!("=== SNIP END ===");376 }377 };378}379380#[cfg(test)]381mod tests {382 use super::*;383384 #[test]385 fn function_selector_generation() {386 assert_eq!(fn_selector!(transfer(address, uint256)), 0xa9059cbb);387 }388389 // #[test]390 // fn function_selector_generation_1() {391 // assert_eq!(392 // fn_selector!(transferFromCrossAccountToCrossAccount(393 // EthCrossAccount,394 // EthCrossAccount,395 // uint256396 // )),397 // 2543295963398 // );399 // }400401 #[test]402 fn event_topic_generation() {403 assert_eq!(404 hex::encode(&event_topic!(Transfer(address, address, uint256))[..]),405 "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",406 );407 }408}crates/evm-coder/src/solidity.rsdiffbeforeafterboth--- a/crates/evm-coder/src/solidity.rs
+++ b/crates/evm-coder/src/solidity.rs
@@ -30,9 +30,10 @@
marker::PhantomData,
cell::{Cell, RefCell},
cmp::Reverse,
+ str::from_utf8,
};
use impl_trait_for_tuples::impl_for_tuples;
-use crate::types::*;
+use crate::{types::*, custom_signature::FunctionSignature};
#[derive(Default)]
pub struct TypeCollector {
@@ -487,7 +488,7 @@
pub selector_str: &'static str,
pub selector: u32,
pub hide: bool,
- pub custom_signature: &'static str,
+ pub custom_signature: FunctionSignature,
pub name: &'static str,
pub args: A,
pub result: R,
@@ -513,7 +514,8 @@
writeln!(
writer,
"\t{hide_comment}/// or in textual repr: {}",
- self.custom_signature
+ // from_utf8(self.custom_signature.as_str()).expect("bad utf8")
+ self.selector_str
)?;
write!(writer, "\t{hide_comment}function {}(", self.name)?;
self.args.solidity_name(writer, tc)?;
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -21,6 +21,8 @@
types::*,
execution::{Result, Error},
weight,
+ custom_signature::{FunctionName, FunctionSignature},
+ make_signature,
};
pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};
use pallet_evm_coder_substrate::dispatch_to_evm;
pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -20,7 +20,13 @@
use alloc::{format, string::ToString};
use core::marker::PhantomData;
use evm_coder::{
- abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,
+ abi::AbiWriter,
+ execution::Result,
+ generate_stubgen, solidity_interface,
+ types::*,
+ ToLog,
+ custom_signature::{FunctionName, FunctionSignature},
+ make_signature,
};
use pallet_evm::{
ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,
pallets/fungible/src/erc.rsdiffbeforeafterboth--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -20,7 +20,15 @@
use alloc::{format, string::ToString};
use core::char::{REPLACEMENT_CHARACTER, decode_utf16};
use core::convert::TryInto;
-use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};
+use evm_coder::{
+ ToLog,
+ execution::*,
+ generate_stubgen, solidity_interface,
+ types::*,
+ weight,
+ custom_signature::{FunctionName, FunctionSignature},
+ make_signature,
+};
use pallet_common::eth::convert_tuple_to_cross_account;
use up_data_structs::CollectionMode;
use pallet_common::erc::{CommonEvmHandler, PrecompileResult};
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -25,7 +25,15 @@
char::{REPLACEMENT_CHARACTER, decode_utf16},
convert::TryInto,
};
-use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
+use evm_coder::{
+ ToLog,
+ execution::*,
+ generate_stubgen, solidity, solidity_interface,
+ types::*,
+ weight,
+ custom_signature::{FunctionName, FunctionSignature},
+ make_signature,
+};
use frame_support::BoundedVec;
use up_data_structs::{
TokenId, PropertyPermission, PropertyKeyPermission, Property, CollectionId, PropertyKey,
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -104,7 +104,11 @@
}
/// @title A contract that allows you to work with collections.
+<<<<<<< HEAD
/// @dev the ERC-165 identifier for this interface is 0xb3152af3
+=======
+/// @dev the ERC-165 identifier for this interface is 0x674be726
+>>>>>>> feat: Add custum signature with unlimited nesting.
contract Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -198,7 +202,7 @@
/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
///
/// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
- /// @dev EVM selector for this function is: 0x84a1d5a8,
+ /// @dev EVM selector for this function is: 0x403e96a7,
/// or in textual repr: setCollectionSponsorCross((address,uint256))
function setCollectionSponsorCross(Tuple6 memory sponsor) public {
require(false, stub_error);
@@ -239,6 +243,7 @@
/// @dev EVM selector for this function is: 0x6ec0a9f1,
/// or in textual repr: collectionSponsor()
<<<<<<< HEAD
+<<<<<<< HEAD
function collectionSponsor() public view returns (Tuple6 memory) {
require(false, stub_error);
dummy;
@@ -249,6 +254,12 @@
dummy;
return Tuple19(0x0000000000000000000000000000000000000000, 0);
>>>>>>> feat: add `EthCrossAccount` type
+=======
+ function collectionSponsor() public view returns (Tuple8 memory) {
+ require(false, stub_error);
+ dummy;
+ return Tuple8(0x0000000000000000000000000000000000000000, 0);
+>>>>>>> feat: Add custum signature with unlimited nesting.
}
/// Set limits for the collection.
@@ -297,7 +308,7 @@
/// Add collection admin.
/// @param newAdmin Cross account administrator address.
- /// @dev EVM selector for this function is: 0x859aa7d6,
+ /// @dev EVM selector for this function is: 0x62e3c7c2,
/// or in textual repr: addCollectionAdminCross((address,uint256))
function addCollectionAdminCross(Tuple6 memory newAdmin) public {
require(false, stub_error);
@@ -307,7 +318,7 @@
/// Remove collection admin.
/// @param admin Cross account administrator address.
- /// @dev EVM selector for this function is: 0x6c0cd173,
+ /// @dev EVM selector for this function is: 0x810d1503,
/// or in textual repr: removeCollectionAdminCross((address,uint256))
function removeCollectionAdminCross(Tuple6 memory admin) public {
require(false, stub_error);
@@ -351,7 +362,7 @@
///
/// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
/// @param collections Addresses of collections that will be available for nesting.
- /// @dev EVM selector for this function is: 0x64872396,
+ /// @dev EVM selector for this function is: 0x112d4586,
/// or in textual repr: setCollectionNesting(bool,address[])
function setCollectionNesting(bool enable, address[] memory collections) public {
require(false, stub_error);
@@ -398,7 +409,7 @@
/// Add user to allowed list.
///
/// @param user User cross account address.
- /// @dev EVM selector for this function is: 0xa0184a3a,
+ /// @dev EVM selector for this function is: 0xf074da88,
/// or in textual repr: addToCollectionAllowListCross((address,uint256))
function addToCollectionAllowListCross(Tuple6 memory user) public {
require(false, stub_error);
@@ -420,7 +431,7 @@
/// Remove user from allowed list.
///
/// @param user User cross account address.
- /// @dev EVM selector for this function is: 0x09ba452a,
+ /// @dev EVM selector for this function is: 0xc00df45c,
/// or in textual repr: removeFromCollectionAllowListCross((address,uint256))
function removeFromCollectionAllowListCross(Tuple6 memory user) public {
require(false, stub_error);
@@ -456,7 +467,7 @@
///
/// @param user User cross account to verify
/// @return "true" if account is the owner or admin
- /// @dev EVM selector for this function is: 0x3e75a905,
+ /// @dev EVM selector for this function is: 0x5aba3351,
/// or in textual repr: isOwnerOrAdminCross((address,uint256))
function isOwnerOrAdminCross(Tuple6 memory user) public view returns (bool) {
require(false, stub_error);
@@ -483,6 +494,7 @@
/// @dev EVM selector for this function is: 0xdf727d3b,
/// or in textual repr: collectionOwner()
<<<<<<< HEAD
+<<<<<<< HEAD
function collectionOwner() public view returns (Tuple6 memory) {
require(false, stub_error);
dummy;
@@ -493,6 +505,12 @@
dummy;
return Tuple19(0x0000000000000000000000000000000000000000, 0);
>>>>>>> feat: add `EthCrossAccount` type
+=======
+ function collectionOwner() public view returns (Tuple8 memory) {
+ require(false, stub_error);
+ dummy;
+ return Tuple8(0x0000000000000000000000000000000000000000, 0);
+>>>>>>> feat: Add custum signature with unlimited nesting.
}
/// Changes collection owner to another account
@@ -523,7 +541,7 @@
///
/// @dev Owner can be changed only by current owner
/// @param newOwner new owner cross account
- /// @dev EVM selector for this function is: 0xe5c9913f,
+ /// @dev EVM selector for this function is: 0xbdff793d,
/// or in textual repr: setOwnerCross((address,uint256))
function setOwnerCross(Tuple6 memory newOwner) public {
require(false, stub_error);
@@ -532,6 +550,7 @@
}
}
+<<<<<<< HEAD
/// @dev anonymous struct
struct Tuple19 {
address field_0;
@@ -581,6 +600,8 @@
}
}
+=======
+>>>>>>> feat: Add custum signature with unlimited nesting.
/// @title ERC721 Token that can be irreversibly burned (destroyed).
/// @dev the ERC-165 identifier for this interface is 0x42966c68
contract ERC721Burnable is Dummy, ERC165 {
@@ -682,7 +703,11 @@
}
/// @title Unique extensions for ERC721.
+<<<<<<< HEAD
/// @dev the ERC-165 identifier for this interface is 0x244543ee
+=======
+/// @dev the ERC-165 identifier for this interface is 0xcc97cb35
+>>>>>>> feat: Add custum signature with unlimited nesting.
contract ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -708,7 +733,7 @@
/// operator of the current owner.
/// @param approved The new substrate address approved NFT controller
/// @param tokenId The NFT to approve
- /// @dev EVM selector for this function is: 0x0ecd0ab0,
+ /// @dev EVM selector for this function is: 0x106fdb59,
/// or in textual repr: approveCross((address,uint256),uint256)
function approveCross(Tuple6 memory approved, uint256 tokenId) public {
require(false, stub_error);
@@ -738,10 +763,15 @@
/// @param to Cross acccount address of new owner
/// @param tokenId The NFT to transfer
/// @dev EVM selector for this function is: 0xd5cf430b,
- /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
+ /// or in textual repr: transferFromCross(EthCrossAccount,EthCrossAccount,uint256)
function transferFromCross(
+<<<<<<< HEAD
Tuple6 memory from,
Tuple6 memory to,
+=======
+ EthCrossAccount memory from,
+ EthCrossAccount memory to,
+>>>>>>> feat: Add custum signature with unlimited nesting.
uint256 tokenId
) public {
require(false, stub_error);
@@ -772,7 +802,7 @@
/// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
/// @param from The current owner of the NFT
/// @param tokenId The NFT to transfer
- /// @dev EVM selector for this function is: 0xbb2f5a58,
+ /// @dev EVM selector for this function is: 0xa8106d4a,
/// or in textual repr: burnFromCross((address,uint256),uint256)
function burnFromCross(Tuple6 memory from, uint256 tokenId) public {
require(false, stub_error);
@@ -819,10 +849,46 @@
// return false;
// }
+<<<<<<< HEAD
}
/// @dev anonymous struct
struct Tuple8 {
+=======
+ /// @notice Function to mint multiple tokens.
+ /// @dev `tokenIds` should be an array of consecutive numbers and first number
+ /// should be obtained with `nextTokenId` method
+ /// @param to The new owner
+ /// @param tokenIds IDs of the minted NFTs
+ /// @dev EVM selector for this function is: 0xf9d9a5a3,
+ /// or in textual repr: mintBulk(address,uint256[])
+ function mintBulk(address to, uint256[] memory tokenIds) public returns (bool) {
+ require(false, stub_error);
+ to;
+ tokenIds;
+ dummy = 0;
+ return false;
+ }
+
+ /// @notice Function to mint multiple tokens with the given tokenUris.
+ /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
+ /// numbers and first number should be obtained with `nextTokenId` method
+ /// @param to The new owner
+ /// @param tokens array of pairs of token ID and token URI for minted tokens
+ /// @dev EVM selector for this function is: 0xfd4e2a99,
+ /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
+ function mintBulkWithTokenURI(address to, Tuple12[] memory tokens) public returns (bool) {
+ require(false, stub_error);
+ to;
+ tokens;
+ dummy = 0;
+ return false;
+ }
+}
+
+/// @dev anonymous struct
+struct Tuple12 {
+>>>>>>> feat: Add custum signature with unlimited nesting.
uint256 field_0;
string field_1;
}
@@ -840,6 +906,12 @@
>>>>>>> feat: add `EthCrossAccount` type
}
+/// @dev anonymous struct
+struct Tuple8 {
+ address field_0;
+ uint256 field_1;
+}
+
/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// @dev the ERC-165 identifier for this interface is 0x780e9d63
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -26,7 +26,15 @@
char::{REPLACEMENT_CHARACTER, decode_utf16},
convert::TryInto,
};
-use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
+use evm_coder::{
+ ToLog,
+ execution::*,
+ generate_stubgen, solidity, solidity_interface,
+ types::*,
+ weight,
+ custom_signature::{FunctionName, FunctionSignature},
+ make_signature,
+};
use frame_support::{BoundedBTreeMap, BoundedVec};
use pallet_common::{
CollectionHandle, CollectionPropertyPermissions,
pallets/refungible/src/erc_token.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -29,7 +29,15 @@
convert::TryInto,
ops::Deref,
};
-use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};
+use evm_coder::{
+ ToLog,
+ execution::*,
+ generate_stubgen, solidity_interface,
+ types::*,
+ weight,
+ custom_signature::{FunctionName, FunctionSignature},
+ make_signature,
+};
use pallet_common::{
CommonWeightInfo,
erc::{CommonEvmHandler, PrecompileResult},
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -18,7 +18,13 @@
use core::marker::PhantomData;
use ethereum as _;
-use evm_coder::{execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
+use evm_coder::{
+ execution::*,
+ generate_stubgen, solidity, solidity_interface,
+ types::*,
+ custom_signature::{FunctionName, FunctionSignature},
+ make_signature,
+, weight};
use frame_support::{traits::Get, storage::StorageNMap};
use crate::sp_api_hidden_includes_decl_storage::hidden_include::StorageDoubleMap;
use crate::Pallet;
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -70,7 +70,11 @@
}
/// @title A contract that allows you to work with collections.
+<<<<<<< HEAD
/// @dev the ERC-165 identifier for this interface is 0xb3152af3
+=======
+/// @dev the ERC-165 identifier for this interface is 0x674be726
+>>>>>>> feat: Add custum signature with unlimited nesting.
interface Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -133,7 +137,7 @@
/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
///
/// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
- /// @dev EVM selector for this function is: 0x84a1d5a8,
+ /// @dev EVM selector for this function is: 0x403e96a7,
/// or in textual repr: setCollectionSponsorCross((address,uint256))
function setCollectionSponsorCross(Tuple6 memory sponsor) external;
@@ -193,13 +197,13 @@
/// Add collection admin.
/// @param newAdmin Cross account administrator address.
- /// @dev EVM selector for this function is: 0x859aa7d6,
+ /// @dev EVM selector for this function is: 0x62e3c7c2,
/// or in textual repr: addCollectionAdminCross((address,uint256))
function addCollectionAdminCross(Tuple6 memory newAdmin) external;
/// Remove collection admin.
/// @param admin Cross account administrator address.
- /// @dev EVM selector for this function is: 0x6c0cd173,
+ /// @dev EVM selector for this function is: 0x810d1503,
/// or in textual repr: removeCollectionAdminCross((address,uint256))
function removeCollectionAdminCross(Tuple6 memory admin) external;
@@ -227,7 +231,7 @@
///
/// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
/// @param collections Addresses of collections that will be available for nesting.
- /// @dev EVM selector for this function is: 0x64872396,
+ /// @dev EVM selector for this function is: 0x112d4586,
/// or in textual repr: setCollectionNesting(bool,address[])
function setCollectionNesting(bool enable, address[] memory collections) external;
@@ -256,7 +260,7 @@
/// Add user to allowed list.
///
/// @param user User cross account address.
- /// @dev EVM selector for this function is: 0xa0184a3a,
+ /// @dev EVM selector for this function is: 0xf074da88,
/// or in textual repr: addToCollectionAllowListCross((address,uint256))
function addToCollectionAllowListCross(Tuple6 memory user) external;
@@ -270,7 +274,7 @@
/// Remove user from allowed list.
///
/// @param user User cross account address.
- /// @dev EVM selector for this function is: 0x09ba452a,
+ /// @dev EVM selector for this function is: 0xc00df45c,
/// or in textual repr: removeFromCollectionAllowListCross((address,uint256))
function removeFromCollectionAllowListCross(Tuple6 memory user) external;
@@ -293,7 +297,7 @@
///
/// @param user User cross account to verify
/// @return "true" if account is the owner or admin
- /// @dev EVM selector for this function is: 0x3e75a905,
+ /// @dev EVM selector for this function is: 0x5aba3351,
/// or in textual repr: isOwnerOrAdminCross((address,uint256))
function isOwnerOrAdminCross(Tuple6 memory user) external view returns (bool);
@@ -332,11 +336,12 @@
///
/// @dev Owner can be changed only by current owner
/// @param newOwner new owner cross account
- /// @dev EVM selector for this function is: 0xe5c9913f,
+ /// @dev EVM selector for this function is: 0xbdff793d,
/// or in textual repr: setOwnerCross((address,uint256))
function setOwnerCross(Tuple6 memory newOwner) external;
}
+<<<<<<< HEAD
/// @dev anonymous struct
struct Tuple19 {
address field_0;
@@ -373,6 +378,8 @@
function tokenURI(uint256 tokenId) external view returns (string memory);
}
+=======
+>>>>>>> feat: Add custum signature with unlimited nesting.
/// @title ERC721 Token that can be irreversibly burned (destroyed).
/// @dev the ERC-165 identifier for this interface is 0x42966c68
interface ERC721Burnable is Dummy, ERC165 {
@@ -438,7 +445,11 @@
}
/// @title Unique extensions for ERC721.
+<<<<<<< HEAD
/// @dev the ERC-165 identifier for this interface is 0x244543ee
+=======
+/// @dev the ERC-165 identifier for this interface is 0xcc97cb35
+>>>>>>> feat: Add custum signature with unlimited nesting.
interface ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -456,7 +467,7 @@
/// operator of the current owner.
/// @param approved The new substrate address approved NFT controller
/// @param tokenId The NFT to approve
- /// @dev EVM selector for this function is: 0x0ecd0ab0,
+ /// @dev EVM selector for this function is: 0x106fdb59,
/// or in textual repr: approveCross((address,uint256),uint256)
function approveCross(Tuple6 memory approved, uint256 tokenId) external;
@@ -476,10 +487,15 @@
/// @param to Cross acccount address of new owner
/// @param tokenId The NFT to transfer
/// @dev EVM selector for this function is: 0xd5cf430b,
- /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
+ /// or in textual repr: transferFromCross(EthCrossAccount,EthCrossAccount,uint256)
function transferFromCross(
+<<<<<<< HEAD
Tuple6 memory from,
Tuple6 memory to,
+=======
+ EthCrossAccount memory from,
+ EthCrossAccount memory to,
+>>>>>>> feat: Add custum signature with unlimited nesting.
uint256 tokenId
) external;
@@ -499,7 +515,7 @@
/// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
/// @param from The current owner of the NFT
/// @param tokenId The NFT to transfer
- /// @dev EVM selector for this function is: 0xbb2f5a58,
+ /// @dev EVM selector for this function is: 0xa8106d4a,
/// or in textual repr: burnFromCross((address,uint256),uint256)
function burnFromCross(Tuple6 memory from, uint256 tokenId) external;
@@ -507,6 +523,7 @@
/// @dev EVM selector for this function is: 0x75794a3c,
/// or in textual repr: nextTokenId()
function nextTokenId() external view returns (uint256);
+<<<<<<< HEAD
// /// @notice Function to mint multiple tokens.
// /// @dev `tokenIds` should be an array of consecutive numbers and first number
// /// should be obtained with `nextTokenId` method
@@ -528,6 +545,30 @@
/// @dev anonymous struct
struct Tuple8 {
+=======
+
+ /// @notice Function to mint multiple tokens.
+ /// @dev `tokenIds` should be an array of consecutive numbers and first number
+ /// should be obtained with `nextTokenId` method
+ /// @param to The new owner
+ /// @param tokenIds IDs of the minted NFTs
+ /// @dev EVM selector for this function is: 0xf9d9a5a3,
+ /// or in textual repr: mintBulk(address,uint256[])
+ function mintBulk(address to, uint256[] memory tokenIds) external returns (bool);
+
+ /// @notice Function to mint multiple tokens with the given tokenUris.
+ /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
+ /// numbers and first number should be obtained with `nextTokenId` method
+ /// @param to The new owner
+ /// @param tokens array of pairs of token ID and token URI for minted tokens
+ /// @dev EVM selector for this function is: 0xfd4e2a99,
+ /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
+ function mintBulkWithTokenURI(address to, Tuple12[] memory tokens) external returns (bool);
+}
+
+/// @dev anonymous struct
+struct Tuple12 {
+>>>>>>> feat: Add custum signature with unlimited nesting.
uint256 field_0;
string field_1;
}
@@ -538,6 +579,12 @@
uint256 field_1;
}
+/// @dev anonymous struct
+struct Tuple8 {
+ address field_0;
+ uint256 field_1;
+}
+
/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// @dev the ERC-165 identifier for this interface is 0x780e9d63
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -409,7 +409,7 @@
expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));
});
- itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
+ itEth.only('Can perform transferFromCross()', async ({helper, privateKey}) => {
const alice = privateKey('//Alice');
const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -251,10 +251,14 @@
{ "internalType": "uint256", "name": "field_1", "type": "uint256" }
],
<<<<<<< HEAD
+<<<<<<< HEAD
"internalType": "struct Tuple6",
=======
"internalType": "struct Tuple19",
>>>>>>> feat: add `EthCrossAccount` type
+=======
+ "internalType": "struct Tuple8",
+>>>>>>> feat: Add custum signature with unlimited nesting.
"name": "",
"type": "tuple"
}
@@ -263,6 +267,7 @@
"type": "function"
},
{
+<<<<<<< HEAD
"inputs": [
{ "internalType": "string[]", "name": "keys", "type": "string[]" }
],
@@ -278,6 +283,11 @@
"type": "tuple[]"
}
],
+=======
+ "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
+ "name": "collectionProperty",
+ "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
+>>>>>>> feat: Add custum signature with unlimited nesting.
"stateMutability": "view",
"type": "function"
},
@@ -298,10 +308,14 @@
{ "internalType": "uint256", "name": "field_1", "type": "uint256" }
],
<<<<<<< HEAD
+<<<<<<< HEAD
"internalType": "struct Tuple6",
=======
"internalType": "struct Tuple19",
>>>>>>> feat: add `EthCrossAccount` type
+=======
+ "internalType": "struct Tuple8",
+>>>>>>> feat: Add custum signature with unlimited nesting.
"name": "",
"type": "tuple"
}
@@ -324,6 +338,7 @@
"type": "function"
},
{
+<<<<<<< HEAD
"inputs": [
{ "internalType": "string[]", "name": "keys", "type": "string[]" }
],
@@ -333,6 +348,8 @@
"type": "function"
},
{
+=======
+>>>>>>> feat: Add custum signature with unlimited nesting.
"inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
"name": "deleteCollectionProperty",
"outputs": [],
@@ -409,19 +426,64 @@
"type": "function"
},
{
+<<<<<<< HEAD
"inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
"name": "mint",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+=======
+ "inputs": [
+ { "internalType": "address", "name": "to", "type": "address" },
+ { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+ ],
+ "name": "mint",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+>>>>>>> feat: Add custum signature with unlimited nesting.
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "to", "type": "address" },
+<<<<<<< HEAD
{ "internalType": "string", "name": "tokenUri", "type": "string" }
],
"name": "mintWithTokenURI",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+=======
+ { "internalType": "uint256[]", "name": "tokenIds", "type": "uint256[]" }
+ ],
+ "name": "mintBulk",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "to", "type": "address" },
+ {
+ "components": [
+ { "internalType": "uint256", "name": "field_0", "type": "uint256" },
+ { "internalType": "string", "name": "field_1", "type": "string" }
+ ],
+ "internalType": "struct Tuple12[]",
+ "name": "tokens",
+ "type": "tuple[]"
+ }
+ ],
+ "name": "mintBulkWithTokenURI",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ { "internalType": "address", "name": "to", "type": "address" },
+ { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
+ { "internalType": "string", "name": "tokenUri", "type": "string" }
+ ],
+ "name": "mintWithTokenURI",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+>>>>>>> feat: Add custum signature with unlimited nesting.
"stateMutability": "nonpayable",
"type": "function"
},
@@ -614,6 +676,7 @@
},
{
"inputs": [
+<<<<<<< HEAD
{
"components": [
{ "internalType": "string", "name": "field_0", "type": "string" },
@@ -623,6 +686,10 @@
"name": "properties",
"type": "tuple[]"
}
+=======
+ { "internalType": "string", "name": "key", "type": "string" },
+ { "internalType": "bytes", "name": "value", "type": "bytes" }
+>>>>>>> feat: Add custum signature with unlimited nesting.
],
"name": "setCollectionProperties",
"outputs": [],
@@ -667,6 +734,7 @@
},
{
"inputs": [
+<<<<<<< HEAD
{
"components": [
{ "internalType": "address", "name": "field_0", "type": "address" },
@@ -676,6 +744,9 @@
"name": "newOwner",
"type": "tuple"
}
+=======
+ { "internalType": "address", "name": "newOwner", "type": "address" }
+>>>>>>> feat: Add custum signature with unlimited nesting.
],
"name": "setOwnerCross",
"outputs": [],
@@ -687,8 +758,13 @@
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" },
{
"components": [
+<<<<<<< HEAD
{ "internalType": "string", "name": "field_0", "type": "string" },
{ "internalType": "bytes", "name": "field_1", "type": "bytes" }
+=======
+ { "internalType": "address", "name": "field_0", "type": "address" },
+ { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+>>>>>>> feat: Add custum signature with unlimited nesting.
],
"internalType": "struct Tuple19[]",
"name": "properties",
@@ -799,8 +875,13 @@
"inputs": [
{
"components": [
+<<<<<<< HEAD
{ "internalType": "address", "name": "field_0", "type": "address" },
{ "internalType": "uint256", "name": "field_1", "type": "uint256" }
+=======
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+>>>>>>> feat: Add custum signature with unlimited nesting.
],
<<<<<<< HEAD
"internalType": "struct Tuple6",
@@ -812,8 +893,13 @@
},
{
"components": [
+<<<<<<< HEAD
{ "internalType": "address", "name": "field_0", "type": "address" },
{ "internalType": "uint256", "name": "field_1", "type": "uint256" }
+=======
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+>>>>>>> feat: Add custum signature with unlimited nesting.
],
<<<<<<< HEAD
"internalType": "struct Tuple6",
tests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/types.ts
+++ b/tests/src/eth/util/playgrounds/types.ts
@@ -14,10 +14,8 @@
args: { [key: string]: string }
};
export interface TEthCrossAccount {
- readonly 0: string,
- readonly 1: string | Uint8Array,
- readonly field_0: string,
- readonly field_1: string | Uint8Array,
+ readonly eth: string,
+ readonly sub: string | Uint8Array,
}
export type EthProperty = string[];
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -364,19 +364,15 @@
export class EthCrossAccountGroup extends EthGroupBase {
fromAddress(address: TEthereumAccount): TEthCrossAccount {
return {
- 0: address,
- 1: '0',
- field_0: address,
- field_1: '0',
+ eth: address,
+ sub: '0',
};
}
fromKeyringPair(keyring: IKeyringPair): TEthCrossAccount {
return {
- 0: '0x0000000000000000000000000000000000000000',
- 1: keyring.addressRaw,
- field_0: '0x0000000000000000000000000000000000000000',
- field_1: keyring.addressRaw,
+ eth: '0x0000000000000000000000000000000000000000',
+ sub: keyring.addressRaw,
};
}
}
@@ -429,7 +425,6 @@
ethAddress: EthAddressGroup;
ethNativeContract: NativeContractGroup;
ethContract: ContractGroup;
- ethCrossAccount: EthCrossAccountGroup;
ethProperty: EthPropertyGroup;
constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {