Current section
Files
Jump to
Current section
Files
src/nimiq_rpc@primitives@account.erl
-module(nimiq_rpc@primitives@account).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/nimiq_rpc/primitives/account.gleam").
-export([decoder/0]).
-export_type([account/0]).
-type account() :: {basic, binary(), integer()} |
{vesting,
binary(),
integer(),
binary(),
integer(),
integer(),
integer(),
integer()} |
{h_t_l_c,
binary(),
integer(),
integer(),
nimiq_rpc@primitives@hash:hash(),
binary(),
binary(),
integer(),
integer()} |
{staking, binary(), integer()}.
-file("src/nimiq_rpc/primitives/account.gleam", 29).
-spec basic_decoder() -> gleam@dynamic@decode:decoder(account()).
basic_decoder() ->
gleam@dynamic@decode:field(
<<"address"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Address) ->
gleam@dynamic@decode:field(
<<"balance"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Balance) ->
gleam@dynamic@decode:success({basic, Address, Balance})
end
)
end
).
-file("src/nimiq_rpc/primitives/account.gleam", 35).
-spec vesting_decoder() -> gleam@dynamic@decode:decoder(account()).
vesting_decoder() ->
gleam@dynamic@decode:field(
<<"address"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Address) ->
gleam@dynamic@decode:field(
<<"balance"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Balance) ->
gleam@dynamic@decode:field(
<<"owner"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Owner) ->
gleam@dynamic@decode:field(
<<"vestingStartTime"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Start_time) ->
gleam@dynamic@decode:field(
<<"vestingStepAmount"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_int/1},
fun(Step_amount) ->
gleam@dynamic@decode:field(
<<"vestingTimeStep"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_int/1},
fun(Time_step) ->
gleam@dynamic@decode:field(
<<"vestingTotalAmount"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_int/1},
fun(Total_amount) ->
gleam@dynamic@decode:success(
{vesting,
Address,
Balance,
Owner,
Start_time,
Step_amount,
Time_step,
Total_amount}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).
-file("src/nimiq_rpc/primitives/account.gleam", 54).
-spec htlc_decoder() -> gleam@dynamic@decode:decoder(account()).
htlc_decoder() ->
gleam@dynamic@decode:field(
<<"address"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Address) ->
gleam@dynamic@decode:field(
<<"balance"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Balance) ->
gleam@dynamic@decode:field(
<<"hashCount"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Hash_count) ->
gleam@dynamic@decode:field(
<<"hashRoot"/utf8>>,
nimiq_rpc@primitives@hash:decoder(),
fun(Hash_root) ->
gleam@dynamic@decode:field(
<<"recipient"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Recipient) ->
gleam@dynamic@decode:field(
<<"sender"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Sender) ->
gleam@dynamic@decode:field(
<<"timeout"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_int/1},
fun(Timeout) ->
gleam@dynamic@decode:field(
<<"totalAmount"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_int/1},
fun(
Total_amount
) ->
gleam@dynamic@decode:success(
{h_t_l_c,
Address,
Balance,
Hash_count,
Hash_root,
Recipient,
Sender,
Timeout,
Total_amount}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).
-file("src/nimiq_rpc/primitives/account.gleam", 75).
-spec staking_decoder() -> gleam@dynamic@decode:decoder(account()).
staking_decoder() ->
gleam@dynamic@decode:field(
<<"address"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Address) ->
gleam@dynamic@decode:field(
<<"balance"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Balance) ->
gleam@dynamic@decode:success({staking, Address, Balance})
end
)
end
).
-file("src/nimiq_rpc/primitives/account.gleam", 81).
-spec decoder() -> gleam@dynamic@decode:decoder(account()).
decoder() ->
gleam@dynamic@decode:field(
<<"type"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Typ) -> case Typ of
<<"basic"/utf8>> ->
basic_decoder();
<<"vesting"/utf8>> ->
vesting_decoder();
<<"htlc"/utf8>> ->
htlc_decoder();
<<"staking"/utf8>> ->
staking_decoder();
_ ->
gleam@dynamic@decode:failure(
{basic, <<""/utf8>>, 0},
<<"Account"/utf8>>
)
end end
).