solana/sdk/src/native_loader.rs

37 lines
1.1 KiB
Rust
Raw Normal View History

//! The native loader native program.
use crate::{
account::{
Account, AccountSharedData, InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS,
},
clock::INITIAL_RENT_EPOCH,
};
2018-12-03 13:31:11 -08:00
crate::declare_id!("NativeLoader1111111111111111111111111111111");
2019-02-13 19:43:56 -08:00
/// Create an executable account with the given shared object name.
#[deprecated(
since = "1.5.17",
note = "Please use `create_loadable_account_for_test` instead"
)]
2021-03-09 13:06:07 -08:00
pub fn create_loadable_account(name: &str, lamports: u64) -> AccountSharedData {
create_loadable_account_with_fields(name, (lamports, INITIAL_RENT_EPOCH))
}
pub fn create_loadable_account_with_fields(
name: &str,
(lamports, rent_epoch): InheritableAccountFields,
) -> AccountSharedData {
AccountSharedData::from(Account {
lamports,
owner: id(),
data: name.as_bytes().to_vec(),
2019-02-13 19:43:56 -08:00
executable: true,
rent_epoch,
})
2019-02-13 19:43:56 -08:00
}
pub fn create_loadable_account_for_test(name: &str) -> AccountSharedData {
create_loadable_account_with_fields(name, DUMMY_INHERITABLE_ACCOUNT_FIELDS)
}