Skip to content

Add stellar contract info wasm-hash command #2093

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 23, 2025

This PR adds a new wasm-hash subcommand to stellar contract info that outputs the WASM hash for a given contract or WASM file.

Changes

  • New subcommand: stellar contract info wasm-hash
  • Input sources: Accepts --wasm, --wasm-hash, or --contract-id (same as other info commands)
  • Output: Hex-encoded WASM hash to stdout
  • Error handling: Proper error for stellar asset contracts

Implementation

  • Added wasm_hash.rs module following existing patterns in cmd/soroban-cli/src/commands/contract/info/
  • Integrated with existing shared infrastructure for contract data fetching
  • Uses crate::utils::contract_hash() for consistent hash calculation
  • Added comprehensive unit tests including verification with real WASM fixtures

Usage

# From local WASM file
$ stellar contract info wasm-hash --wasm ./contract.wasm

# From contract ID on network  
$ stellar contract info wasm-hash --network testnet --contract-id CDSJWGUPY2HFHYNLT3EZX7YGJ4X7YMWPQWHHGNKB6IVH6WRXAJFI7627
283f8e42a3585aa3a511c06c7d09a94d66762773cdf493cc4afc455d7b68adcf

# From existing WASM hash
$ stellar contract info wasm-hash --wasm-hash 283f8e42a3585aa3a511c06c7d09a94d66762773cdf493cc4afc455d7b68adcf
283f8e42a3585aa3a511c06c7d09a94d66762773cdf493cc4afc455d7b68adcf

This provides a convenient way for developers to retrieve WASM hashes without the complex RPC + XDR decoding workflow described in the issue.

Fixes #1877.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Add a stellar contract info wasm-hash command Add stellar contract info wasm-hash command Jul 23, 2025
@Copilot Copilot AI requested a review from leighmcculloch July 23, 2025 22:01
Copilot finished work on behalf of leighmcculloch July 23, 2025 22:01
@leighmcculloch leighmcculloch marked this pull request as ready for review July 24, 2025 06:01
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

I think the code being added for this is not ideal. The --wasm-hash param is still present because it is part of the shared args. Also, in some cases it downloads the wasm unnecessarily even though it could just stop at getting the hash for the contract instance entry.

Given the low importance of this command, and the smaller maintenance burden it is to reuse the other info subcommands shared code that does those not perfect things, I think this is fine as is and preferred over creating bespoke code that does exactly what's needed for this.

@leighmcculloch leighmcculloch requested a review from fnando July 24, 2025 06:03
@leighmcculloch leighmcculloch enabled auto-merge (squash) July 24, 2025 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog (Not Ready)
Development

Successfully merging this pull request may close these issues.

Add a stellar contract info wasm-hash command
2 participants