cardano_wallet 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/nightly.yml +1 -1
- data/.github/workflows/tests.yml +1 -1
- data/lib/cardano_wallet/byron.rb +4 -4
- data/lib/cardano_wallet/shelley.rb +4 -4
- data/lib/cardano_wallet/utils.rb +17 -6
- data/lib/cardano_wallet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3d493df353517eb41d713b9b12973fadd1b56da5f17f8a15763181285d13a82
|
4
|
+
data.tar.gz: 6848865dea8cd920f95d0268065293aba195e67e4cfd1b1324a62e355e119347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d02a807c61dad05dd08fc300990702a10ed631a25268735189772e4f54dabb411d4ab5d2688e10333b9d88558a881de1eaf1545cd3a9547cc29bf4f36116f909
|
7
|
+
data.tar.gz: 4007b0db748e9f88244257e30a9a939dea56e213eec84fce632b603c1d2dbfb55e73222db8f13bb6ab6855e3aa0e8c5e3c575f6ce89d55d7cb51c063a5dffb45
|
data/.github/workflows/tests.yml
CHANGED
data/lib/cardano_wallet/byron.rb
CHANGED
@@ -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, {
|
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 [
|
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, {
|
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 [
|
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 }
|
data/lib/cardano_wallet/utils.rb
CHANGED
@@ -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
|
-
|
10
|
-
payments.
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
|
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.
|
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-
|
11
|
+
date: 2020-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|