Git Product home page Git Product logo

cardano_explorer's People

Contributors

imthatcarlos avatar mlabarca avatar philipqnguyen avatar ronwalker22 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cardano_explorer's Issues

address.summary["caBalance"]["getCoin"] disregards the decimal

While using address.summary["caBalance"]["getCoin"] I found the gem disregards the decimal when displaying the balance.

address_1 = DdzFFzCqrhsxGcvRxsWBj7fbSNd7dTAaWzUEeZtNi5qxApPR3EcqEdxcpqrtwPhurhNRurkBDzhBMFPN6W5aPWYCGZG6FpofhBVMwYux

address_2 = DdzFFzCqrhstjNy7BZScomVmJMNbwZsmKtfnncJv6eEgQP49XYbijFTFi4bhBUD5RKSHQ4v5NtMKJhxEdBmeULKxm5jeSbDa6i4fJJHT


address_1 has a balance of 4,019.2500
checked here: https://cardanoexplorer.com/address/DdzFFzCqrhsxGcvRxsWBj7fbSNd7dTAaWzUEeZtNi5qxApPR3EcqEdxcpqrtwPhurhNRurkBDzhBMFPN6W5aPWYCGZG6FpofhBVMwYux

The gem displays 4019250000 for address_1


address_2 has a balance of 0.000344
checked here:
https://cardanoexplorer.com/address/DdzFFzCqrhstjNy7BZScomVmJMNbwZsmKtfnncJv6eEgQP49XYbijFTFi4bhBUD5RKSHQ4v5NtMKJhxEdBmeULKxm5jeSbDa6i4fJJHT

The gem displays 344 for address_2


Transaction.latest

This is a child issue of #4

So the api/txs/last returns an array of transactions ids (and a couple other fields):

{
   "Right":[
      {
         "cteId":"d5efca4b13c5001c8cbc5617523a7562d6746ff6e454887ba28205e22c854d32",
         "cteTimeIssued":1516154031,
         "cteAmount":{
            "getCoin":"548416093154"
         }
      },
      {
         "cteId":"a3d4531f8955e69b922bee29b1cb615ebcb7d48aba0d1fd132553b9820c30869",
         "cteTimeIssued":1516153991,
         "cteAmount":{
            "getCoin":"548441342333"
         }
      },
      ...
   ]
}

Inside the "Right" key in that JSON is an array of transaction objects. So I think it would be more representative if we make it so that Transaction.latest returns an Array of instantiated transaction objects.

For example this would allow the users to be able to do things like this:

transactions = Transaction.latest #=>
# [#<CardanoExplorer::Transaction ...>, #<CardanoExplorer::Transaction ...>, #<CardanoExplorer::Transaction ...>]

# Then, the user can do things like:
transactions.each { |transaction| .... }
transactions.last.summary #=> { ... }
transactions.first.summary #=> { ... }
transactions[3].summary #=> { ... }

I know right now the Base class doesn't support that, and it was my fault for defining a Base class so early on in the development of this gem. However, we can make changes to the Base class to support this.

First what we can do is make the HTTP request related methods to become a class method like so:

  class Base

   # Other code

  private

    def self.get(path, options = {})
      HTTParty.get "#{root_url}/#{endpoint}/#{path}", query: options
    end

    def self.root_url
      CardanoExplorer.configuration.root_url
    end

    def self.endpoint
      raise NotImplementedError, '#endpoint not defined in child class'
    end

    def get(path, options = {})
      self.class.get path, options
    end
  end

In Transaction class we can add this to return an Array of instantiated Transaction objects:

# transaction.rb
    def self.latest
      get('last').parsed_response['Right'].map {|txs| new txs['cteId']}
    end

We also need to make sure that the endpoint method in all the other classes become a class method as well.

  private

    def self.endpoint
      # whatever their respective endpoints are.
    end

Cover all of the Explorer's API endpoints

This issue is to track the current progress of the goal of covering all of the Cardano SL Explorer API's endpoints.

The official API docs for the Cardano SL Explorer API is here: https://cardanodocs.com/technical/explorer/api/

  • GET /api/addresses/summary/{address}
  • GET /api/blocks/pages
  • GET /api/blocks/pages/total
  • GET /api/blocks/summary/{hash}
  • GET /api/blocks/txs/{hash}
  • GET /api/genesis/address/pages /api/genesis/address?page={page_num}
  • GET /api/genesis/address/pages/total
  • GET /api/genesis/summary
  • GET /api/search/epoch/{epoch}
  • GET /api/txs/last
  • GET /api/txs/summary/{txid}

We'll check mark those items as they are added to the gem.

gem install not working

Hello,

gem install is not working for me. When I followed the install instructions the gem installed fine but I received an error "uninitialized constant CardanoExplorer" when I tried to run my program.

I found and opened up the gem's files that were installed locally. I found that they were mostly empty. Seems like when I run gem install cardano_explorer I only receive two files, LICENSE.txt & README.md

I downloaded and added the lib and spec folders as well as the CHANGELOG.md file from here. Now that I have all the files, the error is gone and the gem works fine.

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.