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])
|
amount = BigDecimal(order[:amount])
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
current_user
|
|
||||||
.balance
|
|
||||||
.withdrawal!(amount)
|
|
||||||
|
|
||||||
record = SellCryptoOrder.create!(
|
record = SellCryptoOrder.create!(
|
||||||
paid_amount: amount,
|
paid_amount: amount,
|
||||||
user_id: current_user.id,
|
user_id: current_user.id,
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ module Mutations
|
|||||||
amount = BigDecimal(order[:amount])
|
amount = BigDecimal(order[:amount])
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
current_user
|
|
||||||
.balance
|
|
||||||
.withdrawal!(amount)
|
|
||||||
|
|
||||||
record = StakeOrder.create!(
|
record = StakeOrder.create!(
|
||||||
amount: amount,
|
amount: amount,
|
||||||
pool_name: order[:pool_name],
|
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 :first_name, String, null: false
|
||||||
field :last_name, String, null: false
|
field :last_name, String, null: false
|
||||||
field :wallet_address, String, null: true
|
field :wallet_address, String, null: true
|
||||||
|
|
||||||
field :balance, BalanceType, null: false
|
|
||||||
field :fiat_balance, FiatBalanceType, null: false
|
field :fiat_balance, FiatBalanceType, null: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ class XStakeSchema < GraphQL::Schema
|
|||||||
|
|
||||||
def self.resolve_type(abstract_type, obj, ctx)
|
def self.resolve_type(abstract_type, obj, ctx)
|
||||||
case obj
|
case obj
|
||||||
when Balance
|
|
||||||
Types::BalanceType
|
|
||||||
when FiatBalance
|
when FiatBalance
|
||||||
Types::FiatBalanceType
|
Types::FiatBalanceType
|
||||||
when SellCryptoOrder
|
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 {
|
type BuyCryptoOrder implements Node {
|
||||||
createdAt: ISO8601DateTime!
|
createdAt: ISO8601DateTime!
|
||||||
id: ID!
|
id: ID!
|
||||||
@@ -553,7 +548,6 @@ input StakeOrderFilterInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type User {
|
type User {
|
||||||
balance: Balance!
|
|
||||||
email: String!
|
email: String!
|
||||||
fiatBalance: FiatBalance!
|
fiatBalance: FiatBalance!
|
||||||
firstName: String!
|
firstName: String!
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { graphql } from "babel-plugin-relay/macro";
|
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useLazyLoadQuery } from "react-relay";
|
|
||||||
import { ethers } from "ethers";
|
import { ethers } from "ethers";
|
||||||
|
|
||||||
import { unfinishedPools } from "../../constants/Pools";
|
import { unfinishedPools } from "../../constants/Pools";
|
||||||
@@ -9,7 +7,6 @@ import type { PoolConfig } from "../../types";
|
|||||||
import { Pool } from "./Pool";
|
import { Pool } from "./Pool";
|
||||||
import sousChef from "../../abi/sousChef.json";
|
import sousChef from "../../abi/sousChef.json";
|
||||||
import { getEndBlock } from "../../utils/getEndBlock";
|
import { getEndBlock } from "../../utils/getEndBlock";
|
||||||
import type { PoolListingQuery } from "./__generated__/PoolListingQuery.graphql";
|
|
||||||
import { notEmpty } from "../../utils/notEmpty";
|
import { notEmpty } from "../../utils/notEmpty";
|
||||||
import { Spinner } from "../../components";
|
import { Spinner } from "../../components";
|
||||||
import { usePersistedState } from "../../hooks/usePersistedState";
|
import { usePersistedState } from "../../hooks/usePersistedState";
|
||||||
@@ -24,20 +21,8 @@ export const PoolListing = () => {
|
|||||||
|
|
||||||
const [isLoadingPools, setIsLoadingPools] = useState(true);
|
const [isLoadingPools, setIsLoadingPools] = useState(true);
|
||||||
|
|
||||||
const { currentUser } = useLazyLoadQuery<PoolListingQuery>(
|
// TODO<wallet>: puxar valor da wallet
|
||||||
graphql`
|
const balance = "0";
|
||||||
query PoolListingQuery {
|
|
||||||
currentUser {
|
|
||||||
balance {
|
|
||||||
amount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
|
|
||||||
const balance = currentUser?.balance.amount ?? "0";
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(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 {
|
fiatBalance {
|
||||||
amountCents
|
amountCents
|
||||||
}
|
}
|
||||||
balance {
|
|
||||||
amount
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
userRef
|
userRef
|
||||||
);
|
);
|
||||||
|
|
||||||
const balanceAmount = user?.balance?.amount ?? 0;
|
// TODO<wallet>: puxar valor da wallet
|
||||||
|
const balanceAmount = 0;
|
||||||
|
|
||||||
const fiatBalanceAmount = user?.fiatBalance.amountCents ?? 0;
|
const fiatBalanceAmount = user?.fiatBalance.amountCents ?? 0;
|
||||||
|
|
||||||
const avaliableCrypto = new BigNumber(balanceAmount);
|
const avaliableCrypto = new BigNumber(balanceAmount);
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ export type ExchangePanel_user = {
|
|||||||
readonly fiatBalance: {
|
readonly fiatBalance: {
|
||||||
readonly amountCents: number;
|
readonly amountCents: number;
|
||||||
};
|
};
|
||||||
readonly balance: {
|
|
||||||
readonly amount: string;
|
|
||||||
};
|
|
||||||
readonly " $refType": "ExchangePanel_user";
|
readonly " $refType": "ExchangePanel_user";
|
||||||
};
|
};
|
||||||
export type ExchangePanel_user$data = ExchangePanel_user;
|
export type ExchangePanel_user$data = ExchangePanel_user;
|
||||||
@@ -44,28 +41,10 @@ const node: ReaderFragment = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"storageKey": null
|
"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",
|
"type": "User",
|
||||||
"abstractKey": null
|
"abstractKey": null
|
||||||
};
|
};
|
||||||
(node as any).hash = '2d9248ccbe47532d3f3ac0f21f02a274';
|
(node as any).hash = '2058ddb20a60f148a524083fa0a680ea';
|
||||||
export default node;
|
export default node;
|
||||||
|
|||||||
@@ -68,10 +68,6 @@ fragment ExchangePanel_user on User {
|
|||||||
amountCents
|
amountCents
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
balance {
|
|
||||||
amount
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -196,25 +192,6 @@ return {
|
|||||||
],
|
],
|
||||||
"storageKey": null
|
"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*/)
|
(v0/*: any*/)
|
||||||
],
|
],
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
@@ -324,12 +301,12 @@ return {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
"cacheID": "fdc958a4c6802df3461f7a625f94729c",
|
"cacheID": "30aa6f9d81cfe033aee64b8577d15936",
|
||||||
"id": null,
|
"id": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"name": "ExchangeQuery",
|
"name": "ExchangeQuery",
|
||||||
"operationKind": "query",
|
"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 type { FC } from "react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useFragment } from "react-relay";
|
|
||||||
|
|
||||||
import { Table, TableRow } from "../../components";
|
import { Table, TableRow } from "../../components";
|
||||||
import { getCurrencyLogo } from "../../utils/getCurrencyLogo";
|
import { getCurrencyLogo } from "../../utils/getCurrencyLogo";
|
||||||
import type { Balance_balance$key } from "./__generated__/Balance_balance.graphql";
|
|
||||||
|
|
||||||
type Props = {
|
export const Balance: FC = () => {
|
||||||
balancesRef: Balance_balance$key;
|
const node = {
|
||||||
|
amount: "PUXAR VALOR DA CARTEIRA",
|
||||||
};
|
};
|
||||||
export const Balance: FC<Props> = ({ balancesRef }) => {
|
|
||||||
const node = useFragment<Balance_balance$key>(
|
|
||||||
graphql`
|
|
||||||
fragment Balance_balance on Balance {
|
|
||||||
amount
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
balancesRef
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!node) return null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
|
<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_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="container mx-auto px-4 sm:px-8 max-w-3xl">
|
||||||
<div className="py-8">
|
<div className="py-8">
|
||||||
<FiatBalance fiatBalancesRef={currentUser.fiatBalance} />
|
<FiatBalance fiatBalancesRef={currentUser.fiatBalance} />
|
||||||
<Balance balancesRef={currentUser.balance} />
|
<Balance />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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 fiatBalance: {
|
||||||
readonly " $fragmentRefs": FragmentRefs<"FiatBalance_fiatBalance">;
|
readonly " $fragmentRefs": FragmentRefs<"FiatBalance_fiatBalance">;
|
||||||
};
|
};
|
||||||
readonly balance: {
|
|
||||||
readonly " $fragmentRefs": FragmentRefs<"Balance_balance">;
|
|
||||||
};
|
|
||||||
} | null;
|
} | null;
|
||||||
};
|
};
|
||||||
export type WalletQuery = {
|
export type WalletQuery = {
|
||||||
@@ -29,16 +26,8 @@ query WalletQuery {
|
|||||||
...FiatBalance_fiatBalance
|
...FiatBalance_fiatBalance
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
balance {
|
|
||||||
...Balance_balance
|
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fragment Balance_balance on Balance {
|
|
||||||
amount
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment FiatBalance_fiatBalance on FiatBalance {
|
fragment FiatBalance_fiatBalance on FiatBalance {
|
||||||
@@ -85,22 +74,6 @@ return {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"storageKey": null
|
"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
|
"storageKey": null
|
||||||
@@ -149,25 +122,6 @@ return {
|
|||||||
],
|
],
|
||||||
"storageKey": null
|
"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*/)
|
(v0/*: any*/)
|
||||||
],
|
],
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
@@ -175,14 +129,14 @@ return {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
"cacheID": "d0537f2712255befa46df80db6c7246b",
|
"cacheID": "4397ad78f82d23c0a186b71bea7c3898",
|
||||||
"id": null,
|
"id": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"name": "WalletQuery",
|
"name": "WalletQuery",
|
||||||
"operationKind": "query",
|
"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;
|
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 :documents, class_name: "UserDocument", dependent: :destroy
|
||||||
has_many :stake_orders, dependent: :restrict_with_error
|
has_many :stake_orders, dependent: :restrict_with_error
|
||||||
has_one :balance, dependent: :restrict_with_error
|
|
||||||
has_one :fiat_balance, dependent: :restrict_with_error
|
has_one :fiat_balance, dependent: :restrict_with_error
|
||||||
|
|
||||||
validates :first_name, :last_name, :email, presence: true
|
validates :first_name, :last_name, :email, presence: true
|
||||||
|
|||||||
@@ -10,22 +10,9 @@ class CreateUserBalances
|
|||||||
return nil if Rails.env.test?
|
return nil if Rails.env.test?
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
create_fiat_balance
|
|
||||||
create_balances
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def create_fiat_balance
|
|
||||||
FiatBalance.find_or_create_by!(
|
FiatBalance.find_or_create_by!(
|
||||||
user_id: user.id
|
user_id: user.id
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_balances
|
|
||||||
Balance.find_or_create_by(
|
|
||||||
user_id: user.id
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
resources :users
|
resources :users
|
||||||
resources :balances
|
|
||||||
resources :fiat_balances
|
resources :fiat_balances
|
||||||
resources :buy_crypto_orders
|
resources :buy_crypto_orders
|
||||||
resources :sell_crypto_orders
|
resources :sell_crypto_orders
|
||||||
|
|||||||
7
db/migrate/20210913231405_drop_balance.rb
Normal file
7
db/migrate/20210913231405_drop_balance.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
class DropBalance < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
# rubocop:disable Rails/ReversibleMigration
|
||||||
|
drop_table(:balances)
|
||||||
|
end
|
||||||
|
end
|
||||||
11
db/schema.rb
generated
11
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2021_09_06_021610) do
|
ActiveRecord::Schema.define(version: 2021_09_13_231405) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pgcrypto"
|
enable_extension "pgcrypto"
|
||||||
@@ -56,14 +56,6 @@ ActiveRecord::Schema.define(version: 2021_09_06_021610) do
|
|||||||
t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
|
t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "balances", force: :cascade do |t|
|
|
||||||
t.bigint "user_id", null: false
|
|
||||||
t.decimal "amount", precision: 20, scale: 10, default: "0.0", null: false
|
|
||||||
t.datetime "created_at", precision: 6, null: false
|
|
||||||
t.datetime "updated_at", precision: 6, null: false
|
|
||||||
t.index ["user_id"], name: "index_balances_on_user_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "buy_crypto_orders", force: :cascade do |t|
|
create_table "buy_crypto_orders", force: :cascade do |t|
|
||||||
t.bigint "user_id", null: false
|
t.bigint "user_id", null: false
|
||||||
t.string "status", null: false
|
t.string "status", null: false
|
||||||
@@ -149,7 +141,6 @@ ActiveRecord::Schema.define(version: 2021_09_06_021610) do
|
|||||||
|
|
||||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||||
add_foreign_key "balances", "users"
|
|
||||||
add_foreign_key "buy_crypto_orders", "users"
|
add_foreign_key "buy_crypto_orders", "users"
|
||||||
add_foreign_key "deposit_orders", "users"
|
add_foreign_key "deposit_orders", "users"
|
||||||
add_foreign_key "fiat_balances", "users"
|
add_foreign_key "fiat_balances", "users"
|
||||||
|
|||||||
192
erd.svg
192
erd.svg
@@ -1,68 +1,34 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
<!-- Generated by graphviz version 2.48.0 (0)
|
<!-- Generated by graphviz version 2.49.0 (0)
|
||||||
-->
|
-->
|
||||||
<!-- Title: XStake Pages: 1 -->
|
<!-- Title: XStake Pages: 1 -->
|
||||||
<svg width="606pt" height="799pt"
|
<svg width="606pt" height="713pt"
|
||||||
viewBox="0.00 0.00 605.60 798.60" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
viewBox="0.00 0.00 605.60 712.60" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(28.8 769.8)">
|
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(28.8 683.8)">
|
||||||
<title>XStake</title>
|
<title>XStake</title>
|
||||||
<polygon fill="white" stroke="transparent" points="-28.8,28.8 -28.8,-769.8 576.8,-769.8 576.8,28.8 -28.8,28.8"/>
|
<polygon fill="white" stroke="transparent" points="-28.8,28.8 -28.8,-683.8 576.8,-683.8 576.8,28.8 -28.8,28.8"/>
|
||||||
<text text-anchor="middle" x="274" y="-726.6" font-family="Arial Bold" font-size="13.00">XStake domain model</text>
|
<text text-anchor="middle" x="274" y="-640.6" font-family="Arial Bold" font-size="13.00">XStake domain model</text>
|
||||||
<!-- m_AdminUser -->
|
<!-- m_AdminUser -->
|
||||||
<g id="node1" class="node">
|
<g id="node1" class="node">
|
||||||
<title>m_AdminUser</title>
|
<title>m_AdminUser</title>
|
||||||
<path fill="none" stroke="black" d="M12,-153C12,-153 150,-153 150,-153 156,-153 162,-159 162,-165 162,-165 162,-236 162,-236 162,-242 156,-248 150,-248 150,-248 12,-248 12,-248 6,-248 0,-242 0,-236 0,-236 0,-165 0,-165 0,-159 6,-153 12,-153"/>
|
<path fill="none" stroke="black" d="M12,-47C12,-47 150,-47 150,-47 156,-47 162,-53 162,-59 162,-59 162,-130 162,-130 162,-136 156,-142 150,-142 150,-142 12,-142 12,-142 6,-142 0,-136 0,-130 0,-130 0,-59 0,-59 0,-53 6,-47 12,-47"/>
|
||||||
<text text-anchor="start" x="49" y="-235.2" font-family="Arial Bold" font-size="11.00">AdminUser</text>
|
<text text-anchor="start" x="49" y="-129.2" font-family="Arial Bold" font-size="11.00">AdminUser</text>
|
||||||
<polyline fill="none" stroke="black" points="0,-228 162,-228 "/>
|
<polyline fill="none" stroke="black" points="0,-122 162,-122 "/>
|
||||||
<text text-anchor="start" x="7" y="-214.5" font-family="Arial" font-size="10.00">email </text>
|
<text text-anchor="start" x="7" y="-108.5" font-family="Arial" font-size="10.00">email </text>
|
||||||
<text text-anchor="start" x="34" y="-214.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗ U</text>
|
<text text-anchor="start" x="34" y="-108.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗ U</text>
|
||||||
<text text-anchor="start" x="7" y="-201.5" font-family="Arial" font-size="10.00">encrypted_password </text>
|
<text text-anchor="start" x="7" y="-95.5" font-family="Arial" font-size="10.00">encrypted_password </text>
|
||||||
<text text-anchor="start" x="101" y="-201.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
<text text-anchor="start" x="101" y="-95.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
||||||
<text text-anchor="start" x="7" y="-188.5" font-family="Arial" font-size="10.00">remember_created_at </text>
|
<text text-anchor="start" x="7" y="-82.5" font-family="Arial" font-size="10.00">remember_created_at </text>
|
||||||
<text text-anchor="start" x="105" y="-188.5" font-family="Arial Italic" font-size="10.00" fill="#999999">datetime</text>
|
<text text-anchor="start" x="105" y="-82.5" font-family="Arial Italic" font-size="10.00" fill="#999999">datetime</text>
|
||||||
<text text-anchor="start" x="7" y="-175.5" font-family="Arial" font-size="10.00">reset_password_sent_at </text>
|
<text text-anchor="start" x="7" y="-69.5" font-family="Arial" font-size="10.00">reset_password_sent_at </text>
|
||||||
<text text-anchor="start" x="117" y="-175.5" font-family="Arial Italic" font-size="10.00" fill="#999999">datetime</text>
|
<text text-anchor="start" x="117" y="-69.5" font-family="Arial Italic" font-size="10.00" fill="#999999">datetime</text>
|
||||||
<text text-anchor="start" x="7" y="-162.5" font-family="Arial" font-size="10.00">reset_password_token </text>
|
<text text-anchor="start" x="7" y="-56.5" font-family="Arial" font-size="10.00">reset_password_token </text>
|
||||||
<text text-anchor="start" x="109" y="-162.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string</text>
|
<text text-anchor="start" x="109" y="-56.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string</text>
|
||||||
</g>
|
|
||||||
<!-- m_Balance -->
|
|
||||||
<g id="node2" class="node">
|
|
||||||
<title>m_Balance</title>
|
|
||||||
<path fill="none" stroke="black" d="M223,-647.5C223,-647.5 343,-647.5 343,-647.5 349,-647.5 355,-653.5 355,-659.5 355,-659.5 355,-691.5 355,-691.5 355,-697.5 349,-703.5 343,-703.5 343,-703.5 223,-703.5 223,-703.5 217,-703.5 211,-697.5 211,-691.5 211,-691.5 211,-659.5 211,-659.5 211,-653.5 217,-647.5 223,-647.5"/>
|
|
||||||
<text text-anchor="start" x="259.5" y="-690.7" font-family="Arial Bold" font-size="11.00">Balance</text>
|
|
||||||
<polyline fill="none" stroke="black" points="211,-683.5 355,-683.5 "/>
|
|
||||||
<text text-anchor="start" x="218" y="-670.5" font-family="Arial" font-size="10.00">amount </text>
|
|
||||||
<text text-anchor="start" x="254" y="-670.5" font-family="Arial Italic" font-size="10.00" fill="#999999">decimal (20,10) ∗</text>
|
|
||||||
<text text-anchor="start" x="218" y="-657.5" font-family="Arial" font-size="10.00">user_id </text>
|
|
||||||
<text text-anchor="start" x="253" y="-657.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
|
||||||
</g>
|
|
||||||
<!-- m_PaperTrail::Version -->
|
|
||||||
<g id="node6" class="node">
|
|
||||||
<title>m_PaperTrail::Version</title>
|
|
||||||
<path fill="none" stroke="black" d="M416,-410C416,-410 536,-410 536,-410 542,-410 548,-416 548,-422 548,-422 548,-493 548,-493 548,-499 542,-505 536,-505 536,-505 416,-505 416,-505 410,-505 404,-499 404,-493 404,-493 404,-422 404,-422 404,-416 410,-410 416,-410"/>
|
|
||||||
<text text-anchor="start" x="423.5" y="-492.2" font-family="Arial Bold" font-size="11.00">PaperTrail::Version</text>
|
|
||||||
<polyline fill="none" stroke="black" points="404,-485 548,-485 "/>
|
|
||||||
<text text-anchor="start" x="411" y="-471.5" font-family="Arial" font-size="10.00">event </text>
|
|
||||||
<text text-anchor="start" x="439" y="-471.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
|
||||||
<text text-anchor="start" x="411" y="-458.5" font-family="Arial" font-size="10.00">item_id </text>
|
|
||||||
<text text-anchor="start" x="446" y="-458.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
|
||||||
<text text-anchor="start" x="411" y="-445.5" font-family="Arial" font-size="10.00">item_type </text>
|
|
||||||
<text text-anchor="start" x="457" y="-445.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
|
||||||
<text text-anchor="start" x="411" y="-432.5" font-family="Arial" font-size="10.00">object </text>
|
|
||||||
<text text-anchor="start" x="441" y="-432.5" font-family="Arial Italic" font-size="10.00" fill="#999999">text</text>
|
|
||||||
<text text-anchor="start" x="411" y="-419.5" font-family="Arial" font-size="10.00">whodunnit </text>
|
|
||||||
<text text-anchor="start" x="459" y="-419.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string</text>
|
|
||||||
</g>
|
|
||||||
<!-- m_Balance->m_PaperTrail::Version -->
|
|
||||||
<g id="edge1" class="edge">
|
|
||||||
<title>m_Balance->m_PaperTrail::Version</title>
|
|
||||||
<path fill="none" stroke="black" d="M348.4,-647.33C355.4,-642.9 362.11,-637.96 368,-632.5 404.05,-599.08 432.34,-550.81 450.75,-513.42"/>
|
|
||||||
<polygon fill="black" stroke="black" points="453.67,-514.61 454.76,-505.14 448,-511.87 453.67,-514.61"/>
|
|
||||||
</g>
|
</g>
|
||||||
<!-- m_BuyCryptoOrder -->
|
<!-- m_BuyCryptoOrder -->
|
||||||
<g id="node3" class="node">
|
<g id="node2" class="node">
|
||||||
<title>m_BuyCryptoOrder</title>
|
<title>m_BuyCryptoOrder</title>
|
||||||
<path fill="none" stroke="black" d="M210,-535.5C210,-535.5 356,-535.5 356,-535.5 362,-535.5 368,-541.5 368,-547.5 368,-547.5 368,-605.5 368,-605.5 368,-611.5 362,-617.5 356,-617.5 356,-617.5 210,-617.5 210,-617.5 204,-617.5 198,-611.5 198,-605.5 198,-605.5 198,-547.5 198,-547.5 198,-541.5 204,-535.5 210,-535.5"/>
|
<path fill="none" stroke="black" d="M210,-535.5C210,-535.5 356,-535.5 356,-535.5 362,-535.5 368,-541.5 368,-547.5 368,-547.5 368,-605.5 368,-605.5 368,-611.5 362,-617.5 356,-617.5 356,-617.5 210,-617.5 210,-617.5 204,-617.5 198,-611.5 198,-605.5 198,-605.5 198,-547.5 198,-547.5 198,-541.5 204,-535.5 210,-535.5"/>
|
||||||
<text text-anchor="start" x="237" y="-604.7" font-family="Arial Bold" font-size="11.00">BuyCryptoOrder</text>
|
<text text-anchor="start" x="237" y="-604.7" font-family="Arial Bold" font-size="11.00">BuyCryptoOrder</text>
|
||||||
@@ -77,7 +43,7 @@
|
|||||||
<text text-anchor="start" x="240" y="-545.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
<text text-anchor="start" x="240" y="-545.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_DepositOrder -->
|
<!-- m_DepositOrder -->
|
||||||
<g id="node4" class="node">
|
<g id="node3" class="node">
|
||||||
<title>m_DepositOrder</title>
|
<title>m_DepositOrder</title>
|
||||||
<path fill="none" stroke="black" d="M214.5,-410C214.5,-410 351.5,-410 351.5,-410 357.5,-410 363.5,-416 363.5,-422 363.5,-422 363.5,-493 363.5,-493 363.5,-499 357.5,-505 351.5,-505 351.5,-505 214.5,-505 214.5,-505 208.5,-505 202.5,-499 202.5,-493 202.5,-493 202.5,-422 202.5,-422 202.5,-416 208.5,-410 214.5,-410"/>
|
<path fill="none" stroke="black" d="M214.5,-410C214.5,-410 351.5,-410 351.5,-410 357.5,-410 363.5,-416 363.5,-422 363.5,-422 363.5,-493 363.5,-493 363.5,-499 357.5,-505 351.5,-505 351.5,-505 214.5,-505 214.5,-505 208.5,-505 202.5,-499 202.5,-493 202.5,-493 202.5,-422 202.5,-422 202.5,-416 208.5,-410 214.5,-410"/>
|
||||||
<text text-anchor="start" x="245.5" y="-492.2" font-family="Arial Bold" font-size="11.00">DepositOrder</text>
|
<text text-anchor="start" x="245.5" y="-492.2" font-family="Arial Bold" font-size="11.00">DepositOrder</text>
|
||||||
@@ -93,14 +59,31 @@
|
|||||||
<text text-anchor="start" x="210" y="-419.5" font-family="Arial" font-size="10.00">user_id </text>
|
<text text-anchor="start" x="210" y="-419.5" font-family="Arial" font-size="10.00">user_id </text>
|
||||||
<text text-anchor="start" x="245" y="-419.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
<text text-anchor="start" x="245" y="-419.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
||||||
</g>
|
</g>
|
||||||
|
<!-- m_PaperTrail::Version -->
|
||||||
|
<g id="node5" class="node">
|
||||||
|
<title>m_PaperTrail::Version</title>
|
||||||
|
<path fill="none" stroke="black" d="M416,-354C416,-354 536,-354 536,-354 542,-354 548,-360 548,-366 548,-366 548,-437 548,-437 548,-443 542,-449 536,-449 536,-449 416,-449 416,-449 410,-449 404,-443 404,-437 404,-437 404,-366 404,-366 404,-360 410,-354 416,-354"/>
|
||||||
|
<text text-anchor="start" x="423.5" y="-436.2" font-family="Arial Bold" font-size="11.00">PaperTrail::Version</text>
|
||||||
|
<polyline fill="none" stroke="black" points="404,-429 548,-429 "/>
|
||||||
|
<text text-anchor="start" x="411" y="-415.5" font-family="Arial" font-size="10.00">event </text>
|
||||||
|
<text text-anchor="start" x="439" y="-415.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
||||||
|
<text text-anchor="start" x="411" y="-402.5" font-family="Arial" font-size="10.00">item_id </text>
|
||||||
|
<text text-anchor="start" x="446" y="-402.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
||||||
|
<text text-anchor="start" x="411" y="-389.5" font-family="Arial" font-size="10.00">item_type </text>
|
||||||
|
<text text-anchor="start" x="457" y="-389.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
||||||
|
<text text-anchor="start" x="411" y="-376.5" font-family="Arial" font-size="10.00">object </text>
|
||||||
|
<text text-anchor="start" x="441" y="-376.5" font-family="Arial Italic" font-size="10.00" fill="#999999">text</text>
|
||||||
|
<text text-anchor="start" x="411" y="-363.5" font-family="Arial" font-size="10.00">whodunnit </text>
|
||||||
|
<text text-anchor="start" x="459" y="-363.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string</text>
|
||||||
|
</g>
|
||||||
<!-- m_DepositOrder->m_PaperTrail::Version -->
|
<!-- m_DepositOrder->m_PaperTrail::Version -->
|
||||||
<g id="edge2" class="edge">
|
<g id="edge1" class="edge">
|
||||||
<title>m_DepositOrder->m_PaperTrail::Version</title>
|
<title>m_DepositOrder->m_PaperTrail::Version</title>
|
||||||
<path fill="none" stroke="black" d="M363.62,-457.5C373.81,-457.5 384.24,-457.5 394.44,-457.5"/>
|
<path fill="none" stroke="black" d="M363.62,-434.16C374.01,-431.11 384.67,-427.98 395.07,-424.94"/>
|
||||||
<polygon fill="black" stroke="black" points="394.74,-460.65 403.74,-457.5 394.74,-454.35 394.74,-460.65"/>
|
<polygon fill="black" stroke="black" points="395.99,-427.95 403.74,-422.39 394.21,-421.9 395.99,-427.95"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_FiatBalance -->
|
<!-- m_FiatBalance -->
|
||||||
<g id="node5" class="node">
|
<g id="node4" class="node">
|
||||||
<title>m_FiatBalance</title>
|
<title>m_FiatBalance</title>
|
||||||
<path fill="none" stroke="black" d="M223,-311C223,-311 343,-311 343,-311 349,-311 355,-317 355,-323 355,-323 355,-368 355,-368 355,-374 349,-380 343,-380 343,-380 223,-380 223,-380 217,-380 211,-374 211,-368 211,-368 211,-323 211,-323 211,-317 217,-311 223,-311"/>
|
<path fill="none" stroke="black" d="M223,-311C223,-311 343,-311 343,-311 349,-311 355,-317 355,-323 355,-323 355,-368 355,-368 355,-374 349,-380 343,-380 343,-380 223,-380 223,-380 217,-380 211,-374 211,-368 211,-368 211,-323 211,-323 211,-317 217,-311 223,-311"/>
|
||||||
<text text-anchor="start" x="250" y="-367.2" font-family="Arial Bold" font-size="11.00">FiatBalance</text>
|
<text text-anchor="start" x="250" y="-367.2" font-family="Arial Bold" font-size="11.00">FiatBalance</text>
|
||||||
@@ -113,13 +96,13 @@
|
|||||||
<text text-anchor="start" x="253" y="-320.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
<text text-anchor="start" x="253" y="-320.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_FiatBalance->m_PaperTrail::Version -->
|
<!-- m_FiatBalance->m_PaperTrail::Version -->
|
||||||
<g id="edge3" class="edge">
|
<g id="edge2" class="edge">
|
||||||
<title>m_FiatBalance->m_PaperTrail::Version</title>
|
<title>m_FiatBalance->m_PaperTrail::Version</title>
|
||||||
<path fill="none" stroke="black" d="M342.86,-380.02C359.59,-389.83 378.09,-400.67 395.82,-411.07"/>
|
<path fill="none" stroke="black" d="M355.12,-366.35C368.17,-370.18 381.87,-374.2 395.16,-378.09"/>
|
||||||
<polygon fill="black" stroke="black" points="394.54,-413.97 403.9,-415.81 397.73,-408.54 394.54,-413.97"/>
|
<polygon fill="black" stroke="black" points="394.3,-381.12 403.82,-380.63 396.07,-375.08 394.3,-381.12"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_SellCryptoOrder -->
|
<!-- m_SellCryptoOrder -->
|
||||||
<g id="node7" class="node">
|
<g id="node6" class="node">
|
||||||
<title>m_SellCryptoOrder</title>
|
<title>m_SellCryptoOrder</title>
|
||||||
<path fill="none" stroke="black" d="M214.5,-198.5C214.5,-198.5 351.5,-198.5 351.5,-198.5 357.5,-198.5 363.5,-204.5 363.5,-210.5 363.5,-210.5 363.5,-268.5 363.5,-268.5 363.5,-274.5 357.5,-280.5 351.5,-280.5 351.5,-280.5 214.5,-280.5 214.5,-280.5 208.5,-280.5 202.5,-274.5 202.5,-268.5 202.5,-268.5 202.5,-210.5 202.5,-210.5 202.5,-204.5 208.5,-198.5 214.5,-198.5"/>
|
<path fill="none" stroke="black" d="M214.5,-198.5C214.5,-198.5 351.5,-198.5 351.5,-198.5 357.5,-198.5 363.5,-204.5 363.5,-210.5 363.5,-210.5 363.5,-268.5 363.5,-268.5 363.5,-274.5 357.5,-280.5 351.5,-280.5 351.5,-280.5 214.5,-280.5 214.5,-280.5 208.5,-280.5 202.5,-274.5 202.5,-268.5 202.5,-268.5 202.5,-210.5 202.5,-210.5 202.5,-204.5 208.5,-198.5 214.5,-198.5"/>
|
||||||
<text text-anchor="start" x="238" y="-267.7" font-family="Arial Bold" font-size="11.00">SellCryptoOrder</text>
|
<text text-anchor="start" x="238" y="-267.7" font-family="Arial Bold" font-size="11.00">SellCryptoOrder</text>
|
||||||
@@ -134,7 +117,7 @@
|
|||||||
<text text-anchor="start" x="245" y="-208.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
<text text-anchor="start" x="245" y="-208.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_StakeOrder -->
|
<!-- m_StakeOrder -->
|
||||||
<g id="node8" class="node">
|
<g id="node7" class="node">
|
||||||
<title>m_StakeOrder</title>
|
<title>m_StakeOrder</title>
|
||||||
<path fill="none" stroke="black" d="M223,-86.5C223,-86.5 343,-86.5 343,-86.5 349,-86.5 355,-92.5 355,-98.5 355,-98.5 355,-156.5 355,-156.5 355,-162.5 349,-168.5 343,-168.5 343,-168.5 223,-168.5 223,-168.5 217,-168.5 211,-162.5 211,-156.5 211,-156.5 211,-98.5 211,-98.5 211,-92.5 217,-86.5 223,-86.5"/>
|
<path fill="none" stroke="black" d="M223,-86.5C223,-86.5 343,-86.5 343,-86.5 349,-86.5 355,-92.5 355,-98.5 355,-98.5 355,-156.5 355,-156.5 355,-162.5 349,-168.5 343,-168.5 343,-168.5 223,-168.5 223,-168.5 217,-168.5 211,-162.5 211,-156.5 211,-156.5 211,-98.5 211,-98.5 211,-92.5 217,-86.5 223,-86.5"/>
|
||||||
<text text-anchor="start" x="251" y="-155.7" font-family="Arial Bold" font-size="11.00">StakeOrder</text>
|
<text text-anchor="start" x="251" y="-155.7" font-family="Arial Bold" font-size="11.00">StakeOrder</text>
|
||||||
@@ -149,64 +132,59 @@
|
|||||||
<text text-anchor="start" x="253" y="-96.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
<text text-anchor="start" x="253" y="-96.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_User -->
|
<!-- m_User -->
|
||||||
<g id="node9" class="node">
|
<g id="node8" class="node">
|
||||||
<title>m_User</title>
|
<title>m_User</title>
|
||||||
<path fill="none" stroke="black" d="M12,-278.5C12,-278.5 150,-278.5 150,-278.5 156,-278.5 162,-284.5 162,-290.5 162,-290.5 162,-400.5 162,-400.5 162,-406.5 156,-412.5 150,-412.5 150,-412.5 12,-412.5 12,-412.5 6,-412.5 0,-406.5 0,-400.5 0,-400.5 0,-290.5 0,-290.5 0,-284.5 6,-278.5 12,-278.5"/>
|
<path fill="none" stroke="black" d="M12,-172.5C12,-172.5 150,-172.5 150,-172.5 156,-172.5 162,-178.5 162,-184.5 162,-184.5 162,-294.5 162,-294.5 162,-300.5 156,-306.5 150,-306.5 150,-306.5 12,-306.5 12,-306.5 6,-306.5 0,-300.5 0,-294.5 0,-294.5 0,-184.5 0,-184.5 0,-178.5 6,-172.5 12,-172.5"/>
|
||||||
<text text-anchor="start" x="66.5" y="-399.7" font-family="Arial Bold" font-size="11.00">User</text>
|
<text text-anchor="start" x="66.5" y="-293.7" font-family="Arial Bold" font-size="11.00">User</text>
|
||||||
<polyline fill="none" stroke="black" points="0,-392.5 162,-392.5 "/>
|
<polyline fill="none" stroke="black" points="0,-286.5 162,-286.5 "/>
|
||||||
<text text-anchor="start" x="7" y="-379.5" font-family="Arial" font-size="10.00">email </text>
|
<text text-anchor="start" x="7" y="-273.5" font-family="Arial" font-size="10.00">email </text>
|
||||||
<text text-anchor="start" x="34" y="-379.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗ U</text>
|
<text text-anchor="start" x="34" y="-273.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗ U</text>
|
||||||
<text text-anchor="start" x="7" y="-366.5" font-family="Arial" font-size="10.00">encrypted_password </text>
|
<text text-anchor="start" x="7" y="-260.5" font-family="Arial" font-size="10.00">encrypted_password </text>
|
||||||
<text text-anchor="start" x="101" y="-366.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
<text text-anchor="start" x="101" y="-260.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
||||||
<text text-anchor="start" x="7" y="-353.5" font-family="Arial" font-size="10.00">first_name </text>
|
<text text-anchor="start" x="7" y="-247.5" font-family="Arial" font-size="10.00">first_name </text>
|
||||||
<text text-anchor="start" x="56" y="-353.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
<text text-anchor="start" x="56" y="-247.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
||||||
<text text-anchor="start" x="7" y="-340.5" font-family="Arial" font-size="10.00">last_name </text>
|
<text text-anchor="start" x="7" y="-234.5" font-family="Arial" font-size="10.00">last_name </text>
|
||||||
<text text-anchor="start" x="56" y="-340.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
<text text-anchor="start" x="56" y="-234.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string ∗</text>
|
||||||
<text text-anchor="start" x="7" y="-327.5" font-family="Arial" font-size="10.00">remember_created_at </text>
|
<text text-anchor="start" x="7" y="-221.5" font-family="Arial" font-size="10.00">remember_created_at </text>
|
||||||
<text text-anchor="start" x="105" y="-327.5" font-family="Arial Italic" font-size="10.00" fill="#999999">datetime</text>
|
<text text-anchor="start" x="105" y="-221.5" font-family="Arial Italic" font-size="10.00" fill="#999999">datetime</text>
|
||||||
<text text-anchor="start" x="7" y="-314.5" font-family="Arial" font-size="10.00">reset_password_sent_at </text>
|
<text text-anchor="start" x="7" y="-208.5" font-family="Arial" font-size="10.00">reset_password_sent_at </text>
|
||||||
<text text-anchor="start" x="117" y="-314.5" font-family="Arial Italic" font-size="10.00" fill="#999999">datetime</text>
|
<text text-anchor="start" x="117" y="-208.5" font-family="Arial Italic" font-size="10.00" fill="#999999">datetime</text>
|
||||||
<text text-anchor="start" x="7" y="-301.5" font-family="Arial" font-size="10.00">reset_password_token </text>
|
<text text-anchor="start" x="7" y="-195.5" font-family="Arial" font-size="10.00">reset_password_token </text>
|
||||||
<text text-anchor="start" x="109" y="-301.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string</text>
|
<text text-anchor="start" x="109" y="-195.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string</text>
|
||||||
<text text-anchor="start" x="7" y="-288.5" font-family="Arial" font-size="10.00">wallet_address </text>
|
<text text-anchor="start" x="7" y="-182.5" font-family="Arial" font-size="10.00">wallet_address </text>
|
||||||
<text text-anchor="start" x="76" y="-288.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string</text>
|
<text text-anchor="start" x="76" y="-182.5" font-family="Arial Italic" font-size="10.00" fill="#999999">string</text>
|
||||||
</g>
|
|
||||||
<!-- m_User->m_Balance -->
|
|
||||||
<g id="edge6" class="edge">
|
|
||||||
<title>m_User->m_Balance</title>
|
|
||||||
<path fill="none" stroke="black" d="M94.93,-412.53C110.13,-475.8 140.87,-570.04 198,-632.5 203.09,-638.06 209.06,-643.01 215.43,-647.39"/>
|
|
||||||
</g>
|
</g>
|
||||||
<!-- m_User->m_BuyCryptoOrder -->
|
<!-- m_User->m_BuyCryptoOrder -->
|
||||||
<g id="edge9" class="edge">
|
<g id="edge7" class="edge">
|
||||||
<title>m_User->m_BuyCryptoOrder</title>
|
<title>m_User->m_BuyCryptoOrder</title>
|
||||||
<path fill="none" stroke="black" d="M118.01,-412.84C138.55,-447.46 166.47,-488.88 198,-520.5 201.09,-523.59 204.37,-526.62 207.78,-529.55"/>
|
<path fill="none" stroke="black" d="M97.69,-306.67C114.53,-367.59 146.11,-457.26 198,-520.5 200.44,-523.47 203.08,-526.35 205.86,-529.12"/>
|
||||||
<polygon fill="black" stroke="black" points="205.99,-532.16 214.94,-535.45 210,-527.3 205.99,-532.16"/>
|
<polygon fill="black" stroke="black" points="203.87,-531.57 212.6,-535.39 208.16,-526.95 203.87,-531.57"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_User->m_DepositOrder -->
|
<!-- m_User->m_DepositOrder -->
|
||||||
<g id="edge8" class="edge">
|
<g id="edge6" class="edge">
|
||||||
<title>m_User->m_DepositOrder</title>
|
<title>m_User->m_DepositOrder</title>
|
||||||
<path fill="none" stroke="black" d="M162.2,-390.41C172.76,-396.33 183.63,-402.41 194.32,-408.4"/>
|
<path fill="none" stroke="black" d="M125.4,-306.72C145.67,-335.62 171.22,-368.82 198,-395.5 200.74,-398.23 203.62,-400.94 206.57,-403.62"/>
|
||||||
<polygon fill="black" stroke="black" points="193.05,-411.3 202.44,-412.95 196.12,-405.8 193.05,-411.3"/>
|
<polygon fill="black" stroke="black" points="204.77,-406.22 213.62,-409.77 208.91,-401.48 204.77,-406.22"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_User->m_FiatBalance -->
|
<!-- m_User->m_FiatBalance -->
|
||||||
<g id="edge7" class="edge">
|
<g id="edge5" class="edge">
|
||||||
<title>m_User->m_FiatBalance</title>
|
<title>m_User->m_FiatBalance</title>
|
||||||
<path fill="none" stroke="black" d="M162.2,-345.5C178.28,-345.5 195.08,-345.5 210.83,-345.5"/>
|
<path fill="none" stroke="black" d="M162.2,-282C180.34,-291.62 199.4,-301.72 216.84,-310.96"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_User->m_SellCryptoOrder -->
|
<!-- m_User->m_SellCryptoOrder -->
|
||||||
<g id="edge10" class="edge">
|
<g id="edge8" class="edge">
|
||||||
<title>m_User->m_SellCryptoOrder</title>
|
<title>m_User->m_SellCryptoOrder</title>
|
||||||
<path fill="none" stroke="black" d="M162.2,-303C173.39,-297.06 184.93,-290.95 196.22,-284.96"/>
|
<path fill="none" stroke="black" d="M162.2,-239.5C172.45,-239.5 182.99,-239.5 193.37,-239.5"/>
|
||||||
<polygon fill="black" stroke="black" points="197.91,-287.63 204.39,-280.63 194.96,-282.07 197.91,-287.63"/>
|
<polygon fill="black" stroke="black" points="193.44,-242.65 202.44,-239.5 193.44,-236.35 193.44,-242.65"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_User->m_StakeOrder -->
|
<!-- m_User->m_StakeOrder -->
|
||||||
<g id="edge5" class="edge">
|
<g id="edge4" class="edge">
|
||||||
<title>m_User->m_StakeOrder</title>
|
<title>m_User->m_StakeOrder</title>
|
||||||
<path fill="none" stroke="black" d="M151.11,-278.14C154.97,-273.33 158.64,-268.43 162,-263.5 183.95,-231.28 172.8,-213.25 198,-183.5 200.49,-180.57 203.16,-177.72 205.98,-174.98"/>
|
<path fill="none" stroke="black" d="M162.2,-194.59C175.51,-187.13 189.32,-179.4 202.62,-171.95"/>
|
||||||
<polygon fill="black" stroke="black" points="208.27,-177.15 212.78,-168.75 204.01,-172.51 208.27,-177.15"/>
|
<polygon fill="black" stroke="black" points="204.51,-174.5 210.83,-167.36 201.44,-169.01 204.51,-174.5"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_UserDocument -->
|
<!-- m_UserDocument -->
|
||||||
<g id="node10" class="node">
|
<g id="node9" class="node">
|
||||||
<title>m_UserDocument</title>
|
<title>m_UserDocument</title>
|
||||||
<path fill="none" stroke="black" d="M223,-0.5C223,-0.5 343,-0.5 343,-0.5 349,-0.5 355,-6.5 355,-12.5 355,-12.5 355,-44.5 355,-44.5 355,-50.5 349,-56.5 343,-56.5 343,-56.5 223,-56.5 223,-56.5 217,-56.5 211,-50.5 211,-44.5 211,-44.5 211,-12.5 211,-12.5 211,-6.5 217,-0.5 223,-0.5"/>
|
<path fill="none" stroke="black" d="M223,-0.5C223,-0.5 343,-0.5 343,-0.5 349,-0.5 355,-6.5 355,-12.5 355,-12.5 355,-44.5 355,-44.5 355,-50.5 349,-56.5 343,-56.5 343,-56.5 223,-56.5 223,-56.5 217,-56.5 211,-50.5 211,-44.5 211,-44.5 211,-12.5 211,-12.5 211,-6.5 217,-0.5 223,-0.5"/>
|
||||||
<text text-anchor="start" x="241.5" y="-43.7" font-family="Arial Bold" font-size="11.00">UserDocument</text>
|
<text text-anchor="start" x="241.5" y="-43.7" font-family="Arial Bold" font-size="11.00">UserDocument</text>
|
||||||
@@ -217,10 +195,10 @@
|
|||||||
<text text-anchor="start" x="253" y="-10.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
<text text-anchor="start" x="253" y="-10.5" font-family="Arial Italic" font-size="10.00" fill="#999999">integer (8) ∗ FK</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- m_User->m_UserDocument -->
|
<!-- m_User->m_UserDocument -->
|
||||||
<g id="edge4" class="edge">
|
<g id="edge3" class="edge">
|
||||||
<title>m_User->m_UserDocument</title>
|
<title>m_User->m_UserDocument</title>
|
||||||
<path fill="none" stroke="black" d="M152.88,-278.49C156.26,-273.63 159.34,-268.62 162,-263.5 202.03,-186.46 146.05,-141.06 198,-71.5 200.37,-68.33 203.04,-65.37 205.94,-62.61"/>
|
<path fill="none" stroke="black" d="M151.26,-172.25C155.09,-167.41 158.71,-162.48 162,-157.5 184.87,-122.95 169.85,-101.9 198,-71.5 201.12,-68.13 204.56,-64.98 208.22,-62.05"/>
|
||||||
<polygon fill="black" stroke="black" points="208.26,-64.78 213.07,-56.55 204.17,-59.98 208.26,-64.78"/>
|
<polygon fill="black" stroke="black" points="210.14,-64.56 215.5,-56.67 206.39,-59.49 210.14,-64.56"/>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 17 KiB |
@@ -4,8 +4,8 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "./bin/webpack-dev-server",
|
"dev": "./bin/webpack-dev-server",
|
||||||
"lint": "eslint --ext .jsx,.js,.tsx,.ts app/javascript/",
|
"lint": "eslint --ext .tsx,.ts app/javascript/",
|
||||||
"lint:fix": "eslint --fix --ext .jsx,.js,.tsx,.ts app/javascript/",
|
"lint:fix": "eslint --fix --ext .tsx,.ts app/javascript/",
|
||||||
"tsc": "tsc --noEmit",
|
"tsc": "tsc --noEmit",
|
||||||
"relay": "relay-compiler",
|
"relay": "relay-compiler",
|
||||||
"relay:watch": "yarn relay --watch"
|
"relay:watch": "yarn relay --watch"
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{js,jsx,ts,tsx}": [
|
"*.{ts,tsx}": [
|
||||||
"yarn lint"
|
"yarn lint"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,26 +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)
|
|
||||||
#
|
|
||||||
FactoryBot.define do
|
|
||||||
factory :balance do
|
|
||||||
association :user
|
|
||||||
amount { (rand * (10000 - 0) + 0) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -27,12 +27,9 @@ RSpec.describe(Mutations::CreateSellCryptoOrder, type: :mutation) do
|
|||||||
GQL
|
GQL
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the user has enough balance" do
|
context "when attributes are valid " do
|
||||||
it "withdraws from his account and creates a buy order" do
|
it "creates a buy order" do
|
||||||
user = create(
|
user = create(:user)
|
||||||
:user,
|
|
||||||
balance: build(:balance, amount: 1.0034)
|
|
||||||
)
|
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
"amount": "0.80",
|
"amount": "0.80",
|
||||||
@@ -58,45 +55,6 @@ RSpec.describe(Mutations::CreateSellCryptoOrder, type: :mutation) do
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
expect(user.balance.reload.amount.to_s).to(eq("0.2034"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when the user does not have enough balance" do
|
|
||||||
it "returns withdrawl error" do
|
|
||||||
user = create(
|
|
||||||
:user,
|
|
||||||
balance: build(:balance, amount: 0.0034)
|
|
||||||
)
|
|
||||||
|
|
||||||
variables = {
|
|
||||||
"amount": "0.80",
|
|
||||||
}
|
|
||||||
|
|
||||||
context = { current_user: user }
|
|
||||||
|
|
||||||
result = XStakeSchema.execute(
|
|
||||||
query_string,
|
|
||||||
variables: variables,
|
|
||||||
context: context
|
|
||||||
).to_h.with_indifferent_access
|
|
||||||
|
|
||||||
expect(result).to(eq({
|
|
||||||
"data" => {
|
|
||||||
"createSellCryptoOrder" => {
|
|
||||||
"errors" => [{
|
|
||||||
"fullMessages" => ["Quantia saldo insuficiente"],
|
|
||||||
"fieldName" => "amount",
|
|
||||||
"messages" => ["saldo insuficiente"],
|
|
||||||
"path" => ["attributes", "amount"],
|
|
||||||
}],
|
|
||||||
"order" => nil,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
|
||||||
expect(user.balance.reload.amount.to_s).to(eq("0.0034"))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,12 +31,9 @@ RSpec.describe(Mutations::CreateStakeOrder, type: :mutation) do
|
|||||||
GQL
|
GQL
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the user has enough balance" do
|
context "when attributes are valid" do
|
||||||
it "withdraws from his account and creates a buy order" do
|
it "creates a buy order" do
|
||||||
user = create(
|
user = create(:user)
|
||||||
:user,
|
|
||||||
balance: build(:balance, amount: 1.0034)
|
|
||||||
)
|
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
"amount": "0.80",
|
"amount": "0.80",
|
||||||
@@ -64,46 +61,6 @@ RSpec.describe(Mutations::CreateStakeOrder, type: :mutation) do
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
expect(user.balance.reload.amount.to_s).to(eq("0.2034"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when the user does not have enough balance" do
|
|
||||||
it "returns withdrawl error" do
|
|
||||||
user = create(
|
|
||||||
:user,
|
|
||||||
balance: build(:balance, amount: 0.0034)
|
|
||||||
)
|
|
||||||
|
|
||||||
variables = {
|
|
||||||
"amount": "0.80",
|
|
||||||
"poolName": "CAKE/BNB",
|
|
||||||
}
|
|
||||||
|
|
||||||
context = { current_user: user }
|
|
||||||
|
|
||||||
result = XStakeSchema.execute(
|
|
||||||
query_string,
|
|
||||||
variables: variables,
|
|
||||||
context: context
|
|
||||||
).to_h.with_indifferent_access
|
|
||||||
|
|
||||||
expect(result).to(eq({
|
|
||||||
"data" => {
|
|
||||||
"createStakeOrder" => {
|
|
||||||
"errors" => [{
|
|
||||||
"fullMessages" => ["Quantia saldo insuficiente"],
|
|
||||||
"fieldName" => "amount",
|
|
||||||
"messages" => ["saldo insuficiente"],
|
|
||||||
"path" => ["attributes", "amount"],
|
|
||||||
}],
|
|
||||||
"order" => nil,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
|
||||||
expect(user.balance.reload.amount.to_s).to(eq("0.0034"))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,11 +32,8 @@ RSpec.describe(Mutations::CreateStakeRemoveOrder, type: :mutation) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "when the user has enough balance" do
|
context "when the user has enough balance" do
|
||||||
it "withdraws from his account and creates a buy order" do
|
it "creates a stake order" do
|
||||||
user = create(
|
user = create(:user)
|
||||||
:user,
|
|
||||||
balance: build(:balance, amount: 0)
|
|
||||||
)
|
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
"amount": "200.80",
|
"amount": "200.80",
|
||||||
@@ -69,10 +66,7 @@ RSpec.describe(Mutations::CreateStakeRemoveOrder, type: :mutation) do
|
|||||||
|
|
||||||
context "when it repeats the mutation with a request in `processing`" do
|
context "when it repeats the mutation with a request in `processing`" do
|
||||||
it "update amount from the order" do
|
it "update amount from the order" do
|
||||||
user = create(
|
user = create(:user)
|
||||||
:user,
|
|
||||||
balance: build(:balance, amount: 0)
|
|
||||||
)
|
|
||||||
|
|
||||||
create(:stake_order, amount: -200.8, user: user, pool_name: "CAKE/BNB")
|
create(:stake_order, amount: -200.8, user: user, pool_name: "CAKE/BNB")
|
||||||
|
|
||||||
|
|||||||
@@ -1,59 +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)
|
|
||||||
#
|
|
||||||
require "rails_helper"
|
|
||||||
|
|
||||||
RSpec.describe(Balance, type: :model) do
|
|
||||||
describe "validations" do
|
|
||||||
it { is_expected.to(validate_presence_of(:amount)) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "associations" do
|
|
||||||
it { is_expected.to(belong_to(:user)) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe ".withdrwal!" do
|
|
||||||
context "when value is greater than the balance" do
|
|
||||||
it "raise ActiveRecord::RecordInvalid" do
|
|
||||||
balance = build(:balance, amount: 70.342)
|
|
||||||
|
|
||||||
expect { balance.withdrawal!(80) }.to(
|
|
||||||
raise_error(ActiveRecord::RecordInvalid, "A validação falhou: Quantia saldo insuficiente")
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when value is equals to the balance" do
|
|
||||||
it "returns true" do
|
|
||||||
balance = build(:balance, amount: 70.342)
|
|
||||||
|
|
||||||
expect(balance.withdrawal!(70.342)).to(eq(true))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when value is smaller than the balance" do
|
|
||||||
it "returns true" do
|
|
||||||
balance = build(:balance, amount: 70.342)
|
|
||||||
|
|
||||||
expect(balance.withdrawal!(20)).to(eq(true))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -33,7 +33,6 @@ RSpec.describe(User, type: :model) do
|
|||||||
describe "associations" do
|
describe "associations" do
|
||||||
it { is_expected.to(have_many(:documents)) }
|
it { is_expected.to(have_many(:documents)) }
|
||||||
it { is_expected.to(have_many(:stake_orders)) }
|
it { is_expected.to(have_many(:stake_orders)) }
|
||||||
it { is_expected.to(have_one(:balance)) }
|
|
||||||
it { is_expected.to(have_one(:fiat_balance)) }
|
it { is_expected.to(have_one(:fiat_balance)) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
require "rails_helper"
|
|
||||||
|
|
||||||
RSpec.describe(BalancePolicy, type: :policy) do
|
|
||||||
context "when user has balances" do
|
|
||||||
it "return only balances from a user" do
|
|
||||||
create(:balance)
|
|
||||||
create(:balance)
|
|
||||||
|
|
||||||
user = build(:user)
|
|
||||||
balance = create(:balance, user: user)
|
|
||||||
|
|
||||||
balances = BalancePolicy::Scope.new(user, Balance).resolve
|
|
||||||
|
|
||||||
expect(balances).to(eq([balance]))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when user has not balances" do
|
|
||||||
it "return empty array" do
|
|
||||||
create(:balance)
|
|
||||||
create(:balance)
|
|
||||||
|
|
||||||
user = build(:user)
|
|
||||||
|
|
||||||
balances = BalancePolicy::Scope.new(user, Balance).resolve
|
|
||||||
|
|
||||||
expect(balances).to(eq([]))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when user is nil" do
|
|
||||||
it "return empty array" do
|
|
||||||
create(:balance)
|
|
||||||
create(:balance)
|
|
||||||
|
|
||||||
balances = BalancePolicy::Scope.new(nil, Balance).resolve
|
|
||||||
|
|
||||||
expect(balances).to(eq([]))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user