Skip to content

Commit

Permalink
fix: only consider blessed inscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Aug 16, 2023
1 parent 7abc51d commit 2a4700c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/pg/brc20/brc20-pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export class Brc20PgStore {
inscription: DbInscriptionInsert;
location: DbLocationInsert;
}): Promise<void> {
if (args.inscription.number < 0) return; // No cursed inscriptions apply.
// Is this a BRC-20 operation? Is it being inscribed to a valid address?
const brc20 = brc20FromInscription(args.inscription);
if (brc20) {
Expand Down Expand Up @@ -215,9 +216,11 @@ export class Brc20PgStore {

async insertOperationTransfer(args: {
inscription_id: number;
inscription_number: number;
location_id: number;
location: DbLocationInsert;
}): Promise<void> {
if (args.inscription_number < 0) return; // No cursed inscriptions apply.
// Is this a BRC-20 balance transfer? Check if we have a valid transfer inscription emitted by
// this address that hasn't been sent to another address before. Use `LIMIT 3` as a quick way
// of checking if we have just inserted the first transfer for this inscription (genesis +
Expand Down
5 changes: 3 additions & 2 deletions src/pg/pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ export class PgStore extends BasePgStore {
private async insertLocation(args: { location: DbLocationInsert }): Promise<void> {
await this.sqlWriteTransaction(async sql => {
// Does the inscription exist? Warn if it doesn't.
const genesis = await sql<{ id: number }[]>`
SELECT id FROM inscriptions WHERE genesis_id = ${args.location.genesis_id}
const genesis = await sql<{ id: number; number: number }[]>`
SELECT id, number FROM inscriptions WHERE genesis_id = ${args.location.genesis_id}
`;
if (genesis.count === 0) {
logger.warn(
Expand Down Expand Up @@ -729,6 +729,7 @@ export class PgStore extends BasePgStore {
});
await this.brc20.insertOperationTransfer({
inscription_id,
inscription_number: genesis[0].number,
location_id: locationRes[0].id,
location: args.location,
});
Expand Down

0 comments on commit 2a4700c

Please sign in to comment.