--- a/pallets/balances-adapter/src/common.rs +++ b/pallets/balances-adapter/src/common.rs @@ -12,12 +12,12 @@ pub struct CommonWeights(PhantomData); impl CommonWeightInfo for CommonWeights { - fn create_multiple_items(amount: &[up_data_structs::CreateItemData]) -> Weight { + fn create_multiple_items(_amount: &[up_data_structs::CreateItemData]) -> Weight { Weight::default() } fn create_multiple_items_ex( - cost: &up_data_structs::CreateItemExData, + _cost: &up_data_structs::CreateItemExData, ) -> Weight { Weight::default() } @@ -26,23 +26,23 @@ Weight::default() } - fn set_collection_properties(amount: u32) -> Weight { + fn set_collection_properties(_amount: u32) -> Weight { Weight::default() } - fn delete_collection_properties(amount: u32) -> Weight { + fn delete_collection_properties(_amount: u32) -> Weight { Weight::default() } - fn set_token_properties(amount: u32) -> Weight { + fn set_token_properties(_amount: u32) -> Weight { Weight::default() } - fn delete_token_properties(amount: u32) -> Weight { + fn delete_token_properties(_amount: u32) -> Weight { Weight::default() } - fn set_token_property_permissions(amount: u32) -> Weight { + fn set_token_property_permissions(_amount: u32) -> Weight { Weight::default() } @@ -70,7 +70,7 @@ Weight::default() } - fn burn_recursively_breadth_raw(amount: u32) -> Weight { + fn burn_recursively_breadth_raw(_amount: u32) -> Weight { Weight::default() } @@ -92,92 +92,92 @@ impl CommonCollectionOperations for NativeFungibleHandle { fn create_item( &self, - sender: ::CrossAccountId, - to: ::CrossAccountId, - data: up_data_structs::CreateItemData, - nesting_budget: &dyn up_data_structs::budget::Budget, + _sender: ::CrossAccountId, + _to: ::CrossAccountId, + _data: up_data_structs::CreateItemData, + _nesting_budget: &dyn up_data_structs::budget::Budget, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn create_multiple_items( &self, - sender: ::CrossAccountId, - to: ::CrossAccountId, - data: Vec, - nesting_budget: &dyn up_data_structs::budget::Budget, + _sender: ::CrossAccountId, + _to: ::CrossAccountId, + _data: Vec, + _nesting_budget: &dyn up_data_structs::budget::Budget, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn create_multiple_items_ex( &self, - sender: ::CrossAccountId, - data: up_data_structs::CreateItemExData<::CrossAccountId>, - nesting_budget: &dyn up_data_structs::budget::Budget, + _sender: ::CrossAccountId, + _data: up_data_structs::CreateItemExData<::CrossAccountId>, + _nesting_budget: &dyn up_data_structs::budget::Budget, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn burn_item( &self, - sender: ::CrossAccountId, - token: TokenId, - amount: u128, + _sender: ::CrossAccountId, + _token: TokenId, + _amount: u128, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn burn_item_recursively( &self, - sender: ::CrossAccountId, - token: TokenId, - self_budget: &dyn up_data_structs::budget::Budget, - breadth_budget: &dyn up_data_structs::budget::Budget, + _sender: ::CrossAccountId, + _token: TokenId, + _self_budget: &dyn up_data_structs::budget::Budget, + _breadth_budget: &dyn up_data_structs::budget::Budget, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn set_collection_properties( &self, - sender: ::CrossAccountId, - properties: Vec, + _sender: ::CrossAccountId, + _properties: Vec, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn delete_collection_properties( &self, - sender: &::CrossAccountId, - property_keys: Vec, + _sender: &::CrossAccountId, + _property_keys: Vec, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn set_token_properties( &self, - sender: ::CrossAccountId, - token_id: TokenId, - properties: Vec, - budget: &dyn up_data_structs::budget::Budget, + _sender: ::CrossAccountId, + _token_id: TokenId, + _properties: Vec, + _budget: &dyn up_data_structs::budget::Budget, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn delete_token_properties( &self, - sender: ::CrossAccountId, - token_id: TokenId, - property_keys: Vec, - budget: &dyn up_data_structs::budget::Budget, + _sender: ::CrossAccountId, + _token_id: TokenId, + _property_keys: Vec, + _budget: &dyn up_data_structs::budget::Budget, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn set_token_property_permissions( &self, - sender: &::CrossAccountId, - property_permissions: Vec, + _sender: &::CrossAccountId, + _property_permissions: Vec, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } @@ -186,9 +186,9 @@ &self, sender: ::CrossAccountId, to: ::CrossAccountId, - token: TokenId, + _token: TokenId, amount: u128, - budget: &dyn up_data_structs::budget::Budget, + _budget: &dyn up_data_structs::budget::Budget, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { with_weight( ::Currency::transfer( @@ -203,21 +203,21 @@ fn approve( &self, - sender: ::CrossAccountId, - spender: ::CrossAccountId, - token: TokenId, - amount: u128, + _sender: ::CrossAccountId, + _spender: ::CrossAccountId, + _token: TokenId, + _amount: u128, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn approve_from( &self, - sender: ::CrossAccountId, - from: ::CrossAccountId, - to: ::CrossAccountId, - token: TokenId, - amount: u128, + _sender: ::CrossAccountId, + _from: ::CrossAccountId, + _to: ::CrossAccountId, + _token: TokenId, + _amount: u128, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } @@ -227,9 +227,9 @@ sender: ::CrossAccountId, from: ::CrossAccountId, to: ::CrossAccountId, - token: TokenId, + _token: TokenId, amount: u128, - budget: &dyn up_data_structs::budget::Budget, + _budget: &dyn up_data_structs::budget::Budget, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { if sender != from { fail!(>::NoPermission); @@ -247,28 +247,28 @@ fn burn_from( &self, - sender: ::CrossAccountId, - from: ::CrossAccountId, - token: TokenId, - amount: u128, - budget: &dyn up_data_structs::budget::Budget, + _sender: ::CrossAccountId, + _from: ::CrossAccountId, + _token: TokenId, + _amount: u128, + _budget: &dyn up_data_structs::budget::Budget, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } fn check_nesting( &self, - sender: ::CrossAccountId, - from: (up_data_structs::CollectionId, TokenId), - under: TokenId, - budget: &dyn up_data_structs::budget::Budget, + _sender: ::CrossAccountId, + _from: (up_data_structs::CollectionId, TokenId), + _under: TokenId, + _budget: &dyn up_data_structs::budget::Budget, ) -> frame_support::sp_runtime::DispatchResult { fail!(>::UnsupportedOperation); } - fn nest(&self, under: TokenId, to_nest: (up_data_structs::CollectionId, TokenId)) {} + fn nest(&self, _under: TokenId, _to_nest: (up_data_structs::CollectionId, TokenId)) {} - fn unnest(&self, under: TokenId, to_nest: (up_data_structs::CollectionId, TokenId)) {} + fn unnest(&self, _under: TokenId, _to_nest: (up_data_structs::CollectionId, TokenId)) {} fn account_tokens(&self, account: ::CrossAccountId) -> Vec { let balance = ::Currency::total_balance(account.as_sub()); @@ -293,27 +293,27 @@ fn token_owner( &self, - token: TokenId, + _token: TokenId, ) -> Result<::CrossAccountId, up_data_structs::TokenOwnerError> { Err(up_data_structs::TokenOwnerError::MultipleOwners) } - fn token_owners(&self, token: TokenId) -> Vec<::CrossAccountId> { + fn token_owners(&self, _token: TokenId) -> Vec<::CrossAccountId> { vec![] } fn token_property( &self, - token_id: TokenId, - key: &up_data_structs::PropertyKey, + _token_id: TokenId, + _key: &up_data_structs::PropertyKey, ) -> Option { None } fn token_properties( &self, - token: TokenId, - keys: Option>, + _token: TokenId, + _keys: Option>, ) -> Vec { vec![] } @@ -344,9 +344,9 @@ fn allowance( &self, - sender: ::CrossAccountId, - spender: ::CrossAccountId, - token: TokenId, + _sender: ::CrossAccountId, + _spender: ::CrossAccountId, + _token: TokenId, ) -> u128 { 0 } @@ -357,20 +357,24 @@ fn set_allowance_for_all( &self, - owner: ::CrossAccountId, - operator: ::CrossAccountId, - approve: bool, + _owner: ::CrossAccountId, + _operator: ::CrossAccountId, + _approve: bool, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } - fn allowance_for_all(&self, owner: ::CrossAccountId, operator: ::CrossAccountId) -> bool { + fn allowance_for_all( + &self, + _owner: ::CrossAccountId, + _operator: ::CrossAccountId, + ) -> bool { false } fn repair_item( &self, - token: TokenId, + _token: TokenId, ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo { fail!(>::UnsupportedOperation); } --- a/pallets/balances-adapter/src/erc.rs +++ b/pallets/balances-adapter/src/erc.rs @@ -9,7 +9,7 @@ use pallet_evm_coder_substrate::{ call, dispatch_to_evm, execution::{PreDispatch, Result}, - frontier_contract, WithRecorder, SubstrateRecorder, + frontier_contract, }; use sp_core::{U256, Get}; use sp_std::vec::Vec; @@ -26,13 +26,6 @@ from: Address, #[indexed] to: Address, - value: U256, - }, - Approval { - #[indexed] - owner: Address, - #[indexed] - spender: Address, value: U256, }, } --- a/pallets/balances-adapter/src/lib.rs +++ b/pallets/balances-adapter/src/lib.rs @@ -1,11 +1,9 @@ // #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] -#![warn(missing_docs)] extern crate alloc; use frame_support::sp_runtime::DispatchResult; pub use pallet::*; -use pallet_common::CollectionHandle; use pallet_evm_coder_substrate::{WithRecorder, SubstrateRecorder}; pub mod common; @@ -13,12 +11,15 @@ pub(crate) type SelfWeightOf = ::WeightInfo; +/// Handle for native fungible collection pub struct NativeFungibleHandle(SubstrateRecorder); impl NativeFungibleHandle { + /// Creates a handle pub fn new() -> NativeFungibleHandle { Self(SubstrateRecorder::new(u64::MAX)) } + /// Check if the collection is internal pub fn check_is_internal(&self) -> DispatchResult { Ok(()) } @@ -35,7 +36,7 @@ #[frame_support::pallet] pub mod pallet { use alloc::string::String; - use frame_support::{traits::Get, sp_runtime::DispatchResult}; + use frame_support::{traits::Get}; use pallet_balances::WeightInfo; use sp_core::U256; @@ -43,25 +44,24 @@ pub trait Config: frame_system::Config + pallet_evm_coder_substrate::Config + pallet_common::Config { + /// Currency from `pallet_balances` type Currency: frame_support::traits::Currency< Self::AccountId, Balance = Self::CurrencyBalance, >; + /// Balance type of chain type CurrencyBalance: Into + TryFrom + PartialEq + From + Into; + /// Decimals of balance type Decimals: Get; + /// Collection name type Name: Get; + /// Collection symbol type Symbol: Get; + /// Weight information type WeightInfo: WeightInfo; } #[pallet::pallet] pub struct Pallet(_); - - // #[pallet::call] - impl Pallet { - pub fn dummy() -> DispatchResult { - Ok(()) - } - } } --- a/pallets/common/src/dispatch.rs +++ b/pallets/common/src/dispatch.rs @@ -11,7 +11,7 @@ use sp_runtime::DispatchError; use up_data_structs::{CollectionId, CreateCollectionData, CollectionFlags}; -use crate::{pallet::Config, CommonCollectionOperations, CollectionHandle}; +use crate::{pallet::Config, CommonCollectionOperations}; // TODO: move to benchmarking /// Price of [`dispatch_tx`] call with noop `call` argument @@ -66,6 +66,7 @@ /// Interface for working with different collections through the dispatcher. pub trait CollectionDispatch { + /// Check if the collection is internal. fn check_is_internal(&self) -> DispatchResult; /// Create a collection. The collection will be created according to the value of [`data.mode`](CreateCollectionData::mode). --- a/pallets/common/src/erc.rs +++ b/pallets/common/src/erc.rs @@ -80,7 +80,7 @@ impl CommonEvmHandler for () { const CODE: &'static [u8] = &[]; - fn call(self, handle: &mut impl PrecompileHandle) -> Option { + fn call(self, _handle: &mut impl PrecompileHandle) -> Option { None } } --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -462,6 +462,7 @@ } const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + /// Collection id for native fungible collction. pub const NATIVE_FINGIBLE_COLLECTION_ID: CollectionId = CollectionId(0); #[pallet::pallet] --- a/pallets/structure/src/lib.rs +++ b/pallets/structure/src/lib.rs @@ -60,7 +60,7 @@ use frame_support::dispatch::{DispatchError, DispatchResult, DispatchResultWithPostInfo}; use frame_support::fail; pub use pallet::*; -use pallet_common::{dispatch::CollectionDispatch, CollectionHandle}; +use pallet_common::{dispatch::CollectionDispatch}; use up_data_structs::{ CollectionId, TokenId, mapping::TokenAddressMapping, budget::Budget, TokenOwnerError, }; --- a/runtime/common/dispatch.rs +++ b/runtime/common/dispatch.rs @@ -25,7 +25,7 @@ }; pub use pallet_common::dispatch::CollectionDispatch; use pallet_fungible::{Pallet as PalletFungible, FungibleHandle}; -use pallet_balances_adapter::{Pallet as PalletNativeFungible, NativeFungibleHandle}; +use pallet_balances_adapter::{NativeFungibleHandle}; use pallet_nonfungible::{Pallet as PalletNonfungible, NonfungibleHandle}; use pallet_refungible::{ Pallet as PalletRefungible, RefungibleHandle, erc_token::RefungibleTokenHandle,