diff --git a/apps/api-reference/next.config.js b/apps/api-reference/next.config.js index cabdf177fd..c5e946757c 100644 --- a/apps/api-reference/next.config.js +++ b/apps/api-reference/next.config.js @@ -29,8 +29,6 @@ export default { return config; }, - transpilePackages: ["@pythnetwork/*"], - headers: () => [ { source: "/:path*", diff --git a/apps/insights/next.config.js b/apps/insights/next.config.js index f21dc69488..58ecfdcf9e 100644 --- a/apps/insights/next.config.js +++ b/apps/insights/next.config.js @@ -22,8 +22,6 @@ const config = { return config; }, - transpilePackages: ["@pythnetwork/*"], - headers: async () => [ { source: "/:path*", diff --git a/apps/insights/turbo.json b/apps/insights/turbo.json index 7e4dea08e5..1dc5300e29 100644 --- a/apps/insights/turbo.json +++ b/apps/insights/turbo.json @@ -14,13 +14,6 @@ "DISABLE_ACCESSIBILITY_REPORTING" ] }, - "start:dev": { - "dependsOn": [ - "//#install:modules", - "pull:env", - "@pythnetwork/solana-utils#build" - ] - }, "fix:lint": { "dependsOn": [ "//#install:modules", diff --git a/apps/staking/next.config.js b/apps/staking/next.config.js index 2388804a1b..f5b093b62c 100644 --- a/apps/staking/next.config.js +++ b/apps/staking/next.config.js @@ -22,8 +22,6 @@ export default { return config; }, - transpilePackages: ["@pythnetwork/*"], - headers: () => [ { source: "/:path*", diff --git a/apps/staking/turbo.json b/apps/staking/turbo.json index a01af66192..e2e8784b75 100644 --- a/apps/staking/turbo.json +++ b/apps/staking/turbo.json @@ -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" - ] } } } diff --git a/governance/pyth_staking_sdk/package.json b/governance/pyth_staking_sdk/package.json index eb05e4175e..76bf1a5364 100644 --- a/governance/pyth_staking_sdk/package.json +++ b/governance/pyth_staking_sdk/package.json @@ -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" diff --git a/governance/pyth_staking_sdk/scripts/update-package-json.mjs b/governance/pyth_staking_sdk/scripts/update-package-json.mjs deleted file mode 100644 index 6b9fd53c02..0000000000 --- a/governance/pyth_staking_sdk/scripts/update-package-json.mjs +++ /dev/null @@ -1,21 +0,0 @@ -import fs from "fs"; -import path from "path"; -import { fileURLToPath } from "url"; - -/** - * This script updates the package.json file in the dist directory after the TypeScript build. - * - * This ensures that the published package correctly references the compiled JavaScript - * instead of the TypeScript source files. - */ - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - -const distPackageJsonPath = path.join(__dirname, "..", "package.json"); - -const packageJson = JSON.parse(fs.readFileSync(distPackageJsonPath, "utf8")); - -packageJson.main = "dist/src/index.js"; -packageJson.types = "dist/src/index.d.ts"; - -fs.writeFileSync(distPackageJsonPath, JSON.stringify(packageJson, null, 2)); diff --git a/governance/pyth_staking_sdk/idl/integrity-pool.json b/governance/pyth_staking_sdk/src/idl/integrity-pool.json similarity index 100% rename from governance/pyth_staking_sdk/idl/integrity-pool.json rename to governance/pyth_staking_sdk/src/idl/integrity-pool.json diff --git a/governance/pyth_staking_sdk/idl/publisher-caps.json b/governance/pyth_staking_sdk/src/idl/publisher-caps.json similarity index 100% rename from governance/pyth_staking_sdk/idl/publisher-caps.json rename to governance/pyth_staking_sdk/src/idl/publisher-caps.json diff --git a/governance/pyth_staking_sdk/idl/stake-caps-parameters.json b/governance/pyth_staking_sdk/src/idl/stake-caps-parameters.json similarity index 100% rename from governance/pyth_staking_sdk/idl/stake-caps-parameters.json rename to governance/pyth_staking_sdk/src/idl/stake-caps-parameters.json diff --git a/governance/pyth_staking_sdk/idl/staking.json b/governance/pyth_staking_sdk/src/idl/staking.json similarity index 100% rename from governance/pyth_staking_sdk/idl/staking.json rename to governance/pyth_staking_sdk/src/idl/staking.json diff --git a/governance/pyth_staking_sdk/src/index.ts b/governance/pyth_staking_sdk/src/index.ts index 0606d1f3de..04421061ab 100644 --- a/governance/pyth_staking_sdk/src/index.ts +++ b/governance/pyth_staking_sdk/src/index.ts @@ -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"; diff --git a/governance/pyth_staking_sdk/src/pdas.ts b/governance/pyth_staking_sdk/src/pdas.ts index 518198d83a..e5a01acbde 100644 --- a/governance/pyth_staking_sdk/src/pdas.ts +++ b/governance/pyth_staking_sdk/src/pdas.ts @@ -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( diff --git a/governance/pyth_staking_sdk/src/pyth-staking-client.ts b/governance/pyth_staking_sdk/src/pyth-staking-client.ts index 1aad557839..8020279fb3 100644 --- a/governance/pyth_staking_sdk/src/pyth-staking-client.ts +++ b/governance/pyth_staking_sdk/src/pyth-staking-client.ts @@ -30,7 +30,10 @@ 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, @@ -38,7 +41,10 @@ import { 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; diff --git a/governance/pyth_staking_sdk/src/pythnet-client.ts b/governance/pyth_staking_sdk/src/pythnet-client.ts index ef704d7e0b..c1f418d175 100644 --- a/governance/pyth_staking_sdk/src/pythnet-client.ts +++ b/governance/pyth_staking_sdk/src/pythnet-client.ts @@ -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; diff --git a/governance/pyth_staking_sdk/src/types.ts b/governance/pyth_staking_sdk/src/types.ts index c102415332..234dbf2850 100644 --- a/governance/pyth_staking_sdk/src/types.ts +++ b/governance/pyth_staking_sdk/src/types.ts @@ -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 extends From diff --git a/governance/pyth_staking_sdk/types/integrity-pool.ts b/governance/pyth_staking_sdk/src/types/integrity-pool.ts similarity index 100% rename from governance/pyth_staking_sdk/types/integrity-pool.ts rename to governance/pyth_staking_sdk/src/types/integrity-pool.ts diff --git a/governance/pyth_staking_sdk/types/publisher-caps.ts b/governance/pyth_staking_sdk/src/types/publisher-caps.ts similarity index 100% rename from governance/pyth_staking_sdk/types/publisher-caps.ts rename to governance/pyth_staking_sdk/src/types/publisher-caps.ts diff --git a/governance/pyth_staking_sdk/types/stake-caps-parameters.ts b/governance/pyth_staking_sdk/src/types/stake-caps-parameters.ts similarity index 100% rename from governance/pyth_staking_sdk/types/stake-caps-parameters.ts rename to governance/pyth_staking_sdk/src/types/stake-caps-parameters.ts diff --git a/governance/pyth_staking_sdk/types/staking.ts b/governance/pyth_staking_sdk/src/types/staking.ts similarity index 100% rename from governance/pyth_staking_sdk/types/staking.ts rename to governance/pyth_staking_sdk/src/types/staking.ts diff --git a/governance/pyth_staking_sdk/src/utils/apy.ts b/governance/pyth_staking_sdk/src/utils/apy.ts index 539540559b..ed23aab35a 100644 --- a/governance/pyth_staking_sdk/src/utils/apy.ts +++ b/governance/pyth_staking_sdk/src/utils/apy.ts @@ -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; diff --git a/governance/pyth_staking_sdk/src/utils/bn.ts b/governance/pyth_staking_sdk/src/utils/bn.ts index 595b4941df..9191dec172 100644 --- a/governance/pyth_staking_sdk/src/utils/bn.ts +++ b/governance/pyth_staking_sdk/src/utils/bn.ts @@ -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 = (obj: T): ConvertBNToBigInt => { if (obj instanceof BN) { diff --git a/governance/pyth_staking_sdk/src/utils/clock.ts b/governance/pyth_staking_sdk/src/utils/clock.ts index 951f094301..6d5240f0e2 100644 --- a/governance/pyth_staking_sdk/src/utils/clock.ts +++ b/governance/pyth_staking_sdk/src/utils/clock.ts @@ -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"); diff --git a/governance/pyth_staking_sdk/src/utils/pool.ts b/governance/pyth_staking_sdk/src/utils/pool.ts index 9bc91b181c..1ad14388cb 100644 --- a/governance/pyth_staking_sdk/src/utils/pool.ts +++ b/governance/pyth_staking_sdk/src/utils/pool.ts @@ -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, diff --git a/governance/pyth_staking_sdk/src/utils/position.ts b/governance/pyth_staking_sdk/src/utils/position.ts index 95dc882598..ca13eb7b33 100644 --- a/governance/pyth_staking_sdk/src/utils/position.ts +++ b/governance/pyth_staking_sdk/src/utils/position.ts @@ -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, diff --git a/governance/pyth_staking_sdk/src/utils/transaction.ts b/governance/pyth_staking_sdk/src/utils/transaction.ts index 825055a886..f0d1fb7315 100644 --- a/governance/pyth_staking_sdk/src/utils/transaction.ts +++ b/governance/pyth_staking_sdk/src/utils/transaction.ts @@ -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[], diff --git a/governance/pyth_staking_sdk/src/utils/vesting.ts b/governance/pyth_staking_sdk/src/utils/vesting.ts index bfd2b5c66a..f9d1ffa317 100644 --- a/governance/pyth_staking_sdk/src/utils/vesting.ts +++ b/governance/pyth_staking_sdk/src/utils/vesting.ts @@ -1,4 +1,4 @@ -import type { UnlockSchedule, VestingSchedule } from "../types"; +import type { UnlockSchedule, VestingSchedule } from "../types.js"; export const getUnlockSchedule = (options: { pythTokenListTime: bigint; diff --git a/governance/pyth_staking_sdk/tsconfig.json b/governance/pyth_staking_sdk/tsconfig.json index 4ae721b71f..32a3705250 100644 --- a/governance/pyth_staking_sdk/tsconfig.json +++ b/governance/pyth_staking_sdk/tsconfig.json @@ -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"] } diff --git a/governance/xc_admin/packages/xc_admin_frontend/turbo.json b/governance/xc_admin/packages/xc_admin_frontend/turbo.json index b2a3d39221..467991d7af 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/turbo.json +++ b/governance/xc_admin/packages/xc_admin_frontend/turbo.json @@ -8,9 +8,6 @@ "NEXT_PUBLIC_MAINNET_RPC", "NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID" ] - }, - "start:dev": { - "dependsOn": ["//#install:modules", "pull:env", "^build"] } } } diff --git a/turbo.json b/turbo.json index fb7f7ce560..3a6d425209 100644 --- a/turbo.json +++ b/turbo.json @@ -133,7 +133,7 @@ "cache": false }, "start:dev": { - "dependsOn": ["//#install:modules", "pull:env"], + "dependsOn": ["//#install:modules", "pull:env", "^build"], "persistent": true, "cache": false },