Skip to content

Commit 64ca579

Browse files
committed
updated to be promise.allSettled when installing modules to not block deployment of the contract
1 parent 6b9dd33 commit 64ca579

File tree

1 file changed

+56
-45
lines changed

1 file changed

+56
-45
lines changed

apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,27 @@ import { CircleAlertIcon, ExternalLinkIcon, InfoIcon } from "lucide-react";
2626
import Link from "next/link";
2727
import { useCallback, useMemo } from "react";
2828
import { FormProvider, type UseFormReturn, useForm } from "react-hook-form";
29-
import { ZERO_ADDRESS, getContract } from "thirdweb";
29+
import {
30+
ZERO_ADDRESS,
31+
getContract,
32+
sendTransaction,
33+
waitForReceipt,
34+
} from "thirdweb";
3035
import type { FetchDeployMetadataResult } from "thirdweb/contract";
3136
import {
3237
deployContractfromDeployMetadata,
3338
deployMarketplaceContract,
3439
getRequiredTransactions,
3540
} from "thirdweb/deploys";
41+
import { installPublishedModule } from "thirdweb/modules";
3642
import { useActiveAccount, useActiveWalletChain } from "thirdweb/react";
3743
import { upload } from "thirdweb/storage";
38-
import { concatHex, padHex } from "thirdweb/utils";
44+
import {
45+
type AbiFunction,
46+
concatHex,
47+
encodeAbiParameters,
48+
padHex,
49+
} from "thirdweb/utils";
3950
import { FormHelperText, FormLabel, Heading, Text } from "tw-components";
4051
import { useCustomFactoryAbi, useFunctionParamsFromABI } from "../hooks";
4152
import { addContractToMultiChainRegistry } from "../utils";
@@ -469,49 +480,49 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
469480
});
470481
console.log("core contract", coreContract);
471482

472-
//if (isSuperchainInterop && moduleDeployData) {
473-
// await Promise.all(
474-
// moduleDeployData.map(async (m) => {
475-
// let moduleData: `0x${string}` | undefined;
476-
//
477-
// const moduleInstallParams = m.deployMetadata.abi.find(
478-
// (abiType) =>
479-
// (abiType as AbiFunction).name === "encodeBytesOnInstall",
480-
// ) as AbiFunction | undefined;
481-
//
482-
// if (m.initializeParams && moduleInstallParams) {
483-
// moduleData = encodeAbiParameters(
484-
// (
485-
// moduleInstallParams.inputs as { name: string; type: string }[]
486-
// ).map((p) => ({
487-
// name: p.name,
488-
// type: p.type,
489-
// })),
490-
// Object.values(m.initializeParams),
491-
// );
492-
// }
493-
// console.log("module install params", moduleInstallParams);
494-
//
495-
// const installTransaction = installPublishedModule({
496-
// contract: coreContract,
497-
// account: activeAccount,
498-
// moduleName: m.deployMetadata.name,
499-
// publisher: m.deployMetadata.publisher,
500-
// version: m.deployMetadata.version,
501-
// moduleData,
502-
// });
503-
// console.log("install transaction", installTransaction);
504-
//
505-
// const txResult = await sendTransaction({
506-
// transaction: installTransaction,
507-
// account: activeAccount,
508-
// });
509-
// console.log("tx result", txResult);
510-
//
511-
// return await waitForReceipt(txResult);
512-
// }),
513-
// );
514-
//}
483+
if (isSuperchainInterop && moduleDeployData) {
484+
await Promise.allSettled(
485+
moduleDeployData.map(async (m) => {
486+
let moduleData: `0x${string}` | undefined;
487+
488+
const moduleInstallParams = m.deployMetadata.abi.find(
489+
(abiType) =>
490+
(abiType as AbiFunction).name === "encodeBytesOnInstall",
491+
) as AbiFunction | undefined;
492+
493+
if (m.initializeParams && moduleInstallParams) {
494+
moduleData = encodeAbiParameters(
495+
(
496+
moduleInstallParams.inputs as { name: string; type: string }[]
497+
).map((p) => ({
498+
name: p.name,
499+
type: p.type,
500+
})),
501+
Object.values(m.initializeParams),
502+
);
503+
}
504+
console.log("module install params", moduleInstallParams);
505+
506+
const installTransaction = installPublishedModule({
507+
contract: coreContract,
508+
account: activeAccount,
509+
moduleName: m.deployMetadata.name,
510+
publisher: m.deployMetadata.publisher,
511+
version: m.deployMetadata.version,
512+
moduleData,
513+
});
514+
console.log("install transaction", installTransaction);
515+
516+
const txResult = await sendTransaction({
517+
transaction: installTransaction,
518+
account: activeAccount,
519+
});
520+
console.log("tx result", txResult);
521+
522+
return await waitForReceipt(txResult);
523+
}),
524+
);
525+
}
515526

516527
return coreContractAddress;
517528
},

0 commit comments

Comments
 (0)