π Query KYC Status from Soroban Contract π οΈ
π Description
Implement an API endpoint to query the KYC/KYB status from the Soroban smart contract for the Stellar wallet service. This endpoint will allow clients to retrieve the verification status (e.g., approved or rejected) of a KYC record by its ID, enabling verification of user identity data stored on the blockchain.
π― Objective
Create a GET /kyc/status/:id endpoint in services/stellar-wallet/src/routes/kyc-status.js to retrieve the KYC status from the Soroban contract, with a unit test to verify functionality.
π Structure
- Directory:
services/stellar-wallet
- Files:
src/routes/kyc-status.js
tests/routes/kyc-status.test.js
- Expected structure:
services/stellar-wallet
βββ src
β βββ index.js
β βββ stellar
β β βββ client.js
β β βββ keys.js
β β βββ fund.js
β βββ db
β β βββ kyc.js
β βββ routes
β β βββ kyc.js
β β βββ kyc-verify.js
β β βββ kyc-status.js
β βββ kyc
β β βββ validate.js
β βββ soroban
β βββ client.js
β βββ kyc-contract.rs
β βββ deploy.js
βββ config
β βββ db.sqlite
βββ tests
β βββ stellar
β β βββ client.test.js
β β βββ keys.test.js
β β βββ fund.test.js
β βββ db
β β βββ kyc.test.js
β βββ routes
β β βββ kyc.test.js
β β βββ kyc-verify.test.js
β β βββ kyc-status.test.js
β βββ kyc
β β βββ validate.test.js
β βββ soroban
β βββ client.test.js
β βββ deploy.test.js
βββ package.json
βββ .env.example
βββ .eslintrc.json
βββ .eslintignore
βββ .prettierrc.json
βββ .prettierignore
βββ .gitignore
β
Requirements
- Create a branch named
feat/kyc-status-endpoint for this task.
- Create
src/routes/kyc-status.js to define a GET /kyc/status/:id endpoint using Express.
- Configure the endpoint to accept a URL parameter
id (the kyc_id from the SQLite database and Soroban contract).
- Validate that
id is a non-empty string; return HTTP 400 with a JSON error message (e.g., { error: "Invalid KYC ID" }) if invalid.
- Use the Soroban client (from Issue 11) and contract ID (from Issue 13) to call the
get_kyc_status function of the KYC contract (from Issue 12) with the provided kyc_id.
- Return a JSON response with HTTP status 200 and the status (e.g.,
{ kyc_id, status }).
- Handle errors (e.g., non-existent
kyc_id, contract call failure) with HTTP 404 or 500 and a JSON error message (e.g., { error: "KYC record not found" }).
- Create a unit test in
tests/routes/kyc-status.test.js to verify:
- Successful queries return HTTP 200 with the correct status.
- Invalid or non-existent
kyc_id returns HTTP 400 or 404.
- Mock the Soroban client in the unit test to avoid network dependencies.
- Update
src/index.js to mount the KYC status routes at /kyc/status.
- Ensure the code adheres to ESLint and Prettier rules (from Issue 3).
- Commit changes to the
feat/kyc-status-endpoint branch with a message like feat: query kyc status.
- Verify that the CI pipeline (from Issue 1) passes, with linting and test jobs succeeding.
π Expected Outcomes
src/routes/kyc-status.js defines a GET /kyc/status/:id endpoint that retrieves the KYC status from the Soroban contract.
- Valid
kyc_id queries return HTTP 200 with a JSON response containing kyc_id and status.
- Invalid or non-existent
kyc_id queries return appropriate HTTP status codes and JSON error messages.
- Unit test in
tests/routes/kyc-status.test.js confirms correct behavior for valid and invalid inputs.
- Express server mounts KYC status routes correctly.
- Code passes ESLint and Prettier checks.
- Changes are committed to the
feat/kyc-status-endpoint branch with a descriptive lowercase commit message.
- CI pipeline runs successfully, with linting passing for
src/routes/kyc-status.js and tests/routes/kyc-status.test.js, and the unit test passing.
π References
π Notes
- The
kyc_id should match the ID used in the SQLite database and Soroban contract.
- Mocking the Soroban client in tests ensures reliable CI execution without network dependencies.
- Error handling should differentiate between invalid input (HTTP 400) and non-existent records (HTTP 404).
- Commit messages must be in lowercase and start with
feat, change, fix, chore, or refactor.
- The CI pipeline should validate the new code, ensuring ESLint passes and the unit test executes successfully.
π Query KYC Status from Soroban Contract π οΈ
π Description
Implement an API endpoint to query the KYC/KYB status from the Soroban smart contract for the Stellar wallet service. This endpoint will allow clients to retrieve the verification status (e.g.,
approvedorrejected) of a KYC record by its ID, enabling verification of user identity data stored on the blockchain.π― Objective
Create a
GET /kyc/status/:idendpoint inservices/stellar-wallet/src/routes/kyc-status.jsto retrieve the KYC status from the Soroban contract, with a unit test to verify functionality.π Structure
services/stellar-walletsrc/routes/kyc-status.jstests/routes/kyc-status.test.jsβ Requirements
feat/kyc-status-endpointfor this task.src/routes/kyc-status.jsto define aGET /kyc/status/:idendpoint using Express.id(thekyc_idfrom the SQLite database and Soroban contract).idis a non-empty string; return HTTP 400 with a JSON error message (e.g.,{ error: "Invalid KYC ID" }) if invalid.get_kyc_statusfunction of the KYC contract (from Issue 12) with the providedkyc_id.{ kyc_id, status }).kyc_id, contract call failure) with HTTP 404 or 500 and a JSON error message (e.g.,{ error: "KYC record not found" }).tests/routes/kyc-status.test.jsto verify:kyc_idreturns HTTP 400 or 404.src/index.jsto mount the KYC status routes at/kyc/status.feat/kyc-status-endpointbranch with a message likefeat: query kyc status.π Expected Outcomes
src/routes/kyc-status.jsdefines aGET /kyc/status/:idendpoint that retrieves the KYC status from the Soroban contract.kyc_idqueries return HTTP 200 with a JSON response containingkyc_idandstatus.kyc_idqueries return appropriate HTTP status codes and JSON error messages.tests/routes/kyc-status.test.jsconfirms correct behavior for valid and invalid inputs.feat/kyc-status-endpointbranch with a descriptive lowercase commit message.src/routes/kyc-status.jsandtests/routes/kyc-status.test.js, and the unit test passing.π References
π Notes
kyc_idshould match the ID used in the SQLite database and Soroban contract.feat,change,fix,chore, orrefactor.