diff --git a/src/pg/brc20/brc20-pg-store.ts b/src/pg/brc20/brc20-pg-store.ts index c2ba0969..96690704 100644 --- a/src/pg/brc20/brc20-pg-store.ts +++ b/src/pg/brc20/brc20-pg-store.ts @@ -46,7 +46,12 @@ export class Brc20PgStore extends BasePgStoreModule { const pointer = args.pointers[i]; if (parseInt(pointer.block_height) < BRC20_GENESIS_BLOCK) continue; if (reveal.inscription) { - if (reveal.location.transfer_type != DbLocationTransferType.transferred) continue; + if ( + reveal.inscription.classic_number < 0 || + reveal.inscription.number < 0 || + reveal.location.transfer_type != DbLocationTransferType.transferred + ) + continue; const brc20 = brc20FromInscriptionContent( hexToBuffer(reveal.inscription.content as string).toString('utf-8') ); diff --git a/tests/brc20.test.ts b/tests/brc20.test.ts index c07c59a8..2b3302fe 100644 --- a/tests/brc20.test.ts +++ b/tests/brc20.test.ts @@ -698,6 +698,43 @@ describe('BRC-20', () => { }, ]); }); + + test('ignores deploy from classic cursed inscription', async () => { + await db.updateInscriptions( + new TestChainhookPayloadBuilder() + .apply() + .block({ + height: BRC20_GENESIS_BLOCK, + hash: '00000000000000000002a90330a99f67e3f01eb2ce070b45930581e82fb7a91d', + }) + .transaction({ + hash: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc', + }) + .inscriptionRevealed( + brc20Reveal({ + json: { + p: 'brc-20', + op: 'deploy', + tick: 'PEPE', + max: '21000000', + }, + number: 0, + classic_number: -1, + tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc', + address: 'bc1p3cyx5e2hgh53w7kpxcvm8s4kkega9gv5wfw7c4qxsvxl0u8x834qf0u2td', + }) + ) + .build() + ); + const response1 = await fastify.inject({ + method: 'GET', + url: `/ordinals/brc-20/tokens?ticker=PEPE`, + }); + expect(response1.statusCode).toBe(200); + const responseJson1 = response1.json(); + expect(responseJson1.total).toBe(0); + expect(responseJson1.results).toHaveLength(0); + }); }); describe('mint', () => { diff --git a/tests/helpers.ts b/tests/helpers.ts index 09cb1801..569b6ed6 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -111,6 +111,7 @@ export function rollBack(payload: Payload) { export function brc20Reveal(args: { json: Brc20; number: number; + classic_number?: number; address: string; tx_id: string; }): BitcoinInscriptionRevealed { @@ -120,8 +121,8 @@ export function brc20Reveal(args: { content_type: 'text/plain;charset=utf-8', content_length: content.length, inscription_number: { - classic: args.number, jubilee: args.number, + classic: args.classic_number ?? args.number, }, inscription_fee: 2000, inscription_id: `${args.tx_id}i0`,