Skip to content

Commit

Permalink
refactor: no array starknet event
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Oct 25, 2024
1 parent bf12cc8 commit 94670fc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
7 changes: 1 addition & 6 deletions dojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,6 @@ typedef struct Event {
struct FieldElement transaction_hash;
} Event;

typedef struct CArrayEvent {
struct Event *data;
uintptr_t data_len;
} CArrayEvent;

typedef struct IndexerUpdate {
int64_t head;
int64_t tps;
Expand Down Expand Up @@ -666,7 +661,7 @@ struct Resultbool client_update_event_message_subscription(struct ToriiClient *c
struct ResultSubscription client_on_starknet_event(struct ToriiClient *client,
const struct EntityKeysClause *clauses,
uintptr_t clauses_len,
void (*callback)(struct CArrayEvent));
void (*callback)(struct Event));

struct ResultSubscription on_indexer_update(struct ToriiClient *client,
const struct FieldElement *contract_address,
Expand Down
2 changes: 1 addition & 1 deletion dojo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ Result<bool> client_update_event_message_subscription(ToriiClient *client,
Result<Subscription*> client_on_starknet_event(ToriiClient *client,
const EntityKeysClause *clauses,
uintptr_t clauses_len,
void (*callback)(CArray<Event>));
void (*callback)(Event));

Result<Subscription*> on_indexer_update(ToriiClient *client,
const FieldElement *contract_address,
Expand Down
6 changes: 1 addition & 5 deletions dojo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,6 @@ cdef extern from *:
CArrayFieldElement data;
FieldElement transaction_hash;

cdef struct CArrayEvent:
Event *data;
uintptr_t data_len;

cdef struct IndexerUpdate:
int64_t head;
int64_t tps;
Expand Down Expand Up @@ -428,7 +424,7 @@ cdef extern from *:
ResultSubscription client_on_starknet_event(ToriiClient *client,
const EntityKeysClause *clauses,
uintptr_t clauses_len,
void (*callback)(CArrayEvent));
void (*callback)(Event));

ResultSubscription on_indexer_update(ToriiClient *client,
const FieldElement *contract_address,
Expand Down
5 changes: 2 additions & 3 deletions src/c/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ pub unsafe extern "C" fn client_on_starknet_event(
client: *mut ToriiClient,
clauses: *const EntityKeysClause,
clauses_len: usize,
callback: unsafe extern "C" fn(CArray<Event>),
callback: unsafe extern "C" fn(Event),
) -> Result<*mut Subscription> {
let client = Arc::from_raw(client);
let clauses = unsafe { std::slice::from_raw_parts(clauses, clauses_len) };
Expand All @@ -323,8 +323,7 @@ pub unsafe extern "C" fn client_on_starknet_event(
let mut rcv = rcv.take_until_if(tripwire.clone());

while let Some(Ok(event)) = rcv.next().await {
let events: Vec<Event> = vec![event].into_iter().map(|e| (&e).into()).collect();
callback(events.into());
callback((&event).into());
}
}

Expand Down

0 comments on commit 94670fc

Please sign in to comment.