@@ -143,6 +143,10 @@ async function getTransactionsForImplementation(options: {
143143 return getTransactionsForMaketplaceV3 ( options ) ;
144144 }
145145
146+ if ( deployMetadata . routerType === "dynamic" ) {
147+ return getTransactionsForDynamicContract ( options ) ;
148+ }
149+
146150 const constructorParams =
147151 implementationConstructorParams ??
148152 ( await getAllDefaultConstructorParamsForImplementation ( {
@@ -223,6 +227,55 @@ async function getTransactionsForMaketplaceV3(options: {
223227 return transactions ;
224228}
225229
230+ async function getTransactionsForDynamicContract ( options : {
231+ chain : Chain ;
232+ client : ThirdwebClient ;
233+ deployMetadata : FetchDeployMetadataResult ;
234+ } ) : Promise < DeployTransactionResult [ ] > {
235+ const { chain, client } = options ;
236+ const WETHAdress = await computePublishedContractAddress ( {
237+ chain,
238+ client,
239+ contractId : "WETH9" ,
240+ } ) ;
241+ const wethTx = await getDeployedInfraContract ( {
242+ chain,
243+ client,
244+ contractId : "WETH9" ,
245+ } ) . then ( ( c ) =>
246+ c ? null : ( { type : "infra" , contractId : "WETH9" } as const ) ,
247+ ) ;
248+ console . log ( options . deployMetadata . defaultExtensions ) ;
249+ const extensions : ( DeployTransactionResult | null ) [ ] = options . deployMetadata
250+ . defaultExtensions
251+ ? await Promise . all (
252+ options . deployMetadata . defaultExtensions . map ( ( e ) => {
253+ return getDeployedInfraContract ( {
254+ chain,
255+ client,
256+ contractId : e . extensionName ,
257+ publisher : e . publisherAddress ,
258+ version : e . extensionVersion || "latest" ,
259+ constructorParams : { _nativeTokenWrapper : WETHAdress } ,
260+ } ) . then ( ( c ) =>
261+ c
262+ ? null
263+ : ( { type : "extension" , contractId : e . extensionName } as const ) ,
264+ ) ;
265+ } ) ,
266+ )
267+ : [ ] ;
268+ // hacky assumption: if we need to deploy any of the extensions, we also need to deploy the implementation
269+ const transactions = [ ...extensions , wethTx ] . filter ( ( e ) => e !== null ) ;
270+ if ( transactions . length ) {
271+ transactions . push ( {
272+ type : "implementation" ,
273+ contractId : options . deployMetadata . name ,
274+ } ) ;
275+ }
276+ return transactions ;
277+ }
278+
226279/**
227280 * Gets the default constructor parameters required for contract implementation deployment
228281 * @param args - The arguments object
0 commit comments