(null);
+
+ if (!account) {
+ return (
+
+
+
+ );
+ }
+
+ if (account.status === "requires_otp") {
+ return (
+
+
+
+
+ );
+ }
+
+ return (
+
+
Logged in as: {account.id}
+
+
+
+ );
+}
diff --git a/apps/playground-web/src/lib/client.ts b/apps/playground-web/src/lib/client.ts
index f8494c4d607..b3d664a7e56 100644
--- a/apps/playground-web/src/lib/client.ts
+++ b/apps/playground-web/src/lib/client.ts
@@ -11,6 +11,7 @@ setThirdwebDomains({
analytics: process.env.NEXT_PUBLIC_ANALYTICS_URL,
insight: process.env.NEXT_PUBLIC_INSIGHT_URL,
bridge: process.env.NEXT_PUBLIC_BRIDGE_URL,
+ engineCloud: process.env.NEXT_PUBLIC_ENGINE_CLOUD_URL,
});
const isDev =
diff --git a/apps/playground-web/src/lib/constants.ts b/apps/playground-web/src/lib/constants.ts
index 81706550735..6f0b78b3fdd 100644
--- a/apps/playground-web/src/lib/constants.ts
+++ b/apps/playground-web/src/lib/constants.ts
@@ -4,7 +4,7 @@ export const metadataBase = process.env.VERCEL_ENV
? new URL("https://playground.thirdweb.com")
: undefined;
-const getDomain = () => {
+export const getDomain = () => {
if (process.env.VERCEL_ENV === "production") {
return "thirdweb.com";
}
diff --git a/apps/playground-web/src/lib/server-wallet.ts b/apps/playground-web/src/lib/server-wallet.ts
new file mode 100644
index 00000000000..84caf7660a3
--- /dev/null
+++ b/apps/playground-web/src/lib/server-wallet.ts
@@ -0,0 +1,15 @@
+import "server-only";
+import { Engine } from "thirdweb";
+import { sepolia } from "thirdweb/chains";
+import { THIRDWEB_CLIENT } from "./client";
+
+const BACKEND_WALLET_ADDRESS = process.env.ENGINE_BACKEND_WALLET as string;
+const ENGINE_VAULT_ACCESS_TOKEN = process.env
+ .ENGINE_VAULT_ACCESS_TOKEN as string;
+
+export const SERVER_WALLET = Engine.serverWallet({
+ address: BACKEND_WALLET_ADDRESS,
+ client: THIRDWEB_CLIENT,
+ vaultAccessToken: ENGINE_VAULT_ACCESS_TOKEN,
+ chain: sepolia,
+});
diff --git a/packages/thirdweb/package.json b/packages/thirdweb/package.json
index 6bb4a97d9fc..44fb1f780da 100644
--- a/packages/thirdweb/package.json
+++ b/packages/thirdweb/package.json
@@ -297,7 +297,7 @@
"knip": "knip",
"build:generate": "bun scripts/generate/generate.ts",
"build:generate-wallets": "bun scripts/wallets/generate.ts",
- "dev": "tsc --project ./tsconfig.build.json --module es2020 --outDir ./dist/esm --watch",
+ "dev": "tsc --project ./tsconfig.build.json --module nodenext --moduleResolution nodenext --outDir ./dist/esm --watch",
"dev:cjs": "printf '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json && tsc --noCheck --project ./tsconfig.build.json --module commonjs --outDir ./dist/cjs --verbatimModuleSyntax false --watch",
"dev:esm": "printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/esm/package.json && tsc --noCheck --project ./tsconfig.build.json --module es2020 --outDir ./dist/esm --watch",
"build": "pnpm clean && pnpm build:types && pnpm build:cjs && pnpm build:esm",
diff --git a/packages/thirdweb/src/login/client/index.ts b/packages/thirdweb/src/login/client/index.ts
index af3e537ef7e..9bb3a81d4ea 100644
--- a/packages/thirdweb/src/login/client/index.ts
+++ b/packages/thirdweb/src/login/client/index.ts
@@ -1 +1 @@
-export { login, type LoginOptions as LoginParams } from "./login.js";
+export { login, type LoginOptions, type LoginResult } from "./login.js";
diff --git a/packages/thirdweb/src/login/client/login.ts b/packages/thirdweb/src/login/client/login.ts
index af758d42324..aa97ccf9e51 100644
--- a/packages/thirdweb/src/login/client/login.ts
+++ b/packages/thirdweb/src/login/client/login.ts
@@ -31,6 +31,7 @@ export type LoginOptions = (
}
) & {
client: ThirdwebClient;
+ chain: Chain;
options?: {
sponsorGas?: boolean;
redirectUrl?: string;
@@ -40,10 +41,12 @@ export type LoginOptions = (
baseURL?: string;
};
+export type LoginResult = Awaited>;
+
export async function login(loginOptions: LoginOptions) {
const IAW = inAppWallet({
auth: {
- mode: "redirect",
+ mode: "popup",
options: [],
redirectUrl: loginOptions.options?.redirectUrl,
passkeyDomain: loginOptions.options?.passkeyDomain,
@@ -62,6 +65,7 @@ export async function login(loginOptions: LoginOptions) {
client: loginOptions.client,
strategy: "jwt",
jwt: loginOptions.jwt,
+ chain: loginOptions.chain,
});
return mapAccount(account, IAW, loginOptions.baseURL);
@@ -87,6 +91,7 @@ export async function login(loginOptions: LoginOptions) {
phoneNumber: loginOptions.phoneNumber,
verificationCode,
client: loginOptions.client,
+ chain: loginOptions.chain,
});
return mapAccount(account, IAW, loginOptions.baseURL);
@@ -115,6 +120,7 @@ export async function login(loginOptions: LoginOptions) {
email: loginOptions.email,
verificationCode,
client: loginOptions.client,
+ chain: loginOptions.chain,
});
return mapAccount(account, IAW, loginOptions.baseURL);
@@ -141,6 +147,7 @@ export async function login(loginOptions: LoginOptions) {
const account = await IAW.connect({
client: loginOptions.client,
strategy: loginOptions.type,
+ chain: loginOptions.chain,
});
return mapAccount(account, IAW, loginOptions.baseURL);
diff --git a/packages/thirdweb/src/login/index.ts b/packages/thirdweb/src/login/index.ts
index dcc46893a9e..970a2ca664a 100644
--- a/packages/thirdweb/src/login/index.ts
+++ b/packages/thirdweb/src/login/index.ts
@@ -2,7 +2,7 @@ export * as Client from "./client/index.js";
export * as Server from "./server/index.js";
// client
-export { login, type LoginOptions as LoginParams } from "./client/login.js";
+export { login, type LoginOptions, type LoginResult } from "./client/login.js";
// server
export {