app/services/wallet_service.rb
def deposit_collection_fees!(deposit, deposit_spread)
    blockchain_currency = BlockchainCurrency.find_by(currency: deposit.currency,
                                                     blockchain_key: @wallet.blockchain_key)
    configs = {
      wallet:   @wallet.to_wallet_api_settings,
      currency: blockchain_currency.to_blockchain_api_settings(withdrawal_gas_speed=false)
    }

    if blockchain_currency.parent_id?
      configs.merge!(parent_currency: blockchain_currency.parent.to_blockchain_api_settings)
    end

    @adapter.configure(configs)
    deposit_transaction = Peatio::Transaction.new(hash:         deposit.txid,
                                                  txout:        deposit.txout,
                                                  to_address:   deposit.address,
                                                  block_number: deposit.block_number,
                                                  amount:       deposit.amount)

    transactions = @adapter.prepare_deposit_collection!(deposit_transaction,
                                                        # In #spread_deposit valid transactions saved with pending state
                                                        deposit_spread.select { |t| t.status.pending? },
                                                        blockchain_currency.to_blockchain_api_settings)

    if transactions.present?
      updated_spread = deposit.spread.map do |s|
        deposit_options = s.fetch(:options, {}).symbolize_keys
        transaction_options = transactions.first.options.presence || {}
        general_options = deposit_options.merge(transaction_options)

        s.merge(options: general_options)
      end

      deposit.update(spread: updated_spread)
      transactions.each { |t| save_transaction(t.as_json.merge(from_address: @wallet.address, kind: 'tx_prebuild', blockchain_key: @wallet.blockchain_key), deposit) }
    end
    transactions
  end
# TODO: We don't need deposit_spread anymore.
We don't need deposit_spread anymore.
We don ' t need deposit_spread anymore .
def deposit_collection_fees!(deposit, deposit_spread)
    blockchain_currency = BlockchainCurrency.find_by(currency: deposit.currency,
                                                     blockchain_key: @wallet.blockchain_key)
    configs = {
      wallet:   @wallet.to_wallet_api_settings,
      currency: blockchain_currency.to_blockchain_api_settings(withdrawal_gas_speed=false)
    }
    if blockchain_currency.parent_id?
      configs.merge!(parent_currency: blockchain_currency.parent.to_blockchain_api_settings)
    end
    @adapter.configure(configs)
    deposit_transaction = Peatio::Transaction.new(hash:         deposit.txid,
                                                  txout:        deposit.txout,
                                                  to_address:   deposit.address,
                                                  block_number: deposit.block_number,
                                                  amount:       deposit.amount)
    transactions = @adapter.prepare_deposit_collection!(deposit_transaction,
                                                        deposit_spread.select { |t| t.status.pending? },
                                                        blockchain_currency.to_blockchain_api_settings)
    if transactions.present?
      updated_spread = deposit.spread.map do |s|
        deposit_options = s.fetch(:options, {}).symbolize_keys
        transaction_options = transactions.first.options.presence || {}
        general_options = deposit_options.merge(transaction_options)
        s.merge(options: general_options)
      end
      deposit.update(spread: updated_spread)
      transactions.each { |t| save_transaction(t.as_json.merge(from_address: @wallet.address, kind: 'tx_prebuild', blockchain_key: @wallet.blockchain_key), deposit) }
    end
    transactions
  end
def deposit_collection_fees! ( deposit , deposit_spread ) blockchain_currency = BlockchainCurrency . find_by ( currency : deposit . currency , blockchain_key : @wallet . blockchain_key ) configs = { wallet : @wallet . to_wallet_api_settings , currency : blockchain_currency . to_blockchain_api_settings ( withdrawal_gas_speed = false ) } if blockchain_currency . parent_id? configs . merge! ( parent_currency : blockchain_currency . parent . to_blockchain_api_settings ) end @adapter . configure ( configs ) deposit_transaction = Peatio :: Transaction . new ( hash : deposit . txid , txout : deposit . txout , to_address : deposit . address , block_number : deposit . block_number , amount : deposit . amount ) transactions = @adapter . prepare_deposit_collection! ( deposit_transaction , deposit_spread . select { | t | t . status . pending? } , blockchain_currency . to_blockchain_api_settings ) if transactions . present? updated_spread = deposit . spread . map do | s | deposit_options = s . fetch ( :options , { } ) . symbolize_keys transaction_options = transactions . first . options . presence || { } general_options = deposit_options . merge ( transaction_options ) s . merge ( options : general_options ) end deposit . update ( spread : updated_spread ) transactions . each { | t | save_transaction ( t . as_json . merge ( from_address : @wallet . address , kind : 'tx_prebuild' , blockchain_key : @wallet . blockchain_key ) , deposit ) } end transactions end
TODO: We don't need deposit_spread anymore.
TODO : We don ' t need deposit_spread anymore .
# In #spread_deposit valid transactions saved with pending state
deposit
deposit_spread