From bde057e8fc792c1207637d66d034936bba48af1c Mon Sep 17 00:00:00 2001 From: febo Date: Sat, 29 Mar 2025 02:06:06 +0000 Subject: [PATCH 1/2] [wip]: Update README information --- README.md | 96 ++++++++++------------------------------------- program/README.md | 4 +- 2 files changed, 21 insertions(+), 79 deletions(-) mode change 100644 => 120000 program/README.md diff --git a/README.md b/README.md index ecf0590..8d84ed5 100644 --- a/README.md +++ b/README.md @@ -5,99 +5,43 @@ -This template should help get you started developing Solana programs. Let's walk through this generated program repository and see what's included. +Attach custom data to any program. -## Project setup +## Overview -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. +The Program Metadata provides the ability to attach metadata information to any program. The metadata information is represented by a PDA account with a pre-defined derivation, e.g., it can be used to add the IDL of a program, with the PDA derived using the `"idl"` string. -```sh -pnpm install -``` +There are two types of metadata accounts: +* `canonical`: these are metadata accounts created by the program upgrade authority. They are derived from `[program key, seed]`. +* `non-canonical` (a.k.a. *third-party*): these are metadata account created by any authority. They are derived from `[program key, authority key, seed]`. -## Managing programs +There can only be a single canonical metadata account for a pair *(program, seed)*, at the same time, there can be any number of non-canonical metadata accounts. The rationale is to allow anyone to add additional metadata to any program, but also provide a mechanism to differentiate metadata information added by the program upgrade authority. -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. +## Building +To build the program locally, first install the required packages using: ```sh -pnpm programs:build -pnpm programs:test -pnpm programs:format -pnpm programs:lint -``` - -## Generating IDLs - -You may use the following command to generate the IDLs for your programs. - -```sh -pnpm generate:idls -``` - -Depending on your program's framework, this will either use Shank or Anchor to generate the IDLs. -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. - -## Generating clients - -Once your programs' IDLs have been generated, you can generate clients for them using the following command. - -```sh -pnpm generate:clients +pnpm install ``` - -Alternatively, you can use the `generate` script to generate both the IDLs and the clients at once. - +and then run: ```sh -pnpm generate +pnpm programs:build ``` -## 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 +## Testing -The following script is available to start your local validator. +The repository includes two types of tests: program tests and JS client tests. +To run the program tests: ```sh -pnpm validator:start +pnpm programs:test ``` -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. - +To run the JS tests: ```sh -pnpm validator:restart +pnpm clients:js:test ``` -Finally, you may stop the local validator using the following command. - -```sh -pnpm validator:stop -``` +## License -## Using external programs in your validator - -If your program requires any external programs to be running, you'll want to in your local validator. - -You can do this by adding their program addresses to the `program-dependencies` array in the `Cargo.toml` of your program. - -```toml -program-dependencies = [ - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", - "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV", -] -``` - -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. - -```sh -pnpm programs:build -pnpm validator:restart -``` +The code is licensed under the [Apache License Version 2.0](LICENSE) \ No newline at end of file diff --git a/program/README.md b/program/README.md deleted file mode 100644 index 8c16175..0000000 --- a/program/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Program Metadata - -Your generated Solana program. Have fun! diff --git a/program/README.md b/program/README.md new file mode 120000 index 0000000..32d46ee --- /dev/null +++ b/program/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file From b475ab38bd2c87e8e666eb57320aa7006bef86e0 Mon Sep 17 00:00:00 2001 From: Fernando Otero Date: Tue, 1 Apr 2025 09:07:28 +0100 Subject: [PATCH 2/2] Cosmetics --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8d84ed5..a87298d 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,13 @@ Attach custom data to any program. ## Overview -The Program Metadata provides the ability to attach metadata information to any program. The metadata information is represented by a PDA account with a pre-defined derivation, e.g., it can be used to add the IDL of a program, with the PDA derived using the `"idl"` string. +The Program Metadata provides the ability to attach metadata information to any program. The information is represented by a PDA account with a pre-defined derivation, e.g., it can be used to add the IDL of a program, with a PDA derived using the `"idl"` string. There are two types of metadata accounts: -* `canonical`: these are metadata accounts created by the program upgrade authority. They are derived from `[program key, seed]`. -* `non-canonical` (a.k.a. *third-party*): these are metadata account created by any authority. They are derived from `[program key, authority key, seed]`. +* canonical: these are metadata accounts created by the program upgrade authority. They are derived from `[program key, seed]`. +* non-canonical (a.k.a. *third-party*): these are metadata account created by any authority. They are derived from `[program key, authority key, seed]`. -There can only be a single canonical metadata account for a pair *(program, seed)*, at the same time, there can be any number of non-canonical metadata accounts. The rationale is to allow anyone to add additional metadata to any program, but also provide a mechanism to differentiate metadata information added by the program upgrade authority. +While there can only be a single canonical metadata account for a pair *(program, seed)*, there can be any number of non-canonical metadata accounts. The rationale is to allow anyone to add additional metadata to any program, but also provide a mechanism to differentiate metadata information added by the program upgrade authority. ## Building @@ -44,4 +44,4 @@ pnpm clients:js:test ## License -The code is licensed under the [Apache License Version 2.0](LICENSE) \ No newline at end of file +The code is licensed under the [Apache License Version 2.0](LICENSE)