From 58eee9795f743a71168aa6c39a041c21913572b9 Mon Sep 17 00:00:00 2001 From: iuwqyir Date: Thu, 10 Apr 2025 22:22:07 +0300 Subject: [PATCH] update insight plaground routes --- apps/playground-web/scripts/utils.ts | 34 +---- .../src/app/insight/insightBlueprints.ts | 116 +++++++++--------- apps/playground-web/src/app/insight/utils.ts | 8 ++ 3 files changed, 70 insertions(+), 88 deletions(-) diff --git a/apps/playground-web/scripts/utils.ts b/apps/playground-web/scripts/utils.ts index 74527fa0376..107c38b4a64 100644 --- a/apps/playground-web/scripts/utils.ts +++ b/apps/playground-web/scripts/utils.ts @@ -1,7 +1,6 @@ -import { - type BlueprintListItem, - type MinimalBlueprintSpec, - fetchBlueprintSpec, +import type { + BlueprintListItem, + MinimalBlueprintSpec, } from "../src/app/insight/utils"; async function fetchBlueprintList() { @@ -19,35 +18,14 @@ async function fetchBlueprintList() { export const fetchAllBlueprints = async (): Promise => { try { - // fetch list - const blueprintSpecs = await fetchBlueprintList(); - - // fetch all blueprints - const blueprints = await Promise.all( - blueprintSpecs.map((spec) => - fetchBlueprintSpec({ - blueprintId: spec.id, - }), - ), - ); + const blueprints = await fetchBlueprintList(); return blueprints.map((blueprint) => { - const paths = Object.keys(blueprint.openapiJson.paths); return { id: blueprint.id, name: blueprint.name, - paths: paths.map((pathName) => { - const pathObj = blueprint.openapiJson.paths[pathName]; - if (!pathObj) { - throw new Error(`Path not found: ${pathName}`); - } - - return { - name: pathObj.get?.summary || "Unknown", - path: pathName, - }; - }), - } satisfies MinimalBlueprintSpec; + paths: blueprint.paths.map(({ method, ...path }) => path), + }; }); } catch (error) { console.error(error); diff --git a/apps/playground-web/src/app/insight/insightBlueprints.ts b/apps/playground-web/src/app/insight/insightBlueprints.ts index fa09cf12268..f65a162ddda 100644 --- a/apps/playground-web/src/app/insight/insightBlueprints.ts +++ b/apps/playground-web/src/app/insight/insightBlueprints.ts @@ -2,6 +2,24 @@ import type { MinimalBlueprintSpec } from "./utils"; export const insightBlueprints: MinimalBlueprintSpec[] = [ + { + id: "events", + name: "Events", + paths: [ + { + name: "Get events", + path: "/v1/events", + }, + { + name: "Get contract events", + path: "/v1/events/{contractAddress}", + }, + { + name: "Get contract events with specific signature", + path: "/v1/events/{contractAddress}/{signature}", + }, + ], + }, { id: "transactions", name: "Transactions", @@ -18,27 +36,15 @@ export const insightBlueprints: MinimalBlueprintSpec[] = [ name: "Get contract transactions with specific signature", path: "/v1/transactions/{contractAddress}/{signature}", }, - { - name: "Get wallet transactions", - path: "/v1/wallets/{wallet_address}/transactions", - }, ], }, { - id: "events", - name: "Events", + id: "blocks", + name: "Blocks", paths: [ { - name: "Get events", - path: "/v1/events", - }, - { - name: "Get contract events", - path: "/v1/events/{contractAddress}", - }, - { - name: "Get contract events with specific signature", - path: "/v1/events/{contractAddress}/{signature}", + name: "Get blocks", + path: "/v1/blocks", }, ], }, @@ -84,50 +90,6 @@ export const insightBlueprints: MinimalBlueprintSpec[] = [ }, ], }, - { - id: "resolve", - name: "Resolve", - paths: [ - { - name: "Resolve", - path: "/v1/resolve/{input}", - }, - ], - }, - { - id: "blocks", - name: "Blocks", - paths: [ - { - name: "Get blocks", - path: "/v1/blocks", - }, - ], - }, - { - id: "contracts", - name: "Contracts", - paths: [ - { - name: "Get contract ABI​", - path: "/v1/contracts/abi/{contractAddress}", - }, - { - name: "Get contract metadata​", - path: "/v1/contracts/metadata/{contractAddress}", - }, - ], - }, - { - id: "decode", - name: "Decode", - paths: [ - { - name: "Unknown", - path: "/v1/decode/{contractAddress}", - }, - ], - }, { id: "nfts", name: "Nfts", @@ -192,4 +154,38 @@ export const insightBlueprints: MinimalBlueprintSpec[] = [ }, ], }, + { + id: "contracts", + name: "Contracts", + paths: [ + { + name: "Get contract ABI​", + path: "/v1/contracts/abi/{contractAddress}", + }, + { + name: "Get contract metadata​", + path: "/v1/contracts/metadata/{contractAddress}", + }, + ], + }, + { + id: "decode", + name: "Decode", + paths: [ + { + name: "Decode logs and transactions​", + path: "/v1/decode/{contractAddress}", + }, + ], + }, + { + id: "resolve", + name: "Resolve", + paths: [ + { + name: "Resolve", + path: "/v1/resolve/{input}", + }, + ], + }, ]; diff --git a/apps/playground-web/src/app/insight/utils.ts b/apps/playground-web/src/app/insight/utils.ts index 6260c0fe90b..f24ce70bc0b 100644 --- a/apps/playground-web/src/app/insight/utils.ts +++ b/apps/playground-web/src/app/insight/utils.ts @@ -9,7 +9,15 @@ export type BlueprintPathMetadata = OpenAPIV3.PathItemObject; export type BlueprintListItem = { id: string; name: string; + description: string; slug: string; + openapiJson: OpenAPIV3.Document; + openapiUrl: string; + paths: { + name: string; + path: string; + method: string; + }[]; }; export type BlueprintSpec = {