Skip to content

feat: implement simulateContractCall in frontend/src/lib/stellar.ts (closes #127) - #293

Open
Obiajulu-gif wants to merge 3 commits into
Ada-Girly881:testnet-implementationfrom
Obiajulu-gif:fix/issue-127-split
Open

feat: implement simulateContractCall in frontend/src/lib/stellar.ts (closes #127)#293
Obiajulu-gif wants to merge 3 commits into
Ada-Girly881:testnet-implementationfrom
Obiajulu-gif:fix/issue-127-split

Conversation

@Obiajulu-gif

Copy link
Copy Markdown
Contributor

Summary

Added simulateContractCall(contractId, method, args: xdr.ScVal[], sourceAddress) — a reusable read-only simulation helper: builds a TransactionBuilder against a loadable (non-signing) source account, runs server.simulateTransaction, guards with SorobanRpc.Api.isSimulationError, and returns scValToNative(result.result.retval). Updated useMarketplace.ts's useListings queryFn for the new getActiveListings signature. Added frontend/src/lib/__tests__/stellar.test.ts covering connectFreighter (success/locked/rejected/not-installed) and simulateContractCall (success + simulation-error paths).

Builds on top of #125 (this branch includes that commit) — merge #125 first, or merge this one after it.

Verification: npx jest src/lib/__tests__/stellar.test.ts passes; tsc --noEmit clean.

Depends on #125 (branched from it). Target: testnet-implementation. Closes #127.

Test plan

  • Jest tests pass locally
  • tsc --noEmit clean (verified locally, re-confirm in CI)

Obiajulu-gif and others added 2 commits July 25, 2026 23:55
Trigger the Freighter authorization popup via the real freighter-api v3
surface (isConnected + requestAccess + getNetwork), normalizing the
{ error } result objects into descriptive thrown Errors for the
not-installed, locked, and user-rejected cases.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…stellar.ts

Add a reusable simulateContractCall(contractId, method, args, source)
that builds a TransactionBuilder against a loadable (non-signing) source
account, runs server.simulateTransaction, and returns
scValToNative(retval), throwing via SorobanRpc.Api.isSimulationError on
failure. Update the useListings queryFn for the new getActiveListings
signature. Add Jest coverage for connectFreighter and
simulateContractCall success/error paths.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Obiajulu-gif is attempting to deploy a commit to the Ada's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Obiajulu-gif Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Implement simulateContractCall in frontend/src/lib/stellar.ts

1 participant