import { AccountThresholdsFactory , SignerFactory } from "./" ; import { AccountValues , IAccountValues } from "../" ; import { publicKeyFromXDR } from "../../util/xdr" ; export class AccountValuesFactory { public static fromXDR ( xdr ) { const id = publicKeyFromXDR ( xdr ) ; const signers = xdr . signers ( ) . map ( ( s ) => SignerFactory . fromXDR ( s ) ) ; const thresholds = AccountThresholdsFactory . fromValue ( xdr . thresholds ( ) ) ; signers . unshift ( SignerFactory . self ( id , thresholds . masterWeight ) ) ; const data = { id , balance : xdr . balance ( ) . toString ( ) , sequenceNumber : xdr . seqNum ( ) . toString ( ) , numSubentries : xdr . numSubEntries ( ) , inflationDestination : xdr . inflationDest ( ) || null , homeDomain : xdr . homeDomain ( ) , thresholds , signers } ; return new AccountValues ( data ) ; } }