Conversation
📝 WalkthroughWalkthroughRefactored TDE initial distribution scripts to introduce modular setup utilities, implement time-aware disbursement filtering, and simplify contract management by removing vesting logic. Added environment variables for deployment tracking and timestamp configuration while reorganizing disbursement workflows into dedicated functions. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@script/initial-distribution/src/tde.ts`:
- Around line 56-58: The sequence ensureDelegation(batchConfig);
disburseAll(batchConfig, tdeDisbursementAddress, disbursableRows);
clearDelegation(batchConfig); must ensure clearDelegation always runs; wrap the
disbursement call in a try/finally so clearDelegation(batchConfig) is invoked in
the finally block (after ensureDelegation and regardless of errors from
disburseAll). Update the code around the calls to use try { await
disburseAll(...); } finally { await clearDelegation(batchConfig); } and preserve
awaiting ensureDelegation(...) before the try.
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
script/initial-distribution/.env.examplescript/initial-distribution/src/findPendingRows.tsscript/initial-distribution/src/tde.tsscript/initial-distribution/src/tdeSetup.tsscript/initial-distribution/src/vesting.ts
💤 Files with no reviewable changes (1)
- script/initial-distribution/src/vesting.ts
📜 Review details
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-03-01T13:52:37.088Z
Learnt from: pkoch
Repo: idos-network/contracts PR: 19
File: script/initial-distribution/src/tde.ts:38-48
Timestamp: 2026-03-01T13:52:37.088Z
Learning: In script/initial-distribution, when using getContract({ client: walletClient }), it is possible to call read.* methods on the resulting contract even if walletClient is not explicitly extended with publicActions (as observed in tde.ts and cca.ts with viem 2.23.x). Treat this as an intentional pattern to verify: - confirm that the behavior is supported by the specific viem version and contract bindings, - document any assumptions about publicActions not being required for read operations, - ensure there are no security implications (e.g., unintended read access) and that access controls are still correct, - consider adding comments or tests that demonstrate expected usage and edge cases, and - if this behavior is relied upon in other files, apply the same pattern consistently within the script/initial-distribution directory.
Applied to files:
script/initial-distribution/src/findPendingRows.tsscript/initial-distribution/src/tde.tsscript/initial-distribution/src/tdeSetup.ts
📚 Learning: 2026-02-23T19:57:43.946Z
Learnt from: pkoch
Repo: idos-network/contracts PR: 13
File: src/WhaleDisburser.sol:23-28
Timestamp: 2026-02-23T19:57:43.946Z
Learning: In src/WhaleDisburser.sol, the disburse function intentionally has no access control. Anyone can call disburse(IERC20 token, address beneficiary, uint256 totalAmount, uint64 vestingStart), which is by design. The function uses safeTransferFrom(msg.sender, ...) so it only pulls from the caller's own balance, and no external funds are at risk.
Applied to files:
script/initial-distribution/src/tde.ts
🧬 Code graph analysis (3)
script/initial-distribution/src/findPendingRows.ts (1)
script/initial-distribution/src/csv.ts (1)
DisbursementRow(11-15)
script/initial-distribution/src/tde.ts (6)
script/initial-distribution/src/tdeSetup.ts (4)
setupTdeEnvironment(16-62)fetchDisbursementLogs(100-118)ensureAllowance(64-79)disburseAll(81-98)script/initial-distribution/src/csv.ts (2)
DisbursementRow(11-15)loadDisbursementCsv(34-55)script/initial-distribution/src/modalities.ts (2)
EVMModality(21-32)EVMModality(33-33)script/initial-distribution/src/findPendingRows.ts (1)
findPendingRows(8-31)script/initial-distribution/src/lib.ts (1)
sumOf(53-55)script/initial-distribution/src/batch.ts (1)
ensureDelegation(165-192)
script/initial-distribution/src/tdeSetup.ts (5)
script/initial-distribution/src/lib.ts (6)
requireEnv(3-7)ensureHex(10-16)iso8601ToTimestamp(44-51)receiptFor(70-77)paginatedGetEvents(135-149)requiredArgs(20-31)script/initial-distribution/src/chains.ts (1)
chainSetup(36-51)script/initial-distribution/src/batch.ts (1)
BatchCallerConfig(38-42)script/initial-distribution/src/abis.ts (2)
tdeDisbursementAbi(203-255)erc20Abi(276-323)script/initial-distribution/src/csv.ts (1)
DisbursementRow(11-15)
🔇 Additional comments (3)
script/initial-distribution/src/findPendingRows.ts (1)
12-30: Good rename and count-tracking cleanup.
logCountsByKey/pendingRowsmakes intent clearer, and the decrement logic still correctly handles duplicate disbursements.script/initial-distribution/.env.example (1)
22-29: Config additions are clear and aligned with runtime behavior.These new env vars are well-described and map cleanly to deployment-block scanning, batch execution, and TDE-time filtering.
script/initial-distribution/src/tdeSetup.ts (1)
40-50:⚠️ Potential issue | 🔴 CriticalFix contract instantiation for read operations: walletClient does not support
.readmethods.
getContract({ client: walletClient })does not include.readmethods in viem v2.23.x—onlypublicClientor{ public: publicClient, wallet: walletClient }provide read access. Lines 40–50 callcontract.read.IDOS_TOKEN()and line 71 callscontract.read.allowance()on walletClient-only instances, which violates viem's API contract.Fix by either:
- Extending walletClient with
publicActions:walletClient.extend(publicActions)- Creating read contracts with publicClient:
getContract({ client: publicClient, ... })- Using the dual-client pattern:
getContract({ client: { public: publicClient, wallet: walletClient }, ... })⛔ Skipped due to learnings
Learnt from: pkoch Repo: idos-network/contracts PR: 19 File: script/initial-distribution/src/tde.ts:38-48 Timestamp: 2026-03-01T13:52:37.088Z Learning: In the idos-network/contracts repository, the team uses `getContract({ client: walletClient })` and successfully calls `.read.*` methods on the resulting contract instances in viem 2.23.x, even though the walletClient is not explicitly extended with publicActions. This pattern is used throughout script/initial-distribution/src/ (tde.ts, cca.ts).
Summary by CodeRabbit
New Features
Changes
Chores