Skip to content

Commit 352977f

Browse files
committed
update insight plaground routes
1 parent cfacfc2 commit 352977f

File tree

3 files changed

+104
-88
lines changed

3 files changed

+104
-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,
28+
};
5129
});
5230
} catch (error) {
5331
console.error(error);

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

Lines changed: 89 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,56 @@
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+
method: "get",
13+
},
14+
{
15+
name: "Get contract events",
16+
path: "/v1/events/{contractAddress}",
17+
method: "get",
18+
},
19+
{
20+
name: "Get contract events with specific signature",
21+
path: "/v1/events/{contractAddress}/{signature}",
22+
method: "get",
23+
},
24+
],
25+
},
526
{
627
id: "transactions",
728
name: "Transactions",
829
paths: [
930
{
1031
name: "Get transactions",
1132
path: "/v1/transactions",
33+
method: "get",
1234
},
1335
{
1436
name: "Get contract transactions",
1537
path: "/v1/transactions/{contractAddress}",
38+
method: "get",
1639
},
1740
{
1841
name: "Get contract transactions with specific signature",
1942
path: "/v1/transactions/{contractAddress}/{signature}",
20-
},
21-
{
22-
name: "Get wallet transactions",
23-
path: "/v1/wallets/{wallet_address}/transactions",
43+
method: "get",
2444
},
2545
],
2646
},
2747
{
28-
id: "events",
29-
name: "Events",
48+
id: "blocks",
49+
name: "Blocks",
3050
paths: [
3151
{
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}",
52+
name: "Get blocks",
53+
path: "/v1/blocks",
54+
method: "get",
4255
},
4356
],
4457
},
@@ -49,82 +62,47 @@ export const insightBlueprints: MinimalBlueprintSpec[] = [
4962
{
5063
name: "Get token transfers by transaction",
5164
path: "/v1/tokens/transfers/transaction/{transaction_hash}",
65+
method: "get",
5266
},
5367
{
5468
name: "Get token transfers by contract",
5569
path: "/v1/tokens/transfers/{contract_address}",
70+
method: "get",
5671
},
5772
{
5873
name: "Get token transfers by wallet address",
5974
path: "/v1/tokens/transfers",
75+
method: "get",
6076
},
6177
{
6278
name: "Get ERC-20 balances by address",
6379
path: "/v1/tokens/erc20/{ownerAddress}",
80+
method: "get",
6481
},
6582
{
6683
name: "Get ERC-721 balances by address",
6784
path: "/v1/tokens/erc721/{ownerAddress}",
85+
method: "get",
6886
},
6987
{
7088
name: "Get ERC-1155 balances by address",
7189
path: "/v1/tokens/erc1155/{ownerAddress}",
90+
method: "get",
7291
},
7392
{
7493
name: "Get supported tokens for price data",
7594
path: "/v1/tokens/price/supported",
95+
method: "get",
7696
},
7797
{
7898
name: "Get token price",
7999
path: "/v1/tokens/price",
100+
method: "get",
80101
},
81102
{
82103
name: "Token lookup",
83104
path: "/v1/tokens/lookup",
84-
},
85-
],
86-
},
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}",
105+
method: "get",
128106
},
129107
],
130108
},
@@ -135,50 +113,62 @@ export const insightBlueprints: MinimalBlueprintSpec[] = [
135113
{
136114
name: "Get collection",
137115
path: "/v1/nfts/collections/{contract_address}",
116+
method: "get",
138117
},
139118
{
140119
name: "Get NFTs by owner",
141120
path: "/v1/nfts",
121+
method: "get",
142122
},
143123
{
144124
name: "Get NFT owners by contract",
145125
path: "/v1/nfts/owners/{contract_address}",
126+
method: "get",
146127
},
147128
{
148129
name: "Get NFT owners by token",
149130
path: "/v1/nfts/owners/{contract_address}/{token_id}",
131+
method: "get",
150132
},
151133
{
152134
name: "Get NFT transfers by owner",
153135
path: "/v1/nfts/transfers",
136+
method: "get",
154137
},
155138
{
156139
name: "Get NFT transfers by transaction",
157140
path: "/v1/nfts/transfers/transaction/{transaction_hash}",
141+
method: "get",
158142
},
159143
{
160144
name: "Get NFT transfers by contract",
161145
path: "/v1/nfts/transfers/{contract_address}",
146+
method: "get",
162147
},
163148
{
164149
name: "Get NFTs by contract",
165150
path: "/v1/nfts/{contract_address}",
151+
method: "get",
166152
},
167153
{
168154
name: "Get NFT transfers by token",
169155
path: "/v1/nfts/transfers/{contract_address}/{token_id}",
156+
method: "get",
170157
},
171158
{
172159
name: "Get NFT by token ID",
173160
path: "/v1/nfts/{contract_address}/{token_id}",
161+
method: "get",
174162
},
175163
{
176164
name: "Force refresh collection metadata",
177165
path: "/v1/nfts/metadata/refresh/{contract_address}",
166+
method: "get",
178167
},
179168
{
180169
name: "Force refresh token metadata",
181170
path: "/v1/nfts/metadata/refresh/{contract_address}/{token_id}",
171+
method: "get",
182172
},
183173
],
184174
},
@@ -189,6 +179,45 @@ export const insightBlueprints: MinimalBlueprintSpec[] = [
189179
{
190180
name: "Get wallet transactions",
191181
path: "/v1/wallets/{wallet_address}/transactions",
182+
method: "get",
183+
},
184+
],
185+
},
186+
{
187+
id: "contracts",
188+
name: "Contracts",
189+
paths: [
190+
{
191+
name: "Get contract ABI​",
192+
path: "/v1/contracts/abi/{contractAddress}",
193+
method: "get",
194+
},
195+
{
196+
name: "Get contract metadata​",
197+
path: "/v1/contracts/metadata/{contractAddress}",
198+
method: "get",
199+
},
200+
],
201+
},
202+
{
203+
id: "decode",
204+
name: "Decode",
205+
paths: [
206+
{
207+
name: "Decode logs and transactions​",
208+
path: "/v1/decode/{contractAddress}",
209+
method: "post",
210+
},
211+
],
212+
},
213+
{
214+
id: "resolve",
215+
name: "Resolve",
216+
paths: [
217+
{
218+
name: "Resolve",
219+
path: "/v1/resolve/{input}",
220+
method: "get",
192221
},
193222
],
194223
},

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

Lines changed: 9 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 = {
@@ -25,6 +33,7 @@ export type MinimalBlueprintSpec = {
2533
paths: {
2634
name: string;
2735
path: string;
36+
method: string;
2837
}[];
2938
};
3039

0 commit comments

Comments
 (0)