Expand description
A generator program that will be able to generate solana program code from a much easier starting place.
How it works
The standard lifecycle of an instruction (standard derive of InstructionListProcessor
):
Instruction::Data
is deserialized withBorshDeserialize::deserialize
from incoming dataInstruction::Data
is split intoInstructionProcessor::FromAccountsData
,InstructionProcessor::ValidateData
, andInstructionProcessor::InstructionData
withInstructionProcessor::data_to_instruction_arg
Instruction::Accounts
is created fromInstructionProcessor::FromAccountsData
byFromAccounts::from_accounts
InstructionProcessor::process
is called withInstructionProcessor::InstructionData
andInstruction::Accounts
Instruction::Accounts
is cleaned up by withAccountArgument::write_back
Re-exports
Modules
TODO: Write big docs here
Account types list of a program.
Standard account types. These are all optional, you can build your own if you don’t like something in one of them.
Numbers that can be decompressed/compressed on read/write
Contains all the entrypoint functions to start a program.
Custom Error support.
An individual instruction for a program.
A list of instructions serving as an interface and entrypoint for the program.
Automatic size calculation for on-chain data. Derive not created yet, must be done manually for now.
Support for type based PDAs
Programs as accounts support.
Will eventually support InstructionList
s and interfaces.
Additional serializable types
Helper utility functions
Macros
Implements AccountArgument
for a type with a certain accessor.
The entrypoint macro, replaces solana_program::entrypoint
macro.
Requires a function that can be passed to entry
.
Similar to the entrypoint
macro but only requires passing a type that implements InstructionList
.
Implementations for a type that impls AccountInfo
.
Print a message to the log.
Verifies a given type implements the proper traits
Structs
CPI functions that check each account for outstanding usages.
Less efficient than CPIUnchecked
but will avoid unsafe situations.
Suggested to use this for validation and then swap to CPIUnchecked
.
Uses solana_program::program::invoke_signed
CPI functions that doesn’t check each account for outstanding usages.
Can result in unsafe situations but is more efficient than CPIChecked
.
Uses solana_program::program::invoke_signed_unchecked
A custom version of Solana’s AccountInfo
that allows for owner changes.
Account information
Describes a single account read or written by a program during instruction execution.
A directive for a single invocation of a Solana program.
Enums
General errors issued by the generator.
Auto-generated discriminant enum variants
Traits
A trait representing accounts on Solana. Can take many different forms.
A trait representing accounts on Solana. Can take many different forms.
Use AccountInfo
.
A way of executing CPI calls
Account info can safely assign the owner.
Account info can safely assign the owner. Use SafeOwnerChange
.
Account info can safely realloc.
Account info can safely realloc. Use SafeRealloc
.
Account info can be turned into a SolanaAccountInfo
.
Account info can be turned into a SolanaAccountInfo
. Use ToSolanaAccountInfo
.
Type Definitions
UnixTimestamp is an approximate measure of real-world time, expressed as Unix time (ie. seconds since the Unix epoch)