Skip to content

Commit a02853e

Browse files
committed
Dashboard: Use React taint API for envs
1 parent ccb9cd5 commit a02853e

File tree

81 files changed

+513
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+513
-388
lines changed

apps/dashboard/next.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ const baseNextConfig: NextConfig = {
123123
webpackBuildWorker: true,
124124
webpackMemoryOptimizations: true,
125125
serverSourceMaps: false,
126+
taint: true,
126127
},
127128
serverExternalPackages: ["pino-pretty"],
128129
async headers() {

apps/dashboard/src/@/actions/acceptInvite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use server";
22

33
import { getAuthToken } from "../../app/(app)/api/lib/getAuthToken";
4-
import { API_SERVER_URL } from "../constants/env";
4+
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "../constants/public-envs";
55

66
export async function acceptInvite(options: {
77
teamId: string;
@@ -17,7 +17,7 @@ export async function acceptInvite(options: {
1717
}
1818

1919
const res = await fetch(
20-
`${API_SERVER_URL}/v1/teams/${options.teamId}/invites/${options.inviteId}/accept`,
20+
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${options.teamId}/invites/${options.inviteId}/accept`,
2121
{
2222
method: "POST",
2323
headers: {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use server";
22

33
import { getAuthToken } from "../../app/(app)/api/lib/getAuthToken";
4-
import { API_SERVER_URL } from "../constants/env";
4+
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "../constants/public-envs";
55

66
export async function reSubscribePlan(options: {
77
teamId: string;
@@ -14,7 +14,7 @@ export async function reSubscribePlan(options: {
1414
}
1515

1616
const res = await fetch(
17-
`${API_SERVER_URL}/v1/teams/${options.teamId}/checkout/resubscribe-plan`,
17+
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${options.teamId}/checkout/resubscribe-plan`,
1818
{
1919
method: "PUT",
2020
headers: {

apps/dashboard/src/@/actions/confirmEmail.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use server";
22

33
import { getAuthToken } from "../../app/(app)/api/lib/getAuthToken";
4-
import { API_SERVER_URL } from "../constants/env";
4+
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "../constants/public-envs";
55

66
export async function confirmEmailWithOTP(otp: string) {
77
const token = await getAuthToken();
@@ -12,16 +12,19 @@ export async function confirmEmailWithOTP(otp: string) {
1212
};
1313
}
1414

15-
const res = await fetch(`${API_SERVER_URL}/v1/account/confirmEmail`, {
16-
method: "PUT",
17-
headers: {
18-
"Content-Type": "application/json",
19-
Authorization: `Bearer ${token}`,
15+
const res = await fetch(
16+
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/account/confirmEmail`,
17+
{
18+
method: "PUT",
19+
headers: {
20+
"Content-Type": "application/json",
21+
Authorization: `Bearer ${token}`,
22+
},
23+
body: JSON.stringify({
24+
confirmationToken: otp,
25+
}),
2026
},
21-
body: JSON.stringify({
22-
confirmationToken: otp,
23-
}),
24-
});
27+
);
2528

2629
if (!res.ok) {
2730
const json = await res.json();

apps/dashboard/src/@/actions/getWalletNFTs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { WalletNFT } from "lib/wallet/nfts/types";
1212
import { getVercelEnv } from "../../lib/vercel-utils";
1313
import { isAlchemySupported } from "../../lib/wallet/nfts/isAlchemySupported";
1414
import { isMoralisSupported } from "../../lib/wallet/nfts/isMoralisSupported";
15-
import { DASHBOARD_THIRDWEB_CLIENT_ID } from "../constants/env";
15+
import { NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID } from "../constants/public-envs";
1616

1717
type WalletNFTApiReturn =
1818
| { result: WalletNFT[]; error?: undefined }
@@ -148,7 +148,7 @@ async function getWalletNFTsFromInsight(params: {
148148

149149
const response = await fetch(url, {
150150
headers: {
151-
"x-client-id": DASHBOARD_THIRDWEB_CLIENT_ID,
151+
"x-client-id": NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
152152
},
153153
});
154154

apps/dashboard/src/@/actions/proxies.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
"use server";
22

33
import { getAuthToken } from "../../app/(app)/api/lib/getAuthToken";
4-
import { API_SERVER_URL, THIRDWEB_ENGINE_CLOUD_URL } from "../constants/env";
4+
import {
5+
NEXT_PUBLIC_ENGINE_CLOUD_URL,
6+
NEXT_PUBLIC_THIRDWEB_API_HOST,
7+
} from "../constants/public-envs";
58

69
type ProxyActionParams = {
710
pathname: string;
@@ -76,11 +79,11 @@ async function proxy<T>(
7679
}
7780

7881
export async function apiServerProxy<T>(params: ProxyActionParams) {
79-
return proxy<T>(API_SERVER_URL, params);
82+
return proxy<T>(NEXT_PUBLIC_THIRDWEB_API_HOST, params);
8083
}
8184

8285
export async function engineCloudProxy<T>(params: ProxyActionParams) {
83-
return proxy<T>(THIRDWEB_ENGINE_CLOUD_URL, params);
86+
return proxy<T>(NEXT_PUBLIC_ENGINE_CLOUD_URL, params);
8487
}
8588

8689
export async function payServerProxy<T>(params: ProxyActionParams) {

apps/dashboard/src/@/actions/sendTeamInvite.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use server";
22

33
import { getAuthToken } from "../../app/(app)/api/lib/getAuthToken";
4-
import { API_SERVER_URL } from "../constants/env";
4+
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "../constants/public-envs";
55

66
export async function sendTeamInvites(options: {
77
teamId: string;
@@ -40,17 +40,20 @@ async function sendInvite(
4040
invite: { email: string; role: "OWNER" | "MEMBER" },
4141
token: string,
4242
) {
43-
const res = await fetch(`${API_SERVER_URL}/v1/teams/${teamId}/invites`, {
44-
method: "POST",
45-
headers: {
46-
Authorization: `Bearer ${token}`,
47-
"Content-Type": "application/json",
43+
const res = await fetch(
44+
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${teamId}/invites`,
45+
{
46+
method: "POST",
47+
headers: {
48+
Authorization: `Bearer ${token}`,
49+
"Content-Type": "application/json",
50+
},
51+
body: JSON.stringify({
52+
inviteEmail: invite.email,
53+
inviteRole: invite.role,
54+
}),
4855
},
49-
body: JSON.stringify({
50-
inviteEmail: invite.email,
51-
inviteRole: invite.role,
52-
}),
53-
});
56+
);
5457

5558
if (!res.ok) {
5659
const errorMessage = await res.text();

apps/dashboard/src/@/actions/updateAccount.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use server";
22
import { getAuthToken } from "../../app/(app)/api/lib/getAuthToken";
3-
import { API_SERVER_URL } from "../constants/env";
3+
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "../constants/public-envs";
44

55
export async function updateAccount(values: {
66
name?: string;
@@ -13,7 +13,7 @@ export async function updateAccount(values: {
1313
throw new Error("No Auth token");
1414
}
1515

16-
const res = await fetch(`${API_SERVER_URL}/v1/account`, {
16+
const res = await fetch(`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/account`, {
1717
method: "PUT",
1818
headers: {
1919
"Content-Type": "application/json",

apps/dashboard/src/@/api/chain.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import "server-only";
22
import type { ChainMetadata } from "thirdweb/chains";
33
import type { ChainService } from "../../app/(app)/(dashboard)/(chain)/types/chain";
4-
import { API_SERVER_URL, THIRDWEB_API_SECRET } from "../constants/env";
4+
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "../constants/public-envs";
5+
import { API_SERVER_SECRET } from "../constants/server-envs";
56

67
export async function getGasSponsoredChains() {
7-
if (!THIRDWEB_API_SECRET) {
8+
if (!API_SERVER_SECRET) {
89
throw new Error("API_SERVER_SECRET is not set");
910
}
10-
const res = await fetch(`${API_SERVER_URL}/v1/chains/gas-sponsored`, {
11-
headers: {
12-
"Content-Type": "application/json",
13-
"x-service-api-key": THIRDWEB_API_SECRET,
11+
const res = await fetch(
12+
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/chains/gas-sponsored`,
13+
{
14+
headers: {
15+
"Content-Type": "application/json",
16+
"x-service-api-key": API_SERVER_SECRET,
17+
},
18+
next: {
19+
revalidate: 15 * 60, //15 minutes
20+
},
1421
},
15-
next: {
16-
revalidate: 15 * 60, //15 minutes
17-
},
18-
});
22+
);
1923

2024
if (!res.ok) {
2125
console.error(
@@ -37,15 +41,15 @@ export async function getGasSponsoredChains() {
3741

3842
export function getChains() {
3943
return fetch(
40-
`${API_SERVER_URL}/v1/chains`,
44+
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/chains`,
4145
// revalidate every 60 minutes
4246
{ next: { revalidate: 60 * 60 } },
4347
).then((res) => res.json()) as Promise<{ data: ChainMetadata[] }>;
4448
}
4549

4650
export function getChainServices() {
4751
return fetch(
48-
`${API_SERVER_URL}/v1/chains/services`,
52+
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/chains/services`,
4953
// revalidate every 60 minutes
5054
{ next: { revalidate: 60 * 60 } },
5155
).then((res) => res.json()) as Promise<{

apps/dashboard/src/@/api/linked-wallets.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getAuthToken } from "../../app/(app)/api/lib/getAuthToken";
2-
import { API_SERVER_URL } from "../constants/env";
2+
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "../constants/public-envs";
33

44
export type LinkedWallet = {
55
createdAt: string;
@@ -14,11 +14,14 @@ export async function getLinkedWallets() {
1414
return null;
1515
}
1616

17-
const res = await fetch(`${API_SERVER_URL}/v1/account/wallets`, {
18-
headers: {
19-
Authorization: `Bearer ${token}`,
17+
const res = await fetch(
18+
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/account/wallets`,
19+
{
20+
headers: {
21+
Authorization: `Bearer ${token}`,
22+
},
2023
},
21-
});
24+
);
2225

2326
if (res.ok) {
2427
const json = (await res.json()) as {

0 commit comments

Comments
 (0)