fix: propagate chain id correctly to bns router (#1180)

This commit is contained in:
Rafael Cárdenas
2022-05-20 10:15:00 -05:00
committed by GitHub
parent 4538420e6e
commit 3a0ead18fd
3 changed files with 14 additions and 6 deletions

4
.vscode/launch.json vendored
View File

@@ -90,8 +90,8 @@
"env": {
"STACKS_BLOCKCHAIN_API_PORT": "3998",
"STACKS_API_MODE": "readonly",
"STACKS_CHAIN_ID": "0x80000000",
"NODE_ENV": "development",
"STACKS_CHAIN_ID": "0x00000001",
"NODE_ENV": "production",
"TS_NODE_SKIP_IGNORE": "true"
},
"killBehavior": "polite",

View File

@@ -17,7 +17,7 @@ export function createBnsNamesRouter(db: DataStore, chainId: ChainID): express.R
const { name, zoneFileHash } = req.params;
const includeUnanchored = isUnanchoredRequest(req, res, next);
let nameFound = false;
const nameQuery = await db.getName({ name: name, includeUnanchored });
const nameQuery = await db.getName({ name: name, includeUnanchored, chainId: chainId });
nameFound = nameQuery.found;
if (!nameFound) {
const subdomainQuery = await db.getSubdomain({ subdomain: name, includeUnanchored });
@@ -54,7 +54,7 @@ export function createBnsNamesRouter(db: DataStore, chainId: ChainID): express.R
const { name } = req.params;
const includeUnanchored = isUnanchoredRequest(req, res, next);
let nameFound = false;
const nameQuery = await db.getName({ name: name, includeUnanchored });
const nameQuery = await db.getName({ name: name, includeUnanchored, chainId: chainId });
nameFound = nameQuery.found;
if (!nameFound) {
const subdomainQuery = await db.getSubdomain({ subdomain: name, includeUnanchored });
@@ -123,7 +123,11 @@ export function createBnsNamesRouter(db: DataStore, chainId: ChainID): express.R
zonefile_hash: result.zonefile_hash,
};
} else {
const nameQuery = await db.getName({ name, includeUnanchored: includeUnanchored });
const nameQuery = await db.getName({
name,
includeUnanchored: includeUnanchored,
chainId: chainId,
});
if (!nameQuery.found) {
res.status(404).json({ error: `cannot find name ${name}` });
return;

View File

@@ -936,7 +936,11 @@ export interface DataStore extends DataStoreEventEmitter {
namespace: string;
includeUnanchored: boolean;
}): Promise<FoundOrNot<DbBnsNamespace>>;
getName(args: { name: string; includeUnanchored: boolean }): Promise<FoundOrNot<DbBnsName>>;
getName(args: {
name: string;
includeUnanchored: boolean;
chainId: ChainID;
}): Promise<FoundOrNot<DbBnsName>>;
getHistoricalZoneFile(args: {
name: string;
zoneFileHash: string;