Sha256: 992b350353c3925f2006bf64d9b22315567e2702d8c3430f65d34724f951a155

Contents?: true

Size: 401 Bytes

Versions: 5

Compression:

Stored size: 401 Bytes

Contents

module Klaytn
  class Decoder
    def decode_uint(value, subtype = "256", start = 0) # ex: 0x4563918244f40000 => 5000000000000000000 (5 KLAY)
      trim(value, start, bitsize(subtype)).hex
    end

    def trim(value, start, bitsize = 256)
      value[start+63-(bitsize/4-1)..start+63]
    end

    def bitsize(subtype, default = 256)
      subtype.present? ? subtype.to_i : default
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
klaytn-0.1.2 lib/klaytn/decoder.rb
klaytn-0.1.1 lib/klaytn/decoder.rb
klaytn-0.1.0 lib/klaytn/decoder.rb
klaytn-0.0.9 lib/klaytn/decoder.rb
klaytn-0.0.8 lib/klaytn/decoder.rb