1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
use crate::{
    types::{CreateAccountOp, OperationBody},
    IntoAccountId, IntoAmount, Operation, StellarSdkError,
};

impl Operation {
    pub fn new_create_account<T: IntoAccountId, U: IntoAmount>(
        destination: T,
        starting_balance: U,
    ) -> Result<Operation, StellarSdkError> {
        Ok(Operation {
            source_account: None,
            body: OperationBody::CreateAccount(CreateAccountOp {
                destination: destination.into_account_id()?,
                starting_balance: starting_balance.into_stroop_amount(true)?,
            }),
        })
    }
}