Skip to content

Commit

Permalink
feat: add metadata and parent columns to inscriptions table (#305)
Browse files Browse the repository at this point in the history
* chore: update client

* feat: add columns

* fix: tests
  • Loading branch information
rafaelcr committed Feb 12, 2024
1 parent 740c865 commit d71e93a
Show file tree
Hide file tree
Showing 14 changed files with 463 additions and 10 deletions.
15 changes: 15 additions & 0 deletions migrations/1707770109739_metadata-parent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate';

export const shorthands: ColumnDefinitions | undefined = undefined;

export function up(pgm: MigrationBuilder): void {
pgm.addColumns('inscriptions', {
metadata: {
type: 'text',
},
parent: {
type: 'text',
},
});
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@fastify/swagger": "^8.3.1",
"@fastify/type-provider-typebox": "^3.2.0",
"@hirosystems/api-toolkit": "^1.3.1",
"@hirosystems/chainhook-client": "^1.6.0",
"@hirosystems/chainhook-client": "^1.7.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^10.0.4",
"@semantic-release/git": "^10.0.1",
Expand Down
2 changes: 2 additions & 0 deletions src/pg/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ function updateFromOrdhookInscriptionRevealed(args: {
sat_rarity: satoshi.rarity,
sat_coinbase_height: satoshi.blockHeight,
recursive: recursive_refs.length > 0,
metadata: args.reveal.metadata ? JSON.stringify(args.reveal.metadata) : null,
parent: args.reveal.parent,
},
location: {
block_hash: args.block_hash,
Expand Down
2 changes: 0 additions & 2 deletions src/pg/pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import {
DbInscriptionIndexFilters,
DbInscriptionIndexOrder,
DbInscriptionIndexPaging,
InscriptionData,
DbInscriptionLocationChange,
DbLocation,
RevealLocationData,
DbLocationPointer,
DbLocationPointerInsert,
DbPaginatedResult,
Expand Down
2 changes: 2 additions & 0 deletions src/pg/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export type InscriptionData = {
sat_rarity: string;
sat_coinbase_height: number;
recursive: boolean;
metadata: string | null;
parent: string | null;
};

export type InscriptionInsert = InscriptionData;
Expand Down
35 changes: 35 additions & 0 deletions tests/api/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ describe('ETag cache', () => {
transfers_pre_inscription: 0,
tx_index: 0,
curse_type: null,
inscription_pointer: null,
delegate: null,
metaprotocol: null,
metadata: null,
parent: null,
})
.build();
await db.updateInscriptions(block);
Expand Down Expand Up @@ -180,6 +185,11 @@ describe('ETag cache', () => {
transfers_pre_inscription: 0,
tx_index: 0,
curse_type: null,
inscription_pointer: null,
delegate: null,
metaprotocol: null,
metadata: null,
parent: null,
})
.build();
await db.updateInscriptions(block1);
Expand Down Expand Up @@ -208,6 +218,11 @@ describe('ETag cache', () => {
transfers_pre_inscription: 0,
tx_index: 0,
curse_type: null,
inscription_pointer: null,
delegate: null,
metaprotocol: null,
metadata: null,
parent: null,
})
.build();
await db.updateInscriptions(block2);
Expand Down Expand Up @@ -283,6 +298,11 @@ describe('ETag cache', () => {
transfers_pre_inscription: 0,
tx_index: 0,
curse_type: null,
inscription_pointer: null,
delegate: null,
metaprotocol: null,
metadata: null,
parent: null,
})
.build();
await db.updateInscriptions(block1);
Expand Down Expand Up @@ -330,6 +350,11 @@ describe('ETag cache', () => {
transfers_pre_inscription: 0,
tx_index: 0,
curse_type: null,
inscription_pointer: null,
delegate: null,
metaprotocol: null,
metadata: null,
parent: null,
})
.build();
await db.updateInscriptions(block2);
Expand Down Expand Up @@ -369,6 +394,11 @@ describe('ETag cache', () => {
transfers_pre_inscription: 0,
tx_index: 0,
curse_type: null,
inscription_pointer: null,
delegate: null,
metaprotocol: null,
metadata: null,
parent: null,
})
.build();
await db.updateInscriptions(block1);
Expand Down Expand Up @@ -416,6 +446,11 @@ describe('ETag cache', () => {
transfers_pre_inscription: 0,
tx_index: 0,
curse_type: null,
inscription_pointer: null,
delegate: null,
metaprotocol: null,
metadata: null,
parent: null,
})
.build();
await db.updateInscriptions(block2);
Expand Down
Loading

0 comments on commit d71e93a

Please sign in to comment.