Skip to content

Commit 5275fd7

Browse files
committed
[Update] Add ModularExt support and refactor modules detection (#4417)
<!-- start pr-codex --> ## PR-Codex overview The focus of this PR is to introduce the `ModularExt` extension and refactor the `detectedModularExtension` logic in the `useContractRouteConfig` hook. ### Detailed summary - Added `ModularExt` import - Refactored `detectedModularExtension` logic to `isModularCore` - Updated `isEnabled` logic for 'Modules' section to use `isModularCore` - Removed unnecessary code related to `detectedModularExtension` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 3c50597 commit 5275fd7

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

apps/dashboard/src/contract-ui/hooks/useRouteConfig.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as ERC20Ext from "thirdweb/extensions/erc20";
1111
import * as ERC721Ext from "thirdweb/extensions/erc721";
1212
import * as ERC1155Ext from "thirdweb/extensions/erc1155";
1313
import * as ERC4337Ext from "thirdweb/extensions/erc4337";
14+
import * as ModularExt from "thirdweb/extensions/modular";
1415
import * as PermissionExt from "thirdweb/extensions/permissions";
1516
import * as ThirdwebExt from "thirdweb/extensions/thirdweb";
1617
import { useReadContract } from "thirdweb/react";
@@ -221,6 +222,13 @@ export function useContractRouteConfig(
221222
hasERC1155ClaimConditions,
222223
]);
223224

225+
const isModularCore = useMemo(() => {
226+
return [
227+
ModularExt.isGetInstalledModulesSupported(functionSelectorQuery.data),
228+
ModularExt.isInstallModuleSupported(functionSelectorQuery.data),
229+
].every(Boolean);
230+
}, [functionSelectorQuery.data]);
231+
224232
// old
225233
const ensQuery = useEns(contract.address);
226234

@@ -238,17 +246,9 @@ export function useContractRouteConfig(
238246
feature: "DirectListings",
239247
});
240248

241-
const detectedModularExtension = extensionDetectedState({
242-
contractQuery,
243-
feature: ["ModularCore"],
244-
});
245-
246-
// claim condition related stuff
247-
248249
return {
249250
detectedEnglishAuctions,
250251
detectedDirectListings,
251-
detectedModularExtension,
252252
};
253253
}, [contractQuery]);
254254

@@ -301,13 +301,17 @@ export function useContractRouteConfig(
301301
isPermissionsEnumerable={isPermissionsEnumerable}
302302
/>
303303
),
304-
isEnabled: contractQuery.isLoading ? "loading" : "enabled",
304+
isEnabled: "enabled",
305305
isDefault: true,
306306
},
307307
{
308308
title: "Modules",
309309
path: "modules",
310-
isEnabled: contractData.detectedModularExtension,
310+
isEnabled: isModularCore
311+
? "enabled"
312+
: functionSelectorQuery.isLoading
313+
? "loading"
314+
: "disabled",
311315
isDefault: true,
312316
component: LazyContractEditModulesPage,
313317
},

0 commit comments

Comments
 (0)