philipqnguyen / cardano_explorer Goto Github PK
View Code? Open in Web Editor NEWA Ruby API wrapper to query the Cardano SL Explorer
License: MIT License
A Ruby API wrapper to query the Cardano SL Explorer
License: MIT License
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
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
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/
We'll check mark those items as they are added to the gem.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.