Skip to content

feat(sdk): add admin and query SDK methods for token, fee, and oracle config - #587

Merged
Levi-Ojukwu merged 5 commits into
Invoice-Liquidity-Network:mainfrom
thegreatfeez:chore/513-514-515-516-sdk-admin-methods
Jul 26, 2026
Merged

feat(sdk): add admin and query SDK methods for token, fee, and oracle config#587
Levi-Ojukwu merged 5 commits into
Invoice-Liquidity-Network:mainfrom
thegreatfeez:chore/513-514-515-516-sdk-admin-methods

Conversation

@thegreatfeez

Copy link
Copy Markdown
Contributor

Summary

Adds the missing SDK wrappers for seven contract functions that already exist on invoice_liquidity but weren't exposed through @iln/sdk:

  • getPayerScore(payer) — read-only wrapper for the payer_score view function
  • addToken(token, decimals) / removeToken(token) — admin wrappers for multi-token support
  • updateFeeRate(rate) / updateMaxDiscount(rate) — admin wrappers for fee/discount configuration
  • setPriceOracle(oracle) / setMaxOracleAge(maxAgeLedgers) — admin wrappers for oracle configuration

Package Affected

  • SDK (@iln/sdk)
  • CLI (@iln/cli)
  • Indexer (@iln/indexer)
  • Notifications
  • Smart Contracts (invoice_liquidity, iln_governance, iln_distribution, reputation_bonus)
  • E2E Tests
  • Documentation
  • CI/CD

Related Issue

Closes #513
Closes #514
Closes #515
Closes #516

Complexity

  • Trivial (typo, docs, small refactor)
  • Medium (new feature, bug fix)
  • High (major refactor, breaking change, security-critical)

Changes Made

  • sdk/src/methods/queries.ts: added getPayerScore, wrapping the payer_score view function (read-only simulation, no signer required)
  • sdk/src/methods/admin.ts: added addToken, removeToken, updateFeeRate, updateMaxDiscount, setPriceOracle, setMaxOracleAge, following the existing setDistributionContract pattern (simulate → assemble → sign → send → poll)
  • sdk/src/index.ts: exported all seven new functions from the SDK's public surface
  • Added unit tests for each new method (sdk/tests/queries.test.ts, addToken.test.ts, removeToken.test.ts, updateFeeRate.test.ts, updateMaxDiscount.test.ts, setPriceOracle.test.ts, setMaxOracleAge.test.ts)

Changeset Included

  • Yes
  • No (not needed for this change)

No .changeset/ tooling is currently wired up in this repo (no .changeset/config.json, no sdk/CHANGELOG.md), so no changeset file was added.

Test Evidence

$ pnpm --filter @iln/sdk exec vitest run tests/queries.test.ts tests/addToken.test.ts tests/removeToken.test.ts tests/updateFeeRate.test.ts tests/updateMaxDiscount.test.ts tests/setPriceOracle.test.ts tests/setMaxOracleAge.test.ts

 ✓ tests/setPriceOracle.test.ts  (3 tests) 5ms
 ✓ tests/updateFeeRate.test.ts  (3 tests) 6ms
 ✓ tests/removeToken.test.ts  (3 tests) 8ms
 ✓ tests/addToken.test.ts  (3 tests) 10ms
 ✓ tests/updateMaxDiscount.test.ts  (3 tests) 9ms
 ✓ tests/queries.test.ts  (8 tests) 11ms
 ✓ tests/setMaxOracleAge.test.ts  (3 tests) 12ms

 Test Files  7 passed (7)
      Tests  26 passed (26)
Test output
 RUN  v1.6.1

 ✓ tests/setPriceOracle.test.ts  (3 tests) 5ms
 ✓ tests/updateFeeRate.test.ts  (3 tests) 6ms
 ✓ tests/removeToken.test.ts  (3 tests) 8ms
 ✓ tests/addToken.test.ts  (3 tests) 10ms
 ✓ tests/updateMaxDiscount.test.ts  (3 tests) 9ms
 ✓ tests/queries.test.ts  (8 tests) 11ms
 ✓ tests/setMaxOracleAge.test.ts  (3 tests) 12ms

 Test Files  7 passed (7)
      Tests  26 passed (26)
   Duration  816ms

Note on the full pnpm test run: the full SDK suite has pre-existing failures unrelated to this change — src/methods/getTokenDecimals.test.ts, src/methods/governance.test.ts, src/methods/nft.test.ts, and sdk/tests/setDistributionContract.test.ts. These fail identically on main (confirmed by running them against main directly before this branch existed) due to a @stellar/stellar-sdk version mismatch between what those tests' mocking approach assumes and what's actually installed (e.g. vi.spyOn(SorobanRpc, "assembleTransaction") fails with Cannot redefine property because that property is a non-configurable getter in the installed SDK version). None of the new tests in this PR use that broken pattern — they use the working vi.mock("@stellar/stellar-sdk", ...) approach already established in adminControls.test.ts.

Rust side: no contract code was touched. cargo fmt --all -- --check currently fails on main itself (42 pre-existing diffs in files unrelated to this PR, e.g. contracts/fuzz/src/lib.rs, contracts/iln_distribution/src/lib.rs), and GitHub's ci.yml workflow run on the current main HEAD is already red for the same reason — confirmed via gh run list. This PR doesn't change that state either way.

Breaking Change

  • Yes (migration notes below)
  • No

Security Considerations

N/A — these are thin wrappers around existing, already-audited contract entrypoints (payer_score, add_token, remove_token, update_fee_rate, update_max_discount, set_price_oracle, set_max_oracle_age). No new contract logic, no new attack surface. Address inputs that map to Soroban contract IDs (token, oracle) are validated with the existing validateContractId helper before being submitted, consistent with setDistributionContract.

Checklist

  • Code follows project conventions (see CONTRIBUTING.md)
  • Tests added/updated and passing
  • Documentation updated (if needed)
  • Commit message follows Conventional Commits
  • No secrets or sensitive data in code
  • Breaking changes documented (if applicable)
  • Changeset added (if needed for release)

Wraps the payer_score view function so consumers can read a payer's
reputation score without hand-building a Soroban simulation call.

Closes Invoice-Liquidity-Network#513
Wraps the add_token and remove_token admin functions so multi-token
support can be managed through the SDK instead of raw contract calls.

Closes Invoice-Liquidity-Network#514
Wraps the update_fee_rate and update_max_discount admin functions so
protocol economics can be configured through the SDK instead of raw
contract calls.

Closes Invoice-Liquidity-Network#515
Wraps the set_price_oracle and set_max_oracle_age admin functions so
oracle configuration can be managed through the SDK instead of raw
contract calls.

Closes Invoice-Liquidity-Network#516
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@thegreatfeez 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! 🚀

Learn more about application limits

@Levi-Ojukwu
Levi-Ojukwu merged commit 6f60f22 into Invoice-Liquidity-Network:main Jul 26, 2026
4 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jul 26, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants