Class: AdequateCryptoAddress::Atom

Inherits:
Object
  • Object
show all
Defined in:
lib/adequate_crypto_address/atom.rb

Overview

Cosmos Hub (ATOM) account addresses are Bech32 (not Bech32m) with the cosmos human-readable part and a 20-byte address payload. https://docs.cosmos.network/main/build/spec/addresses/bech32

Constant Summary collapse

HRP =
'cosmos'
PAYLOAD_BYTES =
20
MAX_LENGTH =
90

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address) ⇒ Atom

Returns a new instance of Atom.



14
15
16
17
# File 'lib/adequate_crypto_address/atom.rb', line 14

def initialize(address)
  @address = address
  @type = detect_type
end

Instance Attribute Details

#address ⇒ Object (readonly)

Returns the value of attribute address.



12
13
14
# File 'lib/adequate_crypto_address/atom.rb', line 12

def address
  @address
end

#type ⇒ Object (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/adequate_crypto_address/atom.rb', line 12

def type
  @type
end

Instance Method Details

#address_type ⇒ Object

:prod when the address is a valid cosmos account address, otherwise nil.



26
27
28
# File 'lib/adequate_crypto_address/atom.rb', line 26

def address_type
  type
end

#valid?(validated_type = nil) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/adequate_crypto_address/atom.rb', line 19

def valid?(validated_type = nil)
  return !type.nil? unless validated_type

  type == validated_type.to_sym
end