Skip to content

Commit 7ab9e20

Browse files
committed
Merge branch 'dustin/engine_playground' of https://github.com/thirdweb-dev/js into dustin/engine_playground
2 parents 00005e3 + 01297fe commit 7ab9e20

File tree

77 files changed

+1906
-419
lines changed

Some content is hidden

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

77 files changed

+1906
-419
lines changed

.changeset/clever-carrots-march.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": minor
3+
---
4+
5+
Add headless components: ChainProvider, ChainIcon & ChainName

.changeset/perfect-bananas-behave.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/seven-olives-applaud.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

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

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,12 @@
11
import { fetchAnalytics } from "data/analytics/fetch-analytics";
2-
3-
export interface WalletStats {
4-
date: string;
5-
uniqueWalletsConnected: number;
6-
totalConnections: number;
7-
walletType: string;
8-
}
9-
10-
export interface WalletUserStats {
11-
date: string;
12-
newUsers: number;
13-
returningUsers: number;
14-
totalUsers: number;
15-
}
16-
17-
export interface InAppWalletStats {
18-
date: string;
19-
authenticationMethod: string;
20-
uniqueWalletsConnected: number;
21-
}
22-
23-
export interface EcosystemWalletStats extends InAppWalletStats {}
24-
25-
export interface UserOpStats {
26-
date: string;
27-
successful: number;
28-
failed: number;
29-
sponsoredUsd: number;
30-
chainId?: string;
31-
}
32-
33-
interface AnalyticsQueryParams {
34-
clientId?: string;
35-
accountId?: string;
36-
from?: Date;
37-
to?: Date;
38-
period?: "day" | "week" | "month" | "year" | "all";
39-
}
2+
import type {
3+
AnalyticsQueryParams,
4+
InAppWalletStats,
5+
RpcMethodStats,
6+
UserOpStats,
7+
WalletStats,
8+
WalletUserStats,
9+
} from "types/analytics";
4010

