Skip to content

Commit 3d33725

Browse files
authored
fix: ignore unanchored param for BNS names endpoint (#2263)
* fix: ignore unanchored * test: unanchored param
1 parent e69f9e4 commit 3d33725

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/datastore/pg-store.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,15 +3825,14 @@ export class PgStore extends BasePgStore {
38253825

38263826
async getNamesByAddressList({
38273827
address,
3828-
includeUnanchored,
38293828
chainId,
38303829
}: {
38313830
address: string;
38323831
includeUnanchored: boolean;
38333832
chainId: ChainID;
38343833
}): Promise<FoundOrNot<string[]>> {
38353834
const queryResult = await this.sqlTransaction(async sql => {
3836-
const maxBlockHeight = await this.getMaxBlockHeight(sql, { includeUnanchored });
3835+
const maxBlockHeight = await this.getMaxBlockHeight(sql, { includeUnanchored: false });
38373836
// 1. Get subdomains owned by this address. These don't produce NFT events so we have to look
38383837
// directly at the `subdomains` table.
38393838
const subdomainsQuery = await sql<{ name: string; fully_qualified_subdomain: string }[]>`
@@ -3886,7 +3885,7 @@ export class PgStore extends BasePgStore {
38863885
const nameCVs = importedNamesQuery.map(i => bnsNameCV(i.name));
38873886
const oldImportedNamesQuery = await sql<{ value: string }[]>`
38883887
SELECT value
3889-
FROM ${includeUnanchored ? sql`nft_custody_unanchored` : sql`nft_custody`}
3888+
FROM nft_custody
38903889
WHERE recipient <> ${address} AND value IN ${sql(nameCVs)}
38913890
`;
38923891
oldImportedNames = oldImportedNamesQuery.map(i => bnsHexValueToName(i.value));
@@ -3897,7 +3896,7 @@ export class PgStore extends BasePgStore {
38973896
// 3. Get newer NFT names owned by this address.
38983897
const nftNamesQuery = await sql<{ value: string }[]>`
38993898
SELECT value
3900-
FROM ${includeUnanchored ? sql`nft_custody_unanchored` : sql`nft_custody`}
3899+
FROM nft_custody
39013900
WHERE recipient = ${address} AND asset_identifier = ${getBnsSmartContractId(chainId)}
39023901
`;
39033902
namesToValidate.push(...nftNamesQuery.map(i => bnsHexValueToName(i.value)));

tests/bns/api.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,9 @@ describe('BNS API tests', () => {
513513
[dbName2]
514514
);
515515

516-
const query1 = await supertest(api.server).get(`/v1/addresses/${blockchain}/${address}`);
516+
const query1 = await supertest(api.server).get(
517+
`/v1/addresses/${blockchain}/${address}?unanchored=true`
518+
);
517519
expect(query1.status).toBe(200);
518520
expect(query1.body.names).toStrictEqual(['imported.btc', 'test-name.btc']);
519521
expect(query1.type).toBe('application/json');

0 commit comments

Comments
 (0)