-
Notifications
You must be signed in to change notification settings - Fork 756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for parsing emitted events #1227
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
RPC.EmittedEvent[] | RPC.Event[]
?Isn't it only
RPC.EmittedEvent[]
?In which case are block_hash, block_number & transaction_hash not included?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Block/tx info is not included in a case where you first fetch transaction receipt with
starknet_getTransactionReceipt
. In those kinds of reponsesRPC.Event
struct is returned (see: this). On the other hand when fetching data withstarknet_fetchEvents
returned struct isRPC.EmittedEvents
.So I thought it would be nice to leave that as is in case someone had code like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the root cause of this wrong input type of
events.parseEvents()
is due toContract.parseEvent()
. This method is callingevents.parseEvents()
withRPC.event
format ; here is the root cause of all this mess.I think that you have to modify
Contract.parseEvent()
:events.parseEvents()
:events.parseEvents()
:events.parseEvents()
has to accept both types as input.RPC.Event[]
type was here only to handleContract.parseEvent()
; it's useless for users. They usesEVENTS_CHUNK
type (result ofRpcProvider.getEvents()
), that includesEmittedEvent
type. NeverRPC.Events
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how pending transaction have anything to do with this. AFAIK events are created and emitted during transaction execution. So there is always tx hash, block hash and block number corresponding to the event. They are missing from events array of the recipiet because that is always available in parent (receipt) object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If PENDING is not appropriate, then we have still a problem in Contract.parseEvents() :
starknet.js/src/contract/default.ts
Line 333 in 47e52cf
InvokeTransactionReceiptResponse
type is not the good one, because it's made ofINVOKE_TXN_RECEIPT | PENDING_INVOKE_TXN_RECEIPT
And in this case, only
EMITTED_EVENT
should be transfered fromContract.parseEvent()
toevents.parseEvents()
(notRPC.event
).Comment about uselessness of
RPC.event
as input ofevents.parseEvents()
remains valid.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I understood correctly, you would like
Contract.parseEvent()
to change and look like this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this way.
I tested successfully this :
contract/default.ts :
events/index.ts :