Skip to content

Commit c67062b

Browse files
committed
Write generated READMEs
1 parent dfff36a commit c67062b

File tree

8 files changed

+166
-11
lines changed

8 files changed

+166
-11
lines changed

.changeset/funny-lamps-relax.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-solana-program": patch
3+
---
4+
5+
Write generated READMEs

template/base/README.md.njk

Lines changed: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
# {{ programName | titleCase }}
22

3-
TODO
3+
{# TODO: Uncomment when CI is generated. #}
4+
{# <a href="https://github.com/{{ organizationName }}/{{ programName }}/actions/workflows/main.yml"><img src="https://img.shields.io/github/actions/workflow/status/{{ organizationName }}/{{ programName }}/main.yml?logo=GitHub" /></a> #}
5+
<a href="https://explorer.solana.com/address/{{ programAddress }}"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2F{{ organizationName }}%2F{{ programName }}%2Fmain%2Fprogram%2Fidl.json&query=%24.version&label=program%20version&logo=data:image/svg%2bxml;base64,PHN2ZyB3aWR0aD0iMzEzIiBoZWlnaHQ9IjI4MSIgdmlld0JveD0iMCAwIDMxMyAyODEiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF80NzZfMjQzMCkiPgo8cGF0aCBkPSJNMzExLjMxOCAyMjEuMDU3TDI1OS42NiAyNzYuNTU4QzI1OC41MzcgMjc3Ljc2NCAyNTcuMTc4IDI3OC43MjUgMjU1LjY2OSAyNzkuMzgyQzI1NC4xNTkgMjgwLjAzOSAyNTIuNTMgMjgwLjM3OCAyNTAuODg0IDI4MC4zNzdINS45OTcxOUM0LjgyODcgMjgwLjM3NyAzLjY4NTY4IDI4MC4wMzUgMi43MDg1NSAyNzkuMzkzQzEuNzMxNDMgMjc4Ljc1MSAwLjk2Mjc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PackageName }}"><img src="https://img.shields.io/npm/v/%40{{ organizationName }}%2F{{ jsClientPackageName }}?logo=npm&color=377CC0" /></a>
8+
{% endif %}
9+
{% if clients.includes('rust') %}
10+
<a href="https://crates.io/crates/{{ rustClientCrateName }}"><img src="https://img.shields.io/crates/v/{{ rustClientCrateName }}?logo=rust" /></a>
11+
{% else %}
12+
<a href="https://crates.io/crates/{{ programCrateName }}"><img src="https://img.shields.io/crates/v/{{ programCrateName }}?logo=rust" /></a>
13+
{% endif %}
14+
15+
This template should help get you started developing Solana programs. Let's walk through this generated program repository and see what's included.
16+
17+
## Project setup
18+
19+
The first thing you'll want to do is install NPM dependencies which will allow you to access all the scripts and tools provided by this template.
20+
21+
```sh
22+
{{ getNpmCommand("install") }}
23+
```
24+
25+
## Managing programs
26+
27+
You'll notice a `program` folder in the root of this repository. This is where your generated Solana program is located.
28+
29+
Whilst only one program gets generated, not that you can have as many programs as you like in this repository.
30+
Whenever you add a new program folder to this repository, remember to add it to the `members` array of your root `Cargo.toml` file.
31+
That way, your programs will be recognized by the following scripts that allow you to build, test, format and lint your programs respectively.
432

533
```sh
634
{{ getNpmCommand("programs:build") }}
@@ -9,4 +37,81 @@ TODO
937
{{ getNpmCommand("programs:lint") }}
1038
```
1139

