add commitCreateStakeRemoveRequestMutation
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -28,6 +28,7 @@ gem "money-rails"
|
|||||||
gem "enumerize"
|
gem "enumerize"
|
||||||
gem "graphql"
|
gem "graphql"
|
||||||
gem "pundit"
|
gem "pundit"
|
||||||
|
gem "ransack", "~> 2.4"
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem "dotenv-rails"
|
gem "dotenv-rails"
|
||||||
|
|||||||
@@ -235,6 +235,10 @@ GEM
|
|||||||
thor (~> 1.0)
|
thor (~> 1.0)
|
||||||
rainbow (3.0.0)
|
rainbow (3.0.0)
|
||||||
rake (13.0.6)
|
rake (13.0.6)
|
||||||
|
ransack (2.4.2)
|
||||||
|
activerecord (>= 5.2.4)
|
||||||
|
activesupport (>= 5.2.4)
|
||||||
|
i18n
|
||||||
rb-fsevent (0.11.0)
|
rb-fsevent (0.11.0)
|
||||||
rb-inotify (0.10.1)
|
rb-inotify (0.10.1)
|
||||||
ffi (~> 1.0)
|
ffi (~> 1.0)
|
||||||
@@ -373,6 +377,7 @@ DEPENDENCIES
|
|||||||
rails (~> 6.1.4)
|
rails (~> 6.1.4)
|
||||||
rails-erd
|
rails-erd
|
||||||
rails-i18n (~> 6.0)
|
rails-i18n (~> 6.0)
|
||||||
|
ransack (~> 2.4)
|
||||||
rspec-graphql_matchers (~> 1.3)
|
rspec-graphql_matchers (~> 1.3)
|
||||||
rspec-rails
|
rspec-rails
|
||||||
rubocop-rails
|
rubocop-rails
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
module Inputs
|
module Inputs
|
||||||
class CreateStakeOrderAttributesInput < Types::BaseInputObject
|
class CreateStakeOrderAttributesInput < Types::BaseInputObject
|
||||||
argument :currency_id, ID, required: true
|
|
||||||
argument :pool_name, String, required: true
|
argument :pool_name, String, required: true
|
||||||
argument :amount, String, "Amount to be paid", required: true
|
argument :amount, String, "Amount to be paid", required: true
|
||||||
end
|
end
|
||||||
|
|||||||
9
app/graphql/inputs/predicate_input.rb
Normal file
9
app/graphql/inputs/predicate_input.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
module Inputs
|
||||||
|
class PredicateInput < Types::BaseInputObject
|
||||||
|
# https://github.com/activerecord-hackery/ransack#search-matchers
|
||||||
|
# add others if necessary
|
||||||
|
argument :eq, String, "Equal", required: false
|
||||||
|
argument :lt, Float, "Less than", required: false
|
||||||
|
end
|
||||||
|
end
|
||||||
10
app/graphql/inputs/stake_order_filter_input.rb
Normal file
10
app/graphql/inputs/stake_order_filter_input.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
module Inputs
|
||||||
|
class StakeOrderFilterInput < Types::BaseInputObject
|
||||||
|
StakeOrder.ransackable_attributes.each do |attr|
|
||||||
|
argument attr, PredicateInput, required: false
|
||||||
|
end
|
||||||
|
|
||||||
|
argument :status, [Types::ProcessStatusEnum], required: false
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -6,7 +6,7 @@ module Mutations
|
|||||||
argument :order, Inputs::CreateStakeOrderAttributesInput, required: true
|
argument :order, Inputs::CreateStakeOrderAttributesInput, required: true
|
||||||
|
|
||||||
def resolve(order:)
|
def resolve(order:)
|
||||||
currency_id = decode_id(order[:currency_id])
|
currency_id = Currency.find_by!(name: "CAKE").id
|
||||||
amount = BigDecimal(order[:amount])
|
amount = BigDecimal(order[:amount])
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ module Mutations
|
|||||||
argument :order, Inputs::CreateStakeOrderAttributesInput, required: true
|
argument :order, Inputs::CreateStakeOrderAttributesInput, required: true
|
||||||
|
|
||||||
def resolve(order:)
|
def resolve(order:)
|
||||||
currency_id = decode_id(order[:currency_id])
|
currency_id = Currency.find_by!(name: "CAKE").id
|
||||||
amount = BigDecimal(order[:amount])
|
amount = -BigDecimal(order[:amount])
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
record = StakeOrder.find_or_initialize_by(
|
record = StakeOrder.find_or_initialize_by(
|
||||||
|
|||||||
21
app/graphql/ransack_support.rb
Normal file
21
app/graphql/ransack_support.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
module RansackSupport
|
||||||
|
def ransack(base, filter)
|
||||||
|
base.ransack(build_ransack_query(base, filter)).result
|
||||||
|
end
|
||||||
|
|
||||||
|
def build_ransack_query(base, filter)
|
||||||
|
filter = filter.to_h
|
||||||
|
mapped_filter = {}
|
||||||
|
|
||||||
|
filter.each do |parent_key, parent_value|
|
||||||
|
next unless base.ransackable_attributes.include?(parent_key.to_s)
|
||||||
|
|
||||||
|
parent_value.each do |children_key, children_value|
|
||||||
|
mapped_filter["#{parent_key}_#{children_key}".to_sym] = children_value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
mapped_filter
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -3,6 +3,7 @@ module Types
|
|||||||
class QueryType < Types::BaseObject
|
class QueryType < Types::BaseObject
|
||||||
include GraphQL::Types::Relay::HasNodeField
|
include GraphQL::Types::Relay::HasNodeField
|
||||||
include GraphQL::Types::Relay::HasNodesField
|
include GraphQL::Types::Relay::HasNodesField
|
||||||
|
include RansackSupport
|
||||||
|
|
||||||
field :current_user, UserType, null: true
|
field :current_user, UserType, null: true
|
||||||
def current_user
|
def current_user
|
||||||
@@ -29,9 +30,16 @@ module Types
|
|||||||
Pundit.policy_scope(current_user, BuyCryptoOrder)
|
Pundit.policy_scope(current_user, BuyCryptoOrder)
|
||||||
end
|
end
|
||||||
|
|
||||||
field :stake_orders, StakeOrderType.connection_type, null: false
|
field :stake_orders, StakeOrderType.connection_type, null: false do
|
||||||
def stake_orders
|
argument :filter, Inputs::StakeOrderFilterInput, required: false
|
||||||
Pundit.policy_scope(current_user, StakeOrder)
|
end
|
||||||
|
|
||||||
|
def stake_orders(filter: nil)
|
||||||
|
scope = Pundit.policy_scope(current_user, StakeOrder)
|
||||||
|
|
||||||
|
scope = scope.where(status: filter.status) if filter&.status
|
||||||
|
|
||||||
|
ransack(scope, filter)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
20
app/javascript/__generated__/schema.graphql
generated
20
app/javascript/__generated__/schema.graphql
generated
@@ -149,7 +149,6 @@ input CreateStakeOrderAttributesInput {
|
|||||||
Amount to be paid
|
Amount to be paid
|
||||||
"""
|
"""
|
||||||
amount: String!
|
amount: String!
|
||||||
currencyId: ID!
|
|
||||||
poolName: String!
|
poolName: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,6 +314,18 @@ type PageInfo {
|
|||||||
startCursor: String
|
startCursor: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input PredicateInput {
|
||||||
|
"""
|
||||||
|
Equal
|
||||||
|
"""
|
||||||
|
eq: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
Less than
|
||||||
|
"""
|
||||||
|
lt: Float
|
||||||
|
}
|
||||||
|
|
||||||
enum ProcessStatus {
|
enum ProcessStatus {
|
||||||
CANCELED
|
CANCELED
|
||||||
COMPLETED
|
COMPLETED
|
||||||
@@ -437,6 +448,7 @@ type Query {
|
|||||||
Returns the elements in the list that come before the specified cursor.
|
Returns the elements in the list that come before the specified cursor.
|
||||||
"""
|
"""
|
||||||
before: String
|
before: String
|
||||||
|
filter: StakeOrderFilterInput
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Returns the first _n_ elements from the list.
|
Returns the first _n_ elements from the list.
|
||||||
@@ -536,6 +548,12 @@ type StakeOrderEdge {
|
|||||||
node: StakeOrder!
|
node: StakeOrder!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input StakeOrderFilterInput {
|
||||||
|
amount: PredicateInput
|
||||||
|
poolName: PredicateInput
|
||||||
|
status: [ProcessStatus!]
|
||||||
|
}
|
||||||
|
|
||||||
type User {
|
type User {
|
||||||
email: String!
|
email: String!
|
||||||
firstName: String!
|
firstName: String!
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import BigNumber from "bignumber.js";
|
|||||||
import type { ChangeEvent, FC } from "react";
|
import type { ChangeEvent, FC } from "react";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import cx from "classnames";
|
import cx from "classnames";
|
||||||
|
import { useRelayEnvironment } from "react-relay";
|
||||||
|
|
||||||
import { Modal } from "../../../components";
|
import { Modal } from "../../../../components";
|
||||||
|
import { commitCreateStakeRemoveOrderMutation } from "./commitCreateStakeRemoveOrder";
|
||||||
|
|
||||||
const inputBaseStyles =
|
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";
|
"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";
|
||||||
@@ -18,18 +20,25 @@ type RemoveStakeModal = {
|
|||||||
export const RemoveStakeModal: FC<RemoveStakeModal> = ({
|
export const RemoveStakeModal: FC<RemoveStakeModal> = ({
|
||||||
setIsOpen,
|
setIsOpen,
|
||||||
isOpen,
|
isOpen,
|
||||||
// stakedCake,
|
stakedCake,
|
||||||
poolName,
|
poolName = "",
|
||||||
}) => {
|
}) => {
|
||||||
|
const enviroment = useRelayEnvironment();
|
||||||
const [amountInput, setAmountInput] = useState<string>("0");
|
const [amountInput, setAmountInput] = useState<string>("0");
|
||||||
const stakedCake = "44.00";
|
const avaliableCake = BigNumber.sum(stakedCake);
|
||||||
const avaliableCake = new BigNumber(stakedCake);
|
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = () => {};
|
const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
commitCreateStakeRemoveOrderMutation(enviroment, {
|
||||||
|
poolName,
|
||||||
|
amount: amountInput,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleInvestInput = ({
|
const handleInvestInput = ({
|
||||||
currentTarget: { value },
|
currentTarget: { value },
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from "relay-runtime";
|
||||||
|
export type commitCreateStakeRemoveOrderMutationVariables = {
|
||||||
|
poolName: string;
|
||||||
|
amount: string;
|
||||||
|
};
|
||||||
|
export type commitCreateStakeRemoveOrderMutationResponse = {
|
||||||
|
readonly createStakeRemoveOrder: {
|
||||||
|
readonly order: {
|
||||||
|
readonly id: string;
|
||||||
|
} | null;
|
||||||
|
} | null;
|
||||||
|
};
|
||||||
|
export type commitCreateStakeRemoveOrderMutation = {
|
||||||
|
readonly response: commitCreateStakeRemoveOrderMutationResponse;
|
||||||
|
readonly variables: commitCreateStakeRemoveOrderMutationVariables;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
mutation commitCreateStakeRemoveOrderMutation(
|
||||||
|
$poolName: String!
|
||||||
|
$amount: String!
|
||||||
|
) {
|
||||||
|
createStakeRemoveOrder(input: {order: {poolName: $poolName, amount: $amount}}) {
|
||||||
|
order {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "amount"
|
||||||
|
},
|
||||||
|
v1 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "poolName"
|
||||||
|
},
|
||||||
|
v2 = [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "amount",
|
||||||
|
"variableName": "amount"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "poolName",
|
||||||
|
"variableName": "poolName"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "ObjectValue",
|
||||||
|
"name": "order"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "ObjectValue",
|
||||||
|
"name": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"concreteType": "CreateStakeRemoveOrderPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "createStakeRemoveOrder",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "StakeOrder",
|
||||||
|
"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": "commitCreateStakeRemoveOrderMutation",
|
||||||
|
"selections": (v2/*: any*/),
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v0/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "commitCreateStakeRemoveOrderMutation",
|
||||||
|
"selections": (v2/*: any*/)
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "a3a646d6f52bf3ddc29e33b8fce4661b",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "commitCreateStakeRemoveOrderMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation commitCreateStakeRemoveOrderMutation(\n $poolName: String!\n $amount: String!\n) {\n createStakeRemoveOrder(input: {order: {poolName: $poolName, amount: $amount}}) {\n order {\n id\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
(node as any).hash = '561be0497e5317997815bea692b73da9';
|
||||||
|
export default node;
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { graphql } from "babel-plugin-relay/macro";
|
||||||
|
import type { Environment } from "react-relay";
|
||||||
|
import { commitMutation } from "react-relay";
|
||||||
|
|
||||||
|
import type { commitCreateStakeRemoveOrderMutationVariables } from "./__generated__/commitCreateStakeRemoveOrderMutation.graphql";
|
||||||
|
|
||||||
|
export const commitCreateStakeRemoveOrderMutation = (
|
||||||
|
environment: Environment,
|
||||||
|
variables: commitCreateStakeRemoveOrderMutationVariables
|
||||||
|
) => {
|
||||||
|
return commitMutation(environment, {
|
||||||
|
mutation: graphql`
|
||||||
|
mutation commitCreateStakeRemoveOrderMutation(
|
||||||
|
$poolName: String!
|
||||||
|
$amount: String!
|
||||||
|
) {
|
||||||
|
createStakeRemoveOrder(
|
||||||
|
input: { order: { poolName: $poolName, amount: $amount } }
|
||||||
|
) {
|
||||||
|
order {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
variables,
|
||||||
|
onCompleted: (_response) => {
|
||||||
|
window.location.href = "/orders/stake";
|
||||||
|
},
|
||||||
|
onError: (_error) => {},
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./RemoveStakeModal";
|
||||||
@@ -2,9 +2,13 @@ import type { FC } from "react";
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import cx from "classnames";
|
import cx from "classnames";
|
||||||
import { XCircleIcon } from "@heroicons/react/outline";
|
import { XCircleIcon } from "@heroicons/react/outline";
|
||||||
|
import { useLazyLoadQuery } from "react-relay";
|
||||||
|
import { graphql } from "babel-plugin-relay/macro";
|
||||||
|
import BigNumber from "bignumber.js";
|
||||||
|
|
||||||
import type { Vault as VaultType } from "../../../types/yieldwatch";
|
import type { Vault as VaultType } from "../../../types/yieldwatch";
|
||||||
import { RemoveStakeModal } from "./RemoveStakeModal";
|
import { RemoveStakeModal } from "./RemoveStakeModal";
|
||||||
|
import type { VaultQuery } from "./__generated__/VaultQuery.graphql";
|
||||||
|
|
||||||
type VaultProps = {
|
type VaultProps = {
|
||||||
vault: Partial<VaultType>;
|
vault: Partial<VaultType>;
|
||||||
@@ -12,26 +16,71 @@ type VaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const Vault: FC<VaultProps> = ({ vault, isLoading }) => {
|
export const Vault: FC<VaultProps> = ({ vault, isLoading }) => {
|
||||||
|
const { stakeOrders } = useLazyLoadQuery<VaultQuery>(
|
||||||
|
graphql`
|
||||||
|
query VaultQuery(
|
||||||
|
$status: ProcessStatus!
|
||||||
|
$poolName: String!
|
||||||
|
$amount: Float!
|
||||||
|
) {
|
||||||
|
stakeOrders(
|
||||||
|
filter: {
|
||||||
|
status: [$status]
|
||||||
|
poolName: { eq: $poolName }
|
||||||
|
amount: { lt: $amount }
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
{
|
||||||
|
status: "PROCESSING",
|
||||||
|
poolName: vault.name ?? "",
|
||||||
|
amount: 0,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const [removeStakeModalIsOpen, setRemoveStakeModalIsOpen] =
|
const [removeStakeModalIsOpen, setRemoveStakeModalIsOpen] =
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
|
|
||||||
const totalDepositedAndRewarded = (
|
|
||||||
(vault.depositedTokens ?? 0) + (vault.totalRewards ?? 0)
|
|
||||||
).toFixed(4);
|
|
||||||
|
|
||||||
const totalDeposited = vault.depositedTokens?.toFixed(4);
|
|
||||||
const totalRewarded = vault.totalRewards?.toFixed(4);
|
|
||||||
|
|
||||||
const handleRemoveStakeModal = () => {
|
const handleRemoveStakeModal = () => {
|
||||||
setRemoveStakeModalIsOpen(true);
|
setRemoveStakeModalIsOpen(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const alreadyOnUnstakeOrder = stakeOrders.edges.reduce((acc, current) => {
|
||||||
|
return BigNumber.sum(acc, current.node.amount);
|
||||||
|
}, new BigNumber(0));
|
||||||
|
|
||||||
|
const totalDepositedAndRewarded =
|
||||||
|
(vault.depositedTokens ?? 0) + (vault.totalRewards ?? 0);
|
||||||
|
|
||||||
|
let totalStaked = BigNumber.sum(
|
||||||
|
alreadyOnUnstakeOrder,
|
||||||
|
totalDepositedAndRewarded
|
||||||
|
);
|
||||||
|
|
||||||
|
totalStaked = totalStaked.isLessThan(0.0001) ? new BigNumber(0) : totalStaked;
|
||||||
|
|
||||||
|
const totalStakedFixed = totalStaked.toFixed(4);
|
||||||
|
const totalDeposited = (
|
||||||
|
totalStaked.isEqualTo(0) ? 0 : vault.depositedTokens
|
||||||
|
)?.toFixed(4);
|
||||||
|
|
||||||
|
const totalRewarded = (
|
||||||
|
totalStaked.isEqualTo(0) ? 0 : vault.totalRewards
|
||||||
|
)?.toFixed(4);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RemoveStakeModal
|
<RemoveStakeModal
|
||||||
isOpen={removeStakeModalIsOpen}
|
isOpen={removeStakeModalIsOpen}
|
||||||
setIsOpen={setRemoveStakeModalIsOpen}
|
setIsOpen={setRemoveStakeModalIsOpen}
|
||||||
stakedCake={totalDepositedAndRewarded}
|
stakedCake={totalStakedFixed}
|
||||||
poolName={vault.name}
|
poolName={vault.name}
|
||||||
/>
|
/>
|
||||||
<div className="shadow-lg px-4 py-6 w-full bg-white dark:bg-gray-800 rounded-lg">
|
<div className="shadow-lg px-4 py-6 w-full bg-white dark:bg-gray-800 rounded-lg">
|
||||||
@@ -53,7 +102,7 @@ export const Vault: FC<VaultProps> = ({ vault, isLoading }) => {
|
|||||||
: ""
|
: ""
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{!isLoading && totalDepositedAndRewarded}
|
{!isLoading && totalStakedFixed}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="dark:text-white">
|
<div className="dark:text-white">
|
||||||
|
|||||||
222
app/javascript/src/pages/Dashboard/Vault/__generated__/VaultQuery.graphql.ts
generated
Normal file
222
app/javascript/src/pages/Dashboard/Vault/__generated__/VaultQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from "relay-runtime";
|
||||||
|
export type ProcessStatus = "CANCELED" | "COMPLETED" | "PROCESSING" | "%future added value";
|
||||||
|
export type VaultQueryVariables = {
|
||||||
|
status: ProcessStatus;
|
||||||
|
poolName: string;
|
||||||
|
amount: number;
|
||||||
|
};
|
||||||
|
export type VaultQueryResponse = {
|
||||||
|
readonly stakeOrders: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly amount: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type VaultQuery = {
|
||||||
|
readonly response: VaultQueryResponse;
|
||||||
|
readonly variables: VaultQueryVariables;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
query VaultQuery(
|
||||||
|
$status: ProcessStatus!
|
||||||
|
$poolName: String!
|
||||||
|
$amount: Float!
|
||||||
|
) {
|
||||||
|
stakeOrders(filter: {status: [$status], poolName: {eq: $poolName}, amount: {lt: $amount}}) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
amount
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "amount"
|
||||||
|
},
|
||||||
|
v1 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "poolName"
|
||||||
|
},
|
||||||
|
v2 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "status"
|
||||||
|
},
|
||||||
|
v3 = [
|
||||||
|
{
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "lt",
|
||||||
|
"variableName": "amount"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "ObjectValue",
|
||||||
|
"name": "amount"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "eq",
|
||||||
|
"variableName": "poolName"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "ObjectValue",
|
||||||
|
"name": "poolName"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "status.0",
|
||||||
|
"variableName": "status"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "ListValue",
|
||||||
|
"name": "status"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "ObjectValue",
|
||||||
|
"name": "filter"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v4 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "amount",
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v2/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "VaultQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v3/*: any*/),
|
||||||
|
"concreteType": "StakeOrderConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "stakeOrders",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "StakeOrderEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "StakeOrder",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v4/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v0/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "VaultQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v3/*: any*/),
|
||||||
|
"concreteType": "StakeOrderConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "stakeOrders",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "StakeOrderEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "StakeOrder",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v4/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "6565697f7f43e955abee8a8a1eeb8e9b",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "VaultQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query VaultQuery(\n $status: ProcessStatus!\n $poolName: String!\n $amount: Float!\n) {\n stakeOrders(filter: {status: [$status], poolName: {eq: $poolName}, amount: {lt: $amount}}) {\n edges {\n node {\n amount\n id\n }\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
(node as any).hash = 'e5dced4589579717b408bc2f555b98ab';
|
||||||
|
export default node;
|
||||||
@@ -11,10 +11,9 @@ import { StakeOrderModal } from "./StakeOrderModal";
|
|||||||
type PoolProps = {
|
type PoolProps = {
|
||||||
pool: PoolConfig;
|
pool: PoolConfig;
|
||||||
balance: string;
|
balance: string;
|
||||||
currencyId: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Pool: FC<PoolProps> = ({ pool, balance, currencyId }) => {
|
export const Pool: FC<PoolProps> = ({ pool, balance }) => {
|
||||||
const {
|
const {
|
||||||
provider,
|
provider,
|
||||||
pancake: { router },
|
pancake: { router },
|
||||||
@@ -36,7 +35,7 @@ export const Pool: FC<PoolProps> = ({ pool, balance, currencyId }) => {
|
|||||||
const totalStaked = await getTotalStaked(provider, pool);
|
const totalStaked = await getTotalStaked(provider, pool);
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(
|
console.info(
|
||||||
`Total Staked for ${pool.stakingToken.symbol} - ${
|
`Total Staked for ${pool.stakingToken.symbol} - ${
|
||||||
pool.earningToken.symbol
|
pool.earningToken.symbol
|
||||||
}: ${JSON.stringify(totalStaked)}`
|
}: ${JSON.stringify(totalStaked)}`
|
||||||
@@ -94,7 +93,6 @@ export const Pool: FC<PoolProps> = ({ pool, balance, currencyId }) => {
|
|||||||
<StakeOrderModal
|
<StakeOrderModal
|
||||||
poolName={pool.earningToken.symbol}
|
poolName={pool.earningToken.symbol}
|
||||||
balance={balance}
|
balance={balance}
|
||||||
currencyId={currencyId}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export const PoolListing = () => {
|
|||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
currency {
|
currency {
|
||||||
id
|
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
amount
|
amount
|
||||||
@@ -31,7 +30,6 @@ export const PoolListing = () => {
|
|||||||
)?.node;
|
)?.node;
|
||||||
|
|
||||||
const balance = cakeBalance?.amount ?? "0";
|
const balance = cakeBalance?.amount ?? "0";
|
||||||
const currencyId = cakeBalance?.currency.id ?? "????";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 place-items-center w-full gap-8 py-4 -mt-16 overflow-x-hidden">
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 place-items-center w-full gap-8 py-4 -mt-16 overflow-x-hidden">
|
||||||
@@ -39,12 +37,7 @@ export const PoolListing = () => {
|
|||||||
.filter((pool) => !pool.isFinished)
|
.filter((pool) => !pool.isFinished)
|
||||||
.sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0))
|
.sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0))
|
||||||
.map((pool) => (
|
.map((pool) => (
|
||||||
<Pool
|
<Pool key={pool.sousId} pool={pool} balance={balance} />
|
||||||
key={pool.sousId}
|
|
||||||
pool={pool}
|
|
||||||
balance={balance}
|
|
||||||
currencyId={currencyId}
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,17 +10,12 @@ import { commitCreateStakeOrderMutation } from "./createStakeOrder";
|
|||||||
type Props = {
|
type Props = {
|
||||||
poolName: string;
|
poolName: string;
|
||||||
balance: string;
|
balance: string;
|
||||||
currencyId: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const inputBaseStyles =
|
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";
|
"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";
|
||||||
|
|
||||||
export const StakeOrderModal: FC<Props> = ({
|
export const StakeOrderModal: FC<Props> = ({ poolName, balance }) => {
|
||||||
poolName,
|
|
||||||
balance,
|
|
||||||
currencyId,
|
|
||||||
}) => {
|
|
||||||
const environment = useRelayEnvironment();
|
const environment = useRelayEnvironment();
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [investAmountInput, setInvestAmountInput] = useState("0");
|
const [investAmountInput, setInvestAmountInput] = useState("0");
|
||||||
@@ -34,7 +29,6 @@ export const StakeOrderModal: FC<Props> = ({
|
|||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
commitCreateStakeOrderMutation(environment, {
|
commitCreateStakeOrderMutation(environment, {
|
||||||
currencyId,
|
|
||||||
amount: investAmountInput,
|
amount: investAmountInput,
|
||||||
poolName,
|
poolName,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import { ConcreteRequest } from "relay-runtime";
|
import { ConcreteRequest } from "relay-runtime";
|
||||||
export type createStakeOrderMutationVariables = {
|
export type createStakeOrderMutationVariables = {
|
||||||
currencyId: string;
|
|
||||||
poolName: string;
|
poolName: string;
|
||||||
amount: string;
|
amount: string;
|
||||||
};
|
};
|
||||||
@@ -24,11 +23,10 @@ export type createStakeOrderMutation = {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
mutation createStakeOrderMutation(
|
mutation createStakeOrderMutation(
|
||||||
$currencyId: ID!
|
|
||||||
$poolName: String!
|
$poolName: String!
|
||||||
$amount: String!
|
$amount: String!
|
||||||
) {
|
) {
|
||||||
createStakeOrder(input: {order: {currencyId: $currencyId, poolName: $poolName, amount: $amount}}) {
|
createStakeOrder(input: {order: {poolName: $poolName, amount: $amount}}) {
|
||||||
order {
|
order {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
@@ -43,16 +41,11 @@ var v0 = {
|
|||||||
"name": "amount"
|
"name": "amount"
|
||||||
},
|
},
|
||||||
v1 = {
|
v1 = {
|
||||||
"defaultValue": null,
|
|
||||||
"kind": "LocalArgument",
|
|
||||||
"name": "currencyId"
|
|
||||||
},
|
|
||||||
v2 = {
|
|
||||||
"defaultValue": null,
|
"defaultValue": null,
|
||||||
"kind": "LocalArgument",
|
"kind": "LocalArgument",
|
||||||
"name": "poolName"
|
"name": "poolName"
|
||||||
},
|
},
|
||||||
v3 = [
|
v2 = [
|
||||||
{
|
{
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": [
|
"args": [
|
||||||
@@ -65,11 +58,6 @@ v3 = [
|
|||||||
"name": "amount",
|
"name": "amount",
|
||||||
"variableName": "amount"
|
"variableName": "amount"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"kind": "Variable",
|
|
||||||
"name": "currencyId",
|
|
||||||
"variableName": "currencyId"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"kind": "Variable",
|
"kind": "Variable",
|
||||||
"name": "poolName",
|
"name": "poolName",
|
||||||
@@ -115,13 +103,12 @@ return {
|
|||||||
"fragment": {
|
"fragment": {
|
||||||
"argumentDefinitions": [
|
"argumentDefinitions": [
|
||||||
(v0/*: any*/),
|
(v0/*: any*/),
|
||||||
(v1/*: any*/),
|
(v1/*: any*/)
|
||||||
(v2/*: any*/)
|
|
||||||
],
|
],
|
||||||
"kind": "Fragment",
|
"kind": "Fragment",
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
"name": "createStakeOrderMutation",
|
"name": "createStakeOrderMutation",
|
||||||
"selections": (v3/*: any*/),
|
"selections": (v2/*: any*/),
|
||||||
"type": "Mutation",
|
"type": "Mutation",
|
||||||
"abstractKey": null
|
"abstractKey": null
|
||||||
},
|
},
|
||||||
@@ -129,22 +116,21 @@ return {
|
|||||||
"operation": {
|
"operation": {
|
||||||
"argumentDefinitions": [
|
"argumentDefinitions": [
|
||||||
(v1/*: any*/),
|
(v1/*: any*/),
|
||||||
(v2/*: any*/),
|
|
||||||
(v0/*: any*/)
|
(v0/*: any*/)
|
||||||
],
|
],
|
||||||
"kind": "Operation",
|
"kind": "Operation",
|
||||||
"name": "createStakeOrderMutation",
|
"name": "createStakeOrderMutation",
|
||||||
"selections": (v3/*: any*/)
|
"selections": (v2/*: any*/)
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
"cacheID": "bfe4935c593947810fbb8d7a52421483",
|
"cacheID": "e845ef953b2de9dd797930c0838f30f8",
|
||||||
"id": null,
|
"id": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"name": "createStakeOrderMutation",
|
"name": "createStakeOrderMutation",
|
||||||
"operationKind": "mutation",
|
"operationKind": "mutation",
|
||||||
"text": "mutation createStakeOrderMutation(\n $currencyId: ID!\n $poolName: String!\n $amount: String!\n) {\n createStakeOrder(input: {order: {currencyId: $currencyId, poolName: $poolName, amount: $amount}}) {\n order {\n id\n }\n }\n}\n"
|
"text": "mutation createStakeOrderMutation(\n $poolName: String!\n $amount: String!\n) {\n createStakeOrder(input: {order: {poolName: $poolName, amount: $amount}}) {\n order {\n id\n }\n }\n}\n"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
(node as any).hash = '036f321e28fcb4bd3e274498cd3f116a';
|
(node as any).hash = '36f248efe00b47bc1b27f597c5ab45c3';
|
||||||
export default node;
|
export default node;
|
||||||
|
|||||||
@@ -10,19 +10,9 @@ export const commitCreateStakeOrderMutation = (
|
|||||||
) => {
|
) => {
|
||||||
return commitMutation(environment, {
|
return commitMutation(environment, {
|
||||||
mutation: graphql`
|
mutation: graphql`
|
||||||
mutation createStakeOrderMutation(
|
mutation createStakeOrderMutation($poolName: String!, $amount: String!) {
|
||||||
$currencyId: ID!
|
|
||||||
$poolName: String!
|
|
||||||
$amount: String!
|
|
||||||
) {
|
|
||||||
createStakeOrder(
|
createStakeOrder(
|
||||||
input: {
|
input: { order: { poolName: $poolName, amount: $amount } }
|
||||||
order: {
|
|
||||||
currencyId: $currencyId
|
|
||||||
poolName: $poolName
|
|
||||||
amount: $amount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
order {
|
order {
|
||||||
id
|
id
|
||||||
@@ -30,7 +20,7 @@ export const commitCreateStakeOrderMutation = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
variables: { ...variables },
|
variables,
|
||||||
onCompleted: (_response) => {
|
onCompleted: (_response) => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ export type PoolListingQueryResponse = {
|
|||||||
readonly edges: ReadonlyArray<{
|
readonly edges: ReadonlyArray<{
|
||||||
readonly node: {
|
readonly node: {
|
||||||
readonly currency: {
|
readonly currency: {
|
||||||
readonly id: string;
|
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
};
|
};
|
||||||
readonly amount: string;
|
readonly amount: string;
|
||||||
@@ -30,8 +29,8 @@ query PoolListingQuery {
|
|||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
currency {
|
currency {
|
||||||
id
|
|
||||||
name
|
name
|
||||||
|
id
|
||||||
}
|
}
|
||||||
amount
|
amount
|
||||||
id
|
id
|
||||||
@@ -46,33 +45,21 @@ var v0 = {
|
|||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"kind": "ScalarField",
|
"kind": "ScalarField",
|
||||||
"name": "id",
|
"name": "name",
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
},
|
},
|
||||||
v1 = {
|
v1 = {
|
||||||
"alias": null,
|
|
||||||
"args": null,
|
|
||||||
"concreteType": "Currency",
|
|
||||||
"kind": "LinkedField",
|
|
||||||
"name": "currency",
|
|
||||||
"plural": false,
|
|
||||||
"selections": [
|
|
||||||
(v0/*: any*/),
|
|
||||||
{
|
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"kind": "ScalarField",
|
"kind": "ScalarField",
|
||||||
"name": "name",
|
"name": "amount",
|
||||||
"storageKey": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
},
|
},
|
||||||
v2 = {
|
v2 = {
|
||||||
"alias": null,
|
"alias": null,
|
||||||
"args": null,
|
"args": null,
|
||||||
"kind": "ScalarField",
|
"kind": "ScalarField",
|
||||||
"name": "amount",
|
"name": "id",
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
@@ -106,8 +93,19 @@ return {
|
|||||||
"name": "node",
|
"name": "node",
|
||||||
"plural": false,
|
"plural": false,
|
||||||
"selections": [
|
"selections": [
|
||||||
(v1/*: any*/),
|
{
|
||||||
(v2/*: any*/)
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Currency",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "currency",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v0/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v1/*: any*/)
|
||||||
],
|
],
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
}
|
}
|
||||||
@@ -151,9 +149,21 @@ return {
|
|||||||
"name": "node",
|
"name": "node",
|
||||||
"plural": false,
|
"plural": false,
|
||||||
"selections": [
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Currency",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "currency",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v2/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
(v1/*: any*/),
|
(v1/*: any*/),
|
||||||
(v2/*: any*/),
|
(v2/*: any*/)
|
||||||
(v0/*: any*/)
|
|
||||||
],
|
],
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
}
|
}
|
||||||
@@ -166,14 +176,14 @@ return {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
"cacheID": "06c9467183eb0e89329ec630a8cc4880",
|
"cacheID": "6abf5e963429e49993af50df156f8e1c",
|
||||||
"id": null,
|
"id": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"name": "PoolListingQuery",
|
"name": "PoolListingQuery",
|
||||||
"operationKind": "query",
|
"operationKind": "query",
|
||||||
"text": "query PoolListingQuery {\n balances {\n edges {\n node {\n currency {\n id\n name\n }\n amount\n id\n }\n }\n }\n}\n"
|
"text": "query PoolListingQuery {\n balances {\n edges {\n node {\n currency {\n name\n id\n }\n amount\n id\n }\n }\n }\n}\n"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
(node as any).hash = '570efc1d3b5dac09303b8692d6830bb2';
|
(node as any).hash = '4fefb238e24b79198799686599255e6c';
|
||||||
export default node;
|
export default node;
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ class StakeOrder < ApplicationRecord
|
|||||||
validates :pool_name, presence: true
|
validates :pool_name, presence: true
|
||||||
validates :amount, presence: true
|
validates :amount, presence: true
|
||||||
|
|
||||||
|
def self.ransackable_attributes(auth_object = nil)
|
||||||
|
super & ["pool_name", "amount"]
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def notification_message
|
def notification_message
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ RSpec.describe(Mutations::CreateStakeOrder, type: :mutation) do
|
|||||||
let(:query_string) do
|
let(:query_string) do
|
||||||
<<~GQL
|
<<~GQL
|
||||||
mutation(
|
mutation(
|
||||||
$currencyId: ID!,
|
|
||||||
$amount: String!,
|
$amount: String!,
|
||||||
$poolName: String!,
|
$poolName: String!,
|
||||||
) {
|
) {
|
||||||
createStakeOrder(input: {
|
createStakeOrder(input: {
|
||||||
order: {
|
order: {
|
||||||
currencyId: $currencyId,
|
|
||||||
amount: $amount,
|
amount: $amount,
|
||||||
poolName: $poolName,
|
poolName: $poolName,
|
||||||
}
|
}
|
||||||
@@ -43,10 +41,7 @@ RSpec.describe(Mutations::CreateStakeOrder, type: :mutation) do
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
currency_global_id = GraphQL::Schema::UniqueWithinType.encode("Currency", currency.id)
|
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
"currencyId": currency_global_id,
|
|
||||||
"amount": "0.80",
|
"amount": "0.80",
|
||||||
"poolName": "CAKE/BNB",
|
"poolName": "CAKE/BNB",
|
||||||
"status": "PROCESSING",
|
"status": "PROCESSING",
|
||||||
@@ -87,10 +82,7 @@ RSpec.describe(Mutations::CreateStakeOrder, type: :mutation) do
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
currency_global_id = GraphQL::Schema::UniqueWithinType.encode("Currency", currency.id)
|
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
"currencyId": currency_global_id,
|
|
||||||
"amount": "0.80",
|
"amount": "0.80",
|
||||||
"poolName": "CAKE/BNB",
|
"poolName": "CAKE/BNB",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ RSpec.describe(Mutations::CreateStakeRemoveOrder, type: :mutation) do
|
|||||||
let(:query_string) do
|
let(:query_string) do
|
||||||
<<~GQL
|
<<~GQL
|
||||||
mutation(
|
mutation(
|
||||||
$currencyId: ID!,
|
|
||||||
$amount: String!,
|
$amount: String!,
|
||||||
$poolName: String!,
|
$poolName: String!,
|
||||||
) {
|
) {
|
||||||
createStakeRemoveOrder(input: {
|
createStakeRemoveOrder(input: {
|
||||||
order: {
|
order: {
|
||||||
currencyId: $currencyId,
|
|
||||||
amount: $amount,
|
amount: $amount,
|
||||||
poolName: $poolName,
|
poolName: $poolName,
|
||||||
}
|
}
|
||||||
@@ -43,11 +41,8 @@ RSpec.describe(Mutations::CreateStakeRemoveOrder, type: :mutation) do
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
currency_global_id = GraphQL::Schema::UniqueWithinType.encode("Currency", currency.id)
|
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
"currencyId": currency_global_id,
|
"amount": "200.80",
|
||||||
"amount": "-200.80",
|
|
||||||
"poolName": "CAKE/BNB",
|
"poolName": "CAKE/BNB",
|
||||||
"status": "PROCESSING",
|
"status": "PROCESSING",
|
||||||
}
|
}
|
||||||
@@ -85,13 +80,10 @@ RSpec.describe(Mutations::CreateStakeRemoveOrder, type: :mutation) do
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
currency_global_id = GraphQL::Schema::UniqueWithinType.encode("Currency", currency.id)
|
|
||||||
|
|
||||||
create(:stake_order, amount: -200.8, user: user, pool_name: "CAKE/BNB", currency: currency)
|
create(:stake_order, amount: -200.8, user: user, pool_name: "CAKE/BNB", currency: currency)
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
"currencyId": currency_global_id,
|
"amount": "200.80",
|
||||||
"amount": "-200.80",
|
|
||||||
"poolName": "CAKE/BNB",
|
"poolName": "CAKE/BNB",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user