Skip to content

Commit

Permalink
fix: solana wallets not recognized as installed in all wallets list (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zoruka authored Dec 11, 2024
1 parent 2a7a963 commit 4d2ddad
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
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 @@ -135,7 +135,7 @@ export class SolanaAdapter extends AdapterBlueprint {
(...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
})
)
}
)
})
})

0 comments on commit 4d2ddad

Please sign in to comment.