Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: solana wallets not recognized as installed in all wallets list #3437

Merged
merged 3 commits into from
Dec 11, 2024
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
23 changes: 23 additions & 0 deletions .changeset/cyan-peaches-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit': patch
'@reown/appkit-core': patch
'@apps/builder': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-common': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-siwe': patch
'@reown/appkit-siwx': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
'@reown/appkit-wallet-button': patch
---

Fixes the Solana wallets not being recognized as installed in the all wallets list
2 changes: 1 addition & 1 deletion packages/adapters/solana/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
}

// Initialize Auth Provider if email/socials enabled
const emailEnabled = options.features?.email !== false

Check warning on line 77 in packages/adapters/solana/src/client.ts

View workflow job for this annotation

GitHub Actions / code_style (lint)

Variable name `emailEnabled` must have one of the following prefixes: is, has, can, should, will, did
const socialsEnabled =

Check warning on line 78 in packages/adapters/solana/src/client.ts

View workflow job for this annotation

GitHub Actions / code_style (lint)

Variable name `socialsEnabled` must have one of the following prefixes: is, has, can, should, will, did
options.features?.socials !== false &&
Array.isArray(options.features?.socials) &&
options.features.socials.length > 0
Expand Down Expand Up @@ -135,7 +135,7 @@
(...providers: WalletStandardProvider[]) => {
providers.forEach(provider => {
this.addConnector({
id: provider.name,
id: PresetsUtil.ConnectorExplorerIds[provider.name] || provider.name,
type: 'ANNOUNCED',
provider: provider as unknown as Provider,
imageUrl: provider.icon,
Expand Down
29 changes: 27 additions & 2 deletions packages/adapters/solana/src/tests/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, beforeEach, vi } from 'vitest'
import { CaipNetworksUtil } from '@reown/appkit-utils'
import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'
import { CaipNetworksUtil, PresetsUtil } from '@reown/appkit-utils'
import { solana } from '@reown/appkit/networks'
import type { ConnectorType, Provider } from '@reown/appkit-core'
import type { W3mFrameProvider } from '@reown/appkit-wallet'
Expand All @@ -8,6 +8,7 @@ import type { ChainNamespace } from '@reown/appkit-common'
import { SolanaAdapter } from '../client'
import { SolStoreUtil } from '../utils/SolanaStoreUtil'
import type { WalletStandardProvider } from '../providers/WalletStandardProvider'
import { watchStandard } from '../utils/watchStandard'

// Mock external dependencies
vi.mock('@solana/web3.js', () => ({
Expand All @@ -27,6 +28,10 @@ vi.mock('../utils/SolanaStoreUtil', () => ({
}
}))

vi.mock('../utils/watchStandard', () => ({
watchStandard: vi.fn()
}))

const mockProvider = {
connect: vi.fn().mockResolvedValue('mock-address'),
disconnect: vi.fn(),
Expand Down Expand Up @@ -192,4 +197,24 @@ describe('SolanaAdapter', () => {
expect(result).toBeDefined()
})
})

describe('SolanaAdapter - syncConnectors', () => {
it.each(['Phantom', 'Trust Wallet', 'Solflare', 'unknown wallet'])(
'should parse watchStandard ids from cloud',
walletName => {
adapter.syncConnectors({ features: { email: false, socials: false } } as any, {} as any)
const watchStandardSpy = watchStandard as Mock<typeof watchStandard>
const addProviderSpy = vi.spyOn(adapter as any, 'addConnector')

const callback = watchStandardSpy.mock.calls[0]![2]
callback({ name: walletName } as any)

expect(addProviderSpy).toHaveBeenCalledWith(
expect.objectContaining({
id: PresetsUtil.ConnectorExplorerIds[walletName] || walletName
})
)
}
)
})
})
Loading