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
29 changes: 29 additions & 0 deletions .changeset/orange-socks-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
'@reown/appkit-adapter-wagmi': patch
'pay-test-exchange': patch
'@reown/appkit-controllers': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit': patch
'@reown/appkit-adapter-bitcoin': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-codemod': patch
'@reown/appkit-common': patch
'@reown/appkit-core': patch
'@reown/appkit-experimental': patch
'@reown/appkit-pay': patch
'@reown/appkit-polyfills': 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 cancelling a SIWX message on mobile would reset the network state and log the user out
9 changes: 9 additions & 0 deletions packages/appkit/tests/siwe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ describe('SIWE mapped to SIWX', () => {
const getNonceSpy = vi.spyOn(siweConfig.methods, 'getNonce')
const verifyMessageSpy = vi.spyOn(siweConfig.methods, 'verifyMessage')
const setConnectedWalletInfoSpy = vi.spyOn(AccountController, 'setConnectedWalletInfo')
const setLastConnectedSIWECaipNetworkSpy = vi.spyOn(
ChainController,
'setLastConnectedSIWECaipNetwork'
)

const cacao = {
h: {
Expand Down Expand Up @@ -207,6 +211,11 @@ describe('SIWE mapped to SIWX', () => {
message: 'Formatted auth message',
signature: 'mock-signature'
})
expect(setLastConnectedSIWECaipNetworkSpy).toHaveBeenCalledWith({
...networks.mainnet,
caipNetworkId: 'eip155:1',
chainNamespace: 'eip155'
})
expect(authenticateSpy).toHaveBeenCalledWith({
chainId: 'eip155:1',
chains: ['eip155:1', 'eip155:10', 'eip155:137'], // must be active chain first
Expand Down
6 changes: 5 additions & 1 deletion packages/controllers/src/utils/SIWXUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export const SIWXUtil = {
methods: string[]
}) {
const siwx = SIWXUtil.getSIWX()

const network = getActiveCaipNetwork()
const namespaces = new Set(chains.map(chain => chain.split(':')[0] as ChainNamespace))

if (!siwx || namespaces.size !== 1 || !namespaces.has('eip155')) {
Expand Down Expand Up @@ -434,6 +434,10 @@ export const SIWXUtil = {
try {
await siwx.setSessions(sessions)

if (network) {
ChainController.setLastConnectedSIWECaipNetwork(network)
}

EventsController.sendEvent({
type: 'track',
event: 'SIWX_AUTH_SUCCESS',
Expand Down
Loading