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),
assemble_calldata2(OwnerID, Nonce, Gas, GasPrice, Amount, TTL, Compiled, CallData)
catch
Error:Reason -> {Error, Reason}
Error:Reason:Stack ->
{Error, {Reason, Stack}}
end.
assemble_calldata2(OwnerID, Nonce, Gas, GasPrice, Amount, TTL, Compiled, CallData) ->
Code = gmser_contract_code:serialize(Compiled),
Source = bundle_source(Compiled),
Compressed = #{contract_source := Bundle} = bundle_source(Compiled),
Code = gmser_contract_code:serialize(Compressed),
VM = 1,
ABI = 1,
<<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)},
{nonce, Nonce},
{code, Code},
{source, Source},
{source, Bundle},
{ct_version, CTVersion},
{ttl, TTL},
{deposit, 0},
@@ -1200,21 +1201,21 @@ bundle_source(Compiled) ->
end.
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),
Rand = integer_to_binary(RN, 36),
TmpDir = filename:join(zx_lib:path(tmp), Rand),
TgzName = <<File, ".tgz">>,
TgzName = File ++ ".tgz",
TarGzPath = filename:join(TmpDir, TgzName),
ok = filelib:ensure_dir(TarGzPath),
{ok, CWD} = file:get_cwd(),
ok = file:set_cwd(TmpDir),
ok = file:write_file(File, Source),
ok = erl_tar:create(TarGzPath, [File], [compressed]),
ok = erl_tar:create(TarGzPath, [{File, Source}], [compressed]),
{ok, TgzBin} = file:read_file(TarGzPath),
ok = file:set_cwd(CWD),
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