Conversation
WalkthroughAdds ABI entry for a new claim function, implements AngleMerklDistributor validator with customization and validation for claim, registers it in the loader, and introduces a unit test validating the claim parameters flow. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Loader
participant LR as GlobalValidatorRegistry
participant AMD as AngleMerklDistributor
Dev->>AMD: NewAngleMerklDistributor()
AMD-->>Dev: *instance*
Dev->>LR: Register(AMD.GetProtocolID(), AMD)
LR-->>Dev: ok
sequenceDiagram
autonumber
actor Client
participant VF as Validator (AMD)
participant ABI as ABIFunction
participant ETH as types.Function
Client->>VF: CustomizeFunctions(ETH, ABI) for "claim"
VF->>ABI: Set description, annotate params (users, tokens, amounts, proofs)
ABI-->>Client: Customized metadata
Client->>VF: ValidateTransaction("claim", params)
alt claim validation
VF->>VF: validateClaimTransaction(params)
VF-->>Client: nil (if 'users' present)
else other function
VF-->>Client: nil
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (5)
abi/angle_merkl_distributor.json (1)
20-23: Confirm proofs dimensionality (bytes32[][]) vs. actual contract signature.The test passes a flat []string for proofs, while the ABI declares bytes32[][]. If the builder enforces ABI shapes, this mismatch will break encoding at runtime. Verify whether the contract expects bytes32[] or bytes32[][]. Adjust either the ABI or input normalization accordingly.
Would you like me to normalize flat proofs to [][] at validation time if the ABI keeps bytes32[][]?
ethereum/angle_merkl_distributor.go (3)
19-26: Nit: Proper-case “Merkl” in description.Small polish for user-facing text.
Apply:
- f.Description = "Claim tokens from the merkl distributor" + f.Description = "Claim tokens from the Merkl distributor"
37-50: Enrich parameter descriptions with expectations (lengths, units, shape).Clarify required relationships to reduce user error.
Apply:
- case "users": - param.Description = "Array of addresses to claim tokens for" + case "users": + param.Description = "Addresses being claimed for (EIP-55 strings; non-empty)" - case "tokens": - param.Description = "Array of token addresses to claim" + case "tokens": + param.Description = "ERC-20 token addresses; must align 1:1 with amounts" - case "amounts": - param.Description = "Array of amounts to claim" + case "amounts": + param.Description = "Amounts (uint256, as decimals string or number); same length as tokens" - case "proofs": - param.Description = "Array of proofs to claim" + case "proofs": + param.Description = "Merkle proofs; either bytes32[] (flat) or bytes32[][] (per-claim)"
52-60: Validate all required fields, lengths, and proofs shape.Current check only ensures presence of users; weak validation risks malformed transactions.
Apply:
func (a *AngleMerklDistributor) validateClaimTransaction(params map[string]interface{}) error { - // Get users - _, ok := params["users"] - if !ok { - return fmt.Errorf("users are required") - } - - return nil + // users + users, ok := params["users"].([]string) + if !ok || len(users) == 0 { + return fmt.Errorf("users are required and must be a non-empty array") + } + + // tokens and amounts + tokens, tokOK := params["tokens"].([]string) + amts, amtOK := params["amounts"].([]string) + if !tokOK || !amtOK || len(tokens) == 0 || len(amts) == 0 { + return fmt.Errorf("tokens and amounts are required and must be non-empty string arrays") + } + if len(tokens) != len(amts) { + return fmt.Errorf("tokens and amounts must have the same length") + } + + // proofs: accept []string or [][]string + pf, pfOK := params["proofs"] + if !pfOK { + return fmt.Errorf("proofs are required") + } + switch p := pf.(type) { + case []string: + if len(p) == 0 { + return fmt.Errorf("proofs cannot be empty") + } + case [][]string: + if len(p) != len(tokens) { + return fmt.Errorf("proofs length must match tokens length") + } + for i := range p { + if len(p[i]) == 0 { + return fmt.Errorf("proofs[%d] cannot be empty", i) + } + } + default: + return fmt.Errorf("proofs must be []string or [][]string") + } + + return nil }I can also add basic EIP-55 address and uint256 string checks if desired.
ethereum/angle_merkl_distributor_test.go (1)
45-68: Align test input shape for proofs with ABI or validator acceptance.Test passes a flat []string while ABI is bytes32[][]. Either wrap as [][]string with one inner slice or keep flat and rely on validator normalization.
If we keep bytes32[][] in the ABI, update the test to:
- "proofs": []string{ /* ... */ }, + "proofs": [][]string{ + { /* existing proofs... */ }, + },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
abi/angle_merkl_distributor.json(1 hunks)ethereum/angle_merkl_distributor.go(1 hunks)ethereum/angle_merkl_distributor_test.go(1 hunks)ethereum/loader.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
ethereum/loader.go (2)
ethereum/angle_merkl_distributor.go (1)
NewAngleMerklDistributor(11-13)ethereum/validator.go (1)
GlobalValidatorRegistry(59-59)
ethereum/angle_merkl_distributor_test.go (1)
ethereum/angle_merkl_distributor.go (1)
NewAngleMerklDistributor(11-13)
ethereum/angle_merkl_distributor.go (1)
types/protocol.go (1)
Function(20-32)
🔇 Additional comments (2)
abi/angle_merkl_distributor.json (1)
25-29: ABI entry looks consistent and minimal.Name, mutability, and no outputs align with a typical claim function. Good addition.
ethereum/loader.go (1)
106-111: LGTM: Validator registration is correct and ID matches ABI filename.The protocol ID “angle_merkl_distributor” aligns with the ABI name derived from angle_merkl_distributor.json.
| import ( | ||
| "testing" | ||
| ) |
There was a problem hiding this comment.
Fix compile error: use strings.Contains (helper not defined).
The call to contains(...) will not compile.
Apply:
import (
- "testing"
+ "strings"
+ "testing"
)
@@
- if tt.errorContains != "" && !contains(err.Error(), tt.errorContains) {
+ if tt.errorContains != "" && !strings.Contains(err.Error(), tt.errorContains) {Also applies to: 83-85
🤖 Prompt for AI Agents
In ethereum/angle_merkl_distributor_test.go around lines 3-5 (and also at usages
around lines 83-85), the helper contains(...) is undefined causing a compile
error; import the standard "strings" package in the import block and replace
calls to contains(...) with strings.Contains(haystack, needle) (or
strings.Contains(err.Error(), "text") as appropriate) so the code compiles.
Adds basic merkl claims contract ABI support
We only require the claim function, so the rest of the ABI is omitted for brevity.
Summary by CodeRabbit