Skip to content

Implemented the two missing reputation_bonus SDK methods - #617

Merged
Levi-Ojukwu merged 1 commit into
Invoice-Liquidity-Network:mainfrom
vjuliaife:main
Jul 28, 2026
Merged

Implemented the two missing reputation_bonus SDK methods#617
Levi-Ojukwu merged 1 commit into
Invoice-Liquidity-Network:mainfrom
vjuliaife:main

Conversation

@vjuliaife

Copy link
Copy Markdown
Contributor

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:

  • getReputationBonusConfig(server, contractId, networkPassphrase?) → { highRepThreshold,
    bonusBps, minDiscountRateBps }
  • getReputationBonusReputation(server, contractId, address, networkPassphrase?) → {
    invoicesSubmitted, invoicesPaid, invoicesDefaulted, score }
  • New types ReputationBonusConfig / ReputationBonusScore, exported from sdk/src/index.ts
  • 10 new test cases (success, zeroed/unknown address, invalid address, simulation errors,
    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

  • Add getReputationBonusConfig() and getReputationBonusReputation(address) to the SDK,
    wrapping the reputation_bonus contract's existing get_config() and get_reputation(address)
    view functions.
  • Add ReputationBonusConfig and ReputationBonusScore TypeScript types mirroring the Rust
    Config and ReputationScore structs.
  • Add unit tests covering success, zeroed/unknown-address behavior, invalid-address rejection,
    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't
expose these two existing view functions.

Details

  • These are distinct from the existing getReputation() in the SDK, which targets the
    invoice_liquidity contract (a different contract with a different ReputationProfile shape
    that includes an address field). The new methods target reputation_bonus and mirror its
    ReputationScore shape exactly (no address field).
  • Contract-side get_config/get_reputation already existed in
    contracts/reputation_bonus/src/lib.rs — no contract changes were needed.
  • Read-only simulation calls follow the same pattern already used by sibling functions in
    sdk/src/methods/reputation.ts (dummy source account, SorobanRpc.Api.isSimulationError check,
    ReputationContractError.fromError mapping).

Testing

  • npx vitest run src/methods/reputation.test.ts — 23/23 passing
  • npx tsc --noEmit — no new type errors (pre-existing unrelated errors confirmed present on
    main)
  • npx eslint src/methods/reputation.ts src/methods/reputation.test.ts src/index.ts — clean

Files changed

  • sdk/src/methods/reputation.ts
  • sdk/src/methods/reputation.test.ts
  • sdk/src/index.ts

Closes #426

@Levi-Ojukwu
Levi-Ojukwu merged commit a99adf9 into Invoice-Liquidity-Network:main Jul 28, 2026
4 checks passed
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.

Add SDK reputation bonus getConfig and getReputation methods

2 participants