Skip to content

Commit

Permalink
use frontend specific RPC env (#66)
Browse files Browse the repository at this point in the history
* change to frontend specific RPC env

* show url instead of hardcoded devnet

* add comment
  • Loading branch information
wanwiset25 authored Jul 22, 2024
1 parent 42d4f30 commit 0adee5a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { configureChains, createConfig, WagmiConfig } from "wagmi";
import { InjectedConnector } from "wagmi/connectors/injected";
import { Chain, Wallet, connectorsForWallets } from "@rainbow-me/rainbowkit";
import { ChainSetting } from "./main";
import { rpcUrl } from "./constants/urls";

function App() {
const chainSetting = useLoaderData() as ChainSetting
Expand All @@ -31,8 +32,9 @@ function App() {
symbol: chainSetting.denom,
},
rpcUrls: {
public: { http: [chainSetting.rpcUrl] },
default: { http: [chainSetting.rpcUrl] },
// public: { http: [chainSetting.rpcUrl] } //backend provided url, for reference.
public: { http: [rpcUrl] },
default: { http: [rpcUrl] },
},
} as const satisfies Chain;

Expand Down Expand Up @@ -65,7 +67,7 @@ function App() {
[
jsonRpcProvider({
rpc: (chain) => ({
http: chainSetting.rpcUrl
http: rpcUrl
}),
}),
]
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/info-cards/InfoCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function getMappedInfo(
Math.round(loaderData.network.subnet.block.txThroughput * 100) / 100
} txs/s`,
},
{ name: "Checkpointed to", value: loaderData.network.parentChain.name },
{ name: "Checkpointed to", value: loaderData.network.parentChain.url },
],
};
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/constants/urls.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const baseUrl = `${import.meta.env.VITE_SUBNET_URL}`;
export const baseUrl = `${import.meta.env.VITE_SUBNET_URL}`;
export const rpcUrl = `${import.meta.env.VITE_SUBNET_RPC}`;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import InfoList from "@/components/info-list/InfoList";
import Loader from "@/components/loader/Loader";
import { formatHash } from "@/utils/formatter";
import { useAccount, useBalance, useNetwork } from "wagmi";
import { rpcUrl } from "@/constants/urls";
export default function ManagementLoggedInPage() {

const [isLoading, setIsLoading] = useState(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ErrorTypes } from "@/pages/errors";

import type { InfoListInfo } from "@/types/info";
import { ChainSetting } from "@/main";
import { rpcUrl } from "@/constants/urls";
interface LoginErrorProps {
errorType: ErrorTypes;
chainSetting: ChainSetting;
Expand Down Expand Up @@ -44,7 +45,7 @@ export default function LoginError({ errorType, chainSetting }: LoginErrorProps)
<br></br>
<b>Network name:</b> {chainSetting.networkName}
<br></br>
<b>New RPC URL:</b> {chainSetting.rpcUrl}
<b>New RPC URL:</b> {rpcUrl}
<br></br>
<b>Chain ID:</b> {chainSetting.networkId}
<br></br>
Expand Down

0 comments on commit 0adee5a

Please sign in to comment.