cardano_wallet 0.3.26 → 0.3.28

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: b939ecfaab3cb3b39b87072b84ada64881ca169a40a21537e046a407c7c940b7
4
- data.tar.gz: 8e208b0afe7adcf2d853955da46a0acb786aae86ce20a5e0eeb31bb8a5d552f7
3
+ metadata.gz: c0c786aa01e91885cd16eec71a342abd8b6c167333a31fa7295387034e419d12
4
+ data.tar.gz: 072f86798b9627fad6271f8914d2f1acb0c66e0f883a98a90c445a76b5771e71
5
5
  SHA512:
6
- metadata.gz: 8420ef9068779be1a4b7ea1c23c8f8ad6995781a5b31508830150cea83bb44370d35be2a03f5045a60d7f3dee6e035669ffaeea8b5007f8663f3acf7c520f020
7
- data.tar.gz: cd653f1463d490e7590dcf99ecd2b19902bee68c02019116363db659238d51c1bfac2ce280a63c29dbcdef6ac0bc2f85595611aa9512f9149907bf18195ac049
6
+ metadata.gz: dbacc44ddf77499f1beafc40a7a7fa5b1e74e8bb875ef8349b64f861348aa01ed07fdcb217f17ad0b4656850d7229a116a577dbd13af7af74d9b2e7b2219b494
7
+ data.tar.gz: 00ef7d5428ffa310d08c13fa4ea12f49033d5fe8332033437b9dfd589ebb298579286006737b5d14ded83797cb410b4c5e22230dea05729885badc3da9e6b5cd
@@ -0,0 +1,50 @@
1
+ name: Docs
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ tags:
8
+ - '*'
9
+ pull_request:
10
+
11
+ jobs:
12
+ build:
13
+ name: Build + Publish Docs
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: '📥 Checkout repository'
18
+ uses: actions/checkout@v2
19
+ - name: '💎 Setup Ruby'
20
+ uses: actions/setup-ruby@v1
21
+
22
+ - name: '🔧 Set versions'
23
+ id: versions
24
+ run: |
25
+ if [[ $GITHUB_REF =~ ^refs/tags/ ]]; then
26
+ version="${GITHUB_REF/refs\/tags\//}"
27
+ commit_message="Release $version"
28
+ else
29
+ version=master
30
+ commit_message="Master"
31
+ fi
32
+ echo "::set-output name=commit_message::$commit_message"
33
+ echo "::set-output name=version::$version"
34
+
35
+ - name: '🔨 Build'
36
+ run: |
37
+ gem install yard
38
+ readme_link=https://github.com/piotr-iohk/cardano-wallet-rb/blob/${{ steps.versions.outputs.version }}/README.md
39
+ yard doc --title "Documentation for cardano_wallet (${{ steps.versions.outputs.version }})"
40
+ sed -i "s|<a href=\"index.html\" title=\"README\">|<a href=\"$readme_link\" title=\"README\">|" ./doc/_index.html
41
+ cp ./doc/_index.html ./doc/index.html
42
+
43
+ - name: '🚀 Publish'
44
+ if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') }}
45
+ uses: peaceiris/actions-gh-pages@v3
46
+ with:
47
+ github_token: ${{ secrets.GITHUB_TOKEN }}
48
+ publish_dir: doc
49
+ destination_dir: ${{ steps.versions.outputs.version }}
50
+ full_commit_message: ${{ steps.versions.outputs.commit_message }}
data/README.md CHANGED
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  <a href="https://badge.fury.io/rb/cardano_wallet">
4
2
  <img src="https://badge.fury.io/rb/cardano_wallet.svg" alt="Gem Version">
5
3
  </a>
@@ -9,15 +7,15 @@
9
7
  <a href="https://github.com/piotr-iohk/cardano-wallet-rb/actions?query=workflow%3ATests">
10
8
  <img src="https://github.com/piotr-iohk/cardano-wallet-rb/workflows/Tests/badge.svg" />
11
9
  </a>
12
-
10
+ <a href="https://github.com/piotr-iohk/cardano-wallet-rb/actions?query=workflow%3ADocs">
11
+ <img src="https://github.com/piotr-iohk/cardano-wallet-rb/workflows/Docs/badge.svg" />
12
+ </a>
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/).
17
-
18
- ## E2E tests
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`.
19
17
 
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
@@ -34,11 +32,14 @@ Or:
34
32
 
35
33
  ## Documentation
36
34
 
37
- For ruby doc see: https://rubydoc.info/gems/cardano_wallet.
35
+ | Link | Description |
36
+ |--|--|
37
+ | [Ruby API (edge)](https://piotr-iohk.github.io/cardano-wallet-rb/master/) | cardano-wallet-rb API |
38
+ |[REST API (edge)](https://input-output-hk.github.io/cardano-wallet/api/edge/)| [cardano-wallet's](https://github.com/input-output-hk/cardano-wallet) REST API|
38
39
 
39
- For `cardano-wallet` REST Api see: https://input-output-hk.github.io/cardano-wallet/api/edge/.
40
+ > :warning: Links point to `edge` APIs corresponding to `master` branches for both cardano-wallet and cardano-wallet-rb. Refer to [release page](https://github.com/piotr-iohk/cardano-wallet-rb/releases) for API doc suitable for the latest release.
40
41
 
41
- ## Usage
42
+ ## Examples
42
43
 
43
44
  ```ruby
44
45
  CW = CardanoWallet.new
@@ -48,16 +49,48 @@ SHELLEY = CW.shelley
48
49
  MISC = CW.misc
49
50
 
50
51
  #Byron
52
+ BYRON.wallets.create({name: "Byron",
53
+ style: "random",
54
+ mnemonic_sentence: CW.utils.mnemonic_sentence,
55
+ passphrase: "Secure Passphrase"})
56
+
51
57
  BYRON.wallets.list.each_with_index do |wal, i|
52
58
  BYRON.wallets.update_metadata(wal['id'], {name: "Wallet number #{i}"})
53
59
  end
54
60
 
61
+ BYRON.wallets.list.each do |wal|
62
+ puts wal['name']
63
+ end
64
+
55
65
  #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"}
66
+ w = SHELLEY.wallets.create({name: "Shelley",
67
+ mnemonic_sentence: CW.utils.mnemonic_sentence,
68
+ passphrase: "Secure Passphrase"})
59
69
 
60
70
  SHELLEY.wallets.get(w['id'])
71
+ SHELLEY.wallets.delete(w['id'])
72
+
73
+ # Transaction
74
+ wid = '1f82e...ccd95'
75
+ metadata = { "1" => "test"}
76
+ tx_c = SHELLEY.transactions.construct(wid, payments = nil, withdrawal = nil, metadata)
77
+ tx_s = SHELLEY.transactions.sign(wid, 'Secure Passphrase', tx_c['transaction'])
78
+ tx_sub = SHELLEY.transactions.submit(wid, tx_s['transaction'])
79
+ puts SHELLEY.transactions.get(wid, tx_sub['id'])
80
+
81
+ # Delegation
82
+ wid = '1f82e...ccd95'
83
+ random_stake_pool_id = SHELLEY.stake_pools.list({stake: 10000}).sample['id']
84
+ delegation = [{
85
+ "join" => {
86
+ "pool" => random_stake_pool_id,
87
+ "stake_key_index" => "0H"
88
+ }
89
+ }]
90
+ tx_c = SHELLEY.transactions.construct(wid, payments = nil, withdrawal = nil, metadata = nil, delegation)
91
+ tx_s = SHELLEY.transactions.sign(wid, 'Secure Passphrase', tx_c['transaction'])
92
+ tx_sub = SHELLEY.transactions.submit(wid, tx_s['transaction'])
93
+ puts SHELLEY.transactions.get(wid, tx_sub['id'])
61
94
 
62
95
  #Misc
63
96
  MISC.network.information
@@ -66,28 +99,6 @@ MISC.proxy.submit_external_transaction(File.new("/tmp/blob.bin").read)
66
99
  MISC.utils.addresses("addr_test1vqrlltfahghjxl5sy5h5mvfrrlt6me5fqphhwjqvj5jd88cccqcek")
