Skip to content

Commit

Permalink
single-pool-js: redo packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed Nov 8, 2023
1 parent 6c83a84 commit ec88bb6
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 84 deletions.
22 changes: 12 additions & 10 deletions single-pool/js/packages/classic/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
"name": "@solana/single-pool-classic",
"version": "1.0.0",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
"exports": {
".": {
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
}
},
"scripts": {
"build": "pnpm tsc",
"build": "rm -fr dist/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./ts-fixup.sh",
"lint": "eslint --max-warnings 0 .",
"lint:fix": "eslint . --fix",
"test": "NODE_OPTIONS='--import=tsx' ava"
},
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/index.js"
"test": "sed -i '1s/.*/{ \"type\": \"module\",/' package.json && NODE_OPTIONS='--loader=tsx' ava ; sed -i '1s/.*/{/' package.json"
},
"devDependencies": {
"@types/node": "^20.9.0",
"@ava/typescript": "^4.1.0",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"ava": "^5.3.1",
Expand All @@ -32,7 +34,7 @@
},
"ava": {
"extensions": {
"ts": "commonjs"
"ts": "module"
},
"nodeArguments": [
"--import=tsx"
Expand Down
10 changes: 5 additions & 5 deletions single-pool/js/packages/classic/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Connection, PublicKey } from '@solana/web3.js';
import { getVoteAccountAddressForPool as getVoteModern } from '@solana/single-pool';

import { rpc } from './internal';
import { rpc } from './internal.js';

export * from './mpl_metadata';
export * from './addresses';
export * from './instructions';
export * from './transactions';
export * from './mpl_metadata.js';
export * from './addresses.js';
export * from './instructions.js';
export * from './transactions.js';

export async function getVoteAccountAddressForPool(connection: Connection, poolAddress: PublicKey) {
const voteAccountModern = await getVoteModern(rpc(connection), poolAddress.toBase58());
Expand Down
2 changes: 1 addition & 1 deletion single-pool/js/packages/classic/src/instructions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
import { SinglePoolInstruction as PoolInstructionModern } from '@solana/single-pool';

import { modernInstructionToLegacy } from './internal';
import { modernInstructionToLegacy } from './internal.js';

export class SinglePoolInstruction {
static async initializePool(voteAccount: PublicKey): Promise<TransactionInstruction> {
Expand Down
2 changes: 1 addition & 1 deletion single-pool/js/packages/classic/src/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PublicKey, Connection } from '@solana/web3.js';
import { SinglePoolProgram as PoolProgramModern } from '@solana/single-pool';

import { paramsToModern, modernTransactionToLegacy, rpc } from './internal';
import { paramsToModern, modernTransactionToLegacy, rpc } from './internal.js';

interface DepositParams {
connection: Connection;
Expand Down
1 change: 1 addition & 0 deletions single-pool/js/packages/classic/ts-fixup.sh
1 change: 1 addition & 0 deletions single-pool/js/packages/classic/tsconfig-base.json
1 change: 1 addition & 0 deletions single-pool/js/packages/classic/tsconfig-cjs.json
21 changes: 0 additions & 21 deletions single-pool/js/packages/classic/tsconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions single-pool/js/packages/classic/tsconfig.json
24 changes: 12 additions & 12 deletions single-pool/js/packages/modern/package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"name": "@solana/single-pool",
"version": "1.0.0",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
"exports": {
".": {
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
}
},
"scripts": {
"build": "pnpm tsc",
"build": "rm -fr dist/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./ts-fixup.sh",
"lint": "eslint --max-warnings 0 .",
"lint:fix": "eslint . --fix",
"test": "NODE_OPTIONS='--loader=tsx' ava"
},
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/index.js"
"lint:fix": "eslint . --fix"
},
"devDependencies": {
"@types/node": "^20.9.0",
"@ava/typescript": "^4.1.0",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"ava": "^5.3.1",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"solana-bankrun": "^0.2.0",
"ts-node": "^10.9.1",
"tsx": "^3.12.7",
"typescript": "^5.2.2"
Expand All @@ -34,7 +34,7 @@
"ts": "module"
},
"nodeArguments": [
"--loader=tsx"
"--import=tsx"
]
}
}
4 changes: 2 additions & 2 deletions single-pool/js/packages/modern/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
createAddressWithSeed,
} from '@solana/web3.js';

