Skip to content

Commit 2792167

Browse files
committed
Add Tribeca client
1 parent 5c7f059 commit 2792167

Some content is hidden

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

65 files changed

+10653
-0
lines changed

bun.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,21 @@
131131
"@solana/kit": "*",
132132
},
133133
},
134+
"clients/tribeca": {
135+
"name": "@macalinao/clients-tribeca",
136+
"version": "0.1.0",
137+
"devDependencies": {
138+
"@macalinao/coda": "workspace:^",
139+
"@macalinao/eslint-config": "catalog:",
140+
"@macalinao/tsconfig": "catalog:",
141+
"@solana/kit": "catalog:",
142+
"eslint": "catalog:",
143+
"typescript": "catalog:",
144+
},
145+
"peerDependencies": {
146+
"@solana/kit": "*",
147+
},
148+
},
134149
"clients/voter-stake-registry": {
135150
"name": "@macalinao/clients-voter-stake-registry",
136151
"version": "0.2.2",
@@ -587,6 +602,8 @@
587602

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

605+
"@macalinao/clients-tribeca": ["@macalinao/clients-tribeca@workspace:clients/tribeca"],
606+
590607
"@macalinao/clients-voter-stake-registry": ["@macalinao/clients-voter-stake-registry@workspace:clients/voter-stake-registry"],
591608

592609
"@macalinao/coda": ["@macalinao/coda@workspace:packages/coda"],

clients/orca-whirlpools/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"description": "TypeScript client for Orca Whirlpools program",
55
"type": "module",
66
"sideEffects": false,
7+
"author": "Ian Macalinao <[email protected]>",
8+
"homepage": "https://coda.ianm.com",
79
"license": "Apache-2.0",
810
"keywords": [
911
"coda",

clients/tribeca/.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Dependencies
2+
node_modules/
3+
.pnp
4+
.pnp.js
5+
6+
# Build output
7+
dist/
8+
*.tsbuildinfo
9+
10+
# Debug
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
.pnpm-debug.log*
15+
bun.lockb
16+
17+
# Environment
18+
.env
19+
.env.local
20+
.env.*.local
21+
22+
# IDE
23+
.vscode/
24+
.idea/
25+
*.swp
26+
*.swo
27+
.DS_Store
28+
29+
# Cache
30+
.turbo/
31+
.eslintcache

clients/tribeca/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# @macalinao/clients-tribeca
2+
3+
[![npm version](https://img.shields.io/npm/v/@macalinao/clients-tribeca.svg)](https://www.npmjs.com/package/@macalinao/clients-tribeca)
4+
5+
TypeScript client for Tribeca governance programs (Govern and Locked Voter), generated using Coda CLI with full ESM support.
6+
7+
## Installation
8+
9+
```bash
10+
bun add @macalinao/clients-tribeca
11+
```
12+
13+
## About Tribeca
14+
15+
Tribeca is a governance protocol on Solana that provides decentralized autonomous organization (DAO) functionality through two main programs:
16+
17+
- **Govern**: Core governance program for creating governors, proposals, and voting
18+
- **Locked Voter**: Vote escrow system for token-weighted governance with time-locked voting power
19+
20+
## Programs Included
21+
22+
### Govern Program
23+
- **Governor**: Manages proposals and voting parameters
24+
- **Proposal**: Individual governance proposals with metadata
25+
- **Vote**: Records individual voter decisions on proposals
26+
- **ProposalMeta**: Additional metadata for proposals
27+
28+
### Locked Voter Program
29+
- **Locker**: Manages vote escrows for a governance token
30+
- **Escrow**: Individual user's locked tokens and voting power
31+
- **Whitelist**: Programs authorized to interact with the locker
32+
33+
## Development
34+
35+
This client is generated from the Tribeca IDLs using Coda CLI:
36+
37+
```bash
38+
# Generate the client from idls/
39+
bun run codegen
40+
41+
# Build the TypeScript
42+
bun run build
43+
```
44+
45+
### Configuration
46+
47+
The `coda.config.mjs` file includes custom PDAs for both programs and links accounts to their corresponding PDA helpers.
48+
49+
## Usage
50+
51+
```typescript
52+
import {
53+
getCastVoteInstruction,
54+
fetchGovernor,
55+
fetchProposal,
56+
getCreateEscrowInstruction,
57+
fetchLocker,
58+
} from "@macalinao/clients-tribeca";
59+
60+
// Governance example
61+
const governor = await fetchGovernor(rpc, governorAddress);
62+
const proposal = await fetchProposal(rpc, proposalAddress);
63+
64+
const voteInstruction = getCastVoteInstruction({
65+
governor: governorAddress,
66+
proposal: proposalAddress,
67+
vote: voteAddress, // PDA automatically calculated
68+
voter: voterPublicKey,
69+
// ... other parameters
70+
});
71+
72+
// Locked voter example
73+
const locker = await fetchLocker(rpc, lockerAddress);
74+
75+
const escrowInstruction = getCreateEscrowInstruction({
76+
locker: lockerAddress,
77+
escrow: escrowAddress, // PDA automatically calculated
78+
authority: authorityPublicKey,
79+
// ... other parameters
80+
});
81+
```
82+
83+
## License
84+
85+
Copyright © 2025 Ian Macalinao
86+
87+
Licensed under the Apache License, Version 2.0

clients/tribeca/coda.config.mjs

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import {
2+
addPdasVisitor,
3+
constantPdaSeedNodeFromString,
4+
constantValueNode,
5+
defineConfig,
6+
numberTypeNode,
7+
pdaLinkNode,
8+
publicKeyTypeNode,
9+
SYSTEM_PROGRAM_VALUE_NODE,
10+
updateAccountsVisitor,
11+
variablePdaSeedNode,
12+
zeroableOptionTypeNode,
13+
} from "@macalinao/coda";
14+
15+
export default defineConfig({
16+
outputDir: "./src/generated",
17+
18+
// Add custom PDAs for Tribeca programs
19+
visitors: [
20+
addPdasVisitor({
21+
lockedVoter: [
22+
{
23+
name: "locker",
24+
docs: [
25+
"Locker account that manages vote escrows for a specific base",
26+
],
27+
seeds: [
28+
constantPdaSeedNodeFromString("utf8", "Locker"),
29+
variablePdaSeedNode("base", publicKeyTypeNode()),
30+
],
31+
},
32+
{
33+
name: "escrow",
34+
docs: ["Escrow account that holds locked tokens for a user"],
35+
seeds: [
36+
constantPdaSeedNodeFromString("utf8", "Escrow"),
37+
variablePdaSeedNode("locker", publicKeyTypeNode()),
38+
variablePdaSeedNode("authority", publicKeyTypeNode()),
39+
],
40+
},
41+
{
42+
name: "whitelist",
43+
docs: [
44+
"Whitelist entry for a program that can interact with the locker",
45+
],
46+
seeds: [
47+
constantPdaSeedNodeFromString("utf8", "LockerWhitelistEntry"),
48+
variablePdaSeedNode("locker", publicKeyTypeNode()),
49+
variablePdaSeedNode("programId", publicKeyTypeNode()),
50+
variablePdaSeedNode(
51+
"owner",
52+
zeroableOptionTypeNode(
53+
publicKeyTypeNode(),
54+
constantValueNode(
55+
publicKeyTypeNode(),
56+
SYSTEM_PROGRAM_VALUE_NODE,
57+
),
58+
),
59+
),
60+
],
61+
},
62+
],
63+
govern: [
64+
{
65+
name: "governor",
66+
docs: ["Governor account that manages proposals and voting"],
67+
seeds: [
68+
constantPdaSeedNodeFromString("utf8", "TribecaGovernor"),
69+
variablePdaSeedNode("base", publicKeyTypeNode()),
70+
],
71+
},
72+
{
73+
name: "proposal",
74+
docs: ["Proposal account for governance actions"],
75+
seeds: [
76+
constantPdaSeedNodeFromString("utf8", "TribecaProposal"),
77+
variablePdaSeedNode("governor", publicKeyTypeNode()),
78+
variablePdaSeedNode("index", numberTypeNode("u64")),
79+
],
80+
},
81+
{
82+
name: "vote",
83+
docs: ["Vote account representing a voter's decision on a proposal"],
84+
seeds: [
85+
constantPdaSeedNodeFromString("utf8", "TribecaVote"),
86+
variablePdaSeedNode("proposal", publicKeyTypeNode()),
87+
variablePdaSeedNode("voter", publicKeyTypeNode()),
88+
],
89+
},
90+
{
91+
name: "proposalMeta",
92+
docs: ["Proposal metadata account with additional information"],
93+
seeds: [
94+
constantPdaSeedNodeFromString("utf8", "TribecaProposalMeta"),
95+
variablePdaSeedNode("proposal", publicKeyTypeNode()),
96+
],
97+
},
98+
],
99+
}),
100+
updateAccountsVisitor({
101+
// lockedVoter accounts
102+
locker: {
103+
pda: pdaLinkNode("locker"),
104+
},
105+
escrow: {
106+
pda: pdaLinkNode("escrow"),
107+
},
108+
lockerWhitelistEntry: {
109+
pda: pdaLinkNode("whitelist"),
110+
},
111+
// govern accounts
112+
governor: {
113+
pda: pdaLinkNode("governor"),
114+
},
115+
proposal: {
116+
pda: pdaLinkNode("proposal"),
117+
},
118+
vote: {
119+
pda: pdaLinkNode("vote"),
120+
},
121+
proposalMeta: {
122+
pda: pdaLinkNode("proposalMeta"),
123+
},
124+
}),
125+
],
126+
});

clients/tribeca/eslint.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { configs } from "@macalinao/eslint-config";
2+
3+
export default [
4+
...configs.fast,
5+
{
6+
languageOptions: {
7+
parserOptions: {
8+
tsconfigRootDir: import.meta.dirname,
9+
},
10+
},
11+
},
12+
{
13+
files: ["src/generated/**/*.ts"],
14+
rules: {
15+
"@typescript-eslint/no-non-null-assertion": "off",
16+
"@typescript-eslint/prefer-nullish-coalescing": "off",
17+
},
18+
},
19+
{
20+
files: [
21+
"src/generated/instructions/*.ts",
22+
"src/generated/types/*.ts",
23+
"src/generated/errors/*.ts",
24+
],
25+
rules: {
26+
"@typescript-eslint/no-unnecessary-condition": "off",
27+
"no-constant-condition": "off",
28+
"@typescript-eslint/no-empty-object-type": "off",
29+
},
30+
},
31+
];

0 commit comments

Comments
 (0)