Skip to content
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
13 changes: 9 additions & 4 deletions apps/dashboard/src/@/components/blocks/multi-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,18 @@ export const MultiSelect = forwardRef<HTMLButtonElement, MultiSelectProps>(
if (filteredOptions.length >= itemsToShow) {
break;
}
const option = options[i];
if (!option) {
continue;
}

if (overrideSearchFn) {
if (overrideSearchFn(options[i], searchValLowercase)) {
filteredOptions.push(options[i]);
if (overrideSearchFn(option, searchValLowercase)) {
filteredOptions.push(option);
}
} else {
if (options[i].label.toLowerCase().includes(searchValLowercase)) {
filteredOptions.push(options[i]);
if (option.label.toLowerCase().includes(searchValLowercase)) {
filteredOptions.push(option);
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions apps/dashboard/src/@/components/blocks/select-with-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ export const SelectWithSearch = React.forwardRef<
if (filteredOptions.length >= itemsToShow) {
break;
}
const option = options[i];
if (!option) {
continue;
}

if (overrideSearchFn) {
if (overrideSearchFn(options[i], searchValLowercase)) {
filteredOptions.push(options[i]);
if (overrideSearchFn(option, searchValLowercase)) {
filteredOptions.push(option);
}
} else {
if (options[i].label.toLowerCase().includes(searchValLowercase)) {
filteredOptions.push(options[i]);
if (option.label.toLowerCase().includes(searchValLowercase)) {
filteredOptions.push(option);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/@/components/ui/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const ChartTooltipContent = React.forwardRef<
}

const [item] = payload;
const key = `${labelKey || item.dataKey || item.name || "value"}`;
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
const itemConfig = getPayloadConfigFromPayload(config, item, key);
const value =
!labelKey && typeof label === "string"
Expand Down
4 changes: 3 additions & 1 deletion apps/dashboard/src/@/components/ui/image-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const ImageUpload = React.forwardRef<HTMLInputElement, ImageUploadProps>(
const [activeFile, setActiveFile] = React.useState<File | null>(null);
const onDrop = React.useCallback(
(acceptedFiles: File[]) => {
setActiveFile(acceptedFiles[0]);
if (acceptedFiles[0]) {
setActiveFile(acceptedFiles[0]);
}
onUpload?.(acceptedFiles);
},
[onUpload],
Expand Down
5 changes: 3 additions & 2 deletions apps/dashboard/src/@/components/ui/input-otp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const InputOTPSlot = React.forwardRef<
React.ComponentPropsWithoutRef<"div"> & { index: number }
>(({ index, className, ...props }, ref) => {
const inputOTPContext = React.useContext(OTPInputContext);
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
// biome-ignore lint/style/noNonNullAssertion: pure shadcn component - it works
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]!;

return (
<div
Expand All @@ -62,7 +63,7 @@ const InputOTPSeparator = React.forwardRef<
React.ElementRef<"div">,
React.ComponentPropsWithoutRef<"div">
>(({ ...props }, ref) => (
// biome-ignore lint/a11y/useFocusableInteractive: <explanation>
// biome-ignore lint/a11y/useFocusableInteractive: pure shadcn component - it works
<div ref={ref} role="separator" {...props}>
<Dot />
</div>
Expand Down
13 changes: 6 additions & 7 deletions apps/dashboard/src/@3rdweb-sdk/react/hooks/useActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ export function useActivity(contract: ThirdwebContract, autoUpdate?: boolean) {
}
const obj = eventsQuery.data.slice(0, 100).reduce(
(acc, curr) => {
if (acc[curr.transactionHash]) {
acc[curr.transactionHash].events.push(curr);
acc[curr.transactionHash].events.sort(
(a, b) => b.logIndex - a.logIndex,
);
if (acc[curr.transactionHash].blockNumber > curr.blockNumber) {
acc[curr.transactionHash].blockNumber = curr.blockNumber;
const internalTx = acc[curr.transactionHash];
if (internalTx) {
internalTx.events.push(curr);
internalTx.events.sort((a, b) => b.logIndex - a.logIndex);
if (internalTx.blockNumber > curr.blockNumber) {
internalTx.blockNumber = curr.blockNumber;
}
} else {
acc[curr.transactionHash] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function fetchDashboardContractMetadata(
if (compilerMetadata?.name.includes(":")) {
const _name = compilerMetadata.name.split(":")[1];
if (_name) {
compilerMetadata.name = compilerMetadata.name.split(":")[1];
compilerMetadata.name = _name;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function minimizeChain(
return {
name: chain.name,
chain: chain.chain,
rpc: [firstRpc],
rpc: [firstRpc || ""],
nativeCurrency: chain.nativeCurrency,
shortName: chain.shortName,
chainId: chain.chainId,
Expand Down Expand Up @@ -509,7 +509,7 @@ export const EmbedSetup: React.FC<EmbedSetupProps> = ({
)}
{colorOptions.map((color) => (
<option key={color} value={color}>
{color[0].toUpperCase() + color.substring(1)}
{color[0]?.toUpperCase() + color.substring(1)}
</option>
))}
</Select>
Expand All @@ -524,7 +524,7 @@ export const EmbedSetup: React.FC<EmbedSetupProps> = ({
<Select {...register("secondaryColor")}>
{colorOptions.map((color) => (
<option key={color} value={color}>
{color[0].toUpperCase() + color.substring(1)}
{color[0]?.toUpperCase() + color.substring(1)}
</option>
))}
</Select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export const PermissionsTable: React.FC<PermissionsTableProps> = ({
roleMembers.forEach((member) => {
return !acc.find((m) => m.member === member)
? acc.push({ member, roles: [role] })
: acc[acc.findIndex((m) => m.member === member)].roles.push(role);
: acc[acc.findIndex((m) => m.member === member)]?.roles.push(
role,
);
});

return acc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const DistributeButton: React.FC<DistributeButtonProps> = ({
const numTransactions = useMemo(() => {
if (
validBalances.length === 1 &&
validBalances[0].name === "Native Token"
validBalances[0]?.name === "Native Token"
) {
return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function EcosystemLandingPage(props: {
console.error("failed to fetch ecosystems", err);
return [];
});
if (ecosystems.length > 0) {
if (ecosystems[0]) {
redirect(`${props.ecosystemLayoutPath}/${ecosystems[0].slug}`);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ export function CreateEcosystemForm(props: {
<ImageUpload
accept="image/png, image/jpeg"
onUpload={(files) => {
form.setValue("logo", files[0]);
form.clearErrors("logo");
if (files[0]) {
form.setValue("logo", files[0]);
form.clearErrors("logo");
}
}}
/>
</FormControl>
Expand Down
16 changes: 12 additions & 4 deletions apps/dashboard/src/app/(dashboard)/explore/[category]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ export default async function ExploreCategoryPage(
<div className="h-10" />
<div className="grid grid-cols-1 gap-5 md:grid-cols-3">
{category.contracts.map((publishedContractId, idx) => {
const publisher: string = Array.isArray(publishedContractId)
const publisher: string | undefined = Array.isArray(
publishedContractId,
)
? publishedContractId[0].split("/")[0]
: publishedContractId.split("/")[0];
const contractId: string = Array.isArray(publishedContractId)
const contractId: string | undefined = Array.isArray(
publishedContractId,
)
? publishedContractId[0].split("/")[1]
: publishedContractId.split("/")[1];
const modules = Array.isArray(publishedContractId)
Expand All @@ -92,6 +96,10 @@ export default async function ExploreCategoryPage(
const overrides = Array.isArray(publishedContractId)
? publishedContractId[2]
: undefined;
if (!publisher || !contractId) {
return null;
}

return (
<ContractCard
key={publisher + contractId + overrides?.title}
Expand All @@ -107,8 +115,8 @@ export default async function ExploreCategoryPage(
modules={
modules?.length
? modules.map((m) => ({
publisher: m.split("/")[0],
moduleId: m.split("/")[1],
publisher: m.split("/")[0] || "",
moduleId: m.split("/")[1] || "",
}))
: undefined
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export default async function Image(props: {
publishedContracts.find((p) => p.version === props.params.version) ||
publishedContracts[0];

if (!publishedContract) {
return null;
}

const publishedContractName =
publishedContract?.displayName || publishedContract?.name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getThirdwebClient } from "@/constants/thirdweb.server";
import { SimpleGrid } from "@chakra-ui/react";
import { fetchPublishedContractVersions } from "components/contract-components/fetch-contracts-with-versions";
import { PublishedContract } from "components/contract-components/published-contract";
import { notFound } from "next/navigation";
import { isAddress } from "thirdweb";
import { resolveAddress } from "thirdweb/extensions/ens";
import { PublishedActions } from "../../../components/contract-actions-published.client";
Expand Down Expand Up @@ -46,6 +47,10 @@ export default async function PublishedContractPage(
publishedContractVersions.find((v) => v.version === props.params.version) ||
publishedContractVersions[0];

if (!publishedContract) {
return notFound();
}

return (
<>
<DeployContractHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export default async function Image(props: {

const publishedContract = publishedContracts[0];

if (!publishedContract) {
return null;
}

const publishedContractName =
publishedContract?.displayName || publishedContract?.name;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
import { Separator } from "@/components/ui/separator";
import { notFound } from "next/navigation";
import { PublishedContract } from "../../../../../components/contract-components/published-contract";
import { PublishedActions } from "../../components/contract-actions-published.client";
import { DeployContractHeader } from "../../components/contract-header";
Expand All @@ -23,6 +24,10 @@ export default async function PublishedContractPage(

const publishedContract = publishedContractVersions[0];

if (!publishedContract) {
notFound();
}

return (
<>
<DeployContractHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ function descriptionShortener(description: string) {
words.push(word);
currentLength += word.length + 1;
}
if (words[words.length - 1].length < 4) {
const lastWord = words[words.length - 1];
if (lastWord && lastWord.length < 4) {
words = words.slice(0, -1);
}
if (words[words.length - 1].endsWith(".")) {
if (words[words.length - 1]?.endsWith(".")) {
return words.join(" ");
}
if (!shortened) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ export async function DeployFormForPublishInfo(props: PublishBasedDeployProps) {
publishedContractVersions.find((v) => v.version === props.version) ||
publishedContractVersions[0];

if (!publishedContract) {
return null;
}

const moduleUris = modules
.filter((m) => m !== null)
.filter((m) => m !== null && m !== undefined)
.map((m) => m.publishMetadataUri);
const [contractMetadata, ...fetchedModules] = await Promise.all([
fetchDeployMetadata({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export async function createTicketAction(

const markdown = prepareEmailBody({
product,
markdownInput: keyVal.markdown,
markdownInput: keyVal.markdown || "",
email: account.data.email,
name: account.data.name,
extraInfoInput: keyVal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function TeamSettingsMobileNav(props: {
return (
<div className="flex items-center gap-2 border-border border-b px-4 py-4 text-muted-foreground">
<Link
href={teamLinks[0].href}
href={teamLinks[0]?.href || "#"}
className="inline-flex items-center gap-1"
onClick={() => {
setShowFull(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export function WalletConnectorsChartCard(props: {
<Bar
key={walletType}
dataKey={walletType}
fill={chartConfig[walletType].color}
fill={chartConfig[walletType]?.color}
radius={4}
stackId="a"
strokeWidth={1.5}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function WalletDistributionChartCard(props: {
return {
walletType,
value: data,
fill: _chartConfig[walletType].color || "transparent",
fill: _chartConfig[walletType]?.color || "transparent",
};
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ const walletsToPickFrom: WalletId[] = [
];

const pickRandomWallet = () => {
return walletsToPickFrom[
Math.floor(Math.random() * walletsToPickFrom.length)
];
return (
walletsToPickFrom[Math.floor(Math.random() * walletsToPickFrom.length)] ||
"io.metamask"
);
};

export function createWalletStatsStub(days: number): WalletStats[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ type ContentItem = {
onClick?: () => void;
};

type TabId = "explore" | "import" | "build" | "deploy";

const DeployOptions = () => {
const [showImportModal, setShowImportModal] = useState(false);
const router = useDashboardRouter();
const trackEvent = useTrack();

const content: Record<string, ContentItem> = useMemo(
const content: Record<TabId, ContentItem> = useMemo(
() => ({
explore: {
title: "Ready-to-deploy",
Expand Down Expand Up @@ -72,8 +74,7 @@ const DeployOptions = () => {
[],
);

const contentKeys = Object.keys(content);
const [activeTab, setActiveTab] = useState(contentKeys[0]);
const [activeTab, setActiveTab] = useState<TabId>("explore");
const activeTabContent = content[activeTab];

return (
Expand All @@ -91,7 +92,7 @@ const DeployOptions = () => {
name: value.title,
isActive: activeTab === key,
isEnabled: true,
onClick: () => setActiveTab(key),
onClick: () => setActiveTab(key as TabId),
}))}
tabClassName="font-medium !text-sm"
/>
Expand Down
Loading
Loading