11//! Program instruction helpers.
22
3- use {
4- crate :: { ConfigKeys , ID } ,
5- bincode:: serialized_size,
6- solana_program:: {
7- instruction:: { AccountMeta , Instruction } ,
8- pubkey:: Pubkey ,
9- system_instruction,
10- } ,
11- } ;
3+ pub use solana_config_interface:: instruction:: { create_account_with_max_config_space, store} ;
4+ use solana_program:: { instruction:: Instruction , pubkey:: Pubkey } ;
125
136/// Trait defining config state to be stored at the end of the account data.
147#[ deprecated( since = "1.0.0" , note = "This trait is no longer supported" ) ]
@@ -17,12 +10,6 @@ pub trait ConfigState: serde::Serialize + Default {
1710 fn max_space ( ) -> u64 ;
1811}
1912
20- fn initialize_account < T : Default + serde:: Serialize > ( config_pubkey : & Pubkey ) -> Instruction {
21- let account_metas = vec ! [ AccountMeta :: new( * config_pubkey, true ) ] ;
22- let account_data = ( ConfigKeys { keys : vec ! [ ] } , T :: default ( ) ) ;
23- Instruction :: new_with_bincode ( ID , & account_data, account_metas)
24- }
25-
2613/// Create a new, empty configuration account
2714#[ deprecated(
2815 since = "1.0.0" ,
@@ -43,41 +30,3 @@ pub fn create_account<T: ConfigState>(
4330 keys,
4431 )
4532}
46-
47- /// Create a new, empty configuration account
48- pub fn create_account_with_max_config_space < T : Default + serde:: Serialize > (
49- from_account_pubkey : & Pubkey ,
50- config_account_pubkey : & Pubkey ,
51- lamports : u64 ,
52- max_config_space : u64 ,
53- keys : Vec < ( Pubkey , bool ) > ,
54- ) -> Vec < Instruction > {
55- let space = max_config_space. saturating_add ( serialized_size ( & ConfigKeys { keys } ) . unwrap ( ) ) ;
56- vec ! [
57- system_instruction:: create_account(
58- from_account_pubkey,
59- config_account_pubkey,
60- lamports,
61- space,
62- & ID ,
63- ) ,
64- initialize_account:: <T >( config_account_pubkey) ,
65- ]
66- }
67-
68- /// Store new data in a configuration account
69- pub fn store < T : serde:: Serialize > (
70- config_account_pubkey : & Pubkey ,
71- is_config_signer : bool ,
72- keys : Vec < ( Pubkey , bool ) > ,
73- data : & T ,
74- ) -> Instruction {
75- let mut account_metas = vec ! [ AccountMeta :: new( * config_account_pubkey, is_config_signer) ] ;
76- for ( signer_pubkey, _) in keys. iter ( ) . filter ( |( _, is_signer) | * is_signer) {
77- if signer_pubkey != config_account_pubkey {
78- account_metas. push ( AccountMeta :: new ( * signer_pubkey, true ) ) ;
79- }
80- }
81- let account_data = ( ConfigKeys { keys } , data) ;
82- Instruction :: new_with_bincode ( ID , & account_data, account_metas)
83- }
0 commit comments