@@ -3,7 +3,7 @@ import ora from "ora"
33import type { Address , Hex } from "viem"
44import { http , createPublicClient , getAddress } from "viem"
55import { createKernelClient , getZeroDevBundlerRPC } from "../clients/index.js"
6- import { type Chain , DEPLOYER_CONTRACT_ADDRESS } from "../constant.js"
6+ import { DEPLOYER_CONTRACT_ADDRESS , type ZerodevChain } from "../constant.js"
77import { ensureHex , writeErrorLogToFile } from "../utils/index.js"
88import { computeContractAddress } from "./computeAddress.js"
99import { DeploymentStatus , checkDeploymentOnChain } from "./findDeployment.js"
@@ -21,15 +21,15 @@ type DeployResult = [string, string]
2121
2222export const deployToChain = async (
2323 privateKey : Hex ,
24- chain : Chain ,
24+ chain : ZerodevChain ,
2525 bytecode : Hex ,
2626 salt : Hex ,
2727 expectedAddress : string | undefined ,
2828 callGasLimit : bigint | undefined
2929) : Promise < DeployResult > => {
3030 const publicClient = createPublicClient ( {
31- chain : chain . viemChainObject ,
32- transport : http ( getZeroDevBundlerRPC ( chain . projectId ) )
31+ chain : chain ,
32+ transport : http ( )
3333 } )
3434 const kernelAccountClient = await createKernelClient ( privateKey , chain )
3535
@@ -86,20 +86,28 @@ export const deployToChain = async (
8686 ] )
8787 } )
8888
89+ await kernelAccountClient . waitForUserOperationReceipt ( {
90+ hash : opHash
91+ } )
92+ await kernelAccountClient . getUserOperationReceipt ( {
93+ hash : opHash
94+ } )
95+
8996 return [ getAddress ( result . data as Address ) , opHash ]
9097}
9198
9299export const deployContracts = async (
93100 privateKey : Hex ,
94101 bytecode : Hex ,
95- chains : Chain [ ] ,
102+ chains : ZerodevChain [ ] ,
96103 salt : Hex ,
97104 expectedAddress : string | undefined ,
98105 callGasLimit : bigint | undefined
99106) => {
100107 const spinner = ora (
101108 `Deploying contract on ${ chains . map ( ( chain ) => chain . name ) . join ( ", " ) } `
102109 ) . start ( )
110+ let anyError = false
103111 const deployments = chains . map ( async ( chain ) => {
104112 return deployToChain (
105113 privateKey ,
@@ -130,6 +138,7 @@ export const deployContracts = async (
130138 )
131139 } else {
132140 writeErrorLogToFile ( chain . name , error )
141+ anyError = true
133142 spinner . fail (
134143 `Deployment for ${ chalk . redBright (
135144 chain . name
@@ -141,5 +150,10 @@ export const deployContracts = async (
141150
142151 await Promise . allSettled ( deployments )
143152 spinner . stop ( )
144- console . log ( "✅ All deployments process successfully finished!" )
153+ if ( anyError ) {
154+ console . log ( "❌ Some deployments failed!" )
155+ process . exit ( 1 )
156+ } else {
157+ console . log ( "✅ All deployments process successfully finished!" )
158+ }
145159}
0 commit comments