Skip to content

Real XDR Decoding for inspect_contract — Remove Placeholder WASM Hash #2

Description

@Nanle-code

Overview

parse_contract_inspect_result always returns wasm_hash: Some("mock_wasm_hash_placeholder") and empty instance_storage. The ledger_entry_from_xdr_base64 function exists but panics with "XDR decoding not fully implemented". Users running starforge contract inspect get fabricated data.

Resolution

Implement ledger_entry_from_xdr_base64 using LedgerEntry::from_xdr_base64(xdr, Limits::none()) — the stellar-xdr crate already exposes this via the ReadXdr trait. Match the resulting LedgerEntryData::ContractData(entry) and extract entry.val as a ScVal::ContractInstance(instance). From instance.executable, match ContractExecutable::Wasm(hash) to get the real 32-byte hash. Decode instance.storage (an Option<ScMap>) by calling the already-written but dead-code collect_instance_storage. Use the already-written but #[allow(dead_code)] functions: format_scval, format_scaddress, format_hash, describe_executable. They're all there — just not wired in. Also send the correct XDR-encoded LedgerKey in ledger_key_to_xdr_base64 using WriteXdr::to_xdr_base64 instead of the format!("{:?}", key) hack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions