Skip to content

Commit 0756804

Browse files
committed
clean up
1 parent 4a65b81 commit 0756804

File tree

14 files changed

+412
-357
lines changed

14 files changed

+412
-357
lines changed

apps/playground-web/src/app/api/erc20BatchMintTo/route.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,18 @@ const engine = new Engine({
2323
accessToken: process.env.ENGINE_ACCESS_TOKEN as string,
2424
});
2525

26-
type TransactionStatus = "Queued" | "Sent" | "Mined" | "error";
27-
28-
interface ClaimResult {
29-
queueId: string;
30-
status: TransactionStatus;
31-
transactionHash?: string | undefined | null;
32-
blockExplorerUrl?: string | undefined | null;
33-
errorMessage?: string;
34-
toAddress?: string;
35-
amount?: string;
36-
chainId?: string;
37-
timestamp?: number;
38-
}
39-
4026
const chain = "84532";
4127

4228
type Receiver = {
4329
toAddress: Address;
4430
amount: string;
4531
};
4632

33+
type DataEntry = {
34+
toAddress: string;
35+
amount: string;
36+
};
37+
4738
export async function POST(req: NextRequest) {
4839
try {
4940
const { data, contractAddress } = await req.json();
@@ -54,7 +45,7 @@ export async function POST(req: NextRequest) {
5445
sampleData: data[0],
5546
});
5647

57-
const receivers: Receiver[] = data.map((entry: any) => ({
48+
const receivers: Receiver[] = data.map((entry: DataEntry) => ({
5849
toAddress: entry.toAddress as Address,
5950
amount: entry.amount,
6051
}));
@@ -79,7 +70,7 @@ export async function POST(req: NextRequest) {
7970
// Return initial queued status
8071
const initialResult = {
8172
queueId: res.result.queueId,
82-
status: "Queued" as const,
73+
status: "queued" as const,
8374
addresses: firstChunk.map((r) => r.toAddress),
8475
amounts: firstChunk.map((r) => r.amount),
8576
timestamp: Date.now(),
@@ -93,12 +84,14 @@ export async function POST(req: NextRequest) {
9384
});
9485

9586
return NextResponse.json([initialResult]);
96-
} catch (error: any) {
87+
} catch (error: unknown) {
9788
console.error("Detailed error:", error);
89+
const errorMessage =
90+
error instanceof Error ? error.message : "Unknown error occurred";
9891
return NextResponse.json(
9992
{
10093
error: "Transfer failed",
101-
details: error.message,
94+
details: errorMessage,
10295
},
10396
{ status: 500 },
10497
);
@@ -112,16 +105,20 @@ async function pollToMine(queueId: string) {
112105
if (status.result.status === "mined") {
113106
const transactionHash = status.result.transactionHash;
114107
const blockExplorerUrl = `https://base-sepolia.blockscout.com/tx/${transactionHash}`;
115-
return { status: "Mined", transactionHash, blockExplorerUrl };
116-
} else if (status.result.status === "errored") {
117-
return { status: "error", errorMessage: status.result.errorMessage };
108+
return { status: "Mined", queueId, transactionHash, blockExplorerUrl };
118109
}
119110

120-
return { status: status.result.status };
111+
return {
112+
status:
113+
status.result.status.charAt(0).toUpperCase() +
114+
status.result.status.slice(1),
115+
queueId,
116+
};
121117
} catch (error) {
122118
console.error("Error checking transaction status:", error);
123119
return {
124120
status: "error",
121+
queueId,
125122
errorMessage: "Failed to check transaction status",
126123
};
127124
}

apps/playground-web/src/app/api/mintTo/route.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,6 @@ const engine = new Engine({
2424
accessToken: process.env.ENGINE_ACCESS_TOKEN as string,
2525
});
2626

27-
interface ClaimResult {
28-
queueId: string;
29-
status: "Queued" | "Sent" | "Mined" | "error";
30-
transactionHash?: string | undefined | null;
31-
blockExplorerUrl?: string | undefined | null;
32-
errorMessage?: string;
33-
toAddress: string;
34-
amount: string;
35-
timestamp: number;
36-
chainId: number;
37-
network: "Base Sep" | "OP Sep" | "Ethereum";
38-
}
39-
4027
export async function POST(req: NextRequest) {
4128
try {
4229
const body = await req.json();
@@ -80,7 +67,7 @@ export async function POST(req: NextRequest) {
8067
};
8168

8269
// Start polling in the background
83-
pollToMine(res.result.queueId, receiver).then((pollResult) => {
70+
pollToMine(res.result.queueId).then((pollResult) => {
8471
// This will be handled by the frontend polling
8572
console.log("Transaction completed:", pollResult);
8673
});
@@ -93,25 +80,18 @@ export async function POST(req: NextRequest) {
9380
{ error: "Error minting ERC1155 tokens", details: error.message },
9481
{ status: 500 },
9582
);
96-
} else {
97-
return NextResponse.json(
98-
{ error: "An unknown error occurred" },
99-
{ status: 500 },
100-
);
10183
}
10284
}
10385
}
10486

105-
async function pollToMine(queueId: string, receiver: string) {
87+
async function pollToMine(queueId: string) {
10688
try {
10789
const status = await engine.transaction.status(queueId);
10890

10991
if (status.result.status === "mined") {
11092
const transactionHash = status.result.transactionHash;
11193
const blockExplorerUrl = `https://base-sepolia.blockscout.com/tx/${transactionHash}`;
11294
return { status: "Mined", transactionHash, blockExplorerUrl };
113-
} else if (status.result.status === "errored") {
114-
return { status: "error", errorMessage: status.result.errorMessage };
11595
}
11696

11797
return { status: status.result.status };

apps/playground-web/src/app/api/transaction-status/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Engine } from "@thirdweb-dev/engine";
2-
import { NextRequest, NextResponse } from "next/server";
2+
import { type NextRequest, NextResponse } from "next/server";
33

44
const engine = new Engine({
55
url: process.env.ENGINE_URL as string,
@@ -35,7 +35,7 @@ export async function GET(req: NextRequest) {
3535
console.error("Error checking transaction status:", error);
3636
return NextResponse.json(
3737
{ error: "Failed to check transaction status" },
38-
{ status: 500 }
38+
{ status: 500 },
3939
);
4040
}
41-
}
41+
}

apps/playground-web/src/app/engine/airdrop/page.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { AirdropERC20 } from "@/components/engine/airdrop/airdrop-erc20";
12
import ThirdwebProvider from "@/components/thirdweb-provider";
23
import { APIHeader } from "../../../components/blocks/APIHeader";
3-
import { AirdropERC20 } from "@/components/engine/airdrop/airdrop-erc20";
44
// TODO: Get updated banner image and description.
55
export default function Page() {
66
return (
@@ -10,14 +10,16 @@ export default function Page() {
1010
title="Airdrop"
1111
description={
1212
<>
13-
Engine makes it effortless for any developer to airdrop tokens at scale. You sponsor the gas so your users only need a wallet address!
13+
Engine makes it effortless for any developer to airdrop tokens at
14+
scale. You sponsor the gas so your users only need a wallet
15+
address!
1416
</>
1517
}
1618
docsLink="https://thirdweb-engine.apidocumentation.com/reference#tag/erc20/POST/contract/{chain}/{contractAddress}/erc20/mint-batch-to"
1719
heroLink="/engine-webhooks.webp"
1820
/>
1921

20-
<section >
22+
<section>
2123
<InGameCurrency />
2224
</section>
2325
</main>
@@ -33,7 +35,8 @@ function InGameCurrency() {
3335
Airdrop
3436
</h2>
3537
<p className="max-w-[600px]">
36-
Use Engine to Airdrop in-game currency to a list of players in one transaction.
38+
Use Engine to Airdrop in-game currency to a list of players in one
39+
transaction.
3740
</p>
3841
</div>
3942
<AirdropERC20 />

apps/playground-web/src/app/engine/minting/page.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { ERC1155MintTo } from "@/components/engine/minting/erc1155-mint-to";
12
import ThirdwebProvider from "@/components/thirdweb-provider";
23
import { APIHeader } from "../../../components/blocks/APIHeader";
3-
import { ERC1155MintTo } from "@/components/engine/minting/erc1155-mint-to";
44
// TODO: Get updated banner image and description.
55
export default function Page() {
66
return (
@@ -10,14 +10,15 @@ export default function Page() {
1010
title="Minting"
1111
description={
1212
<>
13-
Allow your users to mint new tokens into any given contract. You sponsor the gas so your users only need a wallet address!
13+
Allow your users to mint new tokens into any given contract. You
14+
sponsor the gas so your users only need a wallet address!
1415
</>
1516
}
1617
docsLink="https://thirdweb-engine.apidocumentation.com/reference#tag/erc1155/POST/contract/{chain}/{contractAddress}/erc1155/mint-to"
1718
heroLink="/engine-webhooks.webp"
1819
/>
1920

20-
<section >
21+
<section>
2122
<Minting />
2223
</section>
2324
</main>
@@ -33,7 +34,8 @@ function Minting() {
3334
Minting
3435
</h2>
3536
<p className="max-w-[600px]">
36-
Allow your users to mint new tokens into any given contract. You sponsor the gas so your users only need a wallet address!
37+
Allow your users to mint new tokens into any given contract. You
38+
sponsor the gas so your users only need a wallet address!
3739
</p>
3840
</div>
3941
<ERC1155MintTo />

apps/playground-web/src/app/engine/webhooks/page.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { Sponsorship } from "@/components/engine/gasless/Sponsorship";
12
import ThirdwebProvider from "@/components/thirdweb-provider";
23
import { APIHeader } from "../../../components/blocks/APIHeader";
3-
import { Sponsorship } from "@/components/engine/gasless/Sponsorship";
44
// TODO: Get updated banner image and description.
55
export default function Page() {
66
return (
@@ -10,14 +10,15 @@ export default function Page() {
1010
title="Webhooks"
1111
description={
1212
<>
13-
Configure webhooks in Engine to notify your backend server of transaction or backend wallet events.
13+
Configure webhooks in Engine to notify your backend server of
14+
transaction or backend wallet events.
1415
</>
1516
}
1617
docsLink="https://portal.thirdweb.com/engine/features/webhooks"
1718
heroLink="/engine-webhooks.webp"
1819
/>
1920

20-
<section >
21+
<section>
2122
<Webhooks />
2223
</section>
2324
</main>
@@ -33,7 +34,8 @@ function Webhooks() {
3334
Webhooks
3435
</h2>
3536
<p className="max-w-[600px]">
36-
Configure webhooks in Engine to notify your backend server of transaction or backend wallet events.
37+
Configure webhooks in Engine to notify your backend server of
38+
transaction or backend wallet events.
3739
</p>
3840
</div>
3941
<Sponsorship />

apps/playground-web/src/components/engine/airdrop/TransactionResults.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ export function ClaimTransactionResults({
107107
case "Queued":
108108
case "Pending":
109109
return "bg-yellow-500/20 text-yellow-400";
110+
case "Sent":
111+
return "bg-blue-500/20 text-blue-400";
110112
default:
111113
return "bg-red-500/20 text-red-400";
112114
}
@@ -123,12 +125,12 @@ export function ClaimTransactionResults({
123125
};
124126

125127
return (
126-
<Card className="w-full mt-8 bg-background">
127-
<CardHeader className="flex flex-row justify-between items-center">
128-
<h2 className="text-xl font-semibold text-foreground">
128+
<Card className="mt-8 w-full bg-background">
129+
<CardHeader className="flex flex-row items-center justify-between">
130+
<h2 className="font-semibold text-foreground text-xl">
129131
Transaction Results
130132
</h2>
131-
<span className="text-sm text-muted-foreground">
133+
<span className="text-muted-foreground text-sm">
132134
Last 24 hours • {sortedResultsWithDummy.length} transactions
133135
</span>
134136
</CardHeader>
@@ -161,21 +163,21 @@ export function ClaimTransactionResults({
161163
<img
162164
src="/BaseSep.png"
163165
alt="Base"
164-
className="w-4 h-4"
166+
className="h-4 w-4"
165167
/>
166168
)}
167169
{result.network === "OP Sep" && (
168170
<img
169171
src="/OP.png"
170172
alt="Optimism Sep"
171-
className="w-4 h-4"
173+
className="h-4 w-4"
172174
/>
173175
)}
174176
{result.network === "Ethereum" && (
175177
<img
176178
src="/Ethereum.png"
177179
alt="Ethereum"
178-
className="w-4 h-4"
180+
className="h-4 w-4"
179181
/>
180182
)}
181183
{result.network}
@@ -223,7 +225,7 @@ export function ClaimTransactionResults({
223225
</TableCell>
224226
<TableCell>
225227
<span
226-
className={`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${getStatusColor(getDisplayStatus(result))}`}
228+
className={`inline-flex rounded-full px-2 font-semibold text-xs leading-5 ${getStatusColor(getDisplayStatus(result))}`}
227229
>
228230
{getDisplayStatus(result)}
229231
</span>
@@ -254,13 +256,13 @@ export function ClaimTransactionResults({
254256
</Table>
255257
</div>
256258
{showLeftGradient && (
257-
<div className="sm:hidden absolute left-0 top-0 bottom-0 w-12 pointer-events-none bg-gradient-to-r from-background to-transparent" />
259+
<div className="pointer-events-none absolute top-0 bottom-0 left-0 w-12 bg-gradient-to-r from-background to-transparent sm:hidden" />
258260
)}
259261
{showRightGradient && (
260-
<div className="sm:hidden absolute right-0 top-0 bottom-0 w-12 pointer-events-none bg-gradient-to-l from-background to-transparent" />
262+
<div className="pointer-events-none absolute top-0 right-0 bottom-0 w-12 bg-gradient-to-l from-background to-transparent sm:hidden" />
261263
)}
262264
</CardContent>
263-
<CardFooter className="flex justify-between items-center">
265+
<CardFooter className="flex items-center justify-between">
264266
<Button onClick={handlePrevPage} disabled={currentPage === 1}>
265267
Previous
266268
</Button>

0 commit comments

Comments
 (0)