Skip to content

Dashboard: Fix contract deploy page missing last used teamId in client object #7285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
import { Separator } from "@/components/ui/separator";
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
import { serverThirdwebClient } from "@/constants/thirdweb-client.server";
import { SimpleGrid } from "@chakra-ui/react";
import { fetchPublishedContractVersions } from "components/contract-components/fetch-contracts-with-versions";
Expand All @@ -9,7 +8,7 @@ import { notFound } from "next/navigation";
import { isAddress } from "thirdweb";
import { resolveAddress } from "thirdweb/extensions/ens";
import { getRawAccount } from "../../../../../account/settings/getAccount";
import { getAuthToken } from "../../../../../api/lib/getAuthToken";
import { getUserThirdwebClient } from "../../../../../api/lib/getAuthToken";
import { PublishedActions } from "../../../components/contract-actions-published.client";
import { DeployContractHeader } from "../../../components/contract-header";

Expand Down Expand Up @@ -68,9 +67,11 @@ export default async function PublishedContractPage(
return notFound();
}

const [authToken, account] = await Promise.all([
getAuthToken(),
const [account, client] = await Promise.all([
getRawAccount(),
getUserThirdwebClient({
teamId: undefined,
}),
]);

return (
Expand All @@ -92,10 +93,7 @@ export default async function PublishedContractPage(
<PublishedContract
publishedContract={publishedContract}
isLoggedIn={!!account}
client={getClientThirdwebClient({
jwt: authToken,
teamId: undefined,
})}
client={client}
/>
</SimpleGrid>
</ChakraProviderSetup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { getProjects } from "@/api/projects";
import { getTeams } from "@/api/team";
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
import { CustomContractForm } from "components/contract-components/contract-deploy-form/custom-contract";
import type { FetchDeployMetadataResult } from "thirdweb/contract";
import { getAuthToken } from "../../../api/lib/getAuthToken";
import { getUserThirdwebClient } from "../../../api/lib/getAuthToken";
import { loginRedirect } from "../../../login/loginRedirect";

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

const [authToken, teams] = await Promise.all([getAuthToken(), getTeams()]);
const [teams, client] = await Promise.all([
getTeams(),
getUserThirdwebClient({
teamId: undefined,
}),
]);

if (!teams || !authToken) {
if (!teams) {
loginRedirect(pathname);
}

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

const client = getClientThirdwebClient({
jwt: authToken,
teamId: undefined,
});

// TODO: remove the `ChakraProviderSetup` wrapper once the form is updated to no longer use chakra
return (
<ChakraProviderSetup>
<CustomContractForm
metadata={contractMetadata}
metadataNoFee={contractMetadataNoFee}
modules={modules?.filter((m) => m !== null)}
isLoggedIn={!!authToken}
isLoggedIn={true}
teamsAndProjects={teamsAndProjects}
client={client}
/>
Expand Down
Loading