app/services/wallet_service.rb
# TODO: We don't need deposit_spread anymore.
We don't need deposit_spread anymore.
We don ' t need deposit_spread anymore .
def collect_deposit!(deposit, deposit_spread)
    blockchain_currency = BlockchainCurrency.find_by(currency: deposit.currency,
                                                     blockchain_key: @wallet.blockchain_key)
    @adapter.configure(wallet:   @wallet.to_wallet_api_settings,
                       currency: blockchain_currency.to_blockchain_api_settings)
    pa = PaymentAddress.find_by(wallet_id: @wallet.id, member: deposit.member, address: deposit.address)
    @adapter.configure(
      wallet: @wallet.to_wallet_api_settings
                     .merge(pa.details.symbolize_keys)
                     .merge(address: pa.address)
                     .tap { |s| s.merge!(secret: pa.secret) if pa.secret.present? }
                     .compact
    )
    deposit_spread.map do |transaction|
      if transaction.status.pending?
        transaction = @adapter.create_transaction!(transaction, subtract_fee: true)
        save_transaction(transaction.as_json.merge(from_address: deposit.address, kind: 'tx', blockchain_key: @wallet.blockchain_key), deposit) if transaction.present?
      end
      transaction
    end
  end
def collect_deposit! ( deposit , deposit_spread ) blockchain_currency = BlockchainCurrency . find_by ( currency : deposit . currency , blockchain_key : @wallet . blockchain_key ) @adapter . configure ( wallet : @wallet . to_wallet_api_settings , currency : blockchain_currency . to_blockchain_api_settings ) pa = PaymentAddress . find_by ( wallet_id : @wallet . id , member : deposit . member , address : deposit . address ) @adapter . configure ( wallet : @wallet . to_wallet_api_settings . merge ( pa . details . symbolize_keys ) . merge ( address : pa . address ) . tap { | s | s . merge! ( secret : pa . secret ) if pa . secret . present? } . compact ) deposit_spread . map do | transaction | if transaction . status . pending? transaction = @adapter . create_transaction! ( transaction , subtract_fee : true ) save_transaction ( transaction . as_json . merge ( from_address : deposit . address , kind : 'tx' , blockchain_key : @wallet . blockchain_key ) , deposit ) if transaction . present? end transaction end end
TODO: We don't need deposit_spread anymore.
TODO : We don ' t need deposit_spread anymore .
# NOTE: Deposit wallet configuration is tricky because wallet URI #       is saved on Wallet model but wallet address and secret #       are saved in PaymentAddress. # In #spread_deposit valid transactions saved with pending state
deposit
deposit_spread