import { cryptly } from "cryptly" import { isoly } from "isoly" import { isly } from "isly" import { Balances } from "../Balances" import { Rail } from "../Rail" import { Rule } from "../Rule" import { Charge as AccountCharge } from "./Charge" import { Creatable as AccountCreatable } from "./Creatable" import { Details as AccountDetails } from "./Details" import { History as AccountHistory } from "./History" import { Status as AccountStatus } from "./Status" import { Type as AccountType } from "./Type" export interface Account extends Account.Creatable { id: cryptly.Identifier created: isoly.DateTime organization: string balances: Balances rails: Rail.Address[] details?: Account.Details counterparts?: Record key?: string charges?: AccountCharge rules?: Rule[] status: Account.Status type: Account.Type } export namespace Account { export import Charge = AccountCharge export import Creatable = AccountCreatable export import Status = AccountStatus export import History = AccountHistory export import Details = AccountDetails export import Type = AccountType export const type = Creatable.type.extend({ id: isly.string(), created: isly.fromIs("isoly.DateTime", isoly.DateTime.is), organization: isly.string(), balances: Balances.type, rails: Rail.Address.type.array(), details: Details.type.optional(), counterparts: isly.record>(isly.string(), Rail.Address.type).optional(), key: isly.string().optional(), charges: AccountCharge.type.optional(), rules: Rule.type.array().optional(), status: AccountStatus.type, type: Type.type, }) export function isIdentifier(value: cryptly.Identifier | any): value is cryptly.Identifier { return cryptly.Identifier.is(value, 8) } }