Add dataSuffix to pay() with input validation#254
Conversation
- Add optional `dataSuffix` field to `PaymentOptions` type (0x-prefixed hex) - Thread dataSuffix through pay() -> executePaymentWithSDK -> createEphemeralSDK - Set attribution.dataSuffix on SDK preference when dataSuffix is provided - Add validateDataSuffix() to both sdkManager and base-account utils - Remove fixed 16-byte length constraint from makeDataSuffix - Update README and payment README with dataSuffix usage examples - Add test coverage for dataSuffix passthrough and validation Made-with: Cursor
Made-with: Cursor
✅ Heimdall Review Status
|
ilikesymmetry
left a comment
There was a problem hiding this comment.
I'm missing where we're actually leveraging the provided dataSuffix in our request to Keys? I'd expect to see something touching our prepared wallet_sendCalls request to add the dataSuffix capability to our existing one.
| import type { PayerInfoResponses } from '../types.js'; | ||
|
|
||
| function validateDataSuffix(dataSuffix: string): Hex { | ||
| if (!/^0x[0-9a-fA-F]*$/.test(dataSuffix)) { |
There was a problem hiding this comment.
Also could use isHex. I think they should also enforce that length is even # characters for complete bytes
There was a problem hiding this comment.
I think they should also enforce that length is even # characters for complete bytes
Is this enforced on-chain? I don't want to add any failures that could actually execute in other contexts
| chainId: number, | ||
| walletUrl?: string, | ||
| telemetry: boolean = true, | ||
| dataSuffix?: string |
There was a problem hiding this comment.
do we want to make type Hex or 0x${string} throughout for consistency?
I'm not touching the config vs capability question right now, this is just to hook up into the existing config based approach. |
|
PR for docs changes here: base/docs#1177 |
Summary
Add optional
dataSuffixparameter topay()for attribution data. The suffix is threaded through to the SDK'sattribution.dataSuffixpreference and validated as a 0x-prefixed hex string. Removes the previous fixed 16-byte constraint on data suffix length.Changes:
dataSuffix?:0x${string}`` field toPaymentOptionstypedataSuffixthroughpay()->executePaymentWithSDK->createEphemeralSDKattribution.dataSuffixon SDK preference whendataSuffixis providedvalidateDataSuffix()tosdkManagerandbase-account/utilsmakeDataSuffix— accept any valid 0x-prefixed hex stringdataSuffixusage examplesHow did you test your changes?
dataSuffixpassthrough inpay.test.ts: verifiesexecutePaymentWithSDKis called with the correct suffixmakeDataSuffixinutils.test.ts: validates rejection of non-0x-prefixed strings, acceptance of valid hex suffixes, and removal of the 16-byte length restriction