use crate::{
precompiles::{BuiltinAddressMatcher, Error, Ext, PrimitivePrecompile},
vm::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(0x4).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.frame_meter_mut()
.charge_weight_token(RuntimeCosts::Identity(input.len() as _))?;
Ok(input)
}
}