+ drain_profit_message
This commit is contained in:
parent
81cb814c91
commit
ef0a51c166
2 changed files with 50 additions and 17 deletions
|
|
@ -63,6 +63,11 @@ module B32 = struct
|
|||
include B32
|
||||
|
||||
let jsont = Jsont.of_of_string ~kind:"B32" B32.decode ~enc:B32.encode
|
||||
|
||||
let caqti =
|
||||
Caqti_type.custom
|
||||
~encode:(fun v -> Ok (B32.encode v))
|
||||
~decode:B32.decode Caqti_type.string
|
||||
end
|
||||
|
||||
module HashCode : sig
|
||||
|
|
@ -689,12 +694,12 @@ end
|
|||
|
||||
module DrainProfitsMessage = struct
|
||||
type t = {
|
||||
wtid: B32.t;
|
||||
debit_account_section: string;
|
||||
credit_payto_uri: string;
|
||||
wtid: B32.t;
|
||||
master_sig: MasterDrainProfit.t;
|
||||
date: Timestamp.t;
|
||||
amount: Amount.t;
|
||||
master_sig: MasterDrainProfit.t;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
|
|
|
|||
58
src/pg.ml
58
src/pg.ml
|
|
@ -41,6 +41,7 @@ module Caqti_type = struct
|
|||
(* todo: enum type for wire_method? *)
|
||||
let wire_method = Caqti_type.string
|
||||
let payto_uri = Caqti_type.string
|
||||
let b32 = Api.B32.caqti
|
||||
|
||||
include struct
|
||||
(* alias for hash *)
|
||||
|
|
@ -267,6 +268,46 @@ module Caqti_type = struct
|
|||
t7 payto_uri (option string) account_restrictions account_restrictions
|
||||
master_sig (option string) (option int))
|
||||
|
||||
let drain_profit_message =
|
||||
let master_sig = Bin_sig.MasterDrainProfit.caqti in
|
||||
Caqti_type.custom
|
||||
~encode:(fun
|
||||
DrainProfitsMessage.
|
||||
{
|
||||
wtid;
|
||||
debit_account_section;
|
||||
credit_payto_uri;
|
||||
date;
|
||||
amount;
|
||||
master_sig;
|
||||
}
|
||||
->
|
||||
Ok
|
||||
( wtid,
|
||||
debit_account_section,
|
||||
credit_payto_uri,
|
||||
date,
|
||||
amount,
|
||||
master_sig ))
|
||||
~decode:(fun
|
||||
( wtid,
|
||||
debit_account_section,
|
||||
credit_payto_uri,
|
||||
date,
|
||||
amount,
|
||||
master_sig )
|
||||
->
|
||||
Ok
|
||||
{
|
||||
wtid;
|
||||
debit_account_section;
|
||||
credit_payto_uri;
|
||||
date;
|
||||
amount;
|
||||
master_sig;
|
||||
})
|
||||
Caqti_type.(t6 b32 string string time amount master_sig)
|
||||
|
||||
include Caqti_request.Infix
|
||||
end
|
||||
|
||||
|
|
@ -501,24 +542,11 @@ let disable_wire =
|
|||
|
||||
let insert_drain_profit =
|
||||
let insert_drain_profit =
|
||||
let master_sig = Bin_sig.MasterDrainProfit.caqti in
|
||||
Caqti_type.(t6 string string payto_uri time amount master_sig ->. unit)
|
||||
Caqti_type.(drain_profit_message ->. unit)
|
||||
"INSERT INTO profit_drains (wtid, account_section, payto_uri, \
|
||||
trigger_date, amount, master_sig) VALUES ($1, $2, $3, $4, ($5,$6), $7)"
|
||||
in
|
||||
fun (module Conn : CONN)
|
||||
DrainProfitsMessage.
|
||||
{
|
||||
debit_account_section;
|
||||
credit_payto_uri;
|
||||
wtid;
|
||||
master_sig;
|
||||
date;
|
||||
amount;
|
||||
}
|
||||
->
|
||||
Conn.exec insert_drain_profit
|
||||
(wtid, debit_account_section, credit_payto_uri, date, amount, master_sig)
|
||||
fun (module Conn : CONN) v -> Conn.exec insert_drain_profit v
|
||||
|
||||
let insert_aml_officer =
|
||||
let exchange_do_insert_aml_officer =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue