tpl-generic-token 3.2.2

Trezoa Program Library Generic Token
Documentation
  • Coverage
  • 33.33%
    18 out of 54 items documented0 out of 35 items with examples
  • Size
  • Source code size: 37.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 731.31 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • TRZLedgerFoundation

TPL Generic Token

Library that provides bare-bones, dependency-minimized access to TPL Token balance information.

Example usage

This library provides two core structs:

tpl_generic_token::generic_token::Account {
    mint: Pubkey,
    owner: Pubkey,
    amount: u64,
}

tpl_generic_token::generic_token::Mint {
    supply: u64,
    decimals: u8,
}

Both provide a static function fn unpack(account_data: &[u8], program_id: &Pubkey) -> Option<Self> which extracts the above fields from a raw buffer in a manner that is generic across tpl_token and tpl_token_2022, without depending on either library.

This is only intended as a simple way to determine balances and direct account ownership. Users who require additional information such as delegation, mint authority, and so on, should use the full account parsers in the respective token libraries, as those use-cases exceed the scope of this tool.

We also provide the trait GenericTokenAccount which exposes direct access to the fields named above.

Note to maintainers

This library is used in parts of Agave that must not depend on tpl_token, tpl_token_2022, or other outside Trezoa libraries. Care should be taken not to introduce dependencies that may complicate this situation.