Skip to content

Commit

Permalink
fix: return nullable for fetch inscription by name
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed Sep 11, 2023
1 parent 97a1b54 commit a26dcf9
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 56 deletions.
15 changes: 7 additions & 8 deletions api/src/routes/trpc/bridge-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ export const bridgeRouter = router({
getInscriptionByName: procedure
.input(z.object({ name: z.string() }))
.output(
z.object({
inscriptionId: z.string(),
owner: z.string(),
})
z.nullable(
z.object({
inscriptionId: z.string(),
owner: z.string(),
})
)
)
.query(async ({ ctx, input }) => {
expectDb(ctx.prisma);
Expand All @@ -85,10 +87,7 @@ export const bridgeRouter = router({
});

if (inscribedName === null) {
throw new TRPCError({
message: `Unable to fetch inscription for ${input.name}`,
code: 'NOT_FOUND',
});
return null;
}

const inscriptionId = inscriptionBuffToId(hexToBytes(inscribedName.inscription_id));
Expand Down
7 changes: 0 additions & 7 deletions api/src/routes/trpc/search-router.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { router, procedure } from './base';
import { expectDb } from '@db/db-utils';
import { z } from 'zod';
import { convertDbName } from '~/contracts/utils';
import { parseFqn } from '@bns-x/core';
import { nameObjectToHex } from '~/utils';
import { TRPCError } from '@trpc/server';
import { fetchInscriptionOwner, inscriptionBuffToId } from '@fetchers/inscriptions';
import { hexToBytes, bytesToHex } from 'micro-stacks/common';

export const nameSearchResultSchema = z.object({
name: z.string(),
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"typecheck": "turbo run typecheck --continue",
"api:prod": "pnpm --filter @bns-x/api prod",
"build:packages": "turbo run build --filter=@bns-x/client --filter=@bns-x/api-types --filter=@bns-x/bridge",
"build:trpc": "pnpm --filter @bns-x/api build:trpc && pnpm build:packages",
"publish-local": "pnpm build:packages && pnpm publish -r",
"test": "turbo run test"
},
Expand All @@ -41,7 +42,7 @@
"prettier": "^2.8.7",
"start-server-and-test": "^1.15.2",
"tsup": "^6.5.0",
"turbo": "^1.7.0",
"turbo": "^1.10.13",
"typescript": "4.9.5"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-types/src/export-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export type AppProcedures = {
{
inscriptionId: string;
owner: string;
}
} | null
>;
getNameByInscription: AnyProc<
'query',
Expand Down
84 changes: 59 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 7 additions & 14 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
{
"baseBranch": "origin/main",
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**",
".next/**"
]
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**"],
"outputMode": "new-only"
},
"test": {
"dependsOn": [
"^build"
],
"dependsOn": ["^build"],
"outputs": []
},
"lint": {
"outputs": [],
"parallel": true
"outputs": []
},
"dev": {
"cache": false
Expand All @@ -28,4 +21,4 @@
"outputs": []
}
}
}
}

0 comments on commit a26dcf9

Please sign in to comment.