Skip to content

Techengme/myc 3829 eth purchases automated split distribute#1008

Open
techeng322 wants to merge 3 commits intomainfrom
techengme/myc-3829-eth-purchases-automated-split-distribute
Open

Techengme/myc 3829 eth purchases automated split distribute#1008
techeng322 wants to merge 3 commits intomainfrom
techengme/myc-3829-eth-purchases-automated-split-distribute

Conversation

@techeng322
Copy link
Copy Markdown
Collaborator

@techeng322 techeng322 commented Dec 27, 2025

Summary by CodeRabbit

  • Refactor
    • Optimized internal transaction handling for split distributions to consolidate call composition logic before execution.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown

vercel bot commented Dec 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
in-process Ready Ready Preview Dec 27, 2025 4:49pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 27, 2025

📝 Walkthrough

Walkthrough

The changes refactor split fund distribution from a direct execution pattern to a call composition pattern. The new distributeCall utility generates a distribution call object for 0xSplits contracts, while collectMoment now batches this call with other operations before sending the transaction, replacing the previously standalone distributeSplitFunds function.

Changes

Cohort / File(s) Summary
Call composition refactoring
lib/moment/collectMoment.ts
Replaces distributeSplitFunds import with distributeCall; converts split fund handling from direct execution to call array composition; changes calls array type from readonly to mutable; delays transaction sending until after all calls (including split-related calls) are prepared.
Split distribution utilities
lib/splits/distributeCall.ts, lib/splits/distributeSplitFunds.ts
New function distributeCall generates distribution call data for 0xSplits contracts and returns a Call object; removed function distributeSplitFunds that previously executed split distributions directly via sendUserOperation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A split that once flew quick and swift,
Now dances in the batch—a methodic gift!
Call by call we compose the way,
Then send them all in one grand fray! 🎨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title refers to automated split distribution functionality, which is core to the changes (replacing distributeSplitFunds with distributeCall integration), but uses cryptic naming ('Techengme/myc 3829') and lacks clarity on the specific improvement.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch techengme/myc-3829-eth-purchases-automated-split-distribute

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/moment/collectMoment.ts (1)

15-20: CRITICAL: Move type definitions to types/ folder.

Per the coding guidelines: "CRITICAL: ALL types, interfaces, and type definitions MUST be in the types/ folder. NEVER define types in lib/, components/, hooks/, or any other folder."

The CollectMomentInput and CollectResult interfaces should be moved to the types/ folder immediately.

📁 Suggested file structure

Create types/collectMoment.ts:

import { Address, Hash } from "viem";
import { z } from "zod";
import { collectSchema } from "../lib/schema/collectSchema";

export type CollectMomentInput = z.infer<typeof collectSchema> & { artistAddress: Address };

export interface CollectResult {
  hash: Hash;
  chainId: number;
}

Then update this file's imports:

+import { CollectMomentInput, CollectResult } from "@/types/collectMoment";
-
-export type CollectMomentInput = z.infer<typeof collectSchema> & { artistAddress: Address };
-
-export interface CollectResult {
-  hash: Hash;
-  chainId: number;
-}
🧹 Nitpick comments (1)
lib/splits/distributeCall.ts (1)

15-15: Consider removing the default value for tokenAddress.

The default value USDC_ADDRESS may not be appropriate for all use cases, particularly when distributing native ETH (which requires zeroAddress). While the current caller (collectMoment.ts) correctly passes the appropriate value, having a default might:

  1. Mask the intent and make it less obvious that different tokens require different addresses
  2. Lead to incorrect usage by future callers who might not realize they need to explicitly specify the token

Consider making tokenAddress a required parameter to enforce explicit token specification.

