lambdaclass / lambdaclass/eth-agent
Duplicate error handling pattern in safe wrapper methods
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Problem
The safeSend, safeSendUSDC, safeSendUSDT, etc. methods repeat the same error handling pattern.
Location
src/agent/wallet.ts - safeSend* methods
Current Pattern
async safeSendUSDC(...): Promise<SafeSendResult> {
try {
const result = await this.sendUSDC(...);
return { success: true, result };
} catch (error) {
return { success: false, error: ... };
}
}
// Repeated for each token type
Recommendation
Extract to a helper function or use a decorator pattern:
function wrapSafe<T>(fn: () => Promise<T>): Promise<SafeResult<T>> {
try {
const result = await fn();
return { success: true, result };
} catch (error) {
return { success: false, error: normalizeError(error) };
}
}
// Usage
safeSendUSDC = (...args) => wrapSafe(() => this.sendUSDC(...args));
Priority
Low - Code quality / DRY principle
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/agent/wallet.ts by reading the safeSend* methods and their corresponding send methods to compare the repeated error-handling behavior. Identify whether the existing result and error shapes can share one helper without changing public behavior. Done means the duplicated pattern is removed across the safe wrapper methods while successful sends and normalized failures remain equivalent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100