@@ -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,107 @@ 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 ( ${ gasOverrides . gasLimit } ) 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 ( ... [ ] , gasOverrides ) ) ,
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 (
99+ deployerAddress ,
100+ gasOverrides
101+ ) ) , // Use deployer address as placeholder
102+ from : deployerAddress
103+ } ) ;
104+ totalEstimatedCost += factoryGas ;
105+ break ;
120106 }
121107 }
122108
123109 if (
124110 ! output . forwarderImplementation ||
125111 ! ( await isContractDeployed ( output . forwarderImplementation ) )
126112 ) {
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 ;
113+ switch ( useConfiguredGasLimit ) {
114+ case true :
115+ totalEstimatedCost += BigInt ( 3_000_000 ) ;
116+ break ;
117+ default :
118+ const ForwarderV4 = await ethers . getContractFactory (
119+ chainConfig . forwarderContractName
120+ ) ;
121+ const forwarderGas = await deployer . estimateGas ( {
122+ ...( await ForwarderV4 . getDeployTransaction ( gasOverrides ) ) ,
123+ from : deployerAddress
124+ } ) ;
125+ totalEstimatedCost += forwarderGas ;
126+ break ;
140127 }
141128 }
142129
143130 if (
144131 ! output . forwarderFactory ||
145132 ! ( await isContractDeployed ( output . forwarderFactory ) )
146133 ) {
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 ;
134+ switch ( useConfiguredGasLimit ) {
135+ case true :
136+ totalEstimatedCost += BigInt ( 3_000_000 ) ;
137+ break ;
138+ default :
139+ const ForwarderFactory = await ethers . getContractFactory (
140+ chainConfig . forwarderFactoryContractName
141+ ) ;
142+ const forwarderFactoryGas = await deployer . estimateGas ( {
143+ ...( await ForwarderFactory . getDeployTransaction (
144+ deployerAddress ,
145+ gasOverrides
146+ ) ) , // Use deployer address as placeholder
147+ from : deployerAddress
148+ } ) ;
149+ totalEstimatedCost += forwarderFactoryGas ;
150+ break ;
163151 }
164152 }
165153
0 commit comments