Skip to content

Commit c87e9ab

Browse files
committed
Merge branch 'main' into greg/bridge-page
2 parents eaf9176 + 14fe9ee commit c87e9ab

File tree

120 files changed

+5876
-5567
lines changed

Some content is hidden

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

120 files changed

+5876
-5567
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ See our [open source page](https://thirdweb.com/open-source) for more informatio
172172
- [Documentation](https://portal.thirdweb.com/)
173173
- [Templates](https://thirdweb.com/templates)
174174
- [YouTube](https://www.youtube.com/c/thirdweb)
175+
- [X/Twitter](https://x.com/thirdweb)
176+
- [Telegram](https://t.me/officialthirdweb)
175177

176178
## Support
177179

apps/dashboard/knip.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
],
99
"ignoreBinaries": ["only-allow"],
1010
"ignoreDependencies": [
11+
"@thirdweb-dev/api",
1112
"@thirdweb-dev/service-utils",
1213
"@thirdweb-dev/vault-sdk",
1314
"thirdweb",

apps/dashboard/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@shazow/whatsabi": "0.22.2",
2424
"@tanstack/react-query": "5.81.5",
2525
"@tanstack/react-table": "^8.21.3",
26+
"@thirdweb-dev/api": "workspace:*",
2627
"@thirdweb-dev/service-utils": "workspace:*",
2728
"@thirdweb-dev/vault-sdk": "workspace:*",
2829
"@vercel/functions": "2.2.2",

apps/dashboard/src/@/components/blocks/project-page/project-page-header.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,15 @@ type Action =
2323
component: React.ReactNode;
2424
};
2525

26-
function Action(props: { action: Action; variant?: "default" | "secondary" }) {
26+
function Action(props: { action: Action; variant?: "default" | "outline" }) {
2727
const action = props.action;
2828

2929
return "component" in action ? (
3030
action.component
3131
) : (
3232
<Button
3333
asChild
34-
className={cn(
35-
"rounded-full",
36-
props.variant === "secondary" && "border border-border",
37-
)}
34+
className={cn("rounded-full")}
3835
size="sm"
3936
variant={props.variant}
4037
>
@@ -60,7 +57,7 @@ export type ProjectPageHeaderProps = {
6057
icon: React.FC<{ className?: string }>;
6158
isProjectIcon?: boolean;
6259
actions: {
63-
primary: Action;
60+
primary?: Action;
6461
secondary?: Action;
6562
} | null;
6663

@@ -114,7 +111,7 @@ export function ProjectPageHeader(props: ProjectPageHeaderProps) {
114111
{props.actions && (
115112
<div className="hidden lg:flex items-center gap-3">
116113
{props.actions.secondary && (
117-
<Action action={props.actions.secondary} variant="secondary" />
114+
<Action action={props.actions.secondary} variant="outline" />
118115
)}
119116

120117
{props.actions.primary && (
@@ -132,7 +129,7 @@ export function ProjectPageHeader(props: ProjectPageHeaderProps) {
132129
{props.title}
133130
</h2>
134131
{/* description */}
135-
<p className="text-sm text-muted-foreground line-clamp-3 md:line-clamp-2">
132+
<p className="text-sm text-muted-foreground text-pretty">
136133
{props.description}
137134
</p>
138135
</div>
@@ -145,7 +142,7 @@ export function ProjectPageHeader(props: ProjectPageHeaderProps) {
145142
)}
146143

147144
{props.actions?.secondary && (
148-
<Action action={props.actions.secondary} variant="secondary" />
145+
<Action action={props.actions.secondary} variant="outline" />
149146
)}
150147
</div>
151148
)}
Lines changed: 122 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,79 @@
1+
import type {
2+
ListUserWalletsData,
3+
ListUserWalletsResponses,
4+
} from "@thirdweb-dev/api";
5+
import { configure, listUserWallets } from "@thirdweb-dev/api";
16
import type { WalletUser } from "thirdweb/wallets";
2-
import { THIRDWEB_EWS_API_HOST } from "@/constants/urls";
7+
import { THIRDWEB_API_HOST } from "@/constants/urls";
38
import type { SearchType } from "./types";
49

10+
// Configure the API client to use the correct base URL
11+
configure({
12+
override: {
13+
baseUrl: THIRDWEB_API_HOST,
14+
},
15+
});
16+
17+
// Extract types from the generated API
18+
type APIWallet = ListUserWalletsResponses[200]["result"]["wallets"][0];
19+
type APIProfile = APIWallet["profiles"][0];
20+
21+
// Transform API response to match existing WalletUser format
22+
function transformToWalletUser(apiWallet: APIWallet): WalletUser {
23+
return {
24+
id: getProfileId(apiWallet.profiles[0]) || "",
25+
linkedAccounts: apiWallet.profiles.map((profile) => {
26+
// Create details object based on the profile data
27+
let details:
28+
| { email: string; [key: string]: string }
29+
| { phone: string; [key: string]: string }
30+
| { address: string; [key: string]: string }
31+
| { id: string; [key: string]: string };
32+
33+
const profileId = getProfileId(profile);
34+
35+
if ("email" in profile && profile.email) {
36+
details = { email: profile.email, id: profileId };
37+
} else if ("phone" in profile && profile.phone) {
38+
details = { phone: profile.phone, id: profileId };
39+
} else if ("walletAddress" in profile && profile.walletAddress) {
40+
details = { address: profile.walletAddress, id: profileId };
41+
} else {
42+
details = { id: profileId };
43+
}
44+
45+
return {
46+
type: profile.type,
47+
details,
48+
};
49+
}),
50+
wallets: apiWallet.address
51+
? [
52+
{
53+
address: apiWallet.address,
54+
createdAt: apiWallet.createdAt || new Date().toISOString(),
55+
type: "enclave" as const,
56+
},
57+
]
58+
: [],
59+
};
60+
}
61+
62+
// Helper function to safely get ID from any profile type
63+
function getProfileId(profile: APIProfile | undefined): string {
64+
if (!profile) return "";
65+
66+
if ("id" in profile) {
67+
return profile.id;
68+
} else if ("credentialId" in profile) {
69+
return profile.credentialId;
70+
} else if ("identifier" in profile) {
71+
return profile.identifier;
72+
}
73+
74+
return "";
75+
}
76+
577
export async function searchUsers(
678
authToken: string,
779
clientId: string | undefined,
@@ -10,50 +82,57 @@ export async function searchUsers(
1082
searchType: SearchType,
1183
query: string,
1284
): Promise<WalletUser[]> {
13-
const url = new URL(`${THIRDWEB_EWS_API_HOST}/api/2024-05-05/account/list`);
85+
try {
86+
// Prepare query parameters
87+
const queryParams: ListUserWalletsData["query"] = {
88+
limit: 50,
89+
};
1490

15-
// Add clientId or ecosystemSlug parameter
16-
if (ecosystemSlug) {
17-
url.searchParams.append("ecosystemSlug", `ecosystem.${ecosystemSlug}`);
18-
} else if (clientId) {
19-
url.searchParams.append("clientId", clientId);
20-
}
91+
// Add search parameter based on search type
92+
switch (searchType) {
93+
case "email":
94+
queryParams.email = query;
95+
break;
96+
case "phone":
97+
queryParams.phone = query;
98+
break;
99+
case "id":
100+
queryParams.id = query;
101+
break;
102+
case "address":
103+
queryParams.address = query;
104+
break;
105+
case "externalWallet":
106+
queryParams.externalWalletAddress = query;
107+
break;
108+
}
21109

22-
// Add search parameter based on search type
23-
switch (searchType) {
24-
case "email":
25-
url.searchParams.append("email", query);
26-
break;
27-
case "phone":
28-
url.searchParams.append("phone", query);
29-
break;
30-
case "id":
31-
url.searchParams.append("id", query);
32-
break;
33-
case "address":
34-
url.searchParams.append("address", query);
35-
break;
36-
case "externalWallet":
37-
url.searchParams.append("externalWalletAddress", query);
38-
break;
39-
}
110+
// Use the generated API function with Bearer authentication
111+
const response = await listUserWallets({
112+
query: queryParams,
113+
headers: {
114+
Authorization: `Bearer ${authToken}`,
115+
"Content-Type": "application/json",
116+
"x-thirdweb-team-id": teamId,
117+
...(clientId && { "x-client-id": clientId }),
118+
...(ecosystemSlug && {
119+
"x-ecosystem-id": `ecosystem.${ecosystemSlug}`,
120+
}),
121+
},
122+
});
40123

41-
const response = await fetch(url.toString(), {
42-
headers: {
43-
Authorization: `Bearer ${authToken}`,
44-
"Content-Type": "application/json",
45-
"x-thirdweb-team-id": teamId,
46-
...(clientId && { "x-client-id": clientId }),
47-
},
48-
method: "GET",
49-
});
50-
51-
if (!response.ok) {
52-
throw new Error(
53-
`Failed to search users: ${response.status} ${response.statusText}`,
54-
);
55-
}
124+
// Handle response
125+
if (response.error || !response.data) {
126+
console.error(
127+
"Error searching users:",
128+
response.error || "No data returned",
129+
);
130+
return [];
131+
}
56132

57-
const data = await response.json();
58-
return data.users as WalletUser[];
133+
return response.data.result.wallets.map(transformToWalletUser);
134+
} catch (error) {
135+
console.error("Error searching users:", error);
136+
return [];
137+
}
59138
}

apps/dashboard/src/@/constants/urls.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
export const THIRDWEB_EWS_API_HOST =
2-
process.env.NEXT_PUBLIC_THIRDWEB_EWS_API_HOST ||
3-
"https://in-app-wallet.thirdweb.com";
1+
export const THIRDWEB_API_HOST =
2+
process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb-dev.com";
43

54
export const THIRDWEB_PAY_DOMAIN =
65
process.env.NEXT_PUBLIC_PAY_URL || "pay.thirdweb-dev.com";

0 commit comments

Comments
 (0)