Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .changeset/odd-spies-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
'@reown/appkit': patch
'pay-test-exchange': patch
'@reown/appkit-adapter-bitcoin': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-ton': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-codemod': patch
'@reown/appkit-common': patch
'@reown/appkit-controllers': patch
'@reown/appkit-core': patch
'@reown/appkit-experimental': patch
'@reown/appkit-pay': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-siwe': patch
'@reown/appkit-siwx': patch
'@reown/appkit-testing': patch
'@reown/appkit-ui': patch
'@reown/appkit-universal-connector': patch
'@reown/appkit-wallet': patch
'@reown/appkit-wallet-button': patch
---

Fixed an issue where WalletConnect would not reconnect after page refresh when using multi-wallet
7 changes: 7 additions & 0 deletions packages/appkit/src/client/appkit-base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,13 @@ export abstract class AppKitBaseClient {
onConnect: accounts => {
const { address } = CoreHelperUtil.getAccount(accounts[0])

for (const namespace of this.chainNamespaces) {
StorageUtil.removeDisconnectedConnectorId(
ConstantsUtil.CONNECTOR_ID.WALLET_CONNECT,
namespace
)
}

ConnectionController.finalizeWcConnection(address as string)
},
onDisconnect: () => {
Expand Down
46 changes: 45 additions & 1 deletion packages/appkit/tests/client/walletconnect-events.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { beforeAll, describe, expect, it, vi } from 'vitest'

import { ConstantsUtil } from '@reown/appkit-common'
import {
ChainController,
ConnectionController,
CoreHelperUtil,
EventsController
EventsController,
StorageUtil
} from '@reown/appkit-controllers'

import { AppKit } from '../../src/client/appkit.js'
Expand Down Expand Up @@ -125,6 +127,48 @@ describe('WalletConnect Events', () => {

expect(finalizeWcConnectionSpy).toHaveBeenCalledWith('0x123')
})

it('should call StorageUtil.removeDisconnectedConnectorId for all namespaces after onConnect', async () => {
vi.spyOn(CoreHelperUtil, 'getAccount').mockReturnValueOnce({
address: '0x123',
chainId: '1'
})

vi.spyOn(ConnectionController, 'finalizeWcConnection').mockReturnValueOnce()

const removeDisconnectedConnectorIdSpy = vi
.spyOn(StorageUtil, 'removeDisconnectedConnectorId')
.mockImplementation(() => {})

mockUniversalProvider.on.mockClear()

const appkit = new AppKit({
...mockOptions,
universalProvider: mockUniversalProvider as any
})

await appkit.ready()

const connectCallback = mockUniversalProvider.on.mock.calls.find(
([event]) => event === 'connect'
)?.[1]

if (!connectCallback) {
throw new Error('connect callback not found')
}

connectCallback()

expect(removeDisconnectedConnectorIdSpy).toHaveBeenCalledWith(
ConstantsUtil.CONNECTOR_ID.WALLET_CONNECT,
'eip155'
)
expect(removeDisconnectedConnectorIdSpy).toHaveBeenCalledWith(
ConstantsUtil.CONNECTOR_ID.WALLET_CONNECT,
'solana'
)
expect(removeDisconnectedConnectorIdSpy).toHaveBeenCalledTimes(2)
})
})

describe('finalizeWcConnection', () => {
Expand Down
Loading