remove currency model and all references

This commit is contained in:
João Geonizeli
2021-08-28 01:29:07 -03:00
parent 31078f87ae
commit 0d10e86526
74 changed files with 665 additions and 1561 deletions

View File

@@ -6,8 +6,6 @@ module Mutations
argument :order, Inputs::CreateBuyCryptoOrderAttributesInput, required: true
def resolve(order:)
currency_id = decode_id(order[:currency_id])
ActiveRecord::Base.transaction do
current_user
.fiat_balance
@@ -15,7 +13,6 @@ module Mutations
record = BuyCryptoOrder.create!(
paid_amount_cents: order[:amount_cents],
currency_id: currency_id,
user_id: current_user.id,
)

View File

@@ -6,18 +6,15 @@ module Mutations
argument :order, Inputs::CreateSellCryptoOrderAttributesInput, required: true
def resolve(order:)
currency_id = decode_id(order[:currency_id])
amount = BigDecimal(order[:amount])
ActiveRecord::Base.transaction do
current_user
.balances
.find_by!(currency_id: currency_id)
.balance
.withdrawal!(amount)
record = SellCryptoOrder.create!(
paid_amount: amount,
currency_id: currency_id,
user_id: current_user.id,
)

View File

@@ -6,18 +6,15 @@ module Mutations
argument :order, Inputs::CreateStakeOrderAttributesInput, required: true
def resolve(order:)
currency_id = Currency.find_by!(name: "CAKE").id
amount = BigDecimal(order[:amount])
ActiveRecord::Base.transaction do
current_user
.balances
.find_by!(currency_id: currency_id)
.balance
.withdrawal!(amount)
record = StakeOrder.create!(
amount: amount,
currency_id: currency_id,
pool_name: order[:pool_name],
user_id: current_user.id,
)

View File

@@ -6,14 +6,12 @@ module Mutations
argument :order, Inputs::CreateStakeOrderAttributesInput, required: true
def resolve(order:)
currency_id = Currency.find_by!(name: "CAKE").id
amount = -BigDecimal(order[:amount])
ActiveRecord::Base.transaction do
record = StakeOrder.find_or_initialize_by(
pool_name: order[:pool_name],
user_id: current_user.id,
currency_id: currency_id,
status: :processing
)