(* actions.mli *)

open Legilogic_lib
open Yojsoning
open Signing
open Types
open Action

open Alacris_lib
open Side_chain

val error_json : ('a, unit, string, yojson) format4 -> 'a
(** make JSON record with error *)

val get_all_balances_on_trent : unit -> yojson Lwt_exn.t
(** balances for all users *)

val get_transaction_rate_on_trent : unit -> yojson
(** timestamped transaction rate for last minute *)

val get_proof : Revision.t -> yojson Lwt_exn.t
(** Merkle proof for transaction with given tx_revision *)

val apply_main_chain_thread : int -> yojson
(** view deposit/withdrawal thread result *)


(* Main chain -> side chain *)
val deposit_to : operator:Address.t (* Trent's address for now *)
              -> RequestGuid.t      (* UUIDv4 generated by user initiating request *)
              -> Address.t          (* Recipient on side chain *)
              -> TokenAmount.t      (* Number of tokens *)
              -> yojson

(* Side chain -> main chain *)
val withdrawal_from : operator:Address.t (* Trent's address for now *)
                   -> RequestGuid.t      (* UUIDv4 generated by user initiating request *)
                   -> Address.t          (* Side chain source wallet *)
                   -> TokenAmount.t      (* Number of tokens *)
                   -> yojson

(* Side chain user A -> side chain user B *)
val payment_on : operator:Address.t (* Trent's address for now *)
              -> RequestGuid.t      (* UUIDv4 generated by user initiating request *)
              -> Address.t          (* Sender *)
              -> Address.t          (* Recipient *)
              -> TokenAmount.t      (* Number of tokens *)
              -> string             (* A free-form "memo" field *)
              -> yojson

val get_balance_on : operator:Address.t -> Address.t -> yojson Lwt_exn.t
(** balance for particular user *)

val get_recent_user_transactions_on_trent : Address.t -> Revision.t option -> yojson Lwt_exn.t
(** int is max number of transactions *)

val get_status_on_trent_and_main_chain : Address.t -> yojson Lwt_exn.t
(** user accounts information on side and main chains *)

val thread_pending_json : yojson
(** JSON returned when a thread is still working *)
