@@ -158,6 +158,7 @@ CREATE TABLE transactions(
158
158
BOOLEAN
159
159
NOT NULL ,
160
160
-- Transaction details. Events if success is true.
161
+ -- 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.
161
162
events
162
163
JSONB,
163
164
-- Transaction details. Reject reason if success is false.
@@ -249,6 +250,7 @@ CREATE TABLE bakers(
249
250
250
251
-- Every WASM module on chain.
251
252
CREATE TABLE smart_contract_modules (
253
+ -- Index/id of the module (row number).
252
254
index
253
255
BIGINT
254
256
PRIMARY KEY ,
@@ -305,6 +307,100 @@ CREATE TABLE contracts(
305
307
PRIMARY KEY (index, sub_index)
306
308
);
307
309
310
+ -- Every event that links or unlinks a contract to a module.
311
+ CREATE TABLE module_contract_link_events (
312
+ -- An index/id for this event (row number).
313
+ index
314
+ BIGINT
315
+ SERIAL
316
+ PRIMARY KEY
317
+ NOT NULL ,
318
+ -- Event index of the event.
319
+ event_index
320
+ BIGINT
321
+ NOT NULL ,
322
+ -- Transaction index including the event.
323
+ transaction_index
324
+ BIGINT
325
+ NOT NULL ,
326
+ -- Module index that gets linked/unlinked.
327
+ module_index
328
+ BIGINT
329
+ NOT NULL ,
330
+ -- Contract index that gets linked/unlinked.
331
+ contract_index
332
+ BIGINT
333
+ NOT NULL ,
334
+ -- Contract subindex that gets linked/unlinked.
335
+ contract_sub_index
336
+ BIGINT
337
+ NOT NULL ,
338
+ -- True if contract gets linked to the given module, false if contract gets unlinked to the given module.
339
+ is_linked
340
+ BOOLEAN
341
+ NOT NULL ,
342
+
343
+ -- TODO: link_action = int? source = int?
344
+ )
345
+
346
+ -- Every successful event associated to a contract.
347
+ -- TODO: add index over the contract (index,subindex)
348
+ CREATE TABLE contract_events (
349
+ -- An index/id for this event (row number).
350
+ index
351
+ BIGINT
352
+ SERIAL
353
+ PRIMARY KEY
354
+ NOT NULL ,
355
+ -- Transaction index including the event.
356
+ transaction_index
357
+ BIGINT
358
+ NOT NULL ,
359
+ -- Event index of the event.
360
+ event_index
361
+ BIGINT
362
+ NOT NULL ,
363
+ -- Contract index that event is associated with.
364
+ contract_index
365
+ BIGINT
366
+ NOT NULL ,
367
+ -- Contract subindex that event is associated with.
368
+ contract_sub_index
369
+ BIGINT
370
+ NOT NULL ,
371
+
372
+ -- TODO: source = int?
373
+ )
374
+
375
+ -- Every rejected event associated to a contract.
376
+ -- TODO: add index over the contract (index,subindex)
377
+ CREATE TABLE contract_reject_events (
378
+ -- An index/id for this event (row number).
379
+ index
380
+ BIGINT
381
+ SERIAL
382
+ PRIMARY KEY
383
+ NOT NULL ,
384
+ -- Transaction index including the event.
385
+ transaction_index
386
+ BIGINT
387
+ NOT NULL ,
388
+ -- Event index of the event.
389
+ event_index
390
+ BIGINT
391
+ NOT NULL ,
392
+ -- Contract index that event is associated with.
393
+ contract_index
394
+ BIGINT
395
+ NOT NULL ,
396
+ -- Contract subindex that event is associated with.
397
+ contract_sub_index
398
+ BIGINT
399
+ NOT NULL ,
400
+
401
+ -- TODO: source = int?
402
+ )
403
+
308
404
CREATE OR REPLACE FUNCTION block_added_notify_trigger_function () RETURNS trigger AS $trigger$
309
405
DECLARE
310
406
rec blocks;
0 commit comments