import { MPL_METADATA_PROGRAM_ID } from './internal';
import { STAKE_PROGRAM_ID } from './quarantine';
import { MPL_METADATA_PROGRAM_ID } from './internal.js';
import { STAKE_PROGRAM_ID } from './quarantine.js';

export const SINGLE_POOL_PROGRAM_ID = address('SVSPxpvHdN29nkVg9rPapPNDddN5DipNLRUFhyjFThE');

Expand Down
8 changes: 4 additions & 4 deletions single-pool/js/packages/modern/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getAddressCodec } from '@solana/web3.js';

import { PoolAddress, VoteAccountAddress } from './addresses';
import { PoolAddress, VoteAccountAddress } from './addresses.js';

export * from './addresses';
export * from './instructions';
export * from './transactions';
export * from './addresses.js';
export * from './instructions.js';
export * from './transactions.js';

export async function getVoteAccountAddressForPool(
rpc: any, // XXX not exported: Rpc<GetAccountInfoApi>,
Expand Down
6 changes: 3 additions & 3 deletions single-pool/js/packages/modern/src/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import {
findPoolMintAuthorityAddress,
findPoolStakeAuthorityAddress,
SINGLE_POOL_PROGRAM_ID,
} from './addresses';
import { MPL_METADATA_PROGRAM_ID } from './internal';
} from './addresses.js';
import { MPL_METADATA_PROGRAM_ID } from './internal.js';
import {
SYSTEM_PROGRAM_ID,
SYSVAR_RENT_ID,
Expand All @@ -39,7 +39,7 @@ import {
TOKEN_PROGRAM_ID,
u32,
u64,
} from './quarantine';
} from './quarantine.js';

type InitializePoolInstruction = IInstruction<typeof SINGLE_POOL_PROGRAM_ID> &
IInstructionWithAccounts<
Expand Down
6 changes: 3 additions & 3 deletions single-pool/js/packages/modern/src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import {
findPoolMintAuthorityAddress,
findPoolStakeAuthorityAddress,
SINGLE_POOL_PROGRAM_ID,
} from './addresses';
} from './addresses.js';
import {
initializePoolInstruction,
reactivatePoolStakeInstruction,
depositStakeInstruction,
withdrawStakeInstruction,
createTokenMetadataInstruction,
updateTokenMetadataInstruction,
} from './instructions';
} from './instructions.js';
import {
STAKE_PROGRAM_ID,
STAKE_ACCOUNT_SIZE,
Expand All @@ -34,7 +34,7 @@ import {
TokenInstruction,
StakeAuthorizationType,
getAssociatedTokenAddress,
} from './quarantine';
} from './quarantine.js';

interface DepositParams {
rpc: any; // XXX Rpc<???>
Expand Down
1 change: 1 addition & 0 deletions single-pool/js/packages/modern/ts-fixup.sh
1 change: 1 addition & 0 deletions single-pool/js/packages/modern/tsconfig-base.json
1 change: 1 addition & 0 deletions single-pool/js/packages/modern/tsconfig-cjs.json
22 changes: 0 additions & 22 deletions single-pool/js/packages/modern/tsconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions single-pool/js/packages/modern/tsconfig.json
11 changes: 11 additions & 0 deletions single-pool/js/ts-fixup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs"
}
!EOF

cat >dist/mjs/package.json <<!EOF
{
"type": "module"
}
!EOF
25 changes: 25 additions & 0 deletions single-pool/js/tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "src",
"declaration": true,
"esModuleInterop": true,
"inlineSourceMap": false,
"lib": ["esnext"],
"listEmittedFiles": false,
"listFiles": false,
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"pretty": true,
"resolveJsonModule": true,
"rootDir": "src",
"skipLibCheck": true,
"strict": true,
"traceResolution": false,
"types": ["node", "ava"]
},
"compileOnSave": false,
"exclude": ["node_modules", "dist"],
"include": ["src"]
}
8 changes: 8 additions & 0 deletions single-pool/js/tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "es2020"
}
}
8 changes: 8 additions & 0 deletions single-pool/js/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist/mjs",
"target": "esnext"
}
}

0 comments on commit ec88bb6

Please sign in to comment.