Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/api/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ export async function getGatewaySelfRedeem(
return lastTimestamp >= cutoff;
}

export async function getCurrentRound(client = getApollo()) {
return client.query<CurrentRoundQuery, CurrentRoundQueryVariables>({
query: CurrentRoundDocument,
});
}

export async function getOrchestrators(client = getApollo()) {
const protocolResponse = await client.query<
CurrentRoundQuery,
Expand Down
26 changes: 14 additions & 12 deletions pages/api/pending-stake/[address].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { getCacheControlHeader, getCurrentRound } from "@lib/api";
import { getCacheControlHeader } from "@lib/api";
import { bondingManager } from "@lib/api/abis/main/BondingManager";
import { getBondingManagerAddress } from "@lib/api/contracts";
import { roundsManager } from "@lib/api/abis/main/RoundsManager";
import {
getBondingManagerAddress,
getRoundsManagerAddress,
} from "@lib/api/contracts";
import { badRequest, internalError, methodNotAllowed } from "@lib/api/errors";
import { PendingFeesAndStake } from "@lib/api/types/get-pending-stake";
import { l2PublicClient } from "@lib/chains";
Expand All @@ -20,17 +24,15 @@ const handler = async (
const { address } = req.query;

if (!!address && !Array.isArray(address) && isAddress(address)) {
const bondingManagerAddress = await getBondingManagerAddress();
const [bondingManagerAddress, roundsManagerAddress] = await Promise.all(
[getBondingManagerAddress(), getRoundsManagerAddress()]
);

const {
data: { protocol },
} = await getCurrentRound();
const currentRoundString = protocol?.currentRound?.id;

if (!currentRoundString) {
throw new Error("No current round found");
}
const currentRound = BigInt(currentRoundString);
const currentRound = await l2PublicClient.readContract({
address: roundsManagerAddress,
abi: roundsManager,
functionName: "currentRound",
});

const [pendingStake, pendingFees] = await l2PublicClient.multicall({
allowFailure: false,
Expand Down
Loading