MystenLabs / sui

Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by the Move programming language
https://sui.io
Apache License 2.0
5.84k stars 11.06k forks source link

Graphql events filter add beforeCheckpoint, afterCheckpoint params #18397

Open huwentao1 opened 4 days ago

huwentao1 commented 4 days ago
events(
  first: Int
  after: String
  last: Int
  before: String
  filter: EventFilter
): EventConnection!

Can add fromCheckpoint, afterCheckpoint to the filtering of this event, similar to the parameters of TransactionBlockFilter?

input TransactionBlockFilter {
  afterCheckpoint: Int
  atCheckpoint: Int
  beforeCheckpoint: Int
}
wlmyng commented 3 days ago

Hey @huwentao1 , this is something we likely can support. There are some other high priority tasks we're working through right now, but can return to this later.

huwentao1 commented 3 days ago

Hello, @wlmyng I also want to ask a question. I now want to filter some data with the following conditions:

from_height: 37699386 
to_height: 37699389 
packageIds: 
        [
           "0xefe170ec0be4d762196bedecd7a065816576198a6527c99282a2551aaa7da38c",
           "0x88d362329ede856f5f67867929ed570bba06c975abec2fab7f0601c56f6a8cb1"
        ]

Is there currently any suitable excuse for rpc or graphql support?

  1. rpc I now want to check it through rpc, but it seems that it does not support combined query. It can only be used in the form of timerange, or only in the form of packageId.
    curl --location 'https://fullnode.mainnet.sui.io:443' \
    --header 'Content-Type: application/json' \
    --data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "suix_queryEvents",
    "params": [
        {
            "TimeRange": {
                "startTime": "1716627283737",
                "endTime": "1716627284737"
            }
        },
        null,
        null,
        true
    ]
    }'
  2. graphql events If you check it through graphql, it seems that this form is not supported checkpoint filtering.
  3. graphql transactionBlocks transactionBlocks but this method does not support packageIds filtering

I don’t know if I missed relevant information somewhere. Is there any way to achieve the above function?

wlmyng commented 3 days ago

The functionality you're looking for is not currently supported.

  1. On jsonrpc, you can only specify one filtering condition
  2. That's right, it is not implemented on graphql yet
  3. You could potentially leverage function, after_checkpoint, and before_checkpoint? But that may not necessarily correspond to the expected event type.
huwentao1 commented 3 days ago

hey, bro, @wlmyng I think these combined queries are very important for developers to integrate data on the sui chain. Now the integration of on-chain data becomes a bit tricky,When do you plan to add beforeCheckpoint and afterCheckpoint to graphql events?

wlmyng commented 3 days ago

Once we stabilize the performance of our current schema, we'll be happy to explore what additional features are needed to help empower the community. In the meantime, feel free to join our office hours and we can potentially hash out a workaround for your particular use case.