-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(indexer): new JRPC method to list substates (#1049)
Description --- * Added new columns `template_address`, `module_name` and `timestamp` to the `substates` SQLite table. * Added new column `timestamp` to the `events` SQLite table. For now it's populated but not used by any method yet. * The `event_scanner` fetches and stores in database the values for all the new fields in substates and events * New JPRC method `list_substates` * Updated TypeScript bindings related with the new indexer method * Removed old logic for event storing in the `event_manager`, it's all now done only on the `event_scanner` and controlled by the event filter in the indexer config Motivation and Context --- On #1043 we refactored the Indexer to automatically store all substates related to events. This PR follows on that work and adds a new JRPC method `list_substates` that allows to fetch and filter all the substates stored in the Indexer database. It also adds some metadata (`template_address`, `module_name`, `timestamp`) to substates. The new method JRPC method `list_substates` has the following _optional_ parameters: * **filter_by_template**: String with the template address of the components that we want to filter * **filter_by_type**: String with the only type of substate that we want. Possible vaules are `"Component"`, `"Resource"`, `"Vault"`, `"UnclaimedConfidentialOutput"`, `"NonFungible",` `"TransactionReceipt"` and `"FeeClaim"` * **limit**: u64 value for the maximum number of results that we want (intended for pagination) * **offset**: u64 with the position of the first result that we want (intended for pagination) How Has This Been Tested? --- Manually by: * Spawning a local network using `tari_swarm` * Performing some transactions to generate events and substates * Inspecting the Indexer database and also querying the new `list_substate` method What process can a PR reviewer use to test or verify this change? --- See previous section Breaking Changes --- - [x] None - [ ] Requires data directory to be deleted - [ ] Other - Please specify
- Loading branch information
Showing
19 changed files
with
353 additions
and
86 deletions.
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
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
1 change: 1 addition & 0 deletions
1
...storage_sqlite/migrations/2024-06-18-095000_add_metadata_to_events_and_substates/down.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-- This file should undo anything in `up.sql` |
19 changes: 19 additions & 0 deletions
19
...e_storage_sqlite/migrations/2024-06-18-095000_add_metadata_to_events_and_substates/up.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- The transaction hash column will be similar to the one in the "events" table | ||
alter table substates | ||
drop column transaction_hash; | ||
alter table substates | ||
add column tx_hash text not NULL; | ||
|
||
-- Tempalte address for component substates | ||
alter table substates | ||
add column template_address text NULL; | ||
|
||
-- Name of the template module for components | ||
alter table substates | ||
add column module_name text NULL; | ||
|
||
-- block timestamp for events and substates | ||
alter table events | ||
add column timestamp bigint not NULL; | ||
alter table substates | ||
add column timestamp bigint not NULL; |
Oops, something went wrong.