Repository navigation
feat(wallet): implement Soroban simulate-sign-submit-poll pipeline an… - #1541
Merged
chinweobtagaz merged 2 commits intoOct 24, 2026
Merged
chinweobtagaz merged 2 commits into
chinweobtagaz merged 2 commits into
Conversation
…d typed contract clients - Replace deprecated soroban-client with @stellar/stellar-sdk rpc module - Implement full contract invocation flow in walletContext: simulate -> assemble -> sign (Freighter) -> submit -> poll - Support simulateOnly for read-only contract queries - Implement generated typed contract clients for Staking, Puzzle Rewards, AI NFTs, and Arbiter Escrow - Add typed contract registry and getContractClient helper in wallet context - Add comprehensive unit test suite covering full invocation lifecycle and typed clients
|
@Babigdk 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! 🚀 |
Contributor
Author
|
@montionugera @dDevAhmed kindly review and merge |
Combine with SC-91 (OpenKnight-Foundation#1535): keep main's @stellar/stellar-sdk 16 and the generated-bindings path (now useAppContext().invokeBoundContract, plus signTransaction), alongside this branch's RPC simulate-sign-submit-poll invokeSorobanContract and typed contract clients. Adapt the invocation tests to the SDK 16 xdr types and avoid BigInt literals (target ES2017).
Contributor
|
Merged, thanks @Babigdk. This overlapped with SC-91 (#1535), which landed first with generated contract bindings, so I combined the two on your branch:
Next time: rebase onto main before opening the PR, build on what's already there ( |
chinweobtagaz
added a commit
that referenced
this pull request
Oct 25, 2026
…out Freighter - lib/csp.ts: the connect-src fallback was still localhost:8000 after #1536 moved the API default to 8080, so the browser blocked every API call (sign-in, matchmaking, tournaments). - walletContext: only sign through @stellar/freighter-api when isConnected() reports the extension; otherwise signTransaction() waits forever for a reply (#1541).
chinweobtagaz
added a commit
that referenced
this pull request
Oct 25, 2026
* fix: restore green builds and tests after the Oct 24 merges Backend - api/lib.rs: remove the stray .configure(...) line (#1539) and stop compiling the unfinished player_stats module (sqlx/PgPool, wrong tables). - api/players.rs: restore the service::players imports removed in #1542. - pairing/swiss: treat a rematch as such when the history is recorded on either player; make the 'avoidance disabled' test actually disable it. Frontend - accessibility tests render inside AuthProvider, which GamePreferencesProvider now needs. - socket tests: mock the WS ticket (#1540); default API port is 8080 (#1536). - watch page: drop the unused setLiveGames. CI - generate-contract-bindings.sh is executable, so Contract Bindings CI can run it. * fix(frontend): allow the 8080 API in the CSP; don't hang signing without Freighter - lib/csp.ts: the connect-src fallback was still localhost:8000 after #1536 moved the API default to 8080, so the browser blocked every API call (sign-in, matchmaking, tournaments). - walletContext: only sign through @stellar/freighter-api when isConnected() reports the extension; otherwise signTransaction() waits forever for a reply (#1541).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(wallet): implement Soroban simulate-sign-submit-poll pipeline and typed contract clients
What changed and why
Problem
Previously,
frontend/context/walletContext.tsxdynamically imported the deprecatedsoroban-clientpackage and instantiated an RPC client that unconditionally threw an error ("invokeSorobanContract: implement contract-specific invocation (ABI required)"). As a result, any application feature requiring smart contract interactions—such as liquidity staking (yield_staking), puzzle rewards (game_contract), AI companion NFTs (ai_nft), and arbiter escrow releases (arbiter_escrow)—failed immediately at runtime.Solution
@stellar/stellar-sdk: Removed deprecatedsoroban-clientand upgradedwalletContext.tsxto use the official@stellar/stellar-sdk'srpcandHorizonmodules.simulate→sign→submit→poll):G.../C...) into Sorobanxdr.ScVal.rpcServer.simulateTransaction(tx)to compute footprint, resource fees, and authorization entries.options.simulateOnlysupport which extracts and decodes the return value directly from the simulation result without prompting Freighter or incurring gas fees.rpc.assembleTransaction(tx, sim).build().@stellar/freighter-api(with graceful fallback to window-injected Freighter providers) and parses the signed envelope into a StellarTransaction.rpcServer.sendTransaction(signedTx).rpcServer.pollTransaction(hash)until reaching terminal status (SUCCESSorFAILED), then decodes thereturnValueback to native JavaScript structures.frontend/lib/contracts/:YieldStakingContractClient: Handles pool staking, unstaking, yield harvesting, and escrow claims.PuzzleRewardsContractClient: Handles claiming individual and batch puzzle completion rewards and verifying on-chain puzzle balances.AiNftContractClient: Handles companion NFT minting, transfers, metadata queries, and burning.ArbiterEscrowContractClient: Handles match escrow creation, funding, settling payouts/refunds, dispute filing, and arbiter voting.getContractClienttouseAppContextand implemented in-memory client registration to prefer typed clients across the UI.Issue: Closes the wallet context contract helper issue (simulate -> sign -> submit -> poll).
Summary of changes:
frontend/package.json&package-lock.json: Removed deprecatedsoroban-clientand installed@stellar/stellar-sdkv17.frontend/context/walletContext.tsx: Replaced stubbedinvokeSorobanContractwith fullsimulate → assemble → sign → submit → pollpipeline and addedgetContractClientfactory.frontend/lib/api.ts: Centralized contract ID environment variables (CONTRACT_STAKING,CONTRACT_GAME_ESCROW,CONTRACT_ELO_REGISTRY,CONTRACT_TOURNAMENT,CONTRACT_AI_NFT).frontend/lib/contracts/: Addedtypes.ts,baseClient.ts,stakingClient.ts,puzzleRewardsClient.ts,nftClient.ts,escrowClient.ts,registry.ts, andindex.ts.frontend/__tests__/walletContractInvocation.test.ts: Created 13 unit tests covering unconnected wallet protection, full lifecycle invocation,simulateOnlyqueries, error handling (simulation, submission, execution, timeout), and typed contract clients.frontend/vitest.config.ts&vitest.setup.ts: Configured dependency inlining and cross-realmUint8Array/localStoragesupport for jsdom test runner compatibility.How it was tested
npm test):npx vitest run __tests__/walletContractInvocation.test.tspassed (13/13 unit tests).npx tsc --noEmitexecuted with 0 type errors.npm run lintexecuted with 0 ESLint warnings and 0 errors.npm run buildcompleted successfully, verifying Next.js page generation and client bundle code splitting.Contributor Checklist
npm run lintpassed with 0 warnings/errors).__tests__/walletContractInvocation.test.tscovering invocation lifecycle and typed clients; all passing.mainbranch.frontend/lib/api.ts, and updated type definitions.invokeSorobanContract(contractId, functionName, args)signature while adding typed options and returns.Additional context
Soroban Invocation Lifecycle Flow
sequenceDiagram autonumber participant App as Component / Caller participant WC as WalletContext (invokeSorobanContract) participant RPC as Soroban RPC participant F as Freighter Wallet App->>WC: invokeSorobanContract(contractId, fn, args, options) WC->>WC: Convert args to xdr.ScVal & build tx WC->>RPC: simulateTransaction(tx) alt simulateOnly is true RPC-->>WC: Simulation Result (retval) WC-->>App: Return decoded retval else Mutating Contract Call RPC-->>WC: Simulation Data & Footprint WC->>WC: assembleTransaction(tx, sim) WC->>F: signTransaction(preparedTxXDR) F-->>WC: signedEnvelopeXDR WC->>RPC: sendTransaction(signedTx) RPC-->>WC: SendTransactionResponse (hash, status) loop Poll until confirmed WC->>RPC: pollTransaction(hash) RPC-->>WC: GetTransactionResponse (status, returnValue) end WC-->>App: Return { status: "SUCCESS", hash, returnValue } end Closes #1352