WIP: Adding contract_create_built/3

This commit is contained in:
2024-12-09 15:00:21 +09:00
parent dbf4f6bdb2
commit 06fc0ac403
13 changed files with 49 additions and 14 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
%%% @end
-module(hakuzaru).
-vsn("0.4.1").
-vsn("0.2.0").
-author("Craig Everett <ceverett@tsuriai.jp>").
-copyright("Craig Everett <ceverett@tsuriai.jp>").
-license("GPL-3.0-or-later").
+26 -7
View File
@@ -23,7 +23,7 @@
%%% @end
-module(hz).
-vsn("0.4.1").
-vsn("0.2.0").
-author("Craig Everett <ceverett@tsuriai.jp>").
-copyright("Craig Everett <ceverett@tsuriai.jp>").
-license("GPL-3.0-or-later").
@@ -61,6 +61,7 @@
min_gas/0,
min_gas_price/0,
contract_create/3,
contract_create_built/3,
contract_create/8,
prepare_contract/1,
aaci_lookup_spec/2,
@@ -1012,36 +1013,54 @@ contract_create(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Path, InitArgs) ->
Error
end.
contract_create_built(CreatorID, Compiled, InitArgs) ->
case next_nonce(CreatorID) of
{ok, Nonce} ->
Amount = 0,
{ok, Height} = top_height(),
TTL = Height + 262980,
Gas = 500000,
GasPrice = min_gas_price(),
contract_create3(CreatorID, Nonce,
Amount, TTL, Gas, GasPrice,
Compiled, InitArgs);
Error ->
Error
end.
contract_create2(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Source, Options, InitArgs) ->
case aeso_compiler:from_string(Source, Options) of
{ok, Compiled} ->
contract_create3(CreatorID, Nonce, Amount, TTL, Gas, GasPrice,
Source, Compiled, InitArgs);
Compiled, InitArgs);
Error ->
Error
end.
contract_create3(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Source, Compiled, InitArgs) ->
contract_create3(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Compiled, InitArgs) ->
AACI = prepare_aaci(maps:get(aci, Compiled)),
case encode_call_data(AACI, "init", InitArgs) of
{ok, CallData} ->
contract_create4(CreatorID, Nonce, Amount, TTL, Gas, GasPrice,
Source, Compiled, CallData);
Compiled, CallData);
Error ->
Error
end.
contract_create4(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Source, Compiled, CallData) ->
contract_create4(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Compiled, CallData) ->
PK = unicode:characters_to_binary(CreatorID),
try
{account_pubkey, OwnerID} = aeser_api_encoder:decode(PK),
contract_create5(OwnerID, Nonce, Amount, TTL, Gas, GasPrice, Source, Compiled, CallData)
contract_create5(OwnerID, Nonce, Amount, TTL, Gas, GasPrice, Compiled, CallData)
catch
Error:Reason -> {Error, Reason}
end.
contract_create5(OwnerID, Nonce, Amount, TTL, Gas, GasPrice, Source, Compiled, CallData) ->
contract_create5(OwnerID, Nonce, Amount, TTL, Gas, GasPrice, Compiled, CallData) ->
Code = aeser_contract_code:serialize(Compiled),
Source = maps:get(contract_source, Compiled, <<>>),
VM = 1,
ABI = 1,
<<CTVersion:32>> = <<VM:16, ABI:16>>,
+1 -1
View File
@@ -1,5 +1,5 @@
-module(hz_fetcher).
-vsn("0.4.1").
-vsn("0.2.0").
-author("Craig Everett <ceverett@tsuriai.jp>").
-copyright("Craig Everett <ceverett@tsuriai.jp>").
-license("MIT").
+1 -1
View File
@@ -9,7 +9,7 @@
%%% @end
-module(hz_man).
-vsn("0.4.1").
-vsn("0.2.0").
-behavior(gen_server).
-author("Craig Everett <ceverett@tsuriai.jp>").
-copyright("Craig Everett <ceverett@tsuriai.jp>").
+1 -1
View File
@@ -9,7 +9,7 @@
%%% @end
-module(hz_sup).
-vsn("0.4.1").
-vsn("0.2.0").
-behaviour(supervisor).
-author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>").