4111
function buildSearchParams(params: AnalyticsQueryParams): URLSearchParams {
4212
const searchParams = new URLSearchParams();
@@ -115,6 +85,27 @@ export async function getUserOpUsage(
11585
return json.data as UserOpStats[];
11686
}
11787

88+
export async function getRpcMethodUsage(
89+
params: AnalyticsQueryParams,
90+
): Promise<RpcMethodStats[]> {
91+
const searchParams = buildSearchParams(params);
92+
const res = await fetchAnalytics(
93+
`v1/rpc/evm-methods?${searchParams.toString()}`,
94+
{
95+
method: "GET",
96+
headers: { "Content-Type": "application/json" },
97+
},
98+
);
99+
100+
if (res?.status !== 200) {
101+
console.error("Failed to fetch RPC method usage");
102+
return [];
103+
}
104+
105+
const json = await res.json();
106+
return json.data as RpcMethodStats[];
107+
}
108+
118109
export async function getWalletUsers(
119110
params: AnalyticsQueryParams,
120111
): Promise<WalletUserStats[]> {
@@ -135,3 +126,21 @@ export async function getWalletUsers(
135126
const json = await res.json();
136127
return json.data as WalletUserStats[];
137128
}
129+
130+
export async function isProjectActive(
131+
params: AnalyticsQueryParams,
132+
): Promise<boolean> {
133+
const searchParams = buildSearchParams(params);
134+
const res = await fetchAnalytics(`v1/active?${searchParams.toString()}`, {
135+
method: "GET",
136+
headers: { "Content-Type": "application/json" },
137+
});
138+
139+
if (res?.status !== 200) {
140+
console.error("Failed to fetch project active status");
141+
return false;
142+
}
143+
144+
const json = await res.json();
145+
return json.data.isActive as boolean;
146+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { cn } from "@/lib/utils";
2+
3+
export function TextDivider(props: {
4+
text: string;
5+
className?: string;
6+
}) {
7+
return (
8+
<div
9+
className={cn(
10+
"flex items-center text-muted-foreground text-sm",
11+
props.className,
12+
)}
13+
>
14+
<span className="h-[1px] flex-1 bg-border" />
15+
<span className="mx-4">{props.text}</span>
16+
<span className="h-[1px] flex-1 bg-border" />
17+
</div>
18+
);
19+
}

apps/dashboard/src/@/components/blocks/pricing-card.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type PricingCardProps = {
3232
current?: boolean;
3333
canTrialGrowth?: boolean;
3434
activeTrialEndsAt?: string;
35+
redirectPath: string;
3536
};
3637

3738
export const PricingCard: React.FC<PricingCardProps> = ({
@@ -42,6 +43,7 @@ export const PricingCard: React.FC<PricingCardProps> = ({
4243
current = false,
4344
canTrialGrowth = false,
4445
activeTrialEndsAt,
46+
redirectPath,
4547
}) => {
4648
const plan = TEAM_PLANS[billingPlan];
4749
const isCustomPrice = typeof plan.price === "string";
@@ -129,6 +131,7 @@ export const PricingCard: React.FC<PricingCardProps> = ({
129131
variant={cta.variant || "outline"}
130132
teamSlug={teamSlug}
131133
sku={billingPlan === "starter" ? "plan:starter" : "plan:growth"}
134+
redirectPath={redirectPath}
132135
>
133136
{cta.title}
134137
</CheckoutButton>

apps/dashboard/src/@/components/ui/inline-code.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function InlineCode({
77
return (
88
<code
99
className={cn(
10-
"inline-block rounded bg-muted px-2 font-mono text-sm",
10+
"mx-0.5 inline rounded-lg border border-border px-1.5 py-[3px] font-mono text-[0.85em] text-foreground",
1111
className,
1212
)}
1313
>

apps/dashboard/src/@3rdweb-sdk/react/cache-keys.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ export const engineKeys = {
111111
] as const,
112112
health: (instance: string) =>
113113
[...engineKeys.all, instance, "health"] as const,
114-
latestVersion: () => [...engineKeys.all, "latestVersion"] as const,
114+
deploymentPublicConfiguration: () =>
115+
[...engineKeys.all, "deploymentPublicConfiguration"] as const,
115116
systemMetrics: (engineId: string) =>
116117
[...engineKeys.all, engineId, "systemMetrics"] as const,
117118
queueMetrics: (engineId: string) =>

apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { UserOpStats } from "@/api/analytics";
21
import type { Team } from "@/api/team";
32
import {
43
type Query,
@@ -9,6 +8,7 @@ import {
98
import { THIRDWEB_ANALYTICS_API_HOST, THIRDWEB_API_HOST } from "constants/urls";
109
import { useAllChainsData } from "hooks/chains/allChains";
1110
import invariant from "tiny-invariant";
11+
import type { UserOpStats } from "types/analytics";
1212
import { accountKeys, apiKeys, authorizedWallets } from "../cache-keys";
1313
import { useLoggedInUser } from "./useLoggedInUser";
1414

apps/dashboard/src/@3rdweb-sdk/react/hooks/useEngine.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,32 +191,48 @@ export function useEngineQueueMetrics(
191191
});
192192
}
193193

194-
export function useEngineLatestVersion() {
195-
return useQuery({
196-
queryKey: engineKeys.latestVersion(),
194+
interface GetDeploymentPublicConfigurationInput {
195+
teamSlug: string;
196+
}
197+
198+
interface DeploymentPublicConfigurationResponse {
199+
serverVersions: {
200+
name: string;
201+
createdAt: string;
202+
}[];
203+
}
204+
205+
export function useEngineGetDeploymentPublicConfiguration(
206+
input: GetDeploymentPublicConfigurationInput,
207+
) {
208+
return useQuery<DeploymentPublicConfigurationResponse>({
209+
queryKey: engineKeys.deploymentPublicConfiguration(),
197210
queryFn: async () => {
198-
const res = await fetch(`${THIRDWEB_API_HOST}/v1/engine/latest-version`, {
199-
method: "GET",
200-
});
211+
const res = await fetch(
212+
`${THIRDWEB_API_HOST}/v1/teams/${input.teamSlug}/engine/deployments/public-configuration`,
213+
{ method: "GET" },
214+
);
201215
if (!res.ok) {
202216
throw new Error(`Unexpected status ${res.status}: ${await res.text()}`);
203217
}
218+
204219
const json = await res.json();
205-
return json.data.version as string;
220+
return json.data as DeploymentPublicConfigurationResponse;
206221
},
207222
});
208223
}
209224

210-
interface UpdateVersionInput {
225+
interface UpdateDeploymentInput {
226+
teamSlug: string;
211227
deploymentId: string;
212228
serverVersion: string;
213229
}
214230

215-
export function useEngineUpdateServerVersion() {
231+
export function useEngineUpdateDeployment() {
216232
return useMutation({
217-
mutationFn: async (input: UpdateVersionInput) => {
233+
mutationFn: async (input: UpdateDeploymentInput) => {
218234
const res = await fetch(
219-
`${THIRDWEB_API_HOST}/v2/engine/deployments/${input.deploymentId}/infrastructure`,
235+
`${THIRDWEB_API_HOST}/v1/teams/${input.teamSlug}/engine/deployments/${input.deploymentId}`,
220236
{
221237
method: "PUT",
222238
headers: {

0 commit comments

Comments
 (0)