cardano_wallet 0.2.6 → 0.3.1

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: 5e03252209057d5605ab9020ce1ef5ff66f123c6de43039595fbcfeefcc93ceb
4
- data.tar.gz: 17be8811e28fa42f2b7dcc3f143d15d1f3b86ff186031c30dccbd71ee6487028
3
+ metadata.gz: f416f0ff4fd389ce9af664e9c128f0765cda62c346f6b2f3b5237a884e43a253
4
+ data.tar.gz: 5769fb34859b6c2ddc7376a718ba5c0fc7962810cc1d3fc6012a82219d979302
5
5
  SHA512:
6
- metadata.gz: 92fb3ce4f8d6083e03dce79d4a617b672d28c5952590b5ac9604ebd01352ed03d59e62aa3a42f6a1674800a10fa3e26355897dabebfde916a90c73a1e7471a94
7
- data.tar.gz: db0decbb39674070b8741ade621a3e1dd5d6fe8a8539dc13ceaac303bc7b86fc6304c13709caa9f5bfafaecde3f56468ceadbfe879f77243cc407f92716d3526
6
+ metadata.gz: 8b3492bd2f7f215a3ef7008ae997189eab233ab821764f93a1bae69f3bf859258c519dd808e433ec2edcc6f9ba183e59dc28e3439d974dc35dec498f106becf7
7
+ data.tar.gz: 877550274108bc8c06203b9f488493c930d57b45c71ce7601f0116d129826f5638801dc46355b123ec2bf784977129e9a73fdfbc430e1d52f7bd13c28dbe39f8
@@ -3,6 +3,16 @@ name: Nightly
3
3
  on:
4
4
  schedule:
5
5
  - cron: "0 23 * * *"
6
+ workflow_dispatch:
7
+ inputs:
8
+ nodeTag:
9
+ description: 'Node tag (docker)'
10
+ required: true
11
+ default: '1.24.2'
12
+ walletTag:
13
+ description: 'Wallet tag (docker)'
14
+ required: true
15
+ default: 'dev-master-shelley'
6
16
 
7
17
  jobs:
8
18
  test:
@@ -11,24 +21,54 @@ jobs:
11
21
 
12
22
  steps:
13
23
  - uses: actions/checkout@v2
14
- - name: Set up cardano-wallet
15
- run: NODE_CONFIG_PATH=`pwd`/spec/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
24
+
25
+ - name: Cache node db
26
+ id: cache
27
+ uses: actions/cache@v2
21
28
  with:
22
- ruby-version: 2.6
29
+ path: ~/node-db-nightly-docker
30
+ key: ${{ runner.os }}-node-db-nightly-docker-tests-${{ hashFiles('**/protocolMagicId') }}
31
+
32
+ - name: Set up cardano-wallet and cardano-node MANUAL
33
+ if: ${{ github.event.inputs.walletTag != '' && github.event.inputs.nodeTag != ''}}
34
+ env:
35
+ WALLET: ${{ github.event.inputs.walletTag }}
36
+ NODE: ${{ github.event.inputs.nodeTag }}
37
+ run: |
38
+ echo "Wallet: $WALLET"
39
+ echo "Node: $NODE"
40
+ NODE_CONFIG_PATH=`pwd`/spec/testnet docker-compose -f docker-compose-shelley.yml up --detach
41
+ docker run --rm inputoutput/cardano-wallet:$WALLET version
42
+ docker run --rm inputoutput/cardano-node:$NODE version
43
+ ls ~/node-db-nightly-docker
44
+
45
+ - name: Set up cardano-wallet and cardano-node NIGHTLY
46
+ if: ${{ github.event.inputs.walletTag == '' && github.event.inputs.nodeTag == ''}}
47
+ run: |
48
+ echo "Wallet: $WALLET"
49
+ echo "Node: $NODE"
50
+ NODE_CONFIG_PATH=`pwd`/spec/testnet docker-compose -f docker-compose-shelley.yml up --detach
51
+ docker run --rm inputoutput/cardano-wallet:$WALLET version
52
+ docker run --rm inputoutput/cardano-node:$NODE version
53
+ ls ~/node-db-nightly-docker
54
+
55
+ - name: Set up Ruby
56
+ uses: ruby/setup-ruby@v1
57
+
23
58
  - name: Install dependencies
24
59
  run: bundle install
60
+
25
61
  - name: Wait until node is synced
26
62
  run: bundle exec rake wait_until_node_synced
63
+
27
64
  - name: Run all tests
28
65
  run: bundle exec rspec .
66
+
67
+ - name: Stop docker-compose
68
+ run: NODE_CONFIG_PATH=`pwd`/spec/testnet docker-compose -f docker-compose-shelley.yml down
29
69
  env:
30
70
  CI: true
31
71
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
32
72
  NETWORK: testnet
