Current section
Files
Jump to
Current section
Files
src/nimiq_rpc@primitives@inherent.erl
-module(nimiq_rpc@primitives@inherent).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/nimiq_rpc/primitives/inherent.gleam").
-export([decoder/0]).
-export_type([inherent/0]).
-type inherent() :: {reward,
integer(),
integer(),
binary(),
binary(),
integer(),
binary()} |
{penalize, integer(), integer(), binary(), integer()} |
{jail, integer(), integer(), binary(), integer()}.
-file("src/nimiq_rpc/primitives/inherent.gleam", 26).
-spec reward_inherent_decoder() -> gleam@dynamic@decode:decoder(inherent()).
reward_inherent_decoder() ->
gleam@dynamic@decode:field(
<<"blockNumber"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Block_number) ->
gleam@dynamic@decode:field(
<<"blockTime"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Block_time) ->
gleam@dynamic@decode:field(
<<"validatorAddress"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Validator_address) ->
gleam@dynamic@decode:field(
<<"target"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Target) ->
gleam@dynamic@decode:field(
<<"value"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_int/1},
fun(Value) ->
gleam@dynamic@decode:field(
<<"hash"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Hash) ->
gleam@dynamic@decode:success(
{reward,
Block_number,
Block_time,
Validator_address,
Target,
Value,
Hash}
)
end
)
end
)
end
)
end
)
end
)
end
).
-file("src/nimiq_rpc/primitives/inherent.gleam", 43).
-spec penalize_inherent_decoder() -> gleam@dynamic@decode:decoder(inherent()).
penalize_inherent_decoder() ->
gleam@dynamic@decode:field(
<<"blockNumber"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Block_number) ->
gleam@dynamic@decode:field(
<<"blockTime"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Block_time) ->
gleam@dynamic@decode:field(
<<"validatorAddress"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Validator_address) ->
gleam@dynamic@decode:field(
<<"offenseEventBlock"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Offense_event_block) ->
gleam@dynamic@decode:success(
{penalize,
Block_number,
Block_time,
Validator_address,
Offense_event_block}
)
end
)
end
)
end
)
end
).
-file("src/nimiq_rpc/primitives/inherent.gleam", 56).
-spec jail_inherent_decoder() -> gleam@dynamic@decode:decoder(inherent()).
jail_inherent_decoder() ->
gleam@dynamic@decode:field(
<<"blockNumber"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Block_number) ->
gleam@dynamic@decode:field(
<<"blockTime"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Block_time) ->
gleam@dynamic@decode:field(
<<"validatorAddress"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Validator_address) ->
gleam@dynamic@decode:field(
<<"offenseEventBlock"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Offense_event_block) ->
gleam@dynamic@decode:success(
{jail,
Block_number,
Block_time,
Validator_address,
Offense_event_block}
)
end
)
end
)
end
)
end
).
-file("src/nimiq_rpc/primitives/inherent.gleam", 69).
-spec decoder() -> gleam@dynamic@decode:decoder(inherent()).
decoder() ->
gleam@dynamic@decode:field(
<<"type"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Typ) -> case Typ of
<<"reward"/utf8>> ->
reward_inherent_decoder();
<<"penalize"/utf8>> ->
penalize_inherent_decoder();
<<"jail"/utf8>> ->
jail_inherent_decoder();
_ ->
gleam@dynamic@decode:failure(
{reward, 0, 0, <<""/utf8>>, <<""/utf8>>, 0, <<""/utf8>>},
<<"Unknown inherent type"/utf8>>
)
end end
).