Sha256: f95f35cda5fe52bf7ece73bf2ab3d24b1f349d083818b769825f7a8b389fc50c

Contents?: true

Size: 447 Bytes

Versions: 15

Compression:

Stored size: 447 Bytes

Contents

module Stellar
  class PathPaymentStrictReceiveResult
    # send_amount returns the actual amount paid for the corresponding
    # PathPaymentOp to this result.
    #
    def send_amount
      s = success!
      return s.last.amount if s.offers.blank?

      source_asset = s.offers.first.asset_bought
      source_offers = s.offers.take_while { |o| o.asset_bought == source_asset }

      source_offers.map(&:amount_bought).sum
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
stellar-base-0.32.0 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.31.0 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.30.0 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.29.0 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.28.0 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.27.0 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.26.0 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.25.0 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.24.0 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.24.0.pre.1 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.23.1 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.23.0 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.23.0.rc2 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.23.0.rc1 lib/stellar/path_payment_strict_receive_result.rb
stellar-base-0.23.0.pre1 lib/stellar/path_payment_strict_receive_result.rb