Skip to content

Integrate CREATE3Factory into contracts repo (and deploy all flow)#1113

Merged
0xDEnYO merged 11 commits intomainfrom
integrate-create3
Apr 28, 2025
Merged

Integrate CREATE3Factory into contracts repo (and deploy all flow)#1113
0xDEnYO merged 11 commits intomainfrom
integrate-create3

Conversation

@0xDEnYO
Copy link
Copy Markdown
Contributor

@0xDEnYO 0xDEnYO commented Apr 22, 2025

Which Jira task belongs to this PR?

https://lifi.atlassian.net/browse/LF-13286

Why did I implement it this way?

Checklist before requesting a review

Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)

  • I have checked that any arbitrary calls to external contracts are validated and or restricted
  • I have checked that any privileged calls (i.e. storage modifications) are validated and or restricted
  • I have ensured that any new contracts have had AT A MINIMUM 1 preliminary audit conducted on by <company/auditor>

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2025

## Walkthrough

A new deployment step for the CREATE3Factory smart contract was integrated into the deployment workflow. This involved introducing a dedicated Bash function and a Forge Solidity script for deploying the CREATE3Factory contract, updating the deployment sequence in the main deployment script to call this new step early in the process. The new function ensures the contract is deployed, its address is stored, and the deployment is validated before proceeding with the rest of the contracts. No changes were made to exported or public entities outside of the new deployment logic.

## Changes

| Files/Paths                                                                 | Change Summary                                                                                                   |
|-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| script/deploy/deployAllContracts.sh                                         | Updated deployment sequence to call the new CREATE3Factory deployment function early; reordered script sourcing. |
| script/deploy/deployAndStoreCREATE3Factory.sh                               | Added new Bash function to deploy CREATE3Factory, handle errors, and update address in networks.json.            |
| script/deploy/facets/DeployCREATE3Factory.s.sol                             | Added new Forge deployment script contract for CREATE3Factory, with public run() function.                       |

## Suggested reviewers

- ezynda3

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lifi-action-bot lifi-action-bot marked this pull request as draft April 22, 2025 05:00
Comment thread src/Helpers/CREATE3Factory.sol Outdated
/// @notice Enables deploying contracts using CREATE3. Each deployer (msg.sender) has
/// its own namespace for deployed addresses.
/// @custom:version 1.0.0
contract CREATE3Factory is ICREATE3Factory {

Check failure

Code scanning / Olympix Integrated Security

Contracts that can receive ether but cannot send it may lock value permanently. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/locked-ether

Contracts that can receive ether but cannot send it may lock value permanently. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/locked-ether
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (7)
script/deploy/deployAllContracts.sh (1)

43-45: Verify if this deployment strategy is intentional.

The script now exclusively deploys the CREATE3Factory while commenting out all other deployment steps. Is this intended to be a temporary state for testing, or is this the first step in transitioning to a new deployment model using CREATE3?

Consider documenting the new deployment strategy that uses CREATE3Factory, explaining how it replaces or modifies the previous workflow. This will help future developers understand the transition and implementation approach.

src/Helpers/CREATE3Factory.sol (1)

13-22: Add a withdrawal mechanism to handle locked ETH.

The contract can receive ETH through the payable deploy function, but has no way to retrieve it if deployment fails or if ETH is sent directly to the contract. This could lead to permanently locked funds.

Consider adding a withdrawal function accessible only by an owner or admin:

 contract CREATE3Factory is ICREATE3Factory {
+    address public owner;
+    
+    constructor() {
+        owner = msg.sender;
+    }
+    
     /// @inheritdoc	ICREATE3Factory
     function deploy(
         bytes32 salt,
         bytes memory creationCode
     ) external payable override returns (address deployed) {
         // hash salt with the deployer address to give each deployer its own namespace
         salt = keccak256(abi.encodePacked(msg.sender, salt));
         return CREATE3.deploy(salt, creationCode, msg.value);
     }
+
+    /// @notice Allows the owner to withdraw any ETH stuck in the contract
+    /// @param to The address to send the ETH to
+    /// @param amount The amount of ETH to withdraw
+    function withdrawETH(address to, uint256 amount) external {
+        require(msg.sender == owner, "Only owner");
+        require(to != address(0), "Invalid recipient");
+        (bool success, ) = to.call{value: amount}("");
+        require(success, "Transfer failed");
+    }
🧰 Tools
🪛 GitHub Check: Olympix Integrated Security

[failure] 13-13:
Contracts that can receive ether but cannot send it may lock value permanently. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/locked-ether

script/deploy/deployAndStoreCREATE3Factory.sh (5)

1-2: Use env-based shebang for portability.
Replace the hardcoded #!/bin/bash with:

#!/usr/bin/env bash

so that the script picks up the user’s environment bash and works consistently across different systems.


20-21: Verify .env exists before sourcing.
Blindly sourcing .env can silently fail or introduce unexpected variables. Safeguard with:

if [ ! -f .env ]; then
  error ".env file not found"
  return 1
fi
source .env

40-43: Unify error reporting via error helper.
Instead of:

if [[ $RETURN_CODE -ne 0 ]]; then
  echo "❌ Error: deployment was not successful"
  return 1
fi

use:

if [[ $RETURN_CODE -ne 0 ]]; then
  error "Deployment failed on network '$NETWORK' ($ENVIRONMENT)"
  return 1
fi

This ensures consistent, colorized error output.


55-58: Ensure NETWORKS_JSON_FILE_PATH is set.
Before running:

jq -e --arg net "$NETWORK" '.[$net]' "$NETWORKS_JSON_FILE_PATH"

verify that NETWORKS_JSON_FILE_PATH was loaded from config.sh, e.g.:

if [ -z "$NETWORKS_JSON_FILE_PATH" ]; then
  error "NETWORKS_JSON_FILE_PATH is not defined"
  return 1
fi

This yields clearer errors if the config is misconfigured.


61-67: Harden temp-file creation when updating JSON.
You’re using mktemp and jq atomically, which is great. Catch mktemp errors explicitly:

local tmpfile
tmpfile=$(mktemp) || { error "mktemp failed"; return 1; }
if ! jq --arg net "$NETWORK" --arg addr "$FACTORY_ADDRESS" \
  '(.[$net].create3Factory) = $addr' "$NETWORKS_JSON_FILE_PATH" > "$tmpfile"; then
    error "Failed to update networks.json"
    rm -f "$tmpfile"
    return 1
fi

This ensures any temp-file issues are surfaced immediately.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c384c5d and 1884ee4.

📒 Files selected for processing (5)
  • script/deploy/deployAllContracts.sh (2 hunks)
  • script/deploy/deployAndStoreCREATE3Factory.sh (1 hunks)
  • script/deploy/facets/DeployCREATE3Factory.s.sol (1 hunks)
  • src/Helpers/CREATE3Factory.sol (1 hunks)
  • src/Interfaces/ICREATE3Factory.sol (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
script/deploy/deployAllContracts.sh (2)
script/deploy/deployAndStoreCREATE3Factory.sh (1)
  • deployAndStoreCREATE3Factory (5-75)
script/helperFunctions.sh (1)
  • checkFailure (2226-2236)
script/deploy/deployAndStoreCREATE3Factory.sh (1)
script/helperFunctions.sh (3)
  • getFileSuffix (2064-2074)
  • echoDebug (2239-2247)
  • error (2248-2250)
🪛 Shellcheck (0.10.0)
script/deploy/deployAndStoreCREATE3Factory.sh

[warning] 23-23: Declare and assign separately to avoid masking return values.

(SC2155)

🪛 GitHub Check: Olympix Integrated Security
src/Helpers/CREATE3Factory.sol

[failure] 13-13:
Contracts that can receive ether but cannot send it may lock value permanently. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/locked-ether

🪛 GitHub Actions: Types Bindings
src/Helpers/CREATE3Factory.sol

[error] 6-6: Compiler error: Source "src/interfaces/ICREATE3Factory.sol" not found. Import statement at line 6 cannot be resolved.

🪛 GitHub Actions: Enforce Min Test Coverage
src/Helpers/CREATE3Factory.sol

[error] 6-6: Compiler error: Source file 'src/interfaces/ICREATE3Factory.sol' not found. Import statement at line 6 cannot be resolved.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-unit-tests
🔇 Additional comments (10)
src/Interfaces/ICREATE3Factory.sol (1)

1-28: Well-designed interface for deterministic contract deployment.

The interface is clearly documented with comprehensive NatSpec comments and provides a clean abstraction for the CREATE3 deployment pattern. The salt mechanism ensures unique namespaces per deployer, preventing address collisions.

script/deploy/facets/DeployCREATE3Factory.s.sol (2)

8-17: LGTM! Script follows standard Forge deployment pattern.

The deployment script correctly uses the Script contract, retrieves a private key from the environment, and handles the broadcast session appropriately.


6-6:

Details

✅ Verification successful

Verify the import path remapping configuration.

The import uses the "lifi/" prefix which suggests a remapping in Forge's configuration. Ensure this remapping is correctly set up in your foundry.toml or other configuration files to avoid import errors.


🏁 Script executed:

#!/bin/bash
# Check for remapping configuration in foundry.toml
if [ -f foundry.toml ]; then
  echo "Checking remappings in foundry.toml..."
  grep -i "remappings\|lifi" foundry.toml
else
  echo "foundry.toml not found in the repository root"
fi

Length of output: 154


🏁 Script executed:

#!/bin/bash
# Check for remappings.txt
if [ -f remappings.txt ]; then
  echo "Found remappings.txt:"
  cat remappings.txt
else
  echo "remappings.txt not found"
fi

# Show any remappings in foundry.toml
echo "Remappings in foundry.toml (if any):"
grep -n "remappings" -C2 foundry.toml || echo "No remappings entries found"

# Search for CREATE3Factory.sol in the repo
echo "Looking for CREATE3Factory.sol files:"
grep -R "CREATE3Factory.sol" -n .

Length of output: 1496


Import path remapping is correctly configured

– Your remappings.txt includes
lifi/=src/
so import { CREATE3Factory } from "lifi/Helpers/CREATE3Factory.sol"; resolves to src/Helpers/CREATE3Factory.sol.
No changes needed.

script/deploy/deployAllContracts.sh (2)

9-9: LGTM! New deployment script is correctly sourced.

The script properly includes the new CREATE3Factory deployment script.


48-134: Future implementation plan needed for commented-out deployment steps.

All standard deployment steps (core facets, diamond, periphery, etc.) have been commented out. Is there a plan to reimplement these using the CREATE3Factory in a future PR? Consider adding a TODO comment describing the implementation plan and related tickets.

src/Helpers/CREATE3Factory.sol (1)

24-32: LGTM! Function correctly implements the interface.

The getDeployed function properly hashes the salt with the deployer address and calls the CREATE3 utility to predict the deployed address.

script/deploy/deployAndStoreCREATE3Factory.sh (4)

26-31: Debug logging is clear.
Using echoDebug under a DEBUG flag provides controlled verbosity and context for troubleshooting.


49-52: Validate extracted factory address.
The emptiness check correctly catches missing addresses:

if [[ -z "$FACTORY_ADDRESS" ]]; then
  error "Failed to obtain deployed contract address for CREATE3Factory on $NETWORK ($ENVIRONMENT)"
  return 1
fi

This prevents storing invalid data downstream.


69-75: Final logging and exit look solid.
The use of an atomic mv, confirmation log, and return 0 properly signals success.


23-23: 🛠️ Refactor suggestion

Avoid masking return values when declaring locals.
ShellCheck SC2155 flags the combined declaration and assignment:

local FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")

Split it to preserve $? correctly:

local FILE_SUFFIX
FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")
⛔ Skipped due to learnings
Learnt from: 0xDEnYO
PR: lifinance/contracts#715
File: script/tasks/diamondEMERGENCYPause.sh:25-25
Timestamp: 2024-10-08T04:55:05.706Z
Learning: When reviewing shell scripts, do not report issues about masking return values by declaring and assigning variables in the same line (e.g., `local FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")`), as this practice is acceptable to the team.
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 23-23: Declare and assign separately to avoid masking return values.

(SC2155)

Comment thread src/Helpers/CREATE3Factory.sol Outdated
Comment thread script/deploy/deployAndStoreCREATE3Factory.sh Outdated
Comment thread script/deploy/deployAndStoreCREATE3Factory.sh Outdated
Comment thread script/deploy/deployAndStoreCREATE3Factory.sh Outdated
Comment thread script/deploy/deployAndStoreCREATE3Factory.sh
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (3)
script/deploy/deployAndStoreCREATE3Factory.sh (3)

11-12: Make sourcing robust to working-directory changes.

Using relative paths for source will break if the CWD isn’t the repo root. Anchor imports to the script’s directory.

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../config.sh"
source "$SCRIPT_DIR/../helperFunctions.sh"

This change ensures config.sh and helperFunctions.sh are always found.


15-17: Validate input parameters before use.

Currently, missing arguments will lead to empty variables and obscure errors down the line. Add a guard to verify both NETWORK and ENVIRONMENT are provided.

if [[ $# -lt 2 ]]; then
  error "Usage: deployAndStoreCREATE3Factory <NETWORK> <ENVIRONMENT>"
  return 1
fi

Insert this at the top of the function (after the local NETWORK ENVIRONMENT lines).


46-52: Check for empty address before printing success.

Echoing success prior to validating the address can mislead users. Move the success message below the empty‐check.

- FACTORY_ADDRESS=$(echo "$RETURN_DATA" | jq -r '.factory.value')
- echo "✅ Successfully deployed to address $FACTORY_ADDRESS"
- if [[ -z "$FACTORY_ADDRESS" ]]; then
-   error "Failed to obtain deployed contract address for CREATE3Factory on $NETWORK ($ENVIRONMENT)"
-   return 1
- fi
+ FACTORY_ADDRESS=$(echo "$RETURN_DATA" | jq -r '.factory.value')
+ if [[ -z "$FACTORY_ADDRESS" ]]; then
+   error "Failed to obtain deployed contract address for CREATE3Factory on $NETWORK ($ENVIRONMENT)"
+   return 1
+ fi
+ echo "✅ Successfully deployed to address $FACTORY_ADDRESS"
🧹 Nitpick comments (5)
script/deploy/deployAndStoreCREATE3Factory.sh (5)

1-2: Add strict mode flags for safer script execution.

Include set -euo pipefail immediately after the shebang to ensure the script exits on any error, treats unset variables as errors, and fails on pipeline errors. This guards against silent failures and unexpected behavior.

1#!/bin/bash
+2 set -euo pipefail

Place this directly below #!/bin/bash.


22-22: Avoid masking return values when declaring and assigning variables.

ShellCheck SC2155 flags combining local with assignment. Split declaration and assignment to preserve exit codes.

-  local FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")
+  local FILE_SUFFIX
+  FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 22-22: Declare and assign separately to avoid masking return values.

(SC2155)


33-38: Scope deployment variables locally and quote expansions.

Bundle all temp variables under local, and quote parameters and paths to handle spaces or special characters reliably.

-  PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT")
-	RAW_RETURN_DATA=$(PRIVATE_KEY=$PRIVATE_KEY forge script script/deploy/facets/DeployCREATE3Factory.s.sol -f $NETWORK -vvvv --verify --json --legacy --broadcast --skip-simulation --gas-limit 2000000)
-	RETURN_CODE=$?
-	CLEAN_RETURN_DATA=$(echo $RAW_RETURN_DATA | sed 's/^.*{\"logs/{\"logs/')
-	RETURN_DATA=$(echo $CLEAN_RETURN_DATA | jq -r '.returns' 2>/dev/null)
+  local PRIVATE_KEY RAW_RETURN_DATA RETURN_CODE CLEAN_RETURN_DATA RETURN_DATA
+  PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT")
+  RAW_RETURN_DATA=$(PRIVATE_KEY="$PRIVATE_KEY" \
+    forge script "script/deploy/facets/DeployCREATE3Factory.s.sol" \
+      -f "$NETWORK" -vvvv \
+      --verify --json --legacy --broadcast --skip-simulation \
+      --gas-limit 2000000)
+  RETURN_CODE=$?
+  CLEAN_RETURN_DATA=$(echo "$RAW_RETURN_DATA" | sed 's/^.*\({\"logs\)/\1/')
+  RETURN_DATA=$(echo "$CLEAN_RETURN_DATA" | jq -r '.returns' 2>/dev/null)

This change localizes your variables and hardens the invocation.


39-42: Use consistent error logging for deployment failures.

Replace the plain echo with the error helper to standardize formatting and color.

-  if [[ $RETURN_CODE -ne 0 ]]; then
-    echo "❌ Error: deployment was not successful"
-    return 1
-  fi
+  if [[ $RETURN_CODE -ne 0 ]]; then
+    error "❌ Deployment failed for CREATE3Factory on $NETWORK ($ENVIRONMENT)"
+    return 1
+  fi

54-70: Leverage jq -i (when available) or handle tempfile atomically.

You update networks.json via a tmpfile+mv, which is safe. As an alternative, consider jq -i on Linux for in-place edits, or add a backup step before mv to aid rollbacks:

cp "$NETWORKS_JSON_FILE_PATH" "${NETWORKS_JSON_FILE_PATH}.bak"
jq --arg net "$NETWORK" --arg addr "$FACTORY_ADDRESS" \
   '(.[$net].create3Factory) = $addr' "$NETWORKS_JSON_FILE_PATH" > "$tmpfile" \
  && mv "$tmpfile" "$NETWORKS_JSON_FILE_PATH" \
  || { error "Failed to update networks.json"; rm -f "$tmpfile"; return 1; }

This ensures you have a backup and a single atomic move.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1884ee4 and a4fdb12.

📒 Files selected for processing (2)
  • script/deploy/deployAllContracts.sh (2 hunks)
  • script/deploy/deployAndStoreCREATE3Factory.sh (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • script/deploy/deployAllContracts.sh
🧰 Additional context used
🧬 Code Graph Analysis (1)
script/deploy/deployAndStoreCREATE3Factory.sh (1)
script/helperFunctions.sh (3)
  • getFileSuffix (2064-2074)
  • echoDebug (2239-2247)
  • error (2248-2250)
🪛 Shellcheck (0.10.0)
script/deploy/deployAndStoreCREATE3Factory.sh

[warning] 22-22: Declare and assign separately to avoid masking return values.

(SC2155)

@0xDEnYO 0xDEnYO marked this pull request as ready for review April 22, 2025 05:08
@lifi-action-bot
Copy link
Copy Markdown
Collaborator

🤖 GitHub Action: Security Alerts Review 🔍

🟢 Dismissed Security Alerts with Comments
The following alerts were dismissed with proper comments:

🟢 View Alert - File: src/Helpers/CREATE3Factory.sol
🔹 Contracts that can receive ether but cannot send it may lock value permanently. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/locked-ether
🔹 Dismiss Reason: Won't fix
🔹 Dismiss Comment: That is correct but CREATE3 is only used internally and we accept this risk as this address is never used by our partners/integrators

No unresolved security alerts! 🎉

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
script/deploy/deployAndStoreCREATE3Factory.sh (1)

52-56: Prevent misleading logs on missing address
The script currently echoes a success message before verifying FACTORY_ADDRESS, which can lead to false positives if parsing fails. Reorder the check:

- echo "✅ Successfully deployed to address $FACTORY_ADDRESS"
- if [[ -z "$FACTORY_ADDRESS" ]]; then
-   error "Failed to obtain deployed contract address for CREATE3Factory on $NETWORK ($ENVIRONMENT)"
-   return 1
- fi
+ if [[ -z "$FACTORY_ADDRESS" ]]; then
+   error "Failed to obtain deployed contract address for CREATE3Factory on $NETWORK ($ENVIRONMENT)"
+   return 1
+ fi
+ echo "✅ Successfully deployed to address $FACTORY_ADDRESS"
🧹 Nitpick comments (3)
script/deploy/deployAndStoreCREATE3Factory.sh (3)

28-28: Avoid masking return values (SC2155)
Using local FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT") suppresses the exit code of the function. Split declaration and assignment to preserve error detection:

-local FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")
+local FILE_SUFFIX
+FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 28-28: Declare and assign separately to avoid masking return values.

(SC2155)


39-39: Avoid masking return values (SC2155)
Similarly, separate declaration from assignment for PRIVATE_KEY to avoid masking its exit status:

-local PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT")
+local PRIVATE_KEY
+PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT")
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 39-39: Declare and assign separately to avoid masking return values.

(SC2155)


38-44: Improve robustness and consistency of the deployment command

  • Quote variable expansions (e.g., "$NETWORK") to guard against spaces or special characters.
  • Use consistent space-based indentation instead of mixed tabs.

Proposed diff:

-	RAW_RETURN_DATA=$(PRIVATE_KEY="$PRIVATE_KEY" forge script script/deploy/facets/DeployCREATE3Factory.s.sol -f $NETWORK -vvvv --verify --json --legacy --broadcast --skip-simulation --gas-limit 2000000)
+  local RAW_RETURN_DATA
+  RAW_RETURN_DATA=$(PRIVATE_KEY="$PRIVATE_KEY" \
+    forge script script/deploy/facets/DeployCREATE3Factory.s.sol \
+      -f "$NETWORK" \
+      -vvvv --verify --json --legacy --broadcast --skip-simulation \
+      --gas-limit 2000000)
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 39-39: Declare and assign separately to avoid masking return values.

(SC2155)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a4fdb12 and f292674.

📒 Files selected for processing (2)
  • script/deploy/deployAndStoreCREATE3Factory.sh (1 hunks)
  • src/Helpers/CREATE3Factory.sol (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Helpers/CREATE3Factory.sol
🧰 Additional context used
🧬 Code Graph Analysis (1)
script/deploy/deployAndStoreCREATE3Factory.sh (1)
script/helperFunctions.sh (3)
  • error (2248-2250)
  • getFileSuffix (2064-2074)
  • echoDebug (2239-2247)
🪛 Shellcheck (0.10.0)
script/deploy/deployAndStoreCREATE3Factory.sh

[warning] 28-28: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 39-39: Declare and assign separately to avoid masking return values.

(SC2155)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: run-unit-tests
  • GitHub Check: enforce-min-test-coverage
🔇 Additional comments (2)
script/deploy/deployAndStoreCREATE3Factory.sh (2)

7-10: Well-handled parameter validation
The function correctly checks for required arguments and returns a non-zero status on incorrect usage.


21-23: Correctly reading function arguments
Capturing $1 and $2 into NETWORK and ENVIRONMENT is clear and concise.

@lifi-action-bot
Copy link
Copy Markdown
Collaborator

Test Coverage Report

Line Coverage: 79.49% (2113 / 2658 lines)
Function Coverage: 84.50% ( 360 / 426 functions)
Branch Coverage: 47.92% ( 254 / 530 branches)
Test coverage (79.49%) is above min threshold (76%). Check passed.

@0xDEnYO 0xDEnYO enabled auto-merge (squash) April 22, 2025 06:33
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
script/deploy/deployAndStoreCREATE3Factory.sh (1)

53-59: Check address before printing success
The success echo currently comes before validating FACTORY_ADDRESS. Move the check above the echo "✅ Successfully deployed..." to avoid misleading logs when address extraction fails.

🧹 Nitpick comments (4)
script/deploy/deployAndStoreCREATE3Factory.sh (4)

1-5: Add strict error handling for safer Bash execution
It’s best practice to enable strict mode to fail fast on errors, unset variables, and pipeline failures.
Apply this diff at the top of the file:

 #!/bin/bash
+set -euo pipefail

28-29: Avoid SC2155: separate declaration and assignment
Split the local declaration and assignment to preserve the return value of getFileSuffix:

-  local FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")
+  local FILE_SUFFIX
+  FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 28-28: Declare and assign separately to avoid masking return values.

(SC2155)


39-39: Avoid SC2155: mask return code by declare+assign
Separate the local and assignment for PRIVATE_KEY so that the script exit code isn’t masked:

-  local PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT")
+  local PRIVATE_KEY
+  PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT")
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 39-39: Declare and assign separately to avoid masking return values.

(SC2155)


40-41: Quote variables, declare locals, and unify indentation

  1. Use spaces instead of a tab at the start of line 40.
  2. Quote $NETWORK and $PRIVATE_KEY.
  3. Declare RAW_RETURN_DATA and RETURN_CODE with local.
-	RAW_RETURN_DATA=$(PRIVATE_KEY="$PRIVATE_KEY" forge script script/deploy/facets/DeployCREATE3Factory.s.sol -f $NETWORK -vvvv --verify --json --legacy --broadcast --skip-simulation --gas-limit 2000000)
-	RETURN_CODE=$?
+  local RAW_RETURN_DATA
+  local RETURN_CODE
+  RAW_RETURN_DATA=$(PRIVATE_KEY="$PRIVATE_KEY" forge script script/deploy/facets/DeployCREATE3Factory.s.sol \
+    -f "$NETWORK" -vvvv --verify --json --legacy --broadcast --skip-simulation --gas-limit 2000000)
+  RETURN_CODE=$?
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f292674 and afef813.

📒 Files selected for processing (2)
  • script/deploy/deployAndStoreCREATE3Factory.sh (1 hunks)
  • script/deploy/facets/DeployCREATE3Factory.s.sol (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • script/deploy/facets/DeployCREATE3Factory.s.sol
🧰 Additional context used
🧬 Code Graph Analysis (1)
script/deploy/deployAndStoreCREATE3Factory.sh (1)
script/helperFunctions.sh (3)
  • error (2248-2250)
  • getFileSuffix (2064-2074)
  • echoDebug (2239-2247)
🪛 Shellcheck (0.10.0)
script/deploy/deployAndStoreCREATE3Factory.sh

[warning] 28-28: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 39-39: Declare and assign separately to avoid masking return values.

(SC2155)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-unit-tests
🔇 Additional comments (7)
script/deploy/deployAndStoreCREATE3Factory.sh (7)

12-19: No changes needed for blank-line logging or sourcing order beyond the above. The current conventions for log separation and CWD assumptions are acceptable in this repo.


21-23: Reading function arguments correctly
Using local NETWORK="$1" and local ENVIRONMENT="$2" inside the function is appropriate for scoping.


31-36: Debug logging is clear and useful
Using echoDebug to print internal state aids troubleshooting when $DEBUG is enabled.


46-49: Deployment exit check is solid
Verifying RETURN_CODE immediately ensures we don’t proceed on failures. The error message is clear.


61-65: Network existence check is correct
Using jq -e to assert the network key exists and early-return on failure aligns with robust parameter handling.


67-76: Atomic update of networks.json is well-implemented
Leveraging mktemp and jq for an atomic write minimizes risk of corruption.


77-82: Final logging and return are clear
The closing info message and explicit return 0 make the function’s outcome obvious to callers.

Comment thread script/deploy/deployAndStoreCREATE3Factory.sh
Comment thread script/deploy/deployAndStoreCREATE3Factory.sh Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (7)
script/deploy/deployAndStoreCREATE3Factory.sh (7)

1-2: Enable strict mode for robust error handling.

Consider adding set -euo pipefail after the shebang to:

  • Exit immediately on any command failure (-e).
  • Treat unset variables as errors (-u).
  • Prevent subtle bugs in pipelines (-o pipefail).
 #!/bin/bash
+ set -euo pipefail

26-27: Ensure .env file exists to avoid silent failures.

If .env is missing, source .env will error out. Consider adding a guard:

if [[ ! -f .env ]]; then
  error ".env file not found"
  return 1
fi
source .env

29-30: Split declaration and assignment for accurate return codes (SC2155).

Declaring and assigning in one line masks the return code of getFileSuffix. Separate them:

- local FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")
+ local FILE_SUFFIX
+ FILE_SUFFIX=$(getFileSuffix "$ENVIRONMENT")
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 29-29: Declare and assign separately to avoid masking return values.

(SC2155)


32-37: Optional: Combine blank lines and unify logging style.

You currently emit multiple blank lines before debug output. You could compress this to a single echo -e "\n" and standardize on info vs debug functions for clarity.


54-56: Quote JSON input and use structured logging.

Wrap inputs in quotes to prevent word splitting, and consider using an info helper:

- FACTORY_ADDRESS=$(echo $RETURN_DATA | jq -r '.deployed.value')
+ FACTORY_ADDRESS=$(echo "$RETURN_DATA" | jq -r '.deployed.value')

- echo "✅ Successfully deployed to address $FACTORY_ADDRESS"
+ echo "[info] ✅ Successfully deployed CREATE3Factory at address $FACTORY_ADDRESS"

63-66: Handle missing or unreadable networks.json.

Ensure NETWORKS_JSON_FILE_PATH is set and readable before jq:

if [[ -z "$NETWORKS_JSON_FILE_PATH" || ! -r "$NETWORKS_JSON_FILE_PATH" ]]; then
  error "networks.json not found or unreadable at '$NETWORKS_JSON_FILE_PATH'"
  return 1
fi

80-83: Consistent final logging and exit.

Consider using info for the closing message and compressing blank lines:

- echo "[info] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< CREATE3Factory deployed (please check for warnings)"
- echo ""
- return 0
+ echo "[info] <<< CREATE3Factory deployment complete >>>"
+ echo -e "\n"
+ return 0
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between afef813 and e3dd53a.

📒 Files selected for processing (1)
  • script/deploy/deployAndStoreCREATE3Factory.sh (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
script/deploy/deployAndStoreCREATE3Factory.sh (1)
script/helperFunctions.sh (3)
  • error (2248-2250)
  • getFileSuffix (2064-2074)
  • echoDebug (2239-2247)
🪛 Shellcheck (0.10.0)
script/deploy/deployAndStoreCREATE3Factory.sh

[warning] 29-29: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 40-40: Declare and assign separately to avoid masking return values.

(SC2155)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-unit-tests
🔇 Additional comments (4)
script/deploy/deployAndStoreCREATE3Factory.sh (4)

11-14: Good: Validate function parameters.

The check ensures the required <NETWORK> and <ENVIRONMENT> arguments are provided before proceeding.


21-24: Use local to scope parameters.

Declaring NETWORK and ENVIRONMENT as local variables limits their scope to the function, preventing global pollution.


57-60: Good: Guard against missing or null address.

The check prevents storing an empty or invalid address in networks.json.


69-75: Declare tmpfile as local and handle mktemp failures.

- tmpfile=$(mktemp)
+ local tmpfile
+ tmpfile=$(mktemp) || { error "mktemp failed"; return 1; }

Scoping temp files and checking for creation errors improves robustness.

Comment thread script/deploy/deployAndStoreCREATE3Factory.sh
Comment thread script/deploy/deployAndStoreCREATE3Factory.sh
mirooon
mirooon previously approved these changes Apr 22, 2025
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
script/deploy/deployAndStoreCREATE3Factory.sh (2)

29-37: Review FILE_SUFFIX usage
You compute FILE_SUFFIX and log it in debug, but you never apply it when reading/writing networks.json. If multi‑environment files (e.g., networks.staging.json) are intended, incorporate FILE_SUFFIX into NETWORKS_JSON_FILE_PATH. Otherwise, consider removing the unused variable.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 29-29: Declare and assign separately to avoid masking return values.

(SC2155)


41-46: Improve quoting and logging of deployment output

  1. Quote $NETWORK in the forge command to guard against special chars (-f "$NETWORK").
  2. Log the raw return data under debug before cleaning.
  3. Fix the echo quoting for CLEAN_RETURN_DATA.

Proposed diff:

- RAW_RETURN_DATA=$(PRIVATE_KEY="$PRIVATE_KEY" forge script script/deploy/facets/DeployCREATE3Factory.s.sol -f $NETWORK -vvvv --verify --json --legacy --broadcast --skip-simulation --gas-limit 2000000)
+ RAW_RETURN_DATA=$(PRIVATE_KEY="$PRIVATE_KEY" forge script script/deploy/facets/DeployCREATE3Factory.s.sol \
+   -f "$NETWORK" -vvvv --verify --json --legacy --broadcast --skip-simulation --gas-limit 2000000)
RETURN_CODE=$?
+ echoDebug "RAW_RETURN_DATA: $RAW_RETURN_DATA"
  unset PRIVATE_KEY
- CLEAN_RETURN_DATA=$(echo "$RAW_RETURN_DATA" | sed 's/^.*{\"logs/{\"logs/')
- echo "CLEAN_RETURN_DATA: "$CLEAN_RETURN_DATA""
+ CLEAN_RETURN_DATA=$(echo "$RAW_RETURN_DATA" | sed 's/^.*{"logs/{"logs/')
+ echoDebug "CLEAN_RETURN_DATA: $CLEAN_RETURN_DATA"
RETURN_DATA=$(echo "$CLEAN_RETURN_DATA" | jq -r '.returns' 2>/dev/null)
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 45-45: The surrounding quotes actually unquote this. Remove or escape them.

(SC2027)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c813006 and 0f0d97e.

📒 Files selected for processing (1)
  • script/deploy/deployAndStoreCREATE3Factory.sh (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
script/deploy/deployAndStoreCREATE3Factory.sh (1)
Learnt from: 0xDEnYO
PR: lifinance/contracts#1113
File: script/deploy/deployAndStoreCREATE3Factory.sh:40-46
Timestamp: 2025-04-23T02:46:41.926Z
Learning: For lifinance/contracts repository, do not flag or suggest splitting bash variable declarations from assignments (e.g., `local VAR=$(command)` vs `local VAR; VAR=$(command)`). The team is aware of the potential masking of return codes (SC2155) and has made a conscious decision to use the combined syntax.
🧬 Code Graph Analysis (1)
script/deploy/deployAndStoreCREATE3Factory.sh (1)
script/helperFunctions.sh (3)
  • error (2248-2250)
  • getFileSuffix (2064-2074)
  • echoDebug (2239-2247)
🪛 Shellcheck (0.10.0)
script/deploy/deployAndStoreCREATE3Factory.sh

[warning] 29-29: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 40-40: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 45-45: The surrounding quotes actually unquote this. Remove or escape them.

(SC2027)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-unit-tests
🔇 Additional comments (9)
script/deploy/deployAndStoreCREATE3Factory.sh (9)

7-8: Helper functions sourced before use – good move
Sourcing script/helperFunctions.sh (which defines error(), echoDebug(), etc.) before you call error in the parameter check ensures the helper is available and avoids undefined‑command failures.


11-14: Parameter validation guard is properly placed
Checking "$#" before reading "$1"/"$2" protects against missing arguments. The use of return 1 inside the function is also correct for signaling failure in a sourced script.


21-24: Local variable declarations for arguments
Using local NETWORK="$1" and local ENVIRONMENT="$2" scopes these names to the function—great for preventing pollution of the outer shell environment.


29-30: SC2155 static analysis is intentionally disabled here
Per team conventions, you’re combining declaration and assignment for FILE_SUFFIX. We’ll respect the existing learning and not split these.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 29-29: Declare and assign separately to avoid masking return values.

(SC2155)


40-40: SC2155 at PRIVATE_KEY assignment is acceptable
Given the repository’s decision to combine declaration and assignment, no change is needed here.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 40-40: Declare and assign separately to avoid masking return values.

(SC2155)


60-66: Deployed address extraction and validation flow is solid
You correctly parse .deployed.value and guard against empty or null addresses before proceeding.


75-83: Atomic update of JSON via temporary file is best practice
Using mktemp, piping jq output into it, and then mv-ing over the original ensures you won’t corrupt networks.json on failures.


83-85: Confirmation log after storing address
The success message clearly communicates that the new address was persisted. Good for tracing deployment outcomes.


68-72:

Details

❓ Verification inconclusive

Verify NETWORKS_JSON_FILE_PATH is defined in config
You reference $NETWORKS_JSON_FILE_PATH to locate networks.json. Ensure this variable is set by script/config.sh. You can run:

Expect to see a line defining or exporting that variable.


🏁 Script executed:

#!/bin/bash
# Check that NETWORKS_JSON_FILE_PATH is exported in config.sh
grep -R "NETWORKS_JSON_FILE_PATH" script/config.sh

Length of output: 100


Let's locate where config.sh actually lives and verify whether NETWORKS_JSON_FILE_PATH is defined anywhere in the repo:


🏁 Script executed:

#!/bin/bash
# 1) Find all config.sh files in the repo
echo "== CONFIG.SH Locations =="
fd --hidden config.sh

# 2) Search for any definition or export of NETWORKS_JSON_FILE_PATH
echo "== NETWORKS_JSON_FILE_PATH Definitions =="
grep -R "NETWORKS_JSON_FILE_PATH" .

Length of output: 6983


Gathering where and how NETWORKS_JSON_FILE_PATH is actually set and whether config.sh is sourced:


🏁 Script executed:

#!/bin/bash
echo "== config.sh files =="
fd --hidden config.sh

echo "== ‘source’ usage in scripts =="
grep -R "source" -n script

echo "== deployAndStoreCREATE3Factory.sh top (1–50) =="
sed -n '1,50p' script/deploy/deployAndStoreCREATE3Factory.sh

echo "== config.example.sh (1–200) =="
sed -n '1,200p' script/config.example.sh

Length of output: 14557


Ensure script/config.sh Defines NETWORKS_JSON_FILE_PATH
I couldn’t find a script/config.sh in the repo—even though all deploy scripts source it at runtime. Please confirm that you’ve created script/config.sh (for example, by copying script/config.example.sh) and that it includes a line such as:

NETWORKS_JSON_FILE_PATH="$(dirname "$0")/../config/networks.json"

Then verify with:

grep -R "NETWORKS_JSON_FILE_PATH" script/config.sh

Comment thread script/deploy/deployAndStoreCREATE3Factory.sh Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
script/deploy/deployAndStoreCREATE3Factory.sh (2)

1-2: Consider enabling strict mode for more robust error handling.

Adding set -euo pipefail (or at least set -e and set -u) after the shebang can help catch unhandled errors, undefined variables, and pipeline failures early in this script.


40-46: Improve indentation consistency and quoting in the deployment block.

  • Lines 41–42 and 44–46 use a tab for indentation; convert these to two spaces to match the rest of the function.
  • Quote the $NETWORK variable in the Forge CLI invocation to guard against unexpected whitespace.
  • Consider scoping RAW_RETURN_DATA, RETURN_CODE, CLEAN_RETURN_DATA, and RETURN_DATA as local to avoid leaking them into the global namespace.

Example diff:

-  local PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT")
-	RAW_RETURN_DATA=$(PRIVATE_KEY="$PRIVATE_KEY" forge script script/deploy/facets/DeployCREATE3Factory.s.sol -f $NETWORK -vvvv --verify --json --legacy --broadcast --skip-simulation --gas-limit 2000000)
-	RETURN_CODE=$?
-  unset PRIVATE_KEY
-	CLEAN_RETURN_DATA=$(echo "$RAW_RETURN_DATA" | sed 's/^.*{\"logs/{\"logs/')
-  echo "CLEAN_RETURN_DATA: "$CLEAN_RETURN_DATA""
-	RETURN_DATA=$(echo "$CLEAN_RETURN_DATA" | jq -r '.returns' 2>/dev/null)
+  local PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT")
+  local RAW_RETURN_DATA=$(PRIVATE_KEY="$PRIVATE_KEY" forge script script/deploy/facets/DeployCREATE3Factory.s.sol \
+    -f "$NETWORK" -vvvv --verify --json --legacy --broadcast --skip-simulation --gas-limit 2000000)
+  local RETURN_CODE=$?
+  unset PRIVATE_KEY
+  local CLEAN_RETURN_DATA=$(echo "$RAW_RETURN_DATA" | sed 's/^.*{"logs/{"logs/')
+  echo "CLEAN_RETURN_DATA: $CLEAN_RETURN_DATA"
+  local RETURN_DATA=$(echo "$CLEAN_RETURN_DATA" | jq -r '.returns' 2>/dev/null)
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 40-40: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 45-45: The surrounding quotes actually unquote this. Remove or escape them.

(SC2027)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f0d97e and 398e73a.

📒 Files selected for processing (1)
  • script/deploy/deployAndStoreCREATE3Factory.sh (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
script/deploy/deployAndStoreCREATE3Factory.sh (1)
Learnt from: 0xDEnYO
PR: lifinance/contracts#1113
File: script/deploy/deployAndStoreCREATE3Factory.sh:40-46
Timestamp: 2025-04-23T02:46:41.926Z
Learning: For lifinance/contracts repository, do not flag or suggest splitting bash variable declarations from assignments (e.g., `local VAR=$(command)` vs `local VAR; VAR=$(command)`). The team is aware of the potential masking of return codes (SC2155) and has made a conscious decision to use the combined syntax.
🧬 Code Graph Analysis (1)
script/deploy/deployAndStoreCREATE3Factory.sh (1)
script/helperFunctions.sh (3)
  • error (2248-2250)
  • getFileSuffix (2064-2074)
  • echoDebug (2239-2247)
🪛 Shellcheck (0.10.0)
script/deploy/deployAndStoreCREATE3Factory.sh

[warning] 29-29: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 40-40: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 45-45: The surrounding quotes actually unquote this. Remove or escape them.

(SC2027)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-unit-tests
🔇 Additional comments (9)
script/deploy/deployAndStoreCREATE3Factory.sh (9)

11-14: Parameter validation looks good.

The script correctly checks for at least two arguments and uses the error helper to report usage issues. No further changes needed here.


29-30: Local FILE_SUFFIX assignment is correct.

The function-suffix logic is encapsulated and FILE_SUFFIX is properly scoped. Nice use of getFileSuffix.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 29-29: Declare and assign separately to avoid masking return values.

(SC2155)


32-36: Informative debug logging.

Using echoDebug to output internal state is helpful when DEBUG=true. This improves observability without cluttering normal runs.


49-52: Return-code check is correctly ordered.

Verifying $RETURN_CODE before inspecting RETURN_DATA prevents misleading “no data found” errors when the Forge script actually failed.


55-58: Return-data validation is solid.

Checking for empty or null return data ensures the deployment script returned expected values before proceeding.


61-67: Deployed address extraction and validation are correct.

You extract FACTORY_ADDRESS from the JSON and guard against missing or null values. Clear user feedback with the and error messages improves maintainability.


69-73: Networks.json existence check is well-implemented.

Using jq -e to verify the network key before updating avoids silent failures or corrupting the configuration file.


76-82: Safe JSON update with a temporary file.

The workflow of writing to a mktemp file and moving it back ensures atomic updates for networks.json. Good job handling errors and cleanup.


84-86: Final storage and user feedback.

Moving the temp file into place and echoing a success message completes the flow nicely. The quotes around variables prevent word-splitting issues.

@0xDEnYO 0xDEnYO merged commit b74de37 into main Apr 28, 2025
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants