cardano_wallet 0.2.7 → 0.3.2

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: c115a916adbed97481aa950e6c15a6e8609117a68549112dcc18d60300e47657
4
- data.tar.gz: e3cd4ce44ea58b62349bc29e14faf51dfe3b6f69a4135c3dcf6e5575c26bbbfd
3
+ metadata.gz: 36d3287106ec62dbb1ce9d909645f5e30710b4bcef36d1377ee90a63f73f6dfb
4
+ data.tar.gz: b020e0372998c38ea574b6078402f4a0f15c7a7e87172a1871bb878512b397ae
5
5
  SHA512:
6
- metadata.gz: 9d2f7768e00ead4a2cf7b7b463dc3bdea8ac5794dc4a7ef3604dcd31c1663052c2493b382f100acaf9f5dcf1afb996c68da2e74f5720022d70126864a2d26e03
7
- data.tar.gz: 0e353d9082d2f22cce803ab1f38de10a364dbbb936b6f720a93aaaa88584cf326b9d2d969b0fce495cd9cabefe8118be0e5aec5600ed4083d5748aa273153e48
6
+ metadata.gz: b887638f175e47ad6dd9a42b21a84654260e06eada82218eba10a985c5da80882bc65487317be2a19356f6ce2d849dab093cf439fc13b0266f444494b35d2979
7
+ data.tar.gz: 8274bf5c20ce7e38b99fe0cfc4ba5684507cdd5c4dd3800ecd30712f9c8ab3803b1301cec72803da472bee259943be45280aafae5dfe5cdd66348c1ba4ede5b4
@@ -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
@@ -18,10 +18,9 @@ services:
18
18
  - ${NODE_CONFIG_PATH}:/config
19
19
  ports:
20
20
  - 8090:8090
21
- command: serve --testnet /config/${NETWORK}-byron-genesis.json --node-socket /ipc/node.socket --database /wallet-db --listen-address 0.0.0.0
21
+ command: serve --testnet /config/${NETWORK}-byron-genesis.json --node-socket /ipc/node.socket --database /wallet-db --listen-address 0.0.0.0 --token-metadata-server http://metadata-server-mock.herokuapp.com/
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,10 +220,20 @@ module CardanoWallet
188
220
  #
189
221
  # @example
190
222
  # random(wid, [{addr1: 1000000}, {addr2: 1000000}])
191
- def random(wid, payments)
192
- payments_formatted = Utils.format_payments(payments)
223
+ # random(wid, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])
224
+ def random(wid, payments, withdrawal = nil, metadata = nil)
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
231
+ payload = { :payments => payments_formatted }
232
+ payload[:withdrawal] = withdrawal if withdrawal
233
+ payload[:metadata] = metadata if metadata
234
+
193
235
  self.class.post("/wallets/#{wid}/coin-selections/random",
194
- :body => {:payments => payments_formatted}.to_json,
236
+ :body => payload.to_json,
195
237
  :headers => { 'Content-Type' => 'application/json' })
196
238
  end
197
239
 
@@ -236,15 +278,21 @@ module CardanoWallet
236
278
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction
237
279
  # @param wid [String] source wallet id
238
280
  # @param passphrase [String] source wallet's passphrase
239
- # @param payments [Array of Hashes] addres, amount pair
281
+ # @param payments [Array of Hashes] address / amount list or full payments payload with assets
240
282
  # @param withdrawal [String or Array] 'self' or mnemonic sentence
241
283
  # @param metadata [Hash] special metadata JSON subset format (cf: https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction)
242
284
  # @param ttl [Int] transaction's time-to-live in seconds
243
285
  #
244
286
  # @example
245
287
  # create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}], 'self', {"1": "abc"}, ttl = 10)
288
+ # 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
289
  def create(wid, passphrase, payments, withdrawal = nil, metadata = nil, ttl = nil)
247
- payments_formatted = Utils.format_payments(payments)
290
+ Utils.verify_param_is_array!(payments)
291
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
292
+ payments_formatted = payments
293
+ else
294
+ payments_formatted = Utils.format_payments(payments)
295
+ end
248
296
  payload = { :payments => payments_formatted,
249
297
  :passphrase => passphrase
250
298
  }
@@ -262,8 +310,15 @@ module CardanoWallet
262
310
  #
263
311
  # @example
264
312
  # payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}], {"1": "abc"}, ttl = 10)
313
+ # payment_fees(wid, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ], {"1": "abc"}, ttl = 10)
265
314
  def payment_fees(wid, payments, withdrawal = nil, metadata = nil, ttl = nil)
266
- payments_formatted = Utils.format_payments(payments)
315
+ Utils.verify_param_is_array!(payments)
316
+ if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")}
317
+ payments_formatted = payments
318
+ else
319
+ payments_formatted = Utils.format_payments(payments)
320
+ end
321
+
267
322
  payload = { :payments => payments_formatted }
268
323
 
269
324
  payload[:withdrawal] = withdrawal if withdrawal
@@ -1,3 +1,3 @@
1
1
  module CardanoWallet
2
- VERSION = "0.2.7"
2
+ VERSION = "0.3.2"
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.7
4
+ version: 0.3.2
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-12 00:00:00.000000000 Z
11
+ date: 2021-02-18 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.