From 7e7703d26cf2742458c043b2c2a04d0869ac2cfe Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Mon, 3 Jul 2023 14:33:30 -0600 Subject: [PATCH] fix: expect any and stringify for curse_type --- src/chainhook/schemas.ts | 2 +- src/pg/pg-store.ts | 7 +------ tests/inscriptions.test.ts | 4 ++-- tests/sats.test.ts | 4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/chainhook/schemas.ts b/src/chainhook/schemas.ts index 5856e701..44d597b6 100644 --- a/src/chainhook/schemas.ts +++ b/src/chainhook/schemas.ts @@ -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; diff --git a/src/pg/pg-store.ts b/src/pg/pg-store.ts index d04f9d89..ce906b90 100644 --- a/src/pg/pg-store.ts +++ b/src/pg/pg-store.ts @@ -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, @@ -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, diff --git a/tests/inscriptions.test.ts b/tests/inscriptions.test.ts index 748ec174..3009fe7c 100644 --- a/tests/inscriptions.test.ts +++ b/tests/inscriptions.test.ts @@ -215,7 +215,7 @@ describe('/inscriptions', () => { ordinal_offset: 0, satpoint_post_inscription: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc:0:0', - curse_type: 'p2wsh', + curse_type: 88, }) .build() ); @@ -241,7 +241,7 @@ describe('/inscriptions', () => { timestamp: 1676913207000, genesis_timestamp: 1676913207000, genesis_tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc', - curse_type: 'p2wsh', + curse_type: '88', }; // By inscription id diff --git a/tests/sats.test.ts b/tests/sats.test.ts index fa2acb93..27617a37 100644 --- a/tests/sats.test.ts +++ b/tests/sats.test.ts @@ -154,7 +154,7 @@ describe('/sats', () => { timestamp: 1677803510000, tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc', value: '10000', - curse_type: 'p2wsh', + curse_type: '"p2wsh"', }, { address: 'bc1p3cyx5e2hgh53w7kpxcvm8s4kkega9gv5wfw7c4qxsvxl0u8x834qf0u2td', @@ -178,7 +178,7 @@ describe('/sats', () => { timestamp: 1676913207000, tx_id: 'b9cd9489fe30b81d007f753663d12766f1368721a87f4c69056c8215caa57993', value: '10000', - curse_type: 'p2wsh', + curse_type: '"p2wsh"', }, ]); });