Skip to content

Commit 7ab79dc

Browse files
committed
Dashboard: Fix contract deploy page missing last used teamId in client object (#7285)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on updating the authentication mechanism by replacing the usage of `getAuthToken` with `getUserThirdwebClient` in the `page.tsx` and `uri-based-deploy.tsx` files, enhancing the handling of third-party client connections. ### Detailed summary - Removed `getAuthToken` and its associated logic in `page.tsx`. - Introduced `getUserThirdwebClient` to fetch the client in `page.tsx`. - Updated the `isLoggedIn` prop in `PublishedContract` to use `!!account`. - Adjusted the logic in `uri-based-deploy.tsx` to fetch client and teams without `authToken`. - Changed the `isLoggedIn` prop to always be `true` in `uri-based-deploy.tsx`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Streamlined the process for obtaining the user client, simplifying authentication and client initialization for published contract and deploy flows. - Improved logic for login checks and client handling, reducing redundant token fetching and making the login state determination more straightforward. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 2b39669 commit 7ab79dc

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

apps/dashboard/src/app/(app)/(dashboard)/published-contract/[publisher]/[contract_id]/[version]/page.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
22
import { Separator } from "@/components/ui/separator";
3-
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
43
import { serverThirdwebClient } from "@/constants/thirdweb-client.server";
54
import { SimpleGrid } from "@chakra-ui/react";
65
import { fetchPublishedContractVersions } from "components/contract-components/fetch-contracts-with-versions";
@@ -9,7 +8,7 @@ import { notFound } from "next/navigation";
98
import { isAddress } from "thirdweb";
109
import { resolveAddress } from "thirdweb/extensions/ens";
1110
import { getRawAccount } from "../../../../../account/settings/getAccount";
12-
import { getAuthToken } from "../../../../../api/lib/getAuthToken";
11+
import { getUserThirdwebClient } from "../../../../../api/lib/getAuthToken";
1312
import { PublishedActions } from "../../../components/contract-actions-published.client";
1413
import { DeployContractHeader } from "../../../components/contract-header";
1514

@@ -68,9 +67,11 @@ export default async function PublishedContractPage(
6867
return notFound();
6968
}
7069

71-
const [authToken, account] = await Promise.all([
72-
getAuthToken(),
70+
const [account, client] = await Promise.all([
7371
getRawAccount(),
72+
getUserThirdwebClient({
73+
teamId: undefined,
74+
}),
7475
]);
7576

7677
return (
@@ -92,10 +93,7 @@ export default async function PublishedContractPage(
9293
<PublishedContract
9394
publishedContract={publishedContract}
9495
isLoggedIn={!!account}
95-
client={getClientThirdwebClient({
96-
jwt: authToken,
97-
teamId: undefined,
98-
})}
96+
client={client}
9997
/>
10098
</SimpleGrid>
10199
</ChakraProviderSetup>

apps/dashboard/src/app/(app)/(dashboard)/published-contract/components/uri-based-deploy.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { getProjects } from "@/api/projects";
22
import { getTeams } from "@/api/team";
33
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
4-
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
54
import { CustomContractForm } from "components/contract-components/contract-deploy-form/custom-contract";
65
import type { FetchDeployMetadataResult } from "thirdweb/contract";
7-
import { getAuthToken } from "../../../api/lib/getAuthToken";
6+
import { getUserThirdwebClient } from "../../../api/lib/getAuthToken";
87
import { loginRedirect } from "../../../login/loginRedirect";
98

109
type DeployFormForUriProps = {
@@ -21,9 +20,14 @@ export async function DeployFormForUri(props: DeployFormForUriProps) {
2120
return <div>Could not fetch metadata</div>;
2221
}
2322

24-
const [authToken, teams] = await Promise.all([getAuthToken(), getTeams()]);
23+
const [teams, client] = await Promise.all([
24+
getTeams(),
25+
getUserThirdwebClient({
26+
teamId: undefined,
27+
}),
28+
]);
2529

26-
if (!teams || !authToken) {
30+
if (!teams) {
2731
loginRedirect(pathname);
2832
}
2933

@@ -43,19 +47,14 @@ export async function DeployFormForUri(props: DeployFormForUriProps) {
4347
})),
4448
);
4549

46-
const client = getClientThirdwebClient({
47-
jwt: authToken,
48-
teamId: undefined,
49-
});
50-
5150
// TODO: remove the `ChakraProviderSetup` wrapper once the form is updated to no longer use chakra
5251
return (
5352
<ChakraProviderSetup>
5453
<CustomContractForm
5554
metadata={contractMetadata}
5655
metadataNoFee={contractMetadataNoFee}
5756
modules={modules?.filter((m) => m !== null)}
58-
isLoggedIn={!!authToken}
57+
isLoggedIn={true}
5958
teamsAndProjects={teamsAndProjects}
6059
client={client}
6160
/>

0 commit comments

Comments
 (0)