WIP: Adding contract_create_built/3
This commit is contained in:
parent
dbf4f6bdb2
commit
06fc0ac403
16
.gitignore
vendored
Normal file
16
.gitignore
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
.eunit
|
||||||
|
deps
|
||||||
|
cancer
|
||||||
|
*.o
|
||||||
|
*.beam
|
||||||
|
*.plt
|
||||||
|
*.swp
|
||||||
|
erl_crash.dump
|
||||||
|
ebin/*.beam
|
||||||
|
doc/*.html
|
||||||
|
doc/*.css
|
||||||
|
doc/edoc-info
|
||||||
|
doc/erlang.png
|
||||||
|
rel/example_project
|
||||||
|
.concrete/DEV_MODE
|
||||||
|
.rebar
|
@ -3,6 +3,6 @@
|
|||||||
{included_applications,[]},
|
{included_applications,[]},
|
||||||
{applications,[stdlib,kernel]},
|
{applications,[stdlib,kernel]},
|
||||||
{description,"Gajumaru interoperation library"},
|
{description,"Gajumaru interoperation library"},
|
||||||
{vsn,"0.1.0"},
|
{vsn,"0.2.0"},
|
||||||
{modules,[hakuzaru,hz,hz_fetcher,hz_man,hz_sup]},
|
{modules,[hakuzaru,hz,hz_fetcher,hz_man,hz_sup]},
|
||||||
{mod,{hakuzaru,[]}}]}.
|
{mod,{hakuzaru,[]}}]}.
|
||||||
|
Binary file not shown.
BIN
ebin/hz.beam
BIN
ebin/hz.beam
Binary file not shown.
Binary file not shown.
BIN
ebin/hz_man.beam
BIN
ebin/hz_man.beam
Binary file not shown.
BIN
ebin/hz_sup.beam
BIN
ebin/hz_sup.beam
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hakuzaru).
|
-module(hakuzaru).
|
||||||
-vsn("0.4.1").
|
-vsn("0.2.0").
|
||||||
-author("Craig Everett <ceverett@tsuriai.jp>").
|
-author("Craig Everett <ceverett@tsuriai.jp>").
|
||||||
-copyright("Craig Everett <ceverett@tsuriai.jp>").
|
-copyright("Craig Everett <ceverett@tsuriai.jp>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
33
src/hz.erl
33
src/hz.erl
@ -23,7 +23,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz).
|
-module(hz).
|
||||||
-vsn("0.4.1").
|
-vsn("0.2.0").
|
||||||
-author("Craig Everett <ceverett@tsuriai.jp>").
|
-author("Craig Everett <ceverett@tsuriai.jp>").
|
||||||
-copyright("Craig Everett <ceverett@tsuriai.jp>").
|
-copyright("Craig Everett <ceverett@tsuriai.jp>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@ -61,6 +61,7 @@
|
|||||||
min_gas/0,
|
min_gas/0,
|
||||||
min_gas_price/0,
|
min_gas_price/0,
|
||||||
contract_create/3,
|
contract_create/3,
|
||||||
|
contract_create_built/3,
|
||||||
contract_create/8,
|
contract_create/8,
|
||||||
prepare_contract/1,
|
prepare_contract/1,
|
||||||
aaci_lookup_spec/2,
|
aaci_lookup_spec/2,
|
||||||
@ -1012,36 +1013,54 @@ contract_create(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Path, InitArgs) ->
|
|||||||
Error
|
Error
|
||||||
end.
|
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) ->
|
contract_create2(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Source, Options, InitArgs) ->
|
||||||
case aeso_compiler:from_string(Source, Options) of
|
case aeso_compiler:from_string(Source, Options) of
|
||||||
{ok, Compiled} ->
|
{ok, Compiled} ->
|
||||||
contract_create3(CreatorID, Nonce, Amount, TTL, Gas, GasPrice,
|
contract_create3(CreatorID, Nonce, Amount, TTL, Gas, GasPrice,
|
||||||
Source, Compiled, InitArgs);
|
Compiled, InitArgs);
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end.
|
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)),
|
AACI = prepare_aaci(maps:get(aci, Compiled)),
|
||||||
case encode_call_data(AACI, "init", InitArgs) of
|
case encode_call_data(AACI, "init", InitArgs) of
|
||||||
{ok, CallData} ->
|
{ok, CallData} ->
|
||||||
contract_create4(CreatorID, Nonce, Amount, TTL, Gas, GasPrice,
|
contract_create4(CreatorID, Nonce, Amount, TTL, Gas, GasPrice,
|
||||||
Source, Compiled, CallData);
|
Compiled, CallData);
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end.
|
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),
|
PK = unicode:characters_to_binary(CreatorID),
|
||||||
try
|
try
|
||||||
{account_pubkey, OwnerID} = aeser_api_encoder:decode(PK),
|
{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
|
catch
|
||||||
Error:Reason -> {Error, Reason}
|
Error:Reason -> {Error, Reason}
|
||||||
end.
|
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),
|
Code = aeser_contract_code:serialize(Compiled),
|
||||||
|
Source = maps:get(contract_source, Compiled, <<>>),
|
||||||
VM = 1,
|
VM = 1,
|
||||||
ABI = 1,
|
ABI = 1,
|
||||||
<<CTVersion:32>> = <<VM:16, ABI:16>>,
|
<<CTVersion:32>> = <<VM:16, ABI:16>>,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-module(hz_fetcher).
|
-module(hz_fetcher).
|
||||||
-vsn("0.4.1").
|
-vsn("0.2.0").
|
||||||
-author("Craig Everett <ceverett@tsuriai.jp>").
|
-author("Craig Everett <ceverett@tsuriai.jp>").
|
||||||
-copyright("Craig Everett <ceverett@tsuriai.jp>").
|
-copyright("Craig Everett <ceverett@tsuriai.jp>").
|
||||||
-license("MIT").
|
-license("MIT").
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz_man).
|
-module(hz_man).
|
||||||
-vsn("0.4.1").
|
-vsn("0.2.0").
|
||||||
-behavior(gen_server).
|
-behavior(gen_server).
|
||||||
-author("Craig Everett <ceverett@tsuriai.jp>").
|
-author("Craig Everett <ceverett@tsuriai.jp>").
|
||||||
-copyright("Craig Everett <ceverett@tsuriai.jp>").
|
-copyright("Craig Everett <ceverett@tsuriai.jp>").
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz_sup).
|
-module(hz_sup).
|
||||||
-vsn("0.4.1").
|
-vsn("0.2.0").
|
||||||
-behaviour(supervisor).
|
-behaviour(supervisor).
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{name,"Hakuzaru"}.
|
{name,"Hakuzaru"}.
|
||||||
{type,app}.
|
{type,app}.
|
||||||
{modules,[]}.
|
{modules,[]}.
|
||||||
{author,"Craig Everett"}.
|
|
||||||
{prefix,"hz"}.
|
{prefix,"hz"}.
|
||||||
{desc,"Gajumaru interoperation library"}.
|
{desc,"Gajumaru interoperation library"}.
|
||||||
{package_id,{"otpr","hakuzaru",{0,1,0}}}.
|
{author,"Craig Everett"}.
|
||||||
|
{package_id,{"otpr","hakuzaru",{0,2,0}}}.
|
||||||
{deps,[{"otpr","erl_base58",{0,1,0}},
|
{deps,[{"otpr","erl_base58",{0,1,0}},
|
||||||
{"otpr","ec_utils",{1,0,0}},
|
{"otpr","ec_utils",{1,0,0}},
|
||||||
{"otpr","aebytecode",{3,2,1}},
|
{"otpr","aebytecode",{3,2,1}},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user