From f0b953fb7173b6e00a58799ce998e4b56c07d7da Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Wed, 6 Mar 2024 15:00:51 +0000 Subject: [PATCH] fix: check for on/off methods before calling --- libs/wallet/src/connectors/injected-connector.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/wallet/src/connectors/injected-connector.ts b/libs/wallet/src/connectors/injected-connector.ts index 7f05e3e83..285461524 100644 --- a/libs/wallet/src/connectors/injected-connector.ts +++ b/libs/wallet/src/connectors/injected-connector.ts @@ -116,11 +116,19 @@ export class InjectedConnector implements Connector { } on(event: VegaWalletEvent, callback: () => void) { - window.vega.on(event, callback); + // Check for on/off in case user is on older versions which don't support it + // We can remove this check once FF is at the latest version + if ('on' in window.vega && typeof window.vega.on === 'function') { + window.vega.on(event, callback); + } } off(event: VegaWalletEvent, callback: () => void) { - window.vega.off(event, callback); + // Check for on/off in case user is on older versions which don't support it + // We can remove this check once FF is at the latest version + if ('off' in window.vega && typeof window.vega.on === 'function') { + window.vega.off(event, callback); + } } private isInjectedError(obj: unknown): obj is InjectedError {