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
11 changes: 11 additions & 0 deletions .changeset/brave-flies-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@macalinao/clients-orca-whirlpools": patch
"@macalinao/clients-kamino-lending": patch
"@macalinao/clients-spl-governance": patch
"@macalinao/clients-spl-stake-pool": patch
"@macalinao/clients-token-metadata": patch
"@macalinao/clients-quarry": patch
"@macalinao/coda": patch
---

Update docs
22 changes: 20 additions & 2 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"@changesets/cli": "^2.29.7",
"@macalinao/biome-config": "^0.1.2",
"husky": "^9.1.7",
"lint-staged": "^16.2.3",
"lint-staged": "^16.2.4",
"turbo": "^2.5.8",
"typedoc": "^0.28.13",
"typedoc": "^0.28.14",
"typescript": "catalog:",
},
},
"apps/docs": {
Expand Down Expand Up @@ -99,6 +100,21 @@
"@solana/kit": "*",
},
},
"clients/spl-stake-pool": {
"name": "@macalinao/clients-spl-stake-pool",
"version": "0.1.0",
"devDependencies": {
"@macalinao/coda": "workspace:^",
"@macalinao/eslint-config": "catalog:",
"@macalinao/tsconfig": "catalog:",
"@solana/kit": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:",
},
"peerDependencies": {
"@solana/kit": "*",
},
},
"clients/token-metadata": {
"name": "@macalinao/clients-token-metadata",
"version": "0.4.2",
Expand Down Expand Up @@ -533,6 +549,8 @@

"@macalinao/clients-spl-governance": ["@macalinao/clients-spl-governance@workspace:clients/spl-governance"],

"@macalinao/clients-spl-stake-pool": ["@macalinao/clients-spl-stake-pool@workspace:clients/spl-stake-pool"],

"@macalinao/clients-token-metadata": ["@macalinao/clients-token-metadata@workspace:clients/token-metadata"],

"@macalinao/clients-voter-stake-registry": ["@macalinao/clients-voter-stake-registry@workspace:clients/voter-stake-registry"],
Expand Down
4 changes: 2 additions & 2 deletions clients/kamino-lending/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ npm install @macalinao/clients-kamino-lending

```typescript
import {
createInitializeInstruction,
getInitLendingMarketInstruction,
fetchLendingMarket,
// ... other exports
} from "@macalinao/clients-kamino-lending";
Expand All @@ -39,7 +39,7 @@ const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const lendingMarket = await fetchLendingMarket(rpc, marketAddress);

// Create instructions
const instruction = createInitializeInstruction({
const instruction = getInitLendingMarketInstruction({
// ... instruction parameters
});
```
Expand Down
15 changes: 12 additions & 3 deletions clients/orca-whirlpools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,18 @@ The `coda.config.mjs` file can be customized to add PDAs and other Codama visito
## Usage

```typescript
import {} from /* generated exports */ "@macalinao/clients-orca-whirlpools";

// Use the generated client functions
import {
getSwapInstruction,
fetchWhirlpool,
} from "@macalinao/clients-orca-whirlpools";

// Fetch whirlpool account
const whirlpool = await fetchWhirlpool(rpc, whirlpoolAddress);

// Create swap instruction
const instruction = getSwapInstruction({
// ... instruction parameters
});
```

## License
Expand Down
15 changes: 12 additions & 3 deletions clients/quarry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,18 @@ The `coda.config.mjs` file is configured to load all Quarry protocol IDLs and ge
## Usage

```typescript
import {} from /* generated exports */ "@macalinao/clients-quarry";

// Use the generated client functions for any Quarry program
import {
getCreateMinerInstruction,
fetchMiner,
} from "@macalinao/clients-quarry";

// Fetch miner account
const miner = await fetchMiner(rpc, minerAddress);

// Create miner instruction
const instruction = getCreateMinerInstruction({
// ... instruction parameters
});
```

## License
Expand Down
4 changes: 2 additions & 2 deletions clients/spl-governance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ The `coda.config.mjs` file defines custom PDAs for the SPL Governance program, i
## Usage

```typescript
import { createRealm, getRealmPda } from "@macalinao/clients-spl-governance";
import { getCreateRealmInstruction, findRealmPda } from "@macalinao/clients-spl-governance";

// Create a new realm
const realmPda = getRealmPda({ name: "my-dao" });
const realmPda = await findRealmPda({ name: "my-dao" });

// Use the generated client functions
```
Expand Down
61 changes: 61 additions & 0 deletions clients/spl-stake-pool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# @macalinao/clients-spl-stake-pool

[![npm version](https://img.shields.io/npm/v/@macalinao/clients-spl-stake-pool.svg)](https://www.npmjs.com/package/@macalinao/clients-spl-stake-pool)

TypeScript client for the SPL Stake Pool program, generated using Coda with full ESM support.

## Installation

```bash
bun add @macalinao/clients-spl-stake-pool
```

## Development

This client is generated from the SPL Stake Pool IDL using Coda CLI:

```bash
# Generate the client from idls/spl_stake_pool.json
bun run codegen

# Build the TypeScript
bun run build
```

### Configuration

The `coda.config.mjs` file defines custom PDAs for the SPL Stake Pool program, including:

- Withdraw authority for the stake pool
- Stake accounts for validators
- Stake accounts with custom seeds
- Transient stake accounts for delegation operations
- Ephemeral stake accounts for temporary operations

## Usage

```typescript
import {
findWithdrawAuthorityPda,
findStakePda
} from "@macalinao/clients-spl-stake-pool";

// Get withdraw authority PDA
const withdrawAuthorityPda = await findWithdrawAuthorityPda({
stakePool: stakePoolPublicKey
});

// Get stake account PDA
const stakePda = await findStakePda({
voteAccount: validatorVoteAccount,
stakePool: stakePoolPublicKey
});

// Use the generated client functions
```

## License

Copyright © 2025 Ian Macalinao

Licensed under the Apache License, Version 2.0
108 changes: 108 additions & 0 deletions clients/spl-stake-pool/coda.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import {
accountValueNode,
addPdasVisitor,
argumentValueNode,
constantPdaSeedNodeFromString,
defineConfig,
definedTypeLinkNode,
enumValueNode,
numberTypeNode,
pdaLinkNode,
pdaSeedValueNode,
pdaValueNode,
publicKeyTypeNode,
publicKeyValueNode,
remainderOptionTypeNode,
setAccountDiscriminatorFromFieldVisitor,
setInstructionAccountDefaultValuesVisitor,
variablePdaSeedNode,
} from "@macalinao/coda";

/** @type {import("@macalinao/coda").CodaConfig} */
export default defineConfig({
// Use glob pattern to match both IDL files
outputDir: "./src/generated",
docs: {
npmPackageName: "@macalinao/clients-spl-stake-pool",
},
visitors: [
setAccountDiscriminatorFromFieldVisitor({
// Realm accounts
stakePool: {
field: "accountType",
value: enumValueNode(definedTypeLinkNode("accountType"), "StakePool"),
},
validatorList: {
field: "accountType",
value: enumValueNode(
definedTypeLinkNode("accountType"),
"ValidatorList",
),
},
}),
addPdasVisitor({
splStakePool: [
{
name: "withdrawAuthority",
seeds: [
variablePdaSeedNode("stakePoolAddress", publicKeyTypeNode()),
constantPdaSeedNodeFromString("utf8", "withdraw"),
],
},
{
name: "stake",
seeds: [
variablePdaSeedNode("voteAccountAddress", publicKeyTypeNode()),
variablePdaSeedNode("stakePoolAddress", publicKeyTypeNode()),
variablePdaSeedNode(
"seed",
remainderOptionTypeNode(numberTypeNode("u32", "le")),
),
],
},
{
name: "transientStake",
seeds: [
constantPdaSeedNodeFromString("utf8", "transient"),
variablePdaSeedNode("voteAccountAddress", publicKeyTypeNode()),
variablePdaSeedNode("stakePoolAddress", publicKeyTypeNode()),
variablePdaSeedNode("seed", numberTypeNode("u64", "le")),
],
},
{
name: "ephemeralStake",
seeds: [
constantPdaSeedNodeFromString("utf8", "ephemeral"),
variablePdaSeedNode("stakePoolAddress", publicKeyTypeNode()),
variablePdaSeedNode("seed", numberTypeNode("u64", "le")),
],
},
],
}),
setInstructionAccountDefaultValuesVisitor([
{
account: "stakeProgram",
defaultValue: publicKeyValueNode(
"Stake11111111111111111111111111111111111111",
),
},
{
account: "withdrawAuthority",
defaultValue: pdaValueNode(pdaLinkNode("withdrawAuthority"), [
pdaSeedValueNode("stakePoolAddress", accountValueNode("stakePool")),
]),
},
{
account: "transientStakeAccount",
defaultValue: pdaValueNode(pdaLinkNode("transientStake"), [
pdaSeedValueNode(
"voteAccountAddress",
accountValueNode("validatorVoteAccount"),
),
pdaSeedValueNode("stakePoolAddress", accountValueNode("stakePool")),
pdaSeedValueNode("seed", argumentValueNode("transientStakeSeed")),
]),
},
]),
],
});
31 changes: 31 additions & 0 deletions clients/spl-stake-pool/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { configs } from "@macalinao/eslint-config";

export default [
...configs.fast,
{
languageOptions: {
parserOptions: {
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ["src/generated/**/*.ts"],
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
},
},
{
files: [
"src/generated/instructions/*.ts",
"src/generated/types/*.ts",
"src/generated/errors/*.ts",
],
rules: {
"@typescript-eslint/no-unnecessary-condition": "off",
"no-constant-condition": "off",
"@typescript-eslint/no-empty-object-type": "off",
},
},
];
Loading