File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -372,8 +372,14 @@ pub enum TokenInstruction<'a> {
372372 ///
373373 /// Accounts expected by this instruction:
374374 ///
375+ /// * Using runtime Rent sysvar
375376 /// 0. `[writable]` The native token account to sync with its underlying
376377 /// lamports.
378+ ///
379+ /// * Using Rent sysvar account
380+ /// 0. `[writable]` The native token account to sync with its underlying
381+ /// lamports.
382+ /// 1. `[]` Rent sysvar.
377383 SyncNative ,
378384 /// Like [`TokenInstruction::InitializeAccount2`], but does not require the
379385 /// Rent sysvar to be provided
Original file line number Diff line number Diff line change @@ -759,8 +759,13 @@ impl Processor {
759759 let native_account_info = next_account_info ( account_info_iter) ?;
760760 Self :: check_account_owner ( program_id, native_account_info) ?;
761761
762- let rent = Rent :: get ( ) ?;
763- let rent_exempt_reserve = rent. minimum_balance ( native_account_info. data_len ( ) ) ;
762+ let rent_exempt_reserve = if let Ok ( rent_sysvar_info) = next_account_info ( account_info_iter)
763+ {
764+ let rent = Rent :: from_account_info ( rent_sysvar_info) ?;
765+ rent. minimum_balance ( native_account_info. data_len ( ) )
766+ } else {
767+ Rent :: get ( ) ?. minimum_balance ( native_account_info. data_len ( ) )
768+ } ;
764769
765770 let mut native_account = Account :: unpack ( & native_account_info. data . borrow ( ) ) ?;
766771
You can’t perform that action at this time.
0 commit comments