-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd8b33a
commit 7e69b32
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { TRPCError } from "@trpc/server"; | ||
|
||
import { z } from "@blobscan/zod"; | ||
|
||
import { | ||
createExpandsSchema, | ||
withExpands, | ||
} from "../../middlewares/withExpands"; | ||
import { publicProcedure } from "../../procedures"; | ||
import { retrieveBlobData } from "../../utils"; | ||
import { get_AWS_S3 } from "../../utils/aws_s3_blob"; | ||
import { createBlobSelect } from "./common/selects"; | ||
import { serializeBlob, serializeBlobSchema } from "./common/serializers"; | ||
|
||
const inputSchema = z | ||
.object({ | ||
versionedHash: z.string(), | ||
}) | ||
.merge(createExpandsSchema(["transaction", "block"])); | ||
|
||
// 定义Zod验证器 | ||
const outputSchema = z.object({ | ||
data: z.any(), | ||
}); | ||
|
||
export const getByVersionedHash = publicProcedure | ||
.meta({ | ||
openapi: { | ||
method: "GET", | ||
path: "/blobs/versionedHash/{versionedHash}", | ||
tags: ["blobs"], | ||
summary: | ||
"retrieves blob details for given versioned hash or kzg commitment.", | ||
}, | ||
}) | ||
.input(inputSchema) | ||
.use(withExpands) | ||
.output(outputSchema) | ||
.query(async ({ input }: any) => { | ||
const { versionedHash } = input; | ||
const blobData = await get_AWS_S3({ versionedHash }); | ||
// console.log("🚀 ~ .query ~ blobData:", blobData); | ||
return { | ||
data: blobData, | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { t } from "../../trpc-client"; | ||
import { getAll } from "./getAll"; | ||
import { getByBlobId } from "./getByBlobId"; | ||
import { getByVersionedHash } from "./getByVersionedHash"; | ||
|
||
export const blobRouter = t.router({ | ||
getAll, | ||
getByBlobId, | ||
getByVersionedHash, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters