Skip to content

Commit e9db59e

Browse files
authored
update insight plaground routes (#6692)
1 parent 1db2165 commit e9db59e

File tree

3 files changed

+70
-88
lines changed

3 files changed

+70
-88
lines changed

apps/playground-web/scripts/utils.ts

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import {
2-
type BlueprintListItem,
3-
type MinimalBlueprintSpec,
4-
fetchBlueprintSpec,
1+
import type {
2+
BlueprintListItem,
3+
MinimalBlueprintSpec,
54
} from "../src/app/insight/utils";
65

76
async function fetchBlueprintList() {
@@ -19,35 +18,14 @@ async function fetchBlueprintList() {
1918

2019
export const fetchAllBlueprints = async (): Promise<MinimalBlueprintSpec[]> => {
2120
try {
22-
// fetch list
23-
const blueprintSpecs = await fetchBlueprintList();
24-
25-
// fetch all blueprints
26-
const blueprints = await Promise.all(
27-
blueprintSpecs.map((spec) =>
28-
fetchBlueprintSpec({
29-
blueprintId: spec.id,
30-
}),
31-
),
32-
);
21+
const blueprints = await fetchBlueprintList();
3322

3423
return blueprints.map((blueprint) => {
35-
const paths = Object.keys(blueprint.openapiJson.paths);
3624
return {
3725
id: blueprint.id,
3826
name: blueprint.name,
39-
paths: paths.map((pathName) => {
40-
const pathObj = blueprint.openapiJson.paths[pathName];
41-
if (!pathObj) {
42-
throw new Error(`Path not found: ${pathName}`);
43-
}
44-
45-
return {
46-
name: pathObj.get?.summary || "Unknown",
47-
path: pathName,
48-
};
49-
}),
50-
} satisfies MinimalBlueprintSpec;
27+
paths: blueprint.paths.map(({ method, ...path }) => path),
28+
};
5129
});
5230
} catch (error) {
5331
console.error(error);

apps/playground-web/src/app/insight/insightBlueprints.ts

Lines changed: 56 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
import type { MinimalBlueprintSpec } from "./utils";
33

44
export const insightBlueprints: MinimalBlueprintSpec[] = [
5+
{
6+
id: "events",
7+
name: "Events",
8+
paths: [
9+
{
10+
name: "Get events",
11+
path: "/v1/events",
12+
},
13+
{
14+
name: "Get contract events",
15+
path: "/v1/events/{contractAddress}",
16+
},
17+
{
18+
name: "Get contract events with specific signature",
19+
path: "/v1/events/{contractAddress}/{signature}",
20+
},
21+
],
22+
},
523
{
624
id: "transactions",
725
name: "Transactions",
@@ -18,27 +36,15 @@ export const insightBlueprints: MinimalBlueprintSpec[] = [
1836
name: "Get contract transactions with specific signature",
1937
path: "/v1/transactions/{contractAddress}/{signature}",
2038
},
21-
{
22-
name: "Get wallet transactions",
23-
path: "/v1/wallets/{wallet_address}/transactions",
24-
},
2539
],
2640
},
2741
{
28-
id: "events",
29-
name: "Events",
42+
id: "blocks",
43+
name: "Blocks",
3044
paths: [
3145
{
32-
name: "Get events",
33-
path: "/v1/events",
34-
},
35-
{
36-
name: "Get contract events",
37-
path: "/v1/events/{contractAddress}",
38-
},
39-
{
40-
name: "Get contract events with specific signature",
41-
path: "/v1/events/{contractAddress}/{signature}",
46+
name: "Get blocks",
47+
path: "/v1/blocks",
4248
},
4349
],
4450
},
@@ -84,50 +90,6 @@ export const insightBlueprints: MinimalBlueprintSpec[] = [
8490
},
8591
],
8692
},
87-
{
88-
id: "resolve",
89-
name: "Resolve",
90-
paths: [
91-
{
92-
name: "Resolve",
93-
path: "/v1/resolve/{input}",
94-
},
95-
],
96-
},
97-
{
98-
id: "blocks",
99-
name: "Blocks",
100-
paths: [
101-
{
102-
name: "Get blocks",
103-
path: "/v1/blocks",
104-
},
105-
],
106-
},
107-
{
108-
id: "contracts",
109-
name: "Contracts",
110-
paths: [
111-
{
112-
name: "Get contract ABI​",
113-
path: "/v1/contracts/abi/{contractAddress}",
114-
},
115-
{
116-
name: "Get contract metadata​",
117-
path: "/v1/contracts/metadata/{contractAddress}",
118-
},
119-
],
120-
},
121-
{
122-
id: "decode",
123-
name: "Decode",
124-
paths: [
125-
{
126-
name: "Unknown",
127-
path: "/v1/decode/{contractAddress}",
128-
},
129-
],
130-
},
13193
{
13294
id: "nfts",
13395
name: "Nfts",
@@ -192,4 +154,38 @@ export const insightBlueprints: MinimalBlueprintSpec[] = [
192154
},
193155
],
194156
},
157+
{
158+
id: "contracts",
159+
name: "Contracts",
160+
paths: [
161+
{
162+
name: "Get contract ABI​",
163+
path: "/v1/contracts/abi/{contractAddress}",
164+
},
165+
{
166+
name: "Get contract metadata​",
167+
path: "/v1/contracts/metadata/{contractAddress}",
168+
},
169+
],
170+
},
171+
{
172+
id: "decode",
173+
name: "Decode",
174+
paths: [
175+
{
176+
name: "Decode logs and transactions​",
177+
path: "/v1/decode/{contractAddress}",
178+
},
179+
],
180+
},
181+
{
182+
id: "resolve",
183+
name: "Resolve",
184+
paths: [
185+
{
186+
name: "Resolve",
187+
path: "/v1/resolve/{input}",
188+
},
189+
],
190+
},
195191
];

apps/playground-web/src/app/insight/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ export type BlueprintPathMetadata = OpenAPIV3.PathItemObject;
99
export type BlueprintListItem = {
1010
id: string;
1111
name: string;
12+
description: string;
1213
slug: string;
14+
openapiJson: OpenAPIV3.Document;
15+
openapiUrl: string;
16+
paths: {
17+
name: string;
18+
path: string;
19+
method: string;
20+
}[];
1321
};
1422

1523
export type BlueprintSpec = {

0 commit comments

Comments
 (0)