substrate_stellar_sdk/xdr/impls/operations/
create_claimable_balance.rs1use sp_std::vec::Vec;
2
3use crate::{
4 compound_types::LimitedVarArray,
5 types::{CreateClaimableBalanceOp, OperationBody},
6 Asset, Claimant, IntoAmount, Operation, StellarSdkError,
7};
8
9impl Operation {
10 pub fn new_create_claimable_balance<S: IntoAmount>(
11 asset: Asset,
12 amount: S,
13 claimants: Vec<Claimant>,
14 ) -> Result<Operation, StellarSdkError> {
15 if claimants.is_empty() {
16 return Err(StellarSdkError::EmptyClaimants)
17 }
18
19 Ok(Operation {
20 source_account: None,
21 body: OperationBody::CreateClaimableBalance(CreateClaimableBalanceOp {
22 asset,
23 amount: amount.into_stroop_amount(false)?,
24 claimants: LimitedVarArray::new(claimants)?,
25 }),
26 })
27 }
28}