From 94670fcc2c9fb1386fe24bb9aff0366d0ee9a950 Mon Sep 17 00:00:00 2001 From: Nasr Date: Fri, 25 Oct 2024 19:13:23 -0400 Subject: [PATCH] refactor: no array starknet event --- dojo.h | 7 +------ dojo.hpp | 2 +- dojo.pyx | 6 +----- src/c/mod.rs | 5 ++--- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/dojo.h b/dojo.h index 63a82cd..dd67df7 100644 --- a/dojo.h +++ b/dojo.h @@ -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; @@ -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, diff --git a/dojo.hpp b/dojo.hpp index 056d10b..7c04a29 100644 --- a/dojo.hpp +++ b/dojo.hpp @@ -917,7 +917,7 @@ Result client_update_event_message_subscription(ToriiClient *client, Result client_on_starknet_event(ToriiClient *client, const EntityKeysClause *clauses, uintptr_t clauses_len, - void (*callback)(CArray)); + void (*callback)(Event)); Result on_indexer_update(ToriiClient *client, const FieldElement *contract_address, diff --git a/dojo.pyx b/dojo.pyx index cf0a415..788e145 100644 --- a/dojo.pyx +++ b/dojo.pyx @@ -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; @@ -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, diff --git a/src/c/mod.rs b/src/c/mod.rs index 6d7eecf..df24fca 100644 --- a/src/c/mod.rs +++ b/src/c/mod.rs @@ -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), + 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) }; @@ -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 = vec![event].into_iter().map(|e| (&e).into()).collect(); - callback(events.into()); + callback((&event).into()); } }