Skip to content

Fix non-functional readContractState in src/contract/read.ts #105

Description

@meshackyaro

Description

readContractState (src/contract/read.ts) builds a real invocation operation (const _operation = contract.call(method, ...(args as any[]))) but then never uses it — the variable is prefixed _operation and immediately discarded (flagged by tsc --noEmit as TS6133: '_operation' is declared but its value is never read). Instead, the function calls server.simulateTransaction({ toEnvelope: () => ({ toXDR: () => '' }) as any } as any) — i.e. it simulates a hand-faked "envelope" whose XDR is always the empty string, completely unrelated to method/args. In its current form, calling readContractState(client, 'get_escrow', [escrowId]) for any method or arguments performs the exact same meaningless simulation every time and cannot possibly return real contract state.

Component

SDK

Difficulty

🔴 Hard

Tasks

  • Build a real, signable transaction envelope from the constructed operation (source account from server.getAccount, sequence number, network passphrase from client.getNetworkPassphrase()) instead of the empty-XDR stub
  • Pass that real envelope into simulateTransaction
  • Decode and return the actual simulated result instead of the raw RPC response type
  • Add a test (can be a mocked-RPC unit test) that asserts the built XDR reflects the requested method/args

Acceptance Criteria

  • readContractState simulates the actual requested contract call, not a hardcoded empty envelope
  • The unused-variable warning is gone because the operation is genuinely used
  • Test coverage exists for at least one real method/args combination

Estimated Time

2-3 days

Activity

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

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't workingdifficulty: hardHard difficulty issuepriority: highHigh priority issuesdk

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions