Skip to content

near-rails-guide/borsh-rb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Borsh::Rb

Unofficial implementation of Borsh serializer https://borsh.io/

Installation

Add this line to your application's Gemfile:

gem 'borsh-rb'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install borsh-rb

Usage

include Borsh module and define serialisation schema

class User
  include Borsh
  
  borsh id: :string, type: :u8, key: 32, admin: :borsh
  
  def id
    'test'
  end
  
  def type
    1
  end
  
  def key
    'abcd'
  end
  
  admin
    return unless admin?
    
    User.new
  end  
end

Serialize as: User.new.to_borsh

Supported types: :string, :u8, :u16, :u32, :u64, :u128, Integer, Array, :borsh Integer as a type is supported to validate preserialized value length (for ex. public key)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/2rba/borsh-rb.

License

The gem is available as open source under the terms of the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published