-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
224 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use crate::FixedBytes; | ||
|
||
wrap_fixed_bytes! { | ||
/// An Ethereum ABI function pointer, 24 bytes in length. | ||
/// | ||
/// An address (20 bytes), followed by a function selector (4 bytes). | ||
/// Encoded identical to `bytes24`. | ||
pub struct Function<24>; | ||
} | ||
|
||
impl Function { | ||
/// Creates an Ethereum function from an EVM word's upper 24 bytes | ||
/// (`word[8..]`). | ||
#[inline] | ||
#[must_use] | ||
pub fn from_word(word: FixedBytes<32>) -> Self { | ||
Self(FixedBytes(word[8..].try_into().unwrap())) | ||
} | ||
|
||
/// Left-pads the function to 32 bytes (EVM word size). | ||
#[inline] | ||
#[must_use] | ||
pub fn into_word(&self) -> FixedBytes<32> { | ||
let mut word = [0; 32]; | ||
word[8..].copy_from_slice(self.as_slice()); | ||
FixedBytes(word) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.