Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 0 additions & 9 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ stop-test-validator:
pkill -f solana-test-validator

generate-clients:
pnpm generate:clients $(ARGS)
pnpm codama run --all $(ARGS)

generate-idl-%:
cargo run --manifest-path $(call make-path,$*)/Cargo.toml --features codama --bin generate-idl $(ARGS)
Expand Down
30 changes: 15 additions & 15 deletions clients/js/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module.exports = {
extends: ['@solana/eslint-config-solana'],
ignorePatterns: ['.eslintrc.cjs', 'tsup.config.ts', 'env-shim.ts'],
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
rules: {
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/sort-type-constituents': 'off',
'prefer-destructuring': 'off',
'simple-import-sort/imports': 'off',
'sort-keys-fix/sort-keys-fix': 'off',
'typescript-sort-keys/interface': 'off',
},
extends: ['@solana/eslint-config-solana'],
ignorePatterns: ['.eslintrc.cjs', 'tsup.config.ts', 'env-shim.ts'],
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
rules: {
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/sort-type-constituents': 'off',
'prefer-destructuring': 'off',
'simple-import-sort/imports': 'off',
'sort-keys-fix/sort-keys-fix': 'off',
'typescript-sort-keys/interface': 'off',
},
};
1 change: 1 addition & 0 deletions clients/js/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/generated/**
9 changes: 0 additions & 9 deletions clients/js/.prettierrc.json

This file was deleted.

123 changes: 61 additions & 62 deletions clients/js/package.json
Original file line number Diff line number Diff line change
@@ -1,66 +1,65 @@
{
"name": "@solana-program/stake",
"version": "0.5.0",
"description": "JavaScript client for the Stake program",
"sideEffects": false,
"module": "./dist/src/index.mjs",
"main": "./dist/src/index.js",
"types": "./dist/types/index.d.ts",
"type": "commonjs",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/src/index.mjs",
"require": "./dist/src/index.js"
}
},
"files": [
"./dist/src",
"./dist/types"
],
"scripts": {
"build": "rimraf dist && tsup && tsc -p ./tsconfig.declarations.json",
"build:docs": "typedoc",
"test": "ava",
"lint": "eslint --ext js,ts,tsx src",
"lint:fix": "eslint --fix --ext js,ts,tsx src",
"format": "prettier --check src test",
"format:fix": "prettier --write src test",
"prepublishOnly": "pnpm build"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"license": "MIT",
"peerDependencies": {
"@solana/kit": "^6.0"
},
"devDependencies": {
"@ava/typescript": "^6.0.0",
"@solana/eslint-config-solana": "^3.0.3",
"@solana/kit": "^6.0",
"@types/node": "^25",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"ava": "^6.1.3",
"eslint": "^8.57.0",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"tsup": "^8.1.2",
"typedoc": "^0.28.14",
"typescript": "^5.5.3"
},
"ava": {
"nodeArguments": [
"--no-warnings"
"name": "@solana-program/stake",
"version": "0.5.0",
"description": "JavaScript client for the Stake program",
"sideEffects": false,
"module": "./dist/src/index.mjs",
"main": "./dist/src/index.js",
"types": "./dist/types/index.d.ts",
"type": "commonjs",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/src/index.mjs",
"require": "./dist/src/index.js"
}
},
"files": [
"./dist/src",
"./dist/types"
],
"typescript": {
"compile": false,
"rewritePaths": {
"test/": "dist/test/"
}
"scripts": {
"build": "rimraf dist && tsup && tsc -p ./tsconfig.declarations.json",
"build:docs": "typedoc",
"test": "ava",
"lint": "eslint --ext js,ts,tsx src",
"lint:fix": "eslint --fix --ext js,ts,tsx src",
"format": "prettier --check src test",
"format:fix": "prettier --write src test",
"prepublishOnly": "pnpm build"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"license": "MIT",
"peerDependencies": {
"@solana/kit": "^6.0"
},
"devDependencies": {
"@ava/typescript": "^6.0.0",
"@solana/eslint-config-solana": "^3.0.3",
"@solana/kit": "^6.0",
"@types/node": "^25",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"ava": "^6.1.3",
"eslint": "^8.57.0",
"prettier": "^3.8.1",
"rimraf": "^6.0.1",
"tsup": "^8.1.2",
"typedoc": "^0.28.14",
"typescript": "^5.9.3"
},
"ava": {
"nodeArguments": [
"--no-warnings"
],
"typescript": {
"compile": false,
"rewritePaths": {
"test/": "dist/test/"
}
}
}
},
"packageManager": "pnpm@9.1.0"
}
12 changes: 6 additions & 6 deletions clients/js/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

129 changes: 54 additions & 75 deletions clients/js/src/generated/accounts/stakeStateAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,113 +7,92 @@
*/

