Skip to content

Commit beea37e

Browse files
committed
Switch to partial serialized session
1 parent b117445 commit beea37e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lib/state/client/wharf.svelte.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
type AccountCreationPlugin,
1313
type CreateAccountOptions,
1414
type LoginOptions,
15+
type PartialSerializedSession,
1516
type SerializedSession,
1617
type TransactArgs,
1718
type TransactOptions,
@@ -151,7 +152,7 @@ export class WharfState {
151152
}
152153
}
153154

154-
public async restore(args?: SerializedSession, options?: LoginOptions) {
155+
public async restore(args?: PartialSerializedSession, options?: LoginOptions) {
155156
if (!this.sessionKit) {
156157
throw new Error('User not initialized');
157158
}
@@ -164,12 +165,12 @@ export class WharfState {
164165
return session;
165166
}
166167

167-
public async switch(serialized: SerializedSession): Promise<Session> {
168+
public async switch(serialized: PartialSerializedSession): Promise<Session> {
168169
const session = await this.restore(serialized);
169-
this.chainsSession[String(serialized.chain)] = serialized;
170170
if (!session) {
171171
throw new Error(`Failed to switch session to ${JSON.stringify(serialized)}`);
172172
}
173+
this.chainsSession[String(session.chain)] = session.serialize();
173174
return session;
174175
}
175176

0 commit comments

Comments
 (0)