difftreelog
refactor split nonfungible into its own pallet
in: master
8 files changed
pallets/nonfungible/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/pallets/nonfungible/Cargo.toml
@@ -0,0 +1,37 @@
+[package]
+name = "pallet-nonfungible"
+version = "0.1.0"
+edition = "2018"
+
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '2.0.0'
+
+[dependencies]
+frame-support = { default-features = false, version = '4.0.0-dev', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.10' }
+frame-system = { default-features = false, version = '4.0.0-dev', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.10' }
+sp-runtime = { default-features = false, version = '4.0.0-dev', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.10' }
+sp-std = { default-features = false, version = '4.0.0-dev', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.10' }
+sp-core = { default-features = false, version = '4.0.0-dev', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.10' }
+pallet-common = { default-features = false, path = '../common' }
+nft-data-structs = { default-features = false, path = '../../primitives/nft' }
+evm-coder = { default-features = false, path = '../../crates/evm-coder' }
+pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
+ethereum = { default-features = false, version = "0.9.0" }
+
+[features]
+default = ["std"]
+std = [
+ "frame-support/std",
+ "frame-system/std",
+ "sp-runtime/std",
+ "sp-std/std",
+ "nft-data-structs/std",
+ "pallet-common/std",
+ "evm-coder/std",
+ "ethereum/std",
+ "pallet-evm-coder-substrate/std",
+]
+runtime-benchmarks = []
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -0,0 +1 @@
+#![cfg(feature = "runtime-benchmarking")]
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/nonfungible/src/common.rs
@@ -0,0 +1,228 @@
+use core::marker::PhantomData;
+
+use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
+use nft_data_structs::TokenId;
+use pallet_common::{
+ CommonCollectionOperations, CommonWeightInfo, account::CrossAccountId, with_weight,
+};
+use sp_runtime::DispatchError;
+use sp_std::vec::Vec;
+
+use crate::{
+ AccountBalance, Allowance, Config, CreateItemData, DataKind, Error, NonfungibleHandle, Owned,
+ Owner, Pallet, SelfWeightOf, TokenData, weights::WeightInfo,
+};
+
+pub struct CommonWeights<T: Config>(PhantomData<T>);
+impl<T: Config> CommonWeightInfo for CommonWeights<T> {
+ fn create_item() -> Weight {
+ <SelfWeightOf<T>>::create_item()
+ }
+
+ fn create_multiple_items(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::create_multiple_items(amount)
+ }
+
+ fn burn_item() -> Weight {
+ <SelfWeightOf<T>>::burn_item()
+ }
+
+ fn transfer() -> Weight {
+ <SelfWeightOf<T>>::transfer()
+ }
+
+ fn approve() -> Weight {
+ <SelfWeightOf<T>>::approve()
+ }
+
+ fn transfer_from() -> Weight {
+ <SelfWeightOf<T>>::transfer_from()
+ }
+
+ fn set_variable_metadata(_bytes: u32) -> Weight {
+ <SelfWeightOf<T>>::set_variable_metadata()
+ }
+}
+
+fn map_create_data<T: Config>(
+ data: nft_data_structs::CreateItemData,
+ to: &T::CrossAccountId,
+) -> Result<CreateItemData<T>, DispatchError> {
+ match data {
+ nft_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData {
+ const_data: data.const_data,
+ variable_data: data.variable_data,
+ owner: to.clone(),
+ }),
+ _ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),
+ }
+}
+
+impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {
+ fn create_item(
+ &self,
+ sender: T::CrossAccountId,
+ to: T::CrossAccountId,
+ data: nft_data_structs::CreateItemData,
+ ) -> DispatchResultWithPostInfo {
+ with_weight(
+ <Pallet<T>>::create_item(self, &sender, map_create_data(data, &to)?),
+ <SelfWeightOf<T>>::create_item(),
+ )
+ }
+
+ fn create_multiple_items(
+ &self,
+ sender: T::CrossAccountId,
+ to: T::CrossAccountId,
+ data: Vec<nft_data_structs::CreateItemData>,
+ ) -> DispatchResultWithPostInfo {
+ let data = data
+ .into_iter()
+ .map(|d| map_create_data::<T>(d, &to))
+ .collect::<Result<Vec<_>, DispatchError>>()?;
+
+ let amount = data.len();
+ with_weight(
+ <Pallet<T>>::create_multiple_items(self, &sender, data),
+ <SelfWeightOf<T>>::create_multiple_items(amount as u32),
+ )
+ }
+
+ fn burn_item(
+ &self,
+ sender: T::CrossAccountId,
+ token: TokenId,
+ amount: u128,
+ ) -> DispatchResultWithPostInfo {
+ ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
+ if amount == 1 {
+ with_weight(
+ <Pallet<T>>::burn(&self, &sender, token),
+ <SelfWeightOf<T>>::burn_item(),
+ )
+ } else {
+ Ok(().into())
+ }
+ }
+
+ fn transfer(
+ &self,
+ from: T::CrossAccountId,
+ to: T::CrossAccountId,
+ token: TokenId,
+ amount: u128,
+ ) -> DispatchResultWithPostInfo {
+ ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
+ if amount == 1 {
+ with_weight(
+ <Pallet<T>>::transfer(&self, &from, &to, token),
+ <SelfWeightOf<T>>::transfer(),
+ )
+ } else {
+ Ok(().into())
+ }
+ }
+
+ fn approve(
+ &self,
+ sender: T::CrossAccountId,
+ spender: T::CrossAccountId,
+ token: TokenId,
+ amount: u128,
+ ) -> DispatchResultWithPostInfo {
+ ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
+
+ with_weight(
+ if amount == 1 {
+ <Pallet<T>>::set_allowance(&self, &sender, token, Some(&spender))
+ } else {
+ <Pallet<T>>::set_allowance(&self, &sender, token, None)
+ },
+ <SelfWeightOf<T>>::approve(),
+ )
+ }
+
+ fn transfer_from(
+ &self,
+ sender: T::CrossAccountId,
+ from: T::CrossAccountId,
+ to: T::CrossAccountId,
+ token: TokenId,
+ amount: u128,
+ ) -> DispatchResultWithPostInfo {
+ ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
+
+ if amount == 1 {
+ with_weight(
+ <Pallet<T>>::transfer_from(&self, &sender, &from, &to, token),
+ <SelfWeightOf<T>>::transfer_from(),
+ )
+ } else {
+ Ok(().into())
+ }
+ }
+
+ fn set_variable_metadata(
+ &self,
+ sender: T::CrossAccountId,
+ token: TokenId,
+ data: Vec<u8>,
+ ) -> DispatchResultWithPostInfo {
+ with_weight(
+ <Pallet<T>>::set_variable_metadata(&self, &sender, token, data),
+ <SelfWeightOf<T>>::set_variable_metadata(),
+ )
+ }
+
+ fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {
+ <Owned<T>>::iter_prefix((self.id, account.as_sub()))
+ .map(|(id, _)| id)
+ .collect()
+ }
+
+ fn token_exists(&self, token: TokenId) -> bool {
+ <Pallet<T>>::token_exists(self, token)
+ }
+
+ fn token_owner(&self, token: TokenId) -> T::CrossAccountId {
+ <Owner<T>>::get((self.id, token))
+ }
+ fn const_metadata(&self, token: TokenId) -> Vec<u8> {
+ <TokenData<T>>::get((self.id, token, DataKind::Constant))
+ }
+ fn variable_metadata(&self, token: TokenId) -> Vec<u8> {
+ <TokenData<T>>::get((self.id, token, DataKind::Variable))
+ }
+
+ fn collection_tokens(&self) -> u32 {
+ <Pallet<T>>::total_supply(self)
+ }
+
+ fn account_balance(&self, account: T::CrossAccountId) -> u32 {
+ <AccountBalance<T>>::get((self.id, account.as_sub()))
+ }
+
+ fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {
+ if <Owner<T>>::get((self.id, token)) == account {
+ 1
+ } else {
+ 0
+ }
+ }
+
+ fn allowance(
+ &self,
+ sender: T::CrossAccountId,
+ spender: T::CrossAccountId,
+ token: TokenId,
+ ) -> u128 {
+ if <Owner<T>>::get((self.id, token)) != sender {
+ 0
+ } else if <Allowance<T>>::get((self.id, token)) == Some(spender) {
+ 1
+ } else {
+ 0
+ }
+ }
+}
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/nonfungible/src/erc.rs
@@ -0,0 +1,396 @@
+use core::{
+ char::{REPLACEMENT_CHARACTER, decode_utf16},
+ convert::TryInto,
+};
+use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*};
+use frame_support::BoundedVec;
+use nft_data_structs::TokenId;
+use pallet_evm_coder_substrate::dispatch_to_evm;
+use sp_core::{H160, U256};
+use sp_std::{vec::Vec, vec};
+use pallet_common::{account::CrossAccountId, erc::CommonEvmHandler};
+use pallet_evm_coder_substrate::call_internal;
+use pallet_common::erc::PrecompileOutput;
+
+use crate::{
+ AccountBalance, Config, CreateItemData, DataKind, NonfungibleHandle, Owner, Pallet, TokenData,
+ TokensMinted,
+};
+
+#[derive(ToLog)]
+pub enum ERC721Events {
+ Transfer {
+ #[indexed]
+ from: address,
+ #[indexed]
+ to: address,
+ #[indexed]
+ token_id: uint256,
+ },
+ Approval {
+ #[indexed]
+ owner: address,
+ #[indexed]
+ approved: address,
+ #[indexed]
+ token_id: uint256,
+ },
+ #[allow(dead_code)]
+ ApprovalForAll {
+ #[indexed]
+ owner: address,
+ #[indexed]
+ operator: address,
+ approved: bool,
+ },
+}
+
+#[derive(ToLog)]
+pub enum ERC721MintableEvents {
+ #[allow(dead_code)]
+ MintingFinished {},
+}
+
+#[solidity_interface(name = "ERC721Metadata")]
+impl<T: Config> NonfungibleHandle<T> {
+ fn name(&self) -> Result<string> {
+ Ok(decode_utf16(self.name.iter().copied())
+ .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
+ .collect::<string>())
+ }
+ fn symbol(&self) -> Result<string> {
+ Ok(string::from_utf8_lossy(&self.token_prefix).into())
+ }
+
+ #[solidity(rename_selector = "tokenURI")]
+ fn token_uri(&self, token_id: uint256) -> Result<string> {
+ let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
+ Ok(string::from_utf8_lossy(&<TokenData<T>>::get((
+ self.id,
+ token_id,
+ DataKind::Constant,
+ )))
+ .into())
+ }
+}
+
+#[solidity_interface(name = "ERC721Enumerable")]
+impl<T: Config> NonfungibleHandle<T> {
+ fn token_by_index(&self, index: uint256) -> Result<uint256> {
+ Ok(index)
+ }
+
+ fn token_of_owner_by_index(&self, _owner: address, _index: uint256) -> Result<uint256> {
+ // TODO: Not implemetable
+ Err("not implemented".into())
+ }
+
+ fn total_supply(&self) -> Result<uint256> {
+ Ok(<Pallet<T>>::total_supply(self).into())
+ }
+}
+
+#[solidity_interface(name = "ERC721", events(ERC721Events))]
+impl<T: Config> NonfungibleHandle<T> {
+ fn balance_of(&self, owner: address) -> Result<uint256> {
+ let owner = T::CrossAccountId::from_eth(owner);
+ let balance = <AccountBalance<T>>::get((self.id, owner.as_sub()));
+ Ok(balance.into())
+ }
+ fn owner_of(&self, token_id: uint256) -> Result<address> {
+ let token: TokenId = token_id.try_into()?;
+ Ok(*<Owner<T>>::get((self.id, token)).as_eth())
+ }
+ fn safe_transfer_from_with_data(
+ &mut self,
+ _from: address,
+ _to: address,
+ _token_id: uint256,
+ _data: bytes,
+ _value: value,
+ ) -> Result<void> {
+ // TODO: Not implemetable
+ Err("not implemented".into())
+ }
+ fn safe_transfer_from(
+ &mut self,
+ _from: address,
+ _to: address,
+ _token_id: uint256,
+ _value: value,
+ ) -> Result<void> {
+ // TODO: Not implemetable
+ Err("not implemented".into())
+ }
+
+ fn transfer_from(
+ &mut self,
+ caller: caller,
+ from: address,
+ to: address,
+ token_id: uint256,
+ _value: value,
+ ) -> Result<void> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let from = T::CrossAccountId::from_eth(from);
+ let to = T::CrossAccountId::from_eth(to);
+ let token = token_id.try_into()?;
+
+ <Pallet<T>>::transfer_from(self, &caller, &from, &to, token)
+ .map_err(dispatch_to_evm::<T>)?;
+ Ok(())
+ }
+
+ fn approve(
+ &mut self,
+ caller: caller,
+ approved: address,
+ token_id: uint256,
+ _value: value,
+ ) -> Result<void> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let approved = T::CrossAccountId::from_eth(approved);
+ let token = token_id.try_into()?;
+
+ <Pallet<T>>::set_allowance(self, &caller, token, Some(&approved))
+ .map_err(dispatch_to_evm::<T>)?;
+ Ok(())
+ }
+
+ fn set_approval_for_all(
+ &mut self,
+ _caller: caller,
+ _operator: address,
+ _approved: bool,
+ ) -> Result<void> {
+ // TODO: Not implemetable
+ Err("not implemented".into())
+ }
+
+ fn get_approved(&self, _token_id: uint256) -> Result<address> {
+ // TODO: Not implemetable
+ Err("not implemented".into())
+ }
+
+ fn is_approved_for_all(&self, _owner: address, _operator: address) -> Result<address> {
+ // TODO: Not implemetable
+ Err("not implemented".into())
+ }
+}
+
+#[solidity_interface(name = "ERC721Burnable")]
+impl<T: Config> NonfungibleHandle<T> {
+ fn burn(&mut self, caller: caller, token_id: uint256) -> Result<void> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let token = token_id.try_into()?;
+
+ <Pallet<T>>::burn(self, &caller, token).map_err(dispatch_to_evm::<T>)?;
+ Ok(())
+ }
+}
+
+#[solidity_interface(name = "ERC721Mintable", events(ERC721MintableEvents))]
+impl<T: Config> NonfungibleHandle<T> {
+ fn minting_finished(&self) -> Result<bool> {
+ Ok(false)
+ }
+
+ fn mint(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let to = T::CrossAccountId::from_eth(to);
+ let token_id: u32 = token_id.try_into()?;
+ if <TokensMinted<T>>::get(self.id)
+ .checked_add(1)
+ .ok_or("item id overflow")?
+ != token_id
+ {
+ return Err("item id should be next".into());
+ }
+
+ <Pallet<T>>::create_item(
+ self,
+ &caller,
+ CreateItemData {
+ const_data: BoundedVec::default(),
+ variable_data: BoundedVec::default(),
+ owner: to,
+ },
+ )
+ .map_err(dispatch_to_evm::<T>)?;
+
+ Ok(true)
+ }
+
+ #[solidity(rename_selector = "mintWithTokenURI")]
+ fn mint_with_token_uri(
+ &mut self,
+ caller: caller,
+ to: address,
+ token_id: uint256,
+ token_uri: string,
+ ) -> Result<bool> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let to = T::CrossAccountId::from_eth(to);
+ let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;
+ if <TokensMinted<T>>::get(self.id)
+ .checked_add(1)
+ .ok_or("item id overflow")?
+ != token_id
+ {
+ return Err("item id should be next".into());
+ }
+
+ <Pallet<T>>::create_item(
+ self,
+ &caller,
+ CreateItemData {
+ const_data: Vec::<u8>::from(token_uri)
+ .try_into()
+ .map_err(|_| "token uri is too long")?,
+ variable_data: BoundedVec::default(),
+ owner: to,
+ },
+ )
+ .map_err(dispatch_to_evm::<T>)?;
+ Ok(true)
+ }
+
+ fn finish_minting(&mut self, _caller: caller) -> Result<bool> {
+ Err("not implementable".into())
+ }
+}
+
+#[solidity_interface(name = "ERC721UniqueExtensions")]
+impl<T: Config> NonfungibleHandle<T> {
+ #[solidity(rename_selector = "transfer")]
+ fn transfer_nft(
+ &mut self,
+ caller: caller,
+ to: address,
+ token_id: uint256,
+ _value: value,
+ ) -> Result<void> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let to = T::CrossAccountId::from_eth(to);
+ let token = token_id.try_into()?;
+
+ <Pallet<T>>::transfer(self, &caller, &to, token).map_err(dispatch_to_evm::<T>)?;
+ Ok(())
+ }
+
+ fn next_token_id(&self) -> Result<uint256> {
+ Ok(<TokensMinted<T>>::get(self.id)
+ .checked_add(1)
+ .ok_or("item id overflow")?
+ .into())
+ }
+
+ fn set_variable_metadata(
+ &mut self,
+ caller: caller,
+ token_id: uint256,
+ data: bytes,
+ ) -> Result<void> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let token = token_id.try_into()?;
+
+ <Pallet<T>>::set_variable_metadata(self, &caller, token, data)
+ .map_err(dispatch_to_evm::<T>)?;
+ Ok(())
+ }
+
+ fn get_variable_metadata(&self, token_id: uint256) -> Result<bytes> {
+ let token: TokenId = token_id.try_into()?;
+
+ Ok(<TokenData<T>>::get((self.id, token, DataKind::Variable)))
+ }
+
+ fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let to = T::CrossAccountId::from_eth(to);
+ let mut expected_index = <TokensMinted<T>>::get(self.id)
+ .checked_add(1)
+ .ok_or("item id overflow")?;
+
+ let total_tokens = token_ids.len();
+ for id in token_ids.into_iter() {
+ let id: u32 = id.try_into().map_err(|_| "token id overflow")?;
+ if id != expected_index {
+ return Err("item id should be next".into());
+ }
+ expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;
+ }
+ let data = (0..total_tokens)
+ .map(|_| CreateItemData {
+ const_data: BoundedVec::default(),
+ variable_data: BoundedVec::default(),
+ owner: to.clone(),
+ })
+ .collect();
+
+ <Pallet<T>>::create_multiple_items(self, &caller, data).map_err(dispatch_to_evm::<T>)?;
+ Ok(true)
+ }
+
+ #[solidity(rename_selector = "mintBulkWithTokenURI")]
+ fn mint_bulk_with_token_uri(
+ &mut self,
+ caller: caller,
+ to: address,
+ tokens: Vec<(uint256, string)>,
+ ) -> Result<bool> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let to = T::CrossAccountId::from_eth(to);
+ let mut expected_index = <TokensMinted<T>>::get(self.id)
+ .checked_add(1)
+ .ok_or("item id overflow")?;
+
+ let mut data = Vec::with_capacity(tokens.len());
+ for (id, token_uri) in tokens {
+ let id: u32 = id.try_into().map_err(|_| "token id overflow")?;
+ if id != expected_index {
+ panic!("item id should be next ({}) but got {}", expected_index, id);
+ }
+ expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;
+
+ data.push(CreateItemData {
+ const_data: Vec::<u8>::from(token_uri)
+ .try_into()
+ .map_err(|_| "token uri is too long")?,
+ variable_data: vec![].try_into().unwrap(),
+ owner: to.clone(),
+ });
+ }
+
+ <Pallet<T>>::create_multiple_items(self, &caller, data).map_err(dispatch_to_evm::<T>)?;
+ Ok(true)
+ }
+}
+
+#[solidity_interface(
+ name = "UniqueNFT",
+ is(
+ ERC721,
+ ERC721Metadata,
+ ERC721Enumerable,
+ ERC721UniqueExtensions,
+ ERC721Mintable,
+ ERC721Burnable,
+ )
+)]
+impl<T: Config> NonfungibleHandle<T> {}
+
+// Not a tests, but code generators
+generate_stubgen!(gen_impl, UniqueNFTCall, true);
+generate_stubgen!(gen_iface, UniqueNFTCall, false);
+
+pub const CODE: &[u8] = include_bytes!("./stubs/UniqueNFT.raw");
+
+impl<T: Config> CommonEvmHandler for NonfungibleHandle<T> {
+ const CODE: &'static [u8] = include_bytes!("./stubs/UniqueNFT.raw");
+
+ fn call(mut self, source: &H160, input: &[u8], value: U256) -> Option<PrecompileOutput> {
+ let result = call_internal::<UniqueNFTCall, _>(*source, &mut self, value, input);
+ self.0.recorder.evm_to_precompile_output(result)
+ }
+}
pallets/nonfungible/src/lib.rsdiffbeforeafterbothno changes
pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- /dev/null
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -0,0 +1,326 @@
+// SPDX-License-Identifier: OTHER
+// This code is automatically generated
+
+pragma solidity >=0.8.0 <0.9.0;
+
+// Anonymous struct
+struct Tuple0 {
+ uint256 field_0;
+ string field_1;
+}
+
+// Common stubs holder
+contract Dummy {
+ uint8 dummy;
+ string stub_error = "this contract is implemented in native";
+}
+
+// Inline
+contract ERC721Events {
+ event Transfer(
+ address indexed from,
+ address indexed to,
+ uint256 indexed tokenId
+ );
+ event Approval(
+ address indexed owner,
+ address indexed approved,
+ uint256 indexed tokenId
+ );
+ event ApprovalForAll(
+ address indexed owner,
+ address indexed operator,
+ bool approved
+ );
+}
+
+// Inline
+contract ERC721MintableEvents {
+ event MintingFinished();
+}
+
+// Inline
+contract InlineNameSymbol is Dummy {
+ // Selector: name() 06fdde03
+ function name() public view returns (string memory) {
+ require(false, stub_error);
+ dummy;
+ return "";
+ }
+
+ // Selector: symbol() 95d89b41
+ function symbol() public view returns (string memory) {
+ require(false, stub_error);
+ dummy;
+ return "";
+ }
+}
+
+// Inline
+contract InlineTotalSupply is Dummy {
+ // Selector: totalSupply() 18160ddd
+ function totalSupply() public view returns (uint256) {
+ require(false, stub_error);
+ dummy;
+ return 0;
+ }
+}
+
+contract ERC165 is Dummy {
+ // Selector: supportsInterface(bytes4) 01ffc9a7
+ function supportsInterface(uint32 interfaceId) public view returns (bool) {
+ require(false, stub_error);
+ interfaceId;
+ dummy;
+ return false;
+ }
+}
+
+contract ERC721 is Dummy, ERC165, ERC721Events {
+ // Selector: balanceOf(address) 70a08231
+ function balanceOf(address owner) public view returns (uint256) {
+ require(false, stub_error);
+ owner;
+ dummy;
+ return 0;
+ }
+
+ // Selector: ownerOf(uint256) 6352211e
+ function ownerOf(uint256 tokenId) public view returns (address) {
+ require(false, stub_error);
+ tokenId;
+ dummy;
+ return 0x0000000000000000000000000000000000000000;
+ }
+
+ // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672
+ function safeTransferFromWithData(
+ address from,
+ address to,
+ uint256 tokenId,
+ bytes memory data
+ ) public {
+ require(false, stub_error);
+ from;
+ to;
+ tokenId;
+ data;
+ dummy = 0;
+ }
+
+ // Selector: safeTransferFrom(address,address,uint256) 42842e0e
+ function safeTransferFrom(
+ address from,
+ address to,
+ uint256 tokenId
+ ) public {
+ require(false, stub_error);
+ from;
+ to;
+ tokenId;
+ dummy = 0;
+ }
+
+ // Selector: transferFrom(address,address,uint256) 23b872dd
+ function transferFrom(
+ address from,
+ address to,
+ uint256 tokenId
+ ) public {
+ require(false, stub_error);
+ from;
+ to;
+ tokenId;
+ dummy = 0;
+ }
+
+ // Selector: approve(address,uint256) 095ea7b3
+ function approve(address approved, uint256 tokenId) public {
+ require(false, stub_error);
+ approved;
+ tokenId;
+ dummy = 0;
+ }
+
+ // Selector: setApprovalForAll(address,bool) a22cb465
+ function setApprovalForAll(address operator, bool approved) public {
+ require(false, stub_error);
+ operator;
+ approved;
+ dummy = 0;
+ }
+
+ // Selector: getApproved(uint256) 081812fc
+ function getApproved(uint256 tokenId) public view returns (address) {
+ require(false, stub_error);
+ tokenId;
+ dummy;
+ return 0x0000000000000000000000000000000000000000;
+ }
+
+ // Selector: isApprovedForAll(address,address) e985e9c5
+ function isApprovedForAll(address owner, address operator)
+ public
+ view
+ returns (address)
+ {
+ require(false, stub_error);
+ owner;
+ operator;
+ dummy;
+ return 0x0000000000000000000000000000000000000000;
+ }
+}
+
+contract ERC721Burnable is Dummy {
+ // Selector: burn(uint256) 42966c68
+ function burn(uint256 tokenId) public {
+ require(false, stub_error);
+ tokenId;
+ dummy = 0;
+ }
+}
+
+contract ERC721Enumerable is Dummy, InlineTotalSupply {
+ // Selector: tokenByIndex(uint256) 4f6ccce7
+ function tokenByIndex(uint256 index) public view returns (uint256) {
+ require(false, stub_error);
+ index;
+ dummy;
+ return 0;
+ }
+
+ // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
+ function tokenOfOwnerByIndex(address owner, uint256 index)
+ public
+ view
+ returns (uint256)
+ {
+ require(false, stub_error);
+ owner;
+ index;
+ dummy;
+ return 0;
+ }
+}
+
+contract ERC721Metadata is Dummy, InlineNameSymbol {
+ // Selector: tokenURI(uint256) c87b56dd
+ function tokenURI(uint256 tokenId) public view returns (string memory) {
+ require(false, stub_error);
+ tokenId;
+ dummy;
+ return "";
+ }
+}
+
+contract ERC721Mintable is Dummy, ERC721MintableEvents {
+ // Selector: mintingFinished() 05d2035b
+ function mintingFinished() public view returns (bool) {
+ require(false, stub_error);
+ dummy;
+ return false;
+ }
+
+ // Selector: mint(address,uint256) 40c10f19
+ function mint(address to, uint256 tokenId) public returns (bool) {
+ require(false, stub_error);
+ to;
+ tokenId;
+ dummy = 0;
+ return false;
+ }
+
+ // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f
+ function mintWithTokenURI(
+ address to,
+ uint256 tokenId,
+ string memory tokenUri
+ ) public returns (bool) {
+ require(false, stub_error);
+ to;
+ tokenId;
+ tokenUri;
+ dummy = 0;
+ return false;
+ }
+
+ // Selector: finishMinting() 7d64bcb4
+ function finishMinting() public returns (bool) {
+ require(false, stub_error);
+ dummy = 0;
+ return false;
+ }
+}
+
+contract ERC721UniqueExtensions is Dummy {
+ // Selector: transfer(address,uint256) a9059cbb
+ function transfer(address to, uint256 tokenId) public {
+ require(false, stub_error);
+ to;
+ tokenId;
+ dummy = 0;
+ }
+
+ // Selector: nextTokenId() 75794a3c
+ function nextTokenId() public view returns (uint256) {
+ require(false, stub_error);
+ dummy;
+ return 0;
+ }
+
+ // Selector: setVariableMetadata(uint256,bytes) d4eac26d
+ function setVariableMetadata(uint256 tokenId, bytes memory data) public {
+ require(false, stub_error);
+ tokenId;
+ data;
+ dummy = 0;
+ }
+
+ // Selector: getVariableMetadata(uint256) e6c5ce6f
+ function getVariableMetadata(uint256 tokenId)
+ public
+ view
+ returns (bytes memory)
+ {
+ require(false, stub_error);
+ tokenId;
+ dummy;
+ return hex"";
+ }
+
+ // Selector: mintBulk(address,uint256[]) 44a9945e
+ function mintBulk(address to, uint256[] memory tokenIds)
+ public
+ returns (bool)
+ {
+ require(false, stub_error);
+ to;
+ tokenIds;
+ dummy = 0;
+ return false;
+ }
+
+ // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006
+ function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)
+ public
+ returns (bool)
+ {
+ require(false, stub_error);
+ to;
+ tokens;
+ dummy = 0;
+ return false;
+ }
+}
+
+contract UniqueNFT is
+ Dummy,
+ ERC165,
+ ERC721,
+ ERC721Metadata,
+ ERC721Enumerable,
+ ERC721UniqueExtensions,
+ ERC721Mintable,
+ ERC721Burnable
+{}
pallets/nonfungible/src/weights.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/nonfungible/src/weights.rs
@@ -0,0 +1,37 @@
+#![cfg_attr(rustfmt, rustfmt_skip)]
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+
+use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
+use sp_std::marker::PhantomData;
+
+pub trait WeightInfo {
+ fn create_item() -> Weight;
+ fn create_multiple_items(b: u32) -> Weight;
+ fn burn_item() -> Weight;
+ fn transfer() -> Weight;
+ fn approve() -> Weight;
+ fn transfer_from() -> Weight;
+ fn set_variable_metadata() -> Weight;
+}
+
+pub struct SubstrateWeight<T>(PhantomData<T>);
+impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
+ fn create_item() -> Weight {0}
+ fn create_multiple_items(_b: u32) -> Weight {0}
+ fn burn_item() -> Weight {0}
+ fn transfer() -> Weight {0}
+ fn approve() -> Weight {0}
+ fn transfer_from() -> Weight {0}
+ fn set_variable_metadata() -> Weight {0}
+}
+
+impl WeightInfo for () {
+ fn create_item() -> Weight {0}
+ fn create_multiple_items(_b: u32) -> Weight {0}
+ fn burn_item() -> Weight {0}
+ fn transfer() -> Weight {0}
+ fn approve() -> Weight {0}
+ fn transfer_from() -> Weight {0}
+ fn set_variable_metadata() -> Weight {0}
+}