Skip to content

Commit

Permalink
fix: ignore classic cursed
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Jan 4, 2024
1 parent ec5ed8e commit 2e24a6a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/pg/brc20/brc20-pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
);
Expand Down
37 changes: 37 additions & 0 deletions tests/brc20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
3 changes: 2 additions & 1 deletion tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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`,
Expand Down

0 comments on commit 2e24a6a

Please sign in to comment.