cslrb 0.1.0 → 0.2.0

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: d33a65a3c8bef259e507b130abab7ba117ab8a39fb0bd210a2f5761361a35e9c
4
- data.tar.gz: 1f6ecd01d18c9dcbf08a1dc07969eeb083917e2ae3dd07e48f6dd0e24107e162
3
+ metadata.gz: 93db38b6e547d150d766567c4397bff4f9755258934c063e79762c932ee5e261
4
+ data.tar.gz: d39205e4a838e12054eccdd0806ff9207d0109517296881414a25de783faebf7
5
5
  SHA512:
6
- metadata.gz: 87ec3a4f7fdb7eba2e04a4906641a4050d8b22150f7341d18bde9eaedd1e8f386ab827d8c41c5f5cf16154489ece04c73dd031e502c56bc6a558d7394fefe6c3
7
- data.tar.gz: 3324c23d5d29ad6de5df7e3671bcf20bcd94671fdaa41e62e2fc63a8e80ff48e95654ed68e82f6fb9345fed5eba42ea4fac9f3b3f63e573ea296ec6cb3174597
6
+ metadata.gz: b2a7330be72992b49f2fdbfd041d90a2804cfbf0b0650cb43cd612c2250e7b0555f54b16cd4999bf864119291d049fd3cac7a170836ddf1de4b9f8cddbb09e6e
7
+ data.tar.gz: 13f1a4d74ad19f425d5625cbe9ce34b02b0495aa7432d9774fcedff1057c2b54f8834429577d5a15a8698263e3fd0d12ff81e6b953ed2da570ef6c51f5df458a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cslrb (0.1.0)
4
+ cslrb (0.2.0)
5
5
  rutie (~> 0.0.4)
6
6
  thermite (~> 0.13)
7
7
 
@@ -69,4 +69,4 @@ DEPENDENCIES
69
69
  rubocop (~> 1.54)
70
70
 
71
71
  BUNDLED WITH
72
- 2.2.22
72
+ 2.4.17
data/README.md CHANGED
@@ -26,7 +26,7 @@ Or install it yourself as:
26
26
 
27
27
  ## Usage
28
28
 
29
- `cslrb` currently provides a single method, `Cslrb.tx_body_from_hex` which accepts a string (TX CBOR as hex).
29
+ For example with the method `Cslrb.tx_body_from_hex` which accepts a string (TX CBOR as hex):
30
30
 
31
31
  ```shell
32
32
  pry(main)> cbor_hex = "84a40081825820f97da637cc2e8b5b970b1952bcdc62422e82873bb0503a75ab70ed3c3476e9cc010182825839010a7bc8293ae50dd74ae399b261446abff238ea7c564ad52a52168e0b8c6663f1d8c19ba014cf7357207946d54731f2535ae8720c667cdbbc1a000f42408258390177992ea7e2b434bd4ba92e3b2c9592c0805a4552e1d2bb7a7e9c726b4b3ff6604e58320d841aa3af6d4aca9583bd3741ec93518d973a498e1a022468b3021a0002917d031a05d25734a10081825820e41c3c43e11599b056d0de12a55ef49346bb941fcafef7aad08a7b3361b4ccf55840b1fb566bacc3c5f97748dd281f65abec51c64814c289ddcd2792e094091750755542ef4cea7d423a09066486fb2ce185da6fef380dbf65fcadb9bda6c697d701f5f6"
@@ -40,6 +40,7 @@ Passing anything other than a `String` will result in an error.
40
40
 
41
41
  ```ruby
42
42
  Cslrb.tx_body_from_hex(cbor_hex)
43
+ Cslrb.metadata_from_output_datum(cbor_hex)
43
44
  ```
44
45
 
45
46
  ## Development
data/lib/cslrb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cslrb
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
data/src/lib.rs CHANGED
@@ -2,6 +2,7 @@
2
2
  extern crate rutie;
3
3
 
4
4
  use cardano_serialization_lib::{Transaction};
5
+ use cardano_serialization_lib::plutus::{PlutusData, PlutusDatumSchema};
5
6
  use rutie::{Module, Object, RString, VM};
6
7
 
7
8
  module!(Cslrb);
@@ -18,6 +19,16 @@ methods!(
18
19
  Ok(json_string) => return RString::new_utf8(&json_string),
19
20
  Err(err) => return RString::new_utf8(&format!("Error: {}", err)),
20
21
  }
22
+ },
23
+ fn metadata_from_output_datum(cbor_hex: RString) -> RString {
24
+ let ruby_string = cbor_hex.map_err(|e| VM::raise_ex(e) ).unwrap();
25
+ let metadata = PlutusData::from_hex(&ruby_string.to_string()).unwrap();
26
+ let schema = PlutusDatumSchema::BasicConversions;
27
+
28
+ match metadata.to_json(schema) {
29
+ Ok(json_string) => return RString::new_utf8(&json_string),
30
+ Err(err) => return RString::new_utf8(&format!("Error: {}", err)),
31
+ }
21
32
  }
22
33
  );
23
34
 
@@ -26,5 +37,6 @@ methods!(
26
37
  pub extern "C" fn Init_cslrb() {
27
38
  Module::from_existing("Cslrb").define(|itself| {
28
39
  itself.def_self("tx_body_from_hex", tx_body_from_hex);
40
+ itself.def_self("metadata_from_output_datum", metadata_from_output_datum);
29
41
  });
30
42
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cslrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sascha Knobloch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-17 00:00:00.000000000 Z
11
+ date: 2023-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rutie