Make Contract Calls Great Again

This commit is contained in:
2026-05-06 12:46:26 +09:00
parent 8b390f8d82
commit b071467faa
3 changed files with 110 additions and 59 deletions
+4 -29
View File
@@ -559,41 +559,16 @@ open_file(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
open_hash(State = #s{frame = Frame, j = J}) ->
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Retrieve Contract Source")),
Sizer = wxBoxSizer:new(?wxVERTICAL),
AddressSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Address Hash")}]),
AddressTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
_ = wxSizer:add(AddressSz, AddressTx, zxw:flags(wide)),
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
Affirm = wxButton:new(Dialog, ?wxID_OK),
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
_ = wxSizer:add(Sizer, AddressSz, zxw:flags(wide)),
_ = wxSizer:add(Sizer, ButtSz, zxw:flags(wide)),
ok = wxDialog:setSizer(Dialog, Sizer),
ok = wxBoxSizer:layout(Sizer),
ok = wxDialog:setSize(Dialog, {500, 200}),
ok = wxDialog:center(Dialog),
ok = wxTextCtrl:setFocus(AddressTx),
Choice =
case wxDialog:showModal(Dialog) of
?wxID_OK ->
case wxTextCtrl:getValue(AddressTx) of
"" -> cancel;
A -> {ok, A}
end;
?wxID_CANCEL ->
cancel
end,
ok = wxDialog:destroy(Dialog),
case Choice of
Title = J("Retrieve Contract Source"),
Label = J("Address Hash"),
case zxw_modal_text:show(Frame, Title, [{label, Label}]) of
{ok, Address = "ct_" ++ _} -> open_hash2(State, Address);
{ok, Address = "th_" ++ _} -> get_contract_from_tx(State, Address);
{ok, Turd} -> handle_troubling(State, {bad_address, Turd});
cancel -> State
end.
get_contract_from_tx(State, Address) ->
case hz:tx_info(Address) of
{ok, #{"call_info" := #{"contract_id" := Contract}}} ->