Skip to content

Commit

Permalink
Merge branch 'main' into feat/appkit-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
enesozturk authored Oct 14, 2024
2 parents f37e111 + 9d8ce0a commit 422a15f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .changeset/calm-phones-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-wallet': patch
'@apps/demo': patch
'@apps/gallery': patch
'@apps/laboratory': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-polkadot': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-common': patch
'@reown/appkit-core': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-siwe': patch
'@reown/appkit-ui': patch
---

Refactored frame timeouts
3 changes: 3 additions & 0 deletions packages/wallet/src/W3mFrameProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ export class W3mFrameProvider {
}
resolve(undefined as unknown as W3mFrameTypes.Responses[`Frame${T}Response`])
} else if (framEvent.type === `@w3m-frame/${type}_ERROR`) {
if (timer) {
clearTimeout(timer)
}
if ('payload' in framEvent) {
reject(new Error(framEvent.payload?.message || 'An error occurred'))
}
Expand Down
22 changes: 20 additions & 2 deletions packages/wallet/tests/W3mFrameProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import { SecureSiteMock } from './mocks/SecureSite.mock.js'
import { W3mFrameConstants } from '../src/W3mFrameConstants.js'

describe('W3mFrameProvider', () => {
const mockTimeout = vi.fn

const projectId = 'test-project-id'
let provider = new W3mFrameProvider(projectId)
let provider = new W3mFrameProvider({ projectId, onTimeout: mockTimeout })

beforeEach(() => {
provider = new W3mFrameProvider(projectId)
provider = new W3mFrameProvider({ projectId })
provider['w3mFrame'].frameLoadPromise = Promise.resolve()
window.postMessage = vi.fn()
})
Expand Down Expand Up @@ -99,4 +101,20 @@ describe('W3mFrameProvider', () => {
expect(response).toEqual(responsePayload)
expect(postAppEventSpy).toHaveBeenCalled()
})

it(
'should timeout after 30 seconds',
async () => {
const postAppEventSpy = vi.spyOn(provider['w3mFrame'].events, 'postAppEvent')

const mockTimeoutSpy = vi.spyOn(provider, 'onTimeout')

await expect(provider.getFarcasterUri()).rejects.toThrow()

expect(postAppEventSpy).toHaveBeenCalled()

expect(mockTimeoutSpy).toHaveBeenCalled()
},
{ timeout: 35_000 }
)
})

0 comments on commit 422a15f

Please sign in to comment.