Skip to content

feat(express): add typed routes for TRX delegation APIs#8344

Merged
bhavidhingra merged 2 commits intomasterfrom
CHALO-346.trx-express-delegation-routes
Apr 7, 2026
Merged

feat(express): add typed routes for TRX delegation APIs#8344
bhavidhingra merged 2 commits intomasterfrom
CHALO-346.trx-express-delegation-routes

Conversation

@bhavidhingra
Copy link
Copy Markdown
Contributor

@bhavidhingra bhavidhingra commented Mar 24, 2026

Summary

  • Add dedicated typed Express routes for TRX resource delegation APIs
  • POST /api/v2/{coin}/wallet/{id}/getaccountresources — query BANDWIDTH/ENERGY resources for wallet addresses
  • GET /api/v2/{coin}/wallet/{id}/resourcedelegations — query active outgoing/incoming resource delegations

Details

  • New io-ts typed route definitions with request/response validation
  • getaccountresources is a POST endpoint; addresses (and optional destinationAddress) are provided in the request body
  • resourcedelegations supports optional filters: type (outgoing/incoming), resource (case-insensitive: ENERGY/BANDWIDTH), limit, nextBatchPrevId
  • Delegate/undelegate resource transactions already work via existing sendMany route

Test plan

  • Build passes (npx lerna run build --scope @bitgo/express)
  • Test POST /getaccountresources via Express on staging
  • Test GET /resourcedelegations via Express on staging
  • Test delegate/undelegate via POST /sendmany on staging

TICKET: CHALO-346

@bhavidhingra bhavidhingra force-pushed the CHALO-346.trx-express-delegation-routes branch 3 times, most recently from 1dce693 to 335e26d Compare March 25, 2026 16:08
@bhavidhingra bhavidhingra marked this pull request as ready for review March 25, 2026 16:23
@bhavidhingra bhavidhingra requested review from a team as code owners March 25, 2026 16:23
@bhavidhingra bhavidhingra force-pushed the CHALO-346.trx-express-delegation-routes branch 3 times, most recently from e708f00 to bf85e1c Compare April 6, 2026 17:38
@bhavidhingra bhavidhingra requested review from a team as code owners April 6, 2026 17:38
@bhavidhingra bhavidhingra force-pushed the CHALO-346.trx-express-delegation-routes branch 3 times, most recently from 44de9a1 to 32d3271 Compare April 7, 2026 03:12
@MohammedRyaan786 MohammedRyaan786 requested a review from Copilot April 7, 2026 06:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces new typed Express v2 endpoints for TRX account resource lookup and resource delegation querying, and updates the sdk-core wallet method used to fetch account resources to use a POST body.

Changes:

  • Updated Wallet#getAccountResources in sdk-core to POST a request body (and adjusted its unit tests accordingly).
  • Added new io-ts typed route specs for account resources and resource delegations and registered them in the Express API spec.
  • Implemented Express route handlers/wiring for the new typed endpoints.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
modules/sdk-core/test/unit/bitgo/wallet/getAccountResources.ts Updates unit tests to reflect POST+body behavior for getAccountResources.
modules/sdk-core/src/bitgo/wallet/wallet.ts Switches getAccountResources from GET+query to POST+body.
modules/express/src/typedRoutes/api/v2/resourceDelegations.ts Adds typed route definition for resource delegations endpoint.
modules/express/src/typedRoutes/api/v2/accountResources.ts Adds typed route definition for account resources endpoint.
modules/express/src/typedRoutes/api/index.ts Registers the new typed routes in the Express API spec/types.
modules/express/src/clientRoutes.ts Adds handlers and route wiring for the new typed endpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add dedicated Express routes for accountresources and
activedelegations endpoints with io-ts validation.

TICKET: CHALO-346
@bhavidhingra bhavidhingra force-pushed the CHALO-346.trx-express-delegation-routes branch from 32d3271 to ebfd681 Compare April 7, 2026 06:15
@bhavidhingra bhavidhingra force-pushed the CHALO-346.trx-express-delegation-routes branch from 02edda9 to fd11a9b Compare April 7, 2026 06:41
@bhavidhingra bhavidhingra requested a review from Copilot April 7, 2026 06:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…resource delegations handler

Agent-Logs-Url: https://github.com/BitGo/BitGoJS/sessions/c1f514f3-1017-413f-90a9-4de5a30f1f0e

Co-authored-by: bhavidhingra <17147510+bhavidhingra@users.noreply.github.com>

TICKET: CHALO-346
@bhavidhingra bhavidhingra force-pushed the CHALO-346.trx-express-delegation-routes branch from fd11a9b to 784adf4 Compare April 7, 2026 07:14
@sachushaji
Copy link
Copy Markdown
Contributor

@claude

@bhavidhingra bhavidhingra merged commit 25f26da into master Apr 7, 2026
25 checks passed
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.

7 participants