فهرست منبع

chore(staking): remove amount_staked_per_account

This endpoint was built for use calculating fogo points.  However, pulling the
data from the chain is too slow to run in Vercel endpoints, so we're going to
clean this up and try a different approach instead
Connor Prussin 7 ماه پیش
والد
کامیت
d6084de437
3فایلهای تغییر یافته به همراه1 افزوده شده و 58 حذف شده
  1. 0 53
      apps/staking/src/app/api/v1/amount_staked_per_account/route.ts
  2. 0 3
      apps/staking/src/config/server.ts
  3. 1 2
      apps/staking/turbo.json

+ 0 - 53
apps/staking/src/app/api/v1/amount_staked_per_account/route.ts

@@ -1,53 +0,0 @@
-import type { PositionState } from "@pythnetwork/staking-sdk";
-import {
-  PythStakingClient,
-  summarizeAccountPositions,
-  getCurrentEpoch,
-} from "@pythnetwork/staking-sdk";
-import { WalletAdapterNetwork } from "@solana/wallet-adapter-base";
-import { clusterApiUrl, Connection } from "@solana/web3.js";
-
-import {
-  AMOUNT_STAKED_PER_ACCOUNT_SECRET,
-  MAINNET_API_RPC,
-} from "../../../../config/server";
-
-export const maxDuration = 800;
-
-export const GET = async (req: Request) => {
-  if (
-    AMOUNT_STAKED_PER_ACCOUNT_SECRET === undefined ||
-    req.headers.get("authorization") ===
-      `Bearer ${AMOUNT_STAKED_PER_ACCOUNT_SECRET}`
-  ) {
-    const [accounts, epoch] = await Promise.all([
-      client.getAllStakeAccountPositionsAllOwners(),
-      getCurrentEpoch(client.connection),
-    ]);
-    return Response.json(
-      accounts.map((account) => {
-        const summary = summarizeAccountPositions(account, epoch);
-        return [
-          account.data.owner,
-          {
-            voting: stringifySummaryValues(summary.voting),
-            integrityPool: stringifySummaryValues(summary.integrityPool),
-          },
-        ];
-      }),
-    );
-  } else {
-    return new Response("Unauthorized", { status: 400 });
-  }
-};
-
-const stringifySummaryValues = (values: Record<PositionState, bigint>) =>
-  Object.fromEntries(
-    Object.entries(values).map(([state, value]) => [state, value.toString()]),
-  );
-
-const client = new PythStakingClient({
-  connection: new Connection(
-    MAINNET_API_RPC ?? clusterApiUrl(WalletAdapterNetwork.Mainnet),
-  ),
-});

+ 0 - 3
apps/staking/src/config/server.ts

@@ -80,9 +80,6 @@ export const SIMULATION_PAYER_ADDRESS = getOr(
   "SIMULATION_PAYER_ADDRESS",
   "E5KR7yfb9UyVB6ZhmhQki1rM1eBcxHvyGKFZakAC5uc",
 );
-export const AMOUNT_STAKED_PER_ACCOUNT_SECRET = demandInProduction(
-  "AMOUNT_STAKED_PER_ACCOUNT_SECRET",
-);
 
 class MissingEnvironmentError extends Error {
   constructor(name: string) {

+ 1 - 2
apps/staking/turbo.json

@@ -12,8 +12,7 @@
         "MAINNET_API_RPC",
         "BLOCKED_REGIONS",
         "AMPLITUDE_API_KEY",
-        "GOOGLE_ANALYTICS_ID",
-        "AMOUNT_STAKED_PER_ACCOUNT_SECRET"
+        "GOOGLE_ANALYTICS_ID"
       ]
     },
     "start:dev": {