Skip to content

Commit

Permalink
fix: remove names flow on settings view for solana namespace (#2989)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoruka authored Oct 2, 2024
1 parent 4e26add commit d40f978
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 2 deletions.
38 changes: 38 additions & 0 deletions .changeset/three-deers-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
'@reown/appkit-scaffold-ui': patch
'@apps/laboratory': patch
'@reown/appkit-core': patch
'@apps/demo': patch
'@apps/gallery': patch
'@examples/html-ethers': patch
'@examples/html-ethers5': patch
'@examples/html-wagmi': patch
'@examples/next-ethers': patch
'@examples/next-wagmi': patch
'@examples/react-ethers': patch
'@examples/react-ethers5': patch
'@examples/react-solana': patch
'@examples/react-wagmi': patch
'@examples/vue-ethers5': patch
'@examples/vue-solana': patch
'@examples/vue-wagmi': 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-ethers': patch
'@reown/appkit-ethers5': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-siwe': patch
'@reown/appkit-solana': patch
'@reown/appkit-ui': patch
'@reown/appkit-wagmi': patch
'@reown/appkit-wallet': patch
---

Disable names feature flow for Solana networks
6 changes: 6 additions & 0 deletions apps/laboratory/tests/email.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ emailTest('it should switch network and sign', async ({ library }) => {
await validator.expectAcceptedSign()
})

emailTest('it should show names feature only for EVM networks', async ({ library }) => {
await page.goToSettings()
await validator.expectNamesFeatureVisible(library !== 'solana')
await page.closeModal()
})

emailTest('it should show loading on page refresh', async () => {
await page.page.reload()
await validator.expectConnectButtonLoading()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,13 @@ export class ModalWalletValidator extends ModalValidator {
`${chainName} should be visible on approve transaction page`
).toBeTruthy()
}

async expectNamesFeatureVisible(visible: boolean) {
const namesFeature = this.page.getByTestId('account-choose-name-button')
if (visible) {
await expect(namesFeature, 'Names feature should be present').toBeVisible()
} else {
await expect(namesFeature, 'Names feature should not be present').toBeHidden()
}
}
}
9 changes: 9 additions & 0 deletions packages/core/src/controllers/NetworkController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ export const NetworkController = {
return Boolean(smartAccountEnabledNetworks?.includes(Number(networkId)))
},

checkIfNamesSupported() {
const activeCaipNetwork = ChainController.state.activeCaipNetwork

return (
activeCaipNetwork?.chainNamespace &&
ConstantsUtil.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(activeCaipNetwork.chainNamespace)
)
},

resetNetwork() {
const chain = ChainController.state.activeChain

Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/utils/ConstantsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ export const ConstantsUtil = {
'eip155:1313161554'
],

NAMES_SUPPORTED_CHAIN_NAMESPACES: ['eip155'] as ChainNamespace[],

NATIVE_TOKEN_ADDRESS: {
eip155: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
solana: 'So11111111111111111111111111111111111111111',
Expand Down
10 changes: 9 additions & 1 deletion packages/core/tests/controllers/NetworkController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ describe('NetworkController', () => {
})
})

it('should check if network supports names feature', () => {
NetworkController.resetNetwork()
NetworkController.setActiveCaipNetwork(caipNetwork)
expect(NetworkController.checkIfNamesSupported()).toEqual(true)
NetworkController.setActiveCaipNetwork(solanaCaipNetwork)
expect(NetworkController.checkIfNamesSupported()).toEqual(false)
})

it('should get correct active network token address', () => {
let mock = vi
.spyOn(ChainController.state, 'activeCaipNetwork', 'get')
Expand All @@ -152,6 +160,6 @@ describe('NetworkController', () => {
'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:So11111111111111111111111111111111111111111'
)

mock.mockClear()
mock.mockRestore()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export class W3mAccountSettingsView extends LitElement {
private chooseNameButtonTemplate() {
const type = StorageUtil.getConnectedConnector()
const authConnector = ConnectorController.getAuthConnector()
if (!authConnector || type !== 'AUTH' || this.profileName) {
const hasNetworkSupport = NetworkController.checkIfNamesSupported()
if (!hasNetworkSupport || !authConnector || type !== 'AUTH' || this.profileName) {
return null
}

Expand Down

0 comments on commit d40f978

Please sign in to comment.