Skip to content

Commit d2527db

Browse files
committed
core: enable backend wallet requests for ZKsync chains
1 parent 8941d71 commit d2527db

File tree

5 files changed

+64
-24
lines changed

5 files changed

+64
-24
lines changed

.changeset/rare-animals-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@treasure-dev/tdk-core": patch
3+
---
4+
5+
Enabled backend wallet requests for ZKsync chains

packages/core/src/api.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,13 @@ export class TDKAPI {
258258
options?: SendTransactionOptions,
259259
) => {
260260
const chain = defineChain(this.chainId);
261-
// TODO: remove ZK check when sessions are supported
262-
if (options?.useActiveWallet || (await isZkSyncChain(chain))) {
261+
const isZkSync = await isZkSyncChain(chain); // TODO: remove ZK check when sessions are supported
262+
const usesActiveWallet =
263+
options?.useActiveWallet ||
264+
(isZkSync &&
265+
(!options?.backendWalletSignature ||
266+
!options.backendWalletSignatureExpiration));
267+
if (usesActiveWallet) {
263268
if (!this.client) {
264269
throw new Error("No Treasure Connect client set");
265270
}
@@ -361,8 +366,13 @@ export class TDKAPI {
361366
options?: SendTransactionOptions,
362367
) => {
363368
const chain = defineChain(this.chainId);
364-
// TODO: remove ZK check when sessions are supported
365-
if (options?.useActiveWallet || (await isZkSyncChain(chain))) {
369+
const isZkSync = await isZkSyncChain(chain); // TODO: remove ZK check when sessions are supported
370+
const usesActiveWallet =
371+
options?.useActiveWallet ||
372+
(isZkSync &&
373+
(!options?.backendWalletSignature ||
374+
!options.backendWalletSignatureExpiration));
375+
if (usesActiveWallet) {
366376
if (!this.client) {
367377
throw new Error("No Treasure Connect client set");
368378
}

packages/core/src/connect/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { KMSClientConfig } from "@aws-sdk/client-kms";
22
import { type Address, type Hex, defineChain } from "thirdweb";
3-
import { verifyContractWalletSignature } from "thirdweb/auth";
3+
import { verifySignature } from "thirdweb/auth";
44
import { smartWallet } from "thirdweb/wallets";
55
import { DEFAULT_ACCOUNT_FACTORY_V0_7 } from "thirdweb/wallets/smart";
66
import { hashMessage, recoverAddress } from "viem";
@@ -104,7 +104,7 @@ export const verifyBackendWalletSignature = async ({
104104
throw new Error("Backend wallet signature expired");
105105
}
106106

107-
const isValid = await verifyContractWalletSignature({
107+
const isValid = await verifySignature({
108108
client,
109109
chain: defineChain(chainId),
110110
message: JSON.stringify({ expirationTime }),

pnpm-lock.yaml

Lines changed: 42 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ catalog:
6969
tailwindcss: ^3.4.17
7070
"tailwind-config-viewer": ^2.0.4
7171
"tailwindcss-animate": ^1.0.7
72-
thirdweb: 5.89.1 # check ox and viem versions if upgrading
72+
thirdweb: 5.90.0 # check ox and viem versions if upgrading
7373
tsup: 8.3.0 # --watch mode broken with Fastify in later versions
7474
tsx: ^4.19.3
7575
turbo: ^2.4.4

0 commit comments

Comments
 (0)