Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement get_selector_from_name #40

Merged
merged 2 commits into from
Jan 26, 2022
Merged

feat: implement get_selector_from_name #40

merged 2 commits into from
Jan 26, 2022

Conversation

xJonathanLEI
Copy link
Owner

This PR ports get_selector_from_name from cairo-lang.

Copy link
Collaborator

@milancermak milancermak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet 🚀


pub fn get_selector_from_name(func_name: &str) -> Result<H256, NonAsciiNameError> {
if func_name == DEFAULT_ENTRY_POINT_NAME || func_name == DEFAULT_L1_ENTRY_POINT_NAME {
Ok(H256::from_slice(&[0u8; 32]))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

H256::zero() maybe?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're right, and it's const. Much better. Didn't know it exists lol.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me neither until 10 minutes ago 😄


#[test]
fn test_get_selector_from_non_ascii_name() {
let func_name = "🦀";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@xJonathanLEI xJonathanLEI merged commit 90e7b4e into master Jan 26, 2022
@xJonathanLEI xJonathanLEI deleted the dev/selector branch January 26, 2022 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants