handle global_fees; add do_management.sh
This commit is contained in:
parent
4754517d8f
commit
773b1b0d68
11 changed files with 207 additions and 19 deletions
|
|
@ -1,5 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
dune exec offline -- download && \
|
||||
dune exec offline -- sign && \
|
||||
dune exec offline -- upload
|
||||
set -e
|
||||
|
||||
file1="tmp_file1.json"
|
||||
file2="tmp_file2.json"
|
||||
file3="tmp_file3.json"
|
||||
|
||||
dune exec offline -- download --output $file1
|
||||
dune exec offline -- sign --input $file1 --output $file2
|
||||
dune exec offline -- upload --input $file2 --url "/management/keys"
|
||||
dune exec offline -- global-fees --output $file3 --start_date "0.0" --end_date "99999999.9" --history_fee "EUR:0.0" --account_fee "EUR:0.0" --purse_fee "EUR:0.0" --history_expiration "9999999.0" --purse_account_limit 1 --purse_timeout "9999999.0"
|
||||
dune exec offline -- upload --input $file3 --url "/management/global-fees"
|
||||
|
||||
rm $file1
|
||||
rm $file2
|
||||
rm $file3
|
||||
|
|
|
|||
|
|
@ -9,6 +9,18 @@ let default_request_file = "request.json"
|
|||
(*let to_term_ret = function Error e -> `Error (false, e) | Ok () -> `Ok ()*)
|
||||
let to_term_ret = Fun.id
|
||||
|
||||
let timestamp =
|
||||
Arg.Conv.make ~docv:"timestamp argument" ~parser:Timestamp.of_string
|
||||
~pp:Timestamp.pp ()
|
||||
|
||||
let relative_time =
|
||||
Arg.Conv.make ~docv:"relative time argument" ~parser:Timestamp.Span.of_string
|
||||
~pp:Timestamp.Span.pp ()
|
||||
|
||||
let amount =
|
||||
Arg.Conv.make ~docv:"amount argument" ~parser:Amount.of_string ~pp:Amount.pp
|
||||
()
|
||||
|
||||
let setup_cmd =
|
||||
let doc = "Generate offline master keys" in
|
||||
let output =
|
||||
|
|
@ -94,6 +106,50 @@ let revoke_signkey_cmd =
|
|||
let+ output = output and+ master_key = master_key and+ signkey = signkey in
|
||||
revoke_signkey ~output ~master_key ~signkey |> to_term_ret
|
||||
|
||||
let global_fees_cmd =
|
||||
let doc = "Provides global fee configuration." in
|
||||
let start_date =
|
||||
Arg.(required & opt (some timestamp) None & info [ "start_date" ])
|
||||
in
|
||||
let end_date =
|
||||
Arg.(required & opt (some timestamp) None & info [ "end_date" ])
|
||||
in
|
||||
let history_fee =
|
||||
Arg.(required & opt (some amount) None & info [ "history_fee" ])
|
||||
in
|
||||
let account_fee =
|
||||
Arg.(required & opt (some amount) None & info [ "account_fee" ])
|
||||
in
|
||||
let purse_fee =
|
||||
Arg.(required & opt (some amount) None & info [ "purse_fee" ])
|
||||
in
|
||||
let history_expiration =
|
||||
Arg.(
|
||||
required & opt (some relative_time) None & info [ "history_expiration" ])
|
||||
in
|
||||
let purse_account_limit =
|
||||
Arg.(required & opt (some int) None & info [ "purse_account_limit" ])
|
||||
in
|
||||
let purse_timeout =
|
||||
Arg.(required & opt (some relative_time) None & info [ "purse_timeout" ])
|
||||
in
|
||||
Cmd.make (Cmd.info "global-fees" ~doc)
|
||||
@@
|
||||
let+ output = output
|
||||
and+ master_key = master_key
|
||||
and+ start_date = start_date
|
||||
and+ end_date = end_date
|
||||
and+ history_fee = history_fee
|
||||
and+ account_fee = account_fee
|
||||
and+ purse_fee = purse_fee
|
||||
and+ history_expiration = history_expiration
|
||||
and+ purse_account_limit = purse_account_limit
|
||||
and+ purse_timeout = purse_timeout in
|
||||
global_fees ~output ~master_key ~start_date ~end_date ~history_fee
|
||||
~account_fee ~purse_fee ~history_expiration ~purse_account_limit
|
||||
~purse_timeout
|
||||
|> to_term_ret
|
||||
|
||||
let cli =
|
||||
let info =
|
||||
let doc = "MTE Offline CLI tool" in
|
||||
|
|
@ -107,6 +163,7 @@ let cli =
|
|||
upload_cmd;
|
||||
revoke_denom_cmd;
|
||||
revoke_signkey_cmd;
|
||||
global_fees_cmd;
|
||||
]
|
||||
|
||||
let main () = Cmd.eval_result cli
|
||||
|
|
|
|||
|
|
@ -75,3 +75,54 @@ let revoke_signkey ~output ~master_key ~signkey =
|
|||
let* s = Api.encode Api.SignkeyRevocationSignature.jsont v in
|
||||
let* () = write_file output s in
|
||||
Ok ()
|
||||
|
||||
let global_fees ~output ~master_key ~start_date ~end_date ~history_fee
|
||||
~account_fee ~purse_fee ~history_expiration ~purse_account_limit
|
||||
~purse_timeout =
|
||||
let open Crypto in
|
||||
let* key = read_file master_key in
|
||||
let* key = EddsaPrivateKey.of_octets key in
|
||||
let* purse_account_limit =
|
||||
match
|
||||
purse_account_limit >= 0
|
||||
&& purse_account_limit <= Int32.to_int Int32.max_int
|
||||
with
|
||||
| false -> Error "invalid purse_account_limit value"
|
||||
| true -> Ok (Int32.of_int purse_account_limit)
|
||||
in
|
||||
let master_sig =
|
||||
let open Bin_sig.GlobalFees in
|
||||
(* TODO KYC *)
|
||||
let kyc_timeout = None in
|
||||
let kyc_fee = Amount.dummy_value in
|
||||
sign_f ~f:(EddsaSignature.sign ~key)
|
||||
{
|
||||
start_date;
|
||||
end_date;
|
||||
purse_timeout;
|
||||
kyc_timeout;
|
||||
history_expiration;
|
||||
history_fee;
|
||||
kyc_fee;
|
||||
account_fee;
|
||||
purse_fee;
|
||||
purse_account_limit;
|
||||
}
|
||||
in
|
||||
let global_fees =
|
||||
Api.GlobalFees.
|
||||
{
|
||||
start_date;
|
||||
end_date;
|
||||
purse_timeout;
|
||||
history_expiration;
|
||||
history_fee;
|
||||
account_fee;
|
||||
purse_fee;
|
||||
purse_account_limit;
|
||||
master_sig;
|
||||
}
|
||||
in
|
||||
let* s = Api.encode Api.GlobalFees.jsont global_fees in
|
||||
let* () = write_file output s in
|
||||
Ok ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue