support the origin opcode (#103)

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
Cyrill Leutwiler
2024-10-29 18:40:25 +01:00
committed by GitHub
parent a4043ecde7
commit 5b3b90db83
5 changed files with 70 additions and 3 deletions
@@ -27,12 +27,19 @@ where
/// Translates the `tx.origin` instruction.
pub fn origin<'ctx, D>(
_context: &mut Context<'ctx, D>,
context: &mut Context<'ctx, D>,
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
where
D: Dependency + Clone,
{
todo!()
let address_type = context.integer_type(revive_common::BIT_LENGTH_ETH_ADDRESS);
let address_pointer = context.build_alloca_at_entry(address_type, "origin_address");
context.build_store(address_pointer, address_type.const_zero())?;
context.build_runtime_call(
revive_runtime_api::polkavm_imports::ORIGIN,
&[address_pointer.to_int(context).into()],
);
context.build_load_address(address_pointer)
}
/// Translates the `chain_id` instruction.