verified_anchor/account_data.rs
1//! Traits that user types carry into typed-account wrappers.
2
3use solana_program::pubkey::Pubkey;
4
5/// Anchor-compatible account-data trait. The derive `#[derive(AccountData)]`
6/// implements this and the underlying Borsh traits; the `DISCRIMINATOR` is
7/// `sha256(b"account:" ++ <TypeName>)[0..8]` — the real Anchor wire format.
8pub trait AccountData: borsh::BorshDeserialize + borsh::BorshSerialize {
9 const DISCRIMINATOR: [u8; 8];
10}
11
12/// A marker for a Solana program, providing its on-chain id. Carried by
13/// `Program<'info, P>` so the wrapper can check `accounts[i].key == &P::ID`.
14pub trait ProgramId {
15 const ID: Pubkey;
16}
17
18/// Marker for the System Program. Used as `Program<'info, System>` so the
19/// wrapper auto-checks `accounts[i].key == solana_program::system_program::ID`.
20pub struct System;
21impl ProgramId for System {
22 const ID: Pubkey = solana_program::system_program::ID;
23}