Explorar el Código

Merge pull request #2564 from pyth-network/cprussin/remove-amount-staked-per-wallet

chore(staking): remove amount_staked_per_account
Connor Prussin hace 7 meses
padre
commit
35a46dfe73

+ 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": {