Implemented the two missing reputation_bonus SDK methods - #617
Merged
Conversation
4 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
Issue #426 asked for two SDK read methods wrapping reputation_bonus's existing get_config() and
get_reputation(address) view functions. Investigation confirmed the contract side
(contracts/reputation_bonus/src/lib.rs) already exposes both — the gap was entirely in the SDK.
I added the two wrappers to sdk/src/methods/reputation.ts, exported them (and their types) from
sdk/src/index.ts, and added tests to sdk/src/methods/reputation.test.ts, following the exact
conventions already used by the file's existing getReputation/submitReputationInvoice functions
(same simulation pattern, same ReputationContractError error mapping).
What changed:
bonusBps, minDiscountRateBps }
invoicesSubmitted, invoicesPaid, invoicesDefaulted, score }
contract error-code mapping)
Verified: full reputation.test.ts suite passes (23/23), no new TypeScript or lint errors
introduced (pre-existing unrelated errors in batch.ts/client.ts/nft.test.ts/insurance.test.ts
confirmed present on main too), 97.66% line coverage on the touched file, and an independent
review pass found no defects.
PR body (paste as-is)
Summary
getReputationBonusConfig()andgetReputationBonusReputation(address)to the SDK,wrapping the reputation_bonus contract's existing
get_config()andget_reputation(address)view functions.
ReputationBonusConfigandReputationBonusScoreTypeScript types mirroring the RustConfigandReputationScorestructs.and contract/RPC error paths.
Why
Frontend applications need to display reputation_bonus configuration (
high_rep_threshold,bonus_bps,min_discount_rate_bps) and per-address reputation scores, but the SDK didn'texpose these two existing view functions.
Details
getReputation()in the SDK, which targets theinvoice_liquidity contract (a different contract with a different
ReputationProfileshapethat includes an
addressfield). The new methods target reputation_bonus and mirror itsReputationScoreshape exactly (noaddressfield).get_config/get_reputationalready existed incontracts/reputation_bonus/src/lib.rs— no contract changes were needed.sdk/src/methods/reputation.ts(dummy source account,SorobanRpc.Api.isSimulationErrorcheck,ReputationContractError.fromErrormapping).Testing
npx vitest run src/methods/reputation.test.ts— 23/23 passingnpx tsc --noEmit— no new type errors (pre-existing unrelated errors confirmed present onmain)npx eslint src/methods/reputation.ts src/methods/reputation.test.ts src/index.ts— cleanFiles changed
sdk/src/methods/reputation.tssdk/src/methods/reputation.test.tssdk/src/index.tsCloses #426