Skip to content

fix(staking-sdk): fix staking-sdk build #2567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
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
2 changes: 0 additions & 2 deletions apps/api-reference/next.config.js
Original file line number Diff line number Diff line change
@@ -29,8 +29,6 @@ export default {
return config;
},

transpilePackages: ["@pythnetwork/*"],

headers: () => [
{
source: "/:path*",
2 changes: 0 additions & 2 deletions apps/insights/next.config.js
Original file line number Diff line number Diff line change
@@ -22,8 +22,6 @@ const config = {
return config;
},

transpilePackages: ["@pythnetwork/*"],

headers: async () => [
{
source: "/:path*",
7 changes: 0 additions & 7 deletions apps/insights/turbo.json
Original file line number Diff line number Diff line change
@@ -14,13 +14,6 @@
"DISABLE_ACCESSIBILITY_REPORTING"
]
},
"start:dev": {
"dependsOn": [
"//#install:modules",
"pull:env",
"@pythnetwork/solana-utils#build"
]
},
"fix:lint": {
"dependsOn": [
"//#install:modules",
2 changes: 0 additions & 2 deletions apps/staking/next.config.js
Original file line number Diff line number Diff line change
@@ -22,8 +22,6 @@ export default {
return config;
},

transpilePackages: ["@pythnetwork/*"],

headers: () => [
{
source: "/:path*",
8 changes: 0 additions & 8 deletions apps/staking/turbo.json
Original file line number Diff line number Diff line change
@@ -14,14 +14,6 @@
"AMPLITUDE_API_KEY",
"GOOGLE_ANALYTICS_ID"
]
},
"start:dev": {
"dependsOn": [
"//#install:modules",
"pull:env",
"@pythnetwork/hermes-client#build",
"@pythnetwork/solana-utils#build"
]
}
}
}
13 changes: 8 additions & 5 deletions governance/pyth_staking_sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "@pythnetwork/staking-sdk",
"version": "0.1.1",
"version": "0.2.0",
"description": "Pyth staking SDK",
"main": "src/index.ts",
"types": "src/index.d.ts",
"type": "module",
"exports": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": [
"dist/**/*"
],
@@ -15,10 +19,9 @@
"access": "public"
},
"scripts": {
"build": "tsc",
"build": "tsc --noEmit false --incremental false --declaration true --outDir ./dist",
"fix:format": "prettier --write .",
"fix:lint": "eslint --fix . --max-warnings 0",
"prepublishOnly": "node scripts/update-package-json.mjs",
"test:format": "prettier --check .",
"test:lint": "eslint . --max-warnings 0",
"test:types": "tsc"
21 changes: 0 additions & 21 deletions governance/pyth_staking_sdk/scripts/update-package-json.mjs

This file was deleted.

18 changes: 9 additions & 9 deletions governance/pyth_staking_sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export * from "./pdas";
export * from "./pyth-staking-client";
export * from "./pythnet-client";
export * from "./types";
export * from "./utils/apy";
export * from "./utils/clock";
export * from "./utils/pool";
export * from "./utils/position";
export * from "./utils/vesting";
export * from "./pdas.js";
export * from "./pyth-staking-client.js";
export * from "./pythnet-client.js";
export * from "./types.js";
export * from "./utils/apy.js";
export * from "./utils/clock.js";
export * from "./utils/pool.js";
export * from "./utils/position.js";
export * from "./utils/vesting.js";
2 changes: 1 addition & 1 deletion governance/pyth_staking_sdk/src/pdas.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import {
INTEGRITY_POOL_PROGRAM_ADDRESS,
STAKE_CAPS_PARAMETERS_PROGRAM_ADDRESS,
STAKING_PROGRAM_ADDRESS,
} from "./constants";
} from "./constants.js";

