Skip to content

Commit 931c730

Browse files
[Paywall] Support string price format when tokenAddress is not provided (#8330)
1 parent e0c8312 commit 931c730

File tree

1 file changed

+10
-8
lines changed
  • apps/playground-web/src/app/api/paywall

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function GET(request: NextRequest) {
4141

4242
const amount = queryParams.get("amount") || "0.01";
4343
const payTo = queryParams.get("payTo") ?? undefined;
44-
const tokenAddress = queryParams.get("tokenAddress") || token.address;
44+
const tokenAddress = queryParams.get("tokenAddress");
4545
const decimals = queryParams.get("decimals") || token.decimals.toString();
4646
const waitUntil =
4747
(queryParams.get("waitUntil") as "simulated" | "submitted" | "confirmed") ||
@@ -53,13 +53,15 @@ export async function GET(request: NextRequest) {
5353
paymentData,
5454
network: defineChain(Number(chainId)),
5555
payTo,
56-
price: {
57-
amount: toUnits(amount, parseInt(decimals)).toString(),
58-
asset: {
59-
address: tokenAddress as `0x${string}`,
60-
decimals: decimals ? parseInt(decimals) : token.decimals,
61-
},
62-
},
56+
price: tokenAddress
57+
? {
58+
amount: toUnits(amount, parseInt(decimals)).toString(),
59+
asset: {
60+
address: tokenAddress as `0x${string}`,
61+
decimals: decimals ? parseInt(decimals) : token.decimals,
62+
},
63+
}
64+
: amount,
6365
routeConfig: {
6466
description: "Access to paid content",
6567
},

0 commit comments

Comments
 (0)