This commit is contained in:
2026-05-08 23:04:56 +09:00
parent 02945dd10d
commit 7fc3cd00da
+10 -9
View File
@@ -1151,12 +1151,13 @@ assemble_calldata(CreatorID, Nonce, Gas, GasPrice, Amount, TTL, Compiled, CallDa
{account_pubkey, OwnerID} = gmser_api_encoder:decode(PK), {account_pubkey, OwnerID} = gmser_api_encoder:decode(PK),
assemble_calldata2(OwnerID, Nonce, Gas, GasPrice, Amount, TTL, Compiled, CallData) assemble_calldata2(OwnerID, Nonce, Gas, GasPrice, Amount, TTL, Compiled, CallData)
catch catch
Error:Reason -> {Error, Reason} Error:Reason:Stack ->
{Error, {Reason, Stack}}
end. end.
assemble_calldata2(OwnerID, Nonce, Gas, GasPrice, Amount, TTL, Compiled, CallData) -> assemble_calldata2(OwnerID, Nonce, Gas, GasPrice, Amount, TTL, Compiled, CallData) ->
Code = gmser_contract_code:serialize(Compiled), Compressed = #{contract_source := Bundle} = bundle_source(Compiled),
Source = bundle_source(Compiled), Code = gmser_contract_code:serialize(Compressed),
VM = 1, VM = 1,
ABI = 1, ABI = 1,
<<CTVersion:32>> = <<VM:16, ABI:16>>, <<CTVersion:32>> = <<VM:16, ABI:16>>,
@@ -1166,7 +1167,7 @@ assemble_calldata2(OwnerID, Nonce, Gas, GasPrice, Amount, TTL, Compiled, CallDat
[{owner_id, gmser_id:create(account, OwnerID)}, [{owner_id, gmser_id:create(account, OwnerID)},
{nonce, Nonce}, {nonce, Nonce},
{code, Code}, {code, Code},
{source, Source}, {source, Bundle},
{ct_version, CTVersion}, {ct_version, CTVersion},
{ttl, TTL}, {ttl, TTL},
{deposit, 0}, {deposit, 0},
@@ -1200,21 +1201,21 @@ bundle_source(Compiled) ->
end. end.
bundle_source2(Source, Compiled) -> bundle_source2(Source, Compiled) ->
File = unicode:characters_to_binary(maps:get(contract_name, Compiled, <<"contract.aes">>)), File = unicode:characters_to_list(maps:get(contract_name, Compiled, "contract.aes")),
<<RN:(8 * 8)>> = crypto:strong_rand_bytes(8), <<RN:(8 * 8)>> = crypto:strong_rand_bytes(8),
Rand = integer_to_binary(RN, 36), Rand = integer_to_binary(RN, 36),
TmpDir = filename:join(zx_lib:path(tmp), Rand), TmpDir = filename:join(zx_lib:path(tmp), Rand),
TgzName = <<File, ".tgz">>, TgzName = File ++ ".tgz",
TarGzPath = filename:join(TmpDir, TgzName), TarGzPath = filename:join(TmpDir, TgzName),
ok = filelib:ensure_dir(TarGzPath), ok = filelib:ensure_dir(TarGzPath),
{ok, CWD} = file:get_cwd(), {ok, CWD} = file:get_cwd(),
ok = file:set_cwd(TmpDir), ok = file:set_cwd(TmpDir),
ok = file:write_file(File, Source), ok = erl_tar:create(TarGzPath, [{File, Source}], [compressed]),
ok = erl_tar:create(TarGzPath, [File], [compressed]),
{ok, TgzBin} = file:read_file(TarGzPath), {ok, TgzBin} = file:read_file(TarGzPath),
ok = file:set_cwd(CWD), ok = file:set_cwd(CWD),
ok = file:del_dir_r(TmpDir), ok = file:del_dir_r(TmpDir),
TgzBin. {ok, Hash} = eblake2:blake2b(32, TgzBin),
Compiled#{contract_source => TgzBin, source_hash => Hash}.
-spec read_aci(Path) -> Result -spec read_aci(Path) -> Result