Expand description
Hopper-native SPL Token CPI builders.
The API is Hopper-owned (builder pattern over AccountView / Signer).
A builder’s CPI checks that no account in the instruction is borrowed and
that no account fills two writable roles, and leaves signer and writable
privileges to the runtime; a multisig authority’s signers take the fully
checked bounded path.
Provides checked-by-default TransferChecked, MintToChecked, BurnChecked,
ApproveChecked, CloseAccount, Revoke, SetAuthority, FreezeAccount,
ThawAccount, SyncNative, and InitializeAccount builders, plus the
administrative set (InitializeMint, InitializeMultisig, InitializeMultisig2,
InitializeImmutableOwner, GetAccountDataSize, WithdrawExcessLamports,
AmountToUiAmount, UiAmountToAmount, UnwrapLamports) and the p-token
Batch instruction through TokenBatch.
Multisig owner flows are first-class via bounded signer-account slices.
Deprecated plain Transfer/MintTo/Burn/Approve builders are compiled only
when legacy-token-instructions is explicitly enabled.
§One encoding, two programs, two sinks
Every builder encodes its instruction bytes and account metas exactly
once, in its TokenInstruction::emit impl. invoke() and the
invoke_signed / invoke_multisig family send that encoding to SPL
Token; invoke_on sends it to an explicit
TokenProgram, and invoke_for_owner
to whichever of the two programs owns the builder’s first account (one
32-byte compare, and a refusal for any other owner). The same emit can
also append the instruction to a TokenBatch, which sends several
token instructions in one CPI.
Re-exports§
pub use crate::token_admin::return_data_string;pub use crate::token_admin::return_data_u64;pub use crate::token_admin::AmountToUiAmount;pub use crate::token_admin::GetAccountDataSize;pub use crate::token_admin::InitializeImmutableOwner;pub use crate::token_admin::InitializeMint;pub use crate::token_admin::InitializeMultisig;pub use crate::token_admin::InitializeMultisig2;pub use crate::token_admin::UiAmountToAmount;pub use crate::token_admin::UnwrapLamports;pub use crate::token_admin::WithdrawExcessLamports;pub use crate::token_admin::MAX_UI_AMOUNT_LEN;pub use crate::token_batch::TokenBatch;pub use crate::token_mint::InitializeMint2;pub use crate::token_mint::MintConfig;pub use crate::token_mint::MintPlan;pub use crate::token_mint::MintProgram;
Modules§
- instructions
- Legacy module-path re-exports.
Structs§
- Approve
Checked - Builder for SPL Token ApproveChecked (instruction index 13).
- Burn
Checked - Builder for SPL Token BurnChecked (instruction index 15).
- Checked
Mint Decimals - Proof token that an SPL Mint matched expected decimals.
- Checked
Token Authority - Proof token that an SPL TokenAccount matched an expected token authority.
- Checked
Token Mint - Proof token that an SPL TokenAccount matched an expected mint.
- Close
Account - Builder for SPL Token CloseAccount (instruction index 9).
- Freeze
Account - Builder for SPL Token FreezeAccount (instruction index 10).
- Initialize
Account - Builder for SPL Token InitializeAccount (instruction index 1).
- Initialize
Account2 - Builder for SPL Token InitializeAccount2 (instruction index 16).
- Initialize
Account3 - Builder for SPL Token InitializeAccount3 (instruction index 18).
- Mint
ToChecked - Builder for SPL Token MintToChecked (instruction index 14).
- Revoke
- Builder for SPL Token Revoke (instruction index 5).
- SetAuthority
- Builder for SPL Token SetAuthority (instruction index 6).
- SplMint
- Known external SPL Mint adapter.
- SplMint
View - Guard-owned zero-copy SPL Mint view.
- SplToken
Account - Known external SPL TokenAccount adapter.
- SplToken
Account View - Guard-owned zero-copy SPL TokenAccount view.
- Sync
Native - Builder for SPL Token SyncNative (instruction index 17).
- Thaw
Account - Builder for SPL Token ThawAccount (instruction index 11).
- Token
Amount Snapshot - Snapshot of a token account amount before CPI.
- Trailing
- A run of accounts appended after a builder’s fixed accounts, all with the same privileges: the multisig signers of an authority, the member list of a new multisig, or the source accounts of a withheld-fee sweep.
- Transfer
Checked - Builder for classic SPL Token TransferChecked (instruction index 12).
Enums§
- Token
Authority Type - Authority classes accepted by SPL Token’s SetAuthority instruction.
- Token
Program - The two token programs every builder in this module can target.
Constants§
- MAX_
TOKEN_ MULTISIG_ SIGNERS - SPL Token multisig accounts support at most 11 signer accounts.
- SPL_
MINT_ LEN - SPL_
TOKEN_ ACCOUNT_ LEN - TOKEN_
2022_ PROGRAM_ ID - Token-2022 program address.
- TOKEN_
PROGRAM_ ID - SPL Token program address.
Traits§
- Token
Instruction - An SPL Token / Token-2022 instruction builder: something that can encode
itself into a
TokenSink. - Token
Sink - Where a builder’s encoded instruction goes.
Functions§
- require_
mint_ authority - Verify an SPL Mint account’s
mint_authorityCOption field matchesexpected_authority. - require_
mint_ decimals - Verify an SPL Mint account’s
decimalsbyte matchesexpected. - require_
mint_ freeze_ authority - Verify an SPL Mint account’s
freeze_authorityCOption field matchesexpected_freeze. - require_
token_ authority - Verify an SPL Token account’s
ownerfield matchesauthority.key(). - require_
token_ mint - Verify an SPL Token account’s
mintfield matchesexpected_mint. - require_
token_ owner_ eq - Verify an SPL Token account’s
ownerfield matches a pubkey supplied directly (i.e. not wrapped in anAccountView).