Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rkalis committed Nov 28, 2024
1 parent 8d501b2 commit 1061d0e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/allowances/controls/ControlsWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ControlsWrapper = ({ chainId, address, switchChainSize, children, override
const isChainSwitchEnabled = !isNullish(switchChainSize);
const shouldRenderSwitchChainButton = needsToSwitchChain && canSwitchChain && isChainSwitchEnabled;
const disabled =
!isConnectedAddress || (needsToSwitchChain && !shouldRenderSwitchChainButton) || !isNullish(overrideDisabled);
!isConnectedAddress || (needsToSwitchChain && !shouldRenderSwitchChainButton) || Boolean(overrideDisabled);

if (shouldRenderSwitchChainButton) {
return <SwitchChainButton chainId={chainId} size={switchChainSize} />;
Expand Down
6 changes: 3 additions & 3 deletions components/common/table/TableFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { flexRender, Table } from '@tanstack/react-table';
import { isNullish } from 'lib/utils';

interface Props<T> {
table: Table<T>;
Expand All @@ -7,9 +8,8 @@ interface Props<T> {
const TableFooter = <T,>({ table }: Props<T>) => {
const footers = table
.getFooterGroups()
.map((group) => group.headers.map((header) => header.column.columnDef.footer))
.flat()
.filter(Boolean);
.flatMap((group) => group.headers.map((header) => header.column.columnDef.footer))
.filter((footer) => !isNullish(footer));

if (footers.length === 0) return null;

Expand Down
3 changes: 2 additions & 1 deletion lib/chains/Chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getChain } from '@revoke.cash/chains';
import { ETHERSCAN_API_KEYS, ETHERSCAN_RATE_LIMITS, INFURA_API_KEY, RPC_OVERRIDES } from 'lib/constants';
import { EtherscanPlatform, RateLimit } from 'lib/interfaces';
import { PriceStrategy } from 'lib/price/PriceStrategy';
import { isNullish } from 'lib/utils';
import { SECOND } from 'lib/utils/time';
import {
AddEthereumChainParameter,
Expand Down Expand Up @@ -99,7 +100,7 @@ export class Chain {
getRpcUrls(): string[] {
const baseRpcUrls =
getChain(this.chainId)?.rpc?.map((url) => url.replace('${INFURA_API_KEY}', `${INFURA_API_KEY}`)) ?? [];
const specifiedRpcUrls = [this.options.rpc?.main].flat().filter(Boolean) as string[];
const specifiedRpcUrls = [this.options.rpc?.main].flat().filter((url) => !isNullish(url));
const rpcOverrides = RPC_OVERRIDES[this.chainId] ? [RPC_OVERRIDES[this.chainId]] : [];
return [...rpcOverrides, ...specifiedRpcUrls, ...baseRpcUrls];
}
Expand Down
5 changes: 2 additions & 3 deletions lib/hooks/ethereum/events/useEvents.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ERC721_ABI } from 'lib/abis';
import { addressToTopic, sortTokenEventsChronologically } from 'lib/utils';
import { addressToTopic, isNullish, sortTokenEventsChronologically } from 'lib/utils';
import {
generatePatchedAllowanceEvents,
parseApprovalForAllLog,
parseApprovalLog,
parsePermit2Log,
parseTransferLog,
TokenEvent,
} from 'lib/utils/events';
import { useMemo } from 'react';
import { Address, getAbiItem, toEventSelector } from 'viem';
Expand Down Expand Up @@ -90,7 +89,7 @@ export const useEvents = (address: Address, chainId: number) => {
];

// We sort the events in reverse chronological order to ensure that the most recent events are processed first
return sortTokenEventsChronologically(parsedEvents.filter(Boolean) as TokenEvent[]).reverse();
return sortTokenEventsChronologically(parsedEvents.filter((event) => !isNullish(event))).reverse();
}, [transferFrom, transferTo, approval, approvalForAll, permit2Approval]);

return { events, isLoading, error };
Expand Down
3 changes: 2 additions & 1 deletion lib/hooks/page-context/AddressPageContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { usePathname, useRouter } from 'lib/i18n/navigation';
import { isNullish } from 'lib/utils';
import { isSupportedChain } from 'lib/utils/chains';
import { useSearchParams } from 'next/navigation';
import React, { ReactNode, useContext, useLayoutEffect, useState } from 'react';
Expand Down Expand Up @@ -42,7 +43,7 @@ export const AddressPageContextProvider = ({ children, address, domainName, init
// The default selected chain ID is either the chainId query parameter, the connected chain ID, or 1 (Ethereum)
const queryChainId = parseInt(searchParams.get('chainId') as string);
const defaultChainId = [initialChainId, queryChainId, chain?.id, 1]
.filter(Boolean)
.filter((chainId) => !isNullish(chainId))
.find((chainId) => isSupportedChain(chainId!)) as number;
const [selectedChainId, selectChain] = useState<number>(defaultChainId);

Expand Down

0 comments on commit 1061d0e

Please sign in to comment.