diff --git a/backend-rust/README.md b/backend-rust/README.md index e4f351558..abb1bd24d 100644 --- a/backend-rust/README.md +++ b/backend-rust/README.md @@ -55,9 +55,9 @@ cargo run --bin ccdscan-api ### GraphiQL IDE Starting the GraphQL API Service above will provide you an interface -(usually at 127.0.0.1:8000) to execute graphQL querries. +(usually at 127.0.0.1:8000) to execute graphQL queries. -An examples is shown below: +An example is shown below: Query: diff --git a/backend-rust/migrations/0001_initialize.up.sql b/backend-rust/migrations/0001_initialize.up.sql index 23b43e4c4..b12d9fe18 100644 --- a/backend-rust/migrations/0001_initialize.up.sql +++ b/backend-rust/migrations/0001_initialize.up.sql @@ -158,6 +158,7 @@ CREATE TABLE transactions( BOOLEAN NOT NULL, -- Transaction details. Events if success is true. + -- TODO: It would be nice to have every event in a separate row in a table to easily query a specific event from a specific transaction. events JSONB, -- Transaction details. Reject reason if success is false. @@ -249,6 +250,7 @@ CREATE TABLE bakers( -- Every WASM module on chain. CREATE TABLE smart_contract_modules( + -- Index/id of the module (row number). index BIGINT PRIMARY KEY, @@ -305,6 +307,100 @@ CREATE TABLE contracts( PRIMARY KEY (index, sub_index) ); +-- Every event that links or unlinks a contract to a module. +CREATE TABLE module_contract_link_events( + -- An index/id for this event (row number). + index + BIGINT + SERIAL + PRIMARY KEY + NOT NULL, + -- Event index of the event. + event_index + BIGINT + NOT NULL, + -- Transaction index including the event. + transaction_index + BIGINT + NOT NULL, + -- Module index that gets linked/unlinked. + module_index + BIGINT + NOT NULL, + -- Contract index that gets linked/unlinked. + contract_index + BIGINT + NOT NULL, + -- Contract subindex that gets linked/unlinked. + contract_sub_index + BIGINT + NOT NULL, + -- True if contract gets linked to the given module, false if contract gets unlinked to the given module. + is_linked + BOOLEAN + NOT NULL, + + -- TODO: link_action = int? source = int? +) + +-- Every successful event associated to a contract. +-- TODO: add index over the contract (index,subindex) +CREATE TABLE contract_events( + -- An index/id for this event (row number). + index + BIGINT + SERIAL + PRIMARY KEY + NOT NULL, + -- Transaction index including the event. + transaction_index + BIGINT + NOT NULL, + -- Event index of the event. + event_index + BIGINT + NOT NULL, + -- Contract index that event is associated with. + contract_index + BIGINT + NOT NULL, + -- Contract subindex that event is associated with. + contract_sub_index + BIGINT + NOT NULL, + + -- TODO: source = int? +) + +-- Every rejected event associated to a contract. +-- TODO: add index over the contract (index,subindex) +CREATE TABLE contract_reject_events( + -- An index/id for this event (row number). + index + BIGINT + SERIAL + PRIMARY KEY + NOT NULL, + -- Transaction index including the event. + transaction_index + BIGINT + NOT NULL, + -- Event index of the event. + event_index + BIGINT + NOT NULL, + -- Contract index that event is associated with. + contract_index + BIGINT + NOT NULL, + -- Contract subindex that event is associated with. + contract_sub_index + BIGINT + NOT NULL, + + -- TODO: source = int? +) + CREATE OR REPLACE FUNCTION block_added_notify_trigger_function() RETURNS trigger AS $trigger$ DECLARE rec blocks;