Skip to content

Commit

Permalink
fix(entrykit): session client uses smart account (#3547)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Jan 30, 2025
1 parent 491a5ac commit e1db80a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-rules-whisper.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 4 additions & 1 deletion packages/entrykit/src/common.ts
Original file line number Diff line number Diff line change
@@ -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<chain extends Chain = Chain> = Client<Transport, chain, Account>;
export type SessionClient<chain extends Chain = Chain> = ConnectedClient<chain> & { readonly userAddress: Address };
export type SessionClient<chain extends Chain = Chain> = Client<Transport, chain, SmartAccount> & {
readonly userAddress: Address;
};

export const defaultClientConfig = {
pollingInterval: 250,
Expand Down
5 changes: 3 additions & 2 deletions packages/entrykit/src/getSessionAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export async function getSessionAccount<chain extends Chain>({
client: Client<Transport, chain>;
userAddress: Address;
}): Promise<SmartAccount> {
const sessionSigner = getSessionSigner(userAddress);
return await toSimpleSmartAccount({ client, owner: sessionSigner });
const signer = getSessionSigner(userAddress);
const account = await toSimpleSmartAccount({ client, owner: signer });
return account;
}

0 comments on commit e1db80a

Please sign in to comment.