mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-19 09:51:02 +00:00
sync runtime with the pallet (#54)
This commit is contained in:
@@ -53,22 +53,7 @@ pub fn block_number<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let (output_pointer, output_length_pointer) = context.build_stack_parameter(
|
||||
revive_common::BIT_LENGTH_BLOCK_NUMBER,
|
||||
"block_timestamp_output",
|
||||
);
|
||||
context.build_runtime_call(
|
||||
runtime_api::imports::BLOCK_NUMBER,
|
||||
&[
|
||||
output_pointer.to_int(context).into(),
|
||||
output_length_pointer.to_int(context).into(),
|
||||
],
|
||||
);
|
||||
context.build_load_word(
|
||||
output_pointer,
|
||||
revive_common::BIT_LENGTH_BLOCK_NUMBER,
|
||||
"block_number",
|
||||
)
|
||||
context.build_runtime_call_to_getter(runtime_api::imports::BLOCK_NUMBER)
|
||||
}
|
||||
|
||||
/// Translates the `block_timestamp` instruction.
|
||||
@@ -78,22 +63,7 @@ pub fn block_timestamp<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let (output_pointer, output_length_pointer) = context.build_stack_parameter(
|
||||
revive_common::BIT_LENGTH_BLOCK_TIMESTAMP,
|
||||
"block_timestamp_output",
|
||||
);
|
||||
context.build_runtime_call(
|
||||
runtime_api::imports::NOW,
|
||||
&[
|
||||
output_pointer.to_int(context).into(),
|
||||
output_length_pointer.to_int(context).into(),
|
||||
],
|
||||
);
|
||||
context.build_load_word(
|
||||
output_pointer,
|
||||
revive_common::BIT_LENGTH_BLOCK_TIMESTAMP,
|
||||
"block_timestamp",
|
||||
)
|
||||
context.build_runtime_call_to_getter(runtime_api::imports::NOW)
|
||||
}
|
||||
|
||||
/// Translates the `block_hash` instruction.
|
||||
@@ -171,16 +141,15 @@ pub fn address<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let (output_pointer, output_length_pointer) =
|
||||
context.build_stack_parameter(revive_common::BIT_LENGTH_ETH_ADDRESS, "address_output");
|
||||
let pointer = context.build_alloca_at_entry(
|
||||
context.integer_type(revive_common::BIT_LENGTH_ETH_ADDRESS),
|
||||
"address_output",
|
||||
);
|
||||
context.build_runtime_call(
|
||||
runtime_api::imports::ADDRESS,
|
||||
&[
|
||||
output_pointer.to_int(context).into(),
|
||||
output_length_pointer.to_int(context).into(),
|
||||
],
|
||||
&[pointer.to_int(context).into()],
|
||||
);
|
||||
let value = context.build_byte_swap(context.build_load(output_pointer, "address")?)?;
|
||||
let value = context.build_byte_swap(context.build_load(pointer, "address")?)?;
|
||||
Ok(context
|
||||
.builder()
|
||||
.build_int_z_extend(value.into_int_value(), context.word_type(), "address_zext")?
|
||||
@@ -194,18 +163,5 @@ pub fn caller<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let (output_pointer, output_length_pointer) =
|
||||
context.build_stack_parameter(revive_common::BIT_LENGTH_ETH_ADDRESS, "caller_output");
|
||||
context.build_runtime_call(
|
||||
runtime_api::imports::CALLER,
|
||||
&[
|
||||
output_pointer.to_int(context).into(),
|
||||
output_length_pointer.to_int(context).into(),
|
||||
],
|
||||
);
|
||||
let value = context.build_byte_swap(context.build_load(output_pointer, "caller")?)?;
|
||||
Ok(context
|
||||
.builder()
|
||||
.build_int_z_extend(value.into_int_value(), context.word_type(), "caller_zext")?
|
||||
.into())
|
||||
context.build_runtime_call_to_getter(runtime_api::imports::CALLER)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user