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 53075a9
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';

Check warning on line 94 in packages/query/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/query/index.ts#L94

Added line #L94 was not covered by tests
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);

Check warning on line 27 in packages/query/src/stacks/bns/bns-v2-client.ts

View check run for this annotation

Codecov / codecov/patch

packages/query/src/stacks/bns/bns-v2-client.ts#L27

Added line #L27 was not covered by tests
},
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({

Check warning on line 14 in packages/query/src/stacks/bns/bns.schemas.ts

View check run for this annotation

Codecov / codecov/patch

packages/query/src/stacks/bns/bns.schemas.ts#L14

Added line #L14 was not covered by tests
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,
});

Check warning on line 39 in packages/query/src/stacks/bns/bns.schemas.ts

View check run for this annotation

Codecov / codecov/patch

packages/query/src/stacks/bns/bns.schemas.ts#L37-L39

Added lines #L37 - L39 were not covered by tests

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

0 comments on commit 53075a9

Please sign in to comment.