GithubHelp home page GithubHelp logo

lisk-builders / lisk.rb Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 0.0 881 KB

πŸ’Ž A simple Ruby wrapper for the Lisk API.

Home Page: https://lisk-builders.github.io/lisk.rb/

License: MIT License

Ruby 98.90% Shell 1.10%
lisk ruby-wrapper lisk-api blockchain ruby-gem

lisk.rb's Introduction

Lisk.rb

A simple Ruby wrapper for the Lisk API. πŸ’Ž

Live-Preview.

Note before using

This is very early work-in-progress. The idea is to publish this gem as soon as it is fully compatible with Lisk Core 1.0.0, which, however, is not released yet. The current implementation of the lisk.rb gem is pure minimal by design and barely allows checking the node status.

API Implemententation Status:

  • Lisk::Legacy 48/62 APIs for Lisk Core 0.8.0+ (#4)
  • Lisk::Raw 0/34 APIs for Lisk Core 1.0.0+ (#1)

Installation

Add this line to your application's Gemfile:

gem 'lisk'

And then execute:

$ bundle

Or install it yourself as:

$ gem install lisk

Usage

Make sure to include lisk.rb in your scripts.

require 'lisk'

To get started, point the lisk.rb to any Lisk-API endpoint. By default, lisk.rb assumes a running Lisk testnet node on localhost port 7000.

node = Lisk::Client.new "127.0.0.1", 7000

For convenience, check if the Lisk node is connected, fully synchronized, and active by pinging it.

if node.is_alive?
  # only do stuff if client is connected, fully synchronized, and active ...
end

Get access to the Lisk-0.8.0 legacy API (see #4).

lisk = Lisk::API.new node

Get the version of the connected Lisk node.

version = lisk.get_version
build = lisk.get_version_build
p "Lisk node version #{version} build #{build}..."

Get the status of the connected Lisk node.

connected = node.is_alive?
loaded = lisk.is_chain_loaded?
p "Lisk node is connected: #{connected}... Blockchain loaded: #{loaded}..."

Figure out if the node is still synchronizing.

syncing = lisk.is_syncing?
remaining = lisk.get_remaining_blocks
best = lisk.get_chain_best_block
p "Lisk node is syncing: #{syncing}... #{remaining} remaining blocks to latest block #{best}..."

Get some global Lisk blockchain stats.

height = lisk.get_best_block
reward = lisk.get_block_reward / 1e8
supply = lisk.get_available_supply / 1e8
p "Lisk chain latest block: #{height}... total supply: #{supply}... block reward: #{reward}"

See examples/*.rb for more examples implementing the Lisk API.

API Documentation

Is available on Gh-Pages: https://lisk-builders.github.io/lisk.rb/ (work in progress #2).

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lisk-builders/lisk.rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

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

Code of Conduct

Everyone interacting in the Lisk.rb project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

lisk.rb's People

Contributors

4fryn avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lisk.rb's Issues

Implement Lisk-Core 0.8.0 legacy API endpoints

This is a wont-fix issue just using it myself to track which legacy APIs are available in lisk.rb

https://docs.lisk.io/docs/lisk-api-080

Accounts

  • POST /api/accounts/open : Lisk::Legacy::accounts_open secret
  • GET /api/accounts/getBalance?address=address : Lisk::Legacy::accounts_get_balance address
  • GET /api/accounts/getPublicKey?address=address : Lisk::Legacy::accounts_get_public_key address
  • POST /api/accounts/generatePublicKey : Lisk::Legacy::accounts_generate_public_key secret
  • GET /api/accounts?address=address : Lisk::Legacy::accounts address
  • GET /api/accounts/delegates?address=address : Lisk::Legacy::accounts_delegates_get_by_address address
  • PUT /api/accounts/delegates : Lisk::Legacy::accounts_delegates_put votes

Loader

  • GET /api/loader/status : Lisk::Legacy::loader_status_sync
  • GET /api/loader/status/sync : Lisk::Legacy::loader_status
  • GET /api/loader/status/ping : Lisk::Legacy::loader_status_ping

Transactions

  • GET /api/transactions?blockId=blockId&senderId=senderId&recipientId=recipientId&limit=limit&offset=offset&orderBy=field : Lisk::Legacy::transactions filter = nil
  • PUT /api/transactions : Lisk::Legacy::transactions_put transaction
  • GET /api/transactions/get?id=id : Lisk::Legacy::transactions_get_by_id id
  • GET /api/transactions/unconfirmed/get?id=id : Lisk::Legacy::transactions_unconfirmed_get_by_id id
  • GET /api/transactions/unconfirmed : Lisk::Legacy::transactions_unconfirmed
  • GET /api/transactions/queued : Lisk::Legacy::transactions_queued
  • GET /api/transactions/queued/get?id=id : Lisk::Legacy::transactions_queued_get_by_id id

Peers

  • GET /api/peers?state=state&os=os&version=version&limit=limit&offset=offset&orderBy=orderBy : Lisk::Legacy::peers filter = nil
  • GET /api/peers/get?ip=ip&port=port : Lisk::Legacy::peers_get filter = nil
  • GET /api/peers/version : Lisk::Legacy::peers_version

Blocks

  • GET /api/blocks?generatorPublicKey=generatorPublicKey&height=height&previousBlock=previousBlock&totalAmount=totalAmount&totalFee=totalFee&limit=limit&offset=offset&orderBy=orderBy : Lisk::Legacy::blocks filter = nil
  • GET /api/blocks/get?id=id : Lisk::Legacy::blocks_get_by_id id
  • GET /api/blocks/getFee : Lisk::Legacy::blocks_get_fee
  • GET /api/blocks/getFees : Lisk::Legacy::blocks_get_fees
  • GET /api/blocks/getReward : Lisk::Legacy::blocks_get_reward
  • GET /api/blocks/getSupply : Lisk::Legacy::blocks_get_supply
  • GET /api/blocks/getHeight : Lisk::Legacy::blocks_get_height
  • GET /api/blocks/getStatus : Lisk::Legacy::blocks_get_status
  • GET /api/blocks/getNethash : Lisk::Legacy::blocks_get_nethash
  • GET /api/blocks/getMilestone : Lisk::Legacy::blocks_get_milestone

Signatures

  • GET /api/signatures/fee : Lisk::Legacy::signatures_fee
  • PUT /api/signatures : Lisk::Legacy::signatures_put secrets

Delegates

  • PUT /api/delegates : Lisk::Legacy::delegates_put delegate
  • GET /api/delegates?limit=limit&offset=offset&orderBy=orderBy : Lisk::Legacy::delegates filter = nil
  • GET /api/delegates/get?publicKey=publicKey : Lisk::Legacy::delegates_get_by_key public_key
  • GET /api/delegates/get?username=username : Lisk::Legacy::delegates_get_by_name user_name
  • GET /api/delegates/search?q=username&orderBy=producedblocks:desc : Lisk::Legacy::delegates_search query
  • GET /api/delegates/count : Lisk::Legacy::delegates_count
  • GET /api/accounts/delegates/?address=address : Lisk::Legacy::accounts_delegates address
  • GET /api/delegates/voters?publicKey=publicKey : Lisk::Legacy::delegates_voters public_key
  • POST /api/delegates/forging/enable : Lisk::Legacy::delegates_forging_enable secret
  • POST /api/delegates/forging/disable : Lisk::Legacy::delegates_forging_disable secret
  • GET /api/delegates/forging/getForgedByAccount?generatorPublicKey=generatorPublicKey : Lisk::Legacy::delegates_forging_get_forged_by_account public_key
  • GET /api/delegates/getNextForgers?limit=limit : Lisk::Legacy::delegates_get_next_forgers limit = 10

Multi-sig

  • PUT /api/multisignatures : Lisk::Legacy::multisignatures_put secrets
  • GET /api/multisignatures/accounts?publicKey=publicKey : Lisk::Legacy::multisignatures_accounts public_key
  • POST /api/multisignatures/sign : Lisk::Legacy::multisignatures_sign signature
  • GET /api/multisignatures/pending?publicKey=publicKey : Lisk::Legacy::multisignatures_pending public_key

Dapps

  • PUT /api/dapps
  • GET /api/dapps?category=category&name=name&type=type&link=link&limit=limit&offset=offset&orderBy=orderBy
  • GET /api/dapps/get?id=id
  • GET /api/dapps/search?q=q&category=category&installed=installed
  • POST /api/dapps/install
  • GET /api/dapps/installed
  • GET /api/dapps/installedIds
  • POST /api/dapps/uninstall
  • POST /api/dapps/launch
  • GET /api/dapps/installing
  • GET /api/dapps/uninstalling
  • GET /api/dapps/launched
  • GET /api/dapps/categories
  • POST /api/dapps/stop

Add tests (Rake)

Lisk
  has a version number
  does something useful (FAILED - 1)

Failures:

  1) Lisk does something useful
     Failure/Error: expect(false).to eq(true)
     
       expected: true
            got: false
     
       (compared using ==)
     # ./spec/lisk_spec.rb:9:in `block (2 levels) in <top (required)>'

Finished in 0.01016 seconds (files took 0.17413 seconds to load)
2 examples, 1 failure

Implement Lisk-Core 1.0.0 API endpoints

Follow-up on #4

https://app.swaggerhub.com/apis/LiskHQ/Lisk/1.0.18

  • /accounts
  • /blocks
  • /dapps
  • /delegates
  • /delegates/forgers
  • /delegates/forging
  • /node/constants
  • /node/status
  • /peers
  • /signatures
  • /transactions
  • /transactions/unsigned
  • /transactions/unconfirmed
  • /transactions/unprocessed
  • /votes
  • /voters
  • /accounts
  • /blocks
  • /dapps
  • /delegates
  • /delegates/forgers
  • /delegates/forging
  • /node/constants
  • /node/status
  • /peers
  • /signatures
  • /transactions
  • /transactions/unsigned
  • /transactions/unconfirmed
  • /transactions/unprocessed
  • /votes
  • /voters

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.