Skip to content
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

Refactor event filter and Implements indexer event RPC #1136

Merged
merged 7 commits into from
Nov 15, 2023
Merged

Conversation

baichuan3
Copy link
Collaborator

@baichuan3 baichuan3 commented Nov 13, 2023

Continue #1028

Summary

  1. Refactor and simple event filter
  2. Implements indexer event RPC on indexer

Todo

  1. Make tx order type is u64
  2. Add more test cases
  3. Support decode event data in return data

Copy link

vercel bot commented Nov 13, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rooch ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2023 3:09pm

@baichuan3
Copy link
Collaborator Author

  1. queryEvents by Sender
curl --location 'http://localhost:50051' \
--header 'Content-Type: application/json' \
--data '{
    "id": 101,
    "jsonrpc": "2.0",
    "method": "rooch_queryEvents",
    "params": [
        {"sender":"0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56"}, null, "10", true
    ]
}'

result

{
    "jsonrpc": "2.0",
    "result": {
        "data": [
            {
                "indexer_event_id": {
                    "tx_order": 3,
                    "event_index": 0
                },
                "event_id": {
                    "event_handle_id": "0xa91bc7d411afd987f3949d27e2eb6596c0b37859b115487713ec7e92eb07c6a1",
                    "event_seq": 2
                },
                "event_type": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56::event_test::WithdrawEvent",
                "event_data": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c566400000000000000",
                "tx_hash": "0x28dba082087bc9bf65feb5887f5efe9127472a97b4668a7e58fc5f23d0330108",
                "sender": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56",
                "created_at": 0,
                "decoded_event_data": null
            },
            {
                "indexer_event_id": {
                    "tx_order": 2,
                    "event_index": 0
                },
                "event_id": {
                    "event_handle_id": "0xa91bc7d411afd987f3949d27e2eb6596c0b37859b115487713ec7e92eb07c6a1",
                    "event_seq": 1
                },
                "event_type": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56::event_test::WithdrawEvent",
                "event_data": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c566400000000000000",
                "tx_hash": "0x936b1f3ec182423cd146c3f49ba82fe78029866d150f127df4ba4d3d6d0cf375",
                "sender": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56",
                "created_at": 0,
                "decoded_event_data": null
            },
            {
                "indexer_event_id": {
                    "tx_order": 1,
                    "event_index": 0
                },
                "event_id": {
                    "event_handle_id": "0xa91bc7d411afd987f3949d27e2eb6596c0b37859b115487713ec7e92eb07c6a1",
                    "event_seq": 0
                },
                "event_type": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56::event_test::WithdrawEvent",
                "event_data": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c566400000000000000",
                "tx_hash": "0x473eaadfd612ec792a96b1ec3b385107acac6745635b0532afbede8ca739649a",
                "sender": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56",
                "created_at": 0,
                "decoded_event_data": null
            },
            {
                "indexer_event_id": {
                    "tx_order": 0,
                    "event_index": 0
                },
                "event_id": {
                    "event_handle_id": "0xa70cdcf8493ee1964b02fdc8cd85c4d8c5f595891ea255282619db806659aa3f",
                    "event_seq": 0
                },
                "event_type": "0x3::coin::MintEvent",
                "event_data": "0x53303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333a3a6761735f636f696e3a3a476173436f696e000010632d5ec76b050000000000000000000000000000000000000000000000",
                "tx_hash": "0x425e591cac8ddd39f42961eab056deb391d71d22eee74f0969a07241548fef3b",
                "sender": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56",
                "created_at": 0,
                "decoded_event_data": null
            }
        ],
        "next_cursor": {
            "tx_order": 0,
            "event_index": 0
        },
        "has_next_page": false
    },
    "id": 101
}

2 query event by Tx Order Range

curl --location 'http://localhost:50051' \
--header 'Content-Type: application/json' \
--data '{
    "id": 101,
    "jsonrpc": "2.0",
    "method": "rooch_queryEvents",
    "params": [
        {"txOrderRange":{"from_order":0, "to_order":3}}, null, "10", true
    ]
}'

result

