Closed PhilippeR26 closed 3 weeks ago
I think I will first commit something to answer to @tabaktoni, and when it will be accepted, I will focus on @ivpavici requests.
All comments implemented, except the ones waiting answers to my questions : @tabaktoni :
@ivpavici :
@tabaktoni I have added the types from rpc 0.6 (as rpc 0.7 event types can't be imported with current libs used by SNJS) : abi.ts :
import type { ENUM_EVENT, EVENT_FIELD, STRUCT_EVENT } from '../../api/rpcspec_0_6/contract';
I will move to 0.7 when exports available.
NOTA : I have now a huge quantity of commits listed in this PR, that appeared after merge to next-version branch. I don't know how to solve this. If it's a problem, if somebody can solve this ...
Should be now good to merge...
Motivation and Resolution
Solves #1134 . Cairo is now using a new concept : the components. Events can be nested in these components. To differentiate them, an event name can now be defined with more than one hash number ; so the number of felts to represent the hashed name in
key[]
can be greater than one (unless usage of the Cairo#[flat]
attribute). See https://book.cairo-lang.org/ch14-03-contract-events.html?highlight=events#defining-events . As the current code is not taking into account this case of nested events, the parse of a such event is returning an empty array. This PR is solving this case.Usage related changes
Development related changes
getAbiEvents()
creates recursively a tree of events hashs. It will be used for the event parse.events.parseEvents()
is reading the event name hash inkey[]
; if necessary, several numbers are read.Flat
Event. It includes normal events and nested events, with 2 events with the same name (Deposit
). So there is no use of Devnet-rs ; inputs and outputs have been recovered from Sepolia real examples.Checklist: