Skip to content

feat(sdk): add getTokenDecimals SDK method - #444

Open
GBOYEE wants to merge 2 commits into
Invoice-Liquidity-Network:mainfrom
GBOYEE:gf-411-get-token-decimals
Open

feat(sdk): add getTokenDecimals SDK method#444
GBOYEE wants to merge 2 commits into
Invoice-Liquidity-Network:mainfrom
GBOYEE:gf-411-get-token-decimals

Conversation

@GBOYEE

@GBOYEE GBOYEE commented Jul 20, 2026

Copy link
Copy Markdown

Summary

Closes #411

Adds a getTokenDecimals SDK method that wraps the on-chain get_token_decimals(env, token) -> Option<u32> contract method.

  • New sdk/src/methods/getTokenDecimals.ts exporting getTokenDecimals(server, contractId, token, networkPassphrase?).
    • Accepts a Stellar address string; converts it to a Soroban Address ScVal for the contract call.
    • Returns Promise<number | null>null when the token is not registered (None from the contract) or the simulation has no return value.
    • Validates the contract ID and token address via existing validateContractId / validateGAddress helpers.
  • Tests in sdk/src/methods/getTokenDecimals.test.ts using a mock SorobanRpc.Server (mirrors the existing insurance.test.ts pattern).
  • Exported from sdk/src/index.ts.

Test result

pnpm run test in sdk/ — the new getTokenDecimals.test.ts suite passes 6/6.

Note: two unrelated suites fail on untouched main as well (pre-existing, not caused by this change):

  • src/utils/xdrDecoder.test.ts — missing fast-check devDependency.
  • tests/integration/invoiceLifecycle.integration.test.ts — requires testnet secrets (TEST_SUBMITTER_SECRET/TEST_LP_SECRET).

All 283 unit tests pass, including the new suite.

root added 2 commits July 20, 2026 02:41
- Add cli/src/commands/dispute.ts: opens a dispute against an invoice
- Flags: --invoice-id (required), --reason-hash (required, 64-char SHA-256),
  --payer (optional, defaults to configured wallet), --yes to skip confirm
- Validates invoice state is Pending or Funded before calling dispute_invoice
- Register as `iln dispute` in cli/src/index.ts
- Add cli/tests/e2e/dispute.test.ts (8 tests, all passing)
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 get_token_decimals SDK method

1 participant