Skip to content

Commit f67e665

Browse files
committed
feat(docs): added constant based on env
1 parent 09c9820 commit f67e665

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/components/ParserOpenRPC/RequestBox/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import styles from "./styles.module.css";
66
import global from "../global.module.css";
77
import { Tooltip } from "@site/src/components/Tooltip";
88
import { MetamaskProviderContext } from "@site/src/theme/Root";
9+
import { LINEA_REQUEST_URL } from "@site/src/lib/constants";
910

1011
interface RequestBoxProps {
1112
isMetamaskInstalled: boolean;
@@ -32,12 +33,11 @@ export default function RequestBox({
3233
const exampleRequest = useMemo(() => {
3334
const preparedParams = JSON.stringify(paramsData, null, 2);
3435
const preparedShellParams = JSON.stringify(paramsData);
35-
const NETWORK_URL = "https://linea-mainnet.infura.io";
3636
const API_KEY = userAPIKey ? userAPIKey : "<YOUR-API-KEY>";
3737
if (isMetamaskNetwork) {
3838
return `await window.ethereum.request({\n "method": "${method}",\n "params": ${preparedParams.replace(/"([^"]+)":/g, '$1:')},\n});`;
3939
}
40-
return `curl ${NETWORK_URL}/v3/${API_KEY} \\\n -X POST \\\n -H "Content-Type: application/json" \\\n -d '{\n "jsonrpc": "2.0",\n "method": "${method}",\n "params": ${preparedShellParams},\n "id": 1\n }'`;
40+
return `curl ${LINEA_REQUEST_URL}/v3/${API_KEY} \\\n -X POST \\\n -H "Content-Type: application/json" \\\n -d '{\n "jsonrpc": "2.0",\n "method": "${method}",\n "params": ${preparedShellParams},\n "id": 1\n }'`;
4141
}, [userAPIKey, method, paramsData]);
4242

4343
const exampleResponse = useMemo(() => {

src/components/ParserOpenRPC/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { AuthBox } from "@site/src/components/ParserOpenRPC/AuthBox";
1919
import { MetamaskProviderContext } from "@site/src/theme/Root";
2020
import ProjectsBox from "@site/src/components/ParserOpenRPC/ProjectsBox";
21-
import { REF_PATH } from "@site/src/lib/constants";
21+
import { LINEA_REQUEST_URL, REF_PATH } from "@site/src/lib/constants";
2222

2323
interface ParserProps {
2424
network: NETWORK_NAMES;
@@ -168,8 +168,7 @@ export default function ParserOpenRPC({
168168
setReqResult(e);
169169
}
170170
} else {
171-
const NETWORK_URL = "https://linea-mainnet.infura.io";
172-
const URL = `${NETWORK_URL}/v3/${userAPIKey}`;
171+
const URL = `${LINEA_REQUEST_URL}/v3/${userAPIKey}`;
173172
let params = {
174173
method: "POST",
175174
"Content-Type": "application/json",

src/lib/constants.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,8 @@ export const REQUEST_PARAMS = (method = "POST") => ({
474474
export const AUTH_WALLET_SESSION_NAME = "auth.wallet.session";
475475
export const AUTH_WALLET_TOKEN = "auth.wallet.token";
476476
export const AUTH_WALLET_PROJECTS = "auth.wallet.projects";
477+
export const LINEA_DEV_URL = "https://linea-mainnet.dev.infura.org";
478+
export const LINEA_PROD_URL = "https://linea-mainnet.infura.io";
479+
export const LINEA_REQUEST_URL = process.env.VERCEL_ENV === "production"
480+
? LINEA_PROD_URL
481+
: LINEA_DEV_URL;

0 commit comments

Comments
 (0)