{
    "jsonrpc": "2.0",
    "result": {
        "data": [
            {
                "indexer_event_id": {
                    "tx_order": 2,
                    "event_index": 0
                },
                "event_id": {
                    "event_handle_id": "0xa91bc7d411afd987f3949d27e2eb6596c0b37859b115487713ec7e92eb07c6a1",
                    "event_seq": 1
                },
                "event_type": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56::event_test::WithdrawEvent",
                "event_data": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c566400000000000000",
                "tx_hash": "0x936b1f3ec182423cd146c3f49ba82fe78029866d150f127df4ba4d3d6d0cf375",
                "sender": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56",
                "created_at": 0,
                "decoded_event_data": null
            },
            {
                "indexer_event_id": {
                    "tx_order": 1,
                    "event_index": 0
                },
                "event_id": {
                    "event_handle_id": "0xa91bc7d411afd987f3949d27e2eb6596c0b37859b115487713ec7e92eb07c6a1",
                    "event_seq": 0
                },
                "event_type": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56::event_test::WithdrawEvent",
                "event_data": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c566400000000000000",
                "tx_hash": "0x473eaadfd612ec792a96b1ec3b385107acac6745635b0532afbede8ca739649a",
                "sender": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56",
                "created_at": 0,
                "decoded_event_data": null
            },
            {
                "indexer_event_id": {
                    "tx_order": 0,
                    "event_index": 0
                },
                "event_id": {
                    "event_handle_id": "0xa70cdcf8493ee1964b02fdc8cd85c4d8c5f595891ea255282619db806659aa3f",
                    "event_seq": 0
                },
                "event_type": "0x3::coin::MintEvent",
                "event_data": "0x53303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333a3a6761735f636f696e3a3a476173436f696e000010632d5ec76b050000000000000000000000000000000000000000000000",
                "tx_hash": "0x425e591cac8ddd39f42961eab056deb391d71d22eee74f0969a07241548fef3b",
                "sender": "0x4b1b5d2a62f3c9a19a5314167439945bf98fbc871e1402e36d5bad3382064c56",
                "created_at": 0,
                "decoded_event_data": null
            }
        ],
        "next_cursor": {
            "tx_order": 0,
            "event_index": 0
        },
        "has_next_page": false
    },
    "id": 101
}

@baichuan3
Copy link
Collaborator Author

Wait for the automatic creation of SQLite Schema

@baichuan3 baichuan3 marked this pull request as ready for review November 15, 2023 01:05
@baichuan3
Copy link
Collaborator Author

Wait for the automatic creation of SQLite Schema

Automatic creation of SQLite Schema is Ready

@jolestar jolestar merged commit 0b4d902 into main Nov 15, 2023
5 checks passed
@jolestar jolestar deleted the indexer_query branch November 15, 2023 16:16
wubuku added a commit to wubuku/rooch that referenced this pull request Nov 23, 2023
* commit '3bedc7f06b087b5356ea081070f0148c391de12c': (271 commits)
  [bitcoin] Bitcoin relayer improvement (rooch-network#1171)
  [Bitcoin] PoC implementation of bitcoin relayer (rooch-network#1169)
  docs: update README.md (rooch-network#1168)
  add indexer test cases (rooch-network#1167)
  [Documents] Update MacOS rooch binary file install guide rooch-network#1165 (rooch-network#1166)
  Parse json to move struct (rooch-network#1158)
  Implements  indexer transaction RPC (rooch-network#1154)
  add `getCode` eth rpc server method (rooch-network#1155)
  [Documents]new object documents (rooch-network#1149)
  [rpc] The event RPC treat cursor None as -1 (rooch-network#1153)
  [moveos_std] Rename singleton_object to named_object (rooch-network#1146)
  Refactor event filter and Implements indexer event RPC (rooch-network#1136)
  Make tx order type from u128 to u64 (rooch-network#1148)
  docs: add timestamp and relayer introduction article (rooch-network#1122)
  fix: update the variable name of `timestamp_test.move` (rooch-network#1145)
  [Framework] Resolve CoinStore transfer issue (rooch-network#1144)
  [Framework] Refactor CoinInfo & CoinStore & Account CoinStore (rooch-network#1138)
  [Framework] Make ChainID and AddressMapping to singleton Object (rooch-network#1130)
  skip module init when upgrading module through MoveAction::ModuleBundle (rooch-network#1133)
  make from_bytes is decorated by data_struct. (rooch-network#1131)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Indexer] Refactor and simple event filter RPC and event filter type based on indexer
2 participants