remove crypto balance from backend

This commit is contained in:
João Geonizeli
2021-09-13 20:54:21 -03:00
parent d43939dee4
commit d6b6b997d5
33 changed files with 836 additions and 1422 deletions

View File

@@ -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!

View File

@@ -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 () => {

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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"
}
};
})();

View File

@@ -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">

View File

@@ -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>

View File

@@ -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;

View File

@@ -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;