Skip to content

Commit

Permalink
fix: allow nullable and tagged curse types (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Jun 28, 2023
1 parent 9e795b8 commit 641a627
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/chainhook/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CursedInscriptionRevealedSchema = Type.Object({
ordinal_block_height: Type.Integer(),
ordinal_offset: Type.Integer(),
satpoint_post_inscription: Type.String(),
curse_type: Type.String(),
curse_type: Nullable(Type.Union([Type.String(), Type.Object({ tag: Type.Number() })])),
});
export type CursedInscriptionRevealed = Static<typeof CursedInscriptionRevealedSchema>;

Expand Down
9 changes: 7 additions & 2 deletions src/pg/pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ export class PgStore extends BasePgStore {
const reveal = operation.cursed_inscription_revealed;
const satoshi = new OrdinalSatoshi(reveal.ordinal_number);
const satpoint = parseSatPoint(reveal.satpoint_post_inscription);
const curse_type = reveal.curse_type
? typeof reveal.curse_type === 'string'
? reveal.curse_type
: JSON.stringify(reveal.curse_type)
: null;
const id = await this.insertInscriptionGenesis({
inscription: {
genesis_id: reveal.inscription_id,
Expand All @@ -144,7 +149,7 @@ export class PgStore extends BasePgStore {
number: reveal.inscription_number,
content: reveal.content_bytes,
fee: reveal.inscription_fee.toString(),
curse_type: reveal.curse_type,
curse_type,
},
location: {
block_hash,
Expand Down Expand Up @@ -580,7 +585,7 @@ export class PgStore extends BasePgStore {
SELECT id FROM locations WHERE sat_ordinal = ${args.location.sat_ordinal}
`;
if (dup.count > 0) {
logger.error(
logger.warn(
{
block_height: args.location.block_height,
genesis_id: args.inscription.genesis_id,
Expand Down
6 changes: 3 additions & 3 deletions tests/inscriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ describe('/inscriptions', () => {
ordinal_offset: 0,
satpoint_post_inscription:
'38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc:0:0',
curse_type: 'p2wsh',
curse_type: { tag: 66 },
})
.build()
);
Expand Down Expand Up @@ -473,7 +473,7 @@ describe('/inscriptions', () => {
timestamp: 1678122360000,
genesis_timestamp: 1676913207000,
genesis_tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc',
curse_type: 'p2wsh',
curse_type: '{"tag":66}',
});

// Transfer 2
Expand Down Expand Up @@ -524,7 +524,7 @@ describe('/inscriptions', () => {
timestamp: 1678124000000,
genesis_timestamp: 1676913207000,
genesis_tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc',
curse_type: 'p2wsh',
curse_type: '{"tag":66}',
});
});
});
Expand Down

0 comments on commit 641a627

Please sign in to comment.