blockfrost-ruby 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ce10dc5e5d7b6c656d0f0103447d52ce0bb746ba5a39bcc2821b9d249aba333
4
- data.tar.gz: 7658854a8f655919f872141870fbf95d76ee9849ea362ae9dd4b0a20848bcd60
3
+ metadata.gz: f6409f9244d146bc02002c7f9add828de36d1564fdabfdae1cc51d2016c16608
4
+ data.tar.gz: 73521600b8d9a2895333178706bd151a8c6e5f5d412a3901e067640a12913f06
5
5
  SHA512:
6
- metadata.gz: 7c7ab31fb74e3a6c61b5beda94efdca316f2188e06b42799f8ff25106795850be54b110ae202165d679f68010607893645b01a979dca9e0c70b5fd1744e1cce8
7
- data.tar.gz: 4481bf4742675a24b4d2049d4f88fdeaf996769bb7190ee452c46177651125e3f2c521b54ecf20dfb233efbc6a9d3fc4fb93ea66f82279dccbf9e02ea10cd84d
6
+ metadata.gz: 21b47ca521f021b62e2afaaf3b0244b3f1c48af14c773d34875a6635b0885734ae2d5fd26dfc2f93fb00d4a55d81a66bc3b2de7c7bc20ce89c10e1949c346c8a
7
+ data.tar.gz: 9ed16e266632b2c95bbe6940e2895429cc27516cc7eca3bacadad63cdc5dccec34306a0e2462beaefb88f24a1ecac655ef9c3303bbc35bd5c73e6c2b0d5d300a
data/.env.example ADDED
@@ -0,0 +1,3 @@
1
+ BF_IPFS_PROJECT_ID=
2
+ BF_MAINNET_PROJECT_ID=
3
+ BF_TESTNET_PROJECT_ID=
@@ -0,0 +1,13 @@
1
+ name: "Nix build"
2
+ on:
3
+ pull_request:
4
+ push:
5
+ jobs:
6
+ tests:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v3
10
+ - uses: cachix/install-nix-action@v18
11
+ with:
12
+ nix_path: nixpkgs=channel:nixos-unstable
13
+ - run: nix-build
data/.gitignore CHANGED
@@ -9,6 +9,7 @@
9
9
 
10
10
  *.gem
11
11
  *.lock
12
+ *.env
12
13
 
13
14
  # rspec failure tracking
14
15
  .rspec_status
data/.rubocop.yml CHANGED
@@ -5,7 +5,7 @@ AllCops:
5
5
  # Metrics
6
6
 
7
7
  Metrics/BlockLength:
8
- Max: 240
8
+ Max: 350
9
9
 
10
10
  Metrics/MethodLength:
11
11
  Max: 30
@@ -37,3 +37,6 @@ Naming/AccessorMethodName:
37
37
 
38
38
  Layout/LineLength:
39
39
  Max: 150
40
+
41
+ Naming/FileName:
42
+ Enabled: false
data/Gemfile CHANGED
@@ -5,6 +5,6 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in blockfrostruby.gemspec
6
6
  gemspec
7
7
 
8
+ gem 'dotenv'
8
9
  gem 'rake', '~> 13.0'
9
10
  gem 'rspec', '~> 3.0'
