diff --git a/README.md b/README.md index 7cc3989f..b29a9f57 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,18 @@ -This template should help get you started developing Solana programs. Let's walk through this generated program repository and see what's included. +This repository contains the SPL Token program and its clients: + +- [`program`](./program): the original SPL Token program (`spl-token`). +- [`pinocchio/program`](./pinocchio/program): the pinocchio-based Token program (p-token). +- [`interface`](./interface) and [`pinocchio/interface`](./pinocchio/interface): the instruction and state definitions used by the programs. +- [`clients/js`](./clients/js): the JS client, generated from the IDL. ## Project setup -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. +This repository uses a `Makefile` for building, testing and linting. Package names are mapped to directories by replacing the first `-` with a `/` (for example, `pinocchio-program` refers to `pinocchio/program` and `clients-js` to `clients/js`). + +Install the NPM dependencies once to make the Codama renderers available for client generation: ```sh pnpm install @@ -17,76 +24,45 @@ pnpm install ## Managing programs -You'll notice a `program` folder in the root of this repository. This is where your generated Solana program is located. - -Whilst only one program gets generated, note that you can have as many programs as you like in this repository. -Whenever you add a new program folder to this repository, remember to add it to the `members` array of your root `Cargo.toml` file. -That way, your programs will be recognized by the following scripts that allow you to build, test, format and lint your programs respectively. +Build the SBF artifacts into `target/deploy/` with: ```sh -pnpm programs:build -pnpm programs:test -pnpm programs:format -pnpm programs:lint +make build-sbf-program +make build-sbf-pinocchio-program ``` -## Generating clients - -Once your programs' IDLs have been generated, you can generate clients for them using the following command. +The program tests run against the built artifacts using [Mollusk](https://github.com/anza-xyz/mollusk), so build the program before testing it: ```sh -pnpm generate:clients +make test-program +make test-pinocchio-program ``` -Alternatively, you can use the `generate` script to generate both the IDLs and the clients at once. +You can also format-check and lint any Rust package, for example: ```sh -pnpm generate +make format-check-program +make clippy-program ``` -## Managing clients - -The following clients are available for your programs. You may use the following links to learn more about each client. - -- [JS client](./clients/js) -- [Rust client](./clients/rust) - -## Starting and stopping the local validator - -The following script is available to start your local validator. - -```sh -pnpm validator:start -``` - -By default, if a local validator is already running, the script will be skipped. You may use the `validator:restart` script instead to force the validator to restart. - -```sh -pnpm validator:restart -``` +## Generating clients -Finally, you may stop the local validator using the following command. +The program IDL is checked in at the repository root as [`idl.json`](./idl.json). Regenerate the JS client from it with: ```sh -pnpm validator:stop +make generate-clients ``` -## Using external programs in your validator - -If your program requires any external programs to be running, you'll want to add them to your local validator. +## Managing clients -You can do this by adding their program addresses to the `program-dependencies` array in the `Cargo.toml` of your program. +The following clients are available for your programs. You may use the following links to learn more about each client. -```toml -program-dependencies = [ - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", - "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV", -] -``` +- [JS client](./clients/js) +- [Rust client](./clients/rust) -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. +The JS client tests load `target/deploy/pinocchio_token_program.so` into LiteSVM, so build the pinocchio program first: ```sh -pnpm programs:build -pnpm validator:restart +make build-sbf-pinocchio-program +make test-js-clients-js ```