cardano_wallet 0.1.0 → 0.1.5

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: a6e3c345e2c100428cf2bdd638ee903c9df401760a78e75bc531f48d8d2832e3
4
- data.tar.gz: d11fd3e81378d4ff2d4687d16ebe3cdcfa78cf33d342d2d907ac8b8ab374c70b
3
+ metadata.gz: df0d8f6569ab3be773efe025fa14ec11e90fdfc9a51a08817182ec99de86eaec
4
+ data.tar.gz: 4ce00832c57f2afea0c2019d7772f8037b5fb4523e1f8f3be5aa3dfb4040a6d6
5
5
  SHA512:
6
- metadata.gz: a2a32cd78ee9ec09f814b1bb9eca9786327b2da53e82da90067aaa9cca6c7a9d146b9d120115173e0e17e4f154c6d3cdf3c6ba7cbe228ce07f53dc7b435a5d88
7
- data.tar.gz: 5b2f5263447204632e7d80d8a9e15186a19fa7d33e40ee1a74651c0982aa799157a3b42455ea75aff25cd38db2ba8fea1609506f1ac2689dee3bc31911b950eb
6
+ metadata.gz: 97f5be475f2b18c6344e619fb33866a41d0449baf6801820aacc3123a0390195d4ed29a3d253b9b4e9004c6cd96246100a4b9df4a7ec54cb7e4ace3e37beeac8
7
+ data.tar.gz: e38d3564c8d28a01cc585ffbf3bf38d061f498301f26c1464aa9703bc927f18230af5bd3dbd27600a2b27b91a6dadc4059b6c91875a2dd2394951ded48af8cc2
@@ -0,0 +1,34 @@
1
+ name: Nightly
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "0 23 * * *"
6
+
7
+ jobs:
8
+ test:
9
+
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Set up cardano-wallet
15
+ run: NODE_CONFIG_PATH=`pwd`/spec/shelley-testnet docker-compose -f docker-compose-shelley.yml up --detach
16
+ - name: Set up Ruby
17
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
18
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
19
+ # uses: ruby/setup-ruby@v1
20
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
21
+ with:
22
+ ruby-version: 2.6
23
+ - name: Install dependencies
24
+ run: bundle install
25
+ - name: Wait until node is synced
26
+ run: bundle exec rake wait_until_node_synced
27
+ - name: Run all tests
28
+ run: bundle exec rspec
29
+ env:
30
+ CI: true
31
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
32
+ NETWORK: testnet
33
+ WALLET: dev-master-shelley
34
+ NODE: 1.14.2
@@ -21,7 +21,7 @@ jobs:
21
21
  steps:
22
22
  - uses: actions/checkout@v2
23
23
  - name: Set up cardano-wallet
24
- run: docker-compose up --detach
24
+ run: NODE_CONFIG_PATH=`pwd`/spec/shelley-testnet docker-compose -f docker-compose-shelley.yml up --detach
25
25
  - name: Set up Ruby
26
26
  # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
27
27
  # change this to (see https://github.com/ruby/setup-ruby#versioning):
@@ -31,11 +31,11 @@ jobs:
31
31
  ruby-version: 2.6
32
32
  - name: Install dependencies
33
33
  run: bundle install
34
- - name: Run tests
35
- run: bundle exec rake
34
+ - name: Run all tests except nighlty
35
+ run: bundle exec rspec . -t ~nightly
36
36
  env:
37
37
  CI: true
38
38
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
39
39
  NETWORK: testnet
40
- WALLET: dev-master-byron
41
- NODE: latest
40
+ WALLET: dev-master-shelley
41
+ NODE: 1.14.2
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+
2
+ <a href="https://badge.fury.io/rb/cardano_wallet">
3
+ <img src="https://badge.fury.io/rb/cardano_wallet.svg" alt="Gem Version">
4
+ </a>
1
5
  <a href="https://github.com/piotr-iohk/cardano-wallet-rb/releases">
2
6
  <img src="https://img.shields.io/github/release/piotr-iohk/cardano-wallet-rb.svg" />
3
7
  </a>
@@ -7,6 +11,9 @@
7
11
  <a href="https://github.com/piotr-iohk/cardano-wallet-rb/actions?query=workflow%3ATests">
8
12
  <img src="https://github.com/piotr-iohk/cardano-wallet-rb/workflows/Tests/badge.svg" />
9
13
  </a>
14
+ <a href="https://github.com/piotr-iohk/cardano-wallet-rb/actions?query=workflow%3ANightly">
15
+ <img src="https://github.com/piotr-iohk/cardano-wallet-rb/workflows/Nightly/badge.svg" />
16
+ </a>
10
17
 
11
18
  # cardano-wallet-rb
12
19
 
@@ -28,6 +35,12 @@ Or install it yourself as:
28
35
 
29
36
  $ gem install cardano_wallet
30
37
 
38
+ ## Documentation
39
+
40
+ For ruby doc see: https://rubydoc.info/gems/cardano_wallet.
41
+
42
+ For `cardano-wallet` REST Api see: https://input-output-hk.github.io/cardano-wallet/api/edge/.
43
+
31
44
  ## Usage
32
45
 
33
46
  ### Initialize
@@ -42,8 +55,10 @@ CW2 = CardanoWallet.new({port: 443,
42
55
  protocol: "https",
43
56
  cacert: "/root/ca.cert",
44
57
  pem: "/root/client.pem"})
58
+ CW3 = CardanoWallet.new({url: "http://localhost:8090/v2"})
45
59
  ```
46
- ### Excercise the API
60
+
61
+ ### Exercise
47
62
  ```ruby
48
63
  CW = CardanoWallet.new
49
64
 
@@ -59,8 +74,8 @@ end
59
74
 
60
75
  #Shelley
61
76
  w = SHELLEY.wallets.create{name: "Wallet1",
62
- mnemonic_sentence: %w[vintage poem topic machine hazard cement dune glimpse fix brief account badge mass silly business],
63
- passphrase: "Secure Passphrase"}
77
+ mnemonic_sentence: %w[vintage poem topic machine hazard cement dune glimpse fix brief account badge mass silly business],
78
+ passphrase: "Secure Passphrase"}
64
79
 
65
80
  SHELLEY.wallets.get(w['id'])
66
81
 
@@ -72,22 +87,27 @@ MISC.network.clock
72
87
  PROXY.submit_external_transaction(File.new("/tmp/blob.bin").read)
