Skip to content

Commit 969de5a

Browse files
committed
[TOOL-5046] Fix Team not found error on token creation with gas sponsorship enabled
1 parent 5f74b3c commit 969de5a

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { getConfiguredThirdwebClient } from "./thirdweb.server";
33
export function getClientThirdwebClient(params?: {
44
jwt: string | undefined | null;
55
teamId: string | undefined | null;
6+
projectClientId?: string;
67
}) {
78
return getConfiguredThirdwebClient({
89
secretKey: params?.jwt ?? undefined,
910
teamId: params?.teamId ?? undefined,
11+
projectClientId: params?.projectClientId,
1012
});
1113
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { getVercelEnv } from "@/utils/vercel";
2525
export function getConfiguredThirdwebClient(options: {
2626
secretKey: string | undefined;
2727
teamId: string | undefined;
28+
projectClientId: string | undefined;
2829
}): ThirdwebClient {
2930
if (getVercelEnv() !== "production") {
3031
// if not on production: run this when creating a client to set the domains
@@ -89,6 +90,7 @@ export function getConfiguredThirdwebClient(options: {
8990
},
9091
secretKey: secretKey,
9192
teamId: options.teamId,
93+
projectClientId: options.projectClientId,
9294
});
9395
}
9496

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export default async function Page(props: {
3636
const client = getClientThirdwebClient({
3737
jwt: authToken,
3838
teamId: team.id,
39-
});
39+
projectClientId: project.publishableKey,
40+
});
4041

4142
return (
4243
<div className="flex grow flex-col">

packages/thirdweb/src/client/client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ type ClientOptions = Prettify<{
5555
* @hidden
5656
*/
5757
teamId?: string;
58+
59+
/**
60+
* The project client ID for thirdweb dashboard usage.
61+
* @hidden
62+
*/
63+
projectClientId?: string;
5864
}>;
5965

6066
export type CreateThirdwebClientOptions = Prettify<

packages/thirdweb/src/utils/fetch.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,10 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
5757
: undefined;
5858
const clientId = client.clientId;
5959

60-
if (authToken && isBundlerUrl(urlString)) {
60+
if (authToken && isBundlerUrl(urlString) && client.projectClientId && client.teamId) {
6161
headers.set("authorization", `Bearer ${authToken}`);
62-
if (client.teamId) {
63-
headers.set("x-team-id", client.teamId);
64-
}
65-
66-
if (clientId) {
67-
headers.set("x-client-id", clientId);
68-
}
62+
headers.set("x-team-id", client.teamId);
63+
headers.set("x-client-id", client.projectClientId);
6964
}
7065
// if we have an auth token set, use that (thirdweb dashboard sets this for the user)
7166
// pay urls should never send the auth token, because we always want the "developer" to be the one making the request, not the "end user"

0 commit comments

Comments
 (0)