@@ -115,7 +115,11 @@ static BUILTINS: &[Builtin] = &[
115115 /* ... */
116116] ;
117117
118- fn builtin_program_account ( program_id : & Pubkey , name : & str ) -> ( Pubkey , AccountSharedData ) {
118+ /// Create a key and account for a builtin program.
119+ pub fn create_keyed_account_for_builtin_program (
120+ program_id : & Pubkey ,
121+ name : & str ,
122+ ) -> ( Pubkey , AccountSharedData ) {
119123 let data = name. as_bytes ( ) . to_vec ( ) ;
120124 let lamports = Rent :: default ( ) . minimum_balance ( data. len ( ) ) ;
121125 let account = AccountSharedData :: from ( Account {
@@ -129,19 +133,24 @@ fn builtin_program_account(program_id: &Pubkey, name: &str) -> (Pubkey, AccountS
129133}
130134
131135/// Get the key and account for the system program.
132- pub fn system_program ( ) -> ( Pubkey , AccountSharedData ) {
133- builtin_program_account ( & BUILTINS [ 0 ] . program_id , BUILTINS [ 0 ] . name )
136+ pub fn keyed_account_for_system_program ( ) -> ( Pubkey , AccountSharedData ) {
137+ create_keyed_account_for_builtin_program ( & BUILTINS [ 0 ] . program_id , BUILTINS [ 0 ] . name )
134138}
135139
136- /// Get the key and account for the BPF Loader Upgradeable program.
137- pub fn bpf_loader_upgradeable_program ( ) -> ( Pubkey , AccountSharedData ) {
138- builtin_program_account ( & BUILTINS [ 1 ] . program_id , BUILTINS [ 1 ] . name )
140+ /// Get the key and account for the BPF Loader v2 program.
141+ pub fn keyed_account_for_bpf_loader_v2_program ( ) -> ( Pubkey , AccountSharedData ) {
142+ create_keyed_account_for_builtin_program ( & BUILTINS [ 1 ] . program_id , BUILTINS [ 1 ] . name )
143+ }
144+
145+ /// Get the key and account for the BPF Loader v3 (Upgradeable) program.
146+ pub fn keyed_account_for_bpf_loader_v3_program ( ) -> ( Pubkey , AccountSharedData ) {
147+ create_keyed_account_for_builtin_program ( & BUILTINS [ 1 ] . program_id , BUILTINS [ 1 ] . name )
139148}
140149
141150/* ... */
142151
143152/// Create a BPF Loader 2 program account.
144- pub fn program_account_loader_2 ( elf : & [ u8 ] ) -> AccountSharedData {
153+ pub fn create_program_account_loader_v2 ( elf : & [ u8 ] ) -> AccountSharedData {
145154 let lamports = Rent :: default ( ) . minimum_balance ( elf. len ( ) ) ;
146155 AccountSharedData :: from ( Account {
147156 lamports,
@@ -152,8 +161,8 @@ pub fn program_account_loader_2(elf: &[u8]) -> AccountSharedData {
152161 } )
153162}
154163
155- /// Create a BPF Loader Upgradeable program account.
156- pub fn program_account ( program_id : & Pubkey ) -> AccountSharedData {
164+ /// Create a BPF Loader v3 ( Upgradeable) program account.
165+ pub fn create_program_account_loader_v3 ( program_id : & Pubkey ) -> AccountSharedData {
157166 let programdata_address =
158167 Pubkey :: find_program_address ( & [ program_id. as_ref ( ) ] , & bpf_loader_upgradeable:: id ( ) ) . 0 ;
159168 let data = bincode:: serialize ( & UpgradeableLoaderState :: Program {
@@ -170,8 +179,8 @@ pub fn program_account(program_id: &Pubkey) -> AccountSharedData {
170179 } )
171180}
172181
173- /// Create a BPF Loader Upgradeable program data account.
174- pub fn program_data_account ( elf : & [ u8 ] ) -> AccountSharedData {
182+ /// Create a BPF Loader v3 ( Upgradeable) program data account.
183+ pub fn create_program_data_account_loader_v3 ( elf : & [ u8 ] ) -> AccountSharedData {
175184 let data = {
176185 let elf_offset = UpgradeableLoaderState :: size_of_programdata_metadata ( ) ;
177186 let data_len = elf_offset + elf. len ( ) ;
@@ -197,10 +206,16 @@ pub fn program_data_account(elf: &[u8]) -> AccountSharedData {
197206 } )
198207}
199208
200- /// Create a BPF Loader Upgradeable program and program data account.
209+ /// Create a BPF Loader v3 ( Upgradeable) program and program data account.
201210///
202211/// Returns a tuple, where the first element is the program account and the
203212/// second element is the program data account.
204- pub fn program_accounts ( program_id : & Pubkey , elf : & [ u8 ] ) -> ( AccountSharedData , AccountSharedData ) {
205- ( program_account ( program_id) , program_data_account ( elf) )
213+ pub fn create_program_account_pair_loader_v3 (
214+ program_id : & Pubkey ,
215+ elf : & [ u8 ] ,
216+ ) -> ( AccountSharedData , AccountSharedData ) {
217+ (
218+ create_program_account_loader_v3 ( program_id) ,
219+ create_program_data_account_loader_v3 ( elf) ,
220+ )
206221}
0 commit comments