Skip to content

Commit

Permalink
Refactor ClusterModal to remove web3js dependency (#268)
Browse files Browse the repository at this point in the history
This PR refactors `ClusterModal` to remove its web3js dependency, by
inlining a utils function that only it was using
  • Loading branch information
mcintyre94 authored Jul 14, 2023
1 parent a292352 commit 75e5f03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/components/ClusterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { useCluster, useClusterModal, useUpdateCustomUrl } from '@providers/cluster';
import { useDebounceCallback } from '@react-hook/debounce';
import { Cluster, clusterName, CLUSTERS, clusterSlug, ClusterStatus } from '@utils/cluster';
import { assertUnreachable } from '@utils/index';
import dynamic from 'next/dynamic';
import Link from 'next/link';
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
Expand Down Expand Up @@ -82,6 +81,10 @@ function CustomClusterInput({ activeSuffix, active }: InputProps) {
);
}

function assertUnreachable(_x: never): never {
throw new Error('Unreachable!');
}

function ClusterToggle() {
const { status, cluster } = useCluster();

Expand Down
4 changes: 0 additions & 4 deletions app/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export type SignatureProps = {
signature: TransactionSignature;
};

export function assertUnreachable(_x: never): never {
throw new Error('Unreachable!');
}

export function normalizeTokenAmount(raw: string | number, decimals: number): number {
let rawTokens: number;
if (typeof raw === 'string') rawTokens = parseInt(raw);
Expand Down

1 comment on commit 75e5f03

@vercel
Copy link

@vercel vercel bot commented on 75e5f03 Jul 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

explorer – ./

explorer-solana-labs.vercel.app
explorer-git-master-solana-labs.vercel.app
explorer.solana.com

Please sign in to comment.