Skip to content

Commit eed1348

Browse files
authored
reduce service worker bundle size (#4260)
1 parent 92ef546 commit eed1348

File tree

2 files changed

+32
-41
lines changed

2 files changed

+32
-41
lines changed

packages/background/src/backend/core.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import {
1919
DEFAULT_DARK_MODE,
2020
defaultPreferences,
2121
deserializeTransaction,
22-
EthereumConnectionUrl,
23-
EthereumExplorer,
2422
getAccountRecoveryPaths,
2523
getAddMessage,
2624
getRecoveryPaths,
@@ -60,11 +58,17 @@ import {
6058
NOTIFICATION_USER_ACCOUNT_PUBLIC_KEY_DELETED,
6159
NOTIFICATION_USER_ACCOUNT_PUBLIC_KEYS_UPDATED,
6260
NOTIFICATION_XNFT_PREFERENCE_UPDATED,
61+
TAB_APPS,
62+
TAB_BALANCES,
6363
TAB_BALANCES_SET,
64+
TAB_MESSAGES,
65+
TAB_NFTS,
66+
TAB_NOTIFICATIONS,
67+
TAB_RECENT_ACTIVITY,
68+
TAB_SWAP,
6469
TAB_TOKENS,
6570
TAB_XNFT,
6671
} from "@coral-xyz/common";
67-
import { makeDefaultNav } from "@coral-xyz/recoil";
6872
import type {
6973
BlockchainKeyring,
7074
KeyringStore,
@@ -2068,6 +2072,30 @@ export class Backend {
20682072
export const SUCCESS_RESPONSE = "success";
20692073
const defaultNav = makeDefaultNav();
20702074

2075+
function makeDefaultNav() {
2076+
const defaultNav: any = {
2077+
activeTab: TAB_TOKENS,
2078+
data: {},
2079+
};
2080+
[
2081+
[TAB_BALANCES, "Balances"],
2082+
[TAB_NFTS, "Nfts"],
2083+
[TAB_SWAP, "Swap"],
2084+
[TAB_APPS, "Apps"],
2085+
[TAB_MESSAGES, "Messages"],
2086+
[TAB_RECENT_ACTIVITY, "Recent Activity"],
2087+
[TAB_NOTIFICATIONS, "Notifications"],
2088+
[TAB_TOKENS, "Tokens"],
2089+
].forEach(([tabName, tabTitle]) => {
2090+
defaultNav.data[tabName] = {
2091+
id: tabName,
2092+
urls: [makeUrl(tabName, { title: tabTitle, props: {} })],
2093+
ref: tabName === "balances" ? "tokens" : undefined,
2094+
};
2095+
});
2096+
return defaultNav;
2097+
}
2098+
20712099
function setSearchParam(url: string, key: string, value: string): string {
20722100
const [path, search] = url.split("?");
20732101
const searchParams = new URLSearchParams(search);

packages/recoil/src/types.ts

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
import {
2-
type Blockchain,
3-
makeUrl,
4-
TAB_APPS,
5-
TAB_BALANCES,
6-
TAB_MESSAGES,
7-
TAB_NFTS,
8-
TAB_NOTIFICATIONS,
9-
TAB_RECENT_ACTIVITY,
10-
TAB_SWAP,
11-
TAB_TOKENS,
12-
} from "@coral-xyz/common";
1+
import { type Blockchain } from "@coral-xyz/common";
132
import type { BigNumber } from "ethers";
143
import type { RecoilValueReadOnly } from "recoil";
154

@@ -86,32 +75,6 @@ export interface TokenMetadata {
8675
symbol: string;
8776
}
8877

89-
export const TABS = [
90-
[TAB_BALANCES, "Balances"],
91-
[TAB_NFTS, "Nfts"],
92-
[TAB_SWAP, "Swap"],
93-
[TAB_APPS, "Apps"],
94-
[TAB_MESSAGES, "Messages"],
95-
[TAB_RECENT_ACTIVITY, "Recent Activity"],
96-
[TAB_NOTIFICATIONS, "Notifications"],
97-
[TAB_TOKENS, "Tokens"],
98-
];
99-
100-
export function makeDefaultNav() {
101-
const defaultNav: any = {
102-
activeTab: TAB_TOKENS,
103-
data: {},
104-
};
105-
TABS.forEach(([tabName, tabTitle]) => {
106-
defaultNav.data[tabName] = {
107-
id: tabName,
108-
urls: [makeUrl(tabName, { title: tabTitle, props: {} })],
109-
ref: tabName === "balances" ? "tokens" : undefined,
110-
};
111-
});
112-
return defaultNav;
113-
}
114-
11578
export type ExtractRecoilType<P> = P extends RecoilValueReadOnly<infer T>
11679
? T
11780
: never;

0 commit comments

Comments
 (0)