33
73
  WALLET: dev-master-shelley
34
- NODE: 1.21.1
74
+ NODE: 1.25.1
@@ -1,10 +1,3 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
1
  name: Tests
9
2
 
10
3
  on:
@@ -12,6 +5,7 @@ on:
12
5
  branches: [ master ]
13
6
  pull_request:
14
7
  branches: [ master ]
8
+ workflow_dispatch:
15
9
 
16
10
  jobs:
17
11
  test:
@@ -20,22 +14,37 @@ jobs:
20
14
 
21
15
  steps:
22
16
  - uses: actions/checkout@v2
23
- - name: Set up cardano-wallet
24
- run: NODE_CONFIG_PATH=`pwd`/spec/testnet docker-compose -f docker-compose-shelley.yml up --detach
25
- - name: Set up Ruby
26
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
27
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
28
- # uses: ruby/setup-ruby@v1
29
- uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
17
+
18
+ - name: Cache node db
19
+ id: cache
20
+ uses: actions/cache@v2
30
21
  with:
31
- ruby-version: 2.6
22
+ path: ~/node-db-nightly-docker
23
+ key: ${{ runner.os }}-node-db-tests-docker-${{ hashFiles('**/protocolMagicId') }}
24
+
25
+ - name: Set up cardano-wallet and cardano-node
26
+ run: |
27
+ echo "Wallet: $WALLET"
28
+ echo "Node: $NODE"
29
+ NODE_CONFIG_PATH=`pwd`/spec/testnet docker-compose -f docker-compose-shelley.yml up --detach
30
+ docker run --rm inputoutput/cardano-wallet:$WALLET version
31
+ docker run --rm inputoutput/cardano-node:$NODE version
32
+ ls ~/node-db-nightly-docker
33
+
34
+ - name: Set up Ruby
35
+ uses: ruby/setup-ruby@v1
36
+
32
37
  - name: Install dependencies
33
38
  run: bundle install
39
+
34
40
  - name: Run all tests except nighlty
35
- run: bundle exec rspec . -t ~nightly
41
+ run: rspec . -t ~nightly
42
+
43
+ - name: Stop docker-compose
44
+ run: NODE_CONFIG_PATH=`pwd`/spec/testnet docker-compose -f docker-compose-shelley.yml down
36
45
  env:
37
46
  CI: true
38
47
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
39
48
  NETWORK: testnet
40
49
  WALLET: dev-master-shelley
41
- NODE: 1.21.1
50
+ NODE: 1.25.1
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.7.1
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'rake', '~> 12.3'
33
33
  spec.add_development_dependency 'rspec', '~> 3.7'
34
34
  spec.add_development_dependency 'bip_mnemonic', '~> 0.0.4'
35
- spec.add_development_dependency 'codecov', '~> 0.2.8'
35
+ spec.add_development_dependency 'codecov', '0.2.8'
36
36
  spec.add_development_dependency 'simplecov'
37
37
 
38
38
  end
data/dev CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  NETWORK=testnet \
4
4
  WALLET=dev-master-shelley \
5
- NODE=1.20.0 \
5
+ NODE=1.24.2 \
6
6
  NODE_CONFIG_PATH=`pwd`/spec/testnet \
7
7
  docker-compose -f docker-compose-shelley.yml \
8
8
  $1 $2 $3 $4
@@ -4,7 +4,7 @@ services:
4
4
  cardano-node:
5
5
  image: inputoutput/cardano-node:${NODE}
6
6
  volumes:
7
- - node-db:/data
7
+ - ~/node-db-nightly-docker:/data
8
8
  - node-ipc:/ipc
9
9
  - ${NODE_CONFIG_PATH}:/config
10
10
  command: run --socket-path /ipc/node.socket --config /config/${NETWORK}-config.json --topology /config/${NETWORK}-topology.json --database-path /data
@@ -22,6 +22,5 @@ services:
22
22
  restart: on-failure
23
23
 
24
24
  volumes:
25
- node-db:
26
25
  wallet-shelley-db:
27
26
  node-ipc:
@@ -39,6 +39,29 @@ module CardanoWallet
39
39
  def migrations
40
40
  Migrations.new @opt
41
41
  end
42
+
43
+ # API for Assets
44
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Assets
45
+ def assets
46
+ Assets.new @opt
47
+ end
48
+ end
49
+
50
+ class Assets < Base
51
+ def initialize opt
52
+ super
53
+ end
54
+
55
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listByronAssets
56
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getByronAsset
57
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getByronAssetDefault
58
+ def get(wid, policy_id = nil, asset_name = nil)
59
+ ep = "/byron-wallets/#{wid}/assets"
60
+ ep += "/#{policy_id}" if policy_id
61
+ ep += "/#{asset_name}" if asset_name
62
+ self.class.get(ep)
63
+ end
64
+
42
65
  end
