WIP
This commit is contained in:
parent
bfa8cc91c2
commit
c904ed66f3
@ -77,13 +77,14 @@
|
|||||||
|
|
||||||
|
|
||||||
-record(wallet,
|
-record(wallet,
|
||||||
{version = 1 :: integer(),
|
{version = 2 :: integer(),
|
||||||
name = "" :: string(),
|
name = "" :: string(),
|
||||||
poas = [] :: [#poa{}],
|
poas = [] :: [#poa{}],
|
||||||
keys = [] :: [#key{}],
|
keys = [] :: [#key{}],
|
||||||
chain_id = <<"groot.devnet">> :: binary(),
|
chain_id = <<"groot.devnet">> :: binary(),
|
||||||
endpoint = #node{} :: #node{},
|
endpoint = #node{} :: #node{},
|
||||||
nets = [#net{}] :: [#net{}]}).
|
nets = [#net{}] :: [#net{}],
|
||||||
|
txs = #{} :: clutch:key_txs()}).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
-export([ts/0]).
|
-export([ts/0]).
|
||||||
-export([start/2, stop/1]).
|
-export([start/2, stop/1]).
|
||||||
|
|
||||||
-export_type([id/0, key/0, poa/0, tx/0, ts/0]).
|
-export_type([id/0, key/0, poa/0, tx/0, ts/0, key_txs/0]).
|
||||||
|
|
||||||
-include("$zx_include/zx_logger.hrl").
|
-include("$zx_include/zx_logger.hrl").
|
||||||
-include("gmc.hrl").
|
-include("gmc.hrl").
|
||||||
@ -23,6 +23,8 @@
|
|||||||
-type poa() :: #poa{}.
|
-type poa() :: #poa{}.
|
||||||
-type tx() :: #tx{}.
|
-type tx() :: #tx{}.
|
||||||
-type ts() :: integer().
|
-type ts() :: integer().
|
||||||
|
-type chain_txs() :: #{ChainID :: binary() := [tx()]}.
|
||||||
|
-type key_txs() :: #{id() := {{LastCheck :: ts(), mdw | node}, chain_txs()}}.
|
||||||
|
|
||||||
|
|
||||||
ts() ->
|
ts() ->
|
||||||
|
@ -41,12 +41,11 @@
|
|||||||
{version = 1 :: integer(),
|
{version = 1 :: integer(),
|
||||||
window = none :: none | wx:wx_object(),
|
window = none :: none | wx:wx_object(),
|
||||||
tasks = [] :: [#ui{}],
|
tasks = [] :: [#ui{}],
|
||||||
picked = 0 :: non_neg_integer(),
|
selected = 0 :: non_neg_integer(),
|
||||||
wallet = none :: none | #wallet{},
|
wallet = none :: none | #wallet{},
|
||||||
pass = none :: none | binary(),
|
pass = none :: none | binary(),
|
||||||
prefs = #{} :: #{module() := term()},
|
prefs = #{} :: #{module() := term()},
|
||||||
wallets = [] :: [#wr{}],
|
wallets = [] :: [#wr{}]}).
|
||||||
in_flight = [] :: [#tx{}]}).
|
|
||||||
|
|
||||||
|
|
||||||
-type state() :: #s{}.
|
-type state() :: #s{}.
|
||||||
@ -897,37 +896,34 @@ do_mnemonic(ID, #s{wallet = #wallet{keys = Keys}}) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
do_deploy(Build, InitArgs, #s{selected = Index, wallet = #wallet{keys = Keys}}) ->
|
do_deploy(Build,
|
||||||
#key{pair = #s{public = PubKey, secret := SecKey}} = lists:nth(Index, Keys),
|
InitArgs,
|
||||||
|
#s{selected = Index, wallet = #wallet{keys = Keys, chain_id = ChainID}}) ->
|
||||||
|
#key{pair = #{public := PubKey, secret := SecKey}} = lists:nth(Index, Keys),
|
||||||
case hz:contract_create_built(PubKey, Build, InitArgs) of
|
case hz:contract_create_built(PubKey, Build, InitArgs) of
|
||||||
{ok, CreateTX} -> do_deploy2(SecKey, CreateTX);
|
{ok, CreateTX} -> do_deploy2(SecKey, CreateTX, ChainID);
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_deploy2(SecKey, CreateTX) ->
|
do_deploy2(SecKey, CreateTX, ChainID) ->
|
||||||
case gmc_con:sign(Request) of
|
SignedTX = sign_tx_hash(CreateTX, SecKey, ChainID),
|
||||||
{ok, SignedTX} -> do_deploy3(SignedTX);
|
|
||||||
Error -> Error
|
|
||||||
end.
|
|
||||||
|
|
||||||
do_deploy3(SignedTX) ->
|
|
||||||
case hz:post_tx(SignedTX) of
|
case hz:post_tx(SignedTX) of
|
||||||
{ok, Data = #{"tx_hash" := TXHash}} ->
|
{ok, Data = #{"tx_hash" := TXHash}} ->
|
||||||
ok = tell("Contract deploy TX succeded with: ~p", [TXHash]),
|
ok = tell("Contract deploy TX succeded with: ~p", [TXHash]),
|
||||||
do_deploy4(Data);
|
do_deploy3(Data);
|
||||||
{ok, WTF} ->
|
{ok, WTF} ->
|
||||||
{error, WTF};
|
{error, WTF};
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_deploy4(#{"tx_hash" := TXHash}) ->
|
do_deploy3(#{"tx_hash" := TXHash}) ->
|
||||||
case hz:tx_info(TZHash) of
|
case hz:tx_info(TXHash) of
|
||||||
{ok, {"call_info" := #{"return_type" := "ok", "contract_id" := ConID}}} ->
|
{ok, #{"call_info" := #{"return_type" := "ok", "contract_id" := ConID}}} ->
|
||||||
{contract_id, ConID};
|
{contract_id, ConID};
|
||||||
{error, "Tx not mined"} ->
|
{error, "Tx not mined"} ->
|
||||||
{tx_hash, TXHash};
|
{tx_hash, TXHash};
|
||||||
{ok, Reason = {"call_info" := #{"return_type" := "revert"}}} ->
|
{ok, Reason = #{"call_info" := #{"return_type" := "revert"}}} ->
|
||||||
{error, Reason};
|
{error, Reason};
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
@ -1179,7 +1175,8 @@ read2(Bin) ->
|
|||||||
|
|
||||||
read3(T) ->
|
read3(T) ->
|
||||||
case element(2, T) of
|
case element(2, T) of
|
||||||
1 -> {ok, T};
|
1 -> read3(setelement(2, erlang:append_element(T, #{}), 2));
|
||||||
|
2 -> {ok, T};
|
||||||
_ -> {error, bad_wallet}
|
_ -> {error, bad_wallet}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ clicked(State = #s{book = {Notebook, Pages}}, Name, Button) ->
|
|||||||
clicked(State,
|
clicked(State,
|
||||||
#p{instances = Is, funs = {_, Funs}, builds = Builds},
|
#p{instances = Is, funs = {_, Funs}, builds = Builds},
|
||||||
{<<"init">>, call},
|
{<<"init">>, call},
|
||||||
Button) ->
|
_Button) ->
|
||||||
Label = wxChoice:getStringSelection(Is),
|
Label = wxChoice:getStringSelection(Is),
|
||||||
Build = maps:get(Label, Builds),
|
Build = maps:get(Label, Builds),
|
||||||
#f{args = Args} = lists:keyfind(<<"init">>, #f.name, Funs),
|
#f{args = Args} = lists:keyfind(<<"init">>, #f.name, Funs),
|
||||||
@ -300,14 +300,22 @@ clicked(State,
|
|||||||
ok = tell("Label: ~p~nArgs: ~p~nInitArgs: ~p", [Label, Args, InitArgs]),
|
ok = tell("Label: ~p~nArgs: ~p~nInitArgs: ~p", [Label, Args, InitArgs]),
|
||||||
case gmc_con:deploy(Build, InitArgs) of
|
case gmc_con:deploy(Build, InitArgs) of
|
||||||
{contract_id, ConID} ->
|
{contract_id, ConID} ->
|
||||||
|
ok = tell("Got ConID: ~p", [ConID]),
|
||||||
|
State;
|
||||||
{tx_hash, TX_Hash} ->
|
{tx_hash, TX_Hash} ->
|
||||||
|
ok = tell("Got TX_Hash: ~p", [TX_Hash]),
|
||||||
|
State;
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
ok = tell("Deploy failed with: ~p", [Reason])
|
ok = tell("Deploy failed with: ~p", [Reason]),
|
||||||
State
|
State
|
||||||
clicked(State, Page, Name) ->
|
end;
|
||||||
ok = tell("Button: ~p~nPage: ~p", [Name, Page]),
|
clicked(State, Page, Name, Button) ->
|
||||||
|
ok = tell("Button: ~p ~p~nPage: ~p", [Button, Name, Page]),
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
get_arg({_, TextCtrl, _}) ->
|
||||||
|
wxTextCtrl:getValue(TextCtrl).
|
||||||
|
|
||||||
|
|
||||||
new_file(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
|
new_file(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
|
||||||
DefaultDir =
|
DefaultDir =
|
||||||
@ -409,7 +417,7 @@ find_main([], M, Is) ->
|
|||||||
fun_interfaces(Window,
|
fun_interfaces(Window,
|
||||||
Buttons,
|
Buttons,
|
||||||
{OldScrollWin, OldIfaces},
|
{OldScrollWin, OldIfaces},
|
||||||
{#{name := Name, functions := Funs}, ConIfaces},
|
{#{name := Name, functions := Funs}, _ConIfaces},
|
||||||
J) ->
|
J) ->
|
||||||
ok = wxScrolledWindow:destroy(OldScrollWin),
|
ok = wxScrolledWindow:destroy(OldScrollWin),
|
||||||
OldButtonIDs = button_key_list(OldIfaces),
|
OldButtonIDs = button_key_list(OldIfaces),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user