Skip to content

Commit 3e89d56

Browse files
authored
Merge pull request #18 from blockfrost/mmahut/previewpreprod
feat: preview and preprod
2 parents 281629f + 655a061 commit 3e89d56

8 files changed

Lines changed: 167 additions & 1 deletion

File tree

.github/workflows/nix.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ blockfrost_mainnet = Blockfrostruby::CardanoMainNet.new('your-API-key')
8585
# Or if you want to access other networks:
8686

8787
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')
8890
blockfrost_ipfs = Blockfrostruby::IPFS.new('your-API-key')
8991

9092

default.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

gemset.nix

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

lib/blockfrost-ruby.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,32 @@ def initialize(project_id, config = {})
7979
end
8080
end
8181

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+
82108
class IPFS < Net
83109
include IPFSEndpoints
84110

lib/blockfrostruby/constants.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
CARDANO_MAINNET_URL = 'https://cardano-mainnet.blockfrost.io/api/v0'
44
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'
57
IPFS_URL = 'https://ipfs.blockfrost.io/api/v0'
68

79
MAX_COUNT_PER_PAGE = 100

lib/blockfrostruby/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Blockfrostruby
4-
VERSION = '0.1.0'
4+
VERSION = '0.1.1'
55
end

shell.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

0 commit comments

Comments
 (0)