Skip to content

Commit

Permalink
chore: flag for disabling abacus (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo authored Dec 20, 2024
1 parent 3eff5ab commit 112ce26
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lib/abacus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { LocalWallet, SelectedGasDenom } from '@dydxprotocol/v4-client-js';

import type {
AbacusStateNotificationProtocol,
AdjustIsolatedMarginInputFields,
ClosePositionInputFields,
HistoricalPnlPeriods,
Expand Down Expand Up @@ -64,14 +65,15 @@ import { getTransferInputs } from '@/state/inputsSelectors';

import { assertNever } from '../assertNever';
import { LocaleSeparators } from '../numbers';
import { testFlags } from '../testFlags';
import AbacusAnalytics from './analytics';
import AbacusChainTransaction from './dydxChainTransactions';
import AbacusFileSystem from './filesystem';
import AbacusFormatter from './formatter';
import AbacusLocalizer from './localizer';
import AbacusLogger from './logger';
import AbacusRest from './rest';
import AbacusStateNotifier from './stateNotification';
import AbacusStateNotifier, { NoOpAbacusStateNotifier } from './stateNotification';
import AbacusThreading from './threading';
import AbacusWebsocket from './websocket';

Expand Down Expand Up @@ -102,7 +104,7 @@ class AbacusStateManager {

websocket: AbacusWebsocket;

stateNotifier: AbacusStateNotifier;
stateNotifier: AbacusStateNotificationProtocol & { setStore: (store: RootStore) => void };

analytics: AbacusAnalytics;

Expand All @@ -113,7 +115,9 @@ class AbacusStateManager {
constructor() {
this.store = undefined;
this.currentMarket = undefined;
this.stateNotifier = new AbacusStateNotifier();
this.stateNotifier = testFlags.disableAbacus
? new NoOpAbacusStateNotifier()
: new AbacusStateNotifier();
this.analytics = new AbacusAnalytics();
this.websocket = new AbacusWebsocket();
this.abacusFormatter = new AbacusFormatter();
Expand Down Expand Up @@ -153,6 +157,7 @@ class AbacusStateManager {
}

start = ({ network }: { network?: DydxNetwork } = {}) => {
if (testFlags.disableAbacus) return;
if (network) {
this.stateManager.environmentId = network;
}
Expand All @@ -162,6 +167,7 @@ class AbacusStateManager {
};

restart = ({ network }: { network?: DydxNetwork } = {}) => {
if (testFlags.disableAbacus) return;
this.stateManager.readyToConnect = false;
this.start({ network });
};
Expand Down
17 changes: 17 additions & 0 deletions src/lib/abacus/stateNotification.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line max-classes-per-file
import { kollections } from '@dydxprotocol/v4-abacus';
import { fromPairs, throttle } from 'lodash';

Expand Down Expand Up @@ -286,3 +287,19 @@ class AbacusStateNotifier implements AbacusStateNotificationProtocol {
}

export default AbacusStateNotifier;

export class NoOpAbacusStateNotifier implements AbacusStateNotificationProtocol {
environmentsChanged(): void {}

notificationsChanged(): void {}

stateChanged(): void {}

lastOrderChanged() {}

errorsEmitted() {}

apiStateChanged() {}

setStore = () => {};
}
4 changes: 4 additions & 0 deletions src/lib/testFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class TestFlags {
return isDev;
}

get disableAbacus() {
return this.booleanFlag(this.queryParams.disable_abacus);
}

get showNewDepositFlow() {
return !!this.queryParams.deposit_rewrite;
}
Expand Down

0 comments on commit 112ce26

Please sign in to comment.