Skip to content

SDK clients expose no initialize() bindings and PriceOracleClient/RiskRegistryClient.addVerifier are stale relative to the deployed contracts' real interfaces #517

Description

@OxDev-max

Description

None of the 7 classes in sdk/src/clients.ts (InvoiceNftClient, MarketplaceClient,
FinancingPoolClient, TreasuryClient, RiskRegistryClient, AccessControlClient,
PriceOracleClient) exposes an initialize() method, even though KoraClient's own doc
comment (sdk/src/KoraClient.ts:22-33) presents itself as a general-purpose facade "over all 7
Kora Protocol contracts" — meaning the SDK cannot be used to stand up a protocol instance at
all, only to interact with an already-deployed one wired up by hand via scripts/deploy.sh.

Two existing bindings are additionally stale relative to the real contracts:

  • PriceOracleClient.getPrice(asset: string) / setPrice(admin, asset, price)
    (sdk/src/clients.ts:266-277) call get_price/set_price with a single symbol argument.
    The actual contract (contracts/price_oracle/src/lib.rs) requires a (base: Symbol, quote: Symbol) pair for both get_price and set_price — the SDK's single-asset signature
    cannot express a currency pair at all and would fail against the real contract's XDR interface.
  • RiskRegistryClient.addVerifier(admin, verifier) (sdk/src/clients.ts:224-230) omits the
    stake_amount parameter that risk_registry::add_verifier now requires
    (contracts/risk_registry/src/lib.rs:142) — the same staking-model gap as issues Fix Reentrancy Guard in Financing Pool Contracts #2, Refactor Treasury Contracts #7, Optimize Financing Pool Contracts #9.

Requirements and Context

Fixing this closes the loop between the contract-side signature fixes (issues #2, #7, #9) and
the SDK: without it, every downstream fix to the Rust side still leaves the TypeScript client
silently broken for anyone building a dApp or ops tool on top of it.

Suggested Execution

  1. git checkout -b feature/sdk-client-interface-parity
  2. Add an initialize(...) method to each of the 7 client classes, matching each contract's
    current parameter list exactly (cross-reference each contract's pub fn initialize).
  3. Fix PriceOracleClient.getPrice/setPrice to take (base: string, quote: string, ...)
    instead of a single asset, and update sdk/src/types.ts if any oracle-related type needs
    a base/quote pair shape.
  4. Fix RiskRegistryClient.addVerifier to accept and forward a stakeAmount: bigint.
  5. Add the new tests from issue Add Tests for Invoice NFT Contracts #11 covering these corrected/new methods.
  6. Update sdk/README.md's usage examples to reflect the corrected signatures.

Acceptance Criteria

  • Every one of the 7 SDK client classes exposes an initialize() method matching its contract's current signature
  • PriceOracleClient.getPrice/setPrice take a (base, quote) pair, not a single asset
  • RiskRegistryClient.addVerifier accepts and forwards stakeAmount
  • A test (per issue Add Tests for Invoice NFT Contracts #11's infrastructure) proves each corrected method encodes the right number and type of XDR arguments

Guidelines: PR description must include Closes #<issue-number>.
Complexity: High (200 points)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions