11//! Account information.
22#![ cfg_attr( docsrs, feature( doc_auto_cfg) ) ]
33use {
4+ solana_address:: Address ,
45 solana_program_error:: ProgramError ,
56 solana_program_memory:: sol_memset,
6- solana_pubkey:: Pubkey ,
77 std:: {
88 cell:: { Ref , RefCell , RefMut } ,
99 fmt,
@@ -20,14 +20,14 @@ pub const MAX_PERMITTED_DATA_INCREASE: usize = 1_024 * 10;
2020#[ derive( Clone ) ]
2121#[ repr( C ) ]
2222pub struct AccountInfo < ' a > {
23- /// Public key of the account
24- pub key : & ' a Pubkey ,
23+ /// Address of the account
24+ pub key : & ' a Address ,
2525 /// The lamports in the account. Modifiable by programs.
2626 pub lamports : Rc < RefCell < & ' a mut u64 > > ,
2727 /// The data held in this account. Modifiable by programs.
2828 pub data : Rc < RefCell < & ' a mut [ u8 ] > > ,
2929 /// Program that owns this account
30- pub owner : & ' a Pubkey ,
30+ pub owner : & ' a Address ,
3131 /// Formerly, the epoch at which this account will next owe rent. A field
3232 /// must remain because the runtime depends on the exact layout of this
3333 /// struct.
@@ -62,15 +62,15 @@ impl fmt::Debug for AccountInfo<'_> {
6262}
6363
6464impl < ' a > AccountInfo < ' a > {
65- pub fn signer_key ( & self ) -> Option < & Pubkey > {
65+ pub fn signer_key ( & self ) -> Option < & Address > {
6666 if self . is_signer {
6767 Some ( self . key )
6868 } else {
6969 None
7070 }
7171 }
7272
73- pub fn unsigned_key ( & self ) -> & Pubkey {
73+ pub fn unsigned_key ( & self ) -> & Address {
7474 self . key
7575 }
7676
@@ -182,23 +182,23 @@ impl<'a> AccountInfo<'a> {
182182 }
183183
184184 #[ allow( invalid_reference_casting) ]
185- pub fn assign ( & self , new_owner : & Pubkey ) {
185+ pub fn assign ( & self , new_owner : & Address ) {
186186 // Set the non-mut owner field
187187 unsafe {
188188 std:: ptr:: write_volatile (
189- self . owner as * const Pubkey as * mut [ u8 ; 32 ] ,
189+ self . owner as * const Address as * mut [ u8 ; 32 ] ,
190190 new_owner. to_bytes ( ) ,
191191 ) ;
192192 }
193193 }
194194
195195 pub fn new (
196- key : & ' a Pubkey ,
196+ key : & ' a Address ,
197197 is_signer : bool ,
198198 is_writable : bool ,
199199 lamports : & ' a mut u64 ,
200200 data : & ' a mut [ u8 ] ,
201- owner : & ' a Pubkey ,
201+ owner : & ' a Address ,
202202 executable : bool ,
203203 ) -> Self {
204204 #[ allow( deprecated) ]
@@ -241,30 +241,30 @@ impl<'a, T: IntoAccountInfo<'a>> From<T> for AccountInfo<'a> {
241241/// Provides information required to construct an `AccountInfo`, used in
242242/// conversion implementations.
243243pub trait Account {
244- fn get ( & mut self ) -> ( & mut u64 , & mut [ u8 ] , & Pubkey , bool ) ;
244+ fn get ( & mut self ) -> ( & mut u64 , & mut [ u8 ] , & Address , bool ) ;
245245}
246246
247- /// Convert (&'a Pubkey , &'a mut T) where T: Account into an `AccountInfo`
248- impl < ' a , T : Account > IntoAccountInfo < ' a > for ( & ' a Pubkey , & ' a mut T ) {
247+ /// Convert (&'a Address , &'a mut T) where T: Account into an `AccountInfo`
248+ impl < ' a , T : Account > IntoAccountInfo < ' a > for ( & ' a Address , & ' a mut T ) {
249249 fn into_account_info ( self ) -> AccountInfo < ' a > {
250250 let ( key, account) = self ;
251251 let ( lamports, data, owner, executable) = account. get ( ) ;
252252 AccountInfo :: new ( key, false , false , lamports, data, owner, executable)
253253 }
254254}
255255
256- /// Convert (&'a Pubkey , bool, &'a mut T) where T: Account into an
256+ /// Convert (&'a Address , bool, &'a mut T) where T: Account into an
257257/// `AccountInfo`.
258- impl < ' a , T : Account > IntoAccountInfo < ' a > for ( & ' a Pubkey , bool , & ' a mut T ) {
258+ impl < ' a , T : Account > IntoAccountInfo < ' a > for ( & ' a Address , bool , & ' a mut T ) {
259259 fn into_account_info ( self ) -> AccountInfo < ' a > {
260260 let ( key, is_signer, account) = self ;
261261 let ( lamports, data, owner, executable) = account. get ( ) ;
262262 AccountInfo :: new ( key, is_signer, false , lamports, data, owner, executable)
263263 }
264264}
265265
266- /// Convert &'a mut (Pubkey , T) where T: Account into an `AccountInfo`.
267- impl < ' a , T : Account > IntoAccountInfo < ' a > for & ' a mut ( Pubkey , T ) {
266+ /// Convert &'a mut (Address , T) where T: Account into an `AccountInfo`.
267+ impl < ' a , T : Account > IntoAccountInfo < ' a > for & ' a mut ( Address , T ) {
268268 fn into_account_info ( self ) -> AccountInfo < ' a > {
269269 let ( ref key, account) = self ;
270270 let ( lamports, data, owner, executable) = account. get ( ) ;
@@ -288,11 +288,11 @@ impl<'a, T: Account> IntoAccountInfo<'a> for &'a mut (Pubkey, T) {
288288/// ```
289289/// use solana_program_error::ProgramResult;
290290/// use solana_account_info::{AccountInfo, next_account_info};
291- /// use solana_pubkey::Pubkey ;
291+ /// use solana_address::Address ;
292292/// # use solana_program_error::ProgramError;
293293///
294294/// pub fn process_instruction(
295- /// program_id: &Pubkey ,
295+ /// program_id: &Address ,
296296/// accounts: &[AccountInfo],
297297/// instruction_data: &[u8],
298298/// ) -> ProgramResult {
@@ -304,13 +304,13 @@ impl<'a, T: Account> IntoAccountInfo<'a> for &'a mut (Pubkey, T) {
304304///
305305/// Ok(())
306306/// }
307- /// # let p = Pubkey ::new_unique();
307+ /// # let p = Address ::new_unique();
308308/// # let l = &mut 0;
309309/// # let d = &mut [0u8];
310310/// # let a = AccountInfo::new(&p, false, false, l, d, &p, false);
311311/// # let accounts = &[a.clone(), a];
312312/// # process_instruction(
313- /// # &Pubkey ::new_unique(),
313+ /// # &Address ::new_unique(),
314314/// # accounts,
315315/// # &[],
316316/// # )?;
@@ -337,11 +337,11 @@ pub fn next_account_info<'a, 'b, I: Iterator<Item = &'a AccountInfo<'b>>>(
337337/// ```
338338/// use solana_program_error::ProgramResult;
339339/// use solana_account_info::{AccountInfo, next_account_info, next_account_infos};
340- /// use solana_pubkey::Pubkey ;
340+ /// use solana_address::Address ;
341341/// # use solana_program_error::ProgramError;
342342///
343343/// pub fn process_instruction(
344- /// program_id: &Pubkey ,
344+ /// program_id: &Address ,
345345/// accounts: &[AccountInfo],
346346/// instruction_data: &[u8],
347347/// ) -> ProgramResult {
@@ -354,13 +354,13 @@ pub fn next_account_info<'a, 'b, I: Iterator<Item = &'a AccountInfo<'b>>>(
354354///
355355/// Ok(())
356356/// }
357- /// # let p = Pubkey ::new_unique();
357+ /// # let p = Address ::new_unique();
358358/// # let l = &mut 0;
359359/// # let d = &mut [0u8];
360360/// # let a = AccountInfo::new(&p, false, false, l, d, &p, false);
361361/// # let accounts = &[a.clone(), a.clone(), a.clone(), a.clone(), a];
362362/// # process_instruction(
363- /// # &Pubkey ::new_unique(),
363+ /// # &Address ::new_unique(),
364364/// # accounts,
365365/// # &[],
366366/// # )?;
@@ -390,16 +390,16 @@ impl<'a> AsRef<AccountInfo<'a>> for AccountInfo<'a> {
390390pub fn check_type_assumptions ( ) {
391391 use std:: mem:: offset_of;
392392
393- let key = Pubkey :: new_from_array ( [ 10 ; 32 ] ) ;
393+ let key = Address :: new_from_array ( [ 10 ; 32 ] ) ;
394394 let mut lamports = 31 ;
395395 let mut data = vec ! [ 1 , 2 , 3 , 4 , 5 ] ;
396- let owner = Pubkey :: new_from_array ( [ 22 ; 32 ] ) ;
396+ let owner = Address :: new_from_array ( [ 22 ; 32 ] ) ;
397397 let account_info = AccountInfo :: new ( & key, true , false , & mut lamports, & mut data, & owner, true ) ;
398398 let account_info_addr = & account_info as * const _ as u64 ;
399399
400400 // key
401401 assert_eq ! ( offset_of!( AccountInfo , key) , 0 ) ;
402- let key_ptr = ( account_info_addr) as * const & Pubkey ;
402+ let key_ptr = ( account_info_addr) as * const & Address ;
403403 unsafe {
404404 assert_eq ! ( * * key_ptr, key) ;
405405 }
@@ -420,7 +420,7 @@ pub fn check_type_assumptions() {
420420
421421 // owner
422422 assert_eq ! ( offset_of!( AccountInfo , owner) , 24 ) ;
423- let owner_ptr = ( account_info_addr + 24 ) as * const & Pubkey ;
423+ let owner_ptr = ( account_info_addr + 24 ) as * const & Address ;
424424 unsafe {
425425 assert_eq ! ( * * owner_ptr, owner) ;
426426 }
@@ -466,11 +466,11 @@ mod tests {
466466
467467 #[ test]
468468 fn test_next_account_infos ( ) {
469- let k1 = Pubkey :: new_unique ( ) ;
470- let k2 = Pubkey :: new_unique ( ) ;
471- let k3 = Pubkey :: new_unique ( ) ;
472- let k4 = Pubkey :: new_unique ( ) ;
473- let k5 = Pubkey :: new_unique ( ) ;
469+ let k1 = Address :: new_unique ( ) ;
470+ let k2 = Address :: new_unique ( ) ;
471+ let k3 = Address :: new_unique ( ) ;
472+ let k4 = Address :: new_unique ( ) ;
473+ let k5 = Address :: new_unique ( ) ;
474474 let l1 = & mut 0 ;
475475 let l2 = & mut 0 ;
476476 let l3 = & mut 0 ;
@@ -503,7 +503,7 @@ mod tests {
503503
504504 #[ test]
505505 fn test_account_info_as_ref ( ) {
506- let k = Pubkey :: new_unique ( ) ;
506+ let k = Address :: new_unique ( ) ;
507507 let l = & mut 0 ;
508508 let d = & mut [ 0u8 ] ;
509509 let info = AccountInfo :: new ( & k, false , false , l, d, & k, false ) ;
@@ -512,7 +512,7 @@ mod tests {
512512
513513 #[ test]
514514 fn test_account_info_debug_data ( ) {
515- let key = Pubkey :: new_unique ( ) ;
515+ let key = Address :: new_unique ( ) ;
516516 let mut lamports = 42 ;
517517 let mut data = vec ! [ 5 ; 80 ] ;
518518 let data_str = format ! ( "{:?}" , Hex ( & data[ ..MAX_DEBUG_ACCOUNT_DATA ] ) ) ;
0 commit comments