Repository navigation
fix(frontend): Soroban invocation encoding, contract targets, bounded tx timeout, create_market args - #1496
Merged
Ehonrie merged 5 commits intoOct 21, 2026
Conversation
…iven contract buildSorobanInvocation passed a plain object as the host function and ignored params.contractId. It now builds the operation with new Contract(contractId).call(method, ...args), and arguments that are already ScVals pass through unchanged. Also replaces the nonexistent Timeout.INFINITE with TimeoutInfinite and drops the all-zero placeholder signature, which the SDK rejects as an invalid signature. The wallet signs the returned XDR.
… txs Built transactions used Timeout.INFINITE, so a signed XDR stayed valid indefinitely. They now use TX_TIMEOUT_SECONDS (120). A txTooLate rejection from submission is reported as TX_EXPIRED_MESSAGE, asking the user to try again.
…laim calls usePlaceBet, useClaimWinnings, useClaimRefund and DisputeModal passed the market id (a 32-byte hash) as the invocation contract. They now use the market's contractAddress; usePlaceBet takes it as a second argument. buildSorobanInvocation rejects a contractId that is not a C-strkey before building anything. Tests assert the target contract of each invocation.
… typed args useCreateMarket sent a placeholder contract id and 11 arguments, while create_market takes (caller, fighter_a, fighter_b, oracle, lock_time, end_time). It now reads the factory id from the validated config (NEXT_PUBLIC_MARKET_FACTORY_CONTRACT_ID), passes the connected address as caller, and encodes both timestamps as u64 via toU64ScVal. Fighter metadata the contract does not store (records, nationality, weight class) is sent to the backend with the tx hash once the transaction is confirmed. A failure there is logged and does not fail the creation, since the market already exists on-chain. zod is declared as a frontend dependency; lib/config.ts imports it but it was only present through the backend.
Keep both config additions (factory id + site url), main's import and the PR's Contract.call encoding with the secure RPC options helper, and the PR's create_market args. Drop test files removed on main; keep the PR's DisputeModal tests in a separate file. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Fixes the frontend Soroban transaction path: invocations are now encoded correctly, target the right contract, expire after a bounded window, and create markets with the arguments the factory contract declares. Each issue is its own commit.
Commits
d138dab2fix: F-83: buildSorobanInvocation builds an invalid host function and ignores contractId #1421 build invocations withContract.callagainst the given contractf0f570ccfix: F-84: Use a bounded transaction timeout instead of Timeout.INFINITE #1422 bound transaction validity to 120s and map expired txs77a942e5fix: F-82: Place-bet, claim and dispute hooks pass market_id as the contract address #1420 target the market's contract address for bet and claim callsa958f4d3fix: F-81: useCreateMarket sends a placeholder contract id and the wrong create_market arguments #1419 callcreate_marketwith the configured factory and typed argsBehaviour changes
buildSorobanInvocationusesnew Contract(contractId).call(method, ...args)and validatescontractIdis aC...address before touching the network.toU64ScValencodes u64 timestamps.Timeout.INFINITEfrom an export the SDK does not have, so every build threw aTypeError. It now uses a 120 s window (TX_TIMEOUT_SECONDS).txTooLaterejection surfaces asTX_EXPIRED_MESSAGE("please try again").usePlaceBettakes the market'scontractAddressas a second argument.useClaimWinnings,useClaimRefundandDisputeModalusemarket.contractAddress.useCreateMarketreadsNEXT_PUBLIC_MARKET_FACTORY_CONTRACT_IDfrom validated config and sends(caller, fighter_a, fighter_b, oracle, lock_time, end_time). Fighter metadata goes toPOST /api/marketswith the tx hash after confirmation.zodis declared infrontend/package.json;lib/config.tsalready imported it.Testing
__tests__/lib/stellar.invocation.test.tsdecodes the built XDR and asserts the contract id, function name, argument types,maxTime, and the expiry mapping.__tests__/useClaimRefund.test.ts.usePlaceBet,useClaimWinnings,useCreateMarket,DisputeModaltests assert the target contract and encoded arguments. Hook tests mockuseWalletwith a factory, becausehooks/useWallet.tscontains JSX under a.tsextension and cannot be automocked.npx jest: 5 suites that were failing onmainnow pass (useCreateMarket,usePlaceBet,useClaimWinnings,useClaimRefund,stellar.invocation). No suite that passed onmainfails.Not done here
buildSorobanInvocationagainst Testnet simulation, submit, checkgetTransaction.npm ciis broken onmain:package-lock.jsonis out of sync withpackage.json(see Frontend CI broken on main: package-lock.json out of sync with package.json #1333). This PR does not regenerate the lockfile.DisputeModalsnapshot is time-dependent (renders a clock), so it can fail between runs.hooks/useWallet.tscontains JSX in a.tsfile, which breaks any test that loads it. Not changed here.place_betreceives the side as a string. The contract'sBetSideenum encoding is not verified here.Closes #1419
Closes #1420
Closes #1421
Closes #1422