Skip to content

Commit

Permalink
Merge branch 'tu/abacus-ts-types' into tu/abacus-ts-2
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo committed Dec 12, 2024
2 parents 73d52e8 + 2487d1d commit a58d832
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/abacus-ts/lib/createStoreEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function createStoreEffect<T>(
lastCleanup = handleChange(thisValue);
}
});

return () => {
lastCleanup?.();
removeStoreListener();
Expand Down
4 changes: 1 addition & 3 deletions src/abacus-ts/rest/lib/indexerQueryStoreEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ export function createIndexerQueryStoreEffect<T, R>(
config: QuerySetupConfig<T, R>
) {
const fullSelector = createAppSelector(
selectWebsocketUrl,
selectIndexerUrl,
config.selector,
[selectWebsocketUrl, selectIndexerUrl, config.selector],
(wsUrl, indexerUrl, selectorResult) => ({
infrastructure: { wsUrl, indexerUrl },
queryData: selectorResult,
Expand Down
7 changes: 3 additions & 4 deletions src/abacus-ts/socketSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ import { getSelectedNetwork } from '@/state/appSelectors';
import { createAppSelector } from '@/state/appTypes';

const suffix = '/v4/ws';
export const selectWebsocketUrl = createAppSelector(getSelectedNetwork, (network) => {
export const selectWebsocketUrl = createAppSelector([getSelectedNetwork], (network) => {
const endpointsConfig: EndpointsConfig = ENVIRONMENT_CONFIG_MAP[network].endpoints;
return `${endpointsConfig.indexers[0]!.socket}${suffix}`;
});

export const selectIndexerUrl = createAppSelector(getSelectedNetwork, (network) => {
export const selectIndexerUrl = createAppSelector([getSelectedNetwork], (network) => {
const endpointsConfig: EndpointsConfig = ENVIRONMENT_CONFIG_MAP[network].endpoints;
return `${endpointsConfig.indexers[0]!.api}`;
});

export const selectParentSubaccountInfo = createAppSelector(
getUserWalletAddress,
getUserSubaccountNumber,
[getUserWalletAddress, getUserSubaccountNumber],
(wallet, subaccount) => ({ wallet, subaccount })
);
3 changes: 1 addition & 2 deletions src/abacus-ts/websocket/orderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ function orderbookWebsocketValue(
}

const selectMarketAndWsInfo = createAppSelector(
selectWebsocketUrl,
(state) => state.perpetuals.currentMarketId,
[selectWebsocketUrl, (state) => state.perpetuals.currentMarketId],
(wsUrl, currentMarketId) => ({ wsUrl, currentMarketId })
);

Expand Down
3 changes: 1 addition & 2 deletions src/abacus-ts/websocket/parentSubaccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ function accountWebsocketValue(
}

const selectParentSubaccount = createAppSelector(
selectWebsocketUrl,
selectParentSubaccountInfo,
[selectWebsocketUrl, selectParentSubaccountInfo],
(wsUrl, { wallet, subaccount }) => ({ wsUrl, wallet, subaccount })
);

Expand Down

0 comments on commit a58d832

Please sign in to comment.