Skip to content

Commit 3a0ead1

Browse files
authored
fix: propagate chain id correctly to bns router (#1180)
1 parent 4538420 commit 3a0ead1

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@
9090
"env": {
9191
"STACKS_BLOCKCHAIN_API_PORT": "3998",
9292
"STACKS_API_MODE": "readonly",
93-
"STACKS_CHAIN_ID": "0x80000000",
94-
"NODE_ENV": "development",
93+
"STACKS_CHAIN_ID": "0x00000001",
94+
"NODE_ENV": "production",
9595
"TS_NODE_SKIP_IGNORE": "true"
9696
},
9797
"killBehavior": "polite",

src/api/routes/bns/names.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function createBnsNamesRouter(db: DataStore, chainId: ChainID): express.R
1717
const { name, zoneFileHash } = req.params;
1818
const includeUnanchored = isUnanchoredRequest(req, res, next);
1919
let nameFound = false;
20-
const nameQuery = await db.getName({ name: name, includeUnanchored });
20+
const nameQuery = await db.getName({ name: name, includeUnanchored, chainId: chainId });
2121
nameFound = nameQuery.found;
2222
if (!nameFound) {
2323
const subdomainQuery = await db.getSubdomain({ subdomain: name, includeUnanchored });
@@ -54,7 +54,7 @@ export function createBnsNamesRouter(db: DataStore, chainId: ChainID): express.R
5454
const { name } = req.params;
5555
const includeUnanchored = isUnanchoredRequest(req, res, next);
5656
let nameFound = false;
57-
const nameQuery = await db.getName({ name: name, includeUnanchored });
57+
const nameQuery = await db.getName({ name: name, includeUnanchored, chainId: chainId });
5858
nameFound = nameQuery.found;
5959
if (!nameFound) {
6060
const subdomainQuery = await db.getSubdomain({ subdomain: name, includeUnanchored });
@@ -123,7 +123,11 @@ export function createBnsNamesRouter(db: DataStore, chainId: ChainID): express.R
123123
zonefile_hash: result.zonefile_hash,
124124
};
125125
} else {
126-
const nameQuery = await db.getName({ name, includeUnanchored: includeUnanchored });
126+
const nameQuery = await db.getName({
127+
name,
128+
includeUnanchored: includeUnanchored,
129+
chainId: chainId,
130+
});
127131
if (!nameQuery.found) {
128132
res.status(404).json({ error: `cannot find name ${name}` });
129133
return;

src/datastore/common.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,11 @@ export interface DataStore extends DataStoreEventEmitter {
936936
namespace: string;
937937
includeUnanchored: boolean;
938938
}): Promise<FoundOrNot<DbBnsNamespace>>;
939-
getName(args: { name: string; includeUnanchored: boolean }): Promise<FoundOrNot<DbBnsName>>;
939+
getName(args: {
940+
name: string;
941+
includeUnanchored: boolean;
942+
chainId: ChainID;
943+
}): Promise<FoundOrNot<DbBnsName>>;
940944
getHistoricalZoneFile(args: {
941945
name: string;
942946
zoneFileHash: string;

0 commit comments

Comments
 (0)