@@ -29,17 +29,7 @@ async function main() {
2929 const chainConfig = await getChainConfig ( Number ( chainId ) ) ;
3030 const output : DeploymentAddresses = loadOutput ( ) ;
3131
32- let gasOverrides : any = chainConfig . gasParams ;
33-
34- // MegaETH chains: remove gasLimit to let network auto-estimate (required for MegaETH)
35- const MEGAETH_CHAINS = [ 4326 , 6343 ] ; // mainnet and testnet
36- if ( MEGAETH_CHAINS . includes ( Number ( chainId ) ) ) {
37- const { gasLimit, ...gasOverridesWithoutLimit } = gasOverrides ;
38- gasOverrides = gasOverridesWithoutLimit ;
39- console . log (
40- 'ℹ️ MegaETH detected: using auto gas estimation (no gasLimit)'
41- ) ;
42- }
32+ const gasOverrides = chainConfig . gasParams ;
4333
4434 // Handle BigBlocks setup automatically if supported
4535 if ( isBigBlocksSupported ( Number ( chainId ) ) ) {
@@ -57,109 +47,101 @@ async function main() {
5747 // Estimate gas costs for all potential deployments
5848 let totalEstimatedCost = 0n ;
5949
60- // For chains with very high gas limits (like Mantle) or chains with estimation issues (like MegaETH)
61- // skip estimation and use configured limit
62- const CHAINS_SKIP_ESTIMATION = [ 4326 , 6343 ] ; // MegaETH mainnet and testnet
63- const isMegaETH = CHAINS_SKIP_ESTIMATION . includes ( Number ( chainId ) ) ;
64- const useConfiguredGasLimit =
65- ( gasOverrides . gasLimit && gasOverrides . gasLimit > 10_000_000_000 ) ||
66- isMegaETH ;
50+ // For chains with very high gas limits (like Mantle), skip estimation and use configured limit
51+ const useConfiguredGasLimit = gasOverrides . gasLimit > 10_000_000_000 ; // > 10 billion
6752
68- if ( useConfiguredGasLimit && ! isMegaETH ) {
69- console . log (
70- `⚠️ Using configured gas limit ( ${ gasOverrides . gasLimit } ) instead of estimation for this chain`
71- ) ;
72- } else if ( isMegaETH ) {
73- console . log (
74- 'ℹ️ MegaETH: skipping gas estimation, will use auto-estimation during deployment'
75- ) ;
53+ switch ( useConfiguredGasLimit ) {
54+ case true :
55+ console . log (
56+ `⚠️ Using configured gas limit ( ${ 3_000_000 } ) instead of estimation for this chain`
57+ ) ;
58+ break ;
59+ default :
60+ break ;
7661 }
7762
7863 // Only estimate if we need to deploy (not already deployed)
7964 if (
8065 ! output . walletImplementation ||
8166 ! ( await isContractDeployed ( output . walletImplementation ) )
8267 ) {
83- if ( useConfiguredGasLimit && gasOverrides . gasLimit ) {
84- totalEstimatedCost += BigInt ( gasOverrides . gasLimit ) ;
85- } else if ( isMegaETH ) {
86- // Skip estimation for MegaETH - use reasonable default for cost check
87- totalEstimatedCost += BigInt ( 3_000_000 ) ;
88- } else {
89- const WalletSimple = await ethers . getContractFactory (
90- chainConfig . walletImplementationContractName
91- ) ;
92- const walletGas = await deployer . estimateGas ( {
93- ... ( await WalletSimple . getDeployTransaction ( ... [ ] , gasOverrides ) ) ,
94- from : deployerAddress
95- } ) ;
96- totalEstimatedCost += walletGas ;
68+ switch ( useConfiguredGasLimit ) {
69+ case true :
70+ totalEstimatedCost += BigInt ( 3_000_000 ) ;
71+ break ;
72+ default :
73+ const WalletSimple = await ethers . getContractFactory (
74+ chainConfig . walletImplementationContractName
75+ ) ;
76+ const walletGas = await deployer . estimateGas ( {
77+ ... ( await WalletSimple . getDeployTransaction ( ... [ ] ) ) ,
78+ from : deployerAddress
79+ } ) ;
80+ totalEstimatedCost += walletGas ;
81+ break ;
9782 }
9883 }
9984
10085 if (
10186 ! output . walletFactory ||
10287 ! ( await isContractDeployed ( output . walletFactory ) )
10388 ) {
104- if ( useConfiguredGasLimit && gasOverrides . gasLimit ) {
105- totalEstimatedCost += BigInt ( gasOverrides . gasLimit ) ;
106- } else if ( isMegaETH ) {
107- totalEstimatedCost += BigInt ( 3_000_000 ) ;
108- } else {
109- const WalletFactory = await ethers . getContractFactory (
110- chainConfig . walletFactoryContractName
111- ) ;
112- const factoryGas = await deployer . estimateGas ( {
113- ...( await WalletFactory . getDeployTransaction (
114- deployerAddress ,
115- gasOverrides
116- ) ) , // Use deployer address as placeholder
117- from : deployerAddress
118- } ) ;
119- totalEstimatedCost += factoryGas ;
89+ switch ( useConfiguredGasLimit ) {
90+ case true :
91+ totalEstimatedCost += BigInt ( 3_000_000 ) ;
92+ break ;
93+ default :
94+ const WalletFactory = await ethers . getContractFactory (
95+ chainConfig . walletFactoryContractName
96+ ) ;
97+ const factoryGas = await deployer . estimateGas ( {
98+ ...( await WalletFactory . getDeployTransaction ( deployerAddress ) ) , // Use deployer address as placeholder
99+ from : deployerAddress
100+ } ) ;
101+ totalEstimatedCost += factoryGas ;
102+ break ;
120103 }
121104 }
122105
123106 if (
124107 ! output . forwarderImplementation ||
125108 ! ( await isContractDeployed ( output . forwarderImplementation ) )
126109 ) {
127- if ( useConfiguredGasLimit && gasOverrides . gasLimit ) {
128- totalEstimatedCost += BigInt ( gasOverrides . gasLimit ) ;
129- } else if ( isMegaETH ) {
130- totalEstimatedCost += BigInt ( 3_000_000 ) ;
131- } else {
132- const ForwarderV4 = await ethers . getContractFactory (
133- chainConfig . forwarderContractName
134- ) ;
135- const forwarderGas = await deployer . estimateGas ( {
136- ...( await ForwarderV4 . getDeployTransaction ( gasOverrides ) ) ,
137- from : deployerAddress
138- } ) ;
139- totalEstimatedCost += forwarderGas ;
110+ switch ( useConfiguredGasLimit ) {
111+ case true :
112+ totalEstimatedCost += BigInt ( 3_000_000 ) ;
113+ break ;
114+ default :
115+ const ForwarderV4 = await ethers . getContractFactory (
116+ chainConfig . forwarderContractName
117+ ) ;
118+ const forwarderGas = await deployer . estimateGas ( {
119+ ...( await ForwarderV4 . getDeployTransaction ( ) ) ,
120+ from : deployerAddress
121+ } ) ;
122+ totalEstimatedCost += forwarderGas ;
123+ break ;
140124 }
141125 }
142126
143127 if (
144128 ! output . forwarderFactory ||
145129 ! ( await isContractDeployed ( output . forwarderFactory ) )
146130 ) {
147- if ( useConfiguredGasLimit && gasOverrides . gasLimit ) {
148- totalEstimatedCost += BigInt ( gasOverrides . gasLimit ) ;
149- } else if ( isMegaETH ) {
150- totalEstimatedCost += BigInt ( 3_000_000 ) ;
151- } else {
152- const ForwarderFactory = await ethers . getContractFactory (
153- chainConfig . forwarderFactoryContractName
154- ) ;
155- const forwarderFactoryGas = await deployer . estimateGas ( {
156- ...( await ForwarderFactory . getDeployTransaction (
157- deployerAddress ,
158- gasOverrides
159- ) ) , // Use deployer address as placeholder
160- from : deployerAddress
161- } ) ;
162- totalEstimatedCost += forwarderFactoryGas ;
131+ switch ( useConfiguredGasLimit ) {
132+ case true :
133+ totalEstimatedCost += BigInt ( 3_000_000 ) ;
134+ break ;
135+ default :
136+ const ForwarderFactory = await ethers . getContractFactory (
137+ chainConfig . forwarderFactoryContractName
138+ ) ;
139+ const forwarderFactoryGas = await deployer . estimateGas ( {
140+ ...( await ForwarderFactory . getDeployTransaction ( deployerAddress ) ) , // Use deployer address as placeholder
141+ from : deployerAddress
142+ } ) ;
143+ totalEstimatedCost += forwarderFactoryGas ;
144+ break ;
163145 }
164146 }
165147
0 commit comments