Skip to content

Commit

Permalink
add macro to encode/decode abi by using alloy-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerKSI committed Nov 7, 2023
1 parent abfd2cd commit 1085aeb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/kit/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,25 @@ macro_rules! execute_entry_point {
}
};
}

#[macro_export]
macro_rules! prepare_abi_entry_point {
($name:ident) => {
#[no_mangle]
pub fn prepare() {
$name(SolValue::abi_decode(&oei::get_calldata(), true).unwrap());
}
};
}

#[macro_export]
macro_rules! execute_abi_entry_point {
($name:ident) => {
#[no_mangle]
pub fn execute() {
oei::save_return_data(
&$name(SolValue::abi_decode(&oei::get_calldata(), true).unwrap()).abi_encode(),
);
}
};
}

0 comments on commit 1085aeb

Please sign in to comment.