Skip to content

Commit 943f864

Browse files
committed
[Experiment] Remove clientId from serverThirdwebClient
1 parent be60100 commit 943f864

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

apps/dashboard/src/@/constants/thirdweb-client.client.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { NEXT_PUBLIC_DASHBOARD_CLIENT_ID } from "./public-envs";
12
import { getConfiguredThirdwebClient } from "./thirdweb.server";
23

34
export function getClientThirdwebClient(params?: {
@@ -7,5 +8,7 @@ export function getClientThirdwebClient(params?: {
78
return getConfiguredThirdwebClient({
89
secretKey: params?.jwt ?? undefined,
910
teamId: params?.teamId ?? undefined,
11+
type: "client",
12+
clientId: NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
1013
});
1114
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import "server-only";
22

3+
import { NEXT_PUBLIC_DASHBOARD_CLIENT_ID } from "./public-envs";
34
import { DASHBOARD_THIRDWEB_SECRET_KEY } from "./server-envs";
45
import { getConfiguredThirdwebClient } from "./thirdweb.server";
56

67
export const serverThirdwebClient = getConfiguredThirdwebClient({
78
teamId: undefined,
89
secretKey: DASHBOARD_THIRDWEB_SECRET_KEY,
10+
clientId: NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
11+
type: "server",
912
});

apps/dashboard/src/@/constants/thirdweb.server.ts

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
3-
NEXT_PUBLIC_IPFS_GATEWAY_URL,
4-
} from "@/constants/public-envs";
1+
import { NEXT_PUBLIC_IPFS_GATEWAY_URL } from "@/constants/public-envs";
52
import {
63
THIRDWEB_BRIDGE_URL,
74
THIRDWEB_BUNDLER_DOMAIN,
@@ -22,10 +19,21 @@ import {
2219
import { getZkPaymasterData } from "thirdweb/wallets/smart";
2320
import { getVercelEnv } from "../../lib/vercel-utils";
2421

25-
export function getConfiguredThirdwebClient(options: {
26-
secretKey: string | undefined;
27-
teamId: string | undefined;
28-
}): ThirdwebClient {
22+
export function getConfiguredThirdwebClient(
23+
options:
24+
| {
25+
type: "server";
26+
secretKey: string;
27+
clientId: string | undefined;
28+
teamId: string | undefined;
29+
}
30+
| {
31+
type: "client";
32+
clientId: string;
33+
secretKey: string | undefined;
34+
teamId: string | undefined;
35+
},
36+
): ThirdwebClient {
2937
if (getVercelEnv() !== "production") {
3038
// if not on production: run this when creating a client to set the domains
3139
setThirdwebDomains({
@@ -73,16 +81,30 @@ export function getConfiguredThirdwebClient(options: {
7381
});
7482
}
7583

76-
return createThirdwebClient({
77-
teamId: options.teamId,
78-
secretKey: options.secretKey,
79-
clientId: NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
80-
config: {
81-
storage: {
82-
gatewayUrl: NEXT_PUBLIC_IPFS_GATEWAY_URL,
83-
},
84-
},
85-
});
84+
return createThirdwebClient(
85+
// this ternary is purely for making typescript happy - both are same object
86+
options.type === "server"
87+
? {
88+
teamId: options.teamId,
89+
secretKey: options.secretKey,
90+
clientId: options.clientId,
91+
config: {
92+
storage: {
93+
gatewayUrl: NEXT_PUBLIC_IPFS_GATEWAY_URL,
94+
},
95+
},
96+
}
97+
: {
98+
teamId: options.teamId,
99+
secretKey: options.secretKey,
100+
clientId: options.clientId,
101+
config: {
102+
storage: {
103+
gatewayUrl: NEXT_PUBLIC_IPFS_GATEWAY_URL,
104+
},
105+
},
106+
},
107+
);
86108
}
87109

88110
/**

0 commit comments

Comments
 (0)