Skip to content

Commit 14035f7

Browse files
sirtimidclaude
andcommitted
fix(evm-wallet-experiment): distinguish prettified errors from manifest constants
prettifySmallcaps converts both #error objects and manifest constants to strings starting with "[": errors become "[TypeError: msg]" while constants become "[undefined]", "[NaN]", etc. Use a regex that checks for the ": " separator to avoid false positives on void method returns. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a9e5eb6 commit 14035f7

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

packages/evm-wallet-experiment/openclaw-plugin/daemon.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ async function callWallet(options: WalletCallOptions): Promise<unknown> {
146146
throw new Error(`Wallet ${method} returned non-JSON output`);
147147
}
148148

149-
// prettifySmallcaps converts #error objects to strings like "[TypeError: msg]".
150-
// Detect these prettified error strings and throw them as proper errors.
151-
if (typeof decoded === 'string' && decoded.startsWith('[')) {
149+
// prettifySmallcaps converts #error objects to "[ErrorName: msg]" strings,
150+
// but also converts manifest constants to "[undefined]", "[NaN]", etc.
151+
// Distinguish errors by checking for the ": " separator after the bracket.
152+
if (typeof decoded === 'string' && /^\[.+: /u.test(decoded)) {
152153
throw new Error(`Wallet ${method} failed: ${decoded}`);
153154
}
154155

packages/evm-wallet-experiment/scripts/update-limits.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ while read -r DEL_ID; do
221221
REVOKE_FAILED=$((REVOKE_FAILED + 1))
222222
continue
223223
}
224-
# prettifySmallcaps converts #error objects to strings like "[TypeError: msg]".
225-
# A successful revocation returns a hex userOpHash starting with "0x".
226-
# Detect errors by checking if the decoded value is a "[..." error string.
224+
# prettifySmallcaps converts #error objects to "[ErrorName: msg]" strings,
225+
# but also converts manifest constants to "[undefined]", "[NaN]", etc.
226+
# Distinguish errors by the ": " separator (errors always have "Name: msg").
227227
IS_ERROR=$(echo "$REVOKE_OUTPUT" | node -e "
228228
const v = JSON.parse(require('fs').readFileSync('/dev/stdin','utf8').trim());
229-
process.stdout.write(typeof v === 'string' && v.startsWith('[') ? 'true' : 'false');
229+
process.stdout.write(typeof v === 'string' && /^\[.+: /.test(v) ? 'true' : 'false');
230230
" 2>/dev/null || echo "false")
231231
if [[ "$IS_ERROR" == "true" ]]; then
232232
ERR_MSG=$(echo "$REVOKE_OUTPUT" | node -e "

0 commit comments

Comments
 (0)