Merge pull request 'Expose complete deployment parameters' (#4) from dryrun-fix into master
Reviewed-on: #4
This commit is contained in:
commit
5a16ccf45a
39
src/hz.erl
39
src/hz.erl
@ -62,6 +62,7 @@
|
|||||||
min_gas_price/0,
|
min_gas_price/0,
|
||||||
contract_create/3,
|
contract_create/3,
|
||||||
contract_create_built/3,
|
contract_create_built/3,
|
||||||
|
contract_create_built/8,
|
||||||
contract_create/8,
|
contract_create/8,
|
||||||
prepare_contract/1,
|
prepare_contract/1,
|
||||||
prepare_aaci/1,
|
prepare_aaci/1,
|
||||||
@ -1025,6 +1026,16 @@ contract_create(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Path, InitArgs) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
contract_create2(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Source, Options, InitArgs) ->
|
||||||
|
case so_compiler:from_string(Source, Options) of
|
||||||
|
{ok, Compiled} ->
|
||||||
|
contract_create_built(CreatorID, Nonce, Amount, TTL, Gas, GasPrice,
|
||||||
|
Compiled, InitArgs);
|
||||||
|
Error ->
|
||||||
|
Error
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
-spec contract_create_built(CreatorID, Compiled, InitArgs) -> Result
|
-spec contract_create_built(CreatorID, Compiled, InitArgs) -> Result
|
||||||
when CreatorID :: unicode:chardata(),
|
when CreatorID :: unicode:chardata(),
|
||||||
Compiled :: map(),
|
Compiled :: map(),
|
||||||
@ -1045,43 +1056,35 @@ contract_create_built(CreatorID, Compiled, InitArgs) ->
|
|||||||
TTL = Height + 262980,
|
TTL = Height + 262980,
|
||||||
Gas = 500000,
|
Gas = 500000,
|
||||||
GasPrice = min_gas_price(),
|
GasPrice = min_gas_price(),
|
||||||
contract_create3(CreatorID, Nonce,
|
contract_create_built(CreatorID, Nonce,
|
||||||
Amount, TTL, Gas, GasPrice,
|
Amount, TTL, Gas, GasPrice,
|
||||||
Compiled, InitArgs);
|
Compiled, InitArgs);
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
contract_create2(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Source, Options, InitArgs) ->
|
contract_create_built(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Compiled, InitArgs) ->
|
||||||
case so_compiler:from_string(Source, Options) of
|
|
||||||
{ok, Compiled} ->
|
|
||||||
contract_create3(CreatorID, Nonce, Amount, TTL, Gas, GasPrice,
|
|
||||||
Compiled, InitArgs);
|
|
||||||
Error ->
|
|
||||||
Error
|
|
||||||
end.
|
|
||||||
|
|
||||||
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,
|
assemble_calldata(CreatorID, Nonce, Amount, TTL, Gas, GasPrice,
|
||||||
Compiled, CallData);
|
Compiled, CallData);
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
contract_create4(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Compiled, CallData) ->
|
|
||||||
|
assemble_calldata(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} = gmser_api_encoder:decode(PK),
|
{account_pubkey, OwnerID} = gmser_api_encoder:decode(PK),
|
||||||
contract_create5(OwnerID, Nonce, Amount, TTL, Gas, GasPrice, Compiled, CallData)
|
assemble_calldata2(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, Compiled, CallData) ->
|
assemble_calldata2(OwnerID, Nonce, Amount, TTL, Gas, GasPrice, Compiled, CallData) ->
|
||||||
Code = gmser_contract_code:serialize(Compiled),
|
Code = gmser_contract_code:serialize(Compiled),
|
||||||
Source = unicode:characters_to_binary(maps:get(contract_source, Compiled, <<>>)),
|
Source = unicode:characters_to_binary(maps:get(contract_source, Compiled, <<>>)),
|
||||||
VM = 1,
|
VM = 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user