remove currency model and all references
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
module Inputs
|
||||
class CreateBuyCryptoOrderAttributesInput < Types::BaseInputObject
|
||||
argument :currency_id, ID, required: true
|
||||
argument :amount_cents, Integer, "Amount to be paid", required: true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
module Inputs
|
||||
class CreateSellCryptoOrderAttributesInput < Types::BaseInputObject
|
||||
argument :currency_id, ID, required: true
|
||||
argument :amount, String, "Amount to be paid", required: true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -8,10 +8,5 @@ module Types
|
||||
|
||||
field :id, ID, null: false
|
||||
field :amount, String, null: false
|
||||
|
||||
field :currency, CurrencyType, null: false
|
||||
def currency
|
||||
dataloader.with(Dataloader::Source, Currency).load(object.currency_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,12 +7,6 @@ module Types
|
||||
graphql_name "BuyCryptoOrder"
|
||||
|
||||
field :id, ID, null: false
|
||||
|
||||
field :currency, CurrencyType, null: false
|
||||
def currency
|
||||
dataloader.with(Dataloader::Source, Currency).load(object.currency_id)
|
||||
end
|
||||
|
||||
field :status, ProcessStatusEnum, null: false
|
||||
field :paid_amount_cents, Integer, null: false
|
||||
field :received_amount, String, null: true
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class CurrencyType < Types::BaseObject
|
||||
implements GraphQL::Types::Relay::Node
|
||||
global_id_field :id
|
||||
|
||||
graphql_name "Currency"
|
||||
|
||||
field :id, ID, null: false
|
||||
field :name, String, null: false
|
||||
end
|
||||
end
|
||||
@@ -10,16 +10,6 @@ module Types
|
||||
context[:current_user]
|
||||
end
|
||||
|
||||
field :balances, BalanceType.connection_type, null: false
|
||||
def balances
|
||||
Pundit.policy_scope(current_user, Balance)
|
||||
end
|
||||
|
||||
field :fiat_balances, FiatBalanceType.connection_type, null: false
|
||||
def fiat_balances
|
||||
Pundit.policy_scope(current_user, FiatBalance)
|
||||
end
|
||||
|
||||
field :sell_crypto_orders, SellCryptoOrderType.connection_type, null: false
|
||||
def sell_crypto_orders
|
||||
Pundit.policy_scope(current_user, SellCryptoOrder)
|
||||
|
||||
@@ -7,12 +7,6 @@ module Types
|
||||
graphql_name "SellCryptoOrder"
|
||||
|
||||
field :id, ID, null: false
|
||||
|
||||
field :currency, CurrencyType, null: false
|
||||
def currency
|
||||
dataloader.with(Dataloader::Source, Currency).load(object.currency_id)
|
||||
end
|
||||
|
||||
field :status, ProcessStatusEnum, null: false
|
||||
field :paid_amount, String, null: false
|
||||
field :received_amount_cents, Integer, null: true
|
||||
|
||||
@@ -11,5 +11,8 @@ module Types
|
||||
field :first_name, String, null: false
|
||||
field :last_name, String, null: false
|
||||
field :wallet_address, String, null: true
|
||||
|
||||
field :balance, BalanceType, null: false
|
||||
field :fiat_balance, FiatBalanceType, null: false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,8 +6,6 @@ class XStakeSchema < GraphQL::Schema
|
||||
|
||||
def self.resolve_type(abstract_type, obj, ctx)
|
||||
case obj
|
||||
when Currency
|
||||
Types::CurrencyType
|
||||
when Balance
|
||||
Types::BalanceType
|
||||
when FiatBalance
|
||||
|
||||
Reference in New Issue
Block a user