|
| 1 | +# Summary |
| 2 | +- Unified account validation for both solana-program and pinocchio SDKs |
| 3 | +- AccountInfoTrait abstraction enabling single codebase across SDK implementations |
| 4 | +- Validation checks with 8-byte discriminators for account type safety |
| 5 | +- AccountIterator providing detailed error locations (file:line:column) |
| 6 | +- Error codes 12006-12021 with automatic ProgramError conversion |
| 7 | + |
| 8 | +# Used in |
| 9 | +- `light-compressed-token` - Validates all account inputs in compressed token instructions |
| 10 | +- `light-system` - Core validation for compressed account operations |
| 11 | +- `light-compressible` - Validates CompressibleConfig accounts and PDAs |
| 12 | +- `light-ctoken-types` - Uses AccountInfoTrait for runtime-agnostic account handling |
| 13 | +- `light-account-compression` - Merkle tree account validation |
| 14 | +- `light-batched-merkle-tree` - Batch operation account checks |
| 15 | +- `compressed-token-sdk` - Uses validation helpers in instruction builders |
| 16 | +- `light-sdk` - Core SDK account validation utilities |
| 17 | +- `light-sdk-pinocchio` - Pinocchio-specific SDK validation |
| 18 | +- `light-sdk-types` - Uses AccountInfoTrait for CPI context and tree info |
| 19 | +- `light-compressed-token-types` - Uses AccountInfoTrait for instruction account structures |
| 20 | + |
| 21 | +# Navigation |
| 22 | +- This file: Overview and module organization |
| 23 | +- For detailed documentation on specific components, see the `docs/` directory: |
| 24 | + - `docs/CLAUDE.md` - Navigation guide for detailed documentation |
| 25 | + - `docs/ACCOUNT_INFO_TRAIT.md` - AccountInfoTrait abstraction and implementations |
| 26 | + - `docs/ACCOUNT_CHECKS.md` - Account validation functions and patterns |
| 27 | + - `docs/ACCOUNT_ITERATOR.md` - Enhanced iterator with error reporting |
| 28 | + - `docs/ERRORS.md` - Error codes (12006-12021), causes, and resolutions |
| 29 | + - `docs/DISCRIMINATOR.md` - Discriminator trait for account type identification |
| 30 | + - `docs/PACKED_ACCOUNTS.md` - Index-based account access utility |
| 31 | + |
| 32 | +# Source Code Structure |
| 33 | + |
| 34 | +## Core Types (`src/`) |
| 35 | + |
| 36 | +### Account Abstraction (`account_info/`) |
| 37 | +- `account_info_trait.rs` - AccountInfoTrait definition abstracting over SDK differences |
| 38 | + - Unified data access interface (`try_borrow_data`, `try_borrow_mut_data`) |
| 39 | + - PDA derivation functions (`find_program_address`, `create_program_address`) |
| 40 | + - Ownership and permission checks |
| 41 | +- `pinocchio.rs` - Pinocchio AccountInfo implementation (feature: `pinocchio`) |
| 42 | +- `solana.rs` - Solana AccountInfo implementation (feature: `solana`) |
| 43 | +- `test_account_info.rs` - Mock implementation for unit testing (feature: `test-only`) |
| 44 | + |
| 45 | +### Validation Functions (`checks.rs`) |
| 46 | +- Account initialization (`account_info_init` - sets discriminator) |
| 47 | +- Ownership validation (`check_owner`, `check_program`) |
| 48 | +- Permission checks (`check_mut`, `check_non_mut`, `check_signer`) |
| 49 | +- Discriminator validation (`check_discriminator`, `set_discriminator`) |
| 50 | +- PDA validation (`check_pda_seeds`, `check_pda_seeds_with_bump`) |
| 51 | +- Rent exemption checks (`check_account_balance_is_rent_exempt`) |
| 52 | +- Combined validators (`check_account_info_mut`, `check_account_info_non_mut`) |
| 53 | + |
| 54 | +### Account Processing (`account_iterator.rs`) |
| 55 | +- Sequential account processing with enhanced error messages |
| 56 | +- Named account retrieval with automatic validation |
| 57 | +- Location tracking for debugging (file:line:column in errors) |
| 58 | +- Convenience methods: `next_signer`, `next_mut`, `next_non_mut` |
| 59 | +- Optional account handling (`next_option`, `next_option_mut`) |
| 60 | + |
| 61 | +### Account Type Identification (`discriminator.rs`) |
| 62 | +- Discriminator trait for 8-byte account type prefixes |
| 63 | +- Constant discriminator arrays for compile-time verification |
| 64 | +- Integration with zero-copy deserialization |
| 65 | + |
| 66 | +### Dynamic Access (`packed_accounts.rs`) |
| 67 | +- Index-based account access for dynamic account sets |
| 68 | +- Bounds-checked retrieval with descriptive error messages |
| 69 | +- Used for accessing mint, owner, delegate accounts by index |
| 70 | + |
| 71 | +### Error Handling (`error.rs`) |
| 72 | +- AccountError enum with 16 variants (codes 12006-12021) |
| 73 | +- Automatic conversions to ProgramError for both SDKs |
| 74 | +- Pinocchio ProgramError mapping (standard codes 1-11) |
| 75 | +- BorrowError conversions for safe data access |
| 76 | + |
| 77 | +## Feature Flags |
| 78 | +- `solana` - Enables solana-program AccountInfo implementation |
| 79 | +- `pinocchio` - Enables pinocchio AccountInfo implementation |
| 80 | +- `test-only` - Enables test utilities and mock implementations |
| 81 | +- Default: No features (trait definitions only) |
0 commit comments