diff --git a/counter.aes b/counter.aes index 11234a4..1baf464 100644 --- a/counter.aes +++ b/counter.aes @@ -6,8 +6,8 @@ contract Counter = stateful entrypoint init() = {value = 1} - stateful entrypoint increment() = - put({value = state.value + 1}) + stateful entrypoint increment(n : int) = + put({value = state.value + n}) entrypoint value() = - state.value \ No newline at end of file + state.value diff --git a/toy_caller.erl b/toy_caller.erl index 66617ed..8fcd2b9 100644 --- a/toy_caller.erl +++ b/toy_caller.erl @@ -20,7 +20,8 @@ deploy(Source, PubKey, SecKey) -> end. deploy2(Build, PubKey, SecKey) -> - ChainID = <<"groot.testnet">>, % NOTE: This obviously should come from the chain + {ok, #{"network_id" := ChainID}} = hz:status(), + NetworkID = list_to_binary(ChainID), {ok, Height} = hz:top_height(), {ok, Nonce} = hz:next_nonce(PubKey), TTL = Height + 10000, @@ -31,8 +32,8 @@ deploy2(Build, PubKey, SecKey) -> case hz:contract_create_built(PubKey, Nonce, Amount, TTL, Gas, GasPrice, Build, InitArgs) of - {ok, CreateTX} -> deploy3(SecKey, CreateTX, ChainID); - Error -> gmc_v_devman:trouble(Error) + {ok, CreateTX} -> deploy3(SecKey, CreateTX, NetworkID); + Error -> gd_v_devman:trouble(Error) end. deploy3(SecKey, CreateTX, ChainID) -> @@ -42,21 +43,21 @@ deploy3(SecKey, CreateTX, ChainID) -> ok = io:format("The transaction hash is: ~p", [TXHash]), deploy4(Data); {ok, WTF} -> - gmc_v_devman:trouble({error, WTF}); + gd_v_devman:trouble({error, WTF}); Error -> - gmc_v_devman:trouble(Error) + gd_v_devman:trouble(Error) end. deploy4(#{"tx_hash" := TXHash}) -> case hz:tx_info(TXHash) of {ok, #{"call_info" := #{"return_type" := "ok", "contract_id" := ConID}}} -> - gmc_v_devman:open_contract(ConID); + gd_v_devman:open_contract(ConID); {error, "Tx not mined"} -> - gmc_v_devman:trouble({tx_hash, TXHash}); + gd_v_devman:trouble({tx_hash, TXHash}); {ok, Reason = #{"call_info" := #{"return_type" := "revert"}}} -> - gmc_v_devman:trouble({error, Reason}); + gd_v_devman:trouble({error, Reason}); Error -> - gmc_v_devman:trouble(Error) + gd_v_devman:trouble(Error) end.