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,
|
||||
contract_create/3,
|
||||
contract_create_built/3,
|
||||
contract_create_built/8,
|
||||
contract_create/8,
|
||||
prepare_contract/1,
|
||||
prepare_aaci/1,
|
||||
@ -1025,6 +1026,16 @@ contract_create(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Path, InitArgs) ->
|
||||
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
|
||||
when CreatorID :: unicode:chardata(),
|
||||
Compiled :: map(),
|
||||
@ -1045,43 +1056,35 @@ contract_create_built(CreatorID, Compiled, InitArgs) ->
|
||||
TTL = Height + 262980,
|
||||
Gas = 500000,
|
||||
GasPrice = min_gas_price(),
|
||||
contract_create3(CreatorID, Nonce,
|
||||
Amount, TTL, Gas, GasPrice,
|
||||
Compiled, InitArgs);
|
||||
contract_create_built(CreatorID, Nonce,
|
||||
Amount, TTL, Gas, GasPrice,
|
||||
Compiled, InitArgs);
|
||||
Error ->
|
||||
Error
|
||||
end.
|
||||
|
||||
|
||||
contract_create2(CreatorID, Nonce, Amount, TTL, Gas, GasPrice, Source, Options, 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) ->
|
||||
contract_create_built(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,
|
||||
Compiled, CallData);
|
||||
assemble_calldata(CreatorID, Nonce, Amount, TTL, Gas, GasPrice,
|
||||
Compiled, CallData);
|
||||
Error ->
|
||||
Error
|
||||
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),
|
||||
try
|
||||
{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
|
||||
Error:Reason -> {Error, Reason}
|
||||
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),
|
||||
Source = unicode:characters_to_binary(maps:get(contract_source, Compiled, <<>>)),
|
||||
VM = 1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user