Merge pull request 'Fix typespec' (#29) from respec into improve_specs

Reviewed-on: #29
This commit was merged in pull request #29.
This commit is contained in:
2026-05-22 15:57:11 +09:00
+8 -10
View File
@@ -788,9 +788,9 @@ contract_code(ID) ->
Result :: {ok, Source} Result :: {ok, Source}
| {project, Bundle} | {project, Bundle}
| {error, Reason}, | {error, Reason},
Source :: string(), Source :: binary(),
Bundle :: [{FilePath :: string(), Contents :: binary()}], Bundle :: [{FilePath :: string(), Contents :: binary()}],
Reason :: chain_error() | string(). Reason :: chain_error() | string().
%% @doc %% @doc
%% Retrieve the code of a contract as represented on chain. %% Retrieve the code of a contract as represented on chain.
@@ -801,23 +801,21 @@ contract_source(ID) ->
Error -> Error Error -> Error
end. end.
extract(<<"ba_", _/binary>> = Blobby) -> extract(Blobby) ->
case gmser_api_encoder:safe_decode(bytearray, Blobby) of case gmser_api_encoder:safe_decode(bytearray, Blobby) of
{ok, TarBaby} -> extract2(TarBaby); {ok, TarBaby} -> extract2(TarBaby);
{error, invalid_encoding} -> {ok, unicode:characters_to_list(Blobby)} {error, invalid_encoding} -> {ok, Blobby}
end; end.
extract(Blobby) when is_binary(Blobby) ->
{ok, unicode:characters_to_list(Blobby)}.
extract2(TarBaby) -> extract2(TarBaby) ->
case erl_tar:extract({binary, TarBaby}, [memory, compressed]) of case erl_tar:extract({binary, TarBaby}, [memory, compressed]) of
{ok, [{_File, Source}]} -> {ok, [{_File, Source}]} ->
{ok, unicode:characters_to_list(Source)}; {ok, Source};
{ok, Bundle} -> {ok, Bundle} ->
{project, Bundle}; {project, Bundle};
Error -> Error ->
io:format("Dis chit happen: ~tp~n", [Error]), io:format("Dis chit happen: ~tp~n", [Error]),
{ok, unicode:characters_to_list(TarBaby)} {ok, TarBaby}
end. end.