Skip to content

Commit 54651ba

Browse files
[Insight] Make clientId optional and improve error handling
1 parent 5139857 commit 54651ba

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

packages/insight/src/configure.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Config } from "@hey-api/client-fetch";
22
import { client } from "./client/client.gen.js";
33

44
export type InsightClientOptions = {
5-
readonly clientId: string;
5+
readonly clientId?: string;
66
readonly secretKey?: string;
77
};
88

packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export async function getUserStatus({
2525
method: "GET",
2626
headers: {
2727
"Content-Type": "application/json",
28-
"x-thirdweb-client-id": client.clientId,
2928
Authorization: `Bearer embedded-wallet-token:${authToken}`,
3029
},
3130
},

packages/thirdweb/src/wallets/in-app/core/authentication/guest.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ export async function guestAuthenticate(args: {
4545
}),
4646
});
4747

48-
if (!res.ok) throw new Error("Failed to generate guest account");
48+
if (!res.ok) {
49+
const error = await res.text();
50+
throw new Error(
51+
`Failed to generate guest account: ${res.status} ${res.statusText} ${error}`,
52+
);
53+
}
4954

5055
return (await res.json()) satisfies AuthStoredTokenWithCookieReturnType;
5156
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { describe, expect, it } from "vitest";
2+
import { TEST_CLIENT } from "../../../../../test/src/test-clients.js";
3+
import { baseSepolia } from "../../../../chains/chain-definitions/base-sepolia.js";
4+
import { sendBatchTransaction } from "../../../../transaction/actions/send-batch-transaction.js";
5+
import { prepareTransaction } from "../../../../transaction/prepare-transaction.js";
6+
import { generateAccount } from "../../../utils/generateAccount.js";
7+
import { inAppWallet } from "../../web/in-app.js";
8+
9+
const client = TEST_CLIENT;
10+
const chain = baseSepolia;
11+
12+
describe.runIf(process.env.TW_SECRET_KEY)("7702 Minimal Account", () => {
13+
it("should batch transactions", async () => {
14+
const iaw = inAppWallet({
15+
executionMode: {
16+
mode: "EIP7702",
17+
sponsorGas: true,
18+
},
19+
});
20+
const account = await iaw.connect({
21+
client,
22+
strategy: "guest",
23+
chain,
24+
});
25+
const tx1 = prepareTransaction({
26+
client,
27+
chain,
28+
to: (await generateAccount({ client })).address,
29+
value: 0n,
30+
});
31+
const tx2 = prepareTransaction({
32+
client,
33+
chain,
34+
to: (await generateAccount({ client })).address,
35+
value: 0n,
36+
});
37+
const result = await sendBatchTransaction({
38+
account,
39+
transactions: [tx1, tx2],
40+
});
41+
expect(result.transactionHash).toBeDefined();
42+
});
43+
});

0 commit comments

Comments
 (0)