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
12 changes: 7 additions & 5 deletions apps/playground-web/src/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { convertToModelMessages, streamText, type UIMessage } from "ai";
// Allow streaming responses up to 5 minutes
export const maxDuration = 300;

const thirdwebAI = createThirdwebAI({
baseURL: `https://${process.env.NEXT_PUBLIC_API_URL}`,
secretKey: process.env.THIRDWEB_SECRET_KEY,
});

export async function POST(req: Request) {
const SECRET_KEY = process.env.THIRDWEB_SECRET_KEY as string;

const thirdwebAI = createThirdwebAI({
baseURL: `https://${process.env.NEXT_PUBLIC_API_URL}`,
secretKey: SECRET_KEY,
});

const body = await req.json();
const { messages, id }: { messages: UIMessage[]; id: string } = body;

Expand Down
34 changes: 18 additions & 16 deletions apps/playground-web/src/app/api/paywall/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@ import { token } from "../../payments/x402/components/constants";
// Allow streaming responses up to 5 minutes
export const maxDuration = 300;

const client = createThirdwebClient({
secretKey: process.env.THIRDWEB_SECRET_KEY as string,
});
export async function GET(request: NextRequest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add explicit return type to GET function.

Per coding guidelines, TypeScript functions should have explicit return types for clarity and type safety.

Apply this diff:

-export async function GET(request: NextRequest) {
+export async function GET(request: NextRequest): Promise<NextResponse> {

As per coding guidelines

🤖 Prompt for AI Agents
In apps/playground-web/src/app/api/paywall/route.ts around line 10, the exported
async GET function lacks an explicit return type; update its signature to
include a clear TypeScript return type (for example: export async function
GET(request: NextRequest): Promise<Response> { ... } or use
Promise<NextResponse> if you return NextResponse) and ensure the function body
returns a value matching that type.

const SECRET_KEY = process.env.THIRDWEB_SECRET_KEY as string;

const BACKEND_WALLET_ADDRESS = process.env.ENGINE_BACKEND_WALLET as string;
// const BACKEND_WALLET_ADDRESS = process.env.ENGINE_BACKEND_SMART_WALLET as string;
const ENGINE_VAULT_ACCESS_TOKEN = process.env
.ENGINE_VAULT_ACCESS_TOKEN as string;
// const API_URL = `https://${process.env.NEXT_PUBLIC_API_URL || "api.thirdweb.com"}`;
const API_URL = "http://localhost:3030";
const client = createThirdwebClient({
secretKey: SECRET_KEY,
});

const twFacilitator = facilitator({
baseUrl: `${API_URL}/v1/payments/x402`,
client,
serverWalletAddress: BACKEND_WALLET_ADDRESS,
vaultAccessToken: ENGINE_VAULT_ACCESS_TOKEN,
});
const BACKEND_WALLET_ADDRESS = process.env.ENGINE_BACKEND_WALLET as string;
// const BACKEND_WALLET_ADDRESS = process.env.ENGINE_BACKEND_SMART_WALLET as string;
const ENGINE_VAULT_ACCESS_TOKEN = process.env
.ENGINE_VAULT_ACCESS_TOKEN as string;
// const API_URL = `https://${process.env.NEXT_PUBLIC_API_URL || "api.thirdweb.com"}`;
const API_URL = "http://localhost:3030";

const twFacilitator = facilitator({
baseUrl: `${API_URL}/v1/payments/x402`,
client,
serverWalletAddress: BACKEND_WALLET_ADDRESS,
vaultAccessToken: ENGINE_VAULT_ACCESS_TOKEN,
});

export async function GET(request: NextRequest) {
const paymentData = request.headers.get("X-PAYMENT");
const queryParams = request.nextUrl.searchParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFT", () => {
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
},
"owner": null,
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
"tokenAddress": "0x8a90CAb2b38dba80c64b7734e58Ee1dB38B8992e",
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
"type": "ERC721",
}
Expand Down
11 changes: 5 additions & 6 deletions packages/thirdweb/src/extensions/erc721/read/getNFTs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
});

expect(nfts.length).toBe(5);
// TODO (insight): re-enable once insight fixes the client id caching issue
expect(nfts).toMatchInlineSnapshot(`
[
{
Expand Down Expand Up @@ -49,7 +48,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/0",
},
"owner": null,
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
"tokenAddress": "0x8a90CAb2b38dba80c64b7734e58Ee1dB38B8992e",
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/0",
"type": "ERC721",
},
Expand Down Expand Up @@ -86,7 +85,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
},
"owner": null,
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
"tokenAddress": "0x8a90CAb2b38dba80c64b7734e58Ee1dB38B8992e",
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
"type": "ERC721",
},
Expand Down Expand Up @@ -123,7 +122,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/2",
},
"owner": null,
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
"tokenAddress": "0x8a90CAb2b38dba80c64b7734e58Ee1dB38B8992e",
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/2",
"type": "ERC721",
},
Expand Down Expand Up @@ -160,7 +159,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/3",
},
"owner": null,
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
"tokenAddress": "0x8a90CAb2b38dba80c64b7734e58Ee1dB38B8992e",
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/3",
"type": "ERC721",
},
Expand Down Expand Up @@ -197,7 +196,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/4",
},
"owner": null,
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
"tokenAddress": "0x8a90CAb2b38dba80c64b7734e58Ee1dB38B8992e",
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/4",
"type": "ERC721",
},
Expand Down
Loading