Skip to content

Commit

Permalink
fix: expect any and stringify for curse_type (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Jul 3, 2023
1 parent 75e75c1 commit 0459115
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 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: Nullable(Type.Union([Type.String(), Type.Object({ tag: Type.Number() })])),
curse_type: Nullable(Type.Any()),
});
export type CursedInscriptionRevealed = Static<typeof CursedInscriptionRevealedSchema>;

Expand Down
7 changes: 1 addition & 6 deletions src/pg/pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ 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 +143,7 @@ export class PgStore extends BasePgStore {
number: reveal.inscription_number,
content: reveal.content_bytes,
fee: reveal.inscription_fee.toString(),
curse_type,
curse_type: JSON.stringify(reveal.curse_type),
},
location: {
block_hash,
Expand Down
4 changes: 2 additions & 2 deletions tests/inscriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ describe('/inscriptions', () => {
ordinal_offset: 0,
satpoint_post_inscription:
'38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc:0:0',
curse_type: 'p2wsh',
curse_type: 88,
})
.build()
);
Expand All @@ -241,7 +241,7 @@ describe('/inscriptions', () => {
timestamp: 1676913207000,
genesis_timestamp: 1676913207000,
genesis_tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc',
curse_type: 'p2wsh',
curse_type: '88',
};

// By inscription id
Expand Down
4 changes: 2 additions & 2 deletions tests/sats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe('/sats', () => {
timestamp: 1677803510000,
tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc',
value: '10000',
curse_type: 'p2wsh',
curse_type: '"p2wsh"',
},
{
address: 'bc1p3cyx5e2hgh53w7kpxcvm8s4kkega9gv5wfw7c4qxsvxl0u8x834qf0u2td',
Expand All @@ -178,7 +178,7 @@ describe('/sats', () => {
timestamp: 1676913207000,
tx_id: 'b9cd9489fe30b81d007f753663d12766f1368721a87f4c69056c8215caa57993',
value: '10000',
curse_type: 'p2wsh',
curse_type: '"p2wsh"',
},
]);
});
Expand Down

0 comments on commit 0459115

Please sign in to comment.