cardano_wallet 0.3.26 → 0.3.27

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: b939ecfaab3cb3b39b87072b84ada64881ca169a40a21537e046a407c7c940b7
4
- data.tar.gz: 8e208b0afe7adcf2d853955da46a0acb786aae86ce20a5e0eeb31bb8a5d552f7
3
+ metadata.gz: '083f459db029fab491c2d7fddad1f0a6bfff596e08344af6e31ea75dfb9e2a21'
4
+ data.tar.gz: eb50ebc2b10e841c941fc36250bc0d035d52b785fc2920961b9c563b0410c9ae
5
5
  SHA512:
6
- metadata.gz: 8420ef9068779be1a4b7ea1c23c8f8ad6995781a5b31508830150cea83bb44370d35be2a03f5045a60d7f3dee6e035669ffaeea8b5007f8663f3acf7c520f020
7
- data.tar.gz: cd653f1463d490e7590dcf99ecd2b19902bee68c02019116363db659238d51c1bfac2ce280a63c29dbcdef6ac0bc2f85595611aa9512f9149907bf18195ac049
6
+ metadata.gz: 14ca8505a76dc7d21474b92a7e444d76b4b436e8f33ec7553b3a0a49eb1bb83e415eedc0ade4d6fb50353981eb20f56c129f786576ad1c0ed5c1ac216eeb6205
7
+ data.tar.gz: 94ae2907f02096c838b97c9097ee71668ddbbdb293ec2b1786d3ecd505ecfc2c6344c45d9f82016846d5031f22bac7b55ef137621d0bd994290ee03c28558c16
data/README.md CHANGED
@@ -13,11 +13,9 @@
13
13
 
14
14
  # cardano-wallet-rb
15
15
 
16
- Ruby wrapper over [cardano-wallet's](https://github.com/input-output-hk/cardano-wallet) REST [API](https://input-output-hk.github.io/cardano-wallet/api/edge/).
16
+ Ruby wrapper over [cardano-wallet's](https://github.com/input-output-hk/cardano-wallet) REST [API](https://input-output-hk.github.io/cardano-wallet/api/edge/). Requires running `cardano-wallet`.
17
17
 
18
- ## E2E tests
19
-
20
- Cardano-wallet-rb is used for e2e testing of [cardano-wallet](https://github.com/input-output-hk/cardano-wallet/test/e2e) against public testnet.
18
+ Cardano-wallet-rb is used for e2e testing of [cardano-wallet](https://github.com/input-output-hk/cardano-wallet/test/e2e) and also as a backend of [Ikar](https://github.com/piotr-iohk/ikar).
21
19
 
22
20
 
23
21
  ## Installation
@@ -38,7 +36,7 @@ For ruby doc see: https://rubydoc.info/gems/cardano_wallet.
38
36
 
39
37
  For `cardano-wallet` REST Api see: https://input-output-hk.github.io/cardano-wallet/api/edge/.
40
38
 
41
- ## Usage
39
+ ## Examples
42
40
 
43
41
  ```ruby
44
42
  CW = CardanoWallet.new
@@ -48,16 +46,48 @@ SHELLEY = CW.shelley
48
46
  MISC = CW.misc
49
47
 
50
48
  #Byron
49
+ BYRON.wallets.create({name: "Byron",
50
+ style: "random",
51
+ mnemonic_sentence: CW.utils.mnemonic_sentence,
52
+ passphrase: "Secure Passphrase"})
53
+
51
54
  BYRON.wallets.list.each_with_index do |wal, i|
52
55
  BYRON.wallets.update_metadata(wal['id'], {name: "Wallet number #{i}"})
53
56
  end
54
57
 
58
+ BYRON.wallets.list.each do |wal|
59
+ puts wal['name']
60
+ end
61
+
55
62
  #Shelley
56
- w = SHELLEY.wallets.create{name: "Wallet1",
57
- mnemonic_sentence: %w[vintage poem topic machine hazard cement dune glimpse fix brief account badge mass silly business],
58
- passphrase: "Secure Passphrase"}
63
+ w = SHELLEY.wallets.create({name: "Shelley",
64
+ mnemonic_sentence: CW.utils.mnemonic_sentence,
65
+ passphrase: "Secure Passphrase"})
59
66
 
60
67
  SHELLEY.wallets.get(w['id'])
68
+ SHELLEY.wallets.delete(w['id'])
69
+
70
+ # Transaction
71
+ wid = '1f82e...ccd95'
72
+ metadata = { "1" => "test"}
73
+ tx_c = SHELLEY.transactions.construct(wid, payments = nil, withdrawal = nil, metadata)
74
+ tx_s = SHELLEY.transactions.sign(wid, 'Secure Passphrase', tx_c['transaction'])
75
+ tx_sub = SHELLEY.transactions.submit(wid, tx_s['transaction'])
76
+ puts SHELLEY.transactions.get(wid, tx_sub['id'])
77
+
78
+ # Delegation
79
+ wid = '1f82e...ccd95'
80
+ random_stake_pool_id = SHELLEY.stake_pools.list({stake: 10000}).sample['id']
81
+ delegation = [{
82
+ "join" => {
83
+ "pool" => random_stake_pool_id,
84
+ "stake_key_index" => "0H"
85
+ }
86
+ }]
87
+ tx_c = SHELLEY.transactions.construct(wid, payments = nil, withdrawal = nil, metadata = nil, delegation)
88
+ tx_s = SHELLEY.transactions.sign(wid, 'Secure Passphrase', tx_c['transaction'])
89
+ tx_sub = SHELLEY.transactions.submit(wid, tx_s['transaction'])
90
+ puts SHELLEY.transactions.get(wid, tx_sub['id'])
61
91
 
62
92
  #Misc
63
93
  MISC.network.information
@@ -68,25 +98,6 @@ MISC.utils.addresses("addr_test1vqrlltfahghjxl5sy5h5mvfrrlt6me5fqphhwjqvj5jd88cc
68
98
 
69
99
  Refer to [documentation](https://rubydoc.info/gems/cardano_wallet) for more details.
70
100
 
71
- ## Development
72
-
73
- In order to spin up environment for development and testing `docker-compose` can be used. For instance:
74
-
75
- # Byron testnet
76
- $ NETWORK=testnet WALLET=dev-master-byron NODE=latest docker-compose up --detach
77
-
78
- or
79
-
80
- # Shelley testnet
81
- $ NODE=1.13.0 WALLET=dev-master-shelley NODE_CONFIG_PATH=`pwd`/spec/shelley-testnet/ docker-compose -f docker-compose-shelley.yml up
82
-
83
- Run tests on top of that:
84
-
85
- $ rake
86
-
87
- Clean up docker stuff after, e.g.:
88
-
89
- $ NETWORK=... docker-compose down --rmi all --remove-orphans
90
101
 
91
102
  ## Contributing
92
103
 
@@ -30,9 +30,9 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ['lib']
32
32
 
33
+ spec.add_runtime_dependency 'bip_mnemonic', '~> 0.0.4'
33
34
  spec.add_runtime_dependency 'httparty', '~> 0.18.0'
34
35
 
35
- spec.add_development_dependency 'bip_mnemonic', '~> 0.0.4'
36
36
  spec.add_development_dependency 'codecov', '0.2.8'
37
37
  spec.add_development_dependency 'rake', '~> 12.3'
38
38
  spec.add_development_dependency 'rspec', '~> 3.7'
@@ -50,9 +50,9 @@ module CardanoWallet
50
50
  Misc.new @opt
51
51
  end
52
52
 
53
- # Init API for Proxy
54
- def proxy
55
- Proxy.new @opt
53
+ # Init API for Utils
54
+ def utils
55
+ Utils.new @opt
56
56
  end
57
57
  end
58
58
  end
@@ -4,6 +4,51 @@ module CardanoWallet
4
4
  ##
5
5
  # General Utils not connected to API
6
6
  module Utils
7
+ def self.new(opt)
8
+ Init.new opt
9
+ end
10
+
11
+ # Init
12
+ class Init < Base
13
+ # Generate mnemonic sentence
14
+ #
15
+ # @example Default 24-word English mnemonic sentence
16
+ # CardanoWallet.new.utils.mnemonic_sentence
17
+ # ["kiwi", "rent", "denial",...]
18
+ #
19
+ # @example 15-word French mnemonic sentence
20
+ # CardanoWallet.new.utils.mnemonic_sentence(15, 'french')
21
+ # ["ruser", "malaxer", "forgeron",...]
22
+ def mnemonic_sentence(word_count = 24, language = 'english')
23
+ languages = %w[english french spanish korean japanese
24
+ italian chinese_traditional chinese_simplified]
25
+ unless languages.include?(language)
26
+ raise ArgumentError,
27
+ %(Not supported language: '#{language}'. Supported languages are: #{languages}.)
28
+ end
29
+
30
+ words = [9, 12, 15, 18, 21, 24]
31
+ case word_count
32
+ when 9
33
+ bits = 96
34
+ when 12
35
+ bits = 128
36
+ when 15
37
+ bits = 164
38
+ when 18
39
+ bits = 196
40
+ when 21
41
+ bits = 224
42
+ when 24
43
+ bits = 256
44
+ else
45
+ raise ArgumentError,
46
+ %(Not supported count of words #{word_count}. Supported counts are: #{words}.)
47
+ end
48
+ BipMnemonic.to_mnemonic(bits: bits, language: language).split
49
+ end
50
+ end
51
+
7
52
  def self.verify_param_is_hash!(param)
8
53
  raise ArgumentError, 'argument should be Hash' unless param.is_a?(Hash)
9
54
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CardanoWallet
4
- VERSION = '0.3.26'
4
+ VERSION = '0.3.27'
5
5
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'httparty'
4
+ require 'bip_mnemonic'
4
5
 
5
6
  require_relative 'cardano_wallet/version'
6
7
  require_relative 'cardano_wallet/base'
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cardano_wallet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.26
4
+ version: 0.3.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Stachyra
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-15 00:00:00.000000000 Z
11
+ date: 2022-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: httparty
14
+ name: bip_mnemonic
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.18.0
19
+ version: 0.0.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.18.0
26
+ version: 0.0.4
27
27
  - !ruby/object:Gem::Dependency
28
- name: bip_mnemonic
28
+ name: httparty
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.4
34
- type: :development
33
+ version: 0.18.0
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.4
40
+ version: 0.18.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: codecov
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,7 +128,6 @@ files:
128
128
  - README.md
129
129
  - Rakefile
130
130
  - bin/console
131
- - bin/run_all_tests
132
131
  - bin/setup
133
132
  - cardano_wallet.gemspec
134
133
  - dev
data/bin/run_all_tests DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- NODE_DB=./node_db \
4
- WALLET_DB=./wallet_db \
5
- TOKEN_METADATA=http://metadata-server-mock.herokuapp.com/ \
6
- bundle exec rake run_on["testnet"]