lib/cardano_wallet/byron.rb in cardano_wallet-0.3.0 vs lib/cardano_wallet/byron.rb in cardano_wallet-0.3.1

- old
+ new

@@ -203,12 +203,18 @@ # Show random coin selection for particular payment # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/byronSelectCoins # # @example # random(wid, [{addr1: 1000000}, {addr2: 1000000}]) + # random(wid, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ]) def random(wid, payments) - payments_formatted = Utils.format_payments(payments) + Utils.verify_param_is_array!(payments) + if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")} + payments_formatted = payments + else + payments_formatted = Utils.format_payments(payments) + end self.class.post("/byron-wallets/#{wid}/coin-selections/random", :body => {:payments => payments_formatted}.to_json, :headers => { 'Content-Type' => 'application/json' }) end end @@ -245,10 +251,11 @@ # @example # create(wid, passphrase, [{addr1: 1000000}, {addr2: 1000000}]) # create(wid, passphrase, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ]) def create(wid, passphrase, payments) + Utils.verify_param_is_array!(payments) if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")} payments_formatted = payments else payments_formatted = Utils.format_payments(payments) end @@ -264,9 +271,10 @@ # # @example # payment_fees(wid, [{addr1: 1000000}, {addr2: 1000000}]) # payment_fees(wid, [{ "address": "addr1..", "amount": { "quantity": 42000000, "unit": "lovelace" }, "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ]) def payment_fees(wid, payments) + Utils.verify_param_is_array!(payments) if payments.any?{|p| p.has_key?("address".to_sym) || p.has_key?("address")} payments_formatted = payments else payments_formatted = Utils.format_payments(payments) end