Skip to content

Commit

Permalink
fix: typecheck issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MartianGreed committed Aug 21, 2024
1 parent a491c81 commit 1b0a2e8
Show file tree
Hide file tree
Showing 38 changed files with 237 additions and 166 deletions.
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/_components/StarkName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const StarkName = ({ address }: { address?: string }) => {
}, [address]);

const { data: starkName, refetch } = useStarkName({
address: address,
address: address as `0x${string}`,
});

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const TransactionSubmittedModalButton = ({
const { type, l2hash, l1hash } = transfer;
const isTransferCompleted = l1hash && l2hash;

if (l1hash === undefined || l2hash === undefined) return null;
let explorers;

if (type === ActionType.TRANSFER_TO_L2 || isTransferCompleted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const TransactionAction = ({ tx }: { tx: CombinedTransaction }) => {
type: TransactionType.BRIDGE_REALMS_L2_TO_L1_CONFIRM,
chainId: SUPPORTED_L2_CHAIN_ID,
status: "complete",
timestamp: new Date().getTime(),
timestamp: new Date().getTime().toString(),
});
toast({
title: TransactionType.BRIDGE_REALMS_L2_TO_L1_CONFIRM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ export function TransactionStatusL2({ hash }: { hash: string }) {
? "Loading..."
: isError
? error?.message
// @ts-expect-error TODO: check types with apibara
: data?.status === "REJECTED"
// @ts-expect-error TODO: check types with apibara
? `${data.status}`
// @ts-expect-error TODO: check types with apibara
: `${data?.execution_status}`}
</Badge>
);
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/_components/wallet/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export const RenderExplorers = ({ isL1 = true }) => {
const { address } = useAccount();
const { address: l2address } = useL2Account();

const explorersL1 = [{ text: address, url: ETHERSCAN_ACCOUNT_URL(address) }];
const explorersL1 = [{ text: address, url: ETHERSCAN_ACCOUNT_URL(address as string) }];
const explorersL2 = [
{ text: l2address, url: STARKSCAN_ACCOUNT_URL(l2address) },
{ text: l2address, url: STARKSCAN_ACCOUNT_URL(l2address as string) },
];
const explorers = isL1 ? explorersL1 : explorersL2;

Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/src/app/account/assets/BridgeNftWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ import {

import AssetL1CollectionPreview from "./AssetL1CollectionPreview";
import AssetL2CollectionPreview from "./AssetL2CollectionPreview";
import { TransactionFinalityStatus } from "starknet";

export const BridgeNftWrapper = () => {
const [activeChain, setActiveChain] = useState("l1");
const { address } = useAccount();
const { data: pendingWithdrawals } = usePendingRealmsWithdrawals({
address,
status: "ACCEPTED_ON_L1",
status: TransactionFinalityStatus.ACCEPTED_ON_L1,
});
const { toggleAccount } = useUIStore((state) => state);

Expand Down
99 changes: 56 additions & 43 deletions apps/nextjs/src/app/account/delegates/DelegateCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ import {
import { SocialIcons } from "../../_components/SocialIcons";
import { DelegateActions } from "./DelegateActions";

type DelegateCardProps = {
delegate: RouterOutputs["delegates"]["all"]["items"][0] & {
delegateProfile?: NonNullable<{
interests: string[];
statement: string;
github: string;
twitter: string;
}>;
}
}
export function DelegateCard({
delegate,
}: {
delegate: RouterOutputs["delegates"]["all"]["items"][0];
}) {
}: DelegateCardProps) {
//const { data, isLoading, isError } = useStarkProfile({ address: delegate.id });

//const starkName = useStarkDisplayName(delegate.id);
Expand All @@ -51,51 +59,56 @@ export function DelegateCard({
</div>
</div>

{delegate.delegateProfile && (
<div className="mb-2 flex gap-1">
{ }
{delegate.delegateProfile.interests
?.slice(0, 3)
{
delegate.delegateProfile && (
<div className="mb-2 flex gap-1">
{
delegate.delegateProfile.interests
?.slice(0, 3)

.map((interest, index: number) => (
<Badge
key={index}
variant={"outline"}
className="px-1 py-0.5 text-xs"
>
{interest}
</Badge>
))}
{delegate.delegateProfile.interests &&
delegate.delegateProfile.interests.length > 3 && (
<Popover>
<PopoverTrigger asChild>
.map((interest: string, index: number) => (
<Badge
key={index}
variant={"outline"}
className="cursor-pointer px-1 py-0.5 text-xs"
className="px-1 py-0.5 text-xs"
>
+{delegate.delegateProfile.interests.length - 3}
{interest}
</Badge>
</PopoverTrigger>
<PopoverContent className="w-96">
<div className="flex flex-wrap gap-1">
{delegate.delegateProfile.interests
.slice(3)
.map((interest, index) => (
<Badge
key={index}
variant={"outline"}
className="px-1 py-0.5 text-xs"
>
{interest}
</Badge>
))}
</div>
</PopoverContent>
</Popover>
)}
</div>
)}
))}
{
delegate.delegateProfile.interests &&
delegate.delegateProfile.interests.length > 3 && (
<Popover>
<PopoverTrigger asChild>
<Badge
variant={"outline"}
className="cursor-pointer px-1 py-0.5 text-xs"
>
+{
delegate.delegateProfile.interests.length - 3}
</Badge>
</PopoverTrigger>
<PopoverContent className="w-96">
<div className="flex flex-wrap gap-1">
{
delegate.delegateProfile.interests
.slice(3)
.map((interest: string, index: number) => (
<Badge
key={index}
variant={"outline"}
className="px-1 py-0.5 text-xs"
>
{interest}
</Badge>
))}
</div>
</PopoverContent>
</Popover>
)}
</div>
)
}
</CardTitle>
</CardHeader>
{delegate.delegateProfile && (
Expand Down
5 changes: 3 additions & 2 deletions apps/nextjs/src/app/account/lords/Migration.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { UsersRealmsQuery } from "@/types/subgraph";
import type { Realm, UsersRealmsQuery } from "@/types/subgraph";
import type { ColumnDef } from "@tanstack/react-table";
import { useState } from "react";
import Link from "next/link";
import { GalleonStaking } from "@/abi/L1/v1GalleonStaking";
Expand Down Expand Up @@ -47,7 +48,7 @@ function UnstakeStep({
? realmsData.bridgedRealms
: realmsData.bridgedV2Realms
}
columns={columns}
columns={columns as ColumnDef<Pick<Realm, "id" | "name">>[]}
onRowSelectionChange={setSelectedRows}
rowSelection={selectedRows}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/account/lords/VeLords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const VeLords = () => {
const { address } = useAccount();
const { isLoading, data } = useBalance({
address,
token: LORDS[SUPPORTED_L2_CHAIN_ID]?.address,
token: LORDS[SUPPORTED_L2_CHAIN_ID]?.address as `0x${string}`,
watch: true,
});
const [amount, setAmount] = useState<string>();
Expand Down
17 changes: 15 additions & 2 deletions apps/nextjs/src/app/account/profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ import {
import { ProfileForm } from "./ProfileForm";
import { SignInSIWS } from "./SignInSIWS";

export interface DelegateProfile {
statement: string,
interests: string[],
twitter: string,
telegram: string,
discord: string,
github: string,
}
interface DelegatesById {
data: RouterOutputs["delegates"]["byId"] & {
delegateProfile: DelegateProfile,
}
}
export const Profile = ({
initialDelegate,
}: {
Expand All @@ -38,7 +51,7 @@ export const Profile = ({
SUPPORTED_L2_CHAIN_ID
] as `0x${string}`;
const { address } = useAccount();
const { data: delegate } = api.delegates.byId.useQuery(
const { data: delegate }: DelegatesById = api.delegates.byId.useQuery(
{
user: address ?? "0x",
},
Expand Down Expand Up @@ -129,7 +142,7 @@ export const Profile = ({
</CardHeader>
<CardContent className="flex max-w-full flex-col gap-4">
<ProfileForm
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment

delegateProfile={delegate.delegateProfile}
delegateId={delegate.user}
/>
Expand Down
7 changes: 3 additions & 4 deletions apps/nextjs/src/app/account/profile/ProfileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { Github, Loader } from "lucide-react";
import { useSession } from "next-auth/react";
import { useForm } from "react-hook-form";

import type { RouterOutputs } from "@realms-world/api";
import type { DelegateProfile } from "@/app/account/profile/Profile";

import { CreateDelegateProfileSchema } from "@realms-world/db/schema";
import {
Button,
Expand All @@ -33,9 +34,7 @@ export const ProfileForm = ({
delegateProfile,
}: {
delegateId: string;
delegateProfile?: NonNullable<
RouterOutputs["delegates"]["byId"]
>["delegateProfile"];
delegateProfile?: NonNullable<DelegateProfile>;
}) => {
const formRef = useRef<HTMLFormElement>(null);
const form = useForm({
Expand Down
1 change: 1 addition & 0 deletions apps/nextjs/src/app/account/profile/SignInSIWS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const SignInSIWS = () => {
const { address } = useAccount();
const { data: delegate } = api.delegates.byId.useQuery(
{
// @ts-expect-error this is ok
user: address,
},
{
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/bridge/Transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Transfer = ({ action }: { action: string }) => {
const { address: l2Address } = useAccount();
// const [toastOpen, setToastOpen] = useState(false);
const [amount, setAmount] = useState<string>("0");
const { balances, l2loading } = useWalletsProviderContext();
const { balances } = useWalletsProviderContext();
const { sendAsync: iniateWithdrawal } = useWriteInitiateWithdrawLords({
amount,
});
Expand Down Expand Up @@ -91,7 +91,7 @@ export const Transfer = ({ action }: { action: string }) => {
: (balances.l1.lords ?? BigInt(0))
}
symbol="Lords"
isLoading={isL2 ? l2loading && !balances.l2.lords : false}
isLoading={isL2 ? !balances.l2.lords : false}
/>
</div>
</>
Expand Down
1 change: 1 addition & 0 deletions apps/nextjs/src/app/bridge/TransferLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const TransferLog = ({
disabled={!l1hash}
asChild
>
{/* @ts-expect-error button is disabled if l1hash is not defined */}
<Link href={STARKSCAN_ETH_TX_URL(l1hash)} target="_blank">
<span>{`${NetworkType.L1} Tx`}</span>
<ExternalLinkIcon className="ml-2 h-3 w-3" />
Expand Down
3 changes: 3 additions & 0 deletions apps/nextjs/src/app/collection/[id]/(list)/L2ERC721Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ const Price = ({
const { lordsPrice } = useLordsPrice();
const listing = findLowestPriceActiveListing(token.listings, token.owner);

if (!listing) return null;
if (!listing.price) return null;

return (
<div className="flex justify-between">
{token.price && (
Expand Down
35 changes: 19 additions & 16 deletions apps/nextjs/src/app/collection/[id]/(list)/mint/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export default function Mint() {

const {
data: mintData,
write,
// FIX: this may wont work
send: write,
isPending: isTxSubmitting,
} = useSendTransaction({
calls: [
Expand Down Expand Up @@ -99,7 +100,7 @@ export default function Mint() {
className="mr-4"
disabled={isLoading}
size={"lg"}
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return

onClick={() => write()}
>
{isLoading && <Loader2 className="mr-2 h-5 w-5 animate-spin" />}
Expand All @@ -125,21 +126,23 @@ export default function Mint() {
high: (submittedData as any)?.events[1]?.data[3],
})
.toString()}
<Button
className="justify-between normal-case"
size={"xs"}
variant={"outline"}
rel="noopener noreferrer"
asChild
>
<Link
target="_blank"
href={STARKSCAN_TX_URL(mintData?.transaction_hash)}
{mintData?.transaction_hash &&
<Button
className="justify-between normal-case"
size={"xs"}
variant={"outline"}
rel="noopener noreferrer"
asChild
>
<span>View Tx Explorer</span>
<ExternalLinkIcon className="ml-2 h-3 w-3" />
</Link>
</Button>
<Link
target="_blank"
href={STARKSCAN_TX_URL(mintData.transaction_hash)}
>
<span>View Tx Explorer</span>
<ExternalLinkIcon className="ml-2 h-3 w-3" />
</Link>
</Button>
}
</>
) : (
<Loader2 className="ml-2 h-8 w-8 animate-spin" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ export const ContractImage = ({
functionName: "token_uri",
args: [tokenId],
abi: L2_C1ERC20,
address: tokenAddress,
address: tokenAddress as `0x${string}`,
watch: true,
});
const tokenUriData = useMemo(() => {
//@ts-expect-error data does have length
if (data?.length) {
const value = [];
//@ts-expect-error data does have length
for (let i = 1; i < data.length; i++) {
//@ts-expect-error data does have length
const result = shortString.decodeShortString(data[i]);
value.push(result);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/games/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default async function Page({ params }: { params: { id: string } }) {
</div>

<div className="flex-col space-y-2">
{game.playable && (
{game.playable && game.links.homepage && (
<Button
size={"lg"}
variant={"default"}
Expand Down
Loading

0 comments on commit 1b0a2e8

Please sign in to comment.