Skip to content

Commit b3137ae

Browse files
authored
Bump JS client to Kit v6 (#259)
1 parent ac65294 commit b3137ae

51 files changed

Lines changed: 3674 additions & 4826 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.prettierrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ stop-test-validator:
8282
pkill -f solana-test-validator
8383

8484
generate-clients:
85-
pnpm generate:clients $(ARGS)
85+
pnpm codama run --all $(ARGS)
8686

8787
generate-idl-%:
8888
cargo run --manifest-path $(call make-path,$*)/Cargo.toml --features codama --bin generate-idl $(ARGS)

clients/js/.eslintrc.cjs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
module.exports = {
2-
extends: ['@solana/eslint-config-solana'],
3-
ignorePatterns: ['.eslintrc.cjs', 'tsup.config.ts', 'env-shim.ts'],
4-
parserOptions: {
5-
project: 'tsconfig.json',
6-
tsconfigRootDir: __dirname,
7-
sourceType: 'module',
8-
},
9-
rules: {
10-
'@typescript-eslint/ban-types': 'off',
11-
'@typescript-eslint/sort-type-constituents': 'off',
12-
'prefer-destructuring': 'off',
13-
'simple-import-sort/imports': 'off',
14-
'sort-keys-fix/sort-keys-fix': 'off',
15-
'typescript-sort-keys/interface': 'off',
16-
},
2+
extends: ['@solana/eslint-config-solana'],
3+
ignorePatterns: ['.eslintrc.cjs', 'tsup.config.ts', 'env-shim.ts'],
4+
parserOptions: {
5+
project: 'tsconfig.json',
6+
tsconfigRootDir: __dirname,
7+
sourceType: 'module',
8+
},
9+
rules: {
10+
'@typescript-eslint/ban-types': 'off',
11+
'@typescript-eslint/sort-type-constituents': 'off',
12+
'prefer-destructuring': 'off',
13+
'simple-import-sort/imports': 'off',
14+
'sort-keys-fix/sort-keys-fix': 'off',
15+
'typescript-sort-keys/interface': 'off',
16+
},
1717
};

clients/js/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/generated/**

clients/js/.prettierrc.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

clients/js/package.json

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,65 @@
11
{
2-
"name": "@solana-program/stake",
3-
"version": "0.5.0",
4-
"description": "JavaScript client for the Stake program",
5-
"sideEffects": false,
6-
"module": "./dist/src/index.mjs",
7-
"main": "./dist/src/index.js",
8-
"types": "./dist/types/index.d.ts",
9-
"type": "commonjs",
10-
"exports": {
11-
".": {
12-
"types": "./dist/types/index.d.ts",
13-
"import": "./dist/src/index.mjs",
14-
"require": "./dist/src/index.js"
15-
}
16-
},
17-
"files": [
18-
"./dist/src",
19-
"./dist/types"
20-
],
21-
"scripts": {
22-
"build": "rimraf dist && tsup && tsc -p ./tsconfig.declarations.json",
23-
"build:docs": "typedoc",
24-
"test": "ava",
25-
"lint": "eslint --ext js,ts,tsx src",
26-
"lint:fix": "eslint --fix --ext js,ts,tsx src",
27-
"format": "prettier --check src test",
28-
"format:fix": "prettier --write src test",
29-
"prepublishOnly": "pnpm build"
30-
},
31-
"publishConfig": {
32-
"access": "public",
33-
"registry": "https://registry.npmjs.org"
34-
},
35-
"license": "MIT",
36-
"peerDependencies": {
37-
"@solana/kit": "^6.0"
38-
},
39-
"devDependencies": {
40-
"@ava/typescript": "^6.0.0",
41-
"@solana/eslint-config-solana": "^3.0.3",
42-
"@solana/kit": "^6.0",
43-
"@types/node": "^25",
44-
"@typescript-eslint/eslint-plugin": "^7.16.1",
45-
"@typescript-eslint/parser": "^7.16.1",
46-
"ava": "^6.1.3",
47-
"eslint": "^8.57.0",
48-
"prettier": "^3.3.3",
49-
"rimraf": "^6.0.1",
50-
"tsup": "^8.1.2",
51-
"typedoc": "^0.28.14",
52-
"typescript": "^5.5.3"
53-
},
54-
"ava": {
55-
"nodeArguments": [
56-
"--no-warnings"
2+
"name": "@solana-program/stake",
3+
"version": "0.5.0",
4+
"description": "JavaScript client for the Stake program",
5+
"sideEffects": false,
6+
"module": "./dist/src/index.mjs",
7+
"main": "./dist/src/index.js",
8+
"types": "./dist/types/index.d.ts",
9+
"type": "commonjs",
10+
"exports": {
11+
".": {
12+
"types": "./dist/types/index.d.ts",
13+
"import": "./dist/src/index.mjs",
14+
"require": "./dist/src/index.js"
15+
}
16+
},
17+
"files": [
18+
"./dist/src",
19+
"./dist/types"
5720
],
58-
"typescript": {
59-
"compile": false,
60-
"rewritePaths": {
61-
"test/": "dist/test/"
62-
}
21+
"scripts": {
22+
"build": "rimraf dist && tsup && tsc -p ./tsconfig.declarations.json",
23+
"build:docs": "typedoc",
24+
"test": "ava",
25+
"lint": "eslint --ext js,ts,tsx src",
26+
"lint:fix": "eslint --fix --ext js,ts,tsx src",
27+
"format": "prettier --check src test",
28+
"format:fix": "prettier --write src test",
29+
"prepublishOnly": "pnpm build"
30+
},
31+
"publishConfig": {
32+
"access": "public",
33+
"registry": "https://registry.npmjs.org"
34+
},
35+
"license": "MIT",
36+
"peerDependencies": {
37+
"@solana/kit": "^6.0"
38+
},
39+
"devDependencies": {
40+
"@ava/typescript": "^6.0.0",
41+
"@solana/eslint-config-solana": "^3.0.3",
42+
"@solana/kit": "^6.0",
43+
"@types/node": "^25",
44+
"@typescript-eslint/eslint-plugin": "^7.16.1",
45+
"@typescript-eslint/parser": "^7.16.1",
46+
"ava": "^6.1.3",
47+
"eslint": "^8.57.0",
48+
"prettier": "^3.8.1",
49+
"rimraf": "^6.0.1",
50+
"tsup": "^8.1.2",
51+
"typedoc": "^0.28.14",
52+
"typescript": "^5.9.3"
53+
},
54+
"ava": {
55+
"nodeArguments": [
56+
"--no-warnings"
57+
],
58+
"typescript": {
59+
"compile": false,
60+
"rewritePaths": {
61+
"test/": "dist/test/"
62+
}
63+
}
6364
}
64-
},
65-
"packageManager": "pnpm@9.1.0"
6665
}

clients/js/pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/js/src/generated/accounts/stakeStateAccount.ts

Lines changed: 54 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -7,113 +7,92 @@
77
*/
88

99
import {
10-
assertAccountExists,
11-
assertAccountsExist,
12-
combineCodec,
13-
decodeAccount,
14-
fetchEncodedAccount,
15-
fetchEncodedAccounts,
16-
getStructDecoder,
17-
getStructEncoder,
18-
type Account,
19-
type Address,
20-
type Codec,
21-
type Decoder,
22-
type EncodedAccount,
23-
type Encoder,
24-
type FetchAccountConfig,
25-
type FetchAccountsConfig,
26-
type MaybeAccount,
27-
type MaybeEncodedAccount,
10+
assertAccountExists,
11+
assertAccountsExist,
12+
combineCodec,
13+
decodeAccount,
14+
fetchEncodedAccount,
15+
fetchEncodedAccounts,
16+
getStructDecoder,
17+
getStructEncoder,
18+
type Account,
19+
type Address,
20+
type Codec,
21+
type Decoder,
22+
type EncodedAccount,
23+
type Encoder,
24+
type FetchAccountConfig,
25+
type FetchAccountsConfig,
26+
type MaybeAccount,
27+
type MaybeEncodedAccount,
2828
} from '@solana/kit';
29-
import {
30-
getStakeStateV2Decoder,
31-
getStakeStateV2Encoder,
32-
type StakeStateV2,
33-
type StakeStateV2Args,
34-
} from '../types';
29+
import { getStakeStateV2Decoder, getStakeStateV2Encoder, type StakeStateV2, type StakeStateV2Args } from '../types';
3530

3631
export type StakeStateAccount = { state: StakeStateV2 };
3732

3833
export type StakeStateAccountArgs = { state: StakeStateV2Args };
3934

35+
/** Gets the encoder for {@link StakeStateAccountArgs} account data. */
4036
export function getStakeStateAccountEncoder(): Encoder<StakeStateAccountArgs> {
41-
return getStructEncoder([['state', getStakeStateV2Encoder()]]);
37+
return getStructEncoder([['state', getStakeStateV2Encoder()]]);
4238
}
4339

40+
/** Gets the decoder for {@link StakeStateAccount} account data. */
4441
export function getStakeStateAccountDecoder(): Decoder<StakeStateAccount> {
45-
return getStructDecoder([['state', getStakeStateV2Decoder()]]);
42+
return getStructDecoder([['state', getStakeStateV2Decoder()]]);
4643
}
4744

48-
export function getStakeStateAccountCodec(): Codec<
49-
StakeStateAccountArgs,
50-
StakeStateAccount
51-
> {
52-
return combineCodec(
53-
getStakeStateAccountEncoder(),
54-
getStakeStateAccountDecoder()
55-
);
45+
/** Gets the codec for {@link StakeStateAccount} account data. */
46+
export function getStakeStateAccountCodec(): Codec<StakeStateAccountArgs, StakeStateAccount> {
47+
return combineCodec(getStakeStateAccountEncoder(), getStakeStateAccountDecoder());
5648
}
5749

5850
export function decodeStakeStateAccount<TAddress extends string = string>(
59-
encodedAccount: EncodedAccount<TAddress>
51+
encodedAccount: EncodedAccount<TAddress>,
6052
): Account<StakeStateAccount, TAddress>;
6153
export function decodeStakeStateAccount<TAddress extends string = string>(
62-
encodedAccount: MaybeEncodedAccount<TAddress>
54+
encodedAccount: MaybeEncodedAccount<TAddress>,
6355
): MaybeAccount<StakeStateAccount, TAddress>;
6456
export function decodeStakeStateAccount<TAddress extends string = string>(
65-
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>
66-
):
67-
| Account<StakeStateAccount, TAddress>
68-
| MaybeAccount<StakeStateAccount, TAddress> {
69-
return decodeAccount(
70-
encodedAccount as MaybeEncodedAccount<TAddress>,
71-
getStakeStateAccountDecoder()
72-
);
57+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
58+
): Account<StakeStateAccount, TAddress> | MaybeAccount<StakeStateAccount, TAddress> {
59+
return decodeAccount(encodedAccount as MaybeEncodedAccount<TAddress>, getStakeStateAccountDecoder());
7360
}
7461

7562
export async function fetchStakeStateAccount<TAddress extends string = string>(
76-
rpc: Parameters<typeof fetchEncodedAccount>[0],
77-
address: Address<TAddress>,
78-
config?: FetchAccountConfig
63+
rpc: Parameters<typeof fetchEncodedAccount>[0],
64+
address: Address<TAddress>,
65+
config?: FetchAccountConfig,
7966
): Promise<Account<StakeStateAccount, TAddress>> {
80-
const maybeAccount = await fetchMaybeStakeStateAccount(rpc, address, config);
81-
assertAccountExists(maybeAccount);
82-
return maybeAccount;
67+
const maybeAccount = await fetchMaybeStakeStateAccount(rpc, address, config);
68+
assertAccountExists(maybeAccount);
69+
return maybeAccount;
8370
}
8471

85-
export async function fetchMaybeStakeStateAccount<
86-
TAddress extends string = string,
87-
>(
88-
rpc: Parameters<typeof fetchEncodedAccount>[0],
89-
address: Address<TAddress>,
90-
config?: FetchAccountConfig
72+
export async function fetchMaybeStakeStateAccount<TAddress extends string = string>(
73+
rpc: Parameters<typeof fetchEncodedAccount>[0],
74+
address: Address<TAddress>,
75+
config?: FetchAccountConfig,
9176
): Promise<MaybeAccount<StakeStateAccount, TAddress>> {
92-
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
93-
return decodeStakeStateAccount(maybeAccount);
77+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
78+
return decodeStakeStateAccount(maybeAccount);
9479
}
9580

9681
export async function fetchAllStakeStateAccount(
97-
rpc: Parameters<typeof fetchEncodedAccounts>[0],
98-
addresses: Array<Address>,
99-
config?: FetchAccountsConfig
82+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
83+
addresses: Array<Address>,
84+
config?: FetchAccountsConfig,
10085
): Promise<Account<StakeStateAccount>[]> {
101-
const maybeAccounts = await fetchAllMaybeStakeStateAccount(
102-
rpc,
103-
addresses,
104-
config
105-
);
106-
assertAccountsExist(maybeAccounts);
107-
return maybeAccounts;
86+
const maybeAccounts = await fetchAllMaybeStakeStateAccount(rpc, addresses, config);
87+
assertAccountsExist(maybeAccounts);
88+
return maybeAccounts;
10889
}
10990

11091
export async function fetchAllMaybeStakeStateAccount(
111-
rpc: Parameters<typeof fetchEncodedAccounts>[0],
112-
addresses: Array<Address>,
113-
config?: FetchAccountsConfig
92+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
93+
addresses: Array<Address>,
94+
config?: FetchAccountsConfig,
11495
): Promise<MaybeAccount<StakeStateAccount>[]> {
115-
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
116-
return maybeAccounts.map((maybeAccount) =>
117-
decodeStakeStateAccount(maybeAccount)
118-
);
96+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
97+
return maybeAccounts.map(maybeAccount => decodeStakeStateAccount(maybeAccount));
11998
}

0 commit comments

Comments
 (0)