cardano_wallet 0.2.5 → 0.3.0

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: 880714f1f46b46a2b97b2ba99700acfc06c576df55fb457a852152832d964c4e
4
- data.tar.gz: 35964e6bb0356db5f0ae855efc60694857f4987c537e9b563dda8b3253883b2b
3
+ metadata.gz: d0de7182a62723fefbe32712a08ac13765fe4507ac90969d3b752aff67fb05af
4
+ data.tar.gz: e6346e28024ce715b14ab9964634f4dc5bf80f7d63526bae0a6c4bc4d2bce22f
5
5
  SHA512:
6
- metadata.gz: 747a1f8a8c669547c8a076ac8adcbdc463355c094522f2ac50fdae69afba4f22d3aa443fe7d7c1e1b80064699b5fcfcd2b1fa4ad03397ba699f5fba80a645929
7
- data.tar.gz: 78ce365d4ae47bc8b406d719a66e387eb9c26256286f8babbd1ac3499820c3d534b5ce491d7ce745d8267aa9df2b33e4f4fa60cbedb9d4b660faa5aa54002b28
6
+ metadata.gz: d2e7311a7a4ef549aae1f9fb571f1ccc7e84800b9ffe10b80f08b23586a3e2cadd73aefb3215ad1bef28e5f8f09198323fafb01a4d0f3053770dd27d087f1281
7
+ data.tar.gz: 3e4df4399289e3772061e4e8e68cae38a58308cbfb837b940af4736e36b1052884791cc641811a3b987307f75075e8df306bd0778683e83acf1479edd760a381
@@ -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
@@ -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
@@ -221,8 +244,14 @@ module CardanoWallet
221
244
  #
222
245
  # @example
223
246
  # create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}])
247
+ # create(wid, passphrase, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])
248
+
224
249
  def create(wid, passphrase, payments)
225
- payments_formatted = Utils.format_payments(payments)
250
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
251
+ payments_formatted = payments
252
+ else
253
+ payments_formatted = Utils.format_payments(payments)
254
+ end
226
255
  self.class.post("/byron-wallets/#{wid}/transactions",
227
256
  :body => { :payments => payments_formatted,
228
257
  :passphrase => passphrase
@@ -235,8 +264,13 @@ module CardanoWallet
235
264
  #
236
265
  # @example
237
266
  # payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}])
267
+ # payment_fees(wid, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])
238
268
  def payment_fees(wid, payments)
239
- payments_formatted = Utils.format_payments(payments)
269
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
270
+ payments_formatted = payments
271
+ else
272
+ payments_formatted = Utils.format_payments(payments)
273
+ end
240
274
  self.class.post("/byron-wallets/#{wid}/payment-fees",
241
275
  :body => { :payments => payments_formatted }.to_json,
242
276
  :headers => { 'Content-Type' => 'application/json' } )
@@ -95,8 +95,7 @@ module CardanoWallet
95
95
 
96
96
  self.class.post("/wallets/#{wid}/signatures/#{role}/#{index}",
97
97
  :body => payload.to_json,
98
- :headers => { 'Content-Type' => 'application/json',
99
- 'Accept' => 'application/octet-stream'} )
98
+ :headers => { 'Content-Type' => 'application/json' } )
100
99
  end
101
100
 
102
101
  # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/getWalletKey
@@ -109,6 +108,25 @@ module CardanoWallet
109
108
  self.class.get("/addresses/#{address_id}")
110
109
  end
111
110
 
111
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postAnyAddress
112
+ def post_address(payload)
113
+ CardanoWallet::Utils.verify_param_is_hash!(payload)
114
+ self.class.post("/addresses",
115
+ :body => payload.to_json,
116
+ :headers => { 'Content-Type' => 'application/json',
117
+ 'Accept' => 'application/json'} )
118
+ end
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
+
112
130
  end
113
131
 
114
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
@@ -202,7 +234,7 @@ module CardanoWallet
202
234
  # random(wid, {action: "join", pool: "poolid"})
203
235
  # random(wid, {action: "quit"})
204
236
  def random_deleg(wid, deleg_action)
205
- payments_formatted = Utils.verify_param_is_hash!(deleg_action)
237
+ Utils.verify_param_is_hash!(deleg_action)
206
238
  self.class.post("/wallets/#{wid}/coin-selections/random",
207
239
  :body => {:delegation_action => deleg_action}.to_json,
208
240
  :headers => { 'Content-Type' => 'application/json' })
@@ -236,15 +268,20 @@ module CardanoWallet
236
268
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction
237
269
  # @param wid [String] source wallet id
238
270
  # @param passphrase [String] source wallet's passphrase
239
- # @param payments [Array of Hashes] addres, amount pair
271
+ # @param payments [Array of Hashes] address / amount list or full payments payload with assets
240
272
  # @param withdrawal [String or Array] 'self' or mnemonic sentence
241
273
  # @param metadata [Hash] special metadata JSON subset format (cf: https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction)
242
274
  # @param ttl [Int] transaction's time-to-live in seconds
243
275
  #
244
276
  # @example
245
277
  # create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}], 'self', {"1": "abc"}, ttl = 10)
278
+ # 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
279
  def create(wid, passphrase, payments, withdrawal = nil, metadata = nil, ttl = nil)
247
- payments_formatted = Utils.format_payments(payments)
280
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
281
+ payments_formatted = payments
282
+ else
283
+ payments_formatted = Utils.format_payments(payments)
284
+ end
248
285
  payload = { :payments => payments_formatted,
249
286
  :passphrase => passphrase
250
287
  }
@@ -262,8 +299,14 @@ module CardanoWallet
262
299
  #
263
300
  # @example
264
301
  # payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}], {"1": "abc"}, ttl = 10)
302
+ # payment_fees(wid, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ], {"1": "abc"}, ttl = 10)
265
303
  def payment_fees(wid, payments, withdrawal = nil, metadata = nil, ttl = nil)
266
- payments_formatted = Utils.format_payments(payments)
304
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
305
+ payments_formatted = payments
306
+ else
307
+ payments_formatted = Utils.format_payments(payments)
308
+ end
309
+
267
310
  payload = { :payments => payments_formatted }
268
311
 
269
312
  payload[:withdrawal] = withdrawal if withdrawal
@@ -289,6 +332,24 @@ module CardanoWallet
289
332
  super
290
333
  end
291
334
 
335
+ # Stake pools maintenance actions
336
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postMaintenanceAction
337
+ #
338
+ # @example
339
+ # maintenance_action({ "maintenance_action": "gc_stake_pools" })
340
+ def trigger_maintenance_actions(action = {})
341
+ Utils.verify_param_is_hash!(action)
342
+ self.class.post("/stake-pools/maintenance-actions",
343
+ :body => action.to_json,
344
+ :headers => { 'Content-Type' => 'application/json' } )
345
+ end
346
+
347
+ # Metdata GC Status
348
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getMaintenanceActions
349
+ def view_maintenance_actions
350
+ self.class.get("/stake-pools/maintenance-actions")
351
+ end
352
+
292
353
  # List all stake pools
293
354
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listStakePools
294
355
  def list(stake = {})
@@ -1,3 +1,3 @@
1
1
  module CardanoWallet
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.0"
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.5
4
+ version: 0.3.0
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-03 00:00:00.000000000 Z
11
+ date: 2021-01-29 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.