Skip to content

Add flow diff-contract command#2324

Draft
janezpodhostnik wants to merge 1 commit intomasterfrom
janez/diff-contract
Draft

Add flow diff-contract command#2324
janezpodhostnik wants to merge 1 commit intomasterfrom
janez/diff-contract

Conversation

@janezpodhostnik
Copy link
Copy Markdown
Contributor

Closes #???

Description

  • Add new flow diff-contract command that compares a local Cadence contract (file or URL) against a deployed version on-chain
  • Performs import substitution via flow.json before diffing so comparisons are apples-to-apples with on-chain code
  • Outputs unified diff (git patch style) when contracts differ
  • Supports --quiet / -q flag for CI usage: suppresses output and exits with code 1 if contracts differ
  • Address argument is optional — resolves from flow.json deployments or contract aliases when omitted

Usage

  flow diff-contract <file-or-url> [address] [flags]

  # Diff local file, resolve address from flow.json
  flow diff-contract ./MyContract.cdc --network testnet

  # Diff with explicit address
  flow diff-contract ./MyContract.cdc 0xf8d6e0586b0a20c7

  # Diff from URL
  flow diff-contract https://raw.githubusercontent.com/.../MyContract.cdc my-account --network testnet

  # CI mode: silent, exit code 1 if different
  flow diff-contract ./MyContract.cdc -q

For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@janezpodhostnik janezpodhostnik self-assigned this Apr 14, 2026
@github-actions
Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 635da08.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.06838% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/diffcontract/diff-contract.go 76.72% 19 Missing and 8 partials ⚠️
cmd/flow/main.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants