lib/peatio/ndc/wallet.rb in peatio-ndc-0.2.1 vs lib/peatio/ndc/wallet.rb in peatio-ndc-0.2.2
- old
+ new
@@ -1,52 +1,52 @@
+# frozen_string_literal: true
+
module Peatio
module Ndc
class Wallet < Peatio::Wallet::Abstract
-
- def initialize(settings = {})
+ def initialize(settings={})
@settings = settings
end
- def configure(settings = {})
+ def configure(settings={})
# Clean client state during configure.
@client = nil
@settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
- @wallet = @settings.fetch(:wallet) do
+ @wallet = @settings.fetch(:wallet) {
raise Peatio::Wallet::MissingSettingError, :wallet
- end.slice(:uri, :address)
+ }.slice(:uri, :address)
- @currency = @settings.fetch(:currency) do
+ @currency = @settings.fetch(:currency) {
raise Peatio::Wallet::MissingSettingError, :currency
- end.slice(:id, :base_factor, :options)
+ }.slice(:id, :base_factor, :options)
end
- def create_address!(_options = {})
- { address: client.json_rpc(:getnewaddress) }
+ def create_address!(_options={})
+ {address: client.json_rpc(:getnewaddress)}
rescue Ndc::Client::Error => e
raise Peatio::Wallet::ClientError, e
end
- def create_transaction!(transaction, options = {})
+ def create_transaction!(transaction, options={})
txid = client.json_rpc(:sendtoaddress,
[
transaction.to_address,
transaction.amount,
- '',
- '',
- options[:subtract_fee].to_s == 'true' # subtract fee from transaction amount.
+ "",
+ "",
+ options[:subtract_fee].to_s == "true" # subtract fee from transaction amount.
])
transaction.hash = txid
transaction
rescue Ndc::Client::Error => e
raise Peatio::Wallet::ClientError, e
end
def load_balance!
client.json_rpc(:getbalance).to_d
-
rescue Ndc::Client::Error => e
raise Peatio::Wallet::ClientError, e
end
private
@@ -56,5 +56,6 @@
@client ||= Client.new(uri)
end
end
end
end
+