cardano_wallet 0.2.1 → 0.2.2

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: 9645ad1a0ae2d27ca495ab48f75ef2988f91172b1282dca5e1787337c6f25e62
4
- data.tar.gz: 1b4d7ed162072bd9b76aaad62430b60eba0d47d1a091f9c6589ae1db715676f2
3
+ metadata.gz: b3d493df353517eb41d713b9b12973fadd1b56da5f17f8a15763181285d13a82
4
+ data.tar.gz: 6848865dea8cd920f95d0268065293aba195e67e4cfd1b1324a62e355e119347
5
5
  SHA512:
6
- metadata.gz: 959d13d2fe332a88704f8151b2fccb627ee4096c698838563351acb3b02fe48bf4ea23361771744991389115314ea2e26ade929f955c3c593a46662a5d1c690f
7
- data.tar.gz: d6ee9ae3c2591ba9a7341ee74ab76141b31bc4471c90cb0a62335208c518c3157c971066f694c8198744f49713365e26f27c3268ef8312fc6c463dcdb1764b8b
6
+ metadata.gz: d02a807c61dad05dd08fc300990702a10ed631a25268735189772e4f54dabb411d4ab5d2688e10333b9d88558a881de1eaf1545cd3a9547cc29bf4f36116f909
7
+ data.tar.gz: 4007b0db748e9f88244257e30a9a939dea56e213eec84fce632b603c1d2dbfb55e73222db8f13bb6ab6855e3aa0e8c5e3c575f6ce89d55d7cb51c063a5dffb45
@@ -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
@@ -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",
@@ -158,7 +158,7 @@ module CardanoWallet
158
158
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/selectCoins
159
159
  #
160
160
  # @example
161
- # random(wid, {address1: 123, address2: 456})
161
+ # random(wid, [{addr1: 1000000}, {addr2: 1000000}])
162
162
  def random(wid, payments)
163
163
  payments_formatted = Utils.format_payments(payments)
164
164
  self.class.post("/wallets/#{wid}/coin-selections/random",
@@ -194,12 +194,12 @@ module CardanoWallet
194
194
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction
195
195
  # @param wid [String] source wallet id
196
196
  # @param passphrase [String] source wallet's passphrase
197
- # @param payments [Hash] addres, amount pair
197
+ # @param payments [Array of Hashes] addres, amount pair
198
198
  # @param withdrawal [String or Array] 'self' or mnemonic sentence
199
199
  # @param metadata [Hash] special metadata JSON subset format (cf: https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction)
200
200
  #
201
201
  # @example
202
- # create(wid, passphrase, {addr1: 1000000}, 'self', {"1": "abc"})
202
+ # create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}], 'self', {"1": "abc"})
203
203
  def create(wid, passphrase, payments, withdrawal = nil, metadata = nil)
204
204
  payments_formatted = Utils.format_payments(payments)
205
205
  payload = { :payments => payments_formatted,
@@ -217,7 +217,7 @@ module CardanoWallet
217
217
  # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransactionFee
218
218
  #
219
219
  # @example
220
- # payment_fees(wid, {addr1: 1000000}, {"1": "abc"})
220
+ # payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}], {"1": "abc"})
221
221
  def payment_fees(wid, payments, withdrawal = nil, metadata = nil)
222
222
  payments_formatted = Utils.format_payments(payments)
223
223
  payload = { :payments => payments_formatted }
@@ -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.1"
2
+ VERSION = "0.2.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.1
4
+ version: 0.2.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-10-08 00:00:00.000000000 Z
11
+ date: 2020-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty