Skip to content

Commit ef36b0b

Browse files
authored
Codama IDL generation (#198)
* Codama IDL + clients generation * Specify toolchain in make generate-clients * Delete generated clients * Fix account naming * Use codama-cli
1 parent a66990a commit ef36b0b

File tree

9 files changed

+633
-3
lines changed

9 files changed

+633
-3
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ env:
1010
SBPF_PROGRAM_PACKAGES: "['program', 'pinocchio-program']"
1111
RUST_PACKAGES: "['interface', 'program', 'mollusk_harness', 'pinocchio-interface', 'pinocchio-program']"
1212
WASM_PACKAGES: "['interface', 'program']"
13+
IDL_PACKAGES: "['pinocchio-interface']"
1314
MIRI_PACKAGES: "['pinocchio-program']"
1415

1516
jobs:
@@ -20,6 +21,7 @@ jobs:
2021
SBPF_PROGRAM_PACKAGES: ${{ steps.compute.outputs.SBPF_PROGRAM_PACKAGES }}
2122
RUST_PACKAGES: ${{ steps.compute.outputs.RUST_PACKAGES }}
2223
WASM_PACKAGES: ${{ steps.compute.outputs.WASM_PACKAGES }}
24+
IDL_PACKAGES: ${{ steps.compute.outputs.IDL_PACKAGES }}
2325
MIRI_PACKAGES: ${{ steps.compute.outputs.MIRI_PACKAGES }}
2426
RUST_TOOLCHAIN_NIGHTLY: ${{ steps.compute.outputs.RUST_TOOLCHAIN_NIGHTLY }}
2527
SOLANA_CLI_VERSION: ${{ steps.compute.outputs.SOLANA_CLI_VERSION }}
@@ -34,6 +36,7 @@ jobs:
3436
echo "SBPF_PROGRAM_PACKAGES=${{ env.SBPF_PROGRAM_PACKAGES }}" >> $GITHUB_OUTPUT
3537
echo "RUST_PACKAGES=${{ env.RUST_PACKAGES }}" >> $GITHUB_OUTPUT
3638
echo "WASM_PACKAGES=${{ env.WASM_PACKAGES }}" >> $GITHUB_OUTPUT
39+
echo "IDL_PACKAGES=${{ env.IDL_PACKAGES }}" >> $GITHUB_OUTPUT
3740
echo "MIRI_PACKAGES=${{ env.MIRI_PACKAGES }}" >> $GITHUB_OUTPUT
3841
echo "RUST_TOOLCHAIN_NIGHTLY=$(make rust-toolchain-nightly)" >> "$GITHUB_OUTPUT"
3942
echo "SOLANA_CLI_VERSION=$(make solana-cli-version)" >> "$GITHUB_OUTPUT"
@@ -45,6 +48,7 @@ jobs:
4548
sbpf-program-packages: ${{ needs.set_env.outputs.SBPF_PROGRAM_PACKAGES }}
4649
rust-packages: ${{ needs.set_env.outputs.RUST_PACKAGES }}
4750
wasm-packages: ${{ needs.set_env.outputs.WASM_PACKAGES }}
51+
idl-packages: ${{ needs.set_env.outputs.IDL_PACKAGES }}
4852
rustfmt-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }}
4953
clippy-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }}
5054
solana-cli-version: ${{ needs.set_env.outputs.SOLANA_CLI_VERSION }}

Cargo.lock

Lines changed: 238 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ cargo-nightly:
2323
generate-clients:
2424
@echo "No JavaScript clients to generate"
2525

26+
generate-idl-%:
27+
@cargo install --locked --version =0.7.3 codama-cli
28+
codama-rs generate-idl $(call make-path,$*) -o $(call make-path,$*)/idl.json --pretty $(ARGS)
29+
2630
audit:
2731
cargo audit \
2832
--ignore RUSTSEC-2022-0093 \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# associated-token-account
2-
The SPL Associated Token Account program and its clients
2+
The SPL Associated Token Account program

pinocchio/interface/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ edition = "2021"
1010
[lib]
1111
crate-type = ["rlib"]
1212

13+
[features]
14+
codama = ["dep:codama", "dep:codama-macros"]
15+
1316
[dependencies]
17+
codama = { version = "0.7.3", optional = true }
18+
codama-macros = { version = "0.7.3", optional = true }
1419
solana-address = { version = "2.2.0", features = ["decode"] }
1520

1621
[package.metadata.solana]

pinocchio/interface/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
# `pinocchio-associated-token-account-interface`
22

33
Pinocchio instructions and types for interacting with the Associated Token Account program.
4+
5+
## Codama
6+
7+
This crate includes Codama macros.
8+
9+
Generate the IDL from repo root:
10+
11+
```bash
12+
make generate-idl-pinocchio-interface
13+
```
14+
15+
This writes:
16+
17+
```text
18+
pinocchio/interface/idl.json
19+
```

0 commit comments

Comments
 (0)