Class: Klaytn::Decoder

Inherits:
Object
  • Object
show all
Defined in:
lib/klaytn/decoder.rb

Instance Method Summary collapse

Instance Method Details

#bitsize(subtype, default = 256) ⇒ Object



11
12
13
# File 'lib/klaytn/decoder.rb', line 11

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

#decode_uint(value, subtype = "256", start = 0) ⇒ Object

ex: 0x4563918244f40000 => 5000000000000000000 (5 KLAY)



3
4
5
# File 'lib/klaytn/decoder.rb', line 3

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

#trim(value, start, bitsize = 256) ⇒ Object



7
8
9
# File 'lib/klaytn/decoder.rb', line 7

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