export const getConfigAddress = () => {
return PublicKey.findProgramAddressSync(
38 changes: 19 additions & 19 deletions governance/pyth_staking_sdk/src/pyth-staking-client.ts
Original file line number Diff line number Diff line change
@@ -30,15 +30,21 @@ import {
FRACTION_PRECISION_N,
ONE_YEAR_IN_SECONDS,
POSITIONS_ACCOUNT_SIZE,
} from "./constants";
} from "./constants.js";
import IntegrityPoolIdl from "./idl/integrity-pool.json" with { type: "json" };
import PublisherCapsIdl from "./idl/publisher-caps.json" with { type: "json" };
import StakingIdl from "./idl/staking.json" with { type: "json" };
import {
getConfigAddress,
getDelegationRecordAddress,
getPoolConfigAddress,
getStakeAccountCustodyAddress,
getStakeAccountMetadataAddress,
getTargetAccountAddress,
} from "./pdas";
} from "./pdas.js";
import type { IntegrityPool } from "./types/integrity-pool.js";
import type { PublisherCaps } from "./types/publisher-caps.js";
import type { Staking } from "./types/staking.js";
import type {
GlobalConfig,
PoolConfig,
@@ -47,27 +53,21 @@ import type {
TargetAccount,
VoterWeightAction,
VestingSchedule,
} from "./types";
import { PositionState } from "./types";
import type { Staking } from "../types/staking";
import { bigintMax, bigintMin } from "./utils/bigint";
import { convertBigIntToBN, convertBNToBigInt } from "./utils/bn";
import { epochToDate, getCurrentEpoch } from "./utils/clock";
import { extractPublisherData } from "./utils/pool";
} from "./types.js";
import { PositionState } from "./types.js";
import { bigintMax, bigintMin } from "./utils/bigint.js";
import { convertBigIntToBN, convertBNToBigInt } from "./utils/bn.js";
import { epochToDate, getCurrentEpoch } from "./utils/clock.js";
import { extractPublisherData } from "./utils/pool.js";
import {
deserializeStakeAccountPositions,
getPositionState,
getVotingTokenAmount,
} from "./utils/position";
import { sendTransaction } from "./utils/transaction";
import { getUnlockSchedule } from "./utils/vesting";
import type { PythStakingWallet } from "./utils/wallet";
import { DummyWallet } from "./utils/wallet";
import * as IntegrityPoolIdl from "../idl/integrity-pool.json";
import * as PublisherCapsIdl from "../idl/publisher-caps.json";
import * as StakingIdl from "../idl/staking.json";
import type { IntegrityPool } from "../types/integrity-pool";
import type { PublisherCaps } from "../types/publisher-caps";
} from "./utils/position.js";
import { sendTransaction } from "./utils/transaction.js";
import { getUnlockSchedule } from "./utils/vesting.js";
import type { PythStakingWallet } from "./utils/wallet.js";
import { DummyWallet } from "./utils/wallet.js";

