Skip to content

Commit

Permalink
feat: ingest missing ordhook fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Jul 29, 2024
1 parent 939286e commit 96ac172
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 1 deletion.
1 change: 0 additions & 1 deletion docker/docker-compose.dev.postgres.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.7'
services:
postgres:
image: "postgres:15"
Expand Down
13 changes: 13 additions & 0 deletions migrations/1676395230930_inscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,25 @@ export function up(pgm: MigrationBuilder): void {
type: 'boolean',
default: false,
},
input_index: {
type: 'bigint',
notNull: true,
},
pointer: {
type: 'bigint',
},
metadata: {
type: 'text',
},
metaprotocol: {
type: 'text',
},
parent: {
type: 'text',
},
delegate: {
type: 'text',
},
timestamp: {
type: 'timestamptz',
notNull: true,
Expand Down
10 changes: 10 additions & 0 deletions src/api/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,17 @@ export const InscriptionResponse = Type.Object(
examples: ['1463d48e9248159084929294f64bda04487503d30ce7ab58365df1dc6fd58218i0'],
})
),
delegate: Nullable(
Type.String({
examples: ['1463d48e9248159084929294f64bda04487503d30ce7ab58365df1dc6fd58218i0'],
})
),
metadata: Nullable(Type.Any()),
meta_protocol: Nullable(
Type.String({
examples: ['brc20'],
})
),
},
{ title: 'Inscription Response' }
);
Expand Down
2 changes: 2 additions & 0 deletions src/api/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export function parseDbInscriptions(
recursion_refs: i.recursion_refs?.split(',') ?? null,
parent: i.parent,
metadata: i.metadata ? JSON.parse(i.metadata) : null,
delegate: i.delegate ?? null,
meta_protocol: i.metaprotocol ?? null,
}));
}
export function parseDbInscription(item: DbFullyLocatedInscriptionResult): InscriptionResponseType {
Expand Down
4 changes: 4 additions & 0 deletions src/pg/block-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export class BlockCache {
recursive: recursive_refs.length > 0,
metadata: reveal.metadata ? JSON.stringify(reveal.metadata) : null,
parent: reveal.parent,
delegate: reveal.delegate,
input_index: reveal.inscription_input_index,
pointer: reveal.inscription_pointer,
metaprotocol: reveal.metaprotocol,
timestamp: this.timestamp,
});
this.revealedNumbers.push(reveal.inscription_number.jubilee);
Expand Down
8 changes: 8 additions & 0 deletions src/pg/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export type DbInscriptionInsert = {
recursive: boolean;
metadata: string | null;
parent: string | null;
input_index: number;
pointer: number | null;
metaprotocol: string | null;
delegate: string | null;
timestamp: number;
};

Expand Down Expand Up @@ -102,6 +106,10 @@ export type DbFullyLocatedInscriptionResult = {
recursion_refs: string | null;
parent: string | null;
metadata: string | null;
input_index: number;
pointer: number | null;
metaprotocol: string | null;
delegate: string | null;
};

export enum DbLocationTransferType {
Expand Down
26 changes: 26 additions & 0 deletions tests/api/inscriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
};

// By inscription id
Expand Down Expand Up @@ -284,6 +286,8 @@ describe('/inscriptions', () => {
],
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
};

// By inscription id
Expand Down Expand Up @@ -489,6 +493,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
};

// By inscription id
Expand Down Expand Up @@ -573,6 +579,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
};

// By inscription id
Expand Down Expand Up @@ -686,6 +694,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
});

// Transfer 2
Expand Down Expand Up @@ -743,6 +753,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
});
});

Expand Down Expand Up @@ -855,6 +867,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
});
});

Expand Down Expand Up @@ -952,6 +966,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
});

// Transfer 2
Expand Down Expand Up @@ -1009,6 +1025,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
});
});
});
Expand Down Expand Up @@ -1656,6 +1674,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
},
{
address: 'bc1pscktlmn99gyzlvymvrezh6vwd0l4kg06tg5rvssw0czg8873gz5sdkteqj',
Expand Down Expand Up @@ -1684,6 +1704,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
},
]);
});
Expand Down Expand Up @@ -1799,6 +1821,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
};
expect(responseJson1.results[0]).toStrictEqual(result1);

Expand Down Expand Up @@ -1836,6 +1860,8 @@ describe('/inscriptions', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
};
expect(responseJson2.results[0]).toStrictEqual(result2);

Expand Down
4 changes: 4 additions & 0 deletions tests/api/sats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ describe('/sats', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
},
{
address: 'bc1p3cyx5e2hgh53w7kpxcvm8s4kkega9gv5wfw7c4qxsvxl0u8x834qf0u2td',
Expand Down Expand Up @@ -215,6 +217,8 @@ describe('/sats', () => {
recursion_refs: null,
parent: null,
metadata: null,
meta_protocol: null,
delegate: null,
},
]);

Expand Down

0 comments on commit 96ac172

Please sign in to comment.