From e1db80ad5648a9c77b757cda3930aa134e0f1c97 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Thu, 30 Jan 2025 19:00:40 +0000 Subject: [PATCH] fix(entrykit): session client uses smart account (#3547) --- .changeset/serious-rules-whisper.md | 5 +++++ packages/entrykit/src/common.ts | 5 ++++- packages/entrykit/src/getSessionAccount.ts | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .changeset/serious-rules-whisper.md diff --git a/.changeset/serious-rules-whisper.md b/.changeset/serious-rules-whisper.md new file mode 100644 index 0000000000..274453e61f --- /dev/null +++ b/.changeset/serious-rules-whisper.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/entrykit": patch +--- + +Clarified `SessionClient` type as using a `SmartAccount` under the hood so that it can be used with smart account-related Viem actions. diff --git a/packages/entrykit/src/common.ts b/packages/entrykit/src/common.ts index 72e1e52442..f91d0213e3 100644 --- a/packages/entrykit/src/common.ts +++ b/packages/entrykit/src/common.ts @@ -1,9 +1,12 @@ import { resourceToHex } from "@latticexyz/common"; import { Client, Chain, Transport, Account, parseAbi, ClientConfig, Address } from "viem"; import worldConfig from "@latticexyz/world/mud.config"; +import { SmartAccount } from "viem/account-abstraction"; export type ConnectedClient = Client; -export type SessionClient = ConnectedClient & { readonly userAddress: Address }; +export type SessionClient = Client & { + readonly userAddress: Address; +}; export const defaultClientConfig = { pollingInterval: 250, diff --git a/packages/entrykit/src/getSessionAccount.ts b/packages/entrykit/src/getSessionAccount.ts index 72ec2dfd3e..7cc59341fe 100644 --- a/packages/entrykit/src/getSessionAccount.ts +++ b/packages/entrykit/src/getSessionAccount.ts @@ -10,6 +10,7 @@ export async function getSessionAccount({ client: Client; userAddress: Address; }): Promise { - const sessionSigner = getSessionSigner(userAddress); - return await toSimpleSmartAccount({ client, owner: sessionSigner }); + const signer = getSessionSigner(userAddress); + const account = await toSimpleSmartAccount({ client, owner: signer }); + return account; }