Skip to content

Commit 586a51e

Browse files
committed
Address feedback.
Signed-off-by: bgravenorst <[email protected]>
1 parent 3e71233 commit 586a51e

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/plugins/plugin-json-rpc.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export interface ResponseItem {
77
error: Error | null | boolean;
88
}
99

10+
interface MethodItem {
11+
name: string;
12+
}
13+
1014
// Method sorting configuration
1115
const METHOD_SORT_PRIORITIES = {
1216
wallet_: 1, // Highest priority - appears first
@@ -19,16 +23,6 @@ const METHOD_SORT_PRIORITIES = {
1923

2024
const METHOD_SORT_CONFIG = {
2125
priorities: METHOD_SORT_PRIORITIES,
22-
// Optional: Custom sort function for special cases
23-
customSort: null,
24-
// Optional: Group labels for future use
25-
groupLabels: {
26-
wallet_: "Wallet Methods",
27-
eth_: "Ethereum Methods",
28-
personal_: "Personal Methods",
29-
web3_: "Web3 Methods",
30-
default: "Other Methods",
31-
},
3226
};
3327

3428
// Helper function to extract method prefix
@@ -38,7 +32,7 @@ const getMethodPrefix = (methodName: string): string => {
3832
};
3933

4034
// Sort methods by priority group, then alphabetically within each group
41-
const sortMethods = (items: any[], sortConfig = METHOD_SORT_CONFIG) => {
35+
const sortMethods = (items: MethodItem[], sortConfig = METHOD_SORT_CONFIG) => {
4236
return [...items].sort((a, b) => {
4337
const aPrefix = getMethodPrefix(a.name);
4438
const bPrefix = getMethodPrefix(b.name);
@@ -94,7 +88,11 @@ const requests = [
9488
},
9589
];
9690

97-
export const prepareLinkItems = (items, refPath, sortConfig = METHOD_SORT_CONFIG) => {
91+
export const prepareLinkItems = (
92+
items: MethodItem[],
93+
refPath: string,
94+
sortConfig = METHOD_SORT_CONFIG
95+
): { type: string; label: string; href: string }[] => {
9896
const sortedItems = sortMethods(items, sortConfig);
9997

10098
return sortedItems.map(method => ({
@@ -137,8 +135,8 @@ export default function useNetworksMethodPlugin() {
137135
"methodsData.json",
138136
JSON.stringify(dynamicRoutes.data.methods)
139137
);
140-
dynamicRoutes.data.methods.forEach(async method => {
141-
return addRoute({
138+
for (const method of dynamicRoutes.data.methods) {
139+
await addRoute({
142140
path: `/${MM_REF_PATH}/${method.name.toLowerCase()}`,
143141
component: require.resolve("../components/CustomReferencePage/index.tsx"),
144142
modules: {
@@ -147,7 +145,7 @@ export default function useNetworksMethodPlugin() {
147145
exact: true,
148146
customData: { ...method, networkName: NETWORK_NAMES.metamask },
149147
});
150-
});
148+
}
151149
}
152150
},
153151
configureWebpack() {

0 commit comments

Comments
 (0)