cardano_wallet 0.2.0 → 0.2.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: 00a386b2276f8b8373cd9a89cebdba30a5f151c2b32cee0ae3d8915a6daee980
4
- data.tar.gz: 10094b3fb16e9c9e71e61409a314b06d94dd140c01f79641e8bce9dafa21fccc
3
+ metadata.gz: 880714f1f46b46a2b97b2ba99700acfc06c576df55fb457a852152832d964c4e
4
+ data.tar.gz: 35964e6bb0356db5f0ae855efc60694857f4987c537e9b563dda8b3253883b2b
5
5
  SHA512:
6
- metadata.gz: ff0b9ac1b5071acee4be8ad9830adbe082fb01587e4593fa868ed7dd47552609e04ed3a382a47abedba658340a4cad4e25506ad9f0db73e6b6f7f35fe23621a8
7
- data.tar.gz: 19e1aad7916ec508822a48e1ac38996236874236c8d7849754fed3922444bae0396c955d62a4a06a11e4aafefbeb33b494035c5e9026aefa36a5885a7d3495ca
6
+ metadata.gz: 747a1f8a8c669547c8a076ac8adcbdc463355c094522f2ac50fdae69afba4f22d3aa443fe7d7c1e1b80064699b5fcfcd2b1fa4ad03397ba699f5fba80a645929
7
+ data.tar.gz: 78ce365d4ae47bc8b406d719a66e387eb9c26256286f8babbd1ac3499820c3d534b5ce491d7ce745d8267aa9df2b33e4f4fa60cbedb9d4b660faa5aa54002b28
@@ -31,4 +31,4 @@ jobs:
31
31
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
32
32
  NETWORK: testnet
33
33
  WALLET: dev-master-shelley
34
- NODE: 1.20.0
34
+ NODE: 1.21.1
@@ -38,4 +38,4 @@ jobs:
38
38
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
39
39
  NETWORK: testnet
40
40
  WALLET: dev-master-shelley
41
- NODE: 1.20.0
41
+ NODE: 1.21.1
data/README.md CHANGED
@@ -65,7 +65,6 @@ CW = CardanoWallet.new
65
65
  BYRON = CW.byron
66
66
  SHELLEY = CW.shelley
67
67
  MISC = CW.misc
68
- PROXY = CW.proxy
69
68
 
70
69
  #Byron
71
70
  BYRON.wallets.list.each_with_index do |wal, i|
@@ -82,9 +81,8 @@ SHELLEY.wallets.get(w['id'])
82
81
  #Misc
83
82
  MISC.network.information
84
83
  MISC.network.clock
85
-
86
- #Proxy
87
- PROXY.submit_external_transaction(File.new("/tmp/blob.bin").read)
84
+ MISC.proxy.submit_external_transaction(File.new("/tmp/blob.bin").read)
85
+ MISC.utils.addresses("addr_test1vqrlltfahghjxl5sy5h5mvfrrlt6me5fqphhwjqvj5jd88cccqcek")
88
86
  ```
89
87
 
90
88
  Refer to [documentation](https://rubydoc.info/gems/cardano_wallet) for more details.
data/dev CHANGED
@@ -1 +1,8 @@
1
- NETWORK=testnet WALLET=dev-master-shelley NODE=1.19.1 NODE_CONFIG_PATH=`pwd`/spec/testnet docker-compose -f docker-compose-shelley.yml $1
1
+ #!/bin/sh
2
+
3
+ NETWORK=testnet \
4
+ WALLET=dev-master-shelley \
5
+ NODE=1.20.0 \
6
+ NODE_CONFIG_PATH=`pwd`/spec/testnet \
7
+ docker-compose -f docker-compose-shelley.yml \
8
+ $1 $2 $3 $4
@@ -181,7 +181,7 @@ module CardanoWallet
181
181
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/byronSelectCoins
182
182
  #
183
183
  # @example
184
- # random(wid, {address1: 123, address2: 456})
184
+ # random(wid, [{addr1: 1000000}, {addr2: 1000000}])
185
185
  def random(wid, payments)
186
186
  payments_formatted = Utils.format_payments(payments)
187
187
  self.class.post("/byron-wallets/#{wid}/coin-selections/random",
@@ -217,10 +217,10 @@ module CardanoWallet
217
217
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postByronTransaction
218
218
  # @param wid [String] source wallet id
219
219
  # @param passphrase [String] source wallet's passphrase
220
- # @param payments [Hash] addres, amount pair
220
+ # @param payments [Array of Hashes] addres, amount pair
221
221
  #
222
222
  # @example
223
- # create(wid, passphrase, {addr1: 1000000})
223
+ # create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}])
224
224
  def create(wid, passphrase, payments)
225
225
  payments_formatted = Utils.format_payments(payments)
226
226
  self.class.post("/byron-wallets/#{wid}/transactions",
@@ -234,7 +234,7 @@ module CardanoWallet
234
234
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransactionFee
235
235
  #
236
236
  # @example
237
- # payment_fees(wid, {addr1: 1000000})
237
+ # payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}])
238
238
  def payment_fees(wid, payments)
239
239
  payments_formatted = Utils.format_payments(payments)
240
240
  self.class.post("/byron-wallets/#{wid}/payment-fees",
@@ -25,6 +25,34 @@ module CardanoWallet
25
25
  def proxy
26
26
  Proxy.new @opt
27
27
  end
28
+
29
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Settings
30
+ def settings
31
+ Settings.new @opt
32
+ end
33
+
34
+ end
35
+
36
+ # API for Network
37
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Settings
38
+ class Settings < Base
39
+ def initialize opt
40
+ super
41
+ end
42
+
43
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getSettings
44
+ def get
45
+ self.class.get("/settings")
46
+ end
47
+
48
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/putSettings
49
+ def update(params)
50
+ CardanoWallet::Utils.verify_param_is_hash!(params)
51
+ self.class.put("/settings",
52
+ :body => {"settings" => params}.to_json,
53
+ :headers => { 'Content-Type' => 'application/json' }
54
+ )
55
+ end
28
56
  end
29
57
 
30
58
  # API for Network
@@ -60,6 +88,22 @@ module CardanoWallet
60
88
  super
61
89
  end
62
90
 
91
+ # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/signMetadata
92
+ def sign_metadata(wid, role, index, pass, metadata)
93
+ payload = { passphrase: pass }
94
+ payload[:metadata] = metadata if metadata
95
+
96
+ self.class.post("/wallets/#{wid}/signatures/#{role}/#{index}",
97
+ :body => payload.to_json,
98
+ :headers => { 'Content-Type' => 'application/json',
99
+ 'Accept' => 'application/octet-stream'} )
100
+ end
101
+
102
+ # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/getWalletKey
103
+ def get_public_key(wid, role, index)
104
+ self.class.get("/wallets/#{wid}/keys/#{role}/#{index}")
105
+ end
106
+
63
107
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/inspectAddress
64
108
  def addresses(address_id)
65
109
  self.class.get("/addresses/#{address_id}")
@@ -48,6 +48,35 @@ module CardanoWallet
48
48
  Migrations.new @opt
49
49
  end
50
50
 
51
+ # API for Keys
52
+ # @see https://input-output-hk.github.io/cardano-wallet/api/#tag/Keys
53
+ def keys
54
+ Keys.new @opt
55
+ end
56
+
57
+ end
58
+
59
+ class Keys < Base
60
+ def initialize opt
61
+ super
62
+ end
63
+
64
+ # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/signMetadata
65
+ def sign_metadata(wid, role, index, pass, metadata)
66
+ payload = { passphrase: pass }
67
+ payload[:metadata] = metadata if metadata
68
+
69
+ self.class.post("/wallets/#{wid}/signatures/#{role}/#{index}",
70
+ :body => payload.to_json,
71
+ :headers => { 'Content-Type' => 'application/json',
72
+ 'Accept' => 'application/octet-stream'} )
73
+ end
74
+
75
+ # @see https://input-output-hk.github.io/cardano-wallet/api/#operation/getWalletKey
76
+ def get_public_key(wid, role, index)
77
+ self.class.get("/wallets/#{wid}/keys/#{role}/#{index}")
78
+ end
79
+
51
80
  end
52
81
 
53
82
  # API for Wallets
@@ -158,13 +187,26 @@ module CardanoWallet
158
187
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/selectCoins
159
188
  #
160
189
  # @example
161
- # random(wid, {address1: 123, address2: 456})
190
+ # random(wid, [{addr1: 1000000}, {addr2: 1000000}])
162
191
  def random(wid, payments)
163
192
  payments_formatted = Utils.format_payments(payments)
164
193
  self.class.post("/wallets/#{wid}/coin-selections/random",
165
194
  :body => {:payments => payments_formatted}.to_json,
166
195
  :headers => { 'Content-Type' => 'application/json' })
167
196
  end
197
+
198
+ # Coin selection -> Delegation action
199
+ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/selectCoins
200
+ #
201
+ # @example
202
+ # random(wid, {action: "join", pool: "poolid"})
203
+ # random(wid, {action: "quit"})
204
+ def random_deleg(wid, deleg_action)
205
+ payments_formatted = Utils.verify_param_is_hash!(deleg_action)
206
+ self.class.post("/wallets/#{wid}/coin-selections/random",
207
+ :body => {:delegation_action => deleg_action}.to_json,
208
+ :headers => { 'Content-Type' => 'application/json' })
209
+ end
168
210
  end
169
211
 
170
212
  # API for Transactions
@@ -194,19 +236,21 @@ module CardanoWallet
194
236
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction
195
237
  # @param wid [String] source wallet id
196
238
  # @param passphrase [String] source wallet's passphrase
197
- # @param payments [Hash] addres, amount pair
239
+ # @param payments [Array of Hashes] addres, amount pair
198
240
  # @param withdrawal [String or Array] 'self' or mnemonic sentence
199
241
  # @param metadata [Hash] special metadata JSON subset format (cf: https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction)
242
+ # @param ttl [Int] transaction's time-to-live in seconds
200
243
  #
201
244
  # @example
202
- # create(wid, passphrase, {addr1: 1000000}, 'self', {"1": "abc"})
203
- def create(wid, passphrase, payments, withdrawal = nil, metadata = nil)
245
+ # create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}], 'self', {"1": "abc"}, ttl = 10)
246
+ def create(wid, passphrase, payments, withdrawal = nil, metadata = nil, ttl = nil)
204
247
  payments_formatted = Utils.format_payments(payments)
205
248
  payload = { :payments => payments_formatted,
206
249
  :passphrase => passphrase
207
250
  }
208
251
  payload[:withdrawal] = withdrawal if withdrawal
209
252
  payload[:metadata] = metadata if metadata
253
+ payload[:time_to_live] = { quantity: ttl, unit: "second" } if ttl
210
254
 
211
255
  self.class.post("/wallets/#{wid}/transactions",
212
256
  :body => payload.to_json,
@@ -217,13 +261,14 @@ module CardanoWallet
217
261
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransactionFee
218
262
  #
219
263
  # @example
220
- # payment_fees(wid, {addr1: 1000000}, {"1": "abc"})
221
- def payment_fees(wid, payments, withdrawal = nil, metadata = nil)
264
+ # payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}], {"1": "abc"}, ttl = 10)
265
+ def payment_fees(wid, payments, withdrawal = nil, metadata = nil, ttl = nil)
222
266
  payments_formatted = Utils.format_payments(payments)
223
267
  payload = { :payments => payments_formatted }
224
268
 
225
269
  payload[:withdrawal] = withdrawal if withdrawal
226
270
  payload[:metadata] = metadata if metadata
271
+ payload[:time_to_live] = { quantity: ttl, unit: "second" } if ttl
227
272
 
228
273
  self.class.post("/wallets/#{wid}/payment-fees",
229
274
  :body => payload.to_json,
@@ -5,13 +5,24 @@ module CardanoWallet
5
5
  raise ArgumentError, "argument should be Hash" unless param.is_a?(Hash)
6
6
  end
7
7
 
8
+ def self.verify_param_is_array!(param)
9
+ raise ArgumentError, "argument should be Array" unless param.is_a?(Array)
10
+ end
11
+
12
+ ##
13
+ # @param payments [Array of Hashes] - [{addr1: 1}, {addr2: 2}]
14
+ # @return [Array of Hashes] - [{:address=>"addr1", :amount=>{:quantity=>1, :unit=>"lovelace"}}, {:address=>"addr2", :amount=>{:quantity=>2, :unit=>"lovelace"}}]
8
15
  def self.format_payments(payments)
9
- verify_param_is_hash!(payments)
10
- payments.collect do |addr, amt|
11
- {:address => addr.to_s,
12
- :amount => {:quantity => amt.to_i,
13
- :unit => "lovelace"}
14
- }
16
+ verify_param_is_array!(payments)
17
+ raise ArgumentError, "argument should be Array of single Hashes" unless payments.all?{|p| p.size == 1 && p.is_a?(Hash)}
18
+ payments.map do |p|
19
+ a = p.collect do |addr, amt|
20
+ {:address => addr.to_s,
21
+ :amount => {:quantity => amt.to_i,
22
+ :unit => "lovelace"}
23
+ }
24
+ end.flatten
25
+ Hash[*a]
15
26
  end
16
27
  end
17
28
 
@@ -1,3 +1,3 @@
1
1
  module CardanoWallet
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.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.2.0
4
+ version: 0.2.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-09-28 00:00:00.000000000 Z
11
+ date: 2020-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -117,7 +117,6 @@ files:
117
117
  - cardano_wallet.gemspec
118
118
  - dev
119
119
  - docker-compose-shelley.yml
120
- - docker-compose.yml
121
120
  - lib/cardano_wallet.rb
122
121
  - lib/cardano_wallet/base.rb
123
122
  - lib/cardano_wallet/byron.rb
@@ -148,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
147
  - !ruby/object:Gem::Version
149
148
  version: '0'
150
149
  requirements: []
151
- rubygems_version: 3.0.3
150
+ rubygems_version: 3.1.4
152
151
  signing_key:
153
152
  specification_version: 4
154
153
  summary: Ruby wrapper over cardano-wallet.
@@ -1,38 +0,0 @@
1
- version: "3.5"
2
-
3
- services:
4
- cardano-node:
5
- image: inputoutput/cardano-node:${NODE}
6
- environment:
7
- NETWORK:
8
- volumes:
9
- - node-${NETWORK}-db:/data
10
- - node-ipc:/ipc
11
- - node-config:/nix/store
12
- restart: on-failure
13
-
14
- cardano-wallet:
15
- image: inputoutput/cardano-wallet:${WALLET}
16
- volumes:
17
- - wallet-${NETWORK}-db:/wallet-db
18
- - node-ipc:/ipc
19
- - node-config:/config
20
- ports:
21
- - 8090:8090
22
- entrypoint: []
23
- command: bash -c "
24
- ([[ $$NETWORK == \"mainnet\" ]] && $$CMD --mainnet) ||
25
- ([[ $$NETWORK == \"testnet\" ]] && $$CMD --testnet /config/*testnet-genesis.json)
26
- "
27
- environment:
28
- CMD: "cardano-wallet-byron serve --node-socket /ipc/node.socket --database /wallet-db --listen-address 0.0.0.0"
29
- NETWORK:
30
- restart: on-failure
31
-
32
- volumes:
33
- node-mainnet-db:
34
- node-testnet-db:
35
- wallet-mainnet-db:
36
- wallet-testnet-db:
37
- node-ipc:
38
- node-config: