Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions __tests__/components/stake/PoolFilters.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@
// PARTICULAR PURPOSE. See the GNU General Public License for more details.

import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { PoolFilters } from '../../../src/components/stake/PoolFilters';
import {
FilterModel,
PoolFilters,
} from '../../../src/components/stake/PoolFilters';
import { withChakraTheme } from '../../test-utilities';

const defaultFilters = [
const defaultFilters: FilterModel[] = [
{
title: 'Default filter',
type: 'checkbox',
key: 'type',
options: [
{
label: 'Value A',
value: 'checkbox',
default: true,
},
Expand All @@ -31,6 +35,7 @@ const defaultFilters = [
key: '',
options: [
{
label: 'Value B',
value: 'Some value',
default: true,
},
Expand All @@ -42,6 +47,7 @@ const defaultFilters = [
key: '',
options: [
{
label: 'Value C',
value: 'Some value',
default: true,
},
Expand Down
37 changes: 0 additions & 37 deletions __tests__/services/server/allowedMethods.test.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/app/api/[chain]/stats/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { BLOCKS, SUMMARY } from '../../../../graphql/queries';
import { BlocksData, SummaryData } from '../../../../graphql/models';
import { networks } from '../../../../utils/networks';
import { NextRequest, NextResponse } from 'next/server';
import { getCartesiMarketInformationEndpoint } from '../../../../services/coingecko';

interface Response {
params: Promise<{ chain: string; address: string }>;
Expand Down Expand Up @@ -56,7 +57,7 @@ const handler = async ({ params }: Response) => {
query: BLOCKS,
});

const endpoint = `https://api.coingecko.com/api/v3/coins/cartesi?localization=false&tickers=false&market_data=true&community_data=false&developer_data=false&sparkline=false`;
const endpoint = getCartesiMarketInformationEndpoint();
const response = await fetch(endpoint);
const marketData = await response.json();
const circulatingSupply = Math.round(
Expand Down
5 changes: 4 additions & 1 deletion src/app/stake/[pool]/commissions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { notFound } from 'next/navigation';
import StakePoolCommissions from '../../../../components/stake/StakePoolCommissions';
import { ethers } from 'ethers';
import { getFormattedEnsName } from '../../../../services/server/utils';
import { Metadata } from 'next';

interface StakePoolPageProps {
params: Promise<{ pool: string }>;
}

export async function generateMetadata(props: StakePoolPageProps) {
export async function generateMetadata(
props: StakePoolPageProps
): Promise<Metadata> {
const params = await props.params;
const address = params.pool;

Expand Down
5 changes: 4 additions & 1 deletion src/app/stake/[pool]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import StakePool from '../../../components/stake/StakePool';
import { notFound } from 'next/navigation';
import { ethers } from 'ethers';
import { getFormattedEnsName } from '../../../services/server/utils';
import { Metadata } from 'next';

interface StakePoolPageProps {
params: Promise<{ pool: string }>;
}

export async function generateMetadata(props: StakePoolPageProps) {
export async function generateMetadata(
props: StakePoolPageProps
): Promise<Metadata> {
const params = await props.params;
const address = params.pool;

Expand Down
5 changes: 4 additions & 1 deletion src/app/stake/[pool]/stake/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { notFound } from 'next/navigation';
import StakePoolStake from '../../../../components/stake/StakePoolStake';
import { ethers } from 'ethers';
import { getFormattedEnsName } from '../../../../services/server/utils';
import { Metadata } from 'next';

interface StakePoolPageProps {
params: Promise<{ pool: string }>;
}

export async function generateMetadata(props: StakePoolPageProps) {
export async function generateMetadata(
props: StakePoolPageProps
): Promise<Metadata> {
const params = await props.params;
const address = params.pool;

Expand Down
5 changes: 4 additions & 1 deletion src/app/stake/[pool]/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { notFound } from 'next/navigation';
import StakePoolUsers from '../../../../components/stake/StakePoolUsers';
import { ethers } from 'ethers';
import { getFormattedEnsName } from '../../../../services/server/utils';
import { Metadata } from 'next';

interface StakePoolPageProps {
params: Promise<{ pool: string }>;
}

export async function generateMetadata(props: StakePoolPageProps) {
export async function generateMetadata(
props: StakePoolPageProps
): Promise<Metadata> {
const params = await props.params;
const address = params.pool;

Expand Down
2 changes: 1 addition & 1 deletion src/components/BlocksChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const BlocksChart = (props: BlocksChartProps) => {
);
};

const tooltipFormatter = (value, name) => {
const tooltipFormatter = (value: number, name: string) => {
if (name === 'Difficulty') {
return value;
} else if (name === 'Time') {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
import theme from '../styles/theme';
import Address from './Address';
import { CartesiTranparent } from './Icons';
import { useWallet } from './wallet/useWallet';
import { useWallet } from './wallet';
import { useColorModeValue } from './ui/color-mode';

const ListHeader = ({ children }: { children: ReactNode }) => {
Expand Down
15 changes: 0 additions & 15 deletions src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import {
Flex,
FlexProps,
StackProps,
Text,
useBreakpointValue,
VStack,
} from '@chakra-ui/react';
import React, { FC } from 'react';
Expand Down Expand Up @@ -73,19 +71,6 @@ export const PageBody: FC<StackProps> = ({ children, ...restProps }) => (
</VStack>
);

export const ResponsiveDebug: FC = () => {
const color = useBreakpointValue(['yellow', 'red', 'green', 'blue']);
const size = useBreakpointValue(['sm', 'md', 'lg', 'xl']);
const index = useBreakpointValue([0, 1, 2, 3]);
return (
<Center w="100%" minH={50} bg={color}>
<Text>
{size} [{index}]
</Text>
</Center>
);
};

interface PageLayoutProps extends FlexProps {
children: React.ReactNode;
}
Expand Down
6 changes: 2 additions & 4 deletions src/components/PerPageSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

import React, { FC } from 'react';
import {
createListCollection,
HStack,
Portal,
Select,
Text,
Portal,
createListCollection,
} from '@chakra-ui/react';
import { useColorModeValue } from './ui/color-mode';

export interface PerPageSelectProps {
value: number;
Expand All @@ -27,7 +26,6 @@ export interface PerPageSelectProps {

const PerPageSelect: FC<PerPageSelectProps> = (props) => {
const { value, options, onChange } = props;
const borderWidth = useColorModeValue('0 0 1px 0', '0');
const selectOptions = createListCollection({
items: options.map((option) => ({
label: option.toString(),
Expand Down
2 changes: 1 addition & 1 deletion src/components/StepGroup/useStepState.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2022 Cartesi Pte. Ltd.

import { useEffect, useState } from 'react';
import { StepStatus } from '../Step/enums';
import { StepStatus } from '../Step';

// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
Expand Down
2 changes: 1 addition & 1 deletion src/components/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Users: FC<UsersProps> = (props) => {
const [pageNumber, setPageNumber] = useState<number>(0);
const { data, loading } = useUsers(pageNumber, search, sort, rowsPerPage);
const options = Array.from({ length: 3 }).map(
(item, index) => (index + 1) * 10
(_, index) => (index + 1) * 10
);
const pages = Math.ceil(totalItems / rowsPerPage);

Expand Down
2 changes: 1 addition & 1 deletion src/components/block/BlockTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU General Public License for more details.

import { Button, Table, Text } from '@chakra-ui/react';
import { Table, Text } from '@chakra-ui/react';
import { FC } from 'react';
import { useColorModeValue } from '../ui/color-mode';

Expand Down
2 changes: 1 addition & 1 deletion src/components/block/Blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const BlockList = (props: BlockListProps) => {
if (blocks.length > 0 && fetchMore) {
const variables = { ...result.variables };

fetchMore({
void fetchMore({
variables: {
...variables,
skip: blocks.length,
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/AccountMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Jazzicon, { jsNumberForAddress } from 'react-jazzicon';
import { useENS } from '../../services/ens';
import { truncateStringMobile } from '../../utils/stringUtils';
import { ArrowsUpDownIcon } from '../Icons';
import { useWallet } from '../wallet/useWallet';
import { useWallet } from '../wallet';
import { WalletMobileModal } from './modals/WalletMobileModal';
import { useColorModeValue } from '../ui/color-mode';

Expand Down
2 changes: 1 addition & 1 deletion src/components/header/SelectedChain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { TagRootProps } from '@chakra-ui/react';
import { FC } from 'react';
import { useWallet } from '../wallet/useWallet';
import { useWallet } from '../wallet';
import Chain from './Chain';

export interface SelectedChainProps extends TagRootProps {
Expand Down
5 changes: 3 additions & 2 deletions src/components/header/menu/WalletMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import {
import React, { FC, useMemo } from 'react';
import { useENS } from '../../../services/ens';
import { CopyIcon, DisconnectIcon, SwitchIcon } from '../../Icons';
import { useWallet } from '../../wallet/useWallet';
import { useWallet } from '../../wallet';
import { useColorModeValue } from '../../ui/color-mode';
import theme from '../../../styles/theme';
import { isString } from 'lodash';

interface WalletMenuItemProps extends MenuItemProps {
children: React.ReactNode;
Expand Down Expand Up @@ -125,7 +126,7 @@ const WalletMenu: FC = () => {

return (
<>
{typeof account === 'string' && (
{isString(account) && (
<Menu.Content
borderRadius="0"
p={0}
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/modals/WalletMobileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import { flow } from 'lodash/fp';
import { useENS } from '../../../services/ens';
import { CopyIcon, DisconnectIcon, SwitchIcon } from '../../Icons';
import { useWallet } from '../../wallet/useWallet';
import { useWallet } from '../../wallet';
import CloseButton from '../../CloseButton';

export interface IWalletMobileModalProps {
Expand Down
9 changes: 4 additions & 5 deletions src/components/node/NodeManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { useRouter } from 'next/navigation';
import { FC, useEffect, useRef, useState } from 'react';
import { TbChevronLeft } from 'react-icons/tb';
import { useColorModeValue } from '../ui/color-mode';

import Layout from '../Layout';
import { NodeStakeModal } from './modals/NodeStakeModal';
import { NodeUnstakeModal } from './modals/NodeUnstakeModal';
Expand All @@ -49,7 +48,7 @@ import { useNode } from '../../services/node';
import { useStaking } from '../../services/staking';
import { useCartesiToken } from '../../services/token';
import theme from '../../styles/theme';
import { useMessages } from '../../utils/messages';
import { getMessages } from '../../utils/messages';
import { useTimeLeft } from '../../utils/react';

const ManageNode: FC = () => {
Expand Down Expand Up @@ -232,9 +231,9 @@ const ManageNode: FC = () => {
<VStack gap={4} alignItems="stretch">
{currentTransaction === 'authorize' && (
<TransactionBanner
title={useMessages('node.authorize.authorizing')}
failTitle={useMessages('node.authorize.fail')}
successDescription={useMessages(
title={getMessages('node.authorize.authorizing')}
failTitle={getMessages('node.authorize.fail')}
successDescription={getMessages(
'node.authorize.success'
)}
transaction={node.transaction}
Expand Down
1 change: 0 additions & 1 deletion src/components/node/NodeStakingDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ export const NodeStakingDashboard: FC<NodeStakingDashboardProps> = ({
isOpen={isOpenAllowanceModal}
disclosure={disclosure}
allowance={allowance}
balance={balance}
onClose={onCloseStakingPoolAllowanceModal}
onSave={onApprove}
/>
Expand Down
8 changes: 5 additions & 3 deletions src/components/node/inputs/InitialFundsInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ const InitialFundsInput = ({
const { deposit: depositErrors } = errors;

useEffect(() => {
if (isDirty) trigger('deposit');
if (isDirty) {
void trigger('deposit');
}
}, [active]);

useEffect(() => {
Expand Down Expand Up @@ -129,10 +131,10 @@ const InitialFundsInput = ({
type="number"
onBlur={() => trigger('deposit')}
onChange={(evt) => {
onChangeValidate(evt);
void onChangeValidate(evt);
onChange(evt?.target?.value);
//trigger validations for registered field called deposit
trigger('deposit');
void trigger('deposit');
}}
/>
</InputGroup>
Expand Down
Loading