10
- gem 'webmock'
data/README.md CHANGED
@@ -1,21 +1,28 @@
1
- # Blockfrostruby
1
+ [![Gem Version](https://badge.fury.io/rb/blockfrost-ruby.svg)](https://rubygems.org/gems/blockfrost-ruby) <a href="https://fivebinaries.com/"><img src="https://img.shields.io/badge/made%20by-Five%20Binaries-darkviolet.svg?style=flat-square" /></a>
2
2
 
3
- Ruby SDK to work with Blockfrost (Cardano Blockchain API)
4
- Blockfrost is a hosted API as a service serving the data from the Cardano blockchain.
5
- This gem is Ruby SDK for Blockfrost.io to enable developers
6
- to use full power of this API without having to create basic functions for it.
7
- The OpenAPI documentation is hosted at https://github.com/blockfrost/openapi.\
8
- This gem is licensed under ASL 2.0.
3
+ <img src="https://blockfrost.io/images/logo.svg" width="250" align="right" height="90">
4
+
5
+ # blockfrost-ruby
6
+
7
+ <br/>
8
+
9
+ <p align="center">Ruby SDK for <a href="https://blockfrost.io">Blockfrost.io</a> API.</p>
10
+ <p align="center">
11
+ <a href="#installation">Installation</a> •
12
+ <a href="#usage">Usage</a> •
13
+ <a href="#development">Development</a>
14
+ </p>
15
+ <br>
9
16
 
10
- More information about using this API can be found on https://docs.blockfrost.io/
11
17
  ## Installation
12
18
 
13
- For now, it's not hosted on a RubyGems,
14
- so you can install this SDK only from this repo.
19
+ You can download the latest release directly from rubygems.org:
20
+
21
+ $ gem install blockfrost-ruby
15
22
 
16
- To do this, download this repo to your machine, then go to the directory:
23
+ To build the current master, download this repo to your machine, then go to the directory:
17
24
 
18
- $ cd path-to-dir-with-this-repo
25
+ $ cd blockfrost-ruby
19
26
 
20
27
  And run next commands:
21
28
 
@@ -78,6 +85,8 @@ blockfrost_mainnet = Blockfrostruby::CardanoMainNet.new('your-API-key')
78
85
  # Or if you want to access other networks:
79
86
 
80
87
  blockfrost_testnet = Blockfrostruby::CardanoTestNet.new('your-API-key')
88
+ blockfrost_preview = Blockfrostruby::CardanoPreview.new('your-API-key')
89
+ blockfrost_preprod = Blockfrostruby::CardanoPreprod.new('your-API-key')
81
90
  blockfrost_ipfs = Blockfrostruby::IPFS.new('your-API-key')
82
91
 
83
92
 
@@ -131,4 +140,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
131
140
 
132
141
  ## Contributing
133
142
 
134
- Bug reports and pull requests are welcome on GitHub at https://github.com/blockfrost/blockfrostruby.
143
+ Bug reports and pull requests are welcome on GitHub at https://github.com/blockfrost/blockfrost-ruby.
data/default.nix ADDED
@@ -0,0 +1,16 @@
1
+ with import <nixpkgs> {};
2
+ let
3
+ gems = bundlerEnv {
4
+ name = "blockfrost-ruby";
5
+ inherit ruby;
6
+ gemdir = ./.;
7
+ };
8
+ in stdenv.mkDerivation {
9
+ name = "blockfrost-ruby";
10
+ src = ./.;
11
+
12
+ installPhase = ''
13
+ mkdir -p $out
14
+ cp -r $src $out
15
+ '';
16
+ }
data/gemset.nix ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ blockfrost-ruby = {
3
+ groups = ["default"];
4
+ platforms = [];
5
+ source = {
6
+ path = ./.;
7
+ type = "path";
8
+ };
9
+ version = "0.1.1";
10
+ };
11
+ diff-lcs = {
12
+ groups = ["default"];
13
+ platforms = [];
14
+ source = {
15
+ remotes = ["https://rubygems.org"];
16
+ sha256 = "0rwvjahnp7cpmracd8x732rjgnilqv2sx7d1gfrysslc3h039fa9";
17
+ type = "gem";
18
+ };
19
+ version = "1.5.0";
20
+ };
21
+ dotenv = {
22
+ groups = ["default"];
23
+ platforms = [];
24
+ source = {
25
+ remotes = ["https://rubygems.org"];
26
+ sha256 = "1n0pi8x8ql5h1mijvm8lgn6bhq4xjb5a500p5r1krq4s6j9lg565";
27
+ type = "gem";
28
+ };
29
+ version = "2.8.1";
30
+ };
31
+ rake = {
32
+ groups = ["default"];
33
+ platforms = [];
34
+ source = {
35
+ remotes = ["https://rubygems.org"];
36
+ sha256 = "15whn7p9nrkxangbs9hh75q585yfn66lv0v2mhj6q6dl6x8bzr2w";
37
+ type = "gem";
38
+ };
39
+ version = "13.0.6";
40
+ };
41
+ rspec = {
42
+ dependencies = ["rspec-core" "rspec-expectations" "rspec-mocks"];
43
+ groups = ["default"];
44
+ platforms = [];
45
+ source = {
46
+ remotes = ["https://rubygems.org"];
47
+ sha256 = "171rc90vcgjl8p1bdrqa92ymrj8a87qf6w20x05xq29mljcigi6c";
48
+ type = "gem";
49
+ };
50
+ version = "3.12.0";
51
+ };
52
+ rspec-core = {
53
+ dependencies = ["rspec-support"];
54
+ groups = ["default"];
55
+ platforms = [];
56
+ source = {
57
+ remotes = ["https://rubygems.org"];
58
+ sha256 = "1ibb81slc35q5yp276sixp3yrvj9q92wlmi1glbnwlk6g49z8rn4";
59
+ type = "gem";
60
+ };
61
+ version = "3.12.0";
62
+ };
63
+ rspec-expectations = {
64
+ dependencies = ["diff-lcs" "rspec-support"];
65
+ groups = ["default"];
66
+ platforms = [];
67
+ source = {
68
+ remotes = ["https://rubygems.org"];
69
+ sha256 = "0qldsmjhqr4344zdlamzggr3y98wdk2c4hihkhwx8imk800gkl8v";
70
+ type = "gem";
71
+ };
72
+ version = "3.12.0";
73
+ };
74
+ rspec-mocks = {
75
+ dependencies = ["diff-lcs" "rspec-support"];
76
+ groups = ["default"];
77
+ platforms = [];
78
+ source = {
79
+ remotes = ["https://rubygems.org"];
80
+ sha256 = "1yvwnb0x5d6d4ff3wlgahk0wcw72ic51gd2snr1xxc5ify41kabv";
81
+ type = "gem";
82
+ };
83
+ version = "3.12.0";
84
+ };
85
+ rspec-support = {
86
+ groups = ["default"];
87
+ platforms = [];
88
+ source = {
89
+ remotes = ["https://rubygems.org"];
90
+ sha256 = "12y52zwwb3xr7h91dy9k3ndmyyhr3mjcayk0nnarnrzz8yr48kfx";
91
+ type = "gem";
92
+ };
93
+ version = "3.12.0";
94
+ };
95
+ }
@@ -79,6 +79,32 @@ module Blockfrostruby
79
79
  end
80
80
  end
81
81
 
82
+ class CardanoPreview < CardanoMainNet
83
+ # Create an instanse of CardanoPreview object.
84
+ # Using of SDK is a calling methods on such object.
85
+ #
86
+ # @param project_id [String] the project_id from API
87
+ # @param config [Hash] a config with params: use_asc_order_as_default, default_count_per_page, parallel_requests, sleep_between_retries_ms
88
+ # @return [Object] with attr_reader :config, :project_id, :url
89
+ def initialize(project_id, config = {})
90
+ super
91
+ @url = CARDANO_PREVIEW_URL
92
+ end
93
+ end
94
+
95
+ class CardanoPreprod < CardanoMainNet
96
+ # Create an instanse of CardanoPreprod object.
97
+ # Using of SDK is a calling methods on such object.
98
+ #
99
+ # @param project_id [String] the project_id from API
100
+ # @param config [Hash] a config with params: use_asc_order_as_default, default_count_per_page, parallel_requests, sleep_between_retries_ms
101
+ # @return [Object] with attr_reader :config, :project_id, :url
102
+ def initialize(project_id, config = {})
103
+ super
104
+ @url = CARDANO_PREPROD_URL
105
+ end
106
+ end
107
+
82
108
  class IPFS < Net
83
109
  include IPFSEndpoints
84
110
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  CARDANO_MAINNET_URL = 'https://cardano-mainnet.blockfrost.io/api/v0'
4
4
  CARDANO_TESTNET_URL = 'https://cardano-testnet.blockfrost.io/api/v0'
5
+ CARDANO_PREVIEW_URL = 'https://cardano-preview.blockfrost.io/api/v0'
6
+ CARDANO_PREPROD_URL = 'https://cardano-preprod.blockfrost.io/api/v0'
5
7
  IPFS_URL = 'https://ipfs.blockfrost.io/api/v0'
6
8
 
7
9
  MAX_COUNT_PER_PAGE = 100
@@ -54,7 +54,7 @@ module AccountsEndpoints
54
54
  # @return [Hash] formatted result with status and body keys.
55
55
  def get_account_registrations(address, params = {})
56
56
  params = Params.define_params(params, @config)
57
- Request.get_response("#{@url}/accounts/#{address}/registations", @project_id, params)
57
+ Request.get_response("#{@url}/accounts/#{address}/registrations", @project_id, params)
58
58
  end
59
59
 
60
60
  # Calls get request on (@url)/accounts/(address)/withdrawals.
@@ -82,9 +82,9 @@ module AccountsEndpoints
82
82
  # @param address [String] will be added to the url for get request.
83
83
  # @param params [Hash] - params passed by user.
84
84
  # @return [Hash] formatted result with status and body keys.
85
- def get_account_addresses(address, params = {})
85
+ def get_account_assosiated_addresses(address, params = {})
86
86
  params = Params.define_params(params, @config)
87
- Request.get_response("#{@url}/accounts/#{address}/addresses", @project_id, params, @config)
87
+ Request.get_response("#{@url}/accounts/#{address}/addresses", @project_id, params)
88
88
  end
89
89
 
90
90
  # Calls get request on (@url)/accounts/(address)/addresses/assets.
@@ -13,7 +13,7 @@ module AddressesEndpoints
13
13
  #
14
14
  # @param address [String] will be added to the url for get request.
15
15
  # @return [Hash] formatted result with status and body keys.
16
- def get_address(address)
16
+ def get_specific_address(address)
17
17
  Request.get_response("#{@url}/addresses/#{address}", @project_id)
18
18
  end
19
19
 
@@ -23,9 +23,8 @@ module AssetsEndpoints
23
23
  # @param asset [String] will be added to the url for get request.
24
24
  # @param params [Hash] - params passed by user.
25
25
  # @return [Hash] formatted result with status and body keys.
26
- def get_asset(asset, params = {})
27
- params = Params.define_params(params, @config)
28
- Request.get_response("#{@url}/assets/#{asset}", @project_id, params)
26
+ def get_specific_asset(asset)
27
+ Request.get_response("#{@url}/assets/#{asset}", @project_id)
29
28
  end
30
29
 
31
30
  # Calls get request on (@url)/assets/(asset)/history.
@@ -29,9 +29,8 @@ module EpochsEndpoints
29
29
  # @param epoch_number [String] will be added to the url for get request.
30
30
  # @param params [Hash] - params passed by user.
31
31
  # @return [Hash] formatted result with status and body keys.
32
- def get_epoch(epoch_number, params = {})
33
- params = Params.define_params(params, @config)
34
- Request.get_response("#{@url}/epochs/#{epoch_number}", @project_id, params)
32
+ def get_epoch(epoch_number)
33
+ Request.get_response("#{@url}/epochs/#{epoch_number}", @project_id)
35
34
  end
36
35
 
37
36
  # Calls get request on (@url)/epochs/(epoch_number)/next.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blockfrostruby
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
data/shell.nix ADDED
@@ -0,0 +1,12 @@
1
+ with (import <nixpkgs> {});
2
+ let
3
+ ruby = ruby_3_1;
4
+ env = bundlerEnv {
5
+ name = "blockfrost-ruby-env";
6
+ inherit ruby;
7
+ gemdir = ./.;
8
+ };
9
+ in stdenv.mkDerivation {
10
+ name = "blockfrost-ruby";
11
+ buildInputs = [ env ruby nodejs git rubyPackages_3_1.rake rubyPackages_3_1.rspec ];
12
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blockfrost-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan (https://github.com/18bitmood)
@@ -22,6 +22,8 @@ executables: []
22
22
  extensions: []
23
23
  extra_rdoc_files: []
24
24
  files:
25
+ - ".env.example"
26
+ - ".github/workflows/nix.yaml"
25
27
  - ".gitignore"
26
28
  - ".rspec"
27
29
  - ".rubocop.yml"
@@ -31,6 +33,8 @@ files:
31
33
  - README.md
32
34
  - Rakefile
33
35
  - blockfrost-ruby.gemspec
36
+ - default.nix
37
+ - gemset.nix
34
38
  - lib/blockfrost-ruby.rb
35
39
  - lib/blockfrostruby/config.yml
36
40
  - lib/blockfrostruby/configuration.rb
@@ -54,6 +58,7 @@ files:
54
58
  - lib/blockfrostruby/request.rb
55
59
  - lib/blockfrostruby/validator.rb
56
60
  - lib/blockfrostruby/version.rb
61
+ - shell.nix
57
62
  homepage: https://github.com/blockfrost/blockfrost-ruby
58
63
  licenses: []
59
64
  metadata:
@@ -75,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
80
  - !ruby/object:Gem::Version
76
81
  version: '0'
77
82
  requirements: []
78
- rubygems_version: 3.2.16
83
+ rubygems_version: 3.2.26
79
84
  signing_key:
80
85
  specification_version: 4
81
86
  summary: Ruby SDK to work with Blockfrost (Cardano Blockchain API)