referrerpolicy=no-referrer-when-downgrade

pallet_revive/precompiles/builtin/
point_eval.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18use crate::{
19	precompiles::{BuiltinAddressMatcher, Error, Ext, PrimitivePrecompile},
20	Config, Error as CrateError,
21};
22use alloc::vec::Vec;
23use core::{marker::PhantomData, num::NonZero};
24
25pub struct PointEval<T>(PhantomData<T>);
26
27impl<T: Config> PrimitivePrecompile for PointEval<T> {
28	type T = T;
29	const MATCHER: BuiltinAddressMatcher =
30		BuiltinAddressMatcher::Fixed(NonZero::new(0x0a).unwrap());
31	const HAS_CONTRACT_INFO: bool = false;
32
33	fn call(
34		_address: &[u8; 20],
35		_input: Vec<u8>,
36		_env: &mut impl Ext<T = Self::T>,
37	) -> Result<Vec<u8>, Error> {
38		// Exists on Ethereum but we didn't implement it, yet.
39		// This fails the call instead of doing a silent balance transfer.
40		Err(<CrateError<T>>::UnsupportedPrecompileAddress.into())
41	}
42}