Module: Solrengine::Programs::BorshTypes::PublicKey
- Defined in:
- lib/solrengine/programs/borsh_types.rb
Overview
Solana PublicKey: 32-byte fixed array, exposed as Base58 string
Class Method Summary collapse
Class Method Details
.decode(buffer) ⇒ Object
9 10 11 12 |
# File 'lib/solrengine/programs/borsh_types.rb', line 9 def self.decode(buffer) bytes = buffer.read(32) Base58.binary_to_base58(bytes, :bitcoin) end |
.encode(buffer, value) ⇒ Object
14 15 16 17 18 |
# File 'lib/solrengine/programs/borsh_types.rb', line 14 def self.encode(buffer, value) bytes = Base58.base58_to_binary(value, :bitcoin) raise DeserializationError, "PublicKey must be 32 bytes (got #{bytes.bytesize})" unless bytes.bytesize == 32 buffer.write(bytes) end |
.size ⇒ Object
20 21 22 |
# File 'lib/solrengine/programs/borsh_types.rb', line 20 def self.size 32 end |