Skip to content

Commit

Permalink
fix: v5 connectors not appearing on solana (#2979)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoruka authored Oct 2, 2024
1 parent 7d3542e commit 63d4e2d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/base/adapters/solana/web3js/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,11 @@ export class SolanaWeb3JsClient implements ChainAdapter<SolStoreUtilState, CaipN
type: provider.type,
imageUrl: provider.icon,
name: provider.name,
provider,
/**
* When the provider is different from 'AUTH', we don't need to pass it to the connector.
* This avoids issues with the valtio proxy and non-serializable state and follows same logic from other clients.
*/
provider: provider.type === 'AUTH' ? provider : undefined,
chain: CommonConstantsUtil.CHAIN.SOLANA,
...provider.auth
}))
Expand Down
24 changes: 23 additions & 1 deletion packages/core/src/controllers/ConnectorController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,29 @@ export const ConnectorController = {

setConnectors(connectors: ConnectorControllerState['connectors']) {
connectors.forEach(this.syncIfAuthConnector)
state.unMergedConnectors = [...state.unMergedConnectors, ...connectors]
state.unMergedConnectors = [...state.unMergedConnectors, ...connectors].filter(connector => {
/**
* This is a fix for non-serializable objects that may prevent all the connectors in the list from being displayed
* Check more about this issue on https://valtio.dev/docs/api/basic/proxy#Gotchas
*/
try {
const canProxyConnector = Boolean(proxy(connector))

if (!canProxyConnector) {
throw new Error('Connector is not available')
}

return true
} catch (error) {
// eslint-disable-next-line no-console
console.error('ConnectorController.setConnectors: Not possible to add connector', {
connector,
error
})

return false
}
})
state.connectors = this.mergeMultiChainConnectors(state.unMergedConnectors)
},

Expand Down

0 comments on commit 63d4e2d

Please sign in to comment.