Skip to content

Commit 8925931

Browse files
committed
dont break the api
1 parent adace9c commit 8925931

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

clients/rust/src/instructions_bincode.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,35 @@ fn initialize_account<T: Default + serde::Serialize>(config_pubkey: &Pubkey) ->
2424
}
2525

2626
/// Create a new, empty configuration account
27-
pub fn create_account<T: Default + serde::Serialize>(
27+
#[deprecated(
28+
since = "1.0.0",
29+
note = "The `ConfigState` trait is no longer supported"
30+
)]
31+
#[allow(deprecated)]
32+
pub fn create_account<T: ConfigState>(
2833
from_account_pubkey: &Pubkey,
2934
config_account_pubkey: &Pubkey,
3035
lamports: u64,
31-
max_space: u64,
3236
keys: Vec<(Pubkey, bool)>,
3337
) -> Vec<Instruction> {
34-
let space = max_space.saturating_add(serialized_size(&ConfigKeys { keys }).unwrap());
38+
create_account_with_max_config_space::<T>(
39+
from_account_pubkey,
40+
config_account_pubkey,
41+
lamports,
42+
T::max_space(),
43+
keys,
44+
)
45+
}
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());
3556
vec![
3657
system_instruction::create_account(
3758
from_account_pubkey,

program/tests/functional.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ fn test_config_initialize_no_panic() {
545545
let config = Pubkey::new_unique();
546546
let max_space = serialized_size(&MyConfig::default()).unwrap();
547547

548-
let instructions = config_instruction::create_account::<MyConfig>(
548+
let instructions = config_instruction::create_account_with_max_config_space::<MyConfig>(
549549
&Pubkey::new_unique(),
550550
&config,
551551
1,

0 commit comments

Comments
 (0)