cardano_wallet 0.1.1 → 0.1.6

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: 8bee737961a137776d1544ee46ea7e4866ef2dd78bb0a8de1808e34cd3b0f97b
4
- data.tar.gz: cc36f525ddd0e0106ef22536797f7ee1ac3eba66ff6b587fe3074ad6c6ec16d4
3
+ metadata.gz: 170a67d50c0941bcc6827d81d5025594aecd75fcde3736e0d28c1e11efec839f
4
+ data.tar.gz: 0e4e039fac16f50a6a6bb94c381ddf4c89b14cb3ab2f09556054fc4288238c21
5
5
  SHA512:
6
- metadata.gz: 9f4a2a58cc93aa312ad88fda33ed5d34a83834bf38dbf4a4237ec0a923384341089fe942166bf7a93f4f58df22817255777f19237dfdabc5d94e5c44bf71a2c7
7
- data.tar.gz: ab96b3386eaa674fdff19072f78e1d6016ef37d67f4904570a82ab453c771b89d1441e6fb03ec80b8d159300f43af7116fa7fe11e1bcf8845705d3755d32fd37
6
+ metadata.gz: 37902c4bc67884beb01bad10a4771ef1fb9cfcd7ae2a722b25e856249ba9ec92580dc076960c0b7e288729f852c2ff778589eff67f1d34465c320d0fde8b189c
7
+ data.tar.gz: 5370e532f52ff2459957309d2109ae1cfebf2e99fe3332a39a5580e0d073fac69b6080a4fd1ab265f6b781ce483d17275df4609332332904aa03b0f686b37775
@@ -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: master
@@ -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: master
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  <a href="https://badge.fury.io/rb/cardano_wallet">
2
3
  <img src="https://badge.fury.io/rb/cardano_wallet.svg" alt="Gem Version">
3
4
  </a>
@@ -10,6 +11,9 @@
10
11
  <a href="https://github.com/piotr-iohk/cardano-wallet-rb/actions?query=workflow%3ATests">
11
12
  <img src="https://github.com/piotr-iohk/cardano-wallet-rb/workflows/Tests/badge.svg" />
12
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>
13
17
 
14
18
  # cardano-wallet-rb
15
19
 
@@ -87,18 +91,23 @@ Refer to [documentation](https://rubydoc.info/gems/cardano_wallet) for more deta
87
91
 
88
92
  ## Development
89
93
 
90
- 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:
91
95
 
96
+ # Byron testnet
92
97
  $ NETWORK=testnet WALLET=dev-master-byron NODE=latest docker-compose up --detach
93
98
 
94
- This starts:
95
- - `cardano-node` latest [release](https://github.com/input-output-hk/cardano-node/releases)
96
- - `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
97
103
 
98
104
  Run tests on top of that:
99
105
 
100
106
  $ rake
101
107
 
108
+ Clean up docker stuff after, e.g.:
109
+
110
+ $ NETWORK=... docker-compose down --rmi all --remove-orphans
102
111
 
103
112
  ## Contributing
104
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
 
@@ -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:
@@ -22,6 +22,12 @@ module CardanoWallet
22
22
  Addresses.new @opt
23
23
  end
24
24
 
25
+ # API for CoinSelections
26
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Coin-Selections
27
+ def coin_selections
28
+ CoinSelections.new @opt
29
+ end
30
+
25
31
  # Get API for Byron transactions
26
32
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postByronTransactionFee
27
33
  def transactions
@@ -152,6 +158,36 @@ module CardanoWallet
152
158
  self.class.put("/byron-wallets/#{wid}/addresses/#{addr_id}")
153
159
  end
154
160
 
161
+ # Import addresses to Byron wallet.
162
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/importAddresses
163
+ # @param wid [String] wallet id
164
+ # @param addresses [Array] array of addresses
165
+ def bulk_import(wid, addresses)
166
+ self.class.put("/byron-wallets/#{wid}/addresses",
167
+ :body => { :addresses => addresses
168
+ }.to_json,
169
+ :headers => { 'Content-Type' => 'application/json' } )
170
+ end
171
+ end
172
+
173
+ # API for CoinSelections
174
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Coin-Selections
175
+ class CoinSelections < Base
176
+ def initialize opt
177
+ super
178
+ end
179
+
180
+ # Show random coin selection for particular payment
181
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/byronSelectCoins
182
+ #
183
+ # @example
184
+ # random(wid, {address1: 123, address2: 456})
185
+ def random(wid, payments)
186
+ payments_formatted = Utils.format_payments(payments)
187
+ self.class.post("/byron-wallets/#{wid}/coin-selections/random",
188
+ :body => {:payments => payments_formatted}.to_json,
189
+ :headers => { 'Content-Type' => 'application/json' })
190
+ end
155
191
  end
156
192
 
157
193
  # Byron transactions
@@ -161,6 +197,12 @@ module CardanoWallet
161
197
  super
162
198
  end
163
199
 
200
+ # Get tx by id
201
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getByronTransaction
202
+ def get(wid, tx_id)
203
+ self.class.get("/byron-wallets/#{wid}/transactions/#{tx_id}")
204
+ end
205
+
164
206
  # List all Byron wallet's transactions.
165
207
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listByronTransactions
166
208
  #
@@ -174,6 +174,12 @@ module CardanoWallet
174
174
  super
175
175
  end
176
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
+
177
183
  # List all wallet's transactions
178
184
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listTransactions
179
185
  #
@@ -189,17 +195,18 @@ module CardanoWallet
189
195
  # @param wid [String] source wallet id
190
196
  # @param passphrase [String] source wallet's passphrase
191
197
  # @param payments [Hash] addres, amount pair
198
+ # @param q [Hash] query param (currently only withdrawRewards = true | false)
192
199
  #
193
200
  # @example
194
- # create(wid, passphrase, {addr1: 1000000})
195
- def create(wid, passphrase, payments)
201
+ # create(wid, passphrase, {addr1: 1000000}, q)
202
+ def create(wid, passphrase, payments, q = {})
196
203
  payments_formatted = Utils.format_payments(payments)
197
- self.class.post("/wallets/#{wid}/transactions",
204
+ q.empty? ? query = '' : query = Utils.to_query(q)
205
+ self.class.post("/wallets/#{wid}/transactions#{query}",
198
206
  :body => { :payments => payments_formatted,
199
207
  :passphrase => passphrase
200
208
  }.to_json,
201
209
  :headers => { 'Content-Type' => 'application/json' } )
202
-
203
210
  end
204
211
 
205
212
  # Estimate fees for transaction
@@ -230,8 +237,9 @@ module CardanoWallet
230
237
 
231
238
  # List all stake pools
232
239
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listStakePools
233
- def list
234
- 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}")
235
243
  end
236
244
 
237
245
  # Join stake pool
@@ -1,3 +1,3 @@
1
1
  module CardanoWallet
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.6"
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.1
4
+ version: 0.1.6
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-27 00:00:00.000000000 Z
11
+ date: 2020-07-16 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"
@@ -101,6 +116,7 @@ files:
101
116
  - bin/setup
102
117
  - cardano_wallet.gemspec
103
118
  - dev
119
+ - docker-compose-shelley.yml
104
120
  - docker-compose.yml
105
121
  - lib/cardano_wallet.rb
106
122
  - lib/cardano_wallet/base.rb