# frozen_string_literal: true # @author Hernani Rodrigues Vaz module Etht # (see Carteiras) class Carteiras # @return [String] texto formatado valores duma carteira def valores(hjn) format( '%10.6f %2i %2i %11.6f %2i %2i %-3s', v1: hjn[:bs], n1: hjn[:bt].count, n3: hjn[:bk].count, v2: hjn[:es], n2: hjn[:et].count, n4: hjn[:ek].count, ok: ok?(hjn) ? 'OK' : 'NOK' ) end # @return [String] texto formatado transacao normal def formata_tx(htx) format( '%9i %-20.20s %-20.20s %
10.10s %17.6f', bn: htx['blockNumber'], fr: ftx(htx['from'], 20), to: ftx(htx['to'], 20), dt: Time.at(Integer(htx['timeStamp'])), vl: (htx['value'].to_d / 10**18).round(10) ) end # @return [String] texto formatado transacao token def formata_kx(hkx) format( '%9i %-20.20s %-20.20s %
10.10s %11.3f %-5.5s', bn: hkx['blockNumber'], fr: ftx(hkx['from'], 20), to: ftx(hkx['to'], 20), dt: Time.at(Integer(hkx['timeStamp'])), vl: (hkx['value'].to_d / 10**18).round(10), sy: hkx['tokenSymbol'] ) end # @return [String] texto lista carteiras & lista transacoes & ajuste dias def mostra return unless dadosjn.count.positive? puts("\nid address ----bigquery---- ----etherscan----") dadosjn.each { |e| puts format('%-6.6s %-34.34s ', s1: e[:id], s2: ftx(e[:ax], 34)) + valores(e) } mostra_tx mostra_kx mostra_ha end # @example ether address inicio..fim # 0x10f3a0cf0b534c..c033cf32e8a03586 # @param [String] add ether address # @param [Integer] max chars a mostrar # @return [String] ether address formatada def ftx(add, max) i = Integer((max - 2) / 2) max < 7 ? 'erro' : "#{add[0, i]}..#{add[-i..]}" end # @return [String] lista transacoes normais def mostra_tx return unless novaest.count.positive? && ops[:v] puts("\ntx normal address from address to ---data--- ------valor------") sortest.each { |e| puts formata_tx(e) } end # @return [String] lista transacoes token def mostra_kx return unless novaesk.count.positive? && ops[:v] puts("\ntx token address from address to ---data--- ---valor--- token") sortesk.each { |e| puts formata_kx(e) } end # @return [String] texto configuracao ajuste dias def mostra_ha return unless (novaest.count + novaesk.count).positive? && ops[:v] puts("\nstring ajuste dias\n-h=#{totalha.map { |e| "#{e['blockNumber']}:0" }.join(' ')}") end end end