commit 03e668875bd19785f0911db77f6757a2a570972c Author: Craig Everett Date: Wed May 27 15:33:29 2026 +0900 Initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d64bbcd --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +.eunit +deps +cancer +*.o +*.beam +*.plt +*.swp +erl_crash.dump +ebin/*.beam +doc/*.html +doc/erlang.png +doc/stylesheet.css +doc/edoc-info +rel/example_project +.concrete/DEV_MODE +.rebar diff --git a/Emakefile b/Emakefile new file mode 100644 index 0000000..68c7b67 --- /dev/null +++ b/Emakefile @@ -0,0 +1 @@ +{"src/*", [debug_info, {i, "include/"}, {outdir, "ebin/"}]}. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fd4e67d --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright 2026 Craig Everett + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ebin/resolver.app b/ebin/resolver.app new file mode 100644 index 0000000..91d02c1 --- /dev/null +++ b/ebin/resolver.app @@ -0,0 +1,7 @@ +{application,resolver, + [{description,"Resolves and verifies service endpoints via Gajumaru lookup"}, + {registered,[]}, + {included_applications,[]}, + {applications,[stdlib,kernel]}, + {vsn,"0.1.0"}, + {modules,[resolver]}]}. diff --git a/priv/resolver.aes b/priv/resolver.aes new file mode 100644 index 0000000..7c240a4 --- /dev/null +++ b/priv/resolver.aes @@ -0,0 +1,35 @@ +@compiler == 9.0.0 + +include "String.aes" + +contract Resolver = + record state = + {ips : list(string), + port : int, + salt : bytes(), + ids : list(address)} + + stateful entrypoint init(ips : list(string), port : int, salt : string, ids : list(address)) : state = + {ips = ips, + port = port, + salt = String.to_bytes(salt), + ids = ids} + + public stateful entrypoint ips(ips : list(string)) : unit = + require(Call.caller == Contract.creator, "Unauthorized") + put(state{ips = ips}) + + public stateful entrypoint port(port : int) : unit = + require(Call.caller == Contract.creator, "Unauthorized") + put(state{port = port}) + + public stateful entrypoint salt(salt : string) : unit = + require(Call.caller == Contract.creator, "Unauthorized") + put(state{salt = String.to_bytes(salt)}) + + public stateful entrypoint ids(ids : list(address)) : unit = + require(Call.caller == Contract.creator, "Unauthorized") + put(state{ids = ids}) + + public entrypoint resolve() : list(string) * int * bytes() * list(address) = + (state.ips, state.port, state.salt, state.ids) diff --git a/src/resolver.erl b/src/resolver.erl new file mode 100644 index 0000000..266327f --- /dev/null +++ b/src/resolver.erl @@ -0,0 +1,42 @@ +%%% @doc +%%% Resolver +%%% @end + +-module(resolver). +-vsn("0.1.0"). +-author("Craig Everett "). +-copyright("Craig Everett "). +-license("MIT"). + +-export([start/1]). + +-include_lib("$zx_include/zx_logger.hrl"). + +-spec start([ContractID]) -> ok + when ContractID :: string(). + +start([ConID]) -> + ok = hakuzaru:start(), + ok = hz:chain_nodes([{"tsuriai.jp", 4013}]), + {project, [{_, Source}]} = hz:contract_source(ConID), + {ok, Built} = so_compiler:from_string(Source, [{aci, json}]), + AACI = hz_aaci:prepare(maps:get(aci, Built)), + % Dry runs require a caller that is known, and the contract owner is definitely known + {ok, #{"owner_id" := CallerID}} = hz:contract(ConID), + {ok, Nonce} = hz:next_nonce(CallerID), + Gas = 5000000, + GP = 1000000000, + Amount = 0, + TTL = 0, + Fun = "resolve", + {ok, UnsignedTX} = hz:contract_call(CallerID, Nonce, Gas, GP, Amount, TTL, AACI, ConID, Fun, []), + {ok, #{"results" := [#{"call_obj" := #{"return_value" := Return}}]}} = hz:dry_run(UnsignedTX), + R_Type = maps:get(Fun, element(3, AACI)), + Sophia = hz:decode_bytearray(Return, {sophia, R_Type}), + io:format("~ts~n", [Sophia]), +% Erlang = hz:decode_bytearray(Return, {erlang, R_Type}), +% ok = tell(info, "Decoded Erlang: ~tp", [Erlang]), + zx:silent_stop(); +start(Poop) -> + ok = tell(info, "Bad arg: ~tp", [Poop]), + zx:silent_stop(). diff --git a/zomp.meta b/zomp.meta new file mode 100644 index 0000000..9ba1e03 --- /dev/null +++ b/zomp.meta @@ -0,0 +1,26 @@ +{name,"resolver"}. +{type,cli}. +{modules,[]}. +{mod,"resolver"}. +{prefix,none}. +{author,"Craig Everett"}. +{desc,"Resolves and verifies service endpoints via Gajumaru lookup"}. +{package_id,{"otpr","resolver",{0,1,0}}}. +{deps,[{"otpr","hakuzaru",{0,9,1}}, + {"otpr","getopt",{1,0,2}}, + {"otpr","zj",{1,1,0}}, + {"otpr","ec_utils",{1,0,0}}, + {"otpr","eblake2",{1,0,1}}, + {"otpr","base58",{0,1,1}}, + {"otpr","gmbytecode",{3,4,1}}, + {"otpr","gmserialization",{0,1,3}}, + {"otpr","sophia",{9,0,0}}]}. +{key_name,none}. +{a_email,"craigeverett@qpq.swiss"}. +{c_email,"craigeverett@qpq.swiss"}. +{copyright,"Craig Everett"}. +{file_exts,[]}. +{license,"MIT"}. +{repo_url,"https://git.qpq.swiss/zxq9/resolver"}. +{tags,[]}. +{ws_url,"https://git.qpq.swiss/zxq9/resolver"}.