Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] cleanup warnings #984

Merged
merged 1 commit into from
Jan 29, 2025
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
},
"dependencies": {
"@apollo/client": "^3.12.3",
"@apollo/client": "^3.12.5",
"@aptos-labs/ts-sdk": "^1.33.1",
"@aptos-labs/wallet-adapter-mui-design": "3.0.23",
"@aptos-labs/wallet-adapter-react": "3.7.9",
Expand Down
7,952 changes: 2,780 additions & 5,172 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/api/hooks/useGetANS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function useGetNameFromAddress(
return queryResult.data ?? undefined;
}

// this function will return null if ans name not found to prevent useQuery complaining about undefined return
// this function will return null if ANS name not found to prevent useQuery complaining about undefined return
// source for full context: https://tanstack.com/query/v4/docs/react/guides/migrating-to-react-query-4#undefined-is-an-illegal-cache-value-for-successful-queries
async function genANSName(
address: string,
Expand Down
4 changes: 1 addition & 3 deletions src/api/hooks/useGetAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ export function useGetAccount(
) {
const [state] = useGlobalState();

const result = useQuery<Types.AccountData, ResponseError>({
return useQuery<Types.AccountData, ResponseError>({
queryKey: ["account", {address}, state.network_value],
queryFn: () => getAccount({address}, state.aptos_client),
retry: options?.retry ?? false,
});

return result;
}
4 changes: 1 addition & 3 deletions src/api/hooks/useGetAccountAllTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ export function useGetAccountAllTransactionVersions(
return [];
}

const versions: number[] = data.account_transactions.map(
return data.account_transactions.map(
(resource: {transaction_version: number}) => {
return resource.transaction_version;
},
);

return versions;
}
4 changes: 2 additions & 2 deletions src/api/hooks/useGetAccountResources.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Types} from "aptos";
import {useQuery, UseQueryResult} from "@tanstack/react-query";
import {getAccountResources} from "../../api";
import {ResponseError} from "../../api/client";
import {getAccountResources} from "../index";
import {ResponseError} from "../client";
import {useGlobalState} from "../../global-config/GlobalConfig";

export function useGetAccountResources(
Expand Down
7 changes: 1 addition & 6 deletions src/api/hooks/useGetAccountTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ export function useGetAccountTransactions(
): UseQueryResult<Array<Types.Transaction>, ResponseError> {
const [state] = useGlobalState();

const accountTransactionsResult = useQuery<
Array<Types.Transaction>,
ResponseError
>({
return useQuery<Array<Types.Transaction>, ResponseError>({
queryKey: [
"accountTransactions",
{address, start, limit},
Expand All @@ -23,6 +20,4 @@ export function useGetAccountTransactions(
queryFn: () =>
getAccountTransactions({address, start, limit}, state.aptos_client),
});

return accountTransactionsResult;
}
3 changes: 2 additions & 1 deletion src/api/hooks/useGetPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export async function getPrice(
});

if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
console.error(`HTTP error! Status: ${response.status}`);
return null;
}

const data = await response.json();
Expand Down
8 changes: 3 additions & 5 deletions src/api/hooks/useGetTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import {Types} from "aptos";
import {useQuery} from "@tanstack/react-query";
import {getTransaction} from "../../api";
import {ResponseError} from "../../api/client";
import {getTransaction} from "../index";
import {ResponseError} from "../client";
import {useGlobalState} from "../../global-config/GlobalConfig";

export function useGetTransaction(txnHashOrVersion: string) {
const [state] = useGlobalState();

const result = useQuery<Types.Transaction, ResponseError>({
return useQuery<Types.Transaction, ResponseError>({
queryKey: ["transaction", {txnHashOrVersion}, state.network_value],
queryFn: () => getTransaction({txnHashOrVersion}, state.aptos_client),
});

return result;
}
10 changes: 3 additions & 7 deletions src/api/hooks/useGetUserTransactionVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ export default function useGetUserTransactionVersions(
return [];
}

const versions: number[] = data.user_transactions.map(
(txn: {version: number}) => {
return txn.version;
},
);

return versions;
return data.user_transactions.map((txn: {version: number}) => {
return txn.version;
});
}
15 changes: 5 additions & 10 deletions src/api/hooks/useGraphqlClient.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React from "react";
import React, {useEffect, useState} from "react";
import {
ApolloClient,
InMemoryCache,
ApolloLink,
ApolloProvider,
HttpLink,
InMemoryCache,
NormalizedCacheObject,
ApolloLink,
} from "@apollo/client";
import {useEffect, useState} from "react";
import {NetworkName, getApiKey} from "../../constants";
import {getApiKey, NetworkName} from "../../constants";
import {useGlobalState} from "../../global-config/GlobalConfig";

function getIsGraphqlClientSupportedFor(networkName: NetworkName): boolean {
Expand Down Expand Up @@ -81,9 +80,5 @@ export function GraphqlClientProvider({children}: GraphqlClientProviderProps) {

export function useGetIsGraphqlClientSupported(): boolean {
const [state] = useGlobalState();
const isGraphqlClientSupported = getIsGraphqlClientSupportedFor(
state.network_name,
);

return isGraphqlClientSupported;
return getIsGraphqlClientSupportedFor(state.network_name);
}
14 changes: 1 addition & 13 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,6 @@ export async function getValidatorCommissionChange(
return withResponseError(client.view(payload));
}

export async function getDelegationPoolExist(
client: AptosClient,
validatorAddress: Types.Address,
): Promise<Types.MoveValue[]> {
const payload: Types.ViewRequest = {
function: "0x1::delegation_pool::delegation_pool_exists",
type_arguments: [],
arguments: [validatorAddress],
};
return withResponseError(client.view(payload));
}

// Return whether `pending_inactive` stake can be directly withdrawn from the delegation pool,
// for the edge case when the validator had gone inactive before its lockup expired.
export async function getCanWithdrawPendingInactive(
Expand Down Expand Up @@ -321,7 +309,7 @@ export async function getValidatorState(
return withResponseError(client.view(payload));
}

export async function getValidatorCommisionAndState(
export async function getValidatorCommissionAndState(
client: AptosClient,
validatorAddresses: Types.Address[],
): Promise<Types.MoveValue[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/api/query-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type CombinedQueryResultState = {
* @returns
* @example
* const {
* combinedQueryState: {error, isLoading}},
* combinedQueryState: {error, isLoading},
* queries: [query1, query2, query3],
* } = combineQueries([
* useQuery(...),
Expand Down
2 changes: 1 addition & 1 deletion src/components/AmountTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function AmountTextField({
warnMessage,
onAmountChange,
balance,
}: AmountTextFieldProps): JSX.Element {
}: AmountTextFieldProps) {
return (
<FormControl fullWidth>
<Stack direction="row" justifyContent="space-between">
Expand Down
2 changes: 1 addition & 1 deletion src/components/GoBack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function BackButton(handleClick: () => void) {
);
}

export default function GoBack(): JSX.Element | null {
export default function GoBack() {
const navigate = useNavigate();

if (window.history.state && window.history.state.idx > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/HashButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function getHashLinkStr(input: string, type: HashType): string {
}
}

function HashLink(hash: string, type: HashType): JSX.Element {
function HashLink(hash: string, type: HashType) {
switch (type) {
case HashType.ACCOUNT:
case HashType.TRANSACTION:
Expand Down Expand Up @@ -206,7 +206,7 @@ function HashButtonInner({
} else if (img) {
icon = (
<Box component="span" sx={{mr: 1, display: "flex", alignItems: "center"}}>
<img src={img} height={20} width={20} />
<img src={img} alt={img} height={20} width={20} />
</Box>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/IndividualPageContent/CollapsibleCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {grey} from "../../themes/colors/aptosColorPalette";

// return true if there is at least 1 card is not expanded
function getNotAllExpanded(expandedList: boolean[]): boolean {
return expandedList.find((expanded) => expanded === false) !== undefined;
return expandedList.find((expanded) => !expanded) !== undefined;
}

// return true if there is at least 1 card is expanded
function getNotAllCollapse(expandedList: boolean[]): boolean {
return expandedList.find((expanded) => expanded === true) !== undefined;
return expandedList.find((expanded) => expanded) !== undefined;
}

type ExpandAllCollapseAllButtonsProps = {
Expand Down
5 changes: 1 addition & 4 deletions src/components/IndividualPageContent/ContentBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ interface ContentBoxProps extends BoxProps {
children: React.ReactNode;
}

export default function ContentBox({
children,
...props
}: ContentBoxProps): JSX.Element {
export default function ContentBox({children, ...props}: ContentBoxProps) {
const theme = useTheme();
// TODO: unify colors for the new transaction page
const backgroundColor = theme.palette.mode === "dark" ? grey[800] : grey[50];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ContentBoxSpaceBetweenProps extends BoxProps {
export default function ContentBoxSpaceBetween({
children,
...props
}: ContentBoxSpaceBetweenProps): JSX.Element {
}: ContentBoxSpaceBetweenProps) {
const theme = useTheme();
const backgroundColor = theme.palette.mode === "dark" ? grey[800] : grey[50];

Expand Down
136 changes: 0 additions & 136 deletions src/components/IndividualPageContent/JsonCard.tsx

This file was deleted.

Loading