@pina-rs/skill 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/SKILL.md
CHANGED
|
@@ -24,6 +24,7 @@ When no project exists, read [references/project-setup.md](references/project-se
|
|
|
24
24
|
- Do not introduce `unsafe` code or unstable features.
|
|
25
25
|
- Validate account identity, signer status, writability, ownership, and data shape before casts, mutation, lamport transfers, resize operations, or CPI.
|
|
26
26
|
- Use explicit discriminator values and type-specific PDA seed namespaces. Prefer canonical bump validation.
|
|
27
|
+
- Construct account-management operations and generated CPIs as documented instruction structs, then call `.invoke()` or `.invoke_signed(signers)`. Do not recreate the removed free-function helper API.
|
|
27
28
|
- Keep instruction dispatch deterministic: parse once, match explicitly, then construct and validate the accounts type for that instruction.
|
|
28
29
|
- Maintain discriminator-first, fixed-layout storage types expected by Pina and zeropod. Do not place ordinary Rust `bool`, `String`, or variable-length collections in zero-copy account layouts.
|
|
29
30
|
- Preserve error values and wire formats unless the user explicitly accepts a compatibility change.
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ pina idl diff --help
|
|
|
15
15
|
pina idl publish --help
|
|
16
16
|
pina docs --help
|
|
17
17
|
pina init --help
|
|
18
|
+
pina lint --help
|
|
18
19
|
pina test --help
|
|
19
20
|
pina dev --help
|
|
20
21
|
pina keys --help
|
|
@@ -32,6 +33,7 @@ Use `pina docs` to list bundled terminal topics. Custom topics can be supplied t
|
|
|
32
33
|
Run project-aware commands from the program directory or any descendant. Pina uses the nearest ancestor `Pina.toml`; an existing unambiguous Cargo package also works without configuration.
|
|
33
34
|
|
|
34
35
|
```sh
|
|
36
|
+
pina lint
|
|
35
37
|
pina build
|
|
36
38
|
pina test --unit
|
|
37
39
|
pina test
|
|
@@ -44,6 +46,8 @@ pina generate
|
|
|
44
46
|
pina build --features logs,cpi --no-default-features
|
|
45
47
|
```
|
|
46
48
|
|
|
49
|
+
Run `pina lint` before review to execute the official Pina security lint set associated with the installed CLI release. Use `pina lint --fix` only when source edits are authorized, then inspect and test every change. The command intentionally ignores additional project Dylint metadata; use direct `cargo dylint` only after reviewing and pinning any extra native lint libraries.
|
|
50
|
+
|
|
47
51
|
The library target name determines the canonical outputs:
|
|
48
52
|
|
|
49
53
|
```text
|
|
@@ -45,11 +45,67 @@ Use a stable, type-specific byte-string namespace as the first seed. Prefer cano
|
|
|
45
45
|
|
|
46
46
|
Seed changes alter addresses. Treat them as migrations, not refactors.
|
|
47
47
|
|
|
48
|
+
## Account-management instruction builders
|
|
49
|
+
|
|
50
|
+
Pina models account creation, PDA allocation, reallocation, and close operations as values. Construct the documented struct with every input visible, then call `.invoke()` for transaction-level signers or `.invoke_signed(signers)` when another CPI account must sign through program-derived seeds.
|
|
51
|
+
|
|
52
|
+
```rust
|
|
53
|
+
CreateAccount {
|
|
54
|
+
from: payer,
|
|
55
|
+
to: new_account,
|
|
56
|
+
space: 128,
|
|
57
|
+
owner: program_id,
|
|
58
|
+
}
|
|
59
|
+
.invoke()?;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Do not introduce wrapper functions around removed helpers such as `create_account(...)`, `create_program_account::<T>(...)`, or `realloc_account(...)`. Use the matching builder:
|
|
63
|
+
|
|
64
|
+
| Operation | Builder |
|
|
65
|
+
| ----------------------------------------------------- | ------------------------------ |
|
|
66
|
+
| Create a regular account | `CreateAccount` |
|
|
67
|
+
| Derive and create a typed canonical PDA | `CreateProgramAccount` |
|
|
68
|
+
| Validate an explicit bump and create a typed PDA | `CreateProgramAccountWithBump` |
|
|
69
|
+
| Derive and allocate an untyped canonical PDA | `AllocateAccount` |
|
|
70
|
+
| Validate an explicit bump and allocate an untyped PDA | `AllocateAccountWithBump` |
|
|
71
|
+
| Reallocate while balancing rent | `ReallocAccount` |
|
|
72
|
+
| Reallocate with explicit zero-initialization intent | `ReallocAccountZeroed` |
|
|
73
|
+
| Close and return lamports | `CloseAccount` |
|
|
74
|
+
| Zero bytes, close, and return lamports | `CloseAccountZeroed` |
|
|
75
|
+
|
|
76
|
+
Typed PDA creation places the account type on the invocation method:
|
|
77
|
+
|
|
78
|
+
```rust
|
|
79
|
+
let (address, bump) = CreateProgramAccount {
|
|
80
|
+
account: state_account,
|
|
81
|
+
payer,
|
|
82
|
+
owner: program_id,
|
|
83
|
+
seeds,
|
|
84
|
+
}
|
|
85
|
+
.invoke::<State>()?;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Canonical PDA builders derive and validate the target address and return `(Address, u8)`. Explicit-bump builders verify the supplied bump before moving lamports. Both forms automatically append the target PDA signer to additional signers supplied by the caller. Use `u64` for create/allocation `space`; reallocation `new_size` remains `usize`.
|
|
89
|
+
|
|
90
|
+
Close builders intentionally expose only `.invoke()`. They perform checked direct account mutation rather than a CPI, so signer seeds would have no effect.
|
|
91
|
+
|
|
92
|
+
Generated CPI modules follow the same shape. Construct the generated instruction struct using its documented public account and data fields, then invoke it with the validated program account:
|
|
93
|
+
|
|
94
|
+
```rust
|
|
95
|
+
instructions::Update {
|
|
96
|
+
accounts,
|
|
97
|
+
new_price,
|
|
98
|
+
}
|
|
99
|
+
.invoke_signed(&program, signers)?;
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Do not add free convenience constructors to generated CPI modules. Keeping accounts and instruction data visible at construction makes privilege and wire-data review possible at the call site.
|
|
103
|
+
|
|
48
104
|
## Initialization, resize, and close
|
|
49
105
|
|
|
50
|
-
Initialization must prove that the target is empty and that its derived address is correct before
|
|
106
|
+
Initialization must prove that the target is empty and that its derived address is correct before invoking a create or allocation builder. Resize operations must validate authority, owner, address, writability, and the requested bounds before invoking a reallocation builder.
|
|
51
107
|
|
|
52
|
-
When closing an account,
|
|
108
|
+
When closing an account, choose `CloseAccount` or `CloseAccountZeroed` according to the data-erasure requirement. Zero account data before transferring lamports when stale bytes must not remain observable.
|
|
53
109
|
|
|
54
110
|
## Compatibility review
|
|
55
111
|
|
|
@@ -9,13 +9,14 @@ pina init counter_program
|
|
|
9
9
|
cd counter_program
|
|
10
10
|
pina doctor
|
|
11
11
|
pina keys show
|
|
12
|
+
pina lint
|
|
12
13
|
pina build
|
|
13
14
|
pina test --unit
|
|
14
15
|
pina test
|
|
15
16
|
pina generate
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
The scaffold pins the nightly toolchain and `rust-src` needed by `pina build`; install its compatible linker with `cargo install sbpf-linker --version 0.1.8 --locked` before the first SBF build. TypeScript client generation also requires Node.js with npm and `npx`. Keep the generated `Pina.toml` as the project-local discovery and client-selection contract.
|
|
19
|
+
The scaffold pins the nightly toolchain and `rust-src` needed by `pina build`; install its compatible linker with `cargo install sbpf-linker --version 0.1.8 --locked` before the first SBF build. It also records immutable-revision official Pina lint metadata and pinned Dylint binary versions. `pina lint` prepares those tools below Cargo home on first use. TypeScript client generation also requires Node.js with npm and `npx`. Keep the generated `Pina.toml` as the project-local discovery and client-selection contract.
|
|
19
20
|
|
|
20
21
|
Before deployment, establish the program identity explicitly. Use `pina keys new` for a fresh local identity or validate a keypair produced by trusted platform tooling with `pina keys sync --keypair <path>`. Never use `--force` unless the intended operation is an identity rotation.
|
|
21
22
|
|