Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvoskamp committed Dec 11, 2024
1 parent ced597d commit 1f5d46c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/appkit/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ export class AppKit {
throw new Error('Adapter not found')
}

let res
let res: AdapterBlueprint.ConnectResult | undefined = undefined
try {
res = await adapter.connect({
id,
Expand All @@ -848,11 +848,18 @@ export class AppKit {
caipNetwork?.rpcUrls?.default?.http?.[0] ||
this.getCaipNetwork()?.rpcUrls?.default?.http?.[0]
})
/**
* In some cases with wagmi connectors, the connector is already connected
* which throws an `Is already connected`error. In such cases, we need to reconnect
* to restore the session.
* We check if the reconnect method exists (which it does for wagmi connectors) and if so
* we attempt to reconnect and restore the session state.
*/
} catch (error) {
if (!adapter?.reconnect) {
throw new Error('Adapter is not able to connect')
}
res = await adapter.reconnect({
await adapter.reconnect({
id,
info,
type,
Expand Down

0 comments on commit 1f5d46c

Please sign in to comment.