use crate::{
Config, Error,
address::AddressMapper,
vm::{
Ext, RuntimeCosts,
evm::{Interpreter, interpreter::Halt},
},
};
use core::ops::ControlFlow;
pub fn gasprice<E: Ext>(interpreter: &mut Interpreter<E>) -> ControlFlow<Halt> {
interpreter.ext.charge_or_halt(RuntimeCosts::GasPrice)?;
interpreter.stack.push(interpreter.ext.effective_gas_price())
}
pub fn origin<E: Ext>(interpreter: &mut Interpreter<E>) -> ControlFlow<Halt> {
interpreter.ext.charge_or_halt(RuntimeCosts::Origin)?;
match interpreter.ext.origin().account_id() {
Ok(account_id) => {
let address = <E::T as Config>::AddressMapper::to_address(account_id);
interpreter.stack.push(address)
},
Err(_) => ControlFlow::Break(Error::<E::T>::ContractTrapped.into()),
}
}
pub fn blob_hash<'ext, E: Ext>(_interpreter: &mut Interpreter<'ext, E>) -> ControlFlow<Halt> {
ControlFlow::Break(Error::<E::T>::InvalidInstruction.into())
}