Class: WalletValidator::Sol

Inherits:
Object
  • Object
show all
Defined in:
lib/wallet_validator/sol.rb

Constant Summary collapse

MIN_LENGTH =
43
MAX_LENGTH =
44

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address, is_testnet) ⇒ Sol

Returns a new instance of Sol.



9
10
11
12
# File 'lib/wallet_validator/sol.rb', line 9

def initialize(address, is_testnet)
  @address = address
  @is_testnet = is_testnet
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



4
5
6
# File 'lib/wallet_validator/sol.rb', line 4

def address
  @address
end

#is_testnetObject (readonly)

Returns the value of attribute is_testnet.



4
5
6
# File 'lib/wallet_validator/sol.rb', line 4

def is_testnet
  @is_testnet
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
# File 'lib/wallet_validator/sol.rb', line 14

def valid?
  return false if address.length <= MIN_LENGTH
  return false if address.length > MAX_LENGTH

  size = Crypto::Base58.base58_to_int(address, "SOL").size

  size == 32 || size == 33
end