remove crypto balance from backend
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
module Admin
|
||||
class BalancesController < Admin::ApplicationController
|
||||
def valid_action?(name, resource = resource_class)
|
||||
["destroy"].exclude?(name.to_s) && super
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,53 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
require "administrate/base_dashboard"
|
||||
|
||||
class BalanceDashboard < Administrate::BaseDashboard
|
||||
# ATTRIBUTE_TYPES
|
||||
# a hash that describes the type of each of the model's fields.
|
||||
#
|
||||
# Each different type represents an Administrate::Field object,
|
||||
# which determines how the attribute is displayed
|
||||
# on pages throughout the dashboard.
|
||||
ATTRIBUTE_TYPES = {
|
||||
user: Field::BelongsTo,
|
||||
id: Field::Number,
|
||||
amount: Field::String.with_options(searchable: false),
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [:user, :id, :amount].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [:user, :id, :amount, :created_at, :updated_at].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [:user, :amount].freeze
|
||||
|
||||
# COLLECTION_FILTERS
|
||||
# a hash that defines filters that can be used while searching via the search
|
||||
# field of the dashboard.
|
||||
#
|
||||
# For example to add an option to search for open resources by typing "open:"
|
||||
# in the search field:
|
||||
#
|
||||
# COLLECTION_FILTERS = {
|
||||
# open: ->(resources) { resources.where(open: true) }
|
||||
# }.freeze
|
||||
COLLECTION_FILTERS = {}.freeze
|
||||
|
||||
# Overwrite this method to customize how balances are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
#
|
||||
# def display_resource(balance)
|
||||
# "Balance ##{balance.id}"
|
||||
# end
|
||||
end
|
||||
@@ -9,10 +9,6 @@ module Mutations
|
||||
amount = BigDecimal(order[:amount])
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
current_user
|
||||
.balance
|
||||
.withdrawal!(amount)
|
||||
|
||||
record = SellCryptoOrder.create!(
|
||||
paid_amount: amount,
|
||||
user_id: current_user.id,
|
||||
|
||||
@@ -9,10 +9,6 @@ module Mutations
|
||||
amount = BigDecimal(order[:amount])
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
current_user
|
||||
.balance
|
||||
.withdrawal!(amount)
|
||||
|
||||
record = StakeOrder.create!(
|
||||
amount: amount,
|
||||
pool_name: order[:pool_name],
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BalanceType < Types::BaseObject
|
||||
implements GraphQL::Types::Relay::Node
|
||||
global_id_field :id
|
||||
|
||||
graphql_name "Balance"
|
||||
|
||||
field :id, ID, null: false
|
||||
field :amount, String, null: false
|
||||
end
|
||||
end
|
||||
@@ -11,8 +11,6 @@ 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 Balance
|
||||
Types::BalanceType
|
||||
when FiatBalance
|
||||
Types::FiatBalanceType
|
||||
when SellCryptoOrder
|
||||
|
||||
6
app/javascript/__generated__/schema.graphql
generated
6
app/javascript/__generated__/schema.graphql
generated
@@ -1,8 +1,3 @@
|
||||
type Balance implements Node {
|
||||
amount: String!
|
||||
id: ID!
|
||||
}
|
||||
|
||||
type BuyCryptoOrder implements Node {
|
||||
createdAt: ISO8601DateTime!
|
||||
id: ID!
|
||||
@@ -553,7 +548,6 @@ input StakeOrderFilterInput {
|
||||
}
|
||||
|
||||
type User {
|
||||
balance: Balance!
|
||||
email: String!
|
||||
fiatBalance: FiatBalance!
|
||||
firstName: String!
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { graphql } from "babel-plugin-relay/macro";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useLazyLoadQuery } from "react-relay";
|
||||
import { ethers } from "ethers";
|
||||
|
||||
import { unfinishedPools } from "../../constants/Pools";
|
||||
@@ -9,7 +7,6 @@ import type { PoolConfig } from "../../types";
|
||||
import { Pool } from "./Pool";
|
||||
import sousChef from "../../abi/sousChef.json";
|
||||
import { getEndBlock } from "../../utils/getEndBlock";
|
||||
import type { PoolListingQuery } from "./__generated__/PoolListingQuery.graphql";
|
||||
import { notEmpty } from "../../utils/notEmpty";
|
||||
import { Spinner } from "../../components";
|
||||
import { usePersistedState } from "../../hooks/usePersistedState";
|
||||
@@ -24,20 +21,8 @@ export const PoolListing = () => {
|
||||
|
||||
const [isLoadingPools, setIsLoadingPools] = useState(true);
|
||||
|
||||
const { currentUser } = useLazyLoadQuery<PoolListingQuery>(
|
||||
graphql`
|
||||
query PoolListingQuery {
|
||||
currentUser {
|
||||
balance {
|
||||
amount
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
{}
|
||||
);
|
||||
|
||||
const balance = currentUser?.balance.amount ?? "0";
|
||||
// TODO<wallet>: puxar valor da wallet
|
||||
const balance = "0";
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from "relay-runtime";
|
||||
export type PoolListingQueryVariables = {};
|
||||
export type PoolListingQueryResponse = {
|
||||
readonly currentUser: {
|
||||
readonly balance: {
|
||||
readonly amount: string;
|
||||
};
|
||||
} | null;
|
||||
};
|
||||
export type PoolListingQuery = {
|
||||
readonly response: PoolListingQueryResponse;
|
||||
readonly variables: PoolListingQueryVariables;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
query PoolListingQuery {
|
||||
currentUser {
|
||||
balance {
|
||||
amount
|
||||
id
|
||||
}
|
||||
id
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "amount",
|
||||
"storageKey": null
|
||||
},
|
||||
v1 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "PoolListingQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "User",
|
||||
"kind": "LinkedField",
|
||||
"name": "currentUser",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Balance",
|
||||
"kind": "LinkedField",
|
||||
"name": "balance",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Operation",
|
||||
"name": "PoolListingQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "User",
|
||||
"kind": "LinkedField",
|
||||
"name": "currentUser",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Balance",
|
||||
"kind": "LinkedField",
|
||||
"name": "balance",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "6af4091073903ead7eb057e9f245a32c",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "PoolListingQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query PoolListingQuery {\n currentUser {\n balance {\n amount\n id\n }\n id\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
(node as any).hash = 'e296b5abac1f659b33d8c77522fbfc55';
|
||||
export default node;
|
||||
@@ -32,15 +32,14 @@ export const ExchangePanel: FC<Props> = ({ userRef }) => {
|
||||
fiatBalance {
|
||||
amountCents
|
||||
}
|
||||
balance {
|
||||
amount
|
||||
}
|
||||
}
|
||||
`,
|
||||
userRef
|
||||
);
|
||||
|
||||
const balanceAmount = user?.balance?.amount ?? 0;
|
||||
// TODO<wallet>: puxar valor da wallet
|
||||
const balanceAmount = 0;
|
||||
|
||||
const fiatBalanceAmount = user?.fiatBalance.amountCents ?? 0;
|
||||
|
||||
const avaliableCrypto = new BigNumber(balanceAmount);
|
||||
|
||||
@@ -8,9 +8,6 @@ export type ExchangePanel_user = {
|
||||
readonly fiatBalance: {
|
||||
readonly amountCents: number;
|
||||
};
|
||||
readonly balance: {
|
||||
readonly amount: string;
|
||||
};
|
||||
readonly " $refType": "ExchangePanel_user";
|
||||
};
|
||||
export type ExchangePanel_user$data = ExchangePanel_user;
|
||||
@@ -44,28 +41,10 @@ const node: ReaderFragment = {
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Balance",
|
||||
"kind": "LinkedField",
|
||||
"name": "balance",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "amount",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "User",
|
||||
"abstractKey": null
|
||||
};
|
||||
(node as any).hash = '2d9248ccbe47532d3f3ac0f21f02a274';
|
||||
(node as any).hash = '2058ddb20a60f148a524083fa0a680ea';
|
||||
export default node;
|
||||
|
||||
@@ -68,10 +68,6 @@ fragment ExchangePanel_user on User {
|
||||
amountCents
|
||||
id
|
||||
}
|
||||
balance {
|
||||
amount
|
||||
id
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -196,25 +192,6 @@ return {
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Balance",
|
||||
"kind": "LinkedField",
|
||||
"name": "balance",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "amount",
|
||||
"storageKey": null
|
||||
},
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -324,12 +301,12 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "fdc958a4c6802df3461f7a625f94729c",
|
||||
"cacheID": "30aa6f9d81cfe033aee64b8577d15936",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "ExchangeQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query ExchangeQuery {\n currentUser {\n ...ExchangePanel_user\n id\n }\n buyCryptoOrders {\n ...ExchangeHistory_buyCryptoOrders\n }\n sellCryptoOrders {\n ...ExchangeHistory_sellCryptoOrders\n }\n}\n\nfragment ExchangeHistory_buyCryptoOrders on BuyCryptoOrderConnection {\n edges {\n node {\n id\n status\n createdAt\n paidAmountCents\n receivedAmount\n __typename\n }\n }\n}\n\nfragment ExchangeHistory_sellCryptoOrders on SellCryptoOrderConnection {\n edges {\n node {\n id\n status\n paidAmount\n receivedAmountCents\n createdAt\n __typename\n }\n }\n}\n\nfragment ExchangePanel_user on User {\n fiatBalance {\n amountCents\n id\n }\n balance {\n amount\n id\n }\n}\n"
|
||||
"text": "query ExchangeQuery {\n currentUser {\n ...ExchangePanel_user\n id\n }\n buyCryptoOrders {\n ...ExchangeHistory_buyCryptoOrders\n }\n sellCryptoOrders {\n ...ExchangeHistory_sellCryptoOrders\n }\n}\n\nfragment ExchangeHistory_buyCryptoOrders on BuyCryptoOrderConnection {\n edges {\n node {\n id\n status\n createdAt\n paidAmountCents\n receivedAmount\n __typename\n }\n }\n}\n\nfragment ExchangeHistory_sellCryptoOrders on SellCryptoOrderConnection {\n edges {\n node {\n id\n status\n paidAmount\n receivedAmountCents\n createdAt\n __typename\n }\n }\n}\n\nfragment ExchangePanel_user on User {\n fiatBalance {\n amountCents\n id\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -1,26 +1,13 @@
|
||||
import { graphql } from "babel-plugin-relay/macro";
|
||||
import type { FC } from "react";
|
||||
import React from "react";
|
||||
import { useFragment } from "react-relay";
|
||||
|
||||
import { Table, TableRow } from "../../components";
|
||||
import { getCurrencyLogo } from "../../utils/getCurrencyLogo";
|
||||
import type { Balance_balance$key } from "./__generated__/Balance_balance.graphql";
|
||||
|
||||
type Props = {
|
||||
balancesRef: Balance_balance$key;
|
||||
};
|
||||
export const Balance: FC<Props> = ({ balancesRef }) => {
|
||||
const node = useFragment<Balance_balance$key>(
|
||||
graphql`
|
||||
fragment Balance_balance on Balance {
|
||||
amount
|
||||
}
|
||||
`,
|
||||
balancesRef
|
||||
);
|
||||
|
||||
if (!node) return null;
|
||||
export const Balance: FC = () => {
|
||||
const node = {
|
||||
amount: "PUXAR VALOR DA CARTEIRA",
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
|
||||
|
||||
@@ -18,9 +18,6 @@ export const Wallet: FC = () => {
|
||||
fiatBalance {
|
||||
...FiatBalance_fiatBalance
|
||||
}
|
||||
balance {
|
||||
...Balance_balance
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
@@ -34,7 +31,7 @@ export const Wallet: FC = () => {
|
||||
<div className="container mx-auto px-4 sm:px-8 max-w-3xl">
|
||||
<div className="py-8">
|
||||
<FiatBalance fiatBalancesRef={currentUser.fiatBalance} />
|
||||
<Balance balancesRef={currentUser.balance} />
|
||||
<Balance />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ReaderFragment } from "relay-runtime";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type Balance_balance = {
|
||||
readonly amount: string;
|
||||
readonly " $refType": "Balance_balance";
|
||||
};
|
||||
export type Balance_balance$data = Balance_balance;
|
||||
export type Balance_balance$key = {
|
||||
readonly " $data"?: Balance_balance$data;
|
||||
readonly " $fragmentRefs": FragmentRefs<"Balance_balance">;
|
||||
};
|
||||
|
||||
|
||||
|
||||
const node: ReaderFragment = {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "Balance_balance",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "amount",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Balance",
|
||||
"abstractKey": null
|
||||
};
|
||||
(node as any).hash = '3f420063f1e6ebfcd91bd05b7bbb492a';
|
||||
export default node;
|
||||
@@ -10,9 +10,6 @@ export type WalletQueryResponse = {
|
||||
readonly fiatBalance: {
|
||||
readonly " $fragmentRefs": FragmentRefs<"FiatBalance_fiatBalance">;
|
||||
};
|
||||
readonly balance: {
|
||||
readonly " $fragmentRefs": FragmentRefs<"Balance_balance">;
|
||||
};
|
||||
} | null;
|
||||
};
|
||||
export type WalletQuery = {
|
||||
@@ -29,18 +26,10 @@ query WalletQuery {
|
||||
...FiatBalance_fiatBalance
|
||||
id
|
||||
}
|
||||
balance {
|
||||
...Balance_balance
|
||||
id
|
||||
}
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
fragment Balance_balance on Balance {
|
||||
amount
|
||||
}
|
||||
|
||||
fragment FiatBalance_fiatBalance on FiatBalance {
|
||||
amountCents
|
||||
amountCurrency
|
||||
@@ -85,22 +74,6 @@ return {
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Balance",
|
||||
"kind": "LinkedField",
|
||||
"name": "balance",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "Balance_balance"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -149,25 +122,6 @@ return {
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Balance",
|
||||
"kind": "LinkedField",
|
||||
"name": "balance",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "amount",
|
||||
"storageKey": null
|
||||
},
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -175,14 +129,14 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "d0537f2712255befa46df80db6c7246b",
|
||||
"cacheID": "4397ad78f82d23c0a186b71bea7c3898",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "WalletQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query WalletQuery {\n currentUser {\n fiatBalance {\n ...FiatBalance_fiatBalance\n id\n }\n balance {\n ...Balance_balance\n id\n }\n id\n }\n}\n\nfragment Balance_balance on Balance {\n amount\n}\n\nfragment FiatBalance_fiatBalance on FiatBalance {\n amountCents\n amountCurrency\n}\n"
|
||||
"text": "query WalletQuery {\n currentUser {\n fiatBalance {\n ...FiatBalance_fiatBalance\n id\n }\n id\n }\n}\n\nfragment FiatBalance_fiatBalance on FiatBalance {\n amountCents\n amountCurrency\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
(node as any).hash = '61fbc56a1e87c83a8a0a4460c231be53';
|
||||
(node as any).hash = '83fd609428103b13e79c14d20fefaabe';
|
||||
export default node;
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: balances
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# amount :decimal(20, 10) default(0.0), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# user_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_balances_on_user_id (user_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (user_id => users.id)
|
||||
#
|
||||
class Balance < ApplicationRecord
|
||||
include Trackable
|
||||
|
||||
belongs_to :user
|
||||
|
||||
validates :amount, presence: true, numericality: { greater_than_or_equal_to: 0 }
|
||||
|
||||
def withdrawal!(value)
|
||||
update!(amount: amount - value)
|
||||
end
|
||||
|
||||
def deposit!(value)
|
||||
update!(amount: amount + value)
|
||||
end
|
||||
end
|
||||
@@ -29,7 +29,6 @@ class User < ApplicationRecord
|
||||
|
||||
has_many :documents, class_name: "UserDocument", dependent: :destroy
|
||||
has_many :stake_orders, dependent: :restrict_with_error
|
||||
has_one :balance, dependent: :restrict_with_error
|
||||
has_one :fiat_balance, dependent: :restrict_with_error
|
||||
|
||||
validates :first_name, :last_name, :email, presence: true
|
||||
|
||||
@@ -10,22 +10,9 @@ class CreateUserBalances
|
||||
return nil if Rails.env.test?
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
create_fiat_balance
|
||||
create_balances
|
||||
FiatBalance.find_or_create_by!(
|
||||
user_id: user.id
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_fiat_balance
|
||||
FiatBalance.find_or_create_by!(
|
||||
user_id: user.id
|
||||
)
|
||||
end
|
||||
|
||||
def create_balances
|
||||
Balance.find_or_create_by(
|
||||
user_id: user.id
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user