export type PythStakingClientConfig = {
connection: Connection;
10 changes: 5 additions & 5 deletions governance/pyth_staking_sdk/src/pythnet-client.ts
Original file line number Diff line number Diff line change
@@ -7,11 +7,11 @@ import {
} from "@pythnetwork/client";
import { Connection } from "@solana/web3.js";

import { getStakeCapsParametersAddress } from "./pdas";
import { convertBNToBigInt } from "./utils/bn";
import { DummyWallet } from "./utils/wallet";
import * as StakeCapsParametersIdl from "../idl/stake-caps-parameters.json";
import type { StakeCapsParameters } from "../types/stake-caps-parameters";
import StakeCapsParametersIdl from "./idl/stake-caps-parameters.json" with { type: "json" };
import { getStakeCapsParametersAddress } from "./pdas.js";
import type { StakeCapsParameters } from "./types/stake-caps-parameters.js";
import { convertBNToBigInt } from "./utils/bn.js";
import { DummyWallet } from "./utils/wallet.js";
export class PythnetClient {
connection: Connection;
provider: AnchorProvider;
4 changes: 2 additions & 2 deletions governance/pyth_staking_sdk/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { BN, IdlAccounts, IdlTypes } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";

import type { IntegrityPool } from "../types/integrity-pool";
import type { Staking } from "../types/staking";
import type { IntegrityPool } from "./types/integrity-pool.js";
import type { Staking } from "./types/staking.js";

// This type converts all From types to To types in a given object.
export type Convert<T, From, To> = T extends From
2 changes: 1 addition & 1 deletion governance/pyth_staking_sdk/src/utils/apy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FRACTION_PRECISION } from "../constants";
import { FRACTION_PRECISION } from "../constants.js";

export const convertEpochYieldToApy = (epochYield: bigint) => {
return (Number(epochYield) * 52 * 100) / FRACTION_PRECISION;
2 changes: 1 addition & 1 deletion governance/pyth_staking_sdk/src/utils/bn.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { BN } from "@coral-xyz/anchor";

import type { ConvertBigIntToBN, ConvertBNToBigInt } from "../types";
import type { ConvertBigIntToBN, ConvertBNToBigInt } from "../types.js";

export const convertBNToBigInt = <T>(obj: T): ConvertBNToBigInt<T> => {
if (obj instanceof BN) {
2 changes: 1 addition & 1 deletion governance/pyth_staking_sdk/src/utils/clock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Connection } from "@solana/web3.js";

import { EPOCH_DURATION } from "../constants";
import { EPOCH_DURATION } from "../constants.js";

export const getCurrentSolanaTimestamp = async (connection: Connection) => {
const slot = await connection.getSlot("finalized");
6 changes: 3 additions & 3 deletions governance/pyth_staking_sdk/src/utils/pool.ts
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@ import { PublicKey } from "@solana/web3.js";
import {
computeDelegatorRewardPercentage,
convertEpochYieldToApy,
} from "./apy";
import { FRACTION_PRECISION_N } from "../constants";
import type { PoolDataAccount, PublisherData } from "../types";
} from "./apy.js";
import { FRACTION_PRECISION_N } from "../constants.js";
import type { PoolDataAccount, PublisherData } from "../types.js";

export const extractPublisherData = (
poolData: PoolDataAccount,
10 changes: 5 additions & 5 deletions governance/pyth_staking_sdk/src/utils/position.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { BorshCoder } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";

import { convertBNToBigInt } from "./bn";
import type { Staking } from "../../types/staking";
import { convertBNToBigInt } from "./bn.js";
import {
POSITION_BUFFER_SIZE,
POSITIONS_ACCOUNT_HEADER_SIZE,
} from "../constants";
} from "../constants.js";
import type { Staking } from "../types/staking.js";
import type {
Position,
PositionAnchor,
StakeAccountPositions,
TargetWithParameters,
} from "../types";
import { PositionState } from "../types";
} from "../types.js";
import { PositionState } from "../types.js";

export const getPositionState = (
position: Position,
2 changes: 1 addition & 1 deletion governance/pyth_staking_sdk/src/utils/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TransactionBuilder } from "@pythnetwork/solana-utils";
import { Connection, TransactionInstruction } from "@solana/web3.js";

import type { PythStakingWallet } from "./wallet";
import type { PythStakingWallet } from "./wallet.js";

export const sendTransaction = async (
instructions: TransactionInstruction[],
2 changes: 1 addition & 1 deletion governance/pyth_staking_sdk/src/utils/vesting.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UnlockSchedule, VestingSchedule } from "../types";
import type { UnlockSchedule, VestingSchedule } from "../types.js";

export const getUnlockSchedule = (options: {
pythTokenListTime: bigint;
16 changes: 1 addition & 15 deletions governance/pyth_staking_sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
{
"extends": "@cprussin/tsconfig/base.json",
"include": ["**/*.ts", "**/*.json"],
"exclude": ["node_modules", "dist"],
"compilerOptions": {
"outDir": "./dist",
"baseUrl": "./",
"noEmit": false,
"target": "ESNext",
"module": "CommonJS",
"moduleResolution": "Node",
"declaration": true,
"composite": true,
"declarationMap": true,
"esModuleInterop": true,
"verbatimModuleSyntax": false
}
"exclude": ["node_modules", "dist"]
}
3 changes: 0 additions & 3 deletions governance/xc_admin/packages/xc_admin_frontend/turbo.json
Original file line number Diff line number Diff line change
@@ -8,9 +8,6 @@
"NEXT_PUBLIC_MAINNET_RPC",
"NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID"
]
},
"start:dev": {
"dependsOn": ["//#install:modules", "pull:env", "^build"]
}
}
}
2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@
"cache": false
},
"start:dev": {
"dependsOn": ["//#install:modules", "pull:env"],
"dependsOn": ["//#install:modules", "pull:env", "^build"],
"persistent": true,
"cache": false
},