Resized accounts must be rent exempt
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
@ -27,6 +27,20 @@ pub fn create_account(
|
||||
Transaction::new(&[from_keypair, to_keypair], message, recent_blockhash)
|
||||
}
|
||||
|
||||
/// Create and sign new SystemInstruction::Allocate transaction
|
||||
pub fn allocate(
|
||||
payer_keypair: &Keypair,
|
||||
account_keypair: &Keypair,
|
||||
recent_blockhash: Hash,
|
||||
space: u64,
|
||||
) -> Transaction {
|
||||
let payer_pubkey = payer_keypair.pubkey();
|
||||
let account_pubkey = account_keypair.pubkey();
|
||||
let instruction = system_instruction::allocate(&account_pubkey, space);
|
||||
let message = Message::new(&[instruction], Some(&payer_pubkey));
|
||||
Transaction::new(&[payer_keypair, account_keypair], message, recent_blockhash)
|
||||
}
|
||||
|
||||
/// Create and sign new system_instruction::Assign transaction
|
||||
pub fn assign(from_keypair: &Keypair, recent_blockhash: Hash, program_id: &Pubkey) -> Transaction {
|
||||
let from_pubkey = from_keypair.pubkey();
|
||||
|
Reference in New Issue
Block a user