difftreelog
Merge branch 'develop' into tests/eth-helpers
in: master
59 files changed
.maintain/scripts/generate_abi.shdiffbeforeafterboth4dir=$PWD4dir=$PWD556tmp=$(mktemp -d)6tmp=$(mktemp -d)7echo "Tmp file: $tmp/input.sol"7cd $tmp8cd $tmp8cp $dir/$INPUT input.sol9cp $dir/$INPUT input.sol9solcjs --abi -p input.sol10solcjs --abi -p input.solCargo.lockdiffbeforeafterboth1057 "unicode-width",1057 "unicode-width",1058]1058]10591060[[package]]1061name = "concat-idents"1062version = "1.1.4"1063source = "registry+https://github.com/rust-lang/crates.io-index"1064checksum = "0fe0e1d9f7de897d18e590a7496b5facbe87813f746cf4b8db596ba77e07e832"1065dependencies = [1066 "quote",1067 "syn",1068]106910591070[[package]]1060[[package]]1071name = "concurrent-queue"1061name = "concurrent-queue"234723372348[[package]]2338[[package]]2349name = "evm-coder"2339name = "evm-coder"2350version = "0.1.4"2340version = "0.1.5"2351dependencies = [2341dependencies = [2352 "concat-idents",2353 "ethereum",2342 "ethereum",2354 "evm-coder-procedural",2343 "evm-coder-procedural",2355 "evm-core",2344 "evm-core",236723562368[[package]]2357[[package]]2369name = "evm-coder-procedural"2358name = "evm-coder-procedural"2370version = "0.2.1"2359version = "0.2.2"2371dependencies = [2360dependencies = [2372 "Inflector",2361 "Inflector",2373 "hex",2362 "hex",crates/evm-coder/CHANGELOG.mddiffbeforeafterboth3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.445<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->6## [v0.1.5] - 2022-11-30678### Added9- Derive macro to support structures and enums.107## [v0.1.4] - 2022-11-0211## [v0.1.4] - 2022-11-028129### Added13### Addedcrates/evm-coder/Cargo.tomldiffbeforeafterboth1[package]1[package]2name = "evm-coder"2name = "evm-coder"3version = "0.1.4"3version = "0.1.5"4license = "GPLv3"4license = "GPLv3"5edition = "2021"5edition = "2021"6626hex = "0.4.3"26hex = "0.4.3"27hex-literal = "0.3.4"27hex-literal = "0.3.4"28similar-asserts = "1.4.2"28similar-asserts = "1.4.2"29concat-idents = "1.1.3"30trybuild = "1.0"29trybuild = "1.0"313032[features]31[features]crates/evm-coder/procedural/Cargo.tomldiffbeforeafterboth1[package]1[package]2name = "evm-coder-procedural"2name = "evm-coder-procedural"3version = "0.2.1"3version = "0.2.2"4license = "GPLv3"4license = "GPLv3"5edition = "2021"5edition = "2021"66crates/evm-coder/procedural/src/abi_derive/derive_enum.rsdiffbeforeafterbothno changes
crates/evm-coder/procedural/src/abi_derive/derive_struct.rsdiffbeforeafterbothno changes
crates/evm-coder/procedural/src/abi_derive/mod.rsdiffbeforeafterbothno changes
crates/evm-coder/procedural/src/lib.rsdiffbeforeafterboth25 parse_macro_input, spanned::Spanned,25 parse_macro_input, spanned::Spanned,26};26};272728mod abi_derive;28mod solidity_interface;29mod solidity_interface;29mod to_log;30mod to_log;3031243 .into()244 .into()244}245}246247#[proc_macro_derive(AbiCoder)]248pub fn abi_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {249 let ast = syn::parse(input).unwrap();250 let ts = match abi_derive::impl_abi_macro(&ast) {251 Ok(e) => e,252 Err(e) => e.to_compile_error(),253 };254 ts.into()255}245256crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth404 let name = &self.name;404 let name = &self.name;405 let ty = &self.ty;405 let ty = &self.ty;406 quote! {406 quote! {407 #name: <#ty>::abi_read(reader)?407 #name: {408 let value = <#ty as ::evm_coder::abi::AbiRead>::abi_read(reader)?;409 if !is_dynamic {reader.bytes_read(<#ty as ::evm_coder::abi::AbiType>::size())};410 value411 }408 }412 }409 }413 }410414630 let pascal_name = &self.pascal_name;634 let pascal_name = &self.pascal_name;631 let screaming_name = &self.screaming_name;635 let screaming_name = &self.screaming_name;632 if self.has_normal_args {636 if self.has_normal_args {633 let parsers = self637 let args_iter = self.args.iter().filter(|a| !a.is_special());634 .args638 let arg_type = args_iter.clone().map(|a| &a.ty);635 .iter()636 .filter(|a| !a.is_special())637 .map(|a| a.expand_parse());639 let parsers = args_iter.map(|a| a.expand_parse());638 quote! {640 quote! {639 Self::#screaming_name => return Ok(Some(Self::#pascal_name {641 Self::#screaming_name => {642 let is_dynamic = false #(|| <#arg_type as ::evm_coder::abi::AbiType>::is_dynamic())*;643 return Ok(Some(Self::#pascal_name {640 #(644 #(641 #parsers,645 #parsers,642 )*646 )*643 }))647 }))648 }644 }649 }645 } else {650 } else {646 quote! { Self::#screaming_name => return Ok(Some(Self::#pascal_name)) }651 quote! { Self::#screaming_name => return Ok(Some(Self::#pascal_name)) }crates/evm-coder/src/abi/impls.rsdiffbeforeafterboth1use crate::{1use crate::{2 custom_signature::SignatureUnit,2 execution::{Result, ResultWithPostInfo, WithPostDispatchInfo},3 execution::{Result, ResultWithPostInfo, WithPostDispatchInfo},4 make_signature, sealed,3 types::*,5 types::*,4 make_signature,5 custom_signature::SignatureUnit,6};6};7use super::{traits::*, ABI_ALIGNMENT, AbiReader, AbiWriter};7use super::{traits::*, ABI_ALIGNMENT, AbiReader, AbiWriter};8use primitive_types::{U256, H160};8use primitive_types::{U256, H160};9910#[cfg(not(feature = "std"))]10#[cfg(not(feature = "std"))]11use alloc::vec::Vec;11use alloc::vec::Vec;121213macro_rules! impl_abi_readable {13macro_rules! impl_abi_type {14 ($ty:ty, $method:ident, $dynamic:literal) => {14 ($ty:ty, $name:ident, $dynamic:literal) => {15 impl sealed::CanBePlacedInVec for $ty {}15 impl sealed::CanBePlacedInVec for $ty {}161617 impl AbiType for $ty {17 impl AbiType for $ty {18 const SIGNATURE: SignatureUnit = make_signature!(new fixed(stringify!($ty)));18 const SIGNATURE: SignatureUnit = make_signature!(new fixed(stringify!($name)));191920 fn is_dynamic() -> bool {20 fn is_dynamic() -> bool {21 $dynamic21 $dynamic26 }26 }27 }27 }2829 impl AbiRead for $ty {30 fn abi_read(reader: &mut AbiReader) -> Result<$ty> {31 reader.$method()32 }33 }34 };28 };35}29}363031macro_rules! impl_abi_readable {32 ($ty:ty, $method:ident) => {33 impl AbiRead for $ty {34 fn abi_read(reader: &mut AbiReader) -> Result<$ty> {35 reader.$method()36 }37 }38 };39}4041macro_rules! impl_abi_writeable {42 ($ty:ty, $method:ident) => {43 impl AbiWrite for $ty {44 fn abi_write(&self, writer: &mut AbiWriter) {45 writer.$method(&self)46 }47 }48 };49}5051macro_rules! impl_abi {52 ($ty:ty, $method:ident, $dynamic:literal) => {53 impl_abi_type!($ty, $method, $dynamic);37impl_abi_readable!(uint32, uint32, false);54 impl_abi_readable!($ty, $method);55 impl_abi_writeable!($ty, $method);56 };57}5838impl_abi_readable!(uint64, uint64, false);59impl_abi!(bool, bool, false);39impl_abi_readable!(uint128, uint128, false);60impl_abi!(u8, uint8, false);40impl_abi_readable!(uint256, uint256, false);61impl_abi!(u32, uint32, false);41impl_abi_readable!(bytes4, bytes4, false);62impl_abi!(u64, uint64, false);42impl_abi_readable!(address, address, false);63impl_abi!(u128, uint128, false);43impl_abi_readable!(string, string, true);64impl_abi!(U256, uint256, false);4445impl sealed::CanBePlacedInVec for bool {}4647impl AbiType for bool {48 const SIGNATURE: SignatureUnit = make_signature!(new fixed("bool"));65impl_abi!(H160, address, false);4950 fn is_dynamic() -> bool {51 false52 }53 fn size() -> usize {54 ABI_ALIGNMENT55 }56}57impl AbiRead for bool {58 fn abi_read(reader: &mut AbiReader) -> Result<bool> {59 reader.bool()60 }61}6263impl AbiType for uint8 {64 const SIGNATURE: SignatureUnit = make_signature!(new fixed("uint8"));66impl_abi!(string, string, true);656766 fn is_dynamic() -> bool {67 false68 }69 fn size() -> usize {70 ABI_ALIGNMENT71 }72}73impl AbiRead for uint8 {74 fn abi_read(reader: &mut AbiReader) -> Result<uint8> {68impl_abi_writeable!(&str, string);75 reader.uint8()6976 }77}7879impl AbiType for bytes {80 const SIGNATURE: SignatureUnit = make_signature!(new fixed("bytes"));70impl_abi_type!(bytes, bytes, true);817182 fn is_dynamic() -> bool {83 true84 }85 fn size() -> usize {86 ABI_ALIGNMENT87 }88}89impl AbiRead for bytes {72impl AbiRead for bytes {90 fn abi_read(reader: &mut AbiReader) -> Result<bytes> {73 fn abi_read(reader: &mut AbiReader) -> Result<bytes> {91 Ok(bytes(reader.bytes()?))74 Ok(bytes(reader.bytes()?))92 }75 }93}76}7778impl AbiWrite for bytes {79 fn abi_write(&self, writer: &mut AbiWriter) {80 writer.bytes(self.0.as_slice())81 }82}8384impl_abi_type!(bytes4, bytes4, false);85impl AbiRead for bytes4 {86 fn abi_read(reader: &mut AbiReader) -> Result<bytes4> {87 reader.bytes4()88 }89}9091impl<T: AbiWrite> AbiWrite for &T {92 fn abi_write(&self, writer: &mut AbiWriter) {93 T::abi_write(self, writer);94 }95}9697impl<T: AbiType> AbiType for &T {98 const SIGNATURE: SignatureUnit = T::SIGNATURE;99100 fn is_dynamic() -> bool {101 T::is_dynamic()102 }103104 fn size() -> usize {105 T::size()106 }107}9410895impl<R: AbiRead + sealed::CanBePlacedInVec> AbiRead for Vec<R> {109impl<T: AbiType + AbiRead + sealed::CanBePlacedInVec> AbiRead for Vec<T> {96 fn abi_read(reader: &mut AbiReader) -> Result<Vec<R>> {110 fn abi_read(reader: &mut AbiReader) -> Result<Vec<T>> {97 let mut sub = reader.subresult(None)?;111 let mut sub = reader.subresult(None)?;98 let size = sub.uint32()? as usize;112 let size = sub.uint32()? as usize;99 sub.subresult_offset = sub.offset;113 sub.subresult_offset = sub.offset;114 let is_dynamic = <T as AbiType>::is_dynamic();100 let mut out = Vec::with_capacity(size);115 let mut out = Vec::with_capacity(size);101 for _ in 0..size {116 for _ in 0..size {102 out.push(<R>::abi_read(&mut sub)?);117 out.push(<T as AbiRead>::abi_read(&mut sub)?);118 if !is_dynamic {119 sub.bytes_read(<T as AbiType>::size());120 };103 }121 }104 Ok(out)122 Ok(out)105 }123 }106}124}107125108impl<R: AbiType> AbiType for Vec<R> {126impl<T: AbiType> AbiType for Vec<T> {109 const SIGNATURE: SignatureUnit = make_signature!(new nameof(R::SIGNATURE) fixed("[]"));127 const SIGNATURE: SignatureUnit = make_signature!(new nameof(T::SIGNATURE) fixed("[]"));110128111 fn is_dynamic() -> bool {129 fn is_dynamic() -> bool {112 true130 true117 }135 }118}136}119120impl sealed::CanBePlacedInVec for EthCrossAccount {}121122impl AbiType for EthCrossAccount {123 const SIGNATURE: SignatureUnit = make_signature!(new fixed("(address,uint256)"));124125 fn is_dynamic() -> bool {126 address::is_dynamic() || uint256::is_dynamic()127 }128129 fn size() -> usize {130 <address as AbiType>::size() + <uint256 as AbiType>::size()131 }132}133134impl AbiRead for EthCrossAccount {135 fn abi_read(reader: &mut AbiReader) -> Result<EthCrossAccount> {136 let size = if !EthCrossAccount::is_dynamic() {137 Some(<EthCrossAccount as AbiType>::size())138 } else {139 None140 };141 let mut subresult = reader.subresult(size)?;142 let eth = <address>::abi_read(&mut subresult)?;143 let sub = <uint256>::abi_read(&mut subresult)?;144145 Ok(EthCrossAccount { eth, sub })146 }147}148149impl AbiWrite for EthCrossAccount {150 fn abi_write(&self, writer: &mut AbiWriter) {151 self.eth.abi_write(writer);152 self.sub.abi_write(writer);153 }154}155137156impl sealed::CanBePlacedInVec for Property {}138impl sealed::CanBePlacedInVec for Property {}157139188 }170 }189}171}190191macro_rules! impl_abi_writeable {192 ($ty:ty, $method:ident) => {193 impl AbiWrite for $ty {194 fn abi_write(&self, writer: &mut AbiWriter) {195 writer.$method(&self)196 }197 }198 };199}200201impl_abi_writeable!(u8, uint8);202impl_abi_writeable!(u32, uint32);203impl_abi_writeable!(u128, uint128);204impl_abi_writeable!(U256, uint256);205impl_abi_writeable!(H160, address);206impl_abi_writeable!(bool, bool);207impl_abi_writeable!(&str, string);208209impl AbiWrite for string {210 fn abi_write(&self, writer: &mut AbiWriter) {211 writer.string(self)212 }213}214215impl AbiWrite for bytes {216 fn abi_write(&self, writer: &mut AbiWriter) {217 writer.bytes(self.0.as_slice())218 }219}220172221impl<T: AbiWrite + AbiType> AbiWrite for Vec<T> {173impl<T: AbiWrite + AbiType> AbiWrite for Vec<T> {222 fn abi_write(&self, writer: &mut AbiWriter) {174 fn abi_write(&self, writer: &mut AbiWriter) {295247296 impl<$($ident),+> AbiRead for ($($ident,)+)248 impl<$($ident),+> AbiRead for ($($ident,)+)297 where249 where250 Self: AbiType,298 $($ident: AbiRead,)+251 $($ident: AbiRead + AbiType,)+299 ($($ident,)+): AbiType,300 {252 {301 fn abi_read(reader: &mut AbiReader) -> Result<($($ident,)+)> {253 fn abi_read(reader: &mut AbiReader) -> Result<($($ident,)+)> {302 let size = if !<($($ident,)+)>::is_dynamic() { Some(<($($ident,)+)>::size()) } else { None };254 let is_dynamic = <Self>::is_dynamic();255 let size = if !is_dynamic { Some(<Self>::size()) } else { None };303 let mut subresult = reader.subresult(size)?;256 let mut subresult = reader.subresult(size)?;304 Ok((257 Ok((305 $(<$ident>::abi_read(&mut subresult)?,)+258 $({259 let value = <$ident>::abi_read(&mut subresult)?;260 if !is_dynamic {subresult.bytes_read(<$ident as AbiType>::size())};261 value262 },)+306 ))263 ))307 }264 }308 }265 }309266310 #[allow(non_snake_case)]267 #[allow(non_snake_case)]311 impl<$($ident),+> AbiWrite for ($($ident,)+)268 impl<$($ident),+> AbiWrite for ($($ident,)+)312 where269 where313 $($ident: AbiWrite,)+270 $($ident: AbiWrite + AbiType,)+314 {271 {315 fn abi_write(&self, writer: &mut AbiWriter) {272 fn abi_write(&self, writer: &mut AbiWriter) {316 let ($($ident,)+) = self;273 let ($($ident,)+) = self;317 if writer.is_dynamic {274 if <Self as AbiType>::is_dynamic() {318 let mut sub = AbiWriter::new();275 let mut sub = AbiWriter::new();319 $($ident.abi_write(&mut sub);)+276 $($ident.abi_write(&mut sub);)+320 writer.write_subresult(sub);277 writer.write_subresult(sub);crates/evm-coder/src/abi/mod.rsdiffbeforeafterboth75 buf: &[u8],75 buf: &[u8],76 offset: usize,76 offset: usize,77 pad_start: usize,77 pad_start: usize,78 pad_size: usize,78 pad_end: usize,79 block_start: usize,79 block_start: usize,80 block_size: usize,80 block_end: usize,81 ) -> Result<[u8; S]> {81 ) -> Result<[u8; S]> {82 if buf.len() - offset < ABI_ALIGNMENT {82 if buf.len() - offset < ABI_ALIGNMENT {83 return Err(Error::Error(ExitError::OutOfOffset));83 return Err(Error::Error(ExitError::OutOfOffset));84 }84 }85 let mut block = [0; S];85 let mut block = [0; S];86 let is_pad_zeroed = buf[pad_start..pad_size].iter().all(|&v| v == 0);86 let is_pad_zeroed = buf[pad_start..pad_end].iter().all(|&v| v == 0);87 if !is_pad_zeroed {87 if !is_pad_zeroed {88 return Err(Error::Error(ExitError::InvalidRange));88 return Err(Error::Error(ExitError::InvalidRange));89 }89 }90 block.copy_from_slice(&buf[block_start..block_size]);90 block.copy_from_slice(&buf[block_start..block_end]);91 Ok(block)91 Ok(block)92 }92 }9393186186187 /// Slice recursive buffer, advance one word for buffer offset187 /// Slice recursive buffer, advance one word for buffer offset188 /// If `size` is [`None`] then [`Self::offset`] and [`Self::subresult_offset`] evals from [`Self::buf`].188 /// If `size` is [`None`] then [`Self::offset`] and [`Self::subresult_offset`] evals from [`Self::buf`].189 fn subresult(&mut self, size: Option<usize>) -> Result<AbiReader<'i>> {189 pub fn subresult(&mut self, size: Option<usize>) -> Result<AbiReader<'i>> {190 let subresult_offset = self.subresult_offset;190 let subresult_offset = self.subresult_offset;191 let offset = if let Some(size) = size {191 let offset = if let Some(size) = size {192 self.offset += size;192 self.offset += size;193 self.subresult_offset += size;194 0193 0195 } else {194 } else {196 self.uint32()? as usize195 self.uint32()? as usize208 })207 })209 }208 }209210 /// Notify about readed data portion.211 pub fn bytes_read(&mut self, size: usize) {212 self.subresult_offset += size;213 }210214211 /// Is this parser reached end of buffer?215 /// Is this parser reached end of buffer?212 pub fn is_finished(&self) -> bool {216 pub fn is_finished(&self) -> bool {277 self.write_padleft(&u32::to_be_bytes(*value))281 self.write_padleft(&u32::to_be_bytes(*value))278 }282 }283284 /// Write [`u64`] to end of buffer285 pub fn uint64(&mut self, value: &u64) {286 self.write_padleft(&u64::to_be_bytes(*value))287 }279288280 /// Write [`u128`] to end of buffer289 /// Write [`u128`] to end of buffer281 pub fn uint128(&mut self, value: &u128) {290 pub fn uint128(&mut self, value: &u128) {crates/evm-coder/src/abi/test.rsdiffbeforeafterboth6use super::{AbiReader, AbiWriter};6use super::{AbiReader, AbiWriter};7use hex_literal::hex;7use hex_literal::hex;8use primitive_types::{H160, U256};8use primitive_types::{H160, U256};9use concat_idents::concat_idents;10911macro_rules! test_impl {10fn test_impl<T>(function_identifier: u32, decoded_data: T, encoded_data: &[u8])11where12 ($name:ident, $type:ty, $function_identifier:expr, $decoded_data:expr, $encoded_data:expr) => {12 T: AbiWrite + AbiRead + std::cmp::PartialEq + std::fmt::Debug,13 concat_idents!(test_name = encode_decode_, $name {13{14 #[test]15 fn test_name() {16 let function_identifier: u32 = $function_identifier;17 let decoded_data = $decoded_data;18 let encoded_data = $encoded_data;1920 let (call, mut decoder) = AbiReader::new_call(encoded_data).unwrap();14 let (call, mut decoder) = AbiReader::new_call(encoded_data).unwrap();21 assert_eq!(call, u32::to_be_bytes(function_identifier));15 assert_eq!(call, u32::to_be_bytes(function_identifier));22 let data = <$type>::abi_read(&mut decoder).unwrap();16 let data = <T>::abi_read(&mut decoder).unwrap();23 assert_eq!(data, decoded_data);17 assert_eq!(data, decoded_data);241825 let mut writer = AbiWriter::new_call(function_identifier);19 let mut writer = AbiWriter::new_call(function_identifier);26 decoded_data.abi_write(&mut writer);20 decoded_data.abi_write(&mut writer);27 let ed = writer.finish();21 let ed = writer.finish();28 similar_asserts::assert_eq!(encoded_data, ed.as_slice());22 similar_asserts::assert_eq!(encoded_data, ed.as_slice());29 }30 });31 };23}32}332434macro_rules! test_impl_uint {25macro_rules! test_impl_uint {35 ($type:ident) => {26 ($type:ident) => {36 test_impl!(27 test_impl::<$type>(37 $type,38 $type,39 0xdeadbeef,28 0xdeadbeef,40 255 as $type,29 255 as $type,41 &hex!(30 &hex!(42 "31 "43 deadbeef32 deadbeef44 00000000000000000000000000000000000000000000000000000000000000ff33 00000000000000000000000000000000000000000000000000000000000000ff45 "34 "46 )35 ),47 );36 );48 };37 };49}38}503940#[test]41fn encode_decode_uint8() {51test_impl_uint!(uint8);42 test_impl_uint!(uint8);43}4445#[test]46fn encode_decode_uint32() {52test_impl_uint!(uint32);47 test_impl_uint!(uint32);48}4950#[test]51fn encode_decode_uint128() {53test_impl_uint!(uint128);52 test_impl_uint!(uint128);5453}5455#[test]56fn encode_decode_uint256() {55test_impl!(57 test_impl::<uint256>(56 uint256,57 uint256,58 0xdeadbeef,58 0xdeadbeef,59 U256([255, 0, 0, 0]),59 U256([255, 0, 0, 0]),60 &hex!(60 &hex!(61 "61 "62 deadbeef62 deadbeef63 00000000000000000000000000000000000000000000000000000000000000ff63 00000000000000000000000000000000000000000000000000000000000000ff64 "64 "65 )65 ),66);66 );6767}6869#[test]70fn encode_decode_string() {71 test_impl::<String>(72 0xdeadbeef,73 "some string".to_string(),74 &hex!(75 "76 deadbeef77 000000000000000000000000000000000000000000000000000000000000002078 000000000000000000000000000000000000000000000000000000000000000b79 736f6d6520737472696e6700000000000000000000000000000000000000000080 "81 ),82 );83}8485#[test]86fn encode_decode_tuple_string() {87 test_impl::<(String,)>(88 0xdeadbeef,89 ("some string".to_string(),),90 &hex!(91 "92 deadbeef93 000000000000000000000000000000000000000000000000000000000000002094 000000000000000000000000000000000000000000000000000000000000002095 000000000000000000000000000000000000000000000000000000000000000b96 736f6d6520737472696e6700000000000000000000000000000000000000000097 "98 ),99 );100}101102#[test]103fn encode_decode_vec_tuple_address_uint256() {68test_impl!(104 test_impl::<Vec<(address, uint256)>>(69 vec_tuple_address_uint256,70 Vec<(address, uint256)>,71 0x1ACF2D55,105 0x1ACF2D55,72 vec![106 vec![73 (107 (84 ),118 ),85 ],119 ],86 &hex!(120 &hex!(87 "121 "88 1ACF2D55122 1ACF2D5589 0000000000000000000000000000000000000000000000000000000000000020 // offset of (address, uint256)[]123 0000000000000000000000000000000000000000000000000000000000000020 // offset of (address, uint256)[]90 0000000000000000000000000000000000000000000000000000000000000003 // length of (address, uint256)[]124 0000000000000000000000000000000000000000000000000000000000000003 // length of (address, uint256)[]9112592 0000000000000000000000002D2FF76104B7BACB2E8F6731D5BFC184EBECDDBC // address126 0000000000000000000000002D2FF76104B7BACB2E8F6731D5BFC184EBECDDBC // address93 000000000000000000000000000000000000000000000000000000000000000A // uint256127 000000000000000000000000000000000000000000000000000000000000000A // uint2569412895 000000000000000000000000AB8E3D9134955566483B11E6825C9223B6737B10 // address129 000000000000000000000000AB8E3D9134955566483B11E6825C9223B6737B10 // address96 0000000000000000000000000000000000000000000000000000000000000014 // uint256130 0000000000000000000000000000000000000000000000000000000000000014 // uint2569713198 0000000000000000000000008C582BDF2953046705FC56F189385255EFC1BE18 // address132 0000000000000000000000008C582BDF2953046705FC56F189385255EFC1BE18 // address99 000000000000000000000000000000000000000000000000000000000000001E // uint256133 000000000000000000000000000000000000000000000000000000000000001E // uint256100 "134 "101 )135 )102);136 );103137}138139#[test]140fn encode_decode_vec_tuple_uint256_string() {104test_impl!(141 test_impl::<Vec<(uint256, string)>>(105 vec_tuple_uint256_string,106 Vec<(uint256, string)>,107 0xdeadbeef,142 0xdeadbeef,108 vec![143 vec![109 (1.into(), "Test URI 0".to_string()),144 (1.into(), "Test URI 0".to_string()),110 (11.into(), "Test URI 1".to_string()),145 (11.into(), "Test URI 1".to_string()),111 (12.into(), "Test URI 2".to_string()),146 (12.into(), "Test URI 2".to_string()),112 ],147 ],113 &hex!(148 &hex!(114 "149 "115 deadbeef150 deadbeef116 0000000000000000000000000000000000000000000000000000000000000020 // offset of (uint256, string)[]151 0000000000000000000000000000000000000000000000000000000000000020 // offset of (uint256, string)[]117 0000000000000000000000000000000000000000000000000000000000000003 // length of (uint256, string)[]152 0000000000000000000000000000000000000000000000000000000000000003 // length of (uint256, string)[]118153119 0000000000000000000000000000000000000000000000000000000000000060 // offset of first elem154 0000000000000000000000000000000000000000000000000000000000000060 // offset of first elem120 00000000000000000000000000000000000000000000000000000000000000e0 // offset of second elem155 00000000000000000000000000000000000000000000000000000000000000e0 // offset of second elem121 0000000000000000000000000000000000000000000000000000000000000160 // offset of third elem156 0000000000000000000000000000000000000000000000000000000000000160 // offset of third elem122157123 0000000000000000000000000000000000000000000000000000000000000001 // first token id? #60158 0000000000000000000000000000000000000000000000000000000000000001 // first token id? #60124 0000000000000000000000000000000000000000000000000000000000000040 // offset of string159 0000000000000000000000000000000000000000000000000000000000000040 // offset of string125 000000000000000000000000000000000000000000000000000000000000000a // size of string160 000000000000000000000000000000000000000000000000000000000000000a // size of string126 5465737420555249203000000000000000000000000000000000000000000000 // string161 5465737420555249203000000000000000000000000000000000000000000000 // string127162128 000000000000000000000000000000000000000000000000000000000000000b // second token id? Why ==11? #e0163 000000000000000000000000000000000000000000000000000000000000000b // second token id? Why ==11? #e0129 0000000000000000000000000000000000000000000000000000000000000040 // offset of string164 0000000000000000000000000000000000000000000000000000000000000040 // offset of string130 000000000000000000000000000000000000000000000000000000000000000a // size of string165 000000000000000000000000000000000000000000000000000000000000000a // size of string131 5465737420555249203100000000000000000000000000000000000000000000 // string166 5465737420555249203100000000000000000000000000000000000000000000 // string132167133 000000000000000000000000000000000000000000000000000000000000000c // third token id? Why ==12? #160168 000000000000000000000000000000000000000000000000000000000000000c // third token id? Why ==12? #160134 0000000000000000000000000000000000000000000000000000000000000040 // offset of string169 0000000000000000000000000000000000000000000000000000000000000040 // offset of string135 000000000000000000000000000000000000000000000000000000000000000a // size of string170 000000000000000000000000000000000000000000000000000000000000000a // size of string136 5465737420555249203200000000000000000000000000000000000000000000 // string171 5465737420555249203200000000000000000000000000000000000000000000 // string137 "172 "138 )173 )139);174 );175}140176141#[test]177#[test]142fn dynamic_after_static() {178fn dynamic_after_static() {235 similar_asserts::assert_eq!(encoded_data, ed.as_slice());271 similar_asserts::assert_eq!(encoded_data, ed.as_slice());236}272}237273274#[test]275fn encode_decode_vec_tuple_string_bytes() {238test_impl!(276 test_impl::<Vec<(string, bytes)>>(239 vec_tuple_string_bytes,240 Vec<(string, bytes)>,241 0xdeadbeef,277 0xdeadbeef,242 vec![278 vec![243 (279 (261 ("Test URI 2".to_string(), bytes(vec![0x33, 0x33])),297 ("Test URI 2".to_string(), bytes(vec![0x33, 0x33])),262 ],298 ],263 &hex!(299 &hex!(264 "300 "265 deadbeef301 deadbeef266 0000000000000000000000000000000000000000000000000000000000000020302 0000000000000000000000000000000000000000000000000000000000000020267 0000000000000000000000000000000000000000000000000000000000000003303 0000000000000000000000000000000000000000000000000000000000000003304268 305 0000000000000000000000000000000000000000000000000000000000000060269 0000000000000000000000000000000000000000000000000000000000000060306 0000000000000000000000000000000000000000000000000000000000000140270 0000000000000000000000000000000000000000000000000000000000000140307 0000000000000000000000000000000000000000000000000000000000000220271 0000000000000000000000000000000000000000000000000000000000000220308272309 0000000000000000000000000000000000000000000000000000000000000040273 0000000000000000000000000000000000000000000000000000000000000040310 0000000000000000000000000000000000000000000000000000000000000080274 0000000000000000000000000000000000000000000000000000000000000080311 000000000000000000000000000000000000000000000000000000000000000a275 000000000000000000000000000000000000000000000000000000000000000a312 5465737420555249203000000000000000000000000000000000000000000000276 5465737420555249203000000000000000000000000000000000000000000000313 0000000000000000000000000000000000000000000000000000000000000030277 0000000000000000000000000000000000000000000000000000000000000030314 1111111111111111111111111111111111111111111111111111111111111111278 1111111111111111111111111111111111111111111111111111111111111111315 1111111111111111111111111111111100000000000000000000000000000000279 1111111111111111111111111111111100000000000000000000000000000000316280317 0000000000000000000000000000000000000000000000000000000000000040281 0000000000000000000000000000000000000000000000000000000000000040318 0000000000000000000000000000000000000000000000000000000000000080282 0000000000000000000000000000000000000000000000000000000000000080319 000000000000000000000000000000000000000000000000000000000000000a283 000000000000000000000000000000000000000000000000000000000000000a320 5465737420555249203100000000000000000000000000000000000000000000284 5465737420555249203100000000000000000000000000000000000000000000321 000000000000000000000000000000000000000000000000000000000000002f285 000000000000000000000000000000000000000000000000000000000000002f322 2222222222222222222222222222222222222222222222222222222222222222286 2222222222222222222222222222222222222222222222222222222222222222323 2222222222222222222222222222220000000000000000000000000000000000287 2222222222222222222222222222220000000000000000000000000000000000324288325 0000000000000000000000000000000000000000000000000000000000000040289 0000000000000000000000000000000000000000000000000000000000000040326 0000000000000000000000000000000000000000000000000000000000000080290 0000000000000000000000000000000000000000000000000000000000000080327 000000000000000000000000000000000000000000000000000000000000000a291 000000000000000000000000000000000000000000000000000000000000000a328 5465737420555249203200000000000000000000000000000000000000000000292 5465737420555249203200000000000000000000000000000000000000000000329 0000000000000000000000000000000000000000000000000000000000000002293 0000000000000000000000000000000000000000000000000000000000000002330 3333000000000000000000000000000000000000000000000000000000000000294 3333000000000000000000000000000000000000000000000000000000000000331 "295 "296 )332 ),297);333 );334}335336#[test]337// #[ignore = "reason"]338fn encode_decode_tuple0_tuple1_uint8_tuple1_string_bytes_tuple1_uint8_bytes() {339 let int = 0xff;340 let by = bytes(vec![0x11, 0x22, 0x33]);341 let string = "some string".to_string();342343 test_impl::<((u8,), (String, bytes), (u8, bytes))>(344 0xdeadbeef,345 ((int,), (string.clone(), by.clone()), (int, by)),346 &hex!(347 "348 deadbeef349 0000000000000000000000000000000000000000000000000000000000000020350 00000000000000000000000000000000000000000000000000000000000000ff351 0000000000000000000000000000000000000000000000000000000000000060352 0000000000000000000000000000000000000000000000000000000000000120353 0000000000000000000000000000000000000000000000000000000000000040354 0000000000000000000000000000000000000000000000000000000000000080355 000000000000000000000000000000000000000000000000000000000000000b356 736f6d6520737472696e67000000000000000000000000000000000000000000357 0000000000000000000000000000000000000000000000000000000000000003358 1122330000000000000000000000000000000000000000000000000000000000359 00000000000000000000000000000000000000000000000000000000000000ff360 0000000000000000000000000000000000000000000000000000000000000040361 0000000000000000000000000000000000000000000000000000000000000003362 1122330000000000000000000000000000000000000000000000000000000000363 "364 ),365 );366}367368#[test]369fn encode_decode_tuple0_tuple1_uint8_tuple1_uint8_uint8_tuple1_uint8_uint8() {370 test_impl::<((u8,), (u8, u8), (u8, u8))>(371 0xdeadbeef,372 ((43,), (44, 45), (46, 47)),373 &hex!(374 "375 deadbeef376 000000000000000000000000000000000000000000000000000000000000002b377 000000000000000000000000000000000000000000000000000000000000002c378 000000000000000000000000000000000000000000000000000000000000002d379 000000000000000000000000000000000000000000000000000000000000002e380 000000000000000000000000000000000000000000000000000000000000002f381 "382 ),383 );384}385386#[test]387fn encode_decode_tuple0_tuple1_uint8_tuple1_uint8() {388 test_impl::<((u8,), (u8,))>(389 0xdeadbeef,390 ((43,), (44,)),391 &hex!(392 "393 deadbeef394 000000000000000000000000000000000000000000000000000000000000002b395 000000000000000000000000000000000000000000000000000000000000002c396 "397 ),398 );399}400401#[test]402fn encode_decode_tuple0_tuple1_uint8_uint8() {403 test_impl::<((u8, u8),)>(404 0xdeadbeef,405 ((43, 44),),406 &hex!(407 "408 deadbeef409 000000000000000000000000000000000000000000000000000000000000002b410 000000000000000000000000000000000000000000000000000000000000002c411 "412 ),413 );414}415416#[test]417fn encode_decode_tuple_uint8_uint8() {418 test_impl::<(u8, u8)>(419 0xdeadbeef,420 (43, 44),421 &hex!(422 "423 deadbeef424 000000000000000000000000000000000000000000000000000000000000002b425 000000000000000000000000000000000000000000000000000000000000002c426 "427 ),428 );429}430431#[test]432fn encode_decode_tuple0_tuple1_uint8_uint8_tuple1_uint8_uint8_and_uint8() {433 test_impl::<((u8, u8), (u8, u8), u8)>(434 0xdeadbeef,435 ((10, 11), (12, 13), 14),436 &hex!(437 "438 deadbeef439 000000000000000000000000000000000000000000000000000000000000000a440 000000000000000000000000000000000000000000000000000000000000000b441 000000000000000000000000000000000000000000000000000000000000000c442 000000000000000000000000000000000000000000000000000000000000000d443 000000000000000000000000000000000000000000000000000000000000000e444 "445 ),446 );447}448449#[test]450fn encode_decode_tuple0_tuple1_string() {451 test_impl::<((String,),)>(452 0xdeadbeef,453 (("some string".to_string(),),),454 &hex!(455 "456 deadbeef457 0000000000000000000000000000000000000000000000000000000000000020458 0000000000000000000000000000000000000000000000000000000000000020459 0000000000000000000000000000000000000000000000000000000000000020460 000000000000000000000000000000000000000000000000000000000000000b461 736f6d6520737472696e67000000000000000000000000000000000000000000462 "463 ),464 );465}466467#[test]468fn encode_decode_tuple0_tuple1_uint8_string() {469 test_impl::<((u8, String),)>(470 0xdeadbeef,471 ((0xff, "some string".to_string()),),472 &hex!(473 "474 deadbeef475 0000000000000000000000000000000000000000000000000000000000000020476 0000000000000000000000000000000000000000000000000000000000000020477 00000000000000000000000000000000000000000000000000000000000000ff478 0000000000000000000000000000000000000000000000000000000000000040479 000000000000000000000000000000000000000000000000000000000000000b480 736f6d6520737472696e67000000000000000000000000000000000000000000481 "482 ),483 );484}485486#[test]487fn encode_decode_tuple0_tuple1_string_bytes() {488 test_impl::<((String, bytes),)>(489 0xdeadbeef,490 (("some string".to_string(), bytes(vec![1, 2, 3])),),491 &hex!(492 "493 deadbeef494 0000000000000000000000000000000000000000000000000000000000000020495 0000000000000000000000000000000000000000000000000000000000000020496 0000000000000000000000000000000000000000000000000000000000000040497 0000000000000000000000000000000000000000000000000000000000000080498 000000000000000000000000000000000000000000000000000000000000000b499 736f6d6520737472696e67000000000000000000000000000000000000000000500 0000000000000000000000000000000000000000000000000000000000000003501 0102030000000000000000000000000000000000000000000000000000000000502 "503 ),504 );505}506507#[test]508fn encode_decode_tuple0_tuple1_uint8_tuple1_string() {509 test_impl::<((u8,), (String,))>(510 0xdeadbeef,511 ((0xff,), ("some string".to_string(),)),512 &hex!(513 "514 deadbeef515 0000000000000000000000000000000000000000000000000000000000000020516 00000000000000000000000000000000000000000000000000000000000000ff517 0000000000000000000000000000000000000000000000000000000000000040518 0000000000000000000000000000000000000000000000000000000000000020519 000000000000000000000000000000000000000000000000000000000000000b520 736f6d6520737472696e67000000000000000000000000000000000000000000521 "522 ),523 );524}525526#[test]527fn parse_multiple_params() {528 let encoded_data = hex!(529 "530 deadbeef531 000000000000000000000000000000000000000000000000000000000000000a532 000000000000000000000000000000000000000000000000000000000000000b533 "534 );535 let (_, mut decoder) = AbiReader::new_call(&encoded_data).unwrap();536 let p1 = <u8>::abi_read(&mut decoder).unwrap();537 let p2 = <u8>::abi_read(&mut decoder).unwrap();538 assert_eq!(p1, 0x0a);539 assert_eq!(p2, 0x0b);540}298541crates/evm-coder/src/abi/traits.rsdiffbeforeafterboth22 fn size() -> usize;22 fn size() -> usize;23}23}2425/// Sealed traits.26pub mod sealed {27 /// Not all types can be placed in vec, i.e `Vec<u8>` is restricted, `bytes` should be used instead28 pub trait CanBePlacedInVec {}29}302431/// [`AbiReader`] implements reading of many types.25/// [`AbiReader`] implements reading of many types.32pub trait AbiRead {26pub trait AbiRead {50 }44 }51}45}5253impl<T: AbiWrite> AbiWrite for &T {54 fn abi_write(&self, writer: &mut AbiWriter) {55 T::abi_write(self, writer);56 }57}5846crates/evm-coder/src/lib.rsdiffbeforeafterboth93pub use evm_coder_procedural::solidity;93pub use evm_coder_procedural::solidity;94/// See [`solidity_interface`]94/// See [`solidity_interface`]95pub use evm_coder_procedural::weight;95pub use evm_coder_procedural::weight;96pub use evm_coder_procedural::AbiCoder;96pub use sha3_const;97pub use sha3_const;979898/// Derives [`ToLog`] for enum99/// Derives [`ToLog`] for enum111#[cfg(feature = "stubgen")]112#[cfg(feature = "stubgen")]112pub mod solidity;113pub mod solidity;114115/// Sealed traits.116pub mod sealed {117 /// Not every type should be directly placed in vec.118 /// Vec encoding is not memory efficient, as every item will be padded119 /// to 32 bytes.120 /// Instead you should use specialized types (`bytes` in case of `Vec<u8>`)121 pub trait CanBePlacedInVec {}122}113123114/// Solidity type definitions (aliases from solidity name to rust type)124/// Solidity type definitions (aliases from solidity name to rust type)115/// To be used in [`solidity_interface`] definitions, to make sure there is no125/// To be used in [`solidity_interface`] definitions, to make sure there is no119129120 #[cfg(not(feature = "std"))]130 #[cfg(not(feature = "std"))]121 use alloc::{vec::Vec};131 use alloc::{vec::Vec};122 use pallet_evm::account::CrossAccountId;123 use primitive_types::{U256, H160, H256};132 use primitive_types::{U256, H160, H256};124133125 pub type address = H160;134 pub type address = H160;137 #[cfg(feature = "std")]146 #[cfg(feature = "std")]138 pub type string = ::std::string::String;147 pub type string = ::std::string::String;139148140 #[derive(Default, Debug, PartialEq)]149 #[derive(Default, Debug, PartialEq, Eq, Clone)]141 pub struct bytes(pub Vec<u8>);150 pub struct bytes(pub Vec<u8>);142151143 /// Solidity doesn't have `void` type, however we have special implementation152 /// Solidity doesn't have `void` type, however we have special implementation188 }197 }189 }198 }190191 #[derive(Debug, Default)]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::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::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 /// Convert `CrossAccountId` to `uint256`.234 pub fn convert_cross_account_to_uint256<T: pallet_evm::Config>(235 from: &T::CrossAccountId,236 ) -> uint256237 where238 T::AccountId: AsRef<[u8; 32]>,239 {240 let slice = from.as_sub().as_ref();241 uint256::from_big_endian(slice)242 }243244 /// Convert `uint256` to `CrossAccountId`.245 pub fn convert_uint256_to_cross_account<T: pallet_evm::Config>(246 from: uint256,247 ) -> T::CrossAccountId248 where249 T::AccountId: From<[u8; 32]>,250 {251 let mut new_admin_arr = [0_u8; 32];252 from.to_big_endian(&mut new_admin_arr);253 let account_id = T::AccountId::from(new_admin_arr);254 T::CrossAccountId::from_sub(account_id)255 }256199257 #[derive(Debug, Default)]200 #[derive(Debug, Default)]258 pub struct Property {201 pub struct Property {crates/evm-coder/src/solidity.rsdiffbeforeafterbothno changes
crates/evm-coder/src/solidity/impls.rsdiffbeforeafterbothno changes
crates/evm-coder/src/solidity/mod.rsdiffbeforeafterbothno changes
crates/evm-coder/src/solidity/traits.rsdiffbeforeafterbothno changes
crates/evm-coder/tests/abi_derive_generation.rsdiffbeforeafterbothno changes
crates/evm-coder/tests/build_failed/abi_derive_enum_generation.rsdiffbeforeafterbothno changes
crates/evm-coder/tests/build_failed/abi_derive_enum_generation.stderrdiffbeforeafterbothno changes
crates/evm-coder/tests/build_failed/abi_derive_struct_generation.rsdiffbeforeafterbothno changes
crates/evm-coder/tests/build_failed/abi_derive_struct_generation.stderrdiffbeforeafterbothno changes
pallets/common/src/erc.rsdiffbeforeafterboth161617//! This module contains the implementation of pallet methods for evm.17//! This module contains the implementation of pallet methods for evm.181819use evm_coder::{20 abi::AbiType,21 solidity_interface, solidity, ToLog,22 types::*,23 types::Property as PropertyStruct,24 execution::{Result, Error},25 weight,26};27pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};19pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};20use evm_coder::{21 abi::AbiType,22 solidity_interface, solidity, ToLog,23 types::*,24 types::Property as PropertyStruct,25 execution::{Result, Error},26 weight,27};28use pallet_evm_coder_substrate::dispatch_to_evm;28use pallet_evm_coder_substrate::dispatch_to_evm;29use sp_std::vec::Vec;29use sp_std::vec::Vec;30use up_data_structs::{30use up_data_structs::{353536use crate::{36use crate::{37 Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,37 Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,38 eth::convert_cross_account_to_uint256, weights::WeightInfo,38 eth::{EthCrossAccount, convert_cross_account_to_uint256},39 weights::WeightInfo,39};40};4041pallets/common/src/eth.rsdiffbeforeafterboth161617//! The module contains a number of functions for converting and checking ethereum identifiers.17//! The module contains a number of functions for converting and checking ethereum identifiers.181819use evm_coder::types::{uint256, address};19use evm_coder::{20 AbiCoder,21 types::{uint256, address},22};20pub use pallet_evm::{Config, account::CrossAccountId};23pub use pallet_evm::{Config, account::CrossAccountId};21use sp_core::H160;24use sp_core::H160;22use up_data_structs::CollectionId;25use up_data_structs::CollectionId;110 }113 }111}114}115116/// Cross account struct117#[derive(Debug, Default, AbiCoder)]118pub struct EthCrossAccount {119 pub(crate) eth: address,120 pub(crate) sub: uint256,121}122123impl EthCrossAccount {124 pub fn from_sub_cross_account<T>(cross_account_id: &T::CrossAccountId) -> Self125 where126 T: pallet_evm::Config,127 T::AccountId: AsRef<[u8; 32]>,128 {129 if cross_account_id.is_canonical_substrate() {130 Self {131 eth: Default::default(),132 sub: convert_cross_account_to_uint256::<T>(cross_account_id),133 }134 } else {135 Self {136 eth: *cross_account_id.as_eth(),137 sub: Default::default(),138 }139 }140 }141142 pub fn into_sub_cross_account<T>(&self) -> evm_coder::execution::Result<T::CrossAccountId>143 where144 T: pallet_evm::Config,145 T::AccountId: From<[u8; 32]>,146 {147 if self.eth == Default::default() && self.sub == Default::default() {148 Err("All fields of cross account is zeroed".into())149 } else if self.eth == Default::default() {150 Ok(convert_uint256_to_cross_account::<T>(self.sub))151 } else if self.sub == Default::default() {152 Ok(T::CrossAccountId::from_eth(self.eth))153 } else {154 Err("All fields of cross account is non zeroed".into())155 }156 }157}112158pallets/common/src/lib.rsdiffbeforeafterboth376 type TreasuryAccountId: Get<Self::AccountId>;376 type TreasuryAccountId: Get<Self::AccountId>;377377378 /// Address under which the CollectionHelper contract would be available.378 /// Address under which the CollectionHelper contract would be available.379 #[pallet::constant]379 type ContractAddress: Get<H160>;380 type ContractAddress: Get<H160>;380381381 /// Mapper for token addresses to Ethereum addresses.382 /// Mapper for token addresses to Ethereum addresses.pallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth47 type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>;47 type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>;484849 /// Address, under which magic contract will be available49 /// Address, under which magic contract will be available50 #[pallet::constant]50 type ContractAddress: Get<H160>;51 type ContractAddress: Get<H160>;515252 /// In case of enabled sponsoring, but no sponsoring rate limit set,53 /// In case of enabled sponsoring, but no sponsoring rate limit set,pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/erc.rsdiffbeforeafterboth24 weight,24 weight,25};25};26use up_data_structs::CollectionMode;26use up_data_structs::CollectionMode;27use pallet_common::erc::{CommonEvmHandler, PrecompileResult};27use pallet_common::{28 CollectionHandle,29 erc::{CommonEvmHandler, PrecompileResult, CollectionCall},30 eth::EthCrossAccount,31};28use sp_std::vec::Vec;32use sp_std::vec::Vec;29use pallet_evm::{account::CrossAccountId, PrecompileHandle};33use pallet_evm::{account::CrossAccountId, PrecompileHandle};30use pallet_evm_coder_substrate::{call, dispatch_to_evm};34use pallet_evm_coder_substrate::{call, dispatch_to_evm};31use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};35use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};32use pallet_common::{CollectionHandle, erc::CollectionCall};36use sp_core::Get;333734use crate::{38use crate::{35 Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,39 Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,133 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())137 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())134 }138 }139140 /// @notice Returns collection helper contract address141 fn collection_helper_address(&self) -> Result<address> {142 Ok(T::ContractAddress::get())143 }135}144}136145137#[solidity_interface(name = ERC20Mintable)]146#[solidity_interface(name = ERC20Mintable)]pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth547 event Approval(address indexed owner, address indexed spender, uint256 value);547 event Approval(address indexed owner, address indexed spender, uint256 value);548}548}549549550/// @dev the ERC-165 identifier for this interface is 0x942e8b22550/// @dev the ERC-165 identifier for this interface is 0x8cb847c4551contract ERC20 is Dummy, ERC165, ERC20Events {551contract ERC20 is Dummy, ERC165, ERC20Events {552 /// @dev EVM selector for this function is: 0x06fdde03,552 /// @dev EVM selector for this function is: 0x06fdde03,553 /// or in textual repr: name()553 /// or in textual repr: name()635 return 0;635 return 0;636 }636 }637638 /// @notice Returns collection helper contract address639 /// @dev EVM selector for this function is: 0x1896cce6,640 /// or in textual repr: collectionHelperAddress()641 function collectionHelperAddress() public view returns (address) {642 require(false, stub_error);643 dummy;644 return 0x0000000000000000000000000000000000000000;645 }637}646}638647639contract UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}648contract UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}pallets/nonfungible/src/erc.rsdiffbeforeafterboth36use pallet_evm_coder_substrate::dispatch_to_evm;36use pallet_evm_coder_substrate::dispatch_to_evm;37use sp_std::vec::Vec;37use sp_std::vec::Vec;38use pallet_common::{38use pallet_common::{39 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,39 erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},40 erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},40 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,41 eth::EthCrossAccount,41};42};42use pallet_evm::{account::CrossAccountId, PrecompileHandle};43use pallet_evm::{account::CrossAccountId, PrecompileHandle};43use pallet_evm_coder_substrate::call;44use pallet_evm_coder_substrate::call;44use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};45use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};46use sp_core::Get;454746use crate::{48use crate::{47 AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,49 AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,490 Err("not implemented".into())492 Err("not implemented".into())491 }493 }494495 /// @notice Returns collection helper contract address496 fn collection_helper_address(&self) -> Result<address> {497 Ok(T::ContractAddress::get())498 }492}499}493500494/// @title ERC721 Token that can be irreversibly burned (destroyed).501/// @title ERC721 Token that can be irreversibly burned (destroyed).pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth920920921/// @title ERC-721 Non-Fungible Token Standard921/// @title ERC-721 Non-Fungible Token Standard922/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md922/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md923/// @dev the ERC-165 identifier for this interface is 0x80ac58cd923/// @dev the ERC-165 identifier for this interface is 0x983a942b924contract ERC721 is Dummy, ERC165, ERC721Events {924contract ERC721 is Dummy, ERC165, ERC721Events {925 /// @notice Count all NFTs assigned to an owner925 /// @notice Count all NFTs assigned to an owner926 /// @dev NFTs assigned to the zero address are considered invalid, and this926 /// @dev NFTs assigned to the zero address are considered invalid, and this1051 return 0x0000000000000000000000000000000000000000;1051 return 0x0000000000000000000000000000000000000000;1052 }1052 }10531054 /// @notice Returns collection helper contract address1055 /// @dev EVM selector for this function is: 0x1896cce6,1056 /// or in textual repr: collectionHelperAddress()1057 function collectionHelperAddress() public view returns (address) {1058 require(false, stub_error);1059 dummy;1060 return 0x0000000000000000000000000000000000000000;1061 }1053}1062}105410631055contract UniqueNFT is1064contract UniqueNFT ispallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth178178179use RmrkProperty::*;179use RmrkProperty::*;180180181/// Maximum number of levels of depth in the token nesting tree.181/// A maximum number of levels of depth in the token nesting tree.182pub const NESTING_BUDGET: u32 = 5;182pub const NESTING_BUDGET: u32 = 5;183183184type PendingTarget = (CollectionId, TokenId);184type PendingTarget = (CollectionId, TokenId);pallets/refungible/src/erc.rsdiffbeforeafterboth31};31};32use frame_support::{BoundedBTreeMap, BoundedVec};32use frame_support::{BoundedBTreeMap, BoundedVec};33use pallet_common::{33use pallet_common::{34 CollectionHandle, CollectionPropertyPermissions,34 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,35 erc::{CommonEvmHandler, CollectionCall, static_property::key},35 erc::{CommonEvmHandler, CollectionCall, static_property::key},36 CommonCollectionOperations,36 eth::EthCrossAccount,37};37};38use pallet_evm::{account::CrossAccountId, PrecompileHandle};38use pallet_evm::{account::CrossAccountId, PrecompileHandle};39use pallet_evm_coder_substrate::{call, dispatch_to_evm};39use pallet_evm_coder_substrate::{call, dispatch_to_evm};40use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};40use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};41use sp_core::H160;41use sp_core::{H160, Get};42use sp_std::{collections::btree_map::BTreeMap, vec::Vec, vec};42use sp_std::{collections::btree_map::BTreeMap, vec::Vec, vec};43use up_data_structs::{43use up_data_structs::{44 CollectionId, CollectionPropertiesVec, mapping::TokenAddressMapping, Property, PropertyKey,44 CollectionId, CollectionPropertiesVec, mapping::TokenAddressMapping, Property, PropertyKey,483 Err("not implemented".into())483 Err("not implemented".into())484 }484 }485486 /// @notice Returns collection helper contract address487 fn collection_helper_address(&self) -> Result<address> {488 Ok(T::ContractAddress::get())489 }485}490}486491487/// Returns amount of pieces of `token` that `owner` have492/// Returns amount of pieces of `token` that `owner` havepallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth919919920/// @title ERC-721 Non-Fungible Token Standard920/// @title ERC-721 Non-Fungible Token Standard921/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md921/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md922/// @dev the ERC-165 identifier for this interface is 0x58800161922/// @dev the ERC-165 identifier for this interface is 0x4016cd87923contract ERC721 is Dummy, ERC165, ERC721Events {923contract ERC721 is Dummy, ERC165, ERC721Events {924 /// @notice Count all RFTs assigned to an owner924 /// @notice Count all RFTs assigned to an owner925 /// @dev RFTs assigned to the zero address are considered invalid, and this925 /// @dev RFTs assigned to the zero address are considered invalid, and this1048 return 0x0000000000000000000000000000000000000000;1048 return 0x0000000000000000000000000000000000000000;1049 }1049 }10501051 /// @notice Returns collection helper contract address1052 /// @dev EVM selector for this function is: 0x1896cce6,1053 /// or in textual repr: collectionHelperAddress()1054 function collectionHelperAddress() public view returns (address) {1055 require(false, stub_error);1056 dummy;1057 return 0x0000000000000000000000000000000000000000;1058 }1050}1059}105110601052contract UniqueRefungible is1061contract UniqueRefungible ispallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/mod.rsdiffbeforeafterboth28 CollectionById,28 CollectionById,29 dispatch::CollectionDispatch,29 dispatch::CollectionDispatch,30 erc::{CollectionHelpersEvents, static_property::key},30 erc::{CollectionHelpersEvents, static_property::key},31 eth::{map_eth_to_id, collection_id_to_address},31 Pallet as PalletCommon,32 Pallet as PalletCommon,32};33};33use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};34use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};34use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};35use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};35use sp_std::vec;36use sp_std::vec;36use up_data_structs::{37use up_data_structs::{37 CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,38 CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,38 CreateCollectionData,39 CreateCollectionData, CollectionId,39};40};404141use crate::{weights::WeightInfo, Config, SelfWeightOf};42use crate::{weights::WeightInfo, Config, SelfWeightOf};362 Ok(price.into())363 Ok(price.into())363 }364 }365366 /// Returns address of a collection.367 /// @param collectionId - CollectionId of the collection368 /// @return eth mirror address of the collection369 fn collection_address(&self, collection_id: uint32) -> Result<address> {370 Ok(collection_id_to_address(collection_id.into()))371 }372373 /// Returns collectionId of a collection.374 /// @param collectionAddress - Eth address of the collection375 /// @return collectionId of the collection376 fn collection_id(&self, collection_address: address) -> Result<uint32> {377 map_eth_to_id(&collection_address)378 .map(|id| id.0)379 .ok_or(Error::Revert(format!(380 "failed to convert address {} into collectionId.",381 collection_address382 )))383 }364}384}365385366/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]386/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth24}24}252526/// @title Contract, which allows users to operate with collections26/// @title Contract, which allows users to operate with collections27/// @dev the ERC-165 identifier for this interface is 0x7dea03b127/// @dev the ERC-165 identifier for this interface is 0xe65011aa28contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {28contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {29 /// Create an NFT collection29 /// Create an NFT collection30 /// @param name Name of the collection30 /// @param name Name of the collection131 return 0;131 return 0;132 }132 }133134 /// Returns address of a collection.135 /// @param collectionId - CollectionId of the collection136 /// @return eth mirror address of the collection137 /// @dev EVM selector for this function is: 0x2e716683,138 /// or in textual repr: collectionAddress(uint32)139 function collectionAddress(uint32 collectionId) public view returns (address) {140 require(false, stub_error);141 collectionId;142 dummy;143 return 0x0000000000000000000000000000000000000000;144 }145146 /// Returns collectionId of a collection.147 /// @param collectionAddress - Eth address of the collection148 /// @return collectionId of the collection149 /// @dev EVM selector for this function is: 0xb5cb7498,150 /// or in textual repr: collectionId(address)151 function collectionId(address collectionAddress) public view returns (uint32) {152 require(false, stub_error);153 collectionAddress;154 dummy;155 return 0;156 }133}157}134158pallets/unique/src/lib.rsdiffbeforeafterboth86use sp_std::{vec, vec::Vec};86use sp_std::{vec, vec::Vec};87use up_data_structs::{87use up_data_structs::{88 MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,88 MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,89 MAX_PROPERTIES_PER_ITEM, MAX_PROPERTY_KEY_LENGTH, MAX_PROPERTY_VALUE_LENGTH,90 MAX_COLLECTION_PROPERTIES_SIZE, COLLECTION_ADMINS_LIMIT, MAX_TOKEN_PROPERTIES_SIZE,89 CreateItemData, CollectionLimits, CollectionPermissions, CollectionId, CollectionMode, TokenId,91 CreateItemData, CollectionLimits, CollectionPermissions, CollectionId, CollectionMode, TokenId,90 SponsorshipState, CreateCollectionData, CreateItemExData, budget, Property, PropertyKey,92 SponsorshipState, CreateCollectionData, CreateItemExData, budget, Property, PropertyKey,91 PropertyKeyPermission,93 PropertyKeyPermission,102pub mod weights;104pub mod weights;103use weights::WeightInfo;105use weights::WeightInfo;104106105/// Maximum number of levels of depth in the token nesting tree.107/// A maximum number of levels of depth in the token nesting tree.106pub const NESTING_BUDGET: u32 = 5;108pub const NESTING_BUDGET: u32 = 5;107109108decl_error! {110decl_error! {277 {279 {278 type Error = Error<T>;280 type Error = Error<T>;281282 #[doc = "A maximum number of levels of depth in the token nesting tree."]283 const NESTING_BUDGET: u32 = NESTING_BUDGET;284285 #[doc = "Maximal length of a collection name."]286 const MAX_COLLECTION_NAME_LENGTH: u32 = MAX_COLLECTION_NAME_LENGTH;287288 #[doc = "Maximal length of a collection description."]289 const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = MAX_COLLECTION_DESCRIPTION_LENGTH;290291 #[doc = "Maximal length of a token prefix."]292 const MAX_TOKEN_PREFIX_LENGTH: u32 = MAX_TOKEN_PREFIX_LENGTH;293294 #[doc = "Maximum admins per collection."]295 const COLLECTION_ADMINS_LIMIT: u32 = COLLECTION_ADMINS_LIMIT;296297 #[doc = "Maximal length of a property key."]298 const MAX_PROPERTY_KEY_LENGTH: u32 = MAX_PROPERTY_KEY_LENGTH;299300 #[doc = "Maximal length of a property value."]301 const MAX_PROPERTY_VALUE_LENGTH: u32 = MAX_PROPERTY_VALUE_LENGTH;302303 #[doc = "A maximum number of token properties."]304 const MAX_PROPERTIES_PER_ITEM: u32 = MAX_PROPERTIES_PER_ITEM;305306 #[doc = "Maximum size for all collection properties."]307 const MAX_COLLECTION_PROPERTIES_SIZE: u32 = MAX_COLLECTION_PROPERTIES_SIZE;308309 #[doc = "Maximum size of all token properties."]310 const MAX_TOKEN_PROPERTIES_SIZE: u32 = MAX_TOKEN_PROPERTIES_SIZE;311312 #[doc = "Default NFT collection limit."]313 const NFT_DEFAULT_COLLECTION_LIMITS: CollectionLimits = CollectionLimits::with_default_limits(CollectionMode::NFT);314315 #[doc = "Default RFT collection limit."]316 const RFT_DEFAULT_COLLECTION_LIMITS: CollectionLimits = CollectionLimits::with_default_limits(CollectionMode::ReFungible);317318 #[doc = "Default FT collection limit."]319 const FT_DEFAULT_COLLECTION_LIMITS: CollectionLimits = CollectionLimits::with_default_limits(CollectionMode::Fungible(0));320279321280 pub fn deposit_event() = default;322 pub fn deposit_event() = default;primitives/data-structs/CHANGELOG.mddiffbeforeafterboth3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.445<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->66## [v0.2.2] 2022-08-167## [v0.2.2] 2022-08-16788### Other changes9### Other changes28multiple users into `RefungibleMultipleItems` call.29multiple users into `RefungibleMultipleItems` call.293030## [v0.2.0] - 2022-08-0131## [v0.2.0] - 2022-08-013231### Deprecated33### Deprecated3432- `CreateReFungibleData::const_data`35- `CreateReFungibleData::const_data`333634## [v0.1.2] - 2022-07-2537## [v0.1.2] - 2022-07-253835### Added39### Added4036- Type aliases `CollectionName`, `CollectionDescription`, `CollectionTokenPrefix`41- Type aliases `CollectionName`, `CollectionDescription`, `CollectionTokenPrefix`4237## [v0.1.1] - 2022-07-2243## [v0.1.1] - 2022-07-224438### Added45### Added4639- Аields with properties to `CreateReFungibleData` and `CreateRefungibleExData`.47- Fields with properties to `CreateReFungibleData` and `CreateRefungibleExData`.48primitives/data-structs/src/lib.rsdiffbeforeafterboth120// TODO: not used. Delete?120// TODO: not used. Delete?121pub const COLLECTION_FIELD_LIMIT: u32 = CONST_ON_CHAIN_SCHEMA_LIMIT;121pub const COLLECTION_FIELD_LIMIT: u32 = CONST_ON_CHAIN_SCHEMA_LIMIT;122122123/// Maximum length for collection name.123/// Maximal length of a collection name.124pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;124pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;125125126/// Maximum length for collection description.126/// Maximal length of a collection description.127pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;127pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;128128129/// Maximal token prefix length.129/// Maximal length of a token prefix.130pub const MAX_TOKEN_PREFIX_LENGTH: u32 = 16;130pub const MAX_TOKEN_PREFIX_LENGTH: u32 = 16;131131132/// Maximal lenght of property key.132/// Maximal length of a property key.133pub const MAX_PROPERTY_KEY_LENGTH: u32 = 256;133pub const MAX_PROPERTY_KEY_LENGTH: u32 = 256;134134135/// Maximal lenght of property value.135/// Maximal length of a property value.136pub const MAX_PROPERTY_VALUE_LENGTH: u32 = 32768;136pub const MAX_PROPERTY_VALUE_LENGTH: u32 = 32768;137137138/// Maximum properties that can be assigned to token.138/// A maximum number of token properties.139pub const MAX_PROPERTIES_PER_ITEM: u32 = 64;139pub const MAX_PROPERTIES_PER_ITEM: u32 = 64;140140141/// Maximal lenght of extended property value.141/// Maximal lenght of extended property value.144/// Maximum size for all collection properties.144/// Maximum size for all collection properties.145pub const MAX_COLLECTION_PROPERTIES_SIZE: u32 = 40960;145pub const MAX_COLLECTION_PROPERTIES_SIZE: u32 = 40960;146146147/// Maximum size for all token properties.147/// Maximum size of all token properties.148pub const MAX_TOKEN_PROPERTIES_SIZE: u32 = 32768;148pub const MAX_TOKEN_PROPERTIES_SIZE: u32 = 32768;149149150/// How much items can be created per single150/// How much items can be created per single609}609}610610611impl CollectionLimits {611impl CollectionLimits {612 pub fn with_default_limits(collection_type: CollectionMode) -> Self {613 CollectionLimits {614 account_token_ownership_limit: Some(ACCOUNT_TOKEN_OWNERSHIP_LIMIT),615 sponsored_data_size: Some(CUSTOM_DATA_LIMIT),616 sponsored_data_rate_limit: Some(SponsoringRateLimit::SponsoringDisabled),617 token_limit: Some(COLLECTION_TOKEN_LIMIT),618 sponsor_transfer_timeout: match collection_type {619 CollectionMode::NFT => Some(NFT_SPONSOR_TRANSFER_TIMEOUT),620 CollectionMode::ReFungible => Some(REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT),621 CollectionMode::Fungible(_) => Some(FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT),622 },623 sponsor_approve_timeout: Some(SPONSOR_APPROVE_TIMEOUT),624 owner_can_transfer: Some(false),625 owner_can_destroy: Some(true),626 transfers_enabled: Some(true),627 }628 }629612 /// Get effective value for [`account_token_ownership_limit`](self.account_token_ownership_limit).630 /// Get effective value for [`account_token_ownership_limit`](self.account_token_ownership_limit).613 pub fn account_token_ownership_limit(&self) -> u32 {631 pub fn account_token_ownership_limit(&self) -> u32 {tests/package.jsondiffbeforeafterboth102 "testXcmTransferStatemine": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferStatemine.test.ts statemineId=1000 uniqueId=5000",102 "testXcmTransferStatemine": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferStatemine.test.ts statemineId=1000 uniqueId=5000",103 "testXcmTransferMoonbeam": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferMoonbeam.test.ts",103 "testXcmTransferMoonbeam": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferMoonbeam.test.ts",104 "benchMintingFee": "ts-node src/benchmarks/mintFee/benchmark.ts",104 "benchMintingFee": "ts-node src/benchmarks/mintFee/benchmark.ts",105 "testApiConsts": "mocha --timeout 9999999 -r ts-node/register ./**/apiConsts.test.ts",105 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",106 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",106 "loadTransfer": "ts-node src/transfer.nload.ts",107 "loadTransfer": "ts-node src/transfer.nload.ts",107 "polkadot-types-fetch-metadata": "curl -H 'Content-Type: application/json' -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9933 > src/interfaces/metadata.json",108 "polkadot-types-fetch-metadata": "curl -H 'Content-Type: application/json' -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9933 > src/interfaces/metadata.json",tests/src/apiConsts.test.tsdiffbeforeafterbothno changes
tests/src/eth/abi/collectionHelpers.jsondiffbeforeafterboth31 "name": "CollectionDestroyed",31 "name": "CollectionDestroyed",32 "type": "event"32 "type": "event"33 },33 },34 {35 "inputs": [36 { "internalType": "uint32", "name": "collectionId", "type": "uint32" }37 ],38 "name": "collectionAddress",39 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],40 "stateMutability": "view",41 "type": "function"42 },34 {43 {35 "inputs": [],44 "inputs": [],36 "name": "collectionCreationFee",45 "name": "collectionCreationFee",37 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],46 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],38 "stateMutability": "view",47 "stateMutability": "view",39 "type": "function"48 "type": "function"40 },49 },50 {51 "inputs": [52 {53 "internalType": "address",54 "name": "collectionAddress",55 "type": "address"56 }57 ],58 "name": "collectionId",59 "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }],60 "stateMutability": "view",61 "type": "function"62 },41 {63 {42 "inputs": [64 "inputs": [43 { "internalType": "string", "name": "name", "type": "string" },65 { "internalType": "string", "name": "name", "type": "string" },tests/src/eth/abi/fungible.jsondiffbeforeafterboth199 "stateMutability": "view",199 "stateMutability": "view",200 "type": "function"200 "type": "function"201 },201 },202 {203 "inputs": [],204 "name": "collectionHelperAddress",205 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],206 "stateMutability": "view",207 "type": "function"208 },202 {209 {203 "inputs": [],210 "inputs": [],204 "name": "collectionOwner",211 "name": "collectionOwner",tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth229 "stateMutability": "view",229 "stateMutability": "view",230 "type": "function"230 "type": "function"231 },231 },232 {233 "inputs": [],234 "name": "collectionHelperAddress",235 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],236 "stateMutability": "view",237 "type": "function"238 },232 {239 {233 "inputs": [],240 "inputs": [],234 "name": "collectionOwner",241 "name": "collectionOwner",tests/src/eth/abi/reFungible.jsondiffbeforeafterboth211 "stateMutability": "view",211 "stateMutability": "view",212 "type": "function"212 "type": "function"213 },213 },214 {215 "inputs": [],216 "name": "collectionHelperAddress",217 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],218 "stateMutability": "view",219 "type": "function"220 },214 {221 {215 "inputs": [],222 "inputs": [],216 "name": "collectionOwner",223 "name": "collectionOwner",tests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth19}19}202021/// @title Contract, which allows users to operate with collections21/// @title Contract, which allows users to operate with collections22/// @dev the ERC-165 identifier for this interface is 0x7dea03b122/// @dev the ERC-165 identifier for this interface is 0xe65011aa23interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {23interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {24 /// Create an NFT collection24 /// Create an NFT collection25 /// @param name Name of the collection25 /// @param name Name of the collection79 /// or in textual repr: collectionCreationFee()79 /// or in textual repr: collectionCreationFee()80 function collectionCreationFee() external view returns (uint256);80 function collectionCreationFee() external view returns (uint256);8182 /// Returns address of a collection.83 /// @param collectionId - CollectionId of the collection84 /// @return eth mirror address of the collection85 /// @dev EVM selector for this function is: 0x2e716683,86 /// or in textual repr: collectionAddress(uint32)87 function collectionAddress(uint32 collectionId) external view returns (address);8889 /// Returns collectionId of a collection.90 /// @param collectionAddress - Eth address of the collection91 /// @return collectionId of the collection92 /// @dev EVM selector for this function is: 0xb5cb7498,93 /// or in textual repr: collectionId(address)94 function collectionId(address collectionAddress) external view returns (uint32);81}95}8296tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth354 event Approval(address indexed owner, address indexed spender, uint256 value);354 event Approval(address indexed owner, address indexed spender, uint256 value);355}355}356356357/// @dev the ERC-165 identifier for this interface is 0x942e8b22357/// @dev the ERC-165 identifier for this interface is 0x8cb847c4358interface ERC20 is Dummy, ERC165, ERC20Events {358interface ERC20 is Dummy, ERC165, ERC20Events {359 /// @dev EVM selector for this function is: 0x06fdde03,359 /// @dev EVM selector for this function is: 0x06fdde03,360 /// or in textual repr: name()360 /// or in textual repr: name()396 /// or in textual repr: allowance(address,address)396 /// or in textual repr: allowance(address,address)397 function allowance(address owner, address spender) external view returns (uint256);397 function allowance(address owner, address spender) external view returns (uint256);398399 /// @notice Returns collection helper contract address400 /// @dev EVM selector for this function is: 0x1896cce6,401 /// or in textual repr: collectionHelperAddress()402 function collectionHelperAddress() external view returns (address);398}403}399404400interface UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}405interface UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth605605606/// @title ERC-721 Non-Fungible Token Standard606/// @title ERC-721 Non-Fungible Token Standard607/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md607/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md608/// @dev the ERC-165 identifier for this interface is 0x80ac58cd608/// @dev the ERC-165 identifier for this interface is 0x983a942b609interface ERC721 is Dummy, ERC165, ERC721Events {609interface ERC721 is Dummy, ERC165, ERC721Events {610 /// @notice Count all NFTs assigned to an owner610 /// @notice Count all NFTs assigned to an owner611 /// @dev NFTs assigned to the zero address are considered invalid, and this611 /// @dev NFTs assigned to the zero address are considered invalid, and this686 /// or in textual repr: isApprovedForAll(address,address)686 /// or in textual repr: isApprovedForAll(address,address)687 function isApprovedForAll(address owner, address operator) external view returns (address);687 function isApprovedForAll(address owner, address operator) external view returns (address);688689 /// @notice Returns collection helper contract address690 /// @dev EVM selector for this function is: 0x1896cce6,691 /// or in textual repr: collectionHelperAddress()692 function collectionHelperAddress() external view returns (address);688}693}689694690interface UniqueNFT is695interface UniqueNFT istests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth604604605/// @title ERC-721 Non-Fungible Token Standard605/// @title ERC-721 Non-Fungible Token Standard606/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md606/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md607/// @dev the ERC-165 identifier for this interface is 0x58800161607/// @dev the ERC-165 identifier for this interface is 0x4016cd87608interface ERC721 is Dummy, ERC165, ERC721Events {608interface ERC721 is Dummy, ERC165, ERC721Events {609 /// @notice Count all RFTs assigned to an owner609 /// @notice Count all RFTs assigned to an owner610 /// @dev RFTs assigned to the zero address are considered invalid, and this610 /// @dev RFTs assigned to the zero address are considered invalid, and this683 /// or in textual repr: isApprovedForAll(address,address)683 /// or in textual repr: isApprovedForAll(address,address)684 function isApprovedForAll(address owner, address operator) external view returns (address);684 function isApprovedForAll(address owner, address operator) external view returns (address);685686 /// @notice Returns collection helper contract address687 /// @dev EVM selector for this function is: 0x1896cce6,688 /// or in textual repr: collectionHelperAddress()689 function collectionHelperAddress() external view returns (address);685}690}686691687interface UniqueRefungible is692interface UniqueRefungible istests/src/eth/collectionHelperAddress.test.tsdiffbeforeafterbothno changes
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth103103104 contractHelpers(caller: string): Contract {104 contractHelpers(caller: string): Contract {105 const web3 = this.helper.getWeb3();105 const web3 = this.helper.getWeb3();106 return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, gas: this.helper.eth.DEFAULT_GAS});106 return new web3.eth.Contract(contractHelpersAbi as any, this.helper.getApi().consts.evmContractHelpers.contractAddress.toString(), {from: caller, gas: this.helper.eth.DEFAULT_GAS});107 }107 }108108109 collectionHelpers(caller: string) {109 collectionHelpers(caller: string) {110 const web3 = this.helper.getWeb3();110 const web3 = this.helper.getWeb3();111 return new web3.eth.Contract(collectionHelpersAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, gas: this.helper.eth.DEFAULT_GAS});111 return new web3.eth.Contract(collectionHelpersAbi as any, this.helper.getApi().consts.common.contractAddress.toString(), {from: caller, gas: this.helper.eth.DEFAULT_GAS});112 }112 }113113114 collection(address: string, mode: TCollectionMode, caller?: string, mergeDeprecated = false): Contract {114 collection(address: string, mode: TCollectionMode, caller?: string, mergeDeprecated = false): Contract {tests/src/interfaces/augment-api-consts.tsdiffbeforeafterboth8import type { ApiTypes, AugmentedConst } from '@polkadot/api-base/types';8import type { ApiTypes, AugmentedConst } from '@polkadot/api-base/types';9import type { Option, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';9import type { Option, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';10import type { Codec } from '@polkadot/types-codec/types';10import type { Codec } from '@polkadot/types-codec/types';11import type { Perbill, Permill, Weight } from '@polkadot/types/interfaces/runtime';11import type { H160, Perbill, Permill, Weight } from '@polkadot/types/interfaces/runtime';12import type { FrameSupportPalletId, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, SpVersionRuntimeVersion, SpWeightsRuntimeDbWeight, XcmV1MultiLocation } from '@polkadot/types/lookup';12import type { FrameSupportPalletId, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, SpVersionRuntimeVersion, SpWeightsRuntimeDbWeight, UpDataStructsCollectionLimits, XcmV1MultiLocation } from '@polkadot/types/lookup';131314export type __AugmentedConst<ApiType extends ApiTypes> = AugmentedConst<ApiType>;14export type __AugmentedConst<ApiType extends ApiTypes> = AugmentedConst<ApiType>;151569 * Set price to create a collection.69 * Set price to create a collection.70 **/70 **/71 collectionCreationPrice: u128 & AugmentedConst<ApiType>;71 collectionCreationPrice: u128 & AugmentedConst<ApiType>;72 /**73 * Address under which the CollectionHelper contract would be available.74 **/75 contractAddress: H160 & AugmentedConst<ApiType>;72 /**76 /**73 * Generic const77 * Generic const74 **/78 **/82 **/86 **/83 [key: string]: Codec;87 [key: string]: Codec;84 };88 };89 evmContractHelpers: {90 /**91 * Address, under which magic contract will be available92 **/93 contractAddress: H160 & AugmentedConst<ApiType>;94 /**95 * Generic const96 **/97 [key: string]: Codec;98 };85 inflation: {99 inflation: {86 /**100 /**87 * Number of blocks that pass between treasury balance updates due to inflation101 * Number of blocks that pass between treasury balance updates due to inflation231 **/245 **/232 [key: string]: Codec;246 [key: string]: Codec;233 };247 };248 unique: {249 /**250 * Maximum admins per collection.251 **/252 collectionAdminsLimit: u32 & AugmentedConst<ApiType>;253 /**254 * Default FT collection limit.255 **/256 ftDefaultCollectionLimits: UpDataStructsCollectionLimits & AugmentedConst<ApiType>;257 /**258 * Maximal length of a collection description.259 **/260 maxCollectionDescriptionLength: u32 & AugmentedConst<ApiType>;261 /**262 * Maximal length of a collection name.263 **/264 maxCollectionNameLength: u32 & AugmentedConst<ApiType>;265 /**266 * Maximum size for all collection properties.267 **/268 maxCollectionPropertiesSize: u32 & AugmentedConst<ApiType>;269 /**270 * A maximum number of token properties.271 **/272 maxPropertiesPerItem: u32 & AugmentedConst<ApiType>;273 /**274 * Maximal length of a property key.275 **/276 maxPropertyKeyLength: u32 & AugmentedConst<ApiType>;277 /**278 * Maximal length of a property value.279 **/280 maxPropertyValueLength: u32 & AugmentedConst<ApiType>;281 /**282 * Maximal length of a token prefix.283 **/284 maxTokenPrefixLength: u32 & AugmentedConst<ApiType>;285 /**286 * Maximum size of all token properties.287 **/288 maxTokenPropertiesSize: u32 & AugmentedConst<ApiType>;289 /**290 * A maximum number of levels of depth in the token nesting tree.291 **/292 nestingBudget: u32 & AugmentedConst<ApiType>;293 /**294 * Default NFT collection limit.295 **/296 nftDefaultCollectionLimits: UpDataStructsCollectionLimits & AugmentedConst<ApiType>;297 /**298 * Default RFT collection limit.299 **/300 rftDefaultCollectionLimits: UpDataStructsCollectionLimits & AugmentedConst<ApiType>;301 /**302 * Generic const303 **/304 [key: string]: Codec;305 };234 vesting: {306 vesting: {235 /**307 /**236 * The minimum amount transferred to call `vested_transfer`.308 * The minimum amount transferred to call `vested_transfer`.