-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
TS SDK - Event Queries #4503
TS SDK - Event Queries #4503
Conversation
b12082d
to
9fcb1cb
Compare
@@ -12,7 +12,7 @@ export type MoveEvent = { | |||
transactionModule: string; | |||
sender: SuiAddress; | |||
type: string; | |||
fields: { [key: string]: any; }; | |||
fields?: { [key: string]: any; }; |
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.
fields
should always have been optional, i think. Some transactions turned out to have events without fields, this change unblocked the type guard validation
@@ -67,7 +67,8 @@ function objectContent(label: string, id: ObjectId) { | |||
}; | |||
} | |||
|
|||
function fieldsContent(fields: { [key: string]: any }) { | |||
function fieldsContent(fields: { [key: string]: any } | undefined) { | |||
if (!fields) return []; |
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.
this is related to my other comment about making MoveEvent.fields
optional.
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.
Thanks for adding the comprehensive test plan! Overall looks good, requesting changes for some renaming and documentation update(see inline comments). Could you also update the Usage
section in https://github.com/MystenLabs/sui/tree/main/sdk/typescript#usage to include the usage of events related API?
Co-authored-by: Chris Li <76067158+666lcz@users.noreply.github.com>
Co-authored-by: Chris Li <76067158+666lcz@users.noreply.github.com>
Co-authored-by: Chris Li <76067158+666lcz@users.noreply.github.com>
Add historical event queries
New Methods
all new methods are on the rpc
Provider
.getEventsByTransaction()
getEventsByTransactionModule()
getEventsByMoveEventStructName()
getEventsBySender()
getEventsByRecipient()
getEventsByObject()
getEventsByTimeRange()
Common Parameter Defaults
Parameters shared between many functions have defaults, to allow calling functions without specifying count or time range.
allows calling like:
instead of
API Design
The parameters for each method appear exactly as they do in the RPC method, with no abstraction. Initially i had an object that encapsulated a time range & count, but i backed it out in favor of a less opinionated design.
Testing
here's the results of some manual testing.
getEventsByTransaction()
getEventsByObject()
getEventsBySender()
getEventsByRecipient()
getEventsByTimeRange
getEventsByModule
getEventsByMoveEventStructName