-
Notifications
You must be signed in to change notification settings - Fork 544
[TOOL-3942] Playground: Fix slow dev server - generate insight sidebar links with script #6631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,20 @@ | ||
import * as fs from "node:fs"; | ||
import * as path from "node:path"; | ||
import { fetchAllBlueprints } from "./utils"; | ||
|
||
const blueprints = await fetchAllBlueprints(); | ||
|
||
const fileContent = `\ | ||
// This file is auto-generated by the update-insight-blueprints script | ||
import type { MinimalBlueprintSpec } from "./utils"; | ||
|
||
export const insightBlueprints: MinimalBlueprintSpec[] = ${JSON.stringify(blueprints, null, 2)}`; | ||
|
||
fs.writeFileSync( | ||
path.join(__dirname, "../src/app/insight/insightBlueprints.ts"), | ||
fileContent, | ||
); | ||
|
||
console.log( | ||
"Updated insightBlueprints.ts - Please format this file and commit it", | ||
); |
This file contains hidden or 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,56 @@ | ||
import { | ||
type BlueprintListItem, | ||
type MinimalBlueprintSpec, | ||
fetchBlueprintSpec, | ||
} from "../src/app/insight/utils"; | ||
|
||
async function fetchBlueprintList() { | ||
const res = await fetch("https://insight.thirdweb.com/v1/blueprints"); | ||
|
||
if (!res.ok) { | ||
const text = await res.text(); | ||
throw new Error(`Failed to fetch blueprints: ${text}`); | ||
} | ||
|
||
const json = (await res.json()) as { data: BlueprintListItem[] }; | ||
|
||
return json.data; | ||
} | ||
|
||
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, | ||
}), | ||
), | ||
); | ||
|
||
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; | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
return []; | ||
} | ||
}; |
187 changes: 187 additions & 0 deletions
187
apps/playground-web/src/app/insight/insightBlueprints.ts
This file contains hidden or 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,187 @@ | ||
// This file is auto-generated by the update-insight-blueprints script | ||
import type { MinimalBlueprintSpec } from "./utils"; | ||
|
||
export const insightBlueprints: MinimalBlueprintSpec[] = [ | ||
{ | ||
id: "transactions", | ||
name: "Transactions", | ||
paths: [ | ||
{ | ||
name: "Get transactions", | ||
path: "/v1/transactions", | ||
}, | ||
{ | ||
name: "Get contract transactions", | ||
path: "/v1/transactions/:contractAddress", | ||
}, | ||
{ | ||
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", | ||
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: "tokens", | ||
name: "Tokens", | ||
paths: [ | ||
{ | ||
name: "Get token transfers by transaction", | ||
path: "/v1/tokens/transfers/transaction/:transaction_hash", | ||
}, | ||
{ | ||
name: "Get token transfers by contract", | ||
path: "/v1/tokens/transfers/:contract_address", | ||
}, | ||
{ | ||
name: "Get token transfers by wallet address", | ||
path: "/v1/tokens/transfers", | ||
}, | ||
{ | ||
name: "Get ERC-20 balances by address", | ||
path: "/v1/tokens/erc20/:ownerAddress", | ||
}, | ||
{ | ||
name: "Get ERC-721 balances by address", | ||
path: "/v1/tokens/erc721/:ownerAddress", | ||
}, | ||
{ | ||
name: "Get ERC-1155 balances by address", | ||
path: "/v1/tokens/erc1155/:ownerAddress", | ||
}, | ||
{ | ||
name: "Get supported tokens for price data", | ||
path: "/v1/tokens/price/supported", | ||
}, | ||
{ | ||
name: "Get token price", | ||
path: "/v1/tokens/price", | ||
}, | ||
], | ||
}, | ||
{ | ||
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", | ||
paths: [ | ||
{ | ||
name: "Get NFTs by owner", | ||
path: "/v1/nfts", | ||
}, | ||
{ | ||
name: "Get NFT owners by contract", | ||
path: "/v1/nfts/owners/:contract_address", | ||
}, | ||
{ | ||
name: "Get NFT owners by token", | ||
path: "/v1/nfts/owners/:contract_address/:token_id", | ||
}, | ||
{ | ||
name: "Get NFT transfers by owner", | ||
path: "/v1/nfts/transfers", | ||
}, | ||
{ | ||
name: "Get NFT transfers by transaction", | ||
path: "/v1/nfts/transfers/transaction/:transaction_hash", | ||
}, | ||
{ | ||
name: "Get NFT transfers by contract", | ||
path: "/v1/nfts/transfers/:contract_address", | ||
}, | ||
{ | ||
name: "Get NFTs by contract", | ||
path: "/v1/nfts/:contract_address", | ||
}, | ||
{ | ||
name: "Get NFT transfers by token", | ||
path: "/v1/nfts/transfers/:contract_address/:token_id", | ||
}, | ||
{ | ||
name: "Get NFT by token", | ||
path: "/v1/nfts/:contract_address/:token_id", | ||
}, | ||
{ | ||
name: "Force refresh collection metadata", | ||
path: "/v1/nfts/metadata/refresh/:contract_address", | ||
}, | ||
{ | ||
name: "Force refresh token metadata", | ||
path: "/v1/nfts/metadata/refresh/:contract_address/:token_id", | ||
}, | ||
], | ||
}, | ||
{ | ||
id: "wallets", | ||
name: "Wallets", | ||
paths: [ | ||
{ | ||
name: "Get wallet transactions", | ||
path: "/v1/wallets/:wallet_address/transactions", | ||
}, | ||
], | ||
}, | ||
]; |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't generate these from the downloaded files? would be generated when running the script i guess
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, This file is auto generated when running the script