Class: Solace::PublicKey
- Inherits:
-
Object
- Object
- Solace::PublicKey
- Includes:
- Utils::PDA
- Defined in:
- lib/solace/public_key.rb
Constant Summary collapse
- LENGTH =
!@const LENGTH
The length of a Solana public key in bytes 32- MAX_BUMP_SEED =
!@const MAX_BUMP_SEED
The maximum seed value for a Program Derived Address 255- PDA_MARKER =
!@const PDA_MARKER
The marker for a Program Derived Address 'ProgramDerivedAddress'
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
!@attribute bytes @return [Array<Integer>] The bytes of the public key.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compare two public keys for equality.
-
#initialize(bytes) ⇒ PublicKey
constructor
Initialize with a 32-byte array or string.
-
#to_base58 ⇒ String
Return the base58 representation of the public key.
-
#to_bytes ⇒ Array<Integer>
Return the public key as a byte array.
-
#to_s ⇒ String
String representation (base58).
Methods included from Utils::PDA
create_program_address, find_program_address, looks_like_base58_address?, seed_to_bytes
Constructor Details
Instance Attribute Details
#bytes ⇒ Object (readonly)
!@attribute bytes
@return [Array<Integer>] The bytes of the public key
33 34 35 |
# File 'lib/solace/public_key.rb', line 33 def bytes @bytes end |
Instance Method Details
#==(other) ⇒ Boolean
Compare two public keys for equality
63 64 65 |
# File 'lib/solace/public_key.rb', line 63 def ==(other) other.is_a?(Solace::PublicKey) && other.bytes == bytes end |
#to_base58 ⇒ String
Return the base58 representation of the public key
48 49 50 |
# File 'lib/solace/public_key.rb', line 48 def to_base58 Solace::Utils::Codecs.bytes_to_base58(@bytes) end |
#to_bytes ⇒ Array<Integer>
Return the public key as a byte array
70 71 72 |
# File 'lib/solace/public_key.rb', line 70 def to_bytes @bytes.dup end |
#to_s ⇒ String
String representation (base58)
55 56 57 |
# File 'lib/solace/public_key.rb', line 55 def to_s to_base58 end |