base / base/docs

[Bug] Inconsistent dataSuffix hex stripping: slice(2) used in some examples but not others

Open
#1,474 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
337
Forks
792
Avg merge
17h 23m
Merged PRs (30d)
49

Description

## Description
In `tmp-builder-codes-outline.mdx`, there is an inconsistency in how
`dataSuffix` is appended to calldata across examples.

Some examples strip the `0x` prefix:
```js
data: tx.data + suffix.slice(2)
```

While others append directly without stripping:
```js
tx.data = tx.data + dataSuffix
userOp.callData = userOp.callData + dataSuffix
```

## Location
`tmp-builder-codes-outline.mdx`:
- Section "5. Minimal example (EOA)" → uses `suffix.slice(2)`
- Section "A. EOA Transactions" → uses `tx.data + dataSuffix` (no slice)
- Section "B. Smart Account / ERC-4337" → uses `userOp.callData + dataSuffix` (no slice)

## Impact
- Developers copying different examples will get inconsistent behavior
- Appending `0x` prefix mid-calldata will produce malformed transactions
- Could cause silent transaction failures or wrong attribution

## Suggested Fix
Standardize all examples to consistently use `suffix.slice(2)` when
appending to existing hex strings, or use a proper `concat` utility:

```js
data: tx.data + dataSuffix.slice(2)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.