use crate::{
precompiles::{BuiltinAddressMatcher, Error, Ext, PrimitivePrecompile},
wasm::RuntimeCosts,
Config,
};
use alloc::vec::Vec;
use core::{marker::PhantomData, num::NonZero};
pub struct Identity<T>(PhantomData<T>);
impl<T: Config> PrimitivePrecompile for Identity<T> {
type T = T;
const MATCHER: BuiltinAddressMatcher = BuiltinAddressMatcher::Fixed(NonZero::new(4).unwrap());
const HAS_CONTRACT_INFO: bool = false;
fn call(
_address: &[u8; 20],
input: Vec<u8>,
env: &mut impl Ext<T = Self::T>,
) -> Result<Vec<u8>, Error> {
env.gas_meter_mut().charge(RuntimeCosts::Identity(input.len() as _))?;
Ok(input)
}
}