Skip to content

Commit

Permalink
choro
Browse files Browse the repository at this point in the history
  • Loading branch information
jetjinser committed Feb 1, 2023
1 parent 03a22a2 commit e250172
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion blocknative-sdk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocknative-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blocknative-flows"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
license = "MIT/Apache-2.0"
description = "Block Native extension for flows.network"
Expand Down
24 changes: 14 additions & 10 deletions blocknative-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,10 @@ pub fn revoke_listeners() {
}
}

pub fn listen_to_address(address: &str, callback: fn(Event)) {
if let Some(bnm) = event_received(address) {
callback(bnm)
}
}

fn event_received(address: &str) -> Option<Event> {
pub fn listen_to_address<F>(address: &str, callback: F)
where
F: Fn(Event),
{
unsafe {
match is_listening() {
// Calling register
Expand Down Expand Up @@ -130,14 +127,21 @@ fn event_received(address: &str) -> Option<Event> {
.unwrap();

match res.status_code().is_success() {
true => serde_json::from_slice::<Event>(&writer).ok(),
true => {
if let Ok(event) = serde_json::from_slice::<Event>(&writer) {
callback(event)
}
}
false => {
set_error_log(writer.as_ptr(), writer.len() as i32);
None
}
}
}
_ => event_from_subcription(),
_ => {
if let Some(event) = event_from_subcription() {
callback(event)
}
}
}
}
}
Expand Down

1 comment on commit e250172

@vercel
Copy link

@vercel vercel bot commented on e250172 Feb 1, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

bn-flows-js – ./

bn-flows-js.vercel.app
bn-flows-js-jetjinser.vercel.app
bn-flows-js-git-main-jetjinser.vercel.app

Please sign in to comment.