Skip to content

Add rpc.Server.queryContract for one-line read-only contract calls#1502

Merged
quietbits merged 5 commits into
issue-1166from
issue-1469
Jul 2, 2026
Merged

Add rpc.Server.queryContract for one-line read-only contract calls#1502
quietbits merged 5 commits into
issue-1166from
issue-1469

Conversation

@quietbits

@quietbits quietbits commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Adds rpc.Server.queryContract(contractId, method, args?, networkPassphrase?) — a one-line read-only contract query that returns a spec-decoded result, no manual transaction assembly/simulation required. Works transparently for both Wasm contracts and built-in Stellar Asset Contracts (SACs).

Changes

  • queryContract on rpc.Server: resolves the network passphrase (via getNetwork() unless provided), builds a SAC-aware client, simulates the call, and returns .result.
  • Client.from now honors a caller-provided options.server (matching fromWasmHash and the constructor), so queryContract reuses the server's transport (headers, interceptors, allowHttp).
  • Unit tests covering passphrase defaulting/override, arg forwarding, decoded return, and the unknown-method error.
  • E2E tests for happy path

NOTE: Based on #1501

@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Jun 30, 2026
@quietbits quietbits linked an issue Jun 30, 2026 that may be closed by this pull request

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1ee9a78da

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/rpc/server.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1e427d597

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/rpc/server.ts
@oceans404

Copy link
Copy Markdown
Contributor

amazing! can you add an integration test against testnet to confirm the happy path works E2E for both a Wasm contract and a SAC?

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@quietbits quietbits requested a review from Ryang-21 June 30, 2026 18:51
Comment thread src/contract/client.ts
Comment on lines +198 to +203
const server =
options.server ??
new Server(rpcUrl, {
allowHttp,
headers,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice catch 👍

@Ryang-21 Ryang-21 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome work here 👍 🔥

* Make contract.Client factories generic for typed runtime clients

* Add `rpc.Server.getContractMethods` for contract method discovery (#1505)

* Add rpc.Server.getContractMethods for contract method discovery

* Document queryContract and getContractMethods in the invoke-a-contract guide

* Type the contract.Client examples in the invoke and auth guides
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@quietbits quietbits merged commit a8b6c8c into issue-1166 Jul 2, 2026
8 checks passed
@quietbits quietbits deleted the issue-1469 branch July 2, 2026 20:20
@github-project-automation github-project-automation Bot moved this from Backlog (Not Ready) to Done in DevX Jul 2, 2026
quietbits added a commit that referenced this pull request Jul 6, 2026
…om` (#1501)

* Handle SAC in contract.Client.from

* Docs updated

* Fix tests

* Optimize

* Fix and update docs

* Update error response

* Rollup: enable inlineDynamicImports

* Update error message + outdated comment

* Add rpc.Server.queryContract for one-line read-only contract calls (#1502)

* Add rpc.Server.queryContract for one-line read-only contract calls

* Sanitize method name

* Check only contract methods before invoking

* e2e test happy path

* Make contract.Client factories generic for typed runtime clients (#1504)

* Make contract.Client factories generic for typed runtime clients

* Add `rpc.Server.getContractMethods` for contract method discovery (#1505)

* Add rpc.Server.getContractMethods for contract method discovery

* Document queryContract and getContractMethods in the invoke-a-contract guide

* Type the contract.Client examples in the invoke and auth guides

* Updated changelog

* Return { result, isReadCall } from queryContract (#1511)
@oceans404 oceans404 added this to the v17.0.0 milestone Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add one-line read-only contract queries

3 participants