Skip to content

Commit

Permalink
Merge pull request #18 from blockfrost/mmahut/previewpreprod
Browse files Browse the repository at this point in the history
feat: preview and preprod
  • Loading branch information
mmahut authored Nov 24, 2022
2 parents 281629f + 655a061 commit 3e89d56
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .github/workflows/nix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Nix build"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix-build
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ blockfrost_mainnet = Blockfrostruby::CardanoMainNet.new('your-API-key')
# Or if you want to access other networks:

blockfrost_testnet = Blockfrostruby::CardanoTestNet.new('your-API-key')
blockfrost_preview = Blockfrostruby::CardanoPreview.new('your-API-key')
blockfrost_preprod = Blockfrostruby::CardanoPreprod.new('your-API-key')
blockfrost_ipfs = Blockfrostruby::IPFS.new('your-API-key')


Expand Down
16 changes: 16 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
with import <nixpkgs> {};
let
gems = bundlerEnv {
name = "blockfrost-ruby";
inherit ruby;
gemdir = ./.;
};
in stdenv.mkDerivation {
name = "blockfrost-ruby";
src = ./.;

installPhase = ''
mkdir -p $out
cp -r $src $out
'';
}
95 changes: 95 additions & 0 deletions gemset.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
blockfrost-ruby = {
groups = ["default"];
platforms = [];
source = {
path = ./.;
type = "path";
};
version = "0.1.1";
};
diff-lcs = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0rwvjahnp7cpmracd8x732rjgnilqv2sx7d1gfrysslc3h039fa9";
type = "gem";
};
version = "1.5.0";
};
dotenv = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1n0pi8x8ql5h1mijvm8lgn6bhq4xjb5a500p5r1krq4s6j9lg565";
type = "gem";
};
version = "2.8.1";
};
rake = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "15whn7p9nrkxangbs9hh75q585yfn66lv0v2mhj6q6dl6x8bzr2w";
type = "gem";
};
version = "13.0.6";
};
rspec = {
dependencies = ["rspec-core" "rspec-expectations" "rspec-mocks"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "171rc90vcgjl8p1bdrqa92ymrj8a87qf6w20x05xq29mljcigi6c";
type = "gem";
};
version = "3.12.0";
};
rspec-core = {
dependencies = ["rspec-support"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1ibb81slc35q5yp276sixp3yrvj9q92wlmi1glbnwlk6g49z8rn4";
type = "gem";
};
version = "3.12.0";
};
rspec-expectations = {
dependencies = ["diff-lcs" "rspec-support"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0qldsmjhqr4344zdlamzggr3y98wdk2c4hihkhwx8imk800gkl8v";
type = "gem";
};
version = "3.12.0";
};
rspec-mocks = {
dependencies = ["diff-lcs" "rspec-support"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1yvwnb0x5d6d4ff3wlgahk0wcw72ic51gd2snr1xxc5ify41kabv";
type = "gem";
};
version = "3.12.0";
};
rspec-support = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "12y52zwwb3xr7h91dy9k3ndmyyhr3mjcayk0nnarnrzz8yr48kfx";
type = "gem";
};
version = "3.12.0";
};
}
26 changes: 26 additions & 0 deletions lib/blockfrost-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@ def initialize(project_id, config = {})
end
end

class CardanoPreview < CardanoMainNet
# Create an instanse of CardanoPreview object.
# Using of SDK is a calling methods on such object.
#
# @param project_id [String] the project_id from API
# @param config [Hash] a config with params: use_asc_order_as_default, default_count_per_page, parallel_requests, sleep_between_retries_ms
# @return [Object] with attr_reader :config, :project_id, :url
def initialize(project_id, config = {})
super
@url = CARDANO_PREVIEW_URL
end
end

class CardanoPreprod < CardanoMainNet
# Create an instanse of CardanoPreprod object.
# Using of SDK is a calling methods on such object.
#
# @param project_id [String] the project_id from API
# @param config [Hash] a config with params: use_asc_order_as_default, default_count_per_page, parallel_requests, sleep_between_retries_ms
# @return [Object] with attr_reader :config, :project_id, :url
def initialize(project_id, config = {})
super
@url = CARDANO_PREPROD_URL
end
end

class IPFS < Net
include IPFSEndpoints

Expand Down
2 changes: 2 additions & 0 deletions lib/blockfrostruby/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

CARDANO_MAINNET_URL = 'https://cardano-mainnet.blockfrost.io/api/v0'
CARDANO_TESTNET_URL = 'https://cardano-testnet.blockfrost.io/api/v0'
CARDANO_PREVIEW_URL = 'https://cardano-preview.blockfrost.io/api/v0'
CARDANO_PREPROD_URL = 'https://cardano-preprod.blockfrost.io/api/v0'
IPFS_URL = 'https://ipfs.blockfrost.io/api/v0'

MAX_COUNT_PER_PAGE = 100
Expand Down
2 changes: 1 addition & 1 deletion lib/blockfrostruby/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Blockfrostruby
VERSION = '0.1.0'
VERSION = '0.1.1'
end
12 changes: 12 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
with (import <nixpkgs> {});
let
ruby = ruby_3_1;
env = bundlerEnv {
name = "blockfrost-ruby-env";
inherit ruby;
gemdir = ./.;
};
in stdenv.mkDerivation {
name = "blockfrost-ruby";
buildInputs = [ env ruby nodejs git rubyPackages_3_1.rake rubyPackages_3_1.rspec ];
}

0 comments on commit 3e89d56

Please sign in to comment.