Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow nullable and tagged curse types #111

Merged
merged 3 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -139,6 +139,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 @@ -148,7 +153,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 @@ -585,7 +590,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
Loading