12-
TODO
40+
## Generating IDLs
41+
42+
You may use the following command to generate the IDLs for your programs.
43+
44+
```sh
45+
{{ getNpmCommand("generate:idls") }}
46+
```
47+
48+
Depending on your program's framework, this will either use Shank or Anchor to generate the IDLs.
49+
Note that, to ensure IDLs are generated using the correct framework version, the specific version used by the program will be downloaded and used locally.
50+
51+
{% if clients.length > 0 %}
52+
## Generating clients
53+
54+
Once your programs' IDLs have been generated, you can generate clients for them using the following command.
55+
56+
```sh
57+
{{ getNpmCommand("generate:clients") }}
58+
```
59+
60+
Alternatively, you can use the `generate` script to generate both the IDLs and the clients at once.
61+
62+
```sh
63+
{{ getNpmCommand("generate") }}
64+
```
65+
66+
## Managing clients
67+
68+
The following clients are available for your programs. You may use the following links to learn more about each client.
69+
70+
{% for client in clients %}
71+
{% if ['js'].includes(client) %}
72+
- [{{ client | upper }} client](./clients/{{ client }})
73+
{% else %}
74+
- [{{ client | titleCase }} client](./clients/{{ client }})
75+
{% endif %}
76+
{% endfor %}
77+
78+
## Starting and stopping the local validator
79+
80+
The following script is available to start your local validator.
81+
82+
```sh
83+
{{ getNpmCommand("validator") }}
84+
```
85+
86+
By default, if a local validator is already running, the script will be skipped. You may use the `--restart` flag to force the validator to restart.
87+
88+
```sh
89+
{{ getNpmCommand("validator", "--restart") }}
90+
```
91+
92+
Finally, you may stop the local validator using the following command.
93+
94+
```sh
95+
{{ getNpmCommand("validator:stop") }}
96+
```
97+
98+
## Using external programs in your validator
99+
100+
If your program requires any external programs to be running, you'll want to in your local validator.
101+
102+
You can do this by adding their program addresses to the `program-dependencies` array in the `Cargo.toml` of your program.
103+
104+
```toml
105+
program-dependencies = [
106+
"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",
107+
"noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV",
108+
]
109+
```
110+
111+
Next time you build your program and run your validator, these external programs will automatically be fetched from mainnet and used in your local validator.
112+
113+
```sh
114+
{{ getNpmCommand("programs:build") }}
115+
{{ getNpmCommand("validator", "--restart") }}
116+
```
117+
{% endif %}

template/clients/js/clients/js/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# JavaScript client
2+
3+
A generated JavaScript library for the {{ programName | titleCase }} program.
4+
5+
## Getting started
6+
7+
To build and test your JavaScript client from the root of the repository, you may use the following command.
8+
9+
```sh
10+
{{ getNpmCommand("clients:js:test") }}
11+
```
12+
13+
This will start a new local validator, if one is not already running, and run the tests for your JavaScript client.
14+
15+
## Available client scripts.
16+
17+
Alternatively, you can go into the client directory and run the tests directly.
18+
19+
```sh
20+
# Build your programs and start the validator.
21+
{{ getNpmCommand("programs:build") }}
22+
{{ getNpmCommand("validator") }}
23+
24+
# Go into the client directory and run the tests.
25+
cd clients/js
26+
{{ getNpmCommand("install") }}
27+
{{ getNpmCommand("build") }}
28+
{{ getNpmCommand("test") }}
29+
```
30+
31+
You may also use the following scripts to lint and/or format your JavaScript client.
32+
33+
```sh
34+
{{ getNpmCommand("lint") }}
35+
{{ getNpmCommand("lint:fix") }}
36+
{{ getNpmCommand("format") }}
37+
{{ getNpmCommand("format:fix") }}
38+
```

template/clients/rust/clients/rust/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Rust client
2+
3+
A generated Rust library for the {{ programName | titleCase }} program.
4+
5+
## Getting started
6+
7+
To build and test your Rust client from the root of the repository, you may use the following command.
8+
9+
```sh
10+
{{ getNpmCommand("clients:js:test") }}
11+
```
12+
13+
This will start a new local validator, if one is not already running, and run the tests for your Rust client.

template/programs/counter-shank/program/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# {{ programName | titleCase }}
2+
3+
Your generated Solana program. Have fun!

0 commit comments

Comments
 (0)