Skip to content

add aave and tokenAllowance passthroughs#4130

Open
tmcollins4 wants to merge 3 commits intobitpay:masterfrom
tmcollins4:addBwsAaveRoutes
Open

add aave and tokenAllowance passthroughs#4130
tmcollins4 wants to merge 3 commits intobitpay:masterfrom
tmcollins4:addBwsAaveRoutes

Conversation

@tmcollins4
Copy link
Contributor

Description

Added BWS passthrough routes for Aave endpoints and token allowance, following the existing BWS → V8 → BCN pattern. These allow the app/client to access Aave data and token allowance checks through BWS (via BWC).

Changelog

  • Added AaveRouter in packages/bitcore-wallet-service/src/lib/routes/aave.ts following the TssRouter pattern for route organization.
  • Added POST /bws/api/v1/service/aave/userAccountData — returns Aave user health factor, collateral, debt data, etc.
  • Added POST /bws/api/v1/service/aave/reserveData — returns Aave reserve data (variable borrow rate, etc.).
  • Added POST /bws/api/v1/service/aave/reserveTokensAddresses — returns Aave reserve token addresses (aToken, variableDebtToken, etc.).
  • Added POST /bws/api/v1/token/allowance — returns ERC20 token allowance for a given owner/spender pair.
  • Added V8 methods getAaveUserAccountData, getAaveReserveData, getAaveReserveTokensAddresses in v8.ts.
  • Added WalletService methods getAaveUserAccountData, getAaveReserveData, getAaveReserveTokensAddresses, getTokenAllowance in server.ts.
  • All routes use getServerWithAuth consistent with existing passthrough endpoints like /v1/token/info.
  • Added 4 unit tests in v8.test.ts covering all new V8 methods.
  • Added 4 unit tests in expressapp.test.ts covering all new routes.

Testing Notes


Checklist

  • I have read CONTRIBUTING.md and verified that this PR follows the guidelines and requirements outlined in it.

@kajoseph kajoseph requested a review from Copilot March 23, 2026 13:20
@kajoseph kajoseph added the BWS This pull request modifies the bitcore-wallet-service package label Mar 23, 2026
Copy link

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

Adds new Bitcore Wallet Service (BWS) passthrough endpoints to expose Aave data and ERC20 token allowance via the existing BWS → V8 pattern, along with corresponding WalletService/V8 plumbing and tests.

Changes:

  • Added AaveRouter and mounted new /v1/service/aave/* POST routes.
  • Added /v1/token/allowance POST route plus a WalletService.getTokenAllowance passthrough.
  • Added V8 explorer methods for Aave endpoints and unit tests for the new routes/methods.

Reviewed changes

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

Show a summary per file
File Description
packages/bitcore-wallet-service/src/lib/routes/aave.ts Introduces AaveRouter implementing the new Aave passthrough endpoints.
packages/bitcore-wallet-service/src/lib/expressapp.ts Wires up AaveRouter and adds the /v1/token/allowance route.
packages/bitcore-wallet-service/src/lib/server.ts Adds WalletService passthrough methods for Aave and token allowance.
packages/bitcore-wallet-service/src/lib/blockchainexplorers/v8.ts Adds V8 client methods to call V8 Aave endpoints.
packages/bitcore-wallet-service/test/v8.test.ts Adds unit tests for the new V8 methods (including token allowance).
packages/bitcore-wallet-service/test/expressapp.test.ts Adds route tests for Aave endpoints and /v1/token/allowance.

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

Copy link
Collaborator

@kajoseph kajoseph left a comment

Choose a reason for hiding this comment

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

We should

  • in server.ts, add some types and/or JSDocs as well as input validation
  • add methods to BWC to further improve ergonomics

}

getTokenAllowance(opts) {
const bc = this._getBlockchainExplorer(opts.chain || Defaults.EVM_CHAIN, opts.network);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should add some validation to opts, and maybe a param type or at least JSDoc to this fn as well. Something like

    if (!checkRequired(opts, ['chain', 'network', 'tokenAddress', 'ownerAddress', 'spenderAddress'])) {
      throw new Error('Missing required parameters');
    }

…ts, expressapp.ts, server.ts, v8.ts)

- Add BWC client methods for Aave and token allowance (api.ts)
- Add JSDoc and input validation (checkRequired in server.ts, $.checkArgument in api.ts)
- Use getServer instead of getServerWithAuth so invoice frontend can call endpoints directly
- Add unit tests (BWS: v8.test.ts, expressapp.test.ts) and integration tests (BWC: api.test.ts, helpers.ts)
- Fix error contract in expressapp tests: use ClientError instead of Error so tests correctly assert HTTP 400 (not 500) for missing arguments
- Add Aave version validation in server.ts: reject invalid version values (only v2 and v3 supported)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BWS This pull request modifies the bitcore-wallet-service package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants