Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 additions & 27 deletions scripts/deployV1FactoryContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Dec 15, 2025

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.

Copilot uses AI. Check for mistakes.
};
Comment on lines 19 to 21
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gasPrice parameter is being set as a bigint value, but ethers v6 typically expects gas parameters to be in standard number format or properly formatted. Verify that the gasParams object with bigint gasPrice is compatible with the deploy and sendTransaction methods in ethers v6, as this may cause type errors or transaction failures.

Copilot uses AI. Check for mistakes.
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();
Expand All @@ -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
Copy link

Copilot AI Dec 15, 2025

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 48 for assignment and again on line 51 for logging. Consider storing the address in a variable to avoid the duplicate async call.

Copilot uses AI. Check for mistakes.
);

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
Copy link

Copilot AI Dec 15, 2025

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 63 for assignment and again on line 66 for logging. Consider reusing the address stored in output.walletFactory to avoid the duplicate async call.

Suggested change
(await walletFactory.getAddress()) // ethers v6
output.walletFactory // ethers v6

Copilot uses AI. Check for mistakes.
);

const forwarderTxCount = await ethers.provider.getTransactionCount(
forwarderDeployer.address
); // ethers v5 (no change needed)
await forwarderDeployer.getAddress()
); // ethers v6

console.log('Deploying forwarder contracts....');
console.log('Forwarder Tx Count: ', forwarderTxCount);
const forwarderSelfTransactions = 234 - forwarderTxCount;

for (let i = 0; i < forwarderSelfTransactions; i++) {
const tx = await forwarderDeployer.sendTransaction({
to: forwarderDeployer.address,
value: ethers.utils.parseEther('0'), // ethers v5
to: await forwarderDeployer.getAddress(),
value: ethers.parseEther('0'), // ethers v6
gasPrice: gasParams.gasPrice
});
await tx.wait();
Expand All @@ -92,12 +95,12 @@ async function main() {
const forwarderImplementation = await ForwarderImplementation.deploy(
gasParams
);
await forwarderImplementation.deployed(); // ethers v5
output.forwarderImplementation = forwarderImplementation.address; // ethers v5
await forwarderImplementation.waitForDeployment(); // ethers v6
output.forwarderImplementation = await forwarderImplementation.getAddress(); // ethers v6

console.log(
`${forwarderImplementationContractName} deployed at ` +
forwarderImplementation.address // ethers v5
(await forwarderImplementation.getAddress()) // ethers v6
Copy link

Copilot AI Dec 15, 2025

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.

Suggested change
(await forwarderImplementation.getAddress()) // ethers v6
output.forwarderImplementation // ethers v6

Copilot uses AI. Check for mistakes.
);

const ForwarderFactory = await ethers.getContractFactory(
Expand All @@ -106,14 +109,15 @@ async function main() {
);

const forwarderFactory = await ForwarderFactory.deploy(
forwarderImplementation.address, // ethers v5
await forwarderImplementation.getAddress(), // ethers v6
gasParams
);

await forwarderFactory.deployed(); // ethers v5
output.forwarderFactory = forwarderFactory.address; // ethers v5
await forwarderFactory.waitForDeployment(); // ethers v6
output.forwarderFactory = await forwarderFactory.getAddress(); // ethers v6
console.log(
`${forwarderFactoryContractName} deployed at ` + forwarderFactory.address // ethers v5
`${forwarderFactoryContractName} deployed at ` +
(await forwarderFactory.getAddress()) // ethers v6
Copy link

Copilot AI Dec 15, 2025

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.

Suggested change
(await forwarderFactory.getAddress()) // ethers v6
output.forwarderFactory // ethers v6

Copilot uses AI. Check for mistakes.
);

fs.writeFileSync('output.json', JSON.stringify(output));
Expand All @@ -137,16 +141,16 @@ async function main() {
console.log('Done waiting, verifying');
await verifyContract(
walletImplementationContractName,
walletImplementation.address, // ethers v5
await walletImplementation.getAddress(), // ethers v6
[]
);
await verifyContract('WalletFactory', walletFactory.address, [
walletImplementation.address // ethers v5
await verifyContract('WalletFactory', await walletFactory.getAddress(), [
await walletImplementation.getAddress() // ethers v6
]);

await verifyContract(
forwarderImplementationContractName,
forwarderImplementation.address, // ethers v5
await forwarderImplementation.getAddress(), // ethers v6
[]
);

Expand Down
Loading