Crate tensor_vipers

Source
Expand description

Library for writing safer Solana programs.

Re-exports§

pub use validate::Validate;

Modules§

assert
Various assertions.
prelude
The prelude contains all commonly used components of the crate. All programs should include it via use tensor_vipers::prelude::*;.
validate
Validations for accounts.

Macros§

assert_does_not_throw
Asserts that the given assertion block does not throw any errors.
assert_is_ata
Asserts that the given anchor_spl::token::TokenAccount is an associated token account.
assert_is_zero_token_account
Asserts that a token account is “zero”.
assert_keysDeprecated
Asserts that two accounts share the same key.
assert_keys_eq
Asserts that two accounts share the same key.
assert_keys_neq
Asserts that two accounts do not share the same key.
assert_ownerDeprecated
Asserts that an account is owned by the given program.
assert_throws
Asserts that the given assertion block throws a specific error.
format_err
Formats an error as a &str.
invariant
Asserts that an invariant holds, otherwise logs the given message. This is a drop-in replacement for require!.
log_code_location
Logs where in the code the macro was invoked.
program_err
Returns the given error as a program error.
test_assertion
Runs a block, returning a [anchor_lang::prelude::Result<()>].
throw_err
Throws an error.
try_or_err
Tries to unwrap the Result, otherwise returns the error
unwrap_bump
Unwraps a bump seed.
unwrap_checked
Unwraps the result of a block of checked integer math.
unwrap_int
Unwraps the result of a checked integer operation.
unwrap_opt
Attempts to unwrap an Option, and if it fails, prints an error.
unwrap_opt_block
Unwraps a block which returns an Option.
unwrap_or_err
Ensures an Option can be unwrapped, otherwise returns the error.

Structs§

CmpError
A comparable error: an error that can be compared (via equality) to other errors.

Enums§

VipersError
Vipers validation error.

Statics§

ID
The static program ID

Traits§

AsKeyRef
Defines the Pubkey of an account, fetching it as a reference.
IntoCmpError
Conversions into a CmpError.

Functions§

check_id
Confirms that a given pubkey is equivalent to the program ID
id
Returns the program ID
now
Helper for getting the current timestamp as any convertible type.
now_i64
Helper for getting the current timestamp.
validate_derived_address
Validates a derived program address.