Skip to content

Commit

Permalink
update readme and template
Browse files Browse the repository at this point in the history
  • Loading branch information
HardhatChad committed Oct 23, 2024
1 parent f6c6b0b commit 5afc7ca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

- [ ] Localnet toolchain.
- [ ] Mainnet toolchain.
- [ ] Passthrough cargo args.
- [ ] IDL generation.
- [x] ~~Helper functions for simple lamport transfers.~~
- [x] ~~Helper functions to emit events (wrap sol_log_data).~~
Expand All @@ -26,19 +27,19 @@ To get started, install the CLI:
cargo install steel-cli
```

Spin up a new project with the `new` command:
Use the `new` command to create a new project:
```sh
steel new my-project
```

Compile your program using the Solana toolchain:
```sh
cargo build-sbf
steel build
```

Test your program using the Solana toolchain:
```sh
cargo test-sbf
steel test
```

## File structure
Expand Down Expand Up @@ -73,7 +74,7 @@ Cargo.toml (workspace)

### Accounts

Use the `account!` macro to link account structs with the discriminator and implement basic serialization logic.
Use the `account!` macro to link account structs with a discriminator and implement basic serialization logic.

```rs
use steel::*;
Expand All @@ -98,34 +99,35 @@ pub struct Profile {
}

account!(MyAccount, Counter);
account!(MyAccount, Profile);
```

### Instructions

Use the `instruction!` macro to link instruction data with the discriminator and implement basic serialization logic.
Use the `instruction!` macro to link instruction data with a discriminator and implement basic serialization logic.

```rs
use steel::*;

#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
pub enum MyInstruction {
Initialize = 0,
Add = 1,
Add = 0,
Initialize = 1,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Initialize {}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Add {
pub value: u64,
}

instruction!(MyInstruction, Initialize);
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Initialize {}

instruction!(MyInstruction, Add);
instruction!(MyInstruction, Initialize);

```

Expand Down Expand Up @@ -186,8 +188,8 @@ pub fn process_instruction(
let (ix, data) = parse_instruction::<MyInstruction>(&example_api::ID, program_id, data)?;

match ix {
MyInstruction::Initialize => process_initialize(accounts, data)?,
MyInstruction::Add => process_add(accounts, data)?,
MyInstruction::Initialize => process_initialize(accounts, data)?,
}

Ok(())
Expand All @@ -198,7 +200,7 @@ entrypoint!(process_instruction);

### Validation

Use chainable parsers and assertion functions to validate account data.
Use chainable parsers and assertions to validate account data.

```rs
use example_api::prelude::*;
Expand All @@ -223,7 +225,7 @@ pub fn process_add(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult

### CPIs

Use streamlined helpers for executing common tasks like creating accounts and transferring tokens.
Use helper functions to execute common tasks like creating accounts and transferring tokens.

```rs
use steel::*;
Expand Down
13 changes: 9 additions & 4 deletions cli/src/template/readme_md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@
- [`Instruction`](api/src/instruction.rs) – Declared instructions.

## Instructions
- [`Initialize`](program/src/initialize.rs) – Initialize ...
- [`Add`](program/src/add.rs) – Add ...
- [`Initialize`](program/src/initialize.rs) – Initialize ...

## State
- [`Counter`](api/src/state/counter.rs) – Counter ...

## Tests
## Get started

To run the test suit, use the Solana toolchain:
Compile your program:
```sh
steel build
```
cargo test-sbf

Run unit and integration tests:
```sh
steel test
```

0 comments on commit 5afc7ca

Please sign in to comment.