Skip to content

Commit 4c1f384

Browse files
authored
Fix dynamic contract publish (#6729)
1 parent ec099a7 commit 4c1f384

File tree

3 files changed

+118
-5
lines changed

3 files changed

+118
-5
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[
22
"function addExtension(((string name, string metadataURI, address implementation) metadata, (bytes4 functionSelector, string functionSignature)[] functions) extension)",
3-
"function removeExtension(string extensionName)"
3+
"function removeExtension(string extensionName)",
4+
"function getAllExtensions() view returns (((string name, string metadataURI, address implementation) metadata, (bytes4 functionSelector, string functionSignature)[] functions)[])"
45
]

packages/thirdweb/src/extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.ts

Lines changed: 104 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/thirdweb/write/publish.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ThirdwebClient } from "../../../client/client.js";
55
import { ZERO_ADDRESS } from "../../../constants/addresses.js";
66
import { getContract } from "../../../contract/contract.js";
77
import { CONTRACT_PUBLISHER_ADDRESS } from "../../../contract/deployment/publisher.js";
8+
import { isGetAllExtensionsSupported } from "../../../extensions/dynamic-contracts/__generated__/IExtensionManager/read/getAllExtensions.js";
89
import { download } from "../../../storage/download.js";
910
import { upload } from "../../../storage/upload.js";
1011
import type { BaseTransactionOptions } from "../../../transaction/types.js";
@@ -79,8 +80,14 @@ export function publishContract(
7980
compositeAbi: options.metadata.compositeAbi,
8081
constructorParams: options.metadata.constructorParams,
8182
implConstructorParams: options.metadata.implConstructorParams,
82-
defaultExtensions: options.metadata.defaultExtensions,
83-
defaultModules: options.metadata.defaultModules,
83+
defaultExtensions:
84+
routerType === "dynamic"
85+
? options.metadata.defaultExtensions
86+
: undefined,
87+
defaultModules:
88+
routerType === "modular"
89+
? options.metadata.defaultModules
90+
: undefined,
8491
deployType: options.metadata.deployType,
8592
description: options.metadata.description,
8693
displayName: options.metadata.displayName,
@@ -131,6 +138,7 @@ function getRouterType(abi: Abi) {
131138
.filter((f) => f.type === "function")
132139
.map((f) => toFunctionSelector(f));
133140
const isModule = isGetInstalledModulesSupported(fnSelectors);
134-
// TODO add dynamic detection
135-
return isModule ? "modular" : "none";
141+
const isDynamic = isGetAllExtensionsSupported(fnSelectors);
142+
143+
return isModule ? "modular" : isDynamic ? "dynamic" : "none";
136144
}

0 commit comments

Comments
 (0)