43
66
 
44
67
  # Byron wallets
@@ -182,8 +205,14 @@ module CardanoWallet
182
205
  #
183
206
  # @example
184
207
  # random(wid, [{addr1: 1000000}, {addr2: 1000000}])
208
+ # random(wid, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])
185
209
  def random(wid, payments)
186
- payments_formatted = Utils.format_payments(payments)
210
+ Utils.verify_param_is_array!(payments)
211
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
212
+ payments_formatted = payments
213
+ else
214
+ payments_formatted = Utils.format_payments(payments)
215
+ end
187
216
  self.class.post("/byron-wallets/#{wid}/coin-selections/random",
188
217
  :body => {:payments => payments_formatted}.to_json,
189
218
  :headers => { 'Content-Type' => 'application/json' })
@@ -221,8 +250,15 @@ module CardanoWallet
221
250
  #
222
251
  # @example
223
252
  # create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}])
253
+ # create(wid, passphrase, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])
254
+
224
255
  def create(wid, passphrase, payments)
225
- payments_formatted = Utils.format_payments(payments)
256
+ Utils.verify_param_is_array!(payments)
257
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
258
+ payments_formatted = payments
259
+ else
260
+ payments_formatted = Utils.format_payments(payments)
261
+ end
226
262
  self.class.post("/byron-wallets/#{wid}/transactions",
227
263
  :body => { :payments => payments_formatted,
228
264
  :passphrase => passphrase
@@ -235,8 +271,14 @@ module CardanoWallet
235
271
  #
236
272
  # @example
237
273
  # payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}])
274
+ # payment_fees(wid, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])
238
275
  def payment_fees(wid, payments)
239
- payments_formatted = Utils.format_payments(payments)
276
+ Utils.verify_param_is_array!(payments)
277
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
278
+ payments_formatted = payments
279
+ else
280
+ payments_formatted = Utils.format_payments(payments)
281
+ end
240
282
  self.class.post("/byron-wallets/#{wid}/payment-fees",
241
283
  :body => { :payments => payments_formatted }.to_json,
242
284
  :headers => { 'Content-Type' => 'application/json' } )
@@ -117,6 +117,16 @@ module CardanoWallet
117
117
  'Accept' => 'application/json'} )
118
118
  end
119
119
 
120
+ # Current SMASH health
121
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getCurrentSmashHealth
122
+ #
123
+ # @example
124
+ # smash_health({url: "https://smash.cardano-mainnet.iohk.io/"})
125
+ def smash_health(q = {})
126
+ q.empty? ? query = '' : query = CardanoWallet::Utils.to_query(q)
127
+ self.class.get("/smash/health#{query}")
128
+ end
129
+
120
130
  end
121
131
 
122
132
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Proxy
@@ -54,6 +54,29 @@ module CardanoWallet
54
54
  Keys.new @opt
55
55
  end
56
56
 
57
+ # API for Assets
58
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Assets
59
+ def assets
60
+ Assets.new @opt
61
+ end
62
+
63
+ end
64
+
65
+ class Assets < Base
66
+ def initialize opt
67
+ super
68
+ end
69
+
70
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listAssets
71
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getAsset
72
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getAssetDefault
73
+ def get(wid, policy_id = nil, asset_name = nil)
74
+ ep = "/wallets/#{wid}/assets"
75
+ ep += "/#{policy_id}" if policy_id
76
+ ep += "/#{asset_name}" if asset_name
77
+ self.class.get(ep)
78
+ end
79
+
57
80
  end
58
81
 
59
82
  class Keys < Base
@@ -77,6 +100,15 @@ module CardanoWallet
77
100
  self.class.get("/wallets/#{wid}/keys/#{role}/#{index}")
78
101
  end
79
102
 
103
+ # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/postAccountKey
104
+ def create_acc_public_key(wid, index, pass, extended)
105
+ payload = { passphrase: pass, extended: extended }
106
+ self.class.post("/wallets/#{wid}/keys/#{index}",
107
+ :body => payload.to_json,
108
+ :headers => { 'Content-Type' => 'application/json' }
109
+ )
110
+ end
111
+
80
112
  end
81
113
 
82
114
  # API for Wallets
@@ -188,8 +220,14 @@ module CardanoWallet
188
220
  #
189
221
  # @example
190
222
  # random(wid, [{addr1: 1000000}, {addr2: 1000000}])
223
+ # random(wid, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])
191
224
  def random(wid, payments)
192
- payments_formatted = Utils.format_payments(payments)
225
+ Utils.verify_param_is_array!(payments)
226
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
227
+ payments_formatted = payments
228
+ else
229
+ payments_formatted = Utils.format_payments(payments)
230
+ end
193
231
  self.class.post("/wallets/#{wid}/coin-selections/random",
194
232
  :body => {:payments => payments_formatted}.to_json,
195
233
  :headers => { 'Content-Type' => 'application/json' })
