Skip to content

Commit 7967d7f

Browse files
Dedicated Relayer (#8479)
Co-authored-by: Manan Tank <[email protected]>
1 parent 1487de6 commit 7967d7f

File tree

24 files changed

+1600
-9
lines changed

24 files changed

+1600
-9
lines changed

.changeset/some-mice-own.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/service-utils": patch
3+
---
4+
5+
add dedicated relayer to service utils
36.9 KB
Loading
21.1 KB
Loading
15.5 KB
Loading
15.1 KB
Loading
24.4 KB
Loading
25.4 KB
Loading

apps/dashboard/src/@/types/billing.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,16 @@ export type ProductSKU =
1313
| "usage:in_app_wallet"
1414
| "usage:aa_sponsorship"
1515
| "usage:aa_sponsorship_op_grant"
16+
// dedicated relayer SKUs
17+
| DedicatedRelayerSKU
1618
| null;
1719

1820
export type ChainInfraSKU =
1921
| "chain:infra:rpc"
2022
| "chain:infra:insight"
2123
| "chain:infra:account_abstraction";
24+
25+
export type DedicatedRelayerSKU =
26+
| "product:dedicated_relayer_standard"
27+
| "product:dedicated_relayer_premium"
28+
| "product:dedicated_relayer_enterprise";

apps/dashboard/src/app/(app)/(stripe)/checkout/[team_slug]/[sku]/page.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ export default async function CheckoutPage(props: {
1717
searchParams: Promise<{
1818
amount?: string;
1919
invoice_id?: string;
20+
project_id?: string;
21+
chain_id?: string | string[];
2022
}>;
2123
}) {
22-
const params = await props.params;
24+
const [params, searchParams] = await Promise.all([
25+
props.params,
26+
props.searchParams,
27+
]);
28+
29+
console.log("params", params);
30+
console.log("searchParams", searchParams);
2331

2432
switch (params.sku) {
2533
case "topup": {
26-
const amountUSD = Number.parseInt(
27-
(await props.searchParams).amount || "10",
28-
);
34+
const amountUSD = Number.parseInt(searchParams.amount || "10");
2935
if (Number.isNaN(amountUSD)) {
3036
return <StripeRedirectErrorPage errorMessage="Invalid amount" />;
3137
}
@@ -43,7 +49,7 @@ export default async function CheckoutPage(props: {
4349
break;
4450
}
4551
case "invoice": {
46-
const invoiceId = (await props.searchParams).invoice_id;
52+
const invoiceId = searchParams.invoice_id;
4753
if (!invoiceId) {
4854
return <StripeRedirectErrorPage errorMessage="Invalid invoice ID" />;
4955
}
@@ -59,10 +65,12 @@ export default async function CheckoutPage(props: {
5965
redirect(invoice);
6066
break;
6167
}
68+
6269
default: {
6370
const response = await getBillingCheckoutUrl({
6471
sku: decodeURIComponent(params.sku) as Exclude<ProductSKU, null>,
6572
teamSlug: params.team_slug,
73+
params: searchParams,
6674
});
6775

6876
if (response.status === "error") {

apps/dashboard/src/app/(app)/(stripe)/utils/billing.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { getAbsoluteUrl } from "@/utils/vercel";
77
export async function getBillingCheckoutUrl(options: {
88
teamSlug: string;
99
sku: Exclude<ProductSKU, null>;
10+
params: {
11+
project_id?: string;
12+
chain_id?: string | string[];
13+
};
1014
}) {
1115
const token = await getAuthToken();
1216

@@ -17,13 +21,26 @@ export async function getBillingCheckoutUrl(options: {
1721
} as const;
1822
}
1923

24+
const chainIds = options.params.chain_id
25+
? (Array.isArray(options.params.chain_id)
26+
? options.params.chain_id
27+
: [options.params.chain_id]
28+
)
29+
.map((value) => Number(value))
30+
.filter((value) => Number.isFinite(value))
31+
: undefined;
32+
33+
const body = {
34+
redirectTo: getAbsoluteStripeRedirectUrl(),
35+
sku: options.sku,
36+
projectId: options.params.project_id,
37+
chainIds: chainIds,
38+
};
39+
2040
const res = await fetch(
2141
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${options.teamSlug}/checkout/create-link`,
2242
{
23-
body: JSON.stringify({
24-
redirectTo: getAbsoluteStripeRedirectUrl(),
25-
sku: options.sku,
26-
}),
43+
body: JSON.stringify(body),
2744
headers: {
2845
Authorization: `Bearer ${token}`,
2946
"Content-Type": "application/json",

0 commit comments

Comments
 (0)