Skip to content

Commit

Permalink
[TOOL-2822]: Insight Playground: Move chain from subdomain to query p…
Browse files Browse the repository at this point in the history
…aram (#5922)

<!-- start pr-codex -->

## PR-Codex overview
This PR focuses on modifying the handling of a parameter in the `BlueprintPlayground` component, changing its name from `chainId` to `chain`, and updating its usage throughout the codebase.

### Detailed summary
- Changed the `domain` URL format to remove `chainId`.
- Updated the parameter name from `chainId` to `chain` in `modifyParametersForPlayground`.
- Adjusted the parameter handling in `ParameterSection` to reflect the new name.
- Updated the schema creation to default to `z.string()` for parameters without a schema.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
MananTank committed Jan 9, 2025
1 parent ed0d215 commit 5866088
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function BlueprintPlayground(props: {
abortController.abort();
}
}}
domain={`https://{chainId}.insight.${thirdwebDomain}.com`}
domain={`https://insight.${thirdwebDomain}.com`}
path={props.path}
isInsightEnabled={props.isInsightEnabled}
projectSettingsLink={props.projectSettingsLink}
Expand All @@ -122,12 +122,12 @@ export function BlueprintPlayground(props: {

function modifyParametersForPlayground(_parameters: BlueprintParameter[]) {
const parameters = [..._parameters];
// if chainId parameter is not already present - add it, because we need it for the domain
const chainIdParameter = parameters.find((p) => p.name === "chainId");
// if chain parameter is not already mentioned - add it, its required
const chainIdParameter = parameters.find((p) => p.name === "chain");
if (!chainIdParameter) {
parameters.unshift({
name: "chainId",
in: "path",
name: "chain",
in: "query",
required: true,
schema: {
type: "integer",
Expand Down Expand Up @@ -561,14 +561,14 @@ function ParameterSection(props: {
key={param.name}
className={cn(
"grid items-center",
param.name === "chainId"
param.name === "chain"
? "grid-cols-1 lg:grid-cols-2"
: "grid-cols-2",
)}
>
<div className="flex h-full flex-row flex-wrap items-center justify-between gap-1 border-r px-3 py-2">
<div className="font-medium font-mono text-sm">
{param.name === "chainId" ? "chainId" : param.name}
{param.name}
</div>
{param.required && (
<Badge
Expand All @@ -580,7 +580,7 @@ function ParameterSection(props: {
)}
</div>
<div className="relative">
{param.name === "chainId" ? (
{param.name === "chain" ? (
<SingleNetworkSelector
chainId={
field.value ? Number(field.value) : undefined
Expand Down Expand Up @@ -886,6 +886,8 @@ function createParametersFormSchema(parameters: BlueprintParameter[]) {
const paramSchema = openAPIV3ParamToZodFormSchema(param);
if (paramSchema) {
shape[param.name] = paramSchema;
} else {
shape[param.name] = z.string();
}
}

Expand Down

0 comments on commit 5866088

Please sign in to comment.