Class: StellarBase::WithdrawalRequests::CallFeeFixedFrom

Inherits:
Object
  • Object
show all
Defined in:
app/services/stellar_base/withdrawal_requests/call_fee_fixed_from.rb

Constant Summary collapse

CALLBACK_CONFIG_NAME =
:fee_fixed_from
INVALID_FEE_MESSAGE =
"`fee_fixed_from` must return a value >= 0".freeze

Class Method Summary collapse

Class Method Details

.call(params, asset_details) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/stellar_base/withdrawal_requests/call_fee_fixed_from.rb', line 9

def self.call(params, asset_details)
  if fee_fixed = asset_details[:fee_fixed]
    return fee_fixed
  end

  callback = GetCallbackFrom.(asset_details[CALLBACK_CONFIG_NAME])

  return 0.0 if callback.nil?

  fee_fixed = callback.(params, asset_details)

  if fee_fixed.nil?
    fail ArgumentError, INVALID_FEE_MESSAGE
  end

  fee_fixed
end