difftreelog
Merge pull request #433 from UniqueNetwork/doc/evm-coder
in: master
Document evm related crates
58 files changed
.maintain/frame-weight-template.hbsdiffbeforeafterboth14#![cfg_attr(rustfmt, rustfmt_skip)]14#![cfg_attr(rustfmt, rustfmt_skip)]15#![allow(unused_parens)]15#![allow(unused_parens)]16#![allow(unused_imports)]16#![allow(unused_imports)]17#![allow(missing_docs)]17#![allow(clippy::unnecessary_cast)]18#![allow(clippy::unnecessary_cast)]181919use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};20use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};Cargo.lockdiffbeforeafterboth1771 "zeroize",1771 "zeroize",1772]1772]17731774[[package]]1775name = "darling"1776version = "0.13.4"1777source = "registry+https://github.com/rust-lang/crates.io-index"1778checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c"1779dependencies = [1780 "darling_core",1781 "darling_macro",1782]17831784[[package]]1785name = "darling_core"1786version = "0.13.4"1787source = "registry+https://github.com/rust-lang/crates.io-index"1788checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610"1789dependencies = [1790 "fnv",1791 "ident_case",1792 "proc-macro2",1793 "quote",1794 "strsim",1795 "syn",1796]17971798[[package]]1799name = "darling_macro"1800version = "0.13.4"1801source = "registry+https://github.com/rust-lang/crates.io-index"1802checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835"1803dependencies = [1804 "darling_core",1805 "quote",1806 "syn",1807]180817731809[[package]]1774[[package]]1810name = "data-encoding"1775name = "data-encoding"2207version = "0.1.1"2172version = "0.1.1"2208dependencies = [2173dependencies = [2209 "ethereum",2174 "ethereum",2210 "evm-coder-macros",2175 "evm-coder-procedural",2211 "evm-core",2176 "evm-core",2212 "hex",2177 "hex",2213 "hex-literal",2178 "hex-literal",2216]2181]221721822218[[package]]2183[[package]]2219name = "evm-coder-macros"2184name = "evm-coder-procedural"2220version = "0.1.0"2185version = "0.2.0"2221dependencies = [2186dependencies = [2222 "Inflector",2187 "Inflector",2223 "darling",2224 "hex",2188 "hex",2225 "proc-macro2",2189 "proc-macro2",2226 "quote",2190 "quote",2227 "sha3 0.9.1",2191 "sha3 0.10.2",2228 "syn",2192 "syn",2229]2193]223021943428 "winapi",3392 "winapi",3429]3393]34303431[[package]]3432name = "ident_case"3433version = "1.0.1"3434source = "registry+https://github.com/rust-lang/crates.io-index"3435checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"343633943437[[package]]3395[[package]]3438name = "idna"3396name = "idna"crates/evm-coder-macros/Cargo.tomldiffbeforeafterbothno changes
crates/evm-coder-macros/src/lib.rsdiffbeforeafterbothno changes
crates/evm-coder-macros/src/solidity_interface.rsdiffbeforeafterbothno changes
crates/evm-coder-macros/src/to_log.rsdiffbeforeafterbothno changes
crates/evm-coder/Cargo.tomldiffbeforeafterboth5edition = "2021"5edition = "2021"667[dependencies]7[dependencies]8# evm-coder reexports those proc-macro8evm-coder-macros = { path = "../evm-coder-macros" }9evm-coder-procedural = { path = "./procedural" }10# Evm uses primitive-types for H160, H256 and others9primitive-types = { version = "0.11.1", default-features = false }11primitive-types = { version = "0.11.1", default-features = false }10hex-literal = "0.3.3"12# Evm doesn't have reexports for log and others11ethereum = { version = "0.12.0", default-features = false }13ethereum = { version = "0.12.0", default-features = false }14# Error types for execution12evm-core = { default-features = false, git = "https://github.com/uniquenetwork/evm", branch = "unique-polkadot-v0.9.27" }15evm-core = { default-features = false, git = "https://github.com/uniquenetwork/evm", branch = "unique-polkadot-v0.9.27" }16# We have tuple-heavy code in solidity.rs13impl-trait-for-tuples = "0.2.1"17impl-trait-for-tuples = "0.2.2"141815[dev-dependencies]19[dev-dependencies]20# We want to assert some large binary blobs equality in tests16hex = "0.4.3"21hex = "0.4.3"22hex-literal = "0.3.4"172318[features]24[features]19default = ["std"]25default = ["std"]crates/evm-coder/README.mddiffbeforeafterbothno changes
crates/evm-coder/procedural/Cargo.tomldiffbeforeafterbothno changes
crates/evm-coder/procedural/src/lib.rsdiffbeforeafterbothno changes
crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterbothno changes
crates/evm-coder/procedural/src/to_log.rsdiffbeforeafterbothno changes
crates/evm-coder/src/abi.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617//! TODO: I misunterstood therminology, abi IS rlp encoded, so17//! Implementation of EVM RLP reader/writer18//! this module should be replaced with rlp crate191820#![allow(dead_code)]19#![allow(dead_code)]2120323133const ABI_ALIGNMENT: usize = 32;32const ABI_ALIGNMENT: usize = 32;343334/// View into RLP data, which provides method to read typed items from it35#[derive(Clone)]35#[derive(Clone)]36pub struct AbiReader<'i> {36pub struct AbiReader<'i> {37 buf: &'i [u8],37 buf: &'i [u8],38 subresult_offset: usize,38 subresult_offset: usize,39 offset: usize,39 offset: usize,40}40}41impl<'i> AbiReader<'i> {41impl<'i> AbiReader<'i> {42 /// Start reading RLP buffer, assuming there is no padding bytes42 pub fn new(buf: &'i [u8]) -> Self {43 pub fn new(buf: &'i [u8]) -> Self {43 Self {44 Self {44 buf,45 buf,45 subresult_offset: 0,46 subresult_offset: 0,46 offset: 0,47 offset: 0,47 }48 }48 }49 }50 /// Start reading RLP buffer, parsing first 4 bytes as selector49 pub fn new_call(buf: &'i [u8]) -> Result<(types::bytes4, Self)> {51 pub fn new_call(buf: &'i [u8]) -> Result<(types::bytes4, Self)> {50 if buf.len() < 4 {52 if buf.len() < 4 {51 return Err(Error::Error(ExitError::OutOfOffset));53 return Err(Error::Error(ExitError::OutOfOffset));109 )111 )110 }112 }111113114 /// Read [`H160`] at current position, then advance112 pub fn address(&mut self) -> Result<H160> {115 pub fn address(&mut self) -> Result<H160> {113 Ok(H160(self.read_padleft()?))116 Ok(H160(self.read_padleft()?))114 }117 }115118119 /// Read [`bool`] at current position, then advance116 pub fn bool(&mut self) -> Result<bool> {120 pub fn bool(&mut self) -> Result<bool> {117 let data: [u8; 1] = self.read_padleft()?;121 let data: [u8; 1] = self.read_padleft()?;118 match data[0] {122 match data[0] {122 }126 }123 }127 }124128129 /// Read [`[u8; 4]`] at current position, then advance125 pub fn bytes4(&mut self) -> Result<[u8; 4]> {130 pub fn bytes4(&mut self) -> Result<[u8; 4]> {126 self.read_padright()131 self.read_padright()127 }132 }128133134 /// Read [`Vec<u8>`] at current position, then advance129 pub fn bytes(&mut self) -> Result<Vec<u8>> {135 pub fn bytes(&mut self) -> Result<Vec<u8>> {130 let mut subresult = self.subresult()?;136 let mut subresult = self.subresult()?;131 let length = subresult.read_usize()?;137 let length = subresult.uint32()? as usize;132 if subresult.buf.len() < subresult.offset + length {138 if subresult.buf.len() < subresult.offset + length {133 return Err(Error::Error(ExitError::OutOfOffset));139 return Err(Error::Error(ExitError::OutOfOffset));134 }140 }135 Ok(subresult.buf[subresult.offset..subresult.offset + length].into())141 Ok(subresult.buf[subresult.offset..subresult.offset + length].into())136 }142 }143144 /// Read [`string`] at current position, then advance137 pub fn string(&mut self) -> Result<string> {145 pub fn string(&mut self) -> Result<string> {138 string::from_utf8(self.bytes()?).map_err(|_| Error::Error(ExitError::InvalidRange))146 string::from_utf8(self.bytes()?).map_err(|_| Error::Error(ExitError::InvalidRange))139 }147 }140148149 /// Read [`u8`] at current position, then advance141 pub fn uint8(&mut self) -> Result<u8> {150 pub fn uint8(&mut self) -> Result<u8> {142 Ok(self.read_padleft::<1>()?[0])151 Ok(self.read_padleft::<1>()?[0])143 }152 }144153154 /// Read [`u32`] at current position, then advance145 pub fn uint32(&mut self) -> Result<u32> {155 pub fn uint32(&mut self) -> Result<u32> {146 Ok(u32::from_be_bytes(self.read_padleft()?))156 Ok(u32::from_be_bytes(self.read_padleft()?))147 }157 }148158159 /// Read [`u128`] at current position, then advance149 pub fn uint128(&mut self) -> Result<u128> {160 pub fn uint128(&mut self) -> Result<u128> {150 Ok(u128::from_be_bytes(self.read_padleft()?))161 Ok(u128::from_be_bytes(self.read_padleft()?))151 }162 }152163164 /// Read [`U256`] at current position, then advance153 pub fn uint256(&mut self) -> Result<U256> {165 pub fn uint256(&mut self) -> Result<U256> {154 let buf: [u8; 32] = self.read_padleft()?;166 let buf: [u8; 32] = self.read_padleft()?;155 Ok(U256::from_big_endian(&buf))167 Ok(U256::from_big_endian(&buf))156 }168 }157169170 /// Read [`u64`] at current position, then advance158 pub fn uint64(&mut self) -> Result<u64> {171 pub fn uint64(&mut self) -> Result<u64> {159 Ok(u64::from_be_bytes(self.read_padleft()?))172 Ok(u64::from_be_bytes(self.read_padleft()?))160 }173 }161174175 /// Read [`usize`] at current position, then advance176 #[deprecated = "dangerous, as usize may have different width in wasm and native execution"]162 pub fn read_usize(&mut self) -> Result<usize> {177 pub fn read_usize(&mut self) -> Result<usize> {163 Ok(usize::from_be_bytes(self.read_padleft()?))178 Ok(usize::from_be_bytes(self.read_padleft()?))164 }179 }165180181 /// Slice recursive buffer, advance one word for buffer offset166 fn subresult(&mut self) -> Result<AbiReader<'i>> {182 fn subresult(&mut self) -> Result<AbiReader<'i>> {167 let offset = self.read_usize()?;183 let offset = self.uint32()? as usize;168 if offset + self.subresult_offset > self.buf.len() {184 if offset + self.subresult_offset > self.buf.len() {169 return Err(Error::Error(ExitError::InvalidRange));185 return Err(Error::Error(ExitError::InvalidRange));170 }186 }175 })191 })176 }192 }177193194 /// Is this parser reached end of buffer?178 pub fn is_finished(&self) -> bool {195 pub fn is_finished(&self) -> bool {179 self.buf.len() == self.offset196 self.buf.len() == self.offset180 }197 }181}198}182199200/// Writer for RLP encoded data183#[derive(Default)]201#[derive(Default)]184pub struct AbiWriter {202pub struct AbiWriter {185 static_part: Vec<u8>,203 static_part: Vec<u8>,186 dynamic_part: Vec<(usize, AbiWriter)>,204 dynamic_part: Vec<(usize, AbiWriter)>,187 had_call: bool,205 had_call: bool,188}206}189impl AbiWriter {207impl AbiWriter {208 /// Initialize internal buffers for output data, assuming no padding required190 pub fn new() -> Self {209 pub fn new() -> Self {191 Self::default()210 Self::default()192 }211 }212 /// Initialize internal buffers, inserting method selector at beginning193 pub fn new_call(method_id: u32) -> Self {213 pub fn new_call(method_id: u32) -> Self {194 let mut val = Self::new();214 let mut val = Self::new();195 val.static_part.extend(&method_id.to_be_bytes());215 val.static_part.extend(&method_id.to_be_bytes());211 .extend(&[0; ABI_ALIGNMENT][0..ABI_ALIGNMENT - bytes.len()]);231 .extend(&[0; ABI_ALIGNMENT][0..ABI_ALIGNMENT - bytes.len()]);212 }232 }213233234 /// Write [`H160`] to end of buffer214 pub fn address(&mut self, address: &H160) {235 pub fn address(&mut self, address: &H160) {215 self.write_padleft(&address.0)236 self.write_padleft(&address.0)216 }237 }217238239 /// Write [`bool`] to end of buffer218 pub fn bool(&mut self, value: &bool) {240 pub fn bool(&mut self, value: &bool) {219 self.write_padleft(&[if *value { 1 } else { 0 }])241 self.write_padleft(&[if *value { 1 } else { 0 }])220 }242 }221243244 /// Write [`u8`] to end of buffer222 pub fn uint8(&mut self, value: &u8) {245 pub fn uint8(&mut self, value: &u8) {223 self.write_padleft(&[*value])246 self.write_padleft(&[*value])224 }247 }225248249 /// Write [`u32`] to end of buffer226 pub fn uint32(&mut self, value: &u32) {250 pub fn uint32(&mut self, value: &u32) {227 self.write_padleft(&u32::to_be_bytes(*value))251 self.write_padleft(&u32::to_be_bytes(*value))228 }252 }229253254 /// Write [`u128`] to end of buffer230 pub fn uint128(&mut self, value: &u128) {255 pub fn uint128(&mut self, value: &u128) {231 self.write_padleft(&u128::to_be_bytes(*value))256 self.write_padleft(&u128::to_be_bytes(*value))232 }257 }233258259 /// Write [`U256`] to end of buffer234 pub fn uint256(&mut self, value: &U256) {260 pub fn uint256(&mut self, value: &U256) {235 let mut out = [0; 32];261 let mut out = [0; 32];236 value.to_big_endian(&mut out);262 value.to_big_endian(&mut out);237 self.write_padleft(&out)263 self.write_padleft(&out)238 }264 }239265266 /// Write [`usize`] to end of buffer267 #[deprecated = "dangerous, as usize may have different width in wasm and native execution"]240 pub fn write_usize(&mut self, value: &usize) {268 pub fn write_usize(&mut self, value: &usize) {241 self.write_padleft(&usize::to_be_bytes(*value))269 self.write_padleft(&usize::to_be_bytes(*value))242 }270 }243271272 /// Append recursive data, writing pending offset at end of buffer244 pub fn write_subresult(&mut self, result: Self) {273 pub fn write_subresult(&mut self, result: Self) {245 self.dynamic_part.push((self.static_part.len(), result));274 self.dynamic_part.push((self.static_part.len(), result));246 // Empty block, to be filled later275 // Empty block, to be filled later247 self.write_padleft(&[]);276 self.write_padleft(&[]);248 }277 }249278250 pub fn memory(&mut self, value: &[u8]) {279 fn memory(&mut self, value: &[u8]) {251 let mut sub = Self::new();280 let mut sub = Self::new();252 sub.write_usize(&value.len());281 sub.uint32(&(value.len() as u32));253 for chunk in value.chunks(ABI_ALIGNMENT) {282 for chunk in value.chunks(ABI_ALIGNMENT) {254 sub.write_padright(chunk);283 sub.write_padright(chunk);255 }284 }256 self.write_subresult(sub);285 self.write_subresult(sub);257 }286 }258287288 /// Append recursive [`str`] at end of buffer259 pub fn string(&mut self, value: &str) {289 pub fn string(&mut self, value: &str) {260 self.memory(value.as_bytes())290 self.memory(value.as_bytes())261 }291 }262292293 /// Append recursive [`[u8]`] at end of buffer263 pub fn bytes(&mut self, value: &[u8]) {294 pub fn bytes(&mut self, value: &[u8]) {264 self.memory(value)295 self.memory(value)265 }296 }266297298 /// Finish writer, concatenating all internal buffers267 pub fn finish(mut self) -> Vec<u8> {299 pub fn finish(mut self) -> Vec<u8> {268 for (static_offset, part) in self.dynamic_part {300 for (static_offset, part) in self.dynamic_part {269 let part_offset = self.static_part.len() - self.had_call.then(|| 4).unwrap_or(0);301 let part_offset = self.static_part.len() - self.had_call.then(|| 4).unwrap_or(0);278 }310 }279}311}280312313/// [`AbiReader`] implements reading of many types, but it should314/// be limited to types defined in spec315///316/// As this trait can't be made sealed,317/// instead of having `impl AbiRead for T`, we have `impl AbiRead<T> for AbiReader`281pub trait AbiRead<T> {318pub trait AbiRead<T> {319 /// Read item from current position, advanding decoder282 fn abi_read(&mut self) -> Result<T>;320 fn abi_read(&mut self) -> Result<T>;283}321}284322318{356{319 fn abi_read(&mut self) -> Result<Vec<R>> {357 fn abi_read(&mut self) -> Result<Vec<R>> {320 let mut sub = self.subresult()?;358 let mut sub = self.subresult()?;321 let size = sub.read_usize()?;359 let size = sub.uint32()? as usize;322 sub.subresult_offset = sub.offset;360 sub.subresult_offset = sub.offset;323 let mut out = Vec::with_capacity(size);361 let mut out = Vec::with_capacity(size);324 for _ in 0..size {362 for _ in 0..size {366impl_tuples! {A B C D E F G H I}404impl_tuples! {A B C D E F G H I}367impl_tuples! {A B C D E F G H I J}405impl_tuples! {A B C D E F G H I J}368406407/// For questions about inability to provide custom implementations,408/// see [`AbiRead`]369pub trait AbiWrite {409pub trait AbiWrite {410 /// Write value to end of specified encoder370 fn abi_write(&self, writer: &mut AbiWriter);411 fn abi_write(&self, writer: &mut AbiWriter);412 /// Specialization for [`crate::solidity_interface`] implementation,413 /// see comment in `impl AbiWrite for ResultWithPostInfo`371 fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {414 fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {372 let mut writer = AbiWriter::new();415 let mut writer = AbiWriter::new();373 self.abi_write(&mut writer);416 self.abi_write(&mut writer);374 Ok(writer.into())417 Ok(writer.into())375 }418 }376}419}377420421/// This particular AbiWrite implementation should be split to another trait,422/// which only implements `to_result`, but due to lack of specialization feature423/// in stable Rust, we can't have blanket impl of this trait `for T where T: AbiWrite`,424/// so here we abusing default trait methods for it378impl<T: AbiWrite> AbiWrite for ResultWithPostInfo<T> {425impl<T: AbiWrite> AbiWrite for ResultWithPostInfo<T> {379 // this particular AbiWrite implementation should be split to another trait,380 // which only implements [`to_result`]381 //382 // But due to lack of specialization feature in stable Rust, we can't have383 // blanket impl of this trait `for T where T: AbiWrite`, so here we abusing384 // default trait methods for it385 fn abi_write(&self, _writer: &mut AbiWriter) {426 fn abi_write(&self, _writer: &mut AbiWriter) {386 debug_assert!(false, "shouldn't be called, see comment")427 debug_assert!(false, "shouldn't be called, see comment")387 }428 }432 fn abi_write(&self, _writer: &mut AbiWriter) {}473 fn abi_write(&self, _writer: &mut AbiWriter) {}433}474}434475476/// Helper macros to parse reader into variables477#[deprecated]435#[macro_export]478#[macro_export]436macro_rules! abi_decode {479macro_rules! abi_decode {437 ($reader:expr, $($name:ident: $typ:ident),+ $(,)?) => {480 ($reader:expr, $($name:ident: $typ:ident),+ $(,)?) => {441 }484 }442}485}486487/// Helper macros to construct RLP-encoded buffer488#[deprecated]443#[macro_export]489#[macro_export]444macro_rules! abi_encode {490macro_rules! abi_encode {445 ($($typ:ident($value:expr)),* $(,)?) => {{491 ($($typ:ident($value:expr)),* $(,)?) => {{crates/evm-coder/src/events.rsdiffbeforeafterboth191920use crate::types::*;20use crate::types::*;212122/// Implementation of this trait should not be written manually,23/// instead use [`crate::ToLog`] proc macros.24///25/// See also [`evm_coder_procedural::ToLog`], [solidity docs on events](https://docs.soliditylang.org/en/develop/contracts.html#events)22pub trait ToLog {26pub trait ToLog {27 /// Convert event to [`ethereum::Log`].28 /// Because event by itself doesn't contains current contract29 /// address, it should be specified manually.23 fn to_log(&self, contract: H160) -> Log;30 fn to_log(&self, contract: H160) -> Log;24}31}253233/// Only items implementing `ToTopic` may be used as `#[indexed]` field34/// in [`crate::ToLog`] macro usage.35///36/// See also (solidity docs on events)[<https://docs.soliditylang.org/en/develop/contracts.html#events>]26pub trait ToTopic {37pub trait ToTopic {38 /// Convert value to topic to be used in [`ethereum::Log`]27 fn to_topic(&self) -> H256;39 fn to_topic(&self) -> H256;28}40}2941crates/evm-coder/src/execution.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Contract execution related types161817#[cfg(not(feature = "std"))]19#[cfg(not(feature = "std"))]18use alloc::string::{String, ToString};20use alloc::string::{String, ToString};222423use crate::Weight;25use crate::Weight;242627/// Execution error, should be convertible between EVM and Substrate.25#[derive(Debug, Clone)]28#[derive(Debug, Clone)]26pub enum Error {29pub enum Error {30 /// Non-fatal contract error occured27 Revert(String),31 Revert(String),32 /// EVM fatal error28 Fatal(ExitFatal),33 Fatal(ExitFatal),34 /// EVM normal error29 Error(ExitError),35 Error(ExitError),30}36}313738 }44 }39}45}404647/// To be used in [`crate::solidity_interface`] implementation.41pub type Result<T> = core::result::Result<T, Error>;48pub type Result<T> = core::result::Result<T, Error>;424950/// Static information collected from [`crate::weight`].43pub struct DispatchInfo {51pub struct DispatchInfo {52 /// Statically predicted call weight44 pub weight: Weight,53 pub weight: Weight,45}54}465555 }64 }56}65}576667/// Weight information that is only available post dispatch.68/// Note: This can only be used to reduce the weight or fee, not increase it.58#[derive(Default, Clone)]69#[derive(Default, Clone)]59pub struct PostDispatchInfo {70pub struct PostDispatchInfo {71 /// Actual weight consumed by call60 actual_weight: Option<Weight>,72 actual_weight: Option<Weight>,61}73}627463impl PostDispatchInfo {75impl PostDispatchInfo {76 /// Calculate amount to be returned back to user64 pub fn calc_unspent(&self, info: &DispatchInfo) -> Weight {77 pub fn calc_unspent(&self, info: &DispatchInfo) -> Weight {65 info.weight - self.calc_actual_weight(info)78 info.weight - self.calc_actual_weight(info)66 }79 }678081 /// Calculate actual consumed weight, saturating to weight reported82 /// pre-dispatch68 pub fn calc_actual_weight(&self, info: &DispatchInfo) -> Weight {83 pub fn calc_actual_weight(&self, info: &DispatchInfo) -> Weight {69 if let Some(actual_weight) = self.actual_weight {84 if let Some(actual_weight) = self.actual_weight {70 actual_weight.min(info.weight)85 actual_weight.min(info.weight)74 }89 }75}90}769192/// Wrapper for PostDispatchInfo and any user-provided data77#[derive(Clone)]93#[derive(Clone)]78pub struct WithPostDispatchInfo<T> {94pub struct WithPostDispatchInfo<T> {95 /// User provided data79 pub data: T,96 pub data: T,97 /// Info known after dispatch80 pub post_info: PostDispatchInfo,98 pub post_info: PostDispatchInfo,81}99}8210089 }107 }90}108}91109110/// Return type of items in [`crate::solidity_interface`] definition92pub type ResultWithPostInfo<T> =111pub type ResultWithPostInfo<T> =93 core::result::Result<WithPostDispatchInfo<T>, WithPostDispatchInfo<Error>>;112 core::result::Result<WithPostDispatchInfo<T>, WithPostDispatchInfo<Error>>;94113crates/evm-coder/src/lib.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617#![doc = include_str!("../README.md")]18#![deny(missing_docs)]17#![cfg_attr(not(feature = "std"), no_std)]19#![cfg_attr(not(feature = "std"), no_std)]18#[cfg(not(feature = "std"))]20#[cfg(not(feature = "std"))]19extern crate alloc;21extern crate alloc;202221use abi::{AbiRead, AbiReader, AbiWriter};23use abi::{AbiRead, AbiReader, AbiWriter};22pub use evm_coder_macros::{event_topic, fn_selector, solidity_interface, solidity, weight, ToLog};24pub use evm_coder_procedural::{event_topic, fn_selector};23pub mod abi;25pub mod abi;24pub mod events;25pub use events::ToLog;26pub use events::{ToLog, ToTopic};26use execution::DispatchInfo;27use execution::DispatchInfo;27pub mod execution;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;9394/// Derives [`ToLog`] for enum95///96/// Selectors will be derived from variant names, there is currently no way to have custom naming97/// for them98///99/// `#[indexed]`100/// Marks this field as indexed, so it will appear in [`ethereum::Log`] topics instead of data101pub use evm_coder_procedural::ToLog;102103// Api of those modules shouldn't be consumed directly, it is only exported for usage in proc macros104#[doc(hidden)]105pub mod events;106#[doc(hidden)]28pub mod solidity;107pub mod solidity;2910830/// Solidity type definitions109/// Solidity type definitions (aliases from solidity name to rust type)110/// To be used in [`solidity_interface`] definitions, to make sure there is no111/// type conflict between Rust code and generated definitions31pub mod types {112pub mod types {32 #![allow(non_camel_case_types)]113 #![allow(non_camel_case_types, missing_docs)]3311434 #[cfg(not(feature = "std"))]115 #[cfg(not(feature = "std"))]35 use alloc::{vec::Vec};116 use alloc::{vec::Vec};54 pub type string = ::std::string::String;135 pub type string = ::std::string::String;55 pub type bytes = Vec<u8>;136 pub type bytes = Vec<u8>;56137138 /// Solidity doesn't have `void` type, however we have special implementation139 /// for empty tuple return type57 pub type void = ();140 pub type void = ();5814159 //#region Special types142 //#region Special types63 pub type caller = address;146 pub type caller = address;64 //#endregion147 //#endregion65148149 /// Ethereum typed call message, similar to solidity150 /// `msg` object.66 pub struct Msg<C> {151 pub struct Msg<C> {67 pub call: C,152 pub call: C,153 /// Address of user, which called this contract.68 pub caller: H160,154 pub caller: H160,155 /// Payment amount to contract.156 /// Contract should reject payment, if target call is not payable,157 /// and there is no `receiver()` function defined.69 pub value: U256,158 pub value: U256,70 }159 }71}160}72161162/// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro73pub trait Call: Sized {163pub trait Call: Sized {164 /// Parse call buffer into typed call enum74 fn parse(selector: types::bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>>;165 fn parse(selector: types::bytes4, input: &mut AbiReader) -> execution::Result<Option<Self>>;75}166}76167168/// Intended to be used as `#[weight]` output type169/// Should be same between evm-coder and substrate to avoid confusion170///171/// Isn't same thing as gas, some mapping is required between those types77pub type Weight = u64;172pub type Weight = u64;78173174/// In substrate, we have benchmarking, which allows175/// us to not rely on gas metering, but instead predict amount of gas to execute call79pub trait Weighted: Call {176pub trait Weighted: Call {177 /// Predict weight of this call80 fn weight(&self) -> DispatchInfo;178 fn weight(&self) -> DispatchInfo;81}179}82180181/// Type callable with ethereum message, may be implemented by [`solidity_interface`] macro182/// on interface implementation, or for externally-owned real EVM contract83pub trait Callable<C: Call> {183pub trait Callable<C: Call> {184 /// Call contract using specified call data84 fn call(&mut self, call: types::Msg<C>) -> execution::ResultWithPostInfo<AbiWriter>;185 fn call(&mut self, call: types::Msg<C>) -> execution::ResultWithPostInfo<AbiWriter>;85}186}8618787/// Implementation is implicitly provided for all interfaces188/// Implementation of ERC165 is implicitly generated for all interfaces in [`solidity_interface`],189/// this structure holds parsed data for ERC165Call subvariant88///190///89/// Note: no Callable implementation is provided191/// Note: no [`Callable`] implementation is provided, call implementation is inlined into every192/// implementing contract193///194/// See <https://eips.ethereum.org/EIPS/eip-165>90#[derive(Debug)]195#[derive(Debug)]91pub enum ERC165Call {196pub enum ERC165Call {197 /// ERC165 provides single method, which returns true, if contract198 /// implements specified interface92 SupportsInterface { interface_id: types::bytes4 },199 SupportsInterface {200 /// Requested interface201 interface_id: types::bytes4,202 },93}203}9420495impl ERC165Call {205impl ERC165Call {206 /// ERC165 selector is provided by standard96 pub const INTERFACE_ID: types::bytes4 = u32::to_be_bytes(0x01ffc9a7);207 pub const INTERFACE_ID: types::bytes4 = u32::to_be_bytes(0x01ffc9a7);97}208}98209crates/evm-coder/src/solidity.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Implementation detail of [`crate::solidity_interface`] macro code-generation.18//! You should not rely on any public item from this module, as it is only intended to be used19//! by procedural macro, API and output format may be changed at any time.20//!21//! Purpose of this module is to receive solidity contract definition in module-specified22//! format, and then output string, representing interface of this contract in solidity language162317#[cfg(not(feature = "std"))]24#[cfg(not(feature = "std"))]18use alloc::{25use alloc::{string::String, vec::Vec, collections::BTreeMap, format};19 string::String,20 vec::Vec,21 collections::{BTreeSet, BTreeMap},22 format,23};24#[cfg(feature = "std")]26#[cfg(feature = "std")]25use std::collections::{BTreeSet, BTreeMap};27use std::collections::BTreeMap;26use core::{28use core::{27 fmt::{self, Write},29 fmt::{self, Write},28 marker::PhantomData,30 marker::PhantomData,29 cell::{Cell, RefCell},31 cell::{Cell, RefCell},32 cmp::Reverse,30};33};31use impl_trait_for_tuples::impl_for_tuples;34use impl_trait_for_tuples::impl_for_tuples;32use crate::types::*;35use crate::types::*;333634#[derive(Default)]37#[derive(Default)]35pub struct TypeCollector {38pub struct TypeCollector {39 /// Code => id40 /// id ordering is required to perform topo-sort on the resulting data36 structs: RefCell<BTreeSet<string>>,41 structs: RefCell<BTreeMap<string, usize>>,37 anonymous: RefCell<BTreeMap<Vec<string>, usize>>,42 anonymous: RefCell<BTreeMap<Vec<string>, usize>>,38 id: Cell<usize>,43 id: Cell<usize>,39}44}42 Self::default()47 Self::default()43 }48 }44 pub fn collect(&self, item: string) {49 pub fn collect(&self, item: string) {50 let id = self.next_id();45 self.structs.borrow_mut().insert(item);51 self.structs.borrow_mut().insert(item, id);46 }52 }47 pub fn next_id(&self) -> usize {53 pub fn next_id(&self) -> usize {48 let v = self.id.get();54 let v = self.id.get();56 }62 }57 let id = self.next_id();63 let id = self.next_id();58 let mut str = String::new();64 let mut str = String::new();59 writeln!(str, "// Anonymous struct").unwrap();65 writeln!(str, "/// @dev anonymous struct").unwrap();60 writeln!(str, "struct Tuple{} {{", id).unwrap();66 writeln!(str, "struct Tuple{} {{", id).unwrap();61 for (i, name) in names.iter().enumerate() {67 for (i, name) in names.iter().enumerate() {62 writeln!(str, "\t{} field_{};", name, i).unwrap();68 writeln!(str, "\t{} field_{};", name, i).unwrap();66 self.anonymous.borrow_mut().insert(names, id);72 self.anonymous.borrow_mut().insert(names, id);67 format!("Tuple{}", id)73 format!("Tuple{}", id)68 }74 }69 pub fn finish(self) -> BTreeSet<string> {75 pub fn finish(self) -> Vec<string> {70 self.structs.into_inner()76 let mut data = self.structs.into_inner().into_iter().collect::<Vec<_>>();77 data.sort_by_key(|(_, id)| Reverse(*id));78 data.into_iter().map(|(code, _)| code).collect()71 }79 }72}80}738174pub trait SolidityTypeName: 'static {82pub trait SolidityTypeName: 'static {75 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;83 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;84 /// "simple" types are stored inline, no `memory` modifier should be used in solidity76 fn is_simple() -> bool;85 fn is_simple() -> bool;77 fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;86 fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;87 /// Specialization78 fn is_void() -> bool {88 fn is_void() -> bool {79 false89 false80 }90 }125}135}126136127mod sealed {137mod sealed {138 /// Not every type should be directly placed in vec.139 /// Vec encoding is not memory efficient, as every item will be padded140 /// to 32 bytes.141 /// Instead you should use specialized types (`bytes` in case of `Vec<u8>`)128 pub trait CanBePlacedInVec {}142 pub trait CanBePlacedInVec {}129}143}130144402}416}403pub struct SolidityFunction<A, R> {417pub struct SolidityFunction<A, R> {404 pub docs: &'static [&'static str],418 pub docs: &'static [&'static str],405 pub selector: &'static str,419 pub selector_str: &'static str,420 pub selector: u32,406 pub name: &'static str,421 pub name: &'static str,407 pub args: A,422 pub args: A,408 pub result: R,423 pub result: R,416 tc: &TypeCollector,431 tc: &TypeCollector,417 ) -> fmt::Result {432 ) -> fmt::Result {418 for doc in self.docs {433 for doc in self.docs {419 writeln!(writer, "\t//{}", doc)?;434 writeln!(writer, "\t///{}", doc)?;420 }435 }421 if !self.docs.is_empty() {422 writeln!(writer, "\t//")?;436 writeln!(423 }437 writer,438 "\t/// @dev EVM selector for this function is: 0x{:0>8x},",439 self.selector440 )?;424 writeln!(writer, "\t// Selector: {}", self.selector)?;441 writeln!(writer, "\t/// or in textual repr: {}", self.selector_str)?;425 write!(writer, "\tfunction {}(", self.name)?;442 write!(writer, "\tfunction {}(", self.name)?;426 self.args.solidity_name(writer, tc)?;443 self.args.solidity_name(writer, tc)?;427 write!(writer, ")")?;444 write!(writer, ")")?;481}498}482499483pub struct SolidityInterface<F: SolidityFunctions> {500pub struct SolidityInterface<F: SolidityFunctions> {501 pub docs: &'static [&'static str],484 pub selector: bytes4,502 pub selector: bytes4,485 pub name: &'static str,503 pub name: &'static str,486 pub is: &'static [&'static str],504 pub is: &'static [&'static str],495 tc: &TypeCollector,513 tc: &TypeCollector,496 ) -> fmt::Result {514 ) -> fmt::Result {497 const ZERO_BYTES: [u8; 4] = [0; 4];515 const ZERO_BYTES: [u8; 4] = [0; 4];516 for doc in self.docs {517 writeln!(out, "///{}", doc)?;518 }498 if self.selector != ZERO_BYTES {519 if self.selector != ZERO_BYTES {499 writeln!(520 writeln!(500 out,521 out,501 "// Selector: {:0>8x}",522 "/// @dev the ERC-165 identifier for this interface is 0x{:0>8x}",502 u32::from_be_bytes(self.selector)523 u32::from_be_bytes(self.selector)503 )?;524 )?;504 }525 }crates/evm-coder/tests/generics.rsdiffbeforeafterboth191920struct Generic<T>(PhantomData<T>);20struct Generic<T>(PhantomData<T>);212122#[solidity_interface(name = "GenericIs")]22#[solidity_interface(name = GenericIs)]23impl<T> Generic<T> {23impl<T> Generic<T> {24 fn test_1(&self) -> Result<uint256> {24 fn test_1(&self) -> Result<uint256> {25 unreachable!()25 unreachable!()26 }26 }27}27}282829#[solidity_interface(name = "Generic", is(GenericIs))]29#[solidity_interface(name = Generic, is(GenericIs))]30impl<T: Into<u32>> Generic<T> {30impl<T: Into<u32>> Generic<T> {31 fn test_2(&self) -> Result<uint256> {31 fn test_2(&self) -> Result<uint256> {32 unreachable!()32 unreachable!()353536generate_stubgen!(gen_iface, GenericCall<()>, false);36generate_stubgen!(gen_iface, GenericCall<()>, false);373738#[solidity_interface(name = "GenericWhere")]38#[solidity_interface(name = GenericWhere)]39impl<T> Generic<T>39impl<T> Generic<T>40where40where41 T: core::fmt::Debug,41 T: core::fmt::Debug,crates/evm-coder/tests/random.rsdiffbeforeafterboth212122struct Impls;22struct Impls;232324#[solidity_interface(name = "OurInterface")]24#[solidity_interface(name = OurInterface)]25impl Impls {25impl Impls {26 fn fn_a(&self, _input: uint256) -> Result<bool> {26 fn fn_a(&self, _input: uint256) -> Result<bool> {27 unreachable!()27 unreachable!()28 }28 }29}29}303031#[solidity_interface(name = "OurInterface1")]31#[solidity_interface(name = OurInterface1)]32impl Impls {32impl Impls {33 fn fn_b(&self, _input: uint128) -> Result<uint32> {33 fn fn_b(&self, _input: uint128) -> Result<uint32> {34 unreachable!()34 unreachable!()48}48}494950#[solidity_interface(50#[solidity_interface(51 name = "OurInterface2",51 name = OurInterface2,52 is(OurInterface),52 is(OurInterface),53 inline_is(OurInterface1),53 inline_is(OurInterface1),54 events(OurEvents)54 events(OurEvents)80 }80 }81}81}8283#[solidity_interface(84 name = ValidSelector,85 expect_selector = 0x00000000,86)]87impl Impls {}8288crates/evm-coder/tests/solidity_generation.rsdiffbeforeafterboth181819struct ERC20;19struct ERC20;202021#[solidity_interface(name = "ERC20")]21#[solidity_interface(name = ERC20)]22impl ERC20 {22impl ERC20 {23 fn decimals(&self) -> Result<uint8> {23 fn decimals(&self) -> Result<uint8> {24 unreachable!()24 unreachable!()node/cli/src/chain_spec.rsdiffbeforeafterboth115 .public()115 .public()116}116}117117118/// The extensions for the [`ChainSpec`].118/// The extensions for the [`DefaultChainSpec`].119#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]119#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]120#[serde(deny_unknown_fields)]120#[serde(deny_unknown_fields)]121pub struct Extensions {121pub struct Extensions {pallets/common/src/erc.rsdiffbeforeafterboth60}60}616162/// @title A contract that allows you to work with collections.62/// @title A contract that allows you to work with collections.63#[solidity_interface(name = "Collection")]63#[solidity_interface(name = Collection)]64impl<T: Config> CollectionHandle<T>64impl<T: Config> CollectionHandle<T>65where65where66 T::AccountId: From<[u8; 32]>,66 T::AccountId: From<[u8; 32]>,228 }228 }229229230 /// Add collection admin by substrate address.230 /// Add collection admin by substrate address.231 /// @param new_admin Substrate administrator address.231 /// @param newAdmin Substrate administrator address.232 fn add_collection_admin_substrate(232 fn add_collection_admin_substrate(233 &mut self,233 &mut self,234 caller: caller,234 caller: caller,254 }254 }255255256 /// Add collection admin.256 /// Add collection admin.257 /// @param new_admin Address of the added administrator.257 /// @param newAdmin Address of the added administrator.258 fn add_collection_admin(&mut self, caller: caller, new_admin: address) -> Result<void> {258 fn add_collection_admin(&mut self, caller: caller, new_admin: address) -> Result<void> {259 let caller = T::CrossAccountId::from_eth(caller);259 let caller = T::CrossAccountId::from_eth(caller);260 let new_admin = T::CrossAccountId::from_eth(new_admin);260 let new_admin = T::CrossAccountId::from_eth(new_admin);264264265 /// Remove collection admin.265 /// Remove collection admin.266 ///266 ///267 /// @param new_admin Address of the removed administrator.267 /// @param admin Address of the removed administrator.268 fn remove_collection_admin(&mut self, caller: caller, admin: address) -> Result<void> {268 fn remove_collection_admin(&mut self, caller: caller, admin: address) -> Result<void> {269 let caller = T::CrossAccountId::from_eth(caller);269 let caller = T::CrossAccountId::from_eth(caller);270 let admin = T::CrossAccountId::from_eth(admin);270 let admin = T::CrossAccountId::from_eth(admin);pallets/evm-contract-helpers/README.mddiffbeforeafterbothno changes
pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Implementation of magic contract161817use core::marker::PhantomData;19use core::marker::PhantomData;18use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};20use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};31use up_sponsorship::SponsorshipHandler;33use up_sponsorship::SponsorshipHandler;32use sp_std::vec::Vec;34use sp_std::vec::Vec;333536/// See [`ContractHelpersCall`]34struct ContractHelpers<T: Config>(SubstrateRecorder<T>);37pub struct ContractHelpers<T: Config>(SubstrateRecorder<T>);35impl<T: Config> WithRecorder<T> for ContractHelpers<T> {38impl<T: Config> WithRecorder<T> for ContractHelpers<T> {36 fn recorder(&self) -> &SubstrateRecorder<T> {39 fn recorder(&self) -> &SubstrateRecorder<T> {37 &self.040 &self.042 }45 }43}46}444748/// @title Magic contract, which allows users to reconfigure other contracts45#[solidity_interface(name = "ContractHelpers")]49#[solidity_interface(name = ContractHelpers)]46impl<T: Config> ContractHelpers<T>50impl<T: Config> ContractHelpers<T>47where51where48 T::AccountId: AsRef<[u8; 32]>,52 T::AccountId: AsRef<[u8; 32]>,49{53{50 /// Get contract ovner54 /// Get user, which deployed specified contract51 ///55 /// @dev May return zero address in case if contract is deployed52 /// @param Contract_address contract for which the owner is being determined.56 /// using uniquenetwork evm-migration pallet, or using other terms not57 /// intended by pallet-evm58 /// @dev Returns zero address if contract does not exists59 /// @param contractAddress Contract to get owner of53 /// @return Contract owner.60 /// @return address Owner of contract54 fn contract_owner(&self, contract_address: address) -> Result<address> {61 fn contract_owner(&self, contract_address: address) -> Result<address> {55 Ok(<Owner<T>>::get(contract_address))62 Ok(<Owner<T>>::get(contract_address))56 }63 }576458 /// Set sponsor.65 /// Set sponsor.59 ///60 /// @param contract_address Contract for which a sponsor is being established.66 /// @param contractAddress Contract for which a sponsor is being established.61 /// @param sponsor User address who set as pending sponsor.67 /// @param sponsor User address who set as pending sponsor.62 fn set_sponsor(68 fn set_sponsor(63 &mut self,69 &mut self,808681 /// Set contract as self sponsored.87 /// Set contract as self sponsored.82 ///88 ///83 /// @param contract_address Contract for which a self sponsoring is being enabled.89 /// @param contractAddress Contract for which a self sponsoring is being enabled.84 fn self_sponsored_enable(&mut self, caller: caller, contract_address: address) -> Result<void> {90 fn self_sponsored_enable(&mut self, caller: caller, contract_address: address) -> Result<void> {85 self.recorder().consume_sload()?;91 self.recorder().consume_sload()?;86 self.recorder().consume_sstore()?;92 self.recorder().consume_sstore()?;939994 /// Remove sponsor.100 /// Remove sponsor.95 ///101 ///96 /// @param contract_address Contract for which a sponsorship is being removed.102 /// @param contractAddress Contract for which a sponsorship is being removed.97 fn remove_sponsor(&mut self, caller: caller, contract_address: address) -> Result<void> {103 fn remove_sponsor(&mut self, caller: caller, contract_address: address) -> Result<void> {98 self.recorder().consume_sload()?;104 self.recorder().consume_sload()?;99 self.recorder().consume_sstore()?;105 self.recorder().consume_sstore()?;106112107 /// Confirm sponsorship.113 /// Confirm sponsorship.108 ///114 ///109 /// @dev Caller must be same that set via [`set_sponsor`].115 /// @dev Caller must be same that set via [`setSponsor`].110 ///116 ///111 /// @param contract_address Сontract for which need to confirm sponsorship.117 /// @param contractAddress Сontract for which need to confirm sponsorship.112 fn confirm_sponsorship(&mut self, caller: caller, contract_address: address) -> Result<void> {118 fn confirm_sponsorship(&mut self, caller: caller, contract_address: address) -> Result<void> {113 self.recorder().consume_sload()?;119 self.recorder().consume_sload()?;114 self.recorder().consume_sstore()?;120 self.recorder().consume_sstore()?;121127122 /// Get current sponsor.128 /// Get current sponsor.123 ///129 ///124 /// @param contract_address The contract for which a sponsor is requested.130 /// @param contractAddress The contract for which a sponsor is requested.125 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.131 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.126 fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {132 fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {127 let sponsor =133 let sponsor =138144139 /// Check tat contract has confirmed sponsor.145 /// Check tat contract has confirmed sponsor.140 ///146 ///141 /// @param contract_address The contract for which the presence of a confirmed sponsor is checked.147 /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.142 /// @return **true** if contract has confirmed sponsor.148 /// @return **true** if contract has confirmed sponsor.143 fn has_sponsor(&self, contract_address: address) -> Result<bool> {149 fn has_sponsor(&self, contract_address: address) -> Result<bool> {144 Ok(Pallet::<T>::get_sponsor(contract_address).is_some())150 Ok(Pallet::<T>::get_sponsor(contract_address).is_some())145 }151 }146152147 /// Check tat contract has pending sponsor.153 /// Check tat contract has pending sponsor.148 ///154 ///149 /// @param contract_address The contract for which the presence of a pending sponsor is checked.155 /// @param contractAddress The contract for which the presence of a pending sponsor is checked.150 /// @return **true** if contract has pending sponsor.156 /// @return **true** if contract has pending sponsor.151 fn has_pending_sponsor(&self, contract_address: address) -> Result<bool> {157 fn has_pending_sponsor(&self, contract_address: address) -> Result<bool> {152 Ok(match Sponsoring::<T>::get(contract_address) {158 Ok(match Sponsoring::<T>::get(contract_address) {163 &mut self,169 &mut self,164 caller: caller,170 caller: caller,165 contract_address: address,171 contract_address: address,172 // TODO: implement support for enums in evm-coder166 mode: uint8,173 mode: uint8,167 ) -> Result<void> {174 ) -> Result<void> {168 self.recorder().consume_sload()?;175 self.recorder().consume_sload()?;175 Ok(())182 Ok(())176 }183 }177184185 /// Get current contract sponsoring rate limit186 /// @param contractAddress Contract to get sponsoring mode of187 /// @return uint32 Amount of blocks between two sponsored transactions178 fn sponsoring_mode(&self, contract_address: address) -> Result<uint8> {188 fn get_sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {179 Ok(<Pallet<T>>::sponsoring_mode(contract_address).to_eth())189 Ok(<SponsoringRateLimit<T>>::get(contract_address)190 .try_into()191 .map_err(|_| "rate limit > u32::MAX")?)180 }192 }181193194 /// Set contract sponsoring rate limit195 /// @dev Sponsoring rate limit - is a minimum amount of blocks that should196 /// pass between two sponsored transactions197 /// @param contractAddress Contract to change sponsoring rate limit of198 /// @param rateLimit Target rate limit199 /// @dev Only contract owner can change this setting182 fn set_sponsoring_rate_limit(200 fn set_sponsoring_rate_limit(183 &mut self,201 &mut self,184 caller: caller,202 caller: caller,194 Ok(())211 Ok(())195 }212 }196213197 fn get_sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {214 /// Is specified user present in contract allow list198 Ok(<SponsoringRateLimit<T>>::get(contract_address)215 /// @dev Contract owner always implicitly included199 .try_into()216 /// @param contractAddress Contract to check allowlist of200 .map_err(|_| "rate limit > u32::MAX")?)217 /// @param user User to check201 }218 /// @return bool Is specified users exists in contract allowlist202203 fn allowed(&self, contract_address: address, user: address) -> Result<bool> {219 fn allowed(&self, contract_address: address, user: address) -> Result<bool> {204 self.0.consume_sload()?;220 self.0.consume_sload()?;205 Ok(<Pallet<T>>::allowed(contract_address, user))221 Ok(<Pallet<T>>::allowed(contract_address, user))206 }222 }207223208 fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {224 /// Toggle user presence in contract allowlist209 Ok(<AllowlistEnabled<T>>::get(contract_address))225 /// @param contractAddress Contract to change allowlist of210 }226 /// @param user Which user presence should be toggled211227 /// @param isAllowed `true` if user should be allowed to be sponsored228 /// or call this contract, `false` otherwise229 /// @dev Only contract owner can change this setting212 fn toggle_allowlist(230 fn toggle_allowed(213 &mut self,231 &mut self,214 caller: caller,232 caller: caller,215 contract_address: address,233 contract_address: address,234 user: address,216 enabled: bool,235 is_allowed: bool,217 ) -> Result<void> {236 ) -> Result<void> {218 self.recorder().consume_sload()?;237 self.recorder().consume_sload()?;219 self.recorder().consume_sstore()?;238 self.recorder().consume_sstore()?;220239221 <Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;240 <Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;222 <Pallet<T>>::toggle_allowlist(contract_address, enabled);241 <Pallet<T>>::toggle_allowed(contract_address, user, is_allowed);223242224 Ok(())243 Ok(())225 }244 }226245246 /// Is this contract has allowlist access enabled247 /// @dev Allowlist always can have users, and it is used for two purposes:248 /// in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist249 /// in case of allowlist access enabled, only users from allowlist may call this contract250 /// @param contractAddress Contract to get allowlist access of251 /// @return bool Is specified contract has allowlist access enabled252 fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {253 Ok(<AllowlistEnabled<T>>::get(contract_address))254 }255256 /// Toggle contract allowlist access257 /// @param contractAddress Contract to change allowlist access of258 /// @param enabled Should allowlist access to be enabled?227 fn toggle_allowed(259 fn toggle_allowlist(228 &mut self,260 &mut self,229 caller: caller,261 caller: caller,230 contract_address: address,262 contract_address: address,231 user: address,232 allowed: bool,263 enabled: bool,233 ) -> Result<void> {264 ) -> Result<void> {234 self.recorder().consume_sload()?;265 self.recorder().consume_sload()?;235 self.recorder().consume_sstore()?;266 self.recorder().consume_sstore()?;236267237 <Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;268 <Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;238 <Pallet<T>>::toggle_allowed(contract_address, user, allowed);269 <Pallet<T>>::toggle_allowlist(contract_address, enabled);239240 Ok(())270 Ok(())241 }271 }242}272}243273274/// Implements [`OnMethodCall`], which delegates call to [`ContractHelpers`]244pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);275pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);245impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T>276impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T>246where277where283 }314 }284}315}285316317/// Hooks into contract creation, storing owner of newly deployed contract286pub struct HelpersOnCreate<T: Config>(PhantomData<*const T>);318pub struct HelpersOnCreate<T: Config>(PhantomData<*const T>);287impl<T: Config> OnCreate<T> for HelpersOnCreate<T> {319impl<T: Config> OnCreate<T> for HelpersOnCreate<T> {288 fn on_create(owner: H160, contract: H160) {320 fn on_create(owner: H160, contract: H160) {289 <Owner<T>>::insert(contract, owner);321 <Owner<T>>::insert(contract, owner);290 }322 }291}323}292324325/// Bridge to pallet-sponsoring293pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);326pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);294impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>)>327impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>)>295 for HelpersContractSponsoring<T>328 for HelpersContractSponsoring<T>pallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617#![doc = include_str!("../README.md")]17#![cfg_attr(not(feature = "std"), no_std)]18#![cfg_attr(not(feature = "std"), no_std)]19#![deny(missing_docs)]182019use codec::{Decode, Encode, MaxEncodedLen};21use codec::{Decode, Encode, MaxEncodedLen};20pub use pallet::*;22pub use pallet::*;35 pub trait Config:37 pub trait Config:36 frame_system::Config + pallet_evm_coder_substrate::Config + pallet_evm::account::Config38 frame_system::Config + pallet_evm_coder_substrate::Config + pallet_evm::account::Config37 {39 {40 /// Address, under which magic contract will be available38 type ContractAddress: Get<H160>;41 type ContractAddress: Get<H160>;42 /// In case of enabled sponsoring, but no sponsoring rate limit set,43 /// this value will be used implicitly39 type DefaultSponsoringRateLimit: Get<Self::BlockNumber>;44 type DefaultSponsoringRateLimit: Get<Self::BlockNumber>;40 }45 }414642 #[pallet::error]47 #[pallet::error]43 pub enum Error<T> {48 pub enum Error<T> {44 /// This method is only executable by owner.49 /// This method is only executable by contract owner45 NoPermission,50 NoPermission,465147 /// No pending sponsor for contract.52 /// No pending sponsor for contract.217 }222 }218 }223 }219224225 /// Get current sponsoring mode, performing lazy migration from legacy storage220 pub fn sponsoring_mode(contract: H160) -> SponsoringModeT {226 pub fn sponsoring_mode(contract: H160) -> SponsoringModeT {221 <SponsoringMode<T>>::get(contract)227 <SponsoringMode<T>>::get(contract)222 .or_else(|| {228 .or_else(|| {225 .unwrap_or_default()231 .unwrap_or_default()226 }232 }227233234 /// Reconfigure contract sponsoring mode228 pub fn set_sponsoring_mode(contract: H160, mode: SponsoringModeT) {235 pub fn set_sponsoring_mode(contract: H160, mode: SponsoringModeT) {229 if mode == SponsoringModeT::Disabled {236 if mode == SponsoringModeT::Disabled {230 <SponsoringMode<T>>::remove(contract);237 <SponsoringMode<T>>::remove(contract);234 <SelfSponsoring<T>>::remove(contract)241 <SelfSponsoring<T>>::remove(contract)235 }242 }236243244 /// Set duration between two sponsored contract calls237 pub fn set_sponsoring_rate_limit(contract: H160, rate_limit: T::BlockNumber) {245 pub fn set_sponsoring_rate_limit(contract: H160, rate_limit: T::BlockNumber) {238 <SponsoringRateLimit<T>>::insert(contract, rate_limit);246 <SponsoringRateLimit<T>>::insert(contract, rate_limit);239 }247 }240248249 /// Is user added to allowlist, or he is owner of specified contract241 pub fn allowed(contract: H160, user: H160) -> bool {250 pub fn allowed(contract: H160, user: H160) -> bool {242 <Allowlist<T>>::get(&contract, &user) || <Owner<T>>::get(&contract) == user251 <Allowlist<T>>::get(&contract, &user) || <Owner<T>>::get(&contract) == user243 }252 }244253254 /// Toggle contract allowlist access245 pub fn toggle_allowlist(contract: H160, enabled: bool) {255 pub fn toggle_allowlist(contract: H160, enabled: bool) {246 <AllowlistEnabled<T>>::insert(contract, enabled)256 <AllowlistEnabled<T>>::insert(contract, enabled)247 }257 }248258259 /// Toggle user presence in contract's allowlist249 pub fn toggle_allowed(contract: H160, user: H160, allowed: bool) {260 pub fn toggle_allowed(contract: H160, user: H160, allowed: bool) {250 <Allowlist<T>>::insert(contract, user, allowed);261 <Allowlist<T>>::insert(contract, user, allowed);251 }262 }252263264 /// Throw error if user is not allowed to reconfigure target contract253 pub fn ensure_owner(contract: H160, user: H160) -> DispatchResult {265 pub fn ensure_owner(contract: H160, user: H160) -> DispatchResult {254 ensure!(<Owner<T>>::get(&contract) == user, Error::<T>::NoPermission);266 ensure!(<Owner<T>>::get(&contract) == user, Error::<T>::NoPermission);255 Ok(())267 Ok(())256 }268 }257 }269 }258}270}259271272/// Available contract sponsoring modes260#[derive(Encode, Decode, PartialEq, TypeInfo, MaxEncodedLen)]273#[derive(Encode, Decode, PartialEq, TypeInfo, MaxEncodedLen, Default)]261pub enum SponsoringModeT {274pub enum SponsoringModeT {275 /// Sponsoring is disabled276 #[default]262 Disabled,277 Disabled,278 /// Only users from allowlist will be sponsored263 Allowlisted,279 Allowlisted,280 /// All users will be sponsored264 Generous,281 Generous,265}282}266283282 }299 }283}300}284285impl Default for SponsoringModeT {286 fn default() -> Self {287 Self::Disabled288 }289}290301pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8 address field_0;9 uint256 field_1;10}11512// Common stubs holder6/// @dev common stubs holder13contract Dummy {7contract Dummy {14 uint8 dummy;8 uint8 dummy;15 string stub_error = "this contract is implemented in native";9 string stub_error = "this contract is implemented in native";27 }21 }28}22}292330// Selector: 6073d91724/// @title Magic contract, which allows users to reconfigure other contracts25/// @dev the ERC-165 identifier for this interface is 0xd77fab7031contract ContractHelpers is Dummy, ERC165 {26contract ContractHelpers is Dummy, ERC165 {32 // Get contract ovner27 /// Get user, which deployed specified contract33 //28 /// @dev May return zero address in case if contract is deployed34 // @param Contract_address contract for which the owner is being determined.29 /// using uniquenetwork evm-migration pallet, or using other terms not35 // @return Contract owner.30 /// intended by pallet-evm36 //31 /// @dev Returns zero address if contract does not exists37 // Selector: contractOwner(address) 5152b14c32 /// @param contractAddress Contract to get owner of33 /// @return address Owner of contract34 /// @dev EVM selector for this function is: 0x5152b14c,35 /// or in textual repr: contractOwner(address)38 function contractOwner(address contractAddress)36 function contractOwner(address contractAddress)39 public37 public40 view38 view46 return 0x0000000000000000000000000000000000000000;44 return 0x0000000000000000000000000000000000000000;47 }45 }484649 // Set sponsor.47 /// Set sponsor.50 //51 // @param contract_address Contract for which a sponsor is being established.48 /// @param contractAddress Contract for which a sponsor is being established.52 // @param sponsor User address who set as pending sponsor.49 /// @param sponsor User address who set as pending sponsor.53 //50 /// @dev EVM selector for this function is: 0xf01fba93,54 // Selector: setSponsor(address,address) f01fba9351 /// or in textual repr: setSponsor(address,address)55 function setSponsor(address contractAddress, address sponsor) public {52 function setSponsor(address contractAddress, address sponsor) public {56 require(false, stub_error);53 require(false, stub_error);57 contractAddress;54 contractAddress;58 sponsor;55 sponsor;59 dummy = 0;56 dummy = 0;60 }57 }615862 // Set contract as self sponsored.59 /// Set contract as self sponsored.63 //60 ///64 // @param contract_address Contract for which a self sponsoring is being enabled.61 /// @param contractAddress Contract for which a self sponsoring is being enabled.65 //62 /// @dev EVM selector for this function is: 0x89f7d9ae,66 // Selector: selfSponsoredEnable(address) 89f7d9ae63 /// or in textual repr: selfSponsoredEnable(address)67 function selfSponsoredEnable(address contractAddress) public {64 function selfSponsoredEnable(address contractAddress) public {68 require(false, stub_error);65 require(false, stub_error);69 contractAddress;66 contractAddress;70 dummy = 0;67 dummy = 0;71 }68 }726973 // Remove sponsor.70 /// Remove sponsor.74 //71 ///75 // @param contract_address Contract for which a sponsorship is being removed.72 /// @param contractAddress Contract for which a sponsorship is being removed.76 //73 /// @dev EVM selector for this function is: 0xef784250,77 // Selector: removeSponsor(address) ef78425074 /// or in textual repr: removeSponsor(address)78 function removeSponsor(address contractAddress) public {75 function removeSponsor(address contractAddress) public {79 require(false, stub_error);76 require(false, stub_error);80 contractAddress;77 contractAddress;81 dummy = 0;78 dummy = 0;82 }79 }838084 // Confirm sponsorship.81 /// Confirm sponsorship.85 //82 ///86 // @dev Caller must be same that set via [`set_sponsor`].83 /// @dev Caller must be same that set via [`setSponsor`].87 //84 ///88 // @param contract_address Сontract for which need to confirm sponsorship.85 /// @param contractAddress Сontract for which need to confirm sponsorship.89 //86 /// @dev EVM selector for this function is: 0xabc00001,90 // Selector: confirmSponsorship(address) abc0000187 /// or in textual repr: confirmSponsorship(address)91 function confirmSponsorship(address contractAddress) public {88 function confirmSponsorship(address contractAddress) public {92 require(false, stub_error);89 require(false, stub_error);93 contractAddress;90 contractAddress;94 dummy = 0;91 dummy = 0;95 }92 }969397 // Get current sponsor.94 /// Get current sponsor.98 //95 ///99 // @param contract_address The contract for which a sponsor is requested.96 /// @param contractAddress The contract for which a sponsor is requested.100 // @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.97 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.101 //98 /// @dev EVM selector for this function is: 0x743fc745,102 // Selector: getSponsor(address) 743fc74599 /// or in textual repr: getSponsor(address)103 function getSponsor(address contractAddress)100 function getSponsor(address contractAddress)104 public101 public105 view102 view111 return Tuple0(0x0000000000000000000000000000000000000000, 0);108 return Tuple0(0x0000000000000000000000000000000000000000, 0);112 }109 }113110114 // Check tat contract has confirmed sponsor.111 /// Check tat contract has confirmed sponsor.115 //112 ///116 // @param contract_address The contract for which the presence of a confirmed sponsor is checked.113 /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.117 // @return **true** if contract has confirmed sponsor.114 /// @return **true** if contract has confirmed sponsor.118 //115 /// @dev EVM selector for this function is: 0x97418603,119 // Selector: hasSponsor(address) 97418603116 /// or in textual repr: hasSponsor(address)120 function hasSponsor(address contractAddress) public view returns (bool) {117 function hasSponsor(address contractAddress) public view returns (bool) {121 require(false, stub_error);118 require(false, stub_error);122 contractAddress;119 contractAddress;123 dummy;120 dummy;124 return false;121 return false;125 }122 }126123127 // Check tat contract has pending sponsor.124 /// Check tat contract has pending sponsor.128 //125 ///129 // @param contract_address The contract for which the presence of a pending sponsor is checked.126 /// @param contractAddress The contract for which the presence of a pending sponsor is checked.130 // @return **true** if contract has pending sponsor.127 /// @return **true** if contract has pending sponsor.131 //128 /// @dev EVM selector for this function is: 0x39b9b242,132 // Selector: hasPendingSponsor(address) 39b9b242129 /// or in textual repr: hasPendingSponsor(address)133 function hasPendingSponsor(address contractAddress)130 function hasPendingSponsor(address contractAddress)134 public131 public135 view132 view141 return false;138 return false;142 }139 }143140141 /// @dev EVM selector for this function is: 0x6027dc61,144 // Selector: sponsoringEnabled(address) 6027dc61142 /// or in textual repr: sponsoringEnabled(address)145 function sponsoringEnabled(address contractAddress)143 function sponsoringEnabled(address contractAddress)146 public144 public147 view145 view153 return false;151 return false;154 }152 }155153154 /// @dev EVM selector for this function is: 0xfde8a560,156 // Selector: setSponsoringMode(address,uint8) fde8a560155 /// or in textual repr: setSponsoringMode(address,uint8)157 function setSponsoringMode(address contractAddress, uint8 mode) public {156 function setSponsoringMode(address contractAddress, uint8 mode) public {158 require(false, stub_error);157 require(false, stub_error);159 contractAddress;158 contractAddress;160 mode;159 mode;161 dummy = 0;160 dummy = 0;162 }161 }163162164 // Selector: sponsoringMode(address) b70c7267163 /// Get current contract sponsoring rate limit164 /// @param contractAddress Contract to get sponsoring mode of165 /// @return uint32 Amount of blocks between two sponsored transactions166 /// @dev EVM selector for this function is: 0x610cfabd,167 /// or in textual repr: getSponsoringRateLimit(address)165 function sponsoringMode(address contractAddress)168 function getSponsoringRateLimit(address contractAddress)166 public169 public167 view170 view168 returns (uint8)171 returns (uint32)169 {172 {170 require(false, stub_error);173 require(false, stub_error);171 contractAddress;174 contractAddress;172 dummy;175 dummy;173 return 0;176 return 0;174 }177 }175178179 /// Set contract sponsoring rate limit180 /// @dev Sponsoring rate limit - is a minimum amount of blocks that should181 /// pass between two sponsored transactions182 /// @param contractAddress Contract to change sponsoring rate limit of183 /// @param rateLimit Target rate limit184 /// @dev Only contract owner can change this setting185 /// @dev EVM selector for this function is: 0x77b6c908,176 // Selector: setSponsoringRateLimit(address,uint32) 77b6c908186 /// or in textual repr: setSponsoringRateLimit(address,uint32)177 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)187 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)178 public188 public179 {189 {183 dummy = 0;193 dummy = 0;184 }194 }185195186 // Selector: getSponsoringRateLimit(address) 610cfabd196 /// Is specified user present in contract allow list197 /// @dev Contract owner always implicitly included198 /// @param contractAddress Contract to check allowlist of199 /// @param user User to check200 /// @return bool Is specified users exists in contract allowlist201 /// @dev EVM selector for this function is: 0x5c658165,202 /// or in textual repr: allowed(address,address)187 function getSponsoringRateLimit(address contractAddress)203 function allowed(address contractAddress, address user)188 public204 public189 view205 view190 returns (uint32)206 returns (bool)191 {207 {192 require(false, stub_error);208 require(false, stub_error);193 contractAddress;209 contractAddress;210 user;194 dummy;211 dummy;195 return 0;212 return false;196 }213 }197214198 // Selector: allowed(address,address) 5c658165215 /// Toggle user presence in contract allowlist216 /// @param contractAddress Contract to change allowlist of217 /// @param user Which user presence should be toggled218 /// @param isAllowed `true` if user should be allowed to be sponsored219 /// or call this contract, `false` otherwise220 /// @dev Only contract owner can change this setting221 /// @dev EVM selector for this function is: 0x4706cc1c,222 /// or in textual repr: toggleAllowed(address,address,bool)199 function allowed(address contractAddress, address user)223 function toggleAllowed(224 address contractAddress,225 address user,226 bool isAllowed200 public227 ) public {201 view202 returns (bool)203 {204 require(false, stub_error);228 require(false, stub_error);205 contractAddress;229 contractAddress;206 user;230 user;207 dummy;231 isAllowed;208 return false;232 dummy = 0;209 }233 }210234211 // Selector: allowlistEnabled(address) c772ef6c235 /// Is this contract has allowlist access enabled236 /// @dev Allowlist always can have users, and it is used for two purposes:237 /// in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist238 /// in case of allowlist access enabled, only users from allowlist may call this contract239 /// @param contractAddress Contract to get allowlist access of240 /// @return bool Is specified contract has allowlist access enabled241 /// @dev EVM selector for this function is: 0xc772ef6c,242 /// or in textual repr: allowlistEnabled(address)212 function allowlistEnabled(address contractAddress)243 function allowlistEnabled(address contractAddress)213 public244 public214 view245 view220 return false;251 return false;221 }252 }222253254 /// Toggle contract allowlist access255 /// @param contractAddress Contract to change allowlist access of256 /// @param enabled Should allowlist access to be enabled?257 /// @dev EVM selector for this function is: 0x36de20f5,223 // Selector: toggleAllowlist(address,bool) 36de20f5258 /// or in textual repr: toggleAllowlist(address,bool)224 function toggleAllowlist(address contractAddress, bool enabled) public {259 function toggleAllowlist(address contractAddress, bool enabled) public {225 require(false, stub_error);260 require(false, stub_error);226 contractAddress;261 contractAddress;227 enabled;262 enabled;228 dummy = 0;263 dummy = 0;229 }264 }230231 // Selector: toggleAllowed(address,address,bool) 4706cc1c232 function toggleAllowed(233 address contractAddress,234 address user,235 bool allowed236 ) public {237 require(false, stub_error);238 contractAddress;239 user;240 allowed;241 dummy = 0;242 }243}265}266267/// @dev anonymous struct268struct Tuple0 {269 address field_0;270 uint256 field_1;271}244272pallets/evm-migration/README.mddiffbeforeafterbothno changes
pallets/evm-migration/src/benchmarking.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![allow(missing_docs)]161817use super::{Call, Config, Pallet};19use super::{Call, Config, Pallet};18use frame_benchmarking::benchmarks;20use frame_benchmarking::benchmarks;pallets/evm-migration/src/lib.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617#![doc = include_str!("../README.md")]17#![cfg_attr(not(feature = "std"), no_std)]18#![cfg_attr(not(feature = "std"), no_std)]19#![deny(missing_docs)]182019pub use pallet::*;21pub use pallet::*;20#[cfg(feature = "runtime-benchmarks")]22#[cfg(feature = "runtime-benchmarks")]323433 #[pallet::config]35 #[pallet::config]34 pub trait Config: frame_system::Config + pallet_evm::Config {36 pub trait Config: frame_system::Config + pallet_evm::Config {37 /// Weights35 type WeightInfo: WeightInfo;38 type WeightInfo: WeightInfo;36 }39 }3740434644 #[pallet::error]47 #[pallet::error]45 pub enum Error<T> {48 pub enum Error<T> {49 /// Can only migrate to empty address.46 AccountNotEmpty,50 AccountNotEmpty,51 /// Migration of this account is not yet started, or already finished.47 AccountIsNotMigrating,52 AccountIsNotMigrating,48 }53 }4954535854 #[pallet::call]59 #[pallet::call]55 impl<T: Config> Pallet<T> {60 impl<T: Config> Pallet<T> {61 /// Start contract migration, inserts contract stub at target address,62 /// and marks account as pending, allowing to insert storage56 #[pallet::weight(<SelfWeightOf<T>>::begin())]63 #[pallet::weight(<SelfWeightOf<T>>::begin())]57 pub fn begin(origin: OriginFor<T>, address: H160) -> DispatchResult {64 pub fn begin(origin: OriginFor<T>, address: H160) -> DispatchResult {58 ensure_root(origin)?;65 ensure_root(origin)?;65 Ok(())72 Ok(())66 }73 }677475 /// Insert items into contract storage, this method can be called76 /// multiple times68 #[pallet::weight(<SelfWeightOf<T>>::set_data(data.len() as u32))]77 #[pallet::weight(<SelfWeightOf<T>>::set_data(data.len() as u32))]69 pub fn set_data(78 pub fn set_data(70 origin: OriginFor<T>,79 origin: OriginFor<T>,83 Ok(())92 Ok(())84 }93 }859495 /// Finish contract migration, allows it to be called.96 /// It is not possible to alter contract storage via [`Self::set_data`]97 /// after this call.86 #[pallet::weight(<SelfWeightOf<T>>::finish(code.len() as u32))]98 #[pallet::weight(<SelfWeightOf<T>>::finish(code.len() as u32))]87 pub fn finish(origin: OriginFor<T>, address: H160, code: Vec<u8>) -> DispatchResult {99 pub fn finish(origin: OriginFor<T>, address: H160, code: Vec<u8>) -> DispatchResult {88 ensure_root(origin)?;100 ensure_root(origin)?;97 }109 }98 }110 }99111112 /// Implements [`pallet_evm::OnMethodCall`], which reserves accounts with pending migration100 pub struct OnMethodCall<T>(PhantomData<T>);113 pub struct OnMethodCall<T>(PhantomData<T>);101 impl<T: Config> pallet_evm::OnMethodCall<T> for OnMethodCall<T> {114 impl<T: Config> pallet_evm::OnMethodCall<T> for OnMethodCall<T> {102 fn is_reserved(contract: &H160) -> bool {115 fn is_reserved(contract: &H160) -> bool {pallets/evm-migration/src/weights.rsdiffbeforeafterboth26#![cfg_attr(rustfmt, rustfmt_skip)]26#![cfg_attr(rustfmt, rustfmt_skip)]27#![allow(unused_parens)]27#![allow(unused_parens)]28#![allow(unused_imports)]28#![allow(unused_imports)]29#![allow(missing_docs)]29#![allow(clippy::unnecessary_cast)]30#![allow(clippy::unnecessary_cast)]303131use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};32use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};pallets/evm-transaction-payment/README.mddiffbeforeafterbothno changes
pallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617#![doc = include_str!("../README.md")]17#![cfg_attr(not(feature = "std"), no_std)]18#![cfg_attr(not(feature = "std"), no_std)]19#![deny(missing_docs)]182019use core::marker::PhantomData;21use core::marker::PhantomData;20use fp_evm::WithdrawReason;22use fp_evm::WithdrawReason;29pub mod pallet {31pub mod pallet {30 use super::*;32 use super::*;313332 use frame_support::traits::Currency;33 use sp_std::vec::Vec;34 use sp_std::vec::Vec;343535 #[pallet::config]36 #[pallet::config]36 pub trait Config: frame_system::Config + pallet_evm::account::Config {37 pub trait Config: frame_system::Config + pallet_evm::account::Config {38 /// Loosly-coupled handlers for evm call sponsoring37 type EvmSponsorshipHandler: SponsorshipHandler<Self::CrossAccountId, (H160, Vec<u8>)>;39 type EvmSponsorshipHandler: SponsorshipHandler<Self::CrossAccountId, (H160, Vec<u8>)>;38 type Currency: Currency<Self::AccountId>;39 }40 }404141 #[pallet::pallet]42 #[pallet::pallet]42 #[pallet::generate_store(pub(super) trait Store)]43 #[pallet::generate_store(pub(super) trait Store)]43 pub struct Pallet<T>(_);44 pub struct Pallet<T>(_);44}45}454647/// Implements [`fp_evm::TransactionValidityHack`], which provides sponsor address to pallet-evm46pub struct TransactionValidityHack<T: Config>(PhantomData<*const T>);48pub struct TransactionValidityHack<T: Config>(PhantomData<*const T>);47impl<T: Config> fp_evm::TransactionValidityHack<T::CrossAccountId> for TransactionValidityHack<T> {49impl<T: Config> fp_evm::TransactionValidityHack<T::CrossAccountId> for TransactionValidityHack<T> {48 fn who_pays_fee(origin: H160, reason: &WithdrawReason) -> Option<T::CrossAccountId> {50 fn who_pays_fee(origin: H160, reason: &WithdrawReason) -> Option<T::CrossAccountId> {pallets/fungible/src/erc.rsdiffbeforeafterboth50 },50 },51}51}525253#[solidity_interface(name = "ERC20", events(ERC20Events))]53#[solidity_interface(name = ERC20, events(ERC20Events))]54impl<T: Config> FungibleHandle<T> {54impl<T: Config> FungibleHandle<T> {55 fn name(&self) -> Result<string> {55 fn name(&self) -> Result<string> {56 Ok(decode_utf16(self.name.iter().copied())56 Ok(decode_utf16(self.name.iter().copied())129 }129 }130}130}131131132#[solidity_interface(name = "ERC20UniqueExtensions")]132#[solidity_interface(name = ERC20UniqueExtensions)]133impl<T: Config> FungibleHandle<T> {133impl<T: Config> FungibleHandle<T> {134 #[weight(<SelfWeightOf<T>>::burn_from())]134 #[weight(<SelfWeightOf<T>>::burn_from())]135 fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {135 fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {147}147}148148149#[solidity_interface(149#[solidity_interface(150 name = "UniqueFungible",150 name = UniqueFungible,151 is(151 is(152 ERC20,152 ERC20,153 ERC20UniqueExtensions,153 ERC20UniqueExtensions,154 via("CollectionHandle<T>", common_mut, Collection)154 Collection(common_mut, CollectionHandle<T>),155 )155 )156)]156)]157impl<T: Config> FungibleHandle<T> where T::AccountId: From<[u8; 32]> {}157impl<T: Config> FungibleHandle<T> where T::AccountId: From<[u8; 32]> {}pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;556// Common stubs holder6/// @dev common stubs holder7contract Dummy {7contract Dummy {8 uint8 dummy;8 uint8 dummy;9 string stub_error = "this contract is implemented in native";9 string stub_error = "this contract is implemented in native";21 }21 }22}22}232324// Inline24/// @title A contract that allows you to work with collections.25/// @dev the ERC-165 identifier for this interface is 0xffe4da2326contract Collection is Dummy, ERC165 {27 /// Set collection property.28 ///29 /// @param key Property key.30 /// @param value Propery value.31 /// @dev EVM selector for this function is: 0x2f073f66,32 /// or in textual repr: setCollectionProperty(string,bytes)33 function setCollectionProperty(string memory key, bytes memory value)34 public35 {36 require(false, stub_error);37 key;38 value;39 dummy = 0;40 }4142 /// Delete collection property.43 ///44 /// @param key Property key.45 /// @dev EVM selector for this function is: 0x7b7debce,46 /// or in textual repr: deleteCollectionProperty(string)47 function deleteCollectionProperty(string memory key) public {48 require(false, stub_error);49 key;50 dummy = 0;51 }5253 /// Get collection property.54 ///55 /// @dev Throws error if key not found.56 ///57 /// @param key Property key.58 /// @return bytes The property corresponding to the key.59 /// @dev EVM selector for this function is: 0xcf24fd6d,60 /// or in textual repr: collectionProperty(string)61 function collectionProperty(string memory key)62 public63 view64 returns (bytes memory)65 {66 require(false, stub_error);67 key;68 dummy;69 return hex"";70 }7172 /// Set the sponsor of the collection.73 ///74 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.75 ///76 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.77 /// @dev EVM selector for this function is: 0x7623402e,78 /// or in textual repr: setCollectionSponsor(address)79 function setCollectionSponsor(address sponsor) public {80 require(false, stub_error);81 sponsor;82 dummy = 0;83 }8485 /// Collection sponsorship confirmation.86 ///87 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.88 /// @dev EVM selector for this function is: 0x3c50e97a,89 /// or in textual repr: confirmCollectionSponsorship()90 function confirmCollectionSponsorship() public {91 require(false, stub_error);92 dummy = 0;93 }9495 /// Set limits for the collection.96 /// @dev Throws error if limit not found.97 /// @param limit Name of the limit. Valid names:98 /// "accountTokenOwnershipLimit",99 /// "sponsoredDataSize",100 /// "sponsoredDataRateLimit",101 /// "tokenLimit",102 /// "sponsorTransferTimeout",103 /// "sponsorApproveTimeout"104 /// @param value Value of the limit.105 /// @dev EVM selector for this function is: 0x6a3841db,106 /// or in textual repr: setCollectionLimit(string,uint32)107 function setCollectionLimit(string memory limit, uint32 value) public {108 require(false, stub_error);109 limit;110 value;111 dummy = 0;112 }113114 /// Set limits for the collection.115 /// @dev Throws error if limit not found.116 /// @param limit Name of the limit. Valid names:117 /// "ownerCanTransfer",118 /// "ownerCanDestroy",119 /// "transfersEnabled"120 /// @param value Value of the limit.121 /// @dev EVM selector for this function is: 0x993b7fba,122 /// or in textual repr: setCollectionLimit(string,bool)123 function setCollectionLimit(string memory limit, bool value) public {124 require(false, stub_error);125 limit;126 value;127 dummy = 0;128 }129130 /// Get contract address.131 /// @dev EVM selector for this function is: 0xf6b4dfb4,132 /// or in textual repr: contractAddress()133 function contractAddress() public view returns (address) {134 require(false, stub_error);135 dummy;136 return 0x0000000000000000000000000000000000000000;137 }138139 /// Add collection admin by substrate address.140 /// @param newAdmin Substrate administrator address.141 /// @dev EVM selector for this function is: 0x5730062b,142 /// or in textual repr: addCollectionAdminSubstrate(uint256)143 function addCollectionAdminSubstrate(uint256 newAdmin) public {144 require(false, stub_error);145 newAdmin;146 dummy = 0;147 }148149 /// Remove collection admin by substrate address.150 /// @param admin Substrate administrator address.151 /// @dev EVM selector for this function is: 0x4048fcf9,152 /// or in textual repr: removeCollectionAdminSubstrate(uint256)153 function removeCollectionAdminSubstrate(uint256 admin) public {154 require(false, stub_error);155 admin;156 dummy = 0;157 }158159 /// Add collection admin.160 /// @param newAdmin Address of the added administrator.161 /// @dev EVM selector for this function is: 0x92e462c7,162 /// or in textual repr: addCollectionAdmin(address)163 function addCollectionAdmin(address newAdmin) public {164 require(false, stub_error);165 newAdmin;166 dummy = 0;167 }168169 /// Remove collection admin.170 ///171 /// @param admin Address of the removed administrator.172 /// @dev EVM selector for this function is: 0xfafd7b42,173 /// or in textual repr: removeCollectionAdmin(address)174 function removeCollectionAdmin(address admin) public {175 require(false, stub_error);176 admin;177 dummy = 0;178 }179180 /// Toggle accessibility of collection nesting.181 ///182 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'183 /// @dev EVM selector for this function is: 0x112d4586,184 /// or in textual repr: setCollectionNesting(bool)185 function setCollectionNesting(bool enable) public {186 require(false, stub_error);187 enable;188 dummy = 0;189 }190191 /// Toggle accessibility of collection nesting.192 ///193 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'194 /// @param collections Addresses of collections that will be available for nesting.195 /// @dev EVM selector for this function is: 0x64872396,196 /// or in textual repr: setCollectionNesting(bool,address[])197 function setCollectionNesting(bool enable, address[] memory collections)198 public199 {200 require(false, stub_error);201 enable;202 collections;203 dummy = 0;204 }205206 /// Set the collection access method.207 /// @param mode Access mode208 /// 0 for Normal209 /// 1 for AllowList210 /// @dev EVM selector for this function is: 0x41835d4c,211 /// or in textual repr: setCollectionAccess(uint8)212 function setCollectionAccess(uint8 mode) public {213 require(false, stub_error);214 mode;215 dummy = 0;216 }217218 /// Add the user to the allowed list.219 ///220 /// @param user Address of a trusted user.221 /// @dev EVM selector for this function is: 0x67844fe6,222 /// or in textual repr: addToCollectionAllowList(address)223 function addToCollectionAllowList(address user) public {224 require(false, stub_error);225 user;226 dummy = 0;227 }228229 /// Remove the user from the allowed list.230 ///231 /// @param user Address of a removed user.232 /// @dev EVM selector for this function is: 0x85c51acb,233 /// or in textual repr: removeFromCollectionAllowList(address)234 function removeFromCollectionAllowList(address user) public {235 require(false, stub_error);236 user;237 dummy = 0;238 }239240 /// Switch permission for minting.241 ///242 /// @param mode Enable if "true".243 /// @dev EVM selector for this function is: 0x00018e84,244 /// or in textual repr: setCollectionMintMode(bool)245 function setCollectionMintMode(bool mode) public {246 require(false, stub_error);247 mode;248 dummy = 0;249 }250251 /// Check that account is the owner or admin of the collection252 ///253 /// @param user account to verify254 /// @return "true" if account is the owner or admin255 /// @dev EVM selector for this function is: 0x9811b0c7,256 /// or in textual repr: isOwnerOrAdmin(address)257 function isOwnerOrAdmin(address user) public view returns (bool) {258 require(false, stub_error);259 user;260 dummy;261 return false;262 }263264 /// Check that substrate account is the owner or admin of the collection265 ///266 /// @param user account to verify267 /// @return "true" if account is the owner or admin268 /// @dev EVM selector for this function is: 0x68910e00,269 /// or in textual repr: isOwnerOrAdminSubstrate(uint256)270 function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) {271 require(false, stub_error);272 user;273 dummy;274 return false;275 }276277 /// Returns collection type278 ///279 /// @return `Fungible` or `NFT` or `ReFungible`280 /// @dev EVM selector for this function is: 0xd34b55b8,281 /// or in textual repr: uniqueCollectionType()282 function uniqueCollectionType() public returns (string memory) {283 require(false, stub_error);284 dummy = 0;285 return "";286 }287288 /// Changes collection owner to another account289 ///290 /// @dev Owner can be changed only by current owner291 /// @param newOwner new owner account292 /// @dev EVM selector for this function is: 0x13af4035,293 /// or in textual repr: setOwner(address)294 function setOwner(address newOwner) public {295 require(false, stub_error);296 newOwner;297 dummy = 0;298 }299300 /// Changes collection owner to another substrate account301 ///302 /// @dev Owner can be changed only by current owner303 /// @param newOwner new owner substrate account304 /// @dev EVM selector for this function is: 0xb212138f,305 /// or in textual repr: setOwnerSubstrate(uint256)306 function setOwnerSubstrate(uint256 newOwner) public {307 require(false, stub_error);308 newOwner;309 dummy = 0;310 }311}312313/// @dev the ERC-165 identifier for this interface is 0x79cc6790314contract ERC20UniqueExtensions is Dummy, ERC165 {315 /// @dev EVM selector for this function is: 0x79cc6790,316 /// or in textual repr: burnFrom(address,uint256)317 function burnFrom(address from, uint256 amount) public returns (bool) {318 require(false, stub_error);319 from;320 amount;321 dummy = 0;322 return false;323 }324}325326/// @dev inlined interface25contract ERC20Events {327contract ERC20Events {26 event Transfer(address indexed from, address indexed to, uint256 value);328 event Transfer(address indexed from, address indexed to, uint256 value);27 event Approval(329 event Approval(31 );333 );32}334}3333534// Selector: 79cc6790336/// @dev the ERC-165 identifier for this interface is 0x942e8b2235contract ERC20UniqueExtensions is Dummy, ERC165 {36 // Selector: burnFrom(address,uint256) 79cc679037 function burnFrom(address from, uint256 amount) public returns (bool) {38 require(false, stub_error);39 from;40 amount;41 dummy = 0;42 return false;43 }44}4546// Selector: 942e8b2247contract ERC20 is Dummy, ERC165, ERC20Events {337contract ERC20 is Dummy, ERC165, ERC20Events {48 // Selector: name() 06fdde03338 /// @dev EVM selector for this function is: 0x06fdde03,339 /// or in textual repr: name()49 function name() public view returns (string memory) {340 function name() public view returns (string memory) {50 require(false, stub_error);341 require(false, stub_error);51 dummy;342 dummy;52 return "";343 return "";53 }344 }5434555 // Selector: symbol() 95d89b41346 /// @dev EVM selector for this function is: 0x95d89b41,347 /// or in textual repr: symbol()56 function symbol() public view returns (string memory) {348 function symbol() public view returns (string memory) {57 require(false, stub_error);349 require(false, stub_error);58 dummy;350 dummy;59 return "";351 return "";60 }352 }6135362 // Selector: totalSupply() 18160ddd354 /// @dev EVM selector for this function is: 0x18160ddd,355 /// or in textual repr: totalSupply()63 function totalSupply() public view returns (uint256) {356 function totalSupply() public view returns (uint256) {64 require(false, stub_error);357 require(false, stub_error);65 dummy;358 dummy;66 return 0;359 return 0;67 }360 }6836169 // Selector: decimals() 313ce567362 /// @dev EVM selector for this function is: 0x313ce567,363 /// or in textual repr: decimals()70 function decimals() public view returns (uint8) {364 function decimals() public view returns (uint8) {71 require(false, stub_error);365 require(false, stub_error);72 dummy;366 dummy;73 return 0;367 return 0;74 }368 }75369370 /// @dev EVM selector for this function is: 0x70a08231,76 // Selector: balanceOf(address) 70a08231371 /// or in textual repr: balanceOf(address)77 function balanceOf(address owner) public view returns (uint256) {372 function balanceOf(address owner) public view returns (uint256) {78 require(false, stub_error);373 require(false, stub_error);79 owner;374 owner;80 dummy;375 dummy;81 return 0;376 return 0;82 }377 }83378379 /// @dev EVM selector for this function is: 0xa9059cbb,84 // Selector: transfer(address,uint256) a9059cbb380 /// or in textual repr: transfer(address,uint256)85 function transfer(address to, uint256 amount) public returns (bool) {381 function transfer(address to, uint256 amount) public returns (bool) {86 require(false, stub_error);382 require(false, stub_error);87 to;383 to;90 return false;386 return false;91 }387 }92388389 /// @dev EVM selector for this function is: 0x23b872dd,93 // Selector: transferFrom(address,address,uint256) 23b872dd390 /// or in textual repr: transferFrom(address,address,uint256)94 function transferFrom(391 function transferFrom(95 address from,392 address from,96 address to,393 address to,104 return false;401 return false;105 }402 }106403404 /// @dev EVM selector for this function is: 0x095ea7b3,107 // Selector: approve(address,uint256) 095ea7b3405 /// or in textual repr: approve(address,uint256)108 function approve(address spender, uint256 amount) public returns (bool) {406 function approve(address spender, uint256 amount) public returns (bool) {109 require(false, stub_error);407 require(false, stub_error);110 spender;408 spender;113 return false;411 return false;114 }412 }115413414 /// @dev EVM selector for this function is: 0xdd62ed3e,116 // Selector: allowance(address,address) dd62ed3e415 /// or in textual repr: allowance(address,address)117 function allowance(address owner, address spender)416 function allowance(address owner, address spender)118 public417 public119 view418 view127 }426 }128}427}129130// Selector: ffe4da23131contract Collection is Dummy, ERC165 {132 // Set collection property.133 //134 // @param key Property key.135 // @param value Propery value.136 //137 // Selector: setCollectionProperty(string,bytes) 2f073f66138 function setCollectionProperty(string memory key, bytes memory value)139 public140 {141 require(false, stub_error);142 key;143 value;144 dummy = 0;145 }146147 // Delete collection property.148 //149 // @param key Property key.150 //151 // Selector: deleteCollectionProperty(string) 7b7debce152 function deleteCollectionProperty(string memory key) public {153 require(false, stub_error);154 key;155 dummy = 0;156 }157158 // Get collection property.159 //160 // @dev Throws error if key not found.161 //162 // @param key Property key.163 // @return bytes The property corresponding to the key.164 //165 // Selector: collectionProperty(string) cf24fd6d166 function collectionProperty(string memory key)167 public168 view169 returns (bytes memory)170 {171 require(false, stub_error);172 key;173 dummy;174 return hex"";175 }176177 // Set the sponsor of the collection.178 //179 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.180 //181 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.182 //183 // Selector: setCollectionSponsor(address) 7623402e184 function setCollectionSponsor(address sponsor) public {185 require(false, stub_error);186 sponsor;187 dummy = 0;188 }189190 // Collection sponsorship confirmation.191 //192 // @dev After setting the sponsor for the collection, it must be confirmed with this function.193 //194 // Selector: confirmCollectionSponsorship() 3c50e97a195 function confirmCollectionSponsorship() public {196 require(false, stub_error);197 dummy = 0;198 }199200 // Set limits for the collection.201 // @dev Throws error if limit not found.202 // @param limit Name of the limit. Valid names:203 // "accountTokenOwnershipLimit",204 // "sponsoredDataSize",205 // "sponsoredDataRateLimit",206 // "tokenLimit",207 // "sponsorTransferTimeout",208 // "sponsorApproveTimeout"209 // @param value Value of the limit.210 //211 // Selector: setCollectionLimit(string,uint32) 6a3841db212 function setCollectionLimit(string memory limit, uint32 value) public {213 require(false, stub_error);214 limit;215 value;216 dummy = 0;217 }218219 // Set limits for the collection.220 // @dev Throws error if limit not found.221 // @param limit Name of the limit. Valid names:222 // "ownerCanTransfer",223 // "ownerCanDestroy",224 // "transfersEnabled"225 // @param value Value of the limit.226 //227 // Selector: setCollectionLimit(string,bool) 993b7fba228 function setCollectionLimit(string memory limit, bool value) public {229 require(false, stub_error);230 limit;231 value;232 dummy = 0;233 }234235 // Get contract address.236 //237 // Selector: contractAddress() f6b4dfb4238 function contractAddress() public view returns (address) {239 require(false, stub_error);240 dummy;241 return 0x0000000000000000000000000000000000000000;242 }243244 // Add collection admin by substrate address.245 // @param new_admin Substrate administrator address.246 //247 // Selector: addCollectionAdminSubstrate(uint256) 5730062b248 function addCollectionAdminSubstrate(uint256 newAdmin) public {249 require(false, stub_error);250 newAdmin;251 dummy = 0;252 }253254 // Remove collection admin by substrate address.255 // @param admin Substrate administrator address.256 //257 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9258 function removeCollectionAdminSubstrate(uint256 admin) public {259 require(false, stub_error);260 admin;261 dummy = 0;262 }263264 // Add collection admin.265 // @param new_admin Address of the added administrator.266 //267 // Selector: addCollectionAdmin(address) 92e462c7268 function addCollectionAdmin(address newAdmin) public {269 require(false, stub_error);270 newAdmin;271 dummy = 0;272 }273274 // Remove collection admin.275 //276 // @param new_admin Address of the removed administrator.277 //278 // Selector: removeCollectionAdmin(address) fafd7b42279 function removeCollectionAdmin(address admin) public {280 require(false, stub_error);281 admin;282 dummy = 0;283 }284285 // Toggle accessibility of collection nesting.286 //287 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'288 //289 // Selector: setCollectionNesting(bool) 112d4586290 function setCollectionNesting(bool enable) public {291 require(false, stub_error);292 enable;293 dummy = 0;294 }295296 // Toggle accessibility of collection nesting.297 //298 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'299 // @param collections Addresses of collections that will be available for nesting.300 //301 // Selector: setCollectionNesting(bool,address[]) 64872396302 function setCollectionNesting(bool enable, address[] memory collections)303 public304 {305 require(false, stub_error);306 enable;307 collections;308 dummy = 0;309 }310311 // Set the collection access method.312 // @param mode Access mode313 // 0 for Normal314 // 1 for AllowList315 //316 // Selector: setCollectionAccess(uint8) 41835d4c317 function setCollectionAccess(uint8 mode) public {318 require(false, stub_error);319 mode;320 dummy = 0;321 }322323 // Add the user to the allowed list.324 //325 // @param user Address of a trusted user.326 //327 // Selector: addToCollectionAllowList(address) 67844fe6328 function addToCollectionAllowList(address user) public {329 require(false, stub_error);330 user;331 dummy = 0;332 }333334 // Remove the user from the allowed list.335 //336 // @param user Address of a removed user.337 //338 // Selector: removeFromCollectionAllowList(address) 85c51acb339 function removeFromCollectionAllowList(address user) public {340 require(false, stub_error);341 user;342 dummy = 0;343 }344345 // Switch permission for minting.346 //347 // @param mode Enable if "true".348 //349 // Selector: setCollectionMintMode(bool) 00018e84350 function setCollectionMintMode(bool mode) public {351 require(false, stub_error);352 mode;353 dummy = 0;354 }355356 // Check that account is the owner or admin of the collection357 //358 // @param user account to verify359 // @return "true" if account is the owner or admin360 //361 // Selector: isOwnerOrAdmin(address) 9811b0c7362 function isOwnerOrAdmin(address user) public view returns (bool) {363 require(false, stub_error);364 user;365 dummy;366 return false;367 }368369 // Check that substrate account is the owner or admin of the collection370 //371 // @param user account to verify372 // @return "true" if account is the owner or admin373 //374 // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00375 function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) {376 require(false, stub_error);377 user;378 dummy;379 return false;380 }381382 // Returns collection type383 //384 // @return `Fungible` or `NFT` or `ReFungible`385 //386 // Selector: uniqueCollectionType() d34b55b8387 function uniqueCollectionType() public returns (string memory) {388 require(false, stub_error);389 dummy = 0;390 return "";391 }392393 // Changes collection owner to another account394 //395 // @dev Owner can be changed only by current owner396 // @param newOwner new owner account397 //398 // Selector: setOwner(address) 13af4035399 function setOwner(address newOwner) public {400 require(false, stub_error);401 newOwner;402 dummy = 0;403 }404405 // Changes collection owner to another substrate account406 //407 // @dev Owner can be changed only by current owner408 // @param newOwner new owner substrate account409 //410 // Selector: setOwnerSubstrate(uint256) b212138f411 function setOwnerSubstrate(uint256 newOwner) public {412 require(false, stub_error);413 newOwner;414 dummy = 0;415 }416}417428418contract UniqueFungible is429contract UniqueFungible is419 Dummy,430 Dummy,pallets/nonfungible/src/erc.rsdiffbeforeafterboth50};50};515152/// @title A contract that allows to set and delete token properties and change token property permissions.52/// @title A contract that allows to set and delete token properties and change token property permissions.53#[solidity_interface(name = "TokenProperties")]53#[solidity_interface(name = TokenProperties)]54impl<T: Config> NonfungibleHandle<T> {54impl<T: Config> NonfungibleHandle<T> {55 /// @notice Set permissions for token property.55 /// @notice Set permissions for token property.56 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.56 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.57 /// @param key Property key.57 /// @param key Property key.58 /// @param is_mutable Permission to mutate property.58 /// @param isMutable Permission to mutate property.59 /// @param collection_admin Permission to mutate property by collection admin if property is mutable.59 /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.60 /// @param token_owner Permission to mutate property by token owner if property is mutable.60 /// @param tokenOwner Permission to mutate property by token owner if property is mutable.61 fn set_token_property_permission(61 fn set_token_property_permission(62 &mut self,62 &mut self,63 caller: caller,63 caller: caller,201201202/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension202/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension203/// @dev See https://eips.ethereum.org/EIPS/eip-721203/// @dev See https://eips.ethereum.org/EIPS/eip-721204#[solidity_interface(name = "ERC721Metadata")]204#[solidity_interface(name = ERC721Metadata, expect_selector = 0x5b5e139f)]205impl<T: Config> NonfungibleHandle<T> {205impl<T: Config> NonfungibleHandle<T> {206 /// @notice A descriptive name for a collection of NFTs in this contract206 /// @notice A descriptive name for a collection of NFTs in this contract207 fn name(&self) -> Result<string> {207 fn name(&self) -> Result<string> {262262263/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension263/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension264/// @dev See https://eips.ethereum.org/EIPS/eip-721264/// @dev See https://eips.ethereum.org/EIPS/eip-721265#[solidity_interface(name = "ERC721Enumerable")]265#[solidity_interface(name = ERC721Enumerable, expect_selector = 0x780e9d63)]266impl<T: Config> NonfungibleHandle<T> {266impl<T: Config> NonfungibleHandle<T> {267 /// @notice Enumerate valid NFTs267 /// @notice Enumerate valid NFTs268 /// @param index A counter less than `totalSupply()`268 /// @param index A counter less than `totalSupply()`289289290/// @title ERC-721 Non-Fungible Token Standard290/// @title ERC-721 Non-Fungible Token Standard291/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md291/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md292#[solidity_interface(name = "ERC721", events(ERC721Events))]292#[solidity_interface(name = ERC721, events(ERC721Events), expect_selector = 0x80ac58cd)]293impl<T: Config> NonfungibleHandle<T> {293impl<T: Config> NonfungibleHandle<T> {294 /// @notice Count all NFTs assigned to an owner294 /// @notice Count all NFTs assigned to an owner295 /// @dev NFTs assigned to the zero address are considered invalid, and this295 /// @dev NFTs assigned to the zero address are considered invalid, and this316 .as_eth())316 .as_eth())317 }317 }318 /// @dev Not implemented318 /// @dev Not implemented319 #[solidity(rename_selector = "safeTransferFrom")]319 fn safe_transfer_from_with_data(320 fn safe_transfer_from_with_data(320 &mut self,321 &mut self,321 _from: address,322 _from: address,322 _to: address,323 _to: address,323 _token_id: uint256,324 _token_id: uint256,324 _data: bytes,325 _data: bytes,325 _value: value,326 ) -> Result<void> {326 ) -> Result<void> {327 // TODO: Not implemetable327 // TODO: Not implemetable328 Err("not implemented".into())328 Err("not implemented".into())333 _from: address,333 _from: address,334 _to: address,334 _to: address,335 _token_id: uint256,335 _token_id: uint256,336 _value: value,337 ) -> Result<void> {336 ) -> Result<void> {338 // TODO: Not implemetable337 // TODO: Not implemetable339 Err("not implemented".into())338 Err("not implemented".into())348 /// @param from The current owner of the NFT347 /// @param from The current owner of the NFT349 /// @param to The new owner348 /// @param to The new owner350 /// @param tokenId The NFT to transfer349 /// @param tokenId The NFT to transfer351 /// @param _value Not used for an NFT352 #[weight(<SelfWeightOf<T>>::transfer_from())]350 #[weight(<SelfWeightOf<T>>::transfer_from())]353 fn transfer_from(351 fn transfer_from(354 &mut self,352 &mut self,355 caller: caller,353 caller: caller,356 from: address,354 from: address,357 to: address,355 to: address,358 token_id: uint256,356 token_id: uint256,359 _value: value,360 ) -> Result<void> {357 ) -> Result<void> {361 let caller = T::CrossAccountId::from_eth(caller);358 let caller = T::CrossAccountId::from_eth(caller);362 let from = T::CrossAccountId::from_eth(from);359 let from = T::CrossAccountId::from_eth(from);382 &mut self,383 caller: caller,384 approved: address,385 token_id: uint256,386 _value: value,387 ) -> Result<void> {388 let caller = T::CrossAccountId::from_eth(caller);379 let caller = T::CrossAccountId::from_eth(caller);389 let approved = T::CrossAccountId::from_eth(approved);380 let approved = T::CrossAccountId::from_eth(approved);419}410}420411421/// @title ERC721 Token that can be irreversibly burned (destroyed).412/// @title ERC721 Token that can be irreversibly burned (destroyed).422#[solidity_interface(name = "ERC721Burnable")]413#[solidity_interface(name = ERC721Burnable)]423impl<T: Config> NonfungibleHandle<T> {414impl<T: Config> NonfungibleHandle<T> {424 /// @notice Burns a specific ERC721 token.415 /// @notice Burns a specific ERC721 token.425 /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized416 /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized436}427}437428438/// @title ERC721 minting logic.429/// @title ERC721 minting logic.439#[solidity_interface(name = "ERC721Mintable", events(ERC721MintableEvents))]430#[solidity_interface(name = ERC721Mintable, events(ERC721MintableEvents))]440impl<T: Config> NonfungibleHandle<T> {431impl<T: Config> NonfungibleHandle<T> {441 fn minting_finished(&self) -> Result<bool> {432 fn minting_finished(&self) -> Result<bool> {442 Ok(false)433 Ok(false)597}588}598589599/// @title Unique extensions for ERC721.590/// @title Unique extensions for ERC721.600#[solidity_interface(name = "ERC721UniqueExtensions")]591#[solidity_interface(name = ERC721UniqueExtensions)]601impl<T: Config> NonfungibleHandle<T> {592impl<T: Config> NonfungibleHandle<T> {602 /// @notice Transfer ownership of an NFT593 /// @notice Transfer ownership of an NFT603 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`594 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`604 /// is the zero address. Throws if `tokenId` is not a valid NFT.595 /// is the zero address. Throws if `tokenId` is not a valid NFT.605 /// @param to The new owner596 /// @param to The new owner606 /// @param tokenId The NFT to transfer597 /// @param tokenId The NFT to transfer607 /// @param _value Not used for an NFT608 #[weight(<SelfWeightOf<T>>::transfer())]598 #[weight(<SelfWeightOf<T>>::transfer())]609 fn transfer(599 fn transfer(&mut self, caller: caller, to: address, token_id: uint256) -> Result<void> {610 &mut self,611 caller: caller,612 to: address,613 token_id: uint256,614 _value: value,615 ) -> Result<void> {616 let caller = T::CrossAccountId::from_eth(caller);600 let caller = T::CrossAccountId::from_eth(caller);617 let to = T::CrossAccountId::from_eth(to);601 let to = T::CrossAccountId::from_eth(to);630 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.614 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.631 /// @param from The current owner of the NFT615 /// @param from The current owner of the NFT632 /// @param tokenId The NFT to transfer616 /// @param tokenId The NFT to transfer633 /// @param _value Not used for an NFT634 #[weight(<SelfWeightOf<T>>::burn_from())]617 #[weight(<SelfWeightOf<T>>::burn_from())]635 fn burn_from(618 fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result<void> {636 &mut self,637 caller: caller,638 from: address,639 token_id: uint256,640 _value: value,641 ) -> Result<void> {642 let caller = T::CrossAccountId::from_eth(caller);619 let caller = T::CrossAccountId::from_eth(caller);643 let from = T::CrossAccountId::from_eth(from);620 let from = T::CrossAccountId::from_eth(from);751}728}752729753#[solidity_interface(730#[solidity_interface(754 name = "UniqueNFT",731 name = UniqueNFT,755 is(732 is(756 ERC721,733 ERC721,757 ERC721Metadata,734 ERC721Metadata,758 ERC721Enumerable,735 ERC721Enumerable,759 ERC721UniqueExtensions,736 ERC721UniqueExtensions,760 ERC721Mintable,737 ERC721Mintable,761 ERC721Burnable,738 ERC721Burnable,762 via("CollectionHandle<T>", common_mut, Collection),739 Collection(common_mut, CollectionHandle<T>),763 TokenProperties,740 TokenProperties,764 )741 )765)]742)]pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8 uint256 field_0;9 string field_1;10}11512// Common stubs holder6/// @dev common stubs holder13contract Dummy {7contract Dummy {14 uint8 dummy;8 uint8 dummy;15 string stub_error = "this contract is implemented in native";9 string stub_error = "this contract is implemented in native";27 }21 }28}22}292330// Inline24/// @title A contract that allows to set and delete token properties and change token property permissions.25/// @dev the ERC-165 identifier for this interface is 0x4136937726contract TokenProperties is Dummy, ERC165 {27 /// @notice Set permissions for token property.28 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.29 /// @param key Property key.30 /// @param isMutable Permission to mutate property.31 /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.32 /// @param tokenOwner Permission to mutate property by token owner if property is mutable.33 /// @dev EVM selector for this function is: 0x222d97fa,34 /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)35 function setTokenPropertyPermission(36 string memory key,37 bool isMutable,38 bool collectionAdmin,39 bool tokenOwner40 ) public {41 require(false, stub_error);42 key;43 isMutable;44 collectionAdmin;45 tokenOwner;46 dummy = 0;47 }4849 /// @notice Set token property value.50 /// @dev Throws error if `msg.sender` has no permission to edit the property.51 /// @param tokenId ID of the token.52 /// @param key Property key.53 /// @param value Property value.54 /// @dev EVM selector for this function is: 0x1752d67b,55 /// or in textual repr: setProperty(uint256,string,bytes)56 function setProperty(57 uint256 tokenId,58 string memory key,59 bytes memory value60 ) public {61 require(false, stub_error);62 tokenId;63 key;64 value;65 dummy = 0;66 }6768 /// @notice Delete token property value.69 /// @dev Throws error if `msg.sender` has no permission to edit the property.70 /// @param tokenId ID of the token.71 /// @param key Property key.72 /// @dev EVM selector for this function is: 0x066111d1,73 /// or in textual repr: deleteProperty(uint256,string)74 function deleteProperty(uint256 tokenId, string memory key) public {75 require(false, stub_error);76 tokenId;77 key;78 dummy = 0;79 }8081 /// @notice Get token property value.82 /// @dev Throws error if key not found83 /// @param tokenId ID of the token.84 /// @param key Property key.85 /// @return Property value bytes86 /// @dev EVM selector for this function is: 0x7228c327,87 /// or in textual repr: property(uint256,string)88 function property(uint256 tokenId, string memory key)89 public90 view91 returns (bytes memory)92 {93 require(false, stub_error);94 tokenId;95 key;96 dummy;97 return hex"";98 }99}100101/// @title A contract that allows you to work with collections.102/// @dev the ERC-165 identifier for this interface is 0xffe4da23103contract Collection is Dummy, ERC165 {104 /// Set collection property.105 ///106 /// @param key Property key.107 /// @param value Propery value.108 /// @dev EVM selector for this function is: 0x2f073f66,109 /// or in textual repr: setCollectionProperty(string,bytes)110 function setCollectionProperty(string memory key, bytes memory value)111 public112 {113 require(false, stub_error);114 key;115 value;116 dummy = 0;117 }118119 /// Delete collection property.120 ///121 /// @param key Property key.122 /// @dev EVM selector for this function is: 0x7b7debce,123 /// or in textual repr: deleteCollectionProperty(string)124 function deleteCollectionProperty(string memory key) public {125 require(false, stub_error);126 key;127 dummy = 0;128 }129130 /// Get collection property.131 ///132 /// @dev Throws error if key not found.133 ///134 /// @param key Property key.135 /// @return bytes The property corresponding to the key.136 /// @dev EVM selector for this function is: 0xcf24fd6d,137 /// or in textual repr: collectionProperty(string)138 function collectionProperty(string memory key)139 public140 view141 returns (bytes memory)142 {143 require(false, stub_error);144 key;145 dummy;146 return hex"";147 }148149 /// Set the sponsor of the collection.150 ///151 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.152 ///153 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.154 /// @dev EVM selector for this function is: 0x7623402e,155 /// or in textual repr: setCollectionSponsor(address)156 function setCollectionSponsor(address sponsor) public {157 require(false, stub_error);158 sponsor;159 dummy = 0;160 }161162 /// Collection sponsorship confirmation.163 ///164 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.165 /// @dev EVM selector for this function is: 0x3c50e97a,166 /// or in textual repr: confirmCollectionSponsorship()167 function confirmCollectionSponsorship() public {168 require(false, stub_error);169 dummy = 0;170 }171172 /// Set limits for the collection.173 /// @dev Throws error if limit not found.174 /// @param limit Name of the limit. Valid names:175 /// "accountTokenOwnershipLimit",176 /// "sponsoredDataSize",177 /// "sponsoredDataRateLimit",178 /// "tokenLimit",179 /// "sponsorTransferTimeout",180 /// "sponsorApproveTimeout"181 /// @param value Value of the limit.182 /// @dev EVM selector for this function is: 0x6a3841db,183 /// or in textual repr: setCollectionLimit(string,uint32)184 function setCollectionLimit(string memory limit, uint32 value) public {185 require(false, stub_error);186 limit;187 value;188 dummy = 0;189 }190191 /// Set limits for the collection.192 /// @dev Throws error if limit not found.193 /// @param limit Name of the limit. Valid names:194 /// "ownerCanTransfer",195 /// "ownerCanDestroy",196 /// "transfersEnabled"197 /// @param value Value of the limit.198 /// @dev EVM selector for this function is: 0x993b7fba,199 /// or in textual repr: setCollectionLimit(string,bool)200 function setCollectionLimit(string memory limit, bool value) public {201 require(false, stub_error);202 limit;203 value;204 dummy = 0;205 }206207 /// Get contract address.208 /// @dev EVM selector for this function is: 0xf6b4dfb4,209 /// or in textual repr: contractAddress()210 function contractAddress() public view returns (address) {211 require(false, stub_error);212 dummy;213 return 0x0000000000000000000000000000000000000000;214 }215216 /// Add collection admin by substrate address.217 /// @param newAdmin Substrate administrator address.218 /// @dev EVM selector for this function is: 0x5730062b,219 /// or in textual repr: addCollectionAdminSubstrate(uint256)220 function addCollectionAdminSubstrate(uint256 newAdmin) public {221 require(false, stub_error);222 newAdmin;223 dummy = 0;224 }225226 /// Remove collection admin by substrate address.227 /// @param admin Substrate administrator address.228 /// @dev EVM selector for this function is: 0x4048fcf9,229 /// or in textual repr: removeCollectionAdminSubstrate(uint256)230 function removeCollectionAdminSubstrate(uint256 admin) public {231 require(false, stub_error);232 admin;233 dummy = 0;234 }235236 /// Add collection admin.237 /// @param newAdmin Address of the added administrator.238 /// @dev EVM selector for this function is: 0x92e462c7,239 /// or in textual repr: addCollectionAdmin(address)240 function addCollectionAdmin(address newAdmin) public {241 require(false, stub_error);242 newAdmin;243 dummy = 0;244 }245246 /// Remove collection admin.247 ///248 /// @param admin Address of the removed administrator.249 /// @dev EVM selector for this function is: 0xfafd7b42,250 /// or in textual repr: removeCollectionAdmin(address)251 function removeCollectionAdmin(address admin) public {252 require(false, stub_error);253 admin;254 dummy = 0;255 }256257 /// Toggle accessibility of collection nesting.258 ///259 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'260 /// @dev EVM selector for this function is: 0x112d4586,261 /// or in textual repr: setCollectionNesting(bool)262 function setCollectionNesting(bool enable) public {263 require(false, stub_error);264 enable;265 dummy = 0;266 }267268 /// Toggle accessibility of collection nesting.269 ///270 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'271 /// @param collections Addresses of collections that will be available for nesting.272 /// @dev EVM selector for this function is: 0x64872396,273 /// or in textual repr: setCollectionNesting(bool,address[])274 function setCollectionNesting(bool enable, address[] memory collections)275 public276 {277 require(false, stub_error);278 enable;279 collections;280 dummy = 0;281 }282283 /// Set the collection access method.284 /// @param mode Access mode285 /// 0 for Normal286 /// 1 for AllowList287 /// @dev EVM selector for this function is: 0x41835d4c,288 /// or in textual repr: setCollectionAccess(uint8)289 function setCollectionAccess(uint8 mode) public {290 require(false, stub_error);291 mode;292 dummy = 0;293 }294295 /// Add the user to the allowed list.296 ///297 /// @param user Address of a trusted user.298 /// @dev EVM selector for this function is: 0x67844fe6,299 /// or in textual repr: addToCollectionAllowList(address)300 function addToCollectionAllowList(address user) public {301 require(false, stub_error);302 user;303 dummy = 0;304 }305306 /// Remove the user from the allowed list.307 ///308 /// @param user Address of a removed user.309 /// @dev EVM selector for this function is: 0x85c51acb,310 /// or in textual repr: removeFromCollectionAllowList(address)311 function removeFromCollectionAllowList(address user) public {312 require(false, stub_error);313 user;314 dummy = 0;315 }316317 /// Switch permission for minting.318 ///319 /// @param mode Enable if "true".320 /// @dev EVM selector for this function is: 0x00018e84,321 /// or in textual repr: setCollectionMintMode(bool)322 function setCollectionMintMode(bool mode) public {323 require(false, stub_error);324 mode;325 dummy = 0;326 }327328 /// Check that account is the owner or admin of the collection329 ///330 /// @param user account to verify331 /// @return "true" if account is the owner or admin332 /// @dev EVM selector for this function is: 0x9811b0c7,333 /// or in textual repr: isOwnerOrAdmin(address)334 function isOwnerOrAdmin(address user) public view returns (bool) {335 require(false, stub_error);336 user;337 dummy;338 return false;339 }340341 /// Check that substrate account is the owner or admin of the collection342 ///343 /// @param user account to verify344 /// @return "true" if account is the owner or admin345 /// @dev EVM selector for this function is: 0x68910e00,346 /// or in textual repr: isOwnerOrAdminSubstrate(uint256)347 function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) {348 require(false, stub_error);349 user;350 dummy;351 return false;352 }353354 /// Returns collection type355 ///356 /// @return `Fungible` or `NFT` or `ReFungible`357 /// @dev EVM selector for this function is: 0xd34b55b8,358 /// or in textual repr: uniqueCollectionType()359 function uniqueCollectionType() public returns (string memory) {360 require(false, stub_error);361 dummy = 0;362 return "";363 }364365 /// Changes collection owner to another account366 ///367 /// @dev Owner can be changed only by current owner368 /// @param newOwner new owner account369 /// @dev EVM selector for this function is: 0x13af4035,370 /// or in textual repr: setOwner(address)371 function setOwner(address newOwner) public {372 require(false, stub_error);373 newOwner;374 dummy = 0;375 }376377 /// Changes collection owner to another substrate account378 ///379 /// @dev Owner can be changed only by current owner380 /// @param newOwner new owner substrate account381 /// @dev EVM selector for this function is: 0xb212138f,382 /// or in textual repr: setOwnerSubstrate(uint256)383 function setOwnerSubstrate(uint256 newOwner) public {384 require(false, stub_error);385 newOwner;386 dummy = 0;387 }388}389390/// @title ERC721 Token that can be irreversibly burned (destroyed).391/// @dev the ERC-165 identifier for this interface is 0x42966c68392contract ERC721Burnable is Dummy, ERC165 {393 /// @notice Burns a specific ERC721 token.394 /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized395 /// operator of the current owner.396 /// @param tokenId The NFT to approve397 /// @dev EVM selector for this function is: 0x42966c68,398 /// or in textual repr: burn(uint256)399 function burn(uint256 tokenId) public {400 require(false, stub_error);401 tokenId;402 dummy = 0;403 }404}405406/// @dev inlined interface407contract ERC721MintableEvents {408 event MintingFinished();409}410411/// @title ERC721 minting logic.412/// @dev the ERC-165 identifier for this interface is 0x68ccfe89413contract ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {414 /// @dev EVM selector for this function is: 0x05d2035b,415 /// or in textual repr: mintingFinished()416 function mintingFinished() public view returns (bool) {417 require(false, stub_error);418 dummy;419 return false;420 }421422 /// @notice Function to mint token.423 /// @dev `tokenId` should be obtained with `nextTokenId` method,424 /// unlike standard, you can't specify it manually425 /// @param to The new owner426 /// @param tokenId ID of the minted NFT427 /// @dev EVM selector for this function is: 0x40c10f19,428 /// or in textual repr: mint(address,uint256)429 function mint(address to, uint256 tokenId) public returns (bool) {430 require(false, stub_error);431 to;432 tokenId;433 dummy = 0;434 return false;435 }436437 /// @notice Function to mint token with the given tokenUri.438 /// @dev `tokenId` should be obtained with `nextTokenId` method,439 /// unlike standard, you can't specify it manually440 /// @param to The new owner441 /// @param tokenId ID of the minted NFT442 /// @param tokenUri Token URI that would be stored in the NFT properties443 /// @dev EVM selector for this function is: 0x50bb4e7f,444 /// or in textual repr: mintWithTokenURI(address,uint256,string)445 function mintWithTokenURI(446 address to,447 uint256 tokenId,448 string memory tokenUri449 ) public returns (bool) {450 require(false, stub_error);451 to;452 tokenId;453 tokenUri;454 dummy = 0;455 return false;456 }457458 /// @dev Not implemented459 /// @dev EVM selector for this function is: 0x7d64bcb4,460 /// or in textual repr: finishMinting()461 function finishMinting() public returns (bool) {462 require(false, stub_error);463 dummy = 0;464 return false;465 }466}467468/// @title Unique extensions for ERC721.469/// @dev the ERC-165 identifier for this interface is 0xd74d154f470contract ERC721UniqueExtensions is Dummy, ERC165 {471 /// @notice Transfer ownership of an NFT472 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`473 /// is the zero address. Throws if `tokenId` is not a valid NFT.474 /// @param to The new owner475 /// @param tokenId The NFT to transfer476 /// @dev EVM selector for this function is: 0xa9059cbb,477 /// or in textual repr: transfer(address,uint256)478 function transfer(address to, uint256 tokenId) public {479 require(false, stub_error);480 to;481 tokenId;482 dummy = 0;483 }484485 /// @notice Burns a specific ERC721 token.486 /// @dev Throws unless `msg.sender` is the current owner or an authorized487 /// operator for this NFT. Throws if `from` is not the current owner. Throws488 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.489 /// @param from The current owner of the NFT490 /// @param tokenId The NFT to transfer491 /// @dev EVM selector for this function is: 0x79cc6790,492 /// or in textual repr: burnFrom(address,uint256)493 function burnFrom(address from, uint256 tokenId) public {494 require(false, stub_error);495 from;496 tokenId;497 dummy = 0;498 }499500 /// @notice Returns next free NFT ID.501 /// @dev EVM selector for this function is: 0x75794a3c,502 /// or in textual repr: nextTokenId()503 function nextTokenId() public view returns (uint256) {504 require(false, stub_error);505 dummy;506 return 0;507 }508509 /// @notice Function to mint multiple tokens.510 /// @dev `tokenIds` should be an array of consecutive numbers and first number511 /// should be obtained with `nextTokenId` method512 /// @param to The new owner513 /// @param tokenIds IDs of the minted NFTs514 /// @dev EVM selector for this function is: 0x44a9945e,515 /// or in textual repr: mintBulk(address,uint256[])516 function mintBulk(address to, uint256[] memory tokenIds)517 public518 returns (bool)519 {520 require(false, stub_error);521 to;522 tokenIds;523 dummy = 0;524 return false;525 }526527 /// @notice Function to mint multiple tokens with the given tokenUris.528 /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive529 /// numbers and first number should be obtained with `nextTokenId` method530 /// @param to The new owner531 /// @param tokens array of pairs of token ID and token URI for minted tokens532 /// @dev EVM selector for this function is: 0x36543006,533 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])534 function mintBulkWithTokenURI(address to, Tuple8[] memory tokens)535 public536 returns (bool)537 {538 require(false, stub_error);539 to;540 tokens;541 dummy = 0;542 return false;543 }544}545546/// @dev anonymous struct547struct Tuple8 {548 uint256 field_0;549 string field_1;550}551552/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension553/// @dev See https://eips.ethereum.org/EIPS/eip-721554/// @dev the ERC-165 identifier for this interface is 0x780e9d63555contract ERC721Enumerable is Dummy, ERC165 {556 /// @notice Enumerate valid NFTs557 /// @param index A counter less than `totalSupply()`558 /// @return The token identifier for the `index`th NFT,559 /// (sort order not specified)560 /// @dev EVM selector for this function is: 0x4f6ccce7,561 /// or in textual repr: tokenByIndex(uint256)562 function tokenByIndex(uint256 index) public view returns (uint256) {563 require(false, stub_error);564 index;565 dummy;566 return 0;567 }568569 /// @dev Not implemented570 /// @dev EVM selector for this function is: 0x2f745c59,571 /// or in textual repr: tokenOfOwnerByIndex(address,uint256)572 function tokenOfOwnerByIndex(address owner, uint256 index)573 public574 view575 returns (uint256)576 {577 require(false, stub_error);578 owner;579 index;580 dummy;581 return 0;582 }583584 /// @notice Count NFTs tracked by this contract585 /// @return A count of valid NFTs tracked by this contract, where each one of586 /// them has an assigned and queryable owner not equal to the zero address587 /// @dev EVM selector for this function is: 0x18160ddd,588 /// or in textual repr: totalSupply()589 function totalSupply() public view returns (uint256) {590 require(false, stub_error);591 dummy;592 return 0;593 }594}595596/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension597/// @dev See https://eips.ethereum.org/EIPS/eip-721598/// @dev the ERC-165 identifier for this interface is 0x5b5e139f599contract ERC721Metadata is Dummy, ERC165 {600 /// @notice A descriptive name for a collection of NFTs in this contract601 /// @dev EVM selector for this function is: 0x06fdde03,602 /// or in textual repr: name()603 function name() public view returns (string memory) {604 require(false, stub_error);605 dummy;606 return "";607 }608609 /// @notice An abbreviated name for NFTs in this contract610 /// @dev EVM selector for this function is: 0x95d89b41,611 /// or in textual repr: symbol()612 function symbol() public view returns (string memory) {613 require(false, stub_error);614 dummy;615 return "";616 }617618 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.619 ///620 /// @dev If the token has a `url` property and it is not empty, it is returned.621 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.622 /// If the collection property `baseURI` is empty or absent, return "" (empty string)623 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix624 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).625 ///626 /// @return token's const_metadata627 /// @dev EVM selector for this function is: 0xc87b56dd,628 /// or in textual repr: tokenURI(uint256)629 function tokenURI(uint256 tokenId) public view returns (string memory) {630 require(false, stub_error);631 tokenId;632 dummy;633 return "";634 }635}636637/// @dev inlined interface31contract ERC721Events {638contract ERC721Events {32 event Transfer(639 event Transfer(33 address indexed from,640 address indexed from,46 );653 );47}654}4865549// Inline656/// @title ERC-721 Non-Fungible Token Standard50contract ERC721MintableEvents {657/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md51 event MintingFinished();658/// @dev the ERC-165 identifier for this interface is 0x80ac58cd52}5354// Selector: 4136937755contract TokenProperties is Dummy, ERC165 {56 // @notice Set permissions for token property.57 // @dev Throws error if `msg.sender` is not admin or owner of the collection.58 // @param key Property key.59 // @param is_mutable Permission to mutate property.60 // @param collection_admin Permission to mutate property by collection admin if property is mutable.61 // @param token_owner Permission to mutate property by token owner if property is mutable.62 //63 // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa64 function setTokenPropertyPermission(65 string memory key,66 bool isMutable,67 bool collectionAdmin,68 bool tokenOwner69 ) public {70 require(false, stub_error);71 key;72 isMutable;73 collectionAdmin;74 tokenOwner;75 dummy = 0;76 }7778 // @notice Set token property value.79 // @dev Throws error if `msg.sender` has no permission to edit the property.80 // @param tokenId ID of the token.81 // @param key Property key.82 // @param value Property value.83 //84 // Selector: setProperty(uint256,string,bytes) 1752d67b85 function setProperty(86 uint256 tokenId,87 string memory key,88 bytes memory value89 ) public {90 require(false, stub_error);91 tokenId;92 key;93 value;94 dummy = 0;95 }9697 // @notice Delete token property value.98 // @dev Throws error if `msg.sender` has no permission to edit the property.99 // @param tokenId ID of the token.100 // @param key Property key.101 //102 // Selector: deleteProperty(uint256,string) 066111d1103 function deleteProperty(uint256 tokenId, string memory key) public {104 require(false, stub_error);105 tokenId;106 key;107 dummy = 0;108 }109110 // @notice Get token property value.111 // @dev Throws error if key not found112 // @param tokenId ID of the token.113 // @param key Property key.114 // @return Property value bytes115 //116 // Selector: property(uint256,string) 7228c327117 function property(uint256 tokenId, string memory key)118 public119 view120 returns (bytes memory)121 {122 require(false, stub_error);123 tokenId;124 key;125 dummy;126 return hex"";127 }128}129130// Selector: 42966c68131contract ERC721Burnable is Dummy, ERC165 {132 // @notice Burns a specific ERC721 token.133 // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized134 // operator of the current owner.135 // @param tokenId The NFT to approve136 //137 // Selector: burn(uint256) 42966c68138 function burn(uint256 tokenId) public {139 require(false, stub_error);140 tokenId;141 dummy = 0;142 }143}144145// Selector: 58800161146contract ERC721 is Dummy, ERC165, ERC721Events {659contract ERC721 is Dummy, ERC165, ERC721Events {147 // @notice Count all NFTs assigned to an owner660 /// @notice Count all NFTs assigned to an owner148 // @dev NFTs assigned to the zero address are considered invalid, and this661 /// @dev NFTs assigned to the zero address are considered invalid, and this149 // function throws for queries about the zero address.662 /// function throws for queries about the zero address.150 // @param owner An address for whom to query the balance663 /// @param owner An address for whom to query the balance151 // @return The number of NFTs owned by `owner`, possibly zero664 /// @return The number of NFTs owned by `owner`, possibly zero152 //665 /// @dev EVM selector for this function is: 0x70a08231,153 // Selector: balanceOf(address) 70a08231666 /// or in textual repr: balanceOf(address)154 function balanceOf(address owner) public view returns (uint256) {667 function balanceOf(address owner) public view returns (uint256) {155 require(false, stub_error);668 require(false, stub_error);156 owner;669 owner;157 dummy;670 dummy;158 return 0;671 return 0;159 }672 }160673161 // @notice Find the owner of an NFT674 /// @notice Find the owner of an NFT162 // @dev NFTs assigned to zero address are considered invalid, and queries675 /// @dev NFTs assigned to zero address are considered invalid, and queries163 // about them do throw.676 /// about them do throw.164 // @param tokenId The identifier for an NFT677 /// @param tokenId The identifier for an NFT165 // @return The address of the owner of the NFT678 /// @return The address of the owner of the NFT166 //679 /// @dev EVM selector for this function is: 0x6352211e,167 // Selector: ownerOf(uint256) 6352211e680 /// or in textual repr: ownerOf(uint256)168 function ownerOf(uint256 tokenId) public view returns (address) {681 function ownerOf(uint256 tokenId) public view returns (address) {169 require(false, stub_error);682 require(false, stub_error);170 tokenId;683 tokenId;171 dummy;684 dummy;172 return 0x0000000000000000000000000000000000000000;685 return 0x0000000000000000000000000000000000000000;173 }686 }174687175 // @dev Not implemented688 /// @dev Not implemented176 //689 /// @dev EVM selector for this function is: 0xb88d4fde,177 // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672690 /// or in textual repr: safeTransferFrom(address,address,uint256,bytes)178 function safeTransferFromWithData(691 function safeTransferFrom(179 address from,692 address from,180 address to,693 address to,181 uint256 tokenId,694 uint256 tokenId,189 dummy = 0;702 dummy = 0;190 }703 }191704192 // @dev Not implemented705 /// @dev Not implemented193 //706 /// @dev EVM selector for this function is: 0x42842e0e,194 // Selector: safeTransferFrom(address,address,uint256) 42842e0e707 /// or in textual repr: safeTransferFrom(address,address,uint256)195 function safeTransferFrom(708 function safeTransferFrom(196 address from,709 address from,197 address to,710 address to,204 dummy = 0;717 dummy = 0;205 }718 }206719207 // @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE720 /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE208 // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE721 /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE209 // THEY MAY BE PERMANENTLY LOST722 /// THEY MAY BE PERMANENTLY LOST210 // @dev Throws unless `msg.sender` is the current owner or an authorized723 /// @dev Throws unless `msg.sender` is the current owner or an authorized211 // operator for this NFT. Throws if `from` is not the current owner. Throws724 /// operator for this NFT. Throws if `from` is not the current owner. Throws212 // if `to` is the zero address. Throws if `tokenId` is not a valid NFT.725 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.213 // @param from The current owner of the NFT726 /// @param from The current owner of the NFT214 // @param to The new owner727 /// @param to The new owner215 // @param tokenId The NFT to transfer728 /// @param tokenId The NFT to transfer216 // @param _value Not used for an NFT729 /// @dev EVM selector for this function is: 0x23b872dd,217 //218 // Selector: transferFrom(address,address,uint256) 23b872dd730 /// or in textual repr: transferFrom(address,address,uint256)219 function transferFrom(731 function transferFrom(220 address from,732 address from,221 address to,733 address to,228 dummy = 0;740 dummy = 0;229 }741 }230742231 // @notice Set or reaffirm the approved address for an NFT743 /// @notice Set or reaffirm the approved address for an NFT232 // @dev The zero address indicates there is no approved address.744 /// @dev The zero address indicates there is no approved address.233 // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized745 /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized234 // operator of the current owner.746 /// operator of the current owner.235 // @param approved The new approved NFT controller747 /// @param approved The new approved NFT controller236 // @param tokenId The NFT to approve748 /// @param tokenId The NFT to approve237 //749 /// @dev EVM selector for this function is: 0x095ea7b3,238 // Selector: approve(address,uint256) 095ea7b3750 /// or in textual repr: approve(address,uint256)239 function approve(address approved, uint256 tokenId) public {751 function approve(address approved, uint256 tokenId) public {240 require(false, stub_error);752 require(false, stub_error);241 approved;753 approved;242 tokenId;754 tokenId;243 dummy = 0;755 dummy = 0;244 }756 }245757246 // @dev Not implemented758 /// @dev Not implemented247 //759 /// @dev EVM selector for this function is: 0xa22cb465,248 // Selector: setApprovalForAll(address,bool) a22cb465760 /// or in textual repr: setApprovalForAll(address,bool)249 function setApprovalForAll(address operator, bool approved) public {761 function setApprovalForAll(address operator, bool approved) public {250 require(false, stub_error);762 require(false, stub_error);251 operator;763 operator;252 approved;764 approved;253 dummy = 0;765 dummy = 0;254 }766 }255767256 // @dev Not implemented768 /// @dev Not implemented257 //769 /// @dev EVM selector for this function is: 0x081812fc,258 // Selector: getApproved(uint256) 081812fc770 /// or in textual repr: getApproved(uint256)259 function getApproved(uint256 tokenId) public view returns (address) {771 function getApproved(uint256 tokenId) public view returns (address) {260 require(false, stub_error);772 require(false, stub_error);261 tokenId;773 tokenId;262 dummy;774 dummy;263 return 0x0000000000000000000000000000000000000000;775 return 0x0000000000000000000000000000000000000000;264 }776 }265777266 // @dev Not implemented778 /// @dev Not implemented267 //779 /// @dev EVM selector for this function is: 0xe985e9c5,268 // Selector: isApprovedForAll(address,address) e985e9c5780 /// or in textual repr: isApprovedForAll(address,address)269 function isApprovedForAll(address owner, address operator)781 function isApprovedForAll(address owner, address operator)270 public782 public271 view783 view279 }791 }280}792}281282// Selector: 5b5e139f283contract ERC721Metadata is Dummy, ERC165 {284 // @notice A descriptive name for a collection of NFTs in this contract285 //286 // Selector: name() 06fdde03287 function name() public view returns (string memory) {288 require(false, stub_error);289 dummy;290 return "";291 }292293 // @notice An abbreviated name for NFTs in this contract294 //295 // Selector: symbol() 95d89b41296 function symbol() public view returns (string memory) {297 require(false, stub_error);298 dummy;299 return "";300 }301302 // @notice A distinct Uniform Resource Identifier (URI) for a given asset.303 //304 // @dev If the token has a `url` property and it is not empty, it is returned.305 // Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.306 // If the collection property `baseURI` is empty or absent, return "" (empty string)307 // otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix308 // otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).309 //310 // @return token's const_metadata311 //312 // Selector: tokenURI(uint256) c87b56dd313 function tokenURI(uint256 tokenId) public view returns (string memory) {314 require(false, stub_error);315 tokenId;316 dummy;317 return "";318 }319}320321// Selector: 68ccfe89322contract ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {323 // Selector: mintingFinished() 05d2035b324 function mintingFinished() public view returns (bool) {325 require(false, stub_error);326 dummy;327 return false;328 }329330 // @notice Function to mint token.331 // @dev `tokenId` should be obtained with `nextTokenId` method,332 // unlike standard, you can't specify it manually333 // @param to The new owner334 // @param tokenId ID of the minted NFT335 //336 // Selector: mint(address,uint256) 40c10f19337 function mint(address to, uint256 tokenId) public returns (bool) {338 require(false, stub_error);339 to;340 tokenId;341 dummy = 0;342 return false;343 }344345 // @notice Function to mint token with the given tokenUri.346 // @dev `tokenId` should be obtained with `nextTokenId` method,347 // unlike standard, you can't specify it manually348 // @param to The new owner349 // @param tokenId ID of the minted NFT350 // @param tokenUri Token URI that would be stored in the NFT properties351 //352 // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f353 function mintWithTokenURI(354 address to,355 uint256 tokenId,356 string memory tokenUri357 ) public returns (bool) {358 require(false, stub_error);359 to;360 tokenId;361 tokenUri;362 dummy = 0;363 return false;364 }365366 // @dev Not implemented367 //368 // Selector: finishMinting() 7d64bcb4369 function finishMinting() public returns (bool) {370 require(false, stub_error);371 dummy = 0;372 return false;373 }374}375376// Selector: 780e9d63377contract ERC721Enumerable is Dummy, ERC165 {378 // @notice Enumerate valid NFTs379 // @param index A counter less than `totalSupply()`380 // @return The token identifier for the `index`th NFT,381 // (sort order not specified)382 //383 // Selector: tokenByIndex(uint256) 4f6ccce7384 function tokenByIndex(uint256 index) public view returns (uint256) {385 require(false, stub_error);386 index;387 dummy;388 return 0;389 }390391 // @dev Not implemented392 //393 // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59394 function tokenOfOwnerByIndex(address owner, uint256 index)395 public396 view397 returns (uint256)398 {399 require(false, stub_error);400 owner;401 index;402 dummy;403 return 0;404 }405406 // @notice Count NFTs tracked by this contract407 // @return A count of valid NFTs tracked by this contract, where each one of408 // them has an assigned and queryable owner not equal to the zero address409 //410 // Selector: totalSupply() 18160ddd411 function totalSupply() public view returns (uint256) {412 require(false, stub_error);413 dummy;414 return 0;415 }416}417418// Selector: d74d154f419contract ERC721UniqueExtensions is Dummy, ERC165 {420 // @notice Transfer ownership of an NFT421 // @dev Throws unless `msg.sender` is the current owner. Throws if `to`422 // is the zero address. Throws if `tokenId` is not a valid NFT.423 // @param to The new owner424 // @param tokenId The NFT to transfer425 // @param _value Not used for an NFT426 //427 // Selector: transfer(address,uint256) a9059cbb428 function transfer(address to, uint256 tokenId) public {429 require(false, stub_error);430 to;431 tokenId;432 dummy = 0;433 }434435 // @notice Burns a specific ERC721 token.436 // @dev Throws unless `msg.sender` is the current owner or an authorized437 // operator for this NFT. Throws if `from` is not the current owner. Throws438 // if `to` is the zero address. Throws if `tokenId` is not a valid NFT.439 // @param from The current owner of the NFT440 // @param tokenId The NFT to transfer441 // @param _value Not used for an NFT442 //443 // Selector: burnFrom(address,uint256) 79cc6790444 function burnFrom(address from, uint256 tokenId) public {445 require(false, stub_error);446 from;447 tokenId;448 dummy = 0;449 }450451 // @notice Returns next free NFT ID.452 //453 // Selector: nextTokenId() 75794a3c454 function nextTokenId() public view returns (uint256) {455 require(false, stub_error);456 dummy;457 return 0;458 }459460 // @notice Function to mint multiple tokens.461 // @dev `tokenIds` should be an array of consecutive numbers and first number462 // should be obtained with `nextTokenId` method463 // @param to The new owner464 // @param tokenIds IDs of the minted NFTs465 //466 // Selector: mintBulk(address,uint256[]) 44a9945e467 function mintBulk(address to, uint256[] memory tokenIds)468 public469 returns (bool)470 {471 require(false, stub_error);472 to;473 tokenIds;474 dummy = 0;475 return false;476 }477478 // @notice Function to mint multiple tokens with the given tokenUris.479 // @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive480 // numbers and first number should be obtained with `nextTokenId` method481 // @param to The new owner482 // @param tokens array of pairs of token ID and token URI for minted tokens483 //484 // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006485 function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)486 public487 returns (bool)488 {489 require(false, stub_error);490 to;491 tokens;492 dummy = 0;493 return false;494 }495}496497// Selector: ffe4da23498contract Collection is Dummy, ERC165 {499 // Set collection property.500 //501 // @param key Property key.502 // @param value Propery value.503 //504 // Selector: setCollectionProperty(string,bytes) 2f073f66505 function setCollectionProperty(string memory key, bytes memory value)506 public507 {508 require(false, stub_error);509 key;510 value;511 dummy = 0;512 }513514 // Delete collection property.515 //516 // @param key Property key.517 //518 // Selector: deleteCollectionProperty(string) 7b7debce519 function deleteCollectionProperty(string memory key) public {520 require(false, stub_error);521 key;522 dummy = 0;523 }524525 // Get collection property.526 //527 // @dev Throws error if key not found.528 //529 // @param key Property key.530 // @return bytes The property corresponding to the key.531 //532 // Selector: collectionProperty(string) cf24fd6d533 function collectionProperty(string memory key)534 public535 view536 returns (bytes memory)537 {538 require(false, stub_error);539 key;540 dummy;541 return hex"";542 }543544 // Set the sponsor of the collection.545 //546 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.547 //548 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.549 //550 // Selector: setCollectionSponsor(address) 7623402e551 function setCollectionSponsor(address sponsor) public {552 require(false, stub_error);553 sponsor;554 dummy = 0;555 }556557 // Collection sponsorship confirmation.558 //559 // @dev After setting the sponsor for the collection, it must be confirmed with this function.560 //561 // Selector: confirmCollectionSponsorship() 3c50e97a562 function confirmCollectionSponsorship() public {563 require(false, stub_error);564 dummy = 0;565 }566567 // Set limits for the collection.568 // @dev Throws error if limit not found.569 // @param limit Name of the limit. Valid names:570 // "accountTokenOwnershipLimit",571 // "sponsoredDataSize",572 // "sponsoredDataRateLimit",573 // "tokenLimit",574 // "sponsorTransferTimeout",575 // "sponsorApproveTimeout"576 // @param value Value of the limit.577 //578 // Selector: setCollectionLimit(string,uint32) 6a3841db579 function setCollectionLimit(string memory limit, uint32 value) public {580 require(false, stub_error);581 limit;582 value;583 dummy = 0;584 }585586 // Set limits for the collection.587 // @dev Throws error if limit not found.588 // @param limit Name of the limit. Valid names:589 // "ownerCanTransfer",590 // "ownerCanDestroy",591 // "transfersEnabled"592 // @param value Value of the limit.593 //594 // Selector: setCollectionLimit(string,bool) 993b7fba595 function setCollectionLimit(string memory limit, bool value) public {596 require(false, stub_error);597 limit;598 value;599 dummy = 0;600 }601602 // Get contract address.603 //604 // Selector: contractAddress() f6b4dfb4605 function contractAddress() public view returns (address) {606 require(false, stub_error);607 dummy;608 return 0x0000000000000000000000000000000000000000;609 }610611 // Add collection admin by substrate address.612 // @param new_admin Substrate administrator address.613 //614 // Selector: addCollectionAdminSubstrate(uint256) 5730062b615 function addCollectionAdminSubstrate(uint256 newAdmin) public {616 require(false, stub_error);617 newAdmin;618 dummy = 0;619 }620621 // Remove collection admin by substrate address.622 // @param admin Substrate administrator address.623 //624 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9625 function removeCollectionAdminSubstrate(uint256 admin) public {626 require(false, stub_error);627 admin;628 dummy = 0;629 }630631 // Add collection admin.632 // @param new_admin Address of the added administrator.633 //634 // Selector: addCollectionAdmin(address) 92e462c7635 function addCollectionAdmin(address newAdmin) public {636 require(false, stub_error);637 newAdmin;638 dummy = 0;639 }640641 // Remove collection admin.642 //643 // @param new_admin Address of the removed administrator.644 //645 // Selector: removeCollectionAdmin(address) fafd7b42646 function removeCollectionAdmin(address admin) public {647 require(false, stub_error);648 admin;649 dummy = 0;650 }651652 // Toggle accessibility of collection nesting.653 //654 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'655 //656 // Selector: setCollectionNesting(bool) 112d4586657 function setCollectionNesting(bool enable) public {658 require(false, stub_error);659 enable;660 dummy = 0;661 }662663 // Toggle accessibility of collection nesting.664 //665 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'666 // @param collections Addresses of collections that will be available for nesting.667 //668 // Selector: setCollectionNesting(bool,address[]) 64872396669 function setCollectionNesting(bool enable, address[] memory collections)670 public671 {672 require(false, stub_error);673 enable;674 collections;675 dummy = 0;676 }677678 // Set the collection access method.679 // @param mode Access mode680 // 0 for Normal681 // 1 for AllowList682 //683 // Selector: setCollectionAccess(uint8) 41835d4c684 function setCollectionAccess(uint8 mode) public {685 require(false, stub_error);686 mode;687 dummy = 0;688 }689690 // Add the user to the allowed list.691 //692 // @param user Address of a trusted user.693 //694 // Selector: addToCollectionAllowList(address) 67844fe6695 function addToCollectionAllowList(address user) public {696 require(false, stub_error);697 user;698 dummy = 0;699 }700701 // Remove the user from the allowed list.702 //703 // @param user Address of a removed user.704 //705 // Selector: removeFromCollectionAllowList(address) 85c51acb706 function removeFromCollectionAllowList(address user) public {707 require(false, stub_error);708 user;709 dummy = 0;710 }711712 // Switch permission for minting.713 //714 // @param mode Enable if "true".715 //716 // Selector: setCollectionMintMode(bool) 00018e84717 function setCollectionMintMode(bool mode) public {718 require(false, stub_error);719 mode;720 dummy = 0;721 }722723 // Check that account is the owner or admin of the collection724 //725 // @param user account to verify726 // @return "true" if account is the owner or admin727 //728 // Selector: isOwnerOrAdmin(address) 9811b0c7729 function isOwnerOrAdmin(address user) public view returns (bool) {730 require(false, stub_error);731 user;732 dummy;733 return false;734 }735736 // Check that substrate account is the owner or admin of the collection737 //738 // @param user account to verify739 // @return "true" if account is the owner or admin740 //741 // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00742 function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) {743 require(false, stub_error);744 user;745 dummy;746 return false;747 }748749 // Returns collection type750 //751 // @return `Fungible` or `NFT` or `ReFungible`752 //753 // Selector: uniqueCollectionType() d34b55b8754 function uniqueCollectionType() public returns (string memory) {755 require(false, stub_error);756 dummy = 0;757 return "";758 }759760 // Changes collection owner to another account761 //762 // @dev Owner can be changed only by current owner763 // @param newOwner new owner account764 //765 // Selector: setOwner(address) 13af4035766 function setOwner(address newOwner) public {767 require(false, stub_error);768 newOwner;769 dummy = 0;770 }771772 // Changes collection owner to another substrate account773 //774 // @dev Owner can be changed only by current owner775 // @param newOwner new owner substrate account776 //777 // Selector: setOwnerSubstrate(uint256) b212138f778 function setOwnerSubstrate(uint256 newOwner) public {779 require(false, stub_error);780 newOwner;781 dummy = 0;782 }783}784793785contract UniqueNFT is794contract UniqueNFT is786 Dummy,795 Dummy,pallets/refungible/src/erc.rsdiffbeforeafterboth53pub const ADDRESS_FOR_PARTIALLY_OWNED_TOKENS: H160 = H160::repeat_byte(0xff);53pub const ADDRESS_FOR_PARTIALLY_OWNED_TOKENS: H160 = H160::repeat_byte(0xff);545455/// @title A contract that allows to set and delete token properties and change token property permissions.55/// @title A contract that allows to set and delete token properties and change token property permissions.56#[solidity_interface(name = "TokenProperties")]56#[solidity_interface(name = TokenProperties)]57impl<T: Config> RefungibleHandle<T> {57impl<T: Config> RefungibleHandle<T> {58 /// @notice Set permissions for token property.58 /// @notice Set permissions for token property.59 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.59 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.60 /// @param key Property key.60 /// @param key Property key.61 /// @param is_mutable Permission to mutate property.61 /// @param isMutable Permission to mutate property.62 /// @param collection_admin Permission to mutate property by collection admin if property is mutable.62 /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.63 /// @param token_owner Permission to mutate property by token owner if property is mutable.63 /// @param tokenOwner Permission to mutate property by token owner if property is mutable.64 fn set_token_property_permission(64 fn set_token_property_permission(65 &mut self,65 &mut self,66 caller: caller,66 caller: caller,197 MintingFinished {},197 MintingFinished {},198}198}199199200#[solidity_interface(name = "ERC721Metadata")]200#[solidity_interface(name = ERC721Metadata)]201impl<T: Config> RefungibleHandle<T> {201impl<T: Config> RefungibleHandle<T> {202 /// @notice A descriptive name for a collection of RFTs in this contract202 /// @notice A descriptive name for a collection of RFTs in this contract203 fn name(&self) -> Result<string> {203 fn name(&self) -> Result<string> {258258259/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension259/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension260/// @dev See https://eips.ethereum.org/EIPS/eip-721260/// @dev See https://eips.ethereum.org/EIPS/eip-721261#[solidity_interface(name = "ERC721Enumerable")]261#[solidity_interface(name = ERC721Enumerable)]262impl<T: Config> RefungibleHandle<T> {262impl<T: Config> RefungibleHandle<T> {263 /// @notice Enumerate valid RFTs263 /// @notice Enumerate valid RFTs264 /// @param index A counter less than `totalSupply()`264 /// @param index A counter less than `totalSupply()`285285286/// @title ERC-721 Non-Fungible Token Standard286/// @title ERC-721 Non-Fungible Token Standard287/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md287/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md288#[solidity_interface(name = "ERC721", events(ERC721Events))]288#[solidity_interface(name = ERC721, events(ERC721Events))]289impl<T: Config> RefungibleHandle<T> {289impl<T: Config> RefungibleHandle<T> {290 /// @notice Count all RFTs assigned to an owner290 /// @notice Count all RFTs assigned to an owner291 /// @dev RFTs assigned to the zero address are considered invalid, and this291 /// @dev RFTs assigned to the zero address are considered invalid, and this322 _to: address,322 _to: address,323 _token_id: uint256,323 _token_id: uint256,324 _data: bytes,324 _data: bytes,325 _value: value,326 ) -> Result<void> {325 ) -> Result<void> {327 // TODO: Not implemetable326 // TODO: Not implemetable328 Err("not implemented".into())327 Err("not implemented".into())334 _from: address,333 _from: address,335 _to: address,334 _to: address,336 _token_id: uint256,335 _token_id: uint256,337 _value: value,338 ) -> Result<void> {336 ) -> Result<void> {339 // TODO: Not implemetable337 // TODO: Not implemetable340 Err("not implemented".into())338 Err("not implemented".into())350 /// @param from The current owner of the NFT348 /// @param from The current owner of the NFT351 /// @param to The new owner349 /// @param to The new owner352 /// @param tokenId The NFT to transfer350 /// @param tokenId The NFT to transfer353 /// @param _value Not used for an NFT354 #[weight(<SelfWeightOf<T>>::transfer_from_creating_removing())]351 #[weight(<SelfWeightOf<T>>::transfer_from_creating_removing())]355 fn transfer_from(352 fn transfer_from(356 &mut self,353 &mut self,357 caller: caller,354 caller: caller,358 from: address,355 from: address,359 to: address,356 to: address,360 token_id: uint256,357 token_id: uint256,361 _value: value,362 ) -> Result<void> {358 ) -> Result<void> {363 let caller = T::CrossAccountId::from_eth(caller);359 let caller = T::CrossAccountId::from_eth(caller);364 let from = T::CrossAccountId::from_eth(from);360 let from = T::CrossAccountId::from_eth(from);382 &mut self,383 _caller: caller,384 _approved: address,385 _token_id: uint256,386 _value: value,387 ) -> Result<void> {388 Err("not implemented".into())378 Err("not implemented".into())389 }379 }438}428}439429440/// @title ERC721 Token that can be irreversibly burned (destroyed).430/// @title ERC721 Token that can be irreversibly burned (destroyed).441#[solidity_interface(name = "ERC721Burnable")]431#[solidity_interface(name = ERC721Burnable)]442impl<T: Config> RefungibleHandle<T> {432impl<T: Config> RefungibleHandle<T> {443 /// @notice Burns a specific ERC721 token.433 /// @notice Burns a specific ERC721 token.444 /// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized434 /// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized458}448}459449460/// @title ERC721 minting logic.450/// @title ERC721 minting logic.461#[solidity_interface(name = "ERC721Mintable", events(ERC721MintableEvents))]451#[solidity_interface(name = ERC721Mintable, events(ERC721MintableEvents))]462impl<T: Config> RefungibleHandle<T> {452impl<T: Config> RefungibleHandle<T> {463 fn minting_finished(&self) -> Result<bool> {453 fn minting_finished(&self) -> Result<bool> {464 Ok(false)454 Ok(false)616}606}617607618/// @title Unique extensions for ERC721.608/// @title Unique extensions for ERC721.619#[solidity_interface(name = "ERC721UniqueExtensions")]609#[solidity_interface(name = ERC721UniqueExtensions)]620impl<T: Config> RefungibleHandle<T> {610impl<T: Config> RefungibleHandle<T> {621 /// @notice Transfer ownership of an RFT611 /// @notice Transfer ownership of an RFT622 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`612 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`623 /// is the zero address. Throws if `tokenId` is not a valid RFT.613 /// is the zero address. Throws if `tokenId` is not a valid RFT.624 /// Throws if RFT pieces have multiple owners.614 /// Throws if RFT pieces have multiple owners.625 /// @param to The new owner615 /// @param to The new owner626 /// @param tokenId The RFT to transfer616 /// @param tokenId The RFT to transfer627 /// @param _value Not used for an RFT628 #[weight(<SelfWeightOf<T>>::transfer_creating_removing())]617 #[weight(<SelfWeightOf<T>>::transfer_creating_removing())]629 fn transfer(618 fn transfer(&mut self, caller: caller, to: address, token_id: uint256) -> Result<void> {630 &mut self,631 caller: caller,632 to: address,633 token_id: uint256,634 _value: value,635 ) -> Result<void> {636 let caller = T::CrossAccountId::from_eth(caller);619 let caller = T::CrossAccountId::from_eth(caller);637 let to = T::CrossAccountId::from_eth(to);620 let to = T::CrossAccountId::from_eth(to);655 /// Throws if RFT pieces have multiple owners.638 /// Throws if RFT pieces have multiple owners.656 /// @param from The current owner of the RFT639 /// @param from The current owner of the RFT657 /// @param tokenId The RFT to transfer640 /// @param tokenId The RFT to transfer658 /// @param _value Not used for an RFT659 #[weight(<SelfWeightOf<T>>::burn_from())]641 #[weight(<SelfWeightOf<T>>::burn_from())]660 fn burn_from(642 fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result<void> {661 &mut self,662 caller: caller,663 from: address,664 token_id: uint256,665 _value: value,666 ) -> Result<void> {667 let caller = T::CrossAccountId::from_eth(caller);643 let caller = T::CrossAccountId::from_eth(caller);668 let from = T::CrossAccountId::from_eth(from);644 let from = T::CrossAccountId::from_eth(from);801}777}802778803#[solidity_interface(779#[solidity_interface(804 name = "UniqueRefungible",780 name = UniqueRefungible,805 is(781 is(806 ERC721,782 ERC721,807 ERC721Metadata,783 ERC721Metadata,808 ERC721Enumerable,784 ERC721Enumerable,809 ERC721UniqueExtensions,785 ERC721UniqueExtensions,810 ERC721Mintable,786 ERC721Mintable,811 ERC721Burnable,787 ERC721Burnable,812 via("CollectionHandle<T>", common_mut, Collection),788 Collection(common_mut, CollectionHandle<T>),813 TokenProperties,789 TokenProperties,814 )790 )815)]791)]pallets/refungible/src/erc_token.rsdiffbeforeafterboth494950pub struct RefungibleTokenHandle<T: Config>(pub RefungibleHandle<T>, pub TokenId);50pub struct RefungibleTokenHandle<T: Config>(pub RefungibleHandle<T>, pub TokenId);515152#[solidity_interface(name = "ERC1633")]52#[solidity_interface(name = ERC1633)]53impl<T: Config> RefungibleTokenHandle<T> {53impl<T: Config> RefungibleTokenHandle<T> {54 fn parent_token(&self) -> Result<address> {54 fn parent_token(&self) -> Result<address> {55 self.consume_store_reads(2)?;55 self.consume_store_reads(2)?;87 }87 }88}88}898990#[solidity_interface(name = "ERC1633UniqueExtensions")]90#[solidity_interface(name = ERC1633UniqueExtensions)]91impl<T: Config> RefungibleTokenHandle<T> {91impl<T: Config> RefungibleTokenHandle<T> {92 #[solidity(rename_selector = "setParentNFT")]92 #[solidity(rename_selector = "setParentNFT")]93 #[weight(<CommonWeights<T>>::token_owner() + <SelfWeightOf<T>>::set_parent_nft_unchecked())]93 #[weight(<CommonWeights<T>>::token_owner() + <SelfWeightOf<T>>::set_parent_nft_unchecked())]137///137///138/// @dev Implementation of the basic standard token.138/// @dev Implementation of the basic standard token.139/// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md139/// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md140#[solidity_interface(name = "ERC20", events(ERC20Events))]140#[solidity_interface(name = ERC20, events(ERC20Events))]141impl<T: Config> RefungibleTokenHandle<T> {141impl<T: Config> RefungibleTokenHandle<T> {142 /// @return the name of the token.142 /// @return the name of the token.143 fn name(&self) -> Result<string> {143 fn name(&self) -> Result<string> {246 }246 }247}247}248248249#[solidity_interface(name = "ERC20UniqueExtensions")]249#[solidity_interface(name = ERC20UniqueExtensions)]250impl<T: Config> RefungibleTokenHandle<T> {250impl<T: Config> RefungibleTokenHandle<T> {251 /// @dev Function that burns an amount of the token of a given account,251 /// @dev Function that burns an amount of the token of a given account,252 /// deducting from the sender's allowance for said account.252 /// deducting from the sender's allowance for said account.306}306}307307308#[solidity_interface(308#[solidity_interface(309 name = "UniqueRefungibleToken",309 name = UniqueRefungibleToken,310 is(ERC20, ERC20UniqueExtensions, ERC1633, ERC1633UniqueExtensions)310 is(ERC20, ERC20UniqueExtensions, ERC1633, ERC1633UniqueExtensions)311)]311)]312impl<T: Config> RefungibleTokenHandle<T> where T::AccountId: From<[u8; 32]> {}312impl<T: Config> RefungibleTokenHandle<T> where T::AccountId: From<[u8; 32]> {}pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8 uint256 field_0;9 string field_1;10}11512// Common stubs holder6/// @dev common stubs holder13contract Dummy {7contract Dummy {14 uint8 dummy;8 uint8 dummy;15 string stub_error = "this contract is implemented in native";9 string stub_error = "this contract is implemented in native";27 }21 }28}22}292330// Inline24/// @title A contract that allows to set and delete token properties and change token property permissions.25/// @dev the ERC-165 identifier for this interface is 0x4136937726contract TokenProperties is Dummy, ERC165 {27 /// @notice Set permissions for token property.28 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.29 /// @param key Property key.30 /// @param isMutable Permission to mutate property.31 /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.32 /// @param tokenOwner Permission to mutate property by token owner if property is mutable.33 /// @dev EVM selector for this function is: 0x222d97fa,34 /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)35 function setTokenPropertyPermission(36 string memory key,37 bool isMutable,38 bool collectionAdmin,39 bool tokenOwner40 ) public {41 require(false, stub_error);42 key;43 isMutable;44 collectionAdmin;45 tokenOwner;46 dummy = 0;47 }4849 /// @notice Set token property value.50 /// @dev Throws error if `msg.sender` has no permission to edit the property.51 /// @param tokenId ID of the token.52 /// @param key Property key.53 /// @param value Property value.54 /// @dev EVM selector for this function is: 0x1752d67b,55 /// or in textual repr: setProperty(uint256,string,bytes)56 function setProperty(57 uint256 tokenId,58 string memory key,59 bytes memory value60 ) public {61 require(false, stub_error);62 tokenId;63 key;64 value;65 dummy = 0;66 }6768 /// @notice Delete token property value.69 /// @dev Throws error if `msg.sender` has no permission to edit the property.70 /// @param tokenId ID of the token.71 /// @param key Property key.72 /// @dev EVM selector for this function is: 0x066111d1,73 /// or in textual repr: deleteProperty(uint256,string)74 function deleteProperty(uint256 tokenId, string memory key) public {75 require(false, stub_error);76 tokenId;77 key;78 dummy = 0;79 }8081 /// @notice Get token property value.82 /// @dev Throws error if key not found83 /// @param tokenId ID of the token.84 /// @param key Property key.85 /// @return Property value bytes86 /// @dev EVM selector for this function is: 0x7228c327,87 /// or in textual repr: property(uint256,string)88 function property(uint256 tokenId, string memory key)89 public90 view91 returns (bytes memory)92 {93 require(false, stub_error);94 tokenId;95 key;96 dummy;97 return hex"";98 }99}100101/// @title A contract that allows you to work with collections.102/// @dev the ERC-165 identifier for this interface is 0xffe4da23103contract Collection is Dummy, ERC165 {104 /// Set collection property.105 ///106 /// @param key Property key.107 /// @param value Propery value.108 /// @dev EVM selector for this function is: 0x2f073f66,109 /// or in textual repr: setCollectionProperty(string,bytes)110 function setCollectionProperty(string memory key, bytes memory value)111 public112 {113 require(false, stub_error);114 key;115 value;116 dummy = 0;117 }118119 /// Delete collection property.120 ///121 /// @param key Property key.122 /// @dev EVM selector for this function is: 0x7b7debce,123 /// or in textual repr: deleteCollectionProperty(string)124 function deleteCollectionProperty(string memory key) public {125 require(false, stub_error);126 key;127 dummy = 0;128 }129130 /// Get collection property.131 ///132 /// @dev Throws error if key not found.133 ///134 /// @param key Property key.135 /// @return bytes The property corresponding to the key.136 /// @dev EVM selector for this function is: 0xcf24fd6d,137 /// or in textual repr: collectionProperty(string)138 function collectionProperty(string memory key)139 public140 view141 returns (bytes memory)142 {143 require(false, stub_error);144 key;145 dummy;146 return hex"";147 }148149 /// Set the sponsor of the collection.150 ///151 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.152 ///153 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.154 /// @dev EVM selector for this function is: 0x7623402e,155 /// or in textual repr: setCollectionSponsor(address)156 function setCollectionSponsor(address sponsor) public {157 require(false, stub_error);158 sponsor;159 dummy = 0;160 }161162 /// Collection sponsorship confirmation.163 ///164 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.165 /// @dev EVM selector for this function is: 0x3c50e97a,166 /// or in textual repr: confirmCollectionSponsorship()167 function confirmCollectionSponsorship() public {168 require(false, stub_error);169 dummy = 0;170 }171172 /// Set limits for the collection.173 /// @dev Throws error if limit not found.174 /// @param limit Name of the limit. Valid names:175 /// "accountTokenOwnershipLimit",176 /// "sponsoredDataSize",177 /// "sponsoredDataRateLimit",178 /// "tokenLimit",179 /// "sponsorTransferTimeout",180 /// "sponsorApproveTimeout"181 /// @param value Value of the limit.182 /// @dev EVM selector for this function is: 0x6a3841db,183 /// or in textual repr: setCollectionLimit(string,uint32)184 function setCollectionLimit(string memory limit, uint32 value) public {185 require(false, stub_error);186 limit;187 value;188 dummy = 0;189 }190191 /// Set limits for the collection.192 /// @dev Throws error if limit not found.193 /// @param limit Name of the limit. Valid names:194 /// "ownerCanTransfer",195 /// "ownerCanDestroy",196 /// "transfersEnabled"197 /// @param value Value of the limit.198 /// @dev EVM selector for this function is: 0x993b7fba,199 /// or in textual repr: setCollectionLimit(string,bool)200 function setCollectionLimit(string memory limit, bool value) public {201 require(false, stub_error);202 limit;203 value;204 dummy = 0;205 }206207 /// Get contract address.208 /// @dev EVM selector for this function is: 0xf6b4dfb4,209 /// or in textual repr: contractAddress()210 function contractAddress() public view returns (address) {211 require(false, stub_error);212 dummy;213 return 0x0000000000000000000000000000000000000000;214 }215216 /// Add collection admin by substrate address.217 /// @param newAdmin Substrate administrator address.218 /// @dev EVM selector for this function is: 0x5730062b,219 /// or in textual repr: addCollectionAdminSubstrate(uint256)220 function addCollectionAdminSubstrate(uint256 newAdmin) public {221 require(false, stub_error);222 newAdmin;223 dummy = 0;224 }225226 /// Remove collection admin by substrate address.227 /// @param admin Substrate administrator address.228 /// @dev EVM selector for this function is: 0x4048fcf9,229 /// or in textual repr: removeCollectionAdminSubstrate(uint256)230 function removeCollectionAdminSubstrate(uint256 admin) public {231 require(false, stub_error);232 admin;233 dummy = 0;234 }235236 /// Add collection admin.237 /// @param newAdmin Address of the added administrator.238 /// @dev EVM selector for this function is: 0x92e462c7,239 /// or in textual repr: addCollectionAdmin(address)240 function addCollectionAdmin(address newAdmin) public {241 require(false, stub_error);242 newAdmin;243 dummy = 0;244 }245246 /// Remove collection admin.247 ///248 /// @param admin Address of the removed administrator.249 /// @dev EVM selector for this function is: 0xfafd7b42,250 /// or in textual repr: removeCollectionAdmin(address)251 function removeCollectionAdmin(address admin) public {252 require(false, stub_error);253 admin;254 dummy = 0;255 }256257 /// Toggle accessibility of collection nesting.258 ///259 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'260 /// @dev EVM selector for this function is: 0x112d4586,261 /// or in textual repr: setCollectionNesting(bool)262 function setCollectionNesting(bool enable) public {263 require(false, stub_error);264 enable;265 dummy = 0;266 }267268 /// Toggle accessibility of collection nesting.269 ///270 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'271 /// @param collections Addresses of collections that will be available for nesting.272 /// @dev EVM selector for this function is: 0x64872396,273 /// or in textual repr: setCollectionNesting(bool,address[])274 function setCollectionNesting(bool enable, address[] memory collections)275 public276 {277 require(false, stub_error);278 enable;279 collections;280 dummy = 0;281 }282283 /// Set the collection access method.284 /// @param mode Access mode285 /// 0 for Normal286 /// 1 for AllowList287 /// @dev EVM selector for this function is: 0x41835d4c,288 /// or in textual repr: setCollectionAccess(uint8)289 function setCollectionAccess(uint8 mode) public {290 require(false, stub_error);291 mode;292 dummy = 0;293 }294295 /// Add the user to the allowed list.296 ///297 /// @param user Address of a trusted user.298 /// @dev EVM selector for this function is: 0x67844fe6,299 /// or in textual repr: addToCollectionAllowList(address)300 function addToCollectionAllowList(address user) public {301 require(false, stub_error);302 user;303 dummy = 0;304 }305306 /// Remove the user from the allowed list.307 ///308 /// @param user Address of a removed user.309 /// @dev EVM selector for this function is: 0x85c51acb,310 /// or in textual repr: removeFromCollectionAllowList(address)311 function removeFromCollectionAllowList(address user) public {312 require(false, stub_error);313 user;314 dummy = 0;315 }316317 /// Switch permission for minting.318 ///319 /// @param mode Enable if "true".320 /// @dev EVM selector for this function is: 0x00018e84,321 /// or in textual repr: setCollectionMintMode(bool)322 function setCollectionMintMode(bool mode) public {323 require(false, stub_error);324 mode;325 dummy = 0;326 }327328 /// Check that account is the owner or admin of the collection329 ///330 /// @param user account to verify331 /// @return "true" if account is the owner or admin332 /// @dev EVM selector for this function is: 0x9811b0c7,333 /// or in textual repr: isOwnerOrAdmin(address)334 function isOwnerOrAdmin(address user) public view returns (bool) {335 require(false, stub_error);336 user;337 dummy;338 return false;339 }340341 /// Check that substrate account is the owner or admin of the collection342 ///343 /// @param user account to verify344 /// @return "true" if account is the owner or admin345 /// @dev EVM selector for this function is: 0x68910e00,346 /// or in textual repr: isOwnerOrAdminSubstrate(uint256)347 function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) {348 require(false, stub_error);349 user;350 dummy;351 return false;352 }353354 /// Returns collection type355 ///356 /// @return `Fungible` or `NFT` or `ReFungible`357 /// @dev EVM selector for this function is: 0xd34b55b8,358 /// or in textual repr: uniqueCollectionType()359 function uniqueCollectionType() public returns (string memory) {360 require(false, stub_error);361 dummy = 0;362 return "";363 }364365 /// Changes collection owner to another account366 ///367 /// @dev Owner can be changed only by current owner368 /// @param newOwner new owner account369 /// @dev EVM selector for this function is: 0x13af4035,370 /// or in textual repr: setOwner(address)371 function setOwner(address newOwner) public {372 require(false, stub_error);373 newOwner;374 dummy = 0;375 }376377 /// Changes collection owner to another substrate account378 ///379 /// @dev Owner can be changed only by current owner380 /// @param newOwner new owner substrate account381 /// @dev EVM selector for this function is: 0xb212138f,382 /// or in textual repr: setOwnerSubstrate(uint256)383 function setOwnerSubstrate(uint256 newOwner) public {384 require(false, stub_error);385 newOwner;386 dummy = 0;387 }388}389390/// @title ERC721 Token that can be irreversibly burned (destroyed).391/// @dev the ERC-165 identifier for this interface is 0x42966c68392contract ERC721Burnable is Dummy, ERC165 {393 /// @notice Burns a specific ERC721 token.394 /// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized395 /// operator of the current owner.396 /// @param tokenId The RFT to approve397 /// @dev EVM selector for this function is: 0x42966c68,398 /// or in textual repr: burn(uint256)399 function burn(uint256 tokenId) public {400 require(false, stub_error);401 tokenId;402 dummy = 0;403 }404}405406/// @dev inlined interface407contract ERC721MintableEvents {408 event MintingFinished();409}410411/// @title ERC721 minting logic.412/// @dev the ERC-165 identifier for this interface is 0x68ccfe89413contract ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {414 /// @dev EVM selector for this function is: 0x05d2035b,415 /// or in textual repr: mintingFinished()416 function mintingFinished() public view returns (bool) {417 require(false, stub_error);418 dummy;419 return false;420 }421422 /// @notice Function to mint token.423 /// @dev `tokenId` should be obtained with `nextTokenId` method,424 /// unlike standard, you can't specify it manually425 /// @param to The new owner426 /// @param tokenId ID of the minted RFT427 /// @dev EVM selector for this function is: 0x40c10f19,428 /// or in textual repr: mint(address,uint256)429 function mint(address to, uint256 tokenId) public returns (bool) {430 require(false, stub_error);431 to;432 tokenId;433 dummy = 0;434 return false;435 }436437 /// @notice Function to mint token with the given tokenUri.438 /// @dev `tokenId` should be obtained with `nextTokenId` method,439 /// unlike standard, you can't specify it manually440 /// @param to The new owner441 /// @param tokenId ID of the minted RFT442 /// @param tokenUri Token URI that would be stored in the RFT properties443 /// @dev EVM selector for this function is: 0x50bb4e7f,444 /// or in textual repr: mintWithTokenURI(address,uint256,string)445 function mintWithTokenURI(446 address to,447 uint256 tokenId,448 string memory tokenUri449 ) public returns (bool) {450 require(false, stub_error);451 to;452 tokenId;453 tokenUri;454 dummy = 0;455 return false;456 }457458 /// @dev Not implemented459 /// @dev EVM selector for this function is: 0x7d64bcb4,460 /// or in textual repr: finishMinting()461 function finishMinting() public returns (bool) {462 require(false, stub_error);463 dummy = 0;464 return false;465 }466}467468/// @title Unique extensions for ERC721.469/// @dev the ERC-165 identifier for this interface is 0x7c3bef89470contract ERC721UniqueExtensions is Dummy, ERC165 {471 /// @notice Transfer ownership of an RFT472 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`473 /// is the zero address. Throws if `tokenId` is not a valid RFT.474 /// Throws if RFT pieces have multiple owners.475 /// @param to The new owner476 /// @param tokenId The RFT to transfer477 /// @dev EVM selector for this function is: 0xa9059cbb,478 /// or in textual repr: transfer(address,uint256)479 function transfer(address to, uint256 tokenId) public {480 require(false, stub_error);481 to;482 tokenId;483 dummy = 0;484 }485486 /// @notice Burns a specific ERC721 token.487 /// @dev Throws unless `msg.sender` is the current owner or an authorized488 /// operator for this RFT. Throws if `from` is not the current owner. Throws489 /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.490 /// Throws if RFT pieces have multiple owners.491 /// @param from The current owner of the RFT492 /// @param tokenId The RFT to transfer493 /// @dev EVM selector for this function is: 0x79cc6790,494 /// or in textual repr: burnFrom(address,uint256)495 function burnFrom(address from, uint256 tokenId) public {496 require(false, stub_error);497 from;498 tokenId;499 dummy = 0;500 }501502 /// @notice Returns next free RFT ID.503 /// @dev EVM selector for this function is: 0x75794a3c,504 /// or in textual repr: nextTokenId()505 function nextTokenId() public view returns (uint256) {506 require(false, stub_error);507 dummy;508 return 0;509 }510511 /// @notice Function to mint multiple tokens.512 /// @dev `tokenIds` should be an array of consecutive numbers and first number513 /// should be obtained with `nextTokenId` method514 /// @param to The new owner515 /// @param tokenIds IDs of the minted RFTs516 /// @dev EVM selector for this function is: 0x44a9945e,517 /// or in textual repr: mintBulk(address,uint256[])518 function mintBulk(address to, uint256[] memory tokenIds)519 public520 returns (bool)521 {522 require(false, stub_error);523 to;524 tokenIds;525 dummy = 0;526 return false;527 }528529 /// @notice Function to mint multiple tokens with the given tokenUris.530 /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive531 /// numbers and first number should be obtained with `nextTokenId` method532 /// @param to The new owner533 /// @param tokens array of pairs of token ID and token URI for minted tokens534 /// @dev EVM selector for this function is: 0x36543006,535 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])536 function mintBulkWithTokenURI(address to, Tuple8[] memory tokens)537 public538 returns (bool)539 {540 require(false, stub_error);541 to;542 tokens;543 dummy = 0;544 return false;545 }546547 /// Returns EVM address for refungible token548 ///549 /// @param token ID of the token550 /// @dev EVM selector for this function is: 0xab76fac6,551 /// or in textual repr: tokenContractAddress(uint256)552 function tokenContractAddress(uint256 token) public view returns (address) {553 require(false, stub_error);554 token;555 dummy;556 return 0x0000000000000000000000000000000000000000;557 }558}559560/// @dev anonymous struct561struct Tuple8 {562 uint256 field_0;563 string field_1;564}565566/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension567/// @dev See https://eips.ethereum.org/EIPS/eip-721568/// @dev the ERC-165 identifier for this interface is 0x780e9d63569contract ERC721Enumerable is Dummy, ERC165 {570 /// @notice Enumerate valid RFTs571 /// @param index A counter less than `totalSupply()`572 /// @return The token identifier for the `index`th NFT,573 /// (sort order not specified)574 /// @dev EVM selector for this function is: 0x4f6ccce7,575 /// or in textual repr: tokenByIndex(uint256)576 function tokenByIndex(uint256 index) public view returns (uint256) {577 require(false, stub_error);578 index;579 dummy;580 return 0;581 }582583 /// Not implemented584 /// @dev EVM selector for this function is: 0x2f745c59,585 /// or in textual repr: tokenOfOwnerByIndex(address,uint256)586 function tokenOfOwnerByIndex(address owner, uint256 index)587 public588 view589 returns (uint256)590 {591 require(false, stub_error);592 owner;593 index;594 dummy;595 return 0;596 }597598 /// @notice Count RFTs tracked by this contract599 /// @return A count of valid RFTs tracked by this contract, where each one of600 /// them has an assigned and queryable owner not equal to the zero address601 /// @dev EVM selector for this function is: 0x18160ddd,602 /// or in textual repr: totalSupply()603 function totalSupply() public view returns (uint256) {604 require(false, stub_error);605 dummy;606 return 0;607 }608}609610/// @dev the ERC-165 identifier for this interface is 0x5b5e139f611contract ERC721Metadata is Dummy, ERC165 {612 /// @notice A descriptive name for a collection of RFTs in this contract613 /// @dev EVM selector for this function is: 0x06fdde03,614 /// or in textual repr: name()615 function name() public view returns (string memory) {616 require(false, stub_error);617 dummy;618 return "";619 }620621 /// @notice An abbreviated name for RFTs in this contract622 /// @dev EVM selector for this function is: 0x95d89b41,623 /// or in textual repr: symbol()624 function symbol() public view returns (string memory) {625 require(false, stub_error);626 dummy;627 return "";628 }629630 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.631 ///632 /// @dev If the token has a `url` property and it is not empty, it is returned.633 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.634 /// If the collection property `baseURI` is empty or absent, return "" (empty string)635 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix636 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).637 ///638 /// @return token's const_metadata639 /// @dev EVM selector for this function is: 0xc87b56dd,640 /// or in textual repr: tokenURI(uint256)641 function tokenURI(uint256 tokenId) public view returns (string memory) {642 require(false, stub_error);643 tokenId;644 dummy;645 return "";646 }647}648649/// @dev inlined interface31contract ERC721Events {650contract ERC721Events {32 event Transfer(651 event Transfer(33 address indexed from,652 address indexed from,46 );665 );47}666}4866749// Inline668/// @title ERC-721 Non-Fungible Token Standard50contract ERC721MintableEvents {669/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md51 event MintingFinished();670/// @dev the ERC-165 identifier for this interface is 0x5880016152}5354// Selector: 4136937755contract TokenProperties is Dummy, ERC165 {56 // @notice Set permissions for token property.57 // @dev Throws error if `msg.sender` is not admin or owner of the collection.58 // @param key Property key.59 // @param is_mutable Permission to mutate property.60 // @param collection_admin Permission to mutate property by collection admin if property is mutable.61 // @param token_owner Permission to mutate property by token owner if property is mutable.62 //63 // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa64 function setTokenPropertyPermission(65 string memory key,66 bool isMutable,67 bool collectionAdmin,68 bool tokenOwner69 ) public {70 require(false, stub_error);71 key;72 isMutable;73 collectionAdmin;74 tokenOwner;75 dummy = 0;76 }7778 // @notice Set token property value.79 // @dev Throws error if `msg.sender` has no permission to edit the property.80 // @param tokenId ID of the token.81 // @param key Property key.82 // @param value Property value.83 //84 // Selector: setProperty(uint256,string,bytes) 1752d67b85 function setProperty(86 uint256 tokenId,87 string memory key,88 bytes memory value89 ) public {90 require(false, stub_error);91 tokenId;92 key;93 value;94 dummy = 0;95 }9697 // @notice Delete token property value.98 // @dev Throws error if `msg.sender` has no permission to edit the property.99 // @param tokenId ID of the token.100 // @param key Property key.101 //102 // Selector: deleteProperty(uint256,string) 066111d1103 function deleteProperty(uint256 tokenId, string memory key) public {104 require(false, stub_error);105 tokenId;106 key;107 dummy = 0;108 }109110 // @notice Get token property value.111 // @dev Throws error if key not found112 // @param tokenId ID of the token.113 // @param key Property key.114 // @return Property value bytes115 //116 // Selector: property(uint256,string) 7228c327117 function property(uint256 tokenId, string memory key)118 public119 view120 returns (bytes memory)121 {122 require(false, stub_error);123 tokenId;124 key;125 dummy;126 return hex"";127 }128}129130// Selector: 42966c68131contract ERC721Burnable is Dummy, ERC165 {132 // @notice Burns a specific ERC721 token.133 // @dev Throws unless `msg.sender` is the current RFT owner, or an authorized134 // operator of the current owner.135 // @param tokenId The RFT to approve136 //137 // Selector: burn(uint256) 42966c68138 function burn(uint256 tokenId) public {139 require(false, stub_error);140 tokenId;141 dummy = 0;142 }143}144145// Selector: 58800161146contract ERC721 is Dummy, ERC165, ERC721Events {671contract ERC721 is Dummy, ERC165, ERC721Events {147 // @notice Count all RFTs assigned to an owner672 /// @notice Count all RFTs assigned to an owner148 // @dev RFTs assigned to the zero address are considered invalid, and this673 /// @dev RFTs assigned to the zero address are considered invalid, and this149 // function throws for queries about the zero address.674 /// function throws for queries about the zero address.150 // @param owner An address for whom to query the balance675 /// @param owner An address for whom to query the balance151 // @return The number of RFTs owned by `owner`, possibly zero676 /// @return The number of RFTs owned by `owner`, possibly zero152 //677 /// @dev EVM selector for this function is: 0x70a08231,153 // Selector: balanceOf(address) 70a08231678 /// or in textual repr: balanceOf(address)154 function balanceOf(address owner) public view returns (uint256) {679 function balanceOf(address owner) public view returns (uint256) {155 require(false, stub_error);680 require(false, stub_error);156 owner;681 owner;157 dummy;682 dummy;158 return 0;683 return 0;159 }684 }160685161 // @notice Find the owner of an RFT686 /// @notice Find the owner of an RFT162 // @dev RFTs assigned to zero address are considered invalid, and queries687 /// @dev RFTs assigned to zero address are considered invalid, and queries163 // about them do throw.688 /// about them do throw.164 // Returns special 0xffffffffffffffffffffffffffffffffffffffff address for689 /// Returns special 0xffffffffffffffffffffffffffffffffffffffff address for165 // the tokens that are partially owned.690 /// the tokens that are partially owned.166 // @param tokenId The identifier for an RFT691 /// @param tokenId The identifier for an RFT167 // @return The address of the owner of the RFT692 /// @return The address of the owner of the RFT168 //693 /// @dev EVM selector for this function is: 0x6352211e,169 // Selector: ownerOf(uint256) 6352211e694 /// or in textual repr: ownerOf(uint256)170 function ownerOf(uint256 tokenId) public view returns (address) {695 function ownerOf(uint256 tokenId) public view returns (address) {171 require(false, stub_error);696 require(false, stub_error);172 tokenId;697 tokenId;173 dummy;698 dummy;174 return 0x0000000000000000000000000000000000000000;699 return 0x0000000000000000000000000000000000000000;175 }700 }176701177 // @dev Not implemented702 /// @dev Not implemented178 //703 /// @dev EVM selector for this function is: 0x60a11672,179 // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672704 /// or in textual repr: safeTransferFromWithData(address,address,uint256,bytes)180 function safeTransferFromWithData(705 function safeTransferFromWithData(181 address from,706 address from,182 address to,707 address to,191 dummy = 0;716 dummy = 0;192 }717 }193718194 // @dev Not implemented719 /// @dev Not implemented195 //720 /// @dev EVM selector for this function is: 0x42842e0e,196 // Selector: safeTransferFrom(address,address,uint256) 42842e0e721 /// or in textual repr: safeTransferFrom(address,address,uint256)197 function safeTransferFrom(722 function safeTransferFrom(198 address from,723 address from,199 address to,724 address to,206 dummy = 0;731 dummy = 0;207 }732 }208733209 // @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE734 /// @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE210 // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE735 /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE211 // THEY MAY BE PERMANENTLY LOST736 /// THEY MAY BE PERMANENTLY LOST212 // @dev Throws unless `msg.sender` is the current owner or an authorized737 /// @dev Throws unless `msg.sender` is the current owner or an authorized213 // operator for this RFT. Throws if `from` is not the current owner. Throws738 /// operator for this RFT. Throws if `from` is not the current owner. Throws214 // if `to` is the zero address. Throws if `tokenId` is not a valid RFT.739 /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.215 // Throws if RFT pieces have multiple owners.740 /// Throws if RFT pieces have multiple owners.216 // @param from The current owner of the NFT741 /// @param from The current owner of the NFT217 // @param to The new owner742 /// @param to The new owner218 // @param tokenId The NFT to transfer743 /// @param tokenId The NFT to transfer219 // @param _value Not used for an NFT744 /// @dev EVM selector for this function is: 0x23b872dd,220 //221 // Selector: transferFrom(address,address,uint256) 23b872dd745 /// or in textual repr: transferFrom(address,address,uint256)222 function transferFrom(746 function transferFrom(223 address from,747 address from,224 address to,748 address to,231 dummy = 0;755 dummy = 0;232 }756 }233757234 // @dev Not implemented758 /// @dev Not implemented235 //759 /// @dev EVM selector for this function is: 0x095ea7b3,236 // Selector: approve(address,uint256) 095ea7b3760 /// or in textual repr: approve(address,uint256)237 function approve(address approved, uint256 tokenId) public {761 function approve(address approved, uint256 tokenId) public {238 require(false, stub_error);762 require(false, stub_error);239 approved;763 approved;240 tokenId;764 tokenId;241 dummy = 0;765 dummy = 0;242 }766 }243767244 // @dev Not implemented768 /// @dev Not implemented245 //769 /// @dev EVM selector for this function is: 0xa22cb465,246 // Selector: setApprovalForAll(address,bool) a22cb465770 /// or in textual repr: setApprovalForAll(address,bool)247 function setApprovalForAll(address operator, bool approved) public {771 function setApprovalForAll(address operator, bool approved) public {248 require(false, stub_error);772 require(false, stub_error);249 operator;773 operator;250 approved;774 approved;251 dummy = 0;775 dummy = 0;252 }776 }253777254 // @dev Not implemented778 /// @dev Not implemented255 //779 /// @dev EVM selector for this function is: 0x081812fc,256 // Selector: getApproved(uint256) 081812fc780 /// or in textual repr: getApproved(uint256)257 function getApproved(uint256 tokenId) public view returns (address) {781 function getApproved(uint256 tokenId) public view returns (address) {258 require(false, stub_error);782 require(false, stub_error);259 tokenId;783 tokenId;260 dummy;784 dummy;261 return 0x0000000000000000000000000000000000000000;785 return 0x0000000000000000000000000000000000000000;262 }786 }263787264 // @dev Not implemented788 /// @dev Not implemented265 //789 /// @dev EVM selector for this function is: 0xe985e9c5,266 // Selector: isApprovedForAll(address,address) e985e9c5790 /// or in textual repr: isApprovedForAll(address,address)267 function isApprovedForAll(address owner, address operator)791 function isApprovedForAll(address owner, address operator)268 public792 public269 view793 view277 }801 }278}802}279280// Selector: 5b5e139f281contract ERC721Metadata is Dummy, ERC165 {282 // @notice A descriptive name for a collection of RFTs in this contract283 //284 // Selector: name() 06fdde03285 function name() public view returns (string memory) {286 require(false, stub_error);287 dummy;288 return "";289 }290291 // @notice An abbreviated name for RFTs in this contract292 //293 // Selector: symbol() 95d89b41294 function symbol() public view returns (string memory) {295 require(false, stub_error);296 dummy;297 return "";298 }299300 // @notice A distinct Uniform Resource Identifier (URI) for a given asset.301 //302 // @dev If the token has a `url` property and it is not empty, it is returned.303 // Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.304 // If the collection property `baseURI` is empty or absent, return "" (empty string)305 // otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix306 // otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).307 //308 // @return token's const_metadata309 //310 // Selector: tokenURI(uint256) c87b56dd311 function tokenURI(uint256 tokenId) public view returns (string memory) {312 require(false, stub_error);313 tokenId;314 dummy;315 return "";316 }317}318319// Selector: 68ccfe89320contract ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {321 // Selector: mintingFinished() 05d2035b322 function mintingFinished() public view returns (bool) {323 require(false, stub_error);324 dummy;325 return false;326 }327328 // @notice Function to mint token.329 // @dev `tokenId` should be obtained with `nextTokenId` method,330 // unlike standard, you can't specify it manually331 // @param to The new owner332 // @param tokenId ID of the minted RFT333 //334 // Selector: mint(address,uint256) 40c10f19335 function mint(address to, uint256 tokenId) public returns (bool) {336 require(false, stub_error);337 to;338 tokenId;339 dummy = 0;340 return false;341 }342343 // @notice Function to mint token with the given tokenUri.344 // @dev `tokenId` should be obtained with `nextTokenId` method,345 // unlike standard, you can't specify it manually346 // @param to The new owner347 // @param tokenId ID of the minted RFT348 // @param tokenUri Token URI that would be stored in the RFT properties349 //350 // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f351 function mintWithTokenURI(352 address to,353 uint256 tokenId,354 string memory tokenUri355 ) public returns (bool) {356 require(false, stub_error);357 to;358 tokenId;359 tokenUri;360 dummy = 0;361 return false;362 }363364 // @dev Not implemented365 //366 // Selector: finishMinting() 7d64bcb4367 function finishMinting() public returns (bool) {368 require(false, stub_error);369 dummy = 0;370 return false;371 }372}373374// Selector: 780e9d63375contract ERC721Enumerable is Dummy, ERC165 {376 // @notice Enumerate valid RFTs377 // @param index A counter less than `totalSupply()`378 // @return The token identifier for the `index`th NFT,379 // (sort order not specified)380 //381 // Selector: tokenByIndex(uint256) 4f6ccce7382 function tokenByIndex(uint256 index) public view returns (uint256) {383 require(false, stub_error);384 index;385 dummy;386 return 0;387 }388389 // Not implemented390 //391 // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59392 function tokenOfOwnerByIndex(address owner, uint256 index)393 public394 view395 returns (uint256)396 {397 require(false, stub_error);398 owner;399 index;400 dummy;401 return 0;402 }403404 // @notice Count RFTs tracked by this contract405 // @return A count of valid RFTs tracked by this contract, where each one of406 // them has an assigned and queryable owner not equal to the zero address407 //408 // Selector: totalSupply() 18160ddd409 function totalSupply() public view returns (uint256) {410 require(false, stub_error);411 dummy;412 return 0;413 }414}415416// Selector: 7c3bef89417contract ERC721UniqueExtensions is Dummy, ERC165 {418 // @notice Transfer ownership of an RFT419 // @dev Throws unless `msg.sender` is the current owner. Throws if `to`420 // is the zero address. Throws if `tokenId` is not a valid RFT.421 // Throws if RFT pieces have multiple owners.422 // @param to The new owner423 // @param tokenId The RFT to transfer424 // @param _value Not used for an RFT425 //426 // Selector: transfer(address,uint256) a9059cbb427 function transfer(address to, uint256 tokenId) public {428 require(false, stub_error);429 to;430 tokenId;431 dummy = 0;432 }433434 // @notice Burns a specific ERC721 token.435 // @dev Throws unless `msg.sender` is the current owner or an authorized436 // operator for this RFT. Throws if `from` is not the current owner. Throws437 // if `to` is the zero address. Throws if `tokenId` is not a valid RFT.438 // Throws if RFT pieces have multiple owners.439 // @param from The current owner of the RFT440 // @param tokenId The RFT to transfer441 // @param _value Not used for an RFT442 //443 // Selector: burnFrom(address,uint256) 79cc6790444 function burnFrom(address from, uint256 tokenId) public {445 require(false, stub_error);446 from;447 tokenId;448 dummy = 0;449 }450451 // @notice Returns next free RFT ID.452 //453 // Selector: nextTokenId() 75794a3c454 function nextTokenId() public view returns (uint256) {455 require(false, stub_error);456 dummy;457 return 0;458 }459460 // @notice Function to mint multiple tokens.461 // @dev `tokenIds` should be an array of consecutive numbers and first number462 // should be obtained with `nextTokenId` method463 // @param to The new owner464 // @param tokenIds IDs of the minted RFTs465 //466 // Selector: mintBulk(address,uint256[]) 44a9945e467 function mintBulk(address to, uint256[] memory tokenIds)468 public469 returns (bool)470 {471 require(false, stub_error);472 to;473 tokenIds;474 dummy = 0;475 return false;476 }477478 // @notice Function to mint multiple tokens with the given tokenUris.479 // @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive480 // numbers and first number should be obtained with `nextTokenId` method481 // @param to The new owner482 // @param tokens array of pairs of token ID and token URI for minted tokens483 //484 // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006485 function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)486 public487 returns (bool)488 {489 require(false, stub_error);490 to;491 tokens;492 dummy = 0;493 return false;494 }495496 // Returns EVM address for refungible token497 //498 // @param token ID of the token499 //500 // Selector: tokenContractAddress(uint256) ab76fac6501 function tokenContractAddress(uint256 token) public view returns (address) {502 require(false, stub_error);503 token;504 dummy;505 return 0x0000000000000000000000000000000000000000;506 }507}508509// Selector: ffe4da23510contract Collection is Dummy, ERC165 {511 // Set collection property.512 //513 // @param key Property key.514 // @param value Propery value.515 //516 // Selector: setCollectionProperty(string,bytes) 2f073f66517 function setCollectionProperty(string memory key, bytes memory value)518 public519 {520 require(false, stub_error);521 key;522 value;523 dummy = 0;524 }525526 // Delete collection property.527 //528 // @param key Property key.529 //530 // Selector: deleteCollectionProperty(string) 7b7debce531 function deleteCollectionProperty(string memory key) public {532 require(false, stub_error);533 key;534 dummy = 0;535 }536537 // Get collection property.538 //539 // @dev Throws error if key not found.540 //541 // @param key Property key.542 // @return bytes The property corresponding to the key.543 //544 // Selector: collectionProperty(string) cf24fd6d545 function collectionProperty(string memory key)546 public547 view548 returns (bytes memory)549 {550 require(false, stub_error);551 key;552 dummy;553 return hex"";554 }555556 // Set the sponsor of the collection.557 //558 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.559 //560 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.561 //562 // Selector: setCollectionSponsor(address) 7623402e563 function setCollectionSponsor(address sponsor) public {564 require(false, stub_error);565 sponsor;566 dummy = 0;567 }568569 // Collection sponsorship confirmation.570 //571 // @dev After setting the sponsor for the collection, it must be confirmed with this function.572 //573 // Selector: confirmCollectionSponsorship() 3c50e97a574 function confirmCollectionSponsorship() public {575 require(false, stub_error);576 dummy = 0;577 }578579 // Set limits for the collection.580 // @dev Throws error if limit not found.581 // @param limit Name of the limit. Valid names:582 // "accountTokenOwnershipLimit",583 // "sponsoredDataSize",584 // "sponsoredDataRateLimit",585 // "tokenLimit",586 // "sponsorTransferTimeout",587 // "sponsorApproveTimeout"588 // @param value Value of the limit.589 //590 // Selector: setCollectionLimit(string,uint32) 6a3841db591 function setCollectionLimit(string memory limit, uint32 value) public {592 require(false, stub_error);593 limit;594 value;595 dummy = 0;596 }597598 // Set limits for the collection.599 // @dev Throws error if limit not found.600 // @param limit Name of the limit. Valid names:601 // "ownerCanTransfer",602 // "ownerCanDestroy",603 // "transfersEnabled"604 // @param value Value of the limit.605 //606 // Selector: setCollectionLimit(string,bool) 993b7fba607 function setCollectionLimit(string memory limit, bool value) public {608 require(false, stub_error);609 limit;610 value;611 dummy = 0;612 }613614 // Get contract address.615 //616 // Selector: contractAddress() f6b4dfb4617 function contractAddress() public view returns (address) {618 require(false, stub_error);619 dummy;620 return 0x0000000000000000000000000000000000000000;621 }622623 // Add collection admin by substrate address.624 // @param new_admin Substrate administrator address.625 //626 // Selector: addCollectionAdminSubstrate(uint256) 5730062b627 function addCollectionAdminSubstrate(uint256 newAdmin) public {628 require(false, stub_error);629 newAdmin;630 dummy = 0;631 }632633 // Remove collection admin by substrate address.634 // @param admin Substrate administrator address.635 //636 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9637 function removeCollectionAdminSubstrate(uint256 admin) public {638 require(false, stub_error);639 admin;640 dummy = 0;641 }642643 // Add collection admin.644 // @param new_admin Address of the added administrator.645 //646 // Selector: addCollectionAdmin(address) 92e462c7647 function addCollectionAdmin(address newAdmin) public {648 require(false, stub_error);649 newAdmin;650 dummy = 0;651 }652653 // Remove collection admin.654 //655 // @param new_admin Address of the removed administrator.656 //657 // Selector: removeCollectionAdmin(address) fafd7b42658 function removeCollectionAdmin(address admin) public {659 require(false, stub_error);660 admin;661 dummy = 0;662 }663664 // Toggle accessibility of collection nesting.665 //666 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'667 //668 // Selector: setCollectionNesting(bool) 112d4586669 function setCollectionNesting(bool enable) public {670 require(false, stub_error);671 enable;672 dummy = 0;673 }674675 // Toggle accessibility of collection nesting.676 //677 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'678 // @param collections Addresses of collections that will be available for nesting.679 //680 // Selector: setCollectionNesting(bool,address[]) 64872396681 function setCollectionNesting(bool enable, address[] memory collections)682 public683 {684 require(false, stub_error);685 enable;686 collections;687 dummy = 0;688 }689690 // Set the collection access method.691 // @param mode Access mode692 // 0 for Normal693 // 1 for AllowList694 //695 // Selector: setCollectionAccess(uint8) 41835d4c696 function setCollectionAccess(uint8 mode) public {697 require(false, stub_error);698 mode;699 dummy = 0;700 }701702 // Add the user to the allowed list.703 //704 // @param user Address of a trusted user.705 //706 // Selector: addToCollectionAllowList(address) 67844fe6707 function addToCollectionAllowList(address user) public {708 require(false, stub_error);709 user;710 dummy = 0;711 }712713 // Remove the user from the allowed list.714 //715 // @param user Address of a removed user.716 //717 // Selector: removeFromCollectionAllowList(address) 85c51acb718 function removeFromCollectionAllowList(address user) public {719 require(false, stub_error);720 user;721 dummy = 0;722 }723724 // Switch permission for minting.725 //726 // @param mode Enable if "true".727 //728 // Selector: setCollectionMintMode(bool) 00018e84729 function setCollectionMintMode(bool mode) public {730 require(false, stub_error);731 mode;732 dummy = 0;733 }734735 // Check that account is the owner or admin of the collection736 //737 // @param user account to verify738 // @return "true" if account is the owner or admin739 //740 // Selector: isOwnerOrAdmin(address) 9811b0c7741 function isOwnerOrAdmin(address user) public view returns (bool) {742 require(false, stub_error);743 user;744 dummy;745 return false;746 }747748 // Check that substrate account is the owner or admin of the collection749 //750 // @param user account to verify751 // @return "true" if account is the owner or admin752 //753 // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00754 function isOwnerOrAdminSubstrate(uint256 user) public view returns (bool) {755 require(false, stub_error);756 user;757 dummy;758 return false;759 }760761 // Returns collection type762 //763 // @return `Fungible` or `NFT` or `ReFungible`764 //765 // Selector: uniqueCollectionType() d34b55b8766 function uniqueCollectionType() public returns (string memory) {767 require(false, stub_error);768 dummy = 0;769 return "";770 }771772 // Changes collection owner to another account773 //774 // @dev Owner can be changed only by current owner775 // @param newOwner new owner account776 //777 // Selector: setOwner(address) 13af4035778 function setOwner(address newOwner) public {779 require(false, stub_error);780 newOwner;781 dummy = 0;782 }783784 // Changes collection owner to another substrate account785 //786 // @dev Owner can be changed only by current owner787 // @param newOwner new owner substrate account788 //789 // Selector: setOwnerSubstrate(uint256) b212138f790 function setOwnerSubstrate(uint256 newOwner) public {791 require(false, stub_error);792 newOwner;793 dummy = 0;794 }795}796803797contract UniqueRefungible is804contract UniqueRefungible is798 Dummy,805 Dummy,pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;556// Common stubs holder6/// @dev common stubs holder7contract Dummy {7contract Dummy {8 uint8 dummy;8 uint8 dummy;9 string stub_error = "this contract is implemented in native";9 string stub_error = "this contract is implemented in native";21 }21 }22}22}232324// Inline24/// @dev the ERC-165 identifier for this interface is 0x042f110625contract ERC1633UniqueExtensions is Dummy, ERC165 {26 /// @dev EVM selector for this function is: 0x042f1106,27 /// or in textual repr: setParentNFT(address,uint256)28 function setParentNFT(address collection, uint256 nftId)29 public30 returns (bool)31 {32 require(false, stub_error);33 collection;34 nftId;35 dummy = 0;36 return false;37 }38}3940/// @dev the ERC-165 identifier for this interface is 0x5755c3f241contract ERC1633 is Dummy, ERC165 {42 /// @dev EVM selector for this function is: 0x80a54001,43 /// or in textual repr: parentToken()44 function parentToken() public view returns (address) {45 require(false, stub_error);46 dummy;47 return 0x0000000000000000000000000000000000000000;48 }4950 /// @dev EVM selector for this function is: 0xd7f083f3,51 /// or in textual repr: parentTokenId()52 function parentTokenId() public view returns (uint256) {53 require(false, stub_error);54 dummy;55 return 0;56 }57}5859/// @dev the ERC-165 identifier for this interface is 0xab8deb3760contract ERC20UniqueExtensions is Dummy, ERC165 {61 /// @dev Function that burns an amount of the token of a given account,62 /// deducting from the sender's allowance for said account.63 /// @param from The account whose tokens will be burnt.64 /// @param amount The amount that will be burnt.65 /// @dev EVM selector for this function is: 0x79cc6790,66 /// or in textual repr: burnFrom(address,uint256)67 function burnFrom(address from, uint256 amount) public returns (bool) {68 require(false, stub_error);69 from;70 amount;71 dummy = 0;72 return false;73 }7475 /// @dev Function that changes total amount of the tokens.76 /// Throws if `msg.sender` doesn't owns all of the tokens.77 /// @param amount New total amount of the tokens.78 /// @dev EVM selector for this function is: 0xd2418ca7,79 /// or in textual repr: repartition(uint256)80 function repartition(uint256 amount) public returns (bool) {81 require(false, stub_error);82 amount;83 dummy = 0;84 return false;85 }86}8788/// @dev inlined interface25contract ERC20Events {89contract ERC20Events {26 event Transfer(address indexed from, address indexed to, uint256 value);90 event Transfer(address indexed from, address indexed to, uint256 value);27 event Approval(91 event Approval(31 );95 );32}96}339734// Selector: 042f110698/// @title Standard ERC20 token35contract ERC1633UniqueExtensions is Dummy, ERC165 {99///36 // Selector: setParentNFT(address,uint256) 042f1106100/// @dev Implementation of the basic standard token.37 function setParentNFT(address collection, uint256 nftId)101/// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md38 public102/// @dev the ERC-165 identifier for this interface is 0x942e8b2239 returns (bool)40 {41 require(false, stub_error);42 collection;43 nftId;44 dummy = 0;45 return false;46 }47}4849// Selector: 5755c3f250contract ERC1633 is Dummy, ERC165 {51 // Selector: parentToken() 80a5400152 function parentToken() public view returns (address) {53 require(false, stub_error);54 dummy;55 return 0x0000000000000000000000000000000000000000;56 }5758 // Selector: parentTokenId() d7f083f359 function parentTokenId() public view returns (uint256) {60 require(false, stub_error);61 dummy;62 return 0;63 }64}6566// Selector: 942e8b2267contract ERC20 is Dummy, ERC165, ERC20Events {103contract ERC20 is Dummy, ERC165, ERC20Events {68 // @return the name of the token.104 /// @return the name of the token.69 //105 /// @dev EVM selector for this function is: 0x06fdde03,70 // Selector: name() 06fdde03106 /// or in textual repr: name()71 function name() public view returns (string memory) {107 function name() public view returns (string memory) {72 require(false, stub_error);108 require(false, stub_error);73 dummy;109 dummy;74 return "";110 return "";75 }111 }7611277 // @return the symbol of the token.113 /// @return the symbol of the token.78 //114 /// @dev EVM selector for this function is: 0x95d89b41,79 // Selector: symbol() 95d89b41115 /// or in textual repr: symbol()80 function symbol() public view returns (string memory) {116 function symbol() public view returns (string memory) {81 require(false, stub_error);117 require(false, stub_error);82 dummy;118 dummy;83 return "";119 return "";84 }120 }8512186 // @dev Total number of tokens in existence122 /// @dev Total number of tokens in existence87 //123 /// @dev EVM selector for this function is: 0x18160ddd,88 // Selector: totalSupply() 18160ddd124 /// or in textual repr: totalSupply()89 function totalSupply() public view returns (uint256) {125 function totalSupply() public view returns (uint256) {90 require(false, stub_error);126 require(false, stub_error);91 dummy;127 dummy;92 return 0;128 return 0;93 }129 }9413095 // @dev Not supported131 /// @dev Not supported96 //132 /// @dev EVM selector for this function is: 0x313ce567,97 // Selector: decimals() 313ce567133 /// or in textual repr: decimals()98 function decimals() public view returns (uint8) {134 function decimals() public view returns (uint8) {99 require(false, stub_error);135 require(false, stub_error);100 dummy;136 dummy;101 return 0;137 return 0;102 }138 }103139104 // @dev Gets the balance of the specified address.140 /// @dev Gets the balance of the specified address.105 // @param owner The address to query the balance of.141 /// @param owner The address to query the balance of.106 // @return An uint256 representing the amount owned by the passed address.142 /// @return An uint256 representing the amount owned by the passed address.107 //143 /// @dev EVM selector for this function is: 0x70a08231,108 // Selector: balanceOf(address) 70a08231144 /// or in textual repr: balanceOf(address)109 function balanceOf(address owner) public view returns (uint256) {145 function balanceOf(address owner) public view returns (uint256) {110 require(false, stub_error);146 require(false, stub_error);111 owner;147 owner;112 dummy;148 dummy;113 return 0;149 return 0;114 }150 }115151116 // @dev Transfer token for a specified address152 /// @dev Transfer token for a specified address117 // @param to The address to transfer to.153 /// @param to The address to transfer to.118 // @param amount The amount to be transferred.154 /// @param amount The amount to be transferred.119 //155 /// @dev EVM selector for this function is: 0xa9059cbb,120 // Selector: transfer(address,uint256) a9059cbb156 /// or in textual repr: transfer(address,uint256)121 function transfer(address to, uint256 amount) public returns (bool) {157 function transfer(address to, uint256 amount) public returns (bool) {122 require(false, stub_error);158 require(false, stub_error);123 to;159 to;126 return false;162 return false;127 }163 }128164129 // @dev Transfer tokens from one address to another165 /// @dev Transfer tokens from one address to another130 // @param from address The address which you want to send tokens from166 /// @param from address The address which you want to send tokens from131 // @param to address The address which you want to transfer to167 /// @param to address The address which you want to transfer to132 // @param amount uint256 the amount of tokens to be transferred168 /// @param amount uint256 the amount of tokens to be transferred133 //169 /// @dev EVM selector for this function is: 0x23b872dd,134 // Selector: transferFrom(address,address,uint256) 23b872dd170 /// or in textual repr: transferFrom(address,address,uint256)135 function transferFrom(171 function transferFrom(136 address from,172 address from,137 address to,173 address to,145 return false;181 return false;146 }182 }147183148 // @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`.184 /// @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`.149 // Beware that changing an allowance with this method brings the risk that someone may use both the old185 /// Beware that changing an allowance with this method brings the risk that someone may use both the old150 // and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this186 /// and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this151 // race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:187 /// race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:152 // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729188 /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729153 // @param spender The address which will spend the funds.189 /// @param spender The address which will spend the funds.154 // @param amount The amount of tokens to be spent.190 /// @param amount The amount of tokens to be spent.155 //191 /// @dev EVM selector for this function is: 0x095ea7b3,156 // Selector: approve(address,uint256) 095ea7b3192 /// or in textual repr: approve(address,uint256)157 function approve(address spender, uint256 amount) public returns (bool) {193 function approve(address spender, uint256 amount) public returns (bool) {158 require(false, stub_error);194 require(false, stub_error);159 spender;195 spender;162 return false;198 return false;163 }199 }164200165 // @dev Function to check the amount of tokens that an owner allowed to a spender.201 /// @dev Function to check the amount of tokens that an owner allowed to a spender.166 // @param owner address The address which owns the funds.202 /// @param owner address The address which owns the funds.167 // @param spender address The address which will spend the funds.203 /// @param spender address The address which will spend the funds.168 // @return A uint256 specifying the amount of tokens still available for the spender.204 /// @return A uint256 specifying the amount of tokens still available for the spender.169 //205 /// @dev EVM selector for this function is: 0xdd62ed3e,170 // Selector: allowance(address,address) dd62ed3e206 /// or in textual repr: allowance(address,address)171 function allowance(address owner, address spender)207 function allowance(address owner, address spender)172 public208 public173 view209 view181 }217 }182}218}183184// Selector: ab8deb37185contract ERC20UniqueExtensions is Dummy, ERC165 {186 // @dev Function that burns an amount of the token of a given account,187 // deducting from the sender's allowance for said account.188 // @param from The account whose tokens will be burnt.189 // @param amount The amount that will be burnt.190 //191 // Selector: burnFrom(address,uint256) 79cc6790192 function burnFrom(address from, uint256 amount) public returns (bool) {193 require(false, stub_error);194 from;195 amount;196 dummy = 0;197 return false;198 }199200 // @dev Function that changes total amount of the tokens.201 // Throws if `msg.sender` doesn't owns all of the tokens.202 // @param amount New total amount of the tokens.203 //204 // Selector: repartition(uint256) d2418ca7205 function repartition(uint256 amount) public returns (bool) {206 require(false, stub_error);207 amount;208 dummy = 0;209 return false;210 }211}212219213contract UniqueRefungibleToken is220contract UniqueRefungibleToken is214 Dummy,221 Dummy,pallets/unique/src/eth/mod.rsdiffbeforeafterboth203}203}204204205/// @title Contract, which allows users to operate with collections205/// @title Contract, which allows users to operate with collections206#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]206#[solidity_interface(name = CollectionHelpers, events(CollectionHelpersEvents))]207impl<T> EvmCollectionHelpers<T>207impl<T> EvmCollectionHelpers<T>208where208where209 T: Config + pallet_nonfungible::Config + pallet_refungible::Config,209 T: Config + pallet_nonfungible::Config + pallet_refungible::Config,210{210{211 /// Create an NFT collection211 /// Create an NFT collection212 /// @param name Name of the collection212 /// @param name Name of the collection213 /// @param description Informative description of the collection213 /// @param description Informative description of the collection214 /// @param token_prefix Token prefix to represent the collection tokens in UI and user applications214 /// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications215 /// @return address Address of the newly created collection215 /// @return address Address of the newly created collection216 #[weight(<SelfWeightOf<T>>::create_collection())]216 #[weight(<SelfWeightOf<T>>::create_collection())]217 fn create_nonfungible_collection(217 fn create_nonfungible_collection(304 }304 }305305306 /// Check if a collection exists306 /// Check if a collection exists307 /// @param collection_address Address of the collection in question307 /// @param collectionAddress Address of the collection in question308 /// @return bool Does the collection exist?308 /// @return bool Does the collection exist?309 fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {309 fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {310 if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {310 if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;556// Common stubs holder6/// @dev common stubs holder7contract Dummy {7contract Dummy {8 uint8 dummy;8 uint8 dummy;9 string stub_error = "this contract is implemented in native";9 string stub_error = "this contract is implemented in native";21 }21 }22}22}232324// Inline24/// @dev inlined interface25contract CollectionHelpersEvents {25contract CollectionHelpersEvents {26 event CollectionCreated(26 event CollectionCreated(27 address indexed owner,27 address indexed owner,28 address indexed collectionId28 address indexed collectionId29 );29 );30}30}313132// Selector: 675f307432/// @title Contract, which allows users to operate with collections33/// @dev the ERC-165 identifier for this interface is 0x675f307433contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {34contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {34 // Create an NFT collection35 /// Create an NFT collection35 // @param name Name of the collection36 /// @param name Name of the collection36 // @param description Informative description of the collection37 /// @param description Informative description of the collection37 // @param token_prefix Token prefix to represent the collection tokens in UI and user applications38 /// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications38 // @return address Address of the newly created collection39 /// @return address Address of the newly created collection39 //40 /// @dev EVM selector for this function is: 0xe34a6844,40 // Selector: createNonfungibleCollection(string,string,string) e34a684441 /// or in textual repr: createNonfungibleCollection(string,string,string)41 function createNonfungibleCollection(42 function createNonfungibleCollection(42 string memory name,43 string memory name,43 string memory description,44 string memory description,51 return 0x0000000000000000000000000000000000000000;52 return 0x0000000000000000000000000000000000000000;52 }53 }535455 /// @dev EVM selector for this function is: 0xa634a5f9,54 // Selector: createERC721MetadataCompatibleCollection(string,string,string,string) a634a5f956 /// or in textual repr: createERC721MetadataCompatibleCollection(string,string,string,string)55 function createERC721MetadataCompatibleCollection(57 function createERC721MetadataCompatibleCollection(56 string memory name,58 string memory name,57 string memory description,59 string memory description,67 return 0x0000000000000000000000000000000000000000;69 return 0x0000000000000000000000000000000000000000;68 }70 }697172 /// @dev EVM selector for this function is: 0x44a68ad5,70 // Selector: createRefungibleCollection(string,string,string) 44a68ad573 /// or in textual repr: createRefungibleCollection(string,string,string)71 function createRefungibleCollection(74 function createRefungibleCollection(72 string memory name,75 string memory name,73 string memory description,76 string memory description,81 return 0x0000000000000000000000000000000000000000;84 return 0x0000000000000000000000000000000000000000;82 }85 }838687 /// @dev EVM selector for this function is: 0xa5596388,84 // Selector: createERC721MetadataCompatibleRFTCollection(string,string,string,string) a559638888 /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)85 function createERC721MetadataCompatibleRFTCollection(89 function createERC721MetadataCompatibleRFTCollection(86 string memory name,90 string memory name,87 string memory description,91 string memory description,97 return 0x0000000000000000000000000000000000000000;101 return 0x0000000000000000000000000000000000000000;98 }102 }99103100 // Check if a collection exists104 /// Check if a collection exists101 // @param collection_address Address of the collection in question105 /// @param collectionAddress Address of the collection in question102 // @return bool Does the collection exist?106 /// @return bool Does the collection exist?103 //107 /// @dev EVM selector for this function is: 0xc3de1494,104 // Selector: isCollectionExist(address) c3de1494108 /// or in textual repr: isCollectionExist(address)105 function isCollectionExist(address collectionAddress)109 function isCollectionExist(address collectionAddress)106 public110 public107 view111 viewruntime/common/config/ethereum.rsdiffbeforeafterboth120120121impl pallet_evm_transaction_payment::Config for Runtime {121impl pallet_evm_transaction_payment::Config for Runtime {122 type EvmSponsorshipHandler = EvmSponsorshipHandler;122 type EvmSponsorshipHandler = EvmSponsorshipHandler;123 type Currency = Balances;124}123}125124tests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;556// Common stubs holder6/// @dev common stubs holder7interface Dummy {7interface Dummy {889}9}12 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);13}13}141415// Inline15/// @dev inlined interface16interface CollectionHelpersEvents {16interface CollectionHelpersEvents {17 event CollectionCreated(17 event CollectionCreated(18 address indexed owner,18 address indexed owner,19 address indexed collectionId19 address indexed collectionId20 );20 );21}21}222223// Selector: 675f307423/// @title Contract, which allows users to operate with collections24/// @dev the ERC-165 identifier for this interface is 0x675f307424interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {25interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {25 // Create an NFT collection26 /// Create an NFT collection26 // @param name Name of the collection27 /// @param name Name of the collection27 // @param description Informative description of the collection28 /// @param description Informative description of the collection28 // @param token_prefix Token prefix to represent the collection tokens in UI and user applications29 /// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications29 // @return address Address of the newly created collection30 /// @return address Address of the newly created collection30 //31 /// @dev EVM selector for this function is: 0xe34a6844,31 // Selector: createNonfungibleCollection(string,string,string) e34a684432 /// or in textual repr: createNonfungibleCollection(string,string,string)32 function createNonfungibleCollection(33 function createNonfungibleCollection(33 string memory name,34 string memory name,34 string memory description,35 string memory description,35 string memory tokenPrefix36 string memory tokenPrefix36 ) external returns (address);37 ) external returns (address);373839 /// @dev EVM selector for this function is: 0xa634a5f9,38 // Selector: createERC721MetadataCompatibleCollection(string,string,string,string) a634a5f940 /// or in textual repr: createERC721MetadataCompatibleCollection(string,string,string,string)39 function createERC721MetadataCompatibleCollection(41 function createERC721MetadataCompatibleCollection(40 string memory name,42 string memory name,41 string memory description,43 string memory description,42 string memory tokenPrefix,44 string memory tokenPrefix,43 string memory baseUri45 string memory baseUri44 ) external returns (address);46 ) external returns (address);454748 /// @dev EVM selector for this function is: 0x44a68ad5,46 // Selector: createRefungibleCollection(string,string,string) 44a68ad549 /// or in textual repr: createRefungibleCollection(string,string,string)47 function createRefungibleCollection(50 function createRefungibleCollection(48 string memory name,51 string memory name,49 string memory description,52 string memory description,50 string memory tokenPrefix53 string memory tokenPrefix51 ) external returns (address);54 ) external returns (address);525556 /// @dev EVM selector for this function is: 0xa5596388,53 // Selector: createERC721MetadataCompatibleRFTCollection(string,string,string,string) a559638857 /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)54 function createERC721MetadataCompatibleRFTCollection(58 function createERC721MetadataCompatibleRFTCollection(55 string memory name,59 string memory name,56 string memory description,60 string memory description,57 string memory tokenPrefix,61 string memory tokenPrefix,58 string memory baseUri62 string memory baseUri59 ) external returns (address);63 ) external returns (address);606461 // Check if a collection exists65 /// Check if a collection exists62 // @param collection_address Address of the collection in question66 /// @param collectionAddress Address of the collection in question63 // @return bool Does the collection exist?67 /// @return bool Does the collection exist?64 //68 /// @dev EVM selector for this function is: 0xc3de1494,65 // Selector: isCollectionExist(address) c3de149469 /// or in textual repr: isCollectionExist(address)66 function isCollectionExist(address collectionAddress)70 function isCollectionExist(address collectionAddress)67 external71 external68 view72 viewtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8 address field_0;9 uint256 field_1;10}11512// Common stubs holder6/// @dev common stubs holder13interface Dummy {7interface Dummy {14815}9}18 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);19}13}201421// Selector: 6073d91715/// @title Magic contract, which allows users to reconfigure other contracts16/// @dev the ERC-165 identifier for this interface is 0xd77fab7022interface ContractHelpers is Dummy, ERC165 {17interface ContractHelpers is Dummy, ERC165 {23 // Get contract ovner18 /// Get user, which deployed specified contract24 //19 /// @dev May return zero address in case if contract is deployed25 // @param Contract_address contract for which the owner is being determined.20 /// using uniquenetwork evm-migration pallet, or using other terms not26 // @return Contract owner.21 /// intended by pallet-evm27 //22 /// @dev Returns zero address if contract does not exists28 // Selector: contractOwner(address) 5152b14c23 /// @param contractAddress Contract to get owner of24 /// @return address Owner of contract25 /// @dev EVM selector for this function is: 0x5152b14c,26 /// or in textual repr: contractOwner(address)29 function contractOwner(address contractAddress)27 function contractOwner(address contractAddress)30 external28 external31 view29 view32 returns (address);30 returns (address);333134 // Set sponsor.32 /// Set sponsor.35 //36 // @param contract_address Contract for which a sponsor is being established.33 /// @param contractAddress Contract for which a sponsor is being established.37 // @param sponsor User address who set as pending sponsor.34 /// @param sponsor User address who set as pending sponsor.38 //35 /// @dev EVM selector for this function is: 0xf01fba93,39 // Selector: setSponsor(address,address) f01fba9336 /// or in textual repr: setSponsor(address,address)40 function setSponsor(address contractAddress, address sponsor) external;37 function setSponsor(address contractAddress, address sponsor) external;413842 // Set contract as self sponsored.39 /// Set contract as self sponsored.43 //40 ///44 // @param contract_address Contract for which a self sponsoring is being enabled.41 /// @param contractAddress Contract for which a self sponsoring is being enabled.45 //42 /// @dev EVM selector for this function is: 0x89f7d9ae,46 // Selector: selfSponsoredEnable(address) 89f7d9ae43 /// or in textual repr: selfSponsoredEnable(address)47 function selfSponsoredEnable(address contractAddress) external;44 function selfSponsoredEnable(address contractAddress) external;484549 // Remove sponsor.46 /// Remove sponsor.50 //47 ///51 // @param contract_address Contract for which a sponsorship is being removed.48 /// @param contractAddress Contract for which a sponsorship is being removed.52 //49 /// @dev EVM selector for this function is: 0xef784250,53 // Selector: removeSponsor(address) ef78425050 /// or in textual repr: removeSponsor(address)54 function removeSponsor(address contractAddress) external;51 function removeSponsor(address contractAddress) external;555256 // Confirm sponsorship.53 /// Confirm sponsorship.57 //54 ///58 // @dev Caller must be same that set via [`set_sponsor`].55 /// @dev Caller must be same that set via [`setSponsor`].59 //56 ///60 // @param contract_address Сontract for which need to confirm sponsorship.57 /// @param contractAddress Сontract for which need to confirm sponsorship.61 //58 /// @dev EVM selector for this function is: 0xabc00001,62 // Selector: confirmSponsorship(address) abc0000159 /// or in textual repr: confirmSponsorship(address)63 function confirmSponsorship(address contractAddress) external;60 function confirmSponsorship(address contractAddress) external;646165 // Get current sponsor.62 /// Get current sponsor.66 //63 ///67 // @param contract_address The contract for which a sponsor is requested.64 /// @param contractAddress The contract for which a sponsor is requested.68 // @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.65 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.69 //66 /// @dev EVM selector for this function is: 0x743fc745,70 // Selector: getSponsor(address) 743fc74567 /// or in textual repr: getSponsor(address)71 function getSponsor(address contractAddress)68 function getSponsor(address contractAddress)72 external69 external73 view70 view74 returns (Tuple0 memory);71 returns (Tuple0 memory);757276 // Check tat contract has confirmed sponsor.73 /// Check tat contract has confirmed sponsor.77 //74 ///78 // @param contract_address The contract for which the presence of a confirmed sponsor is checked.75 /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.79 // @return **true** if contract has confirmed sponsor.76 /// @return **true** if contract has confirmed sponsor.80 //77 /// @dev EVM selector for this function is: 0x97418603,81 // Selector: hasSponsor(address) 9741860378 /// or in textual repr: hasSponsor(address)82 function hasSponsor(address contractAddress) external view returns (bool);79 function hasSponsor(address contractAddress) external view returns (bool);838084 // Check tat contract has pending sponsor.81 /// Check tat contract has pending sponsor.85 //82 ///86 // @param contract_address The contract for which the presence of a pending sponsor is checked.83 /// @param contractAddress The contract for which the presence of a pending sponsor is checked.87 // @return **true** if contract has pending sponsor.84 /// @return **true** if contract has pending sponsor.88 //85 /// @dev EVM selector for this function is: 0x39b9b242,89 // Selector: hasPendingSponsor(address) 39b9b24286 /// or in textual repr: hasPendingSponsor(address)90 function hasPendingSponsor(address contractAddress)87 function hasPendingSponsor(address contractAddress)91 external88 external92 view89 view93 returns (bool);90 returns (bool);949192 /// @dev EVM selector for this function is: 0x6027dc61,95 // Selector: sponsoringEnabled(address) 6027dc6193 /// or in textual repr: sponsoringEnabled(address)96 function sponsoringEnabled(address contractAddress)94 function sponsoringEnabled(address contractAddress)97 external95 external98 view96 view99 returns (bool);97 returns (bool);1009899 /// @dev EVM selector for this function is: 0xfde8a560,101 // Selector: setSponsoringMode(address,uint8) fde8a560100 /// or in textual repr: setSponsoringMode(address,uint8)102 function setSponsoringMode(address contractAddress, uint8 mode) external;101 function setSponsoringMode(address contractAddress, uint8 mode) external;103102104 // Selector: sponsoringMode(address) b70c7267103 /// Get current contract sponsoring rate limit104 /// @param contractAddress Contract to get sponsoring mode of105 /// @return uint32 Amount of blocks between two sponsored transactions106 /// @dev EVM selector for this function is: 0x610cfabd,107 /// or in textual repr: getSponsoringRateLimit(address)105 function sponsoringMode(address contractAddress)108 function getSponsoringRateLimit(address contractAddress)106 external109 external107 view110 view108 returns (uint8);111 returns (uint32);109112113 /// Set contract sponsoring rate limit114 /// @dev Sponsoring rate limit - is a minimum amount of blocks that should115 /// pass between two sponsored transactions116 /// @param contractAddress Contract to change sponsoring rate limit of117 /// @param rateLimit Target rate limit118 /// @dev Only contract owner can change this setting119 /// @dev EVM selector for this function is: 0x77b6c908,110 // Selector: setSponsoringRateLimit(address,uint32) 77b6c908120 /// or in textual repr: setSponsoringRateLimit(address,uint32)111 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)121 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)112 external;122 external;113123114 // Selector: getSponsoringRateLimit(address) 610cfabd124 /// Is specified user present in contract allow list125 /// @dev Contract owner always implicitly included126 /// @param contractAddress Contract to check allowlist of127 /// @param user User to check128 /// @return bool Is specified users exists in contract allowlist129 /// @dev EVM selector for this function is: 0x5c658165,130 /// or in textual repr: allowed(address,address)115 function getSponsoringRateLimit(address contractAddress)131 function allowed(address contractAddress, address user)116 external132 external117 view133 view118 returns (uint32);134 returns (bool);119135120 // Selector: allowed(address,address) 5c658165136 /// Toggle user presence in contract allowlist137 /// @param contractAddress Contract to change allowlist of138 /// @param user Which user presence should be toggled139 /// @param isAllowed `true` if user should be allowed to be sponsored140 /// or call this contract, `false` otherwise141 /// @dev Only contract owner can change this setting142 /// @dev EVM selector for this function is: 0x4706cc1c,143 /// or in textual repr: toggleAllowed(address,address,bool)121 function allowed(address contractAddress, address user)144 function toggleAllowed(145 address contractAddress,146 address user,147 bool isAllowed122 external148 ) external;123 view149124 returns (bool);150 /// Is this contract has allowlist access enabled125151 /// @dev Allowlist always can have users, and it is used for two purposes:126 // Selector: allowlistEnabled(address) c772ef6c152 /// in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist153 /// in case of allowlist access enabled, only users from allowlist may call this contract154 /// @param contractAddress Contract to get allowlist access of155 /// @return bool Is specified contract has allowlist access enabled156 /// @dev EVM selector for this function is: 0xc772ef6c,157 /// or in textual repr: allowlistEnabled(address)127 function allowlistEnabled(address contractAddress)158 function allowlistEnabled(address contractAddress)128 external159 external129 view160 view130 returns (bool);161 returns (bool);131162163 /// Toggle contract allowlist access164 /// @param contractAddress Contract to change allowlist access of165 /// @param enabled Should allowlist access to be enabled?166 /// @dev EVM selector for this function is: 0x36de20f5,132 // Selector: toggleAllowlist(address,bool) 36de20f5167 /// or in textual repr: toggleAllowlist(address,bool)133 function toggleAllowlist(address contractAddress, bool enabled) external;168 function toggleAllowlist(address contractAddress, bool enabled) external;134135 // Selector: toggleAllowed(address,address,bool) 4706cc1c136 function toggleAllowed(137 address contractAddress,138 address user,139 bool allowed140 ) external;141}169}170171/// @dev anonymous struct172struct Tuple0 {173 address field_0;174 uint256 field_1;175}142176tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;556// Common stubs holder6/// @dev common stubs holder7interface Dummy {7interface Dummy {889}9}12 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);13}13}141415// Inline15/// @title A contract that allows you to work with collections.16/// @dev the ERC-165 identifier for this interface is 0xffe4da2317interface Collection is Dummy, ERC165 {18 /// Set collection property.19 ///20 /// @param key Property key.21 /// @param value Propery value.22 /// @dev EVM selector for this function is: 0x2f073f66,23 /// or in textual repr: setCollectionProperty(string,bytes)24 function setCollectionProperty(string memory key, bytes memory value)25 external;2627 /// Delete collection property.28 ///29 /// @param key Property key.30 /// @dev EVM selector for this function is: 0x7b7debce,31 /// or in textual repr: deleteCollectionProperty(string)32 function deleteCollectionProperty(string memory key) external;3334 /// Get collection property.35 ///36 /// @dev Throws error if key not found.37 ///38 /// @param key Property key.39 /// @return bytes The property corresponding to the key.40 /// @dev EVM selector for this function is: 0xcf24fd6d,41 /// or in textual repr: collectionProperty(string)42 function collectionProperty(string memory key)43 external44 view45 returns (bytes memory);4647 /// Set the sponsor of the collection.48 ///49 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.50 ///51 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.52 /// @dev EVM selector for this function is: 0x7623402e,53 /// or in textual repr: setCollectionSponsor(address)54 function setCollectionSponsor(address sponsor) external;5556 /// Collection sponsorship confirmation.57 ///58 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.59 /// @dev EVM selector for this function is: 0x3c50e97a,60 /// or in textual repr: confirmCollectionSponsorship()61 function confirmCollectionSponsorship() external;6263 /// Set limits for the collection.64 /// @dev Throws error if limit not found.65 /// @param limit Name of the limit. Valid names:66 /// "accountTokenOwnershipLimit",67 /// "sponsoredDataSize",68 /// "sponsoredDataRateLimit",69 /// "tokenLimit",70 /// "sponsorTransferTimeout",71 /// "sponsorApproveTimeout"72 /// @param value Value of the limit.73 /// @dev EVM selector for this function is: 0x6a3841db,74 /// or in textual repr: setCollectionLimit(string,uint32)75 function setCollectionLimit(string memory limit, uint32 value) external;7677 /// Set limits for the collection.78 /// @dev Throws error if limit not found.79 /// @param limit Name of the limit. Valid names:80 /// "ownerCanTransfer",81 /// "ownerCanDestroy",82 /// "transfersEnabled"83 /// @param value Value of the limit.84 /// @dev EVM selector for this function is: 0x993b7fba,85 /// or in textual repr: setCollectionLimit(string,bool)86 function setCollectionLimit(string memory limit, bool value) external;8788 /// Get contract address.89 /// @dev EVM selector for this function is: 0xf6b4dfb4,90 /// or in textual repr: contractAddress()91 function contractAddress() external view returns (address);9293 /// Add collection admin by substrate address.94 /// @param newAdmin Substrate administrator address.95 /// @dev EVM selector for this function is: 0x5730062b,96 /// or in textual repr: addCollectionAdminSubstrate(uint256)97 function addCollectionAdminSubstrate(uint256 newAdmin) external;9899 /// Remove collection admin by substrate address.100 /// @param admin Substrate administrator address.101 /// @dev EVM selector for this function is: 0x4048fcf9,102 /// or in textual repr: removeCollectionAdminSubstrate(uint256)103 function removeCollectionAdminSubstrate(uint256 admin) external;104105 /// Add collection admin.106 /// @param newAdmin Address of the added administrator.107 /// @dev EVM selector for this function is: 0x92e462c7,108 /// or in textual repr: addCollectionAdmin(address)109 function addCollectionAdmin(address newAdmin) external;110111 /// Remove collection admin.112 ///113 /// @param admin Address of the removed administrator.114 /// @dev EVM selector for this function is: 0xfafd7b42,115 /// or in textual repr: removeCollectionAdmin(address)116 function removeCollectionAdmin(address admin) external;117118 /// Toggle accessibility of collection nesting.119 ///120 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'121 /// @dev EVM selector for this function is: 0x112d4586,122 /// or in textual repr: setCollectionNesting(bool)123 function setCollectionNesting(bool enable) external;124125 /// Toggle accessibility of collection nesting.126 ///127 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'128 /// @param collections Addresses of collections that will be available for nesting.129 /// @dev EVM selector for this function is: 0x64872396,130 /// or in textual repr: setCollectionNesting(bool,address[])131 function setCollectionNesting(bool enable, address[] memory collections)132 external;133134 /// Set the collection access method.135 /// @param mode Access mode136 /// 0 for Normal137 /// 1 for AllowList138 /// @dev EVM selector for this function is: 0x41835d4c,139 /// or in textual repr: setCollectionAccess(uint8)140 function setCollectionAccess(uint8 mode) external;141142 /// Add the user to the allowed list.143 ///144 /// @param user Address of a trusted user.145 /// @dev EVM selector for this function is: 0x67844fe6,146 /// or in textual repr: addToCollectionAllowList(address)147 function addToCollectionAllowList(address user) external;148149 /// Remove the user from the allowed list.150 ///151 /// @param user Address of a removed user.152 /// @dev EVM selector for this function is: 0x85c51acb,153 /// or in textual repr: removeFromCollectionAllowList(address)154 function removeFromCollectionAllowList(address user) external;155156 /// Switch permission for minting.157 ///158 /// @param mode Enable if "true".159 /// @dev EVM selector for this function is: 0x00018e84,160 /// or in textual repr: setCollectionMintMode(bool)161 function setCollectionMintMode(bool mode) external;162163 /// Check that account is the owner or admin of the collection164 ///165 /// @param user account to verify166 /// @return "true" if account is the owner or admin167 /// @dev EVM selector for this function is: 0x9811b0c7,168 /// or in textual repr: isOwnerOrAdmin(address)169 function isOwnerOrAdmin(address user) external view returns (bool);170171 /// Check that substrate account is the owner or admin of the collection172 ///173 /// @param user account to verify174 /// @return "true" if account is the owner or admin175 /// @dev EVM selector for this function is: 0x68910e00,176 /// or in textual repr: isOwnerOrAdminSubstrate(uint256)177 function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool);178179 /// Returns collection type180 ///181 /// @return `Fungible` or `NFT` or `ReFungible`182 /// @dev EVM selector for this function is: 0xd34b55b8,183 /// or in textual repr: uniqueCollectionType()184 function uniqueCollectionType() external returns (string memory);185186 /// Changes collection owner to another account187 ///188 /// @dev Owner can be changed only by current owner189 /// @param newOwner new owner account190 /// @dev EVM selector for this function is: 0x13af4035,191 /// or in textual repr: setOwner(address)192 function setOwner(address newOwner) external;193194 /// Changes collection owner to another substrate account195 ///196 /// @dev Owner can be changed only by current owner197 /// @param newOwner new owner substrate account198 /// @dev EVM selector for this function is: 0xb212138f,199 /// or in textual repr: setOwnerSubstrate(uint256)200 function setOwnerSubstrate(uint256 newOwner) external;201}202203/// @dev the ERC-165 identifier for this interface is 0x79cc6790204interface ERC20UniqueExtensions is Dummy, ERC165 {205 /// @dev EVM selector for this function is: 0x79cc6790,206 /// or in textual repr: burnFrom(address,uint256)207 function burnFrom(address from, uint256 amount) external returns (bool);208}209210/// @dev inlined interface16interface ERC20Events {211interface ERC20Events {17 event Transfer(address indexed from, address indexed to, uint256 value);212 event Transfer(address indexed from, address indexed to, uint256 value);18 event Approval(213 event Approval(22 );217 );23}218}2421925// Selector: 79cc6790220/// @dev the ERC-165 identifier for this interface is 0x942e8b2226interface ERC20UniqueExtensions is Dummy, ERC165 {27 // Selector: burnFrom(address,uint256) 79cc679028 function burnFrom(address from, uint256 amount) external returns (bool);29}3031// Selector: 942e8b2232interface ERC20 is Dummy, ERC165, ERC20Events {221interface ERC20 is Dummy, ERC165, ERC20Events {33 // Selector: name() 06fdde03222 /// @dev EVM selector for this function is: 0x06fdde03,223 /// or in textual repr: name()34 function name() external view returns (string memory);224 function name() external view returns (string memory);3522536 // Selector: symbol() 95d89b41226 /// @dev EVM selector for this function is: 0x95d89b41,227 /// or in textual repr: symbol()37 function symbol() external view returns (string memory);228 function symbol() external view returns (string memory);3822939 // Selector: totalSupply() 18160ddd230 /// @dev EVM selector for this function is: 0x18160ddd,231 /// or in textual repr: totalSupply()40 function totalSupply() external view returns (uint256);232 function totalSupply() external view returns (uint256);4123342 // Selector: decimals() 313ce567234 /// @dev EVM selector for this function is: 0x313ce567,235 /// or in textual repr: decimals()43 function decimals() external view returns (uint8);236 function decimals() external view returns (uint8);44237238 /// @dev EVM selector for this function is: 0x70a08231,45 // Selector: balanceOf(address) 70a08231239 /// or in textual repr: balanceOf(address)46 function balanceOf(address owner) external view returns (uint256);240 function balanceOf(address owner) external view returns (uint256);47241242 /// @dev EVM selector for this function is: 0xa9059cbb,48 // Selector: transfer(address,uint256) a9059cbb243 /// or in textual repr: transfer(address,uint256)49 function transfer(address to, uint256 amount) external returns (bool);244 function transfer(address to, uint256 amount) external returns (bool);50245246 /// @dev EVM selector for this function is: 0x23b872dd,51 // Selector: transferFrom(address,address,uint256) 23b872dd247 /// or in textual repr: transferFrom(address,address,uint256)52 function transferFrom(248 function transferFrom(53 address from,249 address from,54 address to,250 address to,55 uint256 amount251 uint256 amount56 ) external returns (bool);252 ) external returns (bool);57253254 /// @dev EVM selector for this function is: 0x095ea7b3,58 // Selector: approve(address,uint256) 095ea7b3255 /// or in textual repr: approve(address,uint256)59 function approve(address spender, uint256 amount) external returns (bool);256 function approve(address spender, uint256 amount) external returns (bool);60257258 /// @dev EVM selector for this function is: 0xdd62ed3e,61 // Selector: allowance(address,address) dd62ed3e259 /// or in textual repr: allowance(address,address)62 function allowance(address owner, address spender)260 function allowance(address owner, address spender)63 external261 external64 view262 view65 returns (uint256);263 returns (uint256);66}264}6768// Selector: ffe4da2369interface Collection is Dummy, ERC165 {70 // Set collection property.71 //72 // @param key Property key.73 // @param value Propery value.74 //75 // Selector: setCollectionProperty(string,bytes) 2f073f6676 function setCollectionProperty(string memory key, bytes memory value)77 external;7879 // Delete collection property.80 //81 // @param key Property key.82 //83 // Selector: deleteCollectionProperty(string) 7b7debce84 function deleteCollectionProperty(string memory key) external;8586 // Get collection property.87 //88 // @dev Throws error if key not found.89 //90 // @param key Property key.91 // @return bytes The property corresponding to the key.92 //93 // Selector: collectionProperty(string) cf24fd6d94 function collectionProperty(string memory key)95 external96 view97 returns (bytes memory);9899 // Set the sponsor of the collection.100 //101 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.102 //103 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.104 //105 // Selector: setCollectionSponsor(address) 7623402e106 function setCollectionSponsor(address sponsor) external;107108 // Collection sponsorship confirmation.109 //110 // @dev After setting the sponsor for the collection, it must be confirmed with this function.111 //112 // Selector: confirmCollectionSponsorship() 3c50e97a113 function confirmCollectionSponsorship() external;114115 // Set limits for the collection.116 // @dev Throws error if limit not found.117 // @param limit Name of the limit. Valid names:118 // "accountTokenOwnershipLimit",119 // "sponsoredDataSize",120 // "sponsoredDataRateLimit",121 // "tokenLimit",122 // "sponsorTransferTimeout",123 // "sponsorApproveTimeout"124 // @param value Value of the limit.125 //126 // Selector: setCollectionLimit(string,uint32) 6a3841db127 function setCollectionLimit(string memory limit, uint32 value) external;128129 // Set limits for the collection.130 // @dev Throws error if limit not found.131 // @param limit Name of the limit. Valid names:132 // "ownerCanTransfer",133 // "ownerCanDestroy",134 // "transfersEnabled"135 // @param value Value of the limit.136 //137 // Selector: setCollectionLimit(string,bool) 993b7fba138 function setCollectionLimit(string memory limit, bool value) external;139140 // Get contract address.141 //142 // Selector: contractAddress() f6b4dfb4143 function contractAddress() external view returns (address);144145 // Add collection admin by substrate address.146 // @param new_admin Substrate administrator address.147 //148 // Selector: addCollectionAdminSubstrate(uint256) 5730062b149 function addCollectionAdminSubstrate(uint256 newAdmin) external;150151 // Remove collection admin by substrate address.152 // @param admin Substrate administrator address.153 //154 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9155 function removeCollectionAdminSubstrate(uint256 admin) external;156157 // Add collection admin.158 // @param new_admin Address of the added administrator.159 //160 // Selector: addCollectionAdmin(address) 92e462c7161 function addCollectionAdmin(address newAdmin) external;162163 // Remove collection admin.164 //165 // @param new_admin Address of the removed administrator.166 //167 // Selector: removeCollectionAdmin(address) fafd7b42168 function removeCollectionAdmin(address admin) external;169170 // Toggle accessibility of collection nesting.171 //172 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'173 //174 // Selector: setCollectionNesting(bool) 112d4586175 function setCollectionNesting(bool enable) external;176177 // Toggle accessibility of collection nesting.178 //179 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'180 // @param collections Addresses of collections that will be available for nesting.181 //182 // Selector: setCollectionNesting(bool,address[]) 64872396183 function setCollectionNesting(bool enable, address[] memory collections)184 external;185186 // Set the collection access method.187 // @param mode Access mode188 // 0 for Normal189 // 1 for AllowList190 //191 // Selector: setCollectionAccess(uint8) 41835d4c192 function setCollectionAccess(uint8 mode) external;193194 // Add the user to the allowed list.195 //196 // @param user Address of a trusted user.197 //198 // Selector: addToCollectionAllowList(address) 67844fe6199 function addToCollectionAllowList(address user) external;200201 // Remove the user from the allowed list.202 //203 // @param user Address of a removed user.204 //205 // Selector: removeFromCollectionAllowList(address) 85c51acb206 function removeFromCollectionAllowList(address user) external;207208 // Switch permission for minting.209 //210 // @param mode Enable if "true".211 //212 // Selector: setCollectionMintMode(bool) 00018e84213 function setCollectionMintMode(bool mode) external;214215 // Check that account is the owner or admin of the collection216 //217 // @param user account to verify218 // @return "true" if account is the owner or admin219 //220 // Selector: isOwnerOrAdmin(address) 9811b0c7221 function isOwnerOrAdmin(address user) external view returns (bool);222223 // Check that substrate account is the owner or admin of the collection224 //225 // @param user account to verify226 // @return "true" if account is the owner or admin227 //228 // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00229 function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool);230231 // Returns collection type232 //233 // @return `Fungible` or `NFT` or `ReFungible`234 //235 // Selector: uniqueCollectionType() d34b55b8236 function uniqueCollectionType() external returns (string memory);237238 // Changes collection owner to another account239 //240 // @dev Owner can be changed only by current owner241 // @param newOwner new owner account242 //243 // Selector: setOwner(address) 13af4035244 function setOwner(address newOwner) external;245246 // Changes collection owner to another substrate account247 //248 // @dev Owner can be changed only by current owner249 // @param newOwner new owner substrate account250 //251 // Selector: setOwnerSubstrate(uint256) b212138f252 function setOwnerSubstrate(uint256 newOwner) external;253}254265255interface UniqueFungible is266interface UniqueFungible is256 Dummy,267 Dummy,tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8 uint256 field_0;9 string field_1;10}11512// Common stubs holder6/// @dev common stubs holder13interface Dummy {7interface Dummy {14815}9}18 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);19}13}201421// Inline15/// @title A contract that allows to set and delete token properties and change token property permissions.16/// @dev the ERC-165 identifier for this interface is 0x4136937717interface TokenProperties is Dummy, ERC165 {18 /// @notice Set permissions for token property.19 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.20 /// @param key Property key.21 /// @param isMutable Permission to mutate property.22 /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.23 /// @param tokenOwner Permission to mutate property by token owner if property is mutable.24 /// @dev EVM selector for this function is: 0x222d97fa,25 /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)26 function setTokenPropertyPermission(27 string memory key,28 bool isMutable,29 bool collectionAdmin,30 bool tokenOwner31 ) external;3233 /// @notice Set token property value.34 /// @dev Throws error if `msg.sender` has no permission to edit the property.35 /// @param tokenId ID of the token.36 /// @param key Property key.37 /// @param value Property value.38 /// @dev EVM selector for this function is: 0x1752d67b,39 /// or in textual repr: setProperty(uint256,string,bytes)40 function setProperty(41 uint256 tokenId,42 string memory key,43 bytes memory value44 ) external;4546 /// @notice Delete token property value.47 /// @dev Throws error if `msg.sender` has no permission to edit the property.48 /// @param tokenId ID of the token.49 /// @param key Property key.50 /// @dev EVM selector for this function is: 0x066111d1,51 /// or in textual repr: deleteProperty(uint256,string)52 function deleteProperty(uint256 tokenId, string memory key) external;5354 /// @notice Get token property value.55 /// @dev Throws error if key not found56 /// @param tokenId ID of the token.57 /// @param key Property key.58 /// @return Property value bytes59 /// @dev EVM selector for this function is: 0x7228c327,60 /// or in textual repr: property(uint256,string)61 function property(uint256 tokenId, string memory key)62 external63 view64 returns (bytes memory);65}6667/// @title A contract that allows you to work with collections.68/// @dev the ERC-165 identifier for this interface is 0xffe4da2369interface Collection is Dummy, ERC165 {70 /// Set collection property.71 ///72 /// @param key Property key.73 /// @param value Propery value.74 /// @dev EVM selector for this function is: 0x2f073f66,75 /// or in textual repr: setCollectionProperty(string,bytes)76 function setCollectionProperty(string memory key, bytes memory value)77 external;7879 /// Delete collection property.80 ///81 /// @param key Property key.82 /// @dev EVM selector for this function is: 0x7b7debce,83 /// or in textual repr: deleteCollectionProperty(string)84 function deleteCollectionProperty(string memory key) external;8586 /// Get collection property.87 ///88 /// @dev Throws error if key not found.89 ///90 /// @param key Property key.91 /// @return bytes The property corresponding to the key.92 /// @dev EVM selector for this function is: 0xcf24fd6d,93 /// or in textual repr: collectionProperty(string)94 function collectionProperty(string memory key)95 external96 view97 returns (bytes memory);9899 /// Set the sponsor of the collection.100 ///101 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.102 ///103 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.104 /// @dev EVM selector for this function is: 0x7623402e,105 /// or in textual repr: setCollectionSponsor(address)106 function setCollectionSponsor(address sponsor) external;107108 /// Collection sponsorship confirmation.109 ///110 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.111 /// @dev EVM selector for this function is: 0x3c50e97a,112 /// or in textual repr: confirmCollectionSponsorship()113 function confirmCollectionSponsorship() external;114115 /// Set limits for the collection.116 /// @dev Throws error if limit not found.117 /// @param limit Name of the limit. Valid names:118 /// "accountTokenOwnershipLimit",119 /// "sponsoredDataSize",120 /// "sponsoredDataRateLimit",121 /// "tokenLimit",122 /// "sponsorTransferTimeout",123 /// "sponsorApproveTimeout"124 /// @param value Value of the limit.125 /// @dev EVM selector for this function is: 0x6a3841db,126 /// or in textual repr: setCollectionLimit(string,uint32)127 function setCollectionLimit(string memory limit, uint32 value) external;128129 /// Set limits for the collection.130 /// @dev Throws error if limit not found.131 /// @param limit Name of the limit. Valid names:132 /// "ownerCanTransfer",133 /// "ownerCanDestroy",134 /// "transfersEnabled"135 /// @param value Value of the limit.136 /// @dev EVM selector for this function is: 0x993b7fba,137 /// or in textual repr: setCollectionLimit(string,bool)138 function setCollectionLimit(string memory limit, bool value) external;139140 /// Get contract address.141 /// @dev EVM selector for this function is: 0xf6b4dfb4,142 /// or in textual repr: contractAddress()143 function contractAddress() external view returns (address);144145 /// Add collection admin by substrate address.146 /// @param newAdmin Substrate administrator address.147 /// @dev EVM selector for this function is: 0x5730062b,148 /// or in textual repr: addCollectionAdminSubstrate(uint256)149 function addCollectionAdminSubstrate(uint256 newAdmin) external;150151 /// Remove collection admin by substrate address.152 /// @param admin Substrate administrator address.153 /// @dev EVM selector for this function is: 0x4048fcf9,154 /// or in textual repr: removeCollectionAdminSubstrate(uint256)155 function removeCollectionAdminSubstrate(uint256 admin) external;156157 /// Add collection admin.158 /// @param newAdmin Address of the added administrator.159 /// @dev EVM selector for this function is: 0x92e462c7,160 /// or in textual repr: addCollectionAdmin(address)161 function addCollectionAdmin(address newAdmin) external;162163 /// Remove collection admin.164 ///165 /// @param admin Address of the removed administrator.166 /// @dev EVM selector for this function is: 0xfafd7b42,167 /// or in textual repr: removeCollectionAdmin(address)168 function removeCollectionAdmin(address admin) external;169170 /// Toggle accessibility of collection nesting.171 ///172 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'173 /// @dev EVM selector for this function is: 0x112d4586,174 /// or in textual repr: setCollectionNesting(bool)175 function setCollectionNesting(bool enable) external;176177 /// Toggle accessibility of collection nesting.178 ///179 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'180 /// @param collections Addresses of collections that will be available for nesting.181 /// @dev EVM selector for this function is: 0x64872396,182 /// or in textual repr: setCollectionNesting(bool,address[])183 function setCollectionNesting(bool enable, address[] memory collections)184 external;185186 /// Set the collection access method.187 /// @param mode Access mode188 /// 0 for Normal189 /// 1 for AllowList190 /// @dev EVM selector for this function is: 0x41835d4c,191 /// or in textual repr: setCollectionAccess(uint8)192 function setCollectionAccess(uint8 mode) external;193194 /// Add the user to the allowed list.195 ///196 /// @param user Address of a trusted user.197 /// @dev EVM selector for this function is: 0x67844fe6,198 /// or in textual repr: addToCollectionAllowList(address)199 function addToCollectionAllowList(address user) external;200201 /// Remove the user from the allowed list.202 ///203 /// @param user Address of a removed user.204 /// @dev EVM selector for this function is: 0x85c51acb,205 /// or in textual repr: removeFromCollectionAllowList(address)206 function removeFromCollectionAllowList(address user) external;207208 /// Switch permission for minting.209 ///210 /// @param mode Enable if "true".211 /// @dev EVM selector for this function is: 0x00018e84,212 /// or in textual repr: setCollectionMintMode(bool)213 function setCollectionMintMode(bool mode) external;214215 /// Check that account is the owner or admin of the collection216 ///217 /// @param user account to verify218 /// @return "true" if account is the owner or admin219 /// @dev EVM selector for this function is: 0x9811b0c7,220 /// or in textual repr: isOwnerOrAdmin(address)221 function isOwnerOrAdmin(address user) external view returns (bool);222223 /// Check that substrate account is the owner or admin of the collection224 ///225 /// @param user account to verify226 /// @return "true" if account is the owner or admin227 /// @dev EVM selector for this function is: 0x68910e00,228 /// or in textual repr: isOwnerOrAdminSubstrate(uint256)229 function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool);230231 /// Returns collection type232 ///233 /// @return `Fungible` or `NFT` or `ReFungible`234 /// @dev EVM selector for this function is: 0xd34b55b8,235 /// or in textual repr: uniqueCollectionType()236 function uniqueCollectionType() external returns (string memory);237238 /// Changes collection owner to another account239 ///240 /// @dev Owner can be changed only by current owner241 /// @param newOwner new owner account242 /// @dev EVM selector for this function is: 0x13af4035,243 /// or in textual repr: setOwner(address)244 function setOwner(address newOwner) external;245246 /// Changes collection owner to another substrate account247 ///248 /// @dev Owner can be changed only by current owner249 /// @param newOwner new owner substrate account250 /// @dev EVM selector for this function is: 0xb212138f,251 /// or in textual repr: setOwnerSubstrate(uint256)252 function setOwnerSubstrate(uint256 newOwner) external;253}254255/// @title ERC721 Token that can be irreversibly burned (destroyed).256/// @dev the ERC-165 identifier for this interface is 0x42966c68257interface ERC721Burnable is Dummy, ERC165 {258 /// @notice Burns a specific ERC721 token.259 /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized260 /// operator of the current owner.261 /// @param tokenId The NFT to approve262 /// @dev EVM selector for this function is: 0x42966c68,263 /// or in textual repr: burn(uint256)264 function burn(uint256 tokenId) external;265}266267/// @dev inlined interface268interface ERC721MintableEvents {269 event MintingFinished();270}271272/// @title ERC721 minting logic.273/// @dev the ERC-165 identifier for this interface is 0x68ccfe89274interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {275 /// @dev EVM selector for this function is: 0x05d2035b,276 /// or in textual repr: mintingFinished()277 function mintingFinished() external view returns (bool);278279 /// @notice Function to mint token.280 /// @dev `tokenId` should be obtained with `nextTokenId` method,281 /// unlike standard, you can't specify it manually282 /// @param to The new owner283 /// @param tokenId ID of the minted NFT284 /// @dev EVM selector for this function is: 0x40c10f19,285 /// or in textual repr: mint(address,uint256)286 function mint(address to, uint256 tokenId) external returns (bool);287288 /// @notice Function to mint token with the given tokenUri.289 /// @dev `tokenId` should be obtained with `nextTokenId` method,290 /// unlike standard, you can't specify it manually291 /// @param to The new owner292 /// @param tokenId ID of the minted NFT293 /// @param tokenUri Token URI that would be stored in the NFT properties294 /// @dev EVM selector for this function is: 0x50bb4e7f,295 /// or in textual repr: mintWithTokenURI(address,uint256,string)296 function mintWithTokenURI(297 address to,298 uint256 tokenId,299 string memory tokenUri300 ) external returns (bool);301302 /// @dev Not implemented303 /// @dev EVM selector for this function is: 0x7d64bcb4,304 /// or in textual repr: finishMinting()305 function finishMinting() external returns (bool);306}307308/// @title Unique extensions for ERC721.309/// @dev the ERC-165 identifier for this interface is 0xd74d154f310interface ERC721UniqueExtensions is Dummy, ERC165 {311 /// @notice Transfer ownership of an NFT312 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`313 /// is the zero address. Throws if `tokenId` is not a valid NFT.314 /// @param to The new owner315 /// @param tokenId The NFT to transfer316 /// @dev EVM selector for this function is: 0xa9059cbb,317 /// or in textual repr: transfer(address,uint256)318 function transfer(address to, uint256 tokenId) external;319320 /// @notice Burns a specific ERC721 token.321 /// @dev Throws unless `msg.sender` is the current owner or an authorized322 /// operator for this NFT. Throws if `from` is not the current owner. Throws323 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.324 /// @param from The current owner of the NFT325 /// @param tokenId The NFT to transfer326 /// @dev EVM selector for this function is: 0x79cc6790,327 /// or in textual repr: burnFrom(address,uint256)328 function burnFrom(address from, uint256 tokenId) external;329330 /// @notice Returns next free NFT ID.331 /// @dev EVM selector for this function is: 0x75794a3c,332 /// or in textual repr: nextTokenId()333 function nextTokenId() external view returns (uint256);334335 /// @notice Function to mint multiple tokens.336 /// @dev `tokenIds` should be an array of consecutive numbers and first number337 /// should be obtained with `nextTokenId` method338 /// @param to The new owner339 /// @param tokenIds IDs of the minted NFTs340 /// @dev EVM selector for this function is: 0x44a9945e,341 /// or in textual repr: mintBulk(address,uint256[])342 function mintBulk(address to, uint256[] memory tokenIds)343 external344 returns (bool);345346 /// @notice Function to mint multiple tokens with the given tokenUris.347 /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive348 /// numbers and first number should be obtained with `nextTokenId` method349 /// @param to The new owner350 /// @param tokens array of pairs of token ID and token URI for minted tokens351 /// @dev EVM selector for this function is: 0x36543006,352 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])353 function mintBulkWithTokenURI(address to, Tuple8[] memory tokens)354 external355 returns (bool);356}357358/// @dev anonymous struct359struct Tuple8 {360 uint256 field_0;361 string field_1;362}363364/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension365/// @dev See https://eips.ethereum.org/EIPS/eip-721366/// @dev the ERC-165 identifier for this interface is 0x780e9d63367interface ERC721Enumerable is Dummy, ERC165 {368 /// @notice Enumerate valid NFTs369 /// @param index A counter less than `totalSupply()`370 /// @return The token identifier for the `index`th NFT,371 /// (sort order not specified)372 /// @dev EVM selector for this function is: 0x4f6ccce7,373 /// or in textual repr: tokenByIndex(uint256)374 function tokenByIndex(uint256 index) external view returns (uint256);375376 /// @dev Not implemented377 /// @dev EVM selector for this function is: 0x2f745c59,378 /// or in textual repr: tokenOfOwnerByIndex(address,uint256)379 function tokenOfOwnerByIndex(address owner, uint256 index)380 external381 view382 returns (uint256);383384 /// @notice Count NFTs tracked by this contract385 /// @return A count of valid NFTs tracked by this contract, where each one of386 /// them has an assigned and queryable owner not equal to the zero address387 /// @dev EVM selector for this function is: 0x18160ddd,388 /// or in textual repr: totalSupply()389 function totalSupply() external view returns (uint256);390}391392/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension393/// @dev See https://eips.ethereum.org/EIPS/eip-721394/// @dev the ERC-165 identifier for this interface is 0x5b5e139f395interface ERC721Metadata is Dummy, ERC165 {396 /// @notice A descriptive name for a collection of NFTs in this contract397 /// @dev EVM selector for this function is: 0x06fdde03,398 /// or in textual repr: name()399 function name() external view returns (string memory);400401 /// @notice An abbreviated name for NFTs in this contract402 /// @dev EVM selector for this function is: 0x95d89b41,403 /// or in textual repr: symbol()404 function symbol() external view returns (string memory);405406 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.407 ///408 /// @dev If the token has a `url` property and it is not empty, it is returned.409 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.410 /// If the collection property `baseURI` is empty or absent, return "" (empty string)411 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix412 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).413 ///414 /// @return token's const_metadata415 /// @dev EVM selector for this function is: 0xc87b56dd,416 /// or in textual repr: tokenURI(uint256)417 function tokenURI(uint256 tokenId) external view returns (string memory);418}419420/// @dev inlined interface22interface ERC721Events {421interface ERC721Events {23 event Transfer(422 event Transfer(24 address indexed from,423 address indexed from,37 );436 );38}437}3943840// Inline439/// @title ERC-721 Non-Fungible Token Standard41interface ERC721MintableEvents {440/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md42 event MintingFinished();441/// @dev the ERC-165 identifier for this interface is 0x80ac58cd43}4445// Selector: 4136937746interface TokenProperties is Dummy, ERC165 {47 // @notice Set permissions for token property.48 // @dev Throws error if `msg.sender` is not admin or owner of the collection.49 // @param key Property key.50 // @param is_mutable Permission to mutate property.51 // @param collection_admin Permission to mutate property by collection admin if property is mutable.52 // @param token_owner Permission to mutate property by token owner if property is mutable.53 //54 // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa55 function setTokenPropertyPermission(56 string memory key,57 bool isMutable,58 bool collectionAdmin,59 bool tokenOwner60 ) external;6162 // @notice Set token property value.63 // @dev Throws error if `msg.sender` has no permission to edit the property.64 // @param tokenId ID of the token.65 // @param key Property key.66 // @param value Property value.67 //68 // Selector: setProperty(uint256,string,bytes) 1752d67b69 function setProperty(70 uint256 tokenId,71 string memory key,72 bytes memory value73 ) external;7475 // @notice Delete token property value.76 // @dev Throws error if `msg.sender` has no permission to edit the property.77 // @param tokenId ID of the token.78 // @param key Property key.79 //80 // Selector: deleteProperty(uint256,string) 066111d181 function deleteProperty(uint256 tokenId, string memory key) external;8283 // @notice Get token property value.84 // @dev Throws error if key not found85 // @param tokenId ID of the token.86 // @param key Property key.87 // @return Property value bytes88 //89 // Selector: property(uint256,string) 7228c32790 function property(uint256 tokenId, string memory key)91 external92 view93 returns (bytes memory);94}9596// Selector: 42966c6897interface ERC721Burnable is Dummy, ERC165 {98 // @notice Burns a specific ERC721 token.99 // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized100 // operator of the current owner.101 // @param tokenId The NFT to approve102 //103 // Selector: burn(uint256) 42966c68104 function burn(uint256 tokenId) external;105}106107// Selector: 58800161108interface ERC721 is Dummy, ERC165, ERC721Events {442interface ERC721 is Dummy, ERC165, ERC721Events {109 // @notice Count all NFTs assigned to an owner443 /// @notice Count all NFTs assigned to an owner110 // @dev NFTs assigned to the zero address are considered invalid, and this444 /// @dev NFTs assigned to the zero address are considered invalid, and this111 // function throws for queries about the zero address.445 /// function throws for queries about the zero address.112 // @param owner An address for whom to query the balance446 /// @param owner An address for whom to query the balance113 // @return The number of NFTs owned by `owner`, possibly zero447 /// @return The number of NFTs owned by `owner`, possibly zero114 //448 /// @dev EVM selector for this function is: 0x70a08231,115 // Selector: balanceOf(address) 70a08231449 /// or in textual repr: balanceOf(address)116 function balanceOf(address owner) external view returns (uint256);450 function balanceOf(address owner) external view returns (uint256);117451118 // @notice Find the owner of an NFT452 /// @notice Find the owner of an NFT119 // @dev NFTs assigned to zero address are considered invalid, and queries453 /// @dev NFTs assigned to zero address are considered invalid, and queries120 // about them do throw.454 /// about them do throw.121 // @param tokenId The identifier for an NFT455 /// @param tokenId The identifier for an NFT122 // @return The address of the owner of the NFT456 /// @return The address of the owner of the NFT123 //457 /// @dev EVM selector for this function is: 0x6352211e,124 // Selector: ownerOf(uint256) 6352211e458 /// or in textual repr: ownerOf(uint256)125 function ownerOf(uint256 tokenId) external view returns (address);459 function ownerOf(uint256 tokenId) external view returns (address);126460127 // @dev Not implemented461 /// @dev Not implemented128 //462 /// @dev EVM selector for this function is: 0xb88d4fde,129 // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672463 /// or in textual repr: safeTransferFrom(address,address,uint256,bytes)130 function safeTransferFromWithData(464 function safeTransferFrom(131 address from,465 address from,132 address to,466 address to,133 uint256 tokenId,467 uint256 tokenId,134 bytes memory data468 bytes memory data135 ) external;469 ) external;136470137 // @dev Not implemented471 /// @dev Not implemented138 //472 /// @dev EVM selector for this function is: 0x42842e0e,139 // Selector: safeTransferFrom(address,address,uint256) 42842e0e473 /// or in textual repr: safeTransferFrom(address,address,uint256)140 function safeTransferFrom(474 function safeTransferFrom(141 address from,475 address from,142 address to,476 address to,143 uint256 tokenId477 uint256 tokenId144 ) external;478 ) external;145479146 // @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE480 /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE147 // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE481 /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE148 // THEY MAY BE PERMANENTLY LOST482 /// THEY MAY BE PERMANENTLY LOST149 // @dev Throws unless `msg.sender` is the current owner or an authorized483 /// @dev Throws unless `msg.sender` is the current owner or an authorized150 // operator for this NFT. Throws if `from` is not the current owner. Throws484 /// operator for this NFT. Throws if `from` is not the current owner. Throws151 // if `to` is the zero address. Throws if `tokenId` is not a valid NFT.485 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.152 // @param from The current owner of the NFT486 /// @param from The current owner of the NFT153 // @param to The new owner487 /// @param to The new owner154 // @param tokenId The NFT to transfer488 /// @param tokenId The NFT to transfer155 // @param _value Not used for an NFT489 /// @dev EVM selector for this function is: 0x23b872dd,156 //157 // Selector: transferFrom(address,address,uint256) 23b872dd490 /// or in textual repr: transferFrom(address,address,uint256)158 function transferFrom(491 function transferFrom(159 address from,492 address from,160 address to,493 address to,161 uint256 tokenId494 uint256 tokenId162 ) external;495 ) external;163496164 // @notice Set or reaffirm the approved address for an NFT497 /// @notice Set or reaffirm the approved address for an NFT165 // @dev The zero address indicates there is no approved address.498 /// @dev The zero address indicates there is no approved address.166 // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized499 /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized167 // operator of the current owner.500 /// operator of the current owner.168 // @param approved The new approved NFT controller501 /// @param approved The new approved NFT controller169 // @param tokenId The NFT to approve502 /// @param tokenId The NFT to approve170 //503 /// @dev EVM selector for this function is: 0x095ea7b3,171 // Selector: approve(address,uint256) 095ea7b3504 /// or in textual repr: approve(address,uint256)172 function approve(address approved, uint256 tokenId) external;505 function approve(address approved, uint256 tokenId) external;173506174 // @dev Not implemented507 /// @dev Not implemented175 //508 /// @dev EVM selector for this function is: 0xa22cb465,176 // Selector: setApprovalForAll(address,bool) a22cb465509 /// or in textual repr: setApprovalForAll(address,bool)177 function setApprovalForAll(address operator, bool approved) external;510 function setApprovalForAll(address operator, bool approved) external;178511179 // @dev Not implemented512 /// @dev Not implemented180 //513 /// @dev EVM selector for this function is: 0x081812fc,181 // Selector: getApproved(uint256) 081812fc514 /// or in textual repr: getApproved(uint256)182 function getApproved(uint256 tokenId) external view returns (address);515 function getApproved(uint256 tokenId) external view returns (address);183516184 // @dev Not implemented517 /// @dev Not implemented185 //518 /// @dev EVM selector for this function is: 0xe985e9c5,186 // Selector: isApprovedForAll(address,address) e985e9c5519 /// or in textual repr: isApprovedForAll(address,address)187 function isApprovedForAll(address owner, address operator)520 function isApprovedForAll(address owner, address operator)188 external521 external189 view522 view190 returns (address);523 returns (address);191}524}192193// Selector: 5b5e139f194interface ERC721Metadata is Dummy, ERC165 {195 // @notice A descriptive name for a collection of NFTs in this contract196 //197 // Selector: name() 06fdde03198 function name() external view returns (string memory);199200 // @notice An abbreviated name for NFTs in this contract201 //202 // Selector: symbol() 95d89b41203 function symbol() external view returns (string memory);204205 // @notice A distinct Uniform Resource Identifier (URI) for a given asset.206 //207 // @dev If the token has a `url` property and it is not empty, it is returned.208 // Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.209 // If the collection property `baseURI` is empty or absent, return "" (empty string)210 // otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix211 // otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).212 //213 // @return token's const_metadata214 //215 // Selector: tokenURI(uint256) c87b56dd216 function tokenURI(uint256 tokenId) external view returns (string memory);217}218219// Selector: 68ccfe89220interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {221 // Selector: mintingFinished() 05d2035b222 function mintingFinished() external view returns (bool);223224 // @notice Function to mint token.225 // @dev `tokenId` should be obtained with `nextTokenId` method,226 // unlike standard, you can't specify it manually227 // @param to The new owner228 // @param tokenId ID of the minted NFT229 //230 // Selector: mint(address,uint256) 40c10f19231 function mint(address to, uint256 tokenId) external returns (bool);232233 // @notice Function to mint token with the given tokenUri.234 // @dev `tokenId` should be obtained with `nextTokenId` method,235 // unlike standard, you can't specify it manually236 // @param to The new owner237 // @param tokenId ID of the minted NFT238 // @param tokenUri Token URI that would be stored in the NFT properties239 //240 // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f241 function mintWithTokenURI(242 address to,243 uint256 tokenId,244 string memory tokenUri245 ) external returns (bool);246247 // @dev Not implemented248 //249 // Selector: finishMinting() 7d64bcb4250 function finishMinting() external returns (bool);251}252253// Selector: 780e9d63254interface ERC721Enumerable is Dummy, ERC165 {255 // @notice Enumerate valid NFTs256 // @param index A counter less than `totalSupply()`257 // @return The token identifier for the `index`th NFT,258 // (sort order not specified)259 //260 // Selector: tokenByIndex(uint256) 4f6ccce7261 function tokenByIndex(uint256 index) external view returns (uint256);262263 // @dev Not implemented264 //265 // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59266 function tokenOfOwnerByIndex(address owner, uint256 index)267 external268 view269 returns (uint256);270271 // @notice Count NFTs tracked by this contract272 // @return A count of valid NFTs tracked by this contract, where each one of273 // them has an assigned and queryable owner not equal to the zero address274 //275 // Selector: totalSupply() 18160ddd276 function totalSupply() external view returns (uint256);277}278279// Selector: d74d154f280interface ERC721UniqueExtensions is Dummy, ERC165 {281 // @notice Transfer ownership of an NFT282 // @dev Throws unless `msg.sender` is the current owner. Throws if `to`283 // is the zero address. Throws if `tokenId` is not a valid NFT.284 // @param to The new owner285 // @param tokenId The NFT to transfer286 // @param _value Not used for an NFT287 //288 // Selector: transfer(address,uint256) a9059cbb289 function transfer(address to, uint256 tokenId) external;290291 // @notice Burns a specific ERC721 token.292 // @dev Throws unless `msg.sender` is the current owner or an authorized293 // operator for this NFT. Throws if `from` is not the current owner. Throws294 // if `to` is the zero address. Throws if `tokenId` is not a valid NFT.295 // @param from The current owner of the NFT296 // @param tokenId The NFT to transfer297 // @param _value Not used for an NFT298 //299 // Selector: burnFrom(address,uint256) 79cc6790300 function burnFrom(address from, uint256 tokenId) external;301302 // @notice Returns next free NFT ID.303 //304 // Selector: nextTokenId() 75794a3c305 function nextTokenId() external view returns (uint256);306307 // @notice Function to mint multiple tokens.308 // @dev `tokenIds` should be an array of consecutive numbers and first number309 // should be obtained with `nextTokenId` method310 // @param to The new owner311 // @param tokenIds IDs of the minted NFTs312 //313 // Selector: mintBulk(address,uint256[]) 44a9945e314 function mintBulk(address to, uint256[] memory tokenIds)315 external316 returns (bool);317318 // @notice Function to mint multiple tokens with the given tokenUris.319 // @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive320 // numbers and first number should be obtained with `nextTokenId` method321 // @param to The new owner322 // @param tokens array of pairs of token ID and token URI for minted tokens323 //324 // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006325 function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)326 external327 returns (bool);328}329330// Selector: ffe4da23331interface Collection is Dummy, ERC165 {332 // Set collection property.333 //334 // @param key Property key.335 // @param value Propery value.336 //337 // Selector: setCollectionProperty(string,bytes) 2f073f66338 function setCollectionProperty(string memory key, bytes memory value)339 external;340341 // Delete collection property.342 //343 // @param key Property key.344 //345 // Selector: deleteCollectionProperty(string) 7b7debce346 function deleteCollectionProperty(string memory key) external;347348 // Get collection property.349 //350 // @dev Throws error if key not found.351 //352 // @param key Property key.353 // @return bytes The property corresponding to the key.354 //355 // Selector: collectionProperty(string) cf24fd6d356 function collectionProperty(string memory key)357 external358 view359 returns (bytes memory);360361 // Set the sponsor of the collection.362 //363 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.364 //365 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.366 //367 // Selector: setCollectionSponsor(address) 7623402e368 function setCollectionSponsor(address sponsor) external;369370 // Collection sponsorship confirmation.371 //372 // @dev After setting the sponsor for the collection, it must be confirmed with this function.373 //374 // Selector: confirmCollectionSponsorship() 3c50e97a375 function confirmCollectionSponsorship() external;376377 // Set limits for the collection.378 // @dev Throws error if limit not found.379 // @param limit Name of the limit. Valid names:380 // "accountTokenOwnershipLimit",381 // "sponsoredDataSize",382 // "sponsoredDataRateLimit",383 // "tokenLimit",384 // "sponsorTransferTimeout",385 // "sponsorApproveTimeout"386 // @param value Value of the limit.387 //388 // Selector: setCollectionLimit(string,uint32) 6a3841db389 function setCollectionLimit(string memory limit, uint32 value) external;390391 // Set limits for the collection.392 // @dev Throws error if limit not found.393 // @param limit Name of the limit. Valid names:394 // "ownerCanTransfer",395 // "ownerCanDestroy",396 // "transfersEnabled"397 // @param value Value of the limit.398 //399 // Selector: setCollectionLimit(string,bool) 993b7fba400 function setCollectionLimit(string memory limit, bool value) external;401402 // Get contract address.403 //404 // Selector: contractAddress() f6b4dfb4405 function contractAddress() external view returns (address);406407 // Add collection admin by substrate address.408 // @param new_admin Substrate administrator address.409 //410 // Selector: addCollectionAdminSubstrate(uint256) 5730062b411 function addCollectionAdminSubstrate(uint256 newAdmin) external;412413 // Remove collection admin by substrate address.414 // @param admin Substrate administrator address.415 //416 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9417 function removeCollectionAdminSubstrate(uint256 admin) external;418419 // Add collection admin.420 // @param new_admin Address of the added administrator.421 //422 // Selector: addCollectionAdmin(address) 92e462c7423 function addCollectionAdmin(address newAdmin) external;424425 // Remove collection admin.426 //427 // @param new_admin Address of the removed administrator.428 //429 // Selector: removeCollectionAdmin(address) fafd7b42430 function removeCollectionAdmin(address admin) external;431432 // Toggle accessibility of collection nesting.433 //434 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'435 //436 // Selector: setCollectionNesting(bool) 112d4586437 function setCollectionNesting(bool enable) external;438439 // Toggle accessibility of collection nesting.440 //441 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'442 // @param collections Addresses of collections that will be available for nesting.443 //444 // Selector: setCollectionNesting(bool,address[]) 64872396445 function setCollectionNesting(bool enable, address[] memory collections)446 external;447448 // Set the collection access method.449 // @param mode Access mode450 // 0 for Normal451 // 1 for AllowList452 //453 // Selector: setCollectionAccess(uint8) 41835d4c454 function setCollectionAccess(uint8 mode) external;455456 // Add the user to the allowed list.457 //458 // @param user Address of a trusted user.459 //460 // Selector: addToCollectionAllowList(address) 67844fe6461 function addToCollectionAllowList(address user) external;462463 // Remove the user from the allowed list.464 //465 // @param user Address of a removed user.466 //467 // Selector: removeFromCollectionAllowList(address) 85c51acb468 function removeFromCollectionAllowList(address user) external;469470 // Switch permission for minting.471 //472 // @param mode Enable if "true".473 //474 // Selector: setCollectionMintMode(bool) 00018e84475 function setCollectionMintMode(bool mode) external;476477 // Check that account is the owner or admin of the collection478 //479 // @param user account to verify480 // @return "true" if account is the owner or admin481 //482 // Selector: isOwnerOrAdmin(address) 9811b0c7483 function isOwnerOrAdmin(address user) external view returns (bool);484485 // Check that substrate account is the owner or admin of the collection486 //487 // @param user account to verify488 // @return "true" if account is the owner or admin489 //490 // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00491 function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool);492493 // Returns collection type494 //495 // @return `Fungible` or `NFT` or `ReFungible`496 //497 // Selector: uniqueCollectionType() d34b55b8498 function uniqueCollectionType() external returns (string memory);499500 // Changes collection owner to another account501 //502 // @dev Owner can be changed only by current owner503 // @param newOwner new owner account504 //505 // Selector: setOwner(address) 13af4035506 function setOwner(address newOwner) external;507508 // Changes collection owner to another substrate account509 //510 // @dev Owner can be changed only by current owner511 // @param newOwner new owner substrate account512 //513 // Selector: setOwnerSubstrate(uint256) b212138f514 function setOwnerSubstrate(uint256 newOwner) external;515}516525517interface UniqueNFT is526interface UniqueNFT is518 Dummy,527 Dummy,tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8 uint256 field_0;9 string field_1;10}11512// Common stubs holder6/// @dev common stubs holder13interface Dummy {7interface Dummy {14815}9}18 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);19}13}201421// Inline15/// @title A contract that allows to set and delete token properties and change token property permissions.16/// @dev the ERC-165 identifier for this interface is 0x4136937717interface TokenProperties is Dummy, ERC165 {18 /// @notice Set permissions for token property.19 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.20 /// @param key Property key.21 /// @param isMutable Permission to mutate property.22 /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.23 /// @param tokenOwner Permission to mutate property by token owner if property is mutable.24 /// @dev EVM selector for this function is: 0x222d97fa,25 /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)26 function setTokenPropertyPermission(27 string memory key,28 bool isMutable,29 bool collectionAdmin,30 bool tokenOwner31 ) external;3233 /// @notice Set token property value.34 /// @dev Throws error if `msg.sender` has no permission to edit the property.35 /// @param tokenId ID of the token.36 /// @param key Property key.37 /// @param value Property value.38 /// @dev EVM selector for this function is: 0x1752d67b,39 /// or in textual repr: setProperty(uint256,string,bytes)40 function setProperty(41 uint256 tokenId,42 string memory key,43 bytes memory value44 ) external;4546 /// @notice Delete token property value.47 /// @dev Throws error if `msg.sender` has no permission to edit the property.48 /// @param tokenId ID of the token.49 /// @param key Property key.50 /// @dev EVM selector for this function is: 0x066111d1,51 /// or in textual repr: deleteProperty(uint256,string)52 function deleteProperty(uint256 tokenId, string memory key) external;5354 /// @notice Get token property value.55 /// @dev Throws error if key not found56 /// @param tokenId ID of the token.57 /// @param key Property key.58 /// @return Property value bytes59 /// @dev EVM selector for this function is: 0x7228c327,60 /// or in textual repr: property(uint256,string)61 function property(uint256 tokenId, string memory key)62 external63 view64 returns (bytes memory);65}6667/// @title A contract that allows you to work with collections.68/// @dev the ERC-165 identifier for this interface is 0xffe4da2369interface Collection is Dummy, ERC165 {70 /// Set collection property.71 ///72 /// @param key Property key.73 /// @param value Propery value.74 /// @dev EVM selector for this function is: 0x2f073f66,75 /// or in textual repr: setCollectionProperty(string,bytes)76 function setCollectionProperty(string memory key, bytes memory value)77 external;7879 /// Delete collection property.80 ///81 /// @param key Property key.82 /// @dev EVM selector for this function is: 0x7b7debce,83 /// or in textual repr: deleteCollectionProperty(string)84 function deleteCollectionProperty(string memory key) external;8586 /// Get collection property.87 ///88 /// @dev Throws error if key not found.89 ///90 /// @param key Property key.91 /// @return bytes The property corresponding to the key.92 /// @dev EVM selector for this function is: 0xcf24fd6d,93 /// or in textual repr: collectionProperty(string)94 function collectionProperty(string memory key)95 external96 view97 returns (bytes memory);9899 /// Set the sponsor of the collection.100 ///101 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.102 ///103 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.104 /// @dev EVM selector for this function is: 0x7623402e,105 /// or in textual repr: setCollectionSponsor(address)106 function setCollectionSponsor(address sponsor) external;107108 /// Collection sponsorship confirmation.109 ///110 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.111 /// @dev EVM selector for this function is: 0x3c50e97a,112 /// or in textual repr: confirmCollectionSponsorship()113 function confirmCollectionSponsorship() external;114115 /// Set limits for the collection.116 /// @dev Throws error if limit not found.117 /// @param limit Name of the limit. Valid names:118 /// "accountTokenOwnershipLimit",119 /// "sponsoredDataSize",120 /// "sponsoredDataRateLimit",121 /// "tokenLimit",122 /// "sponsorTransferTimeout",123 /// "sponsorApproveTimeout"124 /// @param value Value of the limit.125 /// @dev EVM selector for this function is: 0x6a3841db,126 /// or in textual repr: setCollectionLimit(string,uint32)127 function setCollectionLimit(string memory limit, uint32 value) external;128129 /// Set limits for the collection.130 /// @dev Throws error if limit not found.131 /// @param limit Name of the limit. Valid names:132 /// "ownerCanTransfer",133 /// "ownerCanDestroy",134 /// "transfersEnabled"135 /// @param value Value of the limit.136 /// @dev EVM selector for this function is: 0x993b7fba,137 /// or in textual repr: setCollectionLimit(string,bool)138 function setCollectionLimit(string memory limit, bool value) external;139140 /// Get contract address.141 /// @dev EVM selector for this function is: 0xf6b4dfb4,142 /// or in textual repr: contractAddress()143 function contractAddress() external view returns (address);144145 /// Add collection admin by substrate address.146 /// @param newAdmin Substrate administrator address.147 /// @dev EVM selector for this function is: 0x5730062b,148 /// or in textual repr: addCollectionAdminSubstrate(uint256)149 function addCollectionAdminSubstrate(uint256 newAdmin) external;150151 /// Remove collection admin by substrate address.152 /// @param admin Substrate administrator address.153 /// @dev EVM selector for this function is: 0x4048fcf9,154 /// or in textual repr: removeCollectionAdminSubstrate(uint256)155 function removeCollectionAdminSubstrate(uint256 admin) external;156157 /// Add collection admin.158 /// @param newAdmin Address of the added administrator.159 /// @dev EVM selector for this function is: 0x92e462c7,160 /// or in textual repr: addCollectionAdmin(address)161 function addCollectionAdmin(address newAdmin) external;162163 /// Remove collection admin.164 ///165 /// @param admin Address of the removed administrator.166 /// @dev EVM selector for this function is: 0xfafd7b42,167 /// or in textual repr: removeCollectionAdmin(address)168 function removeCollectionAdmin(address admin) external;169170 /// Toggle accessibility of collection nesting.171 ///172 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'173 /// @dev EVM selector for this function is: 0x112d4586,174 /// or in textual repr: setCollectionNesting(bool)175 function setCollectionNesting(bool enable) external;176177 /// Toggle accessibility of collection nesting.178 ///179 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'180 /// @param collections Addresses of collections that will be available for nesting.181 /// @dev EVM selector for this function is: 0x64872396,182 /// or in textual repr: setCollectionNesting(bool,address[])183 function setCollectionNesting(bool enable, address[] memory collections)184 external;185186 /// Set the collection access method.187 /// @param mode Access mode188 /// 0 for Normal189 /// 1 for AllowList190 /// @dev EVM selector for this function is: 0x41835d4c,191 /// or in textual repr: setCollectionAccess(uint8)192 function setCollectionAccess(uint8 mode) external;193194 /// Add the user to the allowed list.195 ///196 /// @param user Address of a trusted user.197 /// @dev EVM selector for this function is: 0x67844fe6,198 /// or in textual repr: addToCollectionAllowList(address)199 function addToCollectionAllowList(address user) external;200201 /// Remove the user from the allowed list.202 ///203 /// @param user Address of a removed user.204 /// @dev EVM selector for this function is: 0x85c51acb,205 /// or in textual repr: removeFromCollectionAllowList(address)206 function removeFromCollectionAllowList(address user) external;207208 /// Switch permission for minting.209 ///210 /// @param mode Enable if "true".211 /// @dev EVM selector for this function is: 0x00018e84,212 /// or in textual repr: setCollectionMintMode(bool)213 function setCollectionMintMode(bool mode) external;214215 /// Check that account is the owner or admin of the collection216 ///217 /// @param user account to verify218 /// @return "true" if account is the owner or admin219 /// @dev EVM selector for this function is: 0x9811b0c7,220 /// or in textual repr: isOwnerOrAdmin(address)221 function isOwnerOrAdmin(address user) external view returns (bool);222223 /// Check that substrate account is the owner or admin of the collection224 ///225 /// @param user account to verify226 /// @return "true" if account is the owner or admin227 /// @dev EVM selector for this function is: 0x68910e00,228 /// or in textual repr: isOwnerOrAdminSubstrate(uint256)229 function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool);230231 /// Returns collection type232 ///233 /// @return `Fungible` or `NFT` or `ReFungible`234 /// @dev EVM selector for this function is: 0xd34b55b8,235 /// or in textual repr: uniqueCollectionType()236 function uniqueCollectionType() external returns (string memory);237238 /// Changes collection owner to another account239 ///240 /// @dev Owner can be changed only by current owner241 /// @param newOwner new owner account242 /// @dev EVM selector for this function is: 0x13af4035,243 /// or in textual repr: setOwner(address)244 function setOwner(address newOwner) external;245246 /// Changes collection owner to another substrate account247 ///248 /// @dev Owner can be changed only by current owner249 /// @param newOwner new owner substrate account250 /// @dev EVM selector for this function is: 0xb212138f,251 /// or in textual repr: setOwnerSubstrate(uint256)252 function setOwnerSubstrate(uint256 newOwner) external;253}254255/// @title ERC721 Token that can be irreversibly burned (destroyed).256/// @dev the ERC-165 identifier for this interface is 0x42966c68257interface ERC721Burnable is Dummy, ERC165 {258 /// @notice Burns a specific ERC721 token.259 /// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized260 /// operator of the current owner.261 /// @param tokenId The RFT to approve262 /// @dev EVM selector for this function is: 0x42966c68,263 /// or in textual repr: burn(uint256)264 function burn(uint256 tokenId) external;265}266267/// @dev inlined interface268interface ERC721MintableEvents {269 event MintingFinished();270}271272/// @title ERC721 minting logic.273/// @dev the ERC-165 identifier for this interface is 0x68ccfe89274interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {275 /// @dev EVM selector for this function is: 0x05d2035b,276 /// or in textual repr: mintingFinished()277 function mintingFinished() external view returns (bool);278279 /// @notice Function to mint token.280 /// @dev `tokenId` should be obtained with `nextTokenId` method,281 /// unlike standard, you can't specify it manually282 /// @param to The new owner283 /// @param tokenId ID of the minted RFT284 /// @dev EVM selector for this function is: 0x40c10f19,285 /// or in textual repr: mint(address,uint256)286 function mint(address to, uint256 tokenId) external returns (bool);287288 /// @notice Function to mint token with the given tokenUri.289 /// @dev `tokenId` should be obtained with `nextTokenId` method,290 /// unlike standard, you can't specify it manually291 /// @param to The new owner292 /// @param tokenId ID of the minted RFT293 /// @param tokenUri Token URI that would be stored in the RFT properties294 /// @dev EVM selector for this function is: 0x50bb4e7f,295 /// or in textual repr: mintWithTokenURI(address,uint256,string)296 function mintWithTokenURI(297 address to,298 uint256 tokenId,299 string memory tokenUri300 ) external returns (bool);301302 /// @dev Not implemented303 /// @dev EVM selector for this function is: 0x7d64bcb4,304 /// or in textual repr: finishMinting()305 function finishMinting() external returns (bool);306}307308/// @title Unique extensions for ERC721.309/// @dev the ERC-165 identifier for this interface is 0x7c3bef89310interface ERC721UniqueExtensions is Dummy, ERC165 {311 /// @notice Transfer ownership of an RFT312 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`313 /// is the zero address. Throws if `tokenId` is not a valid RFT.314 /// Throws if RFT pieces have multiple owners.315 /// @param to The new owner316 /// @param tokenId The RFT to transfer317 /// @dev EVM selector for this function is: 0xa9059cbb,318 /// or in textual repr: transfer(address,uint256)319 function transfer(address to, uint256 tokenId) external;320321 /// @notice Burns a specific ERC721 token.322 /// @dev Throws unless `msg.sender` is the current owner or an authorized323 /// operator for this RFT. Throws if `from` is not the current owner. Throws324 /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.325 /// Throws if RFT pieces have multiple owners.326 /// @param from The current owner of the RFT327 /// @param tokenId The RFT to transfer328 /// @dev EVM selector for this function is: 0x79cc6790,329 /// or in textual repr: burnFrom(address,uint256)330 function burnFrom(address from, uint256 tokenId) external;331332 /// @notice Returns next free RFT ID.333 /// @dev EVM selector for this function is: 0x75794a3c,334 /// or in textual repr: nextTokenId()335 function nextTokenId() external view returns (uint256);336337 /// @notice Function to mint multiple tokens.338 /// @dev `tokenIds` should be an array of consecutive numbers and first number339 /// should be obtained with `nextTokenId` method340 /// @param to The new owner341 /// @param tokenIds IDs of the minted RFTs342 /// @dev EVM selector for this function is: 0x44a9945e,343 /// or in textual repr: mintBulk(address,uint256[])344 function mintBulk(address to, uint256[] memory tokenIds)345 external346 returns (bool);347348 /// @notice Function to mint multiple tokens with the given tokenUris.349 /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive350 /// numbers and first number should be obtained with `nextTokenId` method351 /// @param to The new owner352 /// @param tokens array of pairs of token ID and token URI for minted tokens353 /// @dev EVM selector for this function is: 0x36543006,354 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])355 function mintBulkWithTokenURI(address to, Tuple8[] memory tokens)356 external357 returns (bool);358359 /// Returns EVM address for refungible token360 ///361 /// @param token ID of the token362 /// @dev EVM selector for this function is: 0xab76fac6,363 /// or in textual repr: tokenContractAddress(uint256)364 function tokenContractAddress(uint256 token)365 external366 view367 returns (address);368}369370/// @dev anonymous struct371struct Tuple8 {372 uint256 field_0;373 string field_1;374}375376/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension377/// @dev See https://eips.ethereum.org/EIPS/eip-721378/// @dev the ERC-165 identifier for this interface is 0x780e9d63379interface ERC721Enumerable is Dummy, ERC165 {380 /// @notice Enumerate valid RFTs381 /// @param index A counter less than `totalSupply()`382 /// @return The token identifier for the `index`th NFT,383 /// (sort order not specified)384 /// @dev EVM selector for this function is: 0x4f6ccce7,385 /// or in textual repr: tokenByIndex(uint256)386 function tokenByIndex(uint256 index) external view returns (uint256);387388 /// Not implemented389 /// @dev EVM selector for this function is: 0x2f745c59,390 /// or in textual repr: tokenOfOwnerByIndex(address,uint256)391 function tokenOfOwnerByIndex(address owner, uint256 index)392 external393 view394 returns (uint256);395396 /// @notice Count RFTs tracked by this contract397 /// @return A count of valid RFTs tracked by this contract, where each one of398 /// them has an assigned and queryable owner not equal to the zero address399 /// @dev EVM selector for this function is: 0x18160ddd,400 /// or in textual repr: totalSupply()401 function totalSupply() external view returns (uint256);402}403404/// @dev the ERC-165 identifier for this interface is 0x5b5e139f405interface ERC721Metadata is Dummy, ERC165 {406 /// @notice A descriptive name for a collection of RFTs in this contract407 /// @dev EVM selector for this function is: 0x06fdde03,408 /// or in textual repr: name()409 function name() external view returns (string memory);410411 /// @notice An abbreviated name for RFTs in this contract412 /// @dev EVM selector for this function is: 0x95d89b41,413 /// or in textual repr: symbol()414 function symbol() external view returns (string memory);415416 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.417 ///418 /// @dev If the token has a `url` property and it is not empty, it is returned.419 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.420 /// If the collection property `baseURI` is empty or absent, return "" (empty string)421 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix422 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).423 ///424 /// @return token's const_metadata425 /// @dev EVM selector for this function is: 0xc87b56dd,426 /// or in textual repr: tokenURI(uint256)427 function tokenURI(uint256 tokenId) external view returns (string memory);428}429430/// @dev inlined interface22interface ERC721Events {431interface ERC721Events {23 event Transfer(432 event Transfer(24 address indexed from,433 address indexed from,37 );446 );38}447}3944840// Inline449/// @title ERC-721 Non-Fungible Token Standard41interface ERC721MintableEvents {450/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md42 event MintingFinished();451/// @dev the ERC-165 identifier for this interface is 0x5880016143}4445// Selector: 4136937746interface TokenProperties is Dummy, ERC165 {47 // @notice Set permissions for token property.48 // @dev Throws error if `msg.sender` is not admin or owner of the collection.49 // @param key Property key.50 // @param is_mutable Permission to mutate property.51 // @param collection_admin Permission to mutate property by collection admin if property is mutable.52 // @param token_owner Permission to mutate property by token owner if property is mutable.53 //54 // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa55 function setTokenPropertyPermission(56 string memory key,57 bool isMutable,58 bool collectionAdmin,59 bool tokenOwner60 ) external;6162 // @notice Set token property value.63 // @dev Throws error if `msg.sender` has no permission to edit the property.64 // @param tokenId ID of the token.65 // @param key Property key.66 // @param value Property value.67 //68 // Selector: setProperty(uint256,string,bytes) 1752d67b69 function setProperty(70 uint256 tokenId,71 string memory key,72 bytes memory value73 ) external;7475 // @notice Delete token property value.76 // @dev Throws error if `msg.sender` has no permission to edit the property.77 // @param tokenId ID of the token.78 // @param key Property key.79 //80 // Selector: deleteProperty(uint256,string) 066111d181 function deleteProperty(uint256 tokenId, string memory key) external;8283 // @notice Get token property value.84 // @dev Throws error if key not found85 // @param tokenId ID of the token.86 // @param key Property key.87 // @return Property value bytes88 //89 // Selector: property(uint256,string) 7228c32790 function property(uint256 tokenId, string memory key)91 external92 view93 returns (bytes memory);94}9596// Selector: 42966c6897interface ERC721Burnable is Dummy, ERC165 {98 // @notice Burns a specific ERC721 token.99 // @dev Throws unless `msg.sender` is the current RFT owner, or an authorized100 // operator of the current owner.101 // @param tokenId The RFT to approve102 //103 // Selector: burn(uint256) 42966c68104 function burn(uint256 tokenId) external;105}106107// Selector: 58800161108interface ERC721 is Dummy, ERC165, ERC721Events {452interface ERC721 is Dummy, ERC165, ERC721Events {109 // @notice Count all RFTs assigned to an owner453 /// @notice Count all RFTs assigned to an owner110 // @dev RFTs assigned to the zero address are considered invalid, and this454 /// @dev RFTs assigned to the zero address are considered invalid, and this111 // function throws for queries about the zero address.455 /// function throws for queries about the zero address.112 // @param owner An address for whom to query the balance456 /// @param owner An address for whom to query the balance113 // @return The number of RFTs owned by `owner`, possibly zero457 /// @return The number of RFTs owned by `owner`, possibly zero114 //458 /// @dev EVM selector for this function is: 0x70a08231,115 // Selector: balanceOf(address) 70a08231459 /// or in textual repr: balanceOf(address)116 function balanceOf(address owner) external view returns (uint256);460 function balanceOf(address owner) external view returns (uint256);117461118 // @notice Find the owner of an RFT462 /// @notice Find the owner of an RFT119 // @dev RFTs assigned to zero address are considered invalid, and queries463 /// @dev RFTs assigned to zero address are considered invalid, and queries120 // about them do throw.464 /// about them do throw.121 // Returns special 0xffffffffffffffffffffffffffffffffffffffff address for465 /// Returns special 0xffffffffffffffffffffffffffffffffffffffff address for122 // the tokens that are partially owned.466 /// the tokens that are partially owned.123 // @param tokenId The identifier for an RFT467 /// @param tokenId The identifier for an RFT124 // @return The address of the owner of the RFT468 /// @return The address of the owner of the RFT125 //469 /// @dev EVM selector for this function is: 0x6352211e,126 // Selector: ownerOf(uint256) 6352211e470 /// or in textual repr: ownerOf(uint256)127 function ownerOf(uint256 tokenId) external view returns (address);471 function ownerOf(uint256 tokenId) external view returns (address);128472129 // @dev Not implemented473 /// @dev Not implemented130 //474 /// @dev EVM selector for this function is: 0x60a11672,131 // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672475 /// or in textual repr: safeTransferFromWithData(address,address,uint256,bytes)132 function safeTransferFromWithData(476 function safeTransferFromWithData(133 address from,477 address from,134 address to,478 address to,135 uint256 tokenId,479 uint256 tokenId,136 bytes memory data480 bytes memory data137 ) external;481 ) external;138482139 // @dev Not implemented483 /// @dev Not implemented140 //484 /// @dev EVM selector for this function is: 0x42842e0e,141 // Selector: safeTransferFrom(address,address,uint256) 42842e0e485 /// or in textual repr: safeTransferFrom(address,address,uint256)142 function safeTransferFrom(486 function safeTransferFrom(143 address from,487 address from,144 address to,488 address to,145 uint256 tokenId489 uint256 tokenId146 ) external;490 ) external;147491148 // @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE492 /// @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE149 // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE493 /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE150 // THEY MAY BE PERMANENTLY LOST494 /// THEY MAY BE PERMANENTLY LOST151 // @dev Throws unless `msg.sender` is the current owner or an authorized495 /// @dev Throws unless `msg.sender` is the current owner or an authorized152 // operator for this RFT. Throws if `from` is not the current owner. Throws496 /// operator for this RFT. Throws if `from` is not the current owner. Throws153 // if `to` is the zero address. Throws if `tokenId` is not a valid RFT.497 /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.154 // Throws if RFT pieces have multiple owners.498 /// Throws if RFT pieces have multiple owners.155 // @param from The current owner of the NFT499 /// @param from The current owner of the NFT156 // @param to The new owner500 /// @param to The new owner157 // @param tokenId The NFT to transfer501 /// @param tokenId The NFT to transfer158 // @param _value Not used for an NFT502 /// @dev EVM selector for this function is: 0x23b872dd,159 //160 // Selector: transferFrom(address,address,uint256) 23b872dd503 /// or in textual repr: transferFrom(address,address,uint256)161 function transferFrom(504 function transferFrom(162 address from,505 address from,163 address to,506 address to,164 uint256 tokenId507 uint256 tokenId165 ) external;508 ) external;166509167 // @dev Not implemented510 /// @dev Not implemented168 //511 /// @dev EVM selector for this function is: 0x095ea7b3,169 // Selector: approve(address,uint256) 095ea7b3512 /// or in textual repr: approve(address,uint256)170 function approve(address approved, uint256 tokenId) external;513 function approve(address approved, uint256 tokenId) external;171514172 // @dev Not implemented515 /// @dev Not implemented173 //516 /// @dev EVM selector for this function is: 0xa22cb465,174 // Selector: setApprovalForAll(address,bool) a22cb465517 /// or in textual repr: setApprovalForAll(address,bool)175 function setApprovalForAll(address operator, bool approved) external;518 function setApprovalForAll(address operator, bool approved) external;176519177 // @dev Not implemented520 /// @dev Not implemented178 //521 /// @dev EVM selector for this function is: 0x081812fc,179 // Selector: getApproved(uint256) 081812fc522 /// or in textual repr: getApproved(uint256)180 function getApproved(uint256 tokenId) external view returns (address);523 function getApproved(uint256 tokenId) external view returns (address);181524182 // @dev Not implemented525 /// @dev Not implemented183 //526 /// @dev EVM selector for this function is: 0xe985e9c5,184 // Selector: isApprovedForAll(address,address) e985e9c5527 /// or in textual repr: isApprovedForAll(address,address)185 function isApprovedForAll(address owner, address operator)528 function isApprovedForAll(address owner, address operator)186 external529 external187 view530 view188 returns (address);531 returns (address);189}532}190191// Selector: 5b5e139f192interface ERC721Metadata is Dummy, ERC165 {193 // @notice A descriptive name for a collection of RFTs in this contract194 //195 // Selector: name() 06fdde03196 function name() external view returns (string memory);197198 // @notice An abbreviated name for RFTs in this contract199 //200 // Selector: symbol() 95d89b41201 function symbol() external view returns (string memory);202203 // @notice A distinct Uniform Resource Identifier (URI) for a given asset.204 //205 // @dev If the token has a `url` property and it is not empty, it is returned.206 // Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.207 // If the collection property `baseURI` is empty or absent, return "" (empty string)208 // otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix209 // otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).210 //211 // @return token's const_metadata212 //213 // Selector: tokenURI(uint256) c87b56dd214 function tokenURI(uint256 tokenId) external view returns (string memory);215}216217// Selector: 68ccfe89218interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {219 // Selector: mintingFinished() 05d2035b220 function mintingFinished() external view returns (bool);221222 // @notice Function to mint token.223 // @dev `tokenId` should be obtained with `nextTokenId` method,224 // unlike standard, you can't specify it manually225 // @param to The new owner226 // @param tokenId ID of the minted RFT227 //228 // Selector: mint(address,uint256) 40c10f19229 function mint(address to, uint256 tokenId) external returns (bool);230231 // @notice Function to mint token with the given tokenUri.232 // @dev `tokenId` should be obtained with `nextTokenId` method,233 // unlike standard, you can't specify it manually234 // @param to The new owner235 // @param tokenId ID of the minted RFT236 // @param tokenUri Token URI that would be stored in the RFT properties237 //238 // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f239 function mintWithTokenURI(240 address to,241 uint256 tokenId,242 string memory tokenUri243 ) external returns (bool);244245 // @dev Not implemented246 //247 // Selector: finishMinting() 7d64bcb4248 function finishMinting() external returns (bool);249}250251// Selector: 780e9d63252interface ERC721Enumerable is Dummy, ERC165 {253 // @notice Enumerate valid RFTs254 // @param index A counter less than `totalSupply()`255 // @return The token identifier for the `index`th NFT,256 // (sort order not specified)257 //258 // Selector: tokenByIndex(uint256) 4f6ccce7259 function tokenByIndex(uint256 index) external view returns (uint256);260261 // Not implemented262 //263 // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59264 function tokenOfOwnerByIndex(address owner, uint256 index)265 external266 view267 returns (uint256);268269 // @notice Count RFTs tracked by this contract270 // @return A count of valid RFTs tracked by this contract, where each one of271 // them has an assigned and queryable owner not equal to the zero address272 //273 // Selector: totalSupply() 18160ddd274 function totalSupply() external view returns (uint256);275}276277// Selector: 7c3bef89278interface ERC721UniqueExtensions is Dummy, ERC165 {279 // @notice Transfer ownership of an RFT280 // @dev Throws unless `msg.sender` is the current owner. Throws if `to`281 // is the zero address. Throws if `tokenId` is not a valid RFT.282 // Throws if RFT pieces have multiple owners.283 // @param to The new owner284 // @param tokenId The RFT to transfer285 // @param _value Not used for an RFT286 //287 // Selector: transfer(address,uint256) a9059cbb288 function transfer(address to, uint256 tokenId) external;289290 // @notice Burns a specific ERC721 token.291 // @dev Throws unless `msg.sender` is the current owner or an authorized292 // operator for this RFT. Throws if `from` is not the current owner. Throws293 // if `to` is the zero address. Throws if `tokenId` is not a valid RFT.294 // Throws if RFT pieces have multiple owners.295 // @param from The current owner of the RFT296 // @param tokenId The RFT to transfer297 // @param _value Not used for an RFT298 //299 // Selector: burnFrom(address,uint256) 79cc6790300 function burnFrom(address from, uint256 tokenId) external;301302 // @notice Returns next free RFT ID.303 //304 // Selector: nextTokenId() 75794a3c305 function nextTokenId() external view returns (uint256);306307 // @notice Function to mint multiple tokens.308 // @dev `tokenIds` should be an array of consecutive numbers and first number309 // should be obtained with `nextTokenId` method310 // @param to The new owner311 // @param tokenIds IDs of the minted RFTs312 //313 // Selector: mintBulk(address,uint256[]) 44a9945e314 function mintBulk(address to, uint256[] memory tokenIds)315 external316 returns (bool);317318 // @notice Function to mint multiple tokens with the given tokenUris.319 // @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive320 // numbers and first number should be obtained with `nextTokenId` method321 // @param to The new owner322 // @param tokens array of pairs of token ID and token URI for minted tokens323 //324 // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006325 function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)326 external327 returns (bool);328329 // Returns EVM address for refungible token330 //331 // @param token ID of the token332 //333 // Selector: tokenContractAddress(uint256) ab76fac6334 function tokenContractAddress(uint256 token)335 external336 view337 returns (address);338}339340// Selector: ffe4da23341interface Collection is Dummy, ERC165 {342 // Set collection property.343 //344 // @param key Property key.345 // @param value Propery value.346 //347 // Selector: setCollectionProperty(string,bytes) 2f073f66348 function setCollectionProperty(string memory key, bytes memory value)349 external;350351 // Delete collection property.352 //353 // @param key Property key.354 //355 // Selector: deleteCollectionProperty(string) 7b7debce356 function deleteCollectionProperty(string memory key) external;357358 // Get collection property.359 //360 // @dev Throws error if key not found.361 //362 // @param key Property key.363 // @return bytes The property corresponding to the key.364 //365 // Selector: collectionProperty(string) cf24fd6d366 function collectionProperty(string memory key)367 external368 view369 returns (bytes memory);370371 // Set the sponsor of the collection.372 //373 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.374 //375 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.376 //377 // Selector: setCollectionSponsor(address) 7623402e378 function setCollectionSponsor(address sponsor) external;379380 // Collection sponsorship confirmation.381 //382 // @dev After setting the sponsor for the collection, it must be confirmed with this function.383 //384 // Selector: confirmCollectionSponsorship() 3c50e97a385 function confirmCollectionSponsorship() external;386387 // Set limits for the collection.388 // @dev Throws error if limit not found.389 // @param limit Name of the limit. Valid names:390 // "accountTokenOwnershipLimit",391 // "sponsoredDataSize",392 // "sponsoredDataRateLimit",393 // "tokenLimit",394 // "sponsorTransferTimeout",395 // "sponsorApproveTimeout"396 // @param value Value of the limit.397 //398 // Selector: setCollectionLimit(string,uint32) 6a3841db399 function setCollectionLimit(string memory limit, uint32 value) external;400401 // Set limits for the collection.402 // @dev Throws error if limit not found.403 // @param limit Name of the limit. Valid names:404 // "ownerCanTransfer",405 // "ownerCanDestroy",406 // "transfersEnabled"407 // @param value Value of the limit.408 //409 // Selector: setCollectionLimit(string,bool) 993b7fba410 function setCollectionLimit(string memory limit, bool value) external;411412 // Get contract address.413 //414 // Selector: contractAddress() f6b4dfb4415 function contractAddress() external view returns (address);416417 // Add collection admin by substrate address.418 // @param new_admin Substrate administrator address.419 //420 // Selector: addCollectionAdminSubstrate(uint256) 5730062b421 function addCollectionAdminSubstrate(uint256 newAdmin) external;422423 // Remove collection admin by substrate address.424 // @param admin Substrate administrator address.425 //426 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9427 function removeCollectionAdminSubstrate(uint256 admin) external;428429 // Add collection admin.430 // @param new_admin Address of the added administrator.431 //432 // Selector: addCollectionAdmin(address) 92e462c7433 function addCollectionAdmin(address newAdmin) external;434435 // Remove collection admin.436 //437 // @param new_admin Address of the removed administrator.438 //439 // Selector: removeCollectionAdmin(address) fafd7b42440 function removeCollectionAdmin(address admin) external;441442 // Toggle accessibility of collection nesting.443 //444 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'445 //446 // Selector: setCollectionNesting(bool) 112d4586447 function setCollectionNesting(bool enable) external;448449 // Toggle accessibility of collection nesting.450 //451 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'452 // @param collections Addresses of collections that will be available for nesting.453 //454 // Selector: setCollectionNesting(bool,address[]) 64872396455 function setCollectionNesting(bool enable, address[] memory collections)456 external;457458 // Set the collection access method.459 // @param mode Access mode460 // 0 for Normal461 // 1 for AllowList462 //463 // Selector: setCollectionAccess(uint8) 41835d4c464 function setCollectionAccess(uint8 mode) external;465466 // Add the user to the allowed list.467 //468 // @param user Address of a trusted user.469 //470 // Selector: addToCollectionAllowList(address) 67844fe6471 function addToCollectionAllowList(address user) external;472473 // Remove the user from the allowed list.474 //475 // @param user Address of a removed user.476 //477 // Selector: removeFromCollectionAllowList(address) 85c51acb478 function removeFromCollectionAllowList(address user) external;479480 // Switch permission for minting.481 //482 // @param mode Enable if "true".483 //484 // Selector: setCollectionMintMode(bool) 00018e84485 function setCollectionMintMode(bool mode) external;486487 // Check that account is the owner or admin of the collection488 //489 // @param user account to verify490 // @return "true" if account is the owner or admin491 //492 // Selector: isOwnerOrAdmin(address) 9811b0c7493 function isOwnerOrAdmin(address user) external view returns (bool);494495 // Check that substrate account is the owner or admin of the collection496 //497 // @param user account to verify498 // @return "true" if account is the owner or admin499 //500 // Selector: isOwnerOrAdminSubstrate(uint256) 68910e00501 function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool);502503 // Returns collection type504 //505 // @return `Fungible` or `NFT` or `ReFungible`506 //507 // Selector: uniqueCollectionType() d34b55b8508 function uniqueCollectionType() external returns (string memory);509510 // Changes collection owner to another account511 //512 // @dev Owner can be changed only by current owner513 // @param newOwner new owner account514 //515 // Selector: setOwner(address) 13af4035516 function setOwner(address newOwner) external;517518 // Changes collection owner to another substrate account519 //520 // @dev Owner can be changed only by current owner521 // @param newOwner new owner substrate account522 //523 // Selector: setOwnerSubstrate(uint256) b212138f524 function setOwnerSubstrate(uint256 newOwner) external;525}526533527interface UniqueRefungible is534interface UniqueRefungible is528 Dummy,535 Dummy,tests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth334pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;556// Common stubs holder6/// @dev common stubs holder7interface Dummy {7interface Dummy {889}9}12 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);13}13}141415// Inline15/// @dev the ERC-165 identifier for this interface is 0x042f110616interface ERC1633UniqueExtensions is Dummy, ERC165 {17 /// @dev EVM selector for this function is: 0x042f1106,18 /// or in textual repr: setParentNFT(address,uint256)19 function setParentNFT(address collection, uint256 nftId)20 external21 returns (bool);22}2324/// @dev the ERC-165 identifier for this interface is 0x5755c3f225interface ERC1633 is Dummy, ERC165 {26 /// @dev EVM selector for this function is: 0x80a54001,27 /// or in textual repr: parentToken()28 function parentToken() external view returns (address);2930 /// @dev EVM selector for this function is: 0xd7f083f3,31 /// or in textual repr: parentTokenId()32 function parentTokenId() external view returns (uint256);33}3435/// @dev the ERC-165 identifier for this interface is 0xab8deb3736interface ERC20UniqueExtensions is Dummy, ERC165 {37 /// @dev Function that burns an amount of the token of a given account,38 /// deducting from the sender's allowance for said account.39 /// @param from The account whose tokens will be burnt.40 /// @param amount The amount that will be burnt.41 /// @dev EVM selector for this function is: 0x79cc6790,42 /// or in textual repr: burnFrom(address,uint256)43 function burnFrom(address from, uint256 amount) external returns (bool);4445 /// @dev Function that changes total amount of the tokens.46 /// Throws if `msg.sender` doesn't owns all of the tokens.47 /// @param amount New total amount of the tokens.48 /// @dev EVM selector for this function is: 0xd2418ca7,49 /// or in textual repr: repartition(uint256)50 function repartition(uint256 amount) external returns (bool);51}5253/// @dev inlined interface16interface ERC20Events {54interface ERC20Events {17 event Transfer(address indexed from, address indexed to, uint256 value);55 event Transfer(address indexed from, address indexed to, uint256 value);18 event Approval(56 event Approval(22 );60 );23}61}246225// Selector: 042f110663/// @title Standard ERC20 token26interface ERC1633UniqueExtensions is Dummy, ERC165 {64///27 // Selector: setParentNFT(address,uint256) 042f110665/// @dev Implementation of the basic standard token.28 function setParentNFT(address collection, uint256 nftId)66/// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md29 external67/// @dev the ERC-165 identifier for this interface is 0x942e8b2230 returns (bool);31}3233// Selector: 5755c3f234interface ERC1633 is Dummy, ERC165 {35 // Selector: parentToken() 80a5400136 function parentToken() external view returns (address);3738 // Selector: parentTokenId() d7f083f339 function parentTokenId() external view returns (uint256);40}4142// Selector: 942e8b2243interface ERC20 is Dummy, ERC165, ERC20Events {68interface ERC20 is Dummy, ERC165, ERC20Events {44 // @return the name of the token.69 /// @return the name of the token.45 //70 /// @dev EVM selector for this function is: 0x06fdde03,46 // Selector: name() 06fdde0371 /// or in textual repr: name()47 function name() external view returns (string memory);72 function name() external view returns (string memory);487349 // @return the symbol of the token.74 /// @return the symbol of the token.50 //75 /// @dev EVM selector for this function is: 0x95d89b41,51 // Selector: symbol() 95d89b4176 /// or in textual repr: symbol()52 function symbol() external view returns (string memory);77 function symbol() external view returns (string memory);537854 // @dev Total number of tokens in existence79 /// @dev Total number of tokens in existence55 //80 /// @dev EVM selector for this function is: 0x18160ddd,56 // Selector: totalSupply() 18160ddd81 /// or in textual repr: totalSupply()57 function totalSupply() external view returns (uint256);82 function totalSupply() external view returns (uint256);588359 // @dev Not supported84 /// @dev Not supported60 //85 /// @dev EVM selector for this function is: 0x313ce567,61 // Selector: decimals() 313ce56786 /// or in textual repr: decimals()62 function decimals() external view returns (uint8);87 function decimals() external view returns (uint8);638864 // @dev Gets the balance of the specified address.89 /// @dev Gets the balance of the specified address.65 // @param owner The address to query the balance of.90 /// @param owner The address to query the balance of.66 // @return An uint256 representing the amount owned by the passed address.91 /// @return An uint256 representing the amount owned by the passed address.67 //92 /// @dev EVM selector for this function is: 0x70a08231,68 // Selector: balanceOf(address) 70a0823193 /// or in textual repr: balanceOf(address)69 function balanceOf(address owner) external view returns (uint256);94 function balanceOf(address owner) external view returns (uint256);709571 // @dev Transfer token for a specified address96 /// @dev Transfer token for a specified address72 // @param to The address to transfer to.97 /// @param to The address to transfer to.73 // @param amount The amount to be transferred.98 /// @param amount The amount to be transferred.74 //99 /// @dev EVM selector for this function is: 0xa9059cbb,75 // Selector: transfer(address,uint256) a9059cbb100 /// or in textual repr: transfer(address,uint256)76 function transfer(address to, uint256 amount) external returns (bool);101 function transfer(address to, uint256 amount) external returns (bool);7710278 // @dev Transfer tokens from one address to another103 /// @dev Transfer tokens from one address to another79 // @param from address The address which you want to send tokens from104 /// @param from address The address which you want to send tokens from80 // @param to address The address which you want to transfer to105 /// @param to address The address which you want to transfer to81 // @param amount uint256 the amount of tokens to be transferred106 /// @param amount uint256 the amount of tokens to be transferred82 //107 /// @dev EVM selector for this function is: 0x23b872dd,83 // Selector: transferFrom(address,address,uint256) 23b872dd108 /// or in textual repr: transferFrom(address,address,uint256)84 function transferFrom(109 function transferFrom(85 address from,110 address from,86 address to,111 address to,87 uint256 amount112 uint256 amount88 ) external returns (bool);113 ) external returns (bool);8911490 // @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`.115 /// @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`.91 // Beware that changing an allowance with this method brings the risk that someone may use both the old116 /// Beware that changing an allowance with this method brings the risk that someone may use both the old92 // and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this117 /// and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this93 // race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:118 /// race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:94 // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729119 /// https://github.com/ethereum/EIPs/issues/20#issuecomment-26352472995 // @param spender The address which will spend the funds.120 /// @param spender The address which will spend the funds.96 // @param amount The amount of tokens to be spent.121 /// @param amount The amount of tokens to be spent.97 //122 /// @dev EVM selector for this function is: 0x095ea7b3,98 // Selector: approve(address,uint256) 095ea7b3123 /// or in textual repr: approve(address,uint256)99 function approve(address spender, uint256 amount) external returns (bool);124 function approve(address spender, uint256 amount) external returns (bool);100125101 // @dev Function to check the amount of tokens that an owner allowed to a spender.126 /// @dev Function to check the amount of tokens that an owner allowed to a spender.102 // @param owner address The address which owns the funds.127 /// @param owner address The address which owns the funds.103 // @param spender address The address which will spend the funds.128 /// @param spender address The address which will spend the funds.104 // @return A uint256 specifying the amount of tokens still available for the spender.129 /// @return A uint256 specifying the amount of tokens still available for the spender.105 //130 /// @dev EVM selector for this function is: 0xdd62ed3e,106 // Selector: allowance(address,address) dd62ed3e131 /// or in textual repr: allowance(address,address)107 function allowance(address owner, address spender)132 function allowance(address owner, address spender)108 external133 external109 view134 view110 returns (uint256);135 returns (uint256);111}136}112113// Selector: ab8deb37114interface ERC20UniqueExtensions is Dummy, ERC165 {115 // @dev Function that burns an amount of the token of a given account,116 // deducting from the sender's allowance for said account.117 // @param from The account whose tokens will be burnt.118 // @param amount The amount that will be burnt.119 //120 // Selector: burnFrom(address,uint256) 79cc6790121 function burnFrom(address from, uint256 amount) external returns (bool);122123 // @dev Function that changes total amount of the tokens.124 // Throws if `msg.sender` doesn't owns all of the tokens.125 // @param amount New total amount of the tokens.126 //127 // Selector: repartition(uint256) d2418ca7128 function repartition(uint256 amount) external returns (bool);129}130137131interface UniqueRefungibleToken is138interface UniqueRefungibleToken is132 Dummy,139 Dummy,tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth255 { "internalType": "uint256", "name": "field_0", "type": "uint256" },255 { "internalType": "uint256", "name": "field_0", "type": "uint256" },256 { "internalType": "string", "name": "field_1", "type": "string" }256 { "internalType": "string", "name": "field_1", "type": "string" }257 ],257 ],258 "internalType": "struct Tuple0[]",258 "internalType": "struct Tuple8[]",259 "name": "tokens",259 "name": "tokens",260 "type": "tuple[]"260 "type": "tuple[]"261 }261 }361 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },361 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },362 { "internalType": "bytes", "name": "data", "type": "bytes" }362 { "internalType": "bytes", "name": "data", "type": "bytes" }363 ],363 ],364 "name": "safeTransferFromWithData",364 "name": "safeTransferFrom",365 "outputs": [],365 "outputs": [],366 "stateMutability": "nonpayable",366 "stateMutability": "nonpayable",367 "type": "function"367 "type": "function"tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth255 { "internalType": "uint256", "name": "field_0", "type": "uint256" },255 { "internalType": "uint256", "name": "field_0", "type": "uint256" },256 { "internalType": "string", "name": "field_1", "type": "string" }256 { "internalType": "string", "name": "field_1", "type": "string" }257 ],257 ],258 "internalType": "struct Tuple0[]",258 "internalType": "struct Tuple8[]",259 "name": "tokens",259 "name": "tokens",260 "type": "tuple[]"260 "type": "tuple[]"261 }261 }tests/src/eth/util/contractHelpersAbi.jsondiffbeforeafterboth195 "stateMutability": "view",195 "stateMutability": "view",196 "type": "function"196 "type": "function"197 },197 },198 {199 "inputs": [200 {201 "internalType": "address",202 "name": "contractAddress",203 "type": "address"204 }205 ],206 "name": "sponsoringMode",207 "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],208 "stateMutability": "view",209 "type": "function"210 },211 {198 {212 "inputs": [199 "inputs": [213 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }200 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }225 "type": "address"212 "type": "address"226 },213 },227 { "internalType": "address", "name": "user", "type": "address" },214 { "internalType": "address", "name": "user", "type": "address" },228 { "internalType": "bool", "name": "allowed", "type": "bool" }215 { "internalType": "bool", "name": "isAllowed", "type": "bool" }229 ],216 ],230 "name": "toggleAllowed",217 "name": "toggleAllowed",231 "outputs": [],218 "outputs": [],