-
Notifications
You must be signed in to change notification settings - Fork 62
fix: fixed the deployV1FactoryContracts script #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,22 +12,24 @@ async function main() { | |||||
|
|
||||||
| const feeData = await ethers.provider.getFeeData(); | ||||||
|
|
||||||
| const [walletDeployer, forwarderDeployer] = await ethers.getSigners(); | ||||||
| const signers = await ethers.getSigners(); | ||||||
| const walletDeployer = signers[0]; | ||||||
| const forwarderDeployer = signers[1] || signers[0]; // Use first signer if second is not available | ||||||
|
|
||||||
| const gasParams = { | ||||||
| gasPrice: feeData.gasPrice.mul(2) // Use BigNumber arithmetic for ethers v5 | ||||||
| gasPrice: (feeData.gasPrice ?? 0n) * 2n // Use bigint arithmetic for ethers v6 | ||||||
| }; | ||||||
|
Comment on lines
19
to
21
|
||||||
| const walletTxCount = await ethers.provider.getTransactionCount( | ||||||
| walletDeployer.address | ||||||
| await walletDeployer.getAddress() | ||||||
| ); // Updated for ethers v6 | ||||||
|
|
||||||
| console.log('Deploying wallet contracts....'); | ||||||
| console.log('Wallet Tx Count: ', walletTxCount); | ||||||
| const walletSelfTransactions = 2 - walletTxCount; | ||||||
| for (let i = 0; i < walletSelfTransactions; i++) { | ||||||
| const tx = await walletDeployer.sendTransaction({ | ||||||
| to: walletDeployer.address, | ||||||
| value: ethers.utils.parseEther('0'), // ethers v5 | ||||||
| to: await walletDeployer.getAddress(), | ||||||
| value: ethers.parseEther('0'), // ethers v6 | ||||||
| gasPrice: gasParams.gasPrice | ||||||
| }); | ||||||
| await tx.wait(); | ||||||
|
|
@@ -42,39 +44,40 @@ async function main() { | |||||
| walletDeployer | ||||||
| ); | ||||||
| const walletImplementation = await WalletImplementation.deploy(gasParams); | ||||||
| await walletImplementation.deployed(); // ethers v5 | ||||||
| output.walletImplementation = walletImplementation.address; // ethers v5 | ||||||
| await walletImplementation.waitForDeployment(); // ethers v6 | ||||||
| output.walletImplementation = await walletImplementation.getAddress(); // ethers v6 | ||||||
| console.log( | ||||||
| `${walletImplementationContractName} deployed at ` + | ||||||
| walletImplementation.address // ethers v5 | ||||||
| (await walletImplementation.getAddress()) // ethers v6 | ||||||
|
Comment on lines
+48
to
+51
|
||||||
| ); | ||||||
|
|
||||||
| const WalletFactory = await ethers.getContractFactory( | ||||||
| walletFactoryContractName, | ||||||
| walletDeployer | ||||||
| ); | ||||||
| const walletFactory = await WalletFactory.deploy( | ||||||
| walletImplementation.address, // ethers v5 | ||||||
| await walletImplementation.getAddress(), // ethers v6 | ||||||
| gasParams | ||||||
| ); | ||||||
| await walletFactory.deployed(); // ethers v5 | ||||||
| output.walletFactory = walletFactory.address; // ethers v5 | ||||||
| await walletFactory.waitForDeployment(); // ethers v6 | ||||||
| output.walletFactory = await walletFactory.getAddress(); // ethers v6 | ||||||
| console.log( | ||||||
| `${walletFactoryContractName} deployed at ` + walletFactory.address // ethers v5 | ||||||
| `${walletFactoryContractName} deployed at ` + | ||||||
| (await walletFactory.getAddress()) // ethers v6 | ||||||
|
||||||
| (await walletFactory.getAddress()) // ethers v6 | |
| output.walletFactory // ethers v6 |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant async call: the address is fetched twice - once on line 99 for assignment and again on line 103 for logging. Consider reusing the address stored in output.forwarderImplementation to avoid the duplicate async call.
| (await forwarderImplementation.getAddress()) // ethers v6 | |
| output.forwarderImplementation // ethers v6 |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant async call: the address is fetched twice - once on line 117 for assignment and again on line 120 for logging. Consider reusing the address stored in output.forwarderFactory to avoid the duplicate async call.
| (await forwarderFactory.getAddress()) // ethers v6 | |
| output.forwarderFactory // ethers v6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback value of 0n for gasPrice could cause transactions to fail. If feeData.gasPrice is null or undefined, multiplying 0n by 2n will result in a gasPrice of 0n, which would make transactions not get mined. Consider throwing an error or using a more appropriate fallback strategy when gasPrice is unavailable.