Skip to content

Commit

Permalink
skip extra user session fetch on login
Browse files Browse the repository at this point in the history
  • Loading branch information
alecananian committed Sep 20, 2024
1 parent 4716da3 commit 3d01c9a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/spicy-swans-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@treasure-dev/tdk-react": patch
"@treasure-dev/tdk-core": patch
---

Skip extra user session fetch on login
1 change: 1 addition & 0 deletions packages/core/src/connect/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export const logIn = async (params: ConnectWalletConfig & ConnectConfig) => {
wallet,
chainId,
tdk,
sessions: user.allActiveSigners,
options: sessionOptions,
});
}
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/connect/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@ export const startUserSession = async ({
wallet,
chainId,
tdk,
sessions: userSessions,
options,
}: {
client: TreasureConnectClient;
wallet: Wallet | undefined;
chainId: number;
tdk: TDKAPI;
sessions?: Session[];
options: SessionOptions;
}) => {
// Skip session creation if not required by app
Expand All @@ -146,7 +148,7 @@ export const startUserSession = async ({
const walletChainId = wallet?.getChain()?.id;

// Skip session creation if user has an active session already
const sessions = await tdk.user.getSessions({ chainId });
const sessions = userSessions ?? (await tdk.user.getSessions({ chainId }));
const hasActiveSession = validateSession({
...options,
sessions,
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/contexts/treasure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const TreasureProviderInner = ({
wallet,
chainId: chain.id,
tdk,
sessions: nextUser.allActiveSigners,
options: sessionOptions,
});
}
Expand Down

0 comments on commit 3d01c9a

Please sign in to comment.