Skip to content

Commit

Permalink
fix(query): bns schemas, exports
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Nov 13, 2024
1 parent 6b72065 commit 52fd74d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ export * from './types/remote-config';
export * from './types/utxo';
export * from './src/stacks/bns/bns-v2-client';
export * from './src/stacks/bns/bns.utils';
export * from './src/stacks/bns/bns.schemas';
export * from './src/stacks/bns/bns.query';
1 change: 0 additions & 1 deletion packages/query/src/query-prefixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export enum BitcoinQueryPrefixes {
}

export enum StacksQueryPrefixes {
GetBnsNamesByAddress = 'get-bns-names-by-address',
GetNftMetadata = 'get-nft-metadata',
GetNftHoldings = 'get-nft-holdings',
GetFtMetadata = 'get-ft-metadata',
Expand Down
4 changes: 2 additions & 2 deletions packages/query/src/stacks/bns/bns-v2-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useLeatherNetwork } from '../../leather-query-provider';
import {
BnsV2NamesByAddressResponse,
BnsV2ZoneFileDataResponse,
bnsV2NamesByAddressSchema,
bnsV2NamesByAddressResponseSchema,
bnsV2ZoneFileDataSchema,
} from './bns.schemas';

Expand All @@ -24,7 +24,7 @@ export function bnsV2Client(basePath = BNS_V2_API_BASE_URL) {
`${basePath}/names/address/${address}/valid`,
{ signal }
);
return bnsV2NamesByAddressSchema.parse(resp.data);
return bnsV2NamesByAddressResponseSchema.parse(resp.data);
},
async getZoneFileData(bnsName: string, signal?: AbortSignal) {
const resp = await axios.get<BnsV2ZoneFileDataResponse>(
Expand Down
14 changes: 9 additions & 5 deletions packages/query/src/stacks/bns/bns.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const bnsV2NameSchema = z.object({
revoked: z.boolean(),
});

export const bnsV2NamesByAddressSchema = z.object({
export const bnsV2NamesByAddressResponseSchema = z.object({
total: z.number(),
current_burn_block: z.number(),
limit: z.number(),
offset: z.number(),
names: z.array(bnsV2NameSchema),
});

export type BnsV2NamesByAddressResponse = z.infer<typeof bnsV2NamesByAddressSchema>;
export type BnsV2NamesByAddressResponse = z.infer<typeof bnsV2NamesByAddressResponseSchema>;

export const bnsV2ZoneFileDataSchema = z.object({
owner: z.string(),
Expand All @@ -32,6 +32,10 @@ export const bnsV2ZoneFileDataSchema = z.object({
subdomains: z.array(z.string()),
});

export interface BnsV2ZoneFileDataResponse {
zonefile: z.infer<typeof bnsV2ZoneFileDataSchema>;
}
export type BnsV2ZoneFileData = z.infer<typeof bnsV2ZoneFileDataSchema>;

export const bnsV2ZoneFileResponseSchema = z.object({
zonefile: bnsV2ZoneFileDataSchema,
});

export type BnsV2ZoneFileDataResponse = z.infer<typeof bnsV2ZoneFileResponseSchema>;

0 comments on commit 52fd74d

Please sign in to comment.