add mutations to exchange painel

This commit is contained in:
João Geonizeli
2021-08-15 23:30:53 -03:00
parent 0ccd01abfd
commit 19a08cd50e
29 changed files with 702 additions and 198 deletions

View File

@@ -9,7 +9,9 @@ module Mutations
currency_id = decode_id(order[:currency_id])
ActiveRecord::Base.transaction do
current_user.fiat_balance.withdrawal!(order[:amount_cents])
current_user
.fiat_balance
.withdrawal!(order[:amount_cents])
record = BuyCryptoOrder.create!(
paid_amount_cents: order[:amount_cents],

View File

@@ -10,10 +10,12 @@ module Mutations
amount = BigDecimal(order[:amount])
ActiveRecord::Base.transaction do
current_user.balances.find_by!(currency_id: currency_id)
current_user
.balances
.find_by!(currency_id: currency_id)
.withdrawal!(amount)
record = SellCryptoOrder.create(
record = SellCryptoOrder.create!(
paid_amount: amount,
currency_id: currency_id,
user_id: current_user.id,