Skip to content

Commit a25fb49

Browse files
committed
Add account info and pubkey helpers (anza-xyz#21)
1 parent ac2851d commit a25fb49

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

account-view/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ use crate::{program_error::ProgramError, pubkey::Pubkey, syscalls::sol_memset_};
88
/// single realloc.
99
pub const MAX_PERMITTED_DATA_INCREASE: usize = 1_024 * 10;
1010

11+
#[macro_export]
12+
macro_rules! get_account_info {
13+
( $accounts:ident, $index:expr ) => {{
14+
if $accounts.len() <= $index {
15+
return Err($crate::program_error::ProgramError::NotEnoughAccountKeys);
16+
}
17+
&$accounts[$index]
18+
}};
19+
}
20+
1121
/// Raw account data.
1222
///
1323
/// This data is wrapped in an `AccountInfo` struct, which provides safe access

0 commit comments

Comments
 (0)