@@ -26,7 +26,10 @@ import { zkDeployProxy } from "./zksync/zkDeployProxy.js";
2626export function prepareAutoFactoryDeployTransaction (
2727 args : ClientAndChain & {
2828 cloneFactoryContract : ThirdwebContract ;
29- initializeTransaction : PreparedTransaction ;
29+ initializeTransaction ?: PreparedTransaction ;
30+ initializeData ?: `0x${string } `;
31+ implementationAddress ?: string ;
32+ isCrosschain ?: boolean ;
3033 salt ?: string ;
3134 } ,
3235) {
@@ -44,6 +47,25 @@ export function prepareAutoFactoryDeployTransaction(
4447 : toHex ( blockNumber , {
4548 size : 32 ,
4649 } ) ;
50+
51+ if ( args . isCrosschain ) {
52+ if ( ! args . initializeData || ! args . implementationAddress ) {
53+ throw new Error (
54+ "initializeData or implementationAddress can't be undefined" ,
55+ ) ;
56+ }
57+
58+ return {
59+ data : args . initializeData ,
60+ implementation : args . implementationAddress ,
61+ salt,
62+ } as const ;
63+ }
64+
65+ if ( ! args . initializeTransaction ) {
66+ throw new Error ( "initializeTransaction can't be undefined" ) ;
67+ }
68+
4769 const implementation = await resolvePromisedValue (
4870 args . initializeTransaction . to ,
4971 ) ;
@@ -65,7 +87,10 @@ export function prepareAutoFactoryDeployTransaction(
6587export async function deployViaAutoFactory (
6688 options : ClientAndChainAndAccount & {
6789 cloneFactoryContract : ThirdwebContract ;
68- initializeTransaction : PreparedTransaction ;
90+ initializeTransaction ?: PreparedTransaction ;
91+ initializeData ?: `0x${string } `;
92+ implementationAddress ?: string ;
93+ isCrosschain ?: boolean ;
6994 salt ?: string ;
7095 } ,
7196) : Promise < string > {
@@ -75,10 +100,16 @@ export async function deployViaAutoFactory(
75100 account,
76101 cloneFactoryContract,
77102 initializeTransaction,
103+ initializeData,
104+ implementationAddress,
105+ isCrosschain,
78106 salt,
79107 } = options ;
80108
81109 if ( await isZkSyncChain ( chain ) ) {
110+ if ( ! initializeTransaction ) {
111+ throw new Error ( "initializeTransaction can't be undefined" ) ;
112+ }
82113 return zkDeployProxy ( {
83114 chain,
84115 client,
@@ -94,6 +125,9 @@ export async function deployViaAutoFactory(
94125 client,
95126 cloneFactoryContract,
96127 initializeTransaction,
128+ initializeData,
129+ implementationAddress,
130+ isCrosschain,
97131 salt,
98132 } ) ;
99133 const receipt = await sendAndConfirmTransaction ( {
@@ -116,59 +150,3 @@ export async function deployViaAutoFactory(
116150 }
117151 return decodedEvent [ 0 ] ?. args . proxy ;
118152}
119-
120- /**
121- * @internal
122- */
123- export async function deployViaAutoFactoryWithImplementationParams (
124- options : ClientAndChainAndAccount & {
125- cloneFactoryContract : ThirdwebContract ;
126- initializeData ?: `0x${string } `;
127- implementationAddress : string ;
128- salt ?: string ;
129- } ,
130- ) : Promise < string > {
131- const {
132- client,
133- chain,
134- account,
135- cloneFactoryContract,
136- initializeData,
137- implementationAddress,
138- salt,
139- } = options ;
140-
141- const rpcRequest = getRpcClient ( {
142- client,
143- chain,
144- } ) ;
145- const blockNumber = await eth_blockNumber ( rpcRequest ) ;
146- const parsedSalt = salt
147- ? salt . startsWith ( "0x" ) && salt . length === 66
148- ? ( salt as `0x${string } `)
149- : keccakId ( salt )
150- : toHex ( blockNumber , {
151- size : 32 ,
152- } ) ;
153-
154- const tx = deployProxyByImplementation ( {
155- contract : cloneFactoryContract ,
156- data : initializeData || "0x" ,
157- implementation : implementationAddress ,
158- salt : parsedSalt ,
159- } ) ;
160- const receipt = await sendAndConfirmTransaction ( {
161- transaction : tx ,
162- account,
163- } ) ;
164- const decodedEvent = parseEventLogs ( {
165- events : [ modifiedProxyDeployedEvent ( ) ] ,
166- logs : receipt . logs ,
167- } ) ;
168- if ( decodedEvent . length === 0 || ! decodedEvent [ 0 ] ) {
169- throw new Error (
170- `No ProxyDeployed event found in transaction: ${ receipt . transactionHash } ` ,
171- ) ;
172- }
173- return decodedEvent [ 0 ] ?. args . proxy ;
174- }
0 commit comments