fix: resolve issues #105, #101, #102, #97 — readContractState, DisputeClient constructor, dead code cleanup - #256
Merged
Conversation
…rustflow-protocol#101, trustflow-protocol#97 - Fix non-functional readContractState by building real TransactionBuilder (trustflow-protocol#105) - Standardize DisputeClient constructor to use ContractConfig (trustflow-protocol#101) - Remove dead SimpleCache tests referencing deleted utils.ts (trustflow-protocol#102) - Fix TS2694 type error in simulate.ts (trustflow-protocol#97) - Add unit test for readContractState - Fix ParsedEvent generic type in events.ts
Rampop01
force-pushed
the
fix-rampop-issues
branch
from
August 31, 2026 08:34
6d3f6dd to
8dc4f7e
Compare
|
@Rampop01 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! 🚀 |
7 tasks
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.
Summary
This PR resolves four open issues assigned to @Rampop01 across the TrustFlow SDK codebase.
Issue #105 — Fix non-functional
readContractStateinsrc/contract/read.tsProblem:
readContractStatebuilt a realcontract.call()operation but immediately discarded it (the variable was prefixed_operation). Instead, it simulated a hand-faked envelope whose XDR was always the empty string — meaning every call performed the same meaningless simulation regardless ofmethod/args.Fix:
TransactionBuilderworkflow:Accountfor simulation (no real account needed for read-only calls).contract.call(method, ...args)operation into a real transaction.server.simulateTransaction().scValToNative()to return usable JS values._operationunused-variable warning entirely since the operation is now genuinely consumed.tests/contract-read.test.tstest suite verifying:TrustFlowError.Files changed:
src/contract/read.ts,tests/contract-read.test.tsIssue #101 — Standardize constructor signatures across
DisputeClient,MultiSigEscrowClient, andTrustFlowEscrowClientProblem:
DisputeClientaccepted raw(apiUrl: string, token: string)constructor arguments, unlikeMultiSigEscrowClientandTrustFlowEscrowClientwhich both accept aContractConfigobject. This inconsistency made the SDK harder to use and maintain.Fix:
DisputeClientconstructor to accept(config: ContractConfig, options?: DisputeClientOptions).apiBaseUrlandapiKeyfrom the config object internally.apiBaseUrl,apiKey) are missing.tests/dispute.test.tsto use the new constructor signature.Files changed:
src/escrow/dispute.ts,tests/dispute.test.tsIssue #102 — Remove or fix
src/utils.ts(dead code, duplicate logic, missing dependencies)Problem: The top-level
src/utils.tswas a dead file that importedhumanize-durationandmoment(neither inpackage.json), duplicated logic already insrc/utils/format.ts, and was never imported bysrc/index.ts. It causedtscbuild failures.Fix: The file was already removed in a prior merge to
main. This PR cleans up the remainingSimpleCachetest references intests/utils.test.tsthat pointed to the deleted code and caused test suite failures (TS2304: Cannot find name SimpleCache).Files changed:
tests/utils.test.tsIssue #97 — Remove dead code in
src/utils/validate.tsProblem:
src/utils/validate.tscontained dead/unreachable code paths.Fix: The file was cleaned up in a prior merge. This PR additionally fixes a residual
TS2694type error insrc/contract/simulate.tswhererpc.Api.Transactionno longer exists as an exported member — replaced with a safeas anycast consistent with the SDK's other simulation call sites. Also fixed theParsedEventgeneric default type insrc/events.tsfromRecord<string, unknown>tounknownto resolve index-signature type mismatches.Files changed:
src/contract/simulate.ts,src/events.tsVerification
npx tsc --noEmitpasses with zero errorsCloses #105
Closes #101
Closes #102
Closes #97