@@ -202,7 +240,7 @@ module CardanoWallet
202
240
  # random(wid, {action: "join", pool: "poolid"})
203
241
  # random(wid, {action: "quit"})
204
242
  def random_deleg(wid, deleg_action)
205
- payments_formatted = Utils.verify_param_is_hash!(deleg_action)
243
+ Utils.verify_param_is_hash!(deleg_action)
206
244
  self.class.post("/wallets/#{wid}/coin-selections/random",
207
245
  :body => {:delegation_action => deleg_action}.to_json,
208
246
  :headers => { 'Content-Type' => 'application/json' })
@@ -236,15 +274,21 @@ module CardanoWallet
236
274
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction
237
275
  # @param wid [String] source wallet id
238
276
  # @param passphrase [String] source wallet's passphrase
239
- # @param payments [Array of Hashes] addres, amount pair
277
+ # @param payments [Array of Hashes] address / amount list or full payments payload with assets
240
278
  # @param withdrawal [String or Array] 'self' or mnemonic sentence
241
279
  # @param metadata [Hash] special metadata JSON subset format (cf: https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction)
242
280
  # @param ttl [Int] transaction's time-to-live in seconds
243
281
  #
244
282
  # @example
245
283
  # create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}], 'self', {"1": "abc"}, ttl = 10)
284
+ # create(wid, passphrase, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ], 'self', {"1": "abc"}, ttl = 10)
246
285
  def create(wid, passphrase, payments, withdrawal = nil, metadata = nil, ttl = nil)
247
- payments_formatted = Utils.format_payments(payments)
286
+ Utils.verify_param_is_array!(payments)
287
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
288
+ payments_formatted = payments
289
+ else
290
+ payments_formatted = Utils.format_payments(payments)
291
+ end
248
292
  payload = { :payments => payments_formatted,
249
293
  :passphrase => passphrase
250
294
  }
@@ -262,8 +306,15 @@ module CardanoWallet
262
306
  #
263
307
  # @example
264
308
  # payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}], {"1": "abc"}, ttl = 10)
309
+ # payment_fees(wid, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ], {"1": "abc"}, ttl = 10)
265
310
  def payment_fees(wid, payments, withdrawal = nil, metadata = nil, ttl = nil)
266
- payments_formatted = Utils.format_payments(payments)
311
+ Utils.verify_param_is_array!(payments)
312
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
313
+ payments_formatted = payments
314
+ else
315
+ payments_formatted = Utils.format_payments(payments)
316
+ end
317
+
267
318
  payload = { :payments => payments_formatted }
268
319
 
269
320
  payload[:withdrawal] = withdrawal if withdrawal
@@ -289,6 +340,24 @@ module CardanoWallet
289
340
  super
290
341
  end
291
342
 
343
+ # Stake pools maintenance actions
344
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postMaintenanceAction
345
+ #
346
+ # @example
347
+ # maintenance_action({ "maintenance_action": "gc_stake_pools" })
348
+ def trigger_maintenance_actions(action = {})
349
+ Utils.verify_param_is_hash!(action)
350
+ self.class.post("/stake-pools/maintenance-actions",
351
+ :body => action.to_json,
352
+ :headers => { 'Content-Type' => 'application/json' } )
353
+ end
354
+
355
+ # Metdata GC Status
356
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getMaintenanceActions
357
+ def view_maintenance_actions
358
+ self.class.get("/stake-pools/maintenance-actions")
359
+ end
360
+
292
361
  # List all stake pools
293
362
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listStakePools
294
363
  def list(stake = {})
@@ -1,3 +1,3 @@
1
1
  module CardanoWallet
2
- VERSION = "0.2.6"
2
+ VERSION = "0.3.1"
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.2.6
4
+ version: 0.3.1
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-11-06 00:00:00.000000000 Z
11
+ date: 2021-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -70,14 +70,14 @@ dependencies:
70
70
  name: codecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.2.8
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.2.8
83
83
  - !ruby/object:Gem::Dependency
@@ -107,6 +107,7 @@ files:
107
107
  - ".gitignore"
108
108
  - ".rakeTasks"
109
109
  - ".rspec"
110
+ - ".ruby-version"
110
111
  - CODE_OF_CONDUCT.md
111
112
  - Gemfile
112
113
  - LICENSE.txt
@@ -147,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  - !ruby/object:Gem::Version
148
149
  version: '0'
149
150
  requirements: []
150
- rubygems_version: 3.1.4
151
+ rubygems_version: 3.2.3
151
152
  signing_key:
152
153
  specification_version: 4
153
154
  summary: Ruby wrapper over cardano-wallet.