Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --generate-hexfile flag to forc build for hex-encoded output #7032

Merged
merged 12 commits into from
Apr 8, 2025

Conversation

JoE11-y
Copy link
Contributor

@JoE11-y JoE11-y commented Mar 23, 2025

close #5017

PR adds new --generate-hexfile flag to the forc build command, enabling it to output a hex-encoded JSON representation of the compiled binary alongside the .bin file.

✅ Changes

  • Added --generate-hexfile flag to forc build.
  • Outputs a .json file containing the hex-encoded script binary (e.g., contract-hex.json).
  • Ensures bundler compatibility for frontend/SDK consumption.

🧪 Example Output

{
  "hex": "0xdeadbeefcafebabe..."
}

📦 Example Usage

forc build --generate-hexfile

Generates:

  • contract.bin (as before)
  • contract-hex.json (new hex representation)

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@JoE11-y JoE11-y requested a review from a team as a code owner March 23, 2025 22:25
@fuel-cla-bot
Copy link

fuel-cla-bot bot commented Mar 23, 2025

Thanks for the contribution! Before we can merge this, we need @JoE11-y to sign the Fuel Labs Contributor License Agreement.

Copy link

codspeed-hq bot commented Mar 24, 2025

CodSpeed Performance Report

Merging #7032 will not alter performance

Comparing JoE11-y:feat-add-generate-hex-flag (12862d9) with master (b59e1b6)

Summary

✅ 22 untouched benchmarks

@JoE11-y JoE11-y requested a review from a team as a code owner March 27, 2025 18:44
@JoE11-y JoE11-y requested review from sdankel and zees-dev March 27, 2025 18:44
@JoE11-y JoE11-y requested a review from zees-dev March 31, 2025 09:39
Copy link
Contributor

@zees-dev zees-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor changes required:

  • #[clap(long = "output-hexfile")]
  • prepend output/ to hexfile to persist it there
  • add back the empty line in .gitignore

Other than this; LGTM

@JoE11-y JoE11-y requested a review from sdankel April 2, 2025 12:05
@JoE11-y JoE11-y requested a review from zees-dev April 2, 2025 12:05
Copy link
Contributor

@zees-dev zees-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor fix to the hexfile some variant required

Copy link
Contributor

@zees-dev zees-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice; thanks for this - LGTM 👍

Copy link
Member

@JoshuaBatty JoshuaBatty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR

@JoshuaBatty JoshuaBatty enabled auto-merge (squash) April 2, 2025 23:39
@IGI-111 IGI-111 temporarily deployed to fuel-sway-bot April 8, 2025 11:57 — with GitHub Actions Inactive
@JoshuaBatty JoshuaBatty merged commit 1c68f1c into FuelLabs:master Apr 8, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add --generate-hex flag to forc build
5 participants