import {
assertAccountExists,
assertAccountsExist,
combineCodec,
decodeAccount,
fetchEncodedAccount,
fetchEncodedAccounts,
getStructDecoder,
getStructEncoder,
type Account,
type Address,
type Codec,
type Decoder,
type EncodedAccount,
type Encoder,
type FetchAccountConfig,
type FetchAccountsConfig,
type MaybeAccount,
type MaybeEncodedAccount,
assertAccountExists,
assertAccountsExist,
combineCodec,
decodeAccount,
fetchEncodedAccount,
fetchEncodedAccounts,
getStructDecoder,
getStructEncoder,
type Account,
type Address,
type Codec,
type Decoder,
type EncodedAccount,
type Encoder,
type FetchAccountConfig,
type FetchAccountsConfig,
type MaybeAccount,
type MaybeEncodedAccount,
} from '@solana/kit';
import {
getStakeStateV2Decoder,
getStakeStateV2Encoder,
type StakeStateV2,
type StakeStateV2Args,
} from '../types';
import { getStakeStateV2Decoder, getStakeStateV2Encoder, type StakeStateV2, type StakeStateV2Args } from '../types';

export type StakeStateAccount = { state: StakeStateV2 };

export type StakeStateAccountArgs = { state: StakeStateV2Args };

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

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

export function getStakeStateAccountCodec(): Codec<
StakeStateAccountArgs,
StakeStateAccount
> {
return combineCodec(
getStakeStateAccountEncoder(),
getStakeStateAccountDecoder()
);
/** Gets the codec for {@link StakeStateAccount} account data. */
export function getStakeStateAccountCodec(): Codec<StakeStateAccountArgs, StakeStateAccount> {
return combineCodec(getStakeStateAccountEncoder(), getStakeStateAccountDecoder());
}

export function decodeStakeStateAccount<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress>
encodedAccount: EncodedAccount<TAddress>,
): Account<StakeStateAccount, TAddress>;
export function decodeStakeStateAccount<TAddress extends string = string>(
encodedAccount: MaybeEncodedAccount<TAddress>
encodedAccount: MaybeEncodedAccount<TAddress>,
): MaybeAccount<StakeStateAccount, TAddress>;
export function decodeStakeStateAccount<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>
):
| Account<StakeStateAccount, TAddress>
| MaybeAccount<StakeStateAccount, TAddress> {
return decodeAccount(
encodedAccount as MaybeEncodedAccount<TAddress>,
getStakeStateAccountDecoder()
);
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
): Account<StakeStateAccount, TAddress> | MaybeAccount<StakeStateAccount, TAddress> {
return decodeAccount(encodedAccount as MaybeEncodedAccount<TAddress>, getStakeStateAccountDecoder());
}

export async function fetchStakeStateAccount<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig,
): Promise<Account<StakeStateAccount, TAddress>> {
const maybeAccount = await fetchMaybeStakeStateAccount(rpc, address, config);
assertAccountExists(maybeAccount);
return maybeAccount;
const maybeAccount = await fetchMaybeStakeStateAccount(rpc, address, config);
assertAccountExists(maybeAccount);
return maybeAccount;
}

export async function fetchMaybeStakeStateAccount<
TAddress extends string = string,
>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig
export async function fetchMaybeStakeStateAccount<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig,
): Promise<MaybeAccount<StakeStateAccount, TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return decodeStakeStateAccount(maybeAccount);
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return decodeStakeStateAccount(maybeAccount);
}

export async function fetchAllStakeStateAccount(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig,
): Promise<Account<StakeStateAccount>[]> {
const maybeAccounts = await fetchAllMaybeStakeStateAccount(
rpc,
addresses,
config
);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
const maybeAccounts = await fetchAllMaybeStakeStateAccount(rpc, addresses, config);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}

export async function fetchAllMaybeStakeStateAccount(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig,
): Promise<MaybeAccount<StakeStateAccount>[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) =>
decodeStakeStateAccount(maybeAccount)
);
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map(maybeAccount => decodeStakeStateAccount(maybeAccount));
}
Loading
Loading