|
@@ -2,21 +2,21 @@ use anchor_lang::prelude::*;
|
|
|
use anchor_lang::system_program;
|
|
|
|
|
|
|
|
|
-declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
|
|
+declare_id!("ED6f4gweAE7hWPQPXMt4kWxzDJne8VQEm9zkb1tMpFNB");
|
|
|
|
|
|
|
|
|
#[program]
|
|
|
pub mod rent_example {
|
|
|
use super::*;
|
|
|
|
|
|
- pub fn create_system_account(ctx: Context<CreateSystemAccount>) -> Result<()> {
|
|
|
+ pub fn create_system_account(ctx: Context<CreateSystemAccount>, address_data: AddressData) -> Result<()> {
|
|
|
|
|
|
msg!("Program invoked. Creating a system account...");
|
|
|
msg!(" New public key will be: {}", &ctx.accounts.new_account.key().to_string());
|
|
|
|
|
|
// Determine the necessary minimum rent by calculating the account's size
|
|
|
//
|
|
|
- let account_span = amount as usize;
|
|
|
+ let account_span = (address_data.try_to_vec()?).len();
|
|
|
let lamports_required = (Rent::get()?).minimum_balance(account_span);
|
|
|
|
|
|
msg!("Account span: {}", &account_span);
|
|
@@ -31,7 +31,7 @@ pub mod rent_example {
|
|
|
},
|
|
|
),
|
|
|
lamports_required,
|
|
|
- account_span,
|
|
|
+ account_span as u64,
|
|
|
&ctx.accounts.system_program.key(),
|
|
|
)?;
|
|
|
|
|
@@ -47,4 +47,10 @@ pub struct CreateSystemAccount<'info> {
|
|
|
#[account(mut)]
|
|
|
pub new_account: Signer<'info>,
|
|
|
pub system_program: Program<'info, System>,
|
|
|
+}
|
|
|
+
|
|
|
+#[derive(AnchorSerialize, AnchorDeserialize, Debug)]
|
|
|
+pub struct AddressData {
|
|
|
+ name: String,
|
|
|
+ address: String,
|
|
|
}
|