fix eslint and types
This commit is contained in:
25
app/javascript/__generated__/schema.graphql
generated
25
app/javascript/__generated__/schema.graphql
generated
@@ -39,7 +39,7 @@ type BuyCryptoOrder implements Node {
|
||||
currency: Currency!
|
||||
id: ID!
|
||||
paidAmountCents: Int!
|
||||
receivedAmount: Float
|
||||
receivedAmount: String
|
||||
status: ProcessStatus!
|
||||
updatedAt: ISO8601DateTime!
|
||||
}
|
||||
@@ -78,7 +78,7 @@ input CreateBuyCryptoOrderAttributesInput {
|
||||
"""
|
||||
Amount to be paid
|
||||
"""
|
||||
amount: Float!
|
||||
amountCents: Int!
|
||||
currencyId: ID!
|
||||
}
|
||||
|
||||
@@ -105,15 +105,15 @@ type CreateBuyCryptoOrderPayload {
|
||||
"""
|
||||
Errors encountered during execution of the mutation.
|
||||
"""
|
||||
errors: [String!]
|
||||
order: BuyCryptoOrder!
|
||||
errors: [RecordInvalid!]
|
||||
order: BuyCryptoOrder
|
||||
}
|
||||
|
||||
input CreateSellCryptoOrderAttributesInput {
|
||||
"""
|
||||
Amount to be paid
|
||||
"""
|
||||
amount: Float!
|
||||
amount: String!
|
||||
currencyId: ID!
|
||||
}
|
||||
|
||||
@@ -140,8 +140,8 @@ type CreateSellCryptoOrderPayload {
|
||||
"""
|
||||
Errors encountered during execution of the mutation.
|
||||
"""
|
||||
errors: [String!]
|
||||
order: SellCryptoOrder!
|
||||
errors: [RecordInvalid!]
|
||||
order: SellCryptoOrder
|
||||
}
|
||||
|
||||
type Currency implements Node {
|
||||
@@ -152,9 +152,7 @@ type Currency implements Node {
|
||||
type FiatBalance implements Node {
|
||||
amountCents: Int!
|
||||
amountCurrency: String!
|
||||
createdAt: ISO8601DateTime!
|
||||
id: ID!
|
||||
updatedAt: ISO8601DateTime!
|
||||
}
|
||||
|
||||
"""
|
||||
@@ -356,11 +354,18 @@ type Query {
|
||||
): SellCryptoOrderConnection!
|
||||
}
|
||||
|
||||
type RecordInvalid {
|
||||
fieldName: String
|
||||
fullMessages: [String!]!
|
||||
messages: [String!]
|
||||
path: [String!]
|
||||
}
|
||||
|
||||
type SellCryptoOrder implements Node {
|
||||
createdAt: ISO8601DateTime!
|
||||
currency: Currency!
|
||||
id: ID!
|
||||
paidAmount: Float!
|
||||
paidAmount: String!
|
||||
receivedAmountCents: Int
|
||||
status: ProcessStatus!
|
||||
updatedAt: ISO8601DateTime!
|
||||
|
||||
@@ -10,11 +10,11 @@ import { Routes } from "./Routes";
|
||||
import type { AppQuery } from "./__generated__/AppQuery.graphql";
|
||||
|
||||
export const App: FC = () => {
|
||||
const { currentUser } = useLazyLoadQuery<AppQuery>(
|
||||
const data = useLazyLoadQuery<AppQuery>(
|
||||
graphql`
|
||||
query AppQuery {
|
||||
currentUser {
|
||||
firstName
|
||||
...UserProvider_user
|
||||
}
|
||||
}
|
||||
`,
|
||||
@@ -23,7 +23,7 @@ export const App: FC = () => {
|
||||
|
||||
return (
|
||||
<AppProvider>
|
||||
<UserProvider user={currentUser}>
|
||||
<UserProvider userRef={data.currentUser}>
|
||||
<main className="min-h-screen w-full bg-gray-50 flex flex-col">
|
||||
<Navbar />
|
||||
<div className="flex flex-grow">
|
||||
|
||||
40
app/javascript/src/__generated__/AppQuery.graphql.ts
generated
40
app/javascript/src/__generated__/AppQuery.graphql.ts
generated
@@ -3,10 +3,11 @@
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from "relay-runtime";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type AppQueryVariables = {};
|
||||
export type AppQueryResponse = {
|
||||
readonly currentUser: {
|
||||
readonly firstName: string;
|
||||
readonly " $fragmentRefs": FragmentRefs<"UserProvider_user">;
|
||||
} | null;
|
||||
};
|
||||
export type AppQuery = {
|
||||
@@ -19,21 +20,17 @@ export type AppQuery = {
|
||||
/*
|
||||
query AppQuery {
|
||||
currentUser {
|
||||
firstName
|
||||
...UserProvider_user
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
fragment UserProvider_user on User {
|
||||
firstName
|
||||
}
|
||||
*/
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "firstName",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
const node: ConcreteRequest = {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
@@ -48,7 +45,11 @@ return {
|
||||
"name": "currentUser",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v0/*: any*/)
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "UserProvider_user"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -70,7 +71,13 @@ return {
|
||||
"name": "currentUser",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v0/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "firstName",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -84,14 +91,13 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "ecf2bf1a08ead5c3e2edb202242ed8cf",
|
||||
"cacheID": "ce9692d3fdea00e7368e2a6404748f16",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "AppQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query AppQuery {\n currentUser {\n firstName\n id\n }\n}\n"
|
||||
"text": "query AppQuery {\n currentUser {\n ...UserProvider_user\n id\n }\n}\n\nfragment UserProvider_user on User {\n firstName\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
(node as any).hash = 'ea65c9caf86d93b8ddded2ae3eaa7b0e';
|
||||
(node as any).hash = 'aac57a65620cf50754d54f3c8d6495cf';
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React from "react";
|
||||
import BigNumber from "bignumber.js";
|
||||
|
||||
import type { PoolConfig } from "../types";
|
||||
import { useBsc } from "../contexts/BscProvider";
|
||||
@@ -32,6 +31,7 @@ export const Pool = ({ pool }: PoolProps) => {
|
||||
|
||||
const totalStaked = await getTotalStaked(provider, pool);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
`Total Staked for ${pool.stakingToken.symbol} - ${
|
||||
pool.earningToken.symbol
|
||||
@@ -52,7 +52,7 @@ export const Pool = ({ pool }: PoolProps) => {
|
||||
});
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
}, [pool, provider, router]);
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -95,4 +95,4 @@ export const Pool = ({ pool }: PoolProps) => {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -9,7 +9,9 @@ export const PoolListing = () => {
|
||||
{pools
|
||||
.filter((pool) => !pool.isFinished)
|
||||
.sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0))
|
||||
.map((pool) => <Pool key={pool.sousId} pool={pool} />)}
|
||||
.map((pool) => (
|
||||
<Pool key={pool.sousId} pool={pool} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -3,4 +3,4 @@ import BigNumber from "bignumber.js";
|
||||
export const BSC_BLOCK_TIME = 3;
|
||||
export const BLOCKS_PER_YEAR = new BigNumber(
|
||||
(60 / BSC_BLOCK_TIME) * 60 * 24 * 365
|
||||
);
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { FC } from "react";
|
||||
import React, { useContext } from "react";
|
||||
import { ethers } from "ethers";
|
||||
|
||||
@@ -37,7 +38,7 @@ export const useBsc = () => {
|
||||
return context;
|
||||
};
|
||||
|
||||
export const BscProvider = ({ children }: React.PropsWithChildren<any>) => {
|
||||
export const BscProvider: FC = ({ children }) => {
|
||||
const value: BscContext = {
|
||||
provider,
|
||||
pancake: {
|
||||
@@ -46,4 +47,4 @@ export const BscProvider = ({ children }: React.PropsWithChildren<any>) => {
|
||||
};
|
||||
|
||||
return <Context.Provider value={value}>{children}</Context.Provider>;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import type { FC } from "react";
|
||||
import React, { createContext, useContext } from "react";
|
||||
import { useFragment } from "react-relay";
|
||||
import { graphql } from "babel-plugin-relay/macro";
|
||||
|
||||
import type { UserProvider_user$key } from "./__generated__/UserProvider_user.graphql";
|
||||
|
||||
type CurrentUserContext = {
|
||||
user: {
|
||||
readonly firstName: string;
|
||||
firstName: string;
|
||||
} | null;
|
||||
isAuthenticated: boolean;
|
||||
};
|
||||
@@ -20,13 +24,33 @@ export const useCurrentUser = (): CurrentUserContext => {
|
||||
};
|
||||
|
||||
type Props = {
|
||||
user: {
|
||||
readonly firstName: string;
|
||||
} | null;
|
||||
userRef: UserProvider_user$key | null;
|
||||
};
|
||||
|
||||
export const UserProvider: FC<Props> = ({ user, children }) => (
|
||||
<Context.Provider value={{ user, isAuthenticated: !!user }}>
|
||||
{children}
|
||||
</Context.Provider>
|
||||
);
|
||||
export const UserProvider: FC<Props> = ({ userRef, children }) => {
|
||||
const userData = useFragment<UserProvider_user$key>(
|
||||
graphql`
|
||||
fragment UserProvider_user on User {
|
||||
firstName
|
||||
}
|
||||
`,
|
||||
userRef
|
||||
);
|
||||
|
||||
const user = userData
|
||||
? {
|
||||
firstName: userData.firstName,
|
||||
}
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Context.Provider
|
||||
value={{
|
||||
user,
|
||||
isAuthenticated: !!user,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</Context.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
37
app/javascript/src/contexts/__generated__/UserProvider_user.graphql.ts
generated
Normal file
37
app/javascript/src/contexts/__generated__/UserProvider_user.graphql.ts
generated
Normal file
@@ -0,0 +1,37 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ReaderFragment } from "relay-runtime";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type UserProvider_user = {
|
||||
readonly firstName: string;
|
||||
readonly " $refType": "UserProvider_user";
|
||||
};
|
||||
export type UserProvider_user$data = UserProvider_user;
|
||||
export type UserProvider_user$key = {
|
||||
readonly " $data"?: UserProvider_user$data;
|
||||
readonly " $fragmentRefs": FragmentRefs<"UserProvider_user">;
|
||||
};
|
||||
|
||||
|
||||
|
||||
const node: ReaderFragment = {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "UserProvider_user",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "firstName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "User",
|
||||
"abstractKey": null
|
||||
};
|
||||
(node as any).hash = '352cdd208485d062f3f7c2e22e287a99';
|
||||
export default node;
|
||||
@@ -14,7 +14,6 @@ export const FiatBalances: FC<Props> = ({ fiatBalancesRef }) => {
|
||||
fragment FiatBalances_fiatBalances on FiatBalanceConnection {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
amountCents
|
||||
amountCurrency
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import { FragmentRefs } from "relay-runtime";
|
||||
export type FiatBalances_fiatBalances = {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly id: string;
|
||||
readonly amountCents: number;
|
||||
readonly amountCurrency: string;
|
||||
};
|
||||
@@ -44,13 +43,6 @@ const node: ReaderFragment = {
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -75,5 +67,5 @@ const node: ReaderFragment = {
|
||||
"type": "FiatBalanceConnection",
|
||||
"abstractKey": null
|
||||
};
|
||||
(node as any).hash = '106c8efa69b9cde5af510a15c2493ba6';
|
||||
(node as any).hash = 'a1454d1a8afc3cffb17cbfbe9e3555f7';
|
||||
export default node;
|
||||
|
||||
@@ -46,9 +46,9 @@ fragment Balances_balances on BalanceConnection {
|
||||
fragment FiatBalances_fiatBalances on FiatBalanceConnection {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
amountCents
|
||||
amountCurrency
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,6 @@ return {
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v0/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -149,7 +148,8 @@ return {
|
||||
"kind": "ScalarField",
|
||||
"name": "amountCurrency",
|
||||
"storageKey": null
|
||||
}
|
||||
},
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -222,12 +222,12 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "3c87fba4bacbbbe14fd4b584bfb1f7bb",
|
||||
"cacheID": "6acfc80d1e8d7c882a03e25cc7902d72",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "WalletQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query WalletQuery {\n fiatBalances {\n ...FiatBalances_fiatBalances\n }\n balances {\n ...Balances_balances\n }\n}\n\nfragment Balances_balances on BalanceConnection {\n edges {\n node {\n id\n amount\n currency {\n name\n id\n }\n }\n }\n}\n\nfragment FiatBalances_fiatBalances on FiatBalanceConnection {\n edges {\n node {\n id\n amountCents\n amountCurrency\n }\n }\n}\n"
|
||||
"text": "query WalletQuery {\n fiatBalances {\n ...FiatBalances_fiatBalances\n }\n balances {\n ...Balances_balances\n }\n}\n\nfragment Balances_balances on BalanceConnection {\n edges {\n node {\n id\n amount\n currency {\n name\n id\n }\n }\n }\n}\n\nfragment FiatBalances_fiatBalances on FiatBalanceConnection {\n edges {\n node {\n amountCents\n amountCurrency\n id\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -19,4 +19,4 @@ export const getApr = (
|
||||
const apr = totalRewardPricePerYear.div(totalStakingTokenInPool).times(100);
|
||||
|
||||
return apr.isNaN() || !apr.isFinite() ? null : apr.toNumber();
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { Contract } from "ethers";
|
||||
import { ethers } from "ethers";
|
||||
|
||||
import { tokens } from "../constants/pancake/Tokens";
|
||||
import type { Token } from "../constants/pancake/Tokens";
|
||||
import type { BscContext } from "../contexts/BscProvider";
|
||||
|
||||
// 1 Wei = 1*10^18 Ether
|
||||
const ONE_BUSD_IN_WEI = ethers.utils.parseUnits("1", 18);
|
||||
|
||||
export const getPriceInBusd = async (router: any, token: Token) => {
|
||||
export const getPriceInBusd = async (router: Contract, token: Token) => {
|
||||
try {
|
||||
const result = await router.getAmountsOut(ONE_BUSD_IN_WEI, [
|
||||
token.address["56"],
|
||||
@@ -18,4 +18,4 @@ export const getPriceInBusd = async (router: any, token: Token) => {
|
||||
} catch {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@ import { ethers } from "ethers";
|
||||
import BigNumber from "bignumber.js";
|
||||
|
||||
import erc20 from "../abi/erc20.json";
|
||||
import { Token } from "../constants/pancake/Tokens";
|
||||
import type { PoolConfig } from "../types";
|
||||
|
||||
export const getTotalStaked = async (
|
||||
@@ -27,4 +26,4 @@ export const getTotalStaked = async (
|
||||
} catch {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user