major progress
This commit is contained in:
+1
-1
@@ -2,6 +2,6 @@
|
|||||||
[{description,[]},
|
[{description,[]},
|
||||||
{registered,[]},
|
{registered,[]},
|
||||||
{included_applications,[]},
|
{included_applications,[]},
|
||||||
{applications,[stdlib,kernel]},
|
{applications,[stdlib,kernel, ssl]},
|
||||||
{vsn,"0.1.0"},
|
{vsn,"0.1.0"},
|
||||||
{modules,[rq]}]}.
|
{modules,[rq]}]}.
|
||||||
|
|||||||
+115
-9
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
start(ArgV) ->
|
start(ArgV) ->
|
||||||
ok = hz(),
|
ok = hz(),
|
||||||
|
_ = application:ensure_all_started(ssl),
|
||||||
rq(ArgV).
|
rq(ArgV).
|
||||||
|
|
||||||
|
|
||||||
@@ -33,13 +34,22 @@ help_screen() ->
|
|||||||
rq addr names.aes
|
rq addr names.aes
|
||||||
rq ctstr names
|
rq ctstr names
|
||||||
rq ctstr names.aes deployed address of names
|
rq ctstr names.aes deployed address of names
|
||||||
|
rq decode xy_... only on the ones i use
|
||||||
|
rq grids URL only works with the faucet grids
|
||||||
rq my
|
rq my
|
||||||
rq my everything all
|
rq my everything all
|
||||||
rq my akstr my akstr
|
rq my akstr my akstr
|
||||||
|
rq my acc
|
||||||
|
rq my balance
|
||||||
|
rq my explorer
|
||||||
|
rq my explorer_link
|
||||||
|
rq my explorer_url
|
||||||
|
rq my url
|
||||||
rq my rbx_tuples
|
rq my rbx_tuples
|
||||||
rq my tuples my rbx_tuples
|
rq my tuples my rbx_tuples
|
||||||
rq query ak_... hz:acc("ak_...")
|
rq query ak_... hz:acc("ak_...")
|
||||||
rq query ct_... hz:contract("ak_...")
|
rq query ct_... hz:contract("ak_...")
|
||||||
|
rq query th_... hz:contract("ak_...")
|
||||||
rq lookup NAME
|
rq lookup NAME
|
||||||
rq register NAME
|
rq register NAME
|
||||||
rq src names.aes print contract source
|
rq src names.aes print contract source
|
||||||
@@ -72,10 +82,18 @@ rq_II(Args) ->
|
|||||||
io:format("~ts~n", [nct_ctstr()]);
|
io:format("~ts~n", [nct_ctstr()]);
|
||||||
["debug" | Rest] ->
|
["debug" | Rest] ->
|
||||||
rq_debug(Rest);
|
rq_debug(Rest);
|
||||||
|
["decode", ApiStr] -> rq_decode(ApiStr);
|
||||||
|
["grids", URL] -> rq_grids(URL);
|
||||||
["my"] -> rq_my(everything);
|
["my"] -> rq_my(everything);
|
||||||
["my", "everything"] -> rq_my(everything);
|
["my", "everything"] -> rq_my(everything);
|
||||||
|
["my", "acc"] -> rq_my(acc);
|
||||||
["my", "addr"] -> rq_my(akstr);
|
["my", "addr"] -> rq_my(akstr);
|
||||||
["my", "akstr"] -> rq_my(akstr);
|
["my", "akstr"] -> rq_my(akstr);
|
||||||
|
["my", "balance"] -> rq_my(balance);
|
||||||
|
["my", "explorer"] -> rq_my(url);
|
||||||
|
["my", "explorer_link"] -> rq_my(url);
|
||||||
|
["my", "explorer_url"] -> rq_my(url);
|
||||||
|
["my", "url"] -> rq_my(url);
|
||||||
["my", "rbx_tuples"] -> rq_my(rbx_tuples);
|
["my", "rbx_tuples"] -> rq_my(rbx_tuples);
|
||||||
["my", "tuples"] -> rq_my(rbx_tuples);
|
["my", "tuples"] -> rq_my(rbx_tuples);
|
||||||
["lookup", Name] -> rq_lookup(Name);
|
["lookup", Name] -> rq_lookup(Name);
|
||||||
@@ -87,11 +105,75 @@ rq_II(Args) ->
|
|||||||
BadArgs -> badargs(BadArgs)
|
BadArgs -> badargs(BadArgs)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
rq_decode(CbStr = "cb_" ++ _) ->
|
||||||
|
CbBin = unicode:characters_to_binary(CbStr),
|
||||||
|
io:format("CbBin = ~tp~n", [CbBin]),
|
||||||
|
{contract_bytearray, Bytes} = gmser_api_encoder:decode(CbBin),
|
||||||
|
io:format("Bytes = ~tp~n", [Bytes]),
|
||||||
|
Deser = gmb_fate_encoding:deserialize(Bytes),
|
||||||
|
io:format("Deserialized = ~tp~n", [Deser]),
|
||||||
|
Fmt = gmb_fate_data:format(Deser),
|
||||||
|
io:format("Formatted = ~ts~n", [Fmt]),
|
||||||
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
% hacky to get fund via faucet to work
|
||||||
|
rq_grids(URL) ->
|
||||||
|
{ok, {{sign, https}, URL_II}} = hz_grids:parse(URL),
|
||||||
|
case httpc:request(URL_II) of
|
||||||
|
{ok, {{_HttpVsn, 200, _Slogan}, _Hdrs, JSONBodyStr}} ->
|
||||||
|
rq_grids_ii00(URL_II, JSONBodyStr);
|
||||||
|
{ok, {{_HttpVsn, 404, _Slogan}, _Hdrs, _JSONBodyStr}} ->
|
||||||
|
io:format("BUTTER YOUR OWN BISCUIT FATASS~n", []),
|
||||||
|
io:format("(404... probably faucet copypasta expired)~n", []);
|
||||||
|
Error ->
|
||||||
|
io:format("ERROR: ~tp~n", [Error])
|
||||||
|
end.
|
||||||
|
|
||||||
|
rq_grids_ii00(URL_II, JSONBodyStr) ->
|
||||||
|
{ok, Decoded} = zj:decode(JSONBodyStr),
|
||||||
|
io:format("Decoded = ~tp~n", [Decoded]),
|
||||||
|
case Decoded of
|
||||||
|
#{"chain" := "gajumaru",
|
||||||
|
"grids" := 1,
|
||||||
|
"network_id" := "groot.testnet",
|
||||||
|
"payload" := PayloadStr,
|
||||||
|
"public_id" := false,
|
||||||
|
"signature" := undefined,
|
||||||
|
"type" := "message"} ->
|
||||||
|
rq_grids_iii(URL_II, Decoded, PayloadStr);
|
||||||
|
_Nah ->
|
||||||
|
error(nah_brah)
|
||||||
|
end.
|
||||||
|
|
||||||
|
rq_grids_iii(URL_II, Decoded, PayloadStr) ->
|
||||||
|
io:format("PayloadStr = ~tp~n", [PayloadStr]),
|
||||||
|
Sig = base64:encode(hz:sign_message(unicode:characters_to_binary(PayloadStr), my_secret_key())),
|
||||||
|
Recoded = Decoded#{"signature" => Sig,
|
||||||
|
"public_id" => my_akstr()},
|
||||||
|
io:format("Recoded = ~tp~n", [Recoded]),
|
||||||
|
Reconfuckulated = zj:encode(Recoded),
|
||||||
|
io:format("Reconfuckulated = ~tp~n", [Reconfuckulated]),
|
||||||
|
Shit = httpc:request(post, {URL_II, [], "application/json", Reconfuckulated}, [], []),
|
||||||
|
io:format("Shit = ~tp~n", [Shit]).
|
||||||
|
% ok.
|
||||||
|
|
||||||
rq_my(everything) ->
|
rq_my(everything) ->
|
||||||
rq_my(akstr),
|
rq_my(akstr),
|
||||||
rq_my(rbx_tuples);
|
rq_my(rbx_tuples);
|
||||||
|
rq_my(acc) ->
|
||||||
|
Ak = my_akstr(),
|
||||||
|
rq_query([Ak]);
|
||||||
|
rq_my(balance) ->
|
||||||
|
Ak = my_akstr(),
|
||||||
|
{ok, #{"balance" := B}} = hz:acc(Ak),
|
||||||
|
io:format("Balance = ~tp~n", [B]),
|
||||||
|
io:format("log10(Balance) = ~tp~n", [math:log10(B)]);
|
||||||
rq_my(akstr) ->
|
rq_my(akstr) ->
|
||||||
io:format("~ts~n", [my_akstr()]);
|
io:format("~ts~n", [my_akstr()]);
|
||||||
|
rq_my(url) ->
|
||||||
|
io:format("https://groot.testnet.gajumaru.io/account/~ts~n", [my_akstr()]);
|
||||||
rq_my(rbx_tuples) ->
|
rq_my(rbx_tuples) ->
|
||||||
io:format("~tp~n", [my_rbx_tuples()]).
|
io:format("~tp~n", [my_rbx_tuples()]).
|
||||||
|
|
||||||
@@ -100,10 +182,16 @@ rq_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);
|
rq_query(Rest);
|
||||||
|
rq_query([Cb = "cb_" ++ _ | Rest]) ->
|
||||||
|
rq_decode(Cb),
|
||||||
|
rq_query(Rest);
|
||||||
rq_query([Ct = "ct_" ++ _ | Rest]) ->
|
rq_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);
|
rq_query(Rest);
|
||||||
|
rq_query([Th = "th" ++ _ | Rest]) ->
|
||||||
|
await_thstr(Th),
|
||||||
|
rq_query(Rest);
|
||||||
rq_query([]) ->
|
rq_query([]) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
@@ -177,17 +265,35 @@ dbg_rct() ->
|
|||||||
|
|
||||||
|
|
||||||
rq_register(Name) ->
|
rq_register(Name) ->
|
||||||
{ok, CallTx} = hz:contract_call(my_akstr(), nct_aaci(), nct_ctstr(), "register", [Name]),
|
ct_call(nct_aaci(), nct_ctstr(), "register", [Name]).
|
||||||
{ok, SignedTx} = hz:sign_tx(CallTx, my_secret_key()),
|
|
||||||
{ok, Result} = hz:post_tx(SignedTx),
|
|
||||||
io:format("~tp~n", [Result]).
|
|
||||||
|
|
||||||
rq_lookup(Name) ->
|
rq_lookup(Name) ->
|
||||||
{ok, CallTx} = hz:contract_call(my_akstr(), nct_aaci(), nct_ctstr(), "lookup", {erlang, [Name]}),
|
ct_call(nct_aaci(), nct_ctstr(), "lookup", [Name]).
|
||||||
SignedTx = hz:sign_tx(CallTx, my_secret_key()),
|
|
||||||
{ok, Result} = hz:post_tx(SignedTx),
|
|
||||||
io:format("~tp~n", [Result]).
|
|
||||||
|
|
||||||
|
ct_call(AACI, CtStr, FunName, ErlArgs) ->
|
||||||
|
{ok, CallTx} = hz:contract_call(my_akstr(), AACI, CtStr, FunName, {erlang, ErlArgs}),
|
||||||
|
SignedTx = hz:sign_tx(CallTx, my_secret_key()),
|
||||||
|
{ok, PostResult} = hz:post_tx(SignedTx),
|
||||||
|
case PostResult of
|
||||||
|
#{"tx_hash" := ThStr} ->
|
||||||
|
await_thstr(ThStr);
|
||||||
|
#{"error" := NodeErr} ->
|
||||||
|
io:format("ERROR: node sent back the following extremely helpful error message~n", []),
|
||||||
|
io:format("NodeErr = ~tp~n", [NodeErr]),
|
||||||
|
error(NodeErr);
|
||||||
|
_ ->
|
||||||
|
io:format("ERROR (nyi) node sent back voodoo:~n", []),
|
||||||
|
io:format("PostResult = ~tp~n", [PostResult]),
|
||||||
|
error(nyi)
|
||||||
|
end.
|
||||||
|
|
||||||
|
await_thstr(ThStr) ->
|
||||||
|
{ok, Tx} = hz:tx(ThStr),
|
||||||
|
{ok, TxInfo} = hz:tx_info(ThStr),
|
||||||
|
io:format("Tx = ~tp~n", [Tx]),
|
||||||
|
io:format("TxInfo = ~tp~n", [TxInfo]),
|
||||||
|
ok.
|
||||||
|
|
||||||
|
|
||||||
%% name contract deployed address
|
%% name contract deployed address
|
||||||
@@ -235,7 +341,7 @@ my_keypair() ->
|
|||||||
ecu_eddsa:sign_seed_keypair(my_seed()).
|
ecu_eddsa:sign_seed_keypair(my_seed()).
|
||||||
|
|
||||||
my_seed() ->
|
my_seed() ->
|
||||||
crypto:hash(sha3_512, <<"p@ssw0rd">>).
|
crypto:hash(sha3_256, <<"p@ssw0rd">>).
|
||||||
|
|
||||||
my_rbx_tuples() ->
|
my_rbx_tuples() ->
|
||||||
NoiseStr = "Noise_NK_25519_ChaChaPoly_BLAKE2b",
|
NoiseStr = "Noise_NK_25519_ChaChaPoly_BLAKE2b",
|
||||||
|
|||||||
Reference in New Issue
Block a user