pub struct HookState {
pub accounts: BTreeMap<Address, Option<FetchedAccount>>,
}Expand description
A snapshot of the accounts that the hook lists of its mints read. A builder resolves the hook accounts from the snapshot of each mint.
Fill the snapshot with missing: fetch the accounts it
returns, insert each one and call it again, until it
returns none. A builder reads no account outside the snapshot. An account
that the snapshot does not have, such as a PDA of the trader, fails with
HookError::NotLoaded, which names the accounts.
A hook armed or changed after the fill makes the transaction fail in simulation. Fill the snapshot again.
Fields§
§accounts: BTreeMap<Address, Option<FetchedAccount>>Each fetched account: Some where it exists, None where it does
not. An address it does not hold was not fetched.
Implementations§
Source§impl HookState
impl HookState
Sourcepub fn insert(&mut self, address: Address, account: Option<FetchedAccount>)
pub fn insert(&mut self, address: Address, account: Option<FetchedAccount>)
Records what a fetch of address returned: None for no account.
Sourcepub fn missing(&self, mints: &[Address]) -> Result<Vec<Address>, HookError>
pub fn missing(&self, mints: &[Address]) -> Result<Vec<Address>, HookError>
The accounts to fetch next for a snapshot of mints: the mints, then
each hook’s list, then each account a list reads at a fixed address.
Empty when the snapshot holds them all.
An address is fixed when no trade sets it: a fixed key, or a PDA or
data key whose inputs are literal seeds, the first 8 bytes of the
Execute data (the discriminator), the mint, the validation account
and earlier fixed extras. It names no extra that reads the source, the
destination or the authority.
A missing mint runs no hook. For a missing list, or a list that no resolver can resolve, it returns no more accounts, and a build fails.
§Errors
HookError::MalformedMint for a mint that does not decode.