Skip to content

Comments

Payment Escrow System #30#41

Merged
Xaxxoo merged 5 commits intoStarkHive:mainfrom
aji70:main
Jun 3, 2025
Merged

Payment Escrow System #30#41
Xaxxoo merged 5 commits intoStarkHive:mainfrom
aji70:main

Conversation

@aji70
Copy link
Contributor

@aji70 aji70 commented Jun 2, 2025

This PR introduces a secure and flexible escrow system to manage job payments on the platform. It enables automatic escrow funding upon job acceptance and supports milestone-based payouts, multi-token support, dispute resolution, and refund handling, all with strong security guarantees. closes #30

Summary by CodeRabbit

  • New Features

    • Added ERC20 token support for job budgets and payments, enabling token-based deposits, payments to applicants, and balance checks.
    • Introduced a mock USDC token contract for testing and integration purposes.
  • Bug Fixes

    • Improved test coverage to verify correct token transfers during job creation, approval, and cancellation processes.
  • Tests

    • Enhanced tests to simulate ERC20 token interactions, including minting, approvals, and balance assertions for realistic job and payment flows.

@coderabbitai
Copy link

coderabbitai bot commented Jun 2, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update integrates ERC20 token support into the Jobs contract, introducing token-based escrow for job budgets and payments. It adds a mock ERC20 token contract (MockUSDC), updates the Jobs contract and its interface to manage token transfers, and enhances tests to verify token interactions during job creation and approval.

Changes

File(s) Change Summary
src/contracts/Jobs.cairo Added ERC20 token integration: updated create_job and approve_submission to handle token transfers; added deposit, pay_applicant, and check_balance functions; introduced JobCancelled event and cancel_job with token refund.
src/contracts/MockUSDC.cairo Added new mock ERC20 token contract with mint, transfer, approval, balance, and decimals support; includes Ownable and ERC20 components.
src/interfaces/IJobs.cairo Extended IJobs interface with token parameter in existing methods and added pay_applicant, deposit, and check_balance methods.
src/lib.cairo Added public module declaration for MockUSDC under contracts module.
tests/test_contract.cairo Updated tests to deploy MockUSDC, mint tokens, approve transfers, and verify token balance changes during job creation, approval, and cancellation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant JobsContract
    participant ERC20Token

    User->>ERC20Token: approve(JobsContract, amount)
    User->>JobsContract: create_job(token, budget=amount)
    JobsContract->>ERC20Token: transfer_from(User, JobsContract, amount)
    ERC20Token-->>JobsContract: transfer success

    Note over JobsContract: Job budget escrowed in tokens

    participant Applicant
    Applicant->>JobsContract: apply_for_job()
    User->>JobsContract: approve_submission(token, job_id, applicant_id)
    JobsContract->>ERC20Token: transfer(Applicant, amount)
    ERC20Token-->>JobsContract: transfer success
Loading

Assessment against linked issues

