1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::{
    types::{OperationBody, RevokeSponsorshipOp, RevokeSponsorshipOpSigner},
    IntoPublicKey, LedgerKey, Operation, SignerKey, StellarSdkError,
};

impl Operation {
    pub fn new_revoke_sponsorship_ledger_entry(
        ledger_key: LedgerKey,
    ) -> Result<Operation, StellarSdkError> {
        Ok(Operation {
            source_account: None,
            body: OperationBody::RevokeSponsorship(
                RevokeSponsorshipOp::RevokeSponsorshipLedgerEntry(ledger_key),
            ),
        })
    }

    pub fn new_revoke_sponsorship_signer<T: IntoPublicKey>(
        account_id: T,
        signer_key: SignerKey,
    ) -> Result<Operation, StellarSdkError> {
        Ok(Operation {
            source_account: None,
            body: OperationBody::RevokeSponsorship(RevokeSponsorshipOp::RevokeSponsorshipSigner(
                RevokeSponsorshipOpSigner {
                    account_id: account_id.into_public_key()?,
                    signer_key,
                },
            )),
        })
    }
}