🔎 Proposed change
 export async function distributeCall({
   splitAddress,
-  tokenAddress = USDC_ADDRESS,
+  tokenAddress,
   smartAccount,
 }: {
   splitAddress: Address;
-  tokenAddress?: Address;
+  tokenAddress: Address;
   smartAccount: EvmSmartAccount;
 }): Promise<Call<unknown, { [key: string]: unknown }>> {
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9effe5 and d0d6148.

📒 Files selected for processing (3)
  • lib/moment/collectMoment.ts
  • lib/splits/distributeCall.ts
  • lib/splits/distributeSplitFunds.ts
💤 Files with no reviewable changes (1)
  • lib/splits/distributeSplitFunds.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)

**/*.{ts,tsx}: CRITICAL: Every function MUST be in its own separate file with the file name matching the function name (e.g., getMaxBlockTimestamp.ts exports only getMaxBlockTimestamp). NO exceptions for helper functions, type guards, or utility functions. If a file contains multiple functions, split them immediately.
CRITICAL: ALL types, interfaces, and type definitions MUST be in the types/ folder. NEVER define types in lib/, components/, hooks/, or any other folder. If a type is found outside types/, move it immediately.
Use TypeScript types and interfaces consistently. Avoid any types; use unknown when type is truly unknown.
Follow consistent naming conventions: use camelCase for variables and functions, PascalCase for components and classes, UPPER_SNAKE_CASE for constants.

Files:

  • lib/splits/distributeCall.ts
  • lib/moment/collectMoment.ts
lib/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)

Functions in lib/[feature]/ should be pure utility functions, API calls, or data transformations. One function per file with file name matching function name.

Files:

  • lib/splits/distributeCall.ts
  • lib/moment/collectMoment.ts
🧬 Code graph analysis (2)
lib/splits/distributeCall.ts (3)
lib/consts.ts (2)
  • USDC_ADDRESS (33-35)
  • CHAIN_ID (20-20)
lib/viem/publicClient.ts (2)
  • publicClient (16-16)
  • getPublicClient (7-14)
lib/splits/getSplitsClient.ts (1)
  • getSplitsClient (4-15)
lib/moment/collectMoment.ts (3)
lib/consts.ts (3)
  • CHAIN_ID (20-20)
  • USDC_ADDRESS (33-35)
  • IS_TESTNET (12-12)
lib/splits/distributeCall.ts (1)
  • distributeCall (13-38)
lib/coinbase/sendUserOperation.ts (1)
  • sendUserOperation (15-43)
🔇 Additional comments (3)
lib/moment/collectMoment.ts (2)

70-76: Clean refactoring of transaction sending logic.

The refactoring successfully delays transaction sending until all calls are prepared, maintaining a clear separation between call composition and execution. This makes the code more maintainable and allows for proper batching of operations.


61-66: This batching pattern is supported by 0xSplits.

The 0xSplits SDK supports combining collect and distribute operations in a single transaction via its multicall functionality. Funds deposited into a split remain available as contract balance immediately, and the explicit distribute call in the same transaction will properly distribute those funds to split recipients.

lib/splits/distributeCall.ts (1)

13-38: Implementation correctly uses 0xSplits SDK.

The function properly:

  • Initializes the public client with the correct chain ID
  • Creates a splits client instance
  • Generates distribution call data with the smart account as distributor
  • Returns a well-formed Call object for batch execution

The implementation follows the established patterns in the codebase and integrates cleanly with the Coinbase CDP smart wallet system.

@@ -0,0 +1,38 @@
import { Address, Hash } from "viem";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused import.

The Hash type is imported but never used in this file.

🔎 Proposed fix
-import { Address, Hash } from "viem";
+import { Address } from "viem";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { Address, Hash } from "viem";
import { Address } from "viem";
🤖 Prompt for AI Agents
In lib/splits/distributeCall.ts around line 1, the import statement brings in
both Address and Hash from "viem" but the Hash type is never used; remove the
unused Hash identifier from the import so it reads only import { Address } from
"viem" (or re-add usage if Hash is actually required), then run linter/tsc to
confirm no unused-import warnings remain.

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.

1 participant