73
88
  ```
74
89
 
75
- Refer to documentation.
90
+ Refer to [documentation](https://rubydoc.info/gems/cardano_wallet) for more details.
76
91
 
77
92
  ## Development
78
93
 
79
- In order to spin up environment for development and testing `docker-compose` can be used.
94
+ In order to spin up environment for development and testing `docker-compose` can be used. For instance:
80
95
 
96
+ # Byron testnet
81
97
  $ NETWORK=testnet WALLET=dev-master-byron NODE=latest docker-compose up --detach
82
98
 
83
- This starts:
84
- - `cardano-node` latest [release](https://github.com/input-output-hk/cardano-node/releases)
85
- - `cardano-wallet-byron` [master](https://github.com/input-output-hk/cardano-wallet)
99
+ or
100
+
101
+ # Shelley testnet
102
+ $ NODE=1.13.0 WALLET=dev-master-shelley NODE_CONFIG_PATH=`pwd`/spec/shelley-testnet/ docker-compose -f docker-compose-shelley.yml up
86
103
 
87
104
  Run tests on top of that:
88
105
 
89
106
  $ rake
90
107
 
108
+ Clean up docker stuff after, e.g.:
109
+
110
+ $ NETWORK=... docker-compose down --rmi all --remove-orphans
91
111
 
92
112
  ## Contributing
93
113
 
data/Rakefile CHANGED
@@ -4,3 +4,13 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
7
+
8
+ require_relative "lib/cardano_wallet"
9
+ task :wait_until_node_synced do
10
+ desc "Wait for node to be synced"
11
+ network = CardanoWallet.new.misc.network
12
+ while network.information["sync_progress"]["status"] == "syncing" do
13
+ puts "Syncing... #{network.information["sync_progress"]["progress"]["quantity"]}%"
14
+ sleep 15
15
+ end
16
+ end
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_development_dependency 'rake', '~> 12.3'
33
33
  spec.add_development_dependency 'rspec', '~> 3.7'
34
+ spec.add_development_dependency 'bip_mnemonic', '~> 0.0.4'
34
35
  spec.add_development_dependency 'codecov'
35
36
  spec.add_development_dependency 'simplecov'
36
37
 
data/dev ADDED
@@ -0,0 +1 @@
1
+ NETWORK=testnet WALLET=dev-master-byron NODE=master docker-compose $1
@@ -0,0 +1,27 @@
1
+ version: "3.5"
2
+
3
+ services:
4
+ cardano-node:
5
+ image: inputoutput/cardano-node:${NODE}
6
+ volumes:
7
+ - node-db:/data
8
+ - node-ipc:/ipc
9
+ - ${NODE_CONFIG_PATH}:/config
10
+ command: run --socket-path /ipc/node.socket --config /config/shelley_testnet-config.json --topology /config/shelley_testnet-topology.json --database-path /data
11
+ restart: on-failure
12
+
13
+ cardano-wallet:
14
+ image: inputoutput/cardano-wallet:${WALLET}
15
+ volumes:
16
+ - wallet-shelley-db:/wallet-db
17
+ - node-ipc:/ipc
18
+ - ${NODE_CONFIG_PATH}:/config
19
+ ports:
20
+ - 8090:8090
21
+ command: serve --testnet /config/shelley_testnet-genesis.json --node-socket /ipc/node.socket --database /wallet-db --listen-address 0.0.0.0
22
+ restart: on-failure
23
+
24
+ volumes:
25
+ node-db:
26
+ wallet-shelley-db:
27
+ node-ipc:
@@ -2,7 +2,7 @@ module CardanoWallet
2
2
  class Base
3
3
  include HTTParty
4
4
 
5
- attr_reader :opt
5
+ attr_accessor :opt
6
6
 
7
7
  def initialize(opt = {})
8
8
  raise ArgumentError, "argument should be Hash" unless opt.is_a?(Hash)
@@ -161,6 +161,12 @@ module CardanoWallet
161
161
  super
162
162
  end
163
163
 
164
+ # Get tx by id
165
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getByronTransaction
166
+ def get(wid, tx_id)
167
+ self.class.get("/byron-wallets/#{wid}/transactions/#{tx_id}")
168
+ end
169
+
164
170
  # List all Byron wallet's transactions.
165
171
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listByronTransactions
166
172
  #
@@ -38,8 +38,8 @@ module CardanoWallet
38
38
 
39
39
  # Check network parameters
40
40
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getNetworkParameters
41
- def parameters(epoch_id)
42
- self.class.get("/network/parameters/#{epoch_id}")
41
+ def parameters
42
+ self.class.get("/network/parameters")
43
43
  end
44
44
 
45
45
  end
@@ -42,6 +42,12 @@ module CardanoWallet
42
42
  StakePools.new @opt
43
43
  end
44
44
 
45
+ # API for Migrations
46
+ # @see https://input-output-hk.github.io/cardano-wallet/api/#tag/Migrations
47
+ def migrations
48
+ Migrations.new @opt
49
+ end
50
+
45
51
  end
46
52
 
47
53
  # API for Wallets
@@ -168,6 +174,12 @@ module CardanoWallet
168
174
  super
169
175
  end
170
176
 
177
+ # Get tx by id
178
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getTransaction
179
+ def get(wid, tx_id)
180
+ self.class.get("/wallets/#{wid}/transactions/#{tx_id}")
181
+ end
182
+
171
183
  # List all wallet's transactions
172
184
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listTransactions
173
185
  #
@@ -183,17 +195,18 @@ module CardanoWallet
183
195
  # @param wid [String] source wallet id
184
196
  # @param passphrase [String] source wallet's passphrase
185
197
  # @param payments [Hash] addres, amount pair
198
+ # @param q [Hash] query param (currently only withdrawRewards = true | false)
186
199
  #
187
200
  # @example
188
- # create(wid, passphrase, {addr1: 1000000})
189
- def create(wid, passphrase, payments)
201
+ # create(wid, passphrase, {addr1: 1000000}, q)
202
+ def create(wid, passphrase, payments, q = {})
190
203
  payments_formatted = Utils.format_payments(payments)
191
- self.class.post("/wallets/#{wid}/transactions",
204
+ q.empty? ? query = '' : query = Utils.to_query(q)
205
+ self.class.post("/wallets/#{wid}/transactions#{query}",
192
206
  :body => { :payments => payments_formatted,
193
207
  :passphrase => passphrase
194
208
  }.to_json,
195
209
  :headers => { 'Content-Type' => 'application/json' } )
196
-
197
210
  end
198
211
 
199
212
  # Estimate fees for transaction
@@ -224,8 +237,9 @@ module CardanoWallet
224
237
 
225
238
  # List all stake pools
226
239
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listStakePools
227
- def list
228
- self.class.get("/stake-pools")
240
+ def list(stake = {})
241
+ stake.empty? ? query = '' : query = Utils.to_query(stake)
242
+ self.class.get("/stake-pools#{query}")
229
243
  end
230
244
 
231
245
  # Join stake pool
@@ -250,5 +264,33 @@ module CardanoWallet
250
264
  self.class.get("/wallets/#{wid}/delegation-fees")
251
265
  end
252
266
  end
267
+
268
+ # Shelley migrations
269
+ # @see https://input-output-hk.github.io/cardano-wallet/api/#tag/Migrations
270
+ class Migrations < Base
271
+ def initialize opt
272
+ super
273
+ end
274
+
275
+ # Calculate migration cost
276
+ # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/getShelleyWalletMigrationInfo
277
+ def cost(wid)
278
+ self.class.get("/wallets/#{wid}/migrations")
279
+ end
280
+
281
+ # Migrate all funds from Shelley wallet.
282
+ # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/migrateShelleyWallet
283
+ # @param wid [String] wallet id
284
+ # @param passphrase [String] wallet's passphrase
285
+ # @param [Array] array of addresses
286
+ def migrate(wid, passphrase, addresses)
287
+ self.class.post("/wallets/#{wid}/migrations",
288
+ :body => { :addresses => addresses,
289
+ :passphrase => passphrase
290
+ }.to_json,
291
+ :headers => { 'Content-Type' => 'application/json' } )
292
+ end
293
+
294
+ end
253
295
  end
254
296
  end
@@ -1,3 +1,3 @@
1
1
  module CardanoWallet
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cardano_wallet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Stachyra
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-23 00:00:00.000000000 Z
11
+ date: 2020-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bip_mnemonic
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.4
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: codecov
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +102,7 @@ extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
90
104
  - ".github/workflows/gem-push.yml"
105
+ - ".github/workflows/nightly.yml"
91
106
  - ".github/workflows/tests.yml"
92
107
  - ".gitignore"
93
108
  - ".rakeTasks"
@@ -100,6 +115,8 @@ files:
100
115
  - bin/console
101
116
  - bin/setup
102
117
  - cardano_wallet.gemspec
118
+ - dev
119
+ - docker-compose-shelley.yml
103
120
  - docker-compose.yml
104
121
  - lib/cardano_wallet.rb
105
122
  - lib/cardano_wallet/base.rb