Objective Addressed Explanation
Multi-token support (ETH, USDC, STRK, other ERC-20s) (#30)
Automatic escrow creation when job is accepted (#30)
Token allowance validation and precise decimal handling for different tokens (#30)
Milestone-based payment, dispute resolution, emergency withdrawal, fee/refund mechanisms (#30) These features are not implemented in this PR.
Reentrancy protection (#30) No explicit reentrancy guards or protections are visible in the code.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Introduction of MockUSDC contract (src/contracts/MockUSDC.cairo) Added for testing and token simulation; not explicitly required by the escrow system objectives.

Suggested reviewers

  • Cybermaxi7

Poem

A rabbit hopped through Cairo code,
Bringing tokens to the Jobs abode.
With escrow safe and balances tight,
MockUSDC joins the test’s delight.
Now payments flow in ERC’s stream,
A blockchain bunny’s escrow dream!
🐇💰


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e48d07d and d26b26f.

📒 Files selected for processing (1)
  • src/lib.cairo (1 hunks)

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.

Copy link

@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: 6

🔭 Outside diff range comments (4)
src/contracts/Jobs.cairo (1)

221-237: ⚠️ Potential issue

Critical: Add refund mechanism for cancelled jobs.

The cancel_job function doesn't refund the escrowed budget back to the job owner. This could result in funds being permanently locked in the contract.

 fn cancel_job(ref self: ContractState, job_id: u256, applicant_id: u256) {
     let caller = get_caller_address();
     let mut job = self.get_job(job_id);
     let mut applicant = self.job_applicants.read((job_id, applicant_id));
 
     assert(job.owner == caller, 'Not your job');
 
     applicant.application_status = ApplicationStatus::JobCancelled;
 
     job.status = Status::Cancelled;
+    
+    // Refund the job budget to the owner
+    let success = self.pay_applicant(job.owner, job.budget);
+    assert(success, 'Refund failed');
 
     self.job_applicants.write((job_id, applicant_id), applicant);
tests/test_contract.cairo (3)

285-290: ⚠️ Potential issue

Fix incorrect cheat caller usage.

The stop_cheat_caller_address is called before apply_for_job, but the cheat should be active during the function call.

     cheat_caller_address(contract_address, applicant1, CheatSpan::Indefinite);
 
-    stop_cheat_caller_address(contract_address);
-
     let _applicant1 = dispatcher.apply_for_job(job_id, qualification.clone());
+
+    stop_cheat_caller_address(contract_address);

371-376: ⚠️ Potential issue

Fix incorrect cheat caller usage pattern.

Similar to the previous issue, the cheat should be active during the function call.

     cheat_caller_address(contract_address, applicant1, CheatSpan::Indefinite);
 
-    stop_cheat_caller_address(contract_address);
-
     let _applicant1 = dispatcher.apply_for_job(job_id, qualification.clone());
+
+    stop_cheat_caller_address(contract_address);

461-466: 💡 Verification agent

🧩 Analysis chain

Fix multiple instances of incorrect cheat caller usage.

There are several more instances of the same pattern where stop_cheat_caller_address is called before the function that needs the cheat.

Run the following script to find all instances of this pattern:

Also applies to: 545-550


🏁 Script executed:

#!/bin/bash
# Description: Find all instances where stop_cheat_caller_address is called before apply_for_job

# Search for the pattern where stop_cheat_caller_address appears before apply_for_job
rg -B 5 -A 5 "stop_cheat_caller_address.*\n\s*let.*apply_for_job" tests/test_contract.cairo

Length of output: 285


🏁 Script executed:

#!/bin/bash
# Improved script: for each stop_cheat_caller_address, check the next 5 lines for apply_for_job
grep -n "stop_cheat_caller_address" tests/test_contract.cairo | cut -d: -f1 | while read -r start; do
  end=$((start + 5))
  snippet=$(sed -n "${start},${end}p" tests/test_contract.cairo)
  if echo "$snippet" | grep -q "apply_for_job"; then
    echo "Found pattern at lines ${start}-${end}:"
    echo "$snippet"
    echo
  fi
done

Length of output: 30921


Incorrect cheat context around apply_for_job calls

Several tests in tests/test_contract.cairo call

stop_cheat_caller_address(contract_address);
let _applicant = dispatcher.apply_for_job(...);
stop_cheat_caller_address(contract_address);

without first entering a cheat context, so the call runs under the default caller. Please wrap each apply_for_job in a cheat_caller_address(...) and only then stop the cheat.

Instances to fix:

  • tests/test_contract.cairo: lines 287–292
  • tests/test_contract.cairo: lines 373–378
  • tests/test_contract.cairo: lines 463–468
  • tests/test_contract.cairo: lines 547–552

Example correction:

- stop_cheat_caller_address(contract_address);
- let _applicant1 = dispatcher.apply_for_job(job_id, qualification.clone());
- stop_cheat_caller_address(contract_address);
+ cheat_caller_address(contract_address, applicant1, CheatSpan::Indefinite);
+ let _applicant1 = dispatcher.apply_for_job(job_id, qualification.clone());
+ stop_cheat_caller_address(contract_address);
🧹 Nitpick comments (6)
src/interfaces/IJobs.cairo (1)

16-18: Consider clarifying the deposit function signature.

The deposit function signature might be clearer if it explicitly indicated the flow of funds. Consider renaming parameters or adding documentation to clarify that this deposits tokens FROM the depositor TO the contract.

src/contracts/Jobs.cairo (2)

200-220: Missing milestone-based payment functionality.

The PR objectives mention "milestone-based payouts", but the current implementation only supports a single payment upon job approval. Consider implementing milestone tracking and partial payment functionality to align with the stated objectives.

Would you like me to help design the milestone payment structure or open an issue to track this feature?


88-91: Missing multi-token support functionality.

The PR objectives mention "multi-token support", but the current implementation only supports a single token set during contract construction. Consider implementing a mechanism to support multiple payment tokens per job.

src/contracts/MockUSDC.cairo (1)

47-51: Consider making token initialization more flexible.

The constructor hard-codes the token name and symbol as "USDC". For a mock token used in testing, it might be beneficial to make these configurable.

Consider accepting name and symbol as constructor parameters:

-    fn constructor(ref self: ContractState, recipient: ContractAddress, owner: ContractAddress) {
-        self.erc20.initializer(format!("USDC"), format!("USDC"));
+    fn constructor(ref self: ContractState, recipient: ContractAddress, owner: ContractAddress, name: ByteArray, symbol: ByteArray) {
+        self.erc20.initializer(name, symbol);
         self.ownable.initializer(owner);
         self.custom_decimals.write(8);
     }
tests/test_contract.cairo (2)

33-33: Pass token name and symbol as constructor parameters.

If the MockUSDC constructor is updated to accept name and symbol parameters (as suggested in the previous review), this line should be updated accordingly.

-    let (contract_address, _) = contract_class.deploy(@array![owner.into(), owner.into()]).unwrap();
+    let (contract_address, _) = contract_class.deploy(@array![owner.into(), owner.into(), format!("USDC").into(), format!("USDC").into()]).unwrap();

78-79: Simplify the balance assertion.

The parentheses around the subtraction are unnecessary.

-    let balanceafter = token_dispatcher.balance_of(user);
-    assert(balanceafter == (balanceb4 - budget), 'balance error');
+    let balance_after = token_dispatcher.balance_of(user);
+    assert(balance_after == balanceb4 - budget, 'balance error');
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 494365e and 7ed4289.

📒 Files selected for processing (5)
  • src/contracts/Jobs.cairo (6 hunks)
  • src/contracts/MockUSDC.cairo (1 hunks)
  • src/interfaces/IJobs.cairo (1 hunks)
  • src/lib.cairo (1 hunks)
  • tests/test_contract.cairo (11 hunks)
🔇 Additional comments (4)
src/lib.cairo (1)

3-3: LGTM!

Clean addition of the MockUSDC module declaration.

src/contracts/MockUSDC.cairo (2)

77-112: External implementation delegates correctly to ERC20 component.

The implementation correctly delegates all calls to the underlying ERC20 component methods. Once the interface method names are fixed, the implementation method names should be updated accordingly.

Note: After fixing the interface method names, ensure to update the implementation method names to match.


34-34: ⚠️ Potential issue

Add missing semicolon after the storage field.

Apply this diff to fix the syntax:

-        custom_decimals: u8 // Add custom decimals storage
+        custom_decimals: u8, // Add custom decimals storage

Likely an incorrect or invalid review comment.

tests/test_contract.cairo (1)

401-402: Verify the applicant receives the full budget amount.

Good test coverage! The test correctly verifies that the applicant receives the full budget amount after job approval.

Copy link

@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

♻️ Duplicate comments (1)
tests/test_contract.cairo (1)

385-387: Check for duplicate assertion issue resolution.

Based on past review comments, there was a duplicate balance assertion issue. The current code shows only one balance assertion, indicating the issue was resolved.

🧹 Nitpick comments (3)
src/contracts/MockUSDC.cairo (1)

37-42: Consider more realistic initialization parameters.

The constructor hardcodes "USDC" for both name and symbol, and sets decimals to 8. While functional for testing, consider making these configurable.

 #[constructor]
-fn constructor(ref self: ContractState, recipient: ContractAddress, owner: ContractAddress) {
-    self.erc20.initializer(format!("USDC"), format!("USDC"));
+fn constructor(ref self: ContractState, name: ByteArray, symbol: ByteArray, decimals: u8, owner: ContractAddress) {
+    self.erc20.initializer(name, symbol);
     self.ownable.initializer(owner);
-    self.custom_decimals.write(8);
+    self.custom_decimals.write(decimals);
 }
tests/test_contract.cairo (2)

29-36: Consider parameterizing the ERC20 deployment.

The deploy_erc20 function hardcodes the owner address. Consider making it more flexible for different test scenarios.

-fn deploy_erc20() -> IExternalDispatcher {
-    let owner: ContractAddress = contract_address_const::<'owner'>();
+fn deploy_erc20(owner: ContractAddress) -> IExternalDispatcher {
     
     let contract_class = declare("MockUsdc").unwrap().contract_class();
     let (contract_address, _) = contract_class.deploy(@array![owner.into(), owner.into()]).unwrap();
     
     IExternalDispatcher { contract_address }
 }

51-68: Improve caller address management pattern.

The test properly uses the start/stop cheat caller address pattern, but the logic could be cleaner. The token minting should happen under the owner's context consistently.

-    let sender: ContractAddress = contract_address_const::<'owner'>();
-    start_cheat_caller_address(contract_address, sender);
+    let owner: ContractAddress = contract_address_const::<'owner'>();
+    start_cheat_caller_address(erc20_address, owner);
 
-    let token_dispatcher = IERC20Dispatcher { contract_address: erc20_address };
-    let token_idispatcher = IExternalDispatcher { contract_address: erc20_address };
+    let token_dispatcher = IERC20Dispatcher { contract_address: erc20_address };
+    let token_idispatcher = IExternalDispatcher { contract_address: erc20_address };
 
     token_idispatcher.mint(user, 20000);
 
-    stop_cheat_caller_address(contract_address);
+    stop_cheat_caller_address(erc20_address);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7ed4289 and c46bb5d.

📒 Files selected for processing (4)
  • src/contracts/Jobs.cairo (7 hunks)
  • src/contracts/MockUSDC.cairo (1 hunks)
  • src/interfaces/IJobs.cairo (2 hunks)
  • tests/test_contract.cairo (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/interfaces/IJobs.cairo
  • src/contracts/Jobs.cairo
🔇 Additional comments (7)
src/contracts/MockUSDC.cairo (2)

4-7: LGTM! Clean interface definition.

The IExternal trait provides a clear interface for minting functionality. The method signature is appropriate for a mock token contract.


16-26:

Details

❓ Verification inconclusive

Verify component storage configuration.

The storage structure correctly integrates OpenZeppelin components. However, the custom decimals storage might introduce unnecessary complexity.


🏁 Script executed:

#!/bin/bash
# Description: Check if OpenZeppelin ERC20 already provides decimal customization
# Expected: Find standard decimal configuration options in OpenZeppelin docs

rg -A 5 -B 5 "decimals.*storage" --type cairo || rg -A 5 -B 5 "decimal.*custom" --type cairo

Length of output: 153


Let's search across all .cairo files for any mention of “decimal” to see if the ERC20Component storage already contains a decimals field:


🏁 Script executed:

#!/bin/bash
# Search all Cairo files for any 'decimal' occurrences
rg -n "decimal" -g "*.cairo"

Length of output: 367


Confirm ERC20Component’s decimals handling

I didn’t find any built-in decimals storage or configuration in the local Cairo contracts for ERC20Component. Before keeping custom_decimals, please:

  • Review the OpenZeppelin Cairo ERC20Component implementation (outside this repo) to see if it already exposes or hardcodes a decimals value.
  • If it does, remove the duplicate custom_decimals field and decimals() override.
  • Otherwise, ensure your custom storage is initialized and used consistently without conflicting with the component’s logic.

Locations to check:

  • src/contracts/MockUSDC.cairo: custom_decimals: u8 definition (line 25)
  • src/contracts/MockUSDC.cairo: fn decimals(...) override (lines 54–57)
tests/test_contract.cairo (5)

12-27: LGTM! Improved setup function architecture.

The updated setup function properly deploys both contracts and returns their addresses for use in tests. The separation of concerns with deploy_erc20 helper function improves maintainability.


80-82: LGTM! Proper balance verification.

The test correctly verifies that the user's token balance decreases by the budget amount after job creation, confirming the escrow functionality works as expected.


425-427: LGTM! Proper payment verification.

The test correctly verifies that the applicant receives the budget amount upon approval, confirming the payment functionality works as expected.


73-76:

Details

✅ Verification successful

Verify token parameter integration.

The create_job method now includes the erc20_address parameter, which is good for the escrow functionality. Ensure this aligns with the actual contract interface.


🏁 Script executed:

#!/bin/bash
# Description: Verify that the Jobs contract create_job method signature matches the test calls
# Expected: Find create_job method with token address parameter

ast-grep --pattern $'fn create_job($$$, token: ContractAddress, $$$)' || rg -A 10 "fn create_job" --type cairo

Length of output: 70


To locate the create_job definition and confirm its parameters, let’s search all Cairo files for its signature:


🏁 Script executed:

#!/bin/bash
# Search for the create_job function definition in all .cairo files
rg -n "fn create_job" -g "*.cairo" -A3

Length of output: 504


create_job signature matches contract interface

The create_job function in both src/interfaces/IJobs.cairo and src/contracts/Jobs.cairo already declares token: ContractAddress as its second parameter, so the test call in tests/test_contract.cairo correctly passes erc20_address. No further changes are needed.


418-418:

Details

✅ Verification successful

Verify approve_submission method signature.

The approve_submission method now takes an erc20_address parameter. Ensure this matches the contract implementation.


🏁 Script executed:

#!/bin/bash
# Description: Verify approve_submission method signature in Jobs contract
# Expected: Find method with token address parameter

ast-grep --pattern $'fn approve_submission($$$, token: ContractAddress, $$$)' || rg -A 5 "fn approve_submission" --type cairo

Length of output: 78


🏁 Script executed:

#!/bin/bash
# Search for approve_submission definition and its usage in all Cairo files

echo "Looking for function declaration:"
rg --color=never -n "fn approve_submission" -g '*.cairo' -A5

echo -e "\nLooking for any calls to approve_submission in contract code:"
rg --color=never -n "approve_submission(" -g '*.cairo' -n -A5

Length of output: 1478


approve_submission signature verified

The approve_submission method is defined as:

fn approve_submission(
    ref self: ContractState,
    token: ContractAddress,
    job_id: u256,
    applicant_id: u256,
) { … }

and the test call

dispatcher.approve_submission(erc20_address, job_id, applicant0);

correctly passes erc20_address as the token parameter, followed by job_id and applicant_id. No changes are needed.

Copy link

@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 (1)
tests/test_contract.cairo (1)

40-98: Well-structured token integration test with minor caller address issue.

The test comprehensively covers token minting, approval, job creation, and balance verification. However, there's a redundant stop_cheat_caller_address(contract_address) call on line 67 that doesn't match a corresponding start_cheat_caller_address.

Apply this fix to remove the redundant stop call:

-    stop_cheat_caller_address(contract_address);
+    stop_cheat_caller_address(erc20_address);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c46bb5d and e48d07d.

📒 Files selected for processing (3)
  • src/contracts/Jobs.cairo (9 hunks)
  • src/interfaces/IJobs.cairo (2 hunks)
  • tests/test_contract.cairo (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/interfaces/IJobs.cairo
  • src/contracts/Jobs.cairo
🔇 Additional comments (6)
tests/test_contract.cairo (6)

1-9: LGTM: Import statements are well-structured for token integration.

The imports correctly include all necessary components for ERC20 token testing, including dispatchers, cheat functions, and the MockUSDC interface.


12-27: LGTM: Setup function properly updated for dual contract deployment.

The function correctly returns both the Jobs contract address and ERC20 contract address, which is necessary for the token-integrated tests.


157-495: Comprehensive test coverage for job lifecycle with proper token integration.

The test suite excellently covers the complete job workflow including assignment, submission, and approval with proper token transfer verification. The test_approve_job correctly verifies that the applicant receives the budget tokens upon approval.


477-491: Correct escrow release implementation.

The test properly simulates the escrow release mechanism where tokens are transferred from the contract's escrow to the successful applicant upon job approval.


497-678: Appropriate handling of rejection and change request scenarios.

The tests correctly implement scenarios where tokens remain in escrow during rejection and change requests, which maintains the security of the escrow system.


29-36:

Details

❌ Incorrect review comment

Verify contract name and constructor parameters.

The function declares "MockUsdc" but the import uses "MockUSDC". Ensure the contract name consistency. Also verify that the MockUSDC constructor expects two identical owner parameters.


🏁 Script executed:

#!/bin/bash
# Description: Verify MockUSDC contract name and constructor signature

# Search for MockUSDC contract definition
rg -A 10 -B 5 "contract MockU[sS][dD][cC]"

# Look for constructor implementation
ast-grep --pattern 'fn constructor($$$) {
  $$$
}'

Length of output: 97


🏁 Script executed:

#!/bin/bash
# Search for any Cairo files referencing MockUsdc or MockUSDC
rg -n "MockUsdc" -g '*.cairo'
rg -n "MockUSDC" -g '*.cairo'

# List files containing either spelling
rg -l -g '*.cairo' "MockUsdc|MockUSDC"

# Search for constructor definitions in all .cairo files
rg -n "#\\[constructor\\]" -g '*.cairo'
rg -n "fn constructor" -g '*.cairo'

Length of output: 739


Ignore naming and parameter concerns.

  • The declare("MockUsdc") call matches the inner module name (pub mod MockUsdc) in src/contracts/MockUSDC.cairo.
  • The constructor signature is fn constructor(..., recipient: ContractAddress, owner: ContractAddress). Passing owner.into() twice simply uses the same address for both roles, which is valid for this test.

No changes are required.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@Xaxxoo Xaxxoo left a comment

Choose a reason for hiding this comment

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

LGTM

@Xaxxoo Xaxxoo merged commit 329988c into StarkHive:main Jun 3, 2025
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Payment Escrow System

2 participants