Add Aave endpoint to get user account data#4107
Add Aave endpoint to get user account data#4107tmcollins4 wants to merge 5 commits intobitpay:masterfrom
Conversation
…d contract addresses for aave pools
packages/bitcore-node/src/providers/chain-state/evm/api/aave.ts
Outdated
Show resolved
Hide resolved
kajoseph
left a comment
There was a problem hiding this comment.
Because we're just passing through the Web3 response and there are other systems that depend on this response, let's add a test case for the CSP method to ensure it returns the fields we expect. That way we aren't waiting to see if something breaks if we upgrade web3 and the response changes or something.
packages/bitcore-node/src/providers/chain-state/evm/api/aave.ts
Outdated
Show resolved
Hide resolved
…addresses, Added jsdoc for contract address sourcing
| sandbox.restore(); | ||
| }); | ||
|
|
||
| it('should return expected fields for Aave v3 account data', async () => { |
There was a problem hiding this comment.
These unit tests are fine for testing that the code isn't just flat out broken, but I was hoping for an actual web3 call instead of a stub. Perhaps I should have specified we should add an integration test. I'm not sure if adding an ETH.sepolia config to the test config would break anything similar to how we have a BASE.sepolia test config pointed to a public RPC endpoint.
There was a problem hiding this comment.
Added integration tests for Aave v2 and v3 following the same pattern as evm.test.ts
| async getAaveUserAccountData(params: { network: string; address: string; version: 'v2' | 'v3' }): Promise<any> { | ||
| const { network, address, version } = params; | ||
| const poolAddress = getAavePoolAddress(this.chain, network, version); | ||
| if (!poolAddress) { |
There was a problem hiding this comment.
when true this check will throw a 500 in routes when it was actually a 400. either do this check in routes or properly catch this error in routes and send a 400 response
| res.status(400).send('Unsupported Aave version'); | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
would be nice to do some address validation here
e.g :
if (!Web3.utils.isAddress(address)) {
res.status(400).send('Invalid address');
return;
}
Description
Added an endpoint to get user account data from Aave.
Changelog
Testing Notes
I made a script to call the endpoint with a wallet address
Checklist
BWCif modifying the bitcore-wallet-client package,CLIif modifying the bitcore-cli package, etc.)