Skip to content

Commit

Permalink
refactor(pol): renames vault route param
Browse files Browse the repository at this point in the history
  • Loading branch information
bearpong committed Jan 8, 2025
1 parent 7fbaa3b commit 716cb44
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ export const revalidate = 30;
export default async function PoolPage({
params,
}: {
params: { gaugeAddress: Address };
params: { address: Address };
}) {
if (isIPFS) {
return null;
}

if (!isAddress(params.gaugeAddress)) {
console.error("Invalid gauge address", params.gaugeAddress);
if (!isAddress(params.address)) {
console.error("Invalid gauge address", params.address);
notFound();
}

Expand All @@ -48,11 +48,11 @@ export default async function PoolPage({
transport: http(),
});

const vaultPromise = getRewardVault(params.gaugeAddress);
const vaultPromise = getRewardVault(params.address);

try {
await getRewardVaultStakingToken({
address: params.gaugeAddress,
address: params.address,
// @ts-ignore viem types
publicClient: publicClient as PublicClient,
});
Expand All @@ -68,19 +68,17 @@ export default async function PoolPage({
} catch (error) {
console.warn(
"Vault not found during SSR, but staking token was found",
params.gaugeAddress,
params.address,
);
}

return (
<VaultDetails address={params.gaugeAddress} rewardVault={rewardVault} />
);
return <VaultDetails address={params.address} rewardVault={rewardVault} />;
}

export function generateStaticParams() {
return [
{
gaugeAddress: "0x",
address: "0x",
},
];
}
10 changes: 5 additions & 5 deletions apps/hub/src/app/vaults/vault/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import { FC, Suspense } from "react";
import { notFound, useSearchParams } from "next/navigation";
import { isAddress } from "viem";

import { VaultDetails } from "../[gaugeAddress]/components/VaultDetails";
import Loading from "../[gaugeAddress]/loading";
import { VaultDetails } from "../[address]/components/VaultDetails";
import Loading from "../[address]/loading";

const Gauge: FC = () => {
const searchParams = useSearchParams();
const gaugeAddress = searchParams.get("address");
const address = searchParams.get("address");

if (!gaugeAddress || !isAddress(gaugeAddress)) {
if (!address || !isAddress(address)) {
return notFound();
}
return <VaultDetails address={gaugeAddress} />;
return <VaultDetails address={address} />;
};

export default function GaugeStaticPage() {
Expand Down
6 changes: 3 additions & 3 deletions packages/berajs/src/actions/bgt/getRewardVaultIncentives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ export interface RewardVaultIncentive {
}

export const getRewardVaultIncentives = async (
gaugeAddress: Address,
address: Address,
publicClient: PublicClient,
) => {
const whitelistedTokens = await publicClient.readContract({
address: gaugeAddress,
address: address,
abi: rewardVaultAbi,
functionName: "getWhitelistedTokens",
});

const incentivesInfoPromise = Promise.all(
whitelistedTokens.map((incentive) =>
publicClient.readContract({
address: gaugeAddress,
address: address,
abi: rewardVaultAbi,
functionName: "incentives",
args: [incentive],
Expand Down

0 comments on commit 716cb44

Please sign in to comment.