diff --git a/libs/wallet/src/connectors/injected-connector.ts b/libs/wallet/src/connectors/injected-connector.ts index 4b3d5ee77..d5e639712 100644 --- a/libs/wallet/src/connectors/injected-connector.ts +++ b/libs/wallet/src/connectors/injected-connector.ts @@ -1,14 +1,10 @@ import { clearConfig, setConfig } from '../storage'; import type { Transaction, VegaConnector } from './vega-connector'; -type VegaWalletEvent = 'disconnect'; +type VegaWalletEvent = 'client.disconnected'; declare global { interface Vega { - /** - * @deprecated - */ - getChainId: () => Promise<{ chainID: string }>; connectWallet: (args: { chainId: string }) => Promise; disconnectWallet: () => Promise; listKeys: () => Promise<{ @@ -59,13 +55,6 @@ export class InjectedConnector implements VegaConnector { chainId: string | null = null; description = 'Connects using the Vega wallet browser extension'; - /** - * @deprecated - */ - async getChainId() { - return window.vega.getChainId(); - } - async connectWallet(chainId: string) { this.chainId = chainId; try { @@ -79,7 +68,7 @@ export class InjectedConnector implements VegaConnector { } onDisconnect(cb: () => void) { - window.vega.on('client.disconnect', () => { + window.vega.on('client.disconnected', () => { this.isConnected = false; cb(); }); diff --git a/libs/wallet/src/use-injected-connector.ts b/libs/wallet/src/use-injected-connector.ts index e66ae7a04..094d3052c 100644 --- a/libs/wallet/src/use-injected-connector.ts +++ b/libs/wallet/src/use-injected-connector.ts @@ -40,11 +40,13 @@ export const useInjectedConnector = (onConnect: () => void) => { connector.nodeAddress = new URL(vegaUrl).origin; } - setStatus(Status.GettingChainId); - - const { chainID } = await connector.getChainId(); - if (chainID !== appChainId) { - throw InjectedConnectorErrors.INVALID_CHAIN; + // check the chain id for snap connector + if (connector instanceof SnapConnector) { + setStatus(Status.GettingChainId); + const { chainID } = await connector.getChainId(); + if (chainID !== appChainId) { + throw InjectedConnectorErrors.INVALID_CHAIN; + } } setStatus(Status.Connecting);