|
1 | 1 | import type { ThirdwebContract } from "../../../contract/contract.js"; |
2 | 2 | import { getOrDeployInfraForPublishedContract } from "../../../contract/deployment/utils/bootstrap.js"; |
3 | 3 | import type { Account } from "../../../wallets/interfaces/wallet.js"; |
| 4 | +import { deployPublishedContract } from "../../prebuilts/deploy-published.js"; |
4 | 5 | import { installModule } from "../__generated__/IModularCore/write/installModule.js"; |
5 | 6 |
|
6 | 7 | /** |
@@ -49,17 +50,35 @@ export function installPublishedModule(options: InstallPublishedModuleOptions) { |
49 | 50 |
|
50 | 51 | return installModule({ |
51 | 52 | asyncParams: async () => { |
52 | | - const deployedModule = await getOrDeployInfraForPublishedContract({ |
53 | | - account, |
54 | | - chain: contract.chain, |
55 | | - client: contract.client, |
56 | | - constructorParams, |
57 | | - contractId: moduleName, |
58 | | - publisher, |
59 | | - }); |
| 53 | + let implementationAddress: string; |
| 54 | + |
| 55 | + if (moduleName.toLowerCase().includes("stylus")) { |
| 56 | + // TODO: switch to deterministic / create2 when available |
| 57 | + |
| 58 | + implementationAddress = await deployPublishedContract({ |
| 59 | + account, |
| 60 | + chain: contract.chain, |
| 61 | + client: contract.client, |
| 62 | + contractParams: constructorParams, |
| 63 | + contractId: moduleName, |
| 64 | + publisher, |
| 65 | + }); |
| 66 | + } else { |
| 67 | + const deployedModule = await getOrDeployInfraForPublishedContract({ |
| 68 | + account, |
| 69 | + chain: contract.chain, |
| 70 | + client: contract.client, |
| 71 | + constructorParams, |
| 72 | + contractId: moduleName, |
| 73 | + publisher, |
| 74 | + }); |
| 75 | + |
| 76 | + implementationAddress = deployedModule.implementationContract |
| 77 | + .address as string; |
| 78 | + } |
60 | 79 | return { |
61 | 80 | data: moduleData || "0x", |
62 | | - moduleContract: deployedModule.implementationContract.address as string, |
| 81 | + moduleContract: implementationAddress, |
63 | 82 | }; |
64 | 83 | }, |
65 | 84 | contract, |
|
0 commit comments