Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds a new Kamiden transaction error logger and integrates it into the ActionSystem error handler to send normalized error payloads to a configured remote /tx-errors endpoint without throwing. Changes
Sequence DiagramsequenceDiagram
participant Client
participant ActionSystem
participant AccountHook as useAccount()
participant Logger as txErrorLogger
participant Kamiden as Kamiden Service
Client->>ActionSystem: transaction fails / throws
ActionSystem->>ActionSystem: mark action as Failed
ActionSystem->>AccountHook: read current account (sender)
rect rgba(100,150,200,0.5)
ActionSystem->>Logger: logTxError(error, { sender, system, method })
Logger->>Logger: normalizeError(error)
Logger->>Logger: build payload, safeStringify (bigint→string)
end
rect rgba(150,100,200,0.5)
Logger->>Kamiden: POST {KAMIDEN_URL}/tx-errors (application/json)
Kamiden-->>Logger: HTTP response (status, ok)
Logger->>Logger: log response / errors (no throw)
end
Logger-->>ActionSystem: Promise<void>
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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: 2
🤖 Fix all issues with AI agents
In `@packages/client/src/clients/kamiden/txErrorLogger.ts`:
- Around line 72-79: The payload sent in txErrorLogger.ts uses the raw error
which JSON.stringify may serialize to {} so message/stack are lost; call the
existing normalizeError(error) (or assign const normalized =
normalizeError(error)) and send that normalized object in the payload (e.g., use
normalized for the payload.error field) so the log includes message/stack/other
normalized properties; update references in the try block where payload is
constructed to use the normalized error shape.
In `@packages/client/src/network/systems/ActionSystem/createActionSystem.ts`:
- Around line 173-179: The error handler assumes useAccount.getState().account
exists and accesses account.operatorAddress, which can be undefined and crash;
update the createActionSystem error path to guard against a missing account by
fetching const account = useAccount.getState().account and using optional
chaining or an early guard (e.g., if (!account) { log.debug('[ActionSystem] No
account available for tx error', { action: action.action, description:
action.description }); return; }) before using account.operatorAddress, and when
calling logTxError pass sender: account?.operatorAddress ?? 'unknown' (or skip
sender) and keep system/method fallbacks using action.action ?? 'unknown' and
action.description ?? 'unknown'.
| const account = useAccount.getState().account; | ||
| log.debug('[ActionSystem] Logging tx error', { operatorAddress: account.operatorAddress, action: action.action, description: action.description }); | ||
| if (account.operatorAddress) { | ||
| logTxError(error, { | ||
| sender: account.operatorAddress, | ||
| system: action.action ?? 'unknown', | ||
| method: action.description ?? 'unknown', |
There was a problem hiding this comment.
Guard against missing account to prevent crashes in the error handler.
useAccount.getState().account may be undefined in some flows; accessing .operatorAddress would throw and break error handling.
🛠️ Proposed fix
- const account = useAccount.getState().account;
- log.debug('[ActionSystem] Logging tx error', { operatorAddress: account.operatorAddress, action: action.action, description: action.description });
- if (account.operatorAddress) {
+ const account = useAccount.getState().account;
+ const operatorAddress = account?.operatorAddress;
+ log.debug('[ActionSystem] Logging tx error', { operatorAddress, action: action.action, description: action.description });
+ if (operatorAddress) {
logTxError(error, {
- sender: account.operatorAddress,
+ sender: operatorAddress,
system: action.action ?? 'unknown',
method: action.description ?? 'unknown',
});
} else {
log.warn('[ActionSystem] No operator address, skipping tx error logging');
}🤖 Prompt for AI Agents
In `@packages/client/src/network/systems/ActionSystem/createActionSystem.ts`
around lines 173 - 179, The error handler assumes useAccount.getState().account
exists and accesses account.operatorAddress, which can be undefined and crash;
update the createActionSystem error path to guard against a missing account by
fetching const account = useAccount.getState().account and using optional
chaining or an early guard (e.g., if (!account) { log.debug('[ActionSystem] No
account available for tx error', { action: action.action, description:
action.description }); return; }) before using account.operatorAddress, and when
calling logTxError pass sender: account?.operatorAddress ?? 'unknown' (or skip
sender) and keep system/method fallbacks using action.action ?? 'unknown' and
action.description ?? 'unknown'.
A new kamiden endpoint to log tx errors
Summary by CodeRabbit