Skip to content

good-first-capability: FX convert (GET /fx/convert) #129

Description

@rahulsainlll

What: convert an amount between two currencies using the reference rates. A second operation on the existing FX Rates capability (non-Stellar).

Route: GET /fx/convert?from=USD&to=EUR&amount=100
Sample response: { "from": "USD", "to": "EUR", "amount": "100", "rate": 0.92, "result": "92.00" }
Upstream: the same free no-key FX source the fx capability already uses. Add the op file under capabilities/fx/operations/.

How to build (one file)

Adding an operation to an existing capability is one new file. Copy an operation as your template:

cp apps/capabilities/src/capabilities/stellar/operations/status.ts \
   apps/capabilities/src/capabilities/stellar/operations/<name>.ts

Then edit it: a single-word name (it becomes the op slug, e.g. Effects/c/stellar/effects), the path, price: "0", a sampleRequest + sampleResponse, and the handler. Put any fetch logic in the capability's helper (stellar/horizon.ts).

Also add a word to the Stellar description in capabilities/stellar/capability.ts so search can find the new op (search matches name + description).

The registry auto-collects the file — nothing else to wire.

pnpm --filter capabilities typecheck
pnpm --filter capabilities dev   # then curl the route on localhost:3004

Acceptance

  • New file under stellar/operations/, read-only, no secrets, clean JSON, price: "0".
  • Manifest has sampleRequest + sampleResponse; the Stellar description mentions it.
  • typecheck passes and the route returns the documented shape locally.

See apps/capabilities/README.md. Open a PR with Closes #<this issue>. Because it's a new file, it won't conflict with anyone else's.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good-first-capabilityAdd a first-party capability (copy the stellar/ folder)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions