diff --git a/example/rebar.config b/example/rebar.config new file mode 100644 index 0000000..36b69b8 --- /dev/null +++ b/example/rebar.config @@ -0,0 +1,9 @@ +{erl_opts, [debug_info]}. +{deps, [ + {blockfrost_erlang, {git, "https://github.com/blockfrost/blockfrost-erlang"}} +]}. + +{shell, [ + % {config, "config/sys.config"}, + {apps, [example]} +]}. diff --git a/example/rebar.config.b b/example/rebar.config.b new file mode 100644 index 0000000..57531be --- /dev/null +++ b/example/rebar.config.b @@ -0,0 +1,9 @@ +{erl_opts, [debug_info]}. +{deps, [ + {blockfrost_erlang, "1.0.0"} +]}. + +{shell, [ + % {config, "config/sys.config"}, + {apps, [example]} +]}. diff --git a/example/rebar.lock b/example/rebar.lock new file mode 100644 index 0000000..cd120f0 --- /dev/null +++ b/example/rebar.lock @@ -0,0 +1,36 @@ +{"1.2.0", +[{<<"blockfrost_erlang">>, + {git,"https://github.com/blockfrost/blockfrost-erlang", + {ref,"d786915376f973c6859765eef5f87edfa92035bc"}}, + 0}, + {<<"certifi">>,{pkg,<<"certifi">>,<<"2.12.0">>},2}, + {<<"hackney">>,{pkg,<<"hackney">>,<<"1.19.1">>},1}, + {<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},2}, + {<<"jsx">>,{pkg,<<"jsx">>,<<"3.1.0">>},1}, + {<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2}, + {<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},2}, + {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.4.1">>},2}, + {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.7">>},2}, + {<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2}]}. +[ +{pkg_hash,[ + {<<"certifi">>, <<"2D1CCA2EC95F59643862AF91F001478C9863C2AC9CB6E2F89780BFD8DE987329">>}, + {<<"hackney">>, <<"59DE4716E985DD2B5CBD4954FA1AE187E2B610A9C4520FFCB0B1653C3D6E5559">>}, + {<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>}, + {<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>}, + {<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>}, + {<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>}, + {<<"parse_trans">>, <<"6E6AA8167CB44CC8F39441D05193BE6E6F4E7C2946CB2759F015F8C56B76E5FF">>}, + {<<"ssl_verify_fun">>, <<"354C321CF377240C7B8716899E182CE4890C5938111A1296ADD3EC74CF1715DF">>}, + {<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]}, +{pkg_hash_ext,[ + {<<"certifi">>, <<"EE68D85DF22E554040CDB4BE100F33873AC6051387BAF6A8F6CE82272340FF1C">>}, + {<<"hackney">>, <<"8AA08234BDEFC269995C63C2282CF3CD0E36FEBE3A6BFAB11B610572FDD1CAD0">>}, + {<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>}, + {<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>}, + {<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>}, + {<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>}, + {<<"parse_trans">>, <<"620A406CE75DADA827B82E453C19CF06776BE266F5A67CFF34E1EF2CBB60E49A">>}, + {<<"ssl_verify_fun">>, <<"FE4C190E8F37401D30167C8C405EDA19469F34577987C76DDE613E838BBC67F8">>}, + {<<"unicode_util_compat">>, <<"25EEE6D67DF61960CF6A794239566599B09E17E668D3700247BC498638152521">>}]} +]. diff --git a/example/src/example.app.src b/example/src/example.app.src new file mode 100644 index 0000000..561ea8e --- /dev/null +++ b/example/src/example.app.src @@ -0,0 +1,14 @@ +{application, example, + [{description, "Blockfrost API client example"}, + {vsn, "0.1.0"}, + {registered, []}, + {mod, {example_app, []}}, + {applications, + [kernel, stdlib, blockfrost_erlang]}, + {env,[]}, + {modules, [ + ]}, + + {licenses, ["Apache-2.0"]}, + {links, [{"GitHub", "https://github.com/blockfrost/blockfrost-erlang"}]} + ]}. diff --git a/example/src/example.erl b/example/src/example.erl new file mode 100644 index 0000000..278e3ec --- /dev/null +++ b/example/src/example.erl @@ -0,0 +1,16 @@ +-module(example). + +-export([loop/0]). + +loop() -> + Res = blockfrost:get_blocks_latest(), + case Res of + {ok, Block} -> + Hash = maps:get(<<"hash">>, Block), + TxCount = maps:get(<<"tx_count">>, Block), + io:format("Block ~p tx count: ~p~n", [binary:bin_to_list(Hash), TxCount]), + timer:sleep(timer:seconds(5)), + loop(); + _Else -> + io:format("Got error ~p~n", [_Else]) + end. diff --git a/example/src/example_app.erl b/example/src/example_app.erl new file mode 100644 index 0000000..07c9989 --- /dev/null +++ b/example/src/example_app.erl @@ -0,0 +1,12 @@ +-module(example_app). + +-behaviour(application). + +-export([start/2, stop/1]). + +start(_StartType, _StartArgs) -> + example_sup:start_link(). + +stop(_State) -> + ok. + diff --git a/example/src/example_sup.erl b/example/src/example_sup.erl new file mode 100644 index 0000000..bd764ef --- /dev/null +++ b/example/src/example_sup.erl @@ -0,0 +1,23 @@ +-module(example_sup). + +-behaviour(supervisor). + +-export([start_link/0]). + +-export([init/1]). + +-define(SERVER, ?MODULE). + +start_link() -> + supervisor:start_link({local, ?SERVER}, ?MODULE, []). + +init([]) -> + SupFlags = #{strategy => one_for_all, + intensity => 0, + period => 1}, + ChildSpecs = [ + #{id => example_loop, + start => {example, loop, []} + } + ], + {ok, {SupFlags, ChildSpecs}}. diff --git a/example/src/rebar.lock b/example/src/rebar.lock new file mode 100644 index 0000000..57afcca --- /dev/null +++ b/example/src/rebar.lock @@ -0,0 +1 @@ +[].