git.delta.rocks / unique-network / refs/commits / 93ced84d66b3

difftreelog

fix add license header

Grigoriy Simonov2022-12-16parent: #a90a9da.patch.diff
in: master

1 file changed

modifiedruntime/common/ethereum/precompiles/mod.rsdiffbeforeafterboth
before · runtime/common/ethereum/precompiles/mod.rs
1use pallet_evm::{Precompile, PrecompileHandle, PrecompileResult, PrecompileSet};2use sp_core::H160;3use sp_std::marker::PhantomData;45use pallet_evm_precompile_simple::{ECRecover};6use sr25519::Sr25519Precompile;78mod sr25519;9mod utils;1011pub struct UniquePrecompiles<R>(PhantomData<R>);1213impl<R> UniquePrecompiles<R>14where15	R: pallet_evm::Config,16{17	pub fn new() -> Self {18		Self(Default::default())19	}20	pub fn used_addresses() -> [H160; 2] {21		[hash(1), hash(20482)]22	}23}24impl<R> PrecompileSet for UniquePrecompiles<R>25where26	R: pallet_evm::Config,27{28	fn execute(&self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {29		match handle.code_address() {30			a if a == hash(1) => Some(ECRecover::execute(handle)),31			// Sr25519     0x500232			a if a == hash(20482) => Some(Sr25519Precompile::<R>::execute(handle)),33			_ => None,34		}35	}3637	fn is_precompile(&self, address: H160) -> bool {38		Self::used_addresses().contains(&address)39	}40}4142fn hash(a: u64) -> H160 {43	H160::from_low_u64_be(a)44}
after · runtime/common/ethereum/precompiles/mod.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use pallet_evm::{Precompile, PrecompileHandle, PrecompileResult, PrecompileSet};18use sp_core::H160;19use sp_std::marker::PhantomData;2021use pallet_evm_precompile_simple::{ECRecover};22use sr25519::Sr25519Precompile;2324mod sr25519;25mod utils;2627pub struct UniquePrecompiles<R>(PhantomData<R>);2829impl<R> UniquePrecompiles<R>30where31	R: pallet_evm::Config,32{33	pub fn new() -> Self {34		Self(Default::default())35	}36	pub fn used_addresses() -> [H160; 2] {37		[hash(1), hash(20482)]38	}39}40impl<R> PrecompileSet for UniquePrecompiles<R>41where42	R: pallet_evm::Config,43{44	fn execute(&self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {45		match handle.code_address() {46			a if a == hash(1) => Some(ECRecover::execute(handle)),47			// Sr25519     0x500248			a if a == hash(20482) => Some(Sr25519Precompile::<R>::execute(handle)),49			_ => None,50		}51	}5253	fn is_precompile(&self, address: H160) -> bool {54		Self::used_addresses().contains(&address)55	}56}5758fn hash(a: u64) -> H160 {59	H160::from_low_u64_be(a)60}