difftreelog
remove warnings
in: master
8 files changed
pallets/balances-adapter/src/common.rsdiffbeforeafterboth1use alloc::{vec, vec::Vec};2use core::marker::PhantomData;3use crate::{Config, NativeFungibleHandle};4use frame_support::{5 fail,6 traits::{Currency, ExistenceRequirement},7 weights::Weight,8};9use pallet_balances::{weights::SubstrateWeight as BalancesWeight, WeightInfo};10use pallet_common::{erc::CrossAccountId, CommonCollectionOperations, CommonWeightInfo, with_weight};11use up_data_structs::TokenId;1213pub struct CommonWeights<T: Config>(PhantomData<T>);14impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {15 fn create_multiple_items(amount: &[up_data_structs::CreateItemData]) -> Weight {16 Weight::default()17 }1819 fn create_multiple_items_ex(20 cost: &up_data_structs::CreateItemExData<T::CrossAccountId>,21 ) -> Weight {22 Weight::default()23 }2425 fn burn_item() -> Weight {26 Weight::default()27 }2829 fn set_collection_properties(amount: u32) -> Weight {30 Weight::default()31 }3233 fn delete_collection_properties(amount: u32) -> Weight {34 Weight::default()35 }3637 fn set_token_properties(amount: u32) -> Weight {38 Weight::default()39 }4041 fn delete_token_properties(amount: u32) -> Weight {42 Weight::default()43 }4445 fn set_token_property_permissions(amount: u32) -> Weight {46 Weight::default()47 }4849 fn transfer() -> Weight {50 <BalancesWeight<T> as WeightInfo>::transfer()51 }5253 fn approve() -> Weight {54 Weight::default()55 }5657 fn approve_from() -> Weight {58 Weight::default()59 }6061 fn transfer_from() -> Weight {62 <BalancesWeight<T> as WeightInfo>::transfer()63 }6465 fn burn_from() -> Weight {66 Weight::default()67 }6869 fn burn_recursively_self_raw() -> Weight {70 Weight::default()71 }7273 fn burn_recursively_breadth_raw(amount: u32) -> Weight {74 Weight::default()75 }7677 fn token_owner() -> Weight {78 Weight::default()79 }8081 fn set_allowance_for_all() -> Weight {82 Weight::default()83 }8485 fn force_repair_item() -> Weight {86 Weight::default()87 }88}8990/// Implementation of `CommonCollectionOperations` for `FungibleHandle`. It wraps FungibleHandle Pallete91/// methods and adds weight info.92impl<T: Config> CommonCollectionOperations<T> for NativeFungibleHandle<T> {93 fn create_item(94 &self,95 sender: <T>::CrossAccountId,96 to: <T>::CrossAccountId,97 data: up_data_structs::CreateItemData,98 nesting_budget: &dyn up_data_structs::budget::Budget,99 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {100 fail!(<pallet_common::Error<T>>::UnsupportedOperation);101 }102103 fn create_multiple_items(104 &self,105 sender: <T>::CrossAccountId,106 to: <T>::CrossAccountId,107 data: Vec<up_data_structs::CreateItemData>,108 nesting_budget: &dyn up_data_structs::budget::Budget,109 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {110 fail!(<pallet_common::Error<T>>::UnsupportedOperation);111 }112113 fn create_multiple_items_ex(114 &self,115 sender: <T>::CrossAccountId,116 data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,117 nesting_budget: &dyn up_data_structs::budget::Budget,118 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {119 fail!(<pallet_common::Error<T>>::UnsupportedOperation);120 }121122 fn burn_item(123 &self,124 sender: <T>::CrossAccountId,125 token: TokenId,126 amount: u128,127 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {128 fail!(<pallet_common::Error<T>>::UnsupportedOperation);129 }130131 fn burn_item_recursively(132 &self,133 sender: <T>::CrossAccountId,134 token: TokenId,135 self_budget: &dyn up_data_structs::budget::Budget,136 breadth_budget: &dyn up_data_structs::budget::Budget,137 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {138 fail!(<pallet_common::Error<T>>::UnsupportedOperation);139 }140141 fn set_collection_properties(142 &self,143 sender: <T>::CrossAccountId,144 properties: Vec<up_data_structs::Property>,145 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {146 fail!(<pallet_common::Error<T>>::UnsupportedOperation);147 }148149 fn delete_collection_properties(150 &self,151 sender: &<T>::CrossAccountId,152 property_keys: Vec<up_data_structs::PropertyKey>,153 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {154 fail!(<pallet_common::Error<T>>::UnsupportedOperation);155 }156157 fn set_token_properties(158 &self,159 sender: <T>::CrossAccountId,160 token_id: TokenId,161 properties: Vec<up_data_structs::Property>,162 budget: &dyn up_data_structs::budget::Budget,163 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {164 fail!(<pallet_common::Error<T>>::UnsupportedOperation);165 }166167 fn delete_token_properties(168 &self,169 sender: <T>::CrossAccountId,170 token_id: TokenId,171 property_keys: Vec<up_data_structs::PropertyKey>,172 budget: &dyn up_data_structs::budget::Budget,173 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {174 fail!(<pallet_common::Error<T>>::UnsupportedOperation);175 }176177 fn set_token_property_permissions(178 &self,179 sender: &<T>::CrossAccountId,180 property_permissions: Vec<up_data_structs::PropertyKeyPermission>,181 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {182 fail!(<pallet_common::Error<T>>::UnsupportedOperation);183 }184185 fn transfer(186 &self,187 sender: <T>::CrossAccountId,188 to: <T>::CrossAccountId,189 token: TokenId,190 amount: u128,191 budget: &dyn up_data_structs::budget::Budget,192 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {193 with_weight(194 <T as Config>::Currency::transfer(195 sender.as_sub(),196 to.as_sub(),197 amount.into(),198 ExistenceRequirement::KeepAlive,199 ),200 Default::default(),201 )202 }203204 fn approve(205 &self,206 sender: <T>::CrossAccountId,207 spender: <T>::CrossAccountId,208 token: TokenId,209 amount: u128,210 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {211 fail!(<pallet_common::Error<T>>::UnsupportedOperation);212 }213214 fn approve_from(215 &self,216 sender: <T>::CrossAccountId,217 from: <T>::CrossAccountId,218 to: <T>::CrossAccountId,219 token: TokenId,220 amount: u128,221 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {222 fail!(<pallet_common::Error<T>>::UnsupportedOperation);223 }224225 fn transfer_from(226 &self,227 sender: <T>::CrossAccountId,228 from: <T>::CrossAccountId,229 to: <T>::CrossAccountId,230 token: TokenId,231 amount: u128,232 budget: &dyn up_data_structs::budget::Budget,233 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {234 if sender != from {235 fail!(<pallet_common::Error<T>>::NoPermission);236 }237 with_weight(238 <T as Config>::Currency::transfer(239 from.as_sub(),240 to.as_sub(),241 amount.into(),242 ExistenceRequirement::KeepAlive,243 ),244 Default::default(),245 )246 }247248 fn burn_from(249 &self,250 sender: <T>::CrossAccountId,251 from: <T>::CrossAccountId,252 token: TokenId,253 amount: u128,254 budget: &dyn up_data_structs::budget::Budget,255 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {256 fail!(<pallet_common::Error<T>>::UnsupportedOperation);257 }258259 fn check_nesting(260 &self,261 sender: <T>::CrossAccountId,262 from: (up_data_structs::CollectionId, TokenId),263 under: TokenId,264 budget: &dyn up_data_structs::budget::Budget,265 ) -> frame_support::sp_runtime::DispatchResult {266 fail!(<pallet_common::Error<T>>::UnsupportedOperation);267 }268269 fn nest(&self, under: TokenId, to_nest: (up_data_structs::CollectionId, TokenId)) {}270271 fn unnest(&self, under: TokenId, to_nest: (up_data_structs::CollectionId, TokenId)) {}272273 fn account_tokens(&self, account: <T>::CrossAccountId) -> Vec<TokenId> {274 let balance = <T as Config>::Currency::total_balance(account.as_sub());275 if balance != 0 {276 vec![TokenId::default()]277 } else {278 vec![]279 }280 }281282 fn collection_tokens(&self) -> Vec<TokenId> {283 vec![TokenId::default()]284 }285286 fn token_exists(&self, token: TokenId) -> bool {287 token == TokenId::default()288 }289290 fn last_token_id(&self) -> TokenId {291 TokenId::default()292 }293294 fn token_owner(295 &self,296 token: TokenId,297 ) -> Result<<T>::CrossAccountId, up_data_structs::TokenOwnerError> {298 Err(up_data_structs::TokenOwnerError::MultipleOwners)299 }300301 fn token_owners(&self, token: TokenId) -> Vec<<T>::CrossAccountId> {302 vec![]303 }304305 fn token_property(306 &self,307 token_id: TokenId,308 key: &up_data_structs::PropertyKey,309 ) -> Option<up_data_structs::PropertyValue> {310 None311 }312313 fn token_properties(314 &self,315 token: TokenId,316 keys: Option<Vec<up_data_structs::PropertyKey>>,317 ) -> Vec<up_data_structs::Property> {318 vec![]319 }320321 fn total_supply(&self) -> u32 {322 1323 }324325 fn account_balance(&self, account: <T>::CrossAccountId) -> u32 {326 let balance: u128 = <T as Config>::Currency::free_balance(account.as_sub()).into();327 (balance != 0).into()328 }329330 fn balance(&self, account: <T>::CrossAccountId, token: TokenId) -> u128 {331 if token != TokenId::default() {332 return 0;333 }334 <T as Config>::Currency::free_balance(account.as_sub()).into()335 }336337 fn total_pieces(&self, token: TokenId) -> Option<u128> {338 if token != TokenId::default() {339 return None;340 }341 let total = <T as Config>::Currency::total_issuance();342 Some(total.into())343 }344345 fn allowance(346 &self,347 sender: <T>::CrossAccountId,348 spender: <T>::CrossAccountId,349 token: TokenId,350 ) -> u128 {351 0352 }353354 fn refungible_extensions(&self) -> Option<&dyn pallet_common::RefungibleExtensions<T>> {355 None356 }357358 fn set_allowance_for_all(359 &self,360 owner: <T>::CrossAccountId,361 operator: <T>::CrossAccountId,362 approve: bool,363 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {364 fail!(<pallet_common::Error<T>>::UnsupportedOperation);365 }366367 fn allowance_for_all(&self, owner: <T>::CrossAccountId, operator: <T>::CrossAccountId) -> bool {368 false369 }370371 fn repair_item(372 &self,373 token: TokenId,374 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {375 fail!(<pallet_common::Error<T>>::UnsupportedOperation);376 }377}pallets/balances-adapter/src/erc.rsdiffbeforeafterboth--- 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,
},
}
pallets/balances-adapter/src/lib.rsdiffbeforeafterboth--- 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<T> = <T as Config>::WeightInfo;
+/// Handle for native fungible collection
pub struct NativeFungibleHandle<T: Config>(SubstrateRecorder<T>);
impl<T: Config> NativeFungibleHandle<T> {
+ /// Creates a handle
pub fn new() -> NativeFungibleHandle<T> {
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<U256> + TryFrom<U256> + PartialEq<u128> + From<u128> + Into<u128>;
+ /// Decimals of balance
type Decimals: Get<u8>;
+ /// Collection name
type Name: Get<String>;
+ /// Collection symbol
type Symbol: Get<String>;
+ /// Weight information
type WeightInfo: WeightInfo;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
-
- // #[pallet::call]
- impl<T: Config> Pallet<T> {
- pub fn dummy() -> DispatchResult {
- Ok(())
- }
- }
}
pallets/common/src/dispatch.rsdiffbeforeafterboth--- 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<T: Config> {
+ /// 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).
pallets/common/src/erc.rsdiffbeforeafterboth--- 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<PrecompileResult> {
+ fn call(self, _handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {
None
}
}
pallets/common/src/lib.rsdiffbeforeafterboth--- 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]
pallets/structure/src/lib.rsdiffbeforeafterboth--- 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,
};
runtime/common/dispatch.rsdiffbeforeafterboth--- 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,