-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to retrieve event selectors
- Loading branch information
Showing
6 changed files
with
76 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::interpreter::{ | ||
functions::{FunctionDef, SyncProperty}, | ||
Env, Type, Value, | ||
}; | ||
use anyhow::{bail, Result}; | ||
use lazy_static::lazy_static; | ||
|
||
pub fn event_selector(_env: &Env, receiver: &Value) -> Result<Value> { | ||
let event_abi = match receiver { | ||
Value::TypeObject(Type::Event(event)) => event, | ||
_ => bail!("selector function expects receiver to be an event"), | ||
}; | ||
|
||
Ok(event_abi.selector().into()) | ||
} | ||
|
||
lazy_static! { | ||
pub static ref EVENT_SELECTOR: Arc<dyn FunctionDef> = | ||
SyncProperty::arc("selector", event_selector); | ||
} |
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