-module(gleeth@ethereum@formatting). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/gleeth/ethereum/formatting.gleam"). -export([format_wei_to_ether/1, format_block_number/1, format_address/1, format_hash/1, print_balance/2, print_block_number/1, print_transaction_hash/1, print_error/1, format_hex_with_decimal/2, print_labeled_value/2, print_section/1, print_success/1, print_warning/1, print_info/1, display_address/1, display_hash/1]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -file("src/gleeth/ethereum/formatting.gleam", 11). -spec format_wei_to_ether(binary()) -> binary(). format_wei_to_ether(Wei) -> gleeth@utils@hex:format_wei_to_ether(Wei). -file("src/gleeth/ethereum/formatting.gleam", 16). -spec format_block_number(binary()) -> binary(). format_block_number(Block_number) -> gleeth@utils@hex:format_block_number(Block_number). -file("src/gleeth/ethereum/formatting.gleam", 21). -spec format_address(binary()) -> binary(). format_address(Address) -> case gleam_stdlib:string_starts_with(Address, <<"0x"/utf8>>) of true -> Address; false -> <<"0x"/utf8, Address/binary>> end. -file("src/gleeth/ethereum/formatting.gleam", 29). -spec format_hash(binary()) -> binary(). format_hash(Hash) -> case gleam_stdlib:string_starts_with(Hash, <<"0x"/utf8>>) of true -> Hash; false -> <<"0x"/utf8, Hash/binary>> end. -file("src/gleeth/ethereum/formatting.gleam", 37). -spec print_balance(binary(), binary()) -> nil. print_balance(Address, Balance) -> gleam_stdlib:println(<<"Address: "/utf8, (format_address(Address))/binary>>), gleam_stdlib:println( <<"Balance: "/utf8, (format_wei_to_ether(Balance))/binary>> ), gleam_stdlib:println(<<"Raw Wei: "/utf8, Balance/binary>>). -file("src/gleeth/ethereum/formatting.gleam", 44). -spec print_block_number(binary()) -> nil. print_block_number(Block_number) -> gleam_stdlib:println( <<"Latest Block: "/utf8, (format_block_number(Block_number))/binary>> ), gleam_stdlib:println(<<"Raw Hex: "/utf8, Block_number/binary>>). -file("src/gleeth/ethereum/formatting.gleam", 50). -spec print_transaction_hash(binary()) -> nil. print_transaction_hash(Hash) -> gleam_stdlib:println(<<"Transaction: "/utf8, (format_hash(Hash))/binary>>). -file("src/gleeth/ethereum/formatting.gleam", 55). -spec print_error(binary()) -> nil. print_error(Error) -> gleam_stdlib:println(<<"Error: "/utf8, Error/binary>>). -file("src/gleeth/ethereum/formatting.gleam", 64). ?DOC(" Format hex value with decimal equivalent for display\n"). -spec format_hex_with_decimal(binary(), binary()) -> nil. format_hex_with_decimal(Hex_value, Label) -> case gleeth@utils@hex:to_int(Hex_value) of {ok, Decimal_value} -> gleam_stdlib:println( <<<<<<<<<<<<" "/utf8, Label/binary>>/binary, ": "/utf8>>/binary, (erlang:integer_to_binary(Decimal_value))/binary>>/binary, " ("/utf8>>/binary, (gleeth@utils@hex:normalize(Hex_value))/binary>>/binary, ")"/utf8>> ); {error, _} -> gleam_stdlib:println( <<<<<<" "/utf8, Label/binary>>/binary, ": "/utf8>>/binary, (gleeth@utils@hex:normalize(Hex_value))/binary>> ) end. -file("src/gleeth/ethereum/formatting.gleam", 81). ?DOC(" Print a labeled value\n"). -spec print_labeled_value(binary(), binary()) -> nil. print_labeled_value(Label, Value) -> gleam_stdlib:println( <<<<<<" "/utf8, Label/binary>>/binary, ": "/utf8>>/binary, Value/binary>> ). -file("src/gleeth/ethereum/formatting.gleam", 86). ?DOC(" Print a section header\n"). -spec print_section(binary()) -> nil. print_section(Title) -> gleam_stdlib:println(<<""/utf8>>), gleam_stdlib:println(<>). -file("src/gleeth/ethereum/formatting.gleam", 92). ?DOC(" Print success message with emoji\n"). -spec print_success(binary()) -> nil. print_success(Message) -> gleam_stdlib:println(<<"✅ "/utf8, Message/binary>>). -file("src/gleeth/ethereum/formatting.gleam", 97). ?DOC(" Print warning message with emoji\n"). -spec print_warning(binary()) -> nil. print_warning(Message) -> gleam_stdlib:println(<<"⚠️ "/utf8, Message/binary>>). -file("src/gleeth/ethereum/formatting.gleam", 102). ?DOC(" Print info message with emoji\n"). -spec print_info(binary()) -> nil. print_info(Message) -> gleam_stdlib:println(<<"📋 "/utf8, Message/binary>>). -file("src/gleeth/ethereum/formatting.gleam", 107). ?DOC(" Format address for display (ensure 0x prefix and lowercase)\n"). -spec display_address(binary()) -> binary(). display_address(Address) -> gleeth@utils@hex:normalize(Address). -file("src/gleeth/ethereum/formatting.gleam", 112). ?DOC(" Format hash for display (ensure 0x prefix and lowercase)\n"). -spec display_hash(binary()) -> binary(). display_hash(Hash) -> gleeth@utils@hex:normalize(Hash).