+ test disable-auditor/wire/drain
This commit is contained in:
parent
c04fda0f1e
commit
7c989e590a
9 changed files with 386 additions and 193 deletions
90
src/pg.ml
90
src/pg.ml
|
|
@ -115,43 +115,23 @@ let insert_signkey_revocation =
|
|||
fun (module Conn : CONN) exchange_pub master_sig ->
|
||||
Conn.exec req (exchange_pub, master_sig)
|
||||
|
||||
let get_auditor_timestamp =
|
||||
let find_auditor =
|
||||
let req =
|
||||
Caqti_type.(eddsa_pub ->? time)
|
||||
"SELECT last_change FROM auditors WHERE auditor_pub=$1"
|
||||
Caqti_type.(eddsa_pub ->? auditor)
|
||||
"SELECT auditor_pub, auditor_name, auditor_url, last_change, is_active \
|
||||
FROM auditors WHERE auditor_pub=$1"
|
||||
in
|
||||
fun (module Conn : CONN) auditor_pub -> Conn.find_opt req auditor_pub
|
||||
|
||||
let insert_auditor =
|
||||
let req =
|
||||
Caqti_type.(t4 eddsa_pub string string time ->. unit)
|
||||
"INSERT INTO auditors (auditor_pub, auditor_name, auditor_url, \
|
||||
is_active, last_change) VALUES ($1, $2, $3, true, $4)"
|
||||
in
|
||||
fun (module Conn : CONN)
|
||||
AuditorSetupMessage.
|
||||
{ auditor_url; auditor_name; auditor_pub; master_sig= _; validity_start }
|
||||
-> Conn.exec req (auditor_pub, auditor_name, auditor_url, validity_start)
|
||||
|
||||
let update_auditor =
|
||||
let req =
|
||||
Caqti_type.(t5 eddsa_pub string string bool time ->. unit)
|
||||
"UPDATE auditors SET auditor_url=$2, auditor_name=$3, is_active=$4, \
|
||||
last_change=$5 WHERE auditor_pub=$1"
|
||||
Caqti_type.(auditor ->. unit)
|
||||
"INSERT INTO auditors (auditor_pub, auditor_name, auditor_url, \
|
||||
last_change, is_active) VALUES ($1, $2, $3, $4, $5) ON CONFLICT \
|
||||
(auditor_pub) DO UPDATE SET auditor_name=$2, auditor_url=$3, \
|
||||
last_change=$4, is_active=$5"
|
||||
in
|
||||
fun (module Conn : CONN)
|
||||
AuditorSetupMessage.
|
||||
{ auditor_url; auditor_name; auditor_pub; master_sig= _; validity_start }
|
||||
-> Conn.exec req (auditor_pub, auditor_url, auditor_name, true, validity_start)
|
||||
|
||||
let disable_auditor =
|
||||
let req =
|
||||
Caqti_type.(t5 eddsa_pub string string bool time ->. unit)
|
||||
"UPDATE auditors SET auditor_url=$2, auditor_name=$3, is_active=$4, \
|
||||
last_change=$5 WHERE auditor_pub=$1"
|
||||
in
|
||||
fun (module Conn : CONN) ~auditor_pub ~change_date ->
|
||||
Conn.exec req (auditor_pub, "", "", false, change_date)
|
||||
fun (module Conn : CONN) auditor -> Conn.exec req auditor
|
||||
|
||||
let insert_auditor_denom_sig =
|
||||
let req =
|
||||
|
|
@ -167,6 +147,7 @@ let insert_auditor_denom_sig =
|
|||
Conn.exec req (auditor_pub, h_denom_pub, auditor_sig)
|
||||
|
||||
(* todo auditors
|
||||
map to Auditor.t record
|
||||
maybe check that url and name are unique/same for each auditor_pub
|
||||
and do the ht logic out of pg.ml? *)
|
||||
(* this does not return auditors that are not auditing any denom *)
|
||||
|
|
@ -274,46 +255,30 @@ let insert_global_fees =
|
|||
in
|
||||
fun (module Conn : CONN) v -> Conn.exec req v
|
||||
|
||||
let get_wire_timestamp =
|
||||
let find_wire =
|
||||
let req =
|
||||
Caqti_type.(payto_uri ->? time)
|
||||
"SELECT last_change FROM wire_accounts WHERE payto_uri=$1"
|
||||
Caqti_type.(payto_uri ->? exchange_wire_account)
|
||||
"SELECT payto_uri, conversion_url, debit_restrictions::TEXT, \
|
||||
credit_restrictions::TEXT, master_sig, bank_label, priority FROM \
|
||||
wire_accounts WHERE payto_uri=$1"
|
||||
in
|
||||
fun (module Conn : CONN) ~payto_uri -> Conn.find_opt req payto_uri
|
||||
|
||||
let insert_wire =
|
||||
let update_wire =
|
||||
let req =
|
||||
Caqti_type.(t3 exchange_wire_account bool time ->. unit)
|
||||
"INSERT INTO wire_accounts (payto_uri, conversion_url, \
|
||||
credit_restrictions, debit_restrictions, master_sig, bank_label, \
|
||||
priority, is_active, last_change) VALUES \
|
||||
($1,$2,$3::TEXT::JSONB,$4::TEXT::JSONB,$5,$6,$7,true,$8)"
|
||||
in
|
||||
fun (module Conn : CONN) ~last_change v ->
|
||||
let is_active = true in
|
||||
Conn.exec req (v, is_active, last_change)
|
||||
|
||||
let update_wire =
|
||||
let req =
|
||||
Caqti_type.(t3 exchange_wire_account bool time ->. unit)
|
||||
"UPDATE wire_accounts SET conversion_url=$2, \
|
||||
debit_restrictions=$3::TEXT::JSONB, \
|
||||
credit_restrictions=$4::TEXT::JSONB, master_sig=$5, bank_label=$6, \
|
||||
priority=$7, is_active=$8, last_change=$9 WHERE payto_uri=$1"
|
||||
($1,$2,$3::TEXT::JSONB,$4::TEXT::JSONB,$5,$6,$7,$8,$9) ON CONFLICT \
|
||||
(payto_uri) DO UPDATE SET conversion_url=$2, \
|
||||
credit_restrictions=$3::TEXT::JSONB, \
|
||||
debit_restrictions=$4::TEXT::JSONB, master_sig=$5, bank_label=$6, \
|
||||
priority=$7, is_active=$8, last_change=$9"
|
||||
in
|
||||
fun (module Conn : CONN) ~is_active ~last_change v ->
|
||||
Conn.exec req (v, is_active, last_change)
|
||||
|
||||
let disable_wire =
|
||||
let req =
|
||||
Caqti_type.(t2 payto_uri time ->. unit)
|
||||
"UPDATE wire_accounts SET conversion_url=NULL, debit_restrictions=NULL, \
|
||||
credit_restrictions=NULL, master_sig=NULL, bank_label=NULL, \
|
||||
priority=NULL, is_active=FALSE, last_change=$2 WHERE payto_uri=$1"
|
||||
in
|
||||
fun (module Conn : CONN) ~payto_uri ~validity_end ->
|
||||
Conn.exec req (payto_uri, validity_end)
|
||||
|
||||
let get_wire_accounts =
|
||||
let req =
|
||||
Caqti_type.(unit ->* exchange_wire_account)
|
||||
|
|
@ -323,11 +288,20 @@ let get_wire_accounts =
|
|||
in
|
||||
fun (module Conn : CONN) () -> Conn.collect_list req ()
|
||||
|
||||
let find_drain_profit =
|
||||
let req =
|
||||
Caqti_type.(octets ->? drain_profit_message)
|
||||
"SELECT wtid, account_section, payto_uri, trigger_date, (amount).*, \
|
||||
master_sig FROM profit_drains WHERE wtid=$1"
|
||||
in
|
||||
fun (module Conn : CONN) wtid -> Conn.find_opt req wtid
|
||||
|
||||
let insert_drain_profit =
|
||||
let req =
|
||||
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)"
|
||||
trigger_date, amount, master_sig) VALUES ($1::BYTEA, $2, $3, $4, \
|
||||
($5,$6), $7)"
|
||||
in
|
||||
fun (module Conn : CONN) v -> Conn.exec req v
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue