fuel-core icon indicating copy to clipboard operation
fuel-core copied to clipboard

chore: use Cow in scalars/HexString

Open grandima opened this issue 6 months ago • 2 comments

Linked Issues/PRs

close https://github.com/FuelLabs/fuel-core/issues/2657

Description

Checklist

  • [ ] Breaking changes are clearly marked as such in the PR description and changelog
  • [x] New behavior is reflected in tests
  • [ ] The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • [x] I have reviewed the code myself
  • [ ] I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]


[!NOTE] Replaces owned HexString with Cow-backed HexString<'_> and updates GraphQL types/methods to borrow bytes where possible, reducing clones and adding required lifetimes.

  • Scalars
    • Replace HexString with HexString<'a> backed by Cow<[u8]>.
    • Add conversions: From<Vec<u8>>, From<&[u8]>, From<HexString> for Vec<u8>; update Display, ScalarType, CursorType, FromStr, and Nonce conversions to support borrowing.
  • GraphQL Schema Updates
    • Change return/input types from HexString to HexString<'_> across schema: blob, contract, da_compressed, message, storage, tx (queries, mutations, subscriptions, types, receipts), and upgrades.
    • Introduce lifetimes in types and unions where needed (e.g., Input<'a>, InputCoin<'a>, InputMessage<'a>, UploadedBytecode<'a>, subscriptions).
    • Construct HexString via borrowing (HexString::from(&[..]) / .into()) and remove unnecessary clones in mappers (e.g., witnesses, scripts, predicate/data, storage slots, block/tx streams).
    • Adjust pagination and connection cursors to use HexString<'_> where relevant.

Written by Cursor Bugbot for commit ae7848d887620ce4be7ddc21a087ae86ccff2b12. This will update automatically on new commits. Configure here.

grandima avatar Jun 01 '25 12:06 grandima