67
100
  ```
68
101
 
69
- Refer to [documentation](https://rubydoc.info/gems/cardano_wallet) for more details.
70
-
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
-
91
102
  ## Contributing
92
103
 
93
104
  Bug reports and pull requests are welcome on GitHub at https://github.com/piotr-iohk/cardano-wallet-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/piotr-iohk/cardano-wallet-rb/blob/master/CODE_OF_CONDUCT.md).
@@ -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'
@@ -8,6 +8,16 @@ module CardanoWallet
8
8
 
9
9
  attr_accessor :opt
10
10
 
11
+ # Initialize CardanoWallet.
12
+ # @example Initialize CardanoWallet with default settings
13
+ # @cw = CardanoWallet.new
14
+ #
15
+ # @example Initialize CardanoWallet with custom settings
16
+ # @cw = CardanoWallet.new({ port: 4445,
17
+ # protocol: 'https',
18
+ # cacert: '/path/to/cacert',
19
+ # pem: '/path/to/client.pem',
20
+ # timeout: 600 })
11
21
  def initialize(opt = {})
12
22
  raise ArgumentError, 'argument should be Hash' unless opt.is_a?(Hash)
13
23
 
@@ -50,9 +60,9 @@ module CardanoWallet
50
60
  Misc.new @opt
51
61
  end
52
62
 
53
- # Init API for Proxy
54
- def proxy
55
- Proxy.new @opt
63
+ # Init API for Utils
64
+ def utils
65
+ Utils.new @opt
56
66
  end
57
67
  end
58
68
  end
@@ -3,13 +3,24 @@
3
3
  module CardanoWallet
4
4
  ##
5
5
  # Byron APIs
6
+ # @example
7
+ # @cw = CardanoWallet.new
8
+ # @cw.byron # API for Byron
6
9
  module Byron
7
10
  def self.new(opt)
8
11
  Init.new opt
9
12
  end
10
13
 
11
14
  ##
12
- # Init class for Byron APIs
15
+ # Init class for Byron APIs.
16
+ # @example
17
+ # @cw = CardanoWallet.new
18
+ # @cw.byron.wallets # API for Byron wallets
19
+ # @cw.byron.assets # API for Byron assets
20
+ # @cw.byron.coin_selections # API for Byron coin_selections
21
+ # @cw.byron.addresses # API for Byron addresses
22
+ # @cw.byron.transactions # API for Byron transactions
23
+ # @cw.byron.migrations # API for Byron migrations
13
24
  class Init < Base
14
25
  # Get API for Byron wallets
15
26
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Wallets
@@ -50,10 +61,15 @@ module CardanoWallet
50
61
 
51
62
  ##
52
63
  # Init for Byron assets APIs
64
+ # @example
65
+ # @cw = CardanoWallet.new
66
+ # @cw.byron.assets # API for Byron assets
53
67
  class Assets < Base
54
68
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listByronAssets
55
69
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getByronAsset
56
70
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getByronAssetDefault
71
+ # @example Get all assets that were ever involved in wallet transaction and been on balance
72
+ # @cw.byron.assets.get(wallet_id)
57
73
  def get(wid, policy_id = nil, asset_name = nil)
58
74
  ep = "/byron-wallets/#{wid}/assets"
59
75
  ep += "/#{policy_id}" if policy_id
@@ -64,15 +80,22 @@ module CardanoWallet
64
80
 
65
81
  # Byron wallets
66
82
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Wallets
83
+ # @example
84
+ # @cw = CardanoWallet.new
85
+ # @cw.byron.wallets # API for Byron wallets
67
86
  class Wallets < Base
68
87
  # List Byron wallets
69
88
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listByronWallets
89
+ # @example Get all Byron wallets
90
+ # @cw.byron.wallets.get
70
91
  def list
71
92
  self.class.get('/byron-wallets')
72
93
  end
73
94
 
74
95
  # Get Byron wallet details
75
96
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getByronWallet
97
+ # @example Get Byron wallet details
98
+ # @cw.byron.wallets.get(wallet_id)
76
99
  def get(wid)
77
100
  self.class.get("/byron-wallets/#{wid}")
78
101
  end
@@ -95,6 +118,8 @@ module CardanoWallet
95
118
 
96
119
  # Delete Byron wallet
97
120
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/deleteByronWallet
121
+ # @example Delete Byron wallet
122
+ # @cw.byron.wallets.delete(wallet_id)
98
123
  def delete(wid)
99
124
  self.class.delete("/byron-wallets/#{wid}")
100
125
  end
@@ -103,7 +128,7 @@ module CardanoWallet
103
128
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/putByronWallet
104
129
  #
105
130
  # @example
106
- # update_metadata(wid, {name: "New wallet name"})
131
+ # @cw.byron.wallets.update_metadata(wid, {name: "New wallet name"})
107
132
  def update_metadata(wid, params)
108
133
  Utils.verify_param_is_hash!(params)
109
134
  self.class.put("/byron-wallets/#{wid}",
@@ -113,11 +138,15 @@ module CardanoWallet
113
138
 
114
139
  # See Byron wallet's utxo distribution
115
140
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getByronUTxOsStatistics
141
+ # @example
142
+ # @cw.byron.wallets.utxo(wallet_id)
116
143
  def utxo(wid)
117
144
  self.class.get("/byron-wallets/#{wid}/statistics/utxos")
118
145
  end
119
146
 
120
147
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getByronWalletUtxoSnapshot
148
+ # @example
149
+ # @cw.byron.wallets.utxo_snapshot(wallet_id)
121
150
  def utxo_snapshot(wid)
122
151
  self.class.get("/byron-wallets/#{wid}/utxo")
123
152
  end
@@ -126,7 +155,8 @@ module CardanoWallet
126
155
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/putByronWalletPassphrase
127
156
  #
128
157
  # @example
129
- # update_passphrase(wid, {old_passphrase: "Secure Passphrase", new_passphrase: "Securer Passphrase"})
158
+ # @cw.byron.wallets.update_passphrase(wid, {old_passphrase: "Secure Passphrase",
159
+ # new_passphrase: "Securer Passphrase"})
130
160
  def update_passphrase(wid, params)
131
161
  Utils.verify_param_is_hash!(params)
132
162
  self.class.put("/byron-wallets/#{wid}/passphrase",
@@ -137,12 +167,15 @@ module CardanoWallet
137
167
 
138
168
  # Byron addresses
139
169
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Addresses
170
+ # @example
171
+ # @cw = CardanoWallet.new
172
+ # @cw.byron.addresses # API for Byron addresses
140
173
  class Addresses < Base
141
174
  # List Byron addresses.
142
175
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listByronAddresses
143
176
  #
144
177
  # @example
145
- # list(wid, {state: "used"})
178
+ # @cw.byron.addresses.list(wid, {state: "used"})
146
179
  def list(wid, query = {})
147
180
  query_formatted = query.empty? ? '' : Utils.to_query(query)
148
181
  self.class.get("/byron-wallets/#{wid}/addresses#{query_formatted}")
@@ -154,9 +187,9 @@ module CardanoWallet
154
187
  # @param params [Hash] passphrase and (optional) address_index
155
188
  #
156
189
  # @example Create address with index.
157
- # create(wid, {passphrase: "Secure Passphrase", address_index: 2147483648})
190
+ # @cw.byron.addresses.create(wid, {passphrase: "Secure Passphrase", address_index: 2147483648})
158
191
  # @example Create address with random index.
159
- # create(wid, {passphrase: "Secure Passphrase"})
192
+ # @cw.byron.addresses.create(wid, {passphrase: "Secure Passphrase"})
160
193
  def create(wid, params)
161
194
  Utils.verify_param_is_hash!(params)
162
195
  self.class.post("/byron-wallets/#{wid}/addresses",
@@ -185,13 +218,16 @@ module CardanoWallet
185
218
 
186
219
  # API for CoinSelections
187
220
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Coin-Selections
221
+ # @example
222
+ # @cw = CardanoWallet.new
223
+ # @cw.byron.coin_selections # API for Byron coin_selections
188
224
  class CoinSelections < Base
189
225
  # Show random coin selection for particular payment
190
226
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/byronSelectCoins
191
227
  #
192
228
  # @example
193
- # random(wid, [{addr1: 1000000}, {addr2: 1000000}])
194
- # random(wid, [{ "address": "addr1..",
229
+ # @cw.byron.coin_selections.random(wid, [{addr1: 1000000}, {addr2: 1000000}])
230
+ # @cw.byron.coin_selections.random(wid, [{ "address": "addr1..",
195
231
  # "amount": { "quantity": 42000000, "unit": "lovelace" },
196
232
  # "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])
197
233
  def random(wid, payments)
@@ -209,6 +245,9 @@ module CardanoWallet
209
245
 
210
246
  # Byron transactions
211
247
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postByronTransactionFee
248
+ # @example
249
+ # @cw = CardanoWallet.new
250
+ # @cw.byron.transactions # API for Byron Transactions
212
251
  class Transactions < Base
213
252
  # Construct transaction
214
253
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/constructByronTransaction
@@ -266,7 +305,7 @@ module CardanoWallet
266
305
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listByronTransactions
267
306
  #
268
307
  # @example
269
- # list(wid, {start: "2012-09-25T10:15:00Z", order: "descending"})
308
+ # @cw.byron.transactions.list(wid, {start: "2012-09-25T10:15:00Z", order: "descending"})
270
309
  def list(wid, query = {})
271
310
  query_formatted = query.empty? ? '' : Utils.to_query(query)
272
311
  self.class.get("/byron-wallets/#{wid}/transactions#{query_formatted}")
@@ -279,8 +318,8 @@ module CardanoWallet
279
318
  # @param payments [Array of Hashes] addres, amount pair
280
319
  #
281
320
  # @example
282
- # create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}])
283
- # create(wid, passphrase, [{ "address": "addr1..",
321
+ # @cw.byron.transactions.create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}])
322
+ # @cw.byron.transactions.create(wid, passphrase, [{ "address": "addr1..",
284
323
  # "amount": { "quantity": 42000000, "unit": "lovelace" },
285
324
  # "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])
286
325
 
@@ -301,8 +340,8 @@ module CardanoWallet
301
340
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransactionFee
302
341
  #
303
342
  # @example
304
- # payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}])
305
- # payment_fees(wid, [{ "address": "addr1..",
343
+ # @cw.byron.transactions.payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}])
344
+ # @cw.byron.transactions.payment_fees(wid, [{ "address": "addr1..",
306
345
  # "amount": { "quantity": 42000000, "unit": "lovelace" },
307
346
  # "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])
308
347
  def payment_fees(wid, payments)
@@ -326,6 +365,9 @@ module CardanoWallet
326
365
 
327
366
  # Byron migrations
328
367
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Migrations
368
+ # @example
369
+ # @cw = CardanoWallet.new
370
+ # @cw.byron.migrations # API for Byron Migrations
329
371
  class Migrations < Base
330
372
  # Get migration plan
331
373
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/createByronWalletMigrationPlan
@@ -2,7 +2,10 @@
2
2
 
3
3
  module CardanoWallet
4
4
  ##
5
- # misc
5
+ # Misc
6
+ # @example
7
+ # @cw = CardanoWallet.new
8
+ # @cw.misc
6
9
  module Misc
7
10
  def self.new(opt)
8
11
  Init.new opt
@@ -39,6 +42,9 @@ module CardanoWallet
39
42
  end
40
43
 
41
44
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Node
45
+ # @example
46
+ # @cw = CardanoWallet.new
47
+ # @cw.misc.node
42
48
  class Node < Base
43
49
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Node/paths/~1blocks~1latest~1header/get
44
50
  def block_header
@@ -48,6 +54,9 @@ module CardanoWallet
48
54
 
49
55
  # API for Network
50
56
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Settings
57
+ # @example
58
+ # @cw = CardanoWallet.new
59
+ # @cw.misc.settings
51
60
  class Settings < Base
52
61
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getSettings
53
62
  def get
@@ -65,6 +74,9 @@ module CardanoWallet
65
74
 
66
75
  # API for Network
67
76
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Network
77
+ # @example
78
+ # @cw = CardanoWallet.new
79
+ # @cw.misc.network
68
80
  class Network < Base
69
81
  # Get network information
70
82
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getNetworkInformation
@@ -86,6 +98,9 @@ module CardanoWallet
86
98
  end
87
99
 
88
100
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Utils
101
+ # @example
102
+ # @cw = CardanoWallet.new
103
+ # @cw.misc.utils
89
104
  class Utils < Base
90
105
  # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/signMetadata
91
106
  def sign_metadata(wid, role, index, pass, metadata)
@@ -128,6 +143,9 @@ module CardanoWallet
128
143
  end
129
144
 
130
145
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Proxy
146
+ # @example
147
+ # @cw = CardanoWallet.new
148
+ # @cw.misc.proxy
131
149
  class Proxy < Base
132
150
  # Submit a transaction that was created and signed outside of cardano-wallet.
133
151
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postExternalTransaction
@@ -2,6 +2,9 @@
2
2
 
3
3
  module CardanoWallet
4
4
  # Init API for Shelley Shared wallets
5
+ # @example
6
+ # @cw = CardanoWallet.new
7
+ # @cw.shared # API for Shared
5
8
  module Shared
6
9
  def self.new(opt)
7
10
  Init.new opt
@@ -35,6 +38,9 @@ module CardanoWallet
35
38
 
36
39
  # API for Transactions
37
40
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Shared-Transactions
41
+ # @example
42
+ # @cw = CardanoWallet.new
43
+ # @cw.shared.transactions # API for Shared transactions
38
44
  class Transactions < Base
39
45
  # Construct transaction
40
46
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/constructSharedTransaction
@@ -111,6 +117,9 @@ module CardanoWallet
111
117
 
112
118
  # API for Addresses
113
119
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Shared-Addresses
120
+ # @example
121
+ # @cw = CardanoWallet.new
122
+ # @cw.shared.addresses # API for Shared addresses
114
123
  class Addresses < Base
115
124
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listSharedAddresses
116
125
  def list(wid, query = {})
@@ -121,9 +130,11 @@ module CardanoWallet
121
130
 
122
131
  # API for Keys
123
132
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Shared-Keys
133
+ # @example
134
+ # @cw = CardanoWallet.new
135
+ # @cw.shared.keys # API for Shared Keys
124
136
  class Keys < Base
125
137
  # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/getSharedWalletKey
126
- # https://localhost:8090/v2/shared-wallets/{walletId}/keys/{role}/{index}?hash=false
127
138
  def get_public_key(wid, role, index, hash = {})
128
139
  hash_query = hash.empty? ? '' : Utils.to_query(hash)
129
140
  self.class.get("/shared-wallets/#{wid}/keys/#{role}/#{index}#{hash_query}")
@@ -147,6 +158,9 @@ module CardanoWallet
147
158
 
148
159
  # API for Wallets
149
160
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Shared-Wallets
161
+ # @example
162
+ # @cw = CardanoWallet.new
163
+ # @cw.shared.wallets # API for Shared Wallets
150
164
  class Wallets < Base
151
165
  # List all wallets
152
166
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listSharedWallets
@@ -2,13 +2,26 @@
2
2
 
3
3
  module CardanoWallet
4
4
  # Init API for Shelley
5
+ # @example
6
+ # @cw = CardanoWallet.new
7
+ # @cw.shelley # API for Shelley
5
8
  module Shelley
6
9
  def self.new(opt)
7
10
  Init.new opt
8
11
  end
9
12
 
10
13
  ##
11
- # Base class for Shelley API
14
+ # Init class for Shelley API
15
+ # @example
16
+ # @cw = CardanoWallet.new
17
+ # @cw.shelley.wallets # API for Shelley wallets
18
+ # @cw.shelley.assets # API for Shelley assets
19
+ # @cw.shelley.coin_selections # API for Shelley coin_selections
20
+ # @cw.shelley.addresses # API for Shelley addresses
21
+ # @cw.shelley.transactions # API for Shelley transactions
22
+ # @cw.shelley.migrations # API for Shelley migrations
23
+ # @cw.shelley.stake_pools # API for Shelley stake_pools
24
+ # @cw.shelley.keys # API for Shelley keys
12
25
  class Init < Base
13
26
  # Call API for Wallets
14
27
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Wallets
@@ -61,22 +74,10 @@ module CardanoWallet
61
74
 
62
75
  ##
63
76
  # Base class for Shelley Assets API
77
+ # @example
78
+ # @cw = CardanoWallet.new
79
+ # @cw.shelley.assets # API for Shelley assets
64
80
  class Assets < Base
65
- # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/mintBurnAssets
66
- def mint(wid, mint_burn, pass, metadata = nil, ttl = nil)
67
- payload = {
68
- mint_burn: mint_burn,
69
- passphrase: pass
70
- }
71
-
72
- payload[:metadata] = metadata if metadata
73
- payload[:time_to_live] = { quantity: ttl, unit: 'second' } if ttl
74
-
75
- self.class.post("/wallets/#{wid}/assets",
76
- body: payload.to_json,
77
- headers: { 'Content-Type' => 'application/json' })
78
- end
79
-
80
81
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listAssets
81
82
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getAsset
82
83
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getAssetDefault
@@ -90,6 +91,9 @@ module CardanoWallet
90
91
 
91
92
  ##
92
93
  # Base class for Shelley Keys API
94
+ # @example
95
+ # @cw = CardanoWallet.new
96
+ # @cw.shelley.keys # API for Shelley Keys
93
97
  class Keys < Base
94
98
  # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/signMetadata
95
99
  def sign_metadata(wid, role, index, pass, metadata)
@@ -149,6 +153,9 @@ module CardanoWallet
149
153
 
150
154
  # API for Wallets
151
155
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Wallets
156
+ # @example
157
+ # @cw = CardanoWallet.new
158
+ # @cw.shelley.wallets # API for Shelley wallets
152
159
  class Wallets < Base
153
160
  # List all wallets
154
161
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listWallets
@@ -166,12 +173,12 @@ module CardanoWallet
166
173
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postWallet
167
174
  #
168
175
  # @example Create wallet from mnemonic sentence
169
- # create({name: "Wallet from mnemonic_sentence",
176
+ # @cw.shelley.wallets.create({name: "Wallet from mnemonic_sentence",
170
177
  # passphrase: "Secure Passphrase",
171
178
  # mnemonic_sentence: %w[story egg fun ... ],
172
179
  # })
173
180
  # @example Create wallet from pub key
174
- # create({name: "Wallet from pub key",
181
+ # @cw.shelley.wallets.create({name: "Wallet from pub key",
175
182
  # account_public_key: "b47546e...",
176
183
  # address_pool_gap: 20,
177
184
  # })
@@ -192,7 +199,7 @@ module CardanoWallet
192
199
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/putWallet
193
200
  #
194
201
  # @example
195
- # update_metadata(wid, {name: "New wallet name"})
202
+ # @cw.shelley.wallets.update_metadata(wid, {name: "New wallet name"})
196
203
  def update_metadata(wid, params)
197
204
  Utils.verify_param_is_hash!(params)
198
205
  self.class.put("/wallets/#{wid}",
@@ -215,7 +222,8 @@ module CardanoWallet
215
222
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/putWalletPassphrase
216
223
  #
217
224
  # @example
218
- # update_passphrase(wid, {old_passphrase: "Secure Passphrase", new_passphrase: "Securer Passphrase"})
225
+ # @cw.shelley.wallets.update_passphrase(wid, {old_passphrase: "Secure Passphrase",
226
+ # new_passphrase: "Securer Passphrase"})
219
227
  def update_passphrase(wid, params)
220
228
  Utils.verify_param_is_hash!(params)
221
229
  self.class.put("/wallets/#{wid}/passphrase",
@@ -226,6 +234,9 @@ module CardanoWallet
226
234
 
227
235
  # API for Addresses
228
236
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Addresses
237
+ # @example
238
+ # @cw = CardanoWallet.new
239
+ # @cw.shelley.addresses # API for Shelley addresses
229
240
  class Addresses < Base
230
241
  # List addresses
231
242
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listAddresses
@@ -240,6 +251,9 @@ module CardanoWallet
240
251
 
241
252
  # API for CoinSelections
242
253
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Coin-Selections
254
+ # @example
255
+ # @cw = CardanoWallet.new
256
+ # @cw.shelley.coin_selections # API for Shelley coin_selections
243
257
  class CoinSelections < Base
244
258
  # Show random coin selection for particular payment
245
259
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/selectCoins
@@ -281,6 +295,9 @@ module CardanoWallet
281
295
 
282
296
  # API for Transactions
283
297
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Transactions
298
+ # @example
299
+ # @cw = CardanoWallet.new
300
+ # @cw.shelley.transactions # API for Shelley Transactions
284
301
  class Transactions < Base
285
302
  # Balance transaction
286
303
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/balanceTransaction
@@ -451,6 +468,9 @@ module CardanoWallet
451
468
 
452
469
  # API for StakePools
453
470
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Stake-Pools
471
+ # @example
472
+ # @cw = CardanoWallet.new
473
+ # @cw.shelley.stake_pools # API for Shelley StakePools
454
474
  class StakePools < Base
455
475
  # Stake pools maintenance actions
456
476
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postMaintenanceAction
@@ -508,6 +528,9 @@ module CardanoWallet
508
528
 
509
529
  # Shelley migrations
510
530
  # @see https://input-output-hk.github.io/cardano-wallet/api/#tag/Migrations
531
+ # @example
532
+ # @cw = CardanoWallet.new
533
+ # @cw.shelley.migrations # API for Shelley migrations
511
534
  class Migrations < Base
512
535
  # Get migration plan
513
536
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/createShelleyWalletMigrationPlan
@@ -3,7 +3,53 @@
3
3
  module CardanoWallet
4
4
  ##
5
5
  # General Utils not connected to API
6
+ # @example
7
+ # @cw = CardanoWallet.new
8
+ # @cw.utils
6
9
  module Utils
10
+ def self.new(opt)
11
+ Mnemonic.new opt
12
+ end
13
+
14
+ # Utils for mnemonics
15
+ class Mnemonic < Base
16
+ # Generate mnemonic sentence
17
+ #
18
+ # @example Default 24-word English mnemonic sentence
19
+ # @cw.utils.mnemonic_sentence
20
+ #
21
+ # @example 15-word French mnemonic sentence
22
+ # @cw.utils.mnemonic_sentence(15, 'french')
23
+ def mnemonic_sentence(word_count = 24, language = 'english')
24
+ languages = %w[english french spanish korean japanese
25
+ italian chinese_traditional chinese_simplified]
26
+ unless languages.include?(language)
27
+ raise ArgumentError,
28
+ %(Not supported language: '#{language}'. Supported languages are: #{languages}.)
29
+ end
30
+
31
+ words = [9, 12, 15, 18, 21, 24]
32
+ case word_count
33
+ when 9
34
+ bits = 96
35
+ when 12
36
+ bits = 128
37
+ when 15
38
+ bits = 164
39
+ when 18
40
+ bits = 196
41
+ when 21
42
+ bits = 224
43
+ when 24
44
+ bits = 256
45
+ else
46
+ raise ArgumentError,
47
+ %(Not supported count of words #{word_count}. Supported counts are: #{words}.)
48
+ end
49
+ BipMnemonic.to_mnemonic(bits: bits, language: language).split
50
+ end
51
+ end
52
+
7
53
  def self.verify_param_is_hash!(param)
8
54
  raise ArgumentError, 'argument should be Hash' unless param.is_a?(Hash)
9
55
  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.28'
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'
@@ -11,7 +12,7 @@ require_relative 'cardano_wallet/misc'
11
12
  require_relative 'cardano_wallet/shared'
12
13
 
13
14
  ##
14
- # Main module
15
+ # Main module. Go to {Base.initialize} for more details no how to start.
15
16
  module CardanoWallet
16
17
  def self.new(options = {})
17
18
  CardanoWallet::Base.new(options)
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.28
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-10-06 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
@@ -115,6 +115,7 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - ".github/workflows/docs.yml"
118
119
  - ".github/workflows/gem-push.yml"
119
120
  - ".github/workflows/tests.yml"
120
121
  - ".gitignore"
@@ -128,7 +129,6 @@ files:
128
129
  - README.md
129
130
  - Rakefile
130
131
  - bin/console
131
- - bin/run_all_tests
132
132
  - bin/setup
133
133
  - cardano_wallet.gemspec
134
134
  - 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"]