@@ -12,22 +12,24 @@ async function main() {
1212
1313 const feeData = await ethers . provider . getFeeData ( ) ;
1414
15- const [ walletDeployer , forwarderDeployer ] = await ethers . getSigners ( ) ;
15+ const signers = await ethers . getSigners ( ) ;
16+ const walletDeployer = signers [ 0 ] ;
17+ const forwarderDeployer = signers [ 1 ] || signers [ 0 ] ; // Use first signer if second is not available
1618
1719 const gasParams = {
18- gasPrice : feeData . gasPrice . mul ( 2 ) // Use BigNumber arithmetic for ethers v5
20+ gasPrice : ( feeData . gasPrice ?? 0n ) * 2n // Use bigint arithmetic for ethers v6
1921 } ;
2022 const walletTxCount = await ethers . provider . getTransactionCount (
21- walletDeployer . address
23+ await walletDeployer . getAddress ( )
2224 ) ; // Updated for ethers v6
2325
2426 console . log ( 'Deploying wallet contracts....' ) ;
2527 console . log ( 'Wallet Tx Count: ' , walletTxCount ) ;
2628 const walletSelfTransactions = 2 - walletTxCount ;
2729 for ( let i = 0 ; i < walletSelfTransactions ; i ++ ) {
2830 const tx = await walletDeployer . sendTransaction ( {
29- to : walletDeployer . address ,
30- value : ethers . utils . parseEther ( '0' ) , // ethers v5
31+ to : await walletDeployer . getAddress ( ) ,
32+ value : ethers . parseEther ( '0' ) , // ethers v6
3133 gasPrice : gasParams . gasPrice
3234 } ) ;
3335 await tx . wait ( ) ;
@@ -42,39 +44,40 @@ async function main() {
4244 walletDeployer
4345 ) ;
4446 const walletImplementation = await WalletImplementation . deploy ( gasParams ) ;
45- await walletImplementation . deployed ( ) ; // ethers v5
46- output . walletImplementation = walletImplementation . address ; // ethers v5
47+ await walletImplementation . waitForDeployment ( ) ; // ethers v6
48+ output . walletImplementation = await walletImplementation . getAddress ( ) ; // ethers v6
4749 console . log (
4850 `${ walletImplementationContractName } deployed at ` +
49- walletImplementation . address // ethers v5
51+ ( await walletImplementation . getAddress ( ) ) // ethers v6
5052 ) ;
5153
5254 const WalletFactory = await ethers . getContractFactory (
5355 walletFactoryContractName ,
5456 walletDeployer
5557 ) ;
5658 const walletFactory = await WalletFactory . deploy (
57- walletImplementation . address , // ethers v5
59+ await walletImplementation . getAddress ( ) , // ethers v6
5860 gasParams
5961 ) ;
60- await walletFactory . deployed ( ) ; // ethers v5
61- output . walletFactory = walletFactory . address ; // ethers v5
62+ await walletFactory . waitForDeployment ( ) ; // ethers v6
63+ output . walletFactory = await walletFactory . getAddress ( ) ; // ethers v6
6264 console . log (
63- `${ walletFactoryContractName } deployed at ` + walletFactory . address // ethers v5
65+ `${ walletFactoryContractName } deployed at ` +
66+ ( await walletFactory . getAddress ( ) ) // ethers v6
6467 ) ;
6568
6669 const forwarderTxCount = await ethers . provider . getTransactionCount (
67- forwarderDeployer . address
68- ) ; // ethers v5 (no change needed)
70+ await forwarderDeployer . getAddress ( )
71+ ) ; // ethers v6
6972
7073 console . log ( 'Deploying forwarder contracts....' ) ;
7174 console . log ( 'Forwarder Tx Count: ' , forwarderTxCount ) ;
7275 const forwarderSelfTransactions = 234 - forwarderTxCount ;
7376
7477 for ( let i = 0 ; i < forwarderSelfTransactions ; i ++ ) {
7578 const tx = await forwarderDeployer . sendTransaction ( {
76- to : forwarderDeployer . address ,
77- value : ethers . utils . parseEther ( '0' ) , // ethers v5
79+ to : await forwarderDeployer . getAddress ( ) ,
80+ value : ethers . parseEther ( '0' ) , // ethers v6
7881 gasPrice : gasParams . gasPrice
7982 } ) ;
8083 await tx . wait ( ) ;
@@ -92,12 +95,12 @@ async function main() {
9295 const forwarderImplementation = await ForwarderImplementation . deploy (
9396 gasParams
9497 ) ;
95- await forwarderImplementation . deployed ( ) ; // ethers v5
96- output . forwarderImplementation = forwarderImplementation . address ; // ethers v5
98+ await forwarderImplementation . waitForDeployment ( ) ; // ethers v6
99+ output . forwarderImplementation = await forwarderImplementation . getAddress ( ) ; // ethers v6
97100
98101 console . log (
99102 `${ forwarderImplementationContractName } deployed at ` +
100- forwarderImplementation . address // ethers v5
103+ ( await forwarderImplementation . getAddress ( ) ) // ethers v6
101104 ) ;
102105
103106 const ForwarderFactory = await ethers . getContractFactory (
@@ -106,14 +109,15 @@ async function main() {
106109 ) ;
107110
108111 const forwarderFactory = await ForwarderFactory . deploy (
109- forwarderImplementation . address , // ethers v5
112+ await forwarderImplementation . getAddress ( ) , // ethers v6
110113 gasParams
111114 ) ;
112115
113- await forwarderFactory . deployed ( ) ; // ethers v5
114- output . forwarderFactory = forwarderFactory . address ; // ethers v5
116+ await forwarderFactory . waitForDeployment ( ) ; // ethers v6
117+ output . forwarderFactory = await forwarderFactory . getAddress ( ) ; // ethers v6
115118 console . log (
116- `${ forwarderFactoryContractName } deployed at ` + forwarderFactory . address // ethers v5
119+ `${ forwarderFactoryContractName } deployed at ` +
120+ ( await forwarderFactory . getAddress ( ) ) // ethers v6
117121 ) ;
118122
119123 fs . writeFileSync ( 'output.json' , JSON . stringify ( output ) ) ;
@@ -137,16 +141,16 @@ async function main() {
137141 console . log ( 'Done waiting, verifying' ) ;
138142 await verifyContract (
139143 walletImplementationContractName ,
140- walletImplementation . address , // ethers v5
144+ await walletImplementation . getAddress ( ) , // ethers v6
141145 [ ]
142146 ) ;
143- await verifyContract ( 'WalletFactory' , walletFactory . address , [
144- walletImplementation . address // ethers v5
147+ await verifyContract ( 'WalletFactory' , await walletFactory . getAddress ( ) , [
148+ await walletImplementation . getAddress ( ) // ethers v6
145149 ] ) ;
146150
147151 await verifyContract (
148152 forwarderImplementationContractName ,
149- forwarderImplementation . address , // ethers v5
153+ await forwarderImplementation . getAddress ( ) , // ethers v6
150154 [ ]
151155 ) ;
152156
0 commit comments