git.delta.rocks / unique-network / refs/commits / 3293186a48b2

difftreelog

source

pallets/balances-adapter/src/lib.rs1.9 KiBsourcehistory
1// #![doc = include_str!("../README.md")]2#![cfg_attr(not(feature = "std"), no_std)]34extern crate alloc;5use core::ops::Deref;67use frame_support::sp_runtime::DispatchResult;8pub use pallet::*;9use pallet_evm_coder_substrate::{WithRecorder, SubstrateRecorder};1011pub mod common;12pub mod erc;1314pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;1516/// Handle for native fungible collection17pub struct NativeFungibleHandle<T: Config>(SubstrateRecorder<T>);18impl<T: Config> NativeFungibleHandle<T> {19	/// Creates a handle20	pub fn new() -> NativeFungibleHandle<T> {21		Self(SubstrateRecorder::new(u64::MAX))22	}2324	/// Check if the collection is internal25	pub fn check_is_internal(&self) -> DispatchResult {26		Ok(())27	}28}2930impl<T: Config> WithRecorder<T> for NativeFungibleHandle<T> {31	fn recorder(&self) -> &pallet_evm_coder_substrate::SubstrateRecorder<T> {32		&self.033	}34	fn into_recorder(self) -> pallet_evm_coder_substrate::SubstrateRecorder<T> {35		self.036	}37}3839impl<T: Config> Deref for NativeFungibleHandle<T> {40	type Target = SubstrateRecorder<T>;4142	fn deref(&self) -> &Self::Target {43		&self.044	}45}46#[frame_support::pallet]47pub mod pallet {48	use alloc::string::String;49	use frame_support::{traits::Get};50	use pallet_balances::WeightInfo;51	use sp_core::U256;5253	#[pallet::config]54	pub trait Config:55		frame_system::Config + pallet_evm_coder_substrate::Config + pallet_common::Config56	{57		/// Currency from `pallet_balances`58		type Currency: frame_support::traits::Currency<59			Self::AccountId,60			Balance = Self::CurrencyBalance,61		>;62		/// Balance type of chain63		type CurrencyBalance: Into<U256> + TryFrom<U256> + PartialEq<u128> + From<u128> + Into<u128>;6465		/// Decimals of balance66		type Decimals: Get<u8>;67		/// Collection name68		type Name: Get<String>;69		/// Collection symbol70		type Symbol: Get<String>;7172		/// Weight information73		type WeightInfo: WeightInfo;74	}75	#[pallet::pallet]76	pub struct Pallet<T>(_);77}