/ scripts / deploy.ts
deploy.ts
 1  // import { ethers } from "hardhat";
 2  
 3  // async function main(): Promise<void> {
 4  
 5  
 6  //     // Deploy the Master contract
 7  //     // const MasterFactory = await ethers.getContractFactory("MasterFactory");
 8  //     // const masterFactory = await MasterFactory.deploy();
 9  //     // await masterFactory.waitForDeployment();
10  //     // console.log("MasterFactory deployed to:", masterFactory.target);
11  
12  //     // // // Our random user data
13  //     // const randomUsers = [
14  //     //     { name: "Alice A.", email: "alice@example.org", bio: "Bio for Alice" },
15  //     //     { name: "Bob B.", email: "bob@example.org", bio: "Bio for Bob" },
16  //     //     { name: "Eve E.", email: "eve@example.org", bio: "Bio for Eve" }
17  //     // ];
18  
19  //     // for (const user of randomUsers) {
20  
21  //     //     const tx = await masterFactory.deployUserProfile();
22  //     //     const receipt = await tx.wait();
23  
24  //     //     // // 3. Manually parse logs for 'DeployedUserProfile'
25  //     //     let userProfileAddress: string | undefined;
26  //     //     for (const log of receipt.logs) {
27  //     //         try {
28  //     //             const parsedLog = masterFactory.interface.parseLog(log);
29  //     //             if (parsedLog?.name === "DeployedUserProfile") {
30  //     //                 userProfileAddress = parsedLog.args.userProfileAddress;
31  //     //                 break;
32  //     //             }
33  //     //         } catch (err) {
34  //     //             // log doesn't match Master ABI
35  //     //         }
36  //     //     }
37  
38  //     //     if (!userProfileAddress) {
39  //     //         throw new Error("DeployedUserProfile event not found in transaction receipt");
40  //     //     }
41  
42  //     //     // 4. Now we have the new contract address, connect to UserProfile
43  //     //     const userProfile = await ethers.getContractAt("UserProfile", userProfileAddress);
44  
45  //     //     // 5. Set the user’s profile
46  //     //     const setProfileTx = await userProfile.setProfile(user.name, user.email, user.bio);
47  //     //     await setProfileTx.wait();
48  
49  //     //     console.log(`UserProfile deployed at ${userProfileAddress} | Set profile for: ${user.name}`);
50  //     // }
51  
52  //     // // 6. Finally, fetch all addresses from the master
53  //     // const allProfiles = await masterFactory.getAllUserProfiles();
54  
55  //     // console.log("");
56  //     // console.log("--------------------------------");
57  //     // console.log("Master factory smart contract address:", masterFactory.target);
58  //     // console.log("Profiles from master factory smart contract:", allProfiles);
59  //     // console.log("--------------------------------");
60  // }
61  
62  // main().catch((error: Error) => {
63  //     console.error(error);
64  //     process.exitCode = 1;
65  // });