rindy 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b53c873027d5d1af200f1b6d05e30c1243136a86fd015f0de153f99e5c0df54
4
- data.tar.gz: 21ae0312c85b1e17314ba6abee1a13a15451d014d0b0255828d15073a64358be
3
+ metadata.gz: f18a06b7cf8d43f16bd4743bf3e3203daff123697865101c4fc9f1f47f5cc41e
4
+ data.tar.gz: 5ad276562f4620677c3a0981ffe596ff195e37b78c7ace0468f702cd070ebdbd
5
5
  SHA512:
6
- metadata.gz: fa610021c517c5d001e3c7cda9114845a69b5f586becfcf919995db47a12148f2e13fd5b8824a7e571949a5ed1616e72676926cb08455bc0de5839ac6e01b326
7
- data.tar.gz: f8bc72cdb43aa35eb9553bf56156796b935cfebead4f1895d11a1b956b1ed8b25739357312ba3206b65c78cf028e0f962916303e294cbdd9b0bf20c46d64a6f8
6
+ metadata.gz: b21963925484ad27284605f128190398b657281ee9452f890783e31ccebb68f8e061b13bdf439b446bf424fd742f41c8f1af430ca8ed5f1ca96521defcb5743b
7
+ data.tar.gz: d05ec0628b0ca183035938bdc89ae82a839145f930f7241bfe9a7099b9510356bc9bad068ee7f19603bb258e210c158b796f7249b16f2d52afc79ed21457a2b1
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ target
2
+ tmp
3
+ *.bundle
4
+ *.so
5
+ *.gem
6
+ *~
7
+ vendor/bundle
data/rindy.gemspec ADDED
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'rindy'
5
+ s.version = '0.0.13'
6
+ s.authors = ['John Callahan']
7
+ s.summary = "Ruby wrapper for indy-sdk"
8
+ s.files = `git ls-files -z`.split("\x0")
9
+
10
+ s.platform = Gem::Platform::RUBY
11
+ s.extensions = %w[extconf.rb]
12
+ s.require_path = 'lib'
13
+ s.licenses = [ 'MIT', 'Apache-2.0' ]
14
+
15
+ s.add_dependency 'helix_runtime', '~> 0.7.5'
16
+ end
@@ -0,0 +1,69 @@
1
+ require "spec_helper"
2
+
3
+ describe "Rindy" do
4
+ it "can create a wallet" do
5
+ wallet = IndyWallet.new("WALLET1")
6
+ wallet.create
7
+ end
8
+ it "cannot create a duplicate wallet" do
9
+ wallet1 = IndyWallet.new("WALLET2")
10
+ wallet1.create
11
+ wallet2 = IndyWallet.new("WALLET2")
12
+ expect{wallet2.create}.to raise_error(/Wallet with this name already exists/)
13
+ end
14
+ it "can delete a wallet" do
15
+ wallet = IndyWallet.new("WALLET3")
16
+ wallet.create
17
+ wallet.delete
18
+ end
19
+ it "can open a wallet" do
20
+ wallet = IndyWallet.new("WALLET4")
21
+ wallet.create
22
+ wallet.open
23
+ end
24
+ it "can open and close a wallet" do
25
+ wallet = IndyWallet.new("WALLET5")
26
+ wallet.create
27
+ wallet.open
28
+ wallet.close
29
+ end
30
+ it "cannot delete a wallet twice" do
31
+ wallet = IndyWallet.new("WALLET6")
32
+ wallet.create
33
+ wallet.delete
34
+ expect{wallet.delete}.to raise_error(/No wallet database exists/)
35
+ end
36
+
37
+ it "can create a pool" do
38
+ pool = IndyPool.new("POOL1")
39
+ pool.create
40
+ end
41
+ it "cannot create a duplicate pool" do
42
+ pool1 = IndyPool.new("POOL2")
43
+ pool1.create
44
+ pool2 = IndyPool.new("POOL2")
45
+ expect{pool2.create}.to raise_error(/Pool ledger config file with name/)
46
+ end
47
+ it "can delete a pool" do
48
+ pool = IndyPool.new("POOL3")
49
+ pool.create
50
+ pool.delete
51
+ end
52
+ it "can open a pool" do
53
+ pool = IndyPool.new("POOL4")
54
+ pool.create
55
+ pool.open
56
+ end
57
+ it "can open and close a pool" do
58
+ pool = IndyPool.new("POOL5")
59
+ pool.create
60
+ pool.open
61
+ pool.close
62
+ end
63
+ it "cannot delete a pool twice" do
64
+ pool = IndyPool.new("POOL6")
65
+ pool.create
66
+ pool.delete
67
+ expect{pool.delete}.to raise_error(/No such file or directory/)
68
+ end
69
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'rindy'
data/src/lib.rs ADDED
@@ -0,0 +1,115 @@
1
+ #![recursion_limit="128"]
2
+ #[macro_use] extern crate helix;
3
+ #[macro_use] extern crate serde_json;
4
+ extern crate indyrs as indy;
5
+
6
+ use indy::pool;
7
+ use indy::wallet;
8
+ use std::string::String;
9
+
10
+ use indy::future::Future;
11
+
12
+ use std::env;
13
+ use std::fs;
14
+ use std::io::Write;
15
+ use std::path::PathBuf;
16
+
17
+ ruby! {
18
+ class IndyWallet {
19
+ struct {
20
+ name: String,
21
+ handle: i32
22
+ }
23
+
24
+ def initialize(helix, name: String) {
25
+ let handle = 0;
26
+ IndyWallet { helix, name, handle }
27
+ }
28
+
29
+ def create(&self) {
30
+ let config = format!("{{\"id\":\"wallet{}\"}}", self.name);
31
+ let credentials = String::from("{\"key\":\"8dvfYSt5d1taSd6yJdpjq4emkwsPDDLYxkNFysFD2cZY\",\"key_derivation_method\":\"RAW\"}");
32
+
33
+ wallet::create_wallet(&config, &credentials).wait().unwrap();
34
+ }
35
+ def open(&mut self) {
36
+ let config = format!("{{\"id\":\"wallet{}\"}}", self.name);
37
+ let credentials = String::from("{\"key\":\"8dvfYSt5d1taSd6yJdpjq4emkwsPDDLYxkNFysFD2cZY\",\"key_derivation_method\":\"RAW\"}");
38
+
39
+ self.handle = wallet::open_wallet(&config, &credentials).wait().unwrap();
40
+ }
41
+ def close(&self) {
42
+ wallet::close_wallet(self.handle).wait().unwrap();
43
+ }
44
+ def delete(&self) {
45
+ let config = format!("{{\"id\":\"wallet{}\"}}", self.name);
46
+ let credentials = String::from("{\"key\":\"8dvfYSt5d1taSd6yJdpjq4emkwsPDDLYxkNFysFD2cZY\",\"key_derivation_method\":\"RAW\"}");
47
+
48
+ wallet::delete_wallet(&config, &credentials).wait().unwrap();
49
+ }
50
+ }
51
+
52
+ class IndyPool {
53
+ struct {
54
+ name: String,
55
+ handle: i32
56
+ }
57
+
58
+ def initialize(helix, name: String) {
59
+ let handle = 0;
60
+ const PROTOCOL_VERSION: usize = 2;
61
+ pool::set_protocol_version(PROTOCOL_VERSION).wait().unwrap();
62
+ IndyPool { helix, name, handle }
63
+ }
64
+
65
+ def create(&self) {
66
+ let pool_config_file = create_genesis_txn_file_for_pool(&self.name);
67
+ let pool_config = json!({
68
+ "genesis_txn" : &pool_config_file
69
+ });
70
+ pool::create_pool_ledger_config(&self.name, Some(&pool_config.to_string())).wait().unwrap();
71
+ }
72
+ def open(&mut self) {
73
+ self.handle = pool::open_pool_ledger(&self.name, None).wait().unwrap();
74
+ }
75
+ def close(&self) {
76
+ pool::close_pool_ledger(self.handle).wait().unwrap();
77
+ }
78
+ def delete(&self) {
79
+ pool::delete_pool_ledger(&self.name).wait().unwrap();
80
+ }
81
+ }
82
+ }
83
+
84
+ fn create_genesis_txn_file_for_pool(pool_name: &str) -> String {
85
+ let test_pool_ip = env::var("TEST_POOL_IP").unwrap_or("127.0.0.1".to_string());
86
+
87
+ let node_txns = format!(
88
+ r#"{{"reqSignature":{{}},"txn":{{"data":{{"data":{{"alias":"Node1","blskey":"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba","blskey_pop":"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1","client_ip":"{0}","client_port":9702,"node_ip":"{0}","node_port":9701,"services":["VALIDATOR"]}},"dest":"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv"}},"metadata":{{"from":"Th7MpTaRZVRYnPiabds81Y"}},"type":"0"}},"txnMetadata":{{"seqNo":1,"txnId":"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62"}},"ver":"1"}}
89
+ {{"reqSignature":{{}},"txn":{{"data":{{"data":{{"alias":"Node2","blskey":"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk","blskey_pop":"Qr658mWZ2YC8JXGXwMDQTzuZCWF7NK9EwxphGmcBvCh6ybUuLxbG65nsX4JvD4SPNtkJ2w9ug1yLTj6fgmuDg41TgECXjLCij3RMsV8CwewBVgVN67wsA45DFWvqvLtu4rjNnE9JbdFTc1Z4WCPA3Xan44K1HoHAq9EVeaRYs8zoF5","client_ip":"{0}","client_port":9704,"node_ip":"{0}","node_port":9703,"services":["VALIDATOR"]}},"dest":"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb"}},"metadata":{{"from":"EbP4aYNeTHL6q385GuVpRV"}},"type":"0"}},"txnMetadata":{{"seqNo":2,"txnId":"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc"}},"ver":"1"}}
90
+ {{"reqSignature":{{}},"txn":{{"data":{{"data":{{"alias":"Node3","blskey":"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5","blskey_pop":"QwDeb2CkNSx6r8QC8vGQK3GRv7Yndn84TGNijX8YXHPiagXajyfTjoR87rXUu4G4QLk2cF8NNyqWiYMus1623dELWwx57rLCFqGh7N4ZRbGDRP4fnVcaKg1BcUxQ866Ven4gw8y4N56S5HzxXNBZtLYmhGHvDtk6PFkFwCvxYrNYjh","client_ip":"{0}","client_port":9706,"node_ip":"{0}","node_port":9705,"services":["VALIDATOR"]}},"dest":"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya"}},"metadata":{{"from":"4cU41vWW82ArfxJxHkzXPG"}},"type":"0"}},"txnMetadata":{{"seqNo":3,"txnId":"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4"}},"ver":"1"}}
91
+ {{"reqSignature":{{}},"txn":{{"data":{{"data":{{"alias":"Node4","blskey":"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw","blskey_pop":"RPLagxaR5xdimFzwmzYnz4ZhWtYQEj8iR5ZU53T2gitPCyCHQneUn2Huc4oeLd2B2HzkGnjAff4hWTJT6C7qHYB1Mv2wU5iHHGFWkhnTX9WsEAbunJCV2qcaXScKj4tTfvdDKfLiVuU2av6hbsMztirRze7LvYBkRHV3tGwyCptsrP","client_ip":"{0}","client_port":9708,"node_ip":"{0}","node_port":9707,"services":["VALIDATOR"]}},"dest":"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA"}},"metadata":{{"from":"TWwCRQRZ2ZHMJFn9TzLp7W"}},"type":"0"}},"txnMetadata":{{"seqNo":4,"txnId":"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008"}},"ver":"1"}}"#, test_pool_ip);
92
+
93
+ let pool_config_pathbuf = write_genesis_txn_to_file(pool_name, node_txns.as_str());
94
+ pool_config_pathbuf.as_os_str().to_str().unwrap().to_string()
95
+ }
96
+
97
+ fn write_genesis_txn_to_file(pool_name: &str,
98
+ txn_file_data: &str) -> PathBuf {
99
+ let mut txn_file_path = env::temp_dir();
100
+ txn_file_path.push("indy_client");
101
+ txn_file_path.push(format!("{}.txn", pool_name));
102
+
103
+ if !txn_file_path.parent().unwrap().exists() {
104
+ fs::DirBuilder::new()
105
+ .recursive(true)
106
+ .create(txn_file_path.parent().unwrap()).unwrap();
107
+ }
108
+
109
+ let mut f = fs::File::create(txn_file_path.as_path()).unwrap();
110
+ f.write_all(txn_file_data.as_bytes()).unwrap();
111
+ f.flush().unwrap();
112
+ f.sync_all().unwrap();
113
+
114
+ txn_file_path
115
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rindy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Callahan
@@ -31,6 +31,7 @@ extensions:
31
31
  - extconf.rb
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".gitignore"
34
35
  - Cargo.lock
35
36
  - Cargo.toml
36
37
  - Gemfile
@@ -38,15 +39,18 @@ files:
38
39
  - LICENSE-APACHE
39
40
  - LICENSE-MIT
40
41
  - README.md
41
- - README.md~
42
42
  - Rakefile
43
- - Rakefile~
44
43
  - extconf.rb
45
44
  - lib/rindy.rb
46
- - lib/rindy/native.bundle
47
45
  - lib/tasks/helix_runtime.rake
46
+ - rindy.gemspec
47
+ - spec/rindy_spec.rb
48
+ - spec/spec_helper.rb
49
+ - src/lib.rs
48
50
  homepage:
49
- licenses: []
51
+ licenses:
52
+ - MIT
53
+ - Apache-2.0
50
54
  metadata: {}
51
55
  post_install_message:
52
56
  rdoc_options: []
@@ -67,5 +71,5 @@ rubyforge_project:
67
71
  rubygems_version: 2.7.9
68
72
  signing_key:
69
73
  specification_version: 4
70
- summary: A Helix project
74
+ summary: Ruby wrapper for indy-sdk
71
75
  test_files: []
data/README.md~ DELETED
@@ -1,53 +0,0 @@
1
- # rindy
2
-
3
- [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
-
5
- A ruby wrapper for [indy-sdk](https://github.com/hyperledger/indy-sdk).
6
-
7
- ## Installation
8
-
9
- Create a new rails application:
10
-
11
- $ rails new rindy-rails --skip-active-record
12
- $ cd rindy-rails
13
- $
14
-
15
- Then, add this line to your application's Gemfile:
16
-
17
- ```ruby
18
- gem 'rindy', :github => "johncallahan/rindy"
19
- ```
20
-
21
- You *must* have rust installed. Then, execute:
22
-
23
- $ bundle
24
-
25
- WARNING: You may have to wait a bit for the native extension to build the rindy gem.
26
-
27
- ## Usage
28
-
29
- To try out the gem, execute:
30
-
31
- $ bundle exec rails c
32
- > wallet = IndyWallet.new("mywallet")
33
- > wallet.create
34
- > pool = IndyPool.new("mypool")
35
- > pool.create
36
- >
37
-
38
- If you check ~/.indy_client/pool and ~/.indy_client/wallet directories, you should see the pool and wallet you created.
39
-
40
- ## Development
41
-
42
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
-
44
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). (This gem not yet available on rubygems)
45
-
46
- ## Contributing
47
-
48
- Bug reports and pull requests are welcome on GitHub at https://github.com/johncallahan/rindy.
49
-
50
-
51
- ## License
52
-
53
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT) and the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0).
data/Rakefile~ DELETED
@@ -1,2 +0,0 @@
1
- require 'bundler/setup'
2
- import 'lib/tasks/helix_runtime.rake'
Binary file