|
|
@@ -1,6 +1,6 @@
|
|
|
|
%% @doc rq: Decentralized Identity Namespace Disambiguation Utility
|
|
|
|
%% @doc sbn: Sierra Bravo November
|
|
|
|
-module(rq).
|
|
|
|
-module(sbn).
|
|
|
|
-vsn("0.1.0").
|
|
|
|
-vsn("0.0.6").
|
|
|
|
-author("Peter Harpending").
|
|
|
|
-author("Peter Harpending").
|
|
|
|
-copyright("Peter Harpending").
|
|
|
|
-copyright("Peter Harpending").
|
|
|
|
|
|
|
|
|
|
|
@@ -11,7 +11,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
% deploy opts
|
|
|
|
% deploy opts
|
|
|
|
-record(rdo,
|
|
|
|
-record(rdo,
|
|
|
|
{deploy_file = "rq.deploy" :: file:filename(),
|
|
|
|
{deploy_file = "sbn.deploy" :: file:filename(),
|
|
|
|
op = deploy :: deploy | tx | signed_tx}).
|
|
|
|
op = deploy :: deploy | tx | signed_tx}).
|
|
|
|
|
|
|
|
|
|
|
|
-spec start(ArgV) -> ok
|
|
|
|
-spec start(ArgV) -> ok
|
|
|
@@ -20,134 +20,134 @@
|
|
|
|
start(ArgV) ->
|
|
|
|
start(ArgV) ->
|
|
|
|
ok = hz(),
|
|
|
|
ok = hz(),
|
|
|
|
_ = application:ensure_all_started(ssl),
|
|
|
|
_ = application:ensure_all_started(ssl),
|
|
|
|
rq(ArgV).
|
|
|
|
sbn(ArgV).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
help_screen() ->
|
|
|
|
help_screen() ->
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
rq = Decentralized Identity Namespace Disambiguation Utility
|
|
|
|
sbn = Sierra Bravo November
|
|
|
|
version 0.0.0 + 0.0.1i
|
|
|
|
version 0.0.6
|
|
|
|
|
|
|
|
|
|
|
|
USAGE:
|
|
|
|
USAGE:
|
|
|
|
rq [-s | --shell] [ARGS]
|
|
|
|
sbn [-s | --shell] [ARGS]
|
|
|
|
equivalent to `rq ARGS`, but starts erlang shell with
|
|
|
|
equivalent to `sbn ARGS`, but starts erlang shell with
|
|
|
|
rq&deps in context; with no args, simply starts erlang
|
|
|
|
sbn&deps in context; with no args, simply starts erlang
|
|
|
|
shell.
|
|
|
|
shell.
|
|
|
|
rq [-h | --help]
|
|
|
|
sbn [-h | --help]
|
|
|
|
show this menu
|
|
|
|
show this menu
|
|
|
|
rq debug
|
|
|
|
sbn debug
|
|
|
|
show variables
|
|
|
|
show variables
|
|
|
|
rq addr names
|
|
|
|
sbn addr names
|
|
|
|
rq addr names.aes
|
|
|
|
sbn addr names.aes
|
|
|
|
rq ctstr names
|
|
|
|
sbn ctstr names
|
|
|
|
rq ctstr names.aes deployed address of names
|
|
|
|
sbn ctstr names.aes deployed address of names
|
|
|
|
rq decode cb_... deep decode of api string but only the ones i use
|
|
|
|
sbn decode cb_... deep decode of api string but only the ones i use
|
|
|
|
rq decode tx_... deep decode of api string but only the ones i use
|
|
|
|
sbn decode tx_... deep decode of api string but only the ones i use
|
|
|
|
rq deploy
|
|
|
|
sbn deploy
|
|
|
|
rq deploy --tx debug ContractCreateTx
|
|
|
|
sbn deploy --tx debug ContractCreateTx
|
|
|
|
rq deploy --tx-only
|
|
|
|
sbn deploy --tx-only
|
|
|
|
rq deploy --tx_only
|
|
|
|
sbn deploy --tx_only
|
|
|
|
rq deploy --signed debug SignedTx
|
|
|
|
sbn deploy --signed debug SignedTx
|
|
|
|
rq deploy --signed-tx
|
|
|
|
sbn deploy --signed-tx
|
|
|
|
rq deploy --signed_tx
|
|
|
|
sbn deploy --signed_tx
|
|
|
|
rq grids URL only works with the faucet grids
|
|
|
|
sbn grids URL only works with the faucet grids
|
|
|
|
rq my
|
|
|
|
sbn my
|
|
|
|
rq my everything all
|
|
|
|
sbn my everything all
|
|
|
|
rq my akstr my akstr
|
|
|
|
sbn my akstr my akstr
|
|
|
|
rq my acc
|
|
|
|
sbn my acc
|
|
|
|
rq my balance
|
|
|
|
sbn my balance
|
|
|
|
rq my explorer
|
|
|
|
sbn my explorer
|
|
|
|
rq my explorer_link
|
|
|
|
sbn my explorer_link
|
|
|
|
rq my explorer_url
|
|
|
|
sbn my explorer_url
|
|
|
|
rq my url
|
|
|
|
sbn my url
|
|
|
|
rq my rbx_tuples
|
|
|
|
sbn my rbx_tuples
|
|
|
|
rq my tuples my rbx_tuples
|
|
|
|
sbn my tuples my rbx_tuples
|
|
|
|
rq query ak_... hz:acc("ak_...")
|
|
|
|
sbn query ak_... hz:acc("ak_...")
|
|
|
|
rq query ct_... hz:contract("ak_...")
|
|
|
|
sbn query ct_... hz:contract("ak_...")
|
|
|
|
rq query th_... hz:contract("ak_...")
|
|
|
|
sbn query th_... hz:contract("ak_...")
|
|
|
|
rq lookup NAME
|
|
|
|
sbn lookup NAME
|
|
|
|
rq register NAME
|
|
|
|
sbn register NAME
|
|
|
|
rq src names.aes print contract source
|
|
|
|
sbn src names.aes print contract source
|
|
|
|
rq src rubicon.aes print contract source
|
|
|
|
sbn src rubicon.aes print contract source
|
|
|
|
""".
|
|
|
|
""".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rq([]) -> rq_shell([]);
|
|
|
|
sbn([]) -> sbn_shell([]);
|
|
|
|
rq(["-s" | Rest]) -> rq_shell(Rest);
|
|
|
|
sbn(["-s" | Rest]) -> sbn_shell(Rest);
|
|
|
|
rq(["--shell" | Rest]) -> rq_shell(Rest);
|
|
|
|
sbn(["--shell" | Rest]) -> sbn_shell(Rest);
|
|
|
|
rq(Rest) -> rq_noshell(Rest).
|
|
|
|
sbn(Rest) -> sbn_noshell(Rest).
|
|
|
|
|
|
|
|
|
|
|
|
rq_shell(Args) ->
|
|
|
|
sbn_shell(Args) ->
|
|
|
|
ok = shell:start_interactive(),
|
|
|
|
ok = shell:start_interactive(),
|
|
|
|
case Args of
|
|
|
|
case Args of
|
|
|
|
[] -> ok;
|
|
|
|
[] -> ok;
|
|
|
|
More -> rq_II(More)
|
|
|
|
More -> sbn_II(More)
|
|
|
|
end.
|
|
|
|
end.
|
|
|
|
|
|
|
|
|
|
|
|
rq_noshell(Args) ->
|
|
|
|
sbn_noshell(Args) ->
|
|
|
|
rq_II(Args),
|
|
|
|
sbn_II(Args),
|
|
|
|
zx:silent_stop().
|
|
|
|
zx:silent_stop().
|
|
|
|
|
|
|
|
|
|
|
|
%% @private
|
|
|
|
%% @private
|
|
|
|
%% dispatch function
|
|
|
|
%% dispatch function
|
|
|
|
rq_II(Args) ->
|
|
|
|
sbn_II(Args) ->
|
|
|
|
case Args of
|
|
|
|
case Args of
|
|
|
|
[Addr, Names] when ((Addr =:= "addr") orelse Addr =:= "ctstr") andalso
|
|
|
|
[Addr, Names] when ((Addr =:= "addr") orelse Addr =:= "ctstr") andalso
|
|
|
|
(Names =:= "names.aes" orelse Names =:= "names") ->
|
|
|
|
(Names =:= "names.aes" orelse Names =:= "names") ->
|
|
|
|
io:format("~ts~n", [nct_ctstr()]);
|
|
|
|
io:format("~ts~n", [nct_ctstr()]);
|
|
|
|
["debug" | Rest] ->
|
|
|
|
["debug" | Rest] ->
|
|
|
|
rq_debug(Rest);
|
|
|
|
sbn_debug(Rest);
|
|
|
|
["decode", ApiStr] -> rq_decode(ApiStr);
|
|
|
|
["decode", ApiStr] -> sbn_decode(ApiStr);
|
|
|
|
["deploy"] -> rq_deploy(#rdo{});
|
|
|
|
["deploy"] -> sbn_deploy(#rdo{});
|
|
|
|
["deploy", "--signed"] -> rq_deploy(#rdo{op = signed_tx});
|
|
|
|
["deploy", "--signed"] -> sbn_deploy(#rdo{op = signed_tx});
|
|
|
|
["deploy", "--signed-tx"] -> rq_deploy(#rdo{op = signed_tx});
|
|
|
|
["deploy", "--signed-tx"] -> sbn_deploy(#rdo{op = signed_tx});
|
|
|
|
["deploy", "--signed_tx"] -> rq_deploy(#rdo{op = signed_tx});
|
|
|
|
["deploy", "--signed_tx"] -> sbn_deploy(#rdo{op = signed_tx});
|
|
|
|
["deploy", "--tx"] -> rq_deploy(#rdo{op = tx});
|
|
|
|
["deploy", "--tx"] -> sbn_deploy(#rdo{op = tx});
|
|
|
|
["deploy", "--tx-only"] -> rq_deploy(#rdo{op = tx});
|
|
|
|
["deploy", "--tx-only"] -> sbn_deploy(#rdo{op = tx});
|
|
|
|
["deploy", "--tx_only"] -> rq_deploy(#rdo{op = tx});
|
|
|
|
["deploy", "--tx_only"] -> sbn_deploy(#rdo{op = tx});
|
|
|
|
["grids", URL] -> rq_grids(URL);
|
|
|
|
["grids", URL] -> sbn_grids(URL);
|
|
|
|
["my"] -> rq_my(everything);
|
|
|
|
["my"] -> sbn_my(everything);
|
|
|
|
["my", "everything"] -> rq_my(everything);
|
|
|
|
["my", "everything"] -> sbn_my(everything);
|
|
|
|
["my", "acc"] -> rq_my(acc);
|
|
|
|
["my", "acc"] -> sbn_my(acc);
|
|
|
|
["my", "addr"] -> rq_my(akstr);
|
|
|
|
["my", "addr"] -> sbn_my(akstr);
|
|
|
|
["my", "akstr"] -> rq_my(akstr);
|
|
|
|
["my", "akstr"] -> sbn_my(akstr);
|
|
|
|
["my", "balance"] -> rq_my(balance);
|
|
|
|
["my", "balance"] -> sbn_my(balance);
|
|
|
|
["my", "explorer"] -> rq_my(url);
|
|
|
|
["my", "explorer"] -> sbn_my(url);
|
|
|
|
["my", "explorer_link"] -> rq_my(url);
|
|
|
|
["my", "explorer_link"] -> sbn_my(url);
|
|
|
|
["my", "explorer_url"] -> rq_my(url);
|
|
|
|
["my", "explorer_url"] -> sbn_my(url);
|
|
|
|
["my", "url"] -> rq_my(url);
|
|
|
|
["my", "url"] -> sbn_my(url);
|
|
|
|
["my", "rbx_tuples"] -> rq_my(rbx_tuples);
|
|
|
|
["my", "rbx_tuples"] -> sbn_my(rbx_tuples);
|
|
|
|
["my", "tuples"] -> rq_my(rbx_tuples);
|
|
|
|
["my", "tuples"] -> sbn_my(rbx_tuples);
|
|
|
|
["lookup", Name] -> rq_lookup(Name);
|
|
|
|
["lookup", Name] -> sbn_lookup(Name);
|
|
|
|
["register", Name] -> rq_register(Name);
|
|
|
|
["register", Name] -> sbn_register(Name);
|
|
|
|
["query" | Args2] -> rq_query(Args2);
|
|
|
|
["query" | Args2] -> sbn_query(Args2);
|
|
|
|
["src" | Args2] -> rq_src(Args2);
|
|
|
|
["src" | Args2] -> sbn_src(Args2);
|
|
|
|
["-h" | Args2] -> rq_help(Args2);
|
|
|
|
["-h" | Args2] -> sbn_help(Args2);
|
|
|
|
["--help" | Args2] -> rq_help(Args2);
|
|
|
|
["--help" | Args2] -> sbn_help(Args2);
|
|
|
|
BadArgs -> badargs(BadArgs)
|
|
|
|
BadArgs -> badargs(BadArgs)
|
|
|
|
end.
|
|
|
|
end.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rq_deploy(Opts = #rdo{deploy_file = F}) ->
|
|
|
|
sbn_deploy(Opts = #rdo{deploy_file = F}) ->
|
|
|
|
case file:read_file(F) of
|
|
|
|
case file:read_file(F) of
|
|
|
|
{ok, B} ->
|
|
|
|
{ok, B} ->
|
|
|
|
io:format("already deployed brother~n~ts~n", [B]),
|
|
|
|
io:format("already deployed brother~n~ts~n", [B]),
|
|
|
|
error(low_iq);
|
|
|
|
error(low_iq);
|
|
|
|
_Error ->
|
|
|
|
_Error ->
|
|
|
|
rq_deploy_II(Opts)
|
|
|
|
sbn_deploy_II(Opts)
|
|
|
|
end.
|
|
|
|
end.
|
|
|
|
|
|
|
|
|
|
|
|
rq_deploy_II(#rdo{op = Op}) ->
|
|
|
|
sbn_deploy_II(#rdo{op = Op}) ->
|
|
|
|
{ok, CreateTx} = hz:contract_create(my_akstr(), rct_filepath(), {erlang, [my_rbx_tuples()]}),
|
|
|
|
{ok, CreateTx} = hz:contract_create(my_akstr(), rct_filepath(), {erlang, [my_rbx_tuples()]}),
|
|
|
|
case Op of
|
|
|
|
case Op of
|
|
|
|
deploy ->
|
|
|
|
deploy ->
|
|
|
|
sign_and_post(CreateTx);
|
|
|
|
sign_and_post(CreateTx);
|
|
|
|
tx ->
|
|
|
|
tx ->
|
|
|
|
rq_decode(CreateTx);
|
|
|
|
sbn_decode(CreateTx);
|
|
|
|
signed_tx ->
|
|
|
|
signed_tx ->
|
|
|
|
Signed = hz:sign_tx(CreateTx, my_secret_key()),
|
|
|
|
Signed = hz:sign_tx(CreateTx, my_secret_key()),
|
|
|
|
rq_decode(Signed);
|
|
|
|
sbn_decode(Signed);
|
|
|
|
NYI ->
|
|
|
|
NYI ->
|
|
|
|
io:format("NYI: ~tp~n", [NYI]),
|
|
|
|
io:format("NYI: ~tp~n", [NYI]),
|
|
|
|
error(ur_mom_is_an_op)
|
|
|
|
error(ur_mom_is_an_op)
|
|
|
@@ -160,7 +160,7 @@ sign_and_post(UnsignedTx) ->
|
|
|
|
{ok, PostResult} = hz:post_tx(SignedTx),
|
|
|
|
{ok, PostResult} = hz:post_tx(SignedTx),
|
|
|
|
case PostResult of
|
|
|
|
case PostResult of
|
|
|
|
#{"tx_hash" := ThStr} ->
|
|
|
|
#{"tx_hash" := ThStr} ->
|
|
|
|
rq_query([ThStr]);
|
|
|
|
sbn_query([ThStr]);
|
|
|
|
#{"reason" := NodeErr} ->
|
|
|
|
#{"reason" := NodeErr} ->
|
|
|
|
io:format("ERROR: node sent back the following extremely helpful error message~n", []),
|
|
|
|
io:format("ERROR: node sent back the following extremely helpful error message~n", []),
|
|
|
|
io:format("~tp~n", [NodeErr]),
|
|
|
|
io:format("~tp~n", [NodeErr]),
|
|
|
@@ -172,16 +172,16 @@ sign_and_post(UnsignedTx) ->
|
|
|
|
end.
|
|
|
|
end.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rq_decode(TxStr = "tx_" ++ _) ->
|
|
|
|
sbn_decode(TxStr = "tx_" ++ _) ->
|
|
|
|
rq_decode(unicode:characters_to_binary(TxStr));
|
|
|
|
sbn_decode(unicode:characters_to_binary(TxStr));
|
|
|
|
rq_decode(TxBin = <<"tx_", _/binary>>) ->
|
|
|
|
sbn_decode(TxBin = <<"tx_", _/binary>>) ->
|
|
|
|
io:format("TxBin = ~tp~n", [TxBin]),
|
|
|
|
io:format("TxBin = ~tp~n", [TxBin]),
|
|
|
|
{transaction, Bytes} = gmser_api_encoder:decode(TxBin),
|
|
|
|
{transaction, Bytes} = gmser_api_encoder:decode(TxBin),
|
|
|
|
just_the_tip_decode(Bytes),
|
|
|
|
just_the_tip_decode(Bytes),
|
|
|
|
ok;
|
|
|
|
ok;
|
|
|
|
rq_decode(CbStr = "cb_" ++ _) ->
|
|
|
|
sbn_decode(CbStr = "cb_" ++ _) ->
|
|
|
|
rq_decode(unicode:characters_to_binary(CbStr));
|
|
|
|
sbn_decode(unicode:characters_to_binary(CbStr));
|
|
|
|
rq_decode(CbBin = <<"cb_", _/binary>>) ->
|
|
|
|
sbn_decode(CbBin = <<"cb_", _/binary>>) ->
|
|
|
|
io:format("CbBin = ~tp~n", [CbBin]),
|
|
|
|
io:format("CbBin = ~tp~n", [CbBin]),
|
|
|
|
{contract_bytearray, Bytes} = gmser_api_encoder:decode(CbBin),
|
|
|
|
{contract_bytearray, Bytes} = gmser_api_encoder:decode(CbBin),
|
|
|
|
io:format("Bytes = ~tp~n", [Bytes]),
|
|
|
|
io:format("Bytes = ~tp~n", [Bytes]),
|
|
|
@@ -192,7 +192,7 @@ rq_decode(CbBin = <<"cb_", _/binary>>) ->
|
|
|
|
ok.
|
|
|
|
ok.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
% this is like rq_decode but in the case where the data at hand is
|
|
|
|
% this is like sbn_decode but in the case where the data at hand is
|
|
|
|
% NOT api-encoded; a typical example would be debugging a signed
|
|
|
|
% NOT api-encoded; a typical example would be debugging a signed
|
|
|
|
% transaction; one of the fields is the signatee, which needs to be
|
|
|
|
% transaction; one of the fields is the signatee, which needs to be
|
|
|
|
% decomposed
|
|
|
|
% decomposed
|
|
|
@@ -240,11 +240,11 @@ sig_valid(Pk32, Sig, Tx) ->
|
|
|
|
ok.
|
|
|
|
ok.
|
|
|
|
|
|
|
|
|
|
|
|
% hacky to get fund via faucet to work
|
|
|
|
% hacky to get fund via faucet to work
|
|
|
|
rq_grids(URL) ->
|
|
|
|
sbn_grids(URL) ->
|
|
|
|
{ok, {{sign, https}, URL_II}} = hz_grids:parse(URL),
|
|
|
|
{ok, {{sign, https}, URL_II}} = hz_grids:parse(URL),
|
|
|
|
case httpc:request(URL_II) of
|
|
|
|
case httpc:request(URL_II) of
|
|
|
|
{ok, {{_HttpVsn, 200, _Slogan}, _Hdrs, JSONBodyStr}} ->
|
|
|
|
{ok, {{_HttpVsn, 200, _Slogan}, _Hdrs, JSONBodyStr}} ->
|
|
|
|
rq_grids_ii00(URL_II, JSONBodyStr);
|
|
|
|
sbn_grids_ii00(URL_II, JSONBodyStr);
|
|
|
|
{ok, {{_HttpVsn, 404, _Slogan}, _Hdrs, _JSONBodyStr}} ->
|
|
|
|
{ok, {{_HttpVsn, 404, _Slogan}, _Hdrs, _JSONBodyStr}} ->
|
|
|
|
io:format("BUTTER YOUR OWN BISCUIT FATASS~n", []),
|
|
|
|
io:format("BUTTER YOUR OWN BISCUIT FATASS~n", []),
|
|
|
|
io:format("(404... probably faucet copypasta expired)~n", []);
|
|
|
|
io:format("(404... probably faucet copypasta expired)~n", []);
|
|
|
@@ -252,7 +252,7 @@ rq_grids(URL) ->
|
|
|
|
io:format("ERROR: ~tp~n", [Error])
|
|
|
|
io:format("ERROR: ~tp~n", [Error])
|
|
|
|
end.
|
|
|
|
end.
|
|
|
|
|
|
|
|
|
|
|
|
rq_grids_ii00(URL_II, JSONBodyStr) ->
|
|
|
|
sbn_grids_ii00(URL_II, JSONBodyStr) ->
|
|
|
|
{ok, Decoded} = zj:decode(JSONBodyStr),
|
|
|
|
{ok, Decoded} = zj:decode(JSONBodyStr),
|
|
|
|
io:format("Decoded = ~tp~n", [Decoded]),
|
|
|
|
io:format("Decoded = ~tp~n", [Decoded]),
|
|
|
|
case Decoded of
|
|
|
|
case Decoded of
|
|
|
@@ -262,11 +262,11 @@ rq_grids_ii00(URL_II, JSONBodyStr) ->
|
|
|
|
"payload" := PayloadStr,
|
|
|
|
"payload" := PayloadStr,
|
|
|
|
"public_id" := false,
|
|
|
|
"public_id" := false,
|
|
|
|
"signature" := undefined,
|
|
|
|
"signature" := undefined,
|
|
|
|
"type" := "message"} -> rq_grids_iii(URL_II, Decoded, PayloadStr);
|
|
|
|
"type" := "message"} -> sbn_grids_iii(URL_II, Decoded, PayloadStr);
|
|
|
|
_Nah -> error(nah_brah)
|
|
|
|
_Nah -> error(nah_brah)
|
|
|
|
end.
|
|
|
|
end.
|
|
|
|
|
|
|
|
|
|
|
|
rq_grids_iii(URL_II, Decoded, PayloadStr) ->
|
|
|
|
sbn_grids_iii(URL_II, Decoded, PayloadStr) ->
|
|
|
|
io:format("PayloadStr = ~tp~n", [PayloadStr]),
|
|
|
|
io:format("PayloadStr = ~tp~n", [PayloadStr]),
|
|
|
|
Sig = base64:encode(hz:sign_message(unicode:characters_to_binary(PayloadStr), my_secret_key())),
|
|
|
|
Sig = base64:encode(hz:sign_message(unicode:characters_to_binary(PayloadStr), my_secret_key())),
|
|
|
|
Recoded = Decoded#{"signature" => Sig,
|
|
|
|
Recoded = Decoded#{"signature" => Sig,
|
|
|
@@ -278,67 +278,67 @@ rq_grids_iii(URL_II, Decoded, PayloadStr) ->
|
|
|
|
io:format("Shit = ~tp~n", [Shit]).
|
|
|
|
io:format("Shit = ~tp~n", [Shit]).
|
|
|
|
% ok.
|
|
|
|
% ok.
|
|
|
|
|
|
|
|
|
|
|
|
rq_my(everything) ->
|
|
|
|
sbn_my(everything) ->
|
|
|
|
rq_my(akstr),
|
|
|
|
sbn_my(akstr),
|
|
|
|
rq_my(rbx_tuples);
|
|
|
|
sbn_my(rbx_tuples);
|
|
|
|
rq_my(acc) ->
|
|
|
|
sbn_my(acc) ->
|
|
|
|
Ak = my_akstr(),
|
|
|
|
Ak = my_akstr(),
|
|
|
|
rq_query([Ak]);
|
|
|
|
sbn_query([Ak]);
|
|
|
|
rq_my(balance) ->
|
|
|
|
sbn_my(balance) ->
|
|
|
|
Ak = my_akstr(),
|
|
|
|
Ak = my_akstr(),
|
|
|
|
{ok, #{"balance" := B}} = hz:acc(Ak),
|
|
|
|
{ok, #{"balance" := B}} = hz:acc(Ak),
|
|
|
|
io:format("Balance = ~tp~n", [B]),
|
|
|
|
io:format("Balance = ~tp~n", [B]),
|
|
|
|
io:format("log10(Balance) = ~tp~n", [math:log10(B)]);
|
|
|
|
io:format("log10(Balance) = ~tp~n", [math:log10(B)]);
|
|
|
|
rq_my(akstr) ->
|
|
|
|
sbn_my(akstr) ->
|
|
|
|
io:format("~ts~n", [my_akstr()]);
|
|
|
|
io:format("~ts~n", [my_akstr()]);
|
|
|
|
rq_my(url) ->
|
|
|
|
sbn_my(url) ->
|
|
|
|
io:format("https://groot.testnet.gajumaru.io/account/~ts~n", [my_akstr()]);
|
|
|
|
io:format("https://groot.testnet.gajumaru.io/account/~ts~n", [my_akstr()]);
|
|
|
|
rq_my(rbx_tuples) ->
|
|
|
|
sbn_my(rbx_tuples) ->
|
|
|
|
io:format("~tp~n", [my_rbx_tuples()]).
|
|
|
|
io:format("~tp~n", [my_rbx_tuples()]).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rq_query([Ak = "ak_" ++ _ | Rest]) ->
|
|
|
|
sbn_query([Ak = "ak_" ++ _ | Rest]) ->
|
|
|
|
{ok, X} = hz:acc(Ak),
|
|
|
|
{ok, X} = hz:acc(Ak),
|
|
|
|
io:format("~tp~n", [X]),
|
|
|
|
io:format("~tp~n", [X]),
|
|
|
|
rq_query(Rest);
|
|
|
|
sbn_query(Rest);
|
|
|
|
rq_query([Ct = "ct_" ++ _ | Rest]) ->
|
|
|
|
sbn_query([Ct = "ct_" ++ _ | Rest]) ->
|
|
|
|
{ok, X} = hz:contract(Ct),
|
|
|
|
{ok, X} = hz:contract(Ct),
|
|
|
|
io:format("~tp~n", [X]),
|
|
|
|
io:format("~tp~n", [X]),
|
|
|
|
rq_query(Rest);
|
|
|
|
sbn_query(Rest);
|
|
|
|
rq_query([ThStr = "th" ++ _ | Rest]) ->
|
|
|
|
sbn_query([ThStr = "th" ++ _ | Rest]) ->
|
|
|
|
io:format("ThStr = ~tp~n", [ThStr]),
|
|
|
|
io:format("ThStr = ~tp~n", [ThStr]),
|
|
|
|
io:format("ExplorerUrl = ~ts~n", [explorer_url(ThStr)]),
|
|
|
|
io:format("ExplorerUrl = ~ts~n", [explorer_url(ThStr)]),
|
|
|
|
{ok, TxInfo} = hz:tx_info(ThStr),
|
|
|
|
{ok, TxInfo} = hz:tx_info(ThStr),
|
|
|
|
#{"call_info" := #{"return_value" := CbStr}} = TxInfo,
|
|
|
|
#{"call_info" := #{"return_value" := CbStr}} = TxInfo,
|
|
|
|
rq_decode(CbStr),
|
|
|
|
sbn_decode(CbStr),
|
|
|
|
rq_query(Rest);
|
|
|
|
sbn_query(Rest);
|
|
|
|
rq_query([]) ->
|
|
|
|
sbn_query([]) ->
|
|
|
|
ok.
|
|
|
|
ok.
|
|
|
|
|
|
|
|
|
|
|
|
explorer_url(ThStr = "th" ++ _) ->
|
|
|
|
explorer_url(ThStr = "th" ++ _) ->
|
|
|
|
"https://groot.testnet.gajumaru.io/tx/" ++ ThStr.
|
|
|
|
"https://groot.testnet.gajumaru.io/tx/" ++ ThStr.
|
|
|
|
|
|
|
|
|
|
|
|
rq_src(["names.aes"]) ->
|
|
|
|
sbn_src(["names.aes"]) ->
|
|
|
|
{ok, Bytes} = file:read_file(nct_filepath()),
|
|
|
|
{ok, Bytes} = file:read_file(nct_filepath()),
|
|
|
|
io:format("~s", [Bytes]);
|
|
|
|
io:format("~s", [Bytes]);
|
|
|
|
rq_src(["rubicon.aes"]) ->
|
|
|
|
sbn_src(["rubicon.aes"]) ->
|
|
|
|
{ok, Bytes} = file:read_file(nct_filepath()),
|
|
|
|
{ok, Bytes} = file:read_file(nct_filepath()),
|
|
|
|
io:format("~s", [Bytes]);
|
|
|
|
io:format("~s", [Bytes]);
|
|
|
|
rq_src(FailArgs) ->
|
|
|
|
sbn_src(FailArgs) ->
|
|
|
|
badargs(FailArgs).
|
|
|
|
badargs(FailArgs).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
badargs(FailArgs) ->
|
|
|
|
badargs(FailArgs) ->
|
|
|
|
io:format("you are a failure: ~p~n", [FailArgs]),
|
|
|
|
io:format("you are a failure: ~p~n", [FailArgs]),
|
|
|
|
rq_help([]),
|
|
|
|
sbn_help([]),
|
|
|
|
error(badargs).
|
|
|
|
error(badargs).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rq_help(_) ->
|
|
|
|
sbn_help(_) ->
|
|
|
|
io:format("~ts~n", [help_screen()]).
|
|
|
|
io:format("~ts~n", [help_screen()]).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rq_debug(_) ->
|
|
|
|
sbn_debug(_) ->
|
|
|
|
ok = dbg_hz(),
|
|
|
|
ok = dbg_hz(),
|
|
|
|
ok = dbg_my(),
|
|
|
|
ok = dbg_my(),
|
|
|
|
ok = dbg_nct(),
|
|
|
|
ok = dbg_nct(),
|
|
|
@@ -387,13 +387,13 @@ dbg_rct() ->
|
|
|
|
io:format(Format, Args).
|
|
|
|
io:format(Format, Args).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rq_register(Name) ->
|
|
|
|
sbn_register(Name) ->
|
|
|
|
ct_call(nct_aaci(), nct_ctstr(), "register", [Name, ctstr(<<0:(32 * 8)>>)]).
|
|
|
|
ct_call(nct_aaci(), nct_ctstr(), "register", [Name, ctstr(<<0:(32 * 8)>>)]).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rq_lookup(Name) ->
|
|
|
|
sbn_lookup(Name) ->
|
|
|
|
ct_call(nct_aaci(), nct_ctstr(), "lookup", [Name]).
|
|
|
|
ct_call(nct_aaci(), nct_ctstr(), "lookup", [Name]).
|
|
|
|
|
|
|
|
|
|
|
|
ct_call(AACI, CtStr, FunName, ErlArgs) ->
|
|
|
|
ct_call(AACI, CtStr, FunName, ErlArgs) ->
|
|
|
@@ -402,7 +402,7 @@ ct_call(AACI, CtStr, FunName, ErlArgs) ->
|
|
|
|
{ok, PostResult} = hz:post_tx(SignedTx),
|
|
|
|
{ok, PostResult} = hz:post_tx(SignedTx),
|
|
|
|
case PostResult of
|
|
|
|
case PostResult of
|
|
|
|
#{"tx_hash" := ThStr} ->
|
|
|
|
#{"tx_hash" := ThStr} ->
|
|
|
|
rq_query([ThStr]);
|
|
|
|
sbn_query([ThStr]);
|
|
|
|
#{"error" := NodeErr} ->
|
|
|
|
#{"error" := NodeErr} ->
|
|
|
|
io:format("ERROR: node sent back the following extremely helpful error message~n", []),
|
|
|
|
io:format("ERROR: node sent back the following extremely helpful error message~n", []),
|
|
|
|
io:format("NodeErr = ~tp~n", [NodeErr]),
|
|
|
|
io:format("NodeErr = ~tp~n", [NodeErr]),
|