git clone [email protected]:Nagaprasadvr/solana-pinocchio-starter.git-
-
entrypoint.rs - the entrypoint of the program
- Note: it uses nostd_panic_handler to handle panics also global allocator is disabled meaning no heap allocations
-
lib.rs - lib crate
- Note: uses no_std so we cannot use std library (for performance tweaks)
-
instruction - all instructions are defined here
-
state - all account states are defined here
- utils.rs - utils for state which provide serialization and deserialization helper fns( load_acc , load_mut_acc, etc)
-
error.rs - program errors are listed here
-
-
tests - all tests are defined here
- Note: we are using mollusk-svm - a lightweight solana testing framework for running tests in a local environment without the need of a full solana cluster
- elfs - compiled solana elfs can be added here and loaded to mollusk while testing
- unit_tests.rs - has the unit tests for the program
-
benches - all the benchmarks are defined here
- compute_units.md - compute unit benchmarks
cargo build-sbf- After build is successful get the program pubkey and replace with the pinocchio_pubkey::declare_id!(...)
solana address -k target/deploy/solana_pinocchio_starter-keypair.jsoncargo test --features test-defaultcargo bench --features bench-defaultSolana CLI Version: solana-cli 2.2.17 (src:e998175d; feat:3073396398, client:Agave)
| Name | CUs | Delta |
|---|---|---|
| InitializeMyState | 3357 | +60 |
| UpdateMyState | 465 | -1,355 |
Shank support has been added to generate the client code for the program in ts/rust languages using Codama.
Run this from the root of the repo and change permissions for the bash script if needed (chmod +x gen-client.sh)
# Generate TypeScript client
./gen-client.sh typescript
# Generate Rust client
./gen-client.sh rust
- This will generate the client code in the
clientdirectory using Codama library - Idl is generated and stored in the
client/idldirectory - Generated code structure:
- TypeScript: client/ts/generated
- Rust: client/rust/generated
- Each contains:
- accounts - all the accounts are defined here
- instructions - all the instructions are defined here
- types - all the types are defined here