Skip to content

feat: stork integration#22

Open
pp346 wants to merge 3 commits intomainfrom
feat/stork
Open

feat: stork integration#22
pp346 wants to merge 3 commits intomainfrom
feat/stork

Conversation

@pp346
Copy link

@pp346 pp346 commented Feb 18, 2026

Summary

  • Introduces a Stork PriceAPIDataHandler that queries /v1/prices/latest with comma-separated asset IDs.

Details

  • Parses Stork’s integer price strings into floats and returns current UTC timestamps.
  • Registers the provider in APIQueryHandlerFactory.
  • API
    • Request: GET https://rest.jp.stork-oracle.network/v1/prices/latest?assets=<ID1,ID2,...>
    • Response: JSON map of asset_id -> price (string), scaled by 10^18.
    • Parsing: Converts price string to big.Float and divides by 1e18; unknown assets are ignored.
    • Timestamps: Uses time.Now().UTC() (provider timestamp not propagated).
  • Config
    • New provider name: stork_api.
    • DefaultAPIConfig: Enabled, Atomic=true, Timeout/Interval=3s, ReconnectTimeout=2s, MaxQueries=1.
    • Authentication: Authorization header populated from env var STORK_API_KEY.
  • Implementation
    • Caches requested tickers during CreateURL to map returned asset IDs back to ProviderTicker.
    • Error handling:
      • JSON decode failure → unresolved for all tickers (ErrorFailedToDecode).
      • Price parse failure → unresolved for that ticker (ErrorFailedToParsePrice).
      • Missing response for a requested ticker → unresolved (ErrorNoResponse).
  • Factory
    • Adds stork_api branch to instantiate the new API data handler.

Risk & Impact

  • Low risk: additive provider; no changes to existing providers or schemas.
  • Operational: requires configuring STORK_API_KEY when enabling this provider.
  • Security: introduces API key usage via Authorization header.

Testing

  • New unit tests:
    • URL creation: empty, single, multiple assets.
    • Response parsing: valid single/multiple, bad JSON, bad/empty price, missing/null data, no responses.
    • Numeric edges: hex literal, very small (1), very large, zero.
    • Verifies timestamps are set to “now” and unresolved errors are surfaced.

@pp346 pp346 requested a review from a team as a code owner February 18, 2026 22:08
tqin7
tqin7 previously approved these changes Feb 19, 2026
tqin7
tqin7 previously approved these changes Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants