git.delta.rocks / unique-network / refs/commits / 12dc7ebeba3c

difftreelog

source

pallets/balances-adapter/src/lib.rs1.7 KiBsourcehistory
1// #![doc = include_str!("../README.md")]2#![cfg_attr(not(feature = "std"), no_std)]34extern crate alloc;5use frame_support::sp_runtime::DispatchResult;6pub use pallet::*;7use pallet_evm_coder_substrate::{WithRecorder, SubstrateRecorder};89pub mod common;10pub mod erc;1112pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;1314/// Handle for native fungible collection15pub struct NativeFungibleHandle<T: Config>(SubstrateRecorder<T>);16impl<T: Config> NativeFungibleHandle<T> {17	/// Creates a handle18	pub fn new() -> NativeFungibleHandle<T> {19		Self(SubstrateRecorder::new(u64::MAX))20	}2122	/// Check if the collection is internal23	pub fn check_is_internal(&self) -> DispatchResult {24		Ok(())25	}26}2728impl<T: Config> WithRecorder<T> for NativeFungibleHandle<T> {29	fn recorder(&self) -> &pallet_evm_coder_substrate::SubstrateRecorder<T> {30		&self.031	}32	fn into_recorder(self) -> pallet_evm_coder_substrate::SubstrateRecorder<T> {33		self.034	}35}36#[frame_support::pallet]37pub mod pallet {38	use alloc::string::String;39	use frame_support::{traits::Get};40	use pallet_balances::WeightInfo;41	use sp_core::U256;4243	#[pallet::config]44	pub trait Config:45		frame_system::Config + pallet_evm_coder_substrate::Config + pallet_common::Config46	{47		/// Currency from `pallet_balances`48		type Currency: frame_support::traits::Currency<49			Self::AccountId,50			Balance = Self::CurrencyBalance,51		>;52		/// Balance type of chain53		type CurrencyBalance: Into<U256> + TryFrom<U256> + PartialEq<u128> + From<u128> + Into<u128>;5455		/// Decimals of balance56		type Decimals: Get<u8>;57		/// Collection name58		type Name: Get<String>;59		/// Collection symbol60		type Symbol: Get<String>;6162		/// Weight information63		type WeightInfo: WeightInfo;64	}65	#[pallet::pallet]66	pub struct Pallet<T>(_);67}