fix: types

This commit is contained in:
apotdevin 2021-12-10 11:01:13 -05:00
parent 14eb0a3307
commit 24722d4f84
No known key found for this signature in database
GPG key ID: 4403F1DFBE779457
48 changed files with 228 additions and 314 deletions

View file

@ -338,7 +338,7 @@ type InvoicePayment {
type InvoiceType {
chain_address: String
confirmed_at: String
created_at: String
created_at: String!
date: String!
description: String!
description_hash: String
@ -350,7 +350,7 @@ type InvoiceType {
is_private: Boolean!
is_push: Boolean
payments: [InvoicePayment!]!
received: Float
received: Float!
received_mtokens: String!
request: String
secret: String!
@ -569,7 +569,7 @@ type PaySuccess {
}
type PaymentType {
created_at: String
created_at: String!
date: String!
destination: String!
destination_node: Node!

View file

@ -16,7 +16,6 @@ import { Upload, X, Info } from 'react-feather';
import { DetailsUpload } from '../src/components/details/detailsUpload';
import ReactTooltip from 'react-tooltip';
import { DetailsTable } from '../src/views/details/DetailsTable';
import { ChannelType } from '../src/graphql/types';
import { useUpdateMultipleFeesMutation } from '../src/graphql/mutations/__generated__/updateMultipleFees.generated';
export const IconCursor = styled.div`
@ -91,7 +90,7 @@ const Detail = () => {
</Card>
)}
<Card cardPadding={'0'}>
<DetailsTable channels={data.getChannels as ChannelType[]} />
<DetailsTable channels={data.getChannels} />
</Card>
<ReactTooltip
id={'channel_details_info'}

View file

@ -1,7 +1,6 @@
import React, { useState } from 'react';
import { useGetPeersQuery } from '../src/graphql/queries/__generated__/getPeers.generated';
import { GridWrapper } from '../src/components/gridWrapper/GridWrapper';
import { PeerType } from '../src/graphql/types';
import { NextPageContext } from 'next';
import { getProps } from '../src/utils/ssr';
import {
@ -30,7 +29,7 @@ const PeersView = () => {
<Card mobileCardPadding={'0'} mobileNoBackground={true}>
{data.getPeers.map((peer, index: number) => (
<PeersCard
peer={peer as PeerType}
peer={peer}
index={index + 1}
setIndexOpen={setIndexOpen}
indexOpen={indexOpen}

View file

@ -2,7 +2,6 @@ import * as React from 'react';
import { toast } from 'react-toastify';
import { useRouter } from 'next/router';
import { useGetMessagesQuery } from '../../../src/graphql/queries/__generated__/getMessages.generated';
import { MessagesType } from '../../../src/graphql/types';
import { useAccount } from '../../../src/hooks/UseAccount';
import { useChatState, useChatDispatch } from '../../context/ChatContext';
import { getErrorContent } from '../../utils/error';
@ -63,7 +62,7 @@ export const ChatFetcher: React.FC = () => {
const last = newMessages[0]?.id || '';
dispatch({
type: 'additional',
chats: (newMessages as MessagesType[]) || [],
chats: newMessages || [],
lastChat: last,
});
}

View file

@ -1,7 +1,6 @@
import * as React from 'react';
import { toast } from 'react-toastify';
import { useGetMessagesLazyQuery } from '../../../src/graphql/queries/__generated__/getMessages.generated';
import { MessagesType } from '../../../src/graphql/types';
import { useAccount } from '../../../src/hooks/UseAccount';
import { useChatDispatch } from '../../context/ChatContext';
import { getErrorContent } from '../../utils/error';
@ -57,7 +56,7 @@ export const ChatInit: React.FC = () => {
dispatch({
type: 'initialized',
chats: messages as MessagesType[],
chats: messages,
lastChat,
sender,
});

View file

@ -1,6 +1,6 @@
import React from 'react';
import { shorten } from '../../../../src/components/generic/helpers';
import { ChannelType } from '../../../../src/graphql/types';
import { Channel } from '../../../../src/graphql/types';
import { useGetChannelsQuery } from '../../../../src/graphql/queries/__generated__/getChannels.generated';
import { SelectWithDeco } from '../SelectWithDeco';
import { ValueProp } from '..';
@ -9,7 +9,7 @@ type ChannelSelectProps = {
title: string;
isMulti?: boolean;
maxWidth?: string;
callback: (peer: ChannelType[]) => void;
callback: (peer: Channel[]) => void;
};
export const ChannelSelect = ({
@ -53,7 +53,7 @@ export const ChannelSelect = ({
})
.filter(Boolean);
if (finalPeers.length) {
callback(finalPeers as ChannelType[]);
callback(finalPeers as Channel[]);
} else {
callback([]);
}

View file

@ -1,14 +1,14 @@
import React from 'react';
import { useGetPeersQuery } from '../../../../src/graphql/queries/__generated__/getPeers.generated';
import { shorten } from '../../../../src/components/generic/helpers';
import { PeerType } from '../../../../src/graphql/types';
import { Peer } from '../../../../src/graphql/types';
import { SelectWithDeco } from '../SelectWithDeco';
import { ValueProp } from '..';
type PeerSelectProps = {
title: string;
isMulti?: boolean;
callback: (peer: PeerType[]) => void;
callback: (peer: Peer[]) => void;
};
export const PeerSelect = ({ title, isMulti, callback }: PeerSelectProps) => {
@ -47,7 +47,7 @@ export const PeerSelect = ({ title, isMulti, callback }: PeerSelectProps) => {
})
.filter(Boolean);
if (finalPeers.length) {
callback(finalPeers as PeerType[]);
callback(finalPeers as Peer[]);
} else {
callback([]);
}

View file

@ -1,14 +1,14 @@
import React, { createContext, useContext, useReducer } from 'react';
import { MessagesType } from '../../src/graphql/types';
import { Message } from '../../src/graphql/types';
export interface SentChatProps extends MessagesType {
export interface SentChatProps extends Message {
isSent?: boolean;
feePaid?: number;
}
type State = {
initialized: boolean;
chats: MessagesType[];
chats: Message[];
sentChats: SentChatProps[];
lastChat: string;
sender: string;
@ -17,14 +17,14 @@ type State = {
type ActionType =
| {
type: 'initialized';
chats?: MessagesType[];
chats?: Message[];
lastChat?: string;
sender?: string;
sentChats?: SentChatProps[];
}
| {
type: 'additional';
chats: MessagesType[];
chats: Message[];
lastChat: string;
}
| {

View file

@ -1,19 +1,19 @@
import React, { createContext, useContext, useReducer } from 'react';
import { ChannelType } from '../../src/graphql/types';
import { Channel } from '../../src/graphql/types';
type State = {
inChannel: ChannelType | null;
outChannel: ChannelType | null;
inChannel: Channel | null;
outChannel: Channel | null;
};
type ActionType =
| {
type: 'setIn';
channel: ChannelType | null;
channel: Channel | null;
}
| {
type: 'setOut';
channel: ChannelType | null;
channel: Channel | null;
}
| {
type: 'clear';

View file

@ -9,35 +9,47 @@ export type GetFeeHealthQuery = {
__typename?: 'Query';
getFeeHealth: {
__typename?: 'ChannelsFeeHealth';
score: number;
channels: {
__typename?: 'ChannelFeeHealth';
id: string;
partnerSide: {
__typename?: 'FeeHealth';
score: number;
rate: number;
base: string;
rateScore: number;
baseScore: number;
rateOver: boolean;
baseOver: boolean;
};
mySide: {
__typename?: 'FeeHealth';
score: number;
rate: number;
base: string;
rateScore: number;
baseScore: number;
rateOver: boolean;
baseOver: boolean;
};
partner: {
__typename?: 'Node';
node: { __typename?: 'NodeType'; alias: string };
};
};
score?: number | null | undefined;
channels?:
| Array<{
__typename?: 'ChannelFeeHealth';
id?: string | null | undefined;
partnerSide?:
| {
__typename?: 'FeeHealth';
score?: number | null | undefined;
rate?: number | null | undefined;
base?: string | null | undefined;
rateScore?: number | null | undefined;
baseScore?: number | null | undefined;
rateOver?: boolean | null | undefined;
baseOver?: boolean | null | undefined;
}
| null
| undefined;
mySide?:
| {
__typename?: 'FeeHealth';
score?: number | null | undefined;
rate?: number | null | undefined;
base?: string | null | undefined;
rateScore?: number | null | undefined;
baseScore?: number | null | undefined;
rateOver?: boolean | null | undefined;
baseOver?: boolean | null | undefined;
}
| null
| undefined;
partner?:
| {
__typename?: 'Node';
node: { __typename?: 'NodeType'; alias: string };
}
| null
| undefined;
}>
| null
| undefined;
};
};

View file

@ -18,7 +18,7 @@ export type GetResumeQuery = {
__typename?: 'InvoiceType';
chain_address?: string | null | undefined;
confirmed_at?: string | null | undefined;
created_at?: string | null | undefined;
created_at: string;
description: string;
description_hash?: string | null | undefined;
expires_at: string;
@ -28,7 +28,7 @@ export type GetResumeQuery = {
is_held?: boolean | null | undefined;
is_private: boolean;
is_push?: boolean | null | undefined;
received?: number | null | undefined;
received: number;
received_mtokens: string;
request?: string | null | undefined;
secret: string;
@ -49,7 +49,7 @@ export type GetResumeQuery = {
}
| {
__typename?: 'PaymentType';
created_at?: string | null | undefined;
created_at: string;
destination: string;
fee: number;
fee_mtokens: string;

View file

@ -9,20 +9,26 @@ export type GetTimeHealthQuery = {
__typename?: 'Query';
getTimeHealth: {
__typename?: 'ChannelsTimeHealth';
score: number;
channels: {
__typename?: 'ChannelTimeHealth';
id: string;
score: number;
significant: boolean;
monitoredTime: number;
monitoredUptime: number;
monitoredDowntime: number;
partner: {
__typename?: 'Node';
node: { __typename?: 'NodeType'; alias: string };
};
};
score?: number | null | undefined;
channels?:
| Array<{
__typename?: 'ChannelTimeHealth';
id?: string | null | undefined;
score?: number | null | undefined;
significant?: boolean | null | undefined;
monitoredTime?: number | null | undefined;
monitoredUptime?: number | null | undefined;
monitoredDowntime?: number | null | undefined;
partner?:
| {
__typename?: 'Node';
node: { __typename?: 'NodeType'; alias: string };
}
| null
| undefined;
}>
| null
| undefined;
};
};

View file

@ -11,18 +11,24 @@ export type GetVolumeHealthQuery = {
__typename?: 'Query';
getVolumeHealth: {
__typename?: 'ChannelsHealth';
score: number;
channels: {
__typename?: 'ChannelHealth';
id: string;
score: number;
volumeNormalized: string;
averageVolumeNormalized: string;
partner: {
__typename?: 'Node';
node: { __typename?: 'NodeType'; alias: string };
};
};
score?: number | null | undefined;
channels?:
| Array<{
__typename?: 'ChannelHealth';
id?: string | null | undefined;
score?: number | null | undefined;
volumeNormalized?: string | null | undefined;
averageVolumeNormalized?: string | null | undefined;
partner?:
| {
__typename?: 'Node';
node: { __typename?: 'NodeType'; alias: string };
}
| null
| undefined;
}>
| null
| undefined;
};
};

View file

@ -1,4 +1,4 @@
import { gql } from 'apollo-server-micro';
import { gql } from '@apollo/client';
export const GET_FEE_HEALTH = gql`
query GetFeeHealth {

View file

@ -1,4 +1,4 @@
import { gql } from 'apollo-server-micro';
import { gql } from '@apollo/client';
export const GET_TIME_HEALTH = gql`
query GetTimeHealth {

View file

@ -1,4 +1,4 @@
import { gql } from 'apollo-server-micro';
import { gql } from '@apollo/client';
export const GET_VOLUME_HEALTH = gql`
query GetVolumeHealth {

View file

@ -206,19 +206,19 @@ export type Channel = {
export type ChannelFeeHealth = {
__typename?: 'ChannelFeeHealth';
id: Scalars['String'];
mySide: FeeHealth;
partner: Node;
partnerSide: FeeHealth;
id?: Maybe<Scalars['String']>;
mySide?: Maybe<FeeHealth>;
partner?: Maybe<Node>;
partnerSide?: Maybe<FeeHealth>;
};
export type ChannelHealth = {
__typename?: 'ChannelHealth';
averageVolumeNormalized: Scalars['String'];
id: Scalars['String'];
partner: Node;
score: Scalars['Float'];
volumeNormalized: Scalars['String'];
averageVolumeNormalized?: Maybe<Scalars['String']>;
id?: Maybe<Scalars['String']>;
partner?: Maybe<Node>;
score?: Maybe<Scalars['Float']>;
volumeNormalized?: Maybe<Scalars['String']>;
};
export type ChannelReport = {
@ -243,31 +243,31 @@ export type ChannelRequest = {
export type ChannelTimeHealth = {
__typename?: 'ChannelTimeHealth';
id: Scalars['String'];
monitoredDowntime: Scalars['Float'];
monitoredTime: Scalars['Float'];
monitoredUptime: Scalars['Float'];
partner: Node;
score: Scalars['Float'];
significant: Scalars['Boolean'];
id?: Maybe<Scalars['String']>;
monitoredDowntime?: Maybe<Scalars['Float']>;
monitoredTime?: Maybe<Scalars['Float']>;
monitoredUptime?: Maybe<Scalars['Float']>;
partner?: Maybe<Node>;
score?: Maybe<Scalars['Float']>;
significant?: Maybe<Scalars['Boolean']>;
};
export type ChannelsFeeHealth = {
__typename?: 'ChannelsFeeHealth';
channels: ChannelFeeHealth;
score: Scalars['Float'];
channels?: Maybe<Array<ChannelFeeHealth>>;
score?: Maybe<Scalars['Float']>;
};
export type ChannelsHealth = {
__typename?: 'ChannelsHealth';
channels: ChannelHealth;
score: Scalars['Float'];
channels?: Maybe<Array<ChannelHealth>>;
score?: Maybe<Scalars['Float']>;
};
export type ChannelsTimeHealth = {
__typename?: 'ChannelsTimeHealth';
channels: ChannelTimeHealth;
score: Scalars['Float'];
channels?: Maybe<Array<ChannelTimeHealth>>;
score?: Maybe<Scalars['Float']>;
};
export type ClosedChannel = {
@ -344,13 +344,13 @@ export type DecodeInvoice = {
export type FeeHealth = {
__typename?: 'FeeHealth';
base: Scalars['String'];
baseOver: Scalars['Boolean'];
baseScore: Scalars['Float'];
rate: Scalars['Float'];
rateOver: Scalars['Boolean'];
rateScore: Scalars['Float'];
score: Scalars['Float'];
base?: Maybe<Scalars['String']>;
baseOver?: Maybe<Scalars['Boolean']>;
baseScore?: Maybe<Scalars['Float']>;
rate?: Maybe<Scalars['Float']>;
rateOver?: Maybe<Scalars['Boolean']>;
rateScore?: Maybe<Scalars['Float']>;
score?: Maybe<Scalars['Float']>;
};
export type Forward = {
@ -395,7 +395,7 @@ export type InvoiceType = {
__typename?: 'InvoiceType';
chain_address?: Maybe<Scalars['String']>;
confirmed_at?: Maybe<Scalars['String']>;
created_at?: Maybe<Scalars['String']>;
created_at: Scalars['String'];
date: Scalars['String'];
description: Scalars['String'];
description_hash?: Maybe<Scalars['String']>;
@ -407,7 +407,7 @@ export type InvoiceType = {
is_private: Scalars['Boolean'];
is_push?: Maybe<Scalars['Boolean']>;
payments: Array<InvoicePayment>;
received?: Maybe<Scalars['Float']>;
received: Scalars['Float'];
received_mtokens: Scalars['String'];
request?: Maybe<Scalars['String']>;
secret: Scalars['String'];
@ -807,7 +807,7 @@ export type PaySuccess = {
export type PaymentType = {
__typename?: 'PaymentType';
created_at?: Maybe<Scalars['String']>;
created_at: Scalars['String'];
date: Scalars['String'];
destination: Scalars['String'];
destination_node: Node;

View file

@ -1,7 +1,7 @@
import { ServerAccountType } from '../../src/graphql/types';
import { ServerAccount } from '../../src/graphql/types';
import { useGetAccountQuery } from '../../src/graphql/queries/__generated__/getAccount.generated';
export const useAccount = (): ServerAccountType | null => {
export const useAccount = (): ServerAccount | null => {
const { data, loading } = useGetAccountQuery({ ssr: false });
if (loading || !data?.getAccount) {

View file

@ -1,18 +1,18 @@
import { sortBy, groupBy } from 'lodash';
import { MessagesType } from '../graphql/types';
import { Message } from '../graphql/types';
export const separateBySender = (chats: MessagesType[]) => {
export const separateBySender = (chats: Message[]) => {
return groupBy(chats, 'sender');
};
export const getSenders = (
bySender: ReturnType<typeof separateBySender>
): MessagesType[] => {
const senders: MessagesType[] = [];
): Message[] => {
const senders: Message[] = [];
for (const key in bySender) {
if (Object.prototype.hasOwnProperty.call(bySender, key)) {
const messages = bySender[key];
const sorted: MessagesType[] = sortBy(messages, 'date').reverse();
const sorted: Message[] = sortBy(messages, 'date').reverse();
if (sorted.length > 0) {
const chat = sorted[0];

View file

@ -1,5 +1,5 @@
import * as React from 'react';
import { BosRebalanceResultType } from '../../graphql/types';
import { BosRebalanceResult } from '../../graphql/types';
import {
SubCard,
Separation,
@ -17,7 +17,7 @@ import {
} from './Balance.styled';
type AdvancedResultProps = {
rebalanceResult: BosRebalanceResultType;
rebalanceResult: BosRebalanceResult;
};
export const AdvancedResult: React.FC<AdvancedResultProps> = ({

View file

@ -1,6 +1,6 @@
import React from 'react';
import { shorten } from '../../components/generic/helpers';
import { ChannelType } from '../../graphql/types';
import { Channel } from '../../graphql/types';
import { useGetChannelsQuery } from '../../graphql/queries/__generated__/getChannels.generated';
import { ValueProp } from '../../components/select';
import { SelectWithDecoAndValue } from '../../components/select/SelectWithDeco';
@ -10,8 +10,8 @@ import { ChannelInfo } from './ChannelInfo';
type ChannelSelectProps = {
inThroughId: string;
outThroughId: string;
inCallback: (peer: ChannelType[]) => void;
outCallback: (peer: ChannelType[]) => void;
inCallback: (peer: Channel[]) => void;
outCallback: (peer: Channel[]) => void;
};
type OptionsItem = ValueProp & {
@ -141,9 +141,9 @@ export const PeerSelection = ({
.filter(Boolean);
if (finalPeers.length) {
if (incoming) {
inCallback(finalPeers as ChannelType[]);
inCallback(finalPeers as Channel[]);
} else {
outCallback(finalPeers as ChannelType[]);
outCallback(finalPeers as Channel[]);
}
} else {
if (incoming) {

View file

@ -1,7 +1,6 @@
import React, { useState } from 'react';
import { toast } from 'react-toastify';
import { useGetChainTransactionsQuery } from '../../../graphql/queries/__generated__/getChainTransactions.generated';
import { GetTransactionsType } from '../../../graphql/types';
import {
SubTitle,
Card,
@ -28,7 +27,7 @@ export const ChainTransactions = () => {
<Card mobileCardPadding={'0'} mobileNoBackground={true}>
{data.getChainTransactions.map((transaction, index) => (
<TransactionsCard
transaction={transaction as GetTransactionsType}
transaction={transaction}
key={index}
index={index + 1}
setIndexOpen={setIndexOpen}

View file

@ -1,6 +1,6 @@
import React from 'react';
import styled from 'styled-components';
import { GetTransactionsType } from '../../../graphql/types';
import { ChainTransaction } from '../../../graphql/types';
import {
Separation,
SubCard,
@ -24,7 +24,7 @@ const AddMargin = styled.div`
`;
interface TransactionsCardProps {
transaction: GetTransactionsType;
transaction: Omit<ChainTransaction, 'is_confirmed' | 'is_outgoing'>;
index: number;
setIndexOpen: (index: number) => void;
indexOpen: number;

View file

@ -1,7 +1,6 @@
import React, { useState } from 'react';
import { toast } from 'react-toastify';
import { useGetUtxosQuery } from '../../../graphql/queries/__generated__/getUtxos.generated';
import { GetUtxosType } from '../../../graphql/types';
import {
SubTitle,
Card,
@ -28,7 +27,7 @@ export const ChainUtxos = () => {
<Card mobileCardPadding={'0'} mobileNoBackground={true}>
{data.getUtxos.map((utxo, index: number) => (
<UtxoCard
utxo={utxo as GetUtxosType}
utxo={utxo}
key={index}
index={index + 1}
setIndexOpen={setIndexOpen}

View file

@ -1,5 +1,5 @@
import React from 'react';
import { GetUtxosType } from '../../../graphql/types';
import { Utxo } from '../../../graphql/types';
import { Separation, SubCard } from '../../../components/generic/Styled';
import { MainInfo } from '../../../components/generic/CardGeneric';
import {
@ -11,7 +11,7 @@ import { useConfigState } from '../../../context/ConfigContext';
import { usePriceState } from '../../../context/PriceContext';
interface TransactionsCardProps {
utxo: GetUtxosType;
utxo: Utxo;
index: number;
setIndexOpen: (index: number) => void;
indexOpen: number;

View file

@ -3,7 +3,7 @@ import { BalanceBars, SumBar } from '../../../components/balance';
import { ProgressBar } from '../../../components/generic/CardGeneric';
import { FormatFnType } from '../../../components/price/Price';
import { useConfigState } from '../../../context/ConfigContext';
import { ChannelType } from '../../../graphql/types';
import { Channel } from '../../../graphql/types';
import { getPercent } from '../../../utils/helpers';
import { ChannelStatsColumn, ChannelStatsLine } from './Channel.style';
import { WUMBO_MIN_SIZE } from './Channels';
@ -16,7 +16,7 @@ const getBar = (top: number, bottom: number) => {
};
type ChannelBarsProps = {
info: ChannelType;
info: Channel;
format: FormatFnType;
details: {
biggestRateFee: number;

View file

@ -3,12 +3,12 @@ import { renderLine } from '../../../components/generic/helpers';
import { Separation, SubTitle } from '../../../components/generic/Styled';
import { FormatFnType } from '../../../components/price/Price';
import { useConfigState } from '../../../context/ConfigContext';
import { ChannelType } from '../../../graphql/types';
import { Channel } from '../../../graphql/types';
const MAX_HTLCS = 483;
type ChannelBarsInfoProps = {
info: ChannelType;
info: Channel;
format: FormatFnType;
};

View file

@ -8,7 +8,7 @@ import {
ChevronsDown,
X,
} from 'react-feather';
import { ChannelType } from '../../../graphql/types';
import { Channel } from '../../../graphql/types';
import {
useRebalanceState,
useRebalanceDispatch,
@ -44,7 +44,7 @@ const getPrivate = (status: boolean) => {
};
interface ChannelCardProps {
channelInfo: ChannelType;
channelInfo: Channel;
index: number;
setIndexOpen: (indexNumber: number) => void;
indexOpen: number;

View file

@ -15,7 +15,7 @@ import {
import { ChangeDetails } from '../../../components/modal/changeDetails/ChangeDetails';
import { CloseChannel } from '../../../components/modal/closeChannel/CloseChannel';
import Modal from '../../../components/modal/ReactModal';
import { ChannelType } from '../../../graphql/types';
import { Channel } from '../../../graphql/types';
import {
blockToTime,
formatSats,
@ -29,7 +29,7 @@ import { WumboTag } from './Channel.style';
import { NodePeerSocials } from './NodePeerSocials';
type ChannelDetailsProps = {
info: ChannelType;
info: Channel;
format: FormatFnType;
};

View file

@ -4,7 +4,7 @@ import { useGetChannelsQuery } from '../../../graphql/queries/__generated__/getC
import { useConfigState } from '../../../context/ConfigContext';
import { sortBy } from 'lodash';
import { getPercent } from '../../../utils/helpers';
import { ChannelType } from '../../../graphql/types';
import { Channel } from '../../../graphql/types';
import { useRebalanceState } from '../../../context/RebalanceContext';
import { useRouter } from 'next/router';
import { getErrorContent } from '../../../utils/error';
@ -108,8 +108,8 @@ export const Channels: React.FC = () => {
}
}
const getChannels = (): ChannelType[] => {
const channels: ChannelType[] = data?.getChannels as ChannelType[];
const getChannels = (): Channel[] => {
const channels: Channel[] = data?.getChannels as Channel[];
switch (channelSort) {
case 'local': {
const newArray = sortBy(channels, 'local_balance');
@ -169,7 +169,7 @@ export const Channels: React.FC = () => {
<>
{getChannels().map((channel, index) => (
<ChannelCard
channelInfo={channel as ChannelType}
channelInfo={channel as Channel}
index={index + 1}
setIndexOpen={setIndexOpen}
indexOpen={indexOpen}

View file

@ -1,6 +1,6 @@
import React from 'react';
import styled from 'styled-components';
import { ClosedChannelType } from '../../../graphql/types';
import { ClosedChannel } from '../../../graphql/types';
import { blockToTime } from '../../../utils/helpers';
import { NodeTitle, MainInfo } from '../../../components/generic/CardGeneric';
import {
@ -22,7 +22,7 @@ const Padding = styled.div`
`;
interface PendingCardProps {
channelInfo: ClosedChannelType;
channelInfo: ClosedChannel;
index: number;
setIndexOpen: (index: number) => void;
indexOpen: number;

View file

@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { toast } from 'react-toastify';
import { useGetClosedChannelsQuery } from '../../../graphql/queries/__generated__/getClosedChannels.generated';
import { ClosedChannelType } from '../../../graphql/types';
import { ClosedChannel } from '../../../graphql/types';
import { Card } from '../../../components/generic/Styled';
import { getErrorContent } from '../../../utils/error';
import { LoadingCard } from '../../../components/loading/LoadingCard';
@ -22,7 +22,7 @@ export const ClosedChannels = () => {
<Card mobileCardPadding={'0'} mobileNoBackground={true}>
{data.getClosedChannels.map((channel, index) => (
<ClosedCard
channelInfo={channel as ClosedChannelType}
channelInfo={channel as ClosedChannel}
key={index}
index={index + 1}
setIndexOpen={setIndexOpen}

View file

@ -1,6 +1,6 @@
import React from 'react';
import ReactTooltip from 'react-tooltip';
import { PendingChannelType } from '../../../graphql/types';
import { PendingChannel } from '../../../graphql/types';
import { blockToTime, getPercent } from '../../../utils/helpers';
import {
Progress,
@ -31,7 +31,7 @@ import { getPrice } from '../../../components/price/Price';
import { usePriceState } from '../../../context/PriceContext';
interface PendingCardProps {
channelInfo: PendingChannelType;
channelInfo: PendingChannel;
index: number;
setIndexOpen: (index: number) => void;
indexOpen: number;

View file

@ -1,7 +1,6 @@
import React, { useState } from 'react';
import { toast } from 'react-toastify';
import { useGetPendingChannelsQuery } from '../../../graphql/queries/__generated__/getPendingChannels.generated';
import { PendingChannelType } from '../../../graphql/types';
import { Card } from '../../../components/generic/Styled';
import { getErrorContent } from '../../../utils/error';
import { LoadingCard } from '../../../components/loading/LoadingCard';
@ -22,7 +21,7 @@ export const PendingChannels = () => {
<Card mobileCardPadding={'0'} mobileNoBackground={true}>
{data.getPendingChannels.map((channel, index: number) => (
<PendingCard
channelInfo={channel as PendingChannelType}
channelInfo={channel}
key={index}
index={index + 1}
setIndexOpen={setIndexOpen}

View file

@ -1,6 +1,6 @@
import * as React from 'react';
import { sortBy } from 'lodash';
import { MessagesType } from '../../graphql/types';
import { Message } from '../../graphql/types';
import { SentChatProps } from '../../context/ChatContext';
import {
getMessageDate,
@ -53,7 +53,7 @@ export const MessageCard = ({
};
interface ChatBoxProps {
messages: MessagesType[];
messages: Message[];
alias: string;
}

View file

@ -1,7 +1,7 @@
import * as React from 'react';
import { X, ChevronRight } from 'react-feather';
import { useGetPeersQuery } from '../../graphql/queries/__generated__/getPeers.generated';
import { PeerType } from '../../graphql/types';
import { Peer } from '../../graphql/types';
import { Input } from '../../components/input';
import {
SubCard,
@ -20,7 +20,7 @@ import {
} from './Chat.styled';
interface PeerProps {
peer: PeerType;
peer: Peer;
index: number;
indexOpen: number;
setIndexOpen: (index: number) => void;
@ -98,7 +98,7 @@ export const ChatStart = ({
<SubTitle>Chat with a current peer</SubTitle>
{data.getPeers.map((peer, index) => (
<PeerChatCard
peer={peer as PeerType}
peer={peer}
index={index + 1}
setIndexOpen={setIndexOpen}
indexOpen={indexOpen}

View file

@ -2,9 +2,9 @@ import React, { useMemo, useRef, useEffect } from 'react';
import { useTable, useSortBy, useRowSelect } from 'react-table';
import { separationColor } from '../../styles/Themes';
import { saveToPc } from '../../utils/helpers';
import { ChannelType } from '../../graphql/types';
import styled from 'styled-components';
import { toast } from 'react-toastify';
import { ChannelFeesQuery } from '../../graphql/queries/__generated__/getChannelFees.generated';
const ToastStyle = styled.div`
width: 100%;
@ -57,7 +57,9 @@ const IndeterminateCheckbox = React.forwardRef<
IndeterminateCheckbox.displayName = 'IndeterminateCheckbox';
type DetailsTableType = { channels: ChannelType[] };
type DetailsTableType = {
channels: ChannelFeesQuery['getChannels'];
};
export const DetailsTable = ({ channels }: DetailsTableType) => {
const toastId = useRef<any>(null);

View file

@ -75,7 +75,7 @@ export const Pay: React.FC<PayProps> = ({ predefinedRequest, payCallback }) => {
const { description, tokens, destination_node } = data.decodeRequest;
const { alias } = destination_node.node;
const { alias } = destination_node?.node || { alias: 'Unknown' };
return (
<>

View file

@ -5,16 +5,8 @@ import CopyToClipboard from 'react-copy-to-clipboard';
import { useCreateAddressMutation } from '../../../../graphql/mutations/__generated__/createAddress.generated';
import QRCode from 'qrcode.react';
import { Copy } from 'react-feather';
import {
NoWrapTitle,
ResponsiveLine,
} from '../../../../components/generic/Styled';
import { getErrorContent } from '../../../../utils/error';
import { ColorButton } from '../../../../components/buttons/colorButton/ColorButton';
import {
MultiButton,
SingleButton,
} from '../../../../components/buttons/multiButton/MultiButton';
import { mediaWidths } from '../../../../styles/Themes';
const Responsive = styled.div`
@ -53,17 +45,7 @@ const Column = styled.div`
align-items: center;
`;
const ButtonRow = styled.div`
width: auto;
display: flex;
`;
const TitleWithSpacing = styled(NoWrapTitle)`
margin-right: 10px;
`;
export const ReceiveOnChainCard = () => {
const [nested, setNested] = useState(false);
const [received, setReceived] = useState(false);
const [createAddress, { data, loading }] = useCreateAddressMutation({
@ -95,40 +77,17 @@ export const ReceiveOnChainCard = () => {
</Column>
</Responsive>
) : (
<ResponsiveLine>
<ButtonRow>
<TitleWithSpacing>Type of Address:</TitleWithSpacing>
<MultiButton>
<SingleButton
selected={!nested}
onClick={() => {
setNested(false);
}}
>
P2WPKH
</SingleButton>
<SingleButton
selected={nested}
onClick={() => {
setNested(true);
}}
>
NP2WPKH
</SingleButton>
</MultiButton>
</ButtonRow>
<ColorButton
onClick={() => createAddress({ variables: { nested } })}
disabled={received}
withMargin={'0 0 0 16px'}
mobileMargin={'16px 0 0'}
arrow={true}
loading={loading}
mobileFullWidth={true}
>
Create Address
</ColorButton>
</ResponsiveLine>
<ColorButton
onClick={() => createAddress()}
disabled={received}
withMargin={'0 0 0 16px'}
mobileMargin={'16px 0 0'}
arrow={true}
loading={loading}
mobileFullWidth={true}
>
Create Address
</ColorButton>
)}
</>
);

View file

@ -5,7 +5,6 @@ import styled from 'styled-components';
import CopyToClipboard from 'react-copy-to-clipboard';
import { ColorButton } from '../../../components/buttons/colorButton/ColorButton';
import { renderLine } from '../../../components/generic/helpers';
import { NodeInfoType } from '../../../graphql/types';
import { useGetNodeInfoQuery } from '../../../graphql/queries/__generated__/getNodeInfo.generated';
import { getErrorContent } from '../../../utils/error';
import { LoadingCard } from '../../../components/loading/LoadingCard';
@ -74,7 +73,7 @@ export const ConnectCard = () => {
return <LoadingCard title={'Connect'} />;
}
const { public_key, uris } = (data.getNodeInfo as NodeInfoType) || {};
const { public_key, uris } = data.getNodeInfo || {};
const onionAddress = uris.find((uri: string) => uri.indexOf('onion') >= 0);
const normalAddress = uris.find((uri: string) => uri.indexOf('onion') < 0);

View file

@ -1,13 +1,6 @@
import * as React from 'react';
import { toast } from 'react-toastify';
import { useDecodeRequestQuery } from '../../../../graphql/queries/__generated__/decodeRequest.generated';
import {
Separation,
Sub4Title,
DarkSubTitle,
} from '../../../../components/generic/Styled';
import { useConfigState } from '../../../../context/ConfigContext';
import { usePriceState } from '../../../../context/PriceContext';
import { getErrorContent } from '../../../../utils/error';
import { LoadingCard } from '../../../../components/loading/LoadingCard';
import {
@ -16,7 +9,7 @@ import {
getDateDif,
getFormatDate,
} from '../../../../components/generic/helpers';
import { Price, getPrice } from '../../../../components/price/Price';
import { Price } from '../../../../components/price/Price';
interface DecodedProps {
request: string;
@ -24,10 +17,6 @@ interface DecodedProps {
}
export const Decoded = ({ request, setShow }: DecodedProps) => {
const { currency, displayValues } = useConfigState();
const priceContext = usePriceState();
const format = getPrice(currency, displayValues, priceContext);
const { data, loading } = useDecodeRequestQuery({
fetchPolicy: 'network-only',
variables: { request },
@ -51,54 +40,9 @@ export const Decoded = ({ request, setShow }: DecodedProps) => {
id,
tokens,
destination_node,
probe_route,
} = data.decodeRequest;
const alias = destination_node.node.alias;
const renderRoute = () => {
if (!probe_route?.route) {
return (
<>
<Separation />
<Sub4Title>Route</Sub4Title>
<DarkSubTitle>No route found to pay this request</DarkSubTitle>
</>
);
}
const { fee, safe_fee, confidence, hops } = probe_route.route;
return (
<>
<Separation />
<Sub4Title>Route</Sub4Title>
{renderLine('Confidence', `${Math.round(confidence / 10000)}%`)}
{renderLine('Fee', format({ amount: fee, override: 'sat' }))}
{renderLine('Safe Fee', format({ amount: safe_fee, override: 'sat' }))}
{renderLine('Hops:', hops.length)}
{hops.map((hop, index: number) => {
return (
<React.Fragment key={index}>
<Separation />
<Sub4Title>{`Hop ${index + 1}`}</Sub4Title>
{renderLine('Fee', hop.fee)}
{renderLine('Forwarded Tokens', hop.forward)}
{renderLine(
`Destination `,
getNodeLink(hop.public_key, hop.node.node.alias)
)}
{renderLine('Channel', hop.channel)}
{renderLine(
'Channel Capacity',
format({ amount: hop.channel_capacity })
)}
</React.Fragment>
);
})}
</>
);
};
const alias = destination_node?.node.alias || 'Unknown';
return (
<>
@ -113,7 +57,6 @@ export const Decoded = ({ request, setShow }: DecodedProps) => {
`${getDateDif(expires_at)} (${getFormatDate(expires_at)})`
)}
{renderLine('Amount:', <Price amount={tokens} />)}
{renderRoute()}
</>
);
};

View file

@ -1,5 +1,5 @@
import * as React from 'react';
import { BaseNodesType } from '../../../../graphql/types';
import { BaseNode } from '../../../../graphql/types';
import { useGetNodeQuery } from '../../../../graphql/queries/__generated__/getNode.generated';
import { LoadingCard } from '../../../../components/loading/LoadingCard';
import {
@ -19,7 +19,7 @@ import { ColorButton } from '../../../../components/buttons/colorButton/ColorBut
import { OpenChannelCard } from './OpenChannel';
type OpenProps = {
partner: BaseNodesType;
partner: BaseNode;
setOpenCard: (card: string) => void;
};

View file

@ -27,7 +27,7 @@ import {
X,
} from 'react-feather';
import { ColorButton } from '../../../../components/buttons/colorButton/ColorButton';
import { BaseNodesType } from '../../../../graphql/types';
import { BaseNode } from '../../../../graphql/types';
import { OpenChannelCard } from './OpenChannel';
import { OpenRecommended } from './OpenRecommended';
@ -80,7 +80,7 @@ interface OpenChannelProps {
export const OpenChannel = ({ setOpenCard }: OpenChannelProps) => {
const [openDetails, setOpenDetails] = React.useState(false);
const [partner, setPartner] = React.useState<BaseNodesType | null>(null);
const [partner, setPartner] = React.useState<BaseNode | null>(null);
const [open, set] = React.useState(false);
const { data, loading } = useGetBaseNodesQuery();

View file

@ -1,5 +1,5 @@
import React from 'react';
import { BasePointsType } from '../../graphql/types';
import { BasePoints } from '../../graphql/types';
import styled from 'styled-components';
import { DarkSubTitle } from '../../components/generic/Styled';
import { themeColors } from '../../styles/Themes';
@ -66,7 +66,7 @@ const getWidth = (index: number): string => {
};
type NodeCardType = {
node: BasePointsType | null | undefined;
node: BasePoints | null | undefined;
index: number;
};

View file

@ -2,7 +2,7 @@ import React, { useState } from 'react';
import styled from 'styled-components';
import { ArrowDown, ArrowUp } from 'react-feather';
import ReactTooltip from 'react-tooltip';
import { PeerType } from '../../graphql/types';
import { Peer } from '../../graphql/types';
import {
SubCard,
Separation,
@ -42,7 +42,7 @@ const getSymbol = (status: boolean) => {
};
interface PeerProps {
peer: PeerType;
peer: Peer;
index: number;
setIndexOpen: (index: number) => void;
indexOpen: number;

View file

@ -1,8 +1,7 @@
import {
BoltzSwapStatus,
CreateBoltzReverseSwapType,
DecodeType,
NodeType,
DecodeInvoice,
} from '../../graphql/types';
export type CreateBoltzReverseSwap = Pick<
@ -18,21 +17,16 @@ export type CreateBoltzReverseSwap = Pick<
| 'preimage'
| 'privateKey'
> & {
decodedInvoice?:
| (Pick<
DecodeType,
| 'description'
| 'destination'
| 'expires_at'
| 'id'
| 'safe_tokens'
| 'tokens'
> & {
destination_node: {
node: Pick<NodeType, 'alias'>;
};
})
| null;
decodedInvoice?: Pick<
DecodeInvoice,
| 'description'
| 'destination'
| 'expires_at'
| 'id'
| 'safe_tokens'
| 'tokens'
| 'destination_node'
> | null;
} & { claimTransaction?: string };
export type EnrichedSwap = {

View file

@ -14,7 +14,6 @@ import {
SingleButton,
MultiButton,
} from '../../../components/buttons/multiButton/MultiButton';
import { PermissionsType } from '../../../../server/schema/macaroon/resolvers';
import { useCreateMacaroonMutation } from '../../../graphql/mutations/__generated__/createMacaroon.generated';
import { toast } from 'react-toastify';
import { getErrorContent } from '../../../utils/error';
@ -23,6 +22,7 @@ import Modal from '../../../components/modal/ReactModal';
import { shorten } from '../../../components/generic/helpers';
import CopyToClipboard from 'react-copy-to-clipboard';
import { Copy } from 'react-feather';
import { NetworkInfoInput } from '../../../graphql/types';
const InitPermissions = {
is_ok_to_adjust_peers: false,
@ -49,7 +49,7 @@ export const Bakery = () => {
const [newMacaroon, newMacaroonSet] = React.useState<boolean>(false);
const [permissions, permissionSet] =
React.useState<PermissionsType>(InitPermissions);
React.useState<NetworkInfoInput>(InitPermissions);
let hasATrue = false;
Object.entries(permissions);
@ -113,7 +113,7 @@ export const Bakery = () => {
);
};
const renderLine = (title: string, value: keyof PermissionsType) => (
const renderLine = (title: string, value: keyof NetworkInfoInput) => (
<ResponsiveLine>
{permissions[value] ? (
<Sub4Title>{title}</Sub4Title>

View file

@ -21,7 +21,7 @@ export class InvoiceType {
chain_address: string;
@Field({ nullable: true })
confirmed_at: string;
@Field({ nullable: true })
@Field()
created_at: string;
@Field()
description: string;
@ -41,7 +41,7 @@ export class InvoiceType {
is_private: boolean;
@Field({ nullable: true })
is_push: boolean;
@Field({ nullable: true })
@Field()
received: number;
@Field()
received_mtokens: string;
@ -61,7 +61,7 @@ export class InvoiceType {
@ObjectType()
export class PaymentType {
@Field({ nullable: true })
@Field()
created_at: string;
@Field()
destination: string;