Resized accounts must be rent exempt

This commit is contained in:
Jack May
2022-02-24 17:49:33 -08:00
parent 82cb61dc36
commit 97d40ba3da
11 changed files with 636 additions and 122 deletions

View File

@@ -326,6 +326,21 @@ fn shared_new<T: WritableAccount>(lamports: u64, space: usize, owner: &Pubkey) -
)
}
fn shared_new_rent_epoch<T: WritableAccount>(
lamports: u64,
space: usize,
owner: &Pubkey,
rent_epoch: Epoch,
) -> T {
T::create(
lamports,
vec![0u8; space],
*owner,
bool::default(),
rent_epoch,
)
}
fn shared_new_ref<T: WritableAccount>(
lamports: u64,
space: usize,
@@ -434,6 +449,9 @@ impl Account {
) -> Result<RefCell<Self>, bincode::Error> {
shared_new_ref_data_with_space(lamports, state, space, owner)
}
pub fn new_rent_epoch(lamports: u64, space: usize, owner: &Pubkey, rent_epoch: Epoch) -> Self {
shared_new_rent_epoch(lamports, space, owner, rent_epoch)
}
pub fn deserialize_data<T: serde::de::DeserializeOwned>(&self) -> Result<T, bincode::Error> {
shared_deserialize_data(self)
}
@@ -490,6 +508,9 @@ impl AccountSharedData {
) -> Result<RefCell<Self>, bincode::Error> {
shared_new_ref_data_with_space(lamports, state, space, owner)
}
pub fn new_rent_epoch(lamports: u64, space: usize, owner: &Pubkey, rent_epoch: Epoch) -> Self {
shared_new_rent_epoch(lamports, space, owner, rent_epoch)
}
pub fn deserialize_data<T: serde::de::DeserializeOwned>(&self) -> Result<T, bincode::Error> {
shared_deserialize_data(self)
}