Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 6 additions & 28 deletions apps/playground-web/scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
type BlueprintListItem,
type MinimalBlueprintSpec,
fetchBlueprintSpec,
import type {
BlueprintListItem,
MinimalBlueprintSpec,
} from "../src/app/insight/utils";

async function fetchBlueprintList() {
Expand All @@ -19,35 +18,14 @@ async function fetchBlueprintList() {

export const fetchAllBlueprints = async (): Promise<MinimalBlueprintSpec[]> => {
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);
Expand Down
116 changes: 56 additions & 60 deletions apps/playground-web/src/app/insight/insightBlueprints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
},
],
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}",
},
],
},
];
8 changes: 8 additions & 0 deletions apps/playground-web/src/app/insight/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Loading