Skip to content

Commit d4d853d

Browse files
authored
Merge pull request #13 from macalinao/igm/metaplex-codama
Add Codama CLI and Metaplex Token Metadata program client
2 parents bbf9777 + 807fd89 commit d4d853d

File tree

157 files changed

+34861
-25
lines changed

Some content is hidden

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

157 files changed

+34861
-25
lines changed

biome.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"includes": [
7373
"**",
7474
"!**/bun.lock",
75-
"!apps/example-dapp/src/routeTree.gen.ts"
75+
"!apps/example-dapp/src/routeTree.gen.ts",
76+
"!packages/clients/*/src/generated/**"
7677
]
7778
},
7879
"assist": {

bun.lock

Lines changed: 113 additions & 23 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"workspaces": {
88
"packages": [
99
"packages/*",
10+
"packages/codama/*",
11+
"packages/clients/*",
1012
"apps/*"
1113
],
1214
"catalog": {
@@ -28,8 +30,9 @@
2830
},
2931
"scripts": {
3032
"build": "turbo build",
33+
"build:packages": "turbo build --filter='./packages/**'",
3134
"build:watch": "turbo watch build",
32-
"build:watch:packages": "turbo watch build --filter='./packages/*'",
35+
"build:watch:packages": "turbo watch build --filter='./packages/**'",
3336
"lint": "biome check && turbo run lint",
3437
"lint:fix": "biome check --write --no-errors-on-unmatched --unsafe && turbo run lint -- --fix",
3538
"clean": "turbo run clean",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# @macalinao/token-metadata-client
2+
3+
TypeScript client for the Metaplex Token Metadata program, generated using Codama with full ESM support.
4+
5+
## Installation
6+
7+
```bash
8+
bun add @macalinao/token-metadata-client
9+
```
10+
11+
## Development
12+
13+
This client is generated from the Token Metadata IDL using Codama CLI:
14+
15+
```bash
16+
# Generate the client from idls/token_metadata.json
17+
bun run codegen
18+
19+
# Build the TypeScript
20+
bun run build
21+
```
22+
23+
### Configuration
24+
25+
The `codama.config.mjs` file adds custom PDAs to the generated client, including the standard metadata PDA derivation.
26+
27+
## Usage
28+
29+
```typescript
30+
import { /* generated exports */ } from "@macalinao/token-metadata-client";
31+
32+
// Use the generated client functions
33+
```
34+
35+
## License
36+
37+
Apache-2.0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { defineConfig } from "@macalinao/codama-cli";
2+
import {
3+
addPdasVisitor,
4+
constantPdaSeedNodeFromString,
5+
publicKeyTypeNode,
6+
variablePdaSeedNode,
7+
} from "codama";
8+
9+
const addCustomPDAsVisitor = addPdasVisitor({
10+
tokenMetadata: [
11+
{
12+
name: "metadata",
13+
seeds: [
14+
constantPdaSeedNodeFromString("utf8", "metadata"),
15+
variablePdaSeedNode(
16+
"programId",
17+
publicKeyTypeNode(),
18+
"The address of the program",
19+
),
20+
variablePdaSeedNode(
21+
"mint",
22+
publicKeyTypeNode(),
23+
"The address of the mint account",
24+
),
25+
],
26+
},
27+
],
28+
});
29+
30+
export default defineConfig({
31+
visitors: [addCustomPDAsVisitor],
32+
});
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)