/**
 * Milestone
 */
type BaseMilestone = {
    /**
     * Text describing the function of the milestone.
     */
    description: string;
    /**
     * Milestone status. Ex: Approved, In dispute, etc...
     */
    status?: string;
    /**
     * Evidence of work performed by the service provider.
     */
    evidence?: string;
};
/**
 * Single Release Milestone
 */
type SingleReleaseMilestone = BaseMilestone & {
    /**
     * Approved flag, only if the escrow is single-release
     */
    approved?: boolean;
};
/**
 * Multi Release Milestone
 */
type MultiReleaseMilestone = BaseMilestone & {
    /**
     * Amount to be transferred upon completion of this milestone
     */
    amount: number;
    /**
     * Flags validating certain milestone life states, only if the escrow is multi-release
     */
    flags?: Flags;
};
/**
 * Single Release Escrow
 */
type SingleReleaseEscrow = {
    /**
     * Address of the user signing the contract transaction
     */
    signer: string;
    /**
     * ID (address) that identifies the escrow contract
     */
    contractId: string;
    /**
     * Unique identifier for the escrow
     */
    engagementId: string;
    /**
     * Name of the escrow
     */
    title: string;
    /**
     * Roles that make up the escrow structure
     */
    roles: Roles;
    /**
     * Text describing the function of the escrow
     */
    description: string;
    /**
     * Amount to be transferred upon completion of escrow milestones
     */
    amount: number;
    /**
     * Commission that the platform will receive when the escrow is completed
     */
    platformFee: number;
    /**
     * Amount of the token (XLM, USDC, EURC, etc) in the smart contract.
     */
    balance: number;
    /**
     * Objectives to be completed to define the escrow as completed
     */
    milestones: SingleReleaseMilestone[];
    /**
     * Flags validating certain escrow life states
     */
    flags?: Flags;
    /**
     * Information on the trustline that will manage the movement of funds in escrow
     */
    trustline: Trustline;
    /**
     * Field used to identify the recipient's address in transactions through an intermediary account. This value is included as a memo in the transaction and allows the funds to be correctly routed to the wallet of the specified recipient
     */
    receiverMemo?: number;
};
/**
 * Multi Release Escrow
 */
type MultiReleaseEscrow = Omit<SingleReleaseEscrow, "milestones" | "flags" | "amount"> & {
    milestones: MultiReleaseMilestone[];
};
/**
 * Trustline
 */
type Trustline = {
    /**
     * Public address establishing permission to accept and use a specific token.
     */
    address: string;
    /**
     * Number of decimals into which the token is divided.
     */
    decimals: number;
};
/**
 * Roles
 */
type Roles = {
    /**
     * Address of the entity requiring the service.
     */
    approver: string;
    /**
     * Address of the entity providing the service.
     */
    serviceProvider: string;
    /**
     * Address of the entity that owns the escrow
     */
    platformAddress: string;
    /**
     * Address of the user in charge of releasing the escrow funds to the service provider.
     */
    releaseSigner: string;
    /**
     * Address in charge of resolving disputes within the escrow.
     */
    disputeResolver: string;
    /**
     * Address where escrow proceeds will be sent to
     */
    receiver: string;
};
/**
 * Flags
 */
type Flags = {
    /**
     * Flag indicating that an escrow is in dispute.
     */
    disputed?: boolean;
    /**
     * Flag indicating that escrow funds have already been released.
     */
    released?: boolean;
    /**
     * Flag indicating that a disputed escrow has already been resolved.
     */
    resolved?: boolean;
    /**
     * Flag indicating whether a milestone has been approved by the approver.
     */
    approved?: boolean;
};

/**
 * The base URL for the Trustless Work API
 */
type baseURL = "https://api.trustlesswork.com" | "https://dev.api.trustlesswork.com";
/**
 * Escrow Type
 */
type EscrowType = "single-release" | "multi-release";
/**
 * Unique possible statuses for a Trustless Work request
 */
type Status = "SUCCESS" | "FAILED";

/**
 * Escrow's Response like fund, release, change, etc ...
 */
type EscrowRequestResponse = {
    /**
     * Status of the request
     */
    status: Status;
    /**
     * Unsigned transaction
     */
    unsignedTransaction?: string;
};
/**
 * Send Transaction Response
 */
type SendTransactionResponse = {
    /**
     * Status of the request
     */
    status: Status;
    /**
     * Message of the request
     */
    message: string;
};
/**
 * Initialize Escrow Response
 */
type InitializeSingleReleaseEscrowResponse = EscrowRequestResponse & {
    /**
     * ID (address) that identifies the escrow contract
     */
    contractId: string;
    /**
     * Escrow data
     */
    escrow: SingleReleaseEscrow;
    /**
     * Message of the request
     */
    message: string;
};
/**
 * Initialize Multi Release Escrow Response
 */
type InitializeMultiReleaseEscrowResponse = InitializeSingleReleaseEscrowResponse & {
    /**
     * Escrow data
     */
    escrow: MultiReleaseEscrow;
};
/**
 * Update Escrow Response
 */
type UpdateSingleReleaseEscrowResponse = InitializeSingleReleaseEscrowResponse;
/**
 * Update Multi Release Escrow Response
 */
type UpdateMultiReleaseEscrowResponse = InitializeMultiReleaseEscrowResponse;
/**
 * Get Balances Response
 */
type GetEscrowBalancesResponse = {
    /**
     * Address of the escrow
     */
    address: string;
    /**
     * Balance of the escrow
     */
    balance: number;
};

/**
 * Documentation: https://docs.trustlesswork.com/trustless-work/developer-resources/quickstart/integration-demo-project/entities
 */
/**
 * Single Release Milestone Payload
 */
type SingleReleaseMilestonePayload = {
    /**
     * Text describing the function of the milestone
     */
    description: string;
};
/**
 * Multi Release Milestone Payload
 */
type MultiReleaseMilestonePayload = {
    /**
     * Text describing the function of the milestone
     */
    description: string;
    /**
     * Amount to be transferred upon completion of this milestone
     */
    amount: number;
};
/**
 * Single Release Initialize Escrow Payload
 */
type InitializeSingleReleaseEscrowPayload = Omit<SingleReleaseEscrow, "contractId" | "balance" | "milestones"> & {
    /**
     * Objectives to be completed to define the escrow as completed
     */
    milestones: SingleReleaseMilestonePayload[];
};
/**
 * Multi Release Initialize Escrow Payload
 */
type InitializeMultiReleaseEscrowPayload = Omit<MultiReleaseEscrow, "contractId" | "balance" | "milestones"> & {
    /**
     * Objectives to be completed to define the escrow as completed
     */
    milestones: MultiReleaseMilestonePayload[];
};
/**
 * Single Release Update Escrow Payload
 */
type UpdateSingleReleaseEscrowPayload = {
    /**
     * ID (address) that identifies the escrow contract
     */
    contractId: string;
    /**
     * Escrow data
     */
    escrow: Omit<SingleReleaseEscrow, "contractId" | "signer" | "balance">;
    /**
     * Address of the user signing the contract transaction
     */
    signer: string;
};
/**
 * Multi Release Update Escrow Payload
 */
type UpdateMultiReleaseEscrowPayload = {
    /**
     * ID (address) that identifies the escrow contract
     */
    contractId: string;
    /**
     * Escrow data
     */
    escrow: Omit<MultiReleaseEscrow, "contractId" | "signer" | "balance">;
    /**
     * Address of the user signing the contract transaction
     */
    signer: string;
};
/**
 * Change Milestone Status Payload, this can be a single-release or multi-release
 */
type ChangeMilestoneStatusPayload = {
    /**
     * ID (address) that identifies the escrow contract
     */
    contractId: string;
    /**
     * Index of the milestone to be updated
     */
    milestoneIndex: string;
    /**
     * New status of the milestone
     */
    newStatus: string;
    /**
     * New evidence of work performed by the service provider.
     */
    newEvidence?: string;
    /**
     * Address of the entity providing the service.
     */
    serviceProvider: string;
};
/**
 * Approve Milestone Payload, this can be a single-release or multi-release
 */
type ApproveMilestonePayload = Omit<ChangeMilestoneStatusPayload, "serviceProvider" | "newStatus"> & {
    /**
     * Address of the entity requiring the service.
     */
    approver: string;
    /**
     * New flag value of the milestone
     */
    newFlag: boolean;
};
/**
 * Single Release Start Dispute Payload. This starts a dispute for the entire escrow.
 */
type SingleReleaseStartDisputePayload = {
    /**
     * ID (address) that identifies the escrow contract
     */
    contractId: string;
    /**
     * Address of the user signing the contract transaction
     */
    signer: string;
};
/**
 * Multi Release Start Dispute Payload. This starts a dispute for a specific milestone.
 */
type MultiReleaseStartDisputePayload = SingleReleaseStartDisputePayload & {
    /**
     * Index of the milestone to be disputed
     */
    milestoneIndex: string;
};
/**
 * Resolve Dispute Payload
 */
type SingleReleaseResolveDisputePayload = {
    /**
     * ID (address) that identifies the escrow contract
     */
    contractId: string;
    /**
     * Address in charge of resolving disputes within the escrow.
     */
    disputeResolver: string;
    /**
     * Amount of funds to be returned to the approver based on the global amount.
     */
    approverFunds: string;
    /**
     * Amount of funds to be returned to the receiver based on the global amount.
     */
    receiverFunds: string;
};
/**
 * Multi Release Resolve Dispute Payload
 */
type MultiReleaseResolveDisputePayload = SingleReleaseResolveDisputePayload & {
    /**
     * Index of the milestone to be resolved
     */
    milestoneIndex: string;
};
/**
 * Fund Escrow Payload, this can be a single-release or multi-release
 */
type FundEscrowPayload = {
    /**
     * Amount to be transferred upon completion of escrow milestones
     */
    amount: number;
    /**
     * ID (address) that identifies the escrow contract
     */
    contractId: string;
    /**
     * Address of the user signing the contract transaction
     */
    signer: string;
};
/**
 * Get Escrow Params
 */
type GetEscrowParams = {
    /**
     * ID (address) that identifies the escrow contract
     */
    contractId: string;
    /**
     * Address of the user signing the contract transaction
     */
    signer: string;
};
/**
 * Single Release Release Funds Payload
 */
type SingleReleaseReleaseFundsPayload = {
    /**
     * ID (address) that identifies the escrow contract
     */
    contractId: string;
    /**
     * Address of the user in charge of releasing the escrow funds to the service provider.
     */
    releaseSigner: string;
    /**
     * Address of the user signing the contract transaction
     */
    signer: string;
};
/**
 * Multi Release Release Funds Payload
 */
type MultiReleaseReleaseFundsPayload = SingleReleaseReleaseFundsPayload & {
    /**
     * Index of the milestone to be released
     */
    milestoneIndex: string;
};
/**
 * Get Balance Params
 */
type GetBalanceParams = {
    /**
     * Address of the user signing the contract transaction
     */
    signer: string;
    /**
     * Addresses of the escrows to get the balance
     */
    addresses: string[];
};

export type { ApproveMilestonePayload, ChangeMilestoneStatusPayload, EscrowRequestResponse, EscrowType, Flags, FundEscrowPayload, GetBalanceParams, GetEscrowBalancesResponse, GetEscrowParams, InitializeMultiReleaseEscrowPayload, InitializeMultiReleaseEscrowResponse, InitializeSingleReleaseEscrowPayload, InitializeSingleReleaseEscrowResponse, MultiReleaseEscrow, MultiReleaseMilestone, MultiReleaseReleaseFundsPayload, MultiReleaseResolveDisputePayload, MultiReleaseStartDisputePayload, Roles, SendTransactionResponse, SingleReleaseEscrow, SingleReleaseMilestone, SingleReleaseReleaseFundsPayload, SingleReleaseResolveDisputePayload, SingleReleaseStartDisputePayload, Status, Trustline, UpdateMultiReleaseEscrowPayload, UpdateMultiReleaseEscrowResponse, UpdateSingleReleaseEscrowPayload, UpdateSingleReleaseEscrowResponse, baseURL };
