Expand description

Library for writing safer Solana programs.

Re-exports

pub use validate::Validate;

Modules

Various assertions.

The prelude contains all commonly used components of the crate. All programs should include it via use vipers::prelude::*;.

Validations for accounts.

Macros

Asserts that the given assertion block does not throw any errors.

Asserts that the given anchor_spl::token::TokenAccount is an associated token account.

Asserts that a token account is “zero”.

assert_keysDeprecated

Asserts that two accounts share the same key.

Asserts that two accounts share the same key.

Asserts that two accounts do not share the same key.

assert_ownerDeprecated

Asserts that an account is owned by the given program.

Asserts that the given assertion block throws a specific error.

Formats an error as a &str.

Asserts that an invariant holds, otherwise logs the given message. This is a drop-in replacement for require!.

Logs where in the code the macro was invoked.

Returns the given error as a program error.

Runs a block, returning a [anchor_lang::prelude::Result<()>].

Throws an error.

Tries to unwrap the Result, otherwise returns the error

Unwraps a bump seed.

Unwraps the result of a block of checked integer math.

Unwraps the result of a checked integer operation.

Attempts to unwrap an Option, and if it fails, prints an error.

Unwraps a block which returns an Option.

Ensures an Option can be unwrapped, otherwise returns the error.

Structs

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

Enums

Vipers validation error.

Statics

The static program ID

Traits

Defines the Pubkey of an account, fetching it as a reference.

Conversions into a CmpError.

Functions

Confirms that a given pubkey is equivalent to the program ID

Returns the program ID

Helper for getting the current timestamp as any convertible type.

Helper for getting the current timestamp.

Validates a derived program address.