Skip to content

Commit 113e42d

Browse files
committed
add example for kamino farms
1 parent d1061cc commit 113e42d

File tree

7 files changed

+1924
-2
lines changed

7 files changed

+1924
-2
lines changed

Cargo.lock

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

crates/anchor-gen/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,30 @@
22

33
Generates a crate for cross-program invocations to an Anchor program from a JSON IDL.
44

5+
[![Crates.io](https://img.shields.io/crates/v/anchor-gen)](https://crates.io/crates/anchor-gen) [![License](https://img.shields.io/crates/l/anchor-gen)](https://github.com/saber-hq/anchor-gen/blob/master/LICENSE.txt) [![Build Status](https://img.shields.io/github/workflow/status/saber-hq/anchor-gen/Rust/master)](https://github.com/saber-hq/anchor-gen/actions/workflows/rust.yml?query=branch%3Amaster) [![Contributors](https://img.shields.io/github/contributors/saber-hq/anchor-gen)](https://github.com/saber-hq/anchor-gen/graphs/contributors) [![Code Coverage](https://img.shields.io/codecov/c/github/saber-hq/anchor-gen)](https://app.codecov.io/gh/saber-hq/anchor-gen)
6+
57
Now updated for Anchor 0.31.1!
68

9+
**Warning: this code has not been audited. Please use it at your own risk.**
10+
711
## Usage
812

9-
In a new crate, write:
13+
First, add the following to a `Cargo.toml` file in a new crate:
14+
15+
```toml
16+
[dependencies]
17+
anchor-gen = "0.31.1"
18+
```
19+
20+
Then, in `lib.rs`, write:
1021

1122
```skip
1223
anchor_gen::generate_cpi_crate!("../../examples/govern-cpi/idl.json");
1324
```
1425

1526
This will generate a fully functional Rust CPI client for your IDL.
1627

17-
More examples can be found in the [examples/](https://github.com/saber-hq/anchor-gen/tree/master/examples) directory.
28+
Usage examples can be found in the [examples/](https://github.com/saber-hq/anchor-gen/tree/master/examples) directory.
1829

1930
Note: This does not work on legacy IDLs. To migrate a legacy IDL, use `anchor idl convert idl.json`.
2031

crates/anchor-gen/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Generates a crate for cross-program invocations to an Anchor program from a JSON IDL.
22
//!
3+
//! [![Crates.io](https://img.shields.io/crates/v/anchor-gen)](https://crates.io/crates/anchor-gen) [![License](https://img.shields.io/crates/l/anchor-gen)](https://github.com/saber-hq/anchor-gen/blob/master/LICENSE.txt) [![Build Status](https://img.shields.io/github/workflow/status/saber-hq/anchor-gen/Rust/master)](https://github.com/saber-hq/anchor-gen/actions/workflows/rust.yml?query=branch%3Amaster) [![Contributors](https://img.shields.io/github/contributors/saber-hq/anchor-gen)](https://github.com/saber-hq/anchor-gen/graphs/contributors) [![Code Coverage](https://img.shields.io/codecov/c/github/saber-hq/anchor-gen)](https://app.codecov.io/gh/saber-hq/anchor-gen)
4+
//!
35
//! Now updated for Anchor 0.31.1!
46
//!
57
//! **Warning: this code has not been audited. Please use it at your own risk.**

examples/farms/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "farms"
3+
version = "0.4.0"
4+
edition = "2021"
5+
description = "Autogenerated CPI client for the Kamino Farms program."
6+
authors = ["Ian Macalinao <[email protected]>"]
7+
repository = "https://github.com/saber-hq/anchor-gen"
8+
license = "Apache-2.0"
9+
keywords = ["solana", "anchor"]
10+
11+
[features]
12+
default = ["cpi"]
13+
anchor-debug = []
14+
no-entrypoint = []
15+
no-idl = []
16+
no-log-ix-name = []
17+
cpi = ["no-entrypoint"]
18+
19+
[dependencies]
20+
anchor-gen = { version = "0.4.0", path = "../../crates/anchor-gen" }
21+
anchor-lang = ">=0.20"
22+
# Override anchor to use borsh with the const-generics feature
23+
# Allows to borsh serialize arrays of any length
24+
borsh = { version = "0.10.3", features = ["const-generics"] }

examples/farms/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# farms
2+
3+
Autogenerated CPI client for the Kamino Farms program.
4+
5+
CPI helpers for the [Kamino Farms](https://github.com/Kamino-Finance/kfarms)
6+
program.
7+
8+
This crate was automatically generated by
9+
[anchor-gen](https://github.com/saber-hq/anchor-gen), a crate for generating
10+
Anchor CPI helpers from JSON IDLs.
11+
12+
License: Apache-2.0

0 commit comments

Comments
 (0)