stellar_xdr/next/
account_conversions.rs

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
use super::{AccountId, MuxedAccount, PublicKey};

impl From<AccountId> for MuxedAccount {
    fn from(account_id: AccountId) -> Self {
        account_id.0.into()
    }
}

impl From<PublicKey> for MuxedAccount {
    fn from(public_key: PublicKey) -> Self {
        match public_key {
            PublicKey::PublicKeyTypeEd25519(k) => MuxedAccount::Ed25519(k),
        }
    }
}

impl MuxedAccount {
    #[must_use]
    pub fn account_id(self) -> AccountId {
        match self {
            MuxedAccount::Ed25519(k) => AccountId(PublicKey::PublicKeyTypeEd25519(k)),
            MuxedAccount::MuxedEd25519(m) => AccountId(PublicKey::PublicKeyTypeEd25519(m.ed25519)),
        }
    }
}