Skip to content

Commit 0c50a34

Browse files
authored
SDK v2 (#450)
- Remove old SDK (`@metadaoproject/futarchy`) and replace with `@metadaoproject/programs` - Move all tests and scripts to new SDK - Upgrade typescript to latest - Add a typecheck utility script to root
1 parent 2a3e80b commit 0c50a34

390 files changed

Lines changed: 2615 additions & 61067 deletions

File tree

Some content is hidden

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

CLAUDE.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ programs/ # Solana programs (Anchor)
4040
├── mint_governor/ # Delegated minting authority management
4141
└── damm_v2_cpi/ # Meteora AMM CPI wrapper
4242
43-
sdk/ # TypeScript client library
44-
├── src/v0.3/ - v0.7/ # Versioned SDKs (backward compatible)
43+
sdk/ # TypeScript client library (@metadaoproject/programs)
44+
├── src/<program>/ # One module per program (futarchy, launchpad, conditional_vault, ...)
45+
│ ├── v0.X/ # Each program is independently versioned
46+
│ └── index.ts # Re-exports the latest version
4547
└── package.json
4648
4749
tests/ # TypeScript tests (bankrun + mocha)
@@ -180,7 +182,7 @@ Always append new error variants to the **end** of `#[error_code]` enums. Anchor
180182

181183
### Adding New Instructions
182184
1. Add instruction to Rust program in `programs/[program]/src/instructions/`
183-
2. Update client methods in SDK (`sdk/src/v0.7/`)
185+
2. Update client methods in the corresponding SDK module at the program's current version (e.g. `sdk/src/futarchy/v0.6/`, `sdk/src/launchpad/v0.7/`)
184186
3. Add unit tests in `tests/[program]/unit/`
185187

186188
### Testing with Bankrun
@@ -249,17 +251,29 @@ When designing instructions that involve Squads CPIs, check whether either patte
249251

250252
## SDK Usage
251253

252-
```typescript
253-
// Import versioned clients
254-
import { FutarchyClient, ConditionalVaultClient } from "@metadaoproject/futarchy/v0.7";
254+
The SDK is published as `@metadaoproject/programs` and is organized **per program**, with each program independently versioned. There is no single SDK-wide version anymore — futarchy is at v0.6, launchpad is at v0.7, conditional_vault is at v0.4, etc.
255255

256-
// Key utilities in sdk/src/v0.7/
257-
// - constants.ts: Program IDs, MAINNET_USDC, SQUADS_PROGRAM_ID
258-
// - PDA derivation: getDaoAddr, getProposalAddr, etc.
259-
// - PriceMath.getAmmPrice for price calculations
256+
```typescript
257+
// Top-level imports resolve to the latest version of each program (preferred)
258+
import {
259+
FutarchyClient,
260+
LaunchpadClient,
261+
ConditionalVaultClient,
262+
MAINNET_USDC,
263+
} from "@metadaoproject/programs";
264+
265+
// Or import from a specific program module
266+
import { FutarchyClient } from "@metadaoproject/programs/futarchy";
267+
import { LaunchpadClient } from "@metadaoproject/programs/launchpad";
268+
269+
// Or pin to a specific version (only when reading historical accounts or
270+
// interacting with an older deployed program)
271+
import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6";
260272
```
261273

262-
**Important:** Always use SDK v0.7 imports (`@metadaoproject/futarchy/v0.7`) for new code. Do not use older SDK versions (v0.3-v0.6).
274+
Each program module exports a `Client` class (constructed via `Client.createClient({ provider })`), PDA helpers, and generated Anchor types. Shared utilities (`constants.ts`, top-level `pda.ts`, `AmmMath`) are exported from the package root.
275+
276+
**Important:** Always use top-level or per-program imports for new code. Only reach for a versioned subpath (e.g. `@metadaoproject/programs/futarchy/v0.6`) when you specifically need an older program version. See `sdk/README.md` for the full layout.
263277

264278
## Key External Dependencies
265279

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"scripts": {
55
"lint:fix": "prettier */*{.js,.ts} \"*/**/*{.js,.ts}\" -w",
66
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check",
7+
"typecheck": "tsc --noEmit",
78
"setup-metric-market": "tsx --tsconfig tsconfig.json scripts/setupMetricMarket.ts",
89
"launch-init": "NODE_OPTIONS=\"--no-deprecation\" tsx --tsconfig tsconfig.json scripts/launchInit.ts",
910
"launch-start": "NODE_OPTIONS=\"--no-deprecation\" tsx --tsconfig tsconfig.json scripts/launchStart.ts",
@@ -24,7 +25,7 @@
2425
"dependencies": {
2526
"@coral-xyz/anchor": "=0.29.0",
2627
"@inquirer/prompts": "^7.3.3",
27-
"@metadaoproject/futarchy": "./sdk",
28+
"@metadaoproject/programs": "./sdk",
2829
"@metaplex-foundation/mpl-token-metadata": "^3.2.0",
2930
"@metaplex-foundation/umi": "^0.9.1",
3031
"@metaplex-foundation/umi-bundle-defaults": "^0.9.1",
@@ -68,7 +69,7 @@
6869
"ts-mocha": "^10.0.0",
6970
"ts-node": "^10.9.2",
7071
"tsx": "^4.7.1",
71-
"typescript": "^4.3.5",
72+
"typescript": "5.9.3",
7273
"typescript-eslint": "^8.43.0"
7374
},
7475
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",

rebuild.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
set -e
44
anchor build
55
cd sdk
6+
yarn install
67
yarn build-local
78
cd ..
89
yarn install --force
910
yarn lint:fix
10-
echo "SDK types synced successfully"
11+
echo "rebuild complete"

scripts/setupFutarchyAmm.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
// @ts-nocheck
2+
// Legacy script
13
import * as anchor from "@coral-xyz/anchor";
2-
import { AutocratClient, getDaoAddr } from "@metadaoproject/futarchy/v0.6";
4+
import { AutocratClient, getDaoAddr } from "@metadaoproject/programs/v0.6";
35
import { Keypair, PublicKey } from "@solana/web3.js";
46
import BN from "bn.js";
57
import * as token from "@solana/spl-token";

scripts/v0.3/crankTwap.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as anchor from "@coral-xyz/anchor";
2-
import { AmmClient, AutocratClient } from "@metadaoproject/futarchy/v0.3";
2+
import { AmmClient } from "@metadaoproject/programs/amm/v0.3";
3+
import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.3";
34
import { PublicKey } from "@solana/web3.js";
45

56
const proposal1 = new PublicKey("Dssb1oTTqKjWJTe8QVrStFXxcMZfd7LTSpTRbuHuNdnW");

scripts/v0.3/finalizeProposal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as anchor from "@coral-xyz/anchor";
2-
import { AutocratClient } from "@metadaoproject/futarchy/v0.3";
2+
import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.3";
33

44
const { PublicKey } = anchor.web3;
55

scripts/v0.3/initializeDao.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as anchor from "@coral-xyz/anchor";
2-
import { AutocratClient } from "@metadaoproject/futarchy/v0.3";
2+
import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.3";
33
import {
44
DEAN_DEVNET,
55
DEVNET_DARK,

scripts/v0.3/initializeProposal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as anchor from "@coral-xyz/anchor";
22
import { MEMO_PROGRAM_ID } from "@solana/spl-memo";
33
import * as token from "@solana/spl-token";
44
import { LAMPORTS_PER_SOL } from "@solana/web3.js";
5-
import { AutocratClient } from "@metadaoproject/futarchy/v0.3";
5+
import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.3";
66

77
const { PublicKey } = anchor.web3;
88

scripts/v0.3/initializeVault.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
getVaultAddr,
99
getVaultFinalizeMintAddr,
1010
getVaultRevertMintAddr,
11-
} from "@metadaoproject/futarchy/v0.3";
11+
} from "@metadaoproject/programs/conditional_vault/v0.3";
1212

1313
const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey(
1414
"4nCk4qKJSJf8pzJadMnr9LubA6Y7Zw3EacsVqH1TwVXH",

scripts/v0.3/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @ts-nocheck
2+
// Legacy script
13
import * as anchor from "@coral-xyz/anchor";
24
import * as token from "@solana/spl-token";
35
const { BN, Program } = anchor;

0 commit comments

Comments
 (0)