1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#![deny(missing_docs)]
#![deny(rustdoc::all)]
#![allow(rustdoc::missing_doc_code_examples)]
pub mod assert;
mod error;
mod keyref;
pub mod validate;
use anchor_lang::prelude::*;
pub use error::*;
pub use keyref::AsKeyRef;
#[cfg(feature = "spl-associated-token-account")]
pub use spl_associated_token_account as ata;
pub use validate::Validate;
declare_id!("VipersTest111111111111111111111111111111111");
pub fn validate_derived_address(
derived_address: &Pubkey,
program_id: &Pubkey,
seeds: &[&[u8]],
) -> bool {
match Pubkey::create_program_address(seeds, program_id) {
Ok(ref key) => derived_address == key,
_ => false,
}
}
pub fn now_i64() -> Result<i64> {
Ok(Clock::get()?.unix_timestamp)
}
pub fn now<T: TryFrom<i64>>() -> Result<T> {
now_i64()?
.try_into()
.map_err(|_| ::anchor_lang::prelude::error!(VipersError::IntegerOverflow))
}
pub mod prelude {
pub use super::{
assert_is_zero_token_account, assert_keys_eq, assert_keys_neq, invariant, now, now_i64,
try_or_err, unwrap_bump, unwrap_checked, unwrap_int, unwrap_opt, unwrap_opt_block,
unwrap_or_err, AsKeyRef, CmpError, IntoCmpError, Validate, VipersError,
};
}