add mutations to exchange painel
This commit is contained in:
@@ -42,7 +42,7 @@ export const Pool = ({ pool }: PoolProps) => {
|
||||
rewardTokenPrice: earningPrice,
|
||||
stakingTokenPrice: stakingPrice,
|
||||
tokenPerBlock: parseFloat(pool.tokenPerBlock) / 1e-18,
|
||||
totalStaked: totalStaked,
|
||||
totalStaked,
|
||||
});
|
||||
|
||||
if (aprValue) {
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
|
||||
import { pools } from "../constants/Pools";
|
||||
import { Pool } from "./Poo";
|
||||
import { Pool } from "./Pool";
|
||||
|
||||
export const PoolListing = () => {
|
||||
return (
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export * from "./CreateExchangeOrderModal";
|
||||
@@ -1,23 +1,21 @@
|
||||
/* eslint-disable relay/must-colocate-fragment-spreads */
|
||||
import { graphql } from "babel-plugin-relay/macro";
|
||||
import React, { useState } from "react";
|
||||
import React from "react";
|
||||
import { useLazyLoadQuery } from "react-relay";
|
||||
|
||||
import { CreateExchangeOrderModal } from "./CreateExchangeOrderModel";
|
||||
import { ExchangePanel } from "./ExchangePanel";
|
||||
import { ExchangeHistory } from "./ExchangeHistory";
|
||||
import type { ExchangeQuery } from "./__generated__/ExchangeQuery.graphql";
|
||||
|
||||
export const Exchange = () => {
|
||||
const [modelOpen] = useState<boolean>(false);
|
||||
|
||||
const data = useLazyLoadQuery<ExchangeQuery>(
|
||||
graphql`
|
||||
query ExchangeQuery {
|
||||
fiatBalances {
|
||||
...CreateExchangeOrderModal_fiatBalances
|
||||
...ExchangePanel_fiatBalances
|
||||
}
|
||||
balances {
|
||||
...CreateExchangeOrderModal_balances
|
||||
...ExchangePanel_balances
|
||||
}
|
||||
buyCryptoOrders {
|
||||
...ExchangeHistory_buyCryptoOrders
|
||||
@@ -32,16 +30,15 @@ export const Exchange = () => {
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
<ExchangePanel
|
||||
balancesRefs={data.balances}
|
||||
fiatBalancesRefs={data.fiatBalances}
|
||||
/>
|
||||
|
||||
<ExchangeHistory
|
||||
sellCryptoOrdersRefs={data.sellCryptoOrders}
|
||||
buyCryptoOrdersRefs={data.buyCryptoOrders}
|
||||
/>
|
||||
{modelOpen && (
|
||||
<CreateExchangeOrderModal
|
||||
balancesRefs={data.balances}
|
||||
fiatBalancesRefs={data.fiatBalances}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -83,8 +83,8 @@ export const ExchangeHistory: FC<Props> = ({
|
||||
|
||||
const allResultsOrdeneds = allResults.sort((item1, item2) => {
|
||||
return (
|
||||
new Date(item1.node.createdAt as string).getTime() -
|
||||
new Date(item2.node.createdAt as string).getTime()
|
||||
new Date(item2.node.createdAt as string).getTime() -
|
||||
new Date(item1.node.createdAt as string).getTime()
|
||||
);
|
||||
}) as SellOrBuyOrder[];
|
||||
|
||||
@@ -117,6 +117,8 @@ export const ExchangeHistory: FC<Props> = ({
|
||||
return null;
|
||||
});
|
||||
|
||||
if (!orderRows.length) return null;
|
||||
|
||||
return (
|
||||
<div className="container mx-auto px-4 sm:px-8">
|
||||
<div className="py-8">
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import React, { useState } from "react";
|
||||
import type { FC } from "react";
|
||||
import { graphql } from "babel-plugin-relay/macro";
|
||||
import { useFragment } from "react-relay";
|
||||
import { useFragment, useRelayEnvironment } from "react-relay";
|
||||
import { BigNumber } from "bignumber.js";
|
||||
import cx from "classnames";
|
||||
|
||||
import { useCurrentUser } from "../../../../contexts/UserProvider";
|
||||
import { Unauthenticated } from "../../../../messages/Unauthenticated";
|
||||
import type { CreateExchangeOrderModal_fiatBalances$key } from "./__generated__/CreateExchangeOrderModal_fiatBalances.graphql";
|
||||
import type { CreateExchangeOrderModal_balances$key } from "./__generated__/CreateExchangeOrderModal_balances.graphql";
|
||||
import type { ExchangePanel_fiatBalances$key } from "./__generated__/ExchangePanel_fiatBalances.graphql";
|
||||
import type { ExchangePanel_balances$key } from "./__generated__/ExchangePanel_balances.graphql";
|
||||
import { commitCreateSellCryptoOrderMutation } from "./createSellCryptoOrder";
|
||||
import { commitCreateBuyCryptoOrderMutation } from "./createBuyCryptoOrder";
|
||||
|
||||
const tabBaseStyles =
|
||||
"w-full text-base font-bold text-black px-4 py-2 focus:ring-blue-500";
|
||||
@@ -20,22 +22,23 @@ const inputBaseStyles =
|
||||
"rounded-lg border-transparent flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-gray-700 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-transparent mb-3";
|
||||
|
||||
type Props = {
|
||||
fiatBalancesRefs: CreateExchangeOrderModal_fiatBalances$key;
|
||||
balancesRefs: CreateExchangeOrderModal_balances$key;
|
||||
fiatBalancesRefs: ExchangePanel_fiatBalances$key;
|
||||
balancesRefs: ExchangePanel_balances$key;
|
||||
};
|
||||
|
||||
export const CreateExchangeOrderModal: FC<Props> = ({
|
||||
export const ExchangePanel: FC<Props> = ({
|
||||
fiatBalancesRefs,
|
||||
balancesRefs,
|
||||
}) => {
|
||||
const { isAuthenticated } = useCurrentUser();
|
||||
const environment = useRelayEnvironment();
|
||||
const [exchangeOption, setExchangeOption] = useState<"BUY" | "SELL">("BUY");
|
||||
const [cryptoDock, setCryptoDock] = useState<string>("0");
|
||||
const [fiatDock, setFiatDock] = useState<string>("0.00");
|
||||
|
||||
const fiatBalances = useFragment<CreateExchangeOrderModal_fiatBalances$key>(
|
||||
const fiatBalances = useFragment<ExchangePanel_fiatBalances$key>(
|
||||
graphql`
|
||||
fragment CreateExchangeOrderModal_fiatBalances on FiatBalanceConnection {
|
||||
fragment ExchangePanel_fiatBalances on FiatBalanceConnection {
|
||||
edges {
|
||||
node {
|
||||
amountCents
|
||||
@@ -46,12 +49,15 @@ export const CreateExchangeOrderModal: FC<Props> = ({
|
||||
fiatBalancesRefs
|
||||
);
|
||||
|
||||
const balances = useFragment<CreateExchangeOrderModal_balances$key>(
|
||||
const balances = useFragment<ExchangePanel_balances$key>(
|
||||
graphql`
|
||||
fragment CreateExchangeOrderModal_balances on BalanceConnection {
|
||||
fragment ExchangePanel_balances on BalanceConnection {
|
||||
edges {
|
||||
node {
|
||||
amount
|
||||
currency {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +66,7 @@ export const CreateExchangeOrderModal: FC<Props> = ({
|
||||
);
|
||||
|
||||
if (!isAuthenticated) return <Unauthenticated />;
|
||||
|
||||
const [crypto] = balances.edges;
|
||||
const [fiat] = fiatBalances.edges;
|
||||
|
||||
@@ -83,7 +90,10 @@ export const CreateExchangeOrderModal: FC<Props> = ({
|
||||
}: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const newCryptoAmount = new BigNumber(value);
|
||||
|
||||
if (newCryptoAmount.isLessThanOrEqualTo(avaliableCrypto)) {
|
||||
if (
|
||||
newCryptoAmount.isLessThanOrEqualTo(avaliableCrypto) &&
|
||||
newCryptoAmount.isGreaterThanOrEqualTo(0)
|
||||
) {
|
||||
setCryptoDock(value);
|
||||
}
|
||||
};
|
||||
@@ -91,9 +101,10 @@ export const CreateExchangeOrderModal: FC<Props> = ({
|
||||
const handleFiatAmountChange = ({
|
||||
currentTarget: { value },
|
||||
}: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const newFiatAmount = Number(value);
|
||||
const newFiatAmount = parseInt(value, 10);
|
||||
const avaliableFiatAmount = parseInt(avaliableFiat, 10);
|
||||
|
||||
if (Number(avaliableFiat) >= newFiatAmount) {
|
||||
if (newFiatAmount <= avaliableFiatAmount && newFiatAmount >= 0) {
|
||||
setFiatDock(value);
|
||||
}
|
||||
};
|
||||
@@ -106,8 +117,33 @@ export const CreateExchangeOrderModal: FC<Props> = ({
|
||||
setCryptoDock(avaliableCrypto.toString());
|
||||
};
|
||||
|
||||
const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (exchangeOption === "SELL") {
|
||||
commitCreateSellCryptoOrderMutation(environment, {
|
||||
amount: cryptoDock,
|
||||
currencyId: crypto.node.currency.id,
|
||||
});
|
||||
}
|
||||
|
||||
if (exchangeOption === "BUY") {
|
||||
const [amountCents] = fiatDock.split(".");
|
||||
|
||||
commitCreateBuyCryptoOrderMutation(environment, {
|
||||
amountCents: parseInt(amountCents, 10),
|
||||
currencyId: crypto.node.currency.id,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const submitDisabled =
|
||||
(exchangeOption === "BUY" && parseInt(fiatDock, 10) <= 0) ||
|
||||
(exchangeOption === "SELL" &&
|
||||
new BigNumber(cryptoDock).isLessThanOrEqualTo(0));
|
||||
|
||||
return (
|
||||
<div className="max-w-lg">
|
||||
<div className="max-w-lg mx-auto mt-16">
|
||||
<div className="flex items-center bg-white rounded-full border border-gray-200 mb-3">
|
||||
<button
|
||||
type="button"
|
||||
@@ -132,7 +168,10 @@ export const CreateExchangeOrderModal: FC<Props> = ({
|
||||
Vender
|
||||
</button>
|
||||
</div>
|
||||
<form className="bg-white p-4 rounded-2xl border border-gray-200">
|
||||
<form
|
||||
onSubmit={onSubmit}
|
||||
className="bg-white p-4 rounded-2xl border border-gray-200"
|
||||
>
|
||||
<span className="mb-2">
|
||||
{exchangeOption === "SELL" ? "CAKE" : "BRL"} disponível:{" "}
|
||||
{exchangeOption === "SELL" ? crypto.node.amount : avaliableFiat}
|
||||
@@ -176,8 +215,9 @@ export const CreateExchangeOrderModal: FC<Props> = ({
|
||||
</div>
|
||||
|
||||
<button
|
||||
className="cursor-pointer py-2 px-4 bg-blue-600 hover:bg-blue-700 focus:ring-blue-500 focus:ring-offset-blue-200 text-white w-full transition ease-in duration-200 text-center text-base font-semibold shadow-md focus:outline-none focus:ring-2 focus:ring-offset-2 rounded-lg"
|
||||
className="cursor-pointer py-2 px-4 disabled:opacity-50 disabled:cursor-default bg-blue-600 hover:bg-blue-700 focus:ring-blue-500 focus:ring-offset-blue-200 text-white w-full transition ease-in duration-200 text-center text-base font-semibold shadow-md focus:outline-none focus:ring-2 focus:ring-offset-2 rounded-lg"
|
||||
type="submit"
|
||||
disabled={submitDisabled}
|
||||
>
|
||||
{exchangeOption === "BUY" ? "Comprar" : "Vender"} CAKE
|
||||
</button>
|
||||
@@ -4,18 +4,21 @@
|
||||
|
||||
import { ReaderFragment } from "relay-runtime";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type CreateExchangeOrderModal_balances = {
|
||||
export type ExchangePanel_balances = {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly amount: string;
|
||||
readonly currency: {
|
||||
readonly id: string;
|
||||
};
|
||||
};
|
||||
}>;
|
||||
readonly " $refType": "CreateExchangeOrderModal_balances";
|
||||
readonly " $refType": "ExchangePanel_balances";
|
||||
};
|
||||
export type CreateExchangeOrderModal_balances$data = CreateExchangeOrderModal_balances;
|
||||
export type CreateExchangeOrderModal_balances$key = {
|
||||
readonly " $data"?: CreateExchangeOrderModal_balances$data;
|
||||
readonly " $fragmentRefs": FragmentRefs<"CreateExchangeOrderModal_balances">;
|
||||
export type ExchangePanel_balances$data = ExchangePanel_balances;
|
||||
export type ExchangePanel_balances$key = {
|
||||
readonly " $data"?: ExchangePanel_balances$data;
|
||||
readonly " $fragmentRefs": FragmentRefs<"ExchangePanel_balances">;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +27,7 @@ const node: ReaderFragment = {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "CreateExchangeOrderModal_balances",
|
||||
"name": "ExchangePanel_balances",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
@@ -48,6 +51,24 @@ const node: ReaderFragment = {
|
||||
"kind": "ScalarField",
|
||||
"name": "amount",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Currency",
|
||||
"kind": "LinkedField",
|
||||
"name": "currency",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -59,5 +80,5 @@ const node: ReaderFragment = {
|
||||
"type": "BalanceConnection",
|
||||
"abstractKey": null
|
||||
};
|
||||
(node as any).hash = '42aad1bd63f1135b4d99ec236cd945b5';
|
||||
(node as any).hash = '3be851ad99a353609459a7edc960f272';
|
||||
export default node;
|
||||
@@ -4,18 +4,18 @@
|
||||
|
||||
import { ReaderFragment } from "relay-runtime";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type CreateExchangeOrderModal_fiatBalances = {
|
||||
export type ExchangePanel_fiatBalances = {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly amountCents: number;
|
||||
};
|
||||
}>;
|
||||
readonly " $refType": "CreateExchangeOrderModal_fiatBalances";
|
||||
readonly " $refType": "ExchangePanel_fiatBalances";
|
||||
};
|
||||
export type CreateExchangeOrderModal_fiatBalances$data = CreateExchangeOrderModal_fiatBalances;
|
||||
export type CreateExchangeOrderModal_fiatBalances$key = {
|
||||
readonly " $data"?: CreateExchangeOrderModal_fiatBalances$data;
|
||||
readonly " $fragmentRefs": FragmentRefs<"CreateExchangeOrderModal_fiatBalances">;
|
||||
export type ExchangePanel_fiatBalances$data = ExchangePanel_fiatBalances;
|
||||
export type ExchangePanel_fiatBalances$key = {
|
||||
readonly " $data"?: ExchangePanel_fiatBalances$data;
|
||||
readonly " $fragmentRefs": FragmentRefs<"ExchangePanel_fiatBalances">;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ const node: ReaderFragment = {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "CreateExchangeOrderModal_fiatBalances",
|
||||
"name": "ExchangePanel_fiatBalances",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
@@ -59,5 +59,5 @@ const node: ReaderFragment = {
|
||||
"type": "FiatBalanceConnection",
|
||||
"abstractKey": null
|
||||
};
|
||||
(node as any).hash = 'b3a734bd9e34e02aacfa42b6b95776a5';
|
||||
(node as any).hash = '14b79d15c8353d856f3e74bb7c181cf7';
|
||||
export default node;
|
||||
@@ -0,0 +1,160 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from "relay-runtime";
|
||||
export type createBuyCryptoOrderMutationVariables = {
|
||||
currencyId: string;
|
||||
amountCents: number;
|
||||
};
|
||||
export type createBuyCryptoOrderMutationResponse = {
|
||||
readonly createBuyCryptoOrder: {
|
||||
readonly errors: ReadonlyArray<{
|
||||
readonly messages: ReadonlyArray<string> | null;
|
||||
}> | null;
|
||||
readonly order: {
|
||||
readonly id: string;
|
||||
} | null;
|
||||
} | null;
|
||||
};
|
||||
export type createBuyCryptoOrderMutation = {
|
||||
readonly response: createBuyCryptoOrderMutationResponse;
|
||||
readonly variables: createBuyCryptoOrderMutationVariables;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
mutation createBuyCryptoOrderMutation(
|
||||
$currencyId: ID!
|
||||
$amountCents: Int!
|
||||
) {
|
||||
createBuyCryptoOrder(input: {order: {currencyId: $currencyId, amountCents: $amountCents}}) {
|
||||
errors {
|
||||
messages
|
||||
}
|
||||
order {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = {
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "amountCents"
|
||||
},
|
||||
v1 = {
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "currencyId"
|
||||
},
|
||||
v2 = [
|
||||
{
|
||||
"alias": null,
|
||||
"args": [
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "amountCents",
|
||||
"variableName": "amountCents"
|
||||
},
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "currencyId",
|
||||
"variableName": "currencyId"
|
||||
}
|
||||
],
|
||||
"kind": "ObjectValue",
|
||||
"name": "order"
|
||||
}
|
||||
],
|
||||
"kind": "ObjectValue",
|
||||
"name": "input"
|
||||
}
|
||||
],
|
||||
"concreteType": "CreateBuyCryptoOrderPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "createBuyCryptoOrder",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "RecordInvalid",
|
||||
"kind": "LinkedField",
|
||||
"name": "errors",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "messages",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "BuyCryptoOrder",
|
||||
"kind": "LinkedField",
|
||||
"name": "order",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
];
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "createBuyCryptoOrderMutation",
|
||||
"selections": (v2/*: any*/),
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "createBuyCryptoOrderMutation",
|
||||
"selections": (v2/*: any*/)
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "d7cc0c483d893b14f46781408d9d3f2f",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "createBuyCryptoOrderMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation createBuyCryptoOrderMutation(\n $currencyId: ID!\n $amountCents: Int!\n) {\n createBuyCryptoOrder(input: {order: {currencyId: $currencyId, amountCents: $amountCents}}) {\n errors {\n messages\n }\n order {\n id\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
(node as any).hash = 'a272ce6d5ae676a9cdc4e38eb7cc3cbe';
|
||||
export default node;
|
||||
@@ -0,0 +1,160 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from "relay-runtime";
|
||||
export type createSellCryptoOrderMutationVariables = {
|
||||
currencyId: string;
|
||||
amount: string;
|
||||
};
|
||||
export type createSellCryptoOrderMutationResponse = {
|
||||
readonly createSellCryptoOrder: {
|
||||
readonly errors: ReadonlyArray<{
|
||||
readonly messages: ReadonlyArray<string> | null;
|
||||
}> | null;
|
||||
readonly order: {
|
||||
readonly id: string;
|
||||
} | null;
|
||||
} | null;
|
||||
};
|
||||
export type createSellCryptoOrderMutation = {
|
||||
readonly response: createSellCryptoOrderMutationResponse;
|
||||
readonly variables: createSellCryptoOrderMutationVariables;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
mutation createSellCryptoOrderMutation(
|
||||
$currencyId: ID!
|
||||
$amount: String!
|
||||
) {
|
||||
createSellCryptoOrder(input: {order: {currencyId: $currencyId, amount: $amount}}) {
|
||||
errors {
|
||||
messages
|
||||
}
|
||||
order {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = {
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "amount"
|
||||
},
|
||||
v1 = {
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "currencyId"
|
||||
},
|
||||
v2 = [
|
||||
{
|
||||
"alias": null,
|
||||
"args": [
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "amount",
|
||||
"variableName": "amount"
|
||||
},
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "currencyId",
|
||||
"variableName": "currencyId"
|
||||
}
|
||||
],
|
||||
"kind": "ObjectValue",
|
||||
"name": "order"
|
||||
}
|
||||
],
|
||||
"kind": "ObjectValue",
|
||||
"name": "input"
|
||||
}
|
||||
],
|
||||
"concreteType": "CreateSellCryptoOrderPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "createSellCryptoOrder",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "RecordInvalid",
|
||||
"kind": "LinkedField",
|
||||
"name": "errors",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "messages",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "SellCryptoOrder",
|
||||
"kind": "LinkedField",
|
||||
"name": "order",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
];
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "createSellCryptoOrderMutation",
|
||||
"selections": (v2/*: any*/),
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "createSellCryptoOrderMutation",
|
||||
"selections": (v2/*: any*/)
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "2c81ae5adf76b4fa157bc5453df40fcc",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "createSellCryptoOrderMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation createSellCryptoOrderMutation(\n $currencyId: ID!\n $amount: String!\n) {\n createSellCryptoOrder(input: {order: {currencyId: $currencyId, amount: $amount}}) {\n errors {\n messages\n }\n order {\n id\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
(node as any).hash = '073e3f84d5921279ded3149dd9ec7db9';
|
||||
export default node;
|
||||
@@ -0,0 +1,37 @@
|
||||
import { graphql } from "babel-plugin-relay/macro";
|
||||
import type { Environment } from "react-relay";
|
||||
import { commitMutation } from "react-relay";
|
||||
|
||||
import type { createBuyCryptoOrderMutationVariables } from "./__generated__/createBuyCryptoOrderMutation.graphql";
|
||||
|
||||
export const commitCreateBuyCryptoOrderMutation = (
|
||||
environment: Environment,
|
||||
variables: createBuyCryptoOrderMutationVariables
|
||||
) => {
|
||||
return commitMutation(environment, {
|
||||
mutation: graphql`
|
||||
mutation createBuyCryptoOrderMutation(
|
||||
$currencyId: ID!
|
||||
$amountCents: Int!
|
||||
) {
|
||||
createBuyCryptoOrder(
|
||||
input: {
|
||||
order: { currencyId: $currencyId, amountCents: $amountCents }
|
||||
}
|
||||
) {
|
||||
errors {
|
||||
messages
|
||||
}
|
||||
order {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: { ...variables },
|
||||
onCompleted: (_response) => {
|
||||
window.location.reload();
|
||||
},
|
||||
onError: (_error) => {},
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
import { graphql } from "babel-plugin-relay/macro";
|
||||
import type { Environment } from "react-relay";
|
||||
import { commitMutation } from "react-relay";
|
||||
|
||||
import type { createSellCryptoOrderMutationVariables } from "./__generated__/createSellCryptoOrderMutation.graphql";
|
||||
|
||||
export const commitCreateSellCryptoOrderMutation = (
|
||||
environment: Environment,
|
||||
variables: createSellCryptoOrderMutationVariables
|
||||
) => {
|
||||
return commitMutation(environment, {
|
||||
mutation: graphql`
|
||||
mutation createSellCryptoOrderMutation(
|
||||
$currencyId: ID!
|
||||
$amount: String!
|
||||
) {
|
||||
createSellCryptoOrder(
|
||||
input: { order: { currencyId: $currencyId, amount: $amount } }
|
||||
) {
|
||||
errors {
|
||||
messages
|
||||
}
|
||||
order {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: { ...variables },
|
||||
onCompleted: (_response) => {
|
||||
window.location.reload();
|
||||
},
|
||||
onError: (_error) => {},
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./ExchangePanel";
|
||||
@@ -7,10 +7,10 @@ import { FragmentRefs } from "relay-runtime";
|
||||
export type ExchangeQueryVariables = {};
|
||||
export type ExchangeQueryResponse = {
|
||||
readonly fiatBalances: {
|
||||
readonly " $fragmentRefs": FragmentRefs<"CreateExchangeOrderModal_fiatBalances">;
|
||||
readonly " $fragmentRefs": FragmentRefs<"ExchangePanel_fiatBalances">;
|
||||
};
|
||||
readonly balances: {
|
||||
readonly " $fragmentRefs": FragmentRefs<"CreateExchangeOrderModal_balances">;
|
||||
readonly " $fragmentRefs": FragmentRefs<"ExchangePanel_balances">;
|
||||
};
|
||||
readonly buyCryptoOrders: {
|
||||
readonly " $fragmentRefs": FragmentRefs<"ExchangeHistory_buyCryptoOrders">;
|
||||
@@ -29,10 +29,10 @@ export type ExchangeQuery = {
|
||||
/*
|
||||
query ExchangeQuery {
|
||||
fiatBalances {
|
||||
...CreateExchangeOrderModal_fiatBalances
|
||||
...ExchangePanel_fiatBalances
|
||||
}
|
||||
balances {
|
||||
...CreateExchangeOrderModal_balances
|
||||
...ExchangePanel_balances
|
||||
}
|
||||
buyCryptoOrders {
|
||||
...ExchangeHistory_buyCryptoOrders
|
||||
@@ -42,24 +42,6 @@ query ExchangeQuery {
|
||||
}
|
||||
}
|
||||
|
||||
fragment CreateExchangeOrderModal_balances on BalanceConnection {
|
||||
edges {
|
||||
node {
|
||||
amount
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment CreateExchangeOrderModal_fiatBalances on FiatBalanceConnection {
|
||||
edges {
|
||||
node {
|
||||
amountCents
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment ExchangeHistory_buyCryptoOrders on BuyCryptoOrderConnection {
|
||||
edges {
|
||||
node {
|
||||
@@ -93,6 +75,27 @@ fragment ExchangeHistory_sellCryptoOrders on SellCryptoOrderConnection {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment ExchangePanel_balances on BalanceConnection {
|
||||
edges {
|
||||
node {
|
||||
amount
|
||||
currency {
|
||||
id
|
||||
}
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment ExchangePanel_fiatBalances on FiatBalanceConnection {
|
||||
edges {
|
||||
node {
|
||||
amountCents
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
@@ -161,7 +164,7 @@ return {
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "CreateExchangeOrderModal_fiatBalances"
|
||||
"name": "ExchangePanel_fiatBalances"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -177,7 +180,7 @@ return {
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "CreateExchangeOrderModal_balances"
|
||||
"name": "ExchangePanel_balances"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -296,6 +299,18 @@ return {
|
||||
"name": "amount",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Currency",
|
||||
"kind": "LinkedField",
|
||||
"name": "currency",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -413,14 +428,14 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "ddb6670ea93a9fdc62c7627c3ed09925",
|
||||
"cacheID": "424352bbffec52284c44f109ce54a441",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "ExchangeQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query ExchangeQuery {\n fiatBalances {\n ...CreateExchangeOrderModal_fiatBalances\n }\n balances {\n ...CreateExchangeOrderModal_balances\n }\n buyCryptoOrders {\n ...ExchangeHistory_buyCryptoOrders\n }\n sellCryptoOrders {\n ...ExchangeHistory_sellCryptoOrders\n }\n}\n\nfragment CreateExchangeOrderModal_balances on BalanceConnection {\n edges {\n node {\n amount\n id\n }\n }\n}\n\nfragment CreateExchangeOrderModal_fiatBalances on FiatBalanceConnection {\n edges {\n node {\n amountCents\n id\n }\n }\n}\n\nfragment ExchangeHistory_buyCryptoOrders on BuyCryptoOrderConnection {\n edges {\n node {\n id\n status\n createdAt\n paidAmountCents\n receivedAmount\n currency {\n name\n id\n }\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 currency {\n name\n id\n }\n __typename\n }\n }\n}\n"
|
||||
"text": "query ExchangeQuery {\n fiatBalances {\n ...ExchangePanel_fiatBalances\n }\n balances {\n ...ExchangePanel_balances\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 currency {\n name\n id\n }\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 currency {\n name\n id\n }\n __typename\n }\n }\n}\n\nfragment ExchangePanel_balances on BalanceConnection {\n edges {\n node {\n amount\n currency {\n id\n }\n id\n }\n }\n}\n\nfragment ExchangePanel_fiatBalances on FiatBalanceConnection {\n edges {\n node {\n amountCents\n id\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
(node as any).hash = 'cc0eaddc68f5bd14d39ce9e148876535';
|
||||
(node as any).hash = '3d09bb5b003cac17750666dc76088801';
|
||||
export default node;
|
||||
|
||||
@@ -18,7 +18,10 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
variants: {
|
||||
extend: {},
|
||||
extend: {
|
||||
opacity: ["disabled"],
|
||||